fixed-issue(15): added currency fallback matching and remove customer fee
This commit is contained in:
parent
29279bfd72
commit
3f25a9e1be
|
|
@ -74,6 +74,23 @@ class CartRepository:
|
||||||
matches[code] = (plan, Decimal(str(fee)))
|
matches[code] = (plan, Decimal(str(fee)))
|
||||||
break
|
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
|
return matches
|
||||||
|
|
||||||
async def get_items(self, codes: list[str], currency: str) -> list[PricingItem]:
|
async def get_items(self, codes: list[str], currency: str) -> list[PricingItem]:
|
||||||
|
|
|
||||||
|
|
@ -63,10 +63,7 @@ class PricingEngine:
|
||||||
if coupon.max_discount_limit > 0:
|
if coupon.max_discount_limit > 0:
|
||||||
coupon_discount = min(coupon_discount, coupon.max_discount_limit)
|
coupon_discount = min(coupon_discount, coupon.max_discount_limit)
|
||||||
net = max(Decimal("0"), after_bundle - coupon_discount)
|
net = max(Decimal("0"), after_bundle - coupon_discount)
|
||||||
fee_rate = Decimal("0.02") if curr == "INR" else Decimal("0.03")
|
grand = q(net)
|
||||||
fee = q(net * fee_rate)
|
|
||||||
gst = q(fee * Decimal("0.18")) if curr == "INR" else Decimal("0")
|
|
||||||
grand = q(net + fee + gst)
|
|
||||||
return {
|
return {
|
||||||
"currency": curr,
|
"currency": curr,
|
||||||
"base_subtotal": float(q(base)),
|
"base_subtotal": float(q(base)),
|
||||||
|
|
@ -76,10 +73,10 @@ class PricingEngine:
|
||||||
"coupon_discount_amount": float(q(coupon_discount)),
|
"coupon_discount_amount": float(q(coupon_discount)),
|
||||||
"coupon_error": coupon_error,
|
"coupon_error": coupon_error,
|
||||||
"total_discounts": float(q(bundle + coupon_discount)),
|
"total_discounts": float(q(bundle + coupon_discount)),
|
||||||
"convenience_fee_rate": float(fee_rate * 100),
|
"convenience_fee_rate": 0.0,
|
||||||
"convenience_fee": float(fee),
|
"convenience_fee": 0.0,
|
||||||
"taxable_amount": float(fee),
|
"taxable_amount": 0.0,
|
||||||
"gst_amount": float(gst),
|
"gst_amount": 0.0,
|
||||||
"grand_total": float(grand),
|
"grand_total": float(grand),
|
||||||
"cart_items": [{"code": i.code, "name": i.name, "category": i.category, "price": float(q(i.price))} for i in items],
|
"cart_items": [{"code": i.code, "name": i.name, "category": i.category, "price": float(q(i.price))} for i in items],
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue