Moved to Sqlalchemy 1.4 model and SessionFuture. Upgraded to Angular 12 Upgraded the python dependencies
44 lines
1.1 KiB
Python
44 lines
1.1 KiB
Python
from datetime import date, datetime
|
|
from decimal import Decimal
|
|
from typing import List, Optional
|
|
|
|
from pydantic import validator
|
|
from pydantic.main import BaseModel
|
|
|
|
from . import to_camel
|
|
|
|
|
|
class NetTransactionsItem(BaseModel):
|
|
type_: str
|
|
name: str
|
|
debit: Optional[Decimal]
|
|
credit: Optional[Decimal]
|
|
|
|
class Config:
|
|
anystr_strip_whitespace = True
|
|
alias_generator = to_camel
|
|
json_encoders = {date: lambda v: v.strftime("%d-%b-%Y")}
|
|
|
|
|
|
class NetTransactions(BaseModel):
|
|
start_date: date
|
|
finish_date: date
|
|
body: List[NetTransactionsItem]
|
|
|
|
class Config:
|
|
anystr_strip_whitespace = True
|
|
alias_generator = to_camel
|
|
json_encoders = {date: lambda v: v.strftime("%d-%b-%Y")}
|
|
|
|
@validator("start_date", pre=True)
|
|
def parse_start_date(cls, value):
|
|
if isinstance(value, date):
|
|
return value
|
|
return datetime.strptime(value, "%d-%b-%Y").date()
|
|
|
|
@validator("finish_date", pre=True)
|
|
def parse_finish_date(cls, value):
|
|
if isinstance(value, date):
|
|
return value
|
|
return datetime.strptime(value, "%d-%b-%Y").date()
|