Merge remote-tracking branch 'origin/productComment'

This commit is contained in:
2024-11-09 08:35:38 +03:00
4 changed files with 30 additions and 2 deletions

View File

@@ -1,4 +1,4 @@
from sqlalchemy import Table, Column, Integer, ForeignKey, ForeignKeyConstraint, UniqueConstraint
from sqlalchemy import Table, Column, Integer, ForeignKey, ForeignKeyConstraint, UniqueConstraint, String
from sqlalchemy.orm import relationship, mapped_column, Mapped
from models.base import BaseModel
@@ -90,6 +90,7 @@ class DealProduct(BaseModel):
deal_id = Column(Integer, ForeignKey('deals.id'), primary_key=True, nullable=False, comment='ID Сделки')
product_id = Column(Integer, ForeignKey('products.id'), primary_key=True, nullable=False, comment='ID Продукта')
quantity = Column(Integer, nullable=False, comment='Кол-во продукта')
comment = Column(String, nullable=False, server_default='', comment='Комментарий к товару')
deal = relationship('Deal',
back_populates='products',

View File

@@ -70,6 +70,7 @@ class DealProductSchema(BaseSchema):
product: ProductSchema
services: List[DealProductServiceSchema]
quantity: int
comment: str = ""
class DealStatusHistorySchema(BaseSchema):

View File

@@ -471,7 +471,8 @@ class DealService(BaseService):
deal_product = models.secondary.DealProduct(
deal_id=new_deal.id,
product_id=old_deal_product.product.id,
quantity=old_deal_product.quantity
quantity=old_deal_product.quantity,
comment=old_deal_product.comment,
)
self.session.add(deal_product)
await self.session.flush()
@@ -936,6 +937,7 @@ class DealService(BaseService):
# Updating product
deal_product.quantity = request.product.quantity
deal_product.comment = request.product.comment
# Updating deleting old employees
delete_stmt = (

View File

@@ -79,6 +79,22 @@
{% endif %}
</div>
<!--#endregion -->
<!--#region Product comment -->
{% if product_data.deal_products|length == 1 and common_deal_product.comment %}
<table>
<thead>
<tr>
<th>Комментарий</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{ common_deal_product.comment }}</td>
</tr>
</tbody>
</table>
{% endif %}
<!--#endregion -->
<!--#region Product services -->
{% if common_deal_product.services|length > 0 %}
<table>
@@ -144,6 +160,14 @@
<td style="text-align: center">{{ deal_product.quantity }}</td>
<td></td>
</tr>
{% if deal_product.comment %}
<tr></tr>
<tr>
<td colspan="4">
<b>Комментарий</b>: {{ deal_product.comment }}
</td>
</tr>
{% endif %}
{% endfor %}
</tbody>
</table>