Initial commit: Product Slip Manager
This commit is contained in:
68
slips/schemas.py
Normal file
68
slips/schemas.py
Normal file
@@ -0,0 +1,68 @@
|
||||
from datetime import date
|
||||
from typing import Optional
|
||||
from ninja import Schema
|
||||
|
||||
|
||||
class ProductOut(Schema):
|
||||
id: int
|
||||
code: str
|
||||
description: str
|
||||
default_net_weight: float
|
||||
|
||||
|
||||
class ProductIn(Schema):
|
||||
code: str
|
||||
description: str
|
||||
default_net_weight: float = 5.0
|
||||
|
||||
|
||||
class OrderIn(Schema):
|
||||
product_id: int
|
||||
batch_number: str
|
||||
production_date: date
|
||||
next_control_date: date
|
||||
total_weight: float
|
||||
canister_weight: float
|
||||
canisters_per_box: int
|
||||
|
||||
|
||||
class OrderOut(Schema):
|
||||
id: int
|
||||
product_id: int
|
||||
product_code: str
|
||||
product_description: str
|
||||
batch_number: str
|
||||
production_date: date
|
||||
next_control_date: date
|
||||
total_weight: float
|
||||
canister_weight: float
|
||||
canisters_per_box: int
|
||||
canister_count: int
|
||||
box_count: int
|
||||
canister_pages: int
|
||||
box_pages: int
|
||||
status: str
|
||||
created_at: str
|
||||
printed_at: Optional[str] = None
|
||||
|
||||
@staticmethod
|
||||
def resolve_product_code(obj):
|
||||
return obj.product.code
|
||||
|
||||
@staticmethod
|
||||
def resolve_product_description(obj):
|
||||
return obj.product.description
|
||||
|
||||
@staticmethod
|
||||
def resolve_created_at(obj):
|
||||
return obj.created_at.strftime('%d/%m/%Y %H:%M')
|
||||
|
||||
@staticmethod
|
||||
def resolve_printed_at(obj):
|
||||
if obj.printed_at:
|
||||
return obj.printed_at.strftime('%d/%m/%Y %H:%M')
|
||||
return None
|
||||
|
||||
|
||||
class OrderStatusIn(Schema):
|
||||
status: str
|
||||
Reference in New Issue
Block a user