from sqlalchemy import Column, Integer, String, Numeric, DateTime
from sqlalchemy.orm import relationship
from models._system import Base


class ProvisiongroupPgro(Base):
    __tablename__ = 'provisiongroup_pgro'

    id_pgro = Column(
        Integer,
        primary_key=True,
        autoincrement=True
    )
    name_pgro = Column(
        String(255),
        nullable=False
    )
    percent_pgro = Column(
        Numeric(5, 2),
        nullable=False,
        default=0.00
    )
    created_pgro = Column(
        DateTime,
        nullable=False
    )
    updated_pgro = Column(
        DateTime,
        nullable=True
    )

    deals = relationship(
        "DealDeal",
        back_populates="provisiongroup"
    )
    options = relationship(
        "OptionOpti",
        back_populates="provisiongroup"
    )
