protected DocumentDetail(int detailNumber, OperationDetail detail, bool usePriceIn = true) { this.usePriceIn = usePriceIn; Number = Data.Number.ToEditString(detailNumber); Item item = Item.GetById(detail.ItemId); ItemCode = item.Code; ItemName = item.Name2; MUnit = detail.MUnitName; Quantity = Entities.Quantity.ToString(detail.Quantity); Discount = Percent.ToString(detail.Discount); DiscountValue = Entities.Currency.ToString(detail.DiscountValue); Price = Entities.Currency.ToString(usePriceIn ? detail.PriceIn : detail.PriceOut, usePriceIn ? PriceType.Purchase : PriceType.Sale); Total = Entities.Currency.ToString(detail.Total, usePriceIn ? PriceType.Purchase : PriceType.Sale); Lot = detail.Lot; SerialNumber = detail.SerialNumber; ExpirationDate = detail.ExpirationDate.HasValue ? BusinessDomain.GetFormattedDate(detail.ExpirationDate.Value) : String.Empty; ProductionDate = detail.ProductionDate.HasValue ? BusinessDomain.GetFormattedDate(detail.ProductionDate.Value) : String.Empty; LotLocation = detail.LotLocation; Note = detail.Note; }
public override string ToString() { string action = null; Item item; if (!error) { switch (Type) { case PriceRule.ActionType.Stop: case PriceRule.ActionType.Exit: case PriceRule.ActionType.Message: action = values.Length > 0 ? values [0].ToString() : null; break; case PriceRule.ActionType.Email: action = values.Length > 1 ? String.Format("{0}: {1}; {2}: {3}", Translator.GetString("Message"), values [0], Translator.GetString("Receiver"), values [1]) : null; break; case PriceRule.ActionType.AddGood: case PriceRule.ActionType.AddGlobalGood: List <string> ret = new List <string> (); if (values != null) { foreach (SaleDetail saleDetail in values.OfType <SaleDetail> ()) { item = Item.Cache.GetById(saleDetail.ItemId); if (item == null) { continue; } ret.Add(String.Format("{0}: {1}; {2}: {3}; {4}: {5}", Translator.GetString("Item"), item.Name, Translator.GetString("Quantity"), Quantity.ToString(saleDetail.Quantity), Translator.GetString("Price"), Currency.ToString(saleDetail.PriceOut))); } } action = ret.Count > 0 ? String.Join(Environment.NewLine, ret) : null; break; case PriceRule.ActionType.Price: if (values == null || values.Length == 0) { break; } if (values.Length == 1) { action = Currency.ToString((double)values [0]); break; } if (values.Length < 3) { break; } string priceGroupString = String.Empty; foreach (KeyValuePair <int, string> keyValuePair in Currency.GetAllPriceRulePriceGroups()) { if (keyValuePair.Key == (int)values [0]) { priceGroupString = keyValuePair.Value; break; } } string operatorString = String.Empty; switch ((OperatorType)values [1]) { case OperatorType.Plus: operatorString = "+"; break; case OperatorType.Minus: operatorString = "-"; break; case OperatorType.Multiply: operatorString = "*"; break; case OperatorType.Divide: operatorString = "/"; break; } return(String.Format("{0} {1} {2}", priceGroupString, operatorString, (double)values [2])); case PriceRule.ActionType.Discount: return(Percent.ToString((double)values [0])); case PriceRule.ActionType.ServiceCharge: item = (Item)values [0]; return(String.Format("{0}: {1}; {2}: {3}", Translator.GetString("Item"), item.Name, values [1] is double?Translator.GetString("Percent") : Translator.GetString("Value"), values [1] is double?Percent.ToString((double)values [1]) : values [1])); case PriceRule.ActionType.Payment: case PriceRule.ActionType.AskAdvancePayment: return(String.Format("{0} {1}", Percent.ToString((double)values [0]), Translator.GetString("of operation total"))); default: action = formula; break; } } return(action ?? Translator.GetString("Error!")); }