From af1388f0d731d31b2927d0182ca7f866f4081180 Mon Sep 17 00:00:00 2001 From: mahan Date: Sat, 11 Oct 2025 14:58:30 +0330 Subject: [PATCH] feat: update not created workshops query to include filtering by left work insurance dates --- .../Repository/InsuranceListRepository.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CompanyManagment.EFCore/Repository/InsuranceListRepository.cs b/CompanyManagment.EFCore/Repository/InsuranceListRepository.cs index 94cc98f4..dcf1447b 100644 --- a/CompanyManagment.EFCore/Repository/InsuranceListRepository.cs +++ b/CompanyManagment.EFCore/Repository/InsuranceListRepository.cs @@ -1579,7 +1579,7 @@ public class InsuranceListRepository : RepositoryBase, IIns var acountId = _authHelper.CurrentAccountId(); var accountWorkshopIds = _context.WorkshopAccounts.Where(x => x.AccountId == acountId) .Select(x => x.WorkshopId); - + var firstDayOfMonth = $"{searchModel.Year}/{searchModel.Month}/01".ToGeorgianDateTime(); var insuranceWorkshops = _context.Workshops .Where(x=>x.InsuranceCode != null && x.InsuranceCode.Length >=10 && accountWorkshopIds.Contains(x.id) && x.IsActiveString== "true"); @@ -1588,6 +1588,11 @@ public class InsuranceListRepository : RepositoryBase, IIns .Where(x=>x.Month == searchModel.Month&& x.Year == searchModel.Year).AsQueryable(); var notCreatedWorkshop = insuranceWorkshops.Where(w=>!existInsurances.Select(x=>x.WorkshopId).Contains(w.id)); + + notCreatedWorkshop = notCreatedWorkshop + .Include(x => x.LeftWorkInsurances) + .Where(x => x.LeftWorkInsurances.Any(l=>l.StartWorkDate <= firstDayOfMonth && + (l.LeftWorkDate == null || l.LeftWorkDate >= firstDayOfMonth))); var res = await notCreatedWorkshop .GroupJoin(_context.WorkshopEmployers,