From 7884bbdd4668977e7d15d9ef03dd9eb59ef996da Mon Sep 17 00:00:00 2001 From: chapal Date: Tue, 15 Oct 2024 11:15:16 +0600 Subject: [PATCH] Prod processs --- .../Service/Bonus/ProdBonusProcessService.cs | 60 +++++++------------ 1 file changed, 20 insertions(+), 40 deletions(-) diff --git a/HRM.DA/Service/Bonus/ProdBonusProcessService.cs b/HRM.DA/Service/Bonus/ProdBonusProcessService.cs index a3caa7f..c345d41 100644 --- a/HRM.DA/Service/Bonus/ProdBonusProcessService.cs +++ b/HRM.DA/Service/Bonus/ProdBonusProcessService.cs @@ -646,6 +646,8 @@ namespace HRM.DA 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,10 +662,7 @@ namespace HRM.DA foreach (ProductionBonusSetup oProductionBonusSetup in _oProductionBonusSetups) { - if(oProductionBonusSetup.ID == 10302) - { - - } + prodAttn = prodAttns.Where(x => x.ProdBonusSetupID == oProductionBonusSetup.ID).ToList();//ToObjectsTemplate(); ProdBonusProcessItem oProcessItem = null; foreach (ProdBonusLine oLine in oProductionBonusSetup.ProductionBonusLinesNew) @@ -687,20 +686,10 @@ 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; @@ -709,7 +698,7 @@ namespace HRM.DA //{ //} - if (isSuperVisor == false) + if (isSuperVisor == false) { #region Not Supervisor @@ -717,19 +706,22 @@ 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); if (oProductionBonusSetup.FromDate.Date == dailyAtt.AttnDate.Date) - dailyAtt.InTime = oProductionBonusSetup.FromDate > dailyAtt.InTime ? oProductionBonusSetup.FromDate : dailyAtt.InTime; + bonusIntime = 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; + bonusOuttime = 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 = 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 +741,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,14 +769,16 @@ namespace HRM.DA { if (dailyAtt.OutTime != DateTime.MinValue && dailyAtt.InTime != DateTime.MinValue) { + 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; + bonusIntime = 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; + bonusOuttime = 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 = dailyAtt.InTime.GetValueOrDefault().Date.AddHours(oShift.InTime.Hour).AddMinutes(oShift.InTime.Minute); TimeSpan ts = (TimeSpan)(dailyAtt.OutTime - dailyAtt.InTime); if (ts.Minutes < 16 && ts.Hours < 5)