-
-
Notifications
You must be signed in to change notification settings - Fork 320
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use a transaction's amount precisions when balancing it (#1479)
A surprising development in old behaviour: as a consequence of #931, print now shows amounts with all of their decimal places, so we had better balance transactions using all of those visible digits (so that hledger and a user will agree on whether it's balanced). So now when transaction balancing compares amounts to see if they look equal, it uses (for each commodity) the maximum precision seen in just that transaction's amounts - not the precision from the journal's commodity display styles. This makes it more localised - therefore simpler - and more robust, when print-ing transactions to be re-parsed by hledger (previously, print-ed transactions could be unparseable because they were dependent on commodity directives). However, the new behaviour can break existing journals, so we provide a `--balancing=exact|styled` option to select the new (default) or old balancing behaviour. (The old behaviour may not be *perfectly* replicated, but it's hopefully close enough to be unnoticeable.) This is intended as a temporary migration aid, hopefully to be removed eventually. In journalFinalise, applying commodity display styles to the journal's amounts is now done as a final step (after transaction balancing, not before), and only once (rather than twice when auto postings are enabled), and seems slightly more thorough (affecting some inferred amounts where it didn't before). As a consequence of this change, inferred unit transaction prices (which arise in a two-commodity transaction with 3+ postings, and can be seen with print -x) may in some cases be generated with a different (greater) precision than before. Specifically, it will now be the sum of the number of decimal places in the amounts being converted to and from. (Whereas before, it was.. something else.) Hopefully this will always be a suitable number of digits such that hledger's & users' calculation of balancedness will agree. Lib changes: Hledger.Data.Journal added: journalInferCommodityStyles journalInferAndApplyCommodityStyles removed: canonicalStyleFrom
- Loading branch information
1 parent
2fa60bb
commit 2256d25
Showing
13 changed files
with
309 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.