Commit d901add5 by Ooh-Ao

inventory

parent edcc5878
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python Debugger: FastAPI",
"type": "debugpy",
"request": "launch",
"module": "uvicorn",
"args": [
"src.main:app",
"--reload"
],
"jinja": true
}
]
}
\ No newline at end of file
......@@ -22,9 +22,9 @@ async def create_inventory_lot(db: AsyncSession, lot_in: InventoryLotCreate):
try:
db.add(new_lot)
# ปรับปรุง quantity ของ equipment ถ้าต้องการ
if lot_in.action == InventoryAction.INBOUND:
if lot_in.action == 'INBOUND':
equipment_db.quantity += lot_in.quantity
elif lot_in.action in [InventoryAction.OUTBOUND, InventoryAction.SCRAP, InventoryAction.MAINTENANCE_OUT]:
elif lot_in.action in ["OUTBOUND", InventoryAction.SCRAP, InventoryAction.MAINTENANCE_OUT]:
if equipment_db.quantity < lot_in.quantity:
raise HTTPException(status_code=400, detail="Not enough quantity in stock")
equipment_db.quantity -= lot_in.quantity
......
......@@ -18,6 +18,7 @@ class Equipment(Base):
)
equipmentName = Column(String(255), nullable=False)
description = Column(String, nullable=True)
quantity = Column(Integer, nullable=False)
is_returnable = Column(Boolean, nullable=False, default=True)
categoryId = Column(UUID(as_uuid=True), ForeignKey("equipment_category.categoryId"), nullable=True)
# ถ้าต้องการวันเวลาสร้าง/แก้ไข
......
......@@ -6,6 +6,7 @@ from uuid import UUID
class EquipmentBase(BaseModel):
equipmentName: str
description: Optional[str] = None
quantity: int
is_returnable: bool = True
class EquipmentCreate(EquipmentBase):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment