public JsonResult GetSupplierDetails(string inwardno)
        {
            var data = _InwardFromSupplierService.GetDetailsByPINo(inwardno);

            return(Json(new
            {
                data.SupplierName,
                data.SupplierContactNo,
                data.PoNo,
            }, JsonRequestBehavior.AllowGet));
        }
예제 #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"));
        }