CEL_Payroll/Payroll.BO/Tax/IncomeTax.cs
2024-09-17 14:30:13 +06:00

714 lines
21 KiB
C#

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<ID>("EmployeeID", _employeeID, value);
_employeeID = value;
}
}
#endregion
#region itemID : int
private int _itemID;
public int ItemID
{
get { return _itemID; }
set
{
base.OnPropertyChange<int>("itemCode", _itemID, value);
_itemID = value;
}
}
#endregion
#region previousAmount : double
private double _previousAmount;
public double PreviousAmount
{
get { return _previousAmount; }
set
{
base.OnPropertyChange<double>("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<double>("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<double>("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<ID>("TaxParameterID", _taxParameterID, value);
_taxParameterID = value;
}
}
#endregion
#region position : int
private int _position;
public int Position
{
get { return _position; }
set
{
base.OnPropertyChange<int>("position", _position, value);
_position = value;
}
}
#endregion
#region description : string
private string _description;
public string Description
{
get { return _description; }
set
{
base.OnPropertyChange<string>("description", _description, value);
_description = value;
}
}
#endregion
#region IsChanged : bool
private bool _isChanged;
public bool IsChanged
{
get { return _isChanged; }
set
{
base.OnPropertyChange<bool>("IsChanged", _isChanged, value);
_isChanged = value;
}
}
#endregion
#region itemGroup : EnumIncomeTaxItemCode
private EnumIncomeTaxItemGroup _itemGroup;
public EnumIncomeTaxItemGroup ItemGroup
{
get { return _itemGroup; }
set
{
base.OnPropertyChange<short>("itemGroup",(short) _itemGroup, (short)value);
_itemGroup = value;
}
}
#endregion
#region side : EnumIncomeTaxGroup
private EnumIncomeTaxSide _side;
public EnumIncomeTaxSide Side
{
get { return _side; }
set
{
base.OnPropertyChange<short>("side",(short) _side, (short)value);
_side = value;
}
}
#endregion
#region Service Factory IIncomeTaxService : IIncomeTaxService
internal static IIncomeTaxService Service
{
get { return Services.Factory.CreateService<IIncomeTaxService>(typeof(IIncomeTaxService)); }
}
#endregion
#endregion
#region Functions
public static ObjectsTemplate<IncomeTax> Get(ID employeeid, EnumIncomeTaxDataFrom dataFrom)
{
ObjectsTemplate<IncomeTax> 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<IncomeTax> Get(EnumIncomeTaxDataFrom dataFrom)
{
ObjectsTemplate<IncomeTax> 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<IncomeTax> Get(EnumIncomeTaxDataFrom dataFrom, ID nEmpID, ID nTaxParamID)
{
ObjectsTemplate<IncomeTax> 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<IncomeTax> GetOldIncomeTax(EnumIncomeTaxDataFrom dataFrom, ID nEmpID, ID nTaxParamID)
{
ObjectsTemplate<IncomeTax> 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<IncomeTax> GetPrvYear(
ID taxparameterId, EnumIncomeTaxItemGroup groupCode, int itemId)
{
ObjectsTemplate<IncomeTax> incomeTaxs = null;
try
{
incomeTaxs = Service.GetPrvYear(taxparameterId, groupCode, itemId);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
return incomeTaxs;
}
public static ObjectsTemplate<IncomeTax> GetPrvYear(
ID taxparameterId)
{
ObjectsTemplate<IncomeTax> 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<IncomeTax> GetPrvYear(
ID taxparameterId,ID empID)
{
ObjectsTemplate<IncomeTax> 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<IncomeTax> 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<IncomeTax> 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<IncomeTax> Get(ObjectsTemplate<IncomeTax> Incometaxs, ID employeeId)
{
ObjectsTemplate<IncomeTax> Items = new ObjectsTemplate<IncomeTax>();
foreach (IncomeTax item in Incometaxs)
{
if (item.EmployeeID.Integer == employeeId.Integer)
Items.Add(item);
}
return Items;
}
public static double GetAmount(ObjectsTemplate<IncomeTax> 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<IncomeTax> _IncomeTaxs, EnumIncomeTaxDataFrom saveto)
{
foreach (IncomeTax item in _IncomeTaxs)
item.SetAuditTrailProperties();
IncomeTax.Service.Save(_IncomeTaxs,saveto);
}
public static void UpdateOT(ObjectsTemplate<OTProcess> 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<IncomeTax> IncomeTaxes)
{
IncomeTax.Service.DoTaxYearEnd(IncomeTaxes, SystemInformation.CurrentSysInfo.PayrollTypeID);
}
public void DoYearEndReProcess(ObjectsTemplate<IncomeTax> IncomeTaxes, ID taxParameterID)
{
IncomeTax.Service.DoYearEndReProcess(IncomeTaxes, taxParameterID, Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer);
}
public void DoYearEndReProcess2(ObjectsTemplate<IncomeTax> IncomeTaxes, ID taxParameterID)
{
IncomeTax.Service.DoYearEndReProcess2(IncomeTaxes, taxParameterID);
}
public void DoTaxTempReProcess(ObjectsTemplate<IncomeTax> IncomeTaxes, ID taxParameterID, EnumIncomeTaxDataFrom saveTo)
{
IncomeTax.Service.DoTaxTempReProcess(IncomeTaxes, taxParameterID, saveTo, Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer);
}
public static ObjectsTemplate<IncomeTax> GetByYear(
ID taxparameterId, EnumIncomeTaxDataFrom dataFrom)
{
ObjectsTemplate<IncomeTax> 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<IncomeTax> GetPrvYear(ID taxparameterId,
EnumIncomeTaxItemGroup groupCode, int itemID);
ObjectsTemplate<IncomeTax> GetPrvYear(ID taxparameterId, int payrollTypeID);
ObjectsTemplate<IncomeTax> GetPrvYear(ID taxparameterId, int payrollTypeID,int empid);
ObjectsTemplate<IncomeTax> Get(ID employeeid, EnumIncomeTaxDataFrom dataFrom);
ObjectsTemplate<IncomeTax> Get(EnumIncomeTaxDataFrom dataFrom, int payrollTypeID);
ObjectsTemplate<IncomeTax> Get(EnumIncomeTaxDataFrom dataFrom, ID nEmpID, ID nTaxParamID);
ObjectsTemplate<IncomeTax> 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> otProcess);
ID Save(IncomeTax item, EnumIncomeTaxDataFrom saveto);
void DoYearEndReProcess(ObjectsTemplate<IncomeTax> oIncometaxes, ID taxParameterID, int payrollTypeID);
void DoYearEndReProcess2(ObjectsTemplate<IncomeTax> oIncometaxes, ID taxParameterID);
void DoTaxYearEnd(ObjectsTemplate<IncomeTax> oIncometaxes, ID PayrollTypeID);
void Save(ObjectsTemplate<IncomeTax> _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<IncomeTax> IncomeTaxes, ID taxParameterID, EnumIncomeTaxDataFrom saveTo, int payrollTypeID);
ObjectsTemplate<IncomeTax> 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;
}
}
}