コード例 #1
0
        public ActionResult PurchaseReturn(MainApplication model, FormCollection frmcol)
        {
            string shopcode = Session["LOGINSHOPGODOWNCODE"].ToString();
            string shopname = Session["SHOPGODOWNNAME"].ToString();

            string year = FinancialYear;

            string[] yr    = year.Split(' ', '-');
            string   FinYr = "/" + yr[2].Substring(2) + "-" + yr[6].Substring(2);
            var      LastPurchaseReturn   = _PurchaseReturnService.GetLastPurchaseByFinYr(FinYr, shopcode);
            string   PurchaseReturnCode   = string.Empty;
            int      PurchaseReturnLength = 0;
            int      PurchaseReturnNo     = 0;

            if (LastPurchaseReturn == null)
            {
                PurchaseReturnLength = 1;
                PurchaseReturnNo     = 1;
            }
            else
            {
                int PurchaseReturnIndex = LastPurchaseReturn.PurchaseReturnNo.LastIndexOf('P');
                PurchaseReturnCode   = LastPurchaseReturn.PurchaseReturnNo.Substring(PurchaseReturnIndex + 2, 6);
                PurchaseReturnLength = (Convert.ToInt32(PurchaseReturnCode) + 1).ToString().Length;
                PurchaseReturnNo     = Convert.ToInt32(PurchaseReturnCode) + 1;
            }

            string ShortCode = string.Empty;

            if (shopcode.Contains("SH"))
            {
                var detail = _ShopService.GetShopDetailsByName(shopname);
                ShortCode = detail.ShortCode;
            }
            else
            {
                var detail = _GodownService.GetGodownDetailsByName(shopname);
                ShortCode = detail.ShortCode;
            }
            PurchaseReturnCode = _UtilityService.getName(ShortCode + "/PR", PurchaseReturnLength, PurchaseReturnNo);
            PurchaseReturnCode = PurchaseReturnCode + FinYr;
            string DebitNoteNo = _UtilityService.getName(ShortCode + "/DBN", PurchaseReturnLength, PurchaseReturnNo);

            DebitNoteNo = DebitNoteNo + FinYr;
            model.PurchaseReturnDetails.Code               = Session["LOGINSHOPGODOWNCODE"].ToString();
            model.PurchaseReturnDetails.PurchaseReturnNo   = PurchaseReturnCode;
            model.PurchaseReturnDetails.PurchaseReturnDate = DateTime.Now;
            model.PurchaseReturnDetails.DebitNoteNo        = DebitNoteNo;
            model.PurchaseReturnDetails.DebitNoteDate      = DateTime.Now;
            if (model.PurchaseReturnDetails.PackAndForwd == null)
            {
                model.PurchaseReturnDetails.PackAndForwd = 0;
            }
            model.PurchaseReturnDetails.DebitNoteAmount = Convert.ToDouble(frmcol["SupplierAmount"]);
            model.PurchaseReturnDetails.TotalAmount     = Convert.ToDouble(frmcol["TotalAmountValue"]);
            model.PurchaseReturnDetails.TotalTaxAmount  = Convert.ToDouble(frmcol["TotalTaxAmountValue"]);
            model.PurchaseReturnDetails.GrandTotal      = Convert.ToDouble(frmcol["GrandTotalValue"]);
            model.PurchaseReturnDetails.Status          = "Active";
            model.PurchaseReturnDetails.ModifiedOn      = DateTime.Now;
            _PurchaseReturnService.Create(model.PurchaseReturnDetails);

            DebitNote DebitNote = new DebitNote();

            DebitNote.DebitNoteNo      = DebitNoteNo;
            DebitNote.DebitNoteDate    = DateTime.Now;
            DebitNote.SupplierName     = model.PurchaseReturnDetails.SupplierName;
            DebitNote.BillNo           = model.PurchaseReturnDetails.SupplierBillNo;
            DebitNote.ChallanNo        = model.PurchaseReturnDetails.SupplierChallanNo;
            DebitNote.InwardNo         = model.PurchaseReturnDetails.InwardNo;
            DebitNote.PurchaseReturnNo = PurchaseReturnCode;
            DebitNote.Amount           = Convert.ToDouble(frmcol["SupplierAmount"]);
            DebitNote.Status           = "Active";
            DebitNote.ModifiedOn       = DateTime.Now;
            _DebitNoteService.Create(DebitNote);

            var Inwardreturnlist = TempData["InwardItemList"] as IEnumerable <InwardItemsFromSupplier>;
            int count            = 1;

            foreach (var item in Inwardreturnlist)
            {
                string checkbox = "CheckBox" + count;
                string quantity = "quantity" + count;
                string amount   = "amountvalue" + count;
                string prevqty  = "prevquantityvalue" + count;
                if (frmcol[checkbox] == "Yes")
                {
                    PurchaseReturnItem PurchaseReturnItem = new PurchaseReturnItem();
                    PurchaseReturnItem.PurchaseReturnNo = PurchaseReturnCode;
                    PurchaseReturnItem.Barcode          = item.Barcode;
                    PurchaseReturnItem.ItemCode         = item.itemCode;
                    PurchaseReturnItem.ItemName         = item.Item;
                    PurchaseReturnItem.ItemType         = item.ItemType;
                    PurchaseReturnItem.Description      = item.Description;
                    PurchaseReturnItem.DesignCode       = item.Design;
                    PurchaseReturnItem.DesignName       = item.DesignName;
                    PurchaseReturnItem.Color            = item.Color;
                    PurchaseReturnItem.Material         = item.Material;
                    PurchaseReturnItem.Brand            = item.Brand;
                    PurchaseReturnItem.Size             = item.Size;
                    PurchaseReturnItem.Unit             = item.Unit;
                    PurchaseReturnItem.NumberType       = item.NumberType;
                    PurchaseReturnItem.Quantity         = Convert.ToDouble(frmcol[quantity]);
                    PurchaseReturnItem.Balance          = Convert.ToDouble(frmcol[prevqty]) - Convert.ToDouble(frmcol[quantity]);
                    PurchaseReturnItem.CostPrice        = item.CostPrice;
                    PurchaseReturnItem.DisPer           = item.Discount.ToString();
                    PurchaseReturnItem.SellingPrice     = item.SellingPrice;
                    PurchaseReturnItem.MRP        = item.MRP;
                    PurchaseReturnItem.ItemTax    = item.ItemTax;
                    PurchaseReturnItem.Amount     = Convert.ToDouble(frmcol[amount]);
                    PurchaseReturnItem.Status     = "Active";
                    PurchaseReturnItem.ModifiedOn = DateTime.Now;
                    _PurchaseReturnItemService.Create(PurchaseReturnItem);

                    var inwarditem = _InwardItemFromSupplierService.GetItemByInwardNoAndItemCode(model.PurchaseReturnDetails.InwardNo, PurchaseReturnItem.ItemCode);
                    inwarditem.PurchaseReturn = "Yes";
                    _InwardItemFromSupplierService.Update(inwarditem);

                    DebitNoteItem DebitNoteItem = new DebitNoteItem();
                    DebitNoteItem.DebitNoteNo  = DebitNoteNo;
                    DebitNoteItem.ItemCode     = item.itemCode;
                    DebitNoteItem.ItemName     = item.Item;
                    DebitNoteItem.Description  = item.Description;
                    DebitNoteItem.ItemType     = item.ItemType;
                    DebitNoteItem.Color        = item.Color;
                    DebitNoteItem.Material     = item.Material;
                    DebitNoteItem.DesignName   = item.DesignName;
                    DebitNoteItem.Brand        = item.Brand;
                    DebitNoteItem.Size         = item.Size;
                    DebitNoteItem.Quantity     = Convert.ToDouble(frmcol[quantity]);
                    DebitNoteItem.Unit         = item.Unit;
                    DebitNoteItem.CostPrice    = item.CostPrice;
                    DebitNoteItem.NumberType   = item.NumberType;
                    DebitNoteItem.SellingPrice = item.SellingPrice;
                    DebitNoteItem.MRP          = item.MRP;
                    DebitNoteItem.ItemTax      = item.ItemTax;
                    DebitNoteItem.Amount       = Convert.ToDouble(frmcol[amount]);
                    DebitNoteItem.Status       = "Active";
                    DebitNoteItem.ModifiedOn   = DateTime.Now;
                    _DebitNoteItemService.Create(DebitNoteItem);

                    var iteminward = _InwardItemFromSupplierService.GetItemByInwardNoAndItemCode(model.PurchaseReturnDetails.InwardNo, item.itemCode);
                    iteminward.PurchaseReturn = "Yes";
                    _InwardItemFromSupplierService.Update(iteminward);

                    string code = Session["LOGINSHOPGODOWNCODE"].ToString();
                    if (item.ItemType == "Inventory")
                    {
                        if (code.Contains("SH"))
                        {
                            var shopdetails = _ShopStockService.GetDetailsByItemCodeAndShopCode(item.itemCode, code);
                            shopdetails.Quantity = shopdetails.Quantity - PurchaseReturnItem.Quantity;
                            _ShopStockService.Update(shopdetails);

                            var stockitemdetails = _StockItemDistributionService.GetDetailsByItemCodeAndShopCode(item.itemCode, code);
                            stockitemdetails.ItemQuantity = stockitemdetails.ItemQuantity - PurchaseReturnItem.Quantity;
                            _StockItemDistributionService.Update(stockitemdetails);
                        }
                        else
                        {
                            var godowndetails = _GodownStockService.GetDetailsByItemCodeAndGodownCode(item.itemCode, code);
                            godowndetails.Quantity = godowndetails.Quantity - PurchaseReturnItem.Quantity;
                            _GodownStockService.Update(godowndetails);

                            var stockitemdetails = _StockItemDistributionService.GetDetailsByItemCodeAndGodownCode(item.itemCode, code);
                            stockitemdetails.ItemQuantity = stockitemdetails.ItemQuantity - PurchaseReturnItem.Quantity;
                            _StockItemDistributionService.Update(stockitemdetails);
                        }

                        var entrystockitems = _EntryStockItemService.getDetailsByItemCode(item.itemCode);
                        if (entrystockitems != null)
                        {
                            entrystockitems.TotalQuantity = entrystockitems.TotalQuantity - PurchaseReturnItem.Quantity;
                            _EntryStockItemService.Update(entrystockitems);
                        }
                        else
                        {
                            var openingstockitems = _OpeningStockService.GetDetailsByItemCode(item.itemCode);
                            openingstockitems.TotalQuantity = openingstockitems.TotalQuantity - PurchaseReturnItem.Quantity;
                            _OpeningStockService.UpdateStock(openingstockitems);
                        }
                    }
                }
                count++;
            }
            count = Inwardreturnlist.Count() + 1;
            var purchasereturnlist = TempData["PurchaseReturnList"] as IEnumerable <PurchaseReturnItem>;

            foreach (var item in purchasereturnlist)
            {
                string checkbox = "CheckBox" + count;
                string quantity = "quantity" + count;
                string amount   = "amountvalue" + count;
                string prevqty  = "prevquantityvalue" + count;
                if (frmcol[checkbox] == "Yes")
                {
                    item.PurchaseReturnNo = PurchaseReturnCode;
                    item.Quantity         = Convert.ToDouble(frmcol[quantity]);
                    item.Balance          = Convert.ToDouble(frmcol[prevqty]) - Convert.ToDouble(frmcol[quantity]);
                    item.Amount           = Convert.ToDouble(frmcol[amount]);
                    item.Status           = "Active";
                    item.ModifiedOn       = DateTime.Now;
                    _PurchaseReturnItemService.Create(item);

                    DebitNoteItem DebitNoteItem = new DebitNoteItem();
                    DebitNoteItem.DebitNoteNo  = DebitNoteNo;
                    DebitNoteItem.ItemCode     = item.ItemCode;
                    DebitNoteItem.ItemName     = item.ItemName;
                    DebitNoteItem.Description  = item.Description;
                    DebitNoteItem.ItemType     = item.ItemType;
                    DebitNoteItem.Color        = item.Color;
                    DebitNoteItem.Material     = item.Material;
                    DebitNoteItem.DesignName   = item.DesignName;
                    DebitNoteItem.Brand        = item.Brand;
                    DebitNoteItem.Size         = item.Size;
                    DebitNoteItem.Quantity     = Convert.ToDouble(frmcol[quantity]);
                    DebitNoteItem.Unit         = item.Unit;
                    DebitNoteItem.NumberType   = item.NumberType;
                    DebitNoteItem.CostPrice    = item.CostPrice;
                    DebitNoteItem.SellingPrice = item.SellingPrice;
                    DebitNoteItem.MRP          = item.MRP;
                    DebitNoteItem.ItemTax      = item.ItemTax;
                    DebitNoteItem.Amount       = Convert.ToDouble(frmcol[amount]);
                    DebitNoteItem.Status       = "Active";
                    DebitNoteItem.ModifiedOn   = DateTime.Now;
                    _DebitNoteItemService.Create(DebitNoteItem);

                    string code = Session["LOGINSHOPGODOWNCODE"].ToString();
                    if (item.ItemType == "Inventory")
                    {
                        if (code.Contains("SH"))
                        {
                            var shopdetails = _ShopStockService.GetDetailsByItemCodeAndShopCode(item.ItemCode, code);
                            shopdetails.Quantity = shopdetails.Quantity - item.Quantity;
                            _ShopStockService.Update(shopdetails);

                            var stockitemdetails = _StockItemDistributionService.GetDetailsByItemCodeAndShopCode(item.ItemCode, code);
                            stockitemdetails.ItemQuantity = stockitemdetails.ItemQuantity - item.Quantity;
                            _StockItemDistributionService.Update(stockitemdetails);
                        }
                        else
                        {
                            var godowndetails = _GodownStockService.GetDetailsByItemCodeAndGodownCode(item.ItemCode, code);
                            godowndetails.Quantity = godowndetails.Quantity - item.Quantity;
                            _GodownStockService.Update(godowndetails);

                            var stockitemdetails = _StockItemDistributionService.GetDetailsByItemCodeAndGodownCode(item.ItemCode, code);
                            stockitemdetails.ItemQuantity = stockitemdetails.ItemQuantity - item.Quantity;
                            _StockItemDistributionService.Update(stockitemdetails);
                        }

                        var entrystockitems = _EntryStockItemService.getDetailsByItemCode(item.ItemCode);
                        if (entrystockitems != null)
                        {
                            entrystockitems.TotalQuantity = entrystockitems.TotalQuantity - item.Quantity;
                            _EntryStockItemService.Update(entrystockitems);
                        }
                        else
                        {
                            var openingstockitems = _OpeningStockService.GetDetailsByItemCode(item.ItemCode);
                            openingstockitems.TotalQuantity = openingstockitems.TotalQuantity - item.Quantity;
                            _OpeningStockService.UpdateStock(openingstockitems);
                        }
                    }
                }
                else
                {
                    item.PurchaseReturnNo = PurchaseReturnCode;
                    item.Quantity         = 0;
                    _PurchaseReturnItemService.Create(item);
                }
                count++;
            }
            var data = _InwardFromSupplierService.GetInwardByInwardNo(model.PurchaseReturnDetails.InwardNo);

            data.PurchaseReturn = "Yes";
            if (data.PurchaseReturnNo == null)
            {
                data.PurchaseReturnNo = PurchaseReturnCode;
            }
            else
            {
                data.PurchaseReturnNo = data.PurchaseReturnNo + "," + PurchaseReturnCode;
            }
            _InwardFromSupplierService.UpdateInward(data);

            //Store total tax and total amount of tax of PO
            int itemtaxcount = Convert.ToInt32(frmcol["ReturnItemTaxCount"]);

            model.PurchaseInventoryTaxDetails = new PurchaseInventoryTax();
            for (int i = 1; i <= itemtaxcount; i++)
            {
                string taxnumber   = "ReturnItemTaxNumber" + i;
                string taxamount   = "ReturnAddedTaxAmounthdn" + i;
                string amountontax = "ReturnAddedAmounthdn" + i;
                if (Convert.ToDouble(frmcol[taxamount]) != 0)
                {
                    model.PurchaseInventoryTaxDetails.Code      = PurchaseReturnCode;
                    model.PurchaseInventoryTaxDetails.Amount    = frmcol[amountontax];
                    model.PurchaseInventoryTaxDetails.Tax       = frmcol[taxnumber];
                    model.PurchaseInventoryTaxDetails.TaxAmount = frmcol[taxamount];
                    _PurchaseInventoryTaxService.Create(model.PurchaseInventoryTaxDetails);
                }
            }

            var    details = _PurchaseReturnService.GetPurchaseByReturnNo(PurchaseReturnCode);
            string PRId    = Encode(details.Id.ToString());

            return(RedirectToAction("PurchaseReturnDetails/" + PRId));
        }
