barker/barker/barker/models/regime.py

54 lines
1.4 KiB
Python

from typing import TYPE_CHECKING, List
from sqlalchemy import Boolean, Integer, Unicode
from sqlalchemy.orm import Mapped, mapped_column, relationship
from ..db.base_class import reg
if TYPE_CHECKING:
from .bill import Bill
from .tax import Tax
@reg.mapped_as_dataclass(unsafe_hash=True)
class Regime:
__tablename__ = "regimes"
id: Mapped[int] = mapped_column("id", Integer, primary_key=True)
name: Mapped[str] = mapped_column("name", Unicode(255), nullable=False, unique=True)
header: Mapped[str] = mapped_column("header", Unicode(255), nullable=False)
prefix: Mapped[str] = mapped_column("prefix", Unicode(255), nullable=False, unique=True)
is_fixture: Mapped[bool] = mapped_column("is_fixture", Boolean, nullable=False)
taxes: Mapped[List["Tax"]] = relationship(back_populates="regime")
bills: Mapped[List["Bill"]] = relationship(back_populates="regime")
def __init__(self, id=None, name=None, header=None, prefix=None, is_fixture=False, id_=None):
self.id = id
self.name = name
self.header = header
self.prefix = prefix
self.is_fixture = is_fixture
self.id = id_
@classmethod
def KOT(cls):
return 0
@classmethod
def REGULAR_BILL(cls):
return 1
@classmethod
def NO_CHARGE(cls):
return 2
@classmethod
def STAFF(cls):
return 4
@classmethod
def VOID(cls):
return 8