fix:check tags: _price-matched -> _cost-matched, and whitelisted [#2247]
This commit is contained in:
parent
b8497c830e
commit
71a7879213
@ -104,7 +104,7 @@ transactionCheckBalanced BalancingOpts{commodity_styles_} t = errs
|
|||||||
-- convert this posting's amount to cost,
|
-- convert this posting's amount to cost,
|
||||||
-- without getting confused by redundant costs/equity postings
|
-- without getting confused by redundant costs/equity postings
|
||||||
postingBalancingAmount p
|
postingBalancingAmount p
|
||||||
| "_price-matched" `elem` map fst (ptags p) = mixedAmountStripCosts $ pamount p
|
| "_cost-matched" `elem` map fst (ptags p) = mixedAmountStripCosts $ pamount p
|
||||||
| otherwise = mixedAmountCost $ pamount p
|
| otherwise = mixedAmountCost $ pamount p
|
||||||
|
|
||||||
-- transaction balancedness is checked at each commodity's display precision
|
-- transaction balancedness is checked at each commodity's display precision
|
||||||
|
|||||||
@ -232,7 +232,8 @@ builtinTags = [
|
|||||||
,"_generated-transaction" -- always exists on generated periodic txns
|
,"_generated-transaction" -- always exists on generated periodic txns
|
||||||
,"_generated-posting" -- always exists on generated auto postings
|
,"_generated-posting" -- always exists on generated auto postings
|
||||||
,"_modified" -- always exists on txns which have had auto postings added
|
,"_modified" -- always exists on txns which have had auto postings added
|
||||||
,"_conversion-matched" -- exists on postings which have been matched with a nearby @/@@ cost notation
|
,"_conversion-matched" -- marks postings with a cost which have been matched with a nearby pair of equity conversion postings
|
||||||
|
,"_cost-matched" -- marks equity conversion postings which have been matched with a nearby posting with a cost
|
||||||
]
|
]
|
||||||
|
|
||||||
-- | In each tranaction, check that any conversion postings occur in adjacent pairs.
|
-- | In each tranaction, check that any conversion postings occur in adjacent pairs.
|
||||||
|
|||||||
@ -466,13 +466,13 @@ postingToCost ToCost p
|
|||||||
-- Make sure not to duplicate them when matching ones exist already.
|
-- Make sure not to duplicate them when matching ones exist already.
|
||||||
postingAddInferredEquityPostings :: Bool -> Text -> Posting -> [Posting]
|
postingAddInferredEquityPostings :: Bool -> Text -> Posting -> [Posting]
|
||||||
postingAddInferredEquityPostings verbosetags equityAcct p
|
postingAddInferredEquityPostings verbosetags equityAcct p
|
||||||
| "_price-matched" `elem` map fst (ptags p) = [p]
|
| "_cost-matched" `elem` map fst (ptags p) = [p]
|
||||||
| otherwise = taggedPosting : concatMap conversionPostings costs
|
| otherwise = taggedPosting : concatMap conversionPostings costs
|
||||||
where
|
where
|
||||||
costs = filter (isJust . acost) . amountsRaw $ pamount p
|
costs = filter (isJust . acost) . amountsRaw $ pamount p
|
||||||
taggedPosting
|
taggedPosting
|
||||||
| null costs = p
|
| null costs = p
|
||||||
| otherwise = p{ ptags = ("_price-matched","") : ptags p }
|
| otherwise = p{ ptags = ("_cost-matched","") : ptags p }
|
||||||
conversionPostings amt = case acost amt of
|
conversionPostings amt = case acost amt of
|
||||||
Nothing -> []
|
Nothing -> []
|
||||||
Just _ -> [ cp{ paccount = accountPrefix <> amtCommodity
|
Just _ -> [ cp{ paccount = accountPrefix <> amtCommodity
|
||||||
|
|||||||
@ -299,7 +299,7 @@ transactionInferCostsFromEquity dryrun conversionaccts t = first (annotateErrorW
|
|||||||
-- Approximately: given a pair of conversion postings to match,
|
-- Approximately: given a pair of conversion postings to match,
|
||||||
-- and lists of the remaining unmatched costful and costless other postings,
|
-- and lists of the remaining unmatched costful and costless other postings,
|
||||||
-- 1. find (and consume) two other postings which match the two conversion postings
|
-- 1. find (and consume) two other postings which match the two conversion postings
|
||||||
-- 2. add identifying tags to the four postings
|
-- 2. add identifying (hidden) tags to the four postings
|
||||||
-- 3. add an explicit cost, if missing, to one of the matched other postings
|
-- 3. add an explicit cost, if missing, to one of the matched other postings
|
||||||
-- 4. or if there is a problem, raise an informative error or do nothing as appropriate.
|
-- 4. or if there is a problem, raise an informative error or do nothing as appropriate.
|
||||||
-- Or, if the first argument is true:
|
-- Or, if the first argument is true:
|
||||||
@ -326,8 +326,8 @@ transactionInferCostsFromEquity dryrun conversionaccts t = first (annotateErrorW
|
|||||||
|
|
||||||
-- A function that adds a cost and/or tag to a numbered posting if appropriate.
|
-- A function that adds a cost and/or tag to a numbered posting if appropriate.
|
||||||
postingAddCostAndOrTag np costp (n,p) =
|
postingAddCostAndOrTag np costp (n,p) =
|
||||||
(n, if | n == np -> costp `postingAddTags` [("_price-matched","")]
|
(n, if | n == np -> costp `postingAddTags` [("_cost-matched","")] -- add this tag to the posting with a cost
|
||||||
| n == n1 || n == n2 -> p `postingAddTags` [("_conversion-matched","")]
|
| n == n1 || n == n2 -> p `postingAddTags` [("_conversion-matched","")] -- add this tag to the two equity conversion postings
|
||||||
| otherwise -> p)
|
| otherwise -> p)
|
||||||
|
|
||||||
-- Annotate any errors with the conversion posting pair
|
-- Annotate any errors with the conversion posting pair
|
||||||
|
|||||||
@ -1805,6 +1805,7 @@ Tags you can set to influence hledger's behaviour:
|
|||||||
date2 -- overrides a posting's secondary date
|
date2 -- overrides a posting's secondary date
|
||||||
type -- declares an account's type
|
type -- declares an account's type
|
||||||
```
|
```
|
||||||
|
|
||||||
Tags hledger adds to indicate generated data:
|
Tags hledger adds to indicate generated data:
|
||||||
```
|
```
|
||||||
t -- appears on postings generated by timedot letters
|
t -- appears on postings generated by timedot letters
|
||||||
@ -1814,14 +1815,17 @@ Tags hledger adds to indicate generated data:
|
|||||||
generated-transaction -- appears on generated periodic txns (with --verbose-tags)
|
generated-transaction -- appears on generated periodic txns (with --verbose-tags)
|
||||||
generated-posting -- appears on generated auto postings (with --verbose-tags)
|
generated-posting -- appears on generated auto postings (with --verbose-tags)
|
||||||
modified -- appears on txns which have had auto postings added (with --verbose-tags)
|
modified -- appears on txns which have had auto postings added (with --verbose-tags)
|
||||||
|
|
||||||
Not displayed, but queryable:
|
Not displayed, but queryable:
|
||||||
_generated-transaction -- exists on generated periodic txns (always)
|
_generated-transaction -- exists on generated periodic txns (always)
|
||||||
_generated-posting -- exists on generated auto postings (always)
|
_generated-posting -- exists on generated auto postings (always)
|
||||||
_modified -- exists on txns which have had auto postings added (always)
|
_modified -- exists on txns which have had auto postings added (always)
|
||||||
```
|
```
|
||||||
Tags hledger uses internally:
|
|
||||||
|
Other tags hledger uses internally:
|
||||||
```
|
```
|
||||||
_conversion-matched -- exists on postings which have been matched with a nearby @/@@ cost annotation
|
_cost-matched -- marks postings with a cost which have been matched with a nearby pair of equity conversion postings
|
||||||
|
_conversion-matched -- marks equity conversion postings which have been matched with a nearby posting with a cost
|
||||||
```
|
```
|
||||||
|
|
||||||
### Tag values
|
### Tag values
|
||||||
|
|||||||
@ -58,6 +58,7 @@ $ hledger -f - check tags
|
|||||||
; _generated-posting:
|
; _generated-posting:
|
||||||
; _modified:
|
; _modified:
|
||||||
; _conversion-matched:
|
; _conversion-matched:
|
||||||
|
; _cost-matched:
|
||||||
$ hledger -f - check tags
|
$ hledger -f - check tags
|
||||||
|
|
||||||
# ** 7. Declaring the built-in special tags is harmless.
|
# ** 7. Declaring the built-in special tags is harmless.
|
||||||
@ -77,4 +78,5 @@ tag _generated-transaction ; always exists on generated periodic txns
|
|||||||
tag _generated-posting ; always exists on generated auto postings
|
tag _generated-posting ; always exists on generated auto postings
|
||||||
tag _modified ; always exists on txns which have had auto postings added
|
tag _modified ; always exists on txns which have had auto postings added
|
||||||
tag _conversion-matched ; exists on postings which have been matched with a nearby @/@@ cost notation
|
tag _conversion-matched ; exists on postings which have been matched with a nearby @/@@ cost notation
|
||||||
|
tag _cost-matched ; exists on postings which have been matched with a nearby @/@@ cost notation
|
||||||
$ hledger -f - check tags
|
$ hledger -f - check tags
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user