Project

General

Profile

Edit Copy Actions

Feature #8424

open

Feature #8327: Subscriptions Analytics & visualisation

Product subscription Email and updating schema for efficiency

Added by Divya Inapakurthi 13 days ago. Updated 12 days ago.

Status:
New
Priority:
Normal
Target version:
-
Start date:
03/26/2026
Due date:
03/26/2026 (13 days late)
% Done:

100%

Estimated time:

Add

Subtasks


Add

Related issues

Updated by Divya Inapakurthi 13 days ago

What we fixed / implemented

Product subscription invoice resend now attaches a real PDF

Uses the same invoice PDF generator as service subscriptions.
PDF styling matches service invoices.
File: evergreen_pos_be/src/controllers/resendProductSubInvoice.controller.js
Product subscription PDF shows “Products” and removes utility‑line note

Heading changed from “Services” → “Products”.
Utility‑lines note removed only for product subscriptions.
Files:
evergreen_pos_be/src/controllers/resendProductSubInvoice.controller.js
evergreen_pos_be/src/routes/EvergreenInvoice/EverGreen-invoice-controller.js
Service subscriptions now respect full visitSchedule but only on first payment

Visits are evenly spaced in each month defined in visitSchedule.
Entire yearly schedule is created only on first payment (prevents duplicates on later invoices).
Files:
evergreen_pos_be/src/service-webhook-handlers/invoicePaid.js
evergreen_pos_be/src/services/subscripiton.service.js
Product subscription now stores tenure + total cycles

Added totalCycles and tenureInDays to product subscription schema.
Computed from customPlanEndDate + billingCycleInDays.
File: evergreen_pos_be/src/models/subscription/subscription.model.js
Product subscription cycleNumber now reflects first payment

Previously stayed 0 after first payment because invoicePaid ignores subscription_create.
Now set to 1 at subscription creation.
File: evergreen_pos_be/src/webhook-handlers/checkoutCompleted.js
Product subscription completion now checks totalCycles

If cycleNumber >= totalCycles, it closes the subscription.
File: evergreen_pos_be/src/webhook-handlers/invoicePaid.js
Backfill script for existing product subscriptions

Computes totalCycles, tenureInDays.
Fixes cycleNumber based on paid transactions.
Supports --dry-run and --mongo-uri.
File: evergreen_pos_be/scripts/backfill_product_subscription_cycles.js
Issues resolved

Missing PDF in product subscription “resend invoice”.
Product PDF looked like service invoice.
Utility‑line note showed on product PDF.
Service subscription schedules ignored visitSchedule.
Duplicate yearly job creation on later payments.
Product cycleNumber stuck at 0 after first payment.
Missing tenure/totalCycles for product subscriptions.

Actions #2

Updated by Divya Inapakurthi 12 days ago

  • Due date set to 03/26/2026
  • % Done changed from 0 to 100
Edit Copy Actions

Also available in: Atom PDF