Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Be smarter about rounding entries #9

Closed
tbm opened this issue Jul 23, 2020 · 9 comments
Closed

Be smarter about rounding entries #9

tbm opened this issue Jul 23, 2020 · 9 comments
Labels
enhancement New feature or request
Milestone

Comments

@tbm
Copy link
Collaborator

tbm commented Jul 23, 2020

I'm seeing entries like, which I'm sure are not necessary, and actually make things worse:

  Equity:Rounding                                          0.00000000000000000000001 GBP
@tbm tbm added the enhancement New feature or request label Jul 23, 2020
@tbm tbm added this to the 1.2 milestone Jul 24, 2020
@tbm
Copy link
Collaborator Author

tbm commented Jul 24, 2020

Here's a good test case:

2010-01-01 open Expenses:Postage
2010-01-01 open Liabilities:Credit-Card

2019-09-19 * "Postage"
  Expenses:Postage           3.90 EUR @@ 4.32 USD
  Liabilities:Credit-Card               -4.32 USD

becomes


account Liabilities:Credit-Card

2019-09-19 * Postage
  Expenses:Postage                                              3.90 EUR @ 1.107692307692307692307692308 USD
  Liabilities:Credit-Card                                      -4.32 USD
  Equity:Rounding                     -0.000000000000000000000000001 USD

@tbm tbm modified the milestones: 1.2, 1.3 Jul 25, 2020
@tbm
Copy link
Collaborator Author

tbm commented Oct 1, 2020

@blais do you by any chance remember why you added these rounding entries in the first place? Do you have a test case where they were useful?

As far as I can tell, they do more harm than good, but I'm curious to see a testcase where they are useful.

@blais
Copy link
Member

blais commented Oct 2, 2020

https://github.com/beancount/beancount/blob/master/beancount/parser/options.py#L289

Remove the option and they should be gone.

@blais blais closed this as completed Oct 2, 2020
@tbm
Copy link
Collaborator Author

tbm commented Oct 2, 2020

@blais sorry for not giving enough context. This is about the ledger output. It adds Rounding entries explicitly:

          # Insert a posting to absorb the residual if necessary. This is
          # sometimes needed because Ledger bases its balancing precision on the
          # *last* number of digits used on that currency. This is believed to be
          # a bug, so instead, we simply insert a rounding account to absorb the
          # residual and precisely balance the transaction.
          entry = interpolate.fill_residual_posting(entry, ROUNDING_ACCOUNT)

But in my experience these rounding entries are counterproductive. I'm curious if you have a testcase where they make sense.

@tbm tbm reopened this Oct 2, 2020
@blais
Copy link
Member

blais commented Oct 2, 2020

I don't remember.

@blais blais closed this as completed Oct 2, 2020
@tbm
Copy link
Collaborator Author

tbm commented Oct 2, 2020

I'm reopening this bug. @blais this bug is against beancount2ledger. It's a genuine bug that I need to fix (either by not generating these entries at all or only when they are needed), so please leave it open. You can unsubscribe from the bug though.

@tbm tbm reopened this Oct 2, 2020
@blais
Copy link
Member

blais commented Oct 2, 2020

Sorry about that. If you want to undo the work of the option, I think there is metadata on the postings which were added by that code (and if not, we should tag those auto-inserted postings with metadata). You can iterate and simply remove those postings before doing the conversion. That code should be a patch to Beancount (e.g., remove_rounding_postings()?). Don't remove the postings based on just the account name because the user might use that account explicitly. Does that make sense?

@tbm
Copy link
Collaborator Author

tbm commented Nov 12, 2020

I wonder if this is basically the same cause as beancount/beancount#246

@tbm
Copy link
Collaborator Author

tbm commented Nov 12, 2020

Ok, I've come up with an example where a rounding entry is needed.

Valid in beancount:

2010-01-01 open Expenses:Test
2010-01-01 open Assets:Bank

2020-01-10 * "Test"
  Expenses:Test                           4.990 USD
  Assets:Bank                            -4.990 USD

2020-01-10 * "Test: will fail in ledger due to precision of USD"
  Expenses:Test            150.75 THB @ 0.03344 USD
  Assets:Bank                             -5.04 USD

The second transaction will fail in ledger:

Unbalanced remainder is:
           0.001 USD

@tbm tbm closed this as completed in 7431e5b Nov 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants