feat: price of services over one product in deal document

This commit is contained in:
2024-09-24 21:55:22 +04:00
parent 0e54b0edd3
commit 5df64d4916
2 changed files with 8 additions and 6 deletions

View File

@@ -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]] = []