From 78d143fa8546e4451a6403fc8b0b26bccf3b0fbf Mon Sep 17 00:00:00 2001 From: Mahyargdz Date: Sun, 11 May 2025 10:11:15 +0330 Subject: [PATCH] feat: round the price --- src/modules/discounts/providers/discounts.service.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/modules/discounts/providers/discounts.service.ts b/src/modules/discounts/providers/discounts.service.ts index 26e9382..c5cafdb 100755 --- a/src/modules/discounts/providers/discounts.service.ts +++ b/src/modules/discounts/providers/discounts.service.ts @@ -292,7 +292,8 @@ export class DiscountsService { } else { discountAmount = new Decimal(discount.value); } - subscriptionPlan.price = new Decimal(subscriptionPlan.originalPrice).sub(discountAmount); + // Round the final price to the nearest number + subscriptionPlan.price = new Decimal(subscriptionPlan.originalPrice).sub(discountAmount).round(); } // Update the discount and set subscription plans in one operation @@ -353,7 +354,8 @@ export class DiscountsService { } else { discountAmount = new Decimal(discount.value); } - subscriptionPlan.price = new Decimal(subscriptionPlan.originalPrice).sub(discountAmount); + // Round the final price to the nearest number + subscriptionPlan.price = new Decimal(subscriptionPlan.originalPrice).sub(discountAmount).round(); } console.log(`Setting ${subscriptionPlans.length} subscription plans on discount ${discount.id}`);