"""Accounting Period marshmallow schema.""" from abacus_common_logic.marshalling.custom_fields import ma from royalties.constants.constants import ACCOUNTING_PERIOD_STATUSES, CONTRACT_TYPES class AccountingPeriodDetailSchema(ma.Schema): """Accounting Period GET response.""" accounting_period_id = ma.IntegerId() accounting_period_name = ma.NonemptyString(required=True) accounting_period_status = ma.Enum( options=ACCOUNTING_PERIOD_STATUSES, data_key='accounting_period_status' ) closed_date = ma.FormattedDate(allow_none=True) contract_type = ma.Enum(options=CONTRACT_TYPES, data_key='contract_type') is_visible = ma.Boolean(required=True, default=True) statement_period_id = ma.IntegerId(required=True) visible_reason = ma.String(allow_none=True) class AccountingPeriodPostSchema(ma.Schema): """Accounting Period POST request body.""" accounting_period_name = ma.NonemptyString(required=True) contract_type = ma.Enum( options=CONTRACT_TYPES, data_key='contract_type', required=True ) statement_period_id = ma.IntegerId(required=True) class AccountingPeriodPutSchema(ma.Schema): """Accounting Period PUT request body.""" accounting_period_name = ma.String() accounting_period_status = ma.Enum( options=ACCOUNTING_PERIOD_STATUSES, data_key='accounting_period_status' )