Automated Action be0ae5f3b3 Implement small business inventory management system
- Create project structure with FastAPI and SQLAlchemy
- Implement database models for items, categories, suppliers, and stock movements
- Add CRUD operations for all models
- Configure Alembic for database migrations
- Create RESTful API endpoints for inventory management
- Add health endpoint for system monitoring
- Update README with setup and usage instructions

generated with BackendIM... (backend.im)
2025-05-12 16:23:23 +00:00

27 lines
962 B
Python

from sqlalchemy import Column, Integer, String, Float, ForeignKey, Enum
from sqlalchemy.orm import relationship
from sqlalchemy.sql import func
from sqlalchemy.sql.sqltypes import TIMESTAMP
import enum
from app.database import Base
class MovementType(str, enum.Enum):
PURCHASE = "purchase"
SALE = "sale"
ADJUSTMENT = "adjustment"
RETURN = "return"
class StockMovement(Base):
__tablename__ = "stock_movements"
id = Column(Integer, primary_key=True, index=True)
item_id = Column(Integer, ForeignKey("items.id"), nullable=False)
quantity = Column(Integer, nullable=False)
movement_type = Column(Enum(MovementType), nullable=False)
reference = Column(String, nullable=True)
notes = Column(String, nullable=True)
unit_price = Column(Float, nullable=True)
created_at = Column(TIMESTAMP(timezone=True), server_default=func.now())
# Relationships
item = relationship("Item", foreign_keys=[item_id])