Merge pull request 'fixed-issue(15): added currency fallback matching and remove customer fee' (#13) from currency-conversion into main
Reviewed-on: https://10.10.0.4/AcuPedia/acupedia-api/pulls/13 Reviewed-by: Amit Salunke <amit@noreply.localhost>
This commit is contained in:
commit
fb58889698
|
|
@ -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]:
|
||||
|
|
|
|||
|
|
@ -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],
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue