pas.models.attendence

Attributes

AttendenceType

TYPES

Classes

Attendence

Mixin providing created/modified timestamps for all records.

Module Contents

pas.models.attendence.AttendenceType: TypeAlias = Literal['plenary', 'commission', 'study', 'shortest'][source]
pas.models.attendence.TYPES: dict[AttendenceType, str][source]
class pas.models.attendence.Attendence[source]

Bases: onegov.core.orm.Base, onegov.core.orm.mixins.TimestampMixin

Mixin providing created/modified timestamps for all records.

The columns are deferred loaded as this is primarily for logging and future forensics.

__tablename__ = 'pas_attendence'[source]
id: Column[uuid.UUID][source]
date: Column[datetime.date][source]
duration: Column[int][source]
type: Column[AttendenceType][source]
property type_label: str[source]
parliamentarian_id: Column[uuid.UUID][source]
parliamentarian: relationship[Parliamentarian][source]
commission_id: Column[uuid.UUID | None][source]
commission: relationship[Commission | None][source]
calculate_value() decimal.Decimal[source]

Calculate the value (in hours) for an attendance record.

The calculation follows these business rules: - Plenary sessions:

  • Always counted as 0.5 (half day), regardless of actual duration

This is the special case!

  • Everything else is counted as actual hours:
    • First 2 hours are counted as given

    • After 2 hours, time is rounded to nearest 30-minute increment,

    • and there is another rate applied for the additional time

    • Example: 2h 40min would be calculated as 2.5 hours

Examples:
>>> # Plenary session
>>> attendence.type = 'plenary'
>>> calculate_value(attendence)
'0.5'
>>> # Commission meeting, 2 hours
>>> attendence.type = 'commission'
>>> attendence.duration = 120  # minutes
>>> calculate_value(attendence)
'2.0'
>>> # Study session, 2h 40min
>>> attendence.type = 'study'
>>> attendence.duration = 160  # minutes
>>> calculate_value(attendence)
'2.5'
__repr__() str[source]