feat: empty boxes, ids for shipping pdfs
This commit is contained in:
@@ -72,13 +72,12 @@ class ShippingQRCodeGenerator(BasePdfCardGenerator):
|
||||
shipping_warehouse = await self._session.get(ShippingWarehouse, deal.shipping_warehouse_id)
|
||||
warehouse_name = shipping_warehouse.name if shipping_warehouse else ""
|
||||
|
||||
total_pallets = len(deal.pallets)
|
||||
elements = []
|
||||
|
||||
for pallet_counter in range(total_pallets):
|
||||
for pallet in deal.pallets:
|
||||
elements.append(Paragraph(f"ID: {deal_id}", self.medium_style))
|
||||
elements.append(Paragraph(str(deal.name), self.medium_style))
|
||||
elements.append(Paragraph(f"Паллет {pallet_counter + 1}/{total_pallets}", self.medium_style))
|
||||
elements.append(Paragraph(f"Паллет П{pallet.id}", self.medium_style))
|
||||
elements.append(Paragraph(warehouse_name, self.medium_style))
|
||||
elements.append(PageBreak())
|
||||
|
||||
@@ -113,22 +112,18 @@ class ShippingQRCodeGenerator(BasePdfCardGenerator):
|
||||
|
||||
elements = []
|
||||
|
||||
total_pallets = len(deal.pallets)
|
||||
boxes_on_pallets = await self._get_boxes_on_pallets_count(deal_id)
|
||||
boxes_without_pallets = len(deal.boxes)
|
||||
|
||||
for box_on_pallet in range(boxes_without_pallets):
|
||||
for box in deal.boxes:
|
||||
elements.append(Paragraph(f"ID: {deal_id}", self.medium_style))
|
||||
elements.append(Paragraph(str(deal.name), self.medium_style))
|
||||
elements.append(Paragraph(f"Короб {box_on_pallet + 1}/{boxes_without_pallets}", self.medium_style))
|
||||
elements.append(Paragraph(f"Короб K{box.id}", self.medium_style))
|
||||
elements.append(Paragraph(warehouse_name, self.medium_style))
|
||||
elements.append(PageBreak())
|
||||
|
||||
for pallet_idx, [_, box_count] in enumerate(boxes_on_pallets):
|
||||
for box_on_pallet in range(box_count):
|
||||
for pallet in deal.pallets:
|
||||
for box in pallet.boxes:
|
||||
elements.append(Paragraph(f"ID: {deal_id}", self.medium_style))
|
||||
elements.append(Paragraph(str(deal.name), self.medium_style))
|
||||
box_label = f"Паллет {pallet_idx + 1}/{total_pallets}, Короб {box_on_pallet + 1}/{box_count}"
|
||||
box_label = f"Паллет П{pallet.id}, Короб K{box.id}"
|
||||
elements.append(Paragraph(box_label, self.medium_style))
|
||||
elements.append(Paragraph(warehouse_name, self.medium_style))
|
||||
elements.append(PageBreak())
|
||||
|
||||
@@ -46,9 +46,9 @@ class Box(BaseModel):
|
||||
__tablename__ = 'boxes'
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
|
||||
quantity: Mapped[int] = mapped_column()
|
||||
quantity: Mapped[int] = mapped_column(default=0)
|
||||
|
||||
product_id: Mapped[int] = mapped_column(ForeignKey('products.id'))
|
||||
product_id: Mapped[Optional[int]] = mapped_column(ForeignKey('products.id'), nullable=True)
|
||||
product: Mapped['Product'] = relationship(lazy='joined')
|
||||
|
||||
pallet_id: Mapped[Optional[int]] = mapped_column(ForeignKey('pallets.id'))
|
||||
|
||||
@@ -14,7 +14,7 @@ class ProductAndQuantitySchema(BaseSchema):
|
||||
class BoxSchema(BaseSchema):
|
||||
id: int
|
||||
quantity: int
|
||||
product: ProductSchema
|
||||
product: Optional[ProductSchema]
|
||||
pallet_id: Optional[int]
|
||||
deal_id: Optional[int]
|
||||
|
||||
@@ -40,11 +40,11 @@ class UpdateShippingProductSchema(ProductAndQuantitySchema):
|
||||
shipping_product_id: int
|
||||
|
||||
|
||||
class CreateBoxInPalletSchema(ProductAndQuantitySchema):
|
||||
class CreateBoxInPalletSchema(BaseSchema):
|
||||
pallet_id: Optional[int]
|
||||
|
||||
|
||||
class CreateBoxInDealSchema(ProductAndQuantitySchema):
|
||||
class CreateBoxInDealSchema(BaseSchema):
|
||||
deal_id: Optional[int]
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user