Esempio n. 1
0
        public JsonResult AddReceiveOtherInstallment(Installment_Received instrec, int Istplanid)
        {
            instrec.Date         = DateTime.UtcNow;
            instrec.Payment_Date = DateTime.UtcNow;
            db.Installment_Received.Add(instrec);
            db.SaveChanges();

            var    res    = db.Installment_Plan.Where(x => x.Plot_Id == instrec.Plot_Id && x.Status != 1).OrderByDescending(x => x.Id);
            double Amount = Convert.ToDouble(instrec.Amount_LC);

            foreach (var item in res)
            {
                if (Amount >= item.Amount_LC)
                {
                    Amount = Amount - Convert.ToDouble(item.Amount_LC);

                    Mapping_Installment_Planned_Recevied mipr = new Mapping_Installment_Planned_Recevied()
                    {
                        InstallmentReceived_Id = instrec.Id,
                        Amount             = Amount,
                        InstallmentPlan_Id = item.Id
                    };
                    db.Mapping_Installment_Planned_Recevied.Add(mipr);
                    db.SaveChanges();

                    var res1 = item;
                    res1.Status = 1;
                    db.Installment_Plan.Attach(res1);
                    db.Entry(res).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                }
            }

            Balance_Installments bal = new Balance_Installments()
            {
                Received_Amount   = instrec.Amount_LC,
                Plot_id           = instrec.Plot_Id,
                InstRece_Id       = instrec.Id,
                Transaction_Party = instrec.Customer_Id,
                Due_Amount        = 0
            };

            db.Balance_Installments.Add(bal);
            db.SaveChanges();



            return(Json(true));
        }
Esempio n. 2
0
        public JsonResult AddReceiveInstallment(Installment_Received instrec, int Istplanid)
        {
            instrec.Date         = DateTime.UtcNow;
            instrec.Payment_Date = DateTime.UtcNow;
            db.Installment_Received.Add(instrec);
            db.SaveChanges();

            Mapping_Installment_Planned_Recevied mipr = new Mapping_Installment_Planned_Recevied()
            {
                InstallmentReceived_Id = instrec.Id,
                Amount             = instrec.Amount_LC,
                InstallmentPlan_Id = Istplanid
            };

            db.Mapping_Installment_Planned_Recevied.Add(mipr);
            db.SaveChanges();

            Balance_Installments bal = new Balance_Installments()
            {
                Received_Amount   = instrec.Amount_LC,
                Plot_id           = instrec.Plot_Id,
                InstRece_Id       = instrec.Id,
                Transaction_Party = instrec.Customer_Id,
                Due_Amount        = 0
            };

            db.Balance_Installments.Add(bal);
            db.SaveChanges();

            var res = db.Installment_Plan.SingleOrDefault(x => x.Id == Istplanid);

            res.Status = 1;
            db.Installment_Plan.Attach(res);
            db.Entry(res).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();

            return(Json(true));
        }