From 689eacf227bc182d84dcdeaeec9067016ea16fb6 Mon Sep 17 00:00:00 2001 From: admin Date: Wed, 11 Sep 2024 23:11:34 +0300 Subject: [PATCH] feat: oleg gone away --- services/billing.py | 11 ++++---- templates/documents/bill-of-payment.html | 32 ++++++++++++++++++++---- utils/list_utils.py | 2 ++ 3 files changed, 35 insertions(+), 10 deletions(-) diff --git a/services/billing.py b/services/billing.py index 98c772c..53f51f8 100644 --- a/services/billing.py +++ b/services/billing.py @@ -18,6 +18,7 @@ from models import DealBillRequest, Deal, DealProduct, DealService as DealServic from schemas.billing import * from services.base import BaseService from services.deal import DealService +from utils.list_utils import to_locale_number env = Environment(loader=FileSystemLoader(Path("templates") / Path("documents"))) @@ -148,16 +149,16 @@ class BillingService(BaseService): services.append( CreateBillingRequestValue( name=f'[{product.product.name}] - {service.service.name}', - price=service.price, - amount=product.quantity + price=to_locale_number(service.price), + amount=to_locale_number(product.quantity) ) ) for service in deal.services: services.append( CreateBillingRequestValue( name=f'{service.service.name}', - price=service.price, - amount=service.quantity + price=to_locale_number(service.price), + amount=to_locale_number(service.quantity) ) ) @@ -180,6 +181,7 @@ class BillingService(BaseService): deal_price = sum((service.price * service.amount for service in services)) deal_price_words = get_string_by_number(deal_price)[0:-10] + deal_price = to_locale_number(deal_price) template = env.get_template("bill-of-payment.html") now = datetime.datetime.now() @@ -194,7 +196,6 @@ class BillingService(BaseService): async def create_billing_document_pdf(self, deal_id) -> BytesIO: doc = await self._create_billing_document_html(deal_id) - pdf_file = BytesIO() HTML(string=doc).write_pdf(pdf_file) diff --git a/templates/documents/bill-of-payment.html b/templates/documents/bill-of-payment.html index 02d0f4c..afdf494 100644 --- a/templates/documents/bill-of-payment.html +++ b/templates/documents/bill-of-payment.html @@ -35,10 +35,12 @@ margin-top: 8px; display: flex; justify-content: space-between; + /*flex-direction: column;*/ /*text-align: right;*/ } .footer-block { + justify-content: space-between; } @@ -105,6 +107,22 @@ border-top: 2px solid black; } + .footer-right { + text-align: right; + } + + .footer-line-right { + align-self: flex-end; + font-size: medium; + font-weight: bolder; + margin: 2px 0; + } + + .footer-words { + flex-direction: column-reverse; + display: flex; + justify-content: flex-end; + } @@ -146,9 +164,9 @@ {% for service in services %} {{ service.name }} - {{ service.amount }} - {{ service.price }} - {{ service.price * service.amount }} + {{ service.amount }} шт. + {{ service.price }} ₽ + {{ '{:,}'.format(service.price * service.amount).replace(',', ' ') }} ₽ {% endfor %} @@ -160,10 +178,14 @@ + diff --git a/utils/list_utils.py b/utils/list_utils.py index c859f56..4085582 100644 --- a/utils/list_utils.py +++ b/utils/list_utils.py @@ -7,3 +7,5 @@ def compile_query_to_plain_sql(query) -> str: return query.compile(compile_kwargs={ 'literal_binds': True }) +def to_locale_number(value): + return '{:,}'.format(value).replace(',', ' ') \ No newline at end of file