EchoTex_Payroll/HRM.BO/Attendance/AttnMonthlyBenefit.cs

1623 lines
48 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 System.Data;
using Ease.Core;
namespace HRM.BO
{
#region AttnMonthlyBenefit
public class AttnMonthlyBenefit : BasicBaseObject
{
#region Constructor
public AttnMonthlyBenefit()
{
_value1 = 0;
_value2 = 0;
_value3 = 0;
_value4 = 0;
_value5 = 0;
_value6 = 0;
_value7 = 0;
_value8 = 0;
_value9 = 0;
_value10 = 0;
_value11 = 0;
_value12 = 0;
_value13 = 0;
_value14 = 0;
_value15 = 0;
_value16 = 0;
_value17 = 0;
_value18 = 0;
_value19 = 0;
_value20 = 0;
_value21 = 0;
_value22 = 0;
_value23 = 0;
_value24 = 0;
_value25 = 0;
_value26 = 0;
_value27 = 0;
_value28 = 0;
_value29 = 0;
_value30 = 0;
_value31 = 0;
_adjustment = 0;
_total = 0;
_isUpdated = false;
_isValue1 = false;
_isValue2 = false;
_isValue3 = false;
_isValue4 = false;
_isValue5 = false;
_isValue6 = false;
_isValue7 = false;
_isValue8 = false;
_isValue9 = false;
_isValue10 = false;
_isValue11 = false;
_isValue12 = false;
_isValue13 = false;
_isValue14 = false;
_isValue15 = false;
_isValue16 = false;
_isValue17 = false;
_isValue18 = false;
_isValue19 = false;
_isValue20 = false;
_isValue21 = false;
_isValue22 = false;
_isValue23 = false;
_isValue24 = false;
_isValue25 = false;
_isValue26 = false;
_isValue27 = false;
_isValue28 = false;
_isValue29 = false;
_isValue30 = false;
_isValue31 = false;
}
#endregion
#region Properties
#region EmployeeID
private int _employeeID;
public int EmployeeID
{
get { return _employeeID; }
set { _employeeID = value; }
}
#endregion
#region SalaryMonth
private DateTime _salaryMonth;
public DateTime SalaryMonth
{
get { return _salaryMonth; }
set { _salaryMonth = value; }
}
#endregion
#region ItemName
private string _itemName;
public string ItemName
{
get { return _itemName; }
set { _itemName = value; }
}
#endregion
#region ItemID
private int _itemID;
public int ItemID
{
get { return _itemID; }
set { _itemID = value; }
}
#endregion
#region Amount
private double _amount;
public double Amount
{
get { return _amount; }
set { _amount = value; }
}
#endregion
#region FieldID
private int _fieldID;
public int FieldID
{
get { return _fieldID; }
set { _fieldID = value; }
}
#endregion
#region IsUpdated
private bool _isUpdated;
public bool IsUpdated
{
get { return _isUpdated; }
set { _isUpdated = value; }
}
#endregion
#region ItemType
private enumPayrollComponentType _itemType;
public enumPayrollComponentType ItemType
{
get { return _itemType; }
set { _itemType = value; }
}
#endregion
#region Value1
private double _value1;
public double Value1
{
get { return _value1; }
set { _value1 = value; }
}
#endregion
#region Value2
private double _value2;
public double Value2
{
get { return _value2; }
set { _value2 = value; }
}
#endregion
#region Value3
private double _value3;
public double Value3
{
get { return _value3; }
set { _value3 = value; }
}
#endregion
#region Value4
private double _value4;
public double Value4
{
get { return _value4; }
set { _value4 = value; }
}
#endregion
#region Value5
private double _value5;
public double Value5
{
get { return _value5; }
set { _value5 = value; }
}
#endregion
#region Value6
private double _value6;
public double Value6
{
get { return _value6; }
set { _value6 = value; }
}
#endregion
#region Value7
private double _value7;
public double Value7
{
get { return _value7; }
set { _value7 = value; }
}
#endregion
#region Value8
private double _value8;
public double Value8
{
get { return _value8; }
set { _value8 = value; }
}
#endregion
#region Value9
private double _value9;
public double Value9
{
get { return _value9; }
set { _value9 = value; }
}
#endregion
#region Value10
private double _value10;
public double Value10
{
get { return _value10; }
set { _value10 = value; }
}
#endregion
#region Value11
private double _value11;
public double Value11
{
get { return _value11; }
set { _value11 = value; }
}
#endregion
#region Value12
private double _value12;
public double Value12
{
get { return _value12; }
set { _value12 = value; }
}
#endregion
#region Value13
private double _value13;
public double Value13
{
get { return _value13; }
set { _value13 = value; }
}
#endregion
#region Value14
private double _value14;
public double Value14
{
get { return _value14; }
set { _value14 = value; }
}
#endregion
#region Value15
private double _value15;
public double Value15
{
get { return _value15; }
set { _value15 = value; }
}
#endregion
#region Value16
private double _value16;
public double Value16
{
get { return _value16; }
set { _value16 = value; }
}
#endregion
#region Value17
private double _value17;
public double Value17
{
get { return _value17; }
set { _value17 = value; }
}
#endregion
#region Value18
private double _value18;
public double Value18
{
get { return _value18; }
set { _value18 = value; }
}
#endregion
#region Value19
private double _value19;
public double Value19
{
get { return _value19; }
set { _value19 = value; }
}
#endregion
#region Value20
private double _value20;
public double Value20
{
get { return _value20; }
set { _value20 = value; }
}
#endregion
#region Value21
private double _value21;
public double Value21
{
get { return _value21; }
set { _value21 = value; }
}
#endregion
#region Value22
private double _value22;
public double Value22
{
get { return _value22; }
set { _value22 = value; }
}
#endregion
#region Value23
private double _value23;
public double Value23
{
get { return _value23; }
set { _value23 = value; }
}
#endregion
#region Value24
private double _value24;
public double Value24
{
get { return _value24; }
set { _value24 = value; }
}
#endregion
#region Value25
private double _value25;
public double Value25
{
get { return _value25; }
set { _value25 = value; }
}
#endregion
#region Value26
private double _value26;
public double Value26
{
get { return _value26; }
set { _value26 = value; }
}
#endregion
#region Value27
private double _value27;
public double Value27
{
get { return _value27; }
set { _value27 = value; }
}
#endregion
#region Value28
private double _value28;
public double Value28
{
get { return _value28; }
set { _value28 = value; }
}
#endregion
#region Value29
private double _value29;
public double Value29
{
get { return _value29; }
set { _value29 = value; }
}
#endregion
#region Value30
private double _value30;
public double Value30
{
get { return _value30; }
set { _value30 = value; }
}
#endregion
#region Value31
private double _value31;
public double Value31
{
get { return _value31; }
set { _value31 = value; }
}
#endregion
#region IsEditable : Bool
private bool _isEditable;
public bool IsEditable
{
get { return _isEditable; }
set { _isEditable = value; }
}
#endregion
#region Adjustment
private double _adjustment;
public double Adjustment
{
get { return _adjustment; }
set { _adjustment = value; }
}
#endregion
#region IsAddition
private bool _isAddition;
public bool IsAddition
{
get { return _isAddition; }
set { _isAddition = value; }
}
#endregion
//#region Total
//public double Total
//{
// get
// {
// return Value1 + Value2 + Value3 + Value4 + Value5 + Value6 + Value7 + Value8 + Value9 + Value10 +
// Value11 + Value12 + Value13 + Value14 + Value15 + Value16 + Value17 + Value18 + Value19 + Value20 +
// Value21 + Value22 + Value23 + Value24 + Value25 + Value26 + Value27 + Value28 + Value29 + Value30 + Value31 + Adjustment;
// }
//}
//#endregion
#region Total
private double _total;
public double Total
{
get { return _total; }
set { _total = value; }
}
#endregion
#region IsValue1
private bool _isValue1;
public bool IsValue1
{
get { return _isValue1; }
set { _isValue1 = value; }
}
#endregion
#region IsValue2
private bool _isValue2;
public bool IsValue2
{
get { return _isValue2; }
set { _isValue2 = value; }
}
#endregion
#region IsValue3
private bool _isValue3;
public bool IsValue3
{
get { return _isValue3; }
set { _isValue3 = value; }
}
#endregion
#region IsValue4
private bool _isValue4;
public bool IsValue4
{
get { return _isValue4; }
set { _isValue4 = value; }
}
#endregion
#region IsValue5
private bool _isValue5;
public bool IsValue5
{
get { return _isValue5; }
set { _isValue5 = value; }
}
#endregion
#region IsValue6
private bool _isValue6;
public bool IsValue6
{
get { return _isValue6; }
set { _isValue6 = value; }
}
#endregion
#region IsValue3
private bool _isValue7;
public bool IsValue7
{
get { return _isValue7; }
set { _isValue7 = value; }
}
#endregion
#region IsValue8
private bool _isValue8;
public bool IsValue8
{
get { return _isValue8; }
set { _isValue8 = value; }
}
#endregion
#region IsValue9
private bool _isValue9;
public bool IsValue9
{
get { return _isValue9; }
set { _isValue9 = value; }
}
#endregion
#region IsValue10
private bool _isValue10;
public bool IsValue10
{
get { return _isValue10; }
set { _isValue10 = value; }
}
#endregion
#region IsValue11
private bool _isValue11;
public bool IsValue11
{
get { return _isValue11; }
set { _isValue11 = value; }
}
#endregion
#region IsValue12
private bool _isValue12;
public bool IsValue12
{
get { return _isValue12; }
set { _isValue12 = value; }
}
#endregion
#region IsValue13
private bool _isValue13;
public bool IsValue13
{
get { return _isValue13; }
set { _isValue13 = value; }
}
#endregion
#region IsValue14
private bool _isValue14;
public bool IsValue14
{
get { return _isValue14; }
set { _isValue14 = value; }
}
#endregion
#region IsValue15
private bool _isValue15;
public bool IsValue15
{
get { return _isValue15; }
set { _isValue15 = value; }
}
#endregion
#region IsValue16
private bool _isValue16;
public bool IsValue16
{
get { return _isValue16; }
set { _isValue16 = value; }
}
#endregion
#region IsValue17
private bool _isValue17;
public bool IsValue17
{
get { return _isValue17; }
set { _isValue17 = value; }
}
#endregion
#region IsValue18
private bool _isValue18;
public bool IsValue18
{
get { return _isValue18; }
set { _isValue18 = value; }
}
#endregion
#region IsValue19
private bool _isValue19;
public bool IsValue19
{
get { return _isValue19; }
set { _isValue19 = value; }
}
#endregion
#region IsValue20
private bool _isValue20;
public bool IsValue20
{
get { return _isValue20; }
set { _isValue20 = value; }
}
#endregion
#region IsValue21
private bool _isValue21;
public bool IsValue21
{
get { return _isValue21; }
set { _isValue21 = value; }
}
#endregion
#region IsValue22
private bool _isValue22;
public bool IsValue22
{
get { return _isValue22; }
set { _isValue22 = value; }
}
#endregion
#region IsValue23
private bool _isValue23;
public bool IsValue23
{
get { return _isValue23; }
set { _isValue23 = value; }
}
#endregion
#region IsValue24
private bool _isValue24;
public bool IsValue24
{
get { return _isValue24; }
set { _isValue24 = value; }
}
#endregion
#region IsValue25
private bool _isValue25;
public bool IsValue25
{
get { return _isValue25; }
set { _isValue25 = value; }
}
#endregion
#region IsValue26
private bool _isValue26;
public bool IsValue26
{
get { return _isValue26; }
set { _isValue26 = value; }
}
#endregion
#region IsValue27
private bool _isValue27;
public bool IsValue27
{
get { return _isValue27; }
set { _isValue27 = value; }
}
#endregion
#region IsValue28
private bool _isValue28;
public bool IsValue28
{
get { return _isValue28; }
set { _isValue28 = value; }
}
#endregion
#region IsValue29
private bool _isValue29;
public bool IsValue29
{
get { return _isValue29; }
set { _isValue29 = value; }
}
#endregion
#region IsValue30
private bool _isValue30;
public bool IsValue30
{
get { return _isValue30; }
set { _isValue30 = value; }
}
#endregion
#region IsValue31
private bool _isValue31;
public bool IsValue31
{
get { return _isValue31; }
set { _isValue31 = value; }
}
#endregion
#endregion
//#region Function
//public static ObjectsTemplate<AttnMonthlyBenefit> Get()
//{
// ObjectsTemplate<AttnMonthlyBenefit> attnMonthlyBenefits = null;
// #region Cache Header
// attnMonthlyBenefits = (ObjectsTemplate<AttnMonthlyBenefit>)_cache["Get"];
// if (attnMonthlyBenefits != null)
// return attnMonthlyBenefits;
// #endregion
// attnMonthlyBenefits = AttnMonthlyBenefit.Service.Get();
// #region Cache Footer
// _cache.Add(attnMonthlyBenefits, "Get");
// #endregion
// return attnMonthlyBenefits;
//}
//public static ObjectsTemplate<AttnMonthlyBenefit> Get(int empId)
//{
// ObjectsTemplate<AttnMonthlyBenefit> attnMonthlyBenefits = null;
// #region Cache Header
// attnMonthlyBenefits = (ObjectsTemplate<AttnMonthlyBenefit>)_cache["Get"];
// if (attnMonthlyBenefits != null)
// return attnMonthlyBenefits;
// #endregion
// attnMonthlyBenefits = AttnMonthlyBenefit.Service.Get(empId);
// #region Cache Footer
// _cache.Add(attnMonthlyBenefits, "Get", empId);
// #endregion
// return attnMonthlyBenefits;
//}
//public static ObjectsTemplate<AttnMonthlyBenefit> Get(DateTime sMonth)
//{
// ObjectsTemplate<AttnMonthlyBenefit> attnMonthlyBenefits = null;
// #region Cache Header
// attnMonthlyBenefits = (ObjectsTemplate<AttnMonthlyBenefit>)_cache["GetBySMonth"];
// if (attnMonthlyBenefits != null)
// return attnMonthlyBenefits;
// #endregion
// attnMonthlyBenefits = AttnMonthlyBenefit.Service.Get(sMonth);
// #region Cache Footer
// _cache.Add(attnMonthlyBenefits, "GetBySMonth", sMonth);
// #endregion
// return attnMonthlyBenefits;
//}
//public static ObjectsTemplate<AttnMonthlyBenefit> Get(int empId, DateTime sMonth)
//{
// ObjectsTemplate<AttnMonthlyBenefit> attnMonthlyBenefits = null;
// #region Cache Header
// attnMonthlyBenefits = (ObjectsTemplate<AttnMonthlyBenefit>)_cache["Get"];
// if (attnMonthlyBenefits != null)
// return attnMonthlyBenefits;
// #endregion
// attnMonthlyBenefits = AttnMonthlyBenefit.Service.Get(empId, sMonth);
// #region Cache Footer
// _cache.Add(attnMonthlyBenefits, "Get", empId);
// #endregion
// return attnMonthlyBenefits;
//}
//public static ObjectsTemplate<AttnMonthlyBenefit> Get(int empId, DateTime fromMonth, DateTime toMonth)
//{
// ObjectsTemplate<AttnMonthlyBenefit> attnMonthlyBenefits = null;
// #region Cache Header
// attnMonthlyBenefits = (ObjectsTemplate<AttnMonthlyBenefit>)_cache["Get"];
// if (attnMonthlyBenefits != null)
// return attnMonthlyBenefits;
// #endregion
// attnMonthlyBenefits = AttnMonthlyBenefit.Service.Get(empId, fromMonth, toMonth);
// #region Cache Footer
// _cache.Add(attnMonthlyBenefits, "Get", empId);
// #endregion
// return attnMonthlyBenefits;
//}
//public static ObjectsTemplate<AttnMonthlyBenefit> Get(string empIds, DateTime fromMonth, DateTime toMonth)
//{
// ObjectsTemplate<AttnMonthlyBenefit> attnMonthlyBenefits = null;
// #region Cache Header
// attnMonthlyBenefits = (ObjectsTemplate<AttnMonthlyBenefit>)_cache["Get"];
// if (attnMonthlyBenefits != null)
// return attnMonthlyBenefits;
// #endregion
// attnMonthlyBenefits = AttnMonthlyBenefit.Service.Get(empIds, fromMonth, toMonth);
// #region Cache Footer
// _cache.Add(attnMonthlyBenefits, "Get", empIds);
// #endregion
// return attnMonthlyBenefits;
//}
//public static ObjectsTemplate<AttnMonthlyBenefit> Get(DateTime fromMonth, DateTime toMonth)
//{
// ObjectsTemplate<AttnMonthlyBenefit> attnMonthlyBenefits = null;
// #region Cache Header
// attnMonthlyBenefits = (ObjectsTemplate<AttnMonthlyBenefit>)_cache["Get"];
// if (attnMonthlyBenefits != null)
// return attnMonthlyBenefits;
// #endregion
// attnMonthlyBenefits = AttnMonthlyBenefit.Service.Get(fromMonth, toMonth);
// #region Cache Footer
// _cache.Add(attnMonthlyBenefits, "Get");
// #endregion
// return attnMonthlyBenefits;
//}
//public static ObjectsTemplate<AttnMonthlyBenefit> Get(string empIds, DateTime sMonth)
//{
// ObjectsTemplate<AttnMonthlyBenefit> attnMonthlyBenefits = null;
// #region Cache Header
// attnMonthlyBenefits = (ObjectsTemplate<AttnMonthlyBenefit>)_cache["Get"];
// if (attnMonthlyBenefits != null)
// return attnMonthlyBenefits;
// #endregion
// attnMonthlyBenefits = AttnMonthlyBenefit.Service.Get(empIds, sMonth);
// #region Cache Footer
// _cache.Add(attnMonthlyBenefits, "Get", empIds);
// #endregion
// return attnMonthlyBenefits;
//}
//public static ObjectsTemplate<AttnMonthlyBenefit> GetByDept(string deptId, DateTime sMonth)
//{
// ObjectsTemplate<AttnMonthlyBenefit> attnMonthlyBenefits = null;
// #region Cache Header
// attnMonthlyBenefits = (ObjectsTemplate<AttnMonthlyBenefit>)_cache["Get"];
// if (attnMonthlyBenefits != null)
// return attnMonthlyBenefits;
// #endregion
// attnMonthlyBenefits = AttnMonthlyBenefit.Service.GetByDept(deptId, sMonth);
// #region Cache Footer
// _cache.Add(attnMonthlyBenefits, "Get", deptId);
// #endregion
// return attnMonthlyBenefits;
//}
//internal static double CalculateOvertimeValue(AttnWiseAllowance oAttnWiseAllowance, DailyAttnProcess dailyAttnProcess)
//{
// double value = 0;
// Grade oGrade = dailyAttnProcess.Employee.Grade;
// if (oGrade != null)
// {
// var termParameters = TermParameter.Get().Where(x => x.TermID.Integer == oAttnWiseAllowance.ProvisionID);
// TermParameter termParameter = null;
// foreach (var item in termParameters)
// {
// var setupDetails = SetupDetail.GetParameters(EnumParameterSetup.OT, item.ID.Integer);
// if (setupDetails.Any(x => x.TranID.Integer == oGrade.ID.Integer))
// {
// termParameter = item;
// break;
// }
// }
// if (termParameter != null)
// {
// switch (termParameter.Type)
// {
// case EnumOverTimeType.DailyFlatAmount:
// case EnumOverTimeType.DailyBasicPercent:
// case EnumOverTimeType.FixedAmount:
// value = 1 * oAttnWiseAllowance.Multiple;
// break;
// case EnumOverTimeType.HourlyFlatAmount:
// case EnumOverTimeType.HourlyBasicPercent:
// value = dailyAttnProcess.OTHour * oAttnWiseAllowance.Multiple;
// break;
// case EnumOverTimeType.HoursOfMonth:
// case EnumOverTimeType.Slab:
// case EnumOverTimeType.AnyAmount:
// case EnumOverTimeType.NONE:
// break;
// default:
// break;
// }
// }
// }
// return value;
//}
//internal static double CalculateOvertimeAmount(AttnWiseAllowance oAttnWiseAllowance, DailyAttnProcess dailyAttnProcess, double totalValue)
//{
// double amount = 0;
// Grade oGrade = dailyAttnProcess.Employee.Grade;
// if (oGrade != null)
// {
// var termParameters = TermParameter.Get().Where(x => x.TermID.Integer == oAttnWiseAllowance.ProvisionID);
// TermParameter termParameter = null;
// foreach (var item in termParameters)
// {
// var setupDetails = SetupDetail.GetParameters(EnumParameterSetup.OT, item.ID.Integer);
// if (setupDetails.Any(x => x.TranID.Integer == oGrade.ID.Integer))
// {
// termParameter = item;
// break;
// }
// }
// if (termParameter != null)
// {
// switch (termParameter.Type)
// {
// case EnumOverTimeType.DailyFlatAmount:
// case EnumOverTimeType.FixedAmount:
// case EnumOverTimeType.HourlyFlatAmount:
// amount = totalValue * termParameter.Amount;
// break;
// case EnumOverTimeType.DailyBasicPercent:
// amount = (dailyAttnProcess.Employee.BasicSalary / Convert.ToDouble(DateTime.DaysInMonth(dailyAttnProcess.AttnDate.Year, dailyAttnProcess.AttnDate.Month)))
// * totalValue * (termParameter.Amount / 100);
// break;
// case EnumOverTimeType.HourlyBasicPercent:
// double hours = (double)ConfigurationManager.GetIntValue("overtime", "hoursonmonth", EnumConfigurationType.Logic);
// if (hours <= 0) hours = 180.0;
// amount = (dailyAttnProcess.Employee.BasicSalary / hours) * totalValue * (termParameter.Amount / 100);
// break;
// case EnumOverTimeType.HoursOfMonth:
// case EnumOverTimeType.Slab:
// case EnumOverTimeType.AnyAmount:
// case EnumOverTimeType.NONE:
// break;
// default:
// break;
// }
// }
// }
// return amount;
//}
//public void UpdateOverTimeData(DateTime salaryMonth, enumPayrollComponentType itemType, string value, string isValue, DateTime attnDate)
//{
// AttnMonthlyBenefit.Service.UpdateOverTimeData(salaryMonth, itemType, value, isValue, attnDate);
//}
//public void FixOverTimeData()
//{
// AttnMonthlyBenefit.Service.FixOverTimeData();
//}
//public void Save(ObjectsTemplate<AttnMonthlyBenefit> attnMonthlyBenefits, ObjectsTemplate<AttnBenefitAuditTrail> _oAuditTrails)
//{
// attnMonthlyBenefits.ForEach(x => x.SetAuditTrailProperties());
// AttnMonthlyBenefit.Service.Save(attnMonthlyBenefits, _oAuditTrails);
//}
//public void Save(ObjectsTemplate<AttnMonthlyBenefit> attnMonthlyBenefits)
//{
// attnMonthlyBenefits.ForEach(x => x.SetAuditTrailProperties());
// AttnMonthlyBenefit.Service.Save(attnMonthlyBenefits);
//}
////public void SaveAsBenifits(ObjectsTemplate<ADParameterEmployee> adParamEmps, ObjectsTemplate<EmployeeOverTime> empOverTimes)
////{
//// this.SetAuditTrailProperties();
//// AttnMonthlyBenefit.Service.SaveAsBenifits(adParamEmps, empOverTimes);
////}
////public List<SalaryProcessStatus> Process()
////{
//// ObjectsTemplate<OTSubmit> otSubmitsPreviousMonthtemp = new ObjectsTemplate<OTSubmit>();
//// ObjectsTemplate<EmployeeOverTime> EmpOverTimes = new ObjectsTemplate<EmployeeOverTime>();
//// ObjectsTemplate<Employee> _employees = Employee.Get();
//// List<SalaryProcessStatus> ErrorList = new List<SalaryProcessStatus>();
//// ObjectsTemplate<TermParameter> termParameters = TermParameter.Get();
//// ObjectsTemplate<Term> _overTimes = Term.Get(EnumStatus.Regardless);
//// Term overTime = null;
//// TermParameter tp = new TermParameter();
//// List<EmployeeSetupParameter> appOtParam = tp.ApplicableParameters(_employees);
//// DateTime fromDate = GlobalFunctions.FirstDateOfMonth(Payroll.BO.SystemInformation.CurrentSysInfo.NextPayProcessDate);
//// fromDate = fromDate.AddMonths(-1);
//// fromDate = new DateTime(fromDate.Year, fromDate.Month, 11);
//// DateTime toDate = GlobalFunctions.LastDateOfMonth(Payroll.BO.SystemInformation.CurrentSysInfo.NextPayProcessDate);
//// toDate = new DateTime(toDate.Year, toDate.Month, 10);
//// ObjectsTemplate<EmployeeUnAuthorizeLeave> uleaves = new ObjectsTemplate<EmployeeUnAuthorizeLeave>();
//// ObjectsTemplate<ADParameterEmployee> AdparamEmployee = new ObjectsTemplate<ADParameterEmployee>();
//// ObjectsTemplate<AttnNationalHoliday> _attnNationalHolidays = AttnNationalHoliday.Get(EnumStatus.Active);
//// int normalOtID = 0;
//// int holidayOtID = 0;
//// ObjectsTemplate<OTSubmit> otSubmits = OTSubmit.GetBySalaryMonth(Payroll.BO.SystemInformation.CurrentSysInfo.NextPayProcessDate, EnumWFAttnStatus.DHApproved);
//// DateTime lastAttnMonth = Payroll.BO.SystemInformation.CurrentSysInfo.NextPayProcessDate;
//// lastAttnMonth = new DateTime(lastAttnMonth.Year, lastAttnMonth.Month, 10);
//// otSubmits = otSubmits.Where(o => o.OTSubmitDate <= lastAttnMonth).ToObjectsTemplate();
//// DateTime previousSalaryMonth = Payroll.BO.SystemInformation.CurrentSysInfo.NextPayProcessDate.AddMonths(-1);
//// previousSalaryMonth = GlobalFunctions.LastDateOfMonth(previousSalaryMonth);
//// ObjectsTemplate<OTSubmit> otSubmitsPreviousMonth = OTSubmit.GetBySalaryMonth(previousSalaryMonth, EnumWFAttnStatus.DHApproved);
//// lastAttnMonth = new DateTime(previousSalaryMonth.Year, previousSalaryMonth.Month, 10);
//// otSubmitsPreviousMonthtemp = otSubmitsPreviousMonth.Where(o => o.OTSubmitDate > lastAttnMonth).ToObjectsTemplate();
//// otSubmits.AddRange(otSubmitsPreviousMonthtemp);
//// DateTime lastMonthOTProcessCreateDate = OTProcess.GetOTProcessCreationDate(previousSalaryMonth);
//// otSubmitsPreviousMonthtemp = otSubmitsPreviousMonth.Where(o => o.DHApprovedDate > lastMonthOTProcessCreateDate).ToObjectsTemplate();
//// otSubmits.AddRange(otSubmitsPreviousMonthtemp);
//// otSubmits = otSubmits
//// .GroupBy(p => p.ID)
//// .Select(g => g.First())
//// .ToObjectsTemplate();
//// normalOtID = ConfigurationManager.GetIntValue("overtime", "normalotid", EnumConfigurationType.Logic);
//// holidayOtID = ConfigurationManager.GetIntValue("overtime", "holidayotid", EnumConfigurationType.Logic);
//// Employee employee = null;
//// ObjectsTemplate<EmployeeWorkPlanSetup> _empWPSetups = EmployeeWorkPlanSetup.Get();
//// EmployeeWorkPlanSetup empWPSetup = null;
//// AttnNationalHoliday holiday = null;
//// ID workPlanGroupID = null;
//// ObjectsTemplate<Employee> _distictEmployees = new ObjectsTemplate<Employee>();
//// ObjectsTemplate<EmployeeOverTime> _empOverTimes = null;
//// ObjectsTemplate<EmployeeOverTime> _empOTimesNormals = null;
//// ObjectsTemplate<EmployeeOverTime> _empOTimesFestivals = null;
//// EmployeeOverTime _empOTime = null;
//// #region Normal OT Calculation
//// if (normalOtID != 0 && holidayOtID != 0)
//// {
//// if (_overTimes != null && _overTimes.Count > 0)
//// {
//// foreach (OTSubmit otSmit in otSubmits)
//// {
//// employee = _employees.Where(o => o.ID == otSmit.EmployeeID).FirstOrDefault();
//// if (employee == null)
//// continue;
//// if (!_distictEmployees.Any(o => o.ID == employee.ID))
//// _distictEmployees.Add(employee);
//// EmployeeSetupParameter esp = appOtParam.Find(delegate (EmployeeSetupParameter oemp) { return (oemp.Employee.ID == employee.ID); });
//// empWPSetup = _empWPSetups.Where(o => o.EmployeeID == employee.ID).FirstOrDefault();
//// if (empWPSetup != null)
//// workPlanGroupID = empWPSetup.WorkPlanGroupID;
//// else
//// workPlanGroupID = null;
//// //Mashiur
//// //holiday = AttnNationalHoliday.GetHoliday(_attnNationalHolidays, otSmit.OTSubmitDate.Date, employee.LocationID, workPlanGroupID);
//// //if (holiday == null)
//// // overTime = _overTimes.Where(o => o.ID.Integer == normalOtID).FirstOrDefault();
//// //else
//// //{
//// // if (holiday.HolidayType == HolidayType.General_4_Times)
//// // overTime = _overTimes.Where(o => o.ID.Integer == holidayOtID).FirstOrDefault();
//// // else
//// // overTime = _overTimes.Where(o => o.ID.Integer == normalOtID).FirstOrDefault();
//// //}
//// bool paramNotFound = true;
//// if (esp != null)
//// {
//// for (int i = 0; i <= esp.ParameterIDs.Count - 1; i++)
//// {
//// TermParameter tpt = termParameters.Find(delegate (TermParameter tm)
//// {
//// return (tm.ID.Integer == esp.ParameterIDs[i])
//// && tm.TermID == overTime.ID;
//// });
//// if (tpt != null)
//// {
//// EmployeeOverTime empot = new EmployeeOverTime();
//// empot.EmployeeID = employee.ID;
//// empot.OTMonth = Payroll.BO.SystemInformation.CurrentSysInfo.NextPayProcessDate;
//// empot.PayrollTypeID = Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID;
//// empot.TermID = overTime.ID;
//// empot.TermParameterID = ID.FromInteger(esp.ParameterIDs[i]);
//// TermParameter op = termParameters.GetItem(empot.TermParameterID);
//// empot.OTHours = otSmit.DHOTHour;
//// empot.Value = op.Amount;
//// empot.CreatedBy = User.CurrentUser.LogInPayrollTypeID;
//// empot.CreatedDate = DateTime.Today;
//// empot.MonthDate = Payroll.BO.SystemInformation.CurrentSysInfo.NextPayProcessDate;
//// EmpOverTimes.Add(empot);
//// paramNotFound = false;
//// break;
//// }
//// }
//// if (paramNotFound == true)
//// {
//// //ErrorList.Add(new SalaryProcessStatus(employee.EmployeeNo, employee.Name, "OverTime setup not found"));
//// continue;
//// }
//// }
//// else
//// {
//// //ErrorList.Add(new SalaryProcessStatus(employee.EmployeeNo, employee.Name, "OverTime setup not found"));
//// continue;
//// }
//// }
//// _empOverTimes = new ObjectsTemplate<EmployeeOverTime>();
//// foreach (Employee oItem in _distictEmployees)
//// {
//// _empOTimesNormals = EmpOverTimes.Where(o => o.EmployeeID == oItem.ID && o.TermID.Integer == normalOtID).ToObjectsTemplate();
//// _empOTimesFestivals = EmpOverTimes.Where(o => o.EmployeeID == oItem.ID && o.TermID.Integer == holidayOtID).ToObjectsTemplate();
//// if (_empOTimesNormals.Count > 0)
//// {
//// _empOTime = new EmployeeOverTime();
//// _empOTime.EmployeeID = oItem.ID;
//// _empOTime.OTMonth = Payroll.BO.SystemInformation.CurrentSysInfo.NextPayProcessDate;
//// _empOTime.PayrollTypeID = Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID;
//// _empOTime.TermID = ID.FromInteger(normalOtID);
//// _empOTime.TermParameterID = _empOTimesNormals[0].TermParameterID;
//// _empOTime.OTHours = _empOTimesNormals.Sum(o => o.OTHours);
//// _empOTime.Value = _empOTimesNormals[0].Value;
//// _empOTime.CreatedBy = User.CurrentUser.LogInPayrollTypeID;
//// _empOTime.CreatedDate = DateTime.Today;
//// _empOTime.MonthDate = Payroll.BO.SystemInformation.CurrentSysInfo.NextPayProcessDate;
//// _empOverTimes.Add(_empOTime);
//// }
//// if (_empOTimesFestivals.Count > 0)
//// {
//// _empOTime = new EmployeeOverTime();
//// _empOTime.EmployeeID = oItem.ID;
//// _empOTime.OTMonth = Payroll.BO.SystemInformation.CurrentSysInfo.NextPayProcessDate;
//// _empOTime.PayrollTypeID = Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID;
//// _empOTime.TermID = ID.FromInteger(holidayOtID);
//// _empOTime.TermParameterID = _empOTimesFestivals[0].TermParameterID;
//// _empOTime.OTHours = _empOTimesFestivals.Sum(o => o.OTHours);
//// _empOTime.Value = _empOTimesFestivals[0].Value;
//// _empOTime.CreatedBy = User.CurrentUser.LogInPayrollTypeID;
//// _empOTime.CreatedDate = DateTime.Today;
//// _empOTime.MonthDate = Payroll.BO.SystemInformation.CurrentSysInfo.NextPayProcessDate;
//// _empOverTimes.Add(_empOTime);
//// }
//// }
//// }
//// else
//// {
//// //ErrorList.Add(new SalaryProcessStatus("", "", "No OverTime Type found in the System."));
//// }
//// }
//// else
//// {
//// //ErrorList.Add(new SalaryProcessStatus("", "", "No OverTime Id found in the logic configuration."));
//// }
//// #endregion
//// if (ErrorList.Count == 0)
//// {
//// if (AdparamEmployee.Count > 0 || _empOverTimes.Count > 0 || uleaves.Count > 0)
//// {
//// AttnMonthlyBenefit.Service.SaveAsBenifits(AdparamEmployee, _empOverTimes, uleaves);
//// }
//// //else ErrorList.Add(new SalaryProcessStatus("", "", "There is nothing to process or Save. please check your Attandance data and related setups"));
//// }
//// return ErrorList;
////}
////public static DateTime GetAttandaceSalaryMonth(DateTime dDate)
////{
//// if (dDate.Day >= 11)
//// return GlobalFunctions.LastDateOfMonth(dDate.AddMonths(1));
//// else return GlobalFunctions.LastDateOfMonth(dDate);
////}
////public AttnMonthlyBenefit DeepCopy()
////{
//// AttnMonthlyBenefit oAttnMnthly = new AttnMonthlyBenefit();
//// oAttnMnthly = this.Clone() as AttnMonthlyBenefit;
//// return oAttnMnthly;
////}
//#endregion
//#region Service Factory
//internal static IAttnMonthlyBenefitService Service
//{
// get { return Services.Factory.CreateService<IAttnMonthlyBenefitService>(typeof(IAttnMonthlyBenefitService)); }
//}
//#endregion
}
#endregion
#region AttnMnthBenefitValueMapper
public class AttnMnthBenefitValueMapper
{
#region Declaration
private Dictionary<DateTime, string> mapper = null;
private Dictionary<string, DateTime> mapperInverse = null;
private DateTime month;
private DateTime monthStart, monthEnd;
#endregion
#region Properties
public DateTime ApplicableMonth
{
get { return month; }
}
public IEnumerable<KeyValuePair<string, DateTime>> MapperEnumarator
{
get
{
foreach (KeyValuePair<string, DateTime> item in this.mapperInverse)
yield return item;
}
}
public int MapperItemCount
{
get { return mapper.Count; }
}
#endregion
#region Constructor
public AttnMnthBenefitValueMapper(DateTime currentDate, out DateTime applicableMonth)
{
applicableMonth = currentDate.LastDateOfMonth();
//CalcullateMonthStartEnd(currentDate);
if (currentDate > monthEnd)
{
applicableMonth = currentDate.AddMonths(1).LastDateOfMonth();
//CalcullateMonthStartEnd(currentDate.AddMonths(1));
}
month = applicableMonth;
//CalcullateMapper();
}
public AttnMnthBenefitValueMapper(DateTime currentDate, int monthStartDate, out DateTime applicableMonth)
{
monthStart = GlobalFunctions.AttendanceMonthStart(currentDate, monthStartDate);
monthEnd = GlobalFunctions.AttendanceMonthEnd(currentDate, monthStartDate);
applicableMonth = GlobalFunctions.GetAttandaceSalaryMonth(currentDate, monthStartDate);
//CalcullateMonthStartEnd(currentDate);
month = applicableMonth;
mapper = new Dictionary<DateTime, string>();
mapperInverse = new Dictionary<string, DateTime>();
int value = 1;
for (DateTime currDate = monthStart; currDate <= monthEnd; currDate = currDate.AddDays(1), value++)
{
mapper.Add(currDate, "Value" + value);
mapperInverse.Add("Value" + value, currDate);
}
}
#endregion
//#region Private Functions
//private void CalcullateMonthStartEnd(DateTime currentDate)
//{
// int startIndex = ConfigurationManager.GetIntValue("attendence", "monthstartday", EnumConfigurationType.Logic);
// if (startIndex == 0)
// startIndex = 1;
// monthStart = startIndex == 1 ? currentDate : currentDate.AddMonths(-1);
// monthStart = new DateTime(monthStart.Year, monthStart.Month, startIndex);
// monthEnd = monthStart.AddMonths(1).AddDays(-1);
//}
//private void CalcullateMapper()
//{
// mapper = new Dictionary<DateTime, string>();
// mapperInverse = new Dictionary<string, DateTime>();
// int value = 1;
// for (DateTime currDate = monthStart; currDate <= monthEnd; currDate = currDate.AddDays(1), value++)
// {
// mapper.Add(currDate, "Value" + value);
// mapperInverse.Add("Value" + value, currDate);
// }
//}
//#endregion
#region Indexers
public string this[DateTime date]
{
get { return mapper.ContainsKey(date.Date) ? mapper[date.Date] : string.Empty; }
}
public DateTime this[string valuePropertyName]
{
get
{
return mapperInverse.ContainsKey(valuePropertyName)
? mapperInverse[valuePropertyName]
: DateTime.MinValue;
}
}
public DateTime this[int valueIntPart]
{
get
{
return mapperInverse.ContainsKey("Value" + valueIntPart)
? mapperInverse["Value" + valueIntPart]
: DateTime.MinValue;
}
}
#endregion
}
#endregion
#region IAttnMonthlyBenefitService Service
public interface IAttnMonthlyBenefitService
{
void Save(List<AttnMonthlyBenefit> attnMonthlyBenefits, List<AttnBenefitAuditTrail> _oAuditTrails);
List<AttnMonthlyBenefit> Get();
List<AttnMonthlyBenefit> Get(int empId);
List<AttnMonthlyBenefit> Get(DateTime sMonth);
List<AttnMonthlyBenefit> Get(int empId, DateTime sMonth);
List<AttnMonthlyBenefit> Get(string empIds, DateTime sMonth);
List<AttnMonthlyBenefit> Get(int empId, DateTime fromMonth, DateTime toMonth);
List<AttnMonthlyBenefit> Get(DateTime fromMonth, DateTime toMonth);
List<AttnMonthlyBenefit> Get(string empIds, DateTime fromMonth, DateTime toMonth);
void Save(List<AttnMonthlyBenefit> medicalBenifitSetups);
void SaveAsBenifits(List<ADParameterEmployee> adEmployee, List<EmployeeOverTime> empOverTimes, List<EmployeeUnAuthorizeLeave> unauthLeaves);
void UpdateOverTimeData(DateTime salaryMonth, enumPayrollComponentType itemType, string value, string isValue, DateTime attnDate);
//void Delete(AttnMonthlyBenefit atnMB);
void FixOverTimeData();
List<SalaryProcessStatus> Process(int PayrollTypeId);
List<AttnMonthlyBenefit> GetByDept(string deptId, DateTime sMonth);
}
#endregion
}