using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; using Ease.CoreV35; using Ease.CoreV35.Model; using Ease.CoreV35.Caching; using System.Data.Linq.Mapping; namespace Payroll.BO { #region LoanSchedule [Serializable] public class LoanSchedule:AuditTrailBase { #region Cache Store private static Cache _cache = new Cache(typeof(LoanSchedule)); #endregion #region Constructor public LoanSchedule() { _loanIssueID = null; _employeeID = null; _scheduleNo = 0; _openingBalance = 0; _installmentPrincipal = 0; _installmentInterest = 0; _dueInstallmentDate = DateTime.MinValue; _paymentDate = null; _days = 0; _calculatedDate = DateTime.MinValue; _actualInterest = 0; _closingBalance = 0; _loanIssue = null; _isPaid = false; _interestRate = 0; } #endregion #region Properties #region LoanIssueID : ID private ID _loanIssueID; public ID LoanIssueID { get { return _loanIssueID; } set { base.OnPropertyChange("LoanIssueID", _loanIssueID, value); _loanIssueID = value; } } #endregion #region EmployeeID : ID private ID _employeeID; public ID EmployeeID { get { return _employeeID; } set { base.OnPropertyChange("EmployeeID", _employeeID, value); _employeeID = value; } } #endregion #region scheduleNo : int private int _scheduleNo; public int ScheduleNo { get { return _scheduleNo; } set { base.OnPropertyChange("scheduleNo", _scheduleNo, value); _scheduleNo = value; } } #endregion #region scheduleNo : int private bool _bPaid; public bool Paid { get { return (_paymentDate!=null); } } #endregion #region openingBalance : double private double _openingBalance; public double OpeningBalance { get { return _openingBalance; } set { base.OnPropertyChange("openingBalance", _openingBalance, value); _openingBalance = value; } } #endregion #region installment : double private double _installment; public double Installment { get { return _installmentPrincipal + _installmentInterest; } } #endregion #region installmentPrincipal : double private double _installmentPrincipal; public double InstallmentPrincipal { get { return _installmentPrincipal; } set { base.OnPropertyChange("installmentPrincipal", _installmentPrincipal, value); _installmentPrincipal = value; } } #endregion #region installmentInterest : double private double _installmentInterest; public double InstallmentInterest { get { return _installmentInterest; } set { base.OnPropertyChange("installmentInterest", _installmentInterest, value); _installmentInterest = value; } } #endregion #region dueInstallmentDate : DateTime private DateTime _dueInstallmentDate; public DateTime DueInstallmentDate { get { return _dueInstallmentDate; } set { base.OnPropertyChange("dueInstallmentDate", _dueInstallmentDate, value); _dueInstallmentDate = value; } } #endregion #region paymentDate : System.DateTime private DateTime? _paymentDate; public DateTime? PaymentDate { get { return _paymentDate; } set { base.OnPropertyChange("paymentDate", _paymentDate, value); _paymentDate = value; } } #endregion #region paymentDate : System.DateTime private EnumLoanPaymentMode _paymentMode; public EnumLoanPaymentMode PaymentMode { get { return _paymentMode; } set { base.OnPropertyChange("PaymentMode",(short) _paymentMode,(short) value); _paymentMode = value; } } #endregion #region days : int private int _days; public int Days { get { return _days; } set { base.OnPropertyChange("days", _days, value); _days = value; } } #endregion #region calculatedDate : DateTime private DateTime _calculatedDate; public DateTime CalculatedDate { get { return _calculatedDate; } set { base.OnPropertyChange("calculatedDate", _calculatedDate, value); _calculatedDate = value; } } #endregion #region actualInterest : double private double _actualInterest; public double ActualInterest { get { return _actualInterest; } set { base.OnPropertyChange("actualInterest", _actualInterest, value); _actualInterest = value; } } #endregion #region closingBalance : double private double _closingBalance; public double ClosingBalance { get { return _closingBalance; } set { base.OnPropertyChange("closingBalance", _closingBalance, value); _closingBalance = value; } } #endregion #region loanIssue : LoanIssue private LoanIssue _loanIssue; public LoanIssue LoanIssue { get { if (_loanIssueID.Integer > 0 && _loanIssue == null) { _loanIssue = new LoanIssue(); _loanIssue = LoanIssue.Get(_loanIssueID); } return this._loanIssue; } set { _loanIssue = value; } } #endregion #region IsPaid : bool private bool _isPaid; public bool IsPaid { get { return _isPaid; } set { base.OnPropertyChange("IsPaid", _isPaid, value); _isPaid = value; } } #endregion #region InterestRate : double private double _interestRate; public double InterestRate { get { return _interestRate; } set { base.OnPropertyChange("InterestRate", _interestRate, value); _interestRate = value; } } #endregion #region Service Factory ILoanScheduleService : ILoanScheduleService internal static ILoanScheduleService Service { get { return Services.Factory.CreateService(typeof(ILoanScheduleService)); } } #endregion #endregion #region Functions public static LoanSchedule Get(ID nID) { LoanSchedule oLoanSchedule = null; #region Cache Header oLoanSchedule = (LoanSchedule)_cache["Get", nID]; if (oLoanSchedule != null) return oLoanSchedule; #endregion oLoanSchedule = LoanSchedule.Service.Get(nID); #region Cache Footer _cache.Add(oLoanSchedule, "Get", nID); #endregion return oLoanSchedule; } public static DataSet GetByEmpIDANDLoanID(int EmpID, int LoanID) { DataSet ds = null; try { ds = Service.GetByEmpIDANDLoanID(EmpID, LoanID); } catch (Exception e) { throw new Exception(e.Message, e); } return ds; } public static ObjectsTemplate Get() { #region Cache Header ObjectsTemplate loanSchedules = _cache["Get"] as ObjectsTemplate; if (loanSchedules != null) return loanSchedules; #endregion try { loanSchedules = Service.Get(); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(loanSchedules, "Get"); #endregion return loanSchedules; } public void setId(ID newId) { this.SetID(newId); } public static ObjectsTemplate GetByIssueIDAndMonth(ID nIssueID, DateTime dateTime) { #region Cache Header ObjectsTemplate loanSchedules = _cache["GetByIssueIDAndMonth", nIssueID, dateTime] as ObjectsTemplate; if (loanSchedules != null) return loanSchedules; #endregion try { loanSchedules = Service.GetByIssueIDAndMonth(nIssueID, dateTime); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(loanSchedules, "GetByIssueIDAndMonth", nIssueID, dateTime); #endregion return loanSchedules; } public static DataSet GetLoanPaymentDue(DateTime dFromDate, DateTime dToDate) { DataSet loanSchedules = null; try { loanSchedules = Service.GetLoanPaymentDue(dFromDate, dToDate); } catch (ServiceException e) { throw new Exception(e.Message, e); } return loanSchedules; } public static ObjectsTemplate GetByIssueID(ID nIssueID) { #region Cache Header ObjectsTemplate loanSchedules = _cache["GetByIssueID", nIssueID] as ObjectsTemplate; if (loanSchedules != null) return loanSchedules; #endregion try { loanSchedules = Service.GetByIssueID(nIssueID); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(loanSchedules, "GetByIssueID", nIssueID); #endregion return loanSchedules; } public ID Save() { return LoanSchedule.Service.Save(this); } public void Delete() { LoanSchedule.Service.Delete(ID); } #endregion } #endregion #region ILoanSchedule Service public interface ILoanScheduleService { LoanSchedule Get(ID id); DataSet GetByEmpIDANDLoanID(int EmpID, int LoanID); ObjectsTemplate Get(); ID Save(LoanSchedule item); void Delete(ID id); ObjectsTemplate GetByIssueID(ID nIssueID); ObjectsTemplate GetByIssueIDAndMonth(ID nIssueID, DateTime dateTime); DataSet GetLoanPaymentDue(DateTime dFromDate,DateTime dToDate); DataSet GetScheduleForSalary(DateTime monthDate, ID payrollTypeID); } #endregion }