feat(sub): handling upgrade/downgrade
rw integration and /me endpoints are left
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from repositories.addons import AddonsRepository
|
||||
from repositories.pricing import PricingRepository
|
||||
from schemas.plans import AddonData, OrderDetails, PricingPlans
|
||||
from services.subscriptions import calculate_order_total
|
||||
|
||||
|
||||
async def get_pricing_model(addons_repo: AddonsRepository, pricing_repo: PricingRepository):
|
||||
@@ -21,4 +22,9 @@ async def calculate_price(
|
||||
*, addons_repo: AddonsRepository, order: OrderDetails, pricing: PricingPlans
|
||||
) -> float:
|
||||
addons = [await addons_repo.get_by_id(a) for a in order.addons]
|
||||
return order.devices * pricing.device_price + sum([a.price for a in addons])
|
||||
return calculate_order_total(
|
||||
pricing,
|
||||
order.devices,
|
||||
[addon.id for addon in addons],
|
||||
order.duration_days,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user