From 721968ed2e900e39852c5eb750a9d04f0d43af13 Mon Sep 17 00:00:00 2001 From: mahyargdz Date: Sun, 4 May 2025 10:05:50 +0330 Subject: [PATCH] fix: the delete of discount --- src/modules/discounts/providers/discounts.service.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/modules/discounts/providers/discounts.service.ts b/src/modules/discounts/providers/discounts.service.ts index 558b819..2fa708b 100755 --- a/src/modules/discounts/providers/discounts.service.ts +++ b/src/modules/discounts/providers/discounts.service.ts @@ -190,7 +190,12 @@ export class DiscountsService { await this.removeDiscountDeactivationJob(id); await this.clearDirectDiscountFromPlans(discount, queryRunner); - await queryRunner.manager.softDelete(this.discountRepository.target, discount); + // First remove the relationships + discount.subscriptionPlans = []; + await queryRunner.manager.save(this.discountRepository.target, discount); + + // Then perform the soft delete + await queryRunner.manager.softDelete(this.discountRepository.target, { id: discount.id }); await queryRunner.commitTransaction();