feat: total services amount and recalculating

This commit is contained in:
2024-10-22 19:32:27 +03:00
parent 4fa5c0d05b
commit 9a12ddb6af
5 changed files with 93 additions and 8 deletions

View File

@@ -1,5 +1,5 @@
from sqlalchemy import Table, Column, Integer, ForeignKey, ForeignKeyConstraint, UniqueConstraint
from sqlalchemy.orm import relationship
from sqlalchemy.orm import relationship, mapped_column, Mapped
from models.base import BaseModel
@@ -41,6 +41,7 @@ class DealService(BaseModel):
quantity = Column(Integer, nullable=False, comment='Кол-во услуги')
price = Column(Integer, nullable=False, server_default='0', comment='Цена услуги')
is_fixed_price: Mapped[bool] = mapped_column(default=False, server_default='0', comment='Фиксированная цена')
employees = relationship('User', secondary=deal_service_employees)
@@ -59,6 +60,8 @@ class DealProductService(BaseModel):
price = Column(Integer, nullable=False, comment='Цена услуги')
is_fixed_price: Mapped[bool] = mapped_column(default=False, server_default='0', comment='Фиксированная цена')
deal_product = relationship('DealProduct',
back_populates='services',
primaryjoin="and_(DealProductService.deal_id == DealProduct.deal_id, "
@@ -114,4 +117,3 @@ barcode_template_attribute_link = Table(
Column('barcode_template_id', ForeignKey('barcode_templates.id')),
Column('attribute_id', ForeignKey('barcode_template_attributes.id'))
)