feat(orders): integrate Pally payment and order management
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
from repositories.addons import AddonsRepository
|
||||
from repositories.pricing import PricingRepository
|
||||
from schemas.plans import AddonData, PricingPlans
|
||||
from schemas.plans import AddonData, OrderDetails, PricingPlans
|
||||
|
||||
|
||||
async def get_pricing_model(addons_repo: AddonsRepository, pricing_repo: PricingRepository):
|
||||
@@ -15,3 +15,10 @@ async def get_pricing_model(addons_repo: AddonsRepository, pricing_repo: Pricing
|
||||
]
|
||||
|
||||
return PricingPlans(device_price=pricing.device_price, addons=addons_data)
|
||||
|
||||
|
||||
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])
|
||||
|
||||
Reference in New Issue
Block a user