add contract storage fix various bugs and translations
This commit is contained in:
@@ -140,6 +140,10 @@ class Form(FormBase, table=True):
|
||||
"order_by": "Shipment.name"
|
||||
},
|
||||
)
|
||||
contracts: list["Contract"] = Relationship(
|
||||
back_populates="form",
|
||||
cascade_delete=True
|
||||
)
|
||||
|
||||
class FormUpdate(SQLModel):
|
||||
name: str | None
|
||||
@@ -168,20 +172,92 @@ class TemplateUpdate(SQLModel):
|
||||
class TemplateCreate(TemplateBase):
|
||||
pass
|
||||
|
||||
class ChequeBase(SQLModel):
|
||||
name: str
|
||||
value: str
|
||||
|
||||
class Cheque(ChequeBase, table=True):
|
||||
id: int | None = Field(default=None, primary_key=True)
|
||||
contract_id: int = Field(foreign_key="contract.id", ondelete="CASCADE")
|
||||
contract: Optional["Contract"] = Relationship(
|
||||
back_populates="cheques",
|
||||
)
|
||||
|
||||
class ContractBase(SQLModel):
|
||||
firstname: str
|
||||
lastname: str
|
||||
email: str
|
||||
phone: str
|
||||
payment_method: str
|
||||
cheque_quantity: int
|
||||
|
||||
class Contract(ContractBase, table=True):
|
||||
id: int | None = Field(default=None, primary_key=True)
|
||||
|
||||
form_id: int = Field(
|
||||
foreign_key="form.id",
|
||||
nullable=False,
|
||||
ondelete="CASCADE"
|
||||
)
|
||||
products: list["ContractProduct"] = Relationship(
|
||||
back_populates="contract",
|
||||
cascade_delete=True
|
||||
)
|
||||
form: Optional[Form] = Relationship(back_populates="contracts")
|
||||
cheques: list[Cheque] = Relationship(
|
||||
back_populates="contract",
|
||||
cascade_delete=True
|
||||
)
|
||||
|
||||
class ContractCreate(ContractBase):
|
||||
products: list["ContractProductCreate"] = []
|
||||
cheques: list["Cheque"] = []
|
||||
form_id: int
|
||||
contract: dict
|
||||
|
||||
class ContractPublic(ContractBase):
|
||||
id: int
|
||||
|
||||
# class Contract(ContractBase, table=True):
|
||||
# id: int | None = Field(default=None, primary_key=True)
|
||||
|
||||
class ContractUpdate(SQLModel):
|
||||
pass
|
||||
|
||||
class ContractCreate(ContractBase):
|
||||
class ContractPublic(ContractBase):
|
||||
id: int
|
||||
products: list["ContractProduct"] = []
|
||||
form: Form
|
||||
|
||||
class ContractProductBase(SQLModel):
|
||||
product_id: int = Field(
|
||||
foreign_key="product.id",
|
||||
nullable=False,
|
||||
ondelete="CASCADE"
|
||||
)
|
||||
shipment_id: int | None = Field(
|
||||
default=None,
|
||||
foreign_key="shipment.id",
|
||||
nullable=True,
|
||||
ondelete="CASCADE"
|
||||
)
|
||||
quantity: float
|
||||
|
||||
class ContractProduct(ContractProductBase, table=True):
|
||||
id: int | None = Field(default=None, primary_key=True)
|
||||
contract_id: int = Field(
|
||||
foreign_key="contract.id",
|
||||
nullable=False,
|
||||
ondelete="CASCADE"
|
||||
)
|
||||
contract: Optional["Contract"] = Relationship(back_populates="products")
|
||||
product: Optional["Product"] = Relationship()
|
||||
shipment: Optional["Shipment"] = Relationship()
|
||||
|
||||
class ContractProductPublic(ContractProductBase):
|
||||
id: int
|
||||
quantity: float
|
||||
contract: Contract
|
||||
product: Product
|
||||
shipment: Optional["Shipment"]
|
||||
|
||||
class ContractProductCreate(ContractProductBase):
|
||||
pass
|
||||
|
||||
class ContractProductUpdate(ContractProductBase):
|
||||
pass
|
||||
|
||||
class ShipmentBase(SQLModel):
|
||||
|
||||
Reference in New Issue
Block a user