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 { public enum enumIncomeTaxItemType { None =0, Basic_Salary=1, Allowance=2, Deduction=3, OT=4, Bonus=5, Earned_Leave=6, PF=7, OPI=8, AdjustItem=9, FinalSettlement=10, Other=11 } #region IncomeTax [Serializable] public class IncomeTax : AuditTrailBase { #region Cache Store private static Cache _cache = new Cache(typeof(IncomeTax)); #endregion #region Constructor public IncomeTax() { _employeeID = null; _itemID = 0; _previousAmount = 0; _thisMonthAmount = 0; _projectedAmount = 0; _totalAmount = 0; _taxParameterID = null; _position = 0; _description = string.Empty; _itemGroup = EnumIncomeTaxItemGroup.Other_Allowance; _side = EnumIncomeTaxSide.Tax_Info_Item; _datato = EnumIncomeTaxDataFrom.ProcessTempData; } #endregion #region Properties #region EmployeeID : ID private ID _employeeID; public ID EmployeeID { get { return _employeeID; } set { base.OnPropertyChange("EmployeeID", _employeeID, value); _employeeID = value; } } #endregion #region itemID : int private int _itemID; public int ItemID { get { return _itemID; } set { base.OnPropertyChange("itemCode", _itemID, value); _itemID = value; } } #endregion #region previousAmount : double private double _previousAmount; public double PreviousAmount { get { return _previousAmount; } set { base.OnPropertyChange("previousAmount", _previousAmount, value); _previousAmount = value; //if (_datato == EnumIncomeTaxDataFrom.ProcessedData) // _totalAmount = _totalAmount + value; } } #endregion #region thisMonthAmount : double private double _thisMonthAmount; public double ThisMonthAmount { get { return _thisMonthAmount; } set { base.OnPropertyChange("thisMonthAmount", _thisMonthAmount, value); _thisMonthAmount = value; //if (_datato == EnumIncomeTaxDataFrom.ProcessedData) // _totalAmount = _totalAmount + value; } } #endregion #region projectedAmount : double private double _projectedAmount; public double ProjectedAmount { get { return _projectedAmount; } set { base.OnPropertyChange("projectedAmount", _projectedAmount, value); _projectedAmount = value; //if (_datato == EnumIncomeTaxDataFrom.ProcessedData) // _totalAmount = _totalAmount + value; } } #endregion #region totalAmount : double private double _totalAmount; public double TotalAmount { get { if (_datato != EnumIncomeTaxDataFrom.ProcessedData) _totalAmount = _thisMonthAmount + _previousAmount + _projectedAmount; return _totalAmount; } set { _totalAmount = value; } } #endregion #region Data : enum private EnumIncomeTaxDataFrom _datato; public EnumIncomeTaxDataFrom DataTo { get { return _datato; } set { _datato = value; } } #endregion #region TaxParameterID : ID private ID _taxParameterID; public ID TaxParameterID { get { return _taxParameterID; } set { base.OnPropertyChange("TaxParameterID", _taxParameterID, value); _taxParameterID = value; } } #endregion #region position : int private int _position; public int Position { get { return _position; } set { base.OnPropertyChange("position", _position, value); _position = value; } } #endregion #region description : string private string _description; public string Description { get { return _description; } set { base.OnPropertyChange("description", _description, value); _description = value; } } #endregion #region IsChanged : bool private bool _isChanged; public bool IsChanged { get { return _isChanged; } set { base.OnPropertyChange("IsChanged", _isChanged, value); _isChanged = value; } } #endregion #region itemGroup : EnumIncomeTaxItemCode private EnumIncomeTaxItemGroup _itemGroup; public EnumIncomeTaxItemGroup ItemGroup { get { return _itemGroup; } set { base.OnPropertyChange("itemGroup",(short) _itemGroup, (short)value); _itemGroup = value; } } #endregion #region side : EnumIncomeTaxGroup private EnumIncomeTaxSide _side; public EnumIncomeTaxSide Side { get { return _side; } set { base.OnPropertyChange("side",(short) _side, (short)value); _side = value; } } #endregion #region Service Factory IIncomeTaxService : IIncomeTaxService internal static IIncomeTaxService Service { get { return Services.Factory.CreateService(typeof(IIncomeTaxService)); } } #endregion #endregion #region Functions public static ObjectsTemplate Get(ID employeeid, EnumIncomeTaxDataFrom dataFrom) { ObjectsTemplate incomeTaxs = null; try { incomeTaxs = Service.Get(employeeid, dataFrom); } catch (ServiceException e) { throw new Exception(e.Message, e); } return incomeTaxs; } public static DataSet GetByEmpID(EnumIncomeTaxDataFrom dataFrom,ID employeeid) { DataSet incomeTaxs = null; try { incomeTaxs = Service.GetByEmpID(dataFrom,employeeid); } catch (ServiceException e) { throw new Exception(e.Message, e); } return incomeTaxs; } public static DataSet GetEmpIDforOthTax(EnumIncomeTaxDataFrom dataFrom,ID employeeid) { DataSet incomeTaxs = null; try { incomeTaxs = Service.GetEmpIDforOthTax(dataFrom,employeeid); } catch (ServiceException e) { throw new Exception(e.Message, e); } return incomeTaxs; } public static ObjectsTemplate Get(EnumIncomeTaxDataFrom dataFrom) { ObjectsTemplate incomeTaxs = null; try { incomeTaxs = Service.Get(dataFrom,Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer); } catch (ServiceException e) { throw new Exception(e.Message, e); } return incomeTaxs; } public static ObjectsTemplate Get(EnumIncomeTaxDataFrom dataFrom, ID nEmpID, ID nTaxParamID) { ObjectsTemplate incomeTaxs = null; try { incomeTaxs = Service.Get(dataFrom, nEmpID, nTaxParamID); } catch (ServiceException e) { throw new Exception(e.Message, e); } return incomeTaxs; } //Income Tax From Old Table public static ObjectsTemplate GetOldIncomeTax(EnumIncomeTaxDataFrom dataFrom, ID nEmpID, ID nTaxParamID) { ObjectsTemplate incomeTaxs = null; try { incomeTaxs = Service.GetOldIncomeTax(dataFrom, nEmpID, nTaxParamID); } catch (ServiceException e) { throw new Exception(e.Message, e); } return incomeTaxs; } public static IncomeTax Get(EnumIncomeTaxDataFrom dataFrom, ID nEmpID, EnumIncomeTaxItemGroup groupCode, int itemID) { IncomeTax incomeTax = null; try { incomeTax = Service.Get(dataFrom, nEmpID, groupCode,itemID); } catch (ServiceException e) { throw new Exception(e.Message, e); } return incomeTax; } public static ObjectsTemplate GetPrvYear( ID taxparameterId, EnumIncomeTaxItemGroup groupCode, int itemId) { ObjectsTemplate incomeTaxs = null; try { incomeTaxs = Service.GetPrvYear(taxparameterId, groupCode, itemId); } catch (ServiceException e) { throw new Exception(e.Message, e); } return incomeTaxs; } public static ObjectsTemplate GetPrvYear( ID taxparameterId) { ObjectsTemplate incomeTaxs = null; try { incomeTaxs = Service.GetPrvYear(taxparameterId, Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer); } catch (ServiceException e) { throw new Exception(e.Message, e); } return incomeTaxs; } public static ObjectsTemplate GetPrvYear( ID taxparameterId,ID empID) { ObjectsTemplate incomeTaxs = null; try { incomeTaxs = Service.GetPrvYear(taxparameterId, Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer,empID.Integer); } catch (ServiceException e) { throw new Exception(e.Message, e); } return incomeTaxs; } //public static IncomeTax Get(ObjectsTemplate Incometaxs, // EnumIncomeTaxItemGroup groupCode, int itemId) //{ // IncomeTax ReturnItem = Incometaxs.Find(delegate(IncomeTax taxItem) // { // return taxItem.ItemGroup == EnumIncomeTaxItemGroup.Investment // && taxItem.ItemID == (int)EnumIncomeTaxItemGroup.Investment; // }); // return ReturnItem; //} public EnumIncomeTaxDataFrom GetEnumForSalaryIT(ID nEmpID) { EnumIncomeTaxDataFrom nType; bool isprocessed = false, isfinalized = false; SalaryMonthly.Service.IsSalaryProcessedAndFinalized(nEmpID, SystemInformation.CurrentSysInfo.NextPayProcessDate, ref isprocessed, ref isfinalized); if (isprocessed == true && isfinalized == false) { nType = EnumIncomeTaxDataFrom.SalaryITTempData; } else { nType = EnumIncomeTaxDataFrom.ProcessTempData; } return nType; } //public bool IsFromSalaryTempIT(ID nEmpID) //{ // bool bValid; // bValid = SalaryMonthly.IsSalaryProcessed(nEmpID,SystemInformation.CurrentSysInfo.NextPayProcessDate); // return bValid; //} public static IncomeTax Get(ObjectsTemplate Incometaxs, ID employeeId, EnumIncomeTaxItemGroup groupCode, int itemId) { IncomeTax ReturnItem = Incometaxs.Find(delegate(IncomeTax taxItem) { return taxItem.EmployeeID.Integer ==employeeId.Integer && taxItem.ItemGroup == groupCode && taxItem.ItemID == itemId; }); return ReturnItem; } public static ObjectsTemplate Get(ObjectsTemplate Incometaxs, ID employeeId) { ObjectsTemplate Items = new ObjectsTemplate(); foreach (IncomeTax item in Incometaxs) { if (item.EmployeeID.Integer == employeeId.Integer) Items.Add(item); } return Items; } public static double GetAmount(ObjectsTemplate Incometaxs, ID employeeId, EnumIncomeTaxItemGroup groupCode) { double amount=0; foreach (IncomeTax item in Incometaxs) { if (item.ItemGroup == groupCode && item.EmployeeID == employeeId) amount = amount + item.TotalAmount; } return amount; } public ID Save(EnumIncomeTaxDataFrom savto) { return IncomeTax.Service.Save(this, savto); } public static void Save(ObjectsTemplate _IncomeTaxs, EnumIncomeTaxDataFrom saveto) { foreach (IncomeTax item in _IncomeTaxs) item.SetAuditTrailProperties(); IncomeTax.Service.Save(_IncomeTaxs,saveto); } public static void UpdateOT(ObjectsTemplate otProcess) { IncomeTax.Service.UpdateOT(otProcess); } public void Delete(ID nEmpID,EnumIncomeTaxDataFrom deletefrom,EnumIncomeTaxItemGroup ItemGroup,int ItemID) { IncomeTax.Service.Delete(nEmpID, deletefrom,ItemGroup,ItemID); } public void DeleteYearlyData(ID TaxParamID, EnumIncomeTaxDataFrom deletefrom, ID nEmpID, EnumIncomeTaxItemGroup ItemGroup, int ItemID) { IncomeTax.Service.DeleteYearlyData(TaxParamID,deletefrom,nEmpID,ItemGroup,ItemID ); } public void DoYearEnd(ObjectsTemplate IncomeTaxes) { IncomeTax.Service.DoTaxYearEnd(IncomeTaxes, SystemInformation.CurrentSysInfo.PayrollTypeID); } public void DoYearEndReProcess(ObjectsTemplate IncomeTaxes, ID taxParameterID) { IncomeTax.Service.DoYearEndReProcess(IncomeTaxes, taxParameterID, Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer); } public void DoYearEndReProcess2(ObjectsTemplate IncomeTaxes, ID taxParameterID) { IncomeTax.Service.DoYearEndReProcess2(IncomeTaxes, taxParameterID); } public void DoTaxTempReProcess(ObjectsTemplate IncomeTaxes, ID taxParameterID, EnumIncomeTaxDataFrom saveTo) { IncomeTax.Service.DoTaxTempReProcess(IncomeTaxes, taxParameterID, saveTo, Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer); } public static ObjectsTemplate GetByYear( ID taxparameterId, EnumIncomeTaxDataFrom dataFrom) { ObjectsTemplate incomeTaxs = null; try { incomeTaxs = Service.GetByYear(taxparameterId, dataFrom, Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer); } catch (ServiceException e) { throw new Exception(e.Message, e); } return incomeTaxs; } public static DataSet GetTaxWithProjection(int empID) { DataSet oDataSet = new DataSet(); oDataSet = IncomeTax.Service.GetTaxWithProjection(empID); return oDataSet; } public static DataSet GetTaxAdj(EnumIncomeTaxItemGroup itemcode,int nItemID ,ID empID) { DataSet oDataSet = new DataSet(); oDataSet = IncomeTax.Service.GetTaxAdj(itemcode, nItemID, empID); return oDataSet; } public static DataSet GetTaxWithoutProjection(int empID) { DataSet oDataSet = new DataSet(); oDataSet = IncomeTax.Service.GetTaxWithoutProjection(empID); return oDataSet; } public static DataSet GetTaxCertificate(string empNo, int taxParamId) { DataSet oDataSet = new DataSet(); oDataSet = IncomeTax.Service.GetTaxCertificate(empNo, taxParamId); return oDataSet; } #endregion } #endregion #region IIncomeTax Service public interface IIncomeTaxService { ObjectsTemplate GetPrvYear(ID taxparameterId, EnumIncomeTaxItemGroup groupCode, int itemID); ObjectsTemplate GetPrvYear(ID taxparameterId, int payrollTypeID); ObjectsTemplate GetPrvYear(ID taxparameterId, int payrollTypeID,int empid); ObjectsTemplate Get(ID employeeid, EnumIncomeTaxDataFrom dataFrom); ObjectsTemplate Get(EnumIncomeTaxDataFrom dataFrom, int payrollTypeID); ObjectsTemplate Get(EnumIncomeTaxDataFrom dataFrom, ID nEmpID, ID nTaxParamID); ObjectsTemplate GetOldIncomeTax(EnumIncomeTaxDataFrom dataFrom, ID nEmpID, ID nTaxParamID); IncomeTax Get(EnumIncomeTaxDataFrom dataFrom, ID nEmpID, EnumIncomeTaxItemGroup groupCode, int itemID); DataSet GetByEmpID(EnumIncomeTaxDataFrom dataFrom, ID employeeid); DataSet GetEmpIDforOthTax(EnumIncomeTaxDataFrom dataFrom, ID nEMpID); void UpdateOT(ObjectsTemplate otProcess); ID Save(IncomeTax item, EnumIncomeTaxDataFrom saveto); void DoYearEndReProcess(ObjectsTemplate oIncometaxes, ID taxParameterID, int payrollTypeID); void DoYearEndReProcess2(ObjectsTemplate oIncometaxes, ID taxParameterID); void DoTaxYearEnd(ObjectsTemplate oIncometaxes, ID PayrollTypeID); void Save(ObjectsTemplate _IncomeTaxs, EnumIncomeTaxDataFrom saveto); void Delete(ID nEmpId, EnumIncomeTaxDataFrom deletefrom,EnumIncomeTaxItemGroup ItemGroup,int ItemID); void DeleteYearlyData(ID TaxParamID, EnumIncomeTaxDataFrom deletefrom,ID nEmpID,EnumIncomeTaxItemGroup ItemGroup,int ItemID); void DoTaxTempReProcess(ObjectsTemplate IncomeTaxes, ID taxParameterID, EnumIncomeTaxDataFrom saveTo, int payrollTypeID); ObjectsTemplate GetByYear(ID taxparameterId, EnumIncomeTaxDataFrom dataFrom, int payrollTypeID); DataSet GetTaxWithProjection(int empID); DataSet GetTaxAdj(EnumIncomeTaxItemGroup itemcode, int nItemID, ID empID); DataSet GetTaxWithoutProjection(int empID); DataSet GetTaxCertificate(string empNo, int taxParamId); } #endregion public class TaxRawItem { public TaxRawItem() { _description= ""; _amount =0; _taxItemType= enumIncomeTaxItemType.Basic_Salary; _itemID =0; } private string _description; private double _amount; private enumIncomeTaxItemType _taxItemType; private int _itemID; public string Description { get { return _description ; } set { _description = value; } } public double Amount { get { return _amount; } set { _amount = value; } } public enumIncomeTaxItemType ItemType { get { return _taxItemType; } set { _taxItemType = value; } } public int ItemId { get { return _itemID; } set { _itemID = value; } } public static TaxRawItem Create(string description, double amount, enumIncomeTaxItemType type, int itemId) { TaxRawItem oitem = new TaxRawItem(); oitem.Description = description; oitem.Amount = amount; oitem.ItemType = type; oitem.ItemId = itemId; return oitem; } } }