Fix whitespaces in new revolut format
This commit is contained in:
parent
6577f7e84e
commit
eb629a9a4f
5 changed files with 41 additions and 19 deletions
|
@ -1,4 +1,5 @@
|
||||||
import csv
|
import csv
|
||||||
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import click
|
import click
|
||||||
|
@ -7,9 +8,11 @@ import dateparser
|
||||||
from ofx_processor.utils.base_processor import BaseProcessor, BaseLine
|
from ofx_processor.utils.base_processor import BaseProcessor, BaseLine
|
||||||
|
|
||||||
|
|
||||||
def _amount_str_to_float(amount):
|
def _amount_str_to_float(amount: str):
|
||||||
if amount:
|
if amount:
|
||||||
return float(amount.replace(",", "."))
|
amount = amount.replace(",", ".")
|
||||||
|
amount = re.sub(r"\s+", "", amount)
|
||||||
|
return float(amount)
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
Completed Date;Reference;Paid Out (EUR);Paid In (EUR);Exchange Out;Exchange In; Balance (EUR);Exchange Rate;Category
|
Completed Date;Reference;Paid Out (EUR);Paid In (EUR);Exchange Out;Exchange In; Balance (EUR);Exchange Rate;Category
|
||||||
29 Jan;To Person 1;53,63;;;;21,66; ;Transfers
|
30 août 2021;Virement de NAME;;1 500,00 ;;;1 521,66 ; ;Transferts
|
||||||
29 Jan;To Person 2;0,90;;;;75,29; ;Transfers
|
29 Jan 2020;To Person 1;53,63;;;;21,66; ;Transfers
|
||||||
29 Jan;Refund from Company 2;;53,63;;;76,19; ;Shopping
|
29 Jan 2020;To Person 2;0,90;;;;75,29; ;Transfers
|
||||||
24 Jan;To Person 3;8,50;;;;22,56; ;Transfers
|
29 Jan 2020;Refund from Company 2;;53,63;;;76,19; ;Shopping
|
||||||
16 Jan;To Person 4;1,40;;;;31,06; ;Transfers
|
24 Jan 2020;To Person 3;8,50;;;;22,56; ;Transfers
|
||||||
10 Jan;To Person 5;2,01;;;;32,46; ;Transfers
|
16 Jan 2020;To Person 4;1,40;;;;31,06; ;Transfers
|
||||||
10 Jan;To Person 6;1,21;;;;34,47; ;Transfers
|
10 Jan 2020;To Person 5;2,01;;;;32,46; ;Transfers
|
||||||
5 Jan;Company 1;123,68;;USD 138,00;;35,68;FX-rate €1 = US$1,1158;Shopping
|
10 Jan 2020;To Person 6;1,21;;;;34,47; ;Transfers
|
||||||
4 Jan;Top-up via Apple Pay;;100,00;;;159,36; ;General
|
5 Jan 2020;Company 1;123,68;;USD 138,00;;35,68;FX-rate €1 = US$1,1158;Shopping
|
||||||
|
4 Jan 2020;Top-up via Apple Pay;;100,00;;;159,36; ;General
|
||||||
|
|
|
|
@ -1,4 +1,11 @@
|
||||||
[
|
[
|
||||||
|
{
|
||||||
|
"date": "2021-08-30",
|
||||||
|
"amount": 1500000,
|
||||||
|
"payee_name": "Virement de NAME",
|
||||||
|
"memo": "Transferts",
|
||||||
|
"import_id": "YNAB:1500000:2021-08-30:1"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"date": "2020-01-29",
|
"date": "2020-01-29",
|
||||||
"amount": -53630,
|
"amount": -53630,
|
||||||
|
@ -62,4 +69,4 @@
|
||||||
"memo": "General",
|
"memo": "General",
|
||||||
"import_id": "YNAB:100000:2020-01-04:1"
|
"import_id": "YNAB:100000:2020-01-04:1"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,5 +1,13 @@
|
||||||
{
|
{
|
||||||
"transactions": [
|
"transactions": [
|
||||||
|
{
|
||||||
|
"date": "2021-08-30",
|
||||||
|
"amount": 1500000,
|
||||||
|
"payee_name": "Virement de NAME",
|
||||||
|
"memo": "Transferts",
|
||||||
|
"import_id": "YNAB:1500000:2021-08-30:1",
|
||||||
|
"account_id": "<YOUR REVOLUT ACCOUNT ID>"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"date": "2020-01-29",
|
"date": "2020-01-29",
|
||||||
"amount": -53630,
|
"amount": -53630,
|
||||||
|
|
|
@ -77,7 +77,7 @@ class ConfigTestCase(unittest.TestCase):
|
||||||
self.cli, ["revolut", "tests/samples/revolut.csv", "--keep"]
|
self.cli, ["revolut", "tests/samples/revolut.csv", "--keep"]
|
||||||
)
|
)
|
||||||
expected_filename = ynab.get_config_file_name()
|
expected_filename = ynab.get_config_file_name()
|
||||||
self.assertIn("Error while parsing config file", result.output)
|
self.assertIn("Error while parsing config file", result.output, f"config_file: {name}")
|
||||||
edit.assert_called_with(filename=expected_filename)
|
edit.assert_called_with(filename=expected_filename)
|
||||||
|
|
||||||
@mock.patch("ofx_processor.utils.ynab.DEFAULT_CONFIG_FILENAME", "file.ini")
|
@mock.patch("ofx_processor.utils.ynab.DEFAULT_CONFIG_FILENAME", "file.ini")
|
||||||
|
@ -187,6 +187,7 @@ class DataTestCase(unittest.TestCase):
|
||||||
{"id": "created:9", "matched_transaction_id": None},
|
{"id": "created:9", "matched_transaction_id": None},
|
||||||
{"id": "created:10", "matched_transaction_id": None},
|
{"id": "created:10", "matched_transaction_id": None},
|
||||||
{"id": "created:11", "matched_transaction_id": None},
|
{"id": "created:11", "matched_transaction_id": None},
|
||||||
|
{"id": "created:12", "matched_transaction_id": None},
|
||||||
],
|
],
|
||||||
"duplicate_import_ids": [],
|
"duplicate_import_ids": [],
|
||||||
}
|
}
|
||||||
|
@ -198,8 +199,8 @@ class DataTestCase(unittest.TestCase):
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(result.exit_code, 0)
|
self.assertEqual(result.exit_code, 0)
|
||||||
self.assertIn("Processed 9 transactions total.", result.output)
|
self.assertIn("Processed 10 transactions total.", result.output)
|
||||||
self.assertIn("9 transactions created in YNAB.", result.output)
|
self.assertIn("10 transactions created in YNAB.", result.output)
|
||||||
self.assertNotIn("transactions ignored (duplicates).", result.output)
|
self.assertNotIn("transactions ignored (duplicates).", result.output)
|
||||||
|
|
||||||
@mock.patch("requests.post")
|
@mock.patch("requests.post")
|
||||||
|
@ -232,6 +233,7 @@ class DataTestCase(unittest.TestCase):
|
||||||
"duplicate:9",
|
"duplicate:9",
|
||||||
"duplicate:10",
|
"duplicate:10",
|
||||||
"duplicate:11",
|
"duplicate:11",
|
||||||
|
"duplicate:12",
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -242,9 +244,9 @@ class DataTestCase(unittest.TestCase):
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(result.exit_code, 0)
|
self.assertEqual(result.exit_code, 0)
|
||||||
self.assertIn("Processed 9 transactions total.", result.output)
|
self.assertIn("Processed 10 transactions total.", result.output)
|
||||||
self.assertIn("3 transactions created in YNAB.", result.output)
|
self.assertIn("3 transactions created in YNAB.", result.output)
|
||||||
self.assertIn("6 transactions ignored (duplicates).", result.output)
|
self.assertIn("7 transactions ignored (duplicates).", result.output)
|
||||||
|
|
||||||
@mock.patch("requests.post")
|
@mock.patch("requests.post")
|
||||||
def test_revolut_sends_data_only_duplicates(self, post):
|
def test_revolut_sends_data_only_duplicates(self, post):
|
||||||
|
@ -261,6 +263,7 @@ class DataTestCase(unittest.TestCase):
|
||||||
"duplicate:7",
|
"duplicate:7",
|
||||||
"duplicate:8",
|
"duplicate:8",
|
||||||
"duplicate:9",
|
"duplicate:9",
|
||||||
|
"duplicate:10",
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -271,9 +274,9 @@ class DataTestCase(unittest.TestCase):
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(result.exit_code, 0)
|
self.assertEqual(result.exit_code, 0)
|
||||||
self.assertIn("Processed 9 transactions total.", result.output)
|
self.assertIn("Processed 10 transactions total.", result.output)
|
||||||
self.assertNotIn("transactions created in YNAB.", result.output)
|
self.assertNotIn("transactions created in YNAB.", result.output)
|
||||||
self.assertIn("9 transactions ignored (duplicates).", result.output)
|
self.assertIn("10 transactions ignored (duplicates).", result.output)
|
||||||
|
|
||||||
@mock.patch("requests.post")
|
@mock.patch("requests.post")
|
||||||
def test_bpvf_sends_to_ynab(self, post):
|
def test_bpvf_sends_to_ynab(self, post):
|
||||||
|
|
Loading…
Reference in a new issue