feat: update not created workshops query to include filtering by left work insurance dates

This commit is contained in:
2025-10-11 14:58:30 +03:30
parent ed5681256d
commit af1388f0d7

View File

@@ -1579,7 +1579,7 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, 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<long, InsuranceList>, 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,