update: change the invoice status
This commit is contained in:
@@ -80,7 +80,7 @@ export class InvoiceProcessor extends WorkerProcessor {
|
||||
throw new Error(`Maximum recurring cycles (${invoice.maxRecurringCycles}) reached for invoice ${invoice.id}`);
|
||||
}
|
||||
|
||||
if (invoice.status === InvoiceStatus.CANCELLED) throw new Error(`Cannot create recurring invoice for cancelled invoice ${invoice.id}`);
|
||||
if (invoice.status === InvoiceStatus.ARCHIVED) throw new Error(`Cannot create recurring invoice for archived invoice ${invoice.id}`);
|
||||
}
|
||||
|
||||
//********************************** */
|
||||
@@ -195,11 +195,11 @@ export class InvoiceProcessor extends WorkerProcessor {
|
||||
//********************************** */
|
||||
|
||||
private async cancelOverdueInvoice(invoice: Invoice, queryRunner: QueryRunner) {
|
||||
invoice.status = InvoiceStatus.CANCELLED;
|
||||
invoice.status = InvoiceStatus.ARCHIVED;
|
||||
await queryRunner.manager.save(Invoice, invoice);
|
||||
if (invoice.items[0]?.subscriptionPlan) {
|
||||
this.logger.log(
|
||||
`Invoice ${invoice.id} has been cancelled as it is more than 10 days overdue. Subscription Plan ${invoice.items[0].subscriptionPlan.id} has been cancelled.`,
|
||||
`Invoice ${invoice.id} has been archived as it is more than 10 days overdue. Subscription Plan ${invoice.items[0].subscriptionPlan.id} has been cancelled.`,
|
||||
);
|
||||
const userSubscription = invoice.items[0].subscriptionPlan;
|
||||
userSubscription.status = SubscriptionStatus.INACTIVE;
|
||||
@@ -215,7 +215,7 @@ export class InvoiceProcessor extends WorkerProcessor {
|
||||
}
|
||||
if (invoice.items[0]?.supportPlan) {
|
||||
this.logger.log(
|
||||
`Invoice ${invoice.id} has been cancelled as it is more than 10 days overdue. Support Plan ${invoice.items[0].supportPlan.id} has been cancelled.`,
|
||||
`Invoice ${invoice.id} has been archived as it is more than 10 days overdue. Support Plan ${invoice.items[0].supportPlan.id} has been cancelled.`,
|
||||
);
|
||||
const userSupportPlan = invoice.items[0].supportPlan;
|
||||
userSupportPlan.status = UserSupportPlanStatus.INACTIVE;
|
||||
@@ -223,7 +223,7 @@ export class InvoiceProcessor extends WorkerProcessor {
|
||||
|
||||
await this.applyFreeSupportPlan(invoice, queryRunner);
|
||||
}
|
||||
this.logger.log(`Invoice ${invoice.id} has been cancelled as it is more than 10 days overdue.`);
|
||||
this.logger.log(`Invoice ${invoice.id} has been archived as it is more than 10 days overdue.`);
|
||||
}
|
||||
//********************************** */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user