"""Contract Flowthrough marshmallow schema.""" from abacus_common_logic.marshalling.custom_fields import ma from abacus_contract.constants.constants import \ CONTRACT_FLOWTHROUGH_PREVIOUS_STATUSES from abacus_contract.constants.constants import \ CONTRACT_FLOWTHROUGH_STATUSES class BaseContractFlowthroughSchema(ma.Schema): """Shared contract_flowthrough fields.""" contract_id = ma.IntegerId(required=True) reference_flowthrough_calculation_id = ma.IntegerId(required=True) flowthrough_rate = ma.Decimal(as_string=True, required=True) flowthrough_status = ma.Enum( options=CONTRACT_FLOWTHROUGH_STATUSES, required=True, data_key='flowthrough_status' ) has_automatic_shutoff = ma.Boolean(required=False) recoupment_cap = ma.IntegerId(required=False) previous_flowthrough_status = ma.Enum( options=CONTRACT_FLOWTHROUGH_PREVIOUS_STATUSES, required=False, data_key='previous_flowthrough_status' ) status_last_modified_by = ma.String(allow_none=True, required=False) status_last_modified = ma.FormattedDate(allow_none=True, required=False) class ContractFlowthroughDetailSchema(BaseContractFlowthroughSchema): """Schema for contract_flowthrough details.""" contract_flowthrough_id = ma.IntegerId(required=True) class ContractFlowthroughPutSchema(ma.Schema): """Schema for contract_flowthrough PUT request.""" reference_flowthrough_calculation_id = ma.IntegerId(required=False) flowthrough_rate = ma.Decimal(as_string=True, required=False) flowthrough_status = ma.Enum( options=CONTRACT_FLOWTHROUGH_STATUSES, required=False, data_key='flowthrough_status' ) has_automatic_shutoff = ma.Boolean(required=False) recoupment_cap = ma.IntegerId(required=False, allow_none=True) class ContractFlowthroughPostSchema(ma.Schema): """Schema for contract_flowthrough POST request.""" reference_flowthrough_calculation_id = ma.IntegerId(required=True) flowthrough_rate = ma.Decimal(as_string=True, required=True) has_automatic_shutoff = ma.Boolean(required=True) recoupment_cap = ma.IntegerId(required=False, allow_none=True)