Skip to content

Commit

Permalink
FYLE-1xqdn4y: Extracting post date from bank feeds
Browse files Browse the repository at this point in the history
  • Loading branch information
Kulsekar4 authored Feb 6, 2022
1 parent 3745205 commit ab8b8e3
Show file tree
Hide file tree
Showing 17 changed files with 81 additions and 28 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

## [0.8.0]

### Changed

- Fetching the `post_date` from amex, cdf, s3df and vcf parsers.

## [0.7.0]

### Changed
Expand Down
1 change: 1 addition & 0 deletions card_data_parsers/models/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ class Transaction:
description: str = None
external_id: str = None
bank_name: str = None
post_date: str = None
1 change: 1 addition & 0 deletions card_data_parsers/parsers/amex_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def __extract_transaction_fields(txn_line, default_values):
txn.transaction_type = txn_line[736:737].strip()
txn.description = txn_line[946:991].strip()
txn.external_id = txn_line[631:681].strip()
txn.post_date = get_iso_date_string(txn_line[573:581].strip(), "%Y%m%d")
txn.decimal_place_indicator = txn_line[768:769].strip()
txn.merchant_category_code = txn_line[1678:1681].strip()

Expand Down
6 changes: 6 additions & 0 deletions card_data_parsers/parsers/cdf_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ def __extract_transaction_fields(root: ElementTree, account_number, nickname, de
txn.transaction_dt = get_iso_date_string(
txn.transaction_dt.strip(), '%Y-%m-%d')

# Post Date
txn.post_date = CDFParser.__get_element_by_tag(
ftrxn, 'PostingDate').text
txn.post_date = get_iso_date_string(
txn.post_date.strip(), '%Y-%m-%d')

# Transaction Type
txn.transaction_type = CDFParser.__get_element_by_tag(
ftrxn, 'DebitOrCreditIndicator').text
Expand Down
6 changes: 6 additions & 0 deletions card_data_parsers/parsers/s3df_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ def __extract_transaction_fields(root, account_number, default_values):
txn.transaction_dt = get_iso_date_string(
txn.transaction_dt.strip(), '%Y-%m-%d')

# Post Date
txn.post_date = S3DFParser.__get_element_by_tag(
ftrxn, 'PostingDate').text
txn.post_date = get_iso_date_string(
txn.post_date.strip(), '%Y-%m-%d')

# Transaction Type
txn.transaction_type = S3DFParser.__get_element_by_tag(
ftrxn, 'DebitOrCreditIndicator').text
Expand Down
4 changes: 4 additions & 0 deletions card_data_parsers/parsers/vcf_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ def __process_transaction(txn, account_number_mask_begin, account_number_mask_en
txn.transaction_dt = get_iso_date_string(
txn.transaction_dt.strip(), '%m%d%Y')

txn.post_date = get_iso_date_string(
txn.post_date.strip(), '%m%d%Y')

card_num = txn.account_number
# Masking the card number
if account_number_mask_begin is not None and account_number_mask_end is not None:
Expand Down Expand Up @@ -121,6 +124,7 @@ def __extract_transaction_fields(transaction, default_values):
txn.external_id = transaction[3].strip()
txn.merchant_category_code = transaction[16].strip()
txn.sequence_number = transaction[4].strip()
txn.post_date = transaction[2].strip()

# other amounts to consider are
# at positions 20, 28, 29
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

setup(
name='card_data_parsers',
version='0.7.0',
version='0.8.0',
author='Siva Narayanan',
author_email='[email protected]',
url='https://www.fylehq.com',
Expand Down
1 change: 1 addition & 0 deletions tests/card_data_parsers/amex/p1/expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"merchant_category_code": "10",
"vendor": "5",
"bank_name": "Test Bank",
"post_date": "2009-05-26T10:00:00.000000Z",
"transaction_id": "0914600172007637906017110005010001521"
}
]
1 change: 1 addition & 0 deletions tests/card_data_parsers/amex/p2/expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"merchant_category_code": "10",
"vendor": "5",
"bank_name": "Test Bank",
"post_date": "2009-05-26T10:00:00.000000Z",
"transaction_id": "0914600172007637906017110005010001521"
}
]
12 changes: 8 additions & 4 deletions tests/card_data_parsers/cdf/p2/expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"amount": "13.99",
"currency": "EUR",
"vendor": "ABCDEF",
"external_id": "bcc54fff373cf5b4eb1b3b8c53c111bf"
"external_id": "bcc54fff373cf5b4eb1b3b8c53c111bf",
"post_date": "2018-12-20T10:00:00.000000Z"
},
{
"account_number": "1234*********1213",
Expand All @@ -15,7 +16,8 @@
"amount": "130",
"currency": "EUR",
"vendor": "ABCDEF",
"external_id": "c36c9ba0602a898336e1c08360495d5d"
"external_id": "c36c9ba0602a898336e1c08360495d5d",
"post_date": "2018-12-20T10:00:00.000000Z"
},
{
"account_number": "1234*********1213",
Expand All @@ -24,7 +26,8 @@
"amount": "38.63",
"currency": "EUR",
"vendor": "ABCDEF",
"external_id": "379e9c62e0804eeb9ff0864fb03b96f0"
"external_id": "379e9c62e0804eeb9ff0864fb03b96f0",
"post_date": "2018-12-20T10:00:00.000000Z"
},
{
"account_number": "1234*********1213",
Expand All @@ -33,6 +36,7 @@
"amount": "129",
"currency": "EUR",
"vendor": "ABCDEF",
"external_id": "14a181d358d82b3dd3532e5ec47653d8"
"external_id": "14a181d358d82b3dd3532e5ec47653d8",
"post_date": "2018-12-20T10:00:00.000000Z"
}
]
9 changes: 6 additions & 3 deletions tests/card_data_parsers/cdf/p3/expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"amount": "5",
"currency": "EUR",
"vendor": "Abcd",
"external_id": "516f72d0902bafeec0448b23a9735b94"
"external_id": "516f72d0902bafeec0448b23a9735b94",
"post_date": "2018-12-19T10:00:00.000000Z"
},
{
"account_number": "1234*********1213",
Expand All @@ -15,7 +16,8 @@
"amount": "3.89",
"currency": "EUR",
"vendor": "Abcd",
"external_id": "7479ca62690d075b08a39e072df79c2a"
"external_id": "7479ca62690d075b08a39e072df79c2a",
"post_date": "2018-12-19T10:00:00.000000Z"
},
{
"account_number": "1234*********1213",
Expand All @@ -24,6 +26,7 @@
"amount": "89",
"currency": "EUR",
"vendor": "Abcdedfgh",
"external_id": "79c952ed6c2e4fb3038a405dc494cade"
"external_id": "79c952ed6c2e4fb3038a405dc494cade",
"post_date": "2018-12-19T10:00:00.000000Z"
}
]
9 changes: 6 additions & 3 deletions tests/card_data_parsers/cdf/p4/expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"amount": "5",
"currency": "EUR",
"vendor": "Abcd",
"external_id": "516f72d0902bafeec0448b23a9735b94"
"external_id": "516f72d0902bafeec0448b23a9735b94",
"post_date": "2018-12-19T10:00:00.000000Z"
},
{
"account_number": "12345678910111213",
Expand All @@ -15,7 +16,8 @@
"amount": "3.89",
"currency": "EUR",
"vendor": "Abcd",
"external_id": "7479ca62690d075b08a39e072df79c2a"
"external_id": "7479ca62690d075b08a39e072df79c2a",
"post_date": "2018-12-19T10:00:00.000000Z"
},
{
"account_number": "12345678910111213",
Expand All @@ -24,6 +26,7 @@
"amount": "89",
"currency": "EUR",
"vendor": "Abcdedfgh",
"external_id": "79c952ed6c2e4fb3038a405dc494cade"
"external_id": "79c952ed6c2e4fb3038a405dc494cade",
"post_date": "2018-12-19T10:00:00.000000Z"
}
]
21 changes: 14 additions & 7 deletions tests/card_data_parsers/s3df/p1/expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"amount": "294.97",
"currency": "GBP",
"vendor": "Abcd, --",
"external_id": "5e65fcc2d8388da145d00043ce50dff9"
"external_id": "5e65fcc2d8388da145d00043ce50dff9",
"post_date": "2019-10-02T10:00:00.000000Z"
},
{
"account_number": "2344******7566",
Expand All @@ -15,7 +16,8 @@
"amount": "109",
"currency": "GBP",
"vendor": "Abcd, --",
"external_id": "739a85df06f04d7c823c3a9012cf05e3"
"external_id": "739a85df06f04d7c823c3a9012cf05e3",
"post_date": "2019-10-02T10:00:00.000000Z"
},
{
"account_number": "2344******7567",
Expand All @@ -24,7 +26,8 @@
"amount": "2098.8",
"currency": "GBP",
"vendor": "PARK PLAZA LONDON WATE, --",
"external_id": "bdafcb93370618638a43b53cc5880a28"
"external_id": "bdafcb93370618638a43b53cc5880a28",
"post_date": "2019-10-02T10:00:00.000000Z"
},
{
"account_number": "2344******7567",
Expand All @@ -33,7 +36,8 @@
"amount": "5.64",
"currency": "GBP",
"vendor": "Abcd, --",
"external_id": "1a9375ab8269860d6ee2c1c758f4694d"
"external_id": "1a9375ab8269860d6ee2c1c758f4694d",
"post_date": "2019-10-02T10:00:00.000000Z"
},
{
"account_number": "2344******7567",
Expand All @@ -44,7 +48,8 @@
"foreign_amount": "230.4",
"foreign_currency": "EUR",
"vendor": "Abcd, --",
"external_id": "0205ba3ba7e22335177c2bb52e1bf68f"
"external_id": "0205ba3ba7e22335177c2bb52e1bf68f",
"post_date": "2019-10-02T10:00:00.000000Z"
},
{
"account_number": "2344******7567",
Expand All @@ -53,7 +58,8 @@
"amount": "74",
"currency": "GBP",
"vendor": "Abcd, --",
"external_id": "d331fbcc2d265d4d016b4f6ce76c66b9"
"external_id": "d331fbcc2d265d4d016b4f6ce76c66b9",
"post_date": "2019-10-02T10:00:00.000000Z"
},
{
"account_number": "2344******7567",
Expand All @@ -62,6 +68,7 @@
"amount": "74",
"currency": "GBP",
"vendor": "Abcd, --",
"external_id": "9cf17c980e286b7f88b775d5bb343b18"
"external_id": "9cf17c980e286b7f88b775d5bb343b18",
"post_date": "2019-10-02T10:00:00.000000Z"
}
]
21 changes: 14 additions & 7 deletions tests/card_data_parsers/s3df/p2/expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"amount": "294.97",
"currency": "GBP",
"vendor": "Abcd, --",
"external_id": "5e65fcc2d8388da145d00043ce50dff9"
"external_id": "5e65fcc2d8388da145d00043ce50dff9",
"post_date": "2019-10-02T10:00:00.000000Z"
},
{
"account_number": "23445345667566",
Expand All @@ -15,7 +16,8 @@
"amount": "109",
"currency": "GBP",
"vendor": "Abcd, --",
"external_id": "739a85df06f04d7c823c3a9012cf05e3"
"external_id": "739a85df06f04d7c823c3a9012cf05e3",
"post_date": "2019-10-02T10:00:00.000000Z"
},
{
"account_number": "23445345667567",
Expand All @@ -24,7 +26,8 @@
"amount": "2098.8",
"currency": "GBP",
"vendor": "PARK PLAZA LONDON WATE, --",
"external_id": "bdafcb93370618638a43b53cc5880a28"
"external_id": "bdafcb93370618638a43b53cc5880a28",
"post_date": "2019-10-02T10:00:00.000000Z"
},
{
"account_number": "23445345667567",
Expand All @@ -33,7 +36,8 @@
"amount": "5.64",
"currency": "GBP",
"vendor": "Abcd, --",
"external_id": "1a9375ab8269860d6ee2c1c758f4694d"
"external_id": "1a9375ab8269860d6ee2c1c758f4694d",
"post_date": "2019-10-02T10:00:00.000000Z"
},
{
"account_number": "23445345667567",
Expand All @@ -44,7 +48,8 @@
"foreign_amount": "230.4",
"foreign_currency": "EUR",
"vendor": "Abcd, --",
"external_id": "0205ba3ba7e22335177c2bb52e1bf68f"
"external_id": "0205ba3ba7e22335177c2bb52e1bf68f",
"post_date": "2019-10-02T10:00:00.000000Z"
},
{
"account_number": "23445345667567",
Expand All @@ -53,7 +58,8 @@
"amount": "74",
"currency": "GBP",
"vendor": "Abcd, --",
"external_id": "d331fbcc2d265d4d016b4f6ce76c66b9"
"external_id": "d331fbcc2d265d4d016b4f6ce76c66b9",
"post_date": "2019-10-02T10:00:00.000000Z"
},
{
"account_number": "23445345667567",
Expand All @@ -62,6 +68,7 @@
"amount": "74",
"currency": "GBP",
"vendor": "Abcd, --",
"external_id": "9cf17c980e286b7f88b775d5bb343b18"
"external_id": "9cf17c980e286b7f88b775d5bb343b18",
"post_date": "2019-10-02T10:00:00.000000Z"
}
]
3 changes: 2 additions & 1 deletion tests/card_data_parsers/vcf/p1/expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"external_id": "21f3c22b19f44df7536cf16ba1040ecd",
"merchant_category_code": "5044",
"sequence_number": "0032044068",
"bank_name": "Test Bank"
"bank_name": "Test Bank",
"post_date": "2019-01-03T10:00:00.000000Z"
}
]
3 changes: 2 additions & 1 deletion tests/card_data_parsers/vcf/p2/expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"external_id": "3d31ebfed8cb00c26db8403d5f744598",
"bank_name": "Test Bank",
"merchant_category_code": "",
"sequence_number": "0000009688"
"sequence_number": "0000009688",
"post_date": "2021-11-12T10:00:00.000000Z"
}
]
3 changes: 2 additions & 1 deletion tests/card_data_parsers/vcf/p3/expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"external_id": "a0b742b2bcd36a151c75cfaeadd4ba96",
"bank_name": "Test Bank",
"merchant_category_code": "",
"sequence_number": "0000009688"
"sequence_number": "0000009688",
"post_date": "2021-11-12T10:00:00.000000Z"
}
]

0 comments on commit ab8b8e3

Please sign in to comment.