Feature #11025
openFeature #11019: Subscription Updates for Cancellation by Admin and Customer
Jobs and other fixes
Added by Divya Inapakurthi 13 days ago. Updated 10 days ago.
100%
Subtasks
Related issues
Updated by Divya Inapakurthi 12 days ago
- Status changed from New to In Progress
- % Done changed from 0 to 50
1. Critical Bug Fixes
Stripe Webhook Invoice Validation (createdBy: null):
Issue: Off-store webhook processing failed with Invoice validation failed: createdBy: null is not a valid ObjectId or string.
Fix: In
EverGreen-invoice-model.js
, updated the validator to permit null/undefined. In
invoicePaid.js
, ensured createdBy and groupId reliably fall back to contract.createdBy || contract.clientId.
Plan Variant Buffer Days Auto-Fill:
Issue: When editing a plan variant with no custom buffer days, the "Schedule to Cancel" field was blank instead of pre-filling with the company default (e.g. 5 days).
Fix: In
PlanVariantForm.tsx
and
CreateSubscription.tsx
, updated the modal state and fallback logic to populate the company default.
Variant Buffer Days Propagation in Subscriber Cancellation:
Issue: Cancellation modal in subscriber details wasn't receiving variant-level cancellation days.
Fix: In
subscripiton.service.js
, added variants: 1 projection to the subscriber pipeline. In
ProductSubscriberDetails.tsx
, updated getVariantBufferDays to resolve custom variant days or fall back cleanly to company defaults.
Cancellation Settlement Display Guard:
Fix: In
Subscribers.tsx
, updated the card condition:
tsx
{Boolean(sub.cancellationSettlement) && !['active', 'completed'].includes(sub.status?.toLowerCase() || '') && (
This hides the settlement card for active/completed subscribers and prevents blank-screen null pointer errors.
2. Auto-Job Scheduling Engine Enhancements
Signup-Month Visit Guarantee:
In
visitScheduleHelper.js
, when a customer subscribes late in the month and all fixed dates have passed (e.g., signup on Sept 26 with fixed dates [1, 8, 15, 22]):
If days remaining $\ge$ End-of-Month Lead Time (subscriptionCutoffDays, e.g., 4 days), it schedules 1 immediate visit on Payment Date + Lead Days (e.g. Sept 30th).
Automatically defers the remaining 3 visits to the same month next year (Sept 2027) to ensure the customer receives their full 12-month allotment.
Cascading Minimum Visit Spacing & Weekly Cadence:
If a visit is scheduled late in the month (Sept 30th), subsequent visits enforce minimum visit spacing (7 days for 4 visits/month):
October: Starts on Oct 7/8 (skipping Oct 1 to maintain spacing), cascading to Oct 8, 15, 22, 29.
November: Starts on Nov 4/8 (skipping Nov 1 to maintain spacing from Oct 29), cascading to Nov 8, 15, 22, 29.
Guarantees a steady weekly rhythm without clustering services too closely.
3. Action History & Scheduling Insights
Audit Trail Generation:
resolveVisitScheduleDates now outputs scheduleInsights tracking:
Original master date vs. final scheduled date.
Specific reasons for shifts (Client Spacing buffer, Weekend non-working day, Company Holiday, Capacity limit).
Clear human-readable summary.
Backend Storage:
In
invoicePaid.js
and
subscripiton.service.js
, every auto-created job now records:
job.actionHistory: Entry with action "auto_scheduled" and full explanation note.
job.notes: Concise scheduling reason.
job.subscriptionMeta.metadata.scheduleInsight: Full structured insight payload.
Frontend UI Tooltip:
In
SubscriberJobs.tsx
, added an Info Tooltip ℹ️ in the Start Date column so staff and managers can hover over any date to see why it was chosen or shifted (e.g., "Originally scheduled for 2026-10-01, shifted to 2026-10-08: Enforced minimum visit spacing (7 days buffer from prior visit on 2026-09-30)").