Fix: Discount not showing and other chores
This commit is contained in:
1 parent
42102d7fef
commit
f8c1e0591b
66 files changed
+312
-297
No files matched your search
@@ -1,5 +1,3 @@
|
||||
import uuid
|
||||
|
||||
from barker.models.reporting_level import ReportingLevel
|
||||
from barker.models.voucher_type import VoucherType
|
||||
from sqlalchemy import Boolean, Enum, Integer, Unicode
|
||||
@@ -13,7 +11,7 @@ from ..db.base_class import reg
|
||||
class SettleOption:
|
||||
__tablename__ = "settle_options"
|
||||
|
||||
id: Mapped[uuid.UUID] = mapped_column("id", Integer, primary_key=True)
|
||||
id: Mapped[int] = mapped_column("id", Integer, primary_key=True)
|
||||
name: Mapped[str] = mapped_column("name", Unicode(255), unique=True, nullable=False)
|
||||
voucher_type: Mapped[VoucherType] = mapped_column("voucher_type", Enum(VoucherType), nullable=False)
|
||||
reporting_level: Mapped[ReportingLevel] = mapped_column("reporting_level", Enum(ReportingLevel), nullable=False)
|
||||
|
||||
@@ -40,7 +40,7 @@ class Voucher:
|
||||
ForeignKey("food_tables.id"),
|
||||
nullable=False,
|
||||
)
|
||||
customer_id: Mapped[uuid.UUID] = mapped_column(
|
||||
customer_id: Mapped[uuid.UUID | None] = mapped_column(
|
||||
"customer_id", UUID(as_uuid=True), ForeignKey("customers.id"), nullable=True
|
||||
)
|
||||
narration: Mapped[str] = mapped_column("narration", Unicode(1000), nullable=True)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import uuid
|
||||
|
||||
from decimal import Decimal
|
||||
from typing import Sequence
|
||||
|
||||
import barker.schemas.customer as schemas
|
||||
@@ -135,16 +136,16 @@ def show_id(
|
||||
|
||||
def customer_info(item: Customer, sale_categories: Sequence[SaleCategory]) -> schemas.Customer:
|
||||
return schemas.Customer(
|
||||
id=item.id,
|
||||
id_=item.id,
|
||||
name=item.name,
|
||||
address=item.address,
|
||||
phone=item.phone,
|
||||
printInBill=item.print_in_bill,
|
||||
print_in_bill=item.print_in_bill,
|
||||
discounts=[
|
||||
schemas.CustomerDiscount(
|
||||
id=sc.id,
|
||||
id_=sc.id,
|
||||
name=sc.name,
|
||||
discount=next((d.discount for d in item.discounts if d.sale_category_id == sc.id), 0),
|
||||
discount=next((d.discount for d in item.discounts if d.sale_category_id == sc.id), Decimal(0)),
|
||||
limit=sc.discount_limit,
|
||||
)
|
||||
for sc in sale_categories
|
||||
@@ -157,12 +158,12 @@ def blank_customer_info(sale_categories: Sequence[SaleCategory]) -> schemas.Cust
|
||||
name="",
|
||||
address="",
|
||||
phone="",
|
||||
printInBill=False,
|
||||
print_in_bill=False,
|
||||
discounts=[
|
||||
schemas.CustomerDiscount(
|
||||
id=sc.id,
|
||||
id_=sc.id,
|
||||
name=sc.name,
|
||||
discount=0,
|
||||
discount=Decimal(0),
|
||||
limit=sc.discount_limit,
|
||||
)
|
||||
for sc in sale_categories
|
||||
|
||||
@@ -44,7 +44,7 @@ def customer_discounts(item: Customer, db: Session) -> list[schemas.DiscountItem
|
||||
|
||||
return [
|
||||
schemas.DiscountItem(
|
||||
id=sc.id,
|
||||
id_=sc.id,
|
||||
name=sc.name,
|
||||
discount=Decimal(0)
|
||||
if not default_discount
|
||||
@@ -61,11 +61,11 @@ def customer_discounts(item: Customer, db: Session) -> list[schemas.DiscountItem
|
||||
def customer_discounts_blank(db: Session) -> list[schemas.DiscountItem]:
|
||||
return [
|
||||
schemas.DiscountItem(
|
||||
id=sc.id,
|
||||
id_=sc.id,
|
||||
name=sc.name,
|
||||
discount=0,
|
||||
limit=sc.discount_limit,
|
||||
customer=0,
|
||||
discount=None,
|
||||
limit=Decimal(sc.discount_limit),
|
||||
customer=Decimal(0),
|
||||
)
|
||||
for sc in db.execute(select(SaleCategory).where(SaleCategory.discount_limit != 0).order_by(SaleCategory.name))
|
||||
.scalars()
|
||||
|
||||
@@ -73,11 +73,11 @@ def show_id(
|
||||
|
||||
def device_info(item: Device) -> schemas.Device:
|
||||
return schemas.Device(
|
||||
id=item.id,
|
||||
id_=item.id,
|
||||
name=item.name,
|
||||
enabled=item.enabled,
|
||||
section={"id": item.section_id, "name": item.section.name},
|
||||
creationDate=item.creation_date,
|
||||
lastUser=item.login_history[0].user.name if len(item.login_history) else "Never",
|
||||
lastDate=item.login_history[0].date if len(item.login_history) else None,
|
||||
section=schemas.SectionLink(id_=item.section_id, name=item.section.name),
|
||||
creation_date=item.creation_date,
|
||||
last_user=item.login_history[0].user.name if len(item.login_history) else "Never",
|
||||
last_date=item.login_history[0].date if len(item.login_history) else None,
|
||||
)
|
||||
@@ -137,16 +137,16 @@ def show_list(
|
||||
with SessionFuture() as db:
|
||||
for i, item in enumerate(db.execute(list_).scalars().all()):
|
||||
gbli = schemas.GuestBookListItem(
|
||||
id=item.id,
|
||||
id_=item.id,
|
||||
serial=i + 1,
|
||||
name=item.customer.name,
|
||||
phone=item.customer.phone,
|
||||
pax=item.pax,
|
||||
date=item.date,
|
||||
date_=item.date,
|
||||
status=None if item.status is None else item.status.status,
|
||||
tableId=None if item.status is None else item.status.food_table.id,
|
||||
voucherId=None if item.status is None else item.status.voucher_id,
|
||||
tableName=None if item.status is None else item.status.food_table.name,
|
||||
table_id=None if item.status is None else item.status.food_table.id,
|
||||
voucher_id=None if item.status is None else item.status.voucher_id,
|
||||
table_name=None if item.status is None else item.status.food_table.name,
|
||||
)
|
||||
if item.status is None:
|
||||
last = (
|
||||
@@ -164,7 +164,7 @@ def show_list(
|
||||
gbli.voucher_id = last.id
|
||||
gbli.table_name = last.food_table.name
|
||||
guest_book.insert(0, gbli)
|
||||
return schemas.GuestBookList(date=d, list=guest_book)
|
||||
return schemas.GuestBookList(date_=d, list=guest_book)
|
||||
|
||||
|
||||
@router.get("/{id_}", response_model=schemas.GuestBook)
|
||||
@@ -179,12 +179,12 @@ def show_id(
|
||||
|
||||
def guest_book_info(item: GuestBook) -> schemas.GuestBook:
|
||||
return schemas.GuestBook(
|
||||
id=item.id,
|
||||
id_=item.id,
|
||||
name=item.customer.name,
|
||||
phone=item.customer.phone,
|
||||
pax=item.pax,
|
||||
address=item.customer.address,
|
||||
date=item.date + timedelta(minutes=settings.TIMEZONE_OFFSET_MINUTES),
|
||||
date_=item.date + timedelta(minutes=settings.TIMEZONE_OFFSET_MINUTES),
|
||||
)
|
||||
|
||||
|
||||
@@ -194,5 +194,5 @@ def blank_guest_book_info() -> schemas.GuestBookIn:
|
||||
phone="",
|
||||
pax=0,
|
||||
address="",
|
||||
date=datetime.utcnow() + timedelta(minutes=settings.TIMEZONE_OFFSET_MINUTES),
|
||||
date_=datetime.utcnow() + timedelta(minutes=settings.TIMEZONE_OFFSET_MINUTES),
|
||||
)
|
||||
@@ -155,18 +155,17 @@ def show_id(
|
||||
|
||||
def menu_category_info(item: MenuCategory) -> schemas.MenuCategory:
|
||||
return schemas.MenuCategory(
|
||||
id=item.id,
|
||||
id_=item.id,
|
||||
name=item.name,
|
||||
isActive=item.is_active,
|
||||
isFixture=item.is_fixture,
|
||||
sortOrder=item.sort_order,
|
||||
is_active=item.is_active,
|
||||
is_fixture=item.is_fixture,
|
||||
sort_order=item.sort_order,
|
||||
)
|
||||
|
||||
|
||||
def menu_category_blank() -> schemas.MenuCategoryBlank:
|
||||
return schemas.MenuCategoryBlank(
|
||||
name="",
|
||||
isActive=True,
|
||||
isFixture=False,
|
||||
sortOrder=0,
|
||||
is_active=True,
|
||||
is_fixture=False,
|
||||
)
|
||||
@@ -1,5 +1,7 @@
|
||||
import uuid
|
||||
|
||||
from decimal import Decimal
|
||||
|
||||
import barker.schemas.modifier as schemas
|
||||
|
||||
from fastapi import APIRouter, Depends, HTTPException, Security, status
|
||||
@@ -105,13 +107,13 @@ def show_id(
|
||||
|
||||
def modifier_info(item: Modifier) -> schemas.Modifier:
|
||||
return schemas.Modifier(
|
||||
id=item.id,
|
||||
id_=item.id,
|
||||
name=item.name,
|
||||
showInBill=item.show_in_bill,
|
||||
show_in_bill=item.show_in_bill,
|
||||
price=item.price,
|
||||
isActive=item.is_active,
|
||||
modifierCategory=schemas.ModifierCategoryLink(
|
||||
id=item.modifier_category.id,
|
||||
is_active=item.is_active,
|
||||
modifier_category=schemas.ModifierCategoryLink(
|
||||
id_=item.modifier_category.id,
|
||||
name=item.modifier_category.name,
|
||||
),
|
||||
)
|
||||
@@ -120,7 +122,7 @@ def modifier_info(item: Modifier) -> schemas.Modifier:
|
||||
def modifier_blank() -> schemas.ModifierBlank:
|
||||
return schemas.ModifierBlank(
|
||||
name="",
|
||||
showInBill=False,
|
||||
price=0,
|
||||
isActive=True,
|
||||
show_in_bill=False,
|
||||
price=Decimal(0),
|
||||
is_active=True,
|
||||
)
|
||||
@@ -224,19 +224,19 @@ def modifier_category_info(item: ModifierCategory, date_: date, db: Session) ->
|
||||
)
|
||||
products = [p.id for p in item.products]
|
||||
return schemas.ModifierCategory(
|
||||
id=item.id,
|
||||
id_=item.id,
|
||||
name=item.name,
|
||||
minimum=item.minimum,
|
||||
maximum=item.maximum,
|
||||
isActive=item.is_active,
|
||||
menuCategories=[
|
||||
is_active=item.is_active,
|
||||
menu_categories=[
|
||||
schemas.MenuCategoryLink(
|
||||
id=mc.id,
|
||||
id_=mc.id,
|
||||
name=mc.name,
|
||||
enabled=False,
|
||||
products=[
|
||||
ProductLinkSchema(
|
||||
id=p.product_id,
|
||||
id_=p.product_id,
|
||||
name=p.name,
|
||||
enabled=True if p.product_id in products else False,
|
||||
)
|
||||
@@ -245,7 +245,7 @@ def modifier_category_info(item: ModifierCategory, date_: date, db: Session) ->
|
||||
)
|
||||
for mc in menu_categories
|
||||
],
|
||||
sortOrder=item.sort_order,
|
||||
sort_order=item.sort_order,
|
||||
)
|
||||
|
||||
|
||||
@@ -279,13 +279,13 @@ def modifier_category_blank(date_: date, db: Session) -> schemas.ModifierCategor
|
||||
name="",
|
||||
minimum=0,
|
||||
maximum=0,
|
||||
isActive=True,
|
||||
menuCategories=[
|
||||
is_active=True,
|
||||
menu_categories=[
|
||||
schemas.MenuCategoryLink(
|
||||
id=mc.id,
|
||||
id_=mc.id,
|
||||
name=mc.name,
|
||||
enabled=False,
|
||||
products=[ProductLinkSchema(id=p.product_id, name=p.name, enabled=False) for p in mc.products],
|
||||
products=[ProductLinkSchema(id_=p.product_id, name=p.name, enabled=False) for p in mc.products],
|
||||
)
|
||||
for mc in menu_categories
|
||||
],
|
||||
|
||||
@@ -101,12 +101,12 @@ def show_id(
|
||||
|
||||
def printer_info(item: Printer) -> schemas.Printer:
|
||||
return schemas.Printer(
|
||||
id=item.id,
|
||||
id_=item.id,
|
||||
name=item.name,
|
||||
address=item.address,
|
||||
cutCode=bytes(item.cut_code, "ascii").hex(),
|
||||
cut_code=bytes(item.cut_code, "ascii").hex(),
|
||||
)
|
||||
|
||||
|
||||
def printer_blank() -> schemas.PrinterBlank:
|
||||
return schemas.PrinterBlank(name="", address="", cutCode="1d564103")
|
||||
return schemas.PrinterBlank(name="", address="", cut_code="1d564103")
|
||||
@@ -1,6 +1,7 @@
|
||||
import uuid
|
||||
|
||||
from datetime import date, timedelta
|
||||
from decimal import Decimal
|
||||
|
||||
import barker.schemas.product as schemas
|
||||
|
||||
@@ -283,12 +284,12 @@ def show_blank(
|
||||
return schemas.ProductBlank(
|
||||
name="",
|
||||
units="",
|
||||
price=0,
|
||||
hasHappyHour=False,
|
||||
isNotAvailable=False,
|
||||
isActive=True,
|
||||
sortOrder=0,
|
||||
quantity=0,
|
||||
price=Decimal(0),
|
||||
has_happy_hour=False,
|
||||
is_not_available=False,
|
||||
is_active=True,
|
||||
sort_order=0,
|
||||
quantity=Decimal(0),
|
||||
)
|
||||
|
||||
|
||||
@@ -485,21 +486,21 @@ def query_product_info(item: ProductVersion, happy_hour: bool):
|
||||
|
||||
def product_info(item: ProductVersion) -> schemas.Product:
|
||||
return schemas.Product(
|
||||
id=item.product_id,
|
||||
versionId=item.id,
|
||||
id_=item.product_id,
|
||||
version_id=item.id,
|
||||
name=item.name,
|
||||
units=item.units,
|
||||
menuCategory=schemas.MenuCategoryLink(id=item.menu_category_id, name=item.menu_category.name, products=[]),
|
||||
saleCategory=schemas.SaleCategoryLink(
|
||||
id=item.sale_category_id,
|
||||
menu_category=schemas.MenuCategoryLink(id_=item.menu_category_id, name=item.menu_category.name, products=[]),
|
||||
sale_category=schemas.SaleCategoryLink(
|
||||
id_=item.sale_category_id,
|
||||
name=item.sale_category.name,
|
||||
),
|
||||
price=item.price,
|
||||
hasHappyHour=item.has_happy_hour,
|
||||
isNotAvailable=item.is_not_available,
|
||||
has_happy_hour=item.has_happy_hour,
|
||||
is_not_available=item.is_not_available,
|
||||
quantity=item.quantity,
|
||||
isActive=True,
|
||||
sortOrder=item.sort_order,
|
||||
validFrom=item.valid_from,
|
||||
validTill=item.valid_till,
|
||||
is_active=True,
|
||||
sort_order=item.sort_order,
|
||||
valid_from=item.valid_from,
|
||||
valid_till=item.valid_till,
|
||||
)
|
||||
@@ -114,13 +114,13 @@ def show_id(
|
||||
|
||||
def regime_info(item: Regime) -> schemas.Regime:
|
||||
return schemas.Regime(
|
||||
id=item.id,
|
||||
id_=item.id,
|
||||
name=item.name,
|
||||
header=item.header,
|
||||
prefix=item.prefix,
|
||||
isFixture=item.is_fixture,
|
||||
is_fixture=item.is_fixture,
|
||||
)
|
||||
|
||||
|
||||
def regime_blank() -> schemas.RegimeBlank:
|
||||
return schemas.RegimeBlank(name="", header="", prefix="", isFixture=False)
|
||||
return schemas.RegimeBlank(name="", header="", prefix="", is_fixture=False)
|
||||
@@ -29,8 +29,8 @@ def bill_details(
|
||||
check_audit_permission(start_date, user.permissions)
|
||||
with SessionFuture() as db:
|
||||
return BillSettlement(
|
||||
startDate=start_date,
|
||||
finishDate=finish_date,
|
||||
start_date=start_date,
|
||||
finish_date=finish_date,
|
||||
amounts=settlements(start_date, finish_date, db) + reprints(start_date, finish_date, db),
|
||||
)
|
||||
|
||||
@@ -66,8 +66,8 @@ def settlements(s: date, f: date, db: Session) -> list[BillSettlementItem]:
|
||||
details = so.settle_option.name
|
||||
report.append(
|
||||
BillSettlementItem(
|
||||
date=item.date,
|
||||
billId=", ".join(f"{x.regime.prefix}-{x.bill_number}" for x in item.bills),
|
||||
date_=item.date,
|
||||
bill_id=", ".join(f"{x.regime.prefix}-{x.bill_number}" for x in item.bills),
|
||||
settlement=details,
|
||||
amount=round(so.amount, 2),
|
||||
)
|
||||
@@ -84,8 +84,8 @@ def reprints(s: date, f: date, db: Session) -> list[BillSettlementItem]:
|
||||
)
|
||||
return [
|
||||
BillSettlementItem(
|
||||
date=item.date,
|
||||
billId=", ".join(f"{x.regime.prefix}-{x.bill_number}" for x in item.voucher.bills),
|
||||
date_=item.date,
|
||||
bill_id=", ".join(f"{x.regime.prefix}-{x.bill_number}" for x in item.voucher.bills),
|
||||
settlement=f"Reprinted by {item.user.name}",
|
||||
amount=round(
|
||||
next(s.amount for s in item.voucher.settlements if s.settled == SettleOption.AMOUNT()) * -1,
|
||||
|
||||
@@ -58,7 +58,7 @@ def get_active_cashiers(start_date: date, finish_date: date, db: Session) -> lis
|
||||
.scalars()
|
||||
.all()
|
||||
)
|
||||
return [UserLink(id=u.id, name=u.name) for u in users]
|
||||
return [UserLink(id_=u.id, name=u.name) for u in users]
|
||||
|
||||
|
||||
@router.get("/{id_}", response_model=CashierReport)
|
||||
@@ -69,7 +69,7 @@ def show_id(
|
||||
user: UserToken = Security(get_user, scopes=["cashier-report"]),
|
||||
) -> CashierReport:
|
||||
check_audit_permission(start_date, user.permissions)
|
||||
user_link = UserLink(id=user.id_, name=user.name)
|
||||
user_link = UserLink(id_=user.id_, name=user.name)
|
||||
with SessionFuture() as db:
|
||||
return get_id(id_, start_date, finish_date, user_link, db)
|
||||
|
||||
@@ -113,15 +113,15 @@ def get_id(id_: uuid.UUID, start_date: date, finish_date: date, user: UserLink,
|
||||
info[so.settle_option.name].append(
|
||||
InfoItem(
|
||||
date=item.date,
|
||||
billId=", ".join(f"{x.regime.prefix}-{x.bill_number}" for x in item.bills),
|
||||
bill_id=", ".join(f"{x.regime.prefix}-{x.bill_number}" for x in item.bills),
|
||||
customer=item.customer.name if item.customer is not None else "",
|
||||
amount=so.amount,
|
||||
)
|
||||
)
|
||||
return CashierReport(
|
||||
startDate=start_date,
|
||||
finishDate=finish_date,
|
||||
cashier=UserLink(id=id_, name=cashier),
|
||||
start_date=start_date,
|
||||
finish_date=finish_date,
|
||||
cashier=UserLink(id_=id_, name=cashier),
|
||||
cashiers=", ".join(x.name or "" for x in get_active_cashiers(start_date, finish_date, db)),
|
||||
amounts=[NameAmount(name=key, amount=value) for key, value in amounts.items()],
|
||||
info=info,
|
||||
@@ -139,7 +139,7 @@ def print_report(
|
||||
) -> bool:
|
||||
check_audit_permission(start_date, user.permissions)
|
||||
with SessionFuture() as db:
|
||||
report = get_id(id_, start_date, finish_date, UserLink(id=user.id_, name=user.name), db)
|
||||
report = get_id(id_, start_date, finish_date, UserLink(id_=user.id_, name=user.name), db)
|
||||
print_cashier_report(report, device_id, db)
|
||||
return True
|
||||
|
||||
@@ -152,11 +152,11 @@ def show_blank(
|
||||
) -> CashierReport:
|
||||
check_audit_permission(start_date, user.permissions)
|
||||
return CashierReport(
|
||||
startDate=start_date,
|
||||
finishDate=finish_date,
|
||||
cashier=UserLink(id=None),
|
||||
start_date=start_date,
|
||||
finish_date=finish_date,
|
||||
cashier=UserLink(id_=None),
|
||||
cashiers="",
|
||||
amounts=[],
|
||||
info=[],
|
||||
user=UserLink(id=user.id_),
|
||||
info={},
|
||||
user=UserLink(id_=user.id_),
|
||||
)
|
||||
@@ -34,8 +34,8 @@ def discount_report(
|
||||
check_audit_permission(start_date, user.permissions)
|
||||
with SessionFuture() as db:
|
||||
return DiscountReport(
|
||||
startDate=start_date,
|
||||
finishDate=finish_date,
|
||||
start_date=start_date,
|
||||
finish_date=finish_date,
|
||||
amounts=get_discount_report(start_date, finish_date, db),
|
||||
)
|
||||
|
||||
@@ -88,8 +88,8 @@ def print_report(
|
||||
check_audit_permission(start_date, user.permissions)
|
||||
with SessionFuture() as db:
|
||||
report = DiscountReport(
|
||||
startDate=start_date,
|
||||
finishDate=finish_date,
|
||||
start_date=start_date,
|
||||
finish_date=finish_date,
|
||||
amounts=get_discount_report(start_date, finish_date, db),
|
||||
)
|
||||
print_discount_report(report, device_id, db)
|
||||
|
||||
@@ -37,8 +37,8 @@ def menu_engineering_report_view(
|
||||
check_audit_permission(start_date, user.permissions)
|
||||
with SessionFuture() as db:
|
||||
return MeReport(
|
||||
startDate=start_date,
|
||||
finishDate=finish_date,
|
||||
start_date=start_date,
|
||||
finish_date=finish_date,
|
||||
amounts=menu_engineering_report(start_date, finish_date, db),
|
||||
)
|
||||
|
||||
@@ -114,16 +114,16 @@ def menu_engineering_report(s: date, f: date, db: Session):
|
||||
sc_quantity[sc] += quantity
|
||||
info.append(
|
||||
MeItem(
|
||||
id=id_,
|
||||
id_=id_,
|
||||
name=name,
|
||||
price=price,
|
||||
average=round(sales / quantity) if sales and quantity else price,
|
||||
saleCategory=sc,
|
||||
menuCategory=mc,
|
||||
sale_category=sc,
|
||||
menu_category=mc,
|
||||
quantity=quantity or Decimal(0),
|
||||
sales=sales or Decimal(0),
|
||||
quantityPercent=Decimal(0),
|
||||
salesPercent=Decimal(0),
|
||||
quantity_percent=Decimal(0),
|
||||
sales_percent=Decimal(0),
|
||||
)
|
||||
)
|
||||
for item in info:
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import uuid
|
||||
|
||||
from datetime import date, datetime, time, timedelta
|
||||
from decimal import Decimal
|
||||
|
||||
from fastapi import APIRouter, Cookie, Depends, Security
|
||||
from sqlalchemy import func, or_, select
|
||||
@@ -38,16 +39,16 @@ def get_sale_report(
|
||||
check_audit_permission(start_date, user.permissions)
|
||||
with SessionFuture() as db:
|
||||
return SaleReport(
|
||||
startDate=start_date,
|
||||
finishDate=finish_date,
|
||||
start_date=start_date,
|
||||
finish_date=finish_date,
|
||||
amounts=(
|
||||
get_sale(start_date, finish_date, db)
|
||||
+ [SaleReportItem(name="--", amount=0)]
|
||||
+ [SaleReportItem(name="--", amount=Decimal(0))]
|
||||
+ get_settlements(start_date, finish_date, db)
|
||||
+ [SaleReportItem(name="--", amount=0)]
|
||||
+ [SaleReportItem(name="--", amount=Decimal(0))]
|
||||
+ [SaleReportItem(name=i.name, amount=i.amount) for i in get_tax(start_date, finish_date, db)]
|
||||
),
|
||||
user=UserLink(id=user.id_, name=user.name),
|
||||
user=UserLink(id_=user.id_, name=user.name),
|
||||
)
|
||||
|
||||
|
||||
@@ -84,7 +85,7 @@ def get_sale(s: date, f: date, db: Session) -> list[SaleReportItem]:
|
||||
.group_by(SaleCategory.name)
|
||||
.order_by(SaleCategory.name)
|
||||
).all()
|
||||
total = 0
|
||||
total = Decimal(0)
|
||||
info = []
|
||||
for gt, am in list_:
|
||||
total += am
|
||||
@@ -108,7 +109,7 @@ def get_settlements(s: date, f: date, db: Session) -> list[SaleReportItem]:
|
||||
.group_by(SettleOption.name)
|
||||
.order_by(SettleOption.name)
|
||||
).all()
|
||||
total = 0
|
||||
total = Decimal(0)
|
||||
info = []
|
||||
for gt, am in list_:
|
||||
total += am
|
||||
@@ -126,16 +127,16 @@ def print_report(
|
||||
check_audit_permission(start_date, user.permissions)
|
||||
with SessionFuture() as db:
|
||||
report = SaleReport(
|
||||
startDate=start_date,
|
||||
finishDate=finish_date,
|
||||
start_date=start_date,
|
||||
finish_date=finish_date,
|
||||
amounts=(
|
||||
get_sale(start_date, finish_date, db)
|
||||
+ [SaleReportItem(name="--", amount=0)]
|
||||
+ [SaleReportItem(name="--", amount=Decimal(0))]
|
||||
+ get_settlements(start_date, finish_date, db)
|
||||
+ [SaleReportItem(name="--", amount=0)]
|
||||
+ [SaleReportItem(name="--", amount=Decimal(0))]
|
||||
+ [SaleReportItem(name=i.name, amount=i.amount) for i in get_tax(start_date, finish_date, db)]
|
||||
),
|
||||
user=UserLink(id=user.id_, name=user.name),
|
||||
user=UserLink(id_=user.id_, name=user.name),
|
||||
)
|
||||
print_sale_report(report, device_id, db)
|
||||
return True
|
||||
@@ -32,8 +32,8 @@ def get_tax_report(
|
||||
check_audit_permission(start_date, user.permissions)
|
||||
with SessionFuture() as db:
|
||||
return TaxReport(
|
||||
startDate=start_date.strftime("%d-%b-%Y"),
|
||||
finishDate=finish_date.strftime("%d-%b-%Y"),
|
||||
start_date=start_date,
|
||||
finish_date=finish_date,
|
||||
amounts=get_tax(start_date, finish_date, db),
|
||||
)
|
||||
|
||||
@@ -70,7 +70,7 @@ def get_tax(s: date, f: date, db: Session) -> list[TaxReportItem]:
|
||||
def get_tax_item(name: str, rate: Decimal, net: Decimal, amount: Decimal) -> list[TaxReportItem]:
|
||||
items = name.split(";")
|
||||
if len(items) == 1:
|
||||
return [TaxReportItem(name=name, taxRate=rate, saleAmount=net, amount=amount)]
|
||||
return [TaxReportItem(name=name, tax_rate=rate, sale_amount=net, amount=amount)]
|
||||
else:
|
||||
r = []
|
||||
for i, item in enumerate(it.strip() for it in items):
|
||||
@@ -80,5 +80,5 @@ def get_tax_item(name: str, rate: Decimal, net: Decimal, amount: Decimal) -> lis
|
||||
ratio = Decimal(match.group(2)) / Decimal(match.group(3))
|
||||
sub_net = round(net * ratio, 2)
|
||||
sub_amount = round(amount * ratio, 2)
|
||||
r.append(TaxReportItem(name=f"{match.group(1)}", taxRate=rate, saleAmount=sub_net, amount=sub_amount))
|
||||
r.append(TaxReportItem(name=f"{match.group(1)}", tax_rate=rate, sale_amount=sub_net, amount=sub_amount))
|
||||
return r
|
||||
@@ -96,7 +96,7 @@ def show_list(
|
||||
with SessionFuture() as db:
|
||||
return [
|
||||
schemas.RoleList(
|
||||
id=item.id,
|
||||
id_=item.id,
|
||||
name=item.name,
|
||||
permissions=[p.name for p in sorted(item.permissions, key=lambda p: p.name)],
|
||||
)
|
||||
@@ -116,11 +116,11 @@ def show_id(
|
||||
|
||||
def role_info(item: Role, db: Session) -> schemas.Role:
|
||||
return schemas.Role(
|
||||
id=item.id,
|
||||
id_=item.id,
|
||||
name=item.name,
|
||||
permissions=[
|
||||
schemas.PermissionItem(
|
||||
id=p.id,
|
||||
id_=p.id,
|
||||
name=p.name,
|
||||
enabled=True if p in item.permissions else False,
|
||||
)
|
||||
@@ -133,7 +133,7 @@ def role_blank(db: Session) -> schemas.RoleBlank:
|
||||
return schemas.RoleBlank(
|
||||
name="",
|
||||
permissions=[
|
||||
schemas.PermissionItem(id=p.id, name=p.name, enabled=False)
|
||||
schemas.PermissionItem(id_=p.id, name=p.name, enabled=False)
|
||||
for p in db.execute(select(Permission).order_by(Permission.name)).scalars().all()
|
||||
],
|
||||
)
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import uuid
|
||||
|
||||
from decimal import Decimal
|
||||
|
||||
import barker.schemas.sale_category as schemas
|
||||
|
||||
from fastapi import APIRouter, Depends, HTTPException, Security, status
|
||||
@@ -101,12 +103,12 @@ def show_id(
|
||||
|
||||
def sale_category_info(item: SaleCategory) -> schemas.SaleCategory:
|
||||
return schemas.SaleCategory(
|
||||
id=item.id,
|
||||
id_=item.id,
|
||||
name=item.name,
|
||||
discountLimit=item.discount_limit,
|
||||
tax=schemas.TaxLink(id=item.tax_id, name=item.tax.name, rate=item.tax.rate),
|
||||
discount_limit=item.discount_limit,
|
||||
tax=schemas.TaxLink(id_=item.tax_id, name=item.tax.name, rate=item.tax.rate),
|
||||
)
|
||||
|
||||
|
||||
def sale_category_blank() -> schemas.SaleCategoryBlank:
|
||||
return schemas.SaleCategoryBlank(name="", discountLimit=1)
|
||||
return schemas.SaleCategoryBlank(name="", discount_limit=Decimal(1))
|
||||
@@ -110,7 +110,7 @@ def show_id(
|
||||
|
||||
|
||||
def section_info(item: Section) -> schemas.Section:
|
||||
return schemas.Section(id=item.id, name=item.name)
|
||||
return schemas.Section(id_=item.id, name=item.name)
|
||||
|
||||
|
||||
def section_blank() -> schemas.SectionBlank:
|
||||
|
||||
@@ -127,8 +127,8 @@ def report(section_id: uuid.UUID | None, db: Session) -> list[schemas.SectionPri
|
||||
)
|
||||
list_.append(
|
||||
schemas.SectionPrinter(
|
||||
saleCategory=None if sc_id is None else schemas.SaleCategoryLink(id=sc_id, name=sc_name),
|
||||
printer=None if section_printer is None else schemas.PrinterLink(id=section_printer.printer_id),
|
||||
sale_category=None if sc_id is None else schemas.SaleCategoryLink(id_=sc_id, name=sc_name),
|
||||
printer=None if section_printer is None else schemas.PrinterLink(id_=section_printer.printer_id),
|
||||
copies=0 if section_printer is None else section_printer.copies,
|
||||
)
|
||||
)
|
||||
|
||||
@@ -138,16 +138,21 @@ def show_id(
|
||||
|
||||
def settle_option_info(item: SettleOption) -> schemas.SettleOption:
|
||||
return schemas.SettleOption(
|
||||
id=item.id,
|
||||
id_=item.id,
|
||||
name=item.name,
|
||||
voucherType=item.voucher_type,
|
||||
reportingLevel=item.reporting_level,
|
||||
hasReason=item.has_reason,
|
||||
isFixture=item.is_fixture,
|
||||
voucher_type=item.voucher_type,
|
||||
reporting_level=item.reporting_level,
|
||||
has_reason=item.has_reason,
|
||||
is_fixture=item.is_fixture,
|
||||
)
|
||||
|
||||
|
||||
def settle_option_blank() -> schemas.SettleOption:
|
||||
return schemas.SettleOption(
|
||||
id=0, name="", voucherType=VoucherType.KOT, reportingLevel=ReportingLevel.Skip, hasReason=False, isFixture=False
|
||||
id_=0,
|
||||
name="",
|
||||
voucher_type=VoucherType.KOT,
|
||||
reporting_level=ReportingLevel.Skip,
|
||||
has_reason=False,
|
||||
is_fixture=False,
|
||||
)
|
||||
@@ -31,12 +31,12 @@ def sort_order(
|
||||
db.commit()
|
||||
return [
|
||||
schemas.Table(
|
||||
id=item.id,
|
||||
id_=item.id,
|
||||
name=item.name,
|
||||
seats=item.seats,
|
||||
section=schemas.SectionLink(id=item.section_id, name=item.section.name),
|
||||
isActive=item.is_active,
|
||||
sortOrder=item.sort_order,
|
||||
section=schemas.SectionLink(id_=item.section_id, name=item.section.name),
|
||||
is_active=item.is_active,
|
||||
sort_order=item.sort_order,
|
||||
)
|
||||
for item in db.execute(select(FoodTable).order_by(FoodTable.sort_order)).scalars().all()
|
||||
]
|
||||
@@ -186,16 +186,14 @@ def show_id(
|
||||
|
||||
def food_table_info(item: FoodTable) -> schemas.Table:
|
||||
return schemas.Table(
|
||||
id=item.id,
|
||||
id_=item.id,
|
||||
name=item.name,
|
||||
seats=item.seats,
|
||||
section=schemas.SectionLink(id=item.section_id, name=item.section.name),
|
||||
isActive=item.is_active,
|
||||
status="" if item.status is None else item.status.status,
|
||||
sortOrder=item.sort_order,
|
||||
voucherId=None if item.status is None else item.status.voucher_id,
|
||||
section=schemas.SectionLink(id_=item.section_id, name=item.section.name),
|
||||
is_active=item.is_active,
|
||||
sort_order=item.sort_order,
|
||||
)
|
||||
|
||||
|
||||
def food_table_blank() -> schemas.TableBlank:
|
||||
return schemas.TableBlank(name="", seats=0, isActive=True, sortOrder=0)
|
||||
return schemas.TableBlank(name="", seats=0, is_active=True, sort_order=0)
|
||||
@@ -127,16 +127,16 @@ def show_id(
|
||||
|
||||
def tax_info(item: Tax) -> schemas.Tax:
|
||||
return schemas.Tax(
|
||||
id=item.id,
|
||||
id_=item.id,
|
||||
name=item.name,
|
||||
rate=item.rate,
|
||||
regime=schemas.RegimeLink(id=item.regime_id, name=item.regime.name),
|
||||
isFixture=item.is_fixture,
|
||||
regime=schemas.RegimeLink(id_=item.regime_id, name=item.regime.name),
|
||||
is_fixture=item.is_fixture,
|
||||
)
|
||||
|
||||
|
||||
def tax_blank() -> schemas.TaxBlank:
|
||||
return schemas.TaxBlank(name="", rate=0, isFixture=False)
|
||||
return schemas.TaxBlank(name="", rate=Decimal(0), is_fixture=False)
|
||||
|
||||
|
||||
def name_valid(name: str) -> bool:
|
||||
|
||||
@@ -243,21 +243,21 @@ def show_id(
|
||||
|
||||
def product_info(item: ProductVersion) -> schemas.Product:
|
||||
return schemas.Product(
|
||||
id=item.product_id,
|
||||
versionId=item.id,
|
||||
id_=item.product_id,
|
||||
version_id=item.id,
|
||||
name=item.name,
|
||||
units=item.units,
|
||||
menuCategory=schemas.MenuCategoryLink(id=item.menu_category_id, name=item.menu_category.name, products=[]),
|
||||
saleCategory=schemas.SaleCategoryLink(
|
||||
id=item.sale_category_id,
|
||||
menu_category=schemas.MenuCategoryLink(id_=item.menu_category_id, name=item.menu_category.name, products=[]),
|
||||
sale_category=schemas.SaleCategoryLink(
|
||||
id_=item.sale_category_id,
|
||||
name=item.sale_category.name,
|
||||
),
|
||||
price=item.price,
|
||||
hasHappyHour=item.has_happy_hour,
|
||||
isNotAvailable=item.is_not_available,
|
||||
has_happy_hour=item.has_happy_hour,
|
||||
is_not_available=item.is_not_available,
|
||||
quantity=item.quantity,
|
||||
isActive=True,
|
||||
sortOrder=item.sort_order,
|
||||
validFrom=item.valid_from,
|
||||
validTill=item.valid_till,
|
||||
is_active=True,
|
||||
sort_order=item.sort_order,
|
||||
valid_from=item.valid_from,
|
||||
valid_till=item.valid_till,
|
||||
)
|
||||
@@ -26,12 +26,12 @@ def get_update_product_prices(
|
||||
) -> UpdateProductPrices:
|
||||
if date_ is None:
|
||||
return UpdateProductPrices(
|
||||
date=date.today(),
|
||||
date_=date.today(),
|
||||
items=[],
|
||||
)
|
||||
with SessionFuture() as db:
|
||||
return UpdateProductPrices(
|
||||
date=date_,
|
||||
date_=date_,
|
||||
items=update_product_prices_list(None, date_, db),
|
||||
)
|
||||
|
||||
@@ -44,14 +44,14 @@ def get_update_product_prices_id(
|
||||
) -> UpdateProductPrices:
|
||||
if date_ is None:
|
||||
return UpdateProductPrices(
|
||||
date=date.today(),
|
||||
menuCategoryId=id_,
|
||||
date_=date.today(),
|
||||
menu_category_id=id_,
|
||||
items=[],
|
||||
)
|
||||
with SessionFuture() as db:
|
||||
return UpdateProductPrices(
|
||||
date=date_,
|
||||
menuCategoryId=id_,
|
||||
date_=date_,
|
||||
menu_category_id=id_,
|
||||
items=update_product_prices_list(id_, date_, db),
|
||||
)
|
||||
|
||||
@@ -88,7 +88,7 @@ def update_product_prices_list(
|
||||
)
|
||||
|
||||
return [
|
||||
UpdateProductPricesItem(id=item.product_id, name=item.full_name, oldPrice=item.price, newPrice=item.price)
|
||||
UpdateProductPricesItem(id=item.product_id, name=item.full_name, old_price=item.price, new_price=item.price)
|
||||
for item in db.execute(list_).scalars().all()
|
||||
]
|
||||
|
||||
@@ -103,7 +103,7 @@ def save_update_product_prices(
|
||||
update_product(item.id, item.new_price, data.date_, db)
|
||||
db.commit()
|
||||
return UpdateProductPrices(
|
||||
date=data.date_,
|
||||
date_=data.date_,
|
||||
items=update_product_prices_list(None, data.date_, db),
|
||||
)
|
||||
|
||||
@@ -119,8 +119,8 @@ def save_update_product_prices_id(
|
||||
update_product(item.id, item.new_price, data.date_, db)
|
||||
db.commit()
|
||||
return UpdateProductPrices(
|
||||
date=data.date_,
|
||||
menuCategoryId=id_,
|
||||
date_=data.date_,
|
||||
menu_category_id=id_,
|
||||
items=update_product_prices_list(id_, data.date_, db),
|
||||
)
|
||||
|
||||
|
||||
@@ -137,12 +137,12 @@ def show_list(
|
||||
with SessionFuture() as db:
|
||||
return [
|
||||
schemas.UserList(
|
||||
id=item.id,
|
||||
id_=item.id,
|
||||
name=item.name,
|
||||
lockedOut=item.locked_out,
|
||||
locked_out=item.locked_out,
|
||||
roles=[p.name for p in sorted(item.roles, key=lambda p: p.name)],
|
||||
lastDevice=item.login_history[0].device.name if len(item.login_history) else "Never",
|
||||
lastDate=item.login_history[0].date if len(item.login_history) else None,
|
||||
last_device=item.login_history[0].device.name if len(item.login_history) else "Never",
|
||||
last_date=item.login_history[0].date if len(item.login_history) else None,
|
||||
)
|
||||
for item in db.execute(select(User).order_by(User.name)).scalars().all()
|
||||
]
|
||||
@@ -160,13 +160,13 @@ def show_id(
|
||||
|
||||
def user_info(item: User, db: Session, user: UserToken) -> schemas.User:
|
||||
return schemas.User(
|
||||
id=item.id,
|
||||
id_=item.id,
|
||||
name=item.name,
|
||||
password="",
|
||||
lockedOut=item.locked_out,
|
||||
locked_out=item.locked_out,
|
||||
roles=[
|
||||
schemas.RoleItem(
|
||||
id=r.id,
|
||||
id_=r.id,
|
||||
name=r.name,
|
||||
enabled=True if r in item.roles else False,
|
||||
)
|
||||
@@ -179,10 +179,10 @@ def user_info(item: User, db: Session, user: UserToken) -> schemas.User:
|
||||
|
||||
def user_me(item: User) -> schemas.UserMe:
|
||||
return schemas.UserMe(
|
||||
id="me",
|
||||
id_="me",
|
||||
name=item.name,
|
||||
password="",
|
||||
lockedOut=item.locked_out,
|
||||
locked_out=item.locked_out,
|
||||
roles=[],
|
||||
)
|
||||
|
||||
@@ -191,9 +191,9 @@ def blank_user_info(db: Session) -> schemas.UserIn:
|
||||
return schemas.UserIn(
|
||||
name="",
|
||||
password="",
|
||||
lockedOut=False,
|
||||
locked_out=False,
|
||||
roles=[
|
||||
schemas.RoleItem(id=r.id, name=r.name, enabled=False)
|
||||
schemas.RoleItem(id_=r.id, name=r.name, enabled=False)
|
||||
for r in db.execute(select(Role).order_by(Role.name)).scalars().all()
|
||||
],
|
||||
)
|
||||
@@ -93,18 +93,18 @@ def do_update_settlements(voucher: Voucher, others: list[SettleSchema], db: Sess
|
||||
settlements: list[SettleSchema] = []
|
||||
settlements += others
|
||||
total_amount = voucher.amount
|
||||
settlements.append(SettleSchema(id=SettleOption.AMOUNT(), amount=-total_amount))
|
||||
settlements.append(SettleSchema(id_=SettleOption.AMOUNT(), amount=-total_amount))
|
||||
round_off = round(total_amount) - total_amount
|
||||
if round_off != 0:
|
||||
settlements.append(SettleSchema(id=SettleOption.ROUND_OFF(), amount=-round_off))
|
||||
unsettled = sum(x.amount for x in settlements)
|
||||
settlements.append(SettleSchema(id_=SettleOption.ROUND_OFF(), amount=-round_off))
|
||||
unsettled = sum(x.amount for x in settlements) or Decimal(0)
|
||||
if len(others) and unsettled != 0: # This should not be allowed
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
detail="Payment received is not equal to bill amount",
|
||||
)
|
||||
if unsettled != 0:
|
||||
settlements.append(SettleSchema(id=SettleOption.UNSETTLED(), amount=unsettled))
|
||||
settlements.append(SettleSchema(id_=SettleOption.UNSETTLED(), amount=unsettled))
|
||||
fully_settled = False
|
||||
|
||||
for settlement in settlements:
|
||||
|
||||
@@ -31,7 +31,7 @@ def cancel(
|
||||
item.reason = f"{reason}"
|
||||
item.voucher_type = VoucherType.CANCEL
|
||||
do_update_bill_numbers(item, db)
|
||||
do_update_settlements(item, [SettleSchema(id=SettleOption.CANCEL(), amount=round(item.amount))], db)
|
||||
do_update_settlements(item, [SettleSchema(id_=SettleOption.CANCEL(), amount=round(item.amount))], db)
|
||||
|
||||
if u: # Update table
|
||||
db.execute(delete(Overview).where(Overview.voucher_id == item.id))
|
||||
|
||||
@@ -95,7 +95,7 @@ def void_and_issue_new_bill(
|
||||
old.reason = f"Bill Discounted or Changed / Old Bill: {old_bill_id} / New Bill: {new_bill_id}."
|
||||
old.voucher_type = VoucherType.VOID
|
||||
do_update_bill_numbers(old, db)
|
||||
do_update_settlements(old, [SettleSchema(id=SettleOption.VOID(), amount=round(old.amount))], db)
|
||||
do_update_settlements(old, [SettleSchema(id_=SettleOption.VOID(), amount=round(old.amount))], db)
|
||||
|
||||
if update_table:
|
||||
if old.status is None:
|
||||
|
||||
@@ -49,7 +49,7 @@ def split(
|
||||
item.voucher_type = VoucherType.VOID
|
||||
item.reason = "Bill Split"
|
||||
do_update_bill_numbers(item, db)
|
||||
do_update_settlements(item, [SettleSchema(id=SettleOption.VOID(), amount=round(item.amount))], db)
|
||||
do_update_settlements(item, [SettleSchema(id_=SettleOption.VOID(), amount=round(item.amount))], db)
|
||||
if update_table:
|
||||
db.execute(delete(Overview).where(Overview.voucher_id == item.id))
|
||||
check_permissions(None, item.voucher_type, user.permissions)
|
||||
|
||||
@@ -11,7 +11,7 @@ class BillSettlementItem(BaseModel):
|
||||
bill_id: str
|
||||
settlement: str
|
||||
amount: Decimal
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
@field_validator("date_", mode="before")
|
||||
@classmethod
|
||||
@@ -29,7 +29,7 @@ class BillSettlement(BaseModel):
|
||||
start_date: date
|
||||
finish_date: date
|
||||
amounts: list[BillSettlementItem]
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
@field_validator("start_date", mode="before")
|
||||
@classmethod
|
||||
|
||||
@@ -22,7 +22,7 @@ class SettleOptionSchema(BaseModel):
|
||||
|
||||
id_: int
|
||||
name: str
|
||||
model_config = ConfigDict(alias_generator=to_camel, str_strip_whitespace=True)
|
||||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True, str_strip_whitespace=True)
|
||||
|
||||
|
||||
class InfoItem(BaseModel):
|
||||
@@ -30,7 +30,7 @@ class InfoItem(BaseModel):
|
||||
bill_id: str
|
||||
customer: str
|
||||
amount: Decimal
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
@field_validator("date", mode="before")
|
||||
@classmethod
|
||||
@@ -48,7 +48,7 @@ class CashierReport(BaseModel):
|
||||
user: UserLink
|
||||
amounts: list[NameAmount]
|
||||
info: dict[str, list[InfoItem]]
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
@field_validator("start_date", mode="before")
|
||||
@classmethod
|
||||
|
||||
@@ -10,9 +10,9 @@ from . import to_camel
|
||||
class CustomerDiscount(BaseModel):
|
||||
id_: uuid.UUID
|
||||
name: str
|
||||
discount: Decimal = Field(ge=0, multiple_of=0.0001, default=0, le=1)
|
||||
limit: Decimal = Field(ge=0, multiple_of=0.0001, default=0, le=1)
|
||||
model_config = ConfigDict(alias_generator=to_camel)
|
||||
discount: Decimal = Field(ge=0, default=0, le=1)
|
||||
limit: Decimal = Field(ge=0, default=0, le=1)
|
||||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
|
||||
class CustomerIn(BaseModel):
|
||||
@@ -23,20 +23,20 @@ class CustomerIn(BaseModel):
|
||||
print_in_bill: bool
|
||||
|
||||
discounts: list[CustomerDiscount]
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
|
||||
class Customer(CustomerIn):
|
||||
id_: uuid.UUID
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
|
||||
class CustomerLink(BaseModel):
|
||||
id_: uuid.UUID = Field(...)
|
||||
name: str | None = None
|
||||
model_config = ConfigDict(alias_generator=to_camel)
|
||||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
|
||||
class CustomerBlank(CustomerIn):
|
||||
name: str
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||
@@ -12,7 +12,7 @@ class DeviceIn(BaseModel):
|
||||
name: str = Field(..., min_length=1)
|
||||
enabled: bool
|
||||
section: SectionLink
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
|
||||
class Device(DeviceIn):
|
||||
@@ -20,7 +20,7 @@ class Device(DeviceIn):
|
||||
creation_date: datetime
|
||||
last_user: str
|
||||
last_date: datetime | None = None
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
@field_serializer("creation_date")
|
||||
def serialize_creation_date(self, value: datetime, _info):
|
||||
@@ -34,4 +34,4 @@ class Device(DeviceIn):
|
||||
class DeviceLink(BaseModel):
|
||||
id_: uuid.UUID = Field(...)
|
||||
name: str | None = None
|
||||
model_config = ConfigDict(alias_generator=to_camel)
|
||||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
||||
@@ -9,7 +9,7 @@ from pydantic import BaseModel, ConfigDict, Field
|
||||
class DiscountItem(BaseModel):
|
||||
id_: uuid.UUID
|
||||
name: str
|
||||
discount: Decimal | None = Field(ge=0, multiple_of=0.0001, default=0, le=1)
|
||||
discount: Decimal | None = Field(ge=0, default=0, le=1)
|
||||
limit: Decimal
|
||||
customer: Decimal
|
||||
model_config = ConfigDict(alias_generator=to_camel)
|
||||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
||||
@@ -9,14 +9,14 @@ from . import to_camel
|
||||
class DiscountReportItem(BaseModel):
|
||||
name: str
|
||||
amount: Decimal
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
|
||||
class DiscountReport(BaseModel):
|
||||
start_date: date
|
||||
finish_date: date
|
||||
amounts: list[DiscountReportItem]
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
@field_validator("start_date", mode="before")
|
||||
@classmethod
|
||||
|
||||
@@ -14,7 +14,7 @@ class GuestBookIn(BaseModel):
|
||||
pax: int = Field(ge=0)
|
||||
date_: datetime
|
||||
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
@field_validator("date_", mode="before")
|
||||
@classmethod
|
||||
@@ -31,7 +31,7 @@ class GuestBookIn(BaseModel):
|
||||
class GuestBook(GuestBookIn):
|
||||
id_: uuid.UUID
|
||||
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
|
||||
class GuestBookListItem(BaseModel):
|
||||
@@ -46,7 +46,7 @@ class GuestBookListItem(BaseModel):
|
||||
voucher_id: uuid.UUID | None = None
|
||||
table_name: str | None = None
|
||||
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
@field_validator("date_", mode="before")
|
||||
@classmethod
|
||||
@@ -63,7 +63,7 @@ class GuestBookListItem(BaseModel):
|
||||
class GuestBookList(BaseModel):
|
||||
date_: date
|
||||
list: list[GuestBookListItem]
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
@field_validator("date_", mode="before")
|
||||
@classmethod
|
||||
|
||||
@@ -9,4 +9,4 @@ class HeaderFooter(BaseModel):
|
||||
id_: uuid.UUID
|
||||
name: str
|
||||
text: str
|
||||
model_config = ConfigDict(alias_generator=to_camel)
|
||||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
||||
@@ -11,4 +11,4 @@ class LoginHistory(BaseModel):
|
||||
user_id: uuid.UUID
|
||||
client_id: uuid.UUID
|
||||
date: datetime
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||
@@ -12,7 +12,7 @@ class AccountBase(BaseModel):
|
||||
name: str = Field(..., min_length=1)
|
||||
is_starred: bool
|
||||
is_active: bool
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
|
||||
class AccountIn(AccountBase):
|
||||
@@ -29,7 +29,7 @@ class Account(AccountIn):
|
||||
class EmployeeIn(AccountBase):
|
||||
designation: str
|
||||
salary: int = Field(ge=0)
|
||||
points: Decimal = Field(ge=0, lt=1000, multiple_of=0.01)
|
||||
points: Decimal = Field(ge=0, lt=1000)
|
||||
joining_date: date
|
||||
leaving_date: date | None = None
|
||||
|
||||
@@ -50,7 +50,9 @@ class EmployeeIn(AccountBase):
|
||||
def leaving_date_more_than_joining_date(self) -> "EmployeeIn":
|
||||
if self.is_active:
|
||||
self.leaving_date = None
|
||||
elif self.leaving_date < self.joining_date:
|
||||
if (not self.is_active) and (self.leaving_date is None):
|
||||
raise ValueError("Need leaving date for employee")
|
||||
if self.leaving_date < self.joining_date:
|
||||
raise ValueError("Leaving Date cannot be less than Joining Date")
|
||||
return self
|
||||
|
||||
@@ -70,4 +72,4 @@ class DbSetting(BaseModel):
|
||||
class AccountType(BaseModel):
|
||||
id_: int
|
||||
name: str
|
||||
model_config = ConfigDict(alias_generator=to_camel)
|
||||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
||||
@@ -10,22 +10,22 @@ class MenuCategoryIn(BaseModel):
|
||||
name: str = Field(..., min_length=1)
|
||||
is_active: bool
|
||||
is_fixture: bool
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
|
||||
class MenuCategory(MenuCategoryIn):
|
||||
id_: uuid.UUID
|
||||
sort_order: int
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
|
||||
class MenuCategoryBlank(MenuCategoryIn):
|
||||
name: str
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
|
||||
class MenuCategoryLink(BaseModel):
|
||||
id_: uuid.UUID = Field(...)
|
||||
name: str | None = None
|
||||
products: list[ProductLink]
|
||||
model_config = ConfigDict(alias_generator=to_camel)
|
||||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
||||
@@ -19,14 +19,14 @@ class MeItem(BaseModel):
|
||||
sales: Decimal
|
||||
quantity_percent: Decimal
|
||||
sales_percent: Decimal
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
|
||||
class MeReport(BaseModel):
|
||||
start_date: date
|
||||
finish_date: date
|
||||
amounts: list[MeItem]
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
@field_validator("start_date", mode="before")
|
||||
@classmethod
|
||||
|
||||
@@ -10,24 +10,24 @@ class MergeKot(BaseModel):
|
||||
kot_id: uuid.UUID
|
||||
table_id: uuid.UUID
|
||||
new_voucher_id: uuid.UUID
|
||||
model_config = ConfigDict(alias_generator=to_camel)
|
||||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
|
||||
class MoveKot(BaseModel):
|
||||
voucher_id: uuid.UUID
|
||||
kot_id: uuid.UUID
|
||||
table_id: uuid.UUID
|
||||
model_config = ConfigDict(alias_generator=to_camel)
|
||||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
|
||||
class MergeTable(BaseModel):
|
||||
voucher_id: uuid.UUID
|
||||
table_id: uuid.UUID
|
||||
new_voucher_id: uuid.UUID
|
||||
model_config = ConfigDict(alias_generator=to_camel)
|
||||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
|
||||
class MoveTable(BaseModel):
|
||||
voucher_id: uuid.UUID
|
||||
table_id: uuid.UUID
|
||||
model_config = ConfigDict(alias_generator=to_camel)
|
||||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
||||
@@ -11,10 +11,10 @@ from .modifier_category import ModifierCategoryLink
|
||||
class ModifierIn(BaseModel):
|
||||
name: str = Field(..., min_length=1)
|
||||
show_in_bill: bool
|
||||
price: Decimal = Field(ge=0, multiple_of=0.01, default=0)
|
||||
price: Decimal = Field(ge=0, default=0)
|
||||
is_active: bool
|
||||
modifier_category: ModifierCategoryLink
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
|
||||
class Modifier(ModifierIn):
|
||||
@@ -24,7 +24,7 @@ class Modifier(ModifierIn):
|
||||
class ModifierLink(BaseModel):
|
||||
id_: uuid.UUID = Field(...)
|
||||
name: str | None = None
|
||||
model_config = ConfigDict(alias_generator=to_camel)
|
||||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
|
||||
class ModifierBlank(BaseModel):
|
||||
@@ -32,4 +32,4 @@ class ModifierBlank(BaseModel):
|
||||
show_in_bill: bool
|
||||
price: Decimal
|
||||
is_active: bool
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||
@@ -12,21 +12,21 @@ class ModifierCategoryIn(BaseModel):
|
||||
maximum: int | None = Field(ge=0)
|
||||
is_active: bool
|
||||
menu_categories: list[MenuCategoryLink]
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
|
||||
class ModifierCategory(ModifierCategoryIn):
|
||||
id_: uuid.UUID
|
||||
sort_order: int
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
|
||||
class ModifierCategoryBlank(ModifierCategoryIn):
|
||||
name: str
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
|
||||
class ModifierCategoryLink(BaseModel):
|
||||
id_: uuid.UUID = Field(...)
|
||||
name: str | None = None
|
||||
model_config = ConfigDict(alias_generator=to_camel)
|
||||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
||||
@@ -9,4 +9,4 @@ class PermissionItem(BaseModel):
|
||||
id_: uuid.UUID
|
||||
name: str
|
||||
enabled: bool
|
||||
model_config = ConfigDict(alias_generator=to_camel)
|
||||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
||||
@@ -9,20 +9,20 @@ class PrinterIn(BaseModel):
|
||||
name: str = Field(..., min_length=1)
|
||||
address: str = Field(..., min_length=1)
|
||||
cut_code: str
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
|
||||
class Printer(PrinterIn):
|
||||
id_: uuid.UUID
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
|
||||
class PrinterBlank(PrinterIn):
|
||||
name: str
|
||||
address: str
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
|
||||
class PrinterLink(BaseModel):
|
||||
id_: uuid.UUID = Field(...)
|
||||
model_config = ConfigDict(alias_generator=to_camel)
|
||||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
||||
@@ -15,13 +15,13 @@ class ProductIn(BaseModel):
|
||||
units: str
|
||||
menu_category: MenuCategoryLink = Field(...)
|
||||
sale_category: SaleCategoryLink = Field(...)
|
||||
price: Decimal # = Field(ge=0, multiple_of=0.01, default=0)
|
||||
price: Decimal # = Field(ge=0, default=0)
|
||||
has_happy_hour: bool
|
||||
is_not_available: bool
|
||||
quantity: Decimal = Field(ge=0, multiple_of=0.01, default=0)
|
||||
quantity: Decimal = Field(ge=0, default=0)
|
||||
is_active: bool
|
||||
sort_order: int
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
|
||||
class Product(ProductIn):
|
||||
@@ -29,7 +29,7 @@ class Product(ProductIn):
|
||||
version_id: uuid.UUID
|
||||
valid_from: date | None = None
|
||||
valid_till: date | None = None
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
@field_validator("valid_from", mode="before")
|
||||
@classmethod
|
||||
@@ -67,4 +67,4 @@ class ProductBlank(BaseModel):
|
||||
quantity: Decimal
|
||||
is_active: bool
|
||||
sort_order: int
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||
@@ -9,4 +9,4 @@ class ProductLink(BaseModel):
|
||||
id_: uuid.UUID = Field(...)
|
||||
name: str | None = None
|
||||
enabled: bool | None = None
|
||||
model_config = ConfigDict(alias_generator=to_camel)
|
||||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
||||
@@ -8,10 +8,10 @@ from . import to_camel
|
||||
class ReceivePaymentItem(BaseModel):
|
||||
id_: int
|
||||
amount: Decimal
|
||||
model_config = ConfigDict(alias_generator=to_camel)
|
||||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
|
||||
class ReceivePayment(BaseModel):
|
||||
reason: str
|
||||
amounts: list[ReceivePaymentItem]
|
||||
model_config = ConfigDict(alias_generator=to_camel, str_strip_whitespace=True)
|
||||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True, str_strip_whitespace=True)
|
||||
@@ -8,22 +8,22 @@ class RegimeIn(BaseModel):
|
||||
header: str
|
||||
prefix: str = Field(..., min_length=1)
|
||||
is_fixture: bool
|
||||
model_config = ConfigDict(alias_generator=to_camel)
|
||||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
|
||||
class Regime(RegimeIn):
|
||||
id_: int
|
||||
model_config = ConfigDict(alias_generator=to_camel)
|
||||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
|
||||
class RegimeBlank(RegimeIn):
|
||||
name: str
|
||||
header: str
|
||||
prefix: str
|
||||
model_config = ConfigDict(alias_generator=to_camel)
|
||||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
|
||||
class RegimeLink(BaseModel):
|
||||
id_: int = Field(...)
|
||||
name: str | None = None
|
||||
model_config = ConfigDict(alias_generator=to_camel)
|
||||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
||||
@@ -14,7 +14,7 @@ class RoleIn(BaseModel):
|
||||
|
||||
class Role(RoleIn):
|
||||
id_: uuid.UUID
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
|
||||
class RoleBlank(RoleIn):
|
||||
@@ -26,11 +26,11 @@ class RoleList(BaseModel):
|
||||
id_: uuid.UUID
|
||||
name: str
|
||||
permissions: list[str]
|
||||
model_config = ConfigDict(alias_generator=to_camel, str_strip_whitespace=True)
|
||||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True, str_strip_whitespace=True)
|
||||
|
||||
|
||||
class RoleItem(BaseModel):
|
||||
id_: uuid.UUID
|
||||
name: str
|
||||
enabled: bool
|
||||
model_config = ConfigDict(alias_generator=to_camel)
|
||||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
||||
@@ -10,20 +10,20 @@ from .tax import TaxLink
|
||||
|
||||
class SaleCategoryIn(BaseModel):
|
||||
name: str = Field(..., min_length=1)
|
||||
discount_limit: Decimal = Field(ge=0, multiple_of=0.0001, default=0, le=1)
|
||||
discount_limit: Decimal = Field(ge=0, default=0, le=1)
|
||||
tax: TaxLink = Field(...)
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
|
||||
class SaleCategory(SaleCategoryIn):
|
||||
id_: uuid.UUID
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
|
||||
class SaleCategoryBlank(BaseModel):
|
||||
name: str
|
||||
discount_limit: Decimal
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
|
||||
class SaleCategoryForDiscount(BaseModel):
|
||||
@@ -31,10 +31,10 @@ class SaleCategoryForDiscount(BaseModel):
|
||||
name: str
|
||||
discount_limit: Decimal
|
||||
discount: Decimal
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
|
||||
class SaleCategoryLink(BaseModel):
|
||||
id_: uuid.UUID = Field(...)
|
||||
name: str | None = None
|
||||
model_config = ConfigDict(alias_generator=to_camel)
|
||||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
||||
@@ -10,7 +10,7 @@ from .user import UserLink
|
||||
class SaleReportItem(BaseModel):
|
||||
name: str
|
||||
amount: Decimal
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
|
||||
class SaleReport(BaseModel):
|
||||
@@ -18,7 +18,7 @@ class SaleReport(BaseModel):
|
||||
finish_date: date
|
||||
amounts: list[SaleReportItem]
|
||||
user: UserLink
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
@field_validator("start_date", mode="before")
|
||||
@classmethod
|
||||
|
||||
@@ -12,7 +12,7 @@ class SectionIn(BaseModel):
|
||||
|
||||
class Section(SectionIn):
|
||||
id_: uuid.UUID
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
|
||||
class SectionBlank(BaseModel):
|
||||
@@ -23,4 +23,4 @@ class SectionBlank(BaseModel):
|
||||
class SectionLink(BaseModel):
|
||||
id_: uuid.UUID = Field(...)
|
||||
name: str | None = None
|
||||
model_config = ConfigDict(alias_generator=to_camel)
|
||||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
||||
@@ -9,4 +9,4 @@ class SectionPrinter(BaseModel):
|
||||
sale_category: SaleCategoryLink | None = None
|
||||
printer: PrinterLink | None = None
|
||||
copies: int = Field(ge=0)
|
||||
model_config = ConfigDict(alias_generator=to_camel)
|
||||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
||||
@@ -12,4 +12,4 @@ class SettleOption(BaseModel):
|
||||
reporting_level: ReportingLevel
|
||||
has_reason: bool
|
||||
is_fixture: bool
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||
@@ -8,4 +8,4 @@ from . import to_camel
|
||||
class Split(BaseModel):
|
||||
inventories: list[uuid.UUID]
|
||||
table_id: uuid.UUID
|
||||
model_config = ConfigDict(alias_generator=to_camel)
|
||||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
||||
@@ -12,12 +12,12 @@ class TableIn(BaseModel):
|
||||
section: SectionLink
|
||||
is_active: bool
|
||||
sort_order: int
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
|
||||
class Table(TableIn):
|
||||
id_: uuid.UUID
|
||||
model_config = ConfigDict(alias_generator=to_camel)
|
||||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
|
||||
class TableBlank(BaseModel):
|
||||
@@ -25,10 +25,10 @@ class TableBlank(BaseModel):
|
||||
seats: int
|
||||
is_active: bool
|
||||
sort_order: int
|
||||
model_config = ConfigDict(alias_generator=to_camel)
|
||||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
|
||||
class TableLink(BaseModel):
|
||||
id_: uuid.UUID = Field(...)
|
||||
name: str | None = None
|
||||
model_config = ConfigDict(alias_generator=to_camel)
|
||||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
||||
@@ -13,23 +13,23 @@ class TaxIn(BaseModel):
|
||||
rate: Decimal = Field(ge=0, default=0)
|
||||
regime: RegimeLink = Field(...)
|
||||
is_fixture: bool
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
|
||||
class Tax(TaxIn):
|
||||
id_: uuid.UUID
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
|
||||
class TaxBlank(BaseModel):
|
||||
name: str
|
||||
rate: Decimal = Field(ge=0, default=0)
|
||||
is_fixture: bool
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
|
||||
class TaxLink(BaseModel):
|
||||
id_: uuid.UUID = Field(...)
|
||||
name: str | None = None
|
||||
rate: Decimal | None = None
|
||||
model_config = ConfigDict(alias_generator=to_camel)
|
||||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
||||
@@ -11,14 +11,14 @@ class TaxReportItem(BaseModel):
|
||||
tax_rate: Decimal
|
||||
sale_amount: Decimal
|
||||
amount: Decimal
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
|
||||
class TaxReport(BaseModel):
|
||||
start_date: date
|
||||
finish_date: date
|
||||
amounts: list[TaxReportItem]
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
@field_validator("start_date", mode="before")
|
||||
@classmethod
|
||||
|
||||
@@ -13,14 +13,14 @@ class UpdateProductPricesItem(BaseModel):
|
||||
name: str
|
||||
old_price: Decimal
|
||||
new_price: Decimal
|
||||
model_config = ConfigDict(alias_generator=to_camel)
|
||||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
|
||||
class UpdateProductPrices(BaseModel):
|
||||
date_: date
|
||||
menu_category_id: uuid.UUID | None = None
|
||||
items: list[UpdateProductPricesItem]
|
||||
model_config = ConfigDict(alias_generator=to_camel)
|
||||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
@field_validator("date_", mode="before")
|
||||
@classmethod
|
||||
|
||||
@@ -12,33 +12,34 @@ class UserIn(BaseModel):
|
||||
password: str
|
||||
locked_out: bool
|
||||
roles: list[RoleItem]
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
|
||||
class User(UserIn):
|
||||
id_: uuid.UUID
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
|
||||
class UserMe(UserIn):
|
||||
id_: str
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
|
||||
class UserLink(BaseModel):
|
||||
id_: uuid.UUID | None = None
|
||||
name: str | None = None
|
||||
model_config = ConfigDict(alias_generator=to_camel)
|
||||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
|
||||
class UserList(BaseModel):
|
||||
id_: uuid.UUID
|
||||
name: str
|
||||
locked_out: bool
|
||||
roles: list[str]
|
||||
last_device: str
|
||||
last_date: datetime | None = None
|
||||
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
@field_serializer("last_date")
|
||||
def serialize_last_date(self, value: datetime | None, _info):
|
||||
|
||||
@@ -19,22 +19,27 @@ class Inventory(BaseModel):
|
||||
price: Decimal | None = None
|
||||
tax: TaxLink | None = None
|
||||
tax_rate: Decimal | None = None
|
||||
discount: Decimal = Field(ge=0, multiple_of=0.00001, le=1)
|
||||
discount: Decimal = Field(ge=0, le=1)
|
||||
is_happy_hour: bool
|
||||
modifiers: list[ModifierLink]
|
||||
amount: Decimal | None = None
|
||||
model_config = ConfigDict(alias_generator=to_camel)
|
||||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
@model_validator(mode="after")
|
||||
def calculate_amount(self) -> "Inventory":
|
||||
self.amount = round(Decimal(self.price * self.quantity * (1 - self.discount) * (1 + self.tax_rate)), 2)
|
||||
self.amount = round(
|
||||
Decimal(
|
||||
(self.price or Decimal(0)) * self.quantity * (1 - self.discount) * (1 + (self.tax_rate or Decimal(0)))
|
||||
),
|
||||
2,
|
||||
)
|
||||
return self
|
||||
|
||||
|
||||
class Kot(BaseModel):
|
||||
id_: uuid.UUID | None = None
|
||||
inventories: list[Inventory]
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
|
||||
class VoucherIn(BaseModel):
|
||||
@@ -42,9 +47,9 @@ class VoucherIn(BaseModel):
|
||||
table: TableLink
|
||||
customer: CustomerLink | None = None
|
||||
kots: list[Kot]
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
|
||||
class Voucher(VoucherIn):
|
||||
id_: uuid.UUID
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
|
||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||
Reference in new issue
Block a user