from sqlalchemy import Column, Integer, String, Date, Float, Boolean, ForeignKey, Table, Enum, DateTime
from sqlalchemy.orm import relationship, declarative_base
from sqlalchemy.sql import func
from datetime import datetime, date
import enum

Base = declarative_base()

class AssinaturaAnual(Base):
    __tablename__ = 'assinaturas_anuais'
    
    id = Column(Integer, primary_key=True)
    militante_id = Column(Integer, ForeignKey('militantes.id'), nullable=False)
    data_inicio = Column(Date, nullable=False)
    data_fim = Column(Date, nullable=False)
    valor = Column(Float, nullable=False)
    
    militante = relationship('Militante', backref='assinaturas')
    
    @property
    def ativa(self):
        hoje = date.today()
        return self.data_inicio <= hoje <= self.data_fim 