From 3f25a9e1be2fe5ccc4f7b09aa1cecdca2e942726 Mon Sep 17 00:00:00 2001 From: Urvish Date: Tue, 13 Oct 2026 16:00:05 +0530 Subject: [PATCH] fixed-issue(15): added currency fallback matching and remove customer fee --- app/features/cart/repository.py | 17 +++++++++++++++++ app/features/payments/pricing.py | 13 +++++-------- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/app/features/cart/repository.py b/app/features/cart/repository.py index 6573f3b..147eecc 100644 --- a/app/features/cart/repository.py +++ b/app/features/cart/repository.py @@ -74,6 +74,23 @@ class CartRepository: matches[code] = (plan, Decimal(str(fee))) break + if code not in matches: + for cand in cands: + plan = by_code.get(cand) + if not plan: + continue + fee = plan.total_fee if plan.total_fee is not None else plan.module_fee + plan_curr = plan.currency_code.upper() + if plan_curr == "INR" and curr == "USD": + matches[code] = (plan, max(Decimal("1.00"), (Decimal(str(fee)) / Decimal("80")).quantize(Decimal("1.00")))) + break + elif plan_curr == "USD" and curr == "INR": + matches[code] = (plan, (Decimal(str(fee)) * Decimal("80")).quantize(Decimal("1.00"))) + break + elif fee is not None: + matches[code] = (plan, Decimal(str(fee))) + break + return matches async def get_items(self, codes: list[str], currency: str) -> list[PricingItem]: diff --git a/app/features/payments/pricing.py b/app/features/payments/pricing.py index 2afa258..a74cec1 100644 --- a/app/features/payments/pricing.py +++ b/app/features/payments/pricing.py @@ -63,10 +63,7 @@ class PricingEngine: if coupon.max_discount_limit > 0: coupon_discount = min(coupon_discount, coupon.max_discount_limit) net = max(Decimal("0"), after_bundle - coupon_discount) - fee_rate = Decimal("0.02") if curr == "INR" else Decimal("0.03") - fee = q(net * fee_rate) - gst = q(fee * Decimal("0.18")) if curr == "INR" else Decimal("0") - grand = q(net + fee + gst) + grand = q(net) return { "currency": curr, "base_subtotal": float(q(base)), @@ -76,10 +73,10 @@ class PricingEngine: "coupon_discount_amount": float(q(coupon_discount)), "coupon_error": coupon_error, "total_discounts": float(q(bundle + coupon_discount)), - "convenience_fee_rate": float(fee_rate * 100), - "convenience_fee": float(fee), - "taxable_amount": float(fee), - "gst_amount": float(gst), + "convenience_fee_rate": 0.0, + "convenience_fee": 0.0, + "taxable_amount": 0.0, + "gst_amount": 0.0, "grand_total": float(grand), "cart_items": [{"code": i.code, "name": i.name, "category": i.category, "price": float(q(i.price))} for i in items], }