public PartialViewResult _CreatePartial(int Id) { Session["RunningTable"] = Id; GetBillingModel model = new GetBillingModel(); var Path = Server.MapPath("/xmltables/table" + Id + ".xml"); var KotFilePath = Server.MapPath("/xmlkot/Kot.xml"); if (System.IO.File.Exists(Path)) { model = xml.GetBillingItem(Id.ToString(), Path, KotFilePath); } else { int oulte = nibsrepo.getOutletId(); XmlTextWriter writer = new XmlTextWriter(Server.MapPath("/xmltables/table" + Id + ".xml"), System.Text.Encoding.UTF8); writer.WriteStartDocument(true); writer.Formatting = Formatting.Indented; writer.Indentation = 2; writer.WriteStartElement("Item"); xml.createNode(oulte.ToString(), Id.ToString(), "0", " ", "0", "0", "0", "0", "0", "0", "0", "0", writer); writer.WriteEndElement(); writer.WriteEndDocument(); writer.Close(); // MessageBox.Show("XML File created ! "); model = xml.GetBillingItem(Id.ToString(), Path, KotFilePath); } return(PartialView("_CreatePartial", model)); }
public void updateBillOnDispatch(GetBillingModel model, string path) { XDocument xd = XDocument.Load(path); tblBillMaster tb = new tblBillMaster(); if (model.BillId > 0) { tb = _entities.tblBillMasters.Find(model.BillId); if (tb != null) { tb.Address = model.CustomerAddress; tb.ChequeDate = model.CheckDate; tb.ChequeNo = model.ChequeNo; tb.ContactNo = model.ContactNo; tb.CustomerName = model.CustomerName; tb.Isprinted = false; tb.PaymentType = model.PaymentType; _entities.SaveChanges(); } } int oulte = getOutletId(); var items = (from item in xd.Descendants("Items") where item.Element("UserId").Value == oulte.ToString() select item); items.Remove(); xd.Save(path); }
public PartialViewResult _printData(GetBillingModel model) { var Path = Server.MapPath("/HomeDeliveryXml/HomeDelivery.xml"); PrintBillModel m = new PrintBillModel(); m = take.GetBill(Path, model); return(PartialView("_printData", m)); }
public PartialViewResult _printData(GetBillingModel model) { var Path = Server.MapPath("/TakeAwayXML/Takeaway.xml"); PrintBillModel m = new PrintBillModel(); m = take.GetBill(Path, model); return(PartialView("_printData", m)); }
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 PartialViewResult _getTakeAwayBillingItemOnPageLoad(int TokenNo = 0) { var TakePath = Server.MapPath("/HomeDeliveryXml/HomeDelivery.xml"); var KotFilePath = Server.MapPath("/HomeDeliveryXml/Kot.xml"); GetBillingModel model = new GetBillingModel(); model = take.GetBillingItem(TakePath, KotFilePath); model.TableNo = TokenNo.ToString(); return(PartialView("_GetTakeAwayBillingItems", model)); }
public PartialViewResult _DeleteItem(int Id = 0) { var TakePath = Server.MapPath("/TakeAwayXML/Takeaway.xml"); var KotFilePath = Server.MapPath("/TakeAwayXML/Kot.xml"); GetBillingModel model = new GetBillingModel(); bool status = take.DeleteNode(Id.ToString(), TakePath, KotFilePath); if (status) { model = take.GetBillingItem(TakePath, KotFilePath); model.TableNo = take.GetTokenNo().ToString(); } return(PartialView("_GetTakeAwayBillingItems", model)); }
public PartialViewResult _Return(int TableNo = 0, int ItemId = 0) { var Path = Server.MapPath("~/xmltables/table" + TableNo + ".xml"); var ReturnXml = Server.MapPath("~/xmlkot/ReturnXML.xml"); var KotFilePath = Server.MapPath("~/xmlkot/Kot.xml"); GetBillingModel model = new GetBillingModel(); bool status = nibsrepo._TransferToReturnXML(Path, ReturnXml, TableNo, ItemId); if (status) { model = xml.GetBillingItem(TableNo.ToString(), Path, KotFilePath); } return(PartialView("_CreatePartial", model)); }
public ActionResult ClearKotItem(int Id = 0) { var KotFilePath = Server.MapPath("~/xmlkot/Kot.xml"); var Path = Server.MapPath("~/xmltables/table" + Id + ".xml"); GetBillingModel model = new GetBillingModel(); bool Update = xml.ClearKot(Path, KotFilePath, Id.ToString()); if (Update) { model = xml.GetBillingItem(Id.ToString(), Path, KotFilePath); } return(PartialView("_CreatePartial", model)); }
public PartialViewResult _GetTakeAwayBillingItems(string Type, int Id = 0, int Qty = 0, int TokenNo = 0) { var TakePath = Server.MapPath("/HomeDeliveryXml/HomeDelivery.xml"); var KotFilePath = Server.MapPath("/HomeDeliveryXml/Kot.xml"); GetBillingModel model = new GetBillingModel(); bool status = take.GetXmlData(Id.ToString(), TakePath, Qty.ToString(), Type, KotFilePath, TokenNo.ToString()); if (status) { model = take.GetBillingItem(TakePath, KotFilePath); //model.TableNo = TokenNo.ToString(); } return(PartialView("_GetTakeAwayBillingItems", model)); }
public PartialViewResult _clearKOT() { var TakePath = Server.MapPath("/HomeDeliveryXml/HomeDelivery.xml"); var KotFilePath = Server.MapPath("/HomeDeliveryXml/Kot.xml"); GetBillingModel model = new GetBillingModel(); bool status = take.ClearKot(KotFilePath); if (status) { model = take.GetBillingItem(TakePath, KotFilePath); model.TableNo = take.GetTokenNo().ToString(); } return(PartialView("_GetTakeAwayBillingItems", model)); }
public ActionResult DeleteItem(string ItemName, int Id = 0, int TableNo = 0) { var Path = Server.MapPath("~/xmltables/table" + TableNo + ".xml"); var KotFilePath = Server.MapPath("~/xmlkot/Kot.xml"); GetBillingModel model = new GetBillingModel(); bool Update = xml.DeleteNode(Id.ToString(), TableNo.ToString(), Path, KotFilePath, ItemName); if (Update) { model = xml.GetBillingItem(TableNo.ToString(), Path, KotFilePath); } return(PartialView("_CreatePartial", model)); }
public PartialViewResult _ReturnItem(int Id = 0) { var TakePath = Server.MapPath("/HomeDeliveryXml/HomeDelivery.xml"); var TakeReturn = Server.MapPath("/HomeDeliveryXml/HomeDeliveryReturn.xml"); var KotFilePath = Server.MapPath("/HomeDeliveryXml/Kot.xml"); GetBillingModel model = new GetBillingModel(); bool status = take._TransferToReturnXML(TakePath, TakeReturn, KotFilePath, Id); if (status) { model = take.GetBillingItem(TakePath, KotFilePath); model.TableNo = take.GetTokenNo().ToString(); } return(PartialView("_GetTakeAwayBillingItems", model)); }
public PartialViewResult DispatchOrder(GetBillingModel model) { var Path = Server.MapPath("/HomeDeliveryXml/HomeDelivery.xml"); var KotFilePath = Server.MapPath("/HomeDeliveryXml/Kot.xml"); var ReturnXml = Server.MapPath("/HomeDeliveryXml/HomeDeliveryReturn.xml"); take.SaveReturnItem(ReturnXml); bool status = take.DispatchOrder(model, Path); ModelState.Clear(); model = new GetBillingModel(); model.TableNo = take.GetTokenNo().ToString(); model.getPaymentType = take.getPaymentMode(); model = take.GetBillingItem(Path, KotFilePath); return(PartialView("_GetTakeAwayBillingItems", model)); }
public ActionResult DispatchOrder(GetBillingModel model) { var Path = Server.MapPath("~/xmltables/table" + model.TableNo + ".xml"); var ReturnXml = Server.MapPath("~/xmlkot/ReturnXML.xml"); var KotFilePath = Server.MapPath("~/xmlkot/Kot.xml"); nibsrepo.SaveReturnItem(ReturnXml); xml.updateBillOnDispatch(model, Path); //bool status = xml.DispatchOrder(model, Path); var tableNo = model.TableNo; ModelState.Clear(); model = new GetBillingModel(); model = xml.GetBillingItem(tableNo.ToString(), Path, KotFilePath); return(PartialView("_CreatePartial", model)); }
public ActionResult PrintOrder(GetBillingModel model) { var Path = Server.MapPath("~/xmltables/table" + model.TableNo + ".xml"); PrintBillModel m = new PrintBillModel(); if (model.BillId == 0) { var ReturnXml = Server.MapPath("~/xmlkot/ReturnXML.xml"); var KotFilePath = Server.MapPath("~/xmlkot/Kot.xml"); nibsrepo.SaveReturnItem(ReturnXml); int BillId = xml.DispatchOrder(model, Path); model.BillId = BillId; } m = nibsrepo.GetBill(Path, model); m.BillType = model.OrderType; return(PartialView("PrintOrder", m)); }
public ActionResult UpdateBillingXml(GetBillItemModel m) { //GetBillItemModel m = new GetBillItemModel(); //var data = Id.Split('^'); //m.ItemId = Convert.ToInt32(data[0]); //m.Qty = Convert.ToInt32(data[2]); //m.RunningTable = Convert.ToInt32(data[1]); //m.Type = data[3]; var filepath = Server.MapPath("~/xmltables/table" + m.RunningTable + ".xml"); var KotFilePath = Server.MapPath("~/xmlkot/Kot.xml"); GetBillingModel model = new GetBillingModel(); bool update = nibsrepo.CheckBillItem(m, filepath, KotFilePath); if (update) { model = xml.GetBillingItem(m.RunningTable.ToString(), filepath, KotFilePath); } return(PartialView("_CreatePartial", model)); }
public ActionResult CancelOrder() { int oulte = xml.getOutletId(); GetBillingModel model = new GetBillingModel(); var KotFilePath = Server.MapPath("/HomeDeliveryXml/Kot.xml"); var Path = Server.MapPath("/HomeDeliveryXml/HomeDelivery.xml"); XDocument xd = XDocument.Load(Path); var items = (from item in xd.Descendants("Items") where item.Element("UserId").Value == oulte.ToString() select item); items.Remove(); xd.Save(Path); bool Update = take.ClearKot(KotFilePath); if (Update) { model = take.GetBillingItem(Path, KotFilePath); } return(PartialView("_GetTakeAwayBillingItems", model)); }
public PartialViewResult DispatchOpenFood(BillOpenFoodModel model) { int oulte = xml.getOutletId(); OpenFood food = new OpenFood(); food.Date = DateTime.Now.Date; food.ItemName = model.OpenFoodName; food.OutletId = oulte; food.Price = model.OpenFoodPrice; food.Quantity = model.OpenFoodQuantity; food.Amount = model.OpenFoodPrice * model.OpenFoodQuantity; food.Vat = model.OpenFoodVat; db.OpenFoods.Add(food); db.SaveChanges(); var Path = Server.MapPath("/xmltables/table" + model.TableNo + ".xml"); var KotFilePath = Server.MapPath("~/xmlkot/Kot.xml"); GetBillingModel m = new GetBillingModel(); nibsrepo.SaveXmlOpenFood(model, Path, KotFilePath); m = xml.GetBillingItem(model.TableNo.ToString(), Path, KotFilePath); return(PartialView("_CreatePartial", m)); }
public ActionResult CancelOrder(int TableNo = 0) { int oulte = xml.getOutletId(); GetBillingModel model = new GetBillingModel(); var KotFilePath = Server.MapPath("~/xmlkot/Kot.xml"); var Path = Server.MapPath("~/xmltables/table" + TableNo + ".xml"); XDocument xd = XDocument.Load(Path); var items = (from item in xd.Descendants("Items") where item.Element("UserId").Value == oulte.ToString() select item); items.Remove(); xd.Save(Path); bool Update = xml.ClearKot(Path, KotFilePath, TableNo.ToString()); if (Update) { model = xml.GetBillingItem(TableNo.ToString(), Path, KotFilePath); } return(PartialView("_CreatePartial", model)); }
public bool DispatchOrder(GetBillingModel model, string Path) { try { int oulte = xml.getOutletId(); XDocument xd = XDocument.Load(Path); var result = (from item in xd.Descendants("Items") where item.Element("UserId").Value == oulte.ToString() select item).ToList(); tblBillMaster tb = new tblBillMaster(); tb.BillDate = DateTime.Now.Date; tb.BillingType = "T"; tb.CustomerName = model.CustomerName; tb.DiscountAmount = model.DiscountAmount; tb.NetAmount = Math.Round(model.NetAmount, 2); tb.ServicChargesAmount = Math.Round(model.ServicesCharge, 2); tb.TotalAmount = Math.Round(model.TotalAmount, 2); tb.VatAmount = Math.Round(model.VatAmount, 2); tb.TokenNo = Convert.ToInt32(model.TableNo); tb.PaymentType = model.PaymentType; tb.ChequeNo = model.ChequeNo; tb.ChequeDate = model.CheckDate; tb.OutletId = oulte; tb.Discount = model.Discount; _entities.tblBillMasters.Add(tb); _entities.SaveChanges(); //var Id = _entities.tblBillMasters.Where(o => o.OutletId == oulte && o.BillingType == "R").Select(x => x.BillId).Max(); foreach (var item in result) { tblBillDetail bill = new tblBillDetail(); bill.Amount = Convert.ToDecimal(item.Element("TotalAmount").Value); bill.FullQty = Convert.ToInt32(item.Element("FullQty").Value); bill.HalfQty = Convert.ToInt32(item.Element("HalfQty").Value); bill.ItemId = Convert.ToInt32(item.Element("ItemId").Value); bill.Vat = Convert.ToDecimal(item.Element("Vat").Value); decimal VatAmt = 0; if (model.Discount > 0) { decimal dis = Convert.ToDecimal(item.Element("VatAmt").Value); decimal vat = (model.Discount * dis) / 100; VatAmt = dis - vat; } else { VatAmt = Convert.ToDecimal(item.Element("VatAmt").Value); } bill.VatAmount = VatAmt * Convert.ToInt32(item.Element("FullQty").Value); bill.BillId = tb.BillId; _entities.tblBillDetails.Add(bill); _entities.SaveChanges(); // call auto inventory start.. AutoInventoryRepository auto = new AutoInventoryRepository(); auto.AutoInventory(Convert.ToInt32(item.Element("ItemId").Value), Convert.ToInt32(item.Element("FullQty").Value), Convert.ToInt32(item.Element("HalfQty").Value), oulte); } var items = (from item in xd.Descendants("Items") where item.Element("UserId").Value == oulte.ToString() select item); items.Remove(); xd.Save(Path); CheckStockItemRepository check = new CheckStockItemRepository(); string chk = check.OutStockItems(tb.BillId); return(true); } catch { return(false); } }
public PrintBillModel GetBill(string Path, GetBillingModel m) { PrintBillModel model = new PrintBillModel(); List <PrintItemModel> lst = new List <PrintItemModel>(); List <PrintVatModel> VatList = new List <PrintVatModel>(); int oulte = xml.getOutletId(); var outletData = (from p in _entities.tblOutlets where p.OutletId == oulte select p).SingleOrDefault(); XDocument xd = XDocument.Load(Path); var result = from item in xd.Descendants("Items") where item.Element("UserId").Value == oulte.ToString() select item; var VatDetail = (from p in xd.Descendants("Items") where p.Element("UserId").Value == oulte.ToString() group p by p.Element("Vat").Value into g select new { Vat = g.Key, amtCharges = g.Sum(a => Convert.ToDecimal(a.Element("VatAmt").Value)) // xd.Descendants("Items").Sum(a => Convert.ToDecimal(a.Element("VatAmountCharges").Value)) }).ToList(); model.TinNo = outletData.TinNo; model.ServiceTaxNo = outletData.ServiceTaxNo; model.Address = outletData.Address; model.ContactA = outletData.ContactA; model.CustomerName = string.Empty; model.TableNo = m.TableNo.ToString(); model.DiscountAmount = m.DiscountAmount; model.TotalAmount = m.TotalAmount; model.ServicesCharge = m.ServicesCharge; model.NetAmount = m.NetAmount; model.CustomerName = m.CustomerName; foreach (var item in result) { PrintItemModel pm = new PrintItemModel(); int Itemid = Convert.ToInt32(item.Element("ItemId").Value); if (Itemid == 0) { pm.ItemName = item.Element("ItemName").Value; } else { var Name = _entities.tblItems.Where(o => o.ItemId == Itemid).Select(x => x.Name).SingleOrDefault(); pm.ItemName = Name; } var amount = item.Element("TotalAmount").Value; decimal amt = Convert.ToDecimal(amount); pm.Amount = amt; pm.FullQty = item.Element("FullQty").Value; pm.HalfQty = item.Element("HalfQty").Value; lst.Add(pm); } model.getAllItem = lst; foreach (var item in VatDetail) { PrintVatModel pm = new PrintVatModel(); pm.amtCharges = item.amtCharges; pm.Vat = Convert.ToDecimal(item.Vat); VatList.Add(pm); } model.getAllVat = VatList; return(model); }
public int DispatchOrder(GetBillingModel model, string Path) { try { int oulte = getOutletId(); XDocument xd = XDocument.Load(Path); var result = (from item in xd.Descendants("Items") where item.Element("UserId").Value == oulte.ToString() select item).ToList(); decimal totalVat = 0; foreach (var item in result) { decimal VatAmt = 0; if (model.Discount > 0) { decimal dis = Convert.ToDecimal(item.Element("VatAmountCharges").Value); decimal vat = (model.Discount * dis) / 100; VatAmt = dis - vat; } else { VatAmt = Convert.ToDecimal(item.Element("VatAmountCharges").Value); } totalVat = totalVat + VatAmt; } tblBillMaster tb = new tblBillMaster(); tb.BillDate = DateTime.Now; tb.BillingType = model.OrderType; tb.CustomerName = model.CustomerName; tb.Address = model.CustomerAddress; tb.PackingCharges = model.PackingCharges; tb.ContactNo = model.ContactNo; tb.DiscountAmount = model.DiscountAmount; tb.NetAmount = model.NetAmount; tb.ServicChargesAmount = model.ServicesCharge; tb.TotalAmount = model.TotalAmount; tb.Isprinted = true; //tb.VatAmount = model.VatAmount; tb.VatAmount = totalVat; tb.ServiceTax = model.ServiceTax; tb.TableNo = (model.TableNo); tb.PaymentType = model.PaymentType; tb.ChequeNo = model.ChequeNo; tb.ChequeDate = model.CheckDate; tb.OutletId = oulte; tb.Discount = model.Discount; tb.NetAmountWithoutDiscount = model.NetAmountWithoutDiscount; tb.ContactNo = model.ContactNo; _entities.tblBillMasters.Add(tb); _entities.SaveChanges(); foreach (var item in result) { int ItemId = Convert.ToInt32(item.Element("ItemId").Value); if (ItemId == 0) { //OpenFood food = new OpenFood(); //food.Date = DateTime.Now.Date; //food.ItemName = item.Element("ItemName").Value; //food.OutletId = oulte; //food.Price = Convert.ToDecimal(item.Element("Fullprice").Value); //food.Quantity = Convert.ToInt32(item.Element("FullQty").Value); //food.Amount = Convert.ToDecimal(item.Element("Amount").Value); //food.Vat = Convert.ToInt32(item.Element("VatAmt").Value); //_entities.OpenFoods.Add(food); //_entities.SaveChanges(); } else { tblBillDetail bill = new tblBillDetail(); bill.Amount = Convert.ToDecimal(item.Element("Amount").Value); bill.FullQty = Convert.ToInt32(item.Element("FullQty").Value); bill.HalfQty = Convert.ToInt32(item.Element("HalfQty").Value); bill.ItemId = Convert.ToInt32(item.Element("ItemId").Value); bill.Vat = Convert.ToDecimal(item.Element("VatAmt").Value); decimal VatAmt = 0; if (model.Discount > 0) { decimal dis = Convert.ToDecimal(item.Element("VatAmountCharges").Value); decimal vat = (model.Discount * dis) / 100; VatAmt = dis - vat; } else { VatAmt = Convert.ToDecimal(item.Element("VatAmountCharges").Value); } bill.VatAmount = Math.Truncate(VatAmt * 100) / 100; bill.BillId = tb.BillId; _entities.tblBillDetails.Add(bill); _entities.SaveChanges(); // call auto inventory start.. AutoInventoryRepository auto = new AutoInventoryRepository(); auto.AutoInventory(Convert.ToInt32(item.Element("ItemId").Value), Convert.ToInt32(item.Element("FullQty").Value), Convert.ToInt32(item.Element("HalfQty").Value), oulte); } } //var items = (from item in xd.Descendants("Items") // where item.Element("UserId").Value == oulte.ToString() // select item); //items.Remove(); //xd.Save(Path); CheckStockItemRepository check = new CheckStockItemRepository(); // string chk = check.OutStockItems(Id); return(tb.BillId); } catch (Exception ex) { //Error error = new Error(); //error.ErrorMessage = ex.Message; //_entities.Errors.Add(error); //_entities.SaveChanges(); return(0); } }
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); }
public PrintBillModel GetBill(string Path, GetBillingModel m) { PrintBillModel model = new PrintBillModel(); List <PrintItemModel> lst = new List <PrintItemModel>(); List <PrintVatModel> VatList = new List <PrintVatModel>(); int oulte = getOutletId(); var outletData = (from p in entities.tblOutlets where p.OutletId == oulte select p).SingleOrDefault(); XDocument xd = XDocument.Load(Path); var result = from item in xd.Descendants("Items") where item.Element("UserId").Value == oulte.ToString() && item.Element("TableNo").Value == m.TableNo.ToString() select item; var VatDetail = (from p in xd.Descendants("Items") where p.Element("UserId").Value == oulte.ToString() && p.Element("TableNo").Value == m.TableNo.ToString() group p by p.Element("VatAmt").Value into g select new { Vat = g.Key, amtCharges = g.Sum(a => Convert.ToDecimal(a.Element("VatAmountCharges").Value)) // xd.Descendants("Items").Sum(a => Convert.ToDecimal(a.Element("VatAmountCharges").Value)) }).ToList(); model.BillId = m.BillId; model.TinNo = outletData.TinNo; model.ServiceTaxNo = outletData.ServiceTaxNo; model.Address = outletData.Address; model.ContactA = outletData.ContactA; model.CustomerAddress = m.CustomerAddress; model.TableNo = m.TableNo.ToString(); model.DiscountAmount = Math.Truncate(m.DiscountAmount * 100) / 100; model.TotalAmount = Math.Truncate(m.TotalAmount * 100) / 100;; model.ServicesCharge = Math.Truncate(m.ServicesCharge * 100) / 100;; model.ServiceTax = Math.Truncate(m.ServiceTax * 100) / 100;; model.NetAmount = Math.Truncate(m.NetAmountWithoutDiscount * 100) / 100;; model.CustomerName = m.CustomerName; model.PackingCharge = m.PackingCharges; model.NetAmountAfterDiscount = Math.Truncate(m.NetAmount * 100) / 100; model.CustomerContactNo = m.ContactNo; // model.BillType= foreach (var item in result) { PrintItemModel pm = new PrintItemModel(); int Itemid = Convert.ToInt32(item.Element("ItemId").Value); if (Itemid == 0) { pm.ItemName = item.Element("ItemName").Value; } else { var Name = entities.tblItems.Where(o => o.ItemId == Itemid).Select(x => x.Name).SingleOrDefault(); pm.ItemName = Name; } var amount = item.Element("Amount").Value; decimal amt = Convert.ToDecimal(amount); pm.Amount = Math.Round(amt, 2); pm.FullQty = item.Element("FullQty").Value; pm.HalfQty = item.Element("HalfQty").Value; pm.BasicPrice = Math.Round(Convert.ToDecimal(item.Element("Fullprice").Value), 2); lst.Add(pm); } model.getAllItem = lst; foreach (var item in VatDetail) { PrintVatModel pm = new PrintVatModel(); decimal discountvat = 0; if (m.Discount > 0) { decimal discount = (m.Discount / 100) * item.amtCharges; discountvat = item.amtCharges - discount; } else { discountvat = item.amtCharges; } pm.amtCharges = discountvat; pm.Vat = Convert.ToDecimal(item.Vat); VatList.Add(pm); } model.getAllVat = VatList; return(model); }