using System; using System.Collections.Generic; using System.Linq; using System.Text; using Ease.CoreV35; using Ease.CoreV35.Model; using Ease.CoreV35.Caching; using System.Data.Linq.Mapping; namespace Payroll.BO { #region JVSetup [Serializable] public class JVSetup : BasicBaseObject { public delegate void ItemChanged(); #region Cache Store private static Cache _cache = new Cache(typeof(JVSetup)); #endregion #region Constructor public JVSetup() { _description = string.Empty; _gLCode = string.Empty; _isConfirmed = false; _isEmployeeDetail = false; _jvTypeID = null; _monthDate = DateTime.MinValue; _sequenceNo = 0; _showCC = false; _bookToCC = false; _bookToPC = false; _side = (int)EnumSide.Add; _sideCode = string.Empty; _jvSetupDetails = null; _EmpType = EnumJVEmpType.RegardLess; } #endregion #region Properties #region Description private string _description; public string Description { get { return _description; } set { base.OnPropertyChange("description", _description, value); _description = value; } } #endregion #region GLCode private string _gLCode; public string GLCode { get { return _gLCode; } set { base.OnPropertyChange("glCode", _gLCode, value); _gLCode = value; } } #endregion #region IsConfirmed private bool _isConfirmed; public bool IsConfirmed { get { return _isConfirmed; } set { base.OnPropertyChange("isConfirmed", _isConfirmed, value); _isConfirmed = value; } } #endregion #region IsEmployeeDetail private bool _isEmployeeDetail; public bool IsEmployeeDetail { get { return _isEmployeeDetail; } set { base.OnPropertyChange("isEmployeeDetail", _isEmployeeDetail, value); _isEmployeeDetail = value; } } #endregion #region JVTypeID private ID _jvTypeID; public ID JVTypeID { get { return _jvTypeID; } set { base.OnPropertyChange("jvTypeID", _jvTypeID, value); _jvTypeID = value; } } #endregion #region EmployeeID private ID _EmployeeID; public ID EmployeeID { get { return _EmployeeID; } set { base.OnPropertyChange("EmployeeID", _EmployeeID, value); _EmployeeID = value; } } #endregion #region jvType : JVType private JVType _jvType; public JVType JVType { get { if (JVTypeID.Integer > 0) { _jvType = new JVType(); _jvType = JVType.Get(JVTypeID); } return _jvType; } set { _jvType = value; } } #endregion #region MonthDate private DateTime _monthDate; public DateTime MonthDate { get { return _monthDate; } set { base.OnPropertyChange("monthDate", _monthDate, value); _monthDate = value; } } #endregion #region SequenceNo private int _sequenceNo; public int SequenceNo { get { return _sequenceNo; } set { base.OnPropertyChange("sequenceNo", _sequenceNo, value); _sequenceNo = value; } } #endregion #region ShowCC private bool _showCC; public bool ShowCC { get { return _showCC; } set { base.OnPropertyChange("showCC", _showCC, value); _showCC = value; } } #endregion #region BookToCC private bool _bookToCC; public bool BookToCC { get { return _bookToCC; } set { base.OnPropertyChange("BookToCC", _bookToCC, value); _bookToCC = value; } } #endregion #region BookToPC private bool _bookToPC; public bool BookToPC { get { return _bookToPC; } set { base.OnPropertyChange("BookToPC", _bookToPC, value); _bookToPC = value; } } #endregion #region Side private int _side; public int Side { get { return _side; } set { base.OnPropertyChange("side", _side, value); _side = value; } } #endregion #region SideCode private string _sideCode; public string SideCode { get { return _sideCode; } set { base.OnPropertyChange("sideCode", _sideCode, value); _sideCode = value; } } #endregion #region GroupCode private string _GroupCode=""; public string GroupCode { get { return _GroupCode; } set { base.OnPropertyChange("GroupCode", _GroupCode, value); _GroupCode = value; } } #endregion #region payrollTypeID : ID private ID _payrollTypeID; public ID PayrollTypeID { get { return _payrollTypeID; } set { base.OnPropertyChange("payrollTypeID", _payrollTypeID, value); _payrollTypeID = value; } } #endregion #region EMPLOYEETYPE : EnumJVEmpType private EnumJVEmpType _EmpType; public EnumJVEmpType EMPLOYEETYPE { get { return _EmpType; } set { _EmpType = value; } } #endregion #region Property JVSetupDetails : ObjectsTemplate private ObjectsTemplate _jvSetupDetails; public ObjectsTemplate JVSetupDetails { get { if (_jvSetupDetails == null && !this.ID.IsUnassigned && this.ID.Integer > 0) { _jvSetupDetails = JVSetupDetail.GetByJVSetup(this.ID); } if (_jvSetupDetails == null) { _jvSetupDetails = new ObjectsTemplate(); } return _jvSetupDetails; } set { _jvSetupDetails = value; } } #endregion Property JVSetupDetails : ObjectsTemplate #region JVSetupCC : ObjectsTemplate private ObjectsTemplate _jvSetupCCs; public ObjectsTemplate JVSetupCC { get { if (_jvSetupCCs == null && !this.ID.IsUnassigned && this.ID.Integer > 0) { _jvSetupCCs = Payroll.BO.JVSetupCC.GetByJVSetup(this.ID); } //if (_jvSetupDetails == null) //{ // _jvSetupCCs = new ObjectsTemplate(); //} return _jvSetupCCs; } set { _jvSetupCCs = value; } } #endregion #endregion #region Functions public double GetAmount(SalaryMonthly salary, ObjectsTemplate jvsetupdetails) { double nAmount = 0; foreach (JVSetupDetail oItem in jvsetupdetails) { switch (oItem.JVItemType) { case enumPayrollComponentType.Ordinary_Hour: nAmount = nAmount + salary.GetGrossAmount(EnumSalaryItemCode.Basic_Salary, (int)EnumSalaryItemCode.Basic_Salary); break; case enumPayrollComponentType.Allowance: nAmount = nAmount + salary.GetGrossAmount(EnumSalaryItemCode.Allowance, oItem.ItemID.Integer); break; case enumPayrollComponentType.Deduction: nAmount = nAmount + salary.GetDeductAmount(EnumSalaryItemCode.Deduction, oItem.ItemID.Integer); break; case enumPayrollComponentType.Over_Time: nAmount = nAmount + salary.GetGrossAmount(EnumSalaryItemCode.Over_Time_Amount, oItem.ItemID.Integer); break; case enumPayrollComponentType.Bonus: nAmount = nAmount + salary.GetGrossAmount(EnumSalaryItemCode.Bonus, oItem.ItemID.Integer); break; case enumPayrollComponentType.Loan: nAmount = nAmount + salary.GetAmount(EnumSalaryGroup.Deductions, EnumSalaryItemCode.Loan_Monthly_Installment, oItem.ItemID.Integer); break; case enumPayrollComponentType.LoanInterest: nAmount = nAmount + salary.GetAmount(EnumSalaryGroup.Deductions, EnumSalaryItemCode.Loan_Monthly_Interest, oItem.ItemID.Integer); break; case enumPayrollComponentType.PF: nAmount = nAmount + salary.GetDeductAmount(EnumSalaryItemCode.PF_Contribution, (int)EnumSalaryItemCode.PF_Contribution); break; case enumPayrollComponentType.CPF: nAmount = nAmount + salary.GetDeductAmount(EnumSalaryItemCode.PF_Contribution, (int)EnumSalaryItemCode.PF_Contribution) * 2; break; case enumPayrollComponentType.Gratuity: //nAmount = nAmount + salary.GetAmount(EnumSalaryGroup.Deductions, EnumSalaryItemCode.OPI, oItem.ItemID.Integer); break; case enumPayrollComponentType.IncomeTax: bool isOtherItem = ConfigurationManager.GetBoolValue("incometax", "taxissalaryotheritem", EnumConfigurationType.Logic); if (isOtherItem == false) nAmount = nAmount + salary.GetAmount(EnumSalaryGroup.Deductions, EnumSalaryItemCode.Inc_Tax_Deduction, (int)EnumSalaryItemCode.Inc_Tax_Deduction); else nAmount = nAmount + salary.GetAmount(EnumSalaryGroup.OtherItem, EnumSalaryItemCode.Inc_Tax_Deduction, (int)EnumSalaryItemCode.Inc_Tax_Deduction); break; case enumPayrollComponentType.Net_pay: if (salary.BranchID != null && oItem.ItemID == salary.BranchID) nAmount = nAmount + salary.GetAmount(EnumSalaryGroup.OtherItem, EnumSalaryItemCode.Net_Payable, (int)EnumSalaryItemCode.Net_Payable); break; //case enumPayrollComponentType.OPI: // nAmount = nAmount + salary.GetAmount(EnumSalaryGroup.OtherItem, EnumSalaryItemCode.OPI, oItem.ItemID.Integer); // break; case enumPayrollComponentType.Final_settlement: break; default: break; } } return nAmount; } public double GetAmount(FSTran ofsTran, ObjectsTemplate jvsetupdetails) { double nAmount = 0; foreach (JVSetupDetail oItem in jvsetupdetails) { switch (oItem.JVItemType) { case enumPayrollComponentType.Ordinary_Hour: nAmount = nAmount + ofsTran.GetAmount(EnumFSItemCode.FractionateSalary, (int)EnumSalaryItemCode.Basic_Salary); nAmount = nAmount + ofsTran.GetAmount(EnumFSItemCode.Gross, (int)EnumSalaryItemCode.Basic_Salary); break; case enumPayrollComponentType.Allowance: nAmount = nAmount + ofsTran.GetAmount(EnumFSItemCode.FractionateSalary, oItem.ItemID.Integer); nAmount = nAmount + ofsTran.GetAmount(EnumFSItemCode.Gross, oItem.ItemID.Integer); break; case enumPayrollComponentType.Deduction: nAmount = nAmount + ofsTran.GetAmount(EnumFSItemCode.FractionateSalary, oItem.ItemID.Integer); nAmount = nAmount + ofsTran.GetAmount(EnumFSItemCode.Gross, oItem.ItemID.Integer); break; case enumPayrollComponentType.Over_Time: nAmount = nAmount + ofsTran.GetAmount(EnumFSItemCode.OT, oItem.ItemID.Integer); break; case enumPayrollComponentType.Bonus: nAmount = nAmount + ofsTran.GetAmount(EnumFSItemCode.Bonus, oItem.ItemID.Integer); break; case enumPayrollComponentType.Loan: nAmount = nAmount + ofsTran.GetAmount(EnumFSItemCode.Loan, oItem.ItemID.Integer); break; case enumPayrollComponentType.PF: nAmount = nAmount + ofsTran.GetAmount(EnumFSItemCode.PF, (int)EnumFSItemCode.PF); break; case enumPayrollComponentType.CPF: nAmount = nAmount + ofsTran.GetAmount(EnumFSItemCode.CPF, (int)EnumFSItemCode.CPF); break; case enumPayrollComponentType.Gratuity: nAmount = nAmount + ofsTran.GetAmount(EnumFSItemCode.Gratuity, (int)EnumFSItemCode.Gratuity); break; case enumPayrollComponentType.IncomeTax: nAmount = nAmount + ofsTran.TaxAmount; break; //case enumPayrollComponentType.Net_pay: // if (salary.BranchID != null && oItem.ItemID == salary.BranchID) // nAmount = nAmount + salary.GetAmount(EnumSalaryGroup.OtherItem, EnumSalaryItemCode.Net_Payable, (int)EnumSalaryItemCode.Net_Payable); // break; case enumPayrollComponentType.Final_settlement: case enumPayrollComponentType.OPI: nAmount = nAmount + ofsTran.GetAmount(EnumFSItemCode.Other, oItem.ItemID.Integer); break; case enumPayrollComponentType.Earn_Leave: nAmount = nAmount + ofsTran.GetAmount(EnumFSItemCode.Leave, (int)EnumFSItemCode.Leave); break; //case enumPayrollComponentType.Final_settlement: // break; default: break; } } return nAmount; } public double GetAmount(SalaryMonthly salary) { double nAmount = 0; foreach (JVSetupDetail oItem in this.JVSetupDetails) { switch (oItem.JVItemType) { case enumPayrollComponentType.Ordinary_Hour: nAmount = nAmount + salary.GetGrossAmount(EnumSalaryItemCode.Basic_Salary, (int)EnumSalaryItemCode.Basic_Salary); break; case enumPayrollComponentType.Allowance: nAmount = nAmount + salary.GetAmount(EnumSalaryGroup.Gross,EnumSalaryItemCode.Allowance,oItem.ItemID.Integer); break; case enumPayrollComponentType.Deduction: nAmount = nAmount + salary.GetDeductAmount(EnumSalaryItemCode.Deduction, oItem.ItemID.Integer); break; case enumPayrollComponentType.Over_Time: nAmount = nAmount + salary.GetAmount(EnumSalaryGroup.Gross,EnumSalaryItemCode.Over_Time_Amount, oItem.ItemID.Integer); break; case enumPayrollComponentType.Bonus: nAmount = nAmount + salary.GetGrossAmount(EnumSalaryItemCode.Bonus, oItem.ItemID.Integer); break; case enumPayrollComponentType.Loan: nAmount = nAmount + salary.GetAmount(EnumSalaryGroup.Deductions, EnumSalaryItemCode.Loan_Monthly_Installment, oItem.ItemID.Integer); break; case enumPayrollComponentType.LoanInterest: nAmount = nAmount + salary.GetAmount(EnumSalaryGroup.Deductions, EnumSalaryItemCode.Loan_Monthly_Interest, oItem.ItemID.Integer); break; case enumPayrollComponentType.PF: nAmount = nAmount + salary.GetAmount(EnumSalaryGroup.Deductions, EnumSalaryItemCode.PF_Contribution, (int)EnumSalaryItemCode.PF_Contribution); break; case enumPayrollComponentType.Gratuity: //nAmount = nAmount + salary.GetAmount(EnumSalaryGroup.Deductions, EnumSalaryItemCode., oItem.ItemID.Integer); break; case enumPayrollComponentType.IncomeTax: nAmount = nAmount + salary.GetAmount(EnumSalaryGroup.Deductions, EnumSalaryItemCode.Inc_Tax_Deduction, (int)EnumSalaryItemCode.Inc_Tax_Deduction); break; case enumPayrollComponentType.Net_pay: if (salary.BranchID !=null && oItem.ItemID == salary.BranchID) nAmount = nAmount + salary.GetAmount(EnumSalaryGroup.OtherItem, EnumSalaryItemCode.Net_Payable, (int) EnumSalaryItemCode.Net_Payable); break; case enumPayrollComponentType.Net_pay_Cash: if (salary.AccountNo=="") nAmount = nAmount + salary.GetAmount(EnumSalaryGroup.OtherItem, EnumSalaryItemCode.Net_Payable, (int)EnumSalaryItemCode.Net_Payable); break; case enumPayrollComponentType.OPI: nAmount = nAmount + salary.GetAmount(EnumSalaryGroup.OtherItem, EnumSalaryItemCode.OPI, oItem.ItemID.Integer); break; case enumPayrollComponentType.Final_settlement: break; default: break; } } return nAmount; } public JVSetup Get(ID nJVSetupID) { JVSetup oJVSetup = null; #region Cache Header oJVSetup = (JVSetup)_cache["Get", nJVSetupID]; if (oJVSetup != null) return oJVSetup; #endregion oJVSetup = JVSetup.Service.Get(nJVSetupID); #region Cache Footer _cache.Add(oJVSetup, "Get", nJVSetupID); #endregion return oJVSetup; } public static ObjectsTemplate Get() { #region Cache Header ObjectsTemplate jvsetups = _cache["Get"] as ObjectsTemplate; if (jvsetups != null) return jvsetups; #endregion try { jvsetups = Service.Get(); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(jvsetups, "Get"); #endregion return jvsetups; } public static ObjectsTemplate GetByJVType(ID jvSetupID) { #region Cache Header ObjectsTemplate jvsetups = _cache["GetByJVType", jvSetupID] as ObjectsTemplate; if (jvsetups != null) return jvsetups; #endregion try { jvsetups = Service.GetByJVType(jvSetupID); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(jvsetups, "GetByJVType", jvSetupID); #endregion return jvsetups; } public static ObjectsTemplate GetByJVTypeAndEffectDate(ID jvSetupID, DateTime dEffectDate) { #region Cache Header ObjectsTemplate jvsetups = _cache["GetByJVTypeAndEffectDate", jvSetupID, dEffectDate] as ObjectsTemplate; if (jvsetups != null) return jvsetups; #endregion try { jvsetups = Service.GetByJVTypeAndEffectDate(jvSetupID, dEffectDate); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(jvsetups, "GetByJVTypeAndEffectDate", jvSetupID, dEffectDate); #endregion return jvsetups; } public static ObjectsTemplate GetByMonthDate(DateTime dtMonthDate) { #region Cache Header ObjectsTemplate jvsetups = _cache["GetByMonthDate", dtMonthDate] as ObjectsTemplate; if (jvsetups != null) return jvsetups; #endregion try { jvsetups = Service.GetByMonthDate(dtMonthDate); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(jvsetups, "GetByMonthDate", dtMonthDate); #endregion return jvsetups; } public static ObjectsTemplate GetChildByParentID(ID JVSetupID) { #region Cache Header ObjectsTemplate jvsetupdetails = _cache["GetChildByParentID", JVSetupID] as ObjectsTemplate; if (jvsetupdetails != null) return jvsetupdetails; #endregion try { jvsetupdetails = Service.GetChildByParentID(JVSetupID); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(jvsetupdetails, "GetChildByParentID", JVSetupID); #endregion return jvsetupdetails; } public static ObjectsTemplate GetByJVTypeAndMonth(ID jvTypeID, DateTime dDate) { #region Cache Header ObjectsTemplate jvsetups = _cache["GetByJVTypeAndMonth", jvTypeID, dDate] as ObjectsTemplate; if (jvsetups != null) return jvsetups; #endregion try { jvsetups = Service.GetByJVTypeAndMonth(jvTypeID, dDate); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(jvsetups, "GetByJVTypeAndMonth", jvTypeID, dDate); #endregion return jvsetups; } public int GetSequenceNo() { int nSeq = 0; nSeq = JVSetup.Service.GetSequenceNo(); return nSeq; } public DateTime GetMaxDate(DateTime dGivenDate) { DateTime dMaxDate = DateTime.Now; dMaxDate = JVSetup.Service.GetMaxDate(dGivenDate); return dMaxDate; } public ID Save() { this.SetAuditTrailProperties(); return JVSetup.Service.Save(this); } public void UpdateSequence(ObjectsTemplate jvSetups) { JVSetup.Service.UpdateSequence(jvSetups); } public void Delete() { JVSetup.Service.Delete(this.ID); } #endregion #region Service Factory internal static IJVSetupService Service { get { return Services.Factory.CreateService(typeof(IJVSetupService)); } } #endregion } #endregion #region IJVSetup Service public interface IJVSetupService { JVSetup Get(ID id); ObjectsTemplate Get(); ObjectsTemplate GetByJVType(ID jvSetupID); ObjectsTemplate GetByJVTypeAndEffectDate(ID jvSetupID, DateTime dEffectDate); int GetSequenceNo(); DateTime GetMaxDate(DateTime dGivenDate); ObjectsTemplate GetByMonthDate(DateTime dtMonthDate); ObjectsTemplate GetChildByParentID(ID JVSetupID); ObjectsTemplate GetByJVTypeAndMonth(ID jvTypeID, DateTime lastDate); ID Save(JVSetup oJVSetup); void UpdateSequence(ObjectsTemplate oJVSetups); void Delete(ID id); } #endregion }