Automated Action 5935f302dc Create Small Business Inventory Management System with FastAPI and SQLite
- Set up project structure and FastAPI application
- Create database models with SQLAlchemy
- Implement authentication with JWT
- Add CRUD operations for products, inventory, categories
- Implement purchase order and sales functionality
- Create reporting endpoints
- Set up Alembic for database migrations
- Add comprehensive documentation in README.md
2025-05-16 08:53:15 +00:00

21 lines
1.0 KiB
Python

from sqlalchemy import Column, Integer, String, Text, Numeric, ForeignKey
from sqlalchemy.orm import relationship
from app.db.base_class import Base
class Product(Base):
id = Column(Integer, primary_key=True, index=True)
name = Column(String, index=True, nullable=False)
description = Column(Text, nullable=True)
sku = Column(String, index=True, nullable=True, unique=True)
barcode = Column(String, index=True, nullable=True, unique=True)
unit_price = Column(Numeric(precision=10, scale=2), nullable=False)
cost_price = Column(Numeric(precision=10, scale=2), nullable=False)
category_id = Column(Integer, ForeignKey("category.id"), nullable=True)
# Relationships
category = relationship("Category", back_populates="products")
inventory_items = relationship("Inventory", back_populates="product", cascade="all, delete-orphan")
purchase_order_items = relationship("PurchaseOrderItem", back_populates="product")
sale_items = relationship("SaleItem", back_populates="product")