diff --git a/Company.Domain/RollCallAgg/IRollCallMandatoryRepository.cs b/Company.Domain/RollCallAgg/IRollCallMandatoryRepository.cs index c1a8e006..9c77aa59 100644 --- a/Company.Domain/RollCallAgg/IRollCallMandatoryRepository.cs +++ b/Company.Domain/RollCallAgg/IRollCallMandatoryRepository.cs @@ -15,7 +15,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); + 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/Contract/ComputingViewModel.cs b/CompanyManagment.App.Contracts/Contract/ComputingViewModel.cs index ed64868b..3a2c0ddd 100644 --- a/CompanyManagment.App.Contracts/Contract/ComputingViewModel.cs +++ b/CompanyManagment.App.Contracts/Contract/ComputingViewModel.cs @@ -64,6 +64,6 @@ public class ComputingViewModel /// /// مجموع مرخصی های پرسنل در این فیش حقوقی /// - public TimeSpan TotalLeaveOnThisCheckout { get; set; } + //public TimeSpan TotalLeaveOnThisCheckout { get; set; } //public List holidays; } \ No newline at end of file diff --git a/CompanyManagment.App.Contracts/RollCall/IRollCallMandatoryApplication.cs b/CompanyManagment.App.Contracts/RollCall/IRollCallMandatoryApplication.cs index ce101b2b..27bdb4c0 100644 --- a/CompanyManagment.App.Contracts/RollCall/IRollCallMandatoryApplication.cs +++ b/CompanyManagment.App.Contracts/RollCall/IRollCallMandatoryApplication.cs @@ -8,7 +8,7 @@ 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); + ComputingViewModel MandatoryCompute(long employeeId, long workshopId, DateTime contractStart, DateTime contractEnd, CreateWorkingHoursTemp command, bool holidayWorking, bool isStaticCheckout, bool rotatingShiftCompute, bool totalLeaveCompute); /// /// گزارش نوبت کاری حضور غیاب diff --git a/CompanyManagment.Application/CheckoutApplication.cs b/CompanyManagment.Application/CheckoutApplication.cs index 4101295b..bd4fca43 100644 --- a/CompanyManagment.Application/CheckoutApplication.cs +++ b/CompanyManagment.Application/CheckoutApplication.cs @@ -184,7 +184,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/RollCallMandatoryApplication.cs b/CompanyManagment.Application/RollCallMandatoryApplication.cs index 617b906e..25e46b9f 100644 --- a/CompanyManagment.Application/RollCallMandatoryApplication.cs +++ b/CompanyManagment.Application/RollCallMandatoryApplication.cs @@ -21,9 +21,9 @@ 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) + public ComputingViewModel MandatoryCompute(long employeeId, long workshopId, DateTime contractStart, DateTime contractEnd, CreateWorkingHoursTemp command, bool holidayWorking, bool isStaticCheckout, bool rotatingShiftCompute,bool totalLeaveCompute) { - return _rollCallMandatoryRepository.MandatoryCompute(employeeId,workshopId, contractStart, contractEnd, command, holidayWorking, isStaticCheckout, rotatingShiftCompute); + return _rollCallMandatoryRepository.MandatoryCompute(employeeId,workshopId, contractStart, contractEnd, command, holidayWorking, isStaticCheckout, rotatingShiftCompute, totalLeaveCompute); } public async Task RotatingShiftReport(long workshopId, long employeeId, DateTime contractStart, DateTime contractEnd, diff --git a/CompanyManagment.EFCore/Repository/RollCallMandatoryRepository.cs b/CompanyManagment.EFCore/Repository/RollCallMandatoryRepository.cs index eb78e688..a4aaf37f 100644 --- a/CompanyManagment.EFCore/Repository/RollCallMandatoryRepository.cs +++ b/CompanyManagment.EFCore/Repository/RollCallMandatoryRepository.cs @@ -67,7 +67,7 @@ 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) + CreateWorkingHoursTemp command, bool holidayWorking, bool isStaticCheckout, bool rotatingShiftCompute, bool totalLeaveCompute) { #region Entities @@ -325,7 +325,7 @@ public class RollCallMandatoryRepository : RepositoryBase, IRoll TimeSpan starndardHoursesPerTotalDaysSapn = new TimeSpan(hours, minutes, 0); //محموع تمام مرخصی های این ماه - TimeSpan totalLeaveOnThisCheckout = TimeSpan.Zero; + //TimeSpan totalLeaveOnThisCheckout = TimeSpan.Zero; if (leaveSearchResult.Count > 0 || hoursesleave.Count > 0) { if (leaveSearchResult.Any(x => x.HasShiftDuration)) @@ -345,9 +345,11 @@ public class RollCallMandatoryRepository : RepositoryBase, IRoll TimeSpan totalLeave = new TimeSpan(leaveSearchResult.Sum(x => x.ShiftDuration.Ticks)); totalLeave = totalLeave.Add(hoursesleaveTimeSpans); - totalLeaveOnThisCheckout = totalLeave; + //totalLeaveOnThisCheckout = totalLeave; var totalLeaveDouble = (totalLeave.TotalMinutes) / 60; - if (totalLeaveDouble > starndardHoursesPerTotalDays) + + //اگر مدت مرخصی از مجاز بیشتر بود و مدل محاسبه کامل نبود + if (totalLeaveDouble > starndardHoursesPerTotalDays && !totalLeaveCompute) { sumSpans = sumSpans.Add(starndardHoursesPerTotalDaysSapn); @@ -406,7 +408,7 @@ public class RollCallMandatoryRepository : RepositoryBase, IRoll } - if (sumLeave > starndardHoursesPerTotalDaysSapn) + if (sumLeave > starndardHoursesPerTotalDaysSapn && !totalLeaveCompute) { sumSpans = sumSpans.Add(starndardHoursesPerTotalDaysSapn); totalLeaveSpan = starndardHoursesPerTotalDaysSapn; @@ -417,11 +419,11 @@ public class RollCallMandatoryRepository : RepositoryBase, IRoll totalLeaveSpan = sumLeave; } - #region TotalLeaveOnThisCheckout + //#region TotalLeaveOnThisCheckout - totalLeaveOnThisCheckout = (leavingDayCout * workingPerDayAve).Add(hoursesleaveTimeSpans); + //totalLeaveOnThisCheckout = (leavingDayCout * workingPerDayAve).Add(hoursesleaveTimeSpans); - #endregion + //#endregion } @@ -895,8 +897,8 @@ public class RollCallMandatoryRepository : RepositoryBase, IRoll // مرخصی استحقاقی TotalPaidLeave = totalLeaveSpan, - // مجموع مرخصی های پرسنل در این فیش حقوقی - TotalLeaveOnThisCheckout = totalLeaveOnThisCheckout, + //// مجموع مرخصی های پرسنل در این فیش حقوقی + //TotalLeaveOnThisCheckout = totalLeaveOnThisCheckout, //مرخصی استعلاجی TotalSickLeave = new TimeSpan(sickLeaveTimeSpans.Sum(x => x.Ticks)), diff --git a/CompanyManagment.EFCore/Repository/YearlySalaryRepository.cs b/CompanyManagment.EFCore/Repository/YearlySalaryRepository.cs index e148e46a..1f0278a5 100644 --- a/CompanyManagment.EFCore/Repository/YearlySalaryRepository.cs +++ b/CompanyManagment.EFCore/Repository/YearlySalaryRepository.cs @@ -2133,6 +2133,7 @@ public class YearlySalaryRepository : RepositoryBase, IYearl 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); @@ -2141,12 +2142,13 @@ public class YearlySalaryRepository : RepositoryBase, IYearl var end = EndOfYearCantoleaveList(startDate, separationEndDate, workshopId, employeeId, hasleft, leftWorkDate, fridayStartToEnd, officialHoliday, totalHoursH, totalHorsM, separationStartDate); + //وضعیت تصفیه مزد مرخصی result.LeaveCheckout = true; var canTolv = endOfYearRes.CanToLeave; - var absence = end.Sum(x => x.PeriodOfAbsence); + var absence = end.Where(x=>x.ContractStart >= startDayOfYearGr).Sum(x => x.PeriodOfAbsence); if (canTolv >= absence) { @@ -2208,8 +2210,8 @@ public class YearlySalaryRepository : RepositoryBase, IYearl separationStartDate); var canTolv = endOfYearRes.CanToLeave; - var absence = end.Sum(x => x.PeriodOfAbsence); - if (canTolv >= absence) + var absence = end.Where(x => x.ContractStart >= startDayOfYearGr).Sum(x => x.PeriodOfAbsence); + if (canTolv >= absence) { canTolv -= absence; absence = 0; diff --git a/ServiceHost/Areas/Admin/Pages/Company/Checkouts/Index.cshtml.cs b/ServiceHost/Areas/Admin/Pages/Company/Checkouts/Index.cshtml.cs index 9910ae27..9dc85a10 100644 --- a/ServiceHost/Areas/Admin/Pages/Company/Checkouts/Index.cshtml.cs +++ b/ServiceHost/Areas/Admin/Pages/Company/Checkouts/Index.cshtml.cs @@ -767,9 +767,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 +820,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(); var hasRollCall = _rollCallEmployeeStatusApp.HasRollCallRecord(contract.EmployeeId, @@ -791,13 +832,13 @@ public class IndexModel : PageModel { mandatoryCompute = _rollCallMandatoryApplication.MandatoryCompute(contract.EmployeeId, contract.WorkshopIds, - separation.ContractStartGr, separation.ContractEndGr, workingHours, workshop.WorkshopHolidayWorking, false,workshop.RotatingShiftCompute); + separation.ContractStartGr, separation.ContractEndGr, workingHours, workshop.WorkshopHolidayWorking, false,workshop.RotatingShiftCompute, totalLeaveCompute); } else { mandatoryCompute = _rollCallMandatoryApplication.MandatoryCompute(contract.EmployeeId, contract.WorkshopIds, - separation.ContractStartGr, separation.ContractEndGr, workingHours, workshop.WorkshopHolidayWorking, true,workshop.RotatingShiftCompute); + separation.ContractStartGr, separation.ContractEndGr, workingHours, workshop.WorkshopHolidayWorking, true,workshop.RotatingShiftCompute, totalLeaveCompute); //var hasLeave = _leaveApplication.LeavOnChekout(separation.ContractStartGr, // separation.ContractEndGr, contract.EmployeeId, contract.WorkshopIds); //if (hasLeave != null) @@ -843,18 +884,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, @@ -905,7 +934,7 @@ public class IndexModel : PageModel { foundMandatoryCompute = _rollCallMandatoryApplication.MandatoryCompute(contract.EmployeeId, contract.WorkshopIds, - found.ContractStart, found.ContractEnd, foundWorkingHours, workshop.WorkshopHolidayWorking, false, workshop.RotatingShiftCompute); + found.ContractStart, found.ContractEnd, foundWorkingHours, workshop.WorkshopHolidayWorking, false, workshop.RotatingShiftCompute, totalLeaveCompute); } else @@ -951,22 +980,7 @@ public class IndexModel : PageModel officialHoliday, totalHoursH, totalHoursM, consumableItemDouble, housingAllowanceDouble, familyAllowanceDouble, marriedAllowanceDouble, workshop.IsOldContract); - switch (computeOption) - { - case "OnEndOfYear": - var endOfYearCheckout = separation.ContractEnd.Substring(5, 2); - - mandatoryCompute.TotalPaidLeave = separation.HasLeft || endOfYearCheckout == "12" ? mandatoryCompute.TotalPaidLeave : mandatoryCompute.TotalLeaveOnThisCheckout; - break; - case "OnLeftWork": - mandatoryCompute.TotalPaidLeave = separation.HasLeft ? mandatoryCompute.TotalPaidLeave : mandatoryCompute.TotalLeaveOnThisCheckout; - break; - case "OnEndOfContract": - var startMonth = contract.ContarctStart.Substring(5, 2); - var endMonth = contract.ContractEnd.Substring(5, 2); - mandatoryCompute.TotalPaidLeave = startMonth != endMonth ? mandatoryCompute.TotalLeaveOnThisCheckout : mandatoryCompute.TotalPaidLeave; - break; - } + var command = new CreateCheckout { EmployeeFullName = employee.EmployeeFullName, @@ -1015,7 +1029,7 @@ public class IndexModel : PageModel //مدت غیبت AbsencePeriod = leavePayNew.AbsencePeriod, //کسری غیبت - AbsenceDeduction = 0, + AbsenceDeduction = abcenseDeduction ? leavePayNew.AbsenceDeduction : 0, //وضعیت تصفیه مزد مرخصی LeaveCheckout = leavePayNew.LeaveCheckout, //میانگین ساعت کار در روز