adnilsson / Bank2YNAB4

Converts from banks' CSV format of exported transactions to the frormat accepted by YNAB4
MIT License
0 stars 0 forks source link

Update regexp to also allow one or no decimals #9

Closed adnilsson closed 2 years ago

adnilsson commented 2 years ago

Description

We no longer require that all amounts in a bank statement have a resolution of hundreds. Banks could also truncate zeros, so we allow banks to also have zero or one decimal digits in their amounts.

For example, prior to this PR, the following amounts are invalid for a bank with . as its decimal separator:

The accepted format would be 10.00. The above could also have a minus sign and still be invalid.

This PR updates the regular expression used by TransactionValueParser to allow one or zero decimals in amounts.

Tests

A test is included that has amounts with both zero and just a single decimal. The test computes the net flow in the output file and compares it against a hardcoded value (computed manually from the test data).