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.


On Mon, Sep 9, 2019 at 6:06 AM <[email protected]> wrote:
>
> 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 ?
>
> --
> 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 [email protected].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/beancount/dd051beb-bf72-4a5f-be1d-0212c59b1d99%40googlegroups.com.

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beancount/CAK21%2BhOu3S9FnZ6eiOMQST0oUZtG42KAsEuWgsmazZd%2BmoQiwA%40mail.gmail.com.

Reply via email to