public void DispatchOrder(VendorBillingModel model)
        {
            VendorBillingMaster tb = new VendorBillingMaster();
            int OutletId           = getOutletId();

            if (model.ChequeDate != null)
            {
                tb.ChequeDate = Convert.ToDateTime(model.ChequeDate);
            }
            else
            {
                tb.ChequeDate = null;
            }
            tb.ChequeNo            = model.ChequeNo;
            tb.NetAmount           = model.NetAmount;
            tb.OutletId            = OutletId;
            tb.PaymentMethod       = model.PaymentMethod;
            tb.remainingAmount     = model.remainingAmount;
            tb.ServiceChargeAmount = model.ServiceChargeAmount;
            tb.ServicTaxAmount     = model.ServicTaxAmount;
            tb.TotalAmount         = model.Totalamount;
            tb.VatAmount           = model.VatAmount;
            tb.VendorId            = model.VendorId;
            if (model.PaymentMethod == "Cash" || model.PaymentMethod == "Card" || model.PaymentMethod == "Cash&Card")
            {
                tb.DepositAmount = model.NetAmount;
                UpdateMainBalance(OutletId, model.VendorId, model.NetAmount, model.NetAmount);
            }
            else
            {
                if (model.DepositAmount == 0)
                {
                    tb.DepositAmount = model.NetAmount;
                }
                else
                {
                    tb.DepositAmount = model.DepositAmount;
                }

                UpdateMainBalance(OutletId, model.VendorId, model.NetAmount, model.DepositAmount);
            }

            tb.BillDate = DateTime.Now;
            entities.VendorBillingMasters.Add(tb);
            entities.SaveChanges();
            saveBillingItem(model.VendorId, tb.OrderId);
            deletefromTemp(model.VendorId);
        }
        public VendorBillingModel getBill(int ItemId, int Qty, int VendorId)
        {
            UpdateBillingTable(ItemId, Qty, VendorId);
            VendorBillingModel model = new VendorBillingModel();

            model.getAllItems = getBillingModel(ItemId, Qty, VendorId);
            model.Totalamount = model.getAllItems.Sum(a => a.TotalPrice);
            var     tax        = entities.tbl_ServiceTax.FirstOrDefault();
            decimal ServiceTax = 0;

            if (tax != null)
            {
                ServiceTax = (tax.ServiceCharge / 100) * model.Totalamount;
            }
            model.ServicTaxAmount = ServiceTax;
            var     Charge        = entities.tblServiceCharges.FirstOrDefault();
            decimal ServiceCharge = 0;

            if (Charge != null)
            {
                ServiceCharge = (Charge.Charges / 100) * model.Totalamount;
            }

            model.ServiceChargeAmount = ServiceCharge;
            model.getPaymentMethd     = getPaymentMethod();
            decimal VatAmount = 0;

            foreach (var item in model.getAllItems)
            {
                decimal vat = (item.Vat / 100) * item.TotalPrice;
                VatAmount = VatAmount + vat;
            }
            model.VatAmount     = VatAmount;
            model.IsPrinted     = entities.Temp_VendorBilling.Where(a => a.VendorId == VendorId && a.IsPrinted == true).Any();
            model.NetAmount     = model.Totalamount + model.ServicTaxAmount + model.ServiceChargeAmount + model.VatAmount;
            model.DepositAmount = model.NetAmount;
            return(model);
        }
Beispiel #3
0
 public ActionResult DispatchOrder(VendorBillingModel model)
 {
     vendor.DispatchOrder(model);
     return(RedirectToAction("CreateBilling"));
 }