feat: price of services over one product in deal document
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
from typing import Dict
|
||||||
|
|
||||||
import lexorank
|
import lexorank
|
||||||
from fastapi import HTTPException
|
from fastapi import HTTPException
|
||||||
@@ -997,12 +998,13 @@ class DealService(BaseService):
|
|||||||
# region Deal documents
|
# region Deal documents
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
async def _get_product_services_totals(deal: Deal) -> List[int]:
|
async def _get_product_services_totals(deal: Deal) -> List[Dict[str, int]]:
|
||||||
totals: List[int] = []
|
totals: List[Dict[str, int]] = []
|
||||||
|
|
||||||
for product in deal.products:
|
for product in deal.products:
|
||||||
total = sum((service.price * product.quantity for service in product.services))
|
total_one_product = sum((service.price for service in product.services))
|
||||||
totals.append(total)
|
total = total_one_product * product.quantity
|
||||||
|
totals.append({ "total_one_product": total_one_product, "total": total })
|
||||||
|
|
||||||
return totals
|
return totals
|
||||||
|
|
||||||
@@ -1025,7 +1027,7 @@ class DealService(BaseService):
|
|||||||
|
|
||||||
last_status: DealStatusHistory = max(deal.status_history, key=lambda status: status.changed_at)
|
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))
|
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")
|
template = ENV.get_template("deal.html")
|
||||||
|
|
||||||
product_urls: List[Optional[str]] = []
|
product_urls: List[Optional[str]] = []
|
||||||
|
|||||||
@@ -168,7 +168,7 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<div class="medium-text total align-right bold">
|
<div class="medium-text total align-right bold">
|
||||||
Итого: {{ product_services_totals[loop.index0] }} Р
|
Итого: {{ product_services_totals[loop.index0].total }} Р, за единицу: {{ product_services_totals[loop.index0].total_one_product }} Р
|
||||||
</div>
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="medium-text total align-right bold"></div>
|
<div class="medium-text total align-right bold"></div>
|
||||||
|
|||||||
Reference in New Issue
Block a user