21 lines
1.0 KiB
Python
21 lines
1.0 KiB
Python
from sqlalchemy import Column, Integer, String, Date, Float, ForeignKey
|
|
from sqlalchemy.orm import relationship, declarative_base
|
|
|
|
Base = declarative_base()
|
|
|
|
class Fatura(Base):
|
|
__tablename__ = 'faturas' # Nome da tabela no banco
|
|
|
|
id = Column(Integer, primary_key=True, autoincrement=True) # Chave primária
|
|
numero = Column(String(50), unique=True, nullable=False) # Número da fatura
|
|
data_emissao = Column(Date, nullable=False) # Data de emissão da fatura
|
|
data_vencimento = Column(Date, nullable=False) # Data de vencimento
|
|
valor_total = Column(Float, nullable=False) # Valor total da fatura
|
|
status = Column(String(20), nullable=False, default="pendente") # Status da fatura
|
|
|
|
cliente_id = Column(Integer, ForeignKey('clientes.id'), nullable=False) # FK para cliente
|
|
cliente = relationship("Cliente", back_populates="faturas") # Relacionamento com Cliente
|
|
|
|
def __repr__(self):
|
|
return f"<Fatura(id={self.id}, numero='{self.numero}', status='{self.status}', valor_total={self.valor_total})>"
|