updated parser
This commit is contained in:
@@ -39,11 +39,11 @@ class FileProcessor:
|
||||
remote_path: str
|
||||
) -> bool:
|
||||
"""
|
||||
Process a single ACH file end-to-end.
|
||||
Process a single NACH INWARD file end-to-end.
|
||||
|
||||
Workflow:
|
||||
1. Download file from SFTP
|
||||
2. Parse using ACHParser
|
||||
2. Parse using NEFT_INWARD_Parser
|
||||
3. Map to database format
|
||||
4. Insert to database
|
||||
5. Mark as processed
|
||||
@@ -72,18 +72,10 @@ class FileProcessor:
|
||||
raise Exception(f"Failed to download file: {remote_path}")
|
||||
|
||||
# Step 3: Parse file
|
||||
#parser = ACHParser(local_path)
|
||||
|
||||
# Choose parser by filename prefix
|
||||
|
||||
|
||||
parser = NEFT_INWARD_Parser(local_path)
|
||||
# if filename.startswith('ACH_'):
|
||||
# parser = ACHParser(local_path)
|
||||
# elif filename.startswith('UIH_'):
|
||||
# parser = UIHParser(local_path)
|
||||
# else:
|
||||
# logger.warning(f"Unknown file type for parser: {filename}")
|
||||
# return False
|
||||
|
||||
|
||||
transactions, metadata, summary = parser.parse()
|
||||
|
||||
@@ -104,7 +96,7 @@ class FileProcessor:
|
||||
mapped_records = NEFTDataMapper.map_transactions(transactions, bankcode)
|
||||
|
||||
# Step 5: Insert to database (with account validation)
|
||||
inserted_count = self.repository.bulk_insert_transactions(mapped_records)
|
||||
inserted_count, skipped_count = self.repository.bulk_insert_transactions(mapped_records)
|
||||
|
||||
# Step 6: Mark file as processed
|
||||
processed_file = ProcessedFile(
|
||||
@@ -116,7 +108,7 @@ class FileProcessor:
|
||||
)
|
||||
self.repository.mark_file_processed(processed_file)
|
||||
|
||||
logger.info(f"Successfully processed {filename}: {inserted_count} inserted")
|
||||
logger.info(f"Successfully processed {filename}: {inserted_count} inserted, {skipped_count} skipped (non-ipks accounts)")
|
||||
return True
|
||||
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user