EchoTex_Payroll/HRM.BO/Bonus/BonusProcess.cs

938 lines
26 KiB
C#
Raw Permalink Normal View History

2024-10-14 10:01:49 +06:00
using Ease.Core.Model;
using System;
using System.Collections.Generic;
using System.Data;
namespace HRM.BO
{
#region BonusProcess
public class BonusProcess : AuditTrailBase
{
#region Constructor
public BonusProcess()
{
_disburseDate = null;
_remarks = string.Empty;
_showInWeb = false;
_IsDisburseWithSalary = false;
_IsTaxProcess = false;
_UsedProcess = 0.0;
this.IsApprove = false;
// _bonus = null;
}
#endregion
#region Internal Class
#region BonusProcessDetail
public class BonusProcessDetail : AuditTrailBase
{
#region Constructor
public BonusProcessDetail()
{
_bonusProcessID = 0;
_bonusID = 0;
_employeeID = 0;
_bonusAmount = 0;
_basicSalary = 0;
_grossSalary = 0;
_changeBonusAmount = 0;
_changeAdjustAmount = 0;
_changeSalaryItemAmount = 0;
_changeTaxAmount = 0;
_calculatedAdjustAmount = 0;
_calculatedSalaryItemAmount = 0;
_taxAmount = 0;
Employee = null;
Bonus = null;
_incomeTax = null;
_isProjectedBonus = false;
// _bonusProcess = null;
}
#endregion
#region Internal Class
//public class BonusProcessAdjustItem : AuditTrailBase
//{
// #region Cache Store
// private static Cache _cache = new Cache(typeof(BonusProcessAdjustItem));
// #endregion
// #region Constructor
// public BonusProcessAdjustItem()
// {
// _adjustAmount = 0;
// _bonusAdjustID = 0;
// _bonusProcessDetailID = null;
// }
// #endregion
// #region Properties
// #region AdjustAmount : double
// private double _adjustAmount;
// public double AdjustAmount
// {
// get { return _adjustAmount; }
// set
// {
//
// _adjustAmount = value;
// }
// }
// #endregion
// #region BonusAdjustID : int
// private int _bonusAdjustID;
// public int BonusAdjustID
// {
// get { return _bonusAdjustID; }
// set
// {
//
// _bonusAdjustID = value;
// }
// }
// #endregion
// #region BonusParameterID : ID
// private int _bonusProcessDetailID;
// public int BonusProcessDetailID
// {
// get { return _bonusProcessDetailID; }
// set
// {
//
// _bonusProcessDetailID = value;
// }
// }
// #endregion
// #endregion
//}
#endregion
#region Properties
private bool _isProjectedBonus;
public bool IsProjectedBonus
{
get { return _isProjectedBonus; }
set { _isProjectedBonus = value; }
}
#region BonusProcessID : ID
private int _bonusProcessID;
public int BonusProcessID
{
get { return _bonusProcessID; }
set { _bonusProcessID = value; }
}
#endregion
#region BonusID : ID
private int _bonusID;
public int BonusID
{
get { return _bonusID; }
set { _bonusID = value; }
}
#endregion
#region EmployeeID : ID
private int _employeeID;
public int EmployeeID
{
get { return _employeeID; }
set { _employeeID = value; }
}
#endregion
#region disburseDate : DateTime
private DateTime _bonusMonth;
public DateTime BonusMonth
{
get { return _bonusMonth; }
set { _bonusMonth = value; }
}
#endregion
#region bonusAmount : double
private double _bonusAmount;
public double BonusAmount
{
get { return _bonusAmount; }
set { _bonusAmount = value; }
}
#endregion
#region basicSalary : double
private double _basicSalary;
public double BasicSalary
{
get { return _basicSalary; }
set { _basicSalary = value; }
}
#endregion
#region grossSalary : double
private double _grossSalary;
public double GrossSalary
{
get { return _grossSalary; }
set { _grossSalary = value; }
}
#endregion
#region changeBonusAmount : double
private double _changeBonusAmount;
public double ChangeBonusAmount
{
get { return _changeBonusAmount; }
set { _changeBonusAmount = value; }
}
#endregion
#region changeTaxAmount : double
private double _changeTaxAmount;
public double ChangeTaxAmount
{
get { return _changeTaxAmount; }
set { _changeTaxAmount = value; }
}
#endregion
#region ChangeSalaryItemAmount : double
private double _changeSalaryItemAmount;
public double ChangeSalaryItemAmount
{
get { return _changeSalaryItemAmount; }
set { _changeSalaryItemAmount = value; }
}
#endregion
#region ChangeSalaryItemAmount : double
private double _changeAdjustAmount;
public double ChangeAdjustAmount
{
get { return _changeAdjustAmount; }
set { _changeAdjustAmount = value; }
}
#endregion
#region CalculatedAdjustAmount : double
private double _calculatedAdjustAmount;
public double CalculatedAdjustAmount
{
get { return _calculatedAdjustAmount; }
set { _calculatedAdjustAmount = value; }
}
#endregion
#region CalculatedSalaryItemAmount : double
private double _calculatedSalaryItemAmount;
public double CalculatedSalaryItemAmount
{
get { return _calculatedSalaryItemAmount; }
set { _calculatedSalaryItemAmount = value; }
}
#endregion
#region NetBonusAmount : double
public double NetBonusAmount
{
get
{
//####
bool
isOtherItem =
false; // ConfigurationManager.GetBoolValue("incometax", "taxissalaryotheritem", EnumConfigurationType.Logic);
if (isOtherItem == true) return _changeBonusAmount;
else return (_changeBonusAmount - _changeTaxAmount);
}
}
#endregion
#region taxAmount : double
private double _taxAmount;
public double TaxAmount
{
get { return _taxAmount; }
set { _taxAmount = value; }
}
#endregion
public Employee Employee { get; set; }
public Bonus Bonus { get; set; }
public BonusParameter BonusParam { get; set; }
//#region employee : Employee
//private Employee _employee;
//public Employee Employee
//{
// get
// {
// if (_employeeID.Integer > 0 && _employee == null)
// {
// _employee = new Employee();
// _employee = Employee.Get(_employeeID);
// }
// return this._employee;
// }
// set
// {
// _employee = value;
// }
//}
//#endregion
#region Bonus EmpCostCenter : BonusEmpCotCenter
private List<BonusEmpCostCenter> _bonusEmpCostCenters;
public List<BonusEmpCostCenter> BonusCostCentersInvolments
{
get
{
if (_bonusEmpCostCenters == null)
{
_bonusEmpCostCenters = new List<BonusEmpCostCenter>();
}
return _bonusEmpCostCenters;
}
set { _bonusEmpCostCenters = value; }
}
#endregion
//#region bonus : Bonus
//private Bonus _bonus;
//public Bonus Bonus
//{
// get
// {
// if (_bonusID.Integer > 0 && _bonus == null)
// {
// _bonus = new Bonus();
// _bonus = Bonus.Get(_bonusID);
// }
// return this._bonus;
// }
// set
// {
// _bonus = value;
// }
//}
//#endregion
#region BonusProcessAdjustItems : BonusProcessAdjustItems
//private List<BonusProcess.BonusProcessDetail.BonusProcessAdjustItem> _BonusProcessAdjustItems = null;
//public List<BonusProcess.BonusProcessDetail.BonusProcessAdjustItem> BonusProcessAdjustItems
//{
// get
// {
// return this._BonusProcessAdjustItems;
// }
// set
// {
// _BonusProcessAdjustItems = value;
// }
//}
#endregion
#region Property IncomeTax : List<IncomeTax>
private List<IncomeTax> _incomeTax = null;
public List<IncomeTax> IncomeTaxcoll
{
get { return _incomeTax; }
set { _incomeTax = value; }
}
#endregion Property IncomeTax : List<IncomeTax>
#endregion
}
#endregion
#endregion
#region Properties
#region BonusID : ID
private int _bonusID;
public int BonusID
{
get { return _bonusID; }
set { _bonusID = value; }
}
#endregion
#region bonusMonth : DateTime
private DateTime? _bonusMonth;
public DateTime? BonusMonth
{
get { return _bonusMonth; }
set { _bonusMonth = value; }
}
#endregion
#region basicOnMonth : DateTime
private DateTime _basicOnMonth;
public DateTime BasicOnMonth
{
get { return _basicOnMonth; }
set { _basicOnMonth = value; }
}
#endregion
#region disburseDate : DateTime
private DateTime? _disburseDate;
public DateTime? DisburseDate
{
get { return _disburseDate; }
set { _disburseDate = value; }
}
#endregion
#region remarks : string
private string _remarks;
public string Remarks
{
get { return _remarks; }
set { _remarks = value; }
}
#endregion
#region showInWeb : bool
private bool _showInWeb;
public bool ShowInWeb
{
get { return _showInWeb; }
set { _showInWeb = value; }
}
#endregion
public int PayrollTypeID { get; set; }
#region IsDisburseWithSalary : bool
private bool _IsDisburseWithSalary;
public bool IsDisburseWithSalary
{
get { return _IsDisburseWithSalary; }
set { _IsDisburseWithSalary = value; }
}
#endregion
#region IsTaxProcess : bool
private bool _IsTaxProcess;
public bool IsTaxProcess
{
get { return _IsTaxProcess; }
set { _IsTaxProcess = value; }
}
#endregion
public bool IsApprove { get; set; }
public enumwfStatus wfstatus { get; set; }
#region BonusProcessDetails : BonusProcessDetails
private List<BonusProcess.BonusProcessDetail> _BonusProcessDetails = null;
public List<BonusProcess.BonusProcessDetail> BonusProcessDetails
{
get { return this._BonusProcessDetails; }
set { _BonusProcessDetails = value; }
}
#endregion
#region UsedProcess : int
private double _UsedProcess;
public double UsedProcess
{
get { return _UsedProcess; }
set { _UsedProcess = value; }
}
#endregion
public string getEmpID()
{
string str = "";
this.BonusProcessDetails.ForEach(x =>
{
if (x != null)
str = str + x.EmployeeID + ",";
});
if (str.Length > 0) str = str.Substring(0, str.Length - 1);
return str;
}
//#region Service Factory IBonusProcessService : IBonusProcessService
//internal static IBonusProcessService Service
//{
// get { return Services.Factory.CreateService<IBonusProcessService>(typeof(IBonusProcessService)); }
//}
//#endregion
#endregion
//#region Functions
//public static double GetBonusAmount(DateTime bonusMonthFirstDate, int employeeID, int bonusID)
//{
// double bonusAmount = 0;
// try
// {
// bonusAmount = BonusProcess.Service.GetBonusAmount(bonusMonthFirstDate, employeeID, bonusID);
// }
// catch (Exception e)
// {
// if (e.InnerException == null)
// {
// throw new Exception(e.Message);
// }
// else
// {
// throw new Exception(e.Message, e.InnerException);
// }
// }
// return bonusAmount;
//}
//public static double GetUsedBonusWithinYear(DateTime bonusMonthFirstDate,int bonusID)
//{
// double usedBonus = 0;
// try
// {
// usedBonus = BonusProcess.Service.GetUsedBonusWithinYear(bonusMonthFirstDate, bonusID);
// }
// catch (Exception e)
// {
// if (e.InnerException == null)
// {
// throw new Exception(e.Message);
// }
// else
// {
// throw new Exception(e.Message, e.InnerException);
// }
// }
// return usedBonus;
//}
//public static double GetBonusAmountWithinYear(DateTime bonusYearDate, int employeeID, int bonusID)
//{
// double bonusAmount = 0;
// try
// {
// bonusAmount = BonusProcess.Service.GetBonusAmountWithinYear(bonusYearDate, employeeID, bonusID);
// }
// catch (Exception e)
// {
// if (e.InnerException == null)
// {
// throw new Exception(e.Message);
// }
// else
// {
// throw new Exception(e.Message, e.InnerException);
// }
// }
// return bonusAmount;
//}
//public static BonusProcess Get(int nID)
//{
// BonusProcess oBonusProcess = null;
// #region Cache Header
// oBonusProcess = (BonusProcess)_cache["Get", nID];
// if (oBonusProcess != null)
// return oBonusProcess;
// #endregion
// oBonusProcess = BonusProcess.Service.Get(nID);
// #region Cache Footer
// _cache.Add(oBonusProcess, "Get", nID);
// #endregion
// return oBonusProcess;
//}
//public static BonusProcess Get(int nBonusID, DateTime bonusMonth)
//{
// BonusProcess oBonusProcess = null;
// oBonusProcess = BonusProcess.Service.Get(nBonusID, bonusMonth);
// return oBonusProcess;
//}
//public static List<BonusProcess> GetProcess(DateTime bonusMonth)
//{
// #region Cache Header
// List<BonusProcess> bonusProcesss = _cache["GetProcess", bonusMonth] as List<BonusProcess>;
// if (bonusProcesss != null)
// return bonusProcesss;
// #endregion
// try
// {
// bonusProcesss = Service.GetProcess(bonusMonth);
// }
// catch (ServiceException e)
// {
// throw new Exception(e.Message, e);
// }
// #region Cache Footer
// _cache.Add(bonusProcesss, "GetProcess", bonusMonth);
// #endregion
// return bonusProcesss;
//}
//public static List<BonusProcess.BonusProcessDetail> GetBonusDetails(DateTime dMonth, bool bPayWithsalary)
//{
// #region Cache Header
// List<BonusProcess.BonusProcessDetail> bonusProcesssDetails = _cache["GetBonusDetails", dMonth, bPayWithsalary] as List<BonusProcess.BonusProcessDetail>;
// if (bonusProcesssDetails != null)
// return bonusProcesssDetails;
// #endregion
// try
// {
// bonusProcesssDetails = Service.GetBonusDetails(dMonth, bPayWithsalary);
// }
// catch (ServiceException e)
// {
// throw new Exception(e.Message, e);
// }
// #region Cache Footer
// _cache.Add(bonusProcesssDetails, "GetBonusDetails", dMonth, bPayWithsalary);
// #endregion
// return bonusProcesssDetails;
//}
//public static List<BonusProcess.BonusProcessDetail> GetSumOfBonusDetails(DateTime fromMonth, DateTime toMonth)
//{
// #region Cache Header
// List<BonusProcess.BonusProcessDetail> bonusProcesssDetails = _cache["GetSumOfBonusDetails", fromMonth, toMonth] as List<BonusProcess.BonusProcessDetail>;
// if (bonusProcesssDetails != null)
// return bonusProcesssDetails;
// #endregion
// try
// {
// bonusProcesssDetails = Service.GetSumOfBonusDetails(fromMonth, toMonth);
// }
// catch (ServiceException e)
// {
// throw new Exception(e.Message, e);
// }
// #region Cache Footer
// _cache.Add(bonusProcesssDetails, "GetSumOfBonusDetails", fromMonth, toMonth);
// #endregion
// return bonusProcesssDetails;
//}
////public static List<BonusProcess.BonusProcessDetail.BonusProcessAdjustItem> GetBProcessAdjust(int bonusProDetailID)
////{
//// #region Cache Header
//// List<BonusProcess.BonusProcessDetail.BonusProcessAdjustItem> bonusProcessAdjustItems = _cache["GetBProcessAdjust", bonusProDetailID] as List<BonusProcess.BonusProcessDetail.BonusProcessAdjustItem>;
//// if (bonusProcessAdjustItems != null)
//// return bonusProcessAdjustItems;
//// #endregion
//// try
//// {
//// bonusProcessAdjustItems = Service.GetBProcessAdjust(bonusProDetailID);
//// }
//// catch (ServiceException e)
//// {
//// throw new Exception(e.Message, e);
//// }
//// #region Cache Footer
//// _cache.Add(bonusProcessAdjustItems, "GetBProcessAdjust", bonusProDetailID);
//// #endregion
//// return bonusProcessAdjustItems;
////}
//public static DataSet GetBonusRegister(int BonusID,DateTime dBonusMonth, string sEmpID)
//{
// DataSet ds = null;
// try
// {
// ds = Service.GetBonusRegister(BonusID,dBonusMonth, sEmpID);
// }
// catch (Exception e)
// {
// throw new Exception(e.Message, e);
// }
// return ds;
//}
//public static DataSet GetBonusBankAdvice(int BonusID, DateTime dBonusMonth, string sEmpID)
//{
// DataSet ds = null;
// try
// {
// ds = Service.GetBonusBankAdvice(BonusID, dBonusMonth, sEmpID);
// }
// catch (Exception e)
// {
// throw new Exception(e.Message, e);
// }
// return ds;
//}
//public static DataSet GetBonusPaySlip(int BonusID, DateTime dBonusMonth, string sEmpID)
//{
// DataSet ds = null;
// try
// {
// ds = Service.GetBonusPaySlip(BonusID, dBonusMonth, sEmpID);
// }
// catch (Exception e)
// {
// throw new Exception(e.Message, e);
// }
// return ds;
//}
//public static int GetForNoOfPaidForEmp(DateTime bonusYearDate, int bonusID,int empId)
//{
// int PaidItem = 0;
// try
// {
// PaidItem = BonusProcess.Service.GetForNoOfPaidForEmp(bonusYearDate, bonusID, empId);
// }
// catch (Exception e)
// {
// if (e.InnerException == null)
// {
// throw new Exception(e.Message);
// }
// else
// {
// throw new Exception(e.Message, e.InnerException);
// }
// }
// return PaidItem;
//}
//public static int GetForNoOfPaid(DateTime bonusYearDate,int bonusID)
//{
// int PaidItem = 0;
// try
// {
// PaidItem = BonusProcess.Service.GetForNoOfPaid(bonusYearDate, bonusID);
// }
// catch (Exception e)
// {
// if (e.InnerException == null)
// {
// throw new Exception(e.Message);
// }
// else
// {
// throw new Exception(e.Message, e.InnerException);
// }
// }
// return PaidItem;
//}
//public static List<BonusProcess> GetProcess(int bonusID, DateTime bonusMonth)
//{
// #region Cache Header
// List<BonusProcess> bonusProcesss = _cache["GetProcess", bonusID, bonusMonth] as List<BonusProcess>;
// if (bonusProcesss != null)
// return bonusProcesss;
// #endregion
// try
// {
// bonusProcesss = Service.GetProcess(bonusID, bonusMonth);
// }
// catch (ServiceException e)
// {
// throw new Exception(e.Message, e);
// }
// #region Cache Footer
// _cache.Add(bonusProcesss, "GetProcess", bonusID, bonusMonth);
// #endregion
// return bonusProcesss;
//}
//public int Save()
//{
// this.SetAuditTrailProperties();
// return BonusProcess.Service.Save(this);
//}
//public static void UndoProcess(BonusProcess oBonusProcess)
//{
// BonusProcess.Service.Delete(oBonusProcess);
//}
//#endregion
}
#endregion
#region IBonusProcess Service
public interface IBonusProcessService
{
DataTable GetBonusItemsForESSBonusPayslip(int EmployeeID);
BonusProcess CalculateBonus(int payrolltypeid, List<Employee> employees, int bonusid, DateTime dBasicMonth,
DateTime dPayDate, DateTime dCuttOfDate, double CurrProcess, bool IsDisburseWithSalary, bool IsTaxProcess);
List<BonusProcess.BonusProcessDetail> CalculateBonusTax(List<BonusProcess.BonusProcessDetail> bonusDetails,
List<Employee> employees, int bonusid, int payrolltypeid);
void ApproveBonus(int bonusID, DateTime bonusMonth, int payrolltypeid);
bool IsApproved(int bonusID, DateTime bonusMonth, int payrolltypeid);
double GetBonusAmount(DateTime bonusMonthFirstDate, int employeeID, int bonusID);
void UndoBonusProcess(BonusProcess bonusProcess);
double GetBonusAmountWithinYear(DateTime bonusYearDate, int employeeID, int bonusID);
double GetUsedBonusWithinYear(DateTime bonusYearDate, int bonusID);
BonusProcess Get(int id);
int GetForNoOfPaid(DateTime bonusYear, int bonusID);
BonusProcess Get(int bonusID, DateTime bonusMonth);
List<BonusProcess.BonusProcessDetail> GetBonusDetails(int payrolltypeid, int bonusID, DateTime dMonth);
List<BonusProcess.BonusProcessDetail> GetSumOfBonusDetails(DateTime fromMonth, DateTime toDate);
//DataSet GetBonusRegister(int BonusID, DateTime dBonusMonth, string sEmpID);
DataSet GetBonusBankAdvice(int BonusID, DateTime dBonusMonth, string sEmpID);
DataSet GetBonusPaySlip(int BonusID, DateTime dBonusMonth, string sEmpID);
int Save(BonusProcess item);
void Delete(BonusProcess oBonusProcess);
List<BonusProcess> GetProcess(int bonusID, DateTime bonusMonth);
List<BonusProcess> GetProcess(DateTime bonusMonth);
int GetForNoOfPaidForEmp(DateTime bonusYearDate, int bonusID, int empId);
DataTable GetUnApprovedBonuses(DateTime dMonthDate, int payrollTypeID);
DataSet GetBonusRegisterNew(int BonusID, DateTime dBonusMonth, string sEmpID, int payrolltypeid);
}
#endregion
}