Pārlūkot izejas kodu

计算工资 小数位数调整

leiy 1 gadu atpakaļ
vecāks
revīzija
e5a9a113db

+ 1 - 3
OASystem/OASystem.Api/Controllers/PersonnelModuleController.cs

@@ -359,9 +359,7 @@ namespace OASystem.API.Controllers
                     else
                     {
                         salary = salary = (PayrollComputation.ConvertToDecimal(salary / pm_WageSheet.WorkDays) * pm_WageSheet.RegularDays) + pm_WageSheet.Mealsupplement;
-                    }     
-
-                    
+                    }    
                 }
 
                 

+ 51 - 63
OASystem/OASystem.Api/OAMethodLib/PayrollComputation.cs

@@ -1,4 +1,5 @@
 using Google.Protobuf.WellKnownTypes;
+using NPOI.HPSF;
 using NPOI.OpenXmlFormats.Spreadsheet;
 using NPOI.SS.Formula.Functions;
 using OASystem.API.OAMethodLib.QiYeWeChatAPI;
@@ -825,10 +826,10 @@ namespace OASystem.API.OAMethodLib
                     decimal amountPayable = pm_wsInfo.Basic + pm_wsInfo.Floats + pm_wsInfo.PostAllowance + pm_wsInfo.InformationSecurityFee + pm_wsInfo.OtherSubsidies;
 
                     // 日薪 = *计算方式:日平均工资 = 月工资/当月应出勤天数。
-                    decimal dailyWage = ConvertToDecimal(amountPayable / work_days);
+                    decimal dailyWage = amountPayable / work_days;
 
                     // 病假日薪 *计算方式:日平均工资 = 成都市最低工资标准的80%/当月应出勤天数。 短期病假=当月15天内 
-                    decimal sickLeave_dailywage = ConvertToDecimal(_chengDuMinimumWage / work_days);
+                    decimal sickLeave_dailywage = _chengDuMinimumWage / work_days;
 
                     //病假 一天扣款  
                     sickLeave_deduction = dailyWage - sickLeave_dailywage;
@@ -880,7 +881,7 @@ namespace OASystem.API.OAMethodLib
                                                           
                         decimal user_probationary_bk_decimal = pm_wsInfo.Floats; //绩效工资为0 则为试用员工
 
-                        #region 迟到 早退 
+                        #region 迟到 早退 
 
                         int user_cd_zt_num = 0; //早退/迟到 次数 10分钟内 2次以内不记处罚 三次及以上50一次
                         foreach (var root in userRoots)
@@ -901,7 +902,7 @@ namespace OASystem.API.OAMethodLib
                                 if (timelength == 9) timelength = 7.50M;
 
                                 int exception = exception_info.exception; //异常类型
-                                decimal day_miner_unit = ConvertToDecimal(dailyWage / 15);  //以0.5小时为单位 
+                                decimal day_miner_unit = dailyWage / 15;  //以0.5小时为单位 
 
                                 //1:一个自然月内,不足 10 分钟的迟到/早退,不超过 2 次的部分,不做处罚;3 次及以上,按50 元 / 次处罚;
                                 //2:超过 10 分钟(含 10 分钟),不足 60 分钟的迟到 / 早退,按 50 元 / 次处罚;
@@ -961,13 +962,13 @@ namespace OASystem.API.OAMethodLib
                                     }
                                     else if (timelength > 60 && timelength <= 180)
                                     {
-                                        day_deduction = day_miner_unit * 6; //3小时
+                                        day_deduction = ConvertToDecimal(day_miner_unit * 6); //3小时
                                         meal_deduction += 10.00M;  //餐补扣款
                                         absenteeism_deduction += day_deduction; //矿工半日
                                     }
                                     else
                                     {
-                                        day_deduction = dailyWage;
+                                        day_deduction = ConvertToDecimal(dailyWage);
                                         absenteeism_deduction += day_deduction; //矿工一日
                                         meal_deduction += 10.00M;
                                     }
