Files
brewman/brewman/brewman/schemas/net_transactions.py
T
tanshu 350edf7126 Removed timezone information from columns. Time will be stored in UTC coordinates.
Moved to Sqlalchemy 1.4 model and SessionFuture.

Upgraded to Angular 12

Upgraded the python dependencies
2021-09-07 12:59:18 +05:30

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()