Fix: POLICY-level tasks now generated for all active policies (grouped or not)
- Historical reset: removed policyGroupId: null filter from policy loop, use level POLICY only - Gap fill: same fix - all active future policies get POLICY-level tasks - BOTH-level templates remain on groups (for grouped) or policies (for ungrouped) - ~3500 grouped policies were missing their POLICY tasks (loss runs, mod factor, etc)
This commit is contained in:
parent
02afceb0c5
commit
4e54b7e38c
2 changed files with 5 additions and 7 deletions
|
|
@ -97,10 +97,9 @@ export async function POST(request: NextRequest) {
|
|||
|
||||
log.push(`Group tasks created: ${groupTasksCreated}`)
|
||||
|
||||
// ── 2. Policy-level tasks (ungrouped policies only) ─────────────────────
|
||||
// ── 2. Policy-level tasks (all active policies — grouped or not) ────────
|
||||
const ungroupedPolicies = await prisma.policy.findMany({
|
||||
where: {
|
||||
policyGroupId: null,
|
||||
expirationDate: { gte: new Date() },
|
||||
status: { notIn: ['Cancelled', 'Expired', 'Non-Renewed', 'Rewritten', 'Not taken'] as any[] },
|
||||
},
|
||||
|
|
@ -119,7 +118,7 @@ export async function POST(request: NextRequest) {
|
|||
const templates = await prisma.taskTemplate.findMany({
|
||||
where: {
|
||||
isActive: true,
|
||||
level: { in: ['BOTH', 'POLICY'] as any[] },
|
||||
level: 'POLICY' as any,
|
||||
OR: [
|
||||
{ designationId: null },
|
||||
...(designationIds.length > 0 ? [{ designationId: { in: designationIds } }] : []),
|
||||
|
|
@ -195,7 +194,7 @@ export async function POST(request: NextRequest) {
|
|||
designation2Id: true,
|
||||
claimsAdvocateId: true,
|
||||
policyGroups: { select: { renewalDate: true } },
|
||||
policies: { where: { policyGroupId: null }, select: { expirationDate: true } },
|
||||
policies: { where: { expirationDate: { gte: new Date() }, status: { notIn: ['Cancelled', 'Expired', 'Non-Renewed', 'Rewritten', 'Not taken'] as any[] } }, select: { expirationDate: true } },
|
||||
},
|
||||
})
|
||||
if (!clientRecord) continue
|
||||
|
|
|
|||
|
|
@ -209,10 +209,9 @@ export async function POST(request: NextRequest) {
|
|||
}
|
||||
}
|
||||
|
||||
// Policy-level tasks (ungrouped policies)
|
||||
// Policy-level tasks (all active policies — grouped or not)
|
||||
const ungroupedPolicies = await prisma.policy.findMany({
|
||||
where: {
|
||||
policyGroupId: null,
|
||||
expirationDate: { gte: new Date() },
|
||||
status: { notIn: ['Cancelled', 'Expired', 'Non-Renewed', 'Rewritten', 'Not taken'] },
|
||||
},
|
||||
|
|
@ -240,7 +239,7 @@ export async function POST(request: NextRequest) {
|
|||
const templates = await prisma.taskTemplate.findMany({
|
||||
where: {
|
||||
isActive: true,
|
||||
level: { in: ['BOTH', 'POLICY'] },
|
||||
level: 'POLICY',
|
||||
OR: [
|
||||
{ designationId: null },
|
||||
...(designationIds.length > 0 ? [{ designationId: { in: designationIds } }] : []),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue