diff --git a/0_Framework/Application/UID/IUidService.cs b/0_Framework/Application/UID/IUidService.cs index 19dd0034..c2c26bd5 100644 --- a/0_Framework/Application/UID/IUidService.cs +++ b/0_Framework/Application/UID/IUidService.cs @@ -38,7 +38,7 @@ public class UidBasicInformation { "GENDER_MALE" => Application.Gender.Male, "GENDER_FEMALE" => Application.Gender.Female, - _ => throw new ArgumentOutOfRangeException() + _ => Application.Gender.None }; } public record IdentificationInformation(string NationalId, string BirthDate, string ShenasnameSeri, string ShenasnameSerial, string ShenasnamehNumber); diff --git a/Company.Domain/RollCallAgg/IRollCallMandatoryRepository.cs b/Company.Domain/RollCallAgg/IRollCallMandatoryRepository.cs index b37fd3cb..5ea7c4dc 100644 --- a/Company.Domain/RollCallAgg/IRollCallMandatoryRepository.cs +++ b/Company.Domain/RollCallAgg/IRollCallMandatoryRepository.cs @@ -16,6 +16,7 @@ namespace Company.Domain.RollCallAgg; public interface IRollCallMandatoryRepository : IRepository { ComputingViewModel MandatoryCompute(long employeeId, long workshopId, DateTime contractStart, DateTime contractEnd, CreateWorkingHoursTemp command, bool holidayWorking, bool isStaticCheckout, bool rotatingShiftCompute, double dailyWageUnAffected); + ComputingViewModel MandatoryCompute(long employeeId, long workshopId, DateTime contractStart, DateTime contractEnd, CreateWorkingHoursTemp command, bool holidayWorking, bool isStaticCheckout, bool rotatingShiftCompute, bool totalLeaveCompute); /// /// محاسبه ساعات کارکرد پرسنل در صورت داشتن حضور غیاب diff --git a/CompanyManagment.App.Contracts/RollCall/IRollCallMandatoryApplication.cs b/CompanyManagment.App.Contracts/RollCall/IRollCallMandatoryApplication.cs index d5da6b04..f765d919 100644 --- a/CompanyManagment.App.Contracts/RollCall/IRollCallMandatoryApplication.cs +++ b/CompanyManagment.App.Contracts/RollCall/IRollCallMandatoryApplication.cs @@ -8,7 +8,8 @@ namespace CompanyManagment.App.Contracts.RollCall; public interface IRollCallMandatoryApplication { bool HasRollCallRecord(long employeeId, long workshopId, DateTime contractStart); - ComputingViewModel MandatoryCompute(long employeeId, long workshopId, DateTime contractStart, DateTime contractEnd, CreateWorkingHoursTemp command, bool holidayWorking, bool isStaticCheckout, bool rotatingShiftCompute, double dailyWageUnAffected); + ComputingViewModel MandatoryCompute(long employeeId, long workshopId, DateTime contractStart, DateTime contractEnd, CreateWorkingHoursTemp command, bool holidayWorking, bool isStaticCheckout, bool rotatingShiftCompute, double dailyWageUnAffected, bool totalLeaveCompute); + /// /// گزارش نوبت کاری حضور غیاب diff --git a/CompanyManagment.Application/CheckoutApplication.cs b/CompanyManagment.Application/CheckoutApplication.cs index 5a54f502..5c5ff7e4 100644 --- a/CompanyManagment.Application/CheckoutApplication.cs +++ b/CompanyManagment.Application/CheckoutApplication.cs @@ -197,7 +197,8 @@ public class CheckoutApplication : ICheckoutApplication { command.AbsenceDeduction = command.AbsenceDeduction - command.OvertimePay; command.OvertimePay = 0; - } + command.OverTimeWorkValue = "00:00"; + } else { command.OvertimePay = command.OvertimePay - command.AbsenceDeduction; diff --git a/CompanyManagment.Application/EmployeeDocumentsApplication.cs b/CompanyManagment.Application/EmployeeDocumentsApplication.cs index a84392b8..bce8a935 100644 --- a/CompanyManagment.Application/EmployeeDocumentsApplication.cs +++ b/CompanyManagment.Application/EmployeeDocumentsApplication.cs @@ -1735,7 +1735,7 @@ namespace CompanyManagment.Application if (file.Length > (50 * 1024 * 1024)) return op.Failed("حجم فایل نمی تواند بیشتر از 50 مگابایت باشد"); - if (!allowedExtensions.Contains(fileExtension)) + if (!allowedExtensions.Contains(fileExtension.ToLower())) { var operationMessage = ":فرمت فایل باید یکی از موارد زیر باشد"; operationMessage += "\n"; diff --git a/CompanyManagment.Application/RollCallMandatoryApplication.cs b/CompanyManagment.Application/RollCallMandatoryApplication.cs index ec10dadd..dd9bbd39 100644 --- a/CompanyManagment.Application/RollCallMandatoryApplication.cs +++ b/CompanyManagment.Application/RollCallMandatoryApplication.cs @@ -21,9 +21,11 @@ public class RollCallMandatoryApplication : IRollCallMandatoryApplication return _rollCallMandatoryRepository.Exists(x => x.EmployeeId == employeeId && x.WorkshopId == workshopId && x.StartDate.Value.Date >= contractStart.Date); } - public ComputingViewModel MandatoryCompute(long employeeId, long workshopId, DateTime contractStart, DateTime contractEnd, CreateWorkingHoursTemp command, bool holidayWorking, bool isStaticCheckout, bool rotatingShiftCompute, double dailyWageUnAffected) + public ComputingViewModel MandatoryCompute(long employeeId, long workshopId, DateTime contractStart, DateTime contractEnd, CreateWorkingHoursTemp command, bool holidayWorking, bool isStaticCheckout, bool rotatingShiftCompute, double dailyWageUnAffected, bool totalLeaveCompute) + { - return _rollCallMandatoryRepository.MandatoryCompute(employeeId,workshopId, contractStart, contractEnd, command, holidayWorking, isStaticCheckout, rotatingShiftCompute, dailyWageUnAffected); + return _rollCallMandatoryRepository.MandatoryCompute(employeeId,workshopId, contractStart, contractEnd, command, holidayWorking, isStaticCheckout, rotatingShiftCompute, dailyWageUnAffected, totalLeaveCompute); + } public async Task RotatingShiftReport(long workshopId, long employeeId, DateTime contractStart, DateTime contractEnd, diff --git a/CompanyManagment.EFCore/Repository/CheckoutRepository.cs b/CompanyManagment.EFCore/Repository/CheckoutRepository.cs index 6b0f52d7..f05ae55b 100644 --- a/CompanyManagment.EFCore/Repository/CheckoutRepository.cs +++ b/CompanyManagment.EFCore/Repository/CheckoutRepository.cs @@ -1131,7 +1131,7 @@ public class CheckoutRepository : RepositoryBase, ICheckoutRepos ch.TotalBreakTimeStr = ch.CheckoutRollCall.TotalBreakTimeSpan.ToFarsiHoursAndMinutes("-"); ch.TotalPresentTimeStr = ch.CheckoutRollCall.TotalPresentTimeSpan.ToFarsiHoursAndMinutes("-"); ch.TotalMandatoryTimeStr = ch.CheckoutRollCall.TotalMandatoryTimeSpan.ToFarsiHoursAndMinutes("-"); - ch.TotalPaidLeave = ch.CheckoutRollCall.TotalPaidLeaveTmeSpan.ToFarsiDaysAndHoursAndMinutes("-"); + ch.TotalPaidLeave = Tools.ToFarsiHoursAndMinutes(Convert.ToInt32(ch.CheckoutRollCall.TotalPaidLeaveTmeSpan.TotalHours), ch.CheckoutRollCall.TotalPaidLeaveTmeSpan.Minutes, "-"); ch.MonthlyRollCall = ch.CheckoutRollCall.RollCallDaysCollection .Select(x => new CheckoutDailyRollCallViewModel { diff --git a/CompanyManagment.EFCore/Repository/RollCallMandatoryRepository.cs b/CompanyManagment.EFCore/Repository/RollCallMandatoryRepository.cs index c36e540e..12e59c32 100644 --- a/CompanyManagment.EFCore/Repository/RollCallMandatoryRepository.cs +++ b/CompanyManagment.EFCore/Repository/RollCallMandatoryRepository.cs @@ -39,6 +39,7 @@ using PersianTools.Core; + namespace CompanyManagment.EFCore.Repository; public class RollCallMandatoryRepository : RepositoryBase, IRollCallMandatoryRepository @@ -67,9 +68,10 @@ public class RollCallMandatoryRepository : RepositoryBase, IRoll #region OfficialChckout public ComputingViewModel MandatoryCompute(long employeeId, long workshopId, DateTime contractStart, DateTime contractEnd, - CreateWorkingHoursTemp command, bool holidayWorking, bool isStaticCheckout, bool rotatingShiftCompute,double dailyWageUnAffected) + CreateWorkingHoursTemp command, bool holidayWorking, bool isStaticCheckout, bool rotatingShiftCompute,double dailyWageUnAffected, bool totalLeaveCompute) { - #region Entities + + #region Entities string SumWorkeTime = string.Empty; var weeklyTime = new TimeSpan(); @@ -144,7 +146,7 @@ public class RollCallMandatoryRepository : RepositoryBase, IRoll groupedRollCall = rollCallResult.GroupBy(x => x.ShiftDate.Date).Select(x => { - + DateTime friday = new DateTime(); @@ -197,19 +199,19 @@ public class RollCallMandatoryRepository : RepositoryBase, IRoll BreakTimeSpan = x.BreakTimeSpan }).ToList(); - groupedRollCall = rollCallResult.GroupBy(x => x.CreationDate.Date).Select(x => - { - TimeSpan breakTime; - if (contractStart > endOfFarvardin) - { - breakTime = CalculateBreakTime( - x.First().BreakTimeSpan, - new TimeSpan(x.Sum(shift => shift.ShiftSpan.Ticks))); - } - else - { - breakTime = CalculateBreakTime(breakTimeEntity, new TimeSpan(x.Sum(shift => shift.ShiftSpan.Ticks))); - } + groupedRollCall = rollCallResult.GroupBy(x => x.CreationDate.Date).Select(x => + { + TimeSpan breakTime; + if (contractStart > endOfFarvardin) + { + breakTime = CalculateBreakTime( + x.First().BreakTimeSpan, + new TimeSpan(x.Sum(shift => shift.ShiftSpan.Ticks))); + } + else + { + breakTime = CalculateBreakTime(breakTimeEntity, new TimeSpan(x.Sum(shift => shift.ShiftSpan.Ticks))); + } DateTime friday = new DateTime(); @@ -220,7 +222,7 @@ public class RollCallMandatoryRepository : RepositoryBase, IRoll s.StartDate != null && s.EndDate != null && (s.StartDate.Value.DayOfWeek == DayOfWeek.Friday)) .StartDate.Value; - + } if (x.Any(s => @@ -233,15 +235,15 @@ public class RollCallMandatoryRepository : RepositoryBase, IRoll } return new GroupedRollCalls() - { - CreationDate = x.Key, - ShiftList = x.Select(s => new ShiftList() { Start = s.StartDate!.Value, End = s.EndDate!.Value, EndWithOutResTime = s.EndDate!.Value }) - .ToList(), - //HasFriday = x.Any(s => - // s.StartDate != null && s.EndDate != null && (s.StartDate.Value.DayOfWeek == DayOfWeek.Friday || - // s.EndDate.Value!.DayOfWeek == DayOfWeek.Friday)), + { + CreationDate = x.Key, + ShiftList = x.Select(s => new ShiftList() { Start = s.StartDate!.Value, End = s.EndDate!.Value, EndWithOutResTime = s.EndDate!.Value }) + .ToList(), + //HasFriday = x.Any(s => + // s.StartDate != null && s.EndDate != null && (s.StartDate.Value.DayOfWeek == DayOfWeek.Friday || + // s.EndDate.Value!.DayOfWeek == DayOfWeek.Friday)), - Fridays = friday, + Fridays = friday, SumOneDaySpan = new TimeSpan(x.Sum(shift => shift.ShiftSpan.Ticks)) - breakTime, @@ -265,7 +267,7 @@ public class RollCallMandatoryRepository : RepositoryBase, IRoll TimeSpan sumSpans = new TimeSpan(groupedRollCall.Sum(x => x.SumOneDaySpan.Ticks)); - TimeSpan sumSpansWhitOutleaves = new TimeSpan(groupedRollCall.Sum(x => x.SumOneDaySpan.Ticks)); + TimeSpan sumSpansWhitOutleaves = new TimeSpan(groupedRollCall.Sum(x => x.SumOneDaySpan.Ticks)); //بدست آوردن مرخصی ساعتی @@ -323,6 +325,9 @@ public class RollCallMandatoryRepository : RepositoryBase, IRoll TimeSpan totalLeaveSpan = TimeSpan.Zero; TimeSpan starndardHoursesPerTotalDaysSapn = new TimeSpan(hours, minutes, 0); + + //محموع تمام مرخصی های این ماه + //TimeSpan totalLeaveOnThisCheckout = TimeSpan.Zero; if (leaveSearchResult.Count > 0 || hoursesleave.Count > 0) { if (leaveSearchResult.Any(x => x.HasShiftDuration)) @@ -342,8 +347,11 @@ public class RollCallMandatoryRepository : RepositoryBase, IRoll TimeSpan totalLeave = new TimeSpan(leaveSearchResult.Sum(x => x.ShiftDuration.Ticks)); totalLeave = totalLeave.Add(hoursesleaveTimeSpans); + //totalLeaveOnThisCheckout = totalLeave; var totalLeaveDouble = (totalLeave.TotalMinutes) / 60; - if (totalLeaveDouble > starndardHoursesPerTotalDays) + + //اگر مدت مرخصی از مجاز بیشتر بود و مدل محاسبه کامل نبود + if (totalLeaveDouble > starndardHoursesPerTotalDays && !totalLeaveCompute) { sumSpans = sumSpans.Add(starndardHoursesPerTotalDaysSapn); @@ -402,7 +410,7 @@ public class RollCallMandatoryRepository : RepositoryBase, IRoll } - if (sumLeave > starndardHoursesPerTotalDaysSapn) + if (sumLeave > starndardHoursesPerTotalDaysSapn && !totalLeaveCompute) { sumSpans = sumSpans.Add(starndardHoursesPerTotalDaysSapn); totalLeaveSpan = starndardHoursesPerTotalDaysSapn; @@ -413,7 +421,11 @@ public class RollCallMandatoryRepository : RepositoryBase, IRoll totalLeaveSpan = sumLeave; } - + //#region TotalLeaveOnThisCheckout + + //totalLeaveOnThisCheckout = (leavingDayCout * workingPerDayAve).Add(hoursesleaveTimeSpans); + + //#endregion } @@ -914,9 +926,13 @@ public class RollCallMandatoryRepository : RepositoryBase, IRoll // مرخصی استحقاقی TotalPaidLeave = totalLeaveSpan, + + //// مجموع مرخصی های پرسنل در این فیش حقوقی + //TotalLeaveOnThisCheckout = totalLeaveOnThisCheckout, + //مرخصی استعلاجی TotalSickLeave = new TimeSpan(sickLeaveTimeSpans.Sum(x => x.Ticks)), - + //ساعت موظفی پرسنل در این ماه EmployeeMandatoryHours = mandatoryHoursTimeSpan, #endregion @@ -1822,6 +1838,69 @@ public class RollCallMandatoryRepository : RepositoryBase, IRoll var startDateAndTime = new PersianDateTime(syear, smonth, sday, start.Hour, start.Minute); var startContract = new PersianDateTime(syear, smonth, sday, start.Hour, start.Minute); var endContract = new PersianDateTime(eyear, emonth, eday, 23, 59); + var countLeves = leaveSearchResult.Where(x => x.PaidLeaveType == "روزانه").ToList(); + //int totalLeaveDays = countLeves.Sum(x => int.Parse(x.LeaveHourses)); + List affectedLeaves = new List(); + + DateTime contractStart = ($"{startContract}").ToGeorgianDateTime(); + DateTime contractEnd = ($"{endContract}").ToGeorgianDateTime(); + int leavingDayCout = 0; + List thisCheckoutLeaves = new List(); + + + if (leaveSearchResult.Count > 0) + { + foreach (var leave in leaveSearchResult) + { + //مرخصی های مابین + if (leave.StartLeaveGr >= contractStart && leave.EndLeaveGr <= contractEnd) + { + var modifyleave = new LeaveViewModel() + { + Id = leave.Id, + StartLeaveGr = leave.StartLeaveGr, + EndLeaveGr = leave.EndLeaveGr + }; + thisCheckoutLeaves.Add(leave); + } + + // مرخصی که شروعش قبل از شروع تصفیه حساب است + if (leave.StartLeaveGr < contractStart && leave.EndLeaveGr <= contractEnd) + { + var modifyleave = new LeaveViewModel() + { + Id = leave.Id, + StartLeaveGr = contractStart, + EndLeaveGr = leave.EndLeaveGr + }; + thisCheckoutLeaves.Add(modifyleave); + } + // مرخصی که پایانش بعد از پایان تصفیه حساب است + if (leave.EndLeaveGr > contractEnd && leave.StartLeaveGr >= contractStart) + { + var modifyleave = new LeaveViewModel() + { + Id = leave.Id, + StartLeaveGr = leave.StartLeaveGr, + EndLeaveGr = contractEnd, + }; + thisCheckoutLeaves.Add(modifyleave); + } + + //مرخصی استثنا که تمام بازه فیش را پوشش میدهد + if (leave.StartLeaveGr < contractStart && leave.EndLeaveGr > contractEnd) + { + var modifyleave = new LeaveViewModel() + { + Id = leave.Id, + StartLeaveGr = leave.StartLeaveGr, + EndLeaveGr = contractEnd, + }; + thisCheckoutLeaves.Add(modifyleave); + } + } + } + for (var da = startDateAndTime; da <= endContract; da = da.AddHours(addHours)) { @@ -1845,14 +1924,31 @@ public class RollCallMandatoryRepository : RepositoryBase, IRoll end.Second); Console.WriteLine($"{currentDateFa} - {currentDateGr.Date} - start : {startComplex} end : {endComplex}"); - rollCallList.Add(new RollCallViewModel() + + var hasLeave = thisCheckoutLeaves.Any(x => startComplex.Date <= x.EndLeaveGr.Date && endComplex.Date >= x.StartLeaveGr.Date); + if (!hasLeave) { - StartDate = startComplex, - EndDate = endComplex, - ShiftSpan = (endComplex - startComplex), - ShiftDate = currentDateGr, - ShiftEndWithoutRest = endComplex - }); + rollCallList.Add(new RollCallViewModel() + { + StartDate = startComplex, + EndDate = endComplex, + ShiftSpan = (endComplex - startComplex), + ShiftDate = currentDateGr, + ShiftEndWithoutRest = endComplex + }); + } + else + { + var affected = thisCheckoutLeaves.FirstOrDefault(x => startComplex.Date <= x.EndLeaveGr.Date && endComplex.Date >= x.StartLeaveGr.Date); + var modifyleave = new LeaveViewModel() + { + Id = affected.Id, + StartLeaveGr = affected.StartLeaveGr, + EndLeaveGr = affected.EndLeaveGr + }; + affectedLeaves.Add(modifyleave); + } + var endCal = end - start; @@ -1861,14 +1957,20 @@ public class RollCallMandatoryRepository : RepositoryBase, IRoll } - var countLeves = leaveSearchResult.Where(x => x.PaidLeaveType == "روزانه").ToList(); - if (countLeves.Count > 0) + + + affectedLeaves = affectedLeaves.DistinctBy(x => x.Id).ToList(); + + //مرخصی هایی که تاریخ آن ها بین رکورد های حضور پرسنل بوده و اعمال نشده + var exceptionLeaves = thisCheckoutLeaves + .Where(t => !affectedLeaves.Select(a => a.Id).Contains(t.Id)) + .ToList(); + + //حذف رکورد های حضور به تعداد مرخصی های اعمال نشده + if (exceptionLeaves.Count > 0) { - int totalDays = countLeves.Sum(x => int.Parse(x.LeaveHourses)); - - int countRollCall = rollCallList.Count(); - int takRollCall = totalDays < countRollCall ? (countRollCall - totalDays) : 0; + int takRollCall = exceptionLeaves.Count < countRollCall ? (countRollCall - exceptionLeaves.Count) : 0; rollCallList = rollCallList.Take(takRollCall).ToList(); } diff --git a/CompanyManagment.EFCore/Repository/YearlySalaryRepository.cs b/CompanyManagment.EFCore/Repository/YearlySalaryRepository.cs index a53e3c8d..ca9b3137 100644 --- a/CompanyManagment.EFCore/Repository/YearlySalaryRepository.cs +++ b/CompanyManagment.EFCore/Repository/YearlySalaryRepository.cs @@ -2349,24 +2349,26 @@ public class YearlySalaryRepository : RepositoryBase, IYearl // تعداد روزهایی که برای پرسنل مرخصی حساب شده result.TotalDayOfLeaveCompute = $"{resEndOfYear.CountChekoutDays}"; - } - else if (isOldContract && contractEnd > start1403) - { - var startDate = startWorkDate >= start1403 ? startWorkDate : start1403; + } + else if (isOldContract && contractEnd > start1403) + { + var startDate = startWorkDate >= start1403 ? startWorkDate : start1403; + - var endOfYearRes = EndOfYearCantoleaveList(startDate, separationEndDate, workshopId, employeeId, hasleft, leftWorkDate, fridayStartToEnd, officialHoliday, totalHoursH, totalHorsM, separationStartDate) - .FirstOrDefault(x => x.ContractStart == separationStartDate); - if ((hasleft && leftWorkDate <= separationEndDate) || (separationEndDate == contractEnd && checkoutMonth == "12")) - { - var end = EndOfYearCantoleaveList(startDate, separationEndDate, workshopId, employeeId, - hasleft, leftWorkDate, fridayStartToEnd, officialHoliday, totalHoursH, totalHorsM, - separationStartDate); + var endOfYearRes = EndOfYearCantoleaveList(startDate, separationEndDate, workshopId, employeeId, hasleft, leftWorkDate, fridayStartToEnd, officialHoliday, totalHoursH, totalHorsM, separationStartDate) + .FirstOrDefault(x => x.ContractStart == separationStartDate); + if ((hasleft && leftWorkDate <= separationEndDate) || (separationEndDate == contractEnd && checkoutMonth == "12")) + { + var end = EndOfYearCantoleaveList(startDate, separationEndDate, workshopId, employeeId, + hasleft, leftWorkDate, fridayStartToEnd, officialHoliday, totalHoursH, totalHorsM, + separationStartDate); + - //وضعیت تصفیه مزد مرخصی - result.LeaveCheckout = true; + //وضعیت تصفیه مزد مرخصی + result.LeaveCheckout = true; - var canTolv = endOfYearRes.CanToLeave; - var absence = end.Sum(x => x.PeriodOfAbsence); + var canTolv = endOfYearRes.CanToLeave; + var absence = end.Where(x=>x.ContractStart >= startDayOfYearGr).Sum(x => x.PeriodOfAbsence); if (canTolv >= absence) { @@ -2427,12 +2429,12 @@ public class YearlySalaryRepository : RepositoryBase, IYearl hasleft, leftWorkDate, fridayStartToEnd, officialHoliday, totalHoursH, totalHorsM, separationStartDate); - var canTolv = endOfYearRes.CanToLeave; - var absence = end.Sum(x => x.PeriodOfAbsence); + var canTolv = endOfYearRes.CanToLeave; + var absence = end.Where(x => x.ContractStart >= startDayOfYearGr).Sum(x => x.PeriodOfAbsence); if (canTolv >= absence) - { - canTolv -= absence; - absence = 0; + { + canTolv -= absence; + absence = 0; } else diff --git a/ServiceHost/Areas/Admin/Pages/Company/Checkouts/Index.cshtml.cs b/ServiceHost/Areas/Admin/Pages/Company/Checkouts/Index.cshtml.cs index 9a7bcb23..2c3deda5 100644 --- a/ServiceHost/Areas/Admin/Pages/Company/Checkouts/Index.cshtml.cs +++ b/ServiceHost/Areas/Admin/Pages/Company/Checkouts/Index.cshtml.cs @@ -31,6 +31,7 @@ using PersianTools.Core; using ServiceHost.Hubs; using System.Diagnostics.Contracts; using WorkFlow.Application.Contracts.WorkFlow; +using System.Globalization; namespace ServiceHost.Areas.Admin.Pages.Company.Checkouts; @@ -767,9 +768,51 @@ public class IndexModel : PageModel var workingHours = _workingHoursTempApplication.GetByContractIdConvertToShiftwork4(contract.Id); var separation = _contractApplication.contractSeparation(ConvertYear, ConvertMonth, contract.ContractStartGr, contract.ContractEndGr, contract.EmployeeId, contract.WorkshopIds); - + if (separation.checker) { + //workshopInfo + var workshop = _workshopApplication.GetDetails(contract.WorkshopIds); + + var employeeOptions = + _employeeComputeOptionsApplication.GetAllByWorkshopId(contract.WorkshopIds); + var getYearsOption = employeeOptions.FirstOrDefault(x => x.EmployeeId == contract.EmployeeId); + var yearsOption = getYearsOption == null ? workshop.YearsOptions : getYearsOption.YearsOptions; + var getBonusesOption = employeeOptions.FirstOrDefault(x => x.EmployeeId == contract.EmployeeId); + var bonusesOption = getBonusesOption == null + ? workshop.BonusesOptions + : getBonusesOption.BonusesOptions; + var getComputeOption = employeeOptions.FirstOrDefault(x => x.EmployeeId == contract.EmployeeId); + var computeOption = getComputeOption == null + ? workshop.ComputeOptions + : getComputeOption.ComputeOptions; + //آیا کل مرخصی به ساعت کاراضافه شود؟ + bool totalLeaveCompute = false; + //آیا غیبت محاسبه شود؟ + bool abcenseDeduction = false; + switch (computeOption) + { + case "OnEndOfYear": + var endOfYearCheckout = separation.ContractEnd.Substring(5, 2); + + + totalLeaveCompute = true; + abcenseDeduction = separation.HasLeft || endOfYearCheckout == "12"; + break; + case "OnLeftWork": + + totalLeaveCompute = true; + abcenseDeduction = separation.HasLeft; + break; + case "OnEndOfContract": + var startMonth = contract.ContarctStart.Substring(5, 2); + var endMonth = contract.ContractEnd.Substring(5, 2); + + totalLeaveCompute = startMonth == endMonth ? false : true; + abcenseDeduction = (startMonth != endMonth && separation.HasLeft) || (startMonth != endMonth && contract.ContractEndGr == separation.ContractEndGr); + break; + } + workingHours.ContractStartGr = separation.ContractStartGr; workingHours.ContractEndGr = separation.ContractEndGr; workingHours.ContarctStart = separation.ContarctStart; @@ -778,8 +821,7 @@ public class IndexModel : PageModel workingHours.GetWorkDateHide = contract.GetWorkDate; workingHours.WorkshopId = contract.WorkshopIds; workingHours.EmployeeId = contract.EmployeeId; - //workshopInfo - var workshop = _workshopApplication.GetDetails(contract.WorkshopIds); + var mandatoryCompute = new ComputingViewModel(); #region DailyWageCompute @@ -799,13 +841,15 @@ public class IndexModel : PageModel { mandatoryCompute = _rollCallMandatoryApplication.MandatoryCompute(contract.EmployeeId, contract.WorkshopIds, - separation.ContractStartGr, separation.ContractEndGr, workingHours, workshop.WorkshopHolidayWorking, false,workshop.RotatingShiftCompute, dailyWageUnAffected); + separation.ContractStartGr, separation.ContractEndGr, workingHours, workshop.WorkshopHolidayWorking, false,workshop.RotatingShiftCompute, dailyWageUnAffected, totalLeaveCompute); + } else { mandatoryCompute = _rollCallMandatoryApplication.MandatoryCompute(contract.EmployeeId, contract.WorkshopIds, - separation.ContractStartGr, separation.ContractEndGr, workingHours, workshop.WorkshopHolidayWorking, true,workshop.RotatingShiftCompute, dailyWageUnAffected); + separation.ContractStartGr, separation.ContractEndGr, workingHours, workshop.WorkshopHolidayWorking, true,workshop.RotatingShiftCompute, dailyWageUnAffected, totalLeaveCompute); + //var hasLeave = _leaveApplication.LeavOnChekout(separation.ContractStartGr, // separation.ContractEndGr, contract.EmployeeId, contract.WorkshopIds); //if (hasLeave != null) @@ -851,18 +895,6 @@ public class IndexModel : PageModel // workshop.ComputeOptions = "OnEndOfContract"; //} - var employeeOptions = - _employeeComputeOptionsApplication.GetAllByWorkshopId(contract.WorkshopIds); - var getYearsOption = employeeOptions.FirstOrDefault(x => x.EmployeeId == contract.EmployeeId); - var yearsOption = getYearsOption == null ? workshop.YearsOptions : getYearsOption.YearsOptions; - var getBonusesOption = employeeOptions.FirstOrDefault(x => x.EmployeeId == contract.EmployeeId); - var bonusesOption = getBonusesOption == null - ? workshop.BonusesOptions - : getBonusesOption.BonusesOptions; - var getComputeOption = employeeOptions.FirstOrDefault(x => x.EmployeeId == contract.EmployeeId); - var computeOption = getComputeOption == null - ? workshop.ComputeOptions - : getComputeOption.ComputeOptions; //سنوات var yearsPay = _yearlySalaryRepository.Years(separation.ContractStartGr, separation.LeftWorkDate, @@ -913,7 +945,8 @@ public class IndexModel : PageModel { foundMandatoryCompute = _rollCallMandatoryApplication.MandatoryCompute(contract.EmployeeId, contract.WorkshopIds, - found.ContractStart, found.ContractEnd, foundWorkingHours, workshop.WorkshopHolidayWorking, false, workshop.RotatingShiftCompute, dailyWageUnAffected); + found.ContractStart, found.ContractEnd, foundWorkingHours, workshop.WorkshopHolidayWorking, false, workshop.RotatingShiftCompute, dailyWageUnAffected, totalLeaveCompute); + } else @@ -958,6 +991,8 @@ public class IndexModel : PageModel contract.ContractEndGr, contract.WorkshopIds, contract.EmployeeId, fridayStartToEnd, officialHoliday, totalHoursH, totalHoursM, consumableItemDouble, housingAllowanceDouble, familyAllowanceDouble, marriedAllowanceDouble, workshop.IsOldContract); + + var command = new CreateCheckout { EmployeeFullName = employee.EmployeeFullName, @@ -1006,7 +1041,7 @@ public class IndexModel : PageModel //مدت غیبت AbsencePeriod = leavePayNew.AbsencePeriod, //کسری غیبت - AbsenceDeduction = 0, + AbsenceDeduction = abcenseDeduction ? leavePayNew.AbsenceDeduction : 0, //وضعیت تصفیه مزد مرخصی LeaveCheckout = leavePayNew.LeaveCheckout, //میانگین ساعت کار در روز diff --git a/ServiceHost/Areas/Admin/Pages/Company/Employees/Create.cshtml b/ServiceHost/Areas/Admin/Pages/Company/Employees/Create.cshtml index 32b0cd0e..c0921767 100644 --- a/ServiceHost/Areas/Admin/Pages/Company/Employees/Create.cshtml +++ b/ServiceHost/Areas/Admin/Pages/Company/Employees/Create.cshtml @@ -571,6 +571,12 @@ } else if (response.data.gender === 1) { $('#GenderFemale').prop('checked', true); $('#soldier').prop('disabled', true); + } + else{ + $('#GenderMale').removeClass("disable"); + $('#GenderFemale').removeClass("disable"); + $('#divGender .radio-box').removeClass('disable'); + } currentStep++; showStep(currentStep); diff --git a/ServiceHost/Areas/Admin/Pages/Company/Employees/CreateEmployee.cshtml b/ServiceHost/Areas/Admin/Pages/Company/Employees/CreateEmployee.cshtml index 4df980de..28543bbb 100644 --- a/ServiceHost/Areas/Admin/Pages/Company/Employees/CreateEmployee.cshtml +++ b/ServiceHost/Areas/Admin/Pages/Company/Employees/CreateEmployee.cshtml @@ -571,6 +571,11 @@ } else if (response.data.gender === 1) { $('#GenderFemale').prop('checked', true); $('#soldier').prop('disabled', true); + } + else{ + $('#GenderMale').removeClass("disable"); + $('#GenderFemale').removeClass("disable"); + $('#divGender .radio-box').removeClass('disable'); } currentStep++; showStep(currentStep); diff --git a/ServiceHost/Program.cs b/ServiceHost/Program.cs index bd2e195b..5df65d59 100644 --- a/ServiceHost/Program.cs +++ b/ServiceHost/Program.cs @@ -314,6 +314,7 @@ app.UseCors("AllowSpecificOrigins"); //the backend Tester if (builder.Environment.IsDevelopment()) + { using var scope = app.Services.CreateScope(); var tester = scope.ServiceProvider.GetRequiredService();