public async Task <IActionResult> Edit(int id, [Bind("IdLoanRepayment,CreaditId,MonthForPay,YearForPay,DateOfPay,MonthlyPayment,ExpiredDays,Fine,TotalPayment")] LoanRepayment loanRepayment) { if (id != loanRepayment.IdLoanRepayment) { return(NotFound()); } if (ModelState.IsValid) { try { await Task.Run(() => loanRepaymentRepo.Update(loanRepayment)); } catch (DbUpdateConcurrencyException) { if (!LoanRepaymentExists(loanRepayment.IdLoanRepayment)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CreaditId"] = new SelectList(creditsRepsitory.GetList(), "IdCredits", "Name", loanRepayment.CreaditId); ViewData["MonthForPay"] = new SelectList(monthRepository.getMonths(), "IdMonth", "MonthName", loanRepayment.MonthForPay); // ViewData["YearForPay"] = new SelectList(yearsRepository.getYears(), "IdYears", "YearsName", loanRepayment.YearForPay); return(View(loanRepayment)); }
public async Task <IActionResult> Create([Bind("IdLoanRepayment,CreaditId,MonthForPay,YearForPay,DateOfPay,MonthlyPayment,ExpiredDays,Fine,TotalPayment")] LoanRepayment loanRepayment) { if (ModelState.IsValid) { if (loanRepayment.GetPermission() == 1) { await Task.Run(() => loanRepaymentRepo.Create(loanRepayment)); return(RedirectToAction(nameof(Index))); } else if (loanRepayment.GetPermission() == 0) { return(NotFound("Credit fully paid")); } else if (loanRepayment.GetPermission() == 2) { return(NotFound("Amount of budget is not enough")); } else if (loanRepayment.GetPermission() == 3) { return(NotFound("Incorrect date for pay")); } } ViewData["CreaditId"] = new SelectList(creditsRepsitory.GetList(), "IdCredits", "Name", loanRepayment.CreaditId); ViewData["MonthForPay"] = new SelectList(monthRepository.getMonths(), "IdMonth", "MonthName", loanRepayment.MonthForPay); // ViewData["YearForPay"] = new SelectList(yearsRepository.getYears(), "IdYears", "YearsName", loanRepayment.YearForPay); return(View(loanRepayment)); }
public ActionResult DeleteConfirmed(int id) { LoanRepayment loanRepayment = db.LoanRepayments.Find(id); db.LoanRepayments.Remove(loanRepayment); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "ID,IMEI,AmountRepaid,AmountRemaining,DateOfRepayment,TransactnID")] LoanRepayment loanRepayment) { if (ModelState.IsValid) { db.Entry(loanRepayment).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(loanRepayment)); }
// // GET: /LoanRepayment/Details/5 public ActionResult Details(int id = 0) { LoanRepayment loanrepayment = db.LoanRepayments.Find(id); if (loanrepayment == null) { return(HttpNotFound()); } return(View(loanrepayment)); }
public ActionResult Create([Bind(Include = "ID,IMEI,AmountRepaid,AmountRemaining,DateOfRepayment,TransactnID")] LoanRepayment loanRepayment) { if (ModelState.IsValid) { db.LoanRepayments.Add(loanRepayment); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(loanRepayment)); }
// GET: LoanRepayments/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } LoanRepayment loanRepayment = db.LoanRepayments.Find(id); if (loanRepayment == null) { return(HttpNotFound()); } return(View(loanRepayment)); }
public ActionResult Create(LoanPreClosing loanpreclosing) { if (ModelState.IsValid) { //TODO: Enter in repayment of final entry to close loan LoanRepayment loanrepayment = new LoanRepayment(); var disbursedLoan = db.LoanDisbursements.Where(x => x.LoanDisbursementId == loanpreclosing.LoanDisbursementId).FirstOrDefault(); if (disbursedLoan != null) { //Repayment Entry loanrepayment.BranchId = disbursedLoan.BranchId; loanrepayment.ClientId = disbursedLoan.ClientId; loanrepayment.AmountPaid = loanpreclosing.AmountPaid; loanrepayment.BalanceAmount = loanpreclosing.ActualLoanBalance; loanrepayment.LoanApplicationId = disbursedLoan.LoanApplicationId; loanrepayment.LoanCycleId = disbursedLoan.LoanCycleId; loanrepayment.LoanDisbursementId = disbursedLoan.LoanDisbursementId; var lastEMI = db.LoanEMISchedules.Where(x => x.LoanDisbursementId == disbursedLoan.LoanDisbursementId).OrderByDescending(x => x.EMIDate).FirstOrDefault(); if (lastEMI != null) { loanrepayment.LoanEMIScheduletId = lastEMI.LoanEMIScheduleId; } else { loanrepayment.LoanEMIScheduletId = 0; } loanrepayment.PaymentDate = DateTime.Now; loanrepayment.RepaymentStatusId = 1; //1 : Paid and 2 : Due loanrepayment.UserId = loanpreclosing.UserId; db.LoanRepayments.Add(loanrepayment); if (disbursedLoan.LoanStatu.LoanStatus.ToString() == LoanStatus.Active.ToString()) { disbursedLoan.LoanStatusId = 2; db.SaveChanges(); } db.LoanPreClosings.Add(loanpreclosing); db.SaveChanges(); } return(RedirectToAction("Index")); } ViewBag.LoanDisbursementId = new SelectList(db.LoanDisbursements, "LoanDisbursementId", "DisbursementCode", loanpreclosing.LoanDisbursementId); ViewBag.UserId = new SelectList(db.Users, "Id", "UserName", loanpreclosing.UserId); return(View(loanpreclosing)); }
// // GET: /LoanRepayment/Edit/5 public ActionResult Edit(int id = 0) { LoanRepayment loanrepayment = db.LoanRepayments.Find(id); if (loanrepayment == null) { return(HttpNotFound()); } ViewBag.BranchId = new SelectList(db.Branches, "BranchId", "BranchCode", loanrepayment.BranchId); ViewBag.ClientId = new SelectList(db.Clients, "ClientId", "ClientName", loanrepayment.ClientId); ViewBag.LoanApplicationId = new SelectList(db.LoanApplications, "LoanApplicationId", "LoanApplicationNo", loanrepayment.LoanApplicationId); ViewBag.LoanCycleId = new SelectList(db.LoanCycles, "LoanCycleId", "LoanCycle1", loanrepayment.LoanCycleId); ViewBag.LoanDisbursementId = new SelectList(db.LoanDisbursements, "LoanDisbursementId", "DisbursementCode", loanrepayment.LoanDisbursementId); ViewBag.LoanEMIScheduletId = new SelectList(db.LoanEMISchedules, "LoanEMIScheduleId", "EMIDate", loanrepayment.LoanEMIScheduletId); ViewBag.RepaymentStatusId = new SelectList(db.LoanRepaymentStatus, "LoanRepaymentStatusId", "LoanRepaymentStatus", loanrepayment.RepaymentStatusId); ViewBag.UserId = new SelectList(db.Users, "Id", "UserName", loanrepayment.UserId); return(View(loanrepayment)); }
public void Test_for_RepaymentsReceived() { LoanRepayment loanRepayment = new LoanRepayment() { LoanNumber = "dd", ChequeNumber = "dd", AmmountRepaid = 11, MadeOfPayment = "dd" }; Borrowers borrowers = new Borrowers() { BorrowerId = 1 }; var Result = _LoanClerkServices.RepaymentsReceived(loanRepayment, borrowers.BorrowerId); Assert.True(Result); }
public ActionResult Create(LoanRepayment loanrepayment, string Advance) { if (ModelState.IsValid) { db.LoanRepayments.Add(loanrepayment); db.SaveChanges(); // Update repay balance in Disbursement table decimal amountPaid = db.LoanRepayments.Where(x => x.LoanDisbursementId == loanrepayment.LoanDisbursementId && x.LoanCycleId == loanrepayment.LoanCycleId).Sum(x => x.AmountPaid).Value; LoanDisbursement loanDisburseRecord = db.LoanDisbursements.Where(x => x.LoanDisbursementId == loanrepayment.LoanDisbursementId && x.LoanCycleId == loanrepayment.LoanCycleId).FirstOrDefault(); decimal actualPaidLoanAmt = 0; if (loanDisburseRecord != null) { actualPaidLoanAmt = loanDisburseRecord.TotalRepayAmountWithInterest.Value; loanDisburseRecord.LoanRepayBalance = loanDisburseRecord.LoanRepayBalance - loanrepayment.AmountPaid.Value; } decimal remainLoanBalance = actualPaidLoanAmt - amountPaid; if (remainLoanBalance <= 0) { //Update Status in disbursement when all amount paid // Change loan status loanDisburseRecord.LoanStatusId = 2; } db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.BranchId = new SelectList(db.Branches, "BranchId", "BranchCode", loanrepayment.BranchId); ViewBag.ClientId = new SelectList(db.Clients, "ClientId", "ClientName", loanrepayment.ClientId); ViewBag.LoanApplicationId = new SelectList(db.LoanApplications, "LoanApplicationId", "LoanApplicationNo", loanrepayment.LoanApplicationId); ViewBag.LoanCycleId = new SelectList(db.LoanCycles, "LoanCycleId", "LoanCycle1", loanrepayment.LoanCycleId); ViewBag.LoanDisbursementId = new SelectList(db.LoanDisbursements, "LoanDisbursementId", "DisbursementCode", loanrepayment.LoanDisbursementId); ViewBag.LoanEMIScheduletId = new SelectList(db.LoanEMISchedules, "LoanEMIScheduleId", "EMIDate", loanrepayment.LoanEMIScheduletId); ViewBag.RepaymentStatusId = new SelectList(db.LoanRepaymentStatus, "LoanRepaymentStatusId", "LoanRepaymentStatus", loanrepayment.RepaymentStatusId); ViewBag.UserId = new SelectList(db.Users, "Id", "UserName", loanrepayment.UserId); return(View(loanrepayment)); }
public Response Update(LoanRepayment repayment) { Response response = new Response(); try { using (IDbConnection conn = GetConnection()) { conn.Update(repayment); response.Status = true; response.Description = "Successful"; } } catch (Exception ex) { response.Status = false; response.Description = ex.Message; } return(response); }
public bool RepaymentsReceived(LoanRepayment loanRepayment, int BorrowerId) { return(true); }