From a0150b0eed54948969d7290aefb30ddf2a383eb8 Mon Sep 17 00:00:00 2001 From: chapal Date: Mon, 28 Apr 2025 16:43:39 +0600 Subject: [PATCH] OT process --- HRM.DA/DA/Employee/EmployeeDA.cs | 15 ++++++ HRM.DA/Service/Employee/EmployeeService.cs | 31 +++++++++++ HRM.DA/Service/OverTime/OTProcessService.cs | 57 +++++++++++---------- 3 files changed, 76 insertions(+), 27 deletions(-) diff --git a/HRM.DA/DA/Employee/EmployeeDA.cs b/HRM.DA/DA/Employee/EmployeeDA.cs index aedec39..1a6be93 100644 --- a/HRM.DA/DA/Employee/EmployeeDA.cs +++ b/HRM.DA/DA/Employee/EmployeeDA.cs @@ -842,7 +842,22 @@ namespace HRM.DA } 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) { string strSQLQuery = diff --git a/HRM.DA/Service/Employee/EmployeeService.cs b/HRM.DA/Service/Employee/EmployeeService.cs index 50f77ba..a544994 100644 --- a/HRM.DA/Service/Employee/EmployeeService.cs +++ b/HRM.DA/Service/Employee/EmployeeService.cs @@ -1564,6 +1564,37 @@ namespace HRM.DA return employees; } + public List GetForOTprocess(EnumEmployeeStatus status, int payrollTypeID, DateTime salarymonth) + { + List employees = new List(); + + TransactionContext tc = null; + try + { + tc = TransactionContext.Begin(); + + DataReader dr = new DataReader(EmployeeDA.GetForOTprocess(tc, status, payrollTypeID, salarymonth)); + employees = this.CreateObjects(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) { diff --git a/HRM.DA/Service/OverTime/OTProcessService.cs b/HRM.DA/Service/OverTime/OTProcessService.cs index 13f1c49..f3a02e3 100644 --- a/HRM.DA/Service/OverTime/OTProcessService.cs +++ b/HRM.DA/Service/OverTime/OTProcessService.cs @@ -524,21 +524,21 @@ namespace HRM.DA { bulkCopy.BulkCopyTimeout = 6000; // in seconds - bulkCopy.ColumnMappings.Add("PROCESSID", "PROCESSID"); - bulkCopy.ColumnMappings.Add("PROCESSMONTH", "PROCESSMONTH"); - bulkCopy.ColumnMappings.Add("EMPID", "EMPID"); - bulkCopy.ColumnMappings.Add("AMOUNT", "AMOUNT"); - bulkCopy.ColumnMappings.Add("TERMID", "TERMID"); - bulkCopy.ColumnMappings.Add("HOURS", "HOURS"); - bulkCopy.ColumnMappings.Add("CREATEDBY", "CREATEDBY"); - bulkCopy.ColumnMappings.Add("CREATIONDATE", "CREATIONDATE"); - bulkCopy.ColumnMappings.Add("MODIFIEDBY", "MODIFIEDBY"); - bulkCopy.ColumnMappings.Add("MODIFIEDDATE", "MODIFIEDDATE"); - bulkCopy.ColumnMappings.Add("TERMPARAMETERID", "TERMPARAMETERID"); - bulkCopy.ColumnMappings.Add("EMPOVERTIMEID", "EMPOVERTIMEID"); - bulkCopy.ColumnMappings.Add("ARREARAMOUNT", "ARREARAMOUNT"); - bulkCopy.ColumnMappings.Add("OTMONTH", "OTMONTH"); - bulkCopy.ColumnMappings.Add("PAYROLLTYPEID", "PAYROLLTYPEID"); + bulkCopy.ColumnMappings.Add("PROCESSID", "ProcessId"); + bulkCopy.ColumnMappings.Add("PROCESSMONTH", "ProcessMonth"); + bulkCopy.ColumnMappings.Add("EMPID", "EmpID"); + bulkCopy.ColumnMappings.Add("AMOUNT", "Amount"); + bulkCopy.ColumnMappings.Add("TERMID", "TermID"); + bulkCopy.ColumnMappings.Add("HOURS", "Hours"); + bulkCopy.ColumnMappings.Add("CREATEDBY", "CreatedBy"); + bulkCopy.ColumnMappings.Add("CREATIONDATE", "CreationDate"); + bulkCopy.ColumnMappings.Add("MODIFIEDBY", "ModifiedBy"); + bulkCopy.ColumnMappings.Add("MODIFIEDDATE", "ModifiedDate"); + bulkCopy.ColumnMappings.Add("TERMPARAMETERID", "TermParameterID"); + bulkCopy.ColumnMappings.Add("EMPOVERTIMEID", "EmpOverTimeID"); + bulkCopy.ColumnMappings.Add("ARREARAMOUNT", "ArrearAmount"); + bulkCopy.ColumnMappings.Add("OTMONTH", "OTMonth"); + bulkCopy.ColumnMappings.Add("PAYROLLTYPEID", "PayrollTypeID"); bulkCopy.DestinationTableName = "OTProcess"; @@ -614,7 +614,7 @@ namespace HRM.DA public void Process(List 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"); int basicOnMonth = Convert.ToInt32(new SystemConfigarationService().GetconfigValue(EnumConfigurationType.Logic, "overtime", "basicondate")); bool fixedotmonth = new SystemConfigarationService().GetconfigBooleanValue(EnumConfigurationType.Logic, "overtime", "fixedotmonth"); @@ -623,7 +623,7 @@ namespace HRM.DA PayrollType ptype = new PayrollTypeService().Get(payrolltypeid); List 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(); _EmpOvertimes = new EmployeeOverTimeService().Get(ptype.NextPayProcessDate, payrolltypeid); double basicSalary = 0; @@ -835,13 +835,16 @@ namespace HRM.DA 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:" + ot.Employee.EmployeeNo + " " + ot.Employee.Name); - double nHour = ot.OTHours; - //if ((ot.OTHours - nHour) == 0) - //{ - // throw new Exception("Monthly OT hours can be zero"); - //} - nHour = Math.Floor(ot.OTHours); - nHour += (ot.OTHours - nHour) * 100 / 60; + //double nHour = ot.OTHours; + ////if ((ot.OTHours - nHour) == 0) + ////{ + //// throw new Exception("Monthly OT hours can be zero"); + ////} + //nHour = Math.Floor(ot.OTHours); + //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) { case EnumOverTimeType.AnyAmount: @@ -853,7 +856,7 @@ namespace HRM.DA case EnumOverTimeType.FixedAmount: return ot.OTHours ; 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: return ot.OTHours * tparam.Amount; case EnumOverTimeType.HoursOfMonth: @@ -911,8 +914,8 @@ namespace HRM.DA process.OTMonth = GlobalFunctions.LastDateOfMonth(ot.OTMonth); process.TermID = ot.TermID; process.TermParameterID = ot.TermParameterID; - process.TotalHour = ot.OTHours; - process.Amount = this.GetPayableAmount(ot, nBasic); + process.TotalHour = Math.Round(ot.OTHours, 2); + process.Amount = Math.Round(this.GetPayableAmount(ot, Math.Round(nBasic))); process.PayrollTypeID = ot.PayrollTypeID; return process; -- 2.40.0.windows.1