feat: cards, attributes and modules

This commit is contained in:
2025-02-19 14:46:31 +04:00
parent a509a3a586
commit 1af78ce08a
61 changed files with 3212 additions and 2795 deletions

View File

@@ -11,18 +11,18 @@ from sqlalchemy.orm import joinedload, selectinload
from constants import DOMAIN_NAME
from generators.base_pdf_card_generator.base_pdf_card_generator import BasePdfCardGenerator
from models import Deal, ShippingWarehouse, Pallet
from models import Card, ShippingWarehouse, Pallet
from models.shipping import Box
class ShippingQRCodeGenerator(BasePdfCardGenerator):
async def _get_deal_by_id(self, deal_id: int) -> Optional[Deal]:
async def _get_deal_by_id(self, deal_id: int) -> Optional[Card]:
stmt = (
select(Deal)
.where(Deal.id == deal_id)
select(Card)
.where(Card.id == deal_id)
.options(
joinedload(Deal.shipping_warehouse),
selectinload(Deal.pallets),
joinedload(Card.shipping_warehouse),
selectinload(Card.pallets),
)
)
deal = (await self._session.execute(stmt)).one_or_none()
@@ -93,7 +93,7 @@ class ShippingQRCodeGenerator(BasePdfCardGenerator):
func.count(Box.id).label("box_count"),
)
.join(Box, isouter=True)
.where(Pallet.deal_id == deal_id)
.where(Pallet.card_id == deal_id)
.group_by(Pallet.id)
)
pallets = (await self._session.execute(stmt_boxes_on_pallets)).all()