fix: removed all prices from deal document

This commit is contained in:
2024-10-29 02:45:23 +04:00
parent 750913d3a6
commit cbe3697f1b
4 changed files with 11 additions and 29 deletions

View File

@@ -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),

View File

@@ -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 {

View File

@@ -1,7 +1,7 @@
{% with common_deal_product=product_data.deal_products[0], common_product=product_data.deal_products[0].product %}
<div style="page-break-inside: avoid">
<!--#region Product header -->
<div style="page-break-inside: avoid; page-break-after: avoid">
<div class="product-header-container">
<hr/>
<div style="display: flex">
<div class="img-container">
@@ -85,7 +85,6 @@
<thead>
<tr>
<th>Наименование услуги</th>
<th>Сумма</th>
</tr>
<tfoot>
</tfoot>
@@ -94,15 +93,10 @@
{% for service in common_deal_product.services %}
<tr>
<td>{{ service.service.name }}</td>
<td>{{ format_number(service.price * product_data.quantity) }} Р</td>
</tr>
{% endfor %}
</tbody>
</table>
<div class="medium-text total align-right bold">
Итого: {{ product_data.total_one_product * product_data.quantity }} Р, за
единицу: {{ product_data.total_one_product }} Р
</div>
{% else %}
<div class="medium-text total align-right bold"></div>
{% endif %}
@@ -154,6 +148,8 @@
</tbody>
</table>
<div style="height: 30px"></div>
{% else %}
<div style="margin-bottom: 40px"></div>
{% endif %}
<!--#endregion -->
</div>

View File

@@ -32,12 +32,11 @@
<div class="medium-text bold">Склад отгрузки: {{ data.deal.shipping_warehouse.name }}</div>
{% endif %}
{% if data.deal.services|length > 0 %}
<table>
<table style="margin-bottom: 40px">
<thead>
<tr>
<th>Общие услуги</th>
<th>Количество</th>
<th>Сумма</th>
</tr>
<tfoot>
</tfoot>
@@ -47,16 +46,11 @@
<tr>
<td>{{ service.service.name }}</td>
<td>{{ '{:,}'.format(service.quantity) }} шт.</td>
<td>{{ '{:,}'.format(service.price * service.quantity).replace(',', ' ') }} Р</td>
</tr>
{% endfor %}
</tbody>
</table>
<div class="medium-text total align-right bold">
Итого: {{ data.general_services_total }} Р
</div>
{% else %}
<div class="medium-text total align-right bold">
</div>
<div style="margin-bottom: 40px"></div>
{% endif %}
<!--#endregion -->