
- Set up project structure with FastAPI and SQLite - Create database models for inventory management - Set up SQLAlchemy and Alembic for database migrations - Create initial database migrations - Implement CRUD operations for products, categories, suppliers - Implement stock movement tracking and inventory management - Add authentication and user management - Add API endpoints for all entities - Add health check endpoint - Update README with project information and usage instructions
30 lines
1.2 KiB
Python
30 lines
1.2 KiB
Python
from sqlalchemy import Column, String, Integer, Float, DateTime, Text, ForeignKey, Boolean
|
|
from sqlalchemy.sql import func
|
|
from sqlalchemy.orm import relationship
|
|
|
|
from app.db.base_class import Base
|
|
|
|
|
|
class Product(Base):
|
|
id = Column(String, primary_key=True, index=True)
|
|
name = Column(String, index=True, nullable=False)
|
|
description = Column(Text, nullable=True)
|
|
sku = Column(String, unique=True, index=True, nullable=False)
|
|
barcode = Column(String, unique=True, nullable=True)
|
|
|
|
category_id = Column(String, ForeignKey("category.id"), nullable=True)
|
|
category = relationship("Category", backref="products")
|
|
|
|
supplier_id = Column(String, ForeignKey("supplier.id"), nullable=True)
|
|
supplier = relationship("Supplier", backref="products")
|
|
|
|
cost_price = Column(Float, nullable=False, default=0.0)
|
|
selling_price = Column(Float, nullable=False, default=0.0)
|
|
|
|
current_stock = Column(Integer, nullable=False, default=0)
|
|
reorder_level = Column(Integer, nullable=False, default=0)
|
|
|
|
is_active = Column(Boolean, default=True)
|
|
|
|
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
|
updated_at = Column(DateTime(timezone=True), server_default=func.now(), onupdate=func.now()) |