Merge pull request 'OT process' (#41) from dev_chapal into devqc

Reviewed-on: http://103.197.204.162:3025/CelHRTeam/EchoTex_Payroll/pulls/41
This commit is contained in:
chapal 2025-04-28 16:45:48 +06:00
commit 2791455be2
3 changed files with 76 additions and 27 deletions

View File

@ -842,7 +842,22 @@ namespace HRM.DA
} }
return tc.ExecuteReader(strSQLQuery); return tc.ExecuteReader(strSQLQuery);
} }
internal static IDataReader GetForOTprocess(TransactionContext tc, EnumEmployeeStatus status, int payrollTypeID, DateTime salarymonth )
{
string strSQLQuery = string.Empty;
if (status == EnumEmployeeStatus.Regardless)
{
strSQLQuery = SQLParser.MakeSQL("SELECT * FROM Employee WHERE PAYROLLTYPEID = %n ", payrollTypeID);
}
else
{
strSQLQuery = SQLParser.MakeSQL("SELECT * FROM Employee WHERE (Status = %n or endofcontractdate between %d and %d) AND PAYROLLTYPEID = %n ",
(int)status,GlobalFunctions.FirstDateOfMonth(salarymonth), GlobalFunctions.LastDateOfMonth(salarymonth), payrollTypeID);
}
return tc.ExecuteReader(strSQLQuery);
}
internal static DataSet GetEmpIDsOfManager(TransactionContext tc, int status, DateTime lastDateOfYear) internal static DataSet GetEmpIDsOfManager(TransactionContext tc, int status, DateTime lastDateOfYear)
{ {
string strSQLQuery = string strSQLQuery =

View File

@ -1564,6 +1564,37 @@ namespace HRM.DA
return employees; return employees;
} }
public List<Employee> GetForOTprocess(EnumEmployeeStatus status, int payrollTypeID, DateTime salarymonth)
{
List<Employee> employees = new List<Employee>();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(EmployeeDA.GetForOTprocess(tc, status, payrollTypeID, salarymonth));
employees = this.CreateObjects<Employee>(dr);
dr.Close();
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return employees;
}
public DataTable GetEmpIDsOfManager(int status, DateTime lastDateOfYear) public DataTable GetEmpIDsOfManager(int status, DateTime lastDateOfYear)
{ {

View File

@ -524,21 +524,21 @@ namespace HRM.DA
{ {
bulkCopy.BulkCopyTimeout = 6000; // in seconds bulkCopy.BulkCopyTimeout = 6000; // in seconds
bulkCopy.ColumnMappings.Add("PROCESSID", "PROCESSID"); bulkCopy.ColumnMappings.Add("PROCESSID", "ProcessId");
bulkCopy.ColumnMappings.Add("PROCESSMONTH", "PROCESSMONTH"); bulkCopy.ColumnMappings.Add("PROCESSMONTH", "ProcessMonth");
bulkCopy.ColumnMappings.Add("EMPID", "EMPID"); bulkCopy.ColumnMappings.Add("EMPID", "EmpID");
bulkCopy.ColumnMappings.Add("AMOUNT", "AMOUNT"); bulkCopy.ColumnMappings.Add("AMOUNT", "Amount");
bulkCopy.ColumnMappings.Add("TERMID", "TERMID"); bulkCopy.ColumnMappings.Add("TERMID", "TermID");
bulkCopy.ColumnMappings.Add("HOURS", "HOURS"); bulkCopy.ColumnMappings.Add("HOURS", "Hours");
bulkCopy.ColumnMappings.Add("CREATEDBY", "CREATEDBY"); bulkCopy.ColumnMappings.Add("CREATEDBY", "CreatedBy");
bulkCopy.ColumnMappings.Add("CREATIONDATE", "CREATIONDATE"); bulkCopy.ColumnMappings.Add("CREATIONDATE", "CreationDate");
bulkCopy.ColumnMappings.Add("MODIFIEDBY", "MODIFIEDBY"); bulkCopy.ColumnMappings.Add("MODIFIEDBY", "ModifiedBy");
bulkCopy.ColumnMappings.Add("MODIFIEDDATE", "MODIFIEDDATE"); bulkCopy.ColumnMappings.Add("MODIFIEDDATE", "ModifiedDate");
bulkCopy.ColumnMappings.Add("TERMPARAMETERID", "TERMPARAMETERID"); bulkCopy.ColumnMappings.Add("TERMPARAMETERID", "TermParameterID");
bulkCopy.ColumnMappings.Add("EMPOVERTIMEID", "EMPOVERTIMEID"); bulkCopy.ColumnMappings.Add("EMPOVERTIMEID", "EmpOverTimeID");
bulkCopy.ColumnMappings.Add("ARREARAMOUNT", "ARREARAMOUNT"); bulkCopy.ColumnMappings.Add("ARREARAMOUNT", "ArrearAmount");
bulkCopy.ColumnMappings.Add("OTMONTH", "OTMONTH"); bulkCopy.ColumnMappings.Add("OTMONTH", "OTMonth");
bulkCopy.ColumnMappings.Add("PAYROLLTYPEID", "PAYROLLTYPEID"); bulkCopy.ColumnMappings.Add("PAYROLLTYPEID", "PayrollTypeID");
bulkCopy.DestinationTableName = "OTProcess"; bulkCopy.DestinationTableName = "OTProcess";
@ -614,7 +614,7 @@ namespace HRM.DA
public void Process(List<Employee> emps, int userid, int payrolltypeid) public void Process(List<Employee> emps, int userid, int payrolltypeid)
{ {
// TermParameter.EntryType = ConfigurationManager.GetStringValue("overtime", "entrytype", EnumConfigurationType.Logic); TermParameter.EntryType = new SystemConfigarationService().GetconfigStringValue(EnumConfigurationType.Logic,"overtime", "entrytype");
bool calOnEarnedBasic = new SystemConfigarationService().GetconfigBooleanValue(EnumConfigurationType.Logic, "overtime", "earnedbasic"); bool calOnEarnedBasic = new SystemConfigarationService().GetconfigBooleanValue(EnumConfigurationType.Logic, "overtime", "earnedbasic");
int basicOnMonth = Convert.ToInt32(new SystemConfigarationService().GetconfigValue(EnumConfigurationType.Logic, "overtime", "basicondate")); int basicOnMonth = Convert.ToInt32(new SystemConfigarationService().GetconfigValue(EnumConfigurationType.Logic, "overtime", "basicondate"));
bool fixedotmonth = new SystemConfigarationService().GetconfigBooleanValue(EnumConfigurationType.Logic, "overtime", "fixedotmonth"); bool fixedotmonth = new SystemConfigarationService().GetconfigBooleanValue(EnumConfigurationType.Logic, "overtime", "fixedotmonth");
@ -623,7 +623,7 @@ namespace HRM.DA
PayrollType ptype = new PayrollTypeService().Get(payrolltypeid); PayrollType ptype = new PayrollTypeService().Get(payrolltypeid);
List<Employee> omployees = emps; List<Employee> omployees = emps;
if (emps == null) omployees = new EmployeeService().Get(EnumEmployeeStatus.Live, payrolltypeid); if (emps == null) omployees = new EmployeeService().GetForOTprocess(EnumEmployeeStatus.Live, payrolltypeid, ptype.NextPayProcessDate);
_OtProcess = new List<OTProcess>(); _OtProcess = new List<OTProcess>();
_EmpOvertimes = new EmployeeOverTimeService().Get(ptype.NextPayProcessDate, payrolltypeid); _EmpOvertimes = new EmployeeOverTimeService().Get(ptype.NextPayProcessDate, payrolltypeid);
double basicSalary = 0; double basicSalary = 0;
@ -835,13 +835,16 @@ namespace HRM.DA
TermParameter tparam = TermParameter.GetParameter(this._termParameters, (int)ot.Employee.GradeID, ot.TermID); TermParameter tparam = TermParameter.GetParameter(this._termParameters, (int)ot.Employee.GradeID, ot.TermID);
if (tparam == null) throw new Exception("OT parameter/Policy not found for the employee:" if (tparam == null) throw new Exception("OT parameter/Policy not found for the employee:"
+ ot.Employee.EmployeeNo + " " + ot.Employee.Name); + ot.Employee.EmployeeNo + " " + ot.Employee.Name);
double nHour = ot.OTHours; //double nHour = ot.OTHours;
//if ((ot.OTHours - nHour) == 0) ////if ((ot.OTHours - nHour) == 0)
//{ ////{
// throw new Exception("Monthly OT hours can be zero"); //// throw new Exception("Monthly OT hours can be zero");
//} ////}
nHour = Math.Floor(ot.OTHours); //nHour = Math.Floor(ot.OTHours);
nHour += (ot.OTHours - nHour) * 100 / 60; //nHour += (ot.OTHours - nHour) * 100 / 60;
double nHour = TermParameter.EntryType.ToUpper() == "MINUTE" ? // Means decimal part is in minutes
Math.Round(Math.Floor(ot.OTHours) + (((ot.OTHours - Math.Floor(ot.OTHours)) * 100.00) / 60.00), 2)
: Math.Round(ot.OTHours, 2);
switch (tparam.Type) switch (tparam.Type)
{ {
case EnumOverTimeType.AnyAmount: case EnumOverTimeType.AnyAmount:
@ -853,7 +856,7 @@ namespace HRM.DA
case EnumOverTimeType.FixedAmount: case EnumOverTimeType.FixedAmount:
return ot.OTHours ; return ot.OTHours ;
case EnumOverTimeType.HourlyBasicPercent: case EnumOverTimeType.HourlyBasicPercent:
return this.ConvertToHourlyRate(nBasic, ot.OTMonth, tparam.housInMonth) * ot.OTHours * (tparam.Amount/100); return this.ConvertToHourlyRate(nBasic, ot.OTMonth, _hoursInMonth) * nHour * (tparam.Amount/100);
case EnumOverTimeType.HourlyFlatAmount: case EnumOverTimeType.HourlyFlatAmount:
return ot.OTHours * tparam.Amount; return ot.OTHours * tparam.Amount;
case EnumOverTimeType.HoursOfMonth: case EnumOverTimeType.HoursOfMonth:
@ -911,8 +914,8 @@ namespace HRM.DA
process.OTMonth = GlobalFunctions.LastDateOfMonth(ot.OTMonth); process.OTMonth = GlobalFunctions.LastDateOfMonth(ot.OTMonth);
process.TermID = ot.TermID; process.TermID = ot.TermID;
process.TermParameterID = ot.TermParameterID; process.TermParameterID = ot.TermParameterID;
process.TotalHour = ot.OTHours; process.TotalHour = Math.Round(ot.OTHours, 2);
process.Amount = this.GetPayableAmount(ot, nBasic); process.Amount = Math.Round(this.GetPayableAmount(ot, Math.Round(nBasic)));
process.PayrollTypeID = ot.PayrollTypeID; process.PayrollTypeID = ot.PayrollTypeID;
return process; return process;