Automated Action 54bf9880b9 Implement Small Business Inventory Management System
This commit implements a comprehensive inventory management system for small businesses using FastAPI and SQLAlchemy. Features include:
- Product and category management
- Inventory tracking across multiple locations
- Supplier management
- Purchase management
- Transaction tracking for inventory movements
- Complete API documentation

generated with BackendIM... (backend.im)
2025-05-12 12:55:31 +00:00

30 lines
1.2 KiB
Python

from sqlalchemy import Column, String, Float, Integer, Text, ForeignKey
from sqlalchemy.orm import relationship
from app.models.base import BaseModel
class Category(BaseModel):
"""Product category model"""
__tablename__ = "categories"
name = Column(String(100), unique=True, index=True, nullable=False)
description = Column(Text, nullable=True)
# Relationships
products = relationship("Product", back_populates="category")
class Product(BaseModel):
"""Product model for inventory items"""
__tablename__ = "products"
name = Column(String(255), nullable=False, index=True)
description = Column(Text, nullable=True)
sku = Column(String(50), unique=True, index=True, nullable=False)
category_id = Column(Integer, ForeignKey("categories.id"), nullable=True)
price = Column(Float, nullable=False)
cost_price = Column(Float, nullable=False)
barcode = Column(String(100), unique=True, nullable=True)
# Relationships
category = relationship("Category", back_populates="products")
inventory_items = relationship("InventoryItem", back_populates="product")
purchase_items = relationship("PurchaseItem", back_populates="product")