from datetime import date from sqlalchemy import Column, Date, ForeignKey, Integer, Numeric, String, Text, Enum from sqlalchemy.orm import relationship import enum from app.db.session import Base from app.models.base import Base as CustomBase class PaymentMethod(str, enum.Enum): """Enum for payment methods.""" CREDIT_CARD = "credit_card" BANK_TRANSFER = "bank_transfer" CASH = "cash" CHECK = "check" PAYPAL = "paypal" OTHER = "other" class Payment(Base, CustomBase): """Payment model for tracking invoice payments.""" amount = Column(Numeric(10, 2), nullable=False) payment_date = Column(Date, nullable=False, default=date.today) payment_method = Column(Enum(PaymentMethod), nullable=False) reference = Column(String(255), nullable=True) notes = Column(Text, nullable=True) # Foreign keys invoice_id = Column(Integer, ForeignKey("invoice.id"), nullable=False) # Relationships invoice = relationship("Invoice", back_populates="payments")