Bläddra i källkod

计算工资
事假,病假 费用计算按天计算 0.5天起步

leiy 1 år sedan
förälder
incheckning
828e0447e3
1 ändrade filer med 257 tillägg och 2 borttagningar
  1. 257 2
      OASystem/OASystem.Api/OAMethodLib/PayrollComputation.cs

+ 257 - 2
OASystem/OASystem.Api/OAMethodLib/PayrollComputation.cs

@@ -736,7 +736,7 @@ namespace OASystem.API.OAMethodLib
                                     int leaveType = leave_item.TypeId;
                                     decimal new_duration = leave_item.New_Duration;
                                     //计算餐补 假勤类型扣款
-                                    CalculateTypeFee(leaveDetails,leaveType, leave_item.DtType, leave_item.StartDt, leave_item.EndDt, amountPayable, work_days,
+                                    CalculateTypeFee1(leaveDetails,leaveType, leave_item.DtType, leave_item.StartDt, leave_item.EndDt, amountPayable, work_days,
                                         new_duration,out leave_meals, out thisTypeDeduction);
                                     if (leave_meals != 0)
                                     {
@@ -1276,6 +1276,7 @@ namespace OASystem.API.OAMethodLib
 
         /// <summary>
         /// 计算类型费用
+        /// 病假 事假 计算 按天计算
         /// </summary>
         /// <param name="leaveType">
         /// 1年假;2事假;3病假;4调休假;5婚假;6产假;7陪产假;8其他;9丧假
@@ -1289,7 +1290,261 @@ namespace OASystem.API.OAMethodLib
         /// <param name="duration"></param>
         /// <param name="mealDeduction"></param>
         /// <param name="typeDeduction"></param>
-        public static void CalculateTypeFee(List<LeaveDetails> leaveDetails,int leaveType, string date_Range_type, DateTime startTime, DateTime endTime,
+        public static void CalculateTypeFee1(List<LeaveDetails> leaveDetails, int leaveType, string date_Range_type, DateTime startTime, DateTime endTime,
+            decimal amountPayable, int work_days, decimal duration, out decimal mealDeduction, out decimal typeDeduction)
+        {
+            typeDeduction = 0;
+            mealDeduction = 0;
+
+            string am_starttime = "08:59";
+            string am_endtime = "13:01";
+
+            decimal personalkLeave_dailywage_day = amountPayable / work_days; //日薪 = 事假日薪 *计算方式:日平均工资 = 当月应发工资 /当月应出勤天数。
+
+            //半小时单位
+            decimal halfHour = 7.50M / 0.50M;
+
+            switch (leaveType)
+            {
+                case 1: //年假
+
+                    if (date_Range_type == "halfday")
+                    {
+                        if (duration >= 0.5M && duration <= 1M) //一天
+                        {
+                            var njItem = leaveDetails.Where(it => it.StartDt.ToString("yyyy-MM-dd") == startTime.ToString("yyyy-MM-dd") &&
+                                                      it.EndDt.ToString("yyyy-MM-dd") == endTime.ToString("yyyy-MM-dd")).ToList();
+                            if (njItem.Count > 1)
+                            {
+                                if (njItem[0].StartDt == startTime)
+                                {
+                                    mealDeduction = 10; //餐补扣款
+                                }
+                            }
+                            else
+                            {
+                                mealDeduction = 10; //餐补扣款 
+                            }
+                        }
+                        else // 多天
+                        {
+                            var njManyDaysItem = leaveDetails.Where(it => it.StartDt.ToString("yyyy-MM-dd") == startTime.ToString("yyyy-MM-dd")).ToList();
+                            if (njManyDaysItem.Count > 1)
+                            {
+                                var njManyDaysItem1 = njManyDaysItem.Where(it => it.StartDt != startTime).ToList();
+                                if (njManyDaysItem1.Count > 0)
+                                {
+                                    if (njManyDaysItem1[0].Unit.Equals("天"))
+                                    {
+                                        mealDeduction = 10 * Math.Floor(duration);
+                                    }
+                                    else if (njManyDaysItem1[0].Unit.Equals("小时") && njManyDaysItem1[0].New_Duration >= 3)
+                                    {
+                                        mealDeduction = 10 * Math.Floor(duration);
+                                    }
+                                    else
+                                    {
+                                        mealDeduction = 10 * Math.Ceiling(duration);
+                                    }
+                                }
+                            }
+                            else
+                            {
+                                mealDeduction = 10 * Math.Ceiling(duration);
+                            }
+                        }
+                    }
+
+                    break;
+                case 2: //2事假
+                    // 事假日薪 *计算方式:日平均工资 = 当月应发工资 /当月应出勤天数。 
+                    decimal personalkLeave_dailywage_halfhour = personalkLeave_dailywage_day / 7.50M; //事假单位 0.5小时
+                   
+                    if (date_Range_type == "halfday")
+                    {
+                        mealDeduction = 10.00M * Math.Floor(duration); //餐补扣款 
+                        if (duration % 1 == 0) //整天
+                        {
+                            typeDeduction = ConvertToDecimal(personalkLeave_dailywage_day * duration);
+                        }
+                        else //多含 半天 另外处理
+                        {
+                            decimal sj_wholeDay = Math.Floor(duration); //整天
+                            decimal sj_halfDay = duration % 1; //半天
+
+                            if (sj_halfDay > 0)
+                            {
+                                typeDeduction = (personalkLeave_dailywage_day / 0.50M) * duration;
+
+                                LeaveDetails sjDetailsMeal = leaveDetails.Where(it => it.EndDt == startTime).FirstOrDefault();
+                                if (sjDetailsMeal == null)
+                                {
+                                    mealDeduction += 10.00M;
+                                }
+                            }
+                            else
+                            {
+                                typeDeduction = personalkLeave_dailywage_day * sj_wholeDay;
+                            }
+                            typeDeduction = ConvertToDecimal(typeDeduction);
+                        }
+                    }
+                    else if (date_Range_type == "hour")
+                    {
+                        decimal leave_halfHour = Convert.ToDecimal(duration) / Convert.ToDecimal(0.5);
+                        typeDeduction = ConvertToDecimal(personalkLeave_dailywage_halfhour * leave_halfHour);
+                        //duration = 11M;
+                        if (duration >= 3 && duration < 7.5M) //单天请假三小时
+                        {
+                            mealDeduction = 10; //餐补扣款
+
+                        }
+                        else if (duration >= 7.5M) //多天计算
+                        {
+                            decimal leave_halfHour1 = Convert.ToDecimal(duration) / Convert.ToDecimal(0.5);
+
+
+                            decimal leaveDays = duration / 7.5M;
+                            if (leaveDays % 1 == 0)
+                            {
+                                typeDeduction = ConvertToDecimal(personalkLeave_dailywage_day * leaveDays);
+                                mealDeduction = 10 * leaveDays; //餐补扣款
+                            }
+                            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)
+                                {
+                                    mealDeduction += 10; //餐补扣款
+                                }
+                            }
+                        }
+                    }
+
+                    break;
+                case 3: //3病假
+                        // 病假日薪 *计算方式:日平均工资 = 成都市最低工资标准的80% /当月应出勤天数。 短期病假=当月15天内 
+                    decimal chengDuMinimumWage_Day = _chengDuMinimumWage / work_days;
+                    decimal chengDuMinimumWage_halrHour = chengDuMinimumWage_Day / 7.50M;
+                    decimal sickLeave_dailywage_halfhour_deduction1 = (personalkLeave_dailywage_day / 7.50M) - chengDuMinimumWage_halrHour; //病假单位 0.5小时 扣款金额
+
+                    if (date_Range_type == "halfday")
+                    {
+                        mealDeduction = 10.00M * Math.Ceiling(duration); //餐补扣款 
+
+                        decimal pl_dailywage_day = personalkLeave_dailywage_day - chengDuMinimumWage_Day;
+                        if (duration % 1 == 0) //整天
+                        {
+                            typeDeduction = ConvertToDecimal(pl_dailywage_day * duration);
+                        }
+                        else //多含 半天 另外处理
+                        {
+                            if (duration % 1 > 0)
+                            {
+                                typeDeduction = (pl_dailywage_day / 0.50M) * duration;
+
+                                LeaveDetails bjDetailsMeal = leaveDetails.Where(it => it.EndDt == startTime).FirstOrDefault();
+                                if (bjDetailsMeal == null)
+                                {
+                                    mealDeduction += 10.00M;
+                                }
+                            }
+
+                            typeDeduction = ConvertToDecimal(typeDeduction);
+                        }
+                    }
+                    else if (date_Range_type == "hour")
+                    {
+                        decimal sickLeave_halfHour = duration / 0.5M;
+                        typeDeduction = ConvertToDecimal(sickLeave_dailywage_halfhour_deduction1 * sickLeave_halfHour);
+
+                        if (duration >= 3 && duration < 7.5M) //单天请假三小时 && 请假时间在上午 则没有餐补
+                        {
+                            mealDeduction = 10; //餐补扣款
+                        }
+                        else if (duration >= 7.5M) //多天计算
+                        {
+                            decimal sickLeave_halfHour1 = duration / 0.5M;
+
+                            decimal leaveDays = Convert.ToDecimal(duration / 7.5M);
+
+                            typeDeduction = ConvertToDecimal(sickLeave_dailywage_halfhour_deduction1 * sickLeave_halfHour1);
+                            if (leaveDays % 1 == 0)
+                            {
+                                mealDeduction = 10 * leaveDays; //餐补扣款
+                            }
+                            else
+                            {
+                                mealDeduction = 10 * Convert.ToInt32(leaveDays);
+
+                                typeDeduction = ConvertToDecimal(sickLeave_dailywage_halfhour_deduction1 * Convert.ToInt32(leaveDays));
+
+                                decimal sy_bingjiaunit = sickLeave_halfHour1 - Convert.ToDecimal(15.00M * Convert.ToInt32(leaveDays));
+                                if (sy_bingjiaunit > 0)
+                                {
+                                    typeDeduction += ConvertToDecimal(sickLeave_dailywage_halfhour_deduction1 * sy_bingjiaunit);
+                                }
+
+                                //得到最后一天的请假时间 是否有餐补
+                                int lastHours = (Convert.ToDateTime(endTime) - Convert.ToDateTime("09:00")).Hours;
+                                if (lastHours >= 3)
+                                {
+                                    mealDeduction += 10; //餐补扣款
+                                }
+                            }
+                        }
+                    }
+                    break;
+                case 4: //4调休假
+                    CalculateTypeFeeSub(leaveDetails, date_Range_type, startTime, endTime, duration, out mealDeduction);
+                    break;
+                case 5: //5婚假
+                    CalculateTypeFeeSub(leaveDetails, date_Range_type, startTime, endTime, duration, out mealDeduction);
+                    break;
+                case 6: //6产假
+                    CalculateTypeFeeSub(leaveDetails, date_Range_type, startTime, endTime, duration, out mealDeduction);
+                    break;
+                case 7: //7陪产假
+                    CalculateTypeFeeSub(leaveDetails, date_Range_type, startTime, endTime, duration, out mealDeduction);
+                    break;
+                case 8: //8其他
+                    CalculateTypeFeeSub(leaveDetails, date_Range_type, startTime, endTime, duration, out mealDeduction);
+                    break;
+                case 9: //9丧假
+                    CalculateTypeFeeSub(leaveDetails, date_Range_type, startTime, endTime, duration, out mealDeduction);
+                    break;
+
+            }
+        }
+
+
+
+        /// <summary>
+        /// 计算类型费用
+        /// 病假 事假 计算 按小时计算
+        /// </summary>
+        /// <param name="leaveType">
+        /// 1年假;2事假;3病假;4调休假;5婚假;6产假;7陪产假;8其他;9丧假
+        /// </param>
+        /// <param name="date_Range_type">
+        /// halfday 全天
+        /// hour  小时
+        /// </param>
+        /// <param name="startTime"></param>
+        /// <param name="endTime"></param>
+        /// <param name="duration"></param>
+        /// <param name="mealDeduction"></param>
+        /// <param name="typeDeduction"></param>
+        public static void CalculateTypeFee2(List<LeaveDetails> leaveDetails,int leaveType, string date_Range_type, DateTime startTime, DateTime endTime,
             decimal amountPayable,int work_days, decimal duration, out decimal mealDeduction, out decimal typeDeduction)
         {
             typeDeduction = 0;