feat: price of services over one product in deal document
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from io import BytesIO
|
||||
from typing import Dict
|
||||
|
||||
import lexorank
|
||||
from fastapi import HTTPException
|
||||
@@ -997,12 +998,13 @@ class DealService(BaseService):
|
||||
# region Deal documents
|
||||
|
||||
@staticmethod
|
||||
async def _get_product_services_totals(deal: Deal) -> List[int]:
|
||||
totals: List[int] = []
|
||||
async def _get_product_services_totals(deal: Deal) -> List[Dict[str, int]]:
|
||||
totals: List[Dict[str, int]] = []
|
||||
|
||||
for product in deal.products:
|
||||
total = sum((service.price * product.quantity for service in product.services))
|
||||
totals.append(total)
|
||||
total_one_product = sum((service.price for service in product.services))
|
||||
total = total_one_product * product.quantity
|
||||
totals.append({ "total_one_product": total_one_product, "total": total })
|
||||
|
||||
return totals
|
||||
|
||||
@@ -1025,7 +1027,7 @@ class DealService(BaseService):
|
||||
|
||||
last_status: DealStatusHistory = max(deal.status_history, key=lambda status: status.changed_at)
|
||||
general_services_total = sum((service.price * service.quantity for service in deal.services))
|
||||
product_services_totals = await self._get_product_services_totals(deal)
|
||||
product_services_totals: List[Dict[str, int]] = await self._get_product_services_totals(deal)
|
||||
template = ENV.get_template("deal.html")
|
||||
|
||||
product_urls: List[Optional[str]] = []
|
||||
|
||||
Reference in New Issue
Block a user