756 lines
29 KiB
C#
756 lines
29 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Data;
|
|
using Ease.Core.Model;
|
|
using Ease.Core.DataAccess;
|
|
using Ease.Core.Utility;
|
|
using static iTextSharp.awt.geom.Point2D;
|
|
using HRM.BO.Configuration;
|
|
using Microsoft.VisualBasic;
|
|
|
|
namespace HRM.BO
|
|
{
|
|
#region Class Loan
|
|
[Serializable]
|
|
public class FMLoan : BasicBaseObject
|
|
{
|
|
#region Constructor
|
|
public FMLoan()
|
|
{
|
|
ActivityID = 0;
|
|
CustomerID = 0;
|
|
MemberID = 0;
|
|
Version = 0;
|
|
FundTypeID = 0;
|
|
IssueDate = DateTime.Now;
|
|
StartPayBackMonth = DateTime.Now;
|
|
Description = string.Empty;
|
|
InstallmentNo = 0;
|
|
InterestRate = 0.0;
|
|
LoanCategoryID = 0;
|
|
LoanNo = string.Empty;
|
|
PrincipalAmount = 0.0;
|
|
LoanAccNo = string.Empty;
|
|
TransferLogIDinInt = 0;
|
|
Remarks = string.Empty;
|
|
LoanSchedules = [];
|
|
EarlySettleRequestDate = null;
|
|
EarlySettleRequestBy = null;
|
|
SettleAmount = 0.0;
|
|
SettleStatus = EnumLoanSettleStatus.None;
|
|
EarlySettleDate = null;
|
|
InstrumentNumber = string.Empty;
|
|
InstrumentDate = null;
|
|
InstrumentBank = string.Empty;
|
|
EarlySettleDate = null;
|
|
LoanApplicationID = null;
|
|
LoanEarlySettlementAttachment = new LoanEarlySettlementAttachment();
|
|
LoanAttachment = new FMLoanAttachment();
|
|
VoucherDate = DateTime.MinValue;
|
|
}
|
|
#endregion
|
|
|
|
#region Properties
|
|
|
|
#region Property ActivityID : ID
|
|
public int ActivityID { get; set; }
|
|
|
|
#endregion Property ActivityID : ID
|
|
|
|
#region Property CustomerID : ID
|
|
public int CustomerID { get; set; }
|
|
|
|
#endregion Property CustomerID : ID
|
|
|
|
#region Property LoanCustomer : LoanCustomer
|
|
|
|
public FMLoanCustomer LoanCustomer { set; get; }
|
|
|
|
#endregion Property LoanCustomer : LoanCustomer
|
|
|
|
#region Property Description : string
|
|
public string Description { get; set; }
|
|
|
|
#endregion Property Description : string
|
|
|
|
#region Property InstallmentNo : int
|
|
public int InstallmentNo { get; set; }
|
|
|
|
#endregion Property InstallmentNo : int
|
|
|
|
#region Property InterestRate : double
|
|
public double InterestRate { get; set; }
|
|
|
|
#endregion Property InterestRate : double
|
|
|
|
#region Property IssueDate : DateTime
|
|
public DateTime IssueDate { get; set; }
|
|
|
|
#endregion Property IssueDate : DateTime
|
|
|
|
#region Property LoanCategoryID : ID
|
|
public int LoanCategoryID { get; set; }
|
|
|
|
#endregion Property LoanCategoryID : ID
|
|
|
|
#region Property LoanCategory : LoanCategory
|
|
public FMLoanCategory LoanCategory { get; set; }
|
|
|
|
#endregion Property LoanCategory : LoanCategory
|
|
|
|
#region Property LoanNo : string
|
|
public string LoanNo { get; set; }
|
|
|
|
#endregion Property LoanNo : string
|
|
|
|
#region Property Remarks : string
|
|
public string Remarks { get; set; }
|
|
|
|
#endregion Property LoanNo : string
|
|
|
|
#region Property LoanAccNo : string
|
|
public string LoanAccNo { get; set; }
|
|
|
|
#endregion Property LoanAccNo : string
|
|
|
|
#region Property MemberID : ID
|
|
public int MemberID { get; set; }
|
|
|
|
#endregion Property MemberID : ID
|
|
|
|
#region Property Member : Member
|
|
public Member Member { get; set; }
|
|
|
|
#endregion Property Member : Member
|
|
|
|
#region Property PrincipalAmount : double
|
|
|
|
public double PrincipalAmount { get; set; }
|
|
|
|
#endregion Property PrincipalAmount : double
|
|
|
|
#region Property Status : EnumLoanStatus
|
|
|
|
public EnumFMLoanStatus LoanStatus { get; set; }
|
|
|
|
#endregion Property Status : EnumLoanStatus
|
|
|
|
#region Property Status : EnumLoanIssueStatus
|
|
|
|
public EnumFMLoanIssueStatus LoanIssueStatus { get; set; }
|
|
|
|
#endregion Property Status : EnumLoanIssueStatus
|
|
|
|
#region Property Version : int
|
|
public int Version { get; set; }
|
|
|
|
#endregion Property Version : int
|
|
|
|
#region Property FundTypeID : ID
|
|
public int FundTypeID { get; set; }
|
|
|
|
#endregion Property FundTypeID : ID
|
|
|
|
#region Property StartPayBackMonth : DateTime
|
|
public DateTime StartPayBackMonth { get; set; }
|
|
|
|
#endregion Property StartPayBackMonth : DateTime
|
|
|
|
#region Property Activity : EnumLoanActivity
|
|
public EnumFMLoanActivity Activity { get; set; }
|
|
|
|
#endregion Property Activity : EnumLoanActivity
|
|
|
|
#region Property LoanSchedules : ObjectsTemplate<LoanSchedule>
|
|
|
|
public List<FMLoanSchedule> LoanSchedules { get; set; }
|
|
|
|
#endregion Property LoanSchedules : ObjectsTemplate<LoanSchedule>
|
|
|
|
#region Property ToBeTotalPrincipal : double
|
|
public double ToBeTotalPrincipal { get; set; }
|
|
|
|
#endregion Property ToBeTotalPrincipal : double
|
|
|
|
#region Property ToBeToatalInterest : double
|
|
public double ToBeToatalInterest { get; set; }
|
|
|
|
#endregion Property ToBeToatalInterest : double
|
|
|
|
#region Property ToBeTotal : double
|
|
public double ToBeTotal { get; set; }
|
|
|
|
#endregion Property ToBeTotal : double
|
|
|
|
#region Property InstallmentAmount : double
|
|
//public double ToBeTotal { get; set; }
|
|
public double InstallmentAmount { get; set; }
|
|
|
|
|
|
#endregion Property InstallmentAmount : double
|
|
|
|
#region Property InstallmentInterest : double
|
|
//public double ToBeToatalInterest { get; set; }
|
|
private List<FMLoanSchedule> _loanSchedules;
|
|
public double InstallmentInterest { get; set; }
|
|
|
|
#endregion Property InstallmentInterest : double
|
|
|
|
#region Property InstallmentPrincipal : double
|
|
//public double ToBeTotalPrincipal { get; set; }
|
|
public double InstallmentPrincipal { get; set; }
|
|
|
|
#endregion Property InstallmentPrincipal : double
|
|
|
|
#region Property DisbursementMonth : DateTime
|
|
public DateTime DisbursementMonth { get; set; }
|
|
#endregion Property DisbursementMonth : DateTime
|
|
|
|
#region Property TotalPaidPrincipal : double
|
|
public double TotalPaidPrincipal { get; set; }
|
|
|
|
#endregion Property TotalPaidPrincipal : double
|
|
|
|
#region Property TotalPaidInterest : double
|
|
public double TotalPaidInterest { get; set; }
|
|
|
|
#endregion Property TotalPaidInterest : double
|
|
|
|
#region Property TotalPaid : double
|
|
public double TotalPaid { get; set; }
|
|
|
|
#endregion Property TotalPaid : double
|
|
|
|
#region Property TotalOutstandingPrincipal : double
|
|
public double TotalOutstandingPrincipal { get; set; }
|
|
|
|
#endregion Property TotalOutstandingPrincipal : double
|
|
|
|
#region Property TotalOutstandingInterest : double
|
|
public double TotalOutstandingInterest { get; set; }
|
|
|
|
#endregion Property TotalOutstandingAmount : double
|
|
|
|
#region ESServiceCharge : double
|
|
public double ESServiceCharge { get; set; }
|
|
|
|
#endregion ESServiceCharge
|
|
|
|
#region ESPrincipalReceive : double
|
|
public double ESPrincipalReceive { get; set; }
|
|
|
|
#endregion ESPrincipalReceive
|
|
|
|
#region ESIntrReceive : double
|
|
public double ESIntrReceive { get; set; }
|
|
|
|
#endregion ESIntrReceive
|
|
|
|
|
|
#region Property TotalOutstanding : double
|
|
public double TotalOutstanding { get; set; }
|
|
|
|
#endregion Property TotalOutstanding : double
|
|
|
|
#region Property TotalPaidInstallment : int
|
|
public int TotalPaidInstallment { get; set; }
|
|
|
|
#endregion Property TotalPaidInstallment : int
|
|
|
|
#region Property TotalNonpaidInstallment : int
|
|
public int TotalNonpaidInstallment { get; set; }
|
|
|
|
#endregion Property TotalNonpaidInstallment : int
|
|
|
|
#region Property NextSchedulePayDate : DateTime
|
|
public DateTime NextSchedulePayDate { get; set; }
|
|
|
|
#endregion Property NextSchedulePayDate : DateTime
|
|
|
|
#region Property IsOpening : EnumLoanOpening
|
|
public EnumFMLoanOpening IsOpening { get; set; }
|
|
|
|
#endregion Property IsOpening : EnumLoanOpening
|
|
|
|
#region Property LastSchedulePayDate : DateTime
|
|
public DateTime LastSchedulePayDate { get; set; }
|
|
|
|
#endregion Property LastSchedulePayDate : DateTime
|
|
|
|
#region Property TransferLogIDinInt : int
|
|
public int TransferLogIDinInt { get; set; }
|
|
|
|
#endregion Property TransferLogIDinInt : int
|
|
|
|
#region Property GLTranID : ID
|
|
public int GLTranID { get; set; }
|
|
|
|
#endregion Property GLTranID : ID
|
|
|
|
#region Property EarlySettleRequestDate : DateTime
|
|
public DateTime? EarlySettleRequestDate { get; set; }
|
|
|
|
#endregion Property EarlySettleRequestDate : DateTime
|
|
|
|
#region Property EarlySettleRequestBy : int
|
|
public int? EarlySettleRequestBy { get; set; }
|
|
|
|
#endregion Property EarlySettleRequestBy : int
|
|
|
|
#region Property SettleAmount : double
|
|
public double? SettleAmount { get; set; }
|
|
|
|
#endregion Property SettleAmount : double
|
|
|
|
#region Property InstrumentNumber : string
|
|
public string? InstrumentNumber { get; set; }
|
|
|
|
#endregion Property InstrumentNumber : string
|
|
|
|
#region Property InstrumentDate : DateTime
|
|
public DateTime? InstrumentDate { get; set; }
|
|
|
|
#endregion Property InstrumentDate : DateTime
|
|
|
|
#region Property InstrumentBank : string
|
|
public string? InstrumentBank { get; set; }
|
|
|
|
#endregion Property InstrumentBank : string
|
|
|
|
#region Property DepositAmount : double
|
|
public double? DepositAmount { get; set; }
|
|
|
|
#endregion Property DepositAmount : double
|
|
|
|
#region Property DepositDate : DateTime
|
|
public DateTime? DepositDate { get; set; }
|
|
|
|
#endregion Property DepositDate : DateTime
|
|
#endregion Property DepositDate : DateTime
|
|
|
|
#region Property SettleStatus : EnumFMLoanSettleStatus
|
|
public EnumLoanSettleStatus? SettleStatus { get; set; }
|
|
|
|
#endregion Property SettleStatus : EnumFMLoanSettleStatus
|
|
|
|
#region Property EarlySettleDate : DateTime
|
|
public DateTime? EarlySettleDate { get; set; }
|
|
|
|
#endregion Property EarlySettleDate : DateTime
|
|
|
|
#region Property LoanEarlySettlementAttachment : LoanEarlySettlementAttachment
|
|
public LoanEarlySettlementAttachment LoanEarlySettlementAttachment { get; set; }
|
|
|
|
#endregion Property LoanEarlySettlementAttachment : LoanEarlySettlementAttachment
|
|
|
|
#region Property LoanApplicationID : int
|
|
public int? LoanApplicationID { get; set; }
|
|
|
|
#endregion Property LoanApplicationID : int
|
|
|
|
#region Property CheckNo : String
|
|
public string? CheckNo { get; set; }
|
|
|
|
#endregion Property CheckNo : string
|
|
|
|
#region Property CheckDate : DateTime
|
|
public DateTime? CheckDate { get; set; }
|
|
|
|
#endregion Property CheckDate : DateTime
|
|
|
|
#region VoucerDate : DateTime
|
|
public DateTime VoucherDate { get; set; }
|
|
#endregion
|
|
|
|
#region FMLoanAttachment : LoanAttachment
|
|
public FMLoanAttachment LoanAttachment { get; set; }
|
|
|
|
#endregion LoanAttachment
|
|
#endregion
|
|
|
|
|
|
//public List<FMLoanSchedule> CreateSchedule(int noOfInstallment, double interestRate, double loanAmount, DateTime payBackMonth, DateTime issueDate)
|
|
//{
|
|
// try
|
|
// {
|
|
// this.LoanSchedules.Clear();
|
|
// double monthlyInterestRate = interestRate / 1200;
|
|
// double emi = Financial.Pmt(monthlyInterestRate, noOfInstallment, -loanAmount, 0, 0);
|
|
// double remaningPrincipal = loanAmount;
|
|
// double extraAmount = 0.0;
|
|
// double principal = 0.0;
|
|
// DateTime dNextMonth = new DateTime(payBackMonth.Year, payBackMonth.Month, 25);
|
|
|
|
// for (int i = 1; i <= noOfInstallment; i++)
|
|
// {
|
|
// FMLoanSchedule schedule = new FMLoanSchedule();
|
|
// schedule.SerialNo = i;
|
|
// double interest = remaningPrincipal * monthlyInterestRate;
|
|
// principal = 0.0;
|
|
// if (i < noOfInstallment)
|
|
// {
|
|
// principal = emi - interest;
|
|
// }
|
|
// else
|
|
// {
|
|
// principal = remaningPrincipal;
|
|
// emi = principal + interest + extraAmount;
|
|
// }
|
|
// remaningPrincipal = remaningPrincipal - principal;
|
|
// principal = Math.Round(principal, 2);
|
|
// interest = Math.Round(interest, 2);
|
|
// double installmentAmount = Math.Round(principal + interest);
|
|
// extraAmount += (principal + interest) - Math.Round(emi, 2);
|
|
|
|
// schedule.InstallmentAmount = installmentAmount;
|
|
// schedule.InstallmentPrincipal = principal;
|
|
// schedule.InstallmentInterest = interest;
|
|
// schedule.EffectiveBalance = Math.Round(remaningPrincipal, 2);
|
|
|
|
// if (schedule.SerialNo > 1)
|
|
// {
|
|
// dNextMonth = dNextMonth.AddMonths(1);
|
|
// }
|
|
// schedule.ScheduledPayDate = GlobalFunctions.LastDateOfMonth(dNextMonth);
|
|
|
|
// this.LoanSchedules.Add(schedule);
|
|
// }
|
|
|
|
// return this.LoanSchedules;
|
|
// }
|
|
// catch (Exception e)
|
|
// {
|
|
// throw new Exception(e.Message, e);
|
|
// }
|
|
|
|
//}
|
|
|
|
//public List<FMLoanSchedule> PrepareSchedule(int noOfInstallment, double interestRate, double loanAmount, DateTime payBackMonth, DateTime issueDate)
|
|
//{
|
|
// try
|
|
// {
|
|
// FMLoanSchedule oSchedule = null;
|
|
// this.LoanSchedules.Clear();
|
|
// double nInterest = 0.0;
|
|
// double nTotalInterest = 0.0;
|
|
// double nInsPrinciple = 0.0;
|
|
// double nBalance = 0.0;
|
|
// double nTotalInstPrinciple = 0.0;
|
|
// double nRate = this.InterestRate / 1200.0;
|
|
// double nEffectiveBalance = loanAmount;
|
|
// double nInstAmount = 0.0;
|
|
// DateTime dNextMonth = new DateTime(payBackMonth.Year, payBackMonth.Month, 25);
|
|
|
|
// nInsPrinciple = Math.Round(nEffectiveBalance / noOfInstallment);
|
|
// nInterest = Math.Round(nEffectiveBalance * nRate);
|
|
// nInstAmount = Math.Round(nInsPrinciple + nInterest);
|
|
|
|
// issueDate = GlobalFunctions.LastDateOfMonth(issueDate);
|
|
|
|
// for (int i = 0; i < noOfInstallment; i++)
|
|
// {
|
|
// nEffectiveBalance = Math.Round(nEffectiveBalance - nInsPrinciple);
|
|
// nTotalInstPrinciple += nInsPrinciple;
|
|
// }
|
|
|
|
// nBalance = loanAmount + nTotalInterest;
|
|
// nEffectiveBalance = loanAmount;
|
|
// double dPrevInstallmentAmount = 0;
|
|
// nTotalInterest = 0;
|
|
// nTotalInstPrinciple = 0;
|
|
|
|
// for (int i = 0; i < noOfInstallment; i++)
|
|
// {
|
|
// oSchedule = new FMLoanSchedule();
|
|
|
|
// nTotalInterest = nTotalInterest + nInterest;
|
|
// oSchedule.SerialNo = i + 1;
|
|
|
|
// if (oSchedule.SerialNo == 1)
|
|
// {
|
|
// dNextMonth = new DateTime(payBackMonth.Year, payBackMonth.Month, 25);
|
|
// }
|
|
// else
|
|
// {
|
|
// dNextMonth = dNextMonth.AddMonths(1);
|
|
// }
|
|
|
|
// oSchedule.InstallmentPrincipal = nInsPrinciple;
|
|
// oSchedule.ScheduledPayDate = GlobalFunctions.LastDateOfMonth(dNextMonth);
|
|
// oSchedule.InstallmentInterest = nInterest;
|
|
|
|
// nEffectiveBalance -= oSchedule.InstallmentPrincipal;
|
|
// if (i > 0)
|
|
// {
|
|
// nBalance = loanAmount - (dPrevInstallmentAmount);
|
|
// oSchedule.EffectiveBalance = nBalance;
|
|
// }
|
|
// else
|
|
// {
|
|
// oSchedule.EffectiveBalance = loanAmount;
|
|
// }
|
|
|
|
// dPrevInstallmentAmount = dPrevInstallmentAmount + oSchedule.InstallmentPrincipal;
|
|
// nTotalInstPrinciple += oSchedule.InstallmentPrincipal;
|
|
// oSchedule.InstallmentAmount = oSchedule.InstallmentPrincipal + oSchedule.InstallmentInterest;
|
|
|
|
// this.LoanSchedules.Add(oSchedule);
|
|
// }
|
|
// int count = this.LoanSchedules.Count;
|
|
// return this.LoanSchedules;
|
|
// }
|
|
// catch (ServiceException e)
|
|
// {
|
|
// throw new Exception(e.Message, e);
|
|
// }
|
|
//}
|
|
|
|
//public List<FMLoanSchedule> PrepareEMISchedule(int noOfInstallment, double interestRate, double loanAmount, DateTime payBackMonth, DateTime issueDate)
|
|
//{
|
|
// try
|
|
// {
|
|
// FMLoanSchedule oSchedule = null;
|
|
|
|
// this.LoanSchedules.Clear();
|
|
|
|
// double nInterest = 0.0;
|
|
// double nTotalInterest = 0.0;
|
|
// double nInsPrinciple = 0.0;
|
|
// double nBalance = 0.0;
|
|
// double nTotalInstPrinciple = 0.0;
|
|
// double nRate = this.InterestRate / 1200.0;
|
|
// double nEffectiveBalance = loanAmount;
|
|
// double nInstAmount = Financial.Pmt(nRate, noOfInstallment, -loanAmount, 0, 0);//DueDate.EndOfPeriod
|
|
// DateTime dNextMonth = new DateTime(payBackMonth.Year, payBackMonth.Month, 25);
|
|
// double extra = 0.0;
|
|
// issueDate = GlobalFunctions.LastDateOfMonth(issueDate);
|
|
|
|
// nTotalInterest = 0;
|
|
// for (int i = 0; i < noOfInstallment; i++)
|
|
// {
|
|
// nInterest = nEffectiveBalance * nRate;
|
|
// //nInterest = (nEffectiveBalance * nRate) / (360 * 30);
|
|
// nTotalInterest = nTotalInterest + nInterest;
|
|
|
|
// if (i == noOfInstallment - 1)
|
|
// {
|
|
// nInsPrinciple = loanAmount - nTotalInstPrinciple;
|
|
// }
|
|
// else
|
|
// {
|
|
// nInsPrinciple = nInstAmount - nInterest;
|
|
// }
|
|
|
|
// nEffectiveBalance = nEffectiveBalance - nInsPrinciple;
|
|
// nTotalInstPrinciple += nInsPrinciple;
|
|
// }
|
|
|
|
// nBalance = loanAmount + nTotalInterest;
|
|
// nEffectiveBalance = loanAmount;
|
|
// double dPrevInstallmentAmount = 0;
|
|
// //nInstAmount = Financial.Pmt(nRate, noOfInstallment, -loanAmount, 0, DueDate.EndOfPeriod);
|
|
// nTotalInterest = 0;
|
|
// nTotalInstPrinciple = 0;
|
|
|
|
// for (int i = 0; i < noOfInstallment; i++)
|
|
// {
|
|
// oSchedule = new FMLoanSchedule();
|
|
|
|
// nInterest = nEffectiveBalance * nRate;
|
|
// //nInterest = ((nEffectiveBalance * (this.InterestRate / 100)) / 360) * 30;
|
|
// nTotalInterest = nTotalInterest + nInterest;
|
|
// oSchedule.SerialNo = i + 1;
|
|
|
|
// if (oSchedule.SerialNo == 1)
|
|
// {
|
|
// dNextMonth = new DateTime(payBackMonth.Year, payBackMonth.Month, 25);
|
|
// }
|
|
// else
|
|
// {
|
|
// dNextMonth = dNextMonth.AddMonths(1);
|
|
// }
|
|
|
|
// if (i == noOfInstallment - 1)
|
|
// {
|
|
// oSchedule.InstallmentPrincipal = loanAmount - nTotalInstPrinciple;
|
|
// }
|
|
// else
|
|
// {
|
|
// oSchedule.InstallmentPrincipal = Math.Round(nInstAmount - nInterest);
|
|
// }
|
|
|
|
// oSchedule.ScheduledPayDate = GlobalFunctions.LastDateOfMonth(dNextMonth);
|
|
// oSchedule.InstallmentInterest = Math.Round(nInterest);
|
|
|
|
// if (i > 0)
|
|
// {
|
|
// nBalance = loanAmount - (dPrevInstallmentAmount);//(oSchedule.InstallmentPrincipal + oSchedule.InstallmentInterest);
|
|
// oSchedule.EffectiveBalance = nBalance;
|
|
// }
|
|
// else
|
|
// {
|
|
// oSchedule.EffectiveBalance = nEffectiveBalance;
|
|
// }
|
|
|
|
// nEffectiveBalance -= oSchedule.InstallmentPrincipal;
|
|
// dPrevInstallmentAmount = dPrevInstallmentAmount + oSchedule.InstallmentPrincipal;
|
|
// nTotalInstPrinciple += oSchedule.InstallmentPrincipal;
|
|
// double totalPayAmount = oSchedule.InstallmentInterest + oSchedule.InstallmentPrincipal;
|
|
// if (totalPayAmount > Math.Round(nInstAmount))
|
|
// {
|
|
// extra += totalPayAmount - Math.Round(nInstAmount);
|
|
// }
|
|
// else if (totalPayAmount < Math.Round(nInstAmount))
|
|
// {
|
|
// extra -= Math.Round(nInstAmount) - totalPayAmount;
|
|
// }
|
|
// if (oSchedule.SerialNo == noOfInstallment && extra != 0)
|
|
// nInstAmount = nInstAmount + extra;
|
|
// oSchedule.InstallmentAmount = Math.Round(nInstAmount);//oSchedule.InstallmentPrincipal + oSchedule.InstallmentInterest;
|
|
|
|
// this.LoanSchedules.Add(oSchedule);
|
|
// }
|
|
// int count = this.LoanSchedules.Count;
|
|
|
|
// FMLoan oloan = new FMLoan();
|
|
// oloan.LoanSchedules = this.LoanSchedules;
|
|
// //AdjustSchedele(oloan, EnumLoanFraction.FractionLastMonth);
|
|
|
|
|
|
// return this.LoanSchedules;
|
|
// }
|
|
// catch (ServiceException e)
|
|
// {
|
|
// throw new Exception(e.Message, e);
|
|
// }
|
|
// //if (fractionate != EnumLoanFraction.WithFraction)
|
|
// //{
|
|
// // AdjustSchedele(fractionate);
|
|
// //}
|
|
//}
|
|
|
|
private void AdjustSchedele(FMLoan oloanIssue, EnumLoanFraction fractionate)
|
|
{
|
|
if (fractionate == EnumLoanFraction.WithFraction) return;
|
|
|
|
double nFraction = 0.0;
|
|
|
|
foreach (FMLoanSchedule item in oloanIssue.LoanSchedules)
|
|
{
|
|
nFraction += item.InstallmentInterest - Math.Floor(item.InstallmentInterest);
|
|
nFraction += item.InstallmentPrincipal - Math.Floor(item.InstallmentPrincipal);
|
|
item.InstallmentPrincipal -= item.InstallmentPrincipal - Math.Floor(item.InstallmentPrincipal);
|
|
item.InstallmentInterest -= item.InstallmentInterest - Math.Floor(item.InstallmentInterest);
|
|
}
|
|
double nequal = 0;
|
|
for (int i = 1; i <= oloanIssue.LoanSchedules.Count - 1; i++)
|
|
{
|
|
if (oloanIssue.LoanSchedules[i - 1].InstallmentAmount != oloanIssue.LoanSchedules[i].InstallmentAmount)
|
|
{
|
|
nequal = oloanIssue.LoanSchedules[i - 1].InstallmentAmount - oloanIssue.LoanSchedules[i].InstallmentAmount;
|
|
oloanIssue.LoanSchedules[i].InstallmentPrincipal = oloanIssue.LoanSchedules[i].InstallmentPrincipal + nequal;
|
|
nFraction = nFraction - nequal;
|
|
}
|
|
}
|
|
nFraction = GlobalFunctions.Round(nFraction);
|
|
if (nFraction != 0 && oloanIssue.LoanSchedules.Count > 0)
|
|
{
|
|
if (fractionate == EnumLoanFraction.FractionFirstMonth)
|
|
{
|
|
if (oloanIssue.InterestRate == 0)
|
|
oloanIssue.LoanSchedules[0].InstallmentInterest += nFraction;
|
|
}
|
|
else if (fractionate == EnumLoanFraction.FractionLastMonth)
|
|
{
|
|
if (oloanIssue.InterestRate == 0)
|
|
oloanIssue.LoanSchedules[oloanIssue.LoanSchedules.Count - 1].InstallmentPrincipal += nFraction;
|
|
else oloanIssue.LoanSchedules[oloanIssue.LoanSchedules.Count - 1].InstallmentInterest += nFraction;
|
|
}
|
|
|
|
//for (int i = 0; i < oloanIssue.LoanSchedules.Count; i++)
|
|
//{
|
|
// // if (i == 9) return;
|
|
// oloanIssue.LoanSchedules[i].ClosingBalance = oloanIssue.LoanSchedules[i].OpeningBalance - (oloanIssue.LoanSchedules[i].InstallmentPrincipal + oloanIssue.LoanSchedules[i].InstallmentInterest);
|
|
// if (i < oloanIssue.LoanSchedules.Count - 1)
|
|
// {
|
|
// oloanIssue.LoanSchedules[i + 1].OpeningBalance = oloanIssue.LoanSchedules[i].ClosingBalance;
|
|
// }
|
|
//}
|
|
}
|
|
|
|
//foreach (FMLoanSchedule item in oloanIssue.LoanSchedules)
|
|
//{
|
|
// item.OpeningBalance = Math.Round(item.OpeningBalance, 2);
|
|
// item.Installment = item.InstallmentPrincipal + item.InstallmentInterest;
|
|
// item.ClosingBalance = Math.Round(item.OpeningBalance - (item.InstallmentPrincipal + item.InstallmentInterest), 2);
|
|
//}
|
|
}
|
|
}
|
|
|
|
public class LoanEarlySettlementAttachment : BasicBaseObject
|
|
{
|
|
#region Constructor
|
|
public LoanEarlySettlementAttachment()
|
|
{
|
|
LoanEarlySettlementAttachmentId = 0;
|
|
LoanId = 0;
|
|
LoanEarlySettlementAttachmentDocType = EnumDocumentType.None;
|
|
FileName = string.Empty;
|
|
FileDataString = string.Empty;
|
|
FileData = null;
|
|
uploadDate = DateTime.MinValue;
|
|
uploadBy = 0;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Properties
|
|
public int LoanEarlySettlementAttachmentId { get; set; }
|
|
public int LoanId { get; set; }
|
|
public EnumDocumentType LoanEarlySettlementAttachmentDocType { get; set; }
|
|
public string FileName { get; set; }
|
|
public byte[] FileData { get; set; }
|
|
public string FileDataString { get; set; }
|
|
public DateTime uploadDate { get; set; }
|
|
public int uploadBy { get; set; }
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
#region Loan Service
|
|
|
|
public interface IFMLoanService
|
|
{
|
|
void UpdateLoanIssueStatus(FMLoan oLoan);
|
|
void Save(FMLoan oLoan);
|
|
void Delete(int loanID);
|
|
FMLoan Get(int loanID, bool isGetSchedule, bool isGetCategory, bool isGetCustomer);
|
|
List<FMLoan> GetByFundType(int FundTypeID);
|
|
DataTable GetLoanList(EnumLoanStatus status, int memberID);
|
|
DataTable GetLoanList(int loanCategoryID, string issueOperator, DateTime issueFromDate, DateTime issueToDate, string collectionOperator, DateTime collectionFromDate, DateTime collectionToDate, EnumLoanStatus status, int memberID, int fundTypeID);
|
|
DataTable GetLoanList(int fundTypeID, string memberID, int loanCategoryID, int loanStatusID, bool isIssueDate, DateTime issueFromDate, DateTime issueToDate);
|
|
string GenerateLoanNo(FMLoan loan);
|
|
DataTable GetLoanMember(int loanCategoryID, string issueOperator, DateTime issueFromDate, DateTime issueToDate, string collectionOperator, DateTime collectionFromDate, DateTime collectionToDate, EnumLoanStatus status, int memberID, int custID, int LoanID, int fundTypeID);
|
|
DataTable GetLoanInfoByMonth(DateTime scheduleMonth, int fundTypeID);
|
|
List<FMLoan> GetLoanObjects(int fundTypeID, string memberID, int loanStatusID);
|
|
FMLoan GetLoanForLoanApplicationDeposit(int MemberID, int InstallmentNo, double PrincipalAmount, DateTime issuefrom, DateTime issueToDate);
|
|
List<FMLoan> GetBySettlementStatus(DateTime fromDate, DateTime toDate, int settleStatus);
|
|
void UpdateEarlySettlement(FMLoan oloan);
|
|
FMLoan Get(int loanid, bool isWithSchedule);
|
|
int GetLoanAppEligibility(int MemberID);
|
|
double GetLoanOustandingAmount(int MemberID);
|
|
void UpdateLoanEarlySettlement(FMLoan oLoan);
|
|
void DepositLoanEarlySettlement(FMLoan oLoan);
|
|
void DoLoanEarlySettlement(FMLoan oLoan);
|
|
|
|
string SendMailToLoanEarlySettlementHR(FMLoan oLoan, EmailSettings emailSettings, int HrID);
|
|
string SendMailToLoanEarlySettleApplicant(FMLoan oLoan, EmailSettings emailSettings);
|
|
List<FMLoan> GetLoansByMemberID(int MemberID);
|
|
FMLoan GetLoanByLoanApplicationID(int LoanApplicationID);
|
|
}
|
|
|
|
#endregion
|
|
}
|