diff --git a/HRM.DA/DA/Bonus/ProductionBonusSetupDA.cs b/HRM.DA/DA/Bonus/ProductionBonusSetupDA.cs index e94d745..7ae9e9f 100644 --- a/HRM.DA/DA/Bonus/ProductionBonusSetupDA.cs +++ b/HRM.DA/DA/Bonus/ProductionBonusSetupDA.cs @@ -93,8 +93,8 @@ namespace HRM.DA internal static DataTable GetLayout(TransactionContext tc, DateTime dtSalaryMonth) { return tc.ExecuteDataTable( - "SELECT ProductionBonusSetupID as id, DesignNo as design FROM ProductionBonusSetup where CreationDate >= %d", - dtSalaryMonth); + "SELECT ProductionBonusSetupID as id, DesignNo as design FROM ProductionBonusSetup where Salarymonth >= %d", + GlobalFunctions.FirstDateOfMonth(dtSalaryMonth)); } internal static DataTable GetLayoutMonthly(TransactionContext tc, DateTime dtSalaryMonth) { diff --git a/HRM.DA/Service/Basic/SystemInformationService.cs b/HRM.DA/Service/Basic/SystemInformationService.cs index e78adb7..5ddf171 100644 --- a/HRM.DA/Service/Basic/SystemInformationService.cs +++ b/HRM.DA/Service/Basic/SystemInformationService.cs @@ -24,7 +24,7 @@ namespace HRM.DA oSystemInformation.factoryAddress = oReader.GetString("FACTORYADDRESS"); oSystemInformation.TelephoneNo = oReader.GetString("TELEPHONE"); oSystemInformation.email = oReader.GetString("EMAIL"); - oSystemInformation.webAddress = oReader.GetString("WEBADDRESS"); + //oSystemInformation.webAddress = oReader.GetString("WEBADDRESS"); oSystemInformation.systemStartDate = oReader.GetDateTime("SYSTEMSTARTDATE").Value; oSystemInformation.TaxYearEndDate = oReader.GetDateTime("TAXYEARENDDATE").Value; oSystemInformation.NextPayProcessDate = oReader.GetDateTime("NEXTPAYPROCESSDATE").Value; diff --git a/HRM.DA/Service/Bonus/ProdBonusProcessService.cs b/HRM.DA/Service/Bonus/ProdBonusProcessService.cs index a3caa7f..c96cd16 100644 --- a/HRM.DA/Service/Bonus/ProdBonusProcessService.cs +++ b/HRM.DA/Service/Bonus/ProdBonusProcessService.cs @@ -642,10 +642,12 @@ namespace HRM.DA _oProdBonusProcess.ProdBonusProcessEmps = new List(); List prodAttn = null; List oProcessEmps = new List(); - List oShifts = new ShiftService().GetAllShift(); + //List oShifts = new ShiftService().GetAllShift(); Shift oShift = null; ProdBonusProcessEmp oProcessEmp = null; int setupID = 21; + DateTime? bonusIntime = DateTime.MinValue; + DateTime? bonusOuttime = DateTime.MinValue; ADParameter _ADParam = new ADParameterService().Get(setupID, payrollTypeId); List prodAttns = new ProdBonusAttnService().GetBySetupIDs(_oProductionBonusSetups.CommaSeparatedIDs()); @@ -660,11 +662,8 @@ namespace HRM.DA foreach (ProductionBonusSetup oProductionBonusSetup in _oProductionBonusSetups) { - if(oProductionBonusSetup.ID == 10302) - { - - } - prodAttn = prodAttns.Where(x => x.ProdBonusSetupID == oProductionBonusSetup.ID).ToList();//ToObjectsTemplate(); + + prodAttn = prodAttns.Where(x => x.ProdBonusSetupID == oProductionBonusSetup.ID).ToList();//ToObjectsTemplate(); ProdBonusProcessItem oProcessItem = null; foreach (ProdBonusLine oLine in oProductionBonusSetup.ProductionBonusLinesNew) { @@ -687,29 +686,16 @@ namespace HRM.DA foreach (DataRow dr in foundRows) { basicSal = Convert.ToDouble(dr["BASICSALARY"]); - // - int empidtest = Convert.ToInt32(dr["EMPLOYEEID"]); - if(oProductionBonusSetup.SalaryMonth == new DateTime(2023, 10, 31)) - { - - if (empidtest == 27620) - { - basicSal = 5145; - } - } - + } } - + bool isSuperVisor = allProdBonusSupervisors.FindIndex(x => x.EmployeeID == item.Key && x.ProdBonusLineID == oLine.ID) == -1 ? false : true; List dailyAttm = alldailyAttm.FindAll(x => x.EmployeeID == item.Key); - //if (oProcessItem.EmployeeID == 36901) - //{ - - //} - if (isSuperVisor == false) + + if (isSuperVisor == false) { #region Not Supervisor @@ -717,19 +703,26 @@ namespace HRM.DA { DailyAttnProcess dailyAtt = dailyAttm.FirstOrDefault(o => o.AttnDate.Date == tAtt.InTime.Date); double wh = 0; + if (dailyAtt != null) { + bonusIntime = dailyAtt.InTime; + bonusOuttime = dailyAtt.OutTime; if (dailyAtt.OutTime != DateTime.MinValue && dailyAtt.InTime != DateTime.MinValue) { - oShift = oShifts.FirstOrDefault(x => x.ID == dailyAtt.ShiftID); + // oShift = oShifts.FirstOrDefault(x => x.ID == dailyAtt.ShiftID); if (oProductionBonusSetup.FromDate.Date == dailyAtt.AttnDate.Date) - dailyAtt.InTime = oProductionBonusSetup.FromDate > dailyAtt.InTime ? oProductionBonusSetup.FromDate : dailyAtt.InTime; - else if (oProductionBonusSetup.ToDate.Date == dailyAtt.AttnDate.Date) - dailyAtt.OutTime = oProductionBonusSetup.ToDate < dailyAtt.OutTime ? oProductionBonusSetup.ToDate : dailyAtt.OutTime; - else if (oShift != null && dailyAtt.InTime.GetValueOrDefault().TimeOfDay < oShift.InTime.TimeOfDay) - dailyAtt.InTime = dailyAtt.InTime.GetValueOrDefault().Date.AddHours(oShift.InTime.Hour).AddMinutes(oShift.InTime.Minute); + bonusIntime = oProductionBonusSetup.FromDate > dailyAtt.InTime ? oProductionBonusSetup.FromDate : dailyAtt.InTime; + else if (dailyAtt.InTime.GetValueOrDefault().TimeOfDay < tAtt.InTime.TimeOfDay) + bonusIntime = dailyAtt.InTime.GetValueOrDefault().Date.AddHours(tAtt.InTime.Hour).AddMinutes(tAtt.InTime.Minute); + if (oProductionBonusSetup.ToDate.Date == dailyAtt.AttnDate.Date) + bonusOuttime = oProductionBonusSetup.ToDate < dailyAtt.OutTime ? oProductionBonusSetup.ToDate : dailyAtt.OutTime; + else if (dailyAtt.OutTime.GetValueOrDefault().TimeOfDay > tAtt.OutTime.TimeOfDay) + bonusOuttime = dailyAtt.OutTime.GetValueOrDefault().Date.AddHours(tAtt.OutTime.Hour).AddMinutes(tAtt.OutTime.Minute); + //else if (oShift != null && dailyAtt.InTime.GetValueOrDefault().TimeOfDay < oShift.InTime.TimeOfDay) + // bonusIntime = dailyAtt.InTime.GetValueOrDefault().Date.AddHours(oShift.InTime.Hour).AddMinutes(oShift.InTime.Minute); - TimeSpan ts = (TimeSpan)(dailyAtt.OutTime - dailyAtt.InTime); + TimeSpan ts = (TimeSpan)(bonusOuttime - bonusIntime); if (ts.Minutes < 16 && ts.Hours < 5) wh = ts.Hours; else if (ts.Minutes < 16) @@ -749,22 +742,8 @@ namespace HRM.DA oProcessItem = new ProdBonusProcessItem(); oProcessItem.EmployeeID = item.Key; oProcessItem.OTHour = oth; - if(oProcessItem.EmployeeID == 283) - { - - } - //Amount mismatch hude ammount - if (oProcessItem.EmployeeID == 27620 || oProcessItem.EmployeeID == 27620 || oProcessItem.EmployeeID == 31161 || oProcessItem.EmployeeID == 1822 - || oProcessItem.EmployeeID == 36901 || oProcessItem.EmployeeID == 37542 || oProcessItem.EmployeeID == 41160 || oProcessItem.EmployeeID == 44495 - || oProcessItem.EmployeeID == 44495 || oProcessItem.EmployeeID == 46607 || oProcessItem.EmployeeID == 49783 || oProcessItem.EmployeeID == 55041 - || oProcessItem.EmployeeID == 55155 || oProcessItem.EmployeeID == 55388) - { - - } - if (oProcessItem.EmployeeID == 27620) - { - - } + + oProcessItem.Amount = Math.Round(((double)basicSal / 208 * oth) * 2, 2); //if(oProcessItem.EmployeeID == 55388) //{ @@ -791,16 +770,22 @@ namespace HRM.DA { if (dailyAtt.OutTime != DateTime.MinValue && dailyAtt.InTime != DateTime.MinValue) { - oShift = oShifts.FirstOrDefault(x => x.ID == dailyAtt.ShiftID); + bonusIntime = dailyAtt.InTime; + bonusOuttime = dailyAtt.OutTime; + //oShift = oShifts.FirstOrDefault(x => x.ID == dailyAtt.ShiftID); if (oProductionBonusSetup.FromDate.Date == dailyAtt.AttnDate.Date) - dailyAtt.InTime = oProductionBonusSetup.FromDate > dailyAtt.InTime ? oProductionBonusSetup.FromDate : dailyAtt.InTime; - else if (oProductionBonusSetup.ToDate.Date == dailyAtt.AttnDate.Date) - dailyAtt.OutTime = oProductionBonusSetup.ToDate < dailyAtt.OutTime ? oProductionBonusSetup.ToDate : dailyAtt.OutTime; - else if (oShift != null && dailyAtt.InTime.GetValueOrDefault().TimeOfDay < oShift.InTime.TimeOfDay) - dailyAtt.InTime = dailyAtt.InTime.GetValueOrDefault().Date.AddHours(oShift.InTime.Hour).AddMinutes(oShift.InTime.Minute); + bonusIntime = oProductionBonusSetup.FromDate > dailyAtt.InTime ? oProductionBonusSetup.FromDate : dailyAtt.InTime; + else if (dailyAtt.InTime.GetValueOrDefault().TimeOfDay < tAtt.InTime.TimeOfDay) + bonusIntime = dailyAtt.InTime.GetValueOrDefault().Date.AddHours(tAtt.InTime.Hour).AddMinutes(tAtt.InTime.Minute); + if (oProductionBonusSetup.ToDate.Date == dailyAtt.AttnDate.Date) + bonusOuttime = oProductionBonusSetup.ToDate < dailyAtt.OutTime ? oProductionBonusSetup.ToDate : dailyAtt.OutTime; + else if (dailyAtt.OutTime.GetValueOrDefault().TimeOfDay > tAtt.OutTime.TimeOfDay) + bonusOuttime = dailyAtt.OutTime.GetValueOrDefault().Date.AddHours(tAtt.OutTime.Hour).AddMinutes(tAtt.OutTime.Minute); + //else if (oShift != null && dailyAtt.InTime.GetValueOrDefault().TimeOfDay < oShift.InTime.TimeOfDay) + // bonusIntime = dailyAtt.InTime.GetValueOrDefault().Date.AddHours(oShift.InTime.Hour).AddMinutes(oShift.InTime.Minute); - TimeSpan ts = (TimeSpan)(dailyAtt.OutTime - dailyAtt.InTime); + TimeSpan ts = (TimeSpan)(bonusOuttime - bonusIntime); if (ts.Minutes < 16 && ts.Hours < 5) wh = ts.Hours; else if (ts.Minutes < 16) @@ -827,17 +812,17 @@ namespace HRM.DA oLine.ProdBonusSupervisors = allProdBonusSupervisors.FindAll(x => x.ProdBonusSetupID == oProductionBonusSetup.ID && x.ProdBonusLineID == oLine.ID); //Amount mismatch hude ammount - if (oProcessItem.EmployeeID == 27388 || oProcessItem.EmployeeID == 27620 || oProcessItem.EmployeeID == 31161 || oProcessItem.EmployeeID == 1822 - || oProcessItem.EmployeeID == 36901 || oProcessItem.EmployeeID == 37542 || oProcessItem.EmployeeID == 41160 || oProcessItem.EmployeeID == 44495 - || oProcessItem.EmployeeID == 44495 || oProcessItem.EmployeeID == 46607 || oProcessItem.EmployeeID == 49783 || oProcessItem.EmployeeID == 55041 - || oProcessItem.EmployeeID == 55155 || oProcessItem.EmployeeID == 55388) - { + //if (oProcessItem.EmployeeID == 27388 || oProcessItem.EmployeeID == 27620 || oProcessItem.EmployeeID == 31161 || oProcessItem.EmployeeID == 1822 + // || oProcessItem.EmployeeID == 36901 || oProcessItem.EmployeeID == 37542 || oProcessItem.EmployeeID == 41160 || oProcessItem.EmployeeID == 44495 + // || oProcessItem.EmployeeID == 44495 || oProcessItem.EmployeeID == 46607 || oProcessItem.EmployeeID == 49783 || oProcessItem.EmployeeID == 55041 + // || oProcessItem.EmployeeID == 55155 || oProcessItem.EmployeeID == 55388) + //{ - } - if(oProcessItem.EmployeeID == 27620) - { - double x = ((double)oLine.ProdBonusSupervisors.First(o => o.EmployeeID == item.Key).BonusPercent / 100); - } + //} + //if(oProcessItem.EmployeeID == 27620) + //{ + // double x = ((double)oLine.ProdBonusSupervisors.First(o => o.EmployeeID == item.Key).BonusPercent / 100); + //} oProcessItem.Amount = Math.Round(((double)basicSal / 208 * (double)oth * ((double)oLine.ProdBonusSupervisors.First(o => o.EmployeeID == item.Key).BonusPercent / 100)) * 2, 2); oProcessItem.AchievePercent = 0; @@ -872,17 +857,7 @@ namespace HRM.DA oProcessEmp = new ProdBonusProcessEmp(); oProcessEmp.EmployeeID = item.EmployeeID; //Amount mismatch hude ammount - if (oProcessEmp.EmployeeID == 27388 || oProcessEmp.EmployeeID == 27620 || oProcessEmp.EmployeeID == 31161 || oProcessEmp.EmployeeID == 1822 - || oProcessEmp.EmployeeID == 36901 || oProcessEmp.EmployeeID == 37542 || oProcessEmp.EmployeeID == 41160 || oProcessEmp.EmployeeID == 44495 - || oProcessEmp.EmployeeID == 44495 || oProcessEmp.EmployeeID == 46607 || oProcessEmp.EmployeeID == 49783 || oProcessEmp.EmployeeID == 55041 - || oProcessEmp.EmployeeID == 55155 || oProcessEmp.EmployeeID == 55388) - { - - } - if (oProcessEmp.EmployeeID == 27620) - { - - } + oProcessEmp.Amount = Math.Round((double)item.Amount, 2); oProcessEmp.Description = item.Description; _oProdBonusProcess.ProdBonusProcessEmps.Add(oProcessEmp); diff --git a/HRM.DA/Service/Employee/EmployeeService.cs b/HRM.DA/Service/Employee/EmployeeService.cs index 4582159..8edf881 100644 --- a/HRM.DA/Service/Employee/EmployeeService.cs +++ b/HRM.DA/Service/Employee/EmployeeService.cs @@ -39,7 +39,7 @@ namespace HRM.DA oEmployee.TinNo = oReader.GetString("tinNo"); oEmployee.CategoryID = oReader.GetInt32("categoryID").Value; oEmployee.ForeignExPat = oReader.GetBoolean("foreignExPat").Value; - oEmployee.TaxCircle = (EnumTaxCircle)oReader.GetInt32("taxCircle", true, 0); + //oEmployee.TaxCircle = (EnumTaxCircle)oReader.GetInt32("taxCircle", true, 0); //oEmployee.TaxCircle = oReader.GetString("taxCircle"); oEmployee.IsConfirmed = oReader.GetBoolean("isConfirmed").Value; oEmployee.Status = (EnumEmployeeStatus)oReader.GetInt32("status").Value;