Add more tests with sample data

This commit is contained in:
Gabriel Augendre 2020-02-26 19:59:31 +01:00
parent 97f6f9ce93
commit 5b5f89385c
No known key found for this signature in database
GPG key ID: 1E693F4CE4AEE7B4
13 changed files with 582 additions and 9 deletions

View file

@ -3,6 +3,7 @@ import sys
import click import click
from ofxtools import OFXTree from ofxtools import OFXTree
from ofxtools.header import OFXHeaderError
from ofx_processor.utils.processor import Processor, Line from ofx_processor.utils.processor import Processor, Line
@ -48,14 +49,14 @@ class BpvfProcessor(Processor):
parser = OFXTree() parser = OFXTree()
try: try:
parser.parse(self.filename) parser.parse(self.filename)
except FileNotFoundError: except (FileNotFoundError, OFXHeaderError):
click.secho("Couldn't open ofx file", fg="red") click.secho("Couldn't open or parse ofx file", fg="red")
sys.exit(1) sys.exit(1)
ofx = parser.convert() ofx = parser.convert()
if ofx is None: if ofx is None:
click.secho("Couldn't parse ofx file", fg="red") click.secho("Couldn't convert ofx file", fg="red")
sys.exit(1) sys.exit(1)
return ofx.statements[0].transactions return ofx.statements[0].transactions

View file

@ -1,4 +1,5 @@
import csv import csv
import sys
import click import click
import dateparser import dateparser
@ -52,9 +53,13 @@ class RevolutProcessor(Processor):
account_name = "revolut" account_name = "revolut"
def parse_file(self): def parse_file(self):
try:
with open(self.filename) as f: with open(self.filename) as f:
reader = csv.DictReader(f, delimiter=";") reader = csv.DictReader(f, delimiter=";")
return [line for line in reader] return [line for line in reader]
except FileNotFoundError:
click.secho("File not found", fg="red")
sys.exit(1)
@staticmethod @staticmethod
@click.command("revolut", help="Process Revolut bank statement (CSV)") @click.command("revolut", help="Process Revolut bank statement (CSV)")

View file

@ -52,7 +52,7 @@ class Processor:
self.iterable = self.parse_file() self.iterable = self.parse_file()
def parse_file(self): def parse_file(self):
return [] return [] # pragma: nocover
def push_to_ynab(self): def push_to_ynab(self):
transactions = self.get_transactions() transactions = self.get_transactions()

206
tests/samples/bpvf.ofx Normal file
View file

