44from io import StringIO , BytesIO
55from audit_table import change_audit_table_status_to_processed
66from common .clients import get_s3_client , logger
7- from constants import ACK_HEADERS , get_source_bucket_name , get_ack_bucket_name
8- from logging_decorators import upload_ack_file_logging_decorator
7+ from constants import ACK_HEADERS , get_source_bucket_name , get_ack_bucket_name , COMPLETED_ACK_DIR , TEMP_ACK_DIR , \
8+ BATCH_FILE_PROCESSING_DIR , BATCH_FILE_ARCHIVE_DIR
9+ from logging_decorators import complete_batch_file_process_logging_decorator
910
1011
1112def create_ack_data (
@@ -43,7 +44,7 @@ def create_ack_data(
4344 }
4445
4546
46- @upload_ack_file_logging_decorator
47+ @complete_batch_file_process_logging_decorator
4748def complete_batch_file_process (
4849 message_id : str ,
4950 supplier : str ,
@@ -54,12 +55,18 @@ def complete_batch_file_process(
5455) -> dict :
5556 """Mark the batch file as processed. This involves moving the ack and original file to destinations and updating
5657 the audit table status"""
57- ack_bucket_name = get_ack_bucket_name ()
58- source_bucket_name = get_source_bucket_name ()
5958 ack_filename = f"{ file_key .replace ('.csv' , f'_BusAck_{ created_at_formatted_string } .csv' )} "
6059
61- move_file (ack_bucket_name , f"TempAck/{ ack_filename } " , f"forwardedFile/{ ack_filename } " )
62- move_file (source_bucket_name , f"processing/{ file_key } " , f"archive/{ file_key } " )
60+ move_file (
61+ get_ack_bucket_name (),
62+ f"{ TEMP_ACK_DIR } /{ ack_filename } " ,
63+ f"{ COMPLETED_ACK_DIR } /{ ack_filename } "
64+ )
65+ move_file (
66+ get_source_bucket_name (),
67+ f"{ BATCH_FILE_PROCESSING_DIR } /{ file_key } " ,
68+ f"{ BATCH_FILE_ARCHIVE_DIR } /{ file_key } "
69+ )
6370
6471 change_audit_table_status_to_processed (file_key , message_id )
6572
@@ -99,8 +106,8 @@ def update_ack_file(
99106) -> None :
100107 """Updates the ack file with the new data row based on the given arguments"""
101108 ack_filename = f"{ file_key .replace ('.csv' , f'_BusAck_{ created_at_formatted_string } .csv' )} "
102- temp_ack_file_key = f"TempAck /{ ack_filename } "
103- archive_ack_file_key = f"forwardedFile /{ ack_filename } "
109+ temp_ack_file_key = f"{ TEMP_ACK_DIR } /{ ack_filename } "
110+ archive_ack_file_key = f"{ COMPLETED_ACK_DIR } /{ ack_filename } "
104111 accumulated_csv_content = obtain_current_ack_content (temp_ack_file_key )
105112
106113 for row in ack_data_rows :
0 commit comments