@@ -1009,13 +1010,13 @@ namespace OASystem.API.OAMethodLib
                                     }
                                     else if (timelength > 60 && timelength <= 180)
                                     {
-                                        day_deduction = day_miner_unit * 6; //3小时
+                                        day_deduction = ConvertToDecimal(day_miner_unit * 6); //3小时
                                         absenteeism_deduction += day_deduction; //矿工半日
 
                                     }
                                     else
                                     {
-                                        day_deduction = dailyWage;
+                                        day_deduction = ConvertToDecimal(dailyWage);
                                         meal_deduction += 10.00M;
                                         absenteeism_deduction += day_deduction; //矿工一日
                                     }
@@ -1082,7 +1083,7 @@ namespace OASystem.API.OAMethodLib
                                 {
                                     if (timelength > 60 && timelength <= 180)
                                     {
-                                        day_deduction = day_miner_unit * 6; //3小时
+                                        day_deduction = ConvertToDecimal(day_miner_unit * 6); //3小时
                                         beLate_belate_ex.Reason = thisDtStr + " 缺卡/未打视为旷工上午(3小时)";
                                         meal_deduction += 10.00M;
                                         absenteeism_deduction += day_deduction; //矿工半日
@@ -1090,7 +1091,7 @@ namespace OASystem.API.OAMethodLib
                                     }
                                     else
                                     {
-                                        day_deduction = dailyWage;
+                                        day_deduction = ConvertToDecimal(dailyWage);
                                         beLate_belate_ex.Reason = thisDtStr + " 上午(09:00)-下午(18:00) 缺卡/未打视为旷工一天(7.5小时)";
                                         meal_deduction += 10.00M;
                                         absenteeism_deduction += day_deduction; //矿工一日
@@ -1255,9 +1256,9 @@ namespace OASystem.API.OAMethodLib
                                         var punch_correction = content_Vacation.value.punch_correction;
 
                                         DateTime bukaDt = punch_correction.time_dt;
-
+                                        DateTime bukaDtJudge = Convert.ToDateTime(bukaDt.ToString("yyyy-MM-dd"));
                                         //筛选 不在工作日内的假勤申请
-                                        if (startDt >= bukaDt || bukaDt > endDt)
+                                        if (startDt >= bukaDtJudge || bukaDtJudge > endDt)
                                         {
                                             continue;
                                         }
@@ -1302,7 +1303,7 @@ namespace OASystem.API.OAMethodLib
                         if (ex_reissuecard_Items.Count > 0)
                         {
                             ex_Items_dk.Ex_ItemInfo = ex_reissuecard_Items;
-                            ex_Items_dk.Ex_ItemInfo = ex_reissuecard_Items.OrderBy(it => it.SubTypeId).ThenBy(it => it.StartTimeDt).ToList();
+                            //ex_Items_dk.Ex_ItemInfo = ex_reissuecard_Items.OrderBy(it => it.SubTypeId).ThenBy(it => it.StartTimeDt).ToList();
                             ex_Items.Add(ex_Items_dk);
                         }
 
@@ -1396,9 +1397,10 @@ namespace OASystem.API.OAMethodLib
         /// </summary>
         /// <param name="number"></param>
         /// <returns></returns>
-        public static decimal ConvertToDecimal(decimal number)
+        public static decimal ConvertToDecimal(decimal myDecimal)
         {
-            return Convert.ToDecimal(number.ToString("0.00"));
+            var subDecimal = Math.Floor(myDecimal * 100) / 100;//保留两位小数,直接截取
+            return subDecimal;
         }
 
         /// <summary>
@@ -1460,7 +1462,7 @@ namespace OASystem.API.OAMethodLib
             string am_starttime = "08:59";
             string am_endtime = "13:01";
 
-            decimal personalkLeave_dailywage_day = ConvertToDecimal( amountPayable / work_days); //日薪 = 事假日薪 *计算方式:日平均工资 = 当月应发工资 /当月应出勤天数。
+            decimal personalkLeave_dailywage_day = amountPayable / work_days; //日薪 = 事假日薪 *计算方式:日平均工资 = 当月应发工资 /当月应出勤天数。
 
             //半小时单位
             decimal halfHour = Convert.ToDecimal(7.5) / Convert.ToDecimal(0.5);
@@ -1472,38 +1474,28 @@ namespace OASystem.API.OAMethodLib
                     break;
                 case 2: //2事假
                     // 事假日薪 *计算方式:日平均工资 = 当月应发工资 /当月应出勤天数。 
-                    decimal personalkLeave_dailywage_halfhour = ConvertToDecimal( personalkLeave_dailywage_day / halfHour); //事假单位 0.5小时
+                    decimal personalkLeave_dailywage_halfhour =  personalkLeave_dailywage_day / halfHour; //事假单位 0.5小时
 
                     if (date_Range_type == "halfday")
                     {
                         mealDeduction = 10; //餐补扣款 
-                        typeDeduction = personalkLeave_dailywage_day;
+                        typeDeduction = ConvertToDecimal(personalkLeave_dailywage_day);
                     }
                     else if (date_Range_type == "hour")
                     {
+
                         decimal leave_halfHour = Convert.ToDecimal(duration) / Convert.ToDecimal(0.5);
-                        typeDeduction = personalkLeave_dailywage_halfhour * leave_halfHour;
-                        if (duration >= 3 && duration <= 7.5M) //单天请假三小时
+                        typeDeduction = ConvertToDecimal( personalkLeave_dailywage_halfhour * leave_halfHour);
+                        //duration = 11M;
+                        if (duration >= 3 && duration < 7.5M) //单天请假三小时
                         {
                             mealDeduction = 10; //餐补扣款
 
-                            #region 上午请假超三小时 扣款
-                            //处理开始时间
-                            //if (startTime.CompareTo(am_starttime) > 0 && startTime.CompareTo(am_endtime) < 0)
-                            //{
-                            //    //处理结束时间
-                            //    if (endTime.CompareTo(am_starttime) > 0 && endTime.CompareTo(am_endtime) > 0)
-                            //    {
-                            //        mealDeduction = 10; //餐补扣款
-                            //    }
-                            //}
-                            #endregion
-
                         }
-                        else if (duration > 7.5M) //多天计算
+                        else if (duration >= 7.5M) //多天计算
                         {
                             decimal leave_halfHour1 = Convert.ToDecimal(duration) / Convert.ToDecimal(0.5);
-                            typeDeduction = personalkLeave_dailywage_halfhour * leave_halfHour1;
+                            typeDeduction = ConvertToDecimal(personalkLeave_dailywage_day);
 
                             decimal leaveDays = duration / 7.5M;
                             if (leaveDays % 1 == 0)
@@ -1512,17 +1504,19 @@ namespace OASystem.API.OAMethodLib
                             }
                             else
                             {
+                                typeDeduction = personalkLeave_dailywage_day * Convert.ToInt32(leaveDays);
+                                decimal sy_shijiaunit = leave_halfHour1 - Convert.ToDecimal (15.00M * Convert.ToInt32(leaveDays));
+                                if (sy_shijiaunit > 0)
+                                {
+                                    typeDeduction += ConvertToDecimal(personalkLeave_dailywage_halfhour * sy_shijiaunit);
+                                }
                                 mealDeduction = 10 * Convert.ToInt32(leaveDays);
 
                                 //得到最后一天的请假时间 是否有餐补
                                 int lastHours = (Convert.ToDateTime(endTime) - Convert.ToDateTime("09:00")).Hours;
                                 if (lastHours >= 3)
                                 {
-                                    //处理结束时间
-                                    if (endTime.CompareTo(am_starttime) > 0 && endTime.CompareTo(am_endtime) < 0)
-                                    {
-                                        mealDeduction += 10; //餐补扣款
-                                    }
+                                    mealDeduction += 10; //餐补扣款
                                 }
                             }
                         }
@@ -1532,41 +1526,29 @@ namespace OASystem.API.OAMethodLib
                 case 3: //3病假
                     // 病假日薪 *计算方式:日平均工资 = 成都市最低工资标准的80% /当月应出勤天数。 短期病假=当月15天内 
 
-                    decimal chengDuMinimumWage_halrHour = ConvertToDecimal( _chengDuMinimumWage / work_days) / halfHour;
+                    decimal chengDuMinimumWage_halrHour = _chengDuMinimumWage / work_days / halfHour;
                     decimal sickLeave_dailywage_halfhour_deduction = personalkLeave_dailywage_day - chengDuMinimumWage_halrHour; //病假单位 0.5小时 扣款金额
 
                     if (date_Range_type == "halfday")
                     {
                         mealDeduction = 10; //餐补扣款 
-                        typeDeduction = sickLeave_dailywage_halfhour_deduction * halfHour;
+                        typeDeduction = ConvertToDecimal( sickLeave_dailywage_halfhour_deduction * halfHour);
                     }
                     else if (date_Range_type == "hour")
                     {
                         decimal sickLeave_halfHour = duration / 0.5M;
-                        typeDeduction = sickLeave_dailywage_halfhour_deduction *sickLeave_halfHour ;
-                        if (duration >= 3 && duration <= 7.5M) //单天请假三小时 && 请假时间在上午 则没有餐补
+                        typeDeduction = ConvertToDecimal(personalkLeave_dailywage_day); ;
+                        if (duration >= 3 && duration < 7.5M) //单天请假三小时 && 请假时间在上午 则没有餐补
                         {
                             mealDeduction = 10; //餐补扣款
-
-                            #region 上午请假超三小时扣款
-                            ////处理开始时间
-                            //if (startTime.CompareTo(am_starttime) > 0 && startTime.CompareTo(am_endtime) < 0)
-                            //{
-                            //    //处理结束时间
-                            //    if (endTime.CompareTo(am_starttime) > 0 && endTime.CompareTo(am_endtime) < 0)
-                            //    {
-                            //        mealDeduction = 10; //餐补扣款
-                            //    }
-                            //}
-                            #endregion
-
                         }
-                        else if (duration > 7.5M) //多天计算
+                        else if (duration >= 7.5M) //多天计算
                         {
                             decimal sickLeave_halfHour1 = duration / 0.5M;
-                            typeDeduction = sickLeave_dailywage_halfhour_deduction * sickLeave_halfHour1;
 
                             decimal leaveDays = Convert.ToDecimal(duration / 7.5M);
+
+                            typeDeduction = ConvertToDecimal(sickLeave_dailywage_halfhour_deduction * sickLeave_halfHour1);
                             if (leaveDays % 1 == 0)
                             {
                                 mealDeduction = 10 * leaveDays; //餐补扣款
@@ -1575,15 +1557,21 @@ namespace OASystem.API.OAMethodLib
                             {
                                 mealDeduction = 10 * Convert.ToInt32(leaveDays);
 
+                                typeDeduction = ConvertToDecimal(sickLeave_dailywage_halfhour_deduction * Convert.ToInt32(leaveDays));
+
+                                decimal sy_bingjiaunit = sickLeave_halfHour1 - Convert.ToDecimal(15.00M * Convert.ToInt32(leaveDays));
+                                if (sy_bingjiaunit > 0)
+                                {
+                                    typeDeduction += ConvertToDecimal(sickLeave_dailywage_halfhour_deduction * sy_bingjiaunit);
+                                }
+
                                 //得到最后一天的请假时间 是否有餐补
                                 int lastHours = (Convert.ToDateTime(endTime) - Convert.ToDateTime("09:00")).Hours;
                                 if (lastHours >= 3)
                                 {
-                                    //处理结束时间
-                                    if (endTime.CompareTo(am_starttime) > 0 && endTime.CompareTo(am_endtime) < 0)
-                                    {
-                                        mealDeduction += 10; //餐补扣款
-                                    }
+
+                                    mealDeduction += 10; //餐补扣款
+
                                 }
                             }
                         }

+ 5 - 3
OASystem/OASystem.Domain/ViewModels/Groups/EnterExitCostView.cs

@@ -333,9 +333,11 @@ namespace OASystem.Domain.ViewModels.Groups
             get
             {
                 string str = "";
-
-                if (City.Contains("城市")) str = Country;
-                else str = City;
+                if (!string.IsNullOrEmpty(Country))
+                {
+                    if (City.Contains("城市")) str = Country;
+                    else str = City;
+                }
 
                 return str;