@ -0,0 +1,206 @@
OFXHEADER:100
DATA:OFXSGML
VERSION:102
SECURITY:NONE
ENCODING:USASCII
CHARSET:1252
COMPRESSION:NONE
OLDFILEUID:NONE
NEWFILEUID:NONE
<OFX>
<SIGNONMSGSRSV1>
<SONRS>
<STATUS>
<CODE>0
<SEVERITY>INFO
</STATUS>
<DTSERVER>20200226060348
<LANGUAGE>FRA
<DTPROFUP>20200226060348
<DTACCTUP>20200226060348
</SONRS>
</SIGNONMSGSRSV1>
<BANKMSGSRSV1>
<STMTTRNRS>
<TRNUID>12345678912
<STATUS>
<CODE>0
<SEVERITY>INFO
</STATUS>
<STMTRS>
<CURDEF>EUR
<BANKACCTFROM>
<BANKID>12345</BANKID>
<BRANCHID>65432</BRANCHID>
<ACCTID>12345678912</ACCTID>
<ACCTTYPE>CHECKING</ACCTTYPE>
</BANKACCTFROM>
<BANKTRANLIST>
<DTSTART>20200217
<DTEND>20200226
<STMTTRN>
<TRNTYPE>DEBIT
<DTPOSTED>20200226
<TRNAMT>-9.66
<FITID>25364 HC4X
<CHECKNUM>0719ATG
<NAME>PRLV SEPA Company 3
<MEMO>123456789 PAYPAL 542UHBON
</STMTTRN>
<STMTTRN>
<TRNTYPE>DEBIT
<DTPOSTED>20200225
<TRNAMT>-2.40
<FITID>727278312
<CHECKNUM>2L9Z4OP
<NAME>240220 CB****5555
<MEMO>H.I.K 69VILLEURBANNE
</STMTTRN>
<STMTTRN>
<TRNTYPE>DEBIT
<DTPOSTED>20200225
<TRNAMT>-39.20
<FITID>7834583486
<CHECKNUM>2LFVF8U
<NAME>230220 CB****5555
<MEMO>DELIVEROO FR WWW 39,20EUR 1 EURO = 1,000000
</STMTTRN>
<STMTTRN>
<TRNTYPE>DEBIT
<DTPOSTED>20200225
<TRNAMT>-9.99
<FITID>883783453
<CHECKNUM>0711ZB6
<NAME>PRLV SEPA Company 1
<MEMO>Votre abonnement mobile: 06XXXXX 6498165189060897
</STMTTRN>
<STMTTRN>
<TRNTYPE>DEBIT
<DTPOSTED>20200224
<TRNAMT>-7.50
<FITID>651876109
<CHECKNUM>2JSCN09
<NAME>210220 CB****5555
<MEMO>COMPANY FR LYON 6EME 7,50EUR 1 EURO = 1,000000
</STMTTRN>
<STMTTRN>
<TRNTYPE>DEBIT
<DTPOSTED>20200224
<TRNAMT>-34.99
<FITID>3483483
<CHECKNUM>0710J21
<NAME>PRLV SEPA Company 2
<MEMO>24-02-2020 / 22-03-2020 56418710
</STMTTRN>
<STMTTRN>
<TRNTYPE>DEBIT
<DTPOSTED>20200224
<TRNAMT>-2.39
<FITID>79782112104
<CHECKNUM>5964661
<NAME>VIR Person 1
<MEMO>481840871 Splitwise
</STMTTRN>
<STMTTRN>
<TRNTYPE>CREDIT
<DTPOSTED>20200220
<TRNAMT>+235.00
<FITID>5408506055
<CHECKNUM>2D08DAF
<NAME>VIREMENT Person 2
<MEMO>Cadeau
</STMTTRN>
<STMTTRN>
<TRNTYPE>CREDIT
<DTPOSTED>20200220
<TRNAMT>+55.00
<FITID>548910308
<CHECKNUM>2D088L5
<NAME>VIREMENT Company 3
<MEMO>48716508719
</STMTTRN>
<STMTTRN>
<TRNTYPE>DEBIT
<DTPOSTED>20200219
<TRNAMT>-55.00
<FITID>54874910320
<CHECKNUM>2BCS20C
<NAME>170220 CB****5555
<MEMO>BDE INSA LYON 69VILLEURBANNE
</STMTTRN>
<STMTTRN>
<TRNTYPE>DEBIT
<DTPOSTED>20200219
<TRNAMT>-0.90
<FITID>5478058
<CHECKNUM>2BINNA4
<NAME>180220 CB****5555
<MEMO>GUY AND SONS FR LYON 0,90EUR 1 EURO = 1,000000
</STMTTRN>
<STMTTRN>
<TRNTYPE>DEBIT
<DTPOSTED>20200219
<TRNAMT>-1.40
<FITID>56098760894
<CHECKNUM>2BINNA3
<NAME>170220 CB****5555
<MEMO>GUY AND SONS FR LYON 1,40EUR 1 EURO = 1,000000
</STMTTRN>
<STMTTRN>
<TRNTYPE>DEBIT
<DTPOSTED>20200219
<TRNAMT>-473.50
<FITID>5484916740
<CHECKNUM>5543368
<NAME>VIR Person 1
<MEMO>65187460 Acompte cuisine 2
</STMTTRN>
<STMTTRN>
<TRNTYPE>DEBIT
<DTPOSTED>20200218
<TRNAMT>-96.96
<FITID>6518749560840
<CHECKNUM>070M39Z
<NAME>PRLV SEPA Company 4
<MEMO>487105874 Amazon.fr 3X QC.(OJBIYN:ZOFEUBZF51871
</STMTTRN>
<STMTTRN>
<TRNTYPE>DEBIT
<DTPOSTED>20200217
<TRNAMT>-232.00
<FITID>51981560870
<CHECKNUM>281U2GL
<NAME>150220 CB****5555
<MEMO>GRAND PARC PUY 85LES EPESSES
</STMTTRN>
<STMTTRN>
<TRNTYPE>DEBIT
<DTPOSTED>20200217
<TRNAMT>-1.00
<FITID>6508941561987
<CHECKNUM>287L9X0
<NAME>140220 CB****5555
<MEMO>UBER BV NL HELP.UBER.CO 1,00EUR 1 EURO = 1,000000
</STMTTRN>
<STMTTRN>
<TRNTYPE>CREDIT
<DTPOSTED>20200217
<TRNAMT>+8.60
<FITID>654897503260
<CHECKNUM>281M0PK
<NAME>VIREMENT Person 5
<MEMO>VIREMENT DE PERSON 6
</STMTTRN>
</BANKTRANLIST>
<LEDGERBAL>
<BALAMT>1234.56
<DTASOF>20200226
</LEDGERBAL>
<AVAILBAL>
<BALAMT>1234.56
<DTASOF>20200226
</AVAILBAL>
</STMTRS>
</STMTTRNRS>
</BANKMSGSRSV1>
</OFX>

View file

@ -0,0 +1 @@
[{"date": "2020-02-26", "amount": -9660, "payee_name": "PRLV SEPA Company 3", "memo": "123456789 PAYPAL 542UHBON", "import_id": "YNAB:-9660:2020-02-26:1"}, {"date": "2020-02-25", "amount": -2400, "payee_name": "H.I.K 69VILLEURBANNE", "memo": "240220 CB****5555", "import_id": "YNAB:-2400:2020-02-25:1"}, {"date": "2020-02-25", "amount": -39200, "payee_name": "DELIVEROO FR WWW", "memo": "230220 CB****5555 39,20EUR 1 EURO = 1,000000", "import_id": "YNAB:-39200:2020-02-25:1"}, {"date": "2020-02-25", "amount": -9990, "payee_name": "PRLV SEPA Company 1", "memo": "Votre abonnement mobile: 06XXXXX 6498165189060897", "import_id": "YNAB:-9990:2020-02-25:1"}, {"date": "2020-02-24", "amount": -7500, "payee_name": "COMPANY FR LYON 6EME", "memo": "210220 CB****5555 7,50EUR 1 EURO = 1,000000", "import_id": "YNAB:-7500:2020-02-24:1"}, {"date": "2020-02-24", "amount": -34990, "payee_name": "PRLV SEPA Company 2", "memo": "24-02-2020 / 22-03-2020 56418710", "import_id": "YNAB:-34990:2020-02-24:1"}, {"date": "2020-02-24", "amount": -2390, "payee_name": "VIR Person 1", "memo": "481840871 Splitwise", "import_id": "YNAB:-2390:2020-02-24:1"}, {"date": "2020-02-20", "amount": 235000, "payee_name": "VIREMENT Person 2", "memo": "Cadeau", "import_id": "YNAB:235000:2020-02-20:1"}, {"date": "2020-02-20", "amount": 55000, "payee_name": "VIREMENT Company 3", "memo": "48716508719", "import_id": "YNAB:55000:2020-02-20:1"}, {"date": "2020-02-19", "amount": -55000, "payee_name": "BDE INSA LYON 69VILLEURBANNE", "memo": "170220 CB****5555", "import_id": "YNAB:-55000:2020-02-19:1"}, {"date": "2020-02-19", "amount": -900, "payee_name": "GUY AND SONS FR LYON", "memo": "180220 CB****5555 0,90EUR 1 EURO = 1,000000", "import_id": "YNAB:-900:2020-02-19:1"}, {"date": "2020-02-19", "amount": -1400, "payee_name": "GUY AND SONS FR LYON", "memo": "170220 CB****5555 1,40EUR 1 EURO = 1,000000", "import_id": "YNAB:-1400:2020-02-19:1"}, {"date": "2020-02-19", "amount": -473500, "payee_name": "VIR Person 1", "memo": "65187460 Acompte cuisine 2", "import_id": "YNAB:-473500:2020-02-19:1"}, {"date": "2020-02-18", "amount": -96960, "payee_name": "PRLV SEPA Company 4", "memo": "487105874 Amazon.fr 3X QC.(OJBIYN:ZOFEUBZF51871", "import_id": "YNAB:-96960:2020-02-18:1"}, {"date": "2020-02-17", "amount": -232000, "payee_name": "GRAND PARC PUY 85LES EPESSES", "memo": "150220 CB****5555", "import_id": "YNAB:-232000:2020-02-17:1"}, {"date": "2020-02-17", "amount": -1000, "payee_name": "UBER BV NL HELP.UBER.CO", "memo": "140220 CB****5555 1,00EUR 1 EURO = 1,000000", "import_id": "YNAB:-1000:2020-02-17:1"}, {"date": "2020-02-17", "amount": 8600, "payee_name": "VIREMENT Person 5", "memo": "VIREMENT DE PERSON 6", "import_id": "YNAB:8600:2020-02-17:1"}]

View file

@ -0,0 +1,197 @@
OFXHEADER:100
DATA:OFXSGML
VERSION:102
SECURITY:NONE
ENCODING:USASCII
CHARSET:1252
COMPRESSION:NONE
OLDFILEUID:NONE
<LANGUAGE>FRA
<DTPROFUP>20200226060348
<DTACCTUP>20200226060348
</SONRS>
</SIGNONMSGSRSV1>
<BANKMSGSRSV1>
<STMTTRNRS>
<TRNUID>12345678912
<STATUS>
<CODE>0
<SEVERITY>INFO
</STATUS>
<STMTRS>
<CURDEF>EUR
<BANKACCTFROM>
<BANKID>12345</BANKID>
<BRANCHID>65432</BRANCHID>
<ACCTID>12345678912</ACCTID>
<ACCTTYPE>CHECKING</ACCTTYPE>
</BANKACCTFROM>
<BANKTRANLIST>
<DTSTART>20200217
<DTEND>20200226
<STMTTRN>
<TRNTYPE>DEBIT
<DTPOSTED>20200226
<TRNAMT>-9.66
<FITID>25364 HC4X
<CHECKNUM>0719ATG
<NAME>PRLV SEPA Company 3
<MEMO>123456789 PAYPAL 542UHBON
</STMTTRN>
<STMTTRN>
<TRNTYPE>DEBIT
<DTPOSTED>20200225
<TRNAMT>-2.40
<FITID>727278312
<CHECKNUM>2L9Z4OP
<NAME>240220 CB****5555
<MEMO>H.I.K 69VILLEURBANNE
</STMTTRN>
<STMTTRN>
<TRNTYPE>DEBIT
<DTPOSTED>20200225
<TRNAMT>-39.20
<FITID>7834583486
<CHECKNUM>2LFVF8U
<NAME>230220 CB****5555
<MEMO>DELIVEROO FR WWW 39,20EUR 1 EURO = 1,000000
</STMTTRN>
<STMTTRN>
<TRNTYPE>DEBIT
<DTPOSTED>20200225
<TRNAMT>-9.99
<FITID>883783453
<CHECKNUM>0711ZB6
<NAME>PRLV SEPA Company 1
<MEMO>Votre abonnement mobile: 06XXXXX 6498165189060897
</STMTTRN>
<STMTTRN>
<TRNTYPE>DEBIT
<DTPOSTED>20200224
<TRNAMT>-7.50
<FITID>651876109
<CHECKNUM>2JSCN09
<NAME>210220 CB****5555
<MEMO>COMPANY FR LYON 6EME 7,50EUR 1 EURO = 1,000000
</STMTTRN>
<STMTTRN>
<TRNTYPE>DEBIT
<DTPOSTED>20200224
<TRNAMT>-34.99
<FITID>3483483
<CHECKNUM>0710J21
<NAME>PRLV SEPA Company 2
<MEMO>24-02-2020 / 22-03-2020 56418710
</STMTTRN>
<STMTTRN>
<TRNTYPE>DEBIT
<DTPOSTED>20200224
<TRNAMT>-2.39
<FITID>79782112104
<CHECKNUM>5964661
<NAME>VIR Person 1
<MEMO>481840871 Splitwise
</STMTTRN>
<STMTTRN>
<TRNTYPE>CREDIT
<DTPOSTED>20200220
<TRNAMT>+235.00
<FITID>5408506055
<CHECKNUM>2D08DAF
<NAME>VIREMENT Person 2
<MEMO>Cadeau
</STMTTRN>
<STMTTRN>
<TRNTYPE>CREDIT
<DTPOSTED>20200220
<TRNAMT>+55.00
<FITID>548910308
<CHECKNUM>2D088L5
<NAME>VIREMENT Company 3
<MEMO>48716508719
</STMTTRN>
<STMTTRN>
<TRNTYPE>DEBIT
<DTPOSTED>20200219
<TRNAMT>-55.00
<FITID>54874910320
<CHECKNUM>2BCS20C
<NAME>170220 CB****5555
<MEMO>BDE INSA LYON 69VILLEURBANNE
</STMTTRN>
<STMTTRN>
<TRNTYPE>DEBIT
<DTPOSTED>20200219
<TRNAMT>-0.90
<FITID>5478058
<CHECKNUM>2BINNA4
<NAME>180220 CB****5555
<MEMO>GUY AND SONS FR LYON 0,90EUR 1 EURO = 1,000000
</STMTTRN>
<STMTTRN>
<TRNTYPE>DEBIT
<DTPOSTED>20200219
<TRNAMT>-1.40
<FITID>56098760894
<CHECKNUM>2BINNA3
<NAME>170220 CB****5555
<MEMO>GUY AND SONS FR LYON 1,40EUR 1 EURO = 1,000000
</STMTTRN>
<STMTTRN>
<TRNTYPE>DEBIT
<DTPOSTED>20200219
<TRNAMT>-473.50
<FITID>5484916740
<CHECKNUM>5543368
<NAME>VIR Person 1
<MEMO>65187460 Acompte cuisine 2
</STMTTRN>
<STMTTRN>
<TRNTYPE>DEBIT
<DTPOSTED>20200218
<TRNAMT>-96.96
<FITID>6518749560840
<CHECKNUM>070M39Z
<NAME>PRLV SEPA Company 4
<MEMO>487105874 Amazon.fr 3X QC.(OJBIYN:ZOFEUBZF51871
</STMTTRN>
<STMTTRN>
<TRNTYPE>DEBIT
<DTPOSTED>20200217
<TRNAMT>-232.00
<FITID>51981560870
<CHECKNUM>281U2GL
<NAME>150220 CB****5555
<MEMO>GRAND PARC PUY 85LES EPESSES
</STMTTRN>
<STMTTRN>
<TRNTYPE>DEBIT
<DTPOSTED>20200217
<TRNAMT>-1.00
<FITID>6508941561987
<CHECKNUM>287L9X0
<NAME>140220 CB****5555
<MEMO>UBER BV NL HELP.UBER.CO 1,00EUR 1 EURO = 1,000000
</STMTTRN>
<STMTTRN>
<TRNTYPE>CREDIT
<DTPOSTED>20200217
<TRNAMT>+8.60
<FITID>654897503260
<CHECKNUM>281M0PK
<NAME>VIREMENT Person 5
<MEMO>VIREMENT DE PERSON 6
</STMTTRN>
</BANKTRANLIST>
<LEDGERBAL>
<BALAMT>1234.56
<DTASOF>20200226
</LEDGERBAL>
<AVAILBAL>
<BALAMT>1234.56
<DTASOF>20200226
</AVAILBAL>
</STMTRS>
</STMTTRNRS>
</BANKMSGSRSV1>
</OFX>

97
tests/samples/ce.ofx Normal file
View file

@ -0,0 +1,97 @@
OFXHEADER:100
DATA:OFXSGML
VERSION:102
SECURITY:NONE
ENCODING:USASCII
CHARSET:1252
COMPRESSION:NONE
OLDFILEUID:NONE
NEWFILEUID:NONE
<OFX>
<SIGNONMSGSRSV1>
<SONRS>
<STATUS>
<CODE>0
<SEVERITY>INFO
</STATUS>
<DTSERVER>20200226
<LANGUAGE>FRA
<DTPROFUP>20200226
<DTACCTUP>20200226
</SONRS>
</SIGNONMSGSRSV1>
<BANKMSGSRSV1>
<STMTTRNRS>
<TRNUID>00
<STATUS>
<CODE>0
<SEVERITY>INFO
</STATUS>
<STMTRS>
<CURDEF>EUR
<BANKACCTFROM>
<BANKID>12345
<BRANCHID>54321
<ACCTID>12345678932
<ACCTTYPE>SAVINGS
</BANKACCTFROM>
<BANKTRANLIST>
<DTSTART>20200223
<DTEND>20200225
<STMTTRN>
<TRNTYPE>DEBIT
<DTPOSTED>20200225
<TRNAMT>-21,00
<FITID>54875116484966-41.57.21.325698
<NAME>CB DECATHLON FACT 240220
<MEMO>CB DECATHLON FACT 240220
</STMTTRN>
<STMTTRN>
<TRNTYPE>DEBIT
<DTPOSTED>20200225
<TRNAMT>-7,00
<FITID>54875116484966-41.57.21.325698
<NAME>PRLV COMPANY
<MEMO>Company Ref Prlvt SEPA 99-1KIBHEF-01 45871984
</STMTTRN>
<STMTTRN>
<TRNTYPE>DEBIT
<DTPOSTED>20200224
<TRNAMT>-48,13
<FITID>54875116484966-41.57.21.325698
<NAME>CB 3403 MONOP FACT 210220
<MEMO>CB 3403 MONOP FACT 210220
</STMTTRN>
<STMTTRN>
<TRNTYPE>DEBIT
<DTPOSTED>20200224
<TRNAMT>-1,20
<FITID>54875116484966-41.57.21.325698
<NAME>CB MALATIER FACT 210220
<MEMO>CB MALATIER FACT 210220
</STMTTRN>
<STMTTRN>
<TRNTYPE>CREDIT
<DTPOSTED>20200224
<TRNAMT>+2,39
<FITID>54875116484966-41.57.21.325698
<NAME>VIR SEPA PERSON 1
<MEMO>_
</STMTTRN>
<STMTTRN>
<TRNTYPE>CREDIT
<DTPOSTED>20200224
<TRNAMT>+14,49
<FITID>2402202020200224-05.41.39.551984
<NAME>VIR SEPA PERSON 2
<MEMO>_
</STMTTRN>
</BANKTRANLIST>
<LEDGERBAL>
<BALAMT>1234,56
<DTASOF>20200226
</LEDGERBAL>
</STMTRS>
</STMTTRNRS>
</BANKMSGSRSV1>
</OFX>

View file

@ -0,0 +1 @@
[{"date": "2020-02-25", "amount": -21000, "payee_name": "CB DECATHLON", "memo": "FACT 240220", "import_id": "YNAB:-21000:2020-02-25:1"}, {"date": "2020-02-25", "amount": -7000, "payee_name": "PRLV COMPANY", "memo": "Company Ref Prlvt SEPA 99-1KIBHEF-01 45871984", "import_id": "YNAB:-7000:2020-02-25:1"}, {"date": "2020-02-24", "amount": -48130, "payee_name": "CB 3403 MONOP", "memo": "FACT 210220", "import_id": "YNAB:-48130:2020-02-24:1"}, {"date": "2020-02-24", "amount": -1200, "payee_name": "CB MALATIER", "memo": "FACT 210220", "import_id": "YNAB:-1200:2020-02-24:1"}, {"date": "2020-02-24", "amount": 2390, "payee_name": "VIR SEPA PERSON 1", "memo": "_", "import_id": "YNAB:2390:2020-02-24:1"}, {"date": "2020-02-24", "amount": 14490, "payee_name": "VIR SEPA PERSON 2", "memo": "_", "import_id": "YNAB:14490:2020-02-24:1"}]

10
tests/samples/revolut.csv Normal file
View file

@ -0,0 +1,10 @@
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
29 Jan;To Person 2;0,90;;;;75,29; ;Transfers
29 Jan;Refund from Company 2;;53,63;;;76,19; ;Shopping
24 Jan;To Person 3;8,50;;;;22,56; ;Transfers
16 Jan;To Person 4;1,40;;;;31,06; ;Transfers
10 Jan;To Person 5;2,01;;;;32,46; ;Transfers
10 Jan;To Person 6;1,21;;;;34,47; ;Transfers
5 Jan;Company 1;123,68;;USD 138,00;;35,68;FX-rate €1=US$1,1158;Shopping
4 Jan;Top-up via Apple Pay;;100,00;;;159,36; ;General
1 Completed Date Reference Paid Out (EUR) Paid In (EUR) Exchange Out Exchange In Balance (EUR) Exchange Rate Category
2 29 Jan To Person 1 53,63 21,66 Transfers
3 29 Jan To Person 2 0,90 75,29 Transfers
4 29 Jan Refund from Company 2 53,63 76,19 Shopping
5 24 Jan To Person 3 8,50 22,56 Transfers
6 16 Jan To Person 4 1,40 31,06 Transfers
7 10 Jan To Person 5 2,01 32,46 Transfers
8 10 Jan To Person 6 1,21 34,47 Transfers
9 5 Jan Company 1 123,68 USD 138,00 35,68 FX-rate €1 = US$1,1158 Shopping
10 4 Jan Top-up via Apple Pay 100,00 159,36 General

View file

@ -0,0 +1 @@
[{"date": "2020-01-29", "amount": -53630, "payee_name": "To Person 1", "memo": "Transfers", "import_id": "YNAB:-53630:2020-01-29:1"}, {"date": "2020-01-29", "amount": -900, "payee_name": "To Person 2", "memo": "Transfers", "import_id": "YNAB:-900:2020-01-29:1"}, {"date": "2020-01-29", "amount": 53630, "payee_name": "Refund from Company 2", "memo": "Shopping", "import_id": "YNAB:53630:2020-01-29:1"}, {"date": "2020-01-24", "amount": -8500, "payee_name": "To Person 3", "memo": "Transfers", "import_id": "YNAB:-8500:2020-01-24:1"}, {"date": "2020-01-16", "amount": -1400, "payee_name": "To Person 4", "memo": "Transfers", "import_id": "YNAB:-1400:2020-01-16:1"}, {"date": "2020-01-10", "amount": -2009, "payee_name": "To Person 5", "memo": "Transfers", "import_id": "YNAB:-2009:2020-01-10:1"}, {"date": "2020-01-10", "amount": -1210, "payee_name": "To Person 6", "memo": "Transfers", "import_id": "YNAB:-1210:2020-01-10:1"}, {"date": "2020-01-05", "amount": -123680, "payee_name": "Company 1", "memo": "Shopping - FX-rate \u20ac1\u2008=\u2008US$1,1158", "import_id": "YNAB:-123680:2020-01-05:1"}, {"date": "2020-01-04", "amount": 100000, "payee_name": "Top-up via Apple Pay", "memo": "General", "import_id": "YNAB:100000:2020-01-04:1"}]

View file

@ -1,7 +1,8 @@
import datetime import datetime
import json
import unittest import unittest
from ofx_processor.processors.bpvf import BpvfLine from ofx_processor.processors.bpvf import BpvfLine, BpvfProcessor
class BpvfTransaction: class BpvfTransaction:
@ -22,7 +23,7 @@ class BpvfTransaction:
self.name = name self.name = name
class BpvfProcessorTestCase(unittest.TestCase): class BpvfLineTestCase(unittest.TestCase):
def test_process_name_and_memo_no_change(self): def test_process_name_and_memo_no_change(self):
name = "business" name = "business"
memo = "2020-01-17" memo = "2020-01-17"
@ -84,5 +85,22 @@ class BpvfProcessorTestCase(unittest.TestCase):
self.assertEqual(result_amount, expected_amount) self.assertEqual(result_amount, expected_amount)
class BpvfProcessorTestCase(unittest.TestCase):
def test_file_not_found(self):
with self.assertRaises(SystemExit):
BpvfProcessor("filenotfound.ofx").get_transactions()
def test_file(self):
transactions = BpvfProcessor("tests/samples/bpvf.ofx").get_transactions()
with open("tests/samples/bpvf_expected.json") as f:
expected_transactions = json.load(f)
self.assertListEqual(transactions, expected_transactions)
def test_file_malformed(self):
with self.assertRaises(SystemExit):
BpvfProcessor("tests/samples/bpvf_malformed.ofx")
if __name__ == "__main__": if __name__ == "__main__":
unittest.main() # pragma: nocover unittest.main() # pragma: nocover

View file

@ -0,0 +1,21 @@
import json
import unittest
from ofx_processor.processors.ce import CeProcessor
class CeProcessorTestCase(unittest.TestCase):
def test_file_not_found(self):
with self.assertRaises(SystemExit):
CeProcessor("filenotfound.ofx").get_transactions()
def test_file(self):
transactions = CeProcessor("tests/samples/ce.ofx").get_transactions()
with open("tests/samples/ce_expected.json") as f:
expected_transactions = json.load(f)
self.assertListEqual(transactions, expected_transactions)
if __name__ == "__main__":
unittest.main() # pragma: nocover

View file

@ -1,9 +1,11 @@
import datetime import datetime
import json
import unittest import unittest
from ofx_processor.processors.revolut import ( from ofx_processor.processors.revolut import (
_amount_str_to_float, _amount_str_to_float,
RevolutLine, RevolutLine,
RevolutProcessor,
) )
@ -70,5 +72,18 @@ class RevolutProcessorTestCase(unittest.TestCase):
self.assertEqual(RevolutLine(line).get_payee(), expected) self.assertEqual(RevolutLine(line).get_payee(), expected)
class BpvfProcessorTestCase(unittest.TestCase):
def test_file_not_found(self):
with self.assertRaises(SystemExit):
RevolutProcessor("notfound.csv").get_transactions()
def test_file(self):
transactions = RevolutProcessor("tests/samples/revolut.csv").get_transactions()
with open("tests/samples/revolut_expected.json") as f:
expected_transactions = json.load(f)
self.assertListEqual(transactions, expected_transactions)
if __name__ == "__main__": if __name__ == "__main__":
unittest.main() # pragma: nocover unittest.main() # pragma: nocover