Source code for pas.models.presidential_allowance

from __future__ import annotations

from onegov.core.orm import Base
from onegov.core.orm.mixins import TimestampMixin
from onegov.pas import _
from sqlalchemy import ForeignKey
from sqlalchemy.orm import mapped_column
from sqlalchemy.orm import relationship
from sqlalchemy.orm import Mapped
from uuid import uuid4
from uuid import UUID


from typing import TYPE_CHECKING

if TYPE_CHECKING:
    from onegov.pas.models import PASParliamentarian
    from onegov.pas.models import SettlementRun


[docs] PRESIDENT_YEARLY_ALLOWANCE = 20_000
[docs] VICE_PRESIDENT_YEARLY_ALLOWANCE = 5_000
[docs] PRESIDENT_QUARTERLY = PRESIDENT_YEARLY_ALLOWANCE // 4 # 5000
[docs] VICE_PRESIDENT_QUARTERLY = VICE_PRESIDENT_YEARLY_ALLOWANCE // 4 # 1250
[docs] MAX_ALLOWANCES_PER_RUN = 4
[docs] ALLOWANCE_ROLES: dict[str, str] = { 'president': _('President'), 'vice_president': _('Vice president'), }
# FiBu account for presidential allowances # (amtliche Missionen Kantonsratspräsidiums)
[docs] FIBU_KONTO_ALLOWANCE = '3000.30'
[docs] LOHNART_ALLOWANCE_NR = '2411'
[docs] LOHNART_ALLOWANCE_TEXT = 'Jahreszulage KR-Präsidium'
[docs] class PresidentialAllowance(Base, TimestampMixin): """Tracks presidential allowances (Jahreszulage) for the president and vice president of the Kantonsrat. Each allowance is tied to a settlement run (max 4 per run). """
[docs] __tablename__ = 'pas_presidential_allowances'
#: Internal ID
[docs] id: Mapped[UUID] = mapped_column(primary_key=True, default=uuid4)
#: The role: 'president' or 'vice_president'
[docs] role: Mapped[str]
#: The amount in CHF (cents not needed, always whole francs)
[docs] amount: Mapped[int]
#: The id of the parliamentarian
[docs] parliamentarian_id: Mapped[UUID] = mapped_column( ForeignKey('par_parliamentarians.id'), )
#: The parliamentarian
[docs] parliamentarian: Mapped[PASParliamentarian] = relationship()
#: The settlement run this allowance belongs to
[docs] settlement_run_id: Mapped[UUID] = mapped_column( ForeignKey('pas_settlements.id'), )
#: The settlement run
[docs] settlement_run: Mapped[SettlementRun] = relationship()
@property
[docs] def role_label(self) -> str: return ALLOWANCE_ROLES.get(self.role, '')
[docs] def __repr__(self) -> str: return ( f'<PresidentialAllowance' f' run={self.settlement_run_id}' f' {self.role} {self.amount}>' )