Files
Fulfillment-Backend/models/secondary.py
2024-05-13 07:46:13 +03:00

64 lines
2.5 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from sqlalchemy import Table, Column, Integer, ForeignKey, Boolean
from sqlalchemy.orm import relationship
from models.base import metadata, BaseModel
class DealService(BaseModel):
__tablename__ = 'deal_services'
deal_id = Column(Integer, ForeignKey('deals.id'),
nullable=False,
comment='ID Сделки',
primary_key=True)
deal = relationship('Deal', back_populates='services')
service_id = Column(Integer, ForeignKey('services.id'), nullable=False, comment='ID Услуги', primary_key=True)
service = relationship('Service')
quantity = Column(Integer, nullable=False, comment='Кол-во услуги')
price = Column(Integer, nullable=False, comment='Цена услуги')
class DealProduct(BaseModel):
__tablename__ = 'deal_products'
deal_id = Column(Integer,
ForeignKey('deals.id'),
nullable=False,
comment='ID Сделки',
primary_key=True)
deal = relationship('Deal', back_populates='products')
product_id = Column(Integer, ForeignKey('products.id'), nullable=False, comment='ID Продукта', primary_key=True)
product = relationship('Product')
quantity = Column(Integer, nullable=False, comment='Кол-во продукта')
class DealProductService(BaseModel):
__tablename__ = 'deal_product_services'
deal_id = Column(Integer,
ForeignKey('deals.id'),
nullable=False,
comment='ID Сделки',
primary_key=True)
deal = relationship('Deal', back_populates='product_services')
product_id = Column(Integer, ForeignKey('products.id'), nullable=False, comment='ID Продукта', primary_key=True)
product = relationship('Product')
service_id = Column(Integer, ForeignKey('services.id'), nullable=False, comment='ID Услуги', primary_key=True)
service = relationship('Service')
quantity = Column(Integer, nullable=False, comment='Кол-во продукта')
price = Column(Integer, nullable=False, comment='Цена услуги')
link_to_product_quantity = Column(Boolean, nullable=False, comment='Связь с количеством продукта')
barcode_template_attribute_link = Table(
'barcode_template_attribute_links',
BaseModel.metadata,
Column('barcode_template_id', ForeignKey('barcode_templates.id')),
Column('attribute_id', ForeignKey('barcode_template_attributes.id'))
)