public LoanContractScheduleDS PrepareDataForLoanContractSchedule(BNEWNORMALLOAN normalLoanEntryM, int replaymentTimes) { if (normalLoanEntryM == null) return null; LoanContractScheduleDS dsOut = new LoanContractScheduleDS(); NormalLoanRepaymentRepository facade = new NormalLoanRepaymentRepository(); BNEWNORMALLOAN_REPAYMENT entry = facade.FindRepaymentAmount(normalLoanEntryM.Code, replaymentTimes).FirstOrDefault(); DataRow drInfor = dsOut.DtInfor.NewRow(); drInfor[dsOut.Cl_code] = normalLoanEntryM.Code; drInfor[dsOut.Cl_custID] = normalLoanEntryM.CustomerID; drInfor[dsOut.Cl_cust] = normalLoanEntryM.CustomerName; if (normalLoanEntryM.Drawdown != null) { if (entry != null && entry.ActivatedDate != null) { drInfor[dsOut.Cl_drawdown] = entry.ActivatedDate; } else { drInfor[dsOut.Cl_drawdown] = normalLoanEntryM.Drawdown; } } drInfor[dsOut.Cl_loadAmount] = normalLoanEntryM.LoanAmount; drInfor[dsOut.Cl_loadAmountRepayment] = getCurrentLoanAmount(normalLoanEntryM, replaymentTimes); drInfor[dsOut.Cl_interestKey] = ""; drInfor[dsOut.Cl_interest] = 0; drInfor[dsOut.Cl_valueDate] = normalLoanEntryM.ValueDate; dsOut.DtInfor.Rows.Add(drInfor); bool isDisbursal = normalLoanEntryM.Drawdown == null ? true : false; //Process payment PaymentProcess(ref dsOut, normalLoanEntryM, replaymentTimes); //Process disbursal if (isDisbursal) { DisbursalProcess(ref dsOut, normalLoanEntryM, ref disbursalDate); } //Process interest InterestProcess(ref dsOut, normalLoanEntryM, replaymentTimes, disbursalDate); DataRow rowD = dsOut.DateReport.NewRow(); DateTime today = normalLoanEntryM.ValueDate == null ? DateTime.Today : (DateTime)normalLoanEntryM.ValueDate; rowD["day"] = today.ToString("dd"); rowD["month"] = today.ToString("MM"); rowD["year"] = today.ToString("yyyy"); dsOut.DateReport.Rows.Add(rowD); return dsOut; }
private decimal getCurrentLoanAmount(BNEWNORMALLOAN normalLoanEntryM, int replaymentTimes) { NormalLoanRepaymentRepository facade = new NormalLoanRepaymentRepository(); BNEWNORMALLOAN_REPAYMENT entry = facade.FindRepaymentAmount(normalLoanEntryM.Code, replaymentTimes).FirstOrDefault(); if (entry != null) { return entry.LoanAmount; } else { return (decimal)normalLoanEntryM.LoanAmount; } }
protected void updateNormalLoanRepayment(BNEWNORMALLOAN loan, int repaymentTimes, decimal newAmount, DateTime? activateDate) { NormalLoanRepaymentRepository facade = new NormalLoanRepaymentRepository(); BNEWNORMALLOAN_REPAYMENT existLoanRepay = facade.FindRepaymentAmount(loan.Code, repaymentTimes).FirstOrDefault(); if (existLoanRepay != null) { BNEWNORMALLOAN_REPAYMENT existLoanRepayOld = facade.FindRepaymentAmount(loan.Code, repaymentTimes).FirstOrDefault(); existLoanRepay.LoanAmount = newAmount; facade.Update(existLoanRepayOld, existLoanRepay); } else { existLoanRepay = new BNEWNORMALLOAN_REPAYMENT(); existLoanRepay.RepaymentTimes = repaymentTimes; existLoanRepay.ActivatedDate = activateDate; existLoanRepay.LoanAmount = newAmount; existLoanRepay.Code = loan.Code; facade.Add(existLoanRepay); } facade.Commit(); }
private void updateRepaymentAmount(BNEWNORMALLOAN loan, decimal newAmount) { NormalLoanRepaymentRepository facade = new NormalLoanRepaymentRepository(); BNEWNORMALLOAN_REPAYMENT existLoanRepay = facade.FindRepaymentAmount(loan.Code, int.Parse(hfRepaymentTimes.Value)).FirstOrDefault(); if (existLoanRepay != null) { BNEWNORMALLOAN_REPAYMENT existLoanRepayOld = facade.FindRepaymentAmount(loan.Code, int.Parse(hfRepaymentTimes.Value)).FirstOrDefault(); existLoanRepay.LoanAmount = newAmount; facade.Update(existLoanRepayOld, existLoanRepay); } else { existLoanRepay = new BNEWNORMALLOAN_REPAYMENT(); existLoanRepay.RepaymentTimes = int.Parse(hfRepaymentTimes.Value); existLoanRepay.ActivatedDate = DateTime.Now; existLoanRepay.LoanAmount = newAmount; existLoanRepay.Code = loan.Code; facade.Add(existLoanRepay); } facade.Commit(); }