diff --git a/CHANGELOG.md b/CHANGELOG.md index 67df162..a0d39a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Change Log +## [0.17.0] + +### Changed + +- Updated CDF parser to use employee id when masking account number + ## [0.16.0] ### Changed diff --git a/card_data_parsers/parsers/cdf_parser.py b/card_data_parsers/parsers/cdf_parser.py index 388aa11..96762b1 100644 --- a/card_data_parsers/parsers/cdf_parser.py +++ b/card_data_parsers/parsers/cdf_parser.py @@ -44,7 +44,7 @@ def __get_amount(amount, exponent): return amount @staticmethod - def __extract_transaction_fields(root: ElementTree, account_number, nickname, default_values): + def __extract_transaction_fields(root: ElementTree, account_number, nickname, default_values, use_employee_id_mask_for_account_number): txn = CDFTransaction(**default_values) txn.account_number = account_number @@ -127,6 +127,10 @@ def __extract_transaction_fields(root: ElementTree, account_number, nickname, de ftrxn, 'MasterCardFinancialTransactionId').text txn.external_id = generate_external_id(external_id) + if use_employee_id_mask_for_account_number: + employee_id = CDFParser.__get_element_by_tag( + ftrxn, 'EmployeeId').text + txn.account_number = str(employee_id) + str(txn.account_number) return txn @staticmethod @@ -260,7 +264,7 @@ def __extract_nickname(account): return nickname @staticmethod - def __extract_transactions(root, account_number_mask_begin, account_number_mask_end, default_values, mandatory_fields): + def __extract_transactions(root, account_number_mask_begin, account_number_mask_end, default_values, mandatory_fields, use_employee_id_mask_for_account_number): txns = [] issuer_entity = CDFParser.__get_element_by_tag(root, 'IssuerEntity') if issuer_entity is None: @@ -289,7 +293,7 @@ def __extract_transactions(root, account_number_mask_begin, account_number_mask_ for transaction in financial_transaction_entities: txn = CDFParser.__extract_transaction_fields( - transaction, account_number, nickname, default_values) + transaction, account_number, nickname, default_values, use_employee_id_mask_for_account_number) lodging_transaction_entities = CDFParser.__get_elements_by_tag( transaction, 'LodgingSummaryAddendumEntity') @@ -318,7 +322,7 @@ def __extract_transactions(root, account_number_mask_begin, account_number_mask_ return txns @staticmethod - def parse(file_obj, account_number_mask_begin=None, account_number_mask_end=None, default_values={}, mandatory_fields=[]) -> List[CDFTransaction]: + def parse(file_obj, account_number_mask_begin=None, account_number_mask_end=None, default_values={}, mandatory_fields=[], use_employee_id_mask_for_account_number=False) -> List[CDFTransaction]: root: ElementTree = ET.parse(file_obj).getroot() if root is None: return None @@ -327,4 +331,4 @@ def parse(file_obj, account_number_mask_begin=None, account_number_mask_end=None return None return CDFParser.__extract_transactions( - root, account_number_mask_begin, account_number_mask_end, default_values, mandatory_fields) + root, account_number_mask_begin, account_number_mask_end, default_values, mandatory_fields, use_employee_id_mask_for_account_number)