public GetBillingModel GetBillingItem(string Path, string KotPath) { GetBillingModel model = new GetBillingModel(); List <GetBillingItemModel> itemslst = new List <GetBillingItemModel>(); List <GetKotItemModel> kotList = new List <GetKotItemModel>(); XDocument xd = XDocument.Load(Path); int oulte = xml.getOutletId(); var result = (from item in xd.Descendants("Items") where item.Element("UserId").Value == oulte.ToString() select item).ToList(); foreach (var item in result) { GetBillingItemModel m = new GetBillingItemModel(); m.ItemName = item.Element("ItemName").Value; m.FullQty = Convert.ToInt32(item.Element("FullQty").Value); m.FullPrice = Math.Round(Convert.ToDecimal(item.Element("FullPrice").Value), 2); m.Amount = Math.Round(Convert.ToDecimal(item.Element("TotalAmount").Value), 2); m.Vat = Convert.ToDecimal(item.Element("Vat").Value); m.OfferQty = Convert.ToInt32(item.Element("OfferQty").Value); m.ItemId = Convert.ToInt32(item.Element("ItemId").Value); itemslst.Add(m); } model._getbillingItems = itemslst; XDocument xdKot = XDocument.Load(KotPath); var kotresult = (from k in xdKot.Descendants("Items") where k.Element("UserId").Value == oulte.ToString() select k).ToList(); foreach (var item in kotresult) { GetKotItemModel m = new GetKotItemModel(); m.TNo = Convert.ToInt32(item.Element("TokenNo").Value); m.ItemName = item.Element("ItemName").Value; m.FullQty = Convert.ToInt32(item.Element("FullQty").Value); m.HalfQty = Convert.ToInt32(item.Element("HalfQty").Value); kotList.Add(m); } var serviccharg = (from p in _entities.tbl_ServiceTax select p.ServiceCharge).FirstOrDefault(); if (serviccharg == 0) { //serviccharg = Convert.ToDecimal(4.940); serviccharg = Convert.ToDecimal(5.6); } model._getKotitems = kotList; model.getPaymentType = getPaymentMode(); //model.TableNo = ItemId; model.VatAmount = Math.Round(result.Sum(a => Convert.ToDecimal(a.Element("VatAmt").Value)), 2); model.TotalAmount = Math.Round(result.Sum(a => Convert.ToDecimal(a.Element("TotalAmount").Value)), 2); decimal ServiceChargeAmount = (model.TotalAmount * serviccharg) / 100; model.ServiceTax = Math.Round(ServiceChargeAmount, 2); model.NetAmount = Math.Round(model.TotalAmount + model.VatAmount + model.ServiceTax, 2); model.TableNo = GetTokenNo().ToString(); return(model); }
public GetBillingModel GetBillingItem(string TableNo, string Path, string KotPath) { GetBillingModel model = new GetBillingModel(); List <GetBillingItemModel> itemslst = new List <GetBillingItemModel>(); List <GetKotItemModel> kotList = new List <GetKotItemModel>(); XDocument xd = XDocument.Load(Path); int oulte = getOutletId(); var result = (from item in xd.Descendants("Items") where item.Element("UserId").Value == oulte.ToString() && item.Element("TableNo").Value == TableNo && item.Element("ItemName").Value != string.Empty select item).ToList(); foreach (var item in result) { GetBillingItemModel m = new GetBillingItemModel(); m.ItemName = item.Element("ItemName").Value; m.FullQty = Convert.ToInt32(item.Element("FullQty").Value); m.FullPrice = Math.Round(Convert.ToDecimal(item.Element("Fullprice").Value), 2); m.Amount = Math.Round(Convert.ToDecimal(item.Element("Amount").Value), 2); m.Vat = Convert.ToDecimal(item.Element("VatAmt").Value); m.OfferQty = Convert.ToInt32(item.Element("OfferQty").Value); m.ItemId = Convert.ToInt32(item.Element("ItemId").Value); itemslst.Add(m); } model._getbillingItems = itemslst; XDocument xdKot = XDocument.Load(KotPath); var kotresult = (from k in xdKot.Descendants("Items") where k.Element("UserId").Value == oulte.ToString() select k).ToList(); foreach (var item in kotresult) { GetKotItemModel m = new GetKotItemModel(); m.TNo = Convert.ToInt32(item.Element("TableNo").Value); m.ItemName = item.Element("ItemName").Value; m.FullQty = Convert.ToInt32(item.Element("FullQty").Value); m.HalfQty = Convert.ToInt32(item.Element("HalfQty").Value); kotList.Add(m); } var ServiceTax = (from p in _entities.tbl_ServiceTax select p.ServiceCharge).FirstOrDefault(); if (ServiceTax == 0) { //serviccharg = Convert.ToDecimal(4.940); ServiceTax = Convert.ToDecimal(5.6); } model._getKotitems = kotList; model.getPaymentType = getPaymentMode(); model.TableNo = TableNo; int tableno = Convert.ToInt32(model.TableNo); var billId = _entities.tblBillMasters.Where(a => a.TableNo == model.TableNo && a.OutletId == oulte && a.Isprinted == true).FirstOrDefault(); if (billId != null) { model.BillId = billId.BillId; model.IsPrinted = billId.Isprinted.Value; model.Discount = Math.Truncate(billId.Discount.Value * 100) / 100; model.DiscountAmount = Math.Truncate(billId.DiscountAmount * 100) / 100; model.VatAmount = Math.Truncate(billId.VatAmount * 100) / 100; model.TotalAmount = Math.Truncate(billId.TotalAmount * 100) / 100; model.ServicesCharge = Math.Truncate(billId.ServicChargesAmount * 100) / 100; model.ServiceTax = Math.Truncate(billId.ServiceTax.Value * 100) / 100; model.NetAmount = Math.Truncate(billId.NetAmount * 100) / 100; model.NetAmountWithoutDiscount = Math.Truncate(billId.NetAmountWithoutDiscount.Value * 100) / 100; model.OrderType = billId.BillingType; model.CustomerAddress = billId.Address; model.PackingCharges = Convert.ToInt32(billId.PackingCharges.Value); model.CustomerName = billId.CustomerName; model.ContactNo = billId.ContactNo; } else { model.VatAmount = Math.Truncate(result.Sum(a => Convert.ToDecimal(a.Element("VatAmountCharges").Value)) * 100) / 100; model.TotalAmount = Math.Truncate(result.Sum(a => Convert.ToDecimal(a.Element("Amount").Value)) * 100) / 100; var ServicesCharge = _entities.tblServiceCharges.FirstOrDefault(); decimal serviceChargeAmount = 0; if (ServicesCharge != null) { serviceChargeAmount = (model.TotalAmount * ServicesCharge.Charges) / 100; } decimal ServiceTaxAmount = (model.TotalAmount * ServiceTax) / 100; model.ServiceTax = Math.Truncate(ServiceTaxAmount * 100) / 100; model.ServicesCharge = Math.Truncate(serviceChargeAmount * 100) / 100; model.NetAmount = Math.Round(model.TotalAmount + model.VatAmount + model.ServiceTax + serviceChargeAmount, 2); model.NetAmountWithoutDiscount = Math.Round(model.TotalAmount + model.VatAmount + model.ServiceTax + serviceChargeAmount, 2); } // model.getAllAutoCompleteItem = getAllAutocompleteItems(oulte); return(model); }