"""A Task to make a snapshot of account payment terms.""" from lib.utils import aws from lib.utils import ows from tasks.accounting_period_calculate_vat import helpers def snapshot_account_payment_terms_task(dag_run, **kwargs): """Request for csv data and write it to s3.""" event = helpers.get_event_from_params(dag_run, **kwargs) accounting_period = ows.get_accounting_period_details(event.target_id) accounting_period_id = accounting_period.get('accounting_period_id') payment_terms_snapshot_s3_path = helpers.build_snapshot_path_for_module( accounting_period_id, accounting_period.get('accounting_period_name'), module_name='account_payment_terms.tsv' ) payment_terms_data = ows.get_account_payment_term_snapshot() aws.write_file( aws.location(payment_terms_snapshot_s3_path).url, payment_terms_data)