diff --git a/services/deal.py b/services/deal.py index eb5d144..067e418 100644 --- a/services/deal.py +++ b/services/deal.py @@ -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]] = [] diff --git a/templates/documents/deal.html b/templates/documents/deal.html index d730de4..651dabd 100644 --- a/templates/documents/deal.html +++ b/templates/documents/deal.html @@ -168,7 +168,7 @@
- Итого: {{ product_services_totals[loop.index0] }} Р + Итого: {{ product_services_totals[loop.index0].total }} Р, за единицу: {{ product_services_totals[loop.index0].total_one_product }} Р
{% else %}