dev: transaction balancing: cleanup [#2402]
This commit is contained in:
parent
0252367de4
commit
de4d637def
@ -115,7 +115,6 @@ transactionCheckBalanced BalancingOpts{commodity_styles_=_mglobalstyles, txn_bal
|
|||||||
where
|
where
|
||||||
roundforbalancecheck = case txn_balancing_ of
|
roundforbalancecheck = case txn_balancing_ of
|
||||||
TBPOld -> maybe id styleAmounts _mglobalstyles
|
TBPOld -> maybe id styleAmounts _mglobalstyles
|
||||||
-- TBPCompat -> styleAmounts (transactionstyles `limitprecisionsto` commoditydirectivestyles)
|
|
||||||
TBPExact -> styleAmounts transactionstyles
|
TBPExact -> styleAmounts transactionstyles
|
||||||
where
|
where
|
||||||
transactionstyles = transactionCommodityStylesWith HardRounding t
|
transactionstyles = transactionCommodityStylesWith HardRounding t
|
||||||
|
|||||||
@ -87,24 +87,19 @@ import Data.List (union)
|
|||||||
|
|
||||||
|
|
||||||
-- | How to determine the precision used for checking that transactions are balanced. See #2402.
|
-- | How to determine the precision used for checking that transactions are balanced. See #2402.
|
||||||
data TransactionBalancingPrecision
|
data TransactionBalancingPrecision =
|
||||||
= -- | Legacy behaviour, as in hledger <=1.43:
|
TBPOld
|
||||||
|
-- ^ Legacy behaviour, as in hledger <1.44, included to ease upgrades.
|
||||||
-- use precision inferred from the whole journal, overridable by commodity directive or -c.
|
-- use precision inferred from the whole journal, overridable by commodity directive or -c.
|
||||||
-- Display precision is also transaction balancing precision; increasing it can break journal reading.
|
-- Display precision is also transaction balancing precision; increasing it can break journal reading.
|
||||||
-- Some journals from ledger or beancount are rejected until commodity directives are added.
|
-- Some valid journals are rejected until commodity directives are added.
|
||||||
TBPOld
|
-- Small unbalanced remainders can be hidden, and in accounts that are never reconciled, can accumulate over time.
|
||||||
-- | -- | Use precision inferred from the transaction, reducible by commodity directive (or -c ?)
|
| TBPExact
|
||||||
-- -- This is more robust when there is no commodity directive, because it's not affected by other transactions or P directives.
|
-- ^ Simpler, more robust behaviour, as in Ledger: use precision inferred from the transaction.
|
||||||
-- -- Increasing display precision does not increase balancing precision, so it does not break journal reading.
|
|
||||||
-- -- But reducing it does reduce balancing precision, so existing hledger journals which rely on this can still be read.
|
|
||||||
-- -- Journals from ledger or beancount are accepted without needing commodity directives.
|
|
||||||
-- TBPCompat
|
|
||||||
| -- | Use precision inferred from the transaction.
|
|
||||||
-- This is the most strict; transactions that worked with hledger <=1.43 may need to be adjusted.
|
|
||||||
-- It's also the simplest, and most robust overall ?
|
|
||||||
-- Display precision and transaction balancing precision are independent; display precision never affects journal reading.
|
-- Display precision and transaction balancing precision are independent; display precision never affects journal reading.
|
||||||
-- Journals from ledger or beancount are accepted without needing commodity directives.
|
-- Valid journals from ledger or beancount are accepted without needing commodity directives.
|
||||||
TBPExact
|
-- Every imbalance in a transaction is visibly accounted for in that transaction's journal entry.
|
||||||
|
|
||||||
deriving (Bounded, Enum, Eq, Ord, Read, Show)
|
deriving (Bounded, Enum, Eq, Ord, Read, Show)
|
||||||
|
|
||||||
instance HasAmounts Transaction where
|
instance HasAmounts Transaction where
|
||||||
|
|||||||
@ -284,9 +284,8 @@ transactionBalancingPrecisionFromOpts rawopts =
|
|||||||
case maybestringopt "txn-balancing" rawopts of
|
case maybestringopt "txn-balancing" rawopts of
|
||||||
Nothing -> Right TBPExact
|
Nothing -> Right TBPExact
|
||||||
Just "old" -> Right TBPOld
|
Just "old" -> Right TBPOld
|
||||||
-- Just "compat" -> Right TBPCompat
|
|
||||||
Just "exact" -> Right TBPExact
|
Just "exact" -> Right TBPExact
|
||||||
Just s -> Left $ s<>", should be one of: old, exact" -- compat
|
Just s -> Left $ s<>", should be one of: old, exact"
|
||||||
|
|
||||||
-- | Given a parser to ParsedJournal, input options, file path and
|
-- | Given a parser to ParsedJournal, input options, file path and
|
||||||
-- content: run the parser on the content, and finalise the result to
|
-- content: run the parser on the content, and finalise the result to
|
||||||
|
|||||||
@ -167,7 +167,6 @@ inputflags = [
|
|||||||
,flagReq ["txn-balancing"] (\s opts -> Right $ setopt "txn-balancing" s opts) "..." (unlines [
|
,flagReq ["txn-balancing"] (\s opts -> Right $ setopt "txn-balancing" s opts) "..." (unlines [
|
||||||
"how to check that transactions are balanced:"
|
"how to check that transactions are balanced:"
|
||||||
,"'old': - use global display precision"
|
,"'old': - use global display precision"
|
||||||
-- ,"'compat': - use transaction precision, reducible"
|
|
||||||
,"'exact': - use transaction precision (default)"
|
,"'exact': - use transaction precision (default)"
|
||||||
])
|
])
|
||||||
,flagNone ["infer-costs"] (setboolopt "infer-costs") "infer conversion equity postings from costs"
|
,flagNone ["infer-costs"] (setboolopt "infer-costs") "infer conversion equity postings from costs"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user