Chore: Updated fastapi and pydantic
Refactor: Removed mapped_column name string in models Refactor: Moved from postgres.uuid to uuid in models Fix: Schemas use Daf (Decimal as float to hack around pydantic v2 sending decimals as strings.)
This commit is contained in:
1 parent
e955ef4196
commit
cb3657615a
51 files changed
+277
-429
No files matched your search
@@ -2,8 +2,7 @@ import uuid
|
|||||||
|
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from sqlalchemy import Boolean, ForeignKey, Integer, UniqueConstraint, text
|
from sqlalchemy import Boolean, ForeignKey, Integer, UniqueConstraint, Uuid, text
|
||||||
from sqlalchemy.dialects.postgresql import UUID
|
|
||||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||||
|
|
||||||
from ..db.base_class import reg
|
from ..db.base_class import reg
|
||||||
@@ -22,15 +21,11 @@ class Bill:
|
|||||||
UniqueConstraint("regime_id", "bill_number"),
|
UniqueConstraint("regime_id", "bill_number"),
|
||||||
)
|
)
|
||||||
|
|
||||||
id: Mapped[uuid.UUID] = mapped_column(
|
id: Mapped[uuid.UUID] = mapped_column(Uuid, primary_key=True, server_default=text("gen_random_uuid()"))
|
||||||
"id", UUID(as_uuid=True), primary_key=True, server_default=text("gen_random_uuid()"), insert_default=uuid.uuid4
|
regime_id: Mapped[int] = mapped_column(Integer, ForeignKey("regimes.id"), nullable=False)
|
||||||
)
|
voucher_id: Mapped[uuid.UUID] = mapped_column(Uuid, ForeignKey("vouchers.id"), nullable=False)
|
||||||
regime_id: Mapped[int] = mapped_column("regime_id", Integer, ForeignKey("regimes.id"), nullable=False)
|
is_valid: Mapped[bool] = mapped_column(Boolean, nullable=False)
|
||||||
voucher_id: Mapped[uuid.UUID] = mapped_column(
|
bill_number: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||||
"voucher_id", UUID(as_uuid=True), ForeignKey("vouchers.id"), nullable=False
|
|
||||||
)
|
|
||||||
is_valid: Mapped[bool] = mapped_column("is_valid", Boolean, nullable=False)
|
|
||||||
bill_number: Mapped[int] = mapped_column("bill_number", Integer)
|
|
||||||
|
|
||||||
voucher: Mapped["Voucher"] = relationship(back_populates="bills")
|
voucher: Mapped["Voucher"] = relationship(back_populates="bills")
|
||||||
regime: Mapped["Regime"] = relationship(back_populates="bills")
|
regime: Mapped["Regime"] = relationship(back_populates="bills")
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from typing import TYPE_CHECKING, List, Optional
|
from typing import TYPE_CHECKING, List
|
||||||
|
|
||||||
from sqlalchemy import Boolean, Unicode, text
|
from sqlalchemy import Boolean, Text, Uuid, text
|
||||||
from sqlalchemy.dialects.postgresql import UUID
|
|
||||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||||
from sqlalchemy.sql import expression
|
from sqlalchemy.sql import expression
|
||||||
|
|
||||||
@@ -18,16 +17,12 @@ if TYPE_CHECKING:
|
|||||||
class Customer:
|
class Customer:
|
||||||
__tablename__ = "customers"
|
__tablename__ = "customers"
|
||||||
|
|
||||||
id: Mapped[uuid.UUID] = mapped_column(
|
id: Mapped[uuid.UUID] = mapped_column(Uuid, primary_key=True, server_default=text("gen_random_uuid()"))
|
||||||
"id", UUID(as_uuid=True), primary_key=True, server_default=text("gen_random_uuid()"), insert_default=uuid.uuid4
|
name: Mapped[str] = mapped_column(Text, nullable=False)
|
||||||
)
|
phone: Mapped[str] = mapped_column(Text, nullable=False, unique=True)
|
||||||
name: Mapped[str] = mapped_column("name", Unicode(255), nullable=False)
|
address: Mapped[str | None] = mapped_column(Text, nullable=True)
|
||||||
phone: Mapped[str] = mapped_column("phone", Unicode(255), nullable=False, unique=True)
|
|
||||||
address: Mapped[Optional[str]] = mapped_column("address", Unicode(255), nullable=True)
|
|
||||||
|
|
||||||
print_in_bill: Mapped[bool] = mapped_column(
|
print_in_bill: Mapped[bool] = mapped_column(Boolean, server_default=expression.false(), nullable=False)
|
||||||
"print_in_bill", Boolean, server_default=expression.false(), insert_default=False, nullable=False
|
|
||||||
)
|
|
||||||
|
|
||||||
discounts: Mapped[List["CustomerDiscount"]] = relationship(back_populates="customer")
|
discounts: Mapped[List["CustomerDiscount"]] = relationship(back_populates="customer")
|
||||||
|
|
||||||
|
|||||||
@@ -4,8 +4,7 @@ from datetime import datetime
|
|||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from sqlalchemy import ForeignKey, Numeric, UniqueConstraint, text
|
from sqlalchemy import ForeignKey, Numeric, UniqueConstraint, Uuid, text
|
||||||
from sqlalchemy.dialects.postgresql import UUID
|
|
||||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||||
|
|
||||||
from ..db.base_class import reg
|
from ..db.base_class import reg
|
||||||
@@ -21,16 +20,10 @@ class CustomerDiscount:
|
|||||||
__tablename__ = "customer_discount"
|
__tablename__ = "customer_discount"
|
||||||
__table_args__ = (UniqueConstraint("customer_id", "sale_category_id"),)
|
__table_args__ = (UniqueConstraint("customer_id", "sale_category_id"),)
|
||||||
|
|
||||||
id: Mapped[uuid.UUID] = mapped_column(
|
id: Mapped[uuid.UUID] = mapped_column(Uuid, primary_key=True, server_default=text("gen_random_uuid()"))
|
||||||
"id", UUID(as_uuid=True), primary_key=True, server_default=text("gen_random_uuid()"), insert_default=uuid.uuid4
|
customer_id: Mapped[uuid.UUID] = mapped_column(Uuid, ForeignKey("customers.id"), nullable=False)
|
||||||
)
|
sale_category_id: Mapped[uuid.UUID] = mapped_column(Uuid, ForeignKey("sale_categories.id"), nullable=False)
|
||||||
customer_id: Mapped[uuid.UUID] = mapped_column(
|
discount: Mapped[Decimal] = mapped_column(Numeric(precision=15, scale=5), nullable=False)
|
||||||
"customer_id", UUID(as_uuid=True), ForeignKey("customers.id"), nullable=False
|
|
||||||
)
|
|
||||||
sale_category_id: Mapped[uuid.UUID] = mapped_column(
|
|
||||||
"sale_category_id", UUID(as_uuid=True), ForeignKey("sale_categories.id"), nullable=False
|
|
||||||
)
|
|
||||||
discount: Mapped[Decimal] = mapped_column("discount", Numeric(precision=15, scale=5), nullable=False)
|
|
||||||
|
|
||||||
customer: Mapped["Customer"] = relationship(back_populates="discounts")
|
customer: Mapped["Customer"] = relationship(back_populates="discounts")
|
||||||
sale_category: Mapped["SaleCategory"] = relationship("SaleCategory")
|
sale_category: Mapped["SaleCategory"] = relationship("SaleCategory")
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from sqlalchemy import JSON, Unicode, text
|
from sqlalchemy import JSON, Text, Uuid, text
|
||||||
from sqlalchemy.dialects.postgresql import UUID
|
|
||||||
from sqlalchemy.orm import Mapped, mapped_column
|
from sqlalchemy.orm import Mapped, mapped_column
|
||||||
|
|
||||||
from ..db.base_class import reg
|
from ..db.base_class import reg
|
||||||
@@ -11,11 +10,9 @@ from ..db.base_class import reg
|
|||||||
class DbSetting:
|
class DbSetting:
|
||||||
__tablename__ = "settings"
|
__tablename__ = "settings"
|
||||||
|
|
||||||
id: Mapped[uuid.UUID] = mapped_column(
|
id: Mapped[uuid.UUID] = mapped_column(Uuid, primary_key=True, server_default=text("gen_random_uuid()"))
|
||||||
"id", UUID(as_uuid=True), primary_key=True, server_default=text("gen_random_uuid()"), insert_default=uuid.uuid4
|
name: Mapped[str] = mapped_column(Text, unique=True, nullable=False)
|
||||||
)
|
data = mapped_column(JSON, nullable=False)
|
||||||
name: Mapped[str] = mapped_column("name", Unicode(255), unique=True, nullable=False)
|
|
||||||
data = mapped_column("data", JSON)
|
|
||||||
|
|
||||||
def __init__(self, id_=None, name=None, data=None):
|
def __init__(self, id_=None, name=None, data=None):
|
||||||
self.id = id_
|
self.id = id_
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ from datetime import datetime
|
|||||||
from typing import TYPE_CHECKING, List
|
from typing import TYPE_CHECKING, List
|
||||||
|
|
||||||
from barker.models.login_history import LoginHistory
|
from barker.models.login_history import LoginHistory
|
||||||
from sqlalchemy import Boolean, DateTime, ForeignKey, Unicode, desc, text
|
from sqlalchemy import Boolean, DateTime, ForeignKey, Text, Uuid, desc, text
|
||||||
from sqlalchemy.dialects.postgresql import UUID
|
|
||||||
from sqlalchemy.orm import Mapped, Session, mapped_column, relationship
|
from sqlalchemy.orm import Mapped, Session, mapped_column, relationship
|
||||||
|
|
||||||
from ..db.base_class import reg
|
from ..db.base_class import reg
|
||||||
@@ -21,15 +20,11 @@ if TYPE_CHECKING:
|
|||||||
class Device:
|
class Device:
|
||||||
__tablename__ = "devices"
|
__tablename__ = "devices"
|
||||||
|
|
||||||
id: Mapped[uuid.UUID] = mapped_column(
|
id: Mapped[uuid.UUID] = mapped_column(Uuid, primary_key=True, server_default=text("gen_random_uuid()"))
|
||||||
"id", UUID(as_uuid=True), primary_key=True, server_default=text("gen_random_uuid()"), insert_default=uuid.uuid4
|
name: Mapped[str] = mapped_column(Text, unique=True, nullable=False)
|
||||||
)
|
enabled: Mapped[bool] = mapped_column(Boolean, nullable=False)
|
||||||
name: Mapped[str] = mapped_column("name", Unicode(255), unique=True, nullable=False)
|
section_id: Mapped[uuid.UUID] = mapped_column(Uuid, ForeignKey("sections.id"), nullable=False)
|
||||||
enabled: Mapped[bool] = mapped_column("enabled", Boolean, nullable=False)
|
creation_date: Mapped[datetime] = mapped_column(DateTime(), nullable=False)
|
||||||
section_id: Mapped[uuid.UUID] = mapped_column(
|
|
||||||
"section_id", UUID(as_uuid=True), ForeignKey("sections.id"), nullable=False
|
|
||||||
)
|
|
||||||
creation_date: Mapped[datetime] = mapped_column("creation_date", DateTime(), nullable=False)
|
|
||||||
|
|
||||||
section: Mapped["Section"] = relationship(back_populates="devices")
|
section: Mapped["Section"] = relationship(back_populates="devices")
|
||||||
login_history: Mapped[List["LoginHistory"]] = relationship(
|
login_history: Mapped[List["LoginHistory"]] = relationship(
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from typing import TYPE_CHECKING, Optional
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from sqlalchemy import Boolean, ForeignKey, Integer, Unicode, text
|
from sqlalchemy import Boolean, ForeignKey, Integer, Text, Uuid, text
|
||||||
from sqlalchemy.dialects.postgresql import UUID
|
|
||||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||||
|
|
||||||
from ..db.base_class import reg
|
from ..db.base_class import reg
|
||||||
@@ -18,19 +17,15 @@ if TYPE_CHECKING:
|
|||||||
class FoodTable:
|
class FoodTable:
|
||||||
__tablename__ = "food_tables"
|
__tablename__ = "food_tables"
|
||||||
|
|
||||||
id: Mapped[uuid.UUID] = mapped_column(
|
id: Mapped[uuid.UUID] = mapped_column(Uuid, primary_key=True, server_default=text("gen_random_uuid()"))
|
||||||
"id", UUID(as_uuid=True), primary_key=True, server_default=text("gen_random_uuid()"), insert_default=uuid.uuid4
|
name: Mapped[str] = mapped_column(Text, nullable=False, unique=True)
|
||||||
)
|
seats: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||||
name: Mapped[str] = mapped_column("name", Unicode(255), nullable=False, unique=True)
|
section_id: Mapped[uuid.UUID] = mapped_column(Uuid, ForeignKey("sections.id"), nullable=False)
|
||||||
seats: Mapped[int] = mapped_column("seats", Integer, nullable=False)
|
is_active: Mapped[bool] = mapped_column(Boolean, nullable=False)
|
||||||
section_id: Mapped[uuid.UUID] = mapped_column(
|
sort_order: Mapped[bool] = mapped_column(Integer, nullable=False)
|
||||||
"section_id", UUID(as_uuid=True), ForeignKey("sections.id"), nullable=False
|
|
||||||
)
|
|
||||||
is_active: Mapped[bool] = mapped_column("is_active", Boolean, nullable=False)
|
|
||||||
sort_order: Mapped[bool] = mapped_column("sort_order", Integer, nullable=False)
|
|
||||||
|
|
||||||
section: Mapped["Section"] = relationship("Section", foreign_keys=section_id)
|
section: Mapped["Section"] = relationship("Section", foreign_keys=section_id)
|
||||||
status: Mapped[Optional["Overview"]] = relationship(back_populates="food_table", uselist=False)
|
status: Mapped["Overview" | None] = relationship(back_populates="food_table", uselist=False)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def __name__(self):
|
def __name__(self):
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from typing import TYPE_CHECKING, Optional
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from sqlalchemy import DateTime, ForeignKey, Integer, text
|
from sqlalchemy import DateTime, ForeignKey, Integer, Uuid, text
|
||||||
from sqlalchemy.dialects.postgresql import UUID
|
|
||||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||||
|
|
||||||
from ..db.base_class import reg
|
from ..db.base_class import reg
|
||||||
@@ -18,17 +17,13 @@ if TYPE_CHECKING:
|
|||||||
@reg.mapped_as_dataclass(unsafe_hash=True)
|
@reg.mapped_as_dataclass(unsafe_hash=True)
|
||||||
class GuestBook:
|
class GuestBook:
|
||||||
__tablename__ = "guest_book"
|
__tablename__ = "guest_book"
|
||||||
id: Mapped[uuid.UUID] = mapped_column(
|
id: Mapped[uuid.UUID] = mapped_column(Uuid, primary_key=True, server_default=text("gen_random_uuid()"))
|
||||||
"id", UUID(as_uuid=True), primary_key=True, server_default=text("gen_random_uuid()"), insert_default=uuid.uuid4
|
customer_id: Mapped[uuid.UUID] = mapped_column(Uuid, ForeignKey("customers.id"), nullable=False)
|
||||||
)
|
pax: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||||
customer_id: Mapped[uuid.UUID] = mapped_column(
|
|
||||||
"customer_id", UUID(as_uuid=True), ForeignKey("customers.id"), nullable=False
|
|
||||||
)
|
|
||||||
pax: Mapped[int] = mapped_column("pax", Integer, nullable=False)
|
|
||||||
date: Mapped[datetime] = mapped_column("creation_date", DateTime(), nullable=False)
|
date: Mapped[datetime] = mapped_column("creation_date", DateTime(), nullable=False)
|
||||||
|
|
||||||
customer: Mapped["Customer"] = relationship("Customer")
|
customer: Mapped["Customer"] = relationship("Customer")
|
||||||
status: Mapped[Optional["Overview"]] = relationship(back_populates="guest", uselist=False)
|
status: Mapped["Overview" | None] = relationship(back_populates="guest", uselist=False)
|
||||||
|
|
||||||
def __init__(self, pax=None, id_=None, customer_id=None, customer=None, date_=None):
|
def __init__(self, pax=None, id_=None, customer_id=None, customer=None, date_=None):
|
||||||
self.customer_id = customer_id
|
self.customer_id = customer_id
|
||||||
|
|||||||
@@ -11,12 +11,12 @@ from sqlalchemy import (
|
|||||||
Integer,
|
Integer,
|
||||||
Numeric,
|
Numeric,
|
||||||
UniqueConstraint,
|
UniqueConstraint,
|
||||||
|
Uuid,
|
||||||
case,
|
case,
|
||||||
func,
|
func,
|
||||||
text,
|
text,
|
||||||
type_coerce,
|
type_coerce,
|
||||||
)
|
)
|
||||||
from sqlalchemy.dialects.postgresql import UUID
|
|
||||||
from sqlalchemy.ext.hybrid import hybrid_property
|
from sqlalchemy.ext.hybrid import hybrid_property
|
||||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||||
|
|
||||||
@@ -34,22 +34,16 @@ class Inventory:
|
|||||||
__tablename__ = "inventories"
|
__tablename__ = "inventories"
|
||||||
__table_args__ = (UniqueConstraint("kot_id", "product_id", "is_happy_hour", "price"),)
|
__table_args__ = (UniqueConstraint("kot_id", "product_id", "is_happy_hour", "price"),)
|
||||||
|
|
||||||
id: Mapped[uuid.UUID] = mapped_column(
|
id: Mapped[uuid.UUID] = mapped_column(Uuid, primary_key=True, server_default=text("gen_random_uuid()"))
|
||||||
"id", UUID(as_uuid=True), primary_key=True, server_default=text("gen_random_uuid()"), insert_default=uuid.uuid4
|
kot_id: Mapped[uuid.UUID] = mapped_column(Uuid, ForeignKey("kots.id"), nullable=False, index=True)
|
||||||
)
|
product_id: Mapped[uuid.UUID] = mapped_column(Uuid, ForeignKey("products.id"), nullable=False)
|
||||||
kot_id: Mapped[uuid.UUID] = mapped_column(
|
quantity: Mapped[Decimal] = mapped_column(Numeric(precision=15, scale=2), nullable=False)
|
||||||
"kot_id", UUID(as_uuid=True), ForeignKey("kots.id"), nullable=False, index=True
|
price: Mapped[Decimal] = mapped_column(Numeric(precision=15, scale=2), nullable=False)
|
||||||
)
|
is_happy_hour: Mapped[bool] = mapped_column(Boolean, nullable=False)
|
||||||
product_id: Mapped[uuid.UUID] = mapped_column(
|
tax_rate: Mapped[Decimal] = mapped_column(Numeric(precision=15, scale=5), nullable=False)
|
||||||
"product_id", UUID(as_uuid=True), ForeignKey("products.id"), nullable=False
|
tax_id: Mapped[uuid.UUID] = mapped_column(Uuid, ForeignKey("taxes.id"), nullable=False)
|
||||||
)
|
discount: Mapped[Decimal] = mapped_column(Numeric(precision=15, scale=5), nullable=False)
|
||||||
quantity: Mapped[Decimal] = mapped_column("quantity", Numeric(precision=15, scale=2), nullable=False)
|
sort_order: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||||
price: Mapped[Decimal] = mapped_column("price", Numeric(precision=15, scale=2), nullable=False)
|
|
||||||
is_happy_hour: Mapped[bool] = mapped_column("is_happy_hour", Boolean, nullable=False)
|
|
||||||
tax_rate: Mapped[Decimal] = mapped_column("tax_rate", Numeric(precision=15, scale=5), nullable=False)
|
|
||||||
tax_id: Mapped[uuid.UUID] = mapped_column("tax_id", UUID(as_uuid=True), ForeignKey("taxes.id"), nullable=False)
|
|
||||||
discount: Mapped[Decimal] = mapped_column("discount", Numeric(precision=15, scale=5), nullable=False)
|
|
||||||
sort_order: Mapped[int] = mapped_column("sort_order", Integer, nullable=False)
|
|
||||||
|
|
||||||
kot: Mapped["Kot"] = relationship(back_populates="inventories")
|
kot: Mapped["Kot"] = relationship(back_populates="inventories")
|
||||||
tax: Mapped["Tax"] = relationship(back_populates="inventories")
|
tax: Mapped["Tax"] = relationship(back_populates="inventories")
|
||||||
|
|||||||
@@ -3,8 +3,7 @@ import uuid
|
|||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from sqlalchemy import ForeignKey, Numeric, UniqueConstraint, text
|
from sqlalchemy import ForeignKey, Numeric, UniqueConstraint, Uuid, text
|
||||||
from sqlalchemy.dialects.postgresql import UUID
|
|
||||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||||
|
|
||||||
from ..db.base_class import reg
|
from ..db.base_class import reg
|
||||||
@@ -20,16 +19,10 @@ class InventoryModifier:
|
|||||||
__tablename__ = "inventory_modifiers"
|
__tablename__ = "inventory_modifiers"
|
||||||
__table_args__ = (UniqueConstraint("inventory_id", "modifier_id"),)
|
__table_args__ = (UniqueConstraint("inventory_id", "modifier_id"),)
|
||||||
|
|
||||||
id: Mapped[uuid.UUID] = mapped_column(
|
id: Mapped[uuid.UUID] = mapped_column(Uuid, primary_key=True, server_default=text("gen_random_uuid()"))
|
||||||
"id", UUID(as_uuid=True), primary_key=True, server_default=text("gen_random_uuid()"), insert_default=uuid.uuid4
|
inventory_id: Mapped[uuid.UUID] = mapped_column(Uuid, ForeignKey("inventories.id"), nullable=False)
|
||||||
)
|
modifier_id: Mapped[uuid.UUID] = mapped_column(Uuid, ForeignKey("modifiers.id"), nullable=False)
|
||||||
inventory_id: Mapped[uuid.UUID] = mapped_column(
|
price: Mapped[Decimal] = mapped_column(Numeric(precision=15, scale=2), nullable=False)
|
||||||
"inventory_id", UUID(as_uuid=True), ForeignKey("inventories.id"), nullable=False
|
|
||||||
)
|
|
||||||
modifier_id: Mapped[uuid.UUID] = mapped_column(
|
|
||||||
"modifier_id", UUID(as_uuid=True), ForeignKey("modifiers.id"), nullable=False
|
|
||||||
)
|
|
||||||
price: Mapped[Decimal] = mapped_column("price", Numeric(precision=15, scale=2), nullable=False)
|
|
||||||
|
|
||||||
inventory: Mapped["Inventory"] = relationship(back_populates="modifiers")
|
inventory: Mapped["Inventory"] = relationship(back_populates="modifiers")
|
||||||
modifier: Mapped["Modifier"] = relationship("Modifier")
|
modifier: Mapped["Modifier"] = relationship("Modifier")
|
||||||
|
|||||||
@@ -3,8 +3,7 @@ import uuid
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from typing import TYPE_CHECKING, List
|
from typing import TYPE_CHECKING, List
|
||||||
|
|
||||||
from sqlalchemy import DateTime, ForeignKey, Integer, text
|
from sqlalchemy import DateTime, ForeignKey, Integer, Uuid, text
|
||||||
from sqlalchemy.dialects.postgresql import UUID
|
|
||||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||||
|
|
||||||
from ..db.base_class import reg
|
from ..db.base_class import reg
|
||||||
@@ -21,25 +20,21 @@ if TYPE_CHECKING:
|
|||||||
class Kot:
|
class Kot:
|
||||||
__tablename__ = "kots"
|
__tablename__ = "kots"
|
||||||
|
|
||||||
id: Mapped[uuid.UUID] = mapped_column(
|
id: Mapped[uuid.UUID] = mapped_column(Uuid, primary_key=True, server_default=text("gen_random_uuid()"))
|
||||||
"id", UUID(as_uuid=True), primary_key=True, server_default=text("gen_random_uuid()"), insert_default=uuid.uuid4
|
|
||||||
)
|
|
||||||
voucher_id: Mapped[uuid.UUID] = mapped_column(
|
voucher_id: Mapped[uuid.UUID] = mapped_column(
|
||||||
"voucher_id",
|
Uuid,
|
||||||
UUID(as_uuid=True),
|
|
||||||
ForeignKey("vouchers.id"),
|
ForeignKey("vouchers.id"),
|
||||||
nullable=False,
|
nullable=False,
|
||||||
index=True,
|
index=True,
|
||||||
)
|
)
|
||||||
code: Mapped[int] = mapped_column("code", Integer, nullable=False, unique=True)
|
code: Mapped[int] = mapped_column(Integer, nullable=False, unique=True)
|
||||||
food_table_id: Mapped[uuid.UUID] = mapped_column(
|
food_table_id: Mapped[uuid.UUID] = mapped_column(
|
||||||
"food_table_id",
|
Uuid,
|
||||||
UUID(as_uuid=True),
|
|
||||||
ForeignKey("food_tables.id"),
|
ForeignKey("food_tables.id"),
|
||||||
nullable=False,
|
nullable=False,
|
||||||
)
|
)
|
||||||
date: Mapped[datetime] = mapped_column("date", DateTime, nullable=False, index=True)
|
date: Mapped[datetime] = mapped_column(DateTime, nullable=False, index=True)
|
||||||
user_id: Mapped[uuid.UUID] = mapped_column("user_id", UUID(as_uuid=True), ForeignKey("users.id"), nullable=False)
|
user_id: Mapped[uuid.UUID] = mapped_column(Uuid, ForeignKey("users.id"), nullable=False)
|
||||||
|
|
||||||
voucher: Mapped["Voucher"] = relationship(back_populates="kots")
|
voucher: Mapped["Voucher"] = relationship(back_populates="kots")
|
||||||
user: Mapped["User"] = relationship(backref="kots")
|
user: Mapped["User"] = relationship(backref="kots")
|
||||||
|
|||||||
@@ -3,8 +3,7 @@ import uuid
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from sqlalchemy import DateTime, ForeignKey, UniqueConstraint, text
|
from sqlalchemy import DateTime, ForeignKey, UniqueConstraint, Uuid, text
|
||||||
from sqlalchemy.dialects.postgresql import UUID
|
|
||||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||||
|
|
||||||
from ..db.base_class import reg
|
from ..db.base_class import reg
|
||||||
@@ -19,17 +18,14 @@ if TYPE_CHECKING:
|
|||||||
class LoginHistory:
|
class LoginHistory:
|
||||||
__tablename__ = "login_history"
|
__tablename__ = "login_history"
|
||||||
__table_args__ = (UniqueConstraint("user_id", "device_id", "date"),)
|
__table_args__ = (UniqueConstraint("user_id", "device_id", "date"),)
|
||||||
id: Mapped[uuid.UUID] = mapped_column(
|
id: Mapped[uuid.UUID] = mapped_column(Uuid, primary_key=True, server_default=text("gen_random_uuid()"))
|
||||||
"id", UUID(as_uuid=True), primary_key=True, server_default=text("gen_random_uuid()"), insert_default=uuid.uuid4
|
user_id: Mapped[uuid.UUID] = mapped_column(Uuid, ForeignKey("users.id"), nullable=False)
|
||||||
)
|
|
||||||
user_id: Mapped[uuid.UUID] = mapped_column("user_id", UUID(as_uuid=True), ForeignKey("users.id"), nullable=False)
|
|
||||||
device_id: Mapped[uuid.UUID] = mapped_column(
|
device_id: Mapped[uuid.UUID] = mapped_column(
|
||||||
"device_id",
|
Uuid,
|
||||||
UUID(as_uuid=True),
|
|
||||||
ForeignKey("devices.id"),
|
ForeignKey("devices.id"),
|
||||||
nullable=False,
|
nullable=False,
|
||||||
)
|
)
|
||||||
date: Mapped[datetime] = mapped_column("date", DateTime(), nullable=False)
|
date: Mapped[datetime] = mapped_column(DateTime(), nullable=False)
|
||||||
|
|
||||||
device: Mapped["Device"] = relationship(back_populates="login_history")
|
device: Mapped["Device"] = relationship(back_populates="login_history")
|
||||||
user: Mapped["User"] = relationship(back_populates="login_history")
|
user: Mapped["User"] = relationship(back_populates="login_history")
|
||||||
|
|||||||
@@ -2,8 +2,7 @@ import uuid
|
|||||||
|
|
||||||
from typing import TYPE_CHECKING, List
|
from typing import TYPE_CHECKING, List
|
||||||
|
|
||||||
from sqlalchemy import Boolean, Integer, Unicode, text
|
from sqlalchemy import Boolean, Integer, Text, Uuid, text
|
||||||
from sqlalchemy.dialects.postgresql import UUID
|
|
||||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||||
|
|
||||||
from ..db.base_class import reg
|
from ..db.base_class import reg
|
||||||
@@ -17,14 +16,12 @@ if TYPE_CHECKING:
|
|||||||
class MenuCategory:
|
class MenuCategory:
|
||||||
__tablename__ = "menu_categories"
|
__tablename__ = "menu_categories"
|
||||||
|
|
||||||
id: Mapped[uuid.UUID] = mapped_column(
|
id: Mapped[uuid.UUID] = mapped_column(Uuid, primary_key=True, server_default=text("gen_random_uuid()"))
|
||||||
"id", UUID(as_uuid=True), primary_key=True, server_default=text("gen_random_uuid()"), insert_default=uuid.uuid4
|
name: Mapped[str] = mapped_column(Text, nullable=False, unique=True)
|
||||||
)
|
|
||||||
name: Mapped[str] = mapped_column("name", Unicode(255), nullable=False, unique=True)
|
|
||||||
|
|
||||||
is_active: Mapped[bool] = mapped_column("is_active", Boolean, nullable=False)
|
is_active: Mapped[bool] = mapped_column(Boolean, nullable=False)
|
||||||
is_fixture: Mapped[bool] = mapped_column("is_fixture", Boolean, nullable=False)
|
is_fixture: Mapped[bool] = mapped_column(Boolean, nullable=False)
|
||||||
sort_order: Mapped[int] = mapped_column("sort_order", Integer, nullable=False)
|
sort_order: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||||
|
|
||||||
products: Mapped[List["ProductVersion"]] = relationship(back_populates="menu_category")
|
products: Mapped[List["ProductVersion"]] = relationship(back_populates="menu_category")
|
||||||
|
|
||||||
|
|||||||
@@ -3,8 +3,7 @@ import uuid
|
|||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from sqlalchemy import Boolean, ForeignKey, Numeric, Unicode, text
|
from sqlalchemy import Boolean, ForeignKey, Numeric, Text, Uuid, text
|
||||||
from sqlalchemy.dialects.postgresql import UUID
|
|
||||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||||
|
|
||||||
from ..db.base_class import reg
|
from ..db.base_class import reg
|
||||||
@@ -18,16 +17,13 @@ if TYPE_CHECKING:
|
|||||||
class Modifier:
|
class Modifier:
|
||||||
__tablename__ = "modifiers"
|
__tablename__ = "modifiers"
|
||||||
|
|
||||||
id: Mapped[uuid.UUID] = mapped_column(
|
id: Mapped[uuid.UUID] = mapped_column(Uuid, primary_key=True, server_default=text("gen_random_uuid()"))
|
||||||
"id", UUID(as_uuid=True), primary_key=True, server_default=text("gen_random_uuid()"), insert_default=uuid.uuid4
|
name: Mapped[str] = mapped_column(Text, nullable=False, unique=True)
|
||||||
)
|
show_in_bill: Mapped[bool] = mapped_column(Boolean, nullable=False)
|
||||||
name: Mapped[str] = mapped_column("name", Unicode(255), nullable=False, unique=True)
|
price: Mapped[Decimal] = mapped_column(Numeric(precision=15, scale=2), nullable=False)
|
||||||
show_in_bill: Mapped[bool] = mapped_column("show_in_bill", Boolean, nullable=False)
|
is_active: Mapped[bool] = mapped_column(Boolean, nullable=False)
|
||||||
price: Mapped[Decimal] = mapped_column("price", Numeric(precision=15, scale=2), nullable=False)
|
|
||||||
is_active: Mapped[bool] = mapped_column("is_active", Boolean, nullable=False)
|
|
||||||
modifier_category_id: Mapped[uuid.UUID] = mapped_column(
|
modifier_category_id: Mapped[uuid.UUID] = mapped_column(
|
||||||
"modifier_category_id",
|
Uuid,
|
||||||
UUID(as_uuid=True),
|
|
||||||
ForeignKey("modifier_categories.id"),
|
ForeignKey("modifier_categories.id"),
|
||||||
nullable=False,
|
nullable=False,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from typing import TYPE_CHECKING, List, Optional
|
from typing import TYPE_CHECKING, List
|
||||||
|
|
||||||
from barker.models.modifier_category_product import ModifierCategoryProduct
|
from barker.models.modifier_category_product import ModifierCategoryProduct
|
||||||
from sqlalchemy import Boolean, Integer, Unicode, text
|
from sqlalchemy import Boolean, Integer, Text, Uuid, text
|
||||||
from sqlalchemy.dialects.postgresql import UUID
|
|
||||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||||
|
|
||||||
from ..db.base_class import reg
|
from ..db.base_class import reg
|
||||||
@@ -19,14 +18,12 @@ if TYPE_CHECKING:
|
|||||||
class ModifierCategory:
|
class ModifierCategory:
|
||||||
__tablename__ = "modifier_categories"
|
__tablename__ = "modifier_categories"
|
||||||
|
|
||||||
id: Mapped[uuid.UUID] = mapped_column(
|
id: Mapped[uuid.UUID] = mapped_column(Uuid, primary_key=True, server_default=text("gen_random_uuid()"))
|
||||||
"id", UUID(as_uuid=True), primary_key=True, server_default=text("gen_random_uuid()"), insert_default=uuid.uuid4
|
name: Mapped[str] = mapped_column(Text, nullable=False, unique=True)
|
||||||
)
|
minimum: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||||
name: Mapped[str] = mapped_column("name", Unicode(255), nullable=False, unique=True)
|
maximum: Mapped[int | None] = mapped_column(Integer, nullable=True)
|
||||||
minimum: Mapped[int] = mapped_column("minimum", Integer, nullable=False)
|
is_active: Mapped[bool] = mapped_column(Boolean, nullable=False)
|
||||||
maximum: Mapped[Optional[int]] = mapped_column("maximum", Integer, nullable=True)
|
sort_order: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||||
is_active: Mapped[bool] = mapped_column("is_active", Boolean, nullable=False)
|
|
||||||
sort_order: Mapped[int] = mapped_column("sort_order", Integer, nullable=False)
|
|
||||||
|
|
||||||
products: Mapped[List["Product"]] = relationship(
|
products: Mapped[List["Product"]] = relationship(
|
||||||
secondary=ModifierCategoryProduct.__table__, # type: ignore[attr-defined]
|
secondary=ModifierCategoryProduct.__table__, # type: ignore[attr-defined]
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from sqlalchemy import ForeignKey, UniqueConstraint, text
|
from sqlalchemy import ForeignKey, UniqueConstraint, Uuid, text
|
||||||
from sqlalchemy.dialects.postgresql import UUID
|
|
||||||
from sqlalchemy.orm import Mapped, mapped_column
|
from sqlalchemy.orm import Mapped, mapped_column
|
||||||
|
|
||||||
from ..db.base_class import reg
|
from ..db.base_class import reg
|
||||||
@@ -12,15 +11,10 @@ class ModifierCategoryProduct:
|
|||||||
__tablename__ = "modifier_categories_products"
|
__tablename__ = "modifier_categories_products"
|
||||||
__table_args__ = (UniqueConstraint("product_id", "modifier_category_id"),)
|
__table_args__ = (UniqueConstraint("product_id", "modifier_category_id"),)
|
||||||
|
|
||||||
id: Mapped[uuid.UUID] = mapped_column(
|
id: Mapped[uuid.UUID] = mapped_column(Uuid, primary_key=True, server_default=text("gen_random_uuid()"))
|
||||||
"id", UUID(as_uuid=True), primary_key=True, server_default=text("gen_random_uuid()"), insert_default=uuid.uuid4
|
product_id: Mapped[uuid.UUID] = mapped_column(Uuid, ForeignKey("products.id"), nullable=False)
|
||||||
)
|
|
||||||
product_id: Mapped[uuid.UUID] = mapped_column(
|
|
||||||
"product_id", UUID(as_uuid=True), ForeignKey("products.id"), nullable=False
|
|
||||||
)
|
|
||||||
modifier_category_id: Mapped[uuid.UUID] = mapped_column(
|
modifier_category_id: Mapped[uuid.UUID] = mapped_column(
|
||||||
"modifier_category_id",
|
Uuid,
|
||||||
UUID(as_uuid=True),
|
|
||||||
ForeignKey("modifier_categories.id"),
|
ForeignKey("modifier_categories.id"),
|
||||||
nullable=False,
|
nullable=False,
|
||||||
)
|
)
|
||||||
@@ -2,8 +2,7 @@ import uuid
|
|||||||
|
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from sqlalchemy import ForeignKey, Unicode, text
|
from sqlalchemy import ForeignKey, Text, Uuid, text
|
||||||
from sqlalchemy.dialects.postgresql import UUID
|
|
||||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||||
|
|
||||||
from ..db.base_class import reg
|
from ..db.base_class import reg
|
||||||
@@ -18,27 +17,21 @@ if TYPE_CHECKING:
|
|||||||
@reg.mapped_as_dataclass(unsafe_hash=True)
|
@reg.mapped_as_dataclass(unsafe_hash=True)
|
||||||
class Overview:
|
class Overview:
|
||||||
__tablename__ = "overview"
|
__tablename__ = "overview"
|
||||||
id: Mapped[uuid.UUID] = mapped_column(
|
id: Mapped[uuid.UUID] = mapped_column(Uuid, primary_key=True, server_default=text("gen_random_uuid()"))
|
||||||
"id", UUID(as_uuid=True), primary_key=True, server_default=text("gen_random_uuid()"), insert_default=uuid.uuid4
|
|
||||||
)
|
|
||||||
voucher_id: Mapped[uuid.UUID] = mapped_column(
|
voucher_id: Mapped[uuid.UUID] = mapped_column(
|
||||||
"voucher_id",
|
Uuid,
|
||||||
UUID(as_uuid=True),
|
|
||||||
ForeignKey("vouchers.id"),
|
ForeignKey("vouchers.id"),
|
||||||
nullable=False,
|
nullable=False,
|
||||||
unique=True,
|
unique=True,
|
||||||
)
|
)
|
||||||
food_table_id: Mapped[uuid.UUID] = mapped_column(
|
food_table_id: Mapped[uuid.UUID] = mapped_column(
|
||||||
"food_table_id",
|
Uuid,
|
||||||
UUID(as_uuid=True),
|
|
||||||
ForeignKey("food_tables.id"),
|
ForeignKey("food_tables.id"),
|
||||||
nullable=False,
|
nullable=False,
|
||||||
unique=True,
|
unique=True,
|
||||||
)
|
)
|
||||||
guest_book_id: Mapped[uuid.UUID] = mapped_column(
|
guest_book_id: Mapped[uuid.UUID] = mapped_column(Uuid, ForeignKey("guest_book.id"), unique=True, nullable=True)
|
||||||
"guest_book_id", UUID(as_uuid=True), ForeignKey("guest_book.id"), unique=True, nullable=True
|
status: Mapped[str] = mapped_column(Text, nullable=False)
|
||||||
)
|
|
||||||
status: Mapped[str] = mapped_column("status", Unicode(255), nullable=False)
|
|
||||||
|
|
||||||
voucher: Mapped["Voucher"] = relationship(back_populates="status")
|
voucher: Mapped["Voucher"] = relationship(back_populates="status")
|
||||||
food_table: Mapped["FoodTable"] = relationship(back_populates="status")
|
food_table: Mapped["FoodTable"] = relationship(back_populates="status")
|
||||||
|
|||||||
@@ -2,8 +2,7 @@ import uuid
|
|||||||
|
|
||||||
from typing import TYPE_CHECKING, List
|
from typing import TYPE_CHECKING, List
|
||||||
|
|
||||||
from sqlalchemy import Unicode, text
|
from sqlalchemy import Text, Uuid, text
|
||||||
from sqlalchemy.dialects.postgresql import UUID
|
|
||||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||||
|
|
||||||
from ..db.base_class import reg
|
from ..db.base_class import reg
|
||||||
@@ -18,10 +17,8 @@ if TYPE_CHECKING:
|
|||||||
class Permission:
|
class Permission:
|
||||||
__tablename__ = "permissions"
|
__tablename__ = "permissions"
|
||||||
|
|
||||||
id: Mapped[uuid.UUID] = mapped_column(
|
id: Mapped[uuid.UUID] = mapped_column(Uuid, primary_key=True, server_default=text("gen_random_uuid()"))
|
||||||
"id", UUID(as_uuid=True), primary_key=True, server_default=text("gen_random_uuid()"), insert_default=uuid.uuid4
|
name: Mapped[str] = mapped_column(Text, unique=True, nullable=False)
|
||||||
)
|
|
||||||
name: Mapped[str] = mapped_column("name", Unicode(255), unique=True, nullable=False)
|
|
||||||
|
|
||||||
roles: Mapped[List["Role"]] = relationship(
|
roles: Mapped[List["Role"]] = relationship(
|
||||||
secondary=RolePermission.__table__, back_populates="permissions" # type: ignore[attr-defined]
|
secondary=RolePermission.__table__, back_populates="permissions" # type: ignore[attr-defined]
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from sqlalchemy import Unicode, text
|
from sqlalchemy import Text, Uuid, text
|
||||||
from sqlalchemy.dialects.postgresql import UUID
|
|
||||||
from sqlalchemy.orm import Mapped, mapped_column
|
from sqlalchemy.orm import Mapped, mapped_column
|
||||||
|
|
||||||
from ..db.base_class import reg
|
from ..db.base_class import reg
|
||||||
@@ -11,12 +10,10 @@ from ..db.base_class import reg
|
|||||||
class Printer:
|
class Printer:
|
||||||
__tablename__ = "printers"
|
__tablename__ = "printers"
|
||||||
|
|
||||||
id: Mapped[uuid.UUID] = mapped_column(
|
id: Mapped[uuid.UUID] = mapped_column(Uuid, primary_key=True, server_default=text("gen_random_uuid()"))
|
||||||
"id", UUID(as_uuid=True), primary_key=True, server_default=text("gen_random_uuid()"), insert_default=uuid.uuid4
|
name: Mapped[str] = mapped_column(Text, unique=True, nullable=False)
|
||||||
)
|
address: Mapped[str] = mapped_column(Text, nullable=False)
|
||||||
name: Mapped[str] = mapped_column("name", Unicode(255), unique=True, nullable=False)
|
cut_code: Mapped[str] = mapped_column(Text, nullable=False)
|
||||||
address: Mapped[str] = mapped_column("address", Unicode(255), nullable=False)
|
|
||||||
cut_code: Mapped[str] = mapped_column("cut_code", Unicode(255), nullable=False)
|
|
||||||
|
|
||||||
def __init__(self, name=None, address=None, cut_code=None, id_=None):
|
def __init__(self, name=None, address=None, cut_code=None, id_=None):
|
||||||
self.id = id_
|
self.id = id_
|
||||||
|
|||||||
@@ -3,8 +3,7 @@ import uuid
|
|||||||
from typing import TYPE_CHECKING, List
|
from typing import TYPE_CHECKING, List
|
||||||
|
|
||||||
from barker.models.modifier_category_product import ModifierCategoryProduct
|
from barker.models.modifier_category_product import ModifierCategoryProduct
|
||||||
from sqlalchemy import text
|
from sqlalchemy import Uuid, text
|
||||||
from sqlalchemy.dialects.postgresql import UUID
|
|
||||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||||
|
|
||||||
from ..db.base_class import reg
|
from ..db.base_class import reg
|
||||||
@@ -19,9 +18,7 @@ if TYPE_CHECKING:
|
|||||||
@reg.mapped_as_dataclass(unsafe_hash=True)
|
@reg.mapped_as_dataclass(unsafe_hash=True)
|
||||||
class Product:
|
class Product:
|
||||||
__tablename__ = "products"
|
__tablename__ = "products"
|
||||||
id: Mapped[uuid.UUID] = mapped_column(
|
id: Mapped[uuid.UUID] = mapped_column(Uuid, primary_key=True, server_default=text("gen_random_uuid()"))
|
||||||
"id", UUID(as_uuid=True), primary_key=True, server_default=text("gen_random_uuid()"), insert_default=uuid.uuid4
|
|
||||||
)
|
|
||||||
versions: Mapped[List["ProductVersion"]] = relationship(back_populates="product")
|
versions: Mapped[List["ProductVersion"]] = relationship(back_populates="product")
|
||||||
inventories: Mapped[List["Inventory"]] = relationship(back_populates="product")
|
inventories: Mapped[List["Inventory"]] = relationship(back_populates="product")
|
||||||
modifier_categories: Mapped[List["ModifierCategory"]] = relationship(
|
modifier_categories: Mapped[List["ModifierCategory"]] = relationship(
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import uuid
|
|||||||
|
|
||||||
from datetime import date
|
from datetime import date
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
from typing import TYPE_CHECKING, Optional
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from barker.models.product import Product
|
from barker.models.product import Product
|
||||||
from sqlalchemy import (
|
from sqlalchemy import (
|
||||||
@@ -11,13 +11,13 @@ from sqlalchemy import (
|
|||||||
ForeignKey,
|
ForeignKey,
|
||||||
Integer,
|
Integer,
|
||||||
Numeric,
|
Numeric,
|
||||||
Unicode,
|
Text,
|
||||||
|
Uuid,
|
||||||
case,
|
case,
|
||||||
func,
|
func,
|
||||||
text,
|
text,
|
||||||
)
|
)
|
||||||
from sqlalchemy.dialects import postgresql
|
from sqlalchemy.dialects import postgresql
|
||||||
from sqlalchemy.dialects.postgresql import UUID
|
|
||||||
from sqlalchemy.ext.hybrid import hybrid_property
|
from sqlalchemy.ext.hybrid import hybrid_property
|
||||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||||
|
|
||||||
@@ -32,34 +32,28 @@ if TYPE_CHECKING:
|
|||||||
@reg.mapped_as_dataclass(unsafe_hash=True)
|
@reg.mapped_as_dataclass(unsafe_hash=True)
|
||||||
class ProductVersion:
|
class ProductVersion:
|
||||||
__tablename__ = "product_versions"
|
__tablename__ = "product_versions"
|
||||||
id: Mapped[uuid.UUID] = mapped_column(
|
id: Mapped[uuid.UUID] = mapped_column(Uuid, primary_key=True, server_default=text("gen_random_uuid()"))
|
||||||
"id", UUID(as_uuid=True), primary_key=True, server_default=text("gen_random_uuid()"), insert_default=uuid.uuid4
|
product_id: Mapped[uuid.UUID] = mapped_column(Uuid, ForeignKey("products.id"), nullable=False)
|
||||||
)
|
name: Mapped[str] = mapped_column(Text, nullable=False)
|
||||||
product_id: Mapped[uuid.UUID] = mapped_column(
|
units: Mapped[str] = mapped_column(Text, nullable=False)
|
||||||
"product_id", UUID(as_uuid=True), ForeignKey("products.id"), nullable=False
|
|
||||||
)
|
|
||||||
name: Mapped[str] = mapped_column("name", Unicode(255), nullable=False)
|
|
||||||
units: Mapped[str] = mapped_column("units", Unicode(255), nullable=False)
|
|
||||||
menu_category_id: Mapped[uuid.UUID] = mapped_column(
|
menu_category_id: Mapped[uuid.UUID] = mapped_column(
|
||||||
"menu_category_id",
|
Uuid,
|
||||||
UUID(as_uuid=True),
|
|
||||||
ForeignKey("menu_categories.id"),
|
ForeignKey("menu_categories.id"),
|
||||||
nullable=False,
|
nullable=False,
|
||||||
)
|
)
|
||||||
sale_category_id: Mapped[uuid.UUID] = mapped_column(
|
sale_category_id: Mapped[uuid.UUID] = mapped_column(
|
||||||
"sale_category_id",
|
Uuid,
|
||||||
UUID(as_uuid=True),
|
|
||||||
ForeignKey("sale_categories.id"),
|
ForeignKey("sale_categories.id"),
|
||||||
nullable=False,
|
nullable=False,
|
||||||
)
|
)
|
||||||
price: Mapped[Decimal] = mapped_column("price", Numeric(precision=15, scale=2), nullable=False)
|
price: Mapped[Decimal] = mapped_column(Numeric(precision=15, scale=2), nullable=False)
|
||||||
has_happy_hour: Mapped[bool] = mapped_column("has_happy_hour", Boolean, nullable=False)
|
has_happy_hour: Mapped[bool] = mapped_column(Boolean, nullable=False)
|
||||||
is_not_available: Mapped[bool] = mapped_column("is_not_available", Boolean, nullable=False)
|
is_not_available: Mapped[bool] = mapped_column(Boolean, nullable=False)
|
||||||
quantity: Mapped[Decimal] = mapped_column("quantity", Numeric(precision=15, scale=2), nullable=False)
|
quantity: Mapped[Decimal] = mapped_column(Numeric(precision=15, scale=2), nullable=False)
|
||||||
sort_order: Mapped[int] = mapped_column("sort_order", Integer, nullable=False)
|
sort_order: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||||
|
|
||||||
valid_from: Mapped[Optional[date]] = mapped_column("valid_from", Date(), nullable=True)
|
valid_from: Mapped[date | None] = mapped_column(Date(), nullable=True)
|
||||||
valid_till: Mapped[Optional[date]] = mapped_column("valid_till", Date(), nullable=True)
|
valid_till: Mapped[date | None] = mapped_column(Date(), nullable=True)
|
||||||
|
|
||||||
menu_category: Mapped["MenuCategory"] = relationship(back_populates="products")
|
menu_category: Mapped["MenuCategory"] = relationship(back_populates="products")
|
||||||
sale_category: Mapped["SaleCategory"] = relationship(back_populates="products")
|
sale_category: Mapped["SaleCategory"] = relationship(back_populates="products")
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
from typing import TYPE_CHECKING, List
|
from typing import TYPE_CHECKING, List
|
||||||
|
|
||||||
from sqlalchemy import Boolean, Integer, Unicode
|
from sqlalchemy import Boolean, Integer, Text
|
||||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||||
|
|
||||||
from ..db.base_class import reg
|
from ..db.base_class import reg
|
||||||
@@ -15,11 +15,11 @@ if TYPE_CHECKING:
|
|||||||
class Regime:
|
class Regime:
|
||||||
__tablename__ = "regimes"
|
__tablename__ = "regimes"
|
||||||
|
|
||||||
id: Mapped[int] = mapped_column("id", Integer, primary_key=True)
|
id: Mapped[int] = mapped_column(Integer, primary_key=True)
|
||||||
name: Mapped[str] = mapped_column("name", Unicode(255), nullable=False, unique=True)
|
name: Mapped[str] = mapped_column(Text, nullable=False, unique=True)
|
||||||
header: Mapped[str] = mapped_column("header", Unicode(255), nullable=False)
|
header: Mapped[str] = mapped_column(Text, nullable=False)
|
||||||
prefix: Mapped[str] = mapped_column("prefix", Unicode(255), nullable=False, unique=True)
|
prefix: Mapped[str] = mapped_column(Text, nullable=False, unique=True)
|
||||||
is_fixture: Mapped[bool] = mapped_column("is_fixture", Boolean, nullable=False)
|
is_fixture: Mapped[bool] = mapped_column(Boolean, nullable=False)
|
||||||
|
|
||||||
taxes: Mapped[List["Tax"]] = relationship(back_populates="regime")
|
taxes: Mapped[List["Tax"]] = relationship(back_populates="regime")
|
||||||
bills: Mapped[List["Bill"]] = relationship(back_populates="regime")
|
bills: Mapped[List["Bill"]] = relationship(back_populates="regime")
|
||||||
|
|||||||
@@ -3,8 +3,7 @@ import uuid
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from sqlalchemy import DateTime, ForeignKey, text
|
from sqlalchemy import DateTime, ForeignKey, Uuid, text
|
||||||
from sqlalchemy.dialects.postgresql import UUID
|
|
||||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||||
|
|
||||||
from ..db.base_class import reg
|
from ..db.base_class import reg
|
||||||
@@ -19,18 +18,15 @@ if TYPE_CHECKING:
|
|||||||
class Reprint:
|
class Reprint:
|
||||||
__tablename__ = "reprints"
|
__tablename__ = "reprints"
|
||||||
|
|
||||||
id: Mapped[uuid.UUID] = mapped_column(
|
id: Mapped[uuid.UUID] = mapped_column(Uuid, primary_key=True, server_default=text("gen_random_uuid()"))
|
||||||
"id", UUID(as_uuid=True), primary_key=True, server_default=text("gen_random_uuid()"), insert_default=uuid.uuid4
|
date: Mapped[datetime] = mapped_column(DateTime, nullable=False, index=True)
|
||||||
)
|
|
||||||
date: Mapped[datetime] = mapped_column("date", DateTime, nullable=False, index=True)
|
|
||||||
voucher_id: Mapped[uuid.UUID] = mapped_column(
|
voucher_id: Mapped[uuid.UUID] = mapped_column(
|
||||||
"voucher_id",
|
Uuid,
|
||||||
UUID(as_uuid=True),
|
|
||||||
ForeignKey("vouchers.id"),
|
ForeignKey("vouchers.id"),
|
||||||
nullable=False,
|
nullable=False,
|
||||||
index=True,
|
index=True,
|
||||||
)
|
)
|
||||||
user_id: Mapped[uuid.UUID] = mapped_column("user_id", UUID(as_uuid=True), ForeignKey("users.id"), nullable=False)
|
user_id: Mapped[uuid.UUID] = mapped_column(Uuid, ForeignKey("users.id"), nullable=False)
|
||||||
|
|
||||||
user: Mapped["User"] = relationship(backref="reprints")
|
user: Mapped["User"] = relationship(backref="reprints")
|
||||||
voucher: Mapped["Voucher"] = relationship(back_populates="reprints")
|
voucher: Mapped["Voucher"] = relationship(back_populates="reprints")
|
||||||
|
|||||||
@@ -3,8 +3,7 @@ import uuid
|
|||||||
from typing import TYPE_CHECKING, List
|
from typing import TYPE_CHECKING, List
|
||||||
|
|
||||||
from barker.models.role_permission import RolePermission
|
from barker.models.role_permission import RolePermission
|
||||||
from sqlalchemy import Unicode, text
|
from sqlalchemy import Text, Uuid, text
|
||||||
from sqlalchemy.dialects.postgresql import UUID
|
|
||||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||||
|
|
||||||
from ..db.base_class import reg
|
from ..db.base_class import reg
|
||||||
@@ -18,10 +17,8 @@ if TYPE_CHECKING:
|
|||||||
class Role:
|
class Role:
|
||||||
__tablename__ = "roles"
|
__tablename__ = "roles"
|
||||||
|
|
||||||
id: Mapped[uuid.UUID] = mapped_column(
|
id: Mapped[uuid.UUID] = mapped_column(Uuid, primary_key=True, server_default=text("gen_random_uuid()"))
|
||||||
"id", UUID(as_uuid=True), primary_key=True, server_default=text("gen_random_uuid()"), insert_default=uuid.uuid4
|
name: Mapped[str] = mapped_column(Text, unique=True, nullable=False)
|
||||||
)
|
|
||||||
name: Mapped[str] = mapped_column("name", Unicode(255), unique=True, nullable=False)
|
|
||||||
|
|
||||||
permissions: Mapped[List["Permission"]] = relationship(
|
permissions: Mapped[List["Permission"]] = relationship(
|
||||||
"Permission", secondary=RolePermission.__table__, back_populates="roles" # type: ignore[attr-defined]
|
"Permission", secondary=RolePermission.__table__, back_populates="roles" # type: ignore[attr-defined]
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from sqlalchemy import ForeignKey, UniqueConstraint, text
|
from sqlalchemy import ForeignKey, UniqueConstraint, Uuid, text
|
||||||
from sqlalchemy.dialects.postgresql import UUID
|
|
||||||
from sqlalchemy.orm import Mapped, mapped_column
|
from sqlalchemy.orm import Mapped, mapped_column
|
||||||
|
|
||||||
from ..db.base_class import reg
|
from ..db.base_class import reg
|
||||||
@@ -11,13 +10,10 @@ from ..db.base_class import reg
|
|||||||
class RolePermission:
|
class RolePermission:
|
||||||
__tablename__ = "role_permissions"
|
__tablename__ = "role_permissions"
|
||||||
__table_args__ = (UniqueConstraint("permission_id", "role_id"),)
|
__table_args__ = (UniqueConstraint("permission_id", "role_id"),)
|
||||||
id: Mapped[uuid.UUID] = mapped_column(
|
id: Mapped[uuid.UUID] = mapped_column(Uuid, primary_key=True, server_default=text("gen_random_uuid()"))
|
||||||
"id", UUID(as_uuid=True), primary_key=True, server_default=text("gen_random_uuid()"), insert_default=uuid.uuid4
|
|
||||||
)
|
|
||||||
permission_id: Mapped[uuid.UUID] = mapped_column(
|
permission_id: Mapped[uuid.UUID] = mapped_column(
|
||||||
"permission_id",
|
Uuid,
|
||||||
UUID(as_uuid=True),
|
|
||||||
ForeignKey("permissions.id"),
|
ForeignKey("permissions.id"),
|
||||||
nullable=False,
|
nullable=False,
|
||||||
)
|
)
|
||||||
role_id: Mapped[uuid.UUID] = mapped_column("role_id", UUID(as_uuid=True), ForeignKey("roles.id"), nullable=False)
|
role_id: Mapped[uuid.UUID] = mapped_column(Uuid, ForeignKey("roles.id"), nullable=False)
|
||||||
@@ -3,8 +3,7 @@ import uuid
|
|||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
from typing import TYPE_CHECKING, List
|
from typing import TYPE_CHECKING, List
|
||||||
|
|
||||||
from sqlalchemy import ForeignKey, Numeric, Unicode, text
|
from sqlalchemy import ForeignKey, Numeric, Text, Uuid, text
|
||||||
from sqlalchemy.dialects.postgresql import UUID
|
|
||||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||||
|
|
||||||
from ..db.base_class import reg
|
from ..db.base_class import reg
|
||||||
@@ -19,12 +18,10 @@ if TYPE_CHECKING:
|
|||||||
class SaleCategory:
|
class SaleCategory:
|
||||||
__tablename__ = "sale_categories"
|
__tablename__ = "sale_categories"
|
||||||
|
|
||||||
id: Mapped[uuid.UUID] = mapped_column(
|
id: Mapped[uuid.UUID] = mapped_column(Uuid, primary_key=True, server_default=text("gen_random_uuid()"))
|
||||||
"id", UUID(as_uuid=True), primary_key=True, server_default=text("gen_random_uuid()"), insert_default=uuid.uuid4
|
name: Mapped[str] = mapped_column(Text, nullable=False, unique=True)
|
||||||
)
|
discount_limit: Mapped[Decimal] = mapped_column(Numeric(precision=15, scale=5), nullable=False)
|
||||||
name: Mapped[str] = mapped_column("name", Unicode(255), nullable=False, unique=True)
|
tax_id: Mapped[uuid.UUID] = mapped_column(Uuid, ForeignKey("taxes.id"), nullable=False)
|
||||||
discount_limit: Mapped[Decimal] = mapped_column("discount_limit", Numeric(precision=15, scale=5), nullable=False)
|
|
||||||
tax_id: Mapped[uuid.UUID] = mapped_column("tax_id", UUID(as_uuid=True), ForeignKey("taxes.id"), nullable=False)
|
|
||||||
|
|
||||||
tax: Mapped["Tax"] = relationship(back_populates="sale_categories")
|
tax: Mapped["Tax"] = relationship(back_populates="sale_categories")
|
||||||
products: Mapped[List["ProductVersion"]] = relationship(back_populates="sale_category")
|
products: Mapped[List["ProductVersion"]] = relationship(back_populates="sale_category")
|
||||||
|
|||||||
@@ -2,8 +2,7 @@ import uuid
|
|||||||
|
|
||||||
from typing import TYPE_CHECKING, List
|
from typing import TYPE_CHECKING, List
|
||||||
|
|
||||||
from sqlalchemy import Boolean, Unicode, text
|
from sqlalchemy import Boolean, Text, Uuid, text
|
||||||
from sqlalchemy.dialects.postgresql import UUID
|
|
||||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||||
|
|
||||||
from ..db.base_class import reg
|
from ..db.base_class import reg
|
||||||
@@ -17,11 +16,9 @@ if TYPE_CHECKING:
|
|||||||
class Section:
|
class Section:
|
||||||
__tablename__ = "sections"
|
__tablename__ = "sections"
|
||||||
|
|
||||||
id: Mapped[uuid.UUID] = mapped_column(
|
id: Mapped[uuid.UUID] = mapped_column(Uuid, primary_key=True, server_default=text("gen_random_uuid()"))
|
||||||
"id", UUID(as_uuid=True), primary_key=True, server_default=text("gen_random_uuid()"), insert_default=uuid.uuid4
|
name: Mapped[str] = mapped_column(Text, unique=True, nullable=False)
|
||||||
)
|
is_fixture: Mapped[bool] = mapped_column(Boolean, nullable=False, insert_default=False)
|
||||||
name: Mapped[str] = mapped_column("name", Unicode(255), unique=True, nullable=False)
|
|
||||||
is_fixture: Mapped[bool] = mapped_column("is_fixture", Boolean, nullable=False, insert_default=False)
|
|
||||||
|
|
||||||
devices: Mapped[List["Device"]] = relationship(back_populates="section")
|
devices: Mapped[List["Device"]] = relationship(back_populates="section")
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,7 @@ import uuid
|
|||||||
|
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from sqlalchemy import ForeignKey, Integer, UniqueConstraint, text
|
from sqlalchemy import ForeignKey, Integer, UniqueConstraint, Uuid, text
|
||||||
from sqlalchemy.dialects.postgresql import UUID
|
|
||||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||||
|
|
||||||
from ..db.base_class import reg
|
from ..db.base_class import reg
|
||||||
@@ -20,19 +19,11 @@ class SectionPrinter:
|
|||||||
__tablename__ = "section_printers"
|
__tablename__ = "section_printers"
|
||||||
__table_args__ = (UniqueConstraint("sale_category_id", "section_id"),)
|
__table_args__ = (UniqueConstraint("sale_category_id", "section_id"),)
|
||||||
|
|
||||||
id: Mapped[uuid.UUID] = mapped_column(
|
id: Mapped[uuid.UUID] = mapped_column(Uuid, primary_key=True, server_default=text("gen_random_uuid()"))
|
||||||
"id", UUID(as_uuid=True), primary_key=True, server_default=text("gen_random_uuid()"), insert_default=uuid.uuid4
|
sale_category_id: Mapped[uuid.UUID] = mapped_column(Uuid, ForeignKey("sale_categories.id"), nullable=True)
|
||||||
)
|
section_id: Mapped[uuid.UUID] = mapped_column(Uuid, ForeignKey("sections.id"), nullable=False)
|
||||||
sale_category_id: Mapped[uuid.UUID] = mapped_column(
|
printer_id: Mapped[uuid.UUID] = mapped_column(Uuid, ForeignKey("printers.id"), nullable=False)
|
||||||
"sale_category_id", UUID(as_uuid=True), ForeignKey("sale_categories.id"), nullable=True
|
copies: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||||
)
|
|
||||||
section_id: Mapped[uuid.UUID] = mapped_column(
|
|
||||||
"section_id", UUID(as_uuid=True), ForeignKey("sections.id"), nullable=False
|
|
||||||
)
|
|
||||||
printer_id: Mapped[uuid.UUID] = mapped_column(
|
|
||||||
"printer_id", UUID(as_uuid=True), ForeignKey("printers.id"), nullable=False
|
|
||||||
)
|
|
||||||
copies: Mapped[int] = mapped_column("copies", Integer, nullable=False)
|
|
||||||
|
|
||||||
sale_category: Mapped["SaleCategory"] = relationship(backref="section_printers")
|
sale_category: Mapped["SaleCategory"] = relationship(backref="section_printers")
|
||||||
section: Mapped["Section"] = relationship(backref="section_printers")
|
section: Mapped["Section"] = relationship(backref="section_printers")
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
from barker.models.reporting_level import ReportingLevel
|
from barker.models.reporting_level import ReportingLevel
|
||||||
from barker.models.voucher_type import VoucherType
|
from barker.models.voucher_type import VoucherType
|
||||||
from sqlalchemy import Boolean, Enum, Integer, Unicode
|
from sqlalchemy import Boolean, Enum, Integer, Text
|
||||||
from sqlalchemy.orm import Mapped, mapped_column
|
from sqlalchemy.orm import Mapped, mapped_column
|
||||||
from sqlalchemy.sql import expression
|
from sqlalchemy.sql import expression
|
||||||
|
|
||||||
@@ -11,16 +11,12 @@ from ..db.base_class import reg
|
|||||||
class SettleOption:
|
class SettleOption:
|
||||||
__tablename__ = "settle_options"
|
__tablename__ = "settle_options"
|
||||||
|
|
||||||
id: Mapped[int] = mapped_column("id", Integer, primary_key=True)
|
id: Mapped[int] = mapped_column(Integer, primary_key=True)
|
||||||
name: Mapped[str] = mapped_column("name", Unicode(255), unique=True, nullable=False)
|
name: Mapped[str] = mapped_column(Text, unique=True, nullable=False)
|
||||||
voucher_type: Mapped[VoucherType] = mapped_column("voucher_type", Enum(VoucherType), nullable=False)
|
voucher_type: Mapped[VoucherType] = mapped_column(Enum(VoucherType), nullable=False)
|
||||||
reporting_level: Mapped[ReportingLevel] = mapped_column("reporting_level", Enum(ReportingLevel), nullable=False)
|
reporting_level: Mapped[ReportingLevel] = mapped_column(Enum(ReportingLevel), nullable=False)
|
||||||
has_reason: Mapped[bool] = mapped_column(
|
has_reason: Mapped[bool] = mapped_column(Boolean, nullable=False, server_default=expression.false())
|
||||||
"has_reason", Boolean, nullable=False, server_default=expression.false(), insert_default=False
|
is_fixture: Mapped[bool] = mapped_column(Boolean, nullable=False, server_default=expression.false())
|
||||||
)
|
|
||||||
is_fixture: Mapped[bool] = mapped_column(
|
|
||||||
"is_fixture", Boolean, nullable=False, server_default=expression.false(), insert_default=False
|
|
||||||
)
|
|
||||||
|
|
||||||
def __init__(self, name=None, voucher_type=None, reporting_level=None, has_reason=None, is_fixture=None, id_=None):
|
def __init__(self, name=None, voucher_type=None, reporting_level=None, has_reason=None, is_fixture=None, id_=None):
|
||||||
self.id = id_
|
self.id = id_
|
||||||
|
|||||||
@@ -3,8 +3,7 @@ import uuid
|
|||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from sqlalchemy import ForeignKey, Integer, Numeric, UniqueConstraint, text
|
from sqlalchemy import ForeignKey, Integer, Numeric, UniqueConstraint, Uuid, text
|
||||||
from sqlalchemy.dialects.postgresql import UUID
|
|
||||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||||
|
|
||||||
from ..db.base_class import reg
|
from ..db.base_class import reg
|
||||||
@@ -20,18 +19,15 @@ class Settlement:
|
|||||||
__tablename__ = "settlements"
|
__tablename__ = "settlements"
|
||||||
__table_args__ = (UniqueConstraint("voucher_id", "settled"),)
|
__table_args__ = (UniqueConstraint("voucher_id", "settled"),)
|
||||||
|
|
||||||
id: Mapped[uuid.UUID] = mapped_column(
|
id: Mapped[uuid.UUID] = mapped_column(Uuid, primary_key=True, server_default=text("gen_random_uuid()"))
|
||||||
"id", UUID(as_uuid=True), primary_key=True, server_default=text("gen_random_uuid()"), insert_default=uuid.uuid4
|
|
||||||
)
|
|
||||||
voucher_id: Mapped[uuid.UUID] = mapped_column(
|
voucher_id: Mapped[uuid.UUID] = mapped_column(
|
||||||
"voucher_id",
|
Uuid,
|
||||||
UUID(as_uuid=True),
|
|
||||||
ForeignKey("vouchers.id"),
|
ForeignKey("vouchers.id"),
|
||||||
nullable=False,
|
nullable=False,
|
||||||
index=True,
|
index=True,
|
||||||
)
|
)
|
||||||
settled: Mapped[int] = mapped_column("settled", Integer, ForeignKey("settle_options.id"), nullable=False)
|
settled: Mapped[int] = mapped_column(Integer, ForeignKey("settle_options.id"), nullable=False)
|
||||||
amount: Mapped[Decimal] = mapped_column("amount", Numeric(precision=15, scale=2), nullable=False)
|
amount: Mapped[Decimal] = mapped_column(Numeric(precision=15, scale=2), nullable=False)
|
||||||
|
|
||||||
settle_option: Mapped["SettleOption"] = relationship("SettleOption")
|
settle_option: Mapped["SettleOption"] = relationship("SettleOption")
|
||||||
voucher: Mapped["Voucher"] = relationship(back_populates="settlements")
|
voucher: Mapped["Voucher"] = relationship(back_populates="settlements")
|
||||||
|
|||||||
@@ -3,8 +3,7 @@ import uuid
|
|||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
from typing import TYPE_CHECKING, List
|
from typing import TYPE_CHECKING, List
|
||||||
|
|
||||||
from sqlalchemy import Boolean, ForeignKey, Integer, Numeric, Unicode, text
|
from sqlalchemy import Boolean, ForeignKey, Integer, Numeric, Text, Uuid, text
|
||||||
from sqlalchemy.dialects.postgresql import UUID
|
|
||||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||||
|
|
||||||
from ..db.base_class import reg
|
from ..db.base_class import reg
|
||||||
@@ -20,13 +19,11 @@ if TYPE_CHECKING:
|
|||||||
class Tax:
|
class Tax:
|
||||||
__tablename__ = "taxes"
|
__tablename__ = "taxes"
|
||||||
|
|
||||||
id: Mapped[uuid.UUID] = mapped_column(
|
id: Mapped[uuid.UUID] = mapped_column(Uuid, primary_key=True, server_default=text("gen_random_uuid()"))
|
||||||
"id", UUID(as_uuid=True), primary_key=True, server_default=text("gen_random_uuid()"), insert_default=uuid.uuid4
|
name: Mapped[str] = mapped_column(Text, nullable=False, unique=True)
|
||||||
)
|
rate: Mapped[Decimal] = mapped_column(Numeric(precision=15, scale=5), nullable=False)
|
||||||
name: Mapped[str] = mapped_column("name", Unicode(255), nullable=False, unique=True)
|
regime_id: Mapped[int] = mapped_column(Integer, ForeignKey("regimes.id"), nullable=False)
|
||||||
rate: Mapped[Decimal] = mapped_column("rate", Numeric(precision=15, scale=5), nullable=False)
|
is_fixture: Mapped[bool] = mapped_column(Boolean, nullable=False)
|
||||||
regime_id: Mapped[int] = mapped_column("regime_id", Integer, ForeignKey("regimes.id"), nullable=False)
|
|
||||||
is_fixture: Mapped[bool] = mapped_column("is_fixture", Boolean, nullable=False)
|
|
||||||
|
|
||||||
sale_categories: Mapped[List["SaleCategory"]] = relationship(back_populates="tax")
|
sale_categories: Mapped[List["SaleCategory"]] = relationship(back_populates="tax")
|
||||||
inventories: Mapped[List["Inventory"]] = relationship(back_populates="tax")
|
inventories: Mapped[List["Inventory"]] = relationship(back_populates="tax")
|
||||||
|
|||||||
@@ -5,8 +5,7 @@ from typing import TYPE_CHECKING, List
|
|||||||
|
|
||||||
from barker.models.login_history import LoginHistory
|
from barker.models.login_history import LoginHistory
|
||||||
from barker.models.user_role import UserRole
|
from barker.models.user_role import UserRole
|
||||||
from sqlalchemy import Boolean, Index, Unicode, desc, func, select, text
|
from sqlalchemy import Boolean, Index, Text, Uuid, desc, func, select, text
|
||||||
from sqlalchemy.dialects.postgresql import UUID
|
|
||||||
from sqlalchemy.ext.hybrid import hybrid_property
|
from sqlalchemy.ext.hybrid import hybrid_property
|
||||||
from sqlalchemy.orm import Mapped, Session, mapped_column, relationship
|
from sqlalchemy.orm import Mapped, Session, mapped_column, relationship
|
||||||
|
|
||||||
@@ -20,12 +19,10 @@ if TYPE_CHECKING:
|
|||||||
@reg.mapped_as_dataclass(unsafe_hash=True)
|
@reg.mapped_as_dataclass(unsafe_hash=True)
|
||||||
class User:
|
class User:
|
||||||
__tablename__ = "users"
|
__tablename__ = "users"
|
||||||
id: Mapped[uuid.UUID] = mapped_column(
|
id: Mapped[uuid.UUID] = mapped_column(Uuid, primary_key=True, server_default=text("gen_random_uuid()"))
|
||||||
"id", UUID(as_uuid=True), primary_key=True, server_default=text("gen_random_uuid()"), insert_default=uuid.uuid4
|
name: Mapped[str] = mapped_column(Text, nullable=False)
|
||||||
)
|
_password: Mapped[str] = mapped_column("password", Text, nullable=False)
|
||||||
name: Mapped[str] = mapped_column("name", Unicode(255), nullable=False)
|
locked_out: Mapped[bool] = mapped_column(Boolean, nullable=False)
|
||||||
_password: Mapped[str] = mapped_column("password", Unicode(60), nullable=False)
|
|
||||||
locked_out: Mapped[bool] = mapped_column("locked_out", Boolean, nullable=False)
|
|
||||||
|
|
||||||
roles: Mapped[List["Role"]] = relationship(
|
roles: Mapped[List["Role"]] = relationship(
|
||||||
"Role", secondary=UserRole.__table__, order_by="Role.name" # type: ignore[attr-defined]
|
"Role", secondary=UserRole.__table__, order_by="Role.name" # type: ignore[attr-defined]
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from sqlalchemy import ForeignKey, UniqueConstraint, text
|
from sqlalchemy import ForeignKey, UniqueConstraint, Uuid, text
|
||||||
from sqlalchemy.dialects.postgresql import UUID
|
|
||||||
from sqlalchemy.orm import Mapped, mapped_column
|
from sqlalchemy.orm import Mapped, mapped_column
|
||||||
|
|
||||||
from ..db.base_class import reg
|
from ..db.base_class import reg
|
||||||
@@ -12,8 +11,6 @@ class UserRole:
|
|||||||
__tablename__ = "user_roles"
|
__tablename__ = "user_roles"
|
||||||
__table_args__ = (UniqueConstraint("user_id", "role_id"),)
|
__table_args__ = (UniqueConstraint("user_id", "role_id"),)
|
||||||
|
|
||||||
id: Mapped[uuid.UUID] = mapped_column(
|
id: Mapped[uuid.UUID] = mapped_column(Uuid, primary_key=True, server_default=text("gen_random_uuid()"))
|
||||||
"id", UUID(as_uuid=True), primary_key=True, server_default=text("gen_random_uuid()"), insert_default=uuid.uuid4
|
user_id: Mapped[uuid.UUID] = mapped_column(Uuid, ForeignKey("users.id"), nullable=False)
|
||||||
)
|
role_id: Mapped[uuid.UUID] = mapped_column(Uuid, ForeignKey("roles.id"), nullable=False)
|
||||||
user_id: Mapped[uuid.UUID] = mapped_column("user_id", UUID(as_uuid=True), ForeignKey("users.id"), nullable=False)
|
|
||||||
role_id: Mapped[uuid.UUID] = mapped_column("role_id", UUID(as_uuid=True), ForeignKey("roles.id"), nullable=False)
|
|
||||||
@@ -1,10 +1,9 @@
|
|||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from typing import TYPE_CHECKING, List, Optional
|
from typing import TYPE_CHECKING, List
|
||||||
|
|
||||||
from sqlalchemy import DateTime, Enum, ForeignKey, Integer, Unicode, text
|
from sqlalchemy import DateTime, Enum, ForeignKey, Integer, Text, Uuid, text
|
||||||
from sqlalchemy.dialects.postgresql import UUID
|
|
||||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||||
|
|
||||||
from ..db.base_class import reg
|
from ..db.base_class import reg
|
||||||
@@ -26,27 +25,22 @@ if TYPE_CHECKING:
|
|||||||
class Voucher:
|
class Voucher:
|
||||||
__tablename__ = "vouchers"
|
__tablename__ = "vouchers"
|
||||||
|
|
||||||
id: Mapped[uuid.UUID] = mapped_column(
|
id: Mapped[uuid.UUID] = mapped_column(Uuid, primary_key=True, server_default=text("gen_random_uuid()"))
|
||||||
"id", UUID(as_uuid=True), primary_key=True, server_default=text("gen_random_uuid()"), insert_default=uuid.uuid4
|
date: Mapped[datetime] = mapped_column(DateTime, nullable=False, index=True)
|
||||||
)
|
pax: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||||
date: Mapped[datetime] = mapped_column("date", DateTime, nullable=False, index=True)
|
kot_id: Mapped[uuid.UUID] = mapped_column(Integer, nullable=False, unique=True)
|
||||||
pax: Mapped[int] = mapped_column("pax", Integer, nullable=False)
|
creation_date: Mapped[datetime] = mapped_column(DateTime(), nullable=False)
|
||||||
kot_id: Mapped[uuid.UUID] = mapped_column("kot_id", Integer, nullable=False, unique=True)
|
last_edit_date: Mapped[datetime] = mapped_column(DateTime(), nullable=False)
|
||||||
creation_date: Mapped[datetime] = mapped_column("creation_date", DateTime(), nullable=False)
|
|
||||||
last_edit_date: Mapped[datetime] = mapped_column("last_edit_date", DateTime(), nullable=False)
|
|
||||||
food_table_id: Mapped[uuid.UUID] = mapped_column(
|
food_table_id: Mapped[uuid.UUID] = mapped_column(
|
||||||
"food_table_id",
|
Uuid,
|
||||||
UUID(as_uuid=True),
|
|
||||||
ForeignKey("food_tables.id"),
|
ForeignKey("food_tables.id"),
|
||||||
nullable=False,
|
nullable=False,
|
||||||
)
|
)
|
||||||
customer_id: Mapped[uuid.UUID | None] = mapped_column(
|
customer_id: Mapped[uuid.UUID | None] = mapped_column(Uuid, ForeignKey("customers.id"), nullable=True)
|
||||||
"customer_id", UUID(as_uuid=True), ForeignKey("customers.id"), nullable=True
|
narration: Mapped[str] = mapped_column(Text, nullable=True)
|
||||||
)
|
reason: Mapped[str] = mapped_column(Text, nullable=True)
|
||||||
narration: Mapped[str] = mapped_column("narration", Unicode(1000), nullable=True)
|
voucher_type: Mapped[VoucherType] = mapped_column(Enum(VoucherType), nullable=False)
|
||||||
reason: Mapped[str] = mapped_column("reason", Unicode(255), nullable=True)
|
user_id: Mapped[uuid.UUID] = mapped_column(Uuid, ForeignKey("users.id"), nullable=False)
|
||||||
voucher_type: Mapped[VoucherType] = mapped_column("voucher_type", Enum(VoucherType), nullable=False)
|
|
||||||
user_id: Mapped[uuid.UUID] = mapped_column("user_id", UUID(as_uuid=True), ForeignKey("users.id"), nullable=False)
|
|
||||||
|
|
||||||
user: Mapped["User"] = relationship(backref="vouchers")
|
user: Mapped["User"] = relationship(backref="vouchers")
|
||||||
food_table: Mapped["FoodTable"] = relationship(backref="vouchers")
|
food_table: Mapped["FoodTable"] = relationship(backref="vouchers")
|
||||||
@@ -69,7 +63,7 @@ class Voucher:
|
|||||||
back_populates="voucher",
|
back_populates="voucher",
|
||||||
cascade="delete, delete-orphan",
|
cascade="delete, delete-orphan",
|
||||||
)
|
)
|
||||||
status: Mapped[Optional["Overview"]] = relationship(back_populates="voucher", uselist=False)
|
status: Mapped["Overview" | None] = relationship(back_populates="voucher", uselist=False)
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
|||||||
@@ -88,8 +88,8 @@ def product_sale_report(s: date, f: date, db: Session):
|
|||||||
.order_by(SaleCategory.name, MenuCategory.name, ProductVersion.full_name)
|
.order_by(SaleCategory.name, MenuCategory.name, ProductVersion.full_name)
|
||||||
).all()
|
).all()
|
||||||
info: list[Any] = []
|
info: list[Any] = []
|
||||||
for id_, name, type_, hh, quantity in list_:
|
for id_, name, v_type, hh, quantity in list_:
|
||||||
type_ = to_camel(VoucherType(type_).name)
|
type_ = to_camel(VoucherType(v_type).name)
|
||||||
old = [i for i in info if i["id"] == id_ and i["isHappyHour"] == hh]
|
old = [i for i in info if i["id"] == id_ and i["isHappyHour"] == hh]
|
||||||
if len(old):
|
if len(old):
|
||||||
if type_ not in old[0]:
|
if type_ not in old[0]:
|
||||||
|
|||||||
@@ -1,3 +1,13 @@
|
|||||||
|
from decimal import Decimal
|
||||||
|
from typing import Annotated
|
||||||
|
|
||||||
|
from pydantic import PlainSerializer
|
||||||
|
|
||||||
|
|
||||||
def to_camel(string: str) -> str:
|
def to_camel(string: str) -> str:
|
||||||
first, *others = string.split("_")
|
first, *others = string.split("_")
|
||||||
return "".join([first.lower()] + [word.capitalize() for word in others])
|
return "".join([first.lower()] + [word.capitalize() for word in others])
|
||||||
|
|
||||||
|
|
||||||
|
# Custom serializer to serialize decimal as float and not as string as is the default behaviour in Pydantic V2
|
||||||
|
Daf = Annotated[Decimal, PlainSerializer(lambda x: float(x), return_type=float, when_used="unless-none")]
|
||||||
@@ -1,16 +1,15 @@
|
|||||||
from datetime import date, datetime
|
from datetime import date, datetime
|
||||||
from decimal import Decimal
|
|
||||||
|
|
||||||
from pydantic import BaseModel, ConfigDict, field_serializer, field_validator
|
from pydantic import BaseModel, ConfigDict, field_serializer, field_validator
|
||||||
|
|
||||||
from . import to_camel
|
from . import Daf, to_camel
|
||||||
|
|
||||||
|
|
||||||
class BillSettlementItem(BaseModel):
|
class BillSettlementItem(BaseModel):
|
||||||
date_: datetime
|
date_: datetime
|
||||||
bill_id: str
|
bill_id: str
|
||||||
settlement: str
|
settlement: str
|
||||||
amount: Decimal
|
amount: Daf
|
||||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||||
|
|
||||||
@field_validator("date_", mode="before")
|
@field_validator("date_", mode="before")
|
||||||
|
|||||||
@@ -1,15 +1,14 @@
|
|||||||
from datetime import date, datetime
|
from datetime import date, datetime
|
||||||
from decimal import Decimal
|
|
||||||
|
|
||||||
from pydantic import BaseModel, ConfigDict, field_serializer, field_validator
|
from pydantic import BaseModel, ConfigDict, field_serializer, field_validator
|
||||||
|
|
||||||
from . import to_camel
|
from . import Daf, to_camel
|
||||||
from .user import UserLink
|
from .user import UserLink
|
||||||
|
|
||||||
|
|
||||||
class NameAmount(BaseModel):
|
class NameAmount(BaseModel):
|
||||||
name: str
|
name: str
|
||||||
amount: Decimal
|
amount: Daf
|
||||||
model_config = ConfigDict(str_strip_whitespace=True)
|
model_config = ConfigDict(str_strip_whitespace=True)
|
||||||
|
|
||||||
|
|
||||||
@@ -29,7 +28,7 @@ class InfoItem(BaseModel):
|
|||||||
date: datetime
|
date: datetime
|
||||||
bill_id: str
|
bill_id: str
|
||||||
customer: str
|
customer: str
|
||||||
amount: Decimal
|
amount: Daf
|
||||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||||
|
|
||||||
@field_validator("date", mode="before")
|
@field_validator("date", mode="before")
|
||||||
|
|||||||
@@ -1,17 +1,15 @@
|
|||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from decimal import Decimal
|
|
||||||
|
|
||||||
from pydantic import BaseModel, ConfigDict, Field
|
from pydantic import BaseModel, ConfigDict, Field
|
||||||
|
|
||||||
from . import to_camel
|
from . import Daf, to_camel
|
||||||
|
|
||||||
|
|
||||||
class CustomerDiscount(BaseModel):
|
class CustomerDiscount(BaseModel):
|
||||||
id_: uuid.UUID
|
id_: uuid.UUID
|
||||||
name: str
|
name: str
|
||||||
discount: Decimal = Field(ge=0, default=0, le=1)
|
discount: Daf = Field(ge=0, default=0, le=1)
|
||||||
limit: Decimal = Field(ge=0, default=0, le=1)
|
limit: Daf = Field(ge=0, default=0, le=1)
|
||||||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from decimal import Decimal
|
|
||||||
|
|
||||||
from barker.schemas import to_camel
|
from barker.schemas import to_camel
|
||||||
from pydantic import BaseModel, ConfigDict, Field
|
from pydantic import BaseModel, ConfigDict, Field
|
||||||
|
|
||||||
|
from . import Daf
|
||||||
|
|
||||||
|
|
||||||
class DiscountItem(BaseModel):
|
class DiscountItem(BaseModel):
|
||||||
id_: uuid.UUID
|
id_: uuid.UUID
|
||||||
name: str
|
name: str
|
||||||
discount: Decimal | None = Field(ge=0, default=0, le=1)
|
discount: Daf | None = Field(ge=0, default=0, le=1)
|
||||||
limit: Decimal
|
limit: Daf
|
||||||
customer: Decimal
|
customer: Daf
|
||||||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
||||||
@@ -1,14 +1,13 @@
|
|||||||
from datetime import date, datetime
|
from datetime import date, datetime
|
||||||
from decimal import Decimal
|
|
||||||
|
|
||||||
from pydantic import BaseModel, ConfigDict, field_serializer, field_validator
|
from pydantic import BaseModel, ConfigDict, field_serializer, field_validator
|
||||||
|
|
||||||
from . import to_camel
|
from . import Daf, to_camel
|
||||||
|
|
||||||
|
|
||||||
class DiscountReportItem(BaseModel):
|
class DiscountReportItem(BaseModel):
|
||||||
name: str
|
name: str
|
||||||
amount: Decimal
|
amount: Daf
|
||||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,24 +1,23 @@
|
|||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from datetime import date, datetime
|
from datetime import date, datetime
|
||||||
from decimal import Decimal
|
|
||||||
|
|
||||||
from pydantic import BaseModel, ConfigDict, field_serializer, field_validator
|
from pydantic import BaseModel, ConfigDict, field_serializer, field_validator
|
||||||
|
|
||||||
from . import to_camel
|
from . import Daf, to_camel
|
||||||
|
|
||||||
|
|
||||||
class MeItem(BaseModel):
|
class MeItem(BaseModel):
|
||||||
id_: uuid.UUID
|
id_: uuid.UUID
|
||||||
name: str
|
name: str
|
||||||
price: Decimal
|
price: Daf
|
||||||
average: Decimal
|
average: Daf
|
||||||
sale_category: str
|
sale_category: str
|
||||||
menu_category: str
|
menu_category: str
|
||||||
quantity: Decimal
|
quantity: Daf
|
||||||
sales: Decimal
|
sales: Daf
|
||||||
quantity_percent: Decimal
|
quantity_percent: Daf
|
||||||
sales_percent: Decimal
|
sales_percent: Daf
|
||||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,15 @@
|
|||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from decimal import Decimal
|
|
||||||
|
|
||||||
from pydantic import BaseModel, ConfigDict, Field
|
from pydantic import BaseModel, ConfigDict, Field
|
||||||
|
|
||||||
from . import to_camel
|
from . import Daf, to_camel
|
||||||
from .modifier_category import ModifierCategoryLink
|
from .modifier_category import ModifierCategoryLink
|
||||||
|
|
||||||
|
|
||||||
class ModifierIn(BaseModel):
|
class ModifierIn(BaseModel):
|
||||||
name: str = Field(..., min_length=1)
|
name: str = Field(..., min_length=1)
|
||||||
show_in_bill: bool
|
show_in_bill: bool
|
||||||
price: Decimal = Field(ge=0, default=0)
|
price: Daf = Field(ge=0, default=0)
|
||||||
is_active: bool
|
is_active: bool
|
||||||
modifier_category: ModifierCategoryLink
|
modifier_category: ModifierCategoryLink
|
||||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||||
@@ -30,6 +28,6 @@ class ModifierLink(BaseModel):
|
|||||||
class ModifierBlank(BaseModel):
|
class ModifierBlank(BaseModel):
|
||||||
name: str
|
name: str
|
||||||
show_in_bill: bool
|
show_in_bill: bool
|
||||||
price: Decimal
|
price: Daf
|
||||||
is_active: bool
|
is_active: bool
|
||||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||||
@@ -1,11 +1,10 @@
|
|||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from datetime import date, datetime
|
from datetime import date, datetime
|
||||||
from decimal import Decimal
|
|
||||||
|
|
||||||
from pydantic import BaseModel, ConfigDict, Field, field_serializer, field_validator
|
from pydantic import BaseModel, ConfigDict, Field, field_serializer, field_validator
|
||||||
|
|
||||||
from . import to_camel
|
from . import Daf, to_camel
|
||||||
from .menu_category import MenuCategoryLink
|
from .menu_category import MenuCategoryLink
|
||||||
from .sale_category import SaleCategoryLink
|
from .sale_category import SaleCategoryLink
|
||||||
|
|
||||||
@@ -15,10 +14,10 @@ class ProductIn(BaseModel):
|
|||||||
units: str
|
units: str
|
||||||
menu_category: MenuCategoryLink = Field(...)
|
menu_category: MenuCategoryLink = Field(...)
|
||||||
sale_category: SaleCategoryLink = Field(...)
|
sale_category: SaleCategoryLink = Field(...)
|
||||||
price: Decimal # = Field(ge=0, default=0)
|
price: Daf # = Field(ge=0, default=0)
|
||||||
has_happy_hour: bool
|
has_happy_hour: bool
|
||||||
is_not_available: bool
|
is_not_available: bool
|
||||||
quantity: Decimal = Field(ge=0, default=0)
|
quantity: Daf = Field(ge=0, default=0)
|
||||||
is_active: bool
|
is_active: bool
|
||||||
sort_order: int
|
sort_order: int
|
||||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||||
@@ -61,10 +60,10 @@ class Product(ProductIn):
|
|||||||
class ProductBlank(BaseModel):
|
class ProductBlank(BaseModel):
|
||||||
name: str
|
name: str
|
||||||
units: str
|
units: str
|
||||||
price: Decimal
|
price: Daf
|
||||||
has_happy_hour: bool
|
has_happy_hour: bool
|
||||||
is_not_available: bool
|
is_not_available: bool
|
||||||
quantity: Decimal
|
quantity: Daf
|
||||||
is_active: bool
|
is_active: bool
|
||||||
sort_order: int
|
sort_order: int
|
||||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||||
@@ -1,13 +1,11 @@
|
|||||||
from decimal import Decimal
|
|
||||||
|
|
||||||
from pydantic import BaseModel, ConfigDict
|
from pydantic import BaseModel, ConfigDict
|
||||||
|
|
||||||
from . import to_camel
|
from . import Daf, to_camel
|
||||||
|
|
||||||
|
|
||||||
class ReceivePaymentItem(BaseModel):
|
class ReceivePaymentItem(BaseModel):
|
||||||
id_: int
|
id_: int
|
||||||
amount: Decimal
|
amount: Daf
|
||||||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,14 @@
|
|||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from decimal import Decimal
|
|
||||||
|
|
||||||
from pydantic import BaseModel, ConfigDict, Field
|
from pydantic import BaseModel, ConfigDict, Field
|
||||||
|
|
||||||
from . import to_camel
|
from . import Daf, to_camel
|
||||||
from .tax import TaxLink
|
from .tax import TaxLink
|
||||||
|
|
||||||
|
|
||||||
class SaleCategoryIn(BaseModel):
|
class SaleCategoryIn(BaseModel):
|
||||||
name: str = Field(..., min_length=1)
|
name: str = Field(..., min_length=1)
|
||||||
discount_limit: Decimal = Field(ge=0, default=0, le=1)
|
discount_limit: Daf = Field(ge=0, default=0, le=1)
|
||||||
tax: TaxLink = Field(...)
|
tax: TaxLink = Field(...)
|
||||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||||
|
|
||||||
@@ -22,15 +20,15 @@ class SaleCategory(SaleCategoryIn):
|
|||||||
|
|
||||||
class SaleCategoryBlank(BaseModel):
|
class SaleCategoryBlank(BaseModel):
|
||||||
name: str
|
name: str
|
||||||
discount_limit: Decimal
|
discount_limit: Daf
|
||||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||||
|
|
||||||
|
|
||||||
class SaleCategoryForDiscount(BaseModel):
|
class SaleCategoryForDiscount(BaseModel):
|
||||||
id_: uuid.UUID
|
id_: uuid.UUID
|
||||||
name: str
|
name: str
|
||||||
discount_limit: Decimal
|
discount_limit: Daf
|
||||||
discount: Decimal
|
discount: Daf
|
||||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,14 @@
|
|||||||
from datetime import date, datetime
|
from datetime import date, datetime
|
||||||
from decimal import Decimal
|
|
||||||
|
|
||||||
from pydantic import BaseModel, ConfigDict, field_serializer, field_validator
|
from pydantic import BaseModel, ConfigDict, field_serializer, field_validator
|
||||||
|
|
||||||
from . import to_camel
|
from . import Daf, to_camel
|
||||||
from .user import UserLink
|
from .user import UserLink
|
||||||
|
|
||||||
|
|
||||||
class SaleReportItem(BaseModel):
|
class SaleReportItem(BaseModel):
|
||||||
name: str
|
name: str
|
||||||
amount: Decimal
|
amount: Daf
|
||||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,14 @@
|
|||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from decimal import Decimal
|
|
||||||
|
|
||||||
from barker.schemas.regime import RegimeLink
|
from barker.schemas.regime import RegimeLink
|
||||||
from pydantic import BaseModel, ConfigDict, Field
|
from pydantic import BaseModel, ConfigDict, Field
|
||||||
|
|
||||||
from . import to_camel
|
from . import Daf, to_camel
|
||||||
|
|
||||||
|
|
||||||
class TaxIn(BaseModel):
|
class TaxIn(BaseModel):
|
||||||
name: str = Field(..., min_length=1)
|
name: str = Field(..., min_length=1)
|
||||||
rate: Decimal = Field(ge=0, default=0)
|
rate: Daf = Field(ge=0, default=0)
|
||||||
regime: RegimeLink = Field(...)
|
regime: RegimeLink = Field(...)
|
||||||
is_fixture: bool
|
is_fixture: bool
|
||||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||||
@@ -23,7 +21,7 @@ class Tax(TaxIn):
|
|||||||
|
|
||||||
class TaxBlank(BaseModel):
|
class TaxBlank(BaseModel):
|
||||||
name: str
|
name: str
|
||||||
rate: Decimal = Field(ge=0, default=0)
|
rate: Daf = Field(ge=0, default=0)
|
||||||
is_fixture: bool
|
is_fixture: bool
|
||||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||||
|
|
||||||
@@ -31,5 +29,5 @@ class TaxBlank(BaseModel):
|
|||||||
class TaxLink(BaseModel):
|
class TaxLink(BaseModel):
|
||||||
id_: uuid.UUID = Field(...)
|
id_: uuid.UUID = Field(...)
|
||||||
name: str | None = None
|
name: str | None = None
|
||||||
rate: Decimal | None = None
|
rate: Daf | None = None
|
||||||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
||||||
@@ -1,16 +1,15 @@
|
|||||||
from datetime import date, datetime
|
from datetime import date, datetime
|
||||||
from decimal import Decimal
|
|
||||||
|
|
||||||
from pydantic import BaseModel, ConfigDict, field_serializer, field_validator
|
from pydantic import BaseModel, ConfigDict, field_serializer, field_validator
|
||||||
|
|
||||||
from . import to_camel
|
from . import Daf, to_camel
|
||||||
|
|
||||||
|
|
||||||
class TaxReportItem(BaseModel):
|
class TaxReportItem(BaseModel):
|
||||||
name: str
|
name: str
|
||||||
tax_rate: Decimal
|
tax_rate: Daf
|
||||||
sale_amount: Decimal
|
sale_amount: Daf
|
||||||
amount: Decimal
|
amount: Daf
|
||||||
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +1,17 @@
|
|||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from datetime import date, datetime
|
from datetime import date, datetime
|
||||||
from decimal import Decimal
|
|
||||||
|
|
||||||
from pydantic import BaseModel, ConfigDict, field_serializer, field_validator
|
from pydantic import BaseModel, ConfigDict, field_serializer, field_validator
|
||||||
|
|
||||||
from . import to_camel
|
from . import Daf, to_camel
|
||||||
|
|
||||||
|
|
||||||
class UpdateProductPricesItem(BaseModel):
|
class UpdateProductPricesItem(BaseModel):
|
||||||
id: uuid.UUID
|
id: uuid.UUID
|
||||||
name: str
|
name: str
|
||||||
old_price: Decimal
|
old_price: Daf
|
||||||
new_price: Decimal
|
new_price: Daf
|
||||||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ from decimal import Decimal
|
|||||||
|
|
||||||
from pydantic import BaseModel, ConfigDict, Field, field_validator, model_validator
|
from pydantic import BaseModel, ConfigDict, Field, field_validator, model_validator
|
||||||
|
|
||||||
from . import to_camel
|
from . import Daf, to_camel
|
||||||
from .customer import CustomerLink
|
from .customer import CustomerLink
|
||||||
from .modifier import ModifierLink
|
from .modifier import ModifierLink
|
||||||
from .product_link import ProductLink
|
from .product_link import ProductLink
|
||||||
@@ -15,40 +15,40 @@ from .tax import TaxLink
|
|||||||
class Inventory(BaseModel):
|
class Inventory(BaseModel):
|
||||||
id_: uuid.UUID | None = None
|
id_: uuid.UUID | None = None
|
||||||
product: ProductLink
|
product: ProductLink
|
||||||
quantity: Decimal
|
quantity: Daf
|
||||||
price: Decimal | None = None
|
price: Daf | None = None
|
||||||
tax: TaxLink | None = None
|
tax: TaxLink | None = None
|
||||||
tax_rate: Decimal | None = None
|
tax_rate: Daf | None = None
|
||||||
discount: Decimal = Field(ge=0, le=1)
|
discount: Daf = Field(ge=0, le=1)
|
||||||
is_happy_hour: bool
|
is_happy_hour: bool
|
||||||
modifiers: list[ModifierLink]
|
modifiers: list[ModifierLink]
|
||||||
amount: Decimal | None = None
|
amount: Daf | None = None
|
||||||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
||||||
|
|
||||||
@field_validator("quantity")
|
@field_validator("quantity")
|
||||||
@classmethod
|
@classmethod
|
||||||
def _quantity(cls, value: Decimal | None) -> Decimal:
|
def _quantity(cls, value: Daf | None) -> Daf:
|
||||||
if value is None:
|
if value is None:
|
||||||
return Decimal(0)
|
return Decimal(0)
|
||||||
return round(value, 2)
|
return round(value, 2)
|
||||||
|
|
||||||
@field_validator("price")
|
@field_validator("price")
|
||||||
@classmethod
|
@classmethod
|
||||||
def _price(cls, value: Decimal | None) -> Decimal:
|
def _price(cls, value: Daf | None) -> Daf:
|
||||||
if value is None:
|
if value is None:
|
||||||
return Decimal(0)
|
return Decimal(0)
|
||||||
return round(value, 2)
|
return round(value, 2)
|
||||||
|
|
||||||
@field_validator("tax_rate")
|
@field_validator("tax_rate")
|
||||||
@classmethod
|
@classmethod
|
||||||
def _tax_rate(cls, value: Decimal | None) -> Decimal:
|
def _tax_rate(cls, value: Daf | None) -> Daf:
|
||||||
if value is None:
|
if value is None:
|
||||||
return Decimal(0)
|
return Decimal(0)
|
||||||
return round(value, 5)
|
return round(value, 5)
|
||||||
|
|
||||||
@field_validator("discount")
|
@field_validator("discount")
|
||||||
@classmethod
|
@classmethod
|
||||||
def _discount(cls, value: Decimal | None) -> Decimal:
|
def _discount(cls, value: Daf | None) -> Daf:
|
||||||
if value is None:
|
if value is None:
|
||||||
return Decimal(0)
|
return Decimal(0)
|
||||||
return round(value, 5)
|
return round(value, 5)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ authors = ["tanshu <git@tanshu.com>"]
|
|||||||
[tool.poetry.dependencies]
|
[tool.poetry.dependencies]
|
||||||
python = "^3.11"
|
python = "^3.11"
|
||||||
uvicorn = {extras = ["standard"], version = "^0.21.1"}
|
uvicorn = {extras = ["standard"], version = "^0.21.1"}
|
||||||
fastapi = {extras = ["all"], version = "^0.100.0"}
|
fastapi = {extras = ["all"], version = "^0.101.1"}
|
||||||
python-jose = {extras = ["cryptography"], version = "^3.3.0"}
|
python-jose = {extras = ["cryptography"], version = "^3.3.0"}
|
||||||
passlib = {extras = ["bcrypt"], version = "^1.7.4"}
|
passlib = {extras = ["bcrypt"], version = "^1.7.4"}
|
||||||
psycopg2-binary = "^2.9.6"
|
psycopg2-binary = "^2.9.6"
|
||||||
@@ -17,7 +17,7 @@ PyJWT = "^2.8.0"
|
|||||||
alembic = "^1.11.1"
|
alembic = "^1.11.1"
|
||||||
itsdangerous = "^2.1.2"
|
itsdangerous = "^2.1.2"
|
||||||
python-dotenv = "^1.0.0"
|
python-dotenv = "^1.0.0"
|
||||||
pydantic = {extras = ["dotenv"], version = "^2.0.3"}
|
pydantic = {extras = ["dotenv"], version = "^2.1.1"}
|
||||||
starlette = "^0.27.0"
|
starlette = "^0.27.0"
|
||||||
arq = "^0.25.0"
|
arq = "^0.25.0"
|
||||||
aiohttp = "^3.8.5"
|
aiohttp = "^3.8.5"
|
||||||
|
|||||||
Reference in new issue
Block a user