23 lines
826 B
Python
23 lines
826 B
Python
from sqlalchemy import Column, ForeignKey, Integer, String, Text
|
|
from sqlalchemy.orm import relationship
|
|
|
|
from app.db.session import Base
|
|
from app.models.base import Base as CustomBase
|
|
|
|
|
|
class Customer(Base, CustomBase):
|
|
"""Customer model for managing client information."""
|
|
|
|
name = Column(String(255), nullable=False)
|
|
email = Column(String(255), nullable=True)
|
|
phone = Column(String(50), nullable=True)
|
|
address = Column(Text, nullable=True)
|
|
tax_id = Column(String(50), nullable=True)
|
|
notes = Column(Text, nullable=True)
|
|
|
|
# Foreign keys
|
|
user_id = Column(Integer, ForeignKey("user.id"), nullable=False)
|
|
|
|
# Relationships
|
|
user = relationship("User", back_populates="customers")
|
|
invoices = relationship("Invoice", back_populates="customer", cascade="all, delete-orphan") |