isaacharrisholt / quiffen

Quiffen is a Python package for parsing QIF (Quicken Interchange Format) files.
MIT License
33 stars 28 forks source link

Qif files with transactions containing "$" in amount fail Decimal conversion #56

Closed sebanism closed 1 year ago

sebanism commented 1 year ago

Some qif files I've seen have transactions where the amounts beginning with a "$". As a result users can encounter a [<class 'decimal.ConversionSyntax'>] error.

Refer to the following lines, from line 397 in core/transaction.py:

            elif line_code in {"T", "U"}:
                amount = field_info.replace(",", "")
                if not splits:
                    kwargs["amount"] = amount
                elif current_split:
                    current_split.amount = Decimal(amount)

Would you mind checking if line 398 should be updated to: amount = field_info.replace(",", "").replace("$", "")

isaacharrisholt commented 1 year ago

Would you mind sharing an example of the failing input so I can check that that's the correct solution?

sebanism commented 1 year ago

You bet, here's copy paste of the header and first two trans from a file I was using, file sourced from a banking website:

!Type:Bank

D09/03/2023
T$107.00

MNPP CREDIT  From Acc123456
^

D03/05/2023
T$55.20

MNPP CREDIT  2.7.23- 8.7.23. un
^
isaacharrisholt commented 1 year ago

This should be fixed as of Quiffen 2.0.9.

sebanism commented 1 year ago

Nice fix! Thanks heaps for the quick turn-around. I've updated the package locally and re-ran my files, and all is good.