"""Contract Lifecycle marshmallow schema.""" from abacus_common_logic.marshalling.custom_fields import ma from abacus_contract.constants.constants import CONTRACT_LIFECYCLE_STATUSES class BaseContractLifecycleSchema(ma.Schema): """Shared contract_lifecycle fields.""" contract_id = ma.IntegerId(required=True) contract_lifecycle_schedule_id = ma.IntegerId(required=True) lifecycle_status = ma.Enum( options=CONTRACT_LIFECYCLE_STATUSES, required=True, data_key='lifecycle_status' ) lifecycle_term_start = ma.FormattedDate(allow_none=False) lifecycle_term_end = ma.FormattedDate(allow_none=True) renewal_effective = ma.FormattedDate(allow_none=True) termination_notice_deadline = ma.FormattedDate(allow_none=True) termination_notice_received = ma.FormattedDate(allow_none=True) termination_effective = ma.FormattedDate(allow_none=True) collection_start = ma.FormattedDate(allow_none=True) collection_end = ma.FormattedDate(allow_none=True) last_renewed = ma.FormattedDate(allow_none=True) class ContractLifecycleDetailSchema(BaseContractLifecycleSchema): """Schema for contract_lifecycle details.""" contract_lifecycle_id = ma.IntegerId(required=True) class ContractLifecyclePostSchema(ma.Schema): """Schema for contract_lifecycle POST request.""" lifecycle_term_start = ma.FormattedDate(required=True)