PayrollComputation.cs 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621
  1. using OASystem.API.OAMethodLib.QiYeWeChatAPI;
  2. using OASystem.Domain;
  3. using OASystem.Domain.Entities.PersonnelModule;
  4. using OASystem.Domain.ViewModels.PersonnelModule;
  5. using OASystem.Domain.ViewModels.QiYeWeChat;
  6. using OASystem.Infrastructure.Repositories.Groups;
  7. using TencentCloud.Ocr.V20181119.Models;
  8. namespace OASystem.API.OAMethodLib
  9. {
  10. /// <summary>
  11. /// 工资计算
  12. /// </summary>
  13. public static class PayrollComputation
  14. {
  15. private static Result _result = new Result();
  16. private static readonly IQiYeWeChatApiService _qiYeWeChatApiService = AutofacIocManager.Instance.GetService<IQiYeWeChatApiService>();
  17. private static readonly UsersRepository _usersRep = AutofacIocManager.Instance.GetService<UsersRepository>();
  18. private static readonly IMapper _mapper = AutofacIocManager.Instance.GetService<IMapper>();
  19. private static readonly decimal _chengDuMinimumWage = 2100.00M;
  20. /// <summary>
  21. /// 计算工资
  22. /// </summary>
  23. /// <param name="pm_WageSheetDattaSources"></param>
  24. /// <param name="userNames"></param>
  25. /// <param name="thisYearMonth"></param>
  26. /// <param name="startDt"></param>
  27. /// <param name="endDt"></param>
  28. /// <returns></returns>
  29. public static async Task<Result> SalaryCalculatorAsync(
  30. List<Pm_WageSheet> pm_WageSheetDattaSources, List<UserNameView> userNames,int userId, string thisYearMonth, DateTime startDt, DateTime endDt)
  31. {
  32. if (pm_WageSheetDattaSources.Count <= 0)
  33. {
  34. _result.Msg = "计算工资传入数据为空!";
  35. return _result;
  36. }
  37. if (userNames.Count <= 0 )
  38. {
  39. var nameData = await _usersRep.GetUserNameList(1);
  40. userNames = nameData.Data;
  41. }
  42. //获取所有打卡数据
  43. CheckInView checkIn = await _qiYeWeChatApiService.GetCheckin_MonthDataAsync(startDt, endDt); //时间段内所有 打卡数据
  44. if (checkIn.errcode != 0)
  45. {
  46. _result.Msg = checkIn.errmsg;
  47. return _result;
  48. }
  49. List<Data> checkInDatas = checkIn.datas;
  50. //请假
  51. List<Sp_Detail> sp_leave_details = new List<Sp_Detail>();
  52. sp_leave_details = await _qiYeWeChatApiService.GetApprovalDetailsAsync(startDt, endDt, 2, 1); //时间段内所有 已同意的 请假 审批数据
  53. if (sp_leave_details.Count <= 0)
  54. {
  55. string errMsg = startDt + " - " + endDt + "请假 审批数据获取失败!";
  56. return _result;
  57. }
  58. //打卡补卡
  59. List<Sp_Detail> sp_reissuecard_details = new List<Sp_Detail>();
  60. sp_reissuecard_details = await _qiYeWeChatApiService.GetApprovalDetailsAsync(startDt, endDt, 2, 2); //时间段内所有 已同意的 打卡补卡 审批数据
  61. if (sp_reissuecard_details.Count <= 0)
  62. {
  63. string errMsg = startDt + " - " + endDt + "打卡补卡 审批数据获取失败!";
  64. return _result;
  65. }
  66. foreach (var pm_wsInfo in pm_WageSheetDattaSources)
  67. {
  68. string itemName = userNames.Where(it => it.Id == pm_wsInfo.UserId).FirstOrDefault().CnName;
  69. //补贴 金额
  70. decimal meal_subsidy = 0.00M; // 午餐(午餐10元/天) 补贴 * 计算方式:单日上午请假时长(小时)大于或者等于三小时 没有餐补
  71. //事假 病假 总金额
  72. decimal personalLeaveTotal = 0.00M, // 事假 日薪 *计算方式:日平均工资 = 月工资/当月应出勤天数。
  73. sickLeaveTotal = 0.00M; // 病假 日薪 *计算方式:日平均工资 = 成都市最低工资标准的80%/当月应出勤天数。 短期病假=当月15天内
  74. //扣款金额
  75. decimal beLate_deduction = 0.00M, // 迟到 扣款金额 *计算方式:
  76. // 一个自然月内,不足 10 分钟的迟到/早退,不超过 2 次的部分,不做处罚;3 次及以上,按50元 / 次处罚;
  77. // 超过 10 分钟(含 10 分钟),不足 60 分钟的迟到/早退,按 50 元/次处罚;
  78. // 超过 60 分钟(含 60 分钟),不足 3 小时的迟到/早退,且无请假者,按旷工半日处理;超过3 小时的迟到 / 早退,且无请假者,按旷工一日处理。
  79. early_deduction = 0.00M, // 早退 扣款金额
  80. absenteeism_deduction = 0.00M, // 旷工 扣款金额 *计算方式:旷工扣发当日工资
  81. unprinted_deduction = 0.00M, // 未打卡 扣款金额 *计算方式:
  82. // 试用期员工每月有 2 次 补卡机会,超过 2 次不足 5 次的部分,按 10 元 / 次处罚,5 次及以上的漏卡,按 50 元 / 次处罚;
  83. // 正式员工每月 3 次以内的补卡,按 10 元 / 次处罚,3 次及以上的漏卡,按 50 元 / 次处罚。
  84. sickLeave_deduction = 0.00M,
  85. other_deduction = 0.00M; // 其他 扣款金额
  86. decimal meal_deduction = 0.00M; // 餐补 扣款金额
  87. decimal reissuecard_deduction = 0.00M; // 补卡 扣款金额
  88. //打卡数据
  89. Data? checkInData = checkInDatas.Where(it => it.base_info.name == itemName).FirstOrDefault();
  90. if (checkInData == null) { continue; }
  91. string acctid = checkInData.base_info.acctid; //用户Id
  92. //当月总计数据
  93. Summary_Info? summary_Info = checkInData.summary_info;
  94. if (summary_Info == null) { continue; }
  95. int work_days = summary_Info.work_days; //应出勤天数
  96. int regular_days = summary_Info.regular_days; //正常出勤天数
  97. meal_subsidy = work_days * 10; //应发放餐补
  98. #region 计算日工资 正常日薪 事假日薪 病假日薪
  99. //月 - 应发工资
  100. decimal amountPayable = pm_wsInfo.Basic + pm_wsInfo.Floats + pm_wsInfo.PostAllowance + pm_wsInfo.GarmentWashSubsidies + pm_wsInfo.CommunicationSubsidies +
  101. pm_wsInfo.TrafficSubsidies + pm_wsInfo.InformationSecurityFee + pm_wsInfo.OperationBonus + pm_wsInfo.SpecialAllowance + pm_wsInfo.OtherSubsidies + pm_wsInfo.GroupCost;
  102. // 日薪 = 事假日薪 *计算方式:日平均工资 = 月工资/当月应出勤天数。
  103. decimal dailyWage = amountPayable / work_days;
  104. // 病假日薪 *计算方式:日平均工资 = 成都市最低工资标准的80%/当月应出勤天数。 短期病假=当月15天内
  105. decimal sickLeave_dailywage = _chengDuMinimumWage / work_days;
  106. //病假 一天扣款
  107. sickLeave_deduction = dailyWage - sickLeave_dailywage;
  108. #endregion
  109. int annualLeaveNum = 0, //年假
  110. personalLeaveNum = 0, //事假
  111. sickLeaveNum = 0, //病假
  112. lieuLeaveNum = 0, //调休假
  113. marriageLeaveNum = 0, //婚嫁
  114. maternityLeaveNum = 0, //产假
  115. paternityLeaveNum = 0, //陪产假
  116. funeralLeaveNum = 0, //丧假
  117. reissueCardNum = 0, //补卡 次数
  118. evectionNum = 0, //出差 次数
  119. outIngNum = 0, //外出 次数
  120. outWorkNum = 0, //外勤 次数
  121. otherLeaveNum = 0; //其他
  122. #region 假勤 处理 1-请假;2-补卡;3-出差;4-外出;100-外勤;
  123. List<Sp_Item>? sp_items = checkInData.sp_items.Where(it => it.count != 0).ToList();
  124. if (sp_items != null && sp_items.Count > 0)
  125. {
  126. annualLeaveNum = Fallibilitydispose(sp_items, 1, "年假");
  127. personalLeaveNum = Fallibilitydispose(sp_items, 1, "事假");
  128. sickLeaveNum = Fallibilitydispose(sp_items, 1, "病假");
  129. lieuLeaveNum = Fallibilitydispose(sp_items, 1, "调休假");
  130. marriageLeaveNum = Fallibilitydispose(sp_items, 1, "婚嫁");
  131. maternityLeaveNum = Fallibilitydispose(sp_items, 1, "产假");
  132. paternityLeaveNum = Fallibilitydispose(sp_items, 1, "陪产假");
  133. funeralLeaveNum = Fallibilitydispose(sp_items, 1, "丧假");
  134. otherLeaveNum = Fallibilitydispose(sp_items, 1, "其他");
  135. reissueCardNum = Fallibilitydispose(sp_items, 2, "补卡次数");
  136. evectionNum = Fallibilitydispose(sp_items, 3, "出差");
  137. outIngNum = Fallibilitydispose(sp_items, 4, "外出");
  138. outWorkNum = Fallibilitydispose(sp_items, 3, "外勤");
  139. }
  140. #region 请假类型金额/餐补 处理
  141. List<Sp_Detail> sp_leave_item_infosData = sp_leave_details.Where(it => it.applyer.userid == acctid).ToList();
  142. List<Ex_Items> ex_Items = new List<Ex_Items>();//假勤 And 打卡备注集合
  143. Ex_Items ex_Items_jq = new Ex_Items() { Type = "假勤" }; //假勤
  144. List<Ex_Item> ex_ItemInfos = new List<Ex_Item>();
  145. foreach (Sp_Detail sp_item in sp_leave_item_infosData)
  146. {
  147. Apply_data? apply_data = sp_item.apply_data;
  148. if (apply_data != null)
  149. {
  150. List<ContentsItem> contents = apply_data.contents;
  151. ContentsItem content_Vacation = contents.Where(it => it.control== "Vacation").FirstOrDefault(); //请假类型
  152. ContentsItem content_Textarea = contents.Where(it => it.control == "Textarea").FirstOrDefault(); //多行文本
  153. if (content_Vacation != null)
  154. {
  155. Vacation vacation = content_Vacation.value.vacation;
  156. Attendance attendance = vacation.attendance; //假勤组件
  157. Selector selector = vacation.selector; //请假类型
  158. }
  159. //请假时长
  160. //double leaveLength = (sp_leave.end_time_dt - sp_leave.start_time_dt).TotalHours;
  161. //string typeName = string.Empty;
  162. ////leave_type 1年假;2事假;3病假;4调休假;5婚假;6产假;7陪产假;8其他
  163. //switch (sp_leave.leave_type)
  164. //{
  165. // case 1: //年假
  166. // typeName = "年假";
  167. // if (sp_leave.timeunit == 0) //半天
  168. // {
  169. // meal_deduction += 10;
  170. // }
  171. // else if (sp_leave.timeunit == 1) //小时
  172. // {
  173. // if (sp_leave.duration >= 3 && sp_leave.duration <= 7.5) //7.5小时 一天
  174. // {
  175. // meal_deduction += 10;
  176. // }
  177. // else if (sp_leave.duration > 7.5)
  178. // {
  179. // decimal daysPrice = Convert.ToDecimal(sp_leave.duration / 7.5 * 10);
  180. // meal_deduction += daysPrice;
  181. // }
  182. // }
  183. // break;
  184. // case 2: //事假 需调整
  185. // typeName = "事假";
  186. // if (sp_leave.timeunit == 0) //半天
  187. // {
  188. // meal_deduction += 10;
  189. // personalLeaveTotal += dailyWage / 2;
  190. // }
  191. // else if (sp_leave.timeunit == 1) //小时
  192. // {
  193. // if (sp_leave.duration >= 3 && sp_leave.duration <= 7.5) //7.5小时 一天
  194. // {
  195. // meal_deduction += 10;
  196. // }
  197. // else if (sp_leave.duration > 7.5)
  198. // {
  199. // decimal daysPrice = Convert.ToDecimal(sp_leave.duration / 7.5 * 10);
  200. // meal_deduction += daysPrice;
  201. // }
  202. // }
  203. // break;
  204. // case 3: //病假 需调整
  205. // typeName = "病假";
  206. // if (sp_leave.timeunit == 0) //半天
  207. // {
  208. // meal_deduction += 10;
  209. // sickLeaveTotal += sickLeave_deduction / 2;
  210. // }
  211. // else if (sp_leave.timeunit == 1) //小时
  212. // {
  213. // if (sp_leave.duration >= 3 && sp_leave.duration <= 7.5) //7.5小时 一天
  214. // {
  215. // meal_deduction += 10;
  216. // }
  217. // else if (sp_leave.duration > 7.5)
  218. // {
  219. // decimal daysPrice = Convert.ToDecimal(sp_leave.duration / 7.5 * 10);
  220. // meal_deduction += daysPrice;
  221. // }
  222. // }
  223. // break;
  224. // case 4: //调休假
  225. // typeName = "调休假";
  226. // if (sp_leave.timeunit == 0) //半天
  227. // {
  228. // meal_deduction += 10;
  229. // }
  230. // else if (sp_leave.timeunit == 1) //小时
  231. // {
  232. // if (sp_leave.duration >= 3 && sp_leave.duration <= 7.5) //7.5小时 一天
  233. // {
  234. // meal_deduction += 10;
  235. // }
  236. // else if (sp_leave.duration > 7.5)
  237. // {
  238. // decimal daysPrice = Convert.ToDecimal(sp_leave.duration / 7.5 * 10);
  239. // meal_deduction += daysPrice;
  240. // }
  241. // }
  242. // break;
  243. // case 5: //婚假
  244. // typeName = "婚假";
  245. // if (sp_leave.timeunit == 0) //半天
  246. // {
  247. // meal_deduction += 10;
  248. // }
  249. // else if (sp_leave.timeunit == 1) //小时
  250. // {
  251. // if (sp_leave.duration >= 3 && sp_leave.duration <= 7.5) //7.5小时 一天
  252. // {
  253. // meal_deduction += 10;
  254. // }
  255. // else if (sp_leave.duration > 7.5)
  256. // {
  257. // decimal daysPrice = Convert.ToDecimal(sp_leave.duration / 7.5 * 10);
  258. // meal_deduction += daysPrice;
  259. // }
  260. // }
  261. // break;
  262. // case 6: //产假
  263. // typeName = "产假";
  264. // if (sp_leave.timeunit == 0) //半天
  265. // {
  266. // meal_deduction += 10;
  267. // }
  268. // else if (sp_leave.timeunit == 1) //小时
  269. // {
  270. // if (sp_leave.duration >= 3 && sp_leave.duration <= 7.5) //7.5小时 一天
  271. // {
  272. // meal_deduction += 10;
  273. // }
  274. // else if (sp_leave.duration > 7.5)
  275. // {
  276. // decimal daysPrice = Convert.ToDecimal(sp_leave.duration / 7.5 * 10);
  277. // meal_deduction += daysPrice;
  278. // }
  279. // }
  280. // break;
  281. // case 7: //陪产假
  282. // typeName = "陪产假";
  283. // if (sp_leave.timeunit == 0) //半天
  284. // {
  285. // meal_deduction += 10;
  286. // }
  287. // else if (sp_leave.timeunit == 1) //小时
  288. // {
  289. // if (sp_leave.duration >= 3 && sp_leave.duration <= 7.5) //7.5小时 一天
  290. // {
  291. // meal_deduction += 10;
  292. // }
  293. // else if (sp_leave.duration > 7.5)
  294. // {
  295. // decimal daysPrice = Convert.ToDecimal(sp_leave.duration / 7.5 * 10);
  296. // meal_deduction += daysPrice;
  297. // }
  298. // }
  299. // break;
  300. // default:
  301. // break;
  302. //}
  303. //Ex_Item ex_Item = new Ex_Item()
  304. //{
  305. // SubTypeId = sp_leave.leave_type,
  306. // SubType = typeName,
  307. // Start_time_dt = sp_leave.start_time_dt,
  308. // End_time_dt = sp_leave.end_time_dt,
  309. // Duration = sp_leave.duration,
  310. // Reason = sp_leave.reason,
  311. // Apply_time_dt = sp_item.apply_time_dt,
  312. // Approval_name = sp_item.approval_name,
  313. //};
  314. //ex_ItemInfos.Add(ex_Item);
  315. }
  316. }
  317. if (ex_ItemInfos.Count > 0)
  318. {
  319. ex_Items_jq.Ex_ItemInfo = ex_ItemInfos.OrderBy(it => it.SubTypeId).ThenBy(it => it.Start_time_dt).ToList();
  320. ex_Items.Add(ex_Items_jq);
  321. }
  322. #endregion
  323. #endregion
  324. #region 打卡补卡 处理
  325. if (reissueCardNum == 3)
  326. {
  327. reissuecard_deduction += 10;
  328. }
  329. else if (reissueCardNum >= 4)
  330. {
  331. reissuecard_deduction += 50;
  332. }
  333. #endregion
  334. Ex_Items ex_Items_dk = new Ex_Items() { Type = "打卡" }; //打卡
  335. //List<Ex_Item> ex_reissuecard_Items = new List<Ex_Item>();
  336. List<dynamic> ex_reissuecard_Items = new List<dynamic>();
  337. List<Sp_Detail> sp_reissuecard_item_InfosData = sp_reissuecard_details.Where(it => it.applyer.userid == acctid).ToList();
  338. #region 打卡异常处理 统计 1-迟到;2-早退;3-缺卡;4-旷工;5-地点异常;6-设备异常;
  339. int beLateNum = 0, // 1-迟到;
  340. leaveEarlyNum = 0, // 2-早退;
  341. dummyDeckNum = 0, // 3-缺卡;
  342. minerNum = 0, // 4-旷工;
  343. locationAnomalyNum = 0, // 5-地点异常;
  344. unitExNum = 0; // 6-设备异常;
  345. if (summary_Info.except_days > 0)
  346. {
  347. List<Exception_Info>? ex_infos = checkInData.exception_infos;
  348. if (ex_infos != null && ex_infos.Count >= 0)
  349. {
  350. beLateNum = ExceptionStatistics(ex_infos, 1);
  351. leaveEarlyNum = ExceptionStatistics(ex_infos, 2);
  352. dummyDeckNum = ExceptionStatistics(ex_infos, 3);
  353. minerNum = ExceptionStatistics(ex_infos, 4);
  354. locationAnomalyNum = ExceptionStatistics(ex_infos, 5);
  355. unitExNum = ExceptionStatistics(ex_infos, 6);
  356. }
  357. }
  358. //foreach (Sp_Info sp_reissuecard_item in sp_reissuecard_item_InfosData)
  359. //{
  360. // DateTime apply_time_dt = sp_reissuecard_item.apply_time_dt; //申请时间
  361. // List<string>? approval_name = sp_reissuecard_item.approval_name; //审核人
  362. // Comm sp_comm = sp_reissuecard_item.comm;
  363. // if (sp_comm != null)
  364. // {
  365. // if (sp_comm.applydata != null)
  366. // {
  367. // List<ApplyInfo> applyInfos = sp_comm.applydata;
  368. // if (applyInfos.Count > 0)
  369. // {
  370. // //Ex_Item ex_reissuecard_Item = new Ex_Item();
  371. // dynamic ex_reissuecard_Item = null;
  372. // string text = applyInfos.Where(it => it.type == "text").FirstOrDefault().value.ToString(); //异常状态
  373. // DateTime? datehour = applyInfos.Where(it => it.type == "datehour").FirstOrDefault().valueDt;//补卡时间
  374. // string textarea = applyInfos.Where(it => it.type == "textarea").FirstOrDefault().value.ToString();//补卡事由
  375. // if (text.Contains("未打卡"))
  376. // {
  377. // ex_reissuecard_Item = new
  378. // {
  379. // SubTypeId = 0,
  380. // SubType = "未打卡",
  381. // title = text,
  382. // datehour = datehour == null ? "" : Convert.ToDateTime(datehour).ToString("yyyy-MM-dd HH:mm:ss"),
  383. // textarea = textarea,
  384. // apply_time_dt = apply_time_dt,
  385. // approval_name = approval_name
  386. // };
  387. // }
  388. // else if (text.Contains("迟到"))
  389. // {
  390. // ex_reissuecard_Item = new
  391. // {
  392. // SubTypeId = 1,
  393. // SubType = "迟到",
  394. // title = text,
  395. // datehour = datehour == null ? "" : Convert.ToDateTime(datehour).ToString("yyyy-MM-dd HH:mm:ss"),
  396. // textarea = textarea,
  397. // apply_time_dt = apply_time_dt,
  398. // approval_name = approval_name
  399. // };
  400. // }
  401. // else if (text.Contains("早退"))
  402. // {
  403. // ex_reissuecard_Item = new
  404. // {
  405. // SubTypeId = 2,
  406. // SubType = "早退",
  407. // title = text,
  408. // datehour = datehour == null ? "" : Convert.ToDateTime(datehour).ToString("yyyy-MM-dd HH:mm:ss"),
  409. // textarea = textarea,
  410. // apply_time_dt = apply_time_dt,
  411. // approval_name = approval_name
  412. // };
  413. // }
  414. // else if (text.Contains("缺卡"))
  415. // {
  416. // ex_reissuecard_Item = new
  417. // {
  418. // SubTypeId = 3,
  419. // SubType = "缺卡",
  420. // title = text,
  421. // datehour = datehour == null ? "" : Convert.ToDateTime(datehour).ToString("yyyy-MM-dd HH:mm:ss"),
  422. // textarea = textarea,
  423. // apply_time_dt = apply_time_dt,
  424. // approval_name = approval_name
  425. // };
  426. // }
  427. // else if (text.Contains("旷工"))
  428. // {
  429. // ex_reissuecard_Item = new
  430. // {
  431. // SubTypeId = 4,
  432. // SubType = "旷工",
  433. // title = text,
  434. // datehour = datehour == null ? "" : Convert.ToDateTime(datehour).ToString("yyyy-MM-dd HH:mm:ss"),
  435. // textarea = textarea,
  436. // apply_time_dt = apply_time_dt,
  437. // approval_name = approval_name
  438. // };
  439. // }
  440. // else if (text.Contains("地点异常"))
  441. // {
  442. // ex_reissuecard_Item = new
  443. // {
  444. // SubTypeId = 5,
  445. // SubType = "地点异常",
  446. // title = text,
  447. // datehour = datehour == null ? "" : Convert.ToDateTime(datehour).ToString("yyyy-MM-dd HH:mm:ss"),
  448. // textarea = textarea,
  449. // apply_time_dt = apply_time_dt,
  450. // approval_name = approval_name
  451. // };
  452. // }
  453. // else if (text.Contains("设备异常"))
  454. // {
  455. // ex_reissuecard_Item = new
  456. // {
  457. // SubTypeId = 6,
  458. // SubType = "设备异常",
  459. // title = text,
  460. // datehour = datehour == null ? "" : Convert.ToDateTime(datehour).ToString("yyyy-MM-dd HH:mm:ss"),
  461. // textarea = textarea,
  462. // apply_time_dt = apply_time_dt,
  463. // approval_name = approval_name
  464. // };
  465. // }
  466. // if (ex_reissuecard_Item != null)
  467. // {
  468. // ex_reissuecard_Items.Add(ex_reissuecard_Item);
  469. // }
  470. // }
  471. // }
  472. // }
  473. //}
  474. if (ex_reissuecard_Items.Count > 0)
  475. {
  476. ex_Items_dk.Ex_ItemInfo = ex_reissuecard_Items.OrderBy(it => it.SubTypeId).ThenBy(it => it.datehour).ToList();
  477. ex_Items.Add(ex_Items_dk);
  478. }
  479. #endregion
  480. #region 应发合计 实发合计 扣款合计(假勤扣款,其他扣款,社保扣款,公积金代扣,个税扣款)
  481. decimal mealTotal = meal_subsidy - meal_deduction; //餐补
  482. decimal salaryTotal = amountPayable + mealTotal; //应发合计
  483. //扣款合计 不含个税
  484. decimal eductionTotal = sickLeaveTotal + personalLeaveTotal + beLate_deduction + early_deduction + absenteeism_deduction + unprinted_deduction + other_deduction +
  485. pm_wsInfo.WithholdingInsurance + pm_wsInfo.ReservedFunds;
  486. decimal actualReleaseTotal = salaryTotal - eductionTotal; //实发合计 * 不含个税
  487. #endregion
  488. #region 处理当月工资数据
  489. pm_wsInfo.YearMonth = thisYearMonth;
  490. pm_wsInfo.StartDate = startDt.ToString("yyyy-MM-dd");
  491. pm_wsInfo.EndDate = endDt.ToString("yyyy-MM-dd");
  492. pm_wsInfo.SickLeave = sickLeaveTotal; //病假
  493. pm_wsInfo.SomethingFalse = personalLeaveTotal; //事假
  494. pm_wsInfo.LateTo = beLate_deduction; //迟到
  495. pm_wsInfo.LeaveEarly = early_deduction; //早退
  496. pm_wsInfo.Absenteeism = absenteeism_deduction; //旷工
  497. pm_wsInfo.NotPunch = unprinted_deduction; //未打卡
  498. pm_wsInfo.OtherDeductions = other_deduction; //其他
  499. pm_wsInfo.Ex_ItemsRemark = JsonConvert.SerializeObject(ex_Items); //
  500. pm_wsInfo.Mealsupplement = mealTotal; //餐补
  501. pm_wsInfo.Should = salaryTotal; //应发合计
  502. pm_wsInfo.TotalDeductions = eductionTotal; //扣款合计
  503. pm_wsInfo.TotalRealHair = actualReleaseTotal; //实发合计
  504. pm_wsInfo.AfterTax = actualReleaseTotal - pm_wsInfo.WithholdingTax; //税后工资
  505. pm_wsInfo.LastUpdateUserId = userId;
  506. pm_wsInfo.LastUpdateDt = DateTime.Now;
  507. pm_wsInfo.CreateUserId = userId;
  508. pm_wsInfo.CreateTime = DateTime.Now;
  509. pm_wsInfo.DeleteUserId = null;
  510. pm_wsInfo.DeleteTime = null;
  511. #endregion
  512. }
  513. _result.Code = 0;
  514. _result.Data = pm_WageSheetDattaSources;
  515. return _result;
  516. }
  517. /// <summary>
  518. /// 打卡数据
  519. /// 假勤数据 统计
  520. /// </summary>
  521. /// <param name="datas">数据源</param>
  522. /// <param name="type">
  523. /// 1-请假;2-补卡;3-出差;4-外出;100-外勤;
  524. /// </param>
  525. /// <param name="subTypeName">
  526. /// 年假 事假 病假 调休假 婚嫁 产假 陪产假 丧假 补卡次数 出差 外出数 外勤 其他
  527. /// </param>
  528. /// <returns></returns>
  529. private static int Fallibilitydispose(List<Sp_Item> datas, int type, string? subTypeName)
  530. {
  531. int num = 0;
  532. Sp_Item _Info = datas.Where(it => it.type == type && it.name == subTypeName).FirstOrDefault();
  533. if (_Info != null) { num = _Info.count; }
  534. return num;
  535. }
  536. /// <summary>
  537. /// 打卡数据
  538. /// 异常数据 统计
  539. /// </summary>
  540. /// <returns></returns>
  541. private static int ExceptionStatistics(List<Exception_Info> datas, int type)
  542. {
  543. int num = 0;
  544. Exception_Info _Info = datas.Where(it => it.exception == type).FirstOrDefault();
  545. if (_Info != null) { num = _Info.count; }
  546. return num;
  547. }
  548. }
  549. }