feat(pricing): implement phase 1 - EUR and USD price parity in plan listing and cart repository
This commit is contained in:
parent
cd10f8548d
commit
fb8a52de56
|
|
@ -46,8 +46,8 @@ class CartRepository:
|
|||
if len(parts) == 2 and parts[1] in known_currencies:
|
||||
base = parts[0]
|
||||
|
||||
for cand in [f"{base}_{curr}", code, base]:
|
||||
if cand not in cands:
|
||||
for cand in [f"{base}_{curr}", f"{base}_USD" if curr == "EUR" else None, code, base]:
|
||||
if cand and cand not in cands:
|
||||
cands.append(cand)
|
||||
code_candidates_map[code] = cands
|
||||
candidates.update(cands)
|
||||
|
|
@ -81,12 +81,15 @@ class CartRepository:
|
|||
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":
|
||||
if plan_curr == "INR" and curr in {"USD", "EUR"}:
|
||||
matches[code] = (plan, max(Decimal("1.00"), (Decimal(str(fee)) / Decimal("80")).quantize(Decimal("1.00"))))
|
||||
break
|
||||
elif plan_curr == "USD" and curr == "INR":
|
||||
elif plan_curr in {"USD", "EUR"} and curr == "INR":
|
||||
matches[code] = (plan, (Decimal(str(fee)) * Decimal("80")).quantize(Decimal("1.00")))
|
||||
break
|
||||
elif plan_curr in {"USD", "EUR"} and curr in {"USD", "EUR"}:
|
||||
matches[code] = (plan, Decimal(str(fee)))
|
||||
break
|
||||
elif fee is not None:
|
||||
matches[code] = (plan, Decimal(str(fee)))
|
||||
break
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ async def get_public_plans(session: AsyncSession = Depends(get_db_session)) -> l
|
|||
"billing_period": getattr(p.billing_period, "value", p.billing_period),
|
||||
"price_inr": 0.0,
|
||||
"price_usd": 0.0,
|
||||
"price_eur": 0.0,
|
||||
"is_active": p.is_active,
|
||||
"badge_text": meta.get("badge_text"),
|
||||
"heading": meta.get("heading"),
|
||||
|
|
@ -63,6 +64,7 @@ async def get_public_plans(session: AsyncSession = Depends(get_db_session)) -> l
|
|||
grp = groups[base_code]
|
||||
if is_usd:
|
||||
grp["price_usd"] = fee
|
||||
grp["price_eur"] = fee # EUR equals USD for now
|
||||
else:
|
||||
grp["price_inr"] = fee
|
||||
grp["name"] = p.name
|
||||
|
|
|
|||
Loading…
Reference in New Issue