feat: update not created workshops query to include filtering by left work insurance dates
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user