EchoTex_Payroll/HRM.BO/JV/JVSetup.cs

498 lines
22 KiB
C#
Raw Permalink Normal View History

2024-10-14 10:01:49 +06:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ease.Core;
using Ease.Core.Model;
namespace HRM.BO
{
#region JVSetup
public class JVSetup : BasicBaseObject
{
public delegate void ItemChanged();
#region Constructor
public JVSetup()
{
Description = string.Empty;
GLCode = string.Empty;
IsConfirmed = false;
IsEmployeeDetail = false;
JVTypeID = 0;
MonthDate = DateTime.MinValue;
SequenceNo = 0;
ShowCC = false;
BookToCC = false;
BookToPC = false;
Side = (int)EnumSide.Add;
SideCode = string.Empty;
JVSetupDetails = null;
EMPLOYEETYPE = EnumJVEmpType.RegardLess;
}
#endregion
#region Properties
public string Description { get; set; }
public string GLCode { get; set; }
public string GroupCode { get; set; }
public bool IsConfirmed { get; set; }
public bool IsEmployeeDetail { get; set; }
public int JVTypeID { get; set; }
public JVType JVType { get; set; }
//#region jvType : JVType
//private JVType _jvType;
//public JVType JVType
//{
// get
// {
// if (JVTypeID > 0)
// {
// _jvType = new JVType();
// _jvType = JVTypeDA.Get(JVTypeID);
// }
// return _jvType;
// }
// set
// {
// _jvType = value;
// }
//}
//#endregion
public DateTime MonthDate { get; set; }
public int SequenceNo { get; set; }
public bool ShowCC { get; set; }
public bool BookToCC { get; set; }
public bool BookToPC { get; set; }
public int Side { get; set; }
public string SideCode { get; set; }
public int PayrollTypeID { get; set; }
public EnumJVEmpType EMPLOYEETYPE { get; set; }
public List<JVSetupDetail> JVSetupDetails { get; set; }
//#region Property JVSetupDetails : List<JVSetupDetail>
//private List<JVSetupDetail> _jvSetupDetails;
//public List<JVSetupDetail> JVSetupDetails
//{
// get
// {
// if (_jvSetupDetails == null && !this.ID.IsUnassigned && this.ID.Integer > 0)
// {
// _jvSetupDetails = JVSetupDetail.GetByJVSetup(this.ID);
// }
// if (_jvSetupDetails == null)
// {
// _jvSetupDetails = new List<JVSetupDetail>();
// }
// return _jvSetupDetails;
// }
// set
// {
// _jvSetupDetails = value;
// }
//}
//#endregion Property JVSetupDetails : List<JVSetupDetail>
public List<JVSetupCC> JVSetupCC { get; set; }
public List<JVSetupGrade> JVSetupGrades { get; set; }
//#region JVSetupCC : List<JVSetupCC>
//private List<JVSetupCC> _jvSetupCCs;
//public List<JVSetupCC> JVSetupCC
//{
// get
// {
// if (_jvSetupCCs == null && !this.ID.IsUnassigned && this.ID.Integer > 0)
// {
// _jvSetupCCs = Payroll.BO.JVSetupCC.GetByJVSetup(this.ID);
// }
// //if (_jvSetupDetails == null)
// //{
// // _jvSetupCCs = new List<JVSetupCC>();
// //}
// return _jvSetupCCs;
// }
// set
// {
// _jvSetupCCs = value;
// }
//}
//#endregion
#endregion
//#region Functions
//public double GetAmount(SalaryMonthly salary, List<JVSetupDetail> 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, List<JVSetupDetail> 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.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 List<JVSetup> Get()
//{
// #region Cache Header
// List<JVSetup> jvsetups = _cache["Get"] as List<JVSetup>;
// 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 List<JVSetup> GetByJVType(ID jvSetupID)
//{
// #region Cache Header
// List<JVSetup> jvsetups = _cache["GetByJVType", jvSetupID] as List<JVSetup>;
// 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 List<JVSetup> GetByJVTypeAndEffectDate(ID jvSetupID, DateTime dEffectDate)
//{
// #region Cache Header
// List<JVSetup> jvsetups = _cache["GetByJVTypeAndEffectDate", jvSetupID, dEffectDate] as List<JVSetup>;
// 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 List<JVSetup> GetByMonthDate(DateTime dtMonthDate)
//{
// #region Cache Header
// List<JVSetup> jvsetups = _cache["GetByMonthDate", dtMonthDate] as List<JVSetup>;
// 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 List<JVSetupDetail> GetChildByParentID(ID JVSetupID)
//{
// #region Cache Header
// List<JVSetupDetail> jvsetupdetails = _cache["GetChildByParentID", JVSetupID] as List<JVSetupDetail>;
// 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 List<JVSetup> GetByJVTypeAndMonth(ID jvTypeID, DateTime dDate)
//{
// #region Cache Header
// List<JVSetup> jvsetups = _cache["GetByJVTypeAndMonth", jvTypeID, dDate] as List<JVSetup>;
// 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(List<JVSetup> 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<IJVSetupService>(typeof(IJVSetupService));
// }
//}
//#endregion
}
#endregion
#region IJVSetup Service
public interface IJVSetupService
{
JVSetup Get(int id);
List<JVSetup> Get();
List<JVSetup> GetByJVType(int jvSetupID);
List<JVSetup> GetByJVTypeAndEffectDate(int jvSetupID, DateTime dEffectDate);
int GetSequenceNo();
DateTime GetMaxDate(DateTime dGivenDate);
List<JVSetup> GetByMonthDate(DateTime dtMonthDate);
List<JVSetupDetail> GetChildByParentID(int JVSetupID);
List<JVSetup> GetByJVTypeAndMonth(int jvTypeID, DateTime lastDate);
int Save(JVSetup oJVSetup);
void UpdateSequence(List<JVSetup> oJVSetups);
void Delete(int id);
List<JVSetup> GetLatestSetupByJVType(int payrolltypeid, int jvtypeid);
}
#endregion
}