public static CheckTicket FromCheckXElement(XElement element, Guid customerId, Guid closeTicketCustomerId) { var checkTicket = new CheckTicket(FromXElement(element, customerId)) { BarCode = element.GetXAttributeValue("barcodeCheck"), Date = element.GetXAttributeValue("date").ToDateTime(), CloseTicketCustomerId = closeTicketCustomerId, TotalTtc = element.GetXAttributeValue("sum").ToDecimal(), Rendu = element.GetXAttributeValue("Rendu").ToDecimal() }; var returnBarCodeAttribute = element.GetXAttributeOrNull("returnBarcodeCheck"); if (returnBarCodeAttribute != null) { checkTicket.ReturnBarCode = returnBarCodeAttribute.Value; } if (element.Attribute("DCBC") != null) { checkTicket.CheckDiscount = CloseTicketCheckDiscount.FromXElement(element, Guid.NewGuid(), closeTicketCustomerId); } foreach (var el in element.Elements("product")) { checkTicket.PayProducts.Add(PayProduct.FromCheckXElement(el, Guid.NewGuid(), checkTicket.CustomerId, closeTicketCustomerId)); } return(checkTicket); }
public static XElement ToXElement(CheckTicket obj) { var element = ToXElementBase(obj); element.Add(new XElement("BarCode", obj.BarCode)); element.Add(new XElement("Date", obj.Date)); element.Add(new XElement("CloseTicketCustomerId", obj.CloseTicketCustomerId)); element.Add(new XElement("TotalTtc", obj.TotalTtc)); element.Add(new XElement("Rendu", obj.Rendu)); return(element); }
public static CheckTicket FromXElement(XContainer element) { var checkTicket = new CheckTicket(FromXElementBase(element)) { BarCode = element.GetXElementValue("BarCode"), Date = element.GetXElementValue("Date").ToDateTime(), CloseTicketCustomerId = element.GetXElementValue("CloseTicketCustomerId").ToGuid(), TotalTtc = element.GetXElementValue("TotalTtc").ToDecimal(), Rendu = element.GetXElementValue("Rendu").ToDecimal() }; return(checkTicket); }
public static XElement ToCheckXElement(CheckTicket obj) { var checkElement = new XElement("check"); SetPaysAttributes(checkElement, obj); if (!string.IsNullOrEmpty(obj.ReturnBarCode)) { checkElement.Add(new XAttribute("returnBarcodeCheck", obj.ReturnBarCode)); } checkElement.Add(new XAttribute("barcodeCheck", obj.BarCode)); checkElement.Add(new XAttribute("Rendu", obj.Rendu)); checkElement.Add(new XAttribute("sum", obj.TotalTtc)); checkElement.Add(new XAttribute("date", obj.Date)); if (obj.CheckDiscount != null) { checkElement.Add(new XAttribute("DCBC", obj.CheckDiscount.Dcbc ?? string.Empty)); checkElement.Add(new XAttribute("DCBC_BiloPoints", obj.CheckDiscount.DcbcBiloPoints ?? 0)); checkElement.Add(new XAttribute("DCBC_DobavilePoints", obj.CheckDiscount.DcbcDobavilePoints ?? 0)); checkElement.Add(new XAttribute("DCBC_OtnayliPoints", obj.CheckDiscount.DcbcOtnayliPoints ?? 0)); checkElement.Add(new XAttribute("DCBC_OstalosPoints", obj.CheckDiscount.DcbcOstalosPoints ?? 0)); checkElement.Add(new XAttribute("DCBC_name", obj.CheckDiscount.DcbcName ?? string.Empty)); } foreach (var p in obj.PayProducts) { var ptemp = RepositoryProduct.Products.Find(la => la.CustomerId == p.ProductId); var productElement = new XElement("product", new XElement("CustomerId", p.ProductId), new XElement("grp", RepositorySubGroupProduct.SubGroupProducts.First(sg => sg.Id == (ptemp == null ? 3 : ptemp.CusumerIdSubGroup)).GroupId), new XElement("qty", p.Qty), new XElement("Name", p.Name), new XElement("CodeBare", p.Barcode), new XElement("price", p.PriceHt), new XElement("tva", RepositoryTva.Tvases.Find(l => l.Value == p.Tva).Id), new XElement("total", p.Total), new XElement("Discount", p.Discount), new XElement("sumDiscount", p.SumDiscount)); checkElement.Add(productElement); } return(checkElement); }
public static XElement SetPaysAttributes(XElement checkElement, CheckTicket check) { return(SetPaysAttributesBase(checkElement, check)); }
public static CloseTicket FromCheckXElement(XElement element) { var customerId = GlobalVar.TicketWindow; var closeTicket = new CloseTicket(FromXElement(element.GetXElement("check"), customerId)) { NameTicket = element.GetXAttributeValue("ticket"), DateOpen = element.GetXAttributeValue("openDate").ToDateTime(), DateClose = !string.IsNullOrEmpty(element.GetXAttributeValue("closeDate")) ? element.GetXAttributeValue("closeDate").ToDateTime() : DateTime.Now, CloseTicketGCustomerId = GlobalVar.TicketWindowG }; closeTicket.PayCash = 0; closeTicket.PayResto = 0; closeTicket.PayBankCards = 0; closeTicket.PayBankChecks = 0; foreach (var checkTicket in element.GetXElements("check").Select(check => CheckTicket.FromCheckXElement(check, Guid.NewGuid(), closeTicket.CustomerId))) { closeTicket.PayCash += checkTicket.PayCash - checkTicket.Rendu; closeTicket.PayResto += checkTicket.PayResto; closeTicket.PayBankCards += checkTicket.PayBankCards; closeTicket.PayBankChecks += checkTicket.PayBankChecks; closeTicket.ChecksTicket.Add(checkTicket); } return(closeTicket); }