From 53289ef55a84cef006fc226872a35ca8ad2a30b3 Mon Sep 17 00:00:00 2001 From: AbleKSaju <126228406+AbleKSaju@users.noreply.github.com> Date: Mon, 23 Sep 2024 10:15:52 +0530 Subject: [PATCH] fix: allow flexible min/max amount for coupon codes when pricing rule limits are zero --- models/baseModels/CouponCode/CouponCode.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/models/baseModels/CouponCode/CouponCode.ts b/models/baseModels/CouponCode/CouponCode.ts index 8b4c915b..71779263 100644 --- a/models/baseModels/CouponCode/CouponCode.ts +++ b/models/baseModels/CouponCode/CouponCode.ts @@ -63,6 +63,14 @@ export class CouponCode extends Doc { } const [pricingRuleData] = await this.pricingRuleData(); + + if ( + (pricingRuleData?.minAmount as Money).isZero() && + (pricingRuleData.maxAmount as Money).isZero() + ) { + return; + } + const { minAmount } = pricingRuleData; if ((value as Money).isZero() && this.maxAmount.isZero()) { @@ -87,6 +95,14 @@ export class CouponCode extends Doc { } const [pricingRuleData] = await this.pricingRuleData(); + + if ( + (pricingRuleData?.minAmount as Money).isZero() && + (pricingRuleData.maxAmount as Money).isZero() + ) { + return; + } + const { maxAmount } = pricingRuleData; if (this.minAmount.isZero() && (value as Money).isZero()) {