fix: replace locale setting with months constant
This commit is contained in:
15
constants.py
15
constants.py
@@ -14,3 +14,18 @@ allowed_telegram_ids = [
|
|||||||
502869937, # Sasha
|
502869937, # Sasha
|
||||||
7326211785
|
7326211785
|
||||||
]
|
]
|
||||||
|
|
||||||
|
MONTHS = (
|
||||||
|
'января',
|
||||||
|
'февраля',
|
||||||
|
'марта',
|
||||||
|
'апреля',
|
||||||
|
'мая',
|
||||||
|
'июня',
|
||||||
|
'июля',
|
||||||
|
'августа',
|
||||||
|
'сентября',
|
||||||
|
'октября',
|
||||||
|
'ноября',
|
||||||
|
'декабря'
|
||||||
|
)
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
import datetime
|
|
||||||
import locale
|
|
||||||
from ast import Bytes
|
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import List
|
from typing import List
|
||||||
@@ -14,6 +11,7 @@ from starlette import status
|
|||||||
from weasyprint import HTML
|
from weasyprint import HTML
|
||||||
|
|
||||||
import backend.config
|
import backend.config
|
||||||
|
from constants import MONTHS
|
||||||
from external.billing import BillingClient, CreateBillingRequestValue, CreateBillRequestSchema, CreateBillRequestItems, \
|
from external.billing import BillingClient, CreateBillingRequestValue, CreateBillRequestSchema, CreateBillRequestItems, \
|
||||||
BillStatusUpdateRequest, NotificationChannel, NotifyReceivedBillRequestSchema, DeleteBillRequestSchema
|
BillStatusUpdateRequest, NotificationChannel, NotifyReceivedBillRequestSchema, DeleteBillRequestSchema
|
||||||
from models import DealBillRequest, Deal, DealProduct, DealService as DealServiceModel
|
from models import DealBillRequest, Deal, DealProduct, DealService as DealServiceModel
|
||||||
@@ -21,8 +19,6 @@ from schemas.billing import *
|
|||||||
from services.base import BaseService
|
from services.base import BaseService
|
||||||
from services.deal import DealService
|
from services.deal import DealService
|
||||||
|
|
||||||
locale.setlocale(locale.LC_TIME, "ru_RU.UTF-8")
|
|
||||||
|
|
||||||
env = Environment(loader=FileSystemLoader(Path("templates") / Path("documents")))
|
env = Environment(loader=FileSystemLoader(Path("templates") / Path("documents")))
|
||||||
|
|
||||||
|
|
||||||
@@ -185,12 +181,15 @@ class BillingService(BaseService):
|
|||||||
deal_price = sum((service.price for service in services))
|
deal_price = sum((service.price 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]
|
||||||
template = env.get_template("bill-of-payment.html")
|
template = env.get_template("bill-of-payment.html")
|
||||||
|
|
||||||
|
now = datetime.datetime.now()
|
||||||
|
curr_date = f"{now.day} {MONTHS[now.month - 1]} {now.year} г."
|
||||||
return template.render({
|
return template.render({
|
||||||
"services": services,
|
"services": services,
|
||||||
"deal_price": deal_price,
|
"deal_price": deal_price,
|
||||||
"deal_price_words": deal_price_words,
|
"deal_price_words": deal_price_words,
|
||||||
"deal": deal,
|
"deal": deal,
|
||||||
"curr_date": datetime.datetime.now().strftime("%d %B %Y г.")
|
"curr_date": curr_date
|
||||||
})
|
})
|
||||||
|
|
||||||
async def create_billing_document_pdf(self, deal_id) -> BytesIO:
|
async def create_billing_document_pdf(self, deal_id) -> BytesIO:
|
||||||
|
|||||||
Reference in New Issue
Block a user