diff --git a/WorkFlow/Application/WorkFlow.Application/WorkFlowApplication.cs b/WorkFlow/Application/WorkFlow.Application/WorkFlowApplication.cs index 9bed52c5..ed188fea 100644 --- a/WorkFlow/Application/WorkFlow.Application/WorkFlowApplication.cs +++ b/WorkFlow/Application/WorkFlow.Application/WorkFlowApplication.cs @@ -1,6 +1,7 @@ using _0_Framework.Application; using _0_Framework.Domain.CustomizeCheckoutShared.Enums; using Company.Domain.RollCallAgg.DomainService; +using Company.Domain.WorkshopAgg; using CompanyManagment.App.Contracts.EmployeeDocuments; using WorkFlow.Application.Contracts.RollCallConfirmedAbsence; using WorkFlow.Application.Contracts.RollCallConfirmedWithoutLunchBreak; @@ -23,7 +24,9 @@ public class WorkFlowApplication : IWorkFlowApplication private readonly IRollCallDomainService _rollCallDomainService; private readonly IRollCallConfirmedWithoutLunchBreakRepository _rollCallConfirmedWithoutLunchBreakRepository; private readonly IEmployeeDocumentsApplication _employeeDocumentsApplication; - public WorkFlowApplication(IRollCallConfirmedAbsenceRepository absenceRepository, IWorkFlowRollCallACL rollCallACL, IWorkFlowCheckoutACL checkoutACL, IWorkFlowCustomizedWorkshopSettingsACL customizedWorkshopSettingsACL, IRollCallConfirmedWithoutLunchBreakRepository rollCallConfirmedWithoutLunchBreakRepository, IRollCallDomainService rollCallDomainService, IEmployeeDocumentsApplication employeeDocumentsApplication) + private readonly IWorkshopRepository _workshopRepository; + + public WorkFlowApplication(IRollCallConfirmedAbsenceRepository absenceRepository, IWorkFlowRollCallACL rollCallACL, IWorkFlowCheckoutACL checkoutACL, IWorkFlowCustomizedWorkshopSettingsACL customizedWorkshopSettingsACL, IRollCallConfirmedWithoutLunchBreakRepository rollCallConfirmedWithoutLunchBreakRepository, IRollCallDomainService rollCallDomainService, IEmployeeDocumentsApplication employeeDocumentsApplication, IWorkshopRepository workshopRepository) { _absenceRepository = absenceRepository; _rollCallACL = rollCallACL; @@ -32,6 +35,7 @@ public class WorkFlowApplication : IWorkFlowApplication _rollCallConfirmedWithoutLunchBreakRepository = rollCallConfirmedWithoutLunchBreakRepository; _rollCallDomainService = rollCallDomainService; _employeeDocumentsApplication = employeeDocumentsApplication; + _workshopRepository = workshopRepository; } public async Task CreateRollCallConfirmedAbsence(CreateRollCallConfirmedAbsence command) @@ -416,6 +420,10 @@ public class WorkFlowApplication : IWorkFlowApplication /// public async Task> GetUndefinedRollCalls(long workshopId) { + var workshop = _workshopRepository.Get(workshopId); + + if (workshop == null || workshop.IsStaticCheckout) + return []; var now = DateTime.Now; DateTime.Now.Date.AddMonthsFa(-2, out var twoMonthsAgo); @@ -443,6 +451,10 @@ public class WorkFlowApplication : IWorkFlowApplication /// public async Task> GetRollCallWorkFlowsCutByBgService(long workshopId) { + var workshop = _workshopRepository.Get(workshopId); + + if (workshop == null || workshop.IsStaticCheckout) + return []; var now = DateTime.Now; DateTime.Now.Date.AddMonthsFa(-2, out var twoMonthsAgo); @@ -468,6 +480,11 @@ public class WorkFlowApplication : IWorkFlowApplication public async Task CountCutByBgServiceLastMonth(long workshopId) { + var workshop = _workshopRepository.Get(workshopId); + + if (workshop == null || workshop.IsStaticCheckout) + return 0; + DateTime lastMonthEnd = ($"{DateTime.Now.ToFarsi().Substring(0, 8)}01").ToGeorgianDateTime().AddDays(-1); var now = lastMonthEnd; var twoMonthsAgo = ($"{lastMonthEnd.ToFarsi().Substring(0, 8)}01").ToGeorgianDateTime(); @@ -496,7 +513,11 @@ public class WorkFlowApplication : IWorkFlowApplication /// public async Task CountAbsentRollCallLastMonth(long workshopId) { - + var workshop = _workshopRepository.Get(workshopId); + + if (workshop == null || workshop.IsStaticCheckout) + return 0; + DateTime lastMonthEnd = ($"{DateTime.Now.ToFarsi().Substring(0, 8)}01").ToGeorgianDateTime().AddDays(-1); var now = lastMonthEnd; var twoMonthsAgo = ($"{lastMonthEnd.ToFarsi().Substring(0, 8)}01").ToGeorgianDateTime(); @@ -558,6 +579,11 @@ public class WorkFlowApplication : IWorkFlowApplication public async Task CountEmployeesWithoutLunchBreakLastMonth(long workshopId) { + var workshop = _workshopRepository.Get(workshopId); + + if (workshop == null || workshop.IsStaticCheckout) + return 0; + DateTime lastMonthEnd = ($"{DateTime.Now.ToFarsi().Substring(0, 8)}01").ToGeorgianDateTime().AddDays(-1); var now = lastMonthEnd; var twoMonthsAgo = ($"{lastMonthEnd.ToFarsi().Substring(0, 8)}01").ToGeorgianDateTime(); @@ -596,6 +622,11 @@ public class WorkFlowApplication : IWorkFlowApplication public async Task CountUndefinedLastMonth(long workshopId) { + var workshop = _workshopRepository.Get(workshopId); + + if (workshop == null || workshop.IsStaticCheckout) + return 0; + DateTime lastMonthEnd = ($"{DateTime.Now.ToFarsi().Substring(0, 8)}01").ToGeorgianDateTime().AddDays(-1); var now = lastMonthEnd; var twoMonthsAgo = ($"{lastMonthEnd.ToFarsi().Substring(0, 8)}01").ToGeorgianDateTime(); @@ -625,7 +656,10 @@ public class WorkFlowApplication : IWorkFlowApplication /// public async Task> GetAbsentRollCallWorkFlows(long workshopId) { - + var workshop = _workshopRepository.Get(workshopId); + + if (workshop == null || workshop.IsStaticCheckout) + return []; var now = DateTime.Now; DateTime.Now.Date.AddMonthsFa(-2, out var twoMonthsAgo); @@ -689,6 +723,10 @@ public class WorkFlowApplication : IWorkFlowApplication /// public async Task> GetEmployeesWithoutLunchBreak(long workshopId) { + var workshop = _workshopRepository.Get(workshopId); + + if (workshop == null || workshop.IsStaticCheckout) + return []; var now = DateTime.Now.Date; now.AddMonthsFa(-2, out var twoMonthsAgo);