
Features: - JWT authentication with user registration and login - Customer management with full CRUD operations - Invoice management with automatic calculations - Multi-tenant data isolation by user - SQLite database with Alembic migrations - RESTful API with comprehensive documentation - Tax calculations and invoice status tracking - Code formatted with Ruff linting
25 lines
973 B
Python
25 lines
973 B
Python
from sqlalchemy import Column, Integer, String, DateTime, ForeignKey, Text
|
|
from sqlalchemy.sql import func
|
|
from sqlalchemy.orm import relationship
|
|
from app.db.base import Base
|
|
|
|
|
|
class Customer(Base):
|
|
__tablename__ = "customers"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
name = Column(String, nullable=False)
|
|
email = Column(String, nullable=False)
|
|
phone = Column(String, nullable=True)
|
|
address = Column(Text, nullable=True)
|
|
city = Column(String, nullable=True)
|
|
state = Column(String, nullable=True)
|
|
zip_code = Column(String, nullable=True)
|
|
country = Column(String, nullable=True)
|
|
user_id = Column(Integer, ForeignKey("users.id"), nullable=False)
|
|
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
|
updated_at = Column(DateTime(timezone=True), onupdate=func.now())
|
|
|
|
owner = relationship("User", back_populates="customers")
|
|
invoices = relationship("Invoice", back_populates="customer")
|