Merge remote-tracking branch 'origin/detached'
# Conflicts: # templates/documents/bill-of-payment.html
This commit is contained in:
		@@ -18,6 +18,7 @@ from models import DealBillRequest, Deal, DealProduct, DealService as DealServic
 | 
				
			|||||||
from schemas.billing import *
 | 
					from schemas.billing import *
 | 
				
			||||||
from services.base import BaseService
 | 
					from services.base import BaseService
 | 
				
			||||||
from services.deal import DealService
 | 
					from services.deal import DealService
 | 
				
			||||||
 | 
					from utils.list_utils import to_locale_number
 | 
				
			||||||
 | 
					
 | 
				
			||||||
env = Environment(loader=FileSystemLoader(Path("templates") / Path("documents")))
 | 
					env = Environment(loader=FileSystemLoader(Path("templates") / Path("documents")))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -148,16 +149,16 @@ class BillingService(BaseService):
 | 
				
			|||||||
                services.append(
 | 
					                services.append(
 | 
				
			||||||
                    CreateBillingRequestValue(
 | 
					                    CreateBillingRequestValue(
 | 
				
			||||||
                        name=f'[{product.product.name}] - {service.service.name}',
 | 
					                        name=f'[{product.product.name}] - {service.service.name}',
 | 
				
			||||||
                        price=service.price,
 | 
					                        price=to_locale_number(service.price),
 | 
				
			||||||
                        amount=product.quantity
 | 
					                        amount=to_locale_number(product.quantity)
 | 
				
			||||||
                    )
 | 
					                    )
 | 
				
			||||||
                )
 | 
					                )
 | 
				
			||||||
        for service in deal.services:
 | 
					        for service in deal.services:
 | 
				
			||||||
            services.append(
 | 
					            services.append(
 | 
				
			||||||
                CreateBillingRequestValue(
 | 
					                CreateBillingRequestValue(
 | 
				
			||||||
                    name=f'{service.service.name}',
 | 
					                    name=f'{service.service.name}',
 | 
				
			||||||
                    price=service.price,
 | 
					                    price=to_locale_number(service.price),
 | 
				
			||||||
                    amount=service.quantity
 | 
					                    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 = sum((service.price * service.amount for service in services))
 | 
				
			||||||
        deal_price_words = get_string_by_number(deal_price)[0:-10]
 | 
					        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")
 | 
					        template = env.get_template("bill-of-payment.html")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        now = datetime.datetime.now()
 | 
					        now = datetime.datetime.now()
 | 
				
			||||||
@@ -194,7 +196,6 @@ class BillingService(BaseService):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    async def create_billing_document_pdf(self, deal_id) -> BytesIO:
 | 
					    async def create_billing_document_pdf(self, deal_id) -> BytesIO:
 | 
				
			||||||
        doc = await self._create_billing_document_html(deal_id)
 | 
					        doc = await self._create_billing_document_html(deal_id)
 | 
				
			||||||
 | 
					 | 
				
			||||||
        pdf_file = BytesIO()
 | 
					        pdf_file = BytesIO()
 | 
				
			||||||
        HTML(string=doc).write_pdf(pdf_file)
 | 
					        HTML(string=doc).write_pdf(pdf_file)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -35,17 +35,16 @@
 | 
				
			|||||||
            margin-top: 8px;
 | 
					            margin-top: 8px;
 | 
				
			||||||
            display: flex;
 | 
					            display: flex;
 | 
				
			||||||
            justify-content: space-between;
 | 
					            justify-content: space-between;
 | 
				
			||||||
            text-align: justify;
 | 
					            /*flex-direction: column;*/
 | 
				
			||||||
            /*text-align: right;*/
 | 
					            /*text-align: right;*/
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        .footer-block {
 | 
					        .footer-block {
 | 
				
			||||||
 | 
					            justify-content: space-between;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        .footer-line {
 | 
					        .footer-line {
 | 
				
			||||||
 | 
					 | 
				
			||||||
            text-align: justify;
 | 
					 | 
				
			||||||
            font-size: medium;
 | 
					            font-size: medium;
 | 
				
			||||||
            font-weight: bolder;
 | 
					            font-weight: bolder;
 | 
				
			||||||
            margin: 2px 0;
 | 
					            margin: 2px 0;
 | 
				
			||||||
@@ -109,12 +108,20 @@
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        .footer-right {
 | 
					        .footer-right {
 | 
				
			||||||
            text-align: justify;
 | 
					            text-align: right;
 | 
				
			||||||
            max-width: 200px;
 | 
					 | 
				
			||||||
            text-align-last: justify;
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        .footer-words{
 | 
					
 | 
				
			||||||
            text-align-last: left;
 | 
					        .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;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    </style>
 | 
					    </style>
 | 
				
			||||||
</head>
 | 
					</head>
 | 
				
			||||||
@@ -157,9 +164,9 @@
 | 
				
			|||||||
                {% for service in services %}
 | 
					                {% for service in services %}
 | 
				
			||||||
                <tr>
 | 
					                <tr>
 | 
				
			||||||
                    <td>{{ service.name }}</td>
 | 
					                    <td>{{ service.name }}</td>
 | 
				
			||||||
                    <td>{{ service.amount }}</td>
 | 
					                    <td>{{ service.amount }} шт.</td>
 | 
				
			||||||
                    <td>{{ service.price }}</td>
 | 
					                    <td>{{ service.price }} ₽</td>
 | 
				
			||||||
                    <td>{{ service.price * service.amount }}</td>
 | 
					                    <td>{{ '{:,}'.format(service.price * service.amount).replace(',', ' ') }} ₽</td>
 | 
				
			||||||
                </tr>
 | 
					                </tr>
 | 
				
			||||||
                {% endfor %}
 | 
					                {% endfor %}
 | 
				
			||||||
                </tbody>
 | 
					                </tbody>
 | 
				
			||||||
@@ -171,12 +178,14 @@
 | 
				
			|||||||
                <div class="footer-line">+79777740525 Игорь С. (Т-Банк)</div>
 | 
					                <div class="footer-line">+79777740525 Игорь С. (Т-Банк)</div>
 | 
				
			||||||
            </div>
 | 
					            </div>
 | 
				
			||||||
            <div class="footer-block">
 | 
					            <div class="footer-block">
 | 
				
			||||||
                <div class="footer-line footer-right">
 | 
					                <div class="footer-line-right">Итого к оплате: {{ deal_price }} ₽</div>
 | 
				
			||||||
                    <p>Итого к оплате: {{ deal_price }} Р</p>
 | 
					 | 
				
			||||||
                    <p class="footer-words">{{ deal_price_words }}</p>
 | 
					 | 
				
			||||||
                </div>
 | 
					 | 
				
			||||||
            </div>
 | 
					            </div>
 | 
				
			||||||
        </div>
 | 
					        </div>
 | 
				
			||||||
 | 
					        <div class="footer-words">
 | 
				
			||||||
 | 
					            <div class="footer-line-right">{{ deal_price_words }}</div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        </div>
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
</div>
 | 
					</div>
 | 
				
			||||||
</body>
 | 
					</body>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,3 +7,5 @@ def compile_query_to_plain_sql(query) -> str:
 | 
				
			|||||||
    return query.compile(compile_kwargs={
 | 
					    return query.compile(compile_kwargs={
 | 
				
			||||||
        'literal_binds': True
 | 
					        'literal_binds': True
 | 
				
			||||||
    })
 | 
					    })
 | 
				
			||||||
 | 
					def to_locale_number(value):
 | 
				
			||||||
 | 
					    return  '{:,}'.format(value).replace(',', ' ')
 | 
				
			||||||
		Reference in New Issue
	
	Block a user