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));
        }
Exemple #2
0
        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 ActionResult PrintAgainBill(int BillId = 0)
        {
            var            data  = db.tblBillMasters.Find(BillId);
            PrintBillModel model = new PrintBillModel();

            model.CustomerAddress        = data.Address;
            model.BillId                 = data.BillId;
            model.CustomerName           = data.CustomerName;
            model.Address                = data.tblOutlet.Address;
            model.ContactA               = data.tblOutlet.ContactA;
            model.CustomerContactNo      = data.ContactNo;
            model.discount               = data.Discount.Value;
            model.DiscountAmount         = data.DiscountAmount;
            model.NetAmount              = data.NetAmountWithoutDiscount.Value;
            model.NetAmountAfterDiscount = data.NetAmount;
            model.PackingCharge          = data.PackingCharges.Value;
            model.ServicesCharge         = data.ServicChargesAmount;
            model.ServiceTax             = data.ServiceTax.Value;
            model.ServiceTaxNo           = data.tblOutlet.ServiceTaxNo;
            model.TableNo                = data.TableNo.ToString();
            model.TinNo       = data.tblOutlet.TinNo;
            model.TotalAmount = data.TotalAmount;
            model.BillDate    = data.BillDate;
            List <PrintItemModel> lst     = new List <PrintItemModel>();
            List <PrintVatModel>  VatList = new List <PrintVatModel>();

            foreach (var item in data.tblBillDetails)
            {
                PrintItemModel pm = new PrintItemModel();
                pm.ItemName   = item.tblItem.Name;
                pm.Amount     = item.Amount;
                pm.FullQty    = item.FullQty.ToString();
                pm.BasicPrice = item.tblItem.tblBasePriceItems.Where(a => a.ItemId == item.ItemId).Select(a => a.FullPrice).FirstOrDefault();
                lst.Add(pm);
            }
            model.getAllItem = lst;
            foreach (var item in data.tblBillDetails.GroupBy(a => a.Vat))
            {
                PrintVatModel pm = new PrintVatModel();
                pm.Vat        = Convert.ToDecimal(item.Key);
                pm.amtCharges = item.Sum(a => a.VatAmount.Value);
                VatList.Add(pm);
            }
            model.getAllVat = VatList;
            return(PartialView(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 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 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);
        }