"""A Task to set ERROR statuses for vat related state actions.""" from lib.constants import ABACUS_STATE_STATUSES from lib.utils import ows from tasks.accounting_period_calculate_vat import helpers def notify_failure_task(dag_run, **kwargs): """Update vat related actions for accounting period.""" event = helpers.get_event_from_params(dag_run, **kwargs) accounting_period = ows.get_accounting_period_details(event.target_id) action_states = ows.get_abacus_states( parent_table_name='accounting_period', parent_table_id=accounting_period['accounting_period_id'] ) calculate_vat_action_id = helpers.get_abacus_state_id_by_action_name( action_states, 'calculate_vat' ) if calculate_vat_action_id: helpers.set_abacus_action_to_status( calculate_vat_action_id, ABACUS_STATE_STATUSES.ERROR )