コード例 #2
0
        public ActionResult CreateBillPayment(MainApplication mainapp, FormCollection frmcol)
        {
            MainApplication model = new MainApplication()
            {
                BillPaymentDetails     = new BillPayment(),
                BillPaymentItemDetails = new BillPaymentItem(),
            };

            var details = _BillPaymentService.GetLastRow();
            int val     = 0;
            int length  = 0;

            if (details != null)
            {
                val    = details.Id;
                val    = val + 1;
                length = val.ToString().Length;
            }
            else
            {
                val    = 1;
                length = 1;
            }
            String code = _utilityservice.getName("BP", length, val);

            mainapp.BillPaymentDetails.BillPaymentCode = code;

            // SAVE BILL PAYMENT
            mainapp.BillPaymentDetails.Date         = DateTime.Now;
            mainapp.BillPaymentDetails.SupplierName = frmcol["SupplierName"];
            mainapp.BillPaymentDetails.Payment      = Convert.ToDouble(frmcol["TotalPaymentVal"]);
            mainapp.BillPaymentDetails.PaymentType  = frmcol["PaymentType"];
            mainapp.BillPaymentDetails.Status       = "Active";
            mainapp.BillPaymentDetails.ModifiedOn   = DateTime.Now;

            mainapp.BillPaymentDetails.Cash_1000     = Convert.ToInt32(frmcol["BillPaymentDetails.Cash_1000"]);
            mainapp.BillPaymentDetails.Cash_500      = Convert.ToInt32(frmcol["BillPaymentDetails.Cash_500"]);
            mainapp.BillPaymentDetails.Cash_100      = Convert.ToInt32(frmcol["BillPaymentDetails.Cash_100"]);
            mainapp.BillPaymentDetails.Cash_50       = Convert.ToInt32(frmcol["BillPaymentDetails.Cash_50"]);
            mainapp.BillPaymentDetails.Cash_20       = Convert.ToInt32(frmcol["BillPaymentDetails.Cash_20"]);
            mainapp.BillPaymentDetails.Cash_10       = Convert.ToInt32(frmcol["BillPaymentDetails.Cash_10"]);
            mainapp.BillPaymentDetails.Cash_1        = Convert.ToDouble(frmcol["BillPaymentDetails.Cash_1"]);
            mainapp.BillPaymentDetails.Cash_1000_Amt = Convert.ToDouble(frmcol["Amt1"]);
            mainapp.BillPaymentDetails.Cash_500_Amt  = Convert.ToDouble(frmcol["Amt2"]);
            mainapp.BillPaymentDetails.Cash_100_Amt  = Convert.ToDouble(frmcol["Amt3"]);
            mainapp.BillPaymentDetails.Cash_50_Amt   = Convert.ToDouble(frmcol["Amt4"]);
            mainapp.BillPaymentDetails.Cash_20_Amt   = Convert.ToDouble(frmcol["Amt5"]);
            mainapp.BillPaymentDetails.Cash_10_Amt   = Convert.ToDouble(frmcol["Amt6"]);
            mainapp.BillPaymentDetails.Cash_1_Amt    = Convert.ToDouble(frmcol["Amt7"]);
            mainapp.BillPaymentDetails.TotalCash     = Convert.ToDouble(frmcol["BillPaymentDetails.TotalCash"]);
            mainapp.BillPaymentDetails.SelectedCard  = frmcol["Card"];
            mainapp.BillPaymentDetails.CreditCardNo  = frmcol["BillPaymentDetails.CreditCardNo"];
            if (frmcol["BillPaymentDetails.CreditCardAmount"] == "")
            {
                mainapp.BillPaymentDetails.CreditCardAmount = 0;
            }
            else
            {
                mainapp.BillPaymentDetails.CreditCardAmount = Convert.ToDouble(frmcol["BillPaymentDetails.CreditCardAmount"]);
            }
            mainapp.BillPaymentDetails.CreditCardType = frmcol["BillPaymentDetails.CreditCardType"];
            mainapp.BillPaymentDetails.CreditCardBank = frmcol["BillPaymentDetails.CreditCardBank"];
            mainapp.BillPaymentDetails.DebitCardNo    = frmcol["BillPaymentDetails.DebitCardNo"];
            mainapp.BillPaymentDetails.DebitCardName  = frmcol["BillPaymentDetails.DebitCardName"];
            mainapp.BillPaymentDetails.DebitCardType  = frmcol["BillPaymentDetails.DebitCardType"];
            mainapp.BillPaymentDetails.DebitCardBank  = frmcol["BillPaymentDetails.DebitCardBank"];
            if (frmcol["BillPaymentDetails.DebitCardAmount"] == "")
            {
                mainapp.BillPaymentDetails.DebitCardAmount = 0;
            }
            else
            {
                mainapp.BillPaymentDetails.DebitCardAmount = Convert.ToDouble(frmcol["BillPaymentDetails.DebitCardAmount"]);
            }
            mainapp.BillPaymentDetails.ChequeNo     = frmcol["BillPaymentDetails.ChequeNo"];
            mainapp.BillPaymentDetails.ChequeAccNo  = frmcol["BillPaymentDetails.ChequeAccNo"];
            mainapp.BillPaymentDetails.ChequeAmount = frmcol["BillPaymentDetails.ChequeAmount"];
            if (mainapp.BillPaymentDetails.ChequeNo != null && mainapp.BillPaymentDetails.ChequeNo != "")
            {
                mainapp.BillPaymentDetails.ChequeDate = Convert.ToDateTime(frmcol["BillPaymentDetails.ChequeDate"]);
            }
            else
            {
                mainapp.BillPaymentDetails.ChequeDate = null;
            }
            mainapp.BillPaymentDetails.ChequeBank   = frmcol["BillPaymentDetails.ChequeBank"];
            mainapp.BillPaymentDetails.ChequeBranch = frmcol["BillPaymentDetails.ChequeBranch"];

            var username = HttpContext.Session["UserName"].ToString();

            //IF EXCEPT SUPERADMIN LOGIN THEN SHOW SHOP OR GODOWN
            if (username != "SuperAdmin")
            {
                mainapp.BillPaymentDetails.ShopCode = Session["LOGINSHOPGODOWNCODE"].ToString();
                mainapp.BillPaymentDetails.ShopName = Session["SHOPGODOWNNAME"].ToString();
            }
            else
            {
                mainapp.BillPaymentDetails.ShopCode = "SuperAdmin";
                mainapp.BillPaymentDetails.ShopName = "SuperAdmin";
            }
            _BillPaymentService.Create(mainapp.BillPaymentDetails);

            //SAVE BILL PAYMENT ITEM
            int inwardlistcount = Convert.ToInt32(frmcol["InwardListCount"]);

            if (inwardlistcount != 0)
            {
                for (int i = 1; i < inwardlistcount; i++)
                {
                    string checkbox     = "CheckBox" + i;
                    string inwardno     = "InwardNo" + i;
                    string grandtotal   = "GrandTotal" + i;
                    string debitnoteamt = "DebitNoteAmt" + i;
                    string amountpaid   = "AmountPaid" + i;
                    string payment      = "Payment" + i;
                    string discount     = "Discount" + i;
                    string balanceval   = "BalanceVal" + i;

                    if (frmcol[checkbox] == "Yes")
                    {
                        model.BillPaymentItemDetails.BillPaymentCode      = mainapp.BillPaymentDetails.BillPaymentCode;
                        model.BillPaymentItemDetails.InwardFromSupplierNo = frmcol[inwardno];

                        //get details by inward no..
                        var inwarddetails = _InwardFromSupplierService.GetDetailsByPINo(frmcol[inwardno]);
                        model.BillPaymentItemDetails.InwardFromSupplierDate = inwarddetails.InwardDate;
                        model.BillPaymentItemDetails.SupplierBillNo         = inwarddetails.BillNo;
                        model.BillPaymentItemDetails.SupplierChallanNo      = inwarddetails.ChallanNo;
                        model.BillPaymentItemDetails.PONo            = inwarddetails.PoNo;
                        model.BillPaymentItemDetails.GrandTotal      = Convert.ToDouble(frmcol[grandtotal]);
                        model.BillPaymentItemDetails.DebitNoteAmount = Convert.ToDouble(frmcol[debitnoteamt]);
                        model.BillPaymentItemDetails.PreviousPayment = Convert.ToDouble(frmcol[amountpaid]);
                        model.BillPaymentItemDetails.Payment         = Convert.ToDouble(frmcol[payment]);
                        model.BillPaymentItemDetails.Discount        = Convert.ToDouble(frmcol[discount]);
                        model.BillPaymentItemDetails.Balance         = Convert.ToDouble(frmcol[balanceval]);
                        model.BillPaymentItemDetails.Status          = "Active";
                        model.BillPaymentItemDetails.ModifiedOn      = DateTime.Now;
                        _BillPaymentItemService.Create(model.BillPaymentItemDetails);

                        //UPDATE INWARD FROM SUPPLIER AFTER SUPPLIER PAYMENT..
                        var InwardData = _InwardFromSupplierService.GetDetailsByPINo(frmcol[inwardno]);
                        InwardData.PaymentAmount    = InwardData.PaymentAmount + model.BillPaymentItemDetails.Payment;
                        InwardData.DebitNotesAmount = InwardData.DebitNotesAmount + model.BillPaymentItemDetails.DebitNoteAmount;
                        InwardData.PaymentBalance   = model.BillPaymentItemDetails.Balance;

                        //if inward balanace is 0 then inactive payment status of that inward
                        if (InwardData.PaymentBalance == 0)
                        {
                            InwardData.PaymentStatus = "InActive";
                        }
                        _InwardFromSupplierService.UpdateInward(InwardData);

                        //UPDATE DEBIT NOTE (STATUS IS INAVTIVE WHEN DEBIT NOTE ADJUSTED FOR INWARD BILL PAYMENT
                        var DebitNoteData = _DebitNoteService.GetDebitNoteListByInwardNo(frmcol[inwardno]);
                        foreach (var data in DebitNoteData)
                        {
                            data.Status = "InActive";
                            _DebitNoteService.Update(data);
                        }
                    }
                }
            }
            return(RedirectToAction("CreateBillPayment"));
        }