Feature #6235
openFeature #6234: Implement left over features in the service subscriptions flow
Created the number of auto jobs based on the subscription configuration visit number and bug fix in subscription apis
Description
Automatically generate jobs based on the configured number of visits per year for a service subscription. By default, one job will be scheduled per month with a predefined visit date.
The system should evaluate the current date and create only upcoming jobs. If the subscription starts mid-year or the current month’s visit date has already passed, jobs should be generated starting from the next applicable month.
Jobs should be created only for the remaining scheduled visits within the subscription period.
Subtasks
Related issues
Updated by Ajit A about 1 month ago
- Assignee changed from Ajit A to Yalavarthi Thriveni
Updated by Yalavarthi Thriveni about 1 month ago
- Assignee changed from Yalavarthi Thriveni to Ajit A
Updated by Ajit A 29 days ago
- Subject changed from Created the number of auto jobs based on the subscription configuration visit number to Created the number of auto jobs based on the subscription configuration visit number and bug fix in subscription apis
- % Done changed from 0 to 20
completed few bugs in subscription api found by priyatham
Updated by Ajit A 29 days ago
Yalavarthi Thriveni wrote:
Automatically generate jobs based on the configured number of visits per year for a service subscription. By default, one job will be scheduled per month with a predefined visit date.
The system should evaluate the current date and create only upcoming jobs. If the subscription starts mid-year or the current month’s visit date has already passed, jobs should be generated starting from the next applicable month.
Jobs should be created only for the remaining scheduled visits within the subscription period.
Backend api issues
1) In discount, discount type is there but discount value is missing.. add it
2) Add Action History for Each product plan
3) Add search filter for status for Product Plans
Updated by Ajit A 27 days ago · Edited
- % Done changed from 80 to 100
completed the auto job creation with customer flow
Summary of Backend Changes
1. jobService.js (src/allservices/jobService.js)
Added subscriptionMeta support in createJobNewForInvoice
Preserves subscriptionMeta from job data (defaults to { enabled: false } if not provided)
Enables marking jobs as subscription-based
2. jobs-controller.js (src/controllers/jobs-controller.js)
Updated getAllJobsPagination to derive subscription_based from subscriptionMeta.enabled
Maintains backward compatibility by mapping subscriptionMeta.enabled to subscription_based
3. subscription.controller.js (src/controllers/subscription.controller.js)
Added fallback in getSession to trigger autojob creation if payment is successful but webhooks haven't fired
Checks invoice payment status and calls handleInvoicePaidEvent if needed
Added logging for session checks and payment verification
Updated console log formatting (removed emojis in some places)
4. webhook.controller.js (src/controllers/webhook.controller.js)
Enhanced invoice.paid webhook routing to distinguish service subscriptions (on-store) from product subscriptions (off-store)
Routes service subscriptions to subscriptionService.handleSubscriptionEvent
Routes product subscriptions to invoicePaidHandler
Added logging for webhook event routing
5. EverGreen-invoice-controller.js (src/routes/EvergreenInvoice/EverGreen-invoice-controller.js)
Implemented full installment creation logic in addInstallmentAndPayWithSubscriptionOffline
Added validation for invoice ID, amount, and payment method
Calculates remaining balance and updates invoice status
Creates installment before delegating to subscription service
Returns invoice and installment ID in response
6. subscripiton.service.js (src/services/subscripiton.service.js)
Major addition: automatic job creation (autojobs) for subscription invoices
Added handleInvoicePaidEvent as a public export
Enhanced handleOnStoreInvoicePaid:
Checks if autojobs should be created before updating invoice
Creates jobs based on visitsPerCycle from subscription plan variant
Job scheduling logic:
First job: 5 days after payment date
Remaining jobs: 1st of each subsequent month
Marks jobs with subscriptionMeta: { enabled: true }
Prevents duplicate job creation using jobCreated flag
Added autojob creation in checkout completion handler
Added fallback autojob creation for new invoices
Enhanced idempotency checks to allow autojob creation even if payment was already processed
Added skipPaymentUpdate parameter to handleOnStoreInvoicePaid for retry scenarios
Added logging throughout the autojob creation process
Imported createJobNewForInvoice and getUserModel for job creation
Key Features Added:
Automatic job creation: creates jobs automatically when subscription invoices are paid
Smart scheduling: first job 5 days after payment, subsequent jobs on the 1st of each month
Idempotency: prevents duplicate jobs while allowing retry for missed autojobs
Fallback mechanisms: multiple paths to ensure autojobs are created even if webhooks fail
Enhanced logging: detailed console logs for debugging subscription and autojob flows