fix: the delete of discount

This commit is contained in:
mahyargdz
2025-05-04 10:05:50 +03:30
parent 20cd268938
commit 721968ed2e
@@ -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();