Skip to content

Commit

Permalink
Include ms in transaction_dt (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
Code0987 authored Sep 29, 2021
1 parent a85a172 commit b777448
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 28 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Change Log

## [0.3.0]

### Changed

- Changed `transaction_dt` to include milliseconds. Updated function `get_iso_date_string`.
- Affects `external_id`
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ git push origin v0.1.0
The parse method is supposed to return a list of transactions. This is a list of python dict objects that looks like this:

```
[{"bank_name": "Test BANK", "vendor": "Test", "sync_type": "BANK FEED - VCF", "transaction_type": "debit", "currency": "EUR", "amount": "124.74", "transaction_date": "2018-11-30T10:00:00Z", "account_number": "4142********6333", "transaction_dt": "2018-11-30T10:00:00Z", "external_id": "b2a242d1d9814394b594044b77f36f2f"}]
[{"bank_name": "Test BANK", "vendor": "Test", "sync_type": "BANK FEED - VCF", "transaction_type": "debit", "currency": "EUR", "amount": "124.74", "transaction_date": "2018-11-30T10:00:00.000000Z", "account_number": "4142********6333", "transaction_dt": "2018-11-30T10:00:00.000000Z", "external_id": "b2a242d1d9814394b594044b77f36f2f"}]
```

If there is any non-backward compatible change to this structure e.g. a key is deleted, then bump up major number. Otherwise, bump up minor number.
2 changes: 1 addition & 1 deletion card_data_parsers/parsers/happay_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def __get_transaction_from_line(trxn_line_orig, account_number_mask_begin, accou

# transaction date
txn.transaction_dt = datetime.datetime.strptime(txn.transaction_dt.strip(), "%Y-%m-%d")
txn.transaction_dt = txn.transaction_dt.strftime("%Y-%m-%dT%H:%M:%SZ")
txn.transaction_dt = txn.transaction_dt.strftime("%Y-%m-%dT%H:%M:%S.%fZ")

# orig amount and orig currency
if txn.foreign_amount and txn.foreign_currency:
Expand Down
2 changes: 1 addition & 1 deletion card_data_parsers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def get_iso_date_string(date_string, date_format):
iso_date_string = datetime.strptime(date_string.strip(), date_format)
# hack for timezones: set time to 10 o clock
iso_date_string = iso_date_string.replace(hour=10)
iso_date_string = iso_date_string.strftime("%Y-%m-%dT%H:%M:%SZ")
iso_date_string = iso_date_string.strftime("%Y-%m-%dT%H:%M:%S.%fZ")
else:
iso_date_string = None

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.2.0',
version='0.3.0',
author='Siva Narayanan',
author_email='[email protected]',
url='https://www.fylehq.com',
Expand Down
4 changes: 2 additions & 2 deletions tests/card_data_parsers/amex/p1/expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
"currency": "CAD",
"foreign_amount": "48.33",
"foreign_currency": "USD",
"transaction_dt": "2009-03-13T10:00:00Z",
"transaction_dt": "2009-03-13T10:00:00.000000Z",
"transaction_type": "debit",
"description": "ABC-DEF 9511 HXLGGHWZOV M ZA",
"external_id": "dd11f01234dde3c25b1a4d87a764201e",
"external_id": "0d3eaafa0c8f934f362c53bb2d3ccd67",
"merchant_category_code": "10",
"vendor": "5",
"bank_name": "Test Bank"
Expand Down
8 changes: 4 additions & 4 deletions tests/card_data_parsers/cdf/p2/expected.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[
{
"account_number": "1234*********1213",
"transaction_dt": "2018-12-18T10:00:00Z",
"transaction_dt": "2018-12-18T10:00:00.000000Z",
"transaction_type": "debit",
"amount": "13.99",
"currency": "EUR",
Expand All @@ -10,7 +10,7 @@
},
{
"account_number": "1234*********1213",
"transaction_dt": "2018-12-19T10:00:00Z",
"transaction_dt": "2018-12-19T10:00:00.000000Z",
"transaction_type": "debit",
"amount": "130",
"currency": "EUR",
Expand All @@ -19,7 +19,7 @@
},
{
"account_number": "1234*********1213",
"transaction_dt": "2018-12-19T10:00:00Z",
"transaction_dt": "2018-12-19T10:00:00.000000Z",
"transaction_type": "debit",
"amount": "38.63",
"currency": "EUR",
Expand All @@ -28,7 +28,7 @@
},
{
"account_number": "1234*********1213",
"transaction_dt": "2018-12-19T10:00:00Z",
"transaction_dt": "2018-12-19T10:00:00.000000Z",
"transaction_type": "debit",
"amount": "129",
"currency": "EUR",
Expand Down
6 changes: 3 additions & 3 deletions tests/card_data_parsers/cdf/p3/expected.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[
{
"account_number": "1234*********1213",
"transaction_dt": "2018-12-18T10:00:00Z",
"transaction_dt": "2018-12-18T10:00:00.000000Z",
"transaction_type": "debit",
"amount": "5",
"currency": "EUR",
Expand All @@ -10,7 +10,7 @@
},
{
"account_number": "1234*********1213",
"transaction_dt": "2018-12-18T10:00:00Z",
"transaction_dt": "2018-12-18T10:00:00.000000Z",
"transaction_type": "debit",
"amount": "3.89",
"currency": "EUR",
Expand All @@ -19,7 +19,7 @@
},
{
"account_number": "1234*********1213",
"transaction_dt": "2018-12-18T10:00:00Z",
"transaction_dt": "2018-12-18T10:00:00.000000Z",
"transaction_type": "debit",
"amount": "89",
"currency": "EUR",
Expand Down
12 changes: 6 additions & 6 deletions tests/card_data_parsers/happay/p1/expected.json
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
[
{
"transaction_dt": "2021-08-13T00:00:00Z",
"transaction_dt": "2021-08-13T00:00:00.000000Z",
"account_number": "**0123",
"vendor": "RandomVendor1",
"amount": 624.0,
"transaction_type": "debit",
"description": "",
"external_id": "22ad6bf6230053b0fdd4a17717615004",
"external_id": "60daa9e0ec4a6020f1e0c8f6e9b7b32b",
"nickname": "Boi1",
"currency": "INR",
"foreign_amount": 624.0,
"foreign_currency": "INR",
"bank_name": "Test Bank"
},
{
"transaction_dt": "2021-08-12T00:00:00Z",
"transaction_dt": "2021-08-12T00:00:00.000000Z",
"account_number": "**0123",
"vendor": "RandomVendor2",
"amount": 1005.0,
"transaction_type": "debit",
"description": "",
"external_id": "3bb23c91900be9c326f7b80575250831",
"external_id": "30386309fbdaa313e31cde98fcc261c2",
"nickname": "Boi2",
"currency": "INR",
"foreign_amount": 1005.0,
"foreign_currency": "INR",
"bank_name": "Test Bank"
},
{
"transaction_dt": "2021-08-12T00:00:00Z",
"transaction_dt": "2021-08-12T00:00:00.000000Z",
"account_number": "**0124",
"vendor": "RandomVendor3",
"amount": 114431.81,
"transaction_type": "debit",
"description": "",
"external_id": "910efbef3c4ab927fd4d8a2cd87ab664",
"external_id": "55e4b13075a195ea9c8bdeea59025e9f",
"nickname": "Boi3",
"currency": "INR",
"foreign_amount": 1516.08,
Expand Down
14 changes: 7 additions & 7 deletions tests/card_data_parsers/s3df/p1/expected.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[
{
"account_number": "2344******7566",
"transaction_dt": "2019-01-01T10:00:00Z",
"transaction_dt": "2019-01-01T10:00:00.000000Z",
"transaction_type": "debit",
"amount": "294.97",
"currency": "GBP",
Expand All @@ -10,7 +10,7 @@
},
{
"account_number": "2344******7566",
"transaction_dt": "2019-01-01T10:00:00Z",
"transaction_dt": "2019-01-01T10:00:00.000000Z",
"transaction_type": "debit",
"amount": "109",
"currency": "GBP",
Expand All @@ -19,7 +19,7 @@
},
{
"account_number": "2344******7567",
"transaction_dt": "2019-01-01T10:00:00Z",
"transaction_dt": "2019-01-01T10:00:00.000000Z",
"transaction_type": "debit",
"amount": "2098.8",
"currency": "GBP",
Expand All @@ -28,7 +28,7 @@
},
{
"account_number": "2344******7567",
"transaction_dt": "2019-01-01T10:00:00Z",
"transaction_dt": "2019-01-01T10:00:00.000000Z",
"transaction_type": "debit",
"amount": "5.64",
"currency": "GBP",
Expand All @@ -37,7 +37,7 @@
},
{
"account_number": "2344******7567",
"transaction_dt": "2019-01-01T10:00:00Z",
"transaction_dt": "2019-01-01T10:00:00.000000Z",
"transaction_type": "debit",
"amount": "205.16",
"currency": "GBP",
Expand All @@ -48,7 +48,7 @@
},
{
"account_number": "2344******7567",
"transaction_dt": "2019-01-01T10:00:00Z",
"transaction_dt": "2019-01-01T10:00:00.000000Z",
"transaction_type": "debit",
"amount": "74",
"currency": "GBP",
Expand All @@ -57,7 +57,7 @@
},
{
"account_number": "2344******7567",
"transaction_dt": "2019-01-01T10:00:00Z",
"transaction_dt": "2019-01-01T10:00:00.000000Z",
"transaction_type": "debit",
"amount": "74",
"currency": "GBP",
Expand Down
4 changes: 2 additions & 2 deletions tests/card_data_parsers/vcf/p1/expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"amount": "89.98",
"currency": "EUR",
"transaction_type": "debit",
"transaction_dt": "2019-01-02T10:00:00Z",
"external_id": "521bb8c41273282f9d5e46b9de1fbc01",
"transaction_dt": "2019-01-02T10:00:00.000000Z",
"external_id": "21f3c22b19f44df7536cf16ba1040ecd",
"merchant_category_code": "5044",
"sequence_number": "0032044068",
"bank_name": "Test Bank"
Expand Down

0 comments on commit b777448

Please sign in to comment.