23 lines
870 B
Python
23 lines
870 B
Python
from sqlalchemy import Column, ForeignKey, Integer, Numeric, String, Text, Boolean
|
|
from sqlalchemy.orm import relationship
|
|
|
|
from app.db.session import Base
|
|
from app.models.base import Base as CustomBase
|
|
|
|
|
|
class Product(Base, CustomBase):
|
|
"""Product model for managing products and services."""
|
|
|
|
name = Column(String(255), nullable=False)
|
|
description = Column(Text, nullable=True)
|
|
price = Column(Numeric(10, 2), nullable=False)
|
|
sku = Column(String(50), nullable=True)
|
|
is_service = Column(Boolean, default=False)
|
|
tax_rate = Column(Numeric(5, 2), default=0.00)
|
|
|
|
# Foreign keys
|
|
user_id = Column(Integer, ForeignKey("user.id"), nullable=False)
|
|
|
|
# Relationships
|
|
user = relationship("User", back_populates="products")
|
|
invoice_items = relationship("InvoiceItem", back_populates="product", cascade="all, delete-orphan") |