Balance imported (from fava) are not rounded.

34 views
Skip to first unread message

timoth...@gmail.com

unread,
Sep 9, 2019, 6:06:04 AM9/9/19
to Beancount
Hi!

I have an issue with my importers:
I am not sure if this is related to fava, beancount or my importer.

My importer parse pdf statement, looking for transaction and balance information.

Let's take a specific example.
In my pdf statement, i have the following balance value:
`154185.12`
My regexp find this value and store it in `chunk[7]`

I am then converting this string into an amount and creating a balance entry:


from beancount.core.number import Decimal, D

ope["CRD"] = amount.Amount(D("-" + chunk[7]), "EUR")

entries.append(
data.Balance(
meta,
ope["date"] + datetime.timedelta(1),
self.accountList[compte],
ope["CRD"],
None,
None,
)
)
return entries


This work perfecly well in CLI with bean-extract:

root@5029447231bb:/myData# bean-extract Famille.import Passif/Boursorama/EmpruntRP/
[...]

2016-03-27 balance Passif:Boursorama:EmpruntRP -154185.12 EUR
source: "pdfbourso"

[...]


When i import this file from fava, the balance entry is properly shown as well in the preview form. (with 2 digits after the decimal dot).

But after confirming the import by clicking the "save" button, the entry added in the beancount file is not correct:


2016-03-27 balance Passif:Boursorama:EmpruntRP -154185.119999999995343387126922607421875 EUR
source: "pdfbourso"


Of course, because of theses values, the balance fail.

This happens only for balances. Not for the transaction, although my transaction entries are built exactly the same way by my importer.
Also, this rounding issue does not happen 100% of the time. Sometimes (maybe 20%), the entry is correct with 2 digits after decimal dot.

Any idea about what may happen ?

Martin Blais

unread,
Sep 14, 2019, 11:33:00 PM9/14/19
to Beancount
I have no idea where something's going wrong in your process, but you
can force rounding by using the .quantize() method of the Decimal
number.
> --
> You received this message because you are subscribed to the Google Groups "Beancount" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to beancount+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/dd051beb-bf72-4a5f-be1d-0212c59b1d99%40googlegroups.com.

timoth...@gmail.com

unread,
Sep 16, 2019, 4:25:59 PM9/16/19
to Beancount
This was an issue related to fava.
Solved here: https://github.com/beancount/fava/issues/964
Reply all
Reply to author
Forward
0 new messages