"""A Task to make a snapshot of account tax info.""" from lib.utils import aws from lib.utils import ows from tasks.accounting_period_calculate_vat import helpers def snapshot_account_tax_info_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') tax_info_snapshot_s3_path = helpers.build_snapshot_path_for_module( accounting_period_id, accounting_period.get('accounting_period_name'), module_name='account_tax_info.tsv' ) tax_info_data = ows.get_account_tax_info_snapshot() aws.write_file(aws.location(tax_info_snapshot_s3_path).url, tax_info_data)