From cbe3697f1b6ef2084ebcd9c507cc2f2d65130d34 Mon Sep 17 00:00:00 2001 From: AlexSserb Date: Tue, 29 Oct 2024 02:45:23 +0400 Subject: [PATCH] fix: removed all prices from deal document --- generators/deal_pdf_generator/generator.py | 14 -------------- static/css/deal.css | 6 ++++++ .../documents/deal/deal-product-services.html | 10 +++------- templates/documents/deal/deal-services.html | 10 ++-------- 4 files changed, 11 insertions(+), 29 deletions(-) diff --git a/generators/deal_pdf_generator/generator.py b/generators/deal_pdf_generator/generator.py index 518493f..7936af2 100644 --- a/generators/deal_pdf_generator/generator.py +++ b/generators/deal_pdf_generator/generator.py @@ -16,17 +16,6 @@ class DealPdfGenerator: def __init__(self, session: AsyncSession): self._session = session - @staticmethod - async def _get_product_services_totals(deal: Deal) -> List[Dict[str, int]]: - totals: List[Dict[str, int]] = [] - - for product in deal.products: - 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 - @staticmethod async def _group_deal_products_by_products(deal_products: List[DealProduct]) -> Dict[str, DocumentDealProductData]: products: Dict[str, DocumentDealProductData] = {} @@ -39,10 +28,8 @@ class DealPdfGenerator: ) if key not in products: - total_one_product = sum(service.price for service in deal_product.services) products[key] = { "deal_products": [deal_product], - "total_one_product": total_one_product, "quantity": deal_product.quantity, "additional_info": deal_product.product.additional_info, } @@ -83,7 +70,6 @@ class DealPdfGenerator: document_deal_data = { "deal": deal, - "general_services_total": sum((service.price * service.quantity for service in deal.services)), "products": products, "current_status_str": DEAL_STATUS_STR[deal.current_status], "last_status": max(deal.status_history, key=lambda status: status.changed_at), diff --git a/static/css/deal.css b/static/css/deal.css index 78c114d..da001ff 100644 --- a/static/css/deal.css +++ b/static/css/deal.css @@ -63,6 +63,11 @@ hr { font-weight: bold; } +.product-header-container { + page-break-inside: avoid; + page-break-after: avoid; +} + .product-data { height: 130px; display: flex; @@ -81,6 +86,7 @@ table { border-spacing: 0; border: solid gray 2px; border-radius: 15px; + margin-bottom: 15px; } thead { diff --git a/templates/documents/deal/deal-product-services.html b/templates/documents/deal/deal-product-services.html index 113cabb..df17bf2 100644 --- a/templates/documents/deal/deal-product-services.html +++ b/templates/documents/deal/deal-product-services.html @@ -1,7 +1,7 @@ {% with common_deal_product=product_data.deal_products[0], common_product=product_data.deal_products[0].product %}
-
+

@@ -85,7 +85,6 @@ Наименование услуги - Сумма @@ -94,15 +93,10 @@ {% for service in common_deal_product.services %} {{ service.service.name }} - {{ format_number(service.price * product_data.quantity) }} Р {% endfor %} -
- Итого: {{ product_data.total_one_product * product_data.quantity }} Р, за - единицу: {{ product_data.total_one_product }} Р -
{% else %}
{% endif %} @@ -154,6 +148,8 @@
+ {% else %} +
{% endif %}
diff --git a/templates/documents/deal/deal-services.html b/templates/documents/deal/deal-services.html index d0e83ca..dd33151 100644 --- a/templates/documents/deal/deal-services.html +++ b/templates/documents/deal/deal-services.html @@ -32,12 +32,11 @@
Склад отгрузки: {{ data.deal.shipping_warehouse.name }}
{% endif %} {% if data.deal.services|length > 0 %} - +
- @@ -47,16 +46,11 @@ - {% endfor %}
Общие услуги КоличествоСумма
{{ service.service.name }} {{ '{:,}'.format(service.quantity) }} шт.{{ '{:,}'.format(service.price * service.quantity).replace(',', ' ') }} Р
-
- Итого: {{ data.general_services_total }} Р -
{% else %} -
-
+
{% endif %} \ No newline at end of file