rename "uncleared" status to "unmarked" and --uncleared to --unmarked (#564)
See the issue and linked mail list discussion. Ambiguity between the uncleared state, and the "not cleared" --uncleared flag causes confusion and friction. At this point it seems best to break with Ledger and past hledger, pick a new name and drop --uncleared to put an end to it.
This commit is contained in:
parent
794647780d
commit
e119941648
@ -13,7 +13,7 @@
|
||||
```
|
||||
Usage: hledger-check [-f|--file FILE] [--alias OLD=NEW] [--ignore-assertions]
|
||||
[-b|--begin DATE] [-e|--end DATE] [-C|--cleared]
|
||||
[--pending] [-U|--uncleared] [-R|--real] [--sunday]
|
||||
[--pending] [-U|--unmarked] [-R|--real] [--sunday]
|
||||
[-D|--daily ASSERT] [-W|--weekly ASSERT]
|
||||
[-M|--monthly ASSERT] [-Q|--quarterly ASSERT]
|
||||
[-Y|--yearly ASSERT] [ASSERT]
|
||||
@ -27,8 +27,8 @@ Available options:
|
||||
-b,--begin DATE include postings/txns on or after this date
|
||||
-e,--end DATE include postings/txns before this date
|
||||
-C,--cleared include only cleared postings/txns
|
||||
--pending include only pending postings/txns
|
||||
-U,--uncleared include only uncleared (and pending) postings/txns
|
||||
-P,--pending include only pending postings/txns
|
||||
-U,--unmarked include only unmarked postings/txns
|
||||
-R,--real include only non-virtual postings
|
||||
--sunday weeks start on Sunday
|
||||
-D,--daily ASSERT assertions that must hold at the end of the day
|
||||
@ -228,10 +228,10 @@ inAssertion account = inAssertion'
|
||||
fixupJournal :: Opts -> H.Journal -> IO (H.Journal, [(H.AccountName, H.MixedAmount)])
|
||||
fixupJournal opts j = do
|
||||
today <- H.getCurrentDay
|
||||
let j' = (if cleared opts then H.filterJournalTransactions (H.Status H.Cleared) else id)
|
||||
. (if pending opts then H.filterJournalTransactions (H.Status H.Pending) else id)
|
||||
. (if uncleared opts then H.filterJournalTransactions (H.Status H.Uncleared) else id)
|
||||
. (if real opts then H.filterJournalTransactions (H.Real True) else id)
|
||||
let j' = (if cleared opts then H.filterJournalTransactions (H.Status H.Cleared) else id)
|
||||
. (if pending opts then H.filterJournalTransactions (H.Status H.Pending) else id)
|
||||
. (if unmarked opts then H.filterJournalTransactions (H.Status H.Unmarked) else id)
|
||||
. (if real opts then H.filterJournalTransactions (H.Real True) else id)
|
||||
$ H.journalApplyAliases (aliases opts) j
|
||||
let starting = case begin opts of
|
||||
Just _ ->
|
||||
@ -319,8 +319,8 @@ data Opts = Opts
|
||||
-- ^ Include only cleared postings/txns.
|
||||
, pending :: Bool
|
||||
-- ^ Include only pending postings/txns.
|
||||
, uncleared :: Bool
|
||||
-- ^ Include only uncleared (and pending) postings/txns.
|
||||
, unmarked :: Bool
|
||||
-- ^ Include only unmarked postings/txns.
|
||||
, real :: Bool
|
||||
-- ^ Include only non-virtual postings.
|
||||
, sunday :: Bool
|
||||
@ -362,7 +362,7 @@ args = info (helper <*> parser) $ mconcat
|
||||
<*> switch
|
||||
(arg' "pending" "include only pending postings/txns")
|
||||
<*> switch
|
||||
(arg 'U' "uncleared" "include only uncleared (and pending) postings/txns")
|
||||
(arg 'U' "unmarked" "include only unmarked postings/txns")
|
||||
<*> switch
|
||||
(arg 'R' "real" "include only non-virtual postings")
|
||||
<*> switch
|
||||
|
||||
@ -143,7 +143,7 @@ m4_define({{_reportingoptions_}}, {{
|
||||
`-P --pending`
|
||||
: include only pending postings/txns
|
||||
|
||||
`-U --uncleared`
|
||||
`-U --unmarked`
|
||||
: include only unmarked postings/txns
|
||||
|
||||
`-R --real`
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
1/1 uncleared
|
||||
1/1 unmarked
|
||||
(a) 1
|
||||
(b) 1
|
||||
|
||||
|
||||
@ -941,7 +941,7 @@ Right samplejournal = journalBalanceTransactions False $
|
||||
tsourcepos=nullsourcepos,
|
||||
tdate=parsedate "2008/01/01",
|
||||
tdate2=Nothing,
|
||||
tstatus=Uncleared,
|
||||
tstatus=Unmarked,
|
||||
tcode="",
|
||||
tdescription="income",
|
||||
tcomment="",
|
||||
@ -958,7 +958,7 @@ Right samplejournal = journalBalanceTransactions False $
|
||||
tsourcepos=nullsourcepos,
|
||||
tdate=parsedate "2008/06/01",
|
||||
tdate2=Nothing,
|
||||
tstatus=Uncleared,
|
||||
tstatus=Unmarked,
|
||||
tcode="",
|
||||
tdescription="gift",
|
||||
tcomment="",
|
||||
@ -975,7 +975,7 @@ Right samplejournal = journalBalanceTransactions False $
|
||||
tsourcepos=nullsourcepos,
|
||||
tdate=parsedate "2008/06/02",
|
||||
tdate2=Nothing,
|
||||
tstatus=Uncleared,
|
||||
tstatus=Unmarked,
|
||||
tcode="",
|
||||
tdescription="save",
|
||||
tcomment="",
|
||||
@ -1009,7 +1009,7 @@ Right samplejournal = journalBalanceTransactions False $
|
||||
tsourcepos=nullsourcepos,
|
||||
tdate=parsedate "2008/12/31",
|
||||
tdate2=Nothing,
|
||||
tstatus=Uncleared,
|
||||
tstatus=Unmarked,
|
||||
tcode="",
|
||||
tdescription="pay off",
|
||||
tcomment="",
|
||||
|
||||
@ -81,7 +81,7 @@ nullposting, posting :: Posting
|
||||
nullposting = Posting
|
||||
{pdate=Nothing
|
||||
,pdate2=Nothing
|
||||
,pstatus=Uncleared
|
||||
,pstatus=Unmarked
|
||||
,paccount=""
|
||||
,pamount=nullmixedamt
|
||||
,pcomment=""
|
||||
@ -164,14 +164,15 @@ postingDate2 p = headDef nulldate $ catMaybes dates
|
||||
,maybe Nothing (Just . tdate) $ ptransaction p
|
||||
]
|
||||
|
||||
-- | Get a posting's cleared status: cleared or pending if those are
|
||||
-- explicitly set, otherwise the cleared status of its parent
|
||||
-- transaction, or uncleared if there is no parent transaction. (Note
|
||||
-- Uncleared's ambiguity, it can mean "uncleared" or "don't know".
|
||||
-- | Get a posting's status. This is cleared or pending if those are
|
||||
-- explicitly set on the posting, otherwise the status of its parent
|
||||
-- transaction, or unmarked if there is no parent transaction. (Note
|
||||
-- the ambiguity, unmarked can mean "posting and transaction are both
|
||||
-- unmarked" or "posting is unmarked and don't know about the transaction".
|
||||
postingStatus :: Posting -> ClearedStatus
|
||||
postingStatus Posting{pstatus=s, ptransaction=mt}
|
||||
| s == Uncleared = case mt of Just t -> tstatus t
|
||||
Nothing -> Uncleared
|
||||
| s == Unmarked = case mt of Just t -> tstatus t
|
||||
Nothing -> Unmarked
|
||||
| otherwise = s
|
||||
|
||||
-- | Implicit tags for this transaction.
|
||||
|
||||
@ -95,7 +95,7 @@ nulltransaction = Transaction {
|
||||
tsourcepos=nullsourcepos,
|
||||
tdate=nulldate,
|
||||
tdate2=Nothing,
|
||||
tstatus=Uncleared,
|
||||
tstatus=Unmarked,
|
||||
tcode="",
|
||||
tdescription="",
|
||||
tcomment="",
|
||||
@ -133,7 +133,7 @@ tests_showTransactionUnelided = [
|
||||
nulltransaction{
|
||||
tdate=parsedate "2012/05/14",
|
||||
tdate2=Just $ parsedate "2012/05/15",
|
||||
tstatus=Uncleared,
|
||||
tstatus=Unmarked,
|
||||
tcode="code",
|
||||
tdescription="desc",
|
||||
tcomment="tcomment1\ntcomment2\n",
|
||||
@ -543,7 +543,7 @@ tests_Hledger_Data_Transaction = TestList $ concat [
|
||||
," assets:checking"
|
||||
,""
|
||||
])
|
||||
(let t = Transaction 0 nullsourcepos (parsedate "2007/01/28") Nothing Uncleared "" "coopportunity" "" []
|
||||
(let t = Transaction 0 nullsourcepos (parsedate "2007/01/28") Nothing Unmarked "" "coopportunity" "" []
|
||||
[posting{paccount="expenses:food:groceries", pamount=Mixed [usd 47.18], ptransaction=Just t}
|
||||
,posting{paccount="assets:checking", pamount=Mixed [usd (-47.18)], ptransaction=Just t}
|
||||
] ""
|
||||
@ -557,7 +557,7 @@ tests_Hledger_Data_Transaction = TestList $ concat [
|
||||
," assets:checking $-47.18"
|
||||
,""
|
||||
])
|
||||
(let t = Transaction 0 nullsourcepos (parsedate "2007/01/28") Nothing Uncleared "" "coopportunity" "" []
|
||||
(let t = Transaction 0 nullsourcepos (parsedate "2007/01/28") Nothing Unmarked "" "coopportunity" "" []
|
||||
[posting{paccount="expenses:food:groceries", pamount=Mixed [usd 47.18], ptransaction=Just t}
|
||||
,posting{paccount="assets:checking", pamount=Mixed [usd (-47.18)], ptransaction=Just t}
|
||||
] ""
|
||||
@ -573,7 +573,7 @@ tests_Hledger_Data_Transaction = TestList $ concat [
|
||||
,""
|
||||
])
|
||||
(showTransaction
|
||||
(txnTieKnot $ Transaction 0 nullsourcepos (parsedate "2007/01/28") Nothing Uncleared "" "coopportunity" "" []
|
||||
(txnTieKnot $ Transaction 0 nullsourcepos (parsedate "2007/01/28") Nothing Unmarked "" "coopportunity" "" []
|
||||
[posting{paccount="expenses:food:groceries", pamount=Mixed [usd 47.18]}
|
||||
,posting{paccount="assets:checking", pamount=Mixed [usd (-47.19)]}
|
||||
] ""))
|
||||
@ -586,7 +586,7 @@ tests_Hledger_Data_Transaction = TestList $ concat [
|
||||
,""
|
||||
])
|
||||
(showTransaction
|
||||
(txnTieKnot $ Transaction 0 nullsourcepos (parsedate "2007/01/28") Nothing Uncleared "" "coopportunity" "" []
|
||||
(txnTieKnot $ Transaction 0 nullsourcepos (parsedate "2007/01/28") Nothing Unmarked "" "coopportunity" "" []
|
||||
[posting{paccount="expenses:food:groceries", pamount=Mixed [usd 47.18]}
|
||||
] ""))
|
||||
|
||||
@ -598,7 +598,7 @@ tests_Hledger_Data_Transaction = TestList $ concat [
|
||||
,""
|
||||
])
|
||||
(showTransaction
|
||||
(txnTieKnot $ Transaction 0 nullsourcepos (parsedate "2007/01/28") Nothing Uncleared "" "coopportunity" "" []
|
||||
(txnTieKnot $ Transaction 0 nullsourcepos (parsedate "2007/01/28") Nothing Unmarked "" "coopportunity" "" []
|
||||
[posting{paccount="expenses:food:groceries", pamount=missingmixedamt}
|
||||
] ""))
|
||||
|
||||
@ -611,7 +611,7 @@ tests_Hledger_Data_Transaction = TestList $ concat [
|
||||
,""
|
||||
])
|
||||
(showTransaction
|
||||
(txnTieKnot $ Transaction 0 nullsourcepos (parsedate "2010/01/01") Nothing Uncleared "" "x" "" []
|
||||
(txnTieKnot $ Transaction 0 nullsourcepos (parsedate "2010/01/01") Nothing Unmarked "" "x" "" []
|
||||
[posting{paccount="a", pamount=Mixed [num 1 `at` (usd 2 `withPrecision` 0)]}
|
||||
,posting{paccount="b", pamount= missingmixedamt}
|
||||
] ""))
|
||||
@ -619,19 +619,19 @@ tests_Hledger_Data_Transaction = TestList $ concat [
|
||||
,"balanceTransaction" ~: do
|
||||
assertBool "detect unbalanced entry, sign error"
|
||||
(isLeft $ balanceTransaction Nothing
|
||||
(Transaction 0 nullsourcepos (parsedate "2007/01/28") Nothing Uncleared "" "test" "" []
|
||||
(Transaction 0 nullsourcepos (parsedate "2007/01/28") Nothing Unmarked "" "test" "" []
|
||||
[posting{paccount="a", pamount=Mixed [usd 1]}
|
||||
,posting{paccount="b", pamount=Mixed [usd 1]}
|
||||
] ""))
|
||||
|
||||
assertBool "detect unbalanced entry, multiple missing amounts"
|
||||
(isLeft $ balanceTransaction Nothing
|
||||
(Transaction 0 nullsourcepos (parsedate "2007/01/28") Nothing Uncleared "" "test" "" []
|
||||
(Transaction 0 nullsourcepos (parsedate "2007/01/28") Nothing Unmarked "" "test" "" []
|
||||
[posting{paccount="a", pamount=missingmixedamt}
|
||||
,posting{paccount="b", pamount=missingmixedamt}
|
||||
] ""))
|
||||
|
||||
let e = balanceTransaction Nothing (Transaction 0 nullsourcepos (parsedate "2007/01/28") Nothing Uncleared "" "" "" []
|
||||
let e = balanceTransaction Nothing (Transaction 0 nullsourcepos (parsedate "2007/01/28") Nothing Unmarked "" "" "" []
|
||||
[posting{paccount="a", pamount=Mixed [usd 1]}
|
||||
,posting{paccount="b", pamount=missingmixedamt}
|
||||
] "")
|
||||
@ -642,7 +642,7 @@ tests_Hledger_Data_Transaction = TestList $ concat [
|
||||
Right e' -> (pamount $ last $ tpostings e')
|
||||
Left _ -> error' "should not happen")
|
||||
|
||||
let e = balanceTransaction Nothing (Transaction 0 nullsourcepos (parsedate "2011/01/01") Nothing Uncleared "" "" "" []
|
||||
let e = balanceTransaction Nothing (Transaction 0 nullsourcepos (parsedate "2011/01/01") Nothing Unmarked "" "" "" []
|
||||
[posting{paccount="a", pamount=Mixed [usd 1.35]}
|
||||
,posting{paccount="b", pamount=Mixed [eur (-1)]}
|
||||
] "")
|
||||
@ -654,49 +654,49 @@ tests_Hledger_Data_Transaction = TestList $ concat [
|
||||
Left _ -> error' "should not happen")
|
||||
|
||||
assertBool "balanceTransaction balances based on cost if there are unit prices" (isRight $
|
||||
balanceTransaction Nothing (Transaction 0 nullsourcepos (parsedate "2011/01/01") Nothing Uncleared "" "" "" []
|
||||
balanceTransaction Nothing (Transaction 0 nullsourcepos (parsedate "2011/01/01") Nothing Unmarked "" "" "" []
|
||||
[posting{paccount="a", pamount=Mixed [usd 1 `at` eur 2]}
|
||||
,posting{paccount="a", pamount=Mixed [usd (-2) `at` eur 1]}
|
||||
] ""))
|
||||
|
||||
assertBool "balanceTransaction balances based on cost if there are total prices" (isRight $
|
||||
balanceTransaction Nothing (Transaction 0 nullsourcepos (parsedate "2011/01/01") Nothing Uncleared "" "" "" []
|
||||
balanceTransaction Nothing (Transaction 0 nullsourcepos (parsedate "2011/01/01") Nothing Unmarked "" "" "" []
|
||||
[posting{paccount="a", pamount=Mixed [usd 1 @@ eur 1]}
|
||||
,posting{paccount="a", pamount=Mixed [usd (-2) @@ eur 1]}
|
||||
] ""))
|
||||
|
||||
,"isTransactionBalanced" ~: do
|
||||
let t = Transaction 0 nullsourcepos (parsedate "2009/01/01") Nothing Uncleared "" "a" "" []
|
||||
let t = Transaction 0 nullsourcepos (parsedate "2009/01/01") Nothing Unmarked "" "a" "" []
|
||||
[posting{paccount="b", pamount=Mixed [usd 1.00], ptransaction=Just t}
|
||||
,posting{paccount="c", pamount=Mixed [usd (-1.00)], ptransaction=Just t}
|
||||
] ""
|
||||
assertBool "detect balanced" (isTransactionBalanced Nothing t)
|
||||
let t = Transaction 0 nullsourcepos (parsedate "2009/01/01") Nothing Uncleared "" "a" "" []
|
||||
let t = Transaction 0 nullsourcepos (parsedate "2009/01/01") Nothing Unmarked "" "a" "" []
|
||||
[posting{paccount="b", pamount=Mixed [usd 1.00], ptransaction=Just t}
|
||||
,posting{paccount="c", pamount=Mixed [usd (-1.01)], ptransaction=Just t}
|
||||
] ""
|
||||
assertBool "detect unbalanced" (not $ isTransactionBalanced Nothing t)
|
||||
let t = Transaction 0 nullsourcepos (parsedate "2009/01/01") Nothing Uncleared "" "a" "" []
|
||||
let t = Transaction 0 nullsourcepos (parsedate "2009/01/01") Nothing Unmarked "" "a" "" []
|
||||
[posting{paccount="b", pamount=Mixed [usd 1.00], ptransaction=Just t}
|
||||
] ""
|
||||
assertBool "detect unbalanced, one posting" (not $ isTransactionBalanced Nothing t)
|
||||
let t = Transaction 0 nullsourcepos (parsedate "2009/01/01") Nothing Uncleared "" "a" "" []
|
||||
let t = Transaction 0 nullsourcepos (parsedate "2009/01/01") Nothing Unmarked "" "a" "" []
|
||||
[posting{paccount="b", pamount=Mixed [usd 0], ptransaction=Just t}
|
||||
] ""
|
||||
assertBool "one zero posting is considered balanced for now" (isTransactionBalanced Nothing t)
|
||||
let t = Transaction 0 nullsourcepos (parsedate "2009/01/01") Nothing Uncleared "" "a" "" []
|
||||
let t = Transaction 0 nullsourcepos (parsedate "2009/01/01") Nothing Unmarked "" "a" "" []
|
||||
[posting{paccount="b", pamount=Mixed [usd 1.00], ptransaction=Just t}
|
||||
,posting{paccount="c", pamount=Mixed [usd (-1.00)], ptransaction=Just t}
|
||||
,posting{paccount="d", pamount=Mixed [usd 100], ptype=VirtualPosting, ptransaction=Just t}
|
||||
] ""
|
||||
assertBool "virtual postings don't need to balance" (isTransactionBalanced Nothing t)
|
||||
let t = Transaction 0 nullsourcepos (parsedate "2009/01/01") Nothing Uncleared "" "a" "" []
|
||||
let t = Transaction 0 nullsourcepos (parsedate "2009/01/01") Nothing Unmarked "" "a" "" []
|
||||
[posting{paccount="b", pamount=Mixed [usd 1.00], ptransaction=Just t}
|
||||
,posting{paccount="c", pamount=Mixed [usd (-1.00)], ptransaction=Just t}
|
||||
,posting{paccount="d", pamount=Mixed [usd 100], ptype=BalancedVirtualPosting, ptransaction=Just t}
|
||||
] ""
|
||||
assertBool "balanced virtual postings need to balance among themselves" (not $ isTransactionBalanced Nothing t)
|
||||
let t = Transaction 0 nullsourcepos (parsedate "2009/01/01") Nothing Uncleared "" "a" "" []
|
||||
let t = Transaction 0 nullsourcepos (parsedate "2009/01/01") Nothing Unmarked "" "a" "" []
|
||||
[posting{paccount="b", pamount=Mixed [usd 1.00], ptransaction=Just t}
|
||||
,posting{paccount="c", pamount=Mixed [usd (-1.00)], ptransaction=Just t}
|
||||
,posting{paccount="d", pamount=Mixed [usd 100], ptype=BalancedVirtualPosting, ptransaction=Just t}
|
||||
|
||||
@ -182,17 +182,17 @@ type Tag = (TagName, TagValue) -- ^ A tag name and (possibly empty) value.
|
||||
|
||||
-- | The status of a transaction or posting, recorded with a status mark
|
||||
-- (nothing, !, or *). What these mean is ultimately user defined.
|
||||
-- Calling the unmarked state "Uncleared" creates some ambiguity
|
||||
-- Calling the unmarked state "Unmarked" creates some ambiguity
|
||||
-- but is traditional in Ledger/hledger so we keep it (#564).
|
||||
-- Calling the type "Cleared..." might also be confusing, just Status
|
||||
-- would be better but that's currently used as a Query constructor.
|
||||
data ClearedStatus = Uncleared | Pending | Cleared
|
||||
data ClearedStatus = Unmarked | Pending | Cleared
|
||||
deriving (Eq,Ord,Typeable,Data,Generic)
|
||||
|
||||
instance NFData ClearedStatus
|
||||
|
||||
instance Show ClearedStatus where -- custom show.. bad idea.. don't do it..
|
||||
show Uncleared = ""
|
||||
show Unmarked = ""
|
||||
show Pending = "!"
|
||||
show Cleared = "*"
|
||||
|
||||
|
||||
@ -293,8 +293,8 @@ tests_parseQueryTerm = [
|
||||
"status:1" `gives` (Left $ Status Cleared)
|
||||
"status:*" `gives` (Left $ Status Cleared)
|
||||
"status:!" `gives` (Left $ Status Pending)
|
||||
"status:0" `gives` (Left $ Status Uncleared)
|
||||
"status:" `gives` (Left $ Status Uncleared)
|
||||
"status:0" `gives` (Left $ Status Unmarked)
|
||||
"status:" `gives` (Left $ Status Unmarked)
|
||||
"real:1" `gives` (Left $ Real True)
|
||||
"date:2008" `gives` (Left $ Date $ DateSpan (Just $ parsedate "2008/01/01") (Just $ parsedate "2009/01/01"))
|
||||
"date:from 2012/5/17" `gives` (Left $ Date $ DateSpan (Just $ parsedate "2012/05/17") Nothing)
|
||||
@ -367,7 +367,7 @@ parseTag s | "=" `T.isInfixOf` s = (T.unpack n, Just $ tail $ T.unpack v)
|
||||
parseStatus :: T.Text -> Either String ClearedStatus
|
||||
parseStatus s | s `elem` ["*","1"] = Right Cleared
|
||||
| s `elem` ["!"] = Right Pending
|
||||
| s `elem` ["","0"] = Right Uncleared
|
||||
| s `elem` ["","0"] = Right Unmarked
|
||||
| otherwise = Left $ "could not parse "++show s++" as a status (should be *, ! or empty)"
|
||||
|
||||
-- | Parse the boolean value part of a "status:" query. "1" means true,
|
||||
@ -695,12 +695,12 @@ tests_matchesPosting = [
|
||||
(Status Cleared) `matchesPosting` nullposting{pstatus=Cleared}
|
||||
assertBool "negative match on cleared posting status" $
|
||||
not $ (Not $ Status Cleared) `matchesPosting` nullposting{pstatus=Cleared}
|
||||
assertBool "positive match on uncleared posting status" $
|
||||
(Status Uncleared) `matchesPosting` nullposting{pstatus=Uncleared}
|
||||
assertBool "negative match on unclered posting status" $
|
||||
not $ (Not $ Status Uncleared) `matchesPosting` nullposting{pstatus=Uncleared}
|
||||
assertBool "positive match on unmarked posting status" $
|
||||
(Status Unmarked) `matchesPosting` nullposting{pstatus=Unmarked}
|
||||
assertBool "negative match on unmarked posting status" $
|
||||
not $ (Not $ Status Unmarked) `matchesPosting` nullposting{pstatus=Unmarked}
|
||||
assertBool "positive match on true posting status acquired from transaction" $
|
||||
(Status Cleared) `matchesPosting` nullposting{pstatus=Uncleared,ptransaction=Just nulltransaction{tstatus=Cleared}}
|
||||
(Status Cleared) `matchesPosting` nullposting{pstatus=Unmarked,ptransaction=Just nulltransaction{tstatus=Cleared}}
|
||||
assertBool "real:1 on real posting" $ (Real True) `matchesPosting` nullposting{ptype=RegularPosting}
|
||||
assertBool "real:1 on virtual posting fails" $ not $ (Real True) `matchesPosting` nullposting{ptype=VirtualPosting}
|
||||
assertBool "real:1 on balanced virtual posting fails" $ not $ (Real True) `matchesPosting` nullposting{ptype=BalancedVirtualPosting}
|
||||
|
||||
@ -174,7 +174,7 @@ statusp =
|
||||
choice'
|
||||
[ many spacenonewline >> char '*' >> return Cleared
|
||||
, many spacenonewline >> char '!' >> return Pending
|
||||
, return Uncleared
|
||||
, return Unmarked
|
||||
]
|
||||
<?> "cleared status"
|
||||
|
||||
|
||||
@ -627,7 +627,7 @@ transactionFromCsvRecord sourcepos rules record = t
|
||||
]
|
||||
status =
|
||||
case mfieldtemplate "status" of
|
||||
Nothing -> Uncleared
|
||||
Nothing -> Unmarked
|
||||
Just str -> either statuserror id .
|
||||
runParser (statusp <* eof) "" .
|
||||
T.pack $ render str
|
||||
|
||||
@ -470,7 +470,7 @@ test_transactionp = do
|
||||
nulltransaction{
|
||||
tdate=parsedate "2012/05/14",
|
||||
tdate2=Just $ parsedate "2012/05/15",
|
||||
tstatus=Uncleared,
|
||||
tstatus=Unmarked,
|
||||
tcode="code",
|
||||
tdescription="desc",
|
||||
tcomment=" tcomment1\n tcomment2\n ttag1: val1\n",
|
||||
|
||||
@ -407,7 +407,7 @@ Right samplejournal2 =
|
||||
tsourcepos=nullsourcepos,
|
||||
tdate=parsedate "2008/01/01",
|
||||
tdate2=Just $ parsedate "2009/01/01",
|
||||
tstatus=Uncleared,
|
||||
tstatus=Unmarked,
|
||||
tcode="",
|
||||
tdescription="income",
|
||||
tcomment="",
|
||||
|
||||
@ -264,7 +264,7 @@ intervalFromRawOpts = lastDef NoInterval . catMaybes . map intervalfromrawopt
|
||||
| otherwise = Nothing
|
||||
|
||||
-- | Get any cleared statuses to be matched, as specified by -C/--cleared,
|
||||
-- -P/--pending, -U/--uncleared options. -UPC is equivalent to no flags,
|
||||
-- -P/--pending, -U/--unmarked options. -UPC is equivalent to no flags,
|
||||
-- so this returns a list of 0-2 unique statuses.
|
||||
clearedStatusFromRawOpts :: RawOpts -> [ClearedStatus]
|
||||
clearedStatusFromRawOpts = simplify . nub . sort . catMaybes . map clearedstatusfromrawopt
|
||||
@ -272,7 +272,7 @@ clearedStatusFromRawOpts = simplify . nub . sort . catMaybes . map clearedstatus
|
||||
clearedstatusfromrawopt (n,_)
|
||||
| n == "cleared" = Just Cleared
|
||||
| n == "pending" = Just Pending
|
||||
| n == "uncleared" = Just Uncleared
|
||||
| n == "unmarked" = Just Unmarked
|
||||
| otherwise = Nothing
|
||||
simplify l = if length l == 3 then [] else l -- TODO: (maxBound :: ClearedStatus) or something
|
||||
|
||||
|
||||
@ -192,17 +192,18 @@ separated from it by a space, indicating one of three statuses:
|
||||
|
||||
mark | status
|
||||
:-----------|:-------------------
|
||||
| uncleared (no mark)
|
||||
| unmarked
|
||||
`!` | pending
|
||||
`*` | cleared
|
||||
|
||||
When reporting, you can filter by status with
|
||||
the `-U/--uncleared`, `-P/--pending`, and `-C/--cleared` flags;
|
||||
the `-U/--unmarked`, `-P/--pending`, and `-C/--cleared` flags;
|
||||
or the `status:`, `status:!`, and `status:*` [queries](/manual.html#queries);
|
||||
or the U, P, C keys in hledger-ui.
|
||||
|
||||
Note, in Ledger and in older versions of hledger, the "unmarked" state is called
|
||||
"uncleared". As of hledger 1.3 we have renamed it to unmarked for clarity.
|
||||
|
||||
Note from hledger 1.3 onwards, -U/--uncleared matches the uncleared (unmarked) status only.
|
||||
To replicate Ledger and old hledger's behaviour of also matching pending, combine -U and -P.
|
||||
|
||||
Status marks are optional, but can be helpful eg for reconciling with real-world accounts.
|
||||
|
||||
@ -320,7 +320,7 @@ asHandle ui0@UIState{
|
||||
VtyEvent (EvKey (KChar 'Z') []) -> scrollTop >> (continue $ regenerateScreens j d $ toggleEmpty ui)
|
||||
VtyEvent (EvKey (KChar 'C') []) -> scrollTop >> (continue $ regenerateScreens j d $ toggleCleared ui)
|
||||
VtyEvent (EvKey (KChar 'P') []) -> scrollTop >> (continue $ regenerateScreens j d $ togglePending ui)
|
||||
VtyEvent (EvKey (KChar 'U') []) -> scrollTop >> (continue $ regenerateScreens j d $ toggleUncleared ui)
|
||||
VtyEvent (EvKey (KChar 'U') []) -> scrollTop >> (continue $ regenerateScreens j d $ toggleUnmarked ui)
|
||||
VtyEvent (EvKey (KChar 'R') []) -> scrollTop >> (continue $ regenerateScreens j d $ toggleReal ui)
|
||||
VtyEvent (EvKey (KDown) [MShift]) -> continue $ regenerateScreens j d $ shrinkReportPeriod d ui
|
||||
VtyEvent (EvKey (KUp) [MShift]) -> continue $ regenerateScreens j d $ growReportPeriod d ui
|
||||
|
||||
@ -290,7 +290,7 @@ rsHandle ui@UIState{
|
||||
VtyEvent (EvKey (KChar 'Z') []) -> scrollTop >> (continue $ regenerateScreens j d $ toggleEmpty ui)
|
||||
VtyEvent (EvKey (KChar 'C') []) -> scrollTop >> (continue $ regenerateScreens j d $ toggleCleared ui)
|
||||
VtyEvent (EvKey (KChar 'P') []) -> scrollTop >> (continue $ regenerateScreens j d $ togglePending ui)
|
||||
VtyEvent (EvKey (KChar 'U') []) -> scrollTop >> (continue $ regenerateScreens j d $ toggleUncleared ui)
|
||||
VtyEvent (EvKey (KChar 'U') []) -> scrollTop >> (continue $ regenerateScreens j d $ toggleUnmarked ui)
|
||||
VtyEvent (EvKey (KChar 'R') []) -> scrollTop >> (continue $ regenerateScreens j d $ toggleReal ui)
|
||||
VtyEvent (EvKey (KChar '/') []) -> (continue $ regenerateScreens j d $ showMinibuffer ui)
|
||||
VtyEvent (EvKey (KDown) [MShift]) -> continue $ regenerateScreens j d $ shrinkReportPeriod d ui
|
||||
|
||||
@ -27,10 +27,10 @@ togglePending :: UIState -> UIState
|
||||
togglePending ui@UIState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}}} =
|
||||
ui{aopts=uopts{cliopts_=copts{reportopts_=reportOptsToggleStatus Pending ropts}}}
|
||||
|
||||
-- | Toggle between showing only uncleared items or all items.
|
||||
toggleUncleared :: UIState -> UIState
|
||||
toggleUncleared ui@UIState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}}} =
|
||||
ui{aopts=uopts{cliopts_=copts{reportopts_=reportOptsToggleStatus Uncleared ropts}}}
|
||||
-- | Toggle between showing only unmarked items or all items.
|
||||
toggleUnmarked :: UIState -> UIState
|
||||
toggleUnmarked ui@UIState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}}} =
|
||||
ui{aopts=uopts{cliopts_=copts{reportopts_=reportOptsToggleStatus Unmarked ropts}}}
|
||||
|
||||
reportOptsToggleStatus s ropts
|
||||
| clearedstatus_ ropts == [s] = ropts{clearedstatus_=[]}
|
||||
|
||||
@ -32,7 +32,7 @@ uiShowClearedStatus = map showstatus
|
||||
where
|
||||
showstatus Cleared = "cleared"
|
||||
showstatus Pending = "pending"
|
||||
showstatus Uncleared = "uncleared"
|
||||
showstatus Unmarked = "unmarked"
|
||||
|
||||
-- | Draw the help dialog, called when help mode is active.
|
||||
helpDialog :: Widget Name
|
||||
@ -78,7 +78,7 @@ helpDialog =
|
||||
,renderKey ("/", "set a filter query")
|
||||
,renderKey ("C", "toggle cleared/all")
|
||||
,renderKey ("P", "toggle pending/all")
|
||||
,renderKey ("U", "toggle uncleared/all")
|
||||
,renderKey ("U", "toggle unmarked/all")
|
||||
,renderKey ("R", "toggle real/all")
|
||||
,renderKey ("Z", "toggle nonzero/all")
|
||||
,renderKey ("DEL/BS", "remove filters")
|
||||
|
||||
@ -344,7 +344,7 @@ journal7 = nulljournal {jtxns =
|
||||
tsourcepos=nullsourcepos,
|
||||
tdate=parsedate "2007/01/01",
|
||||
tdate2=Nothing,
|
||||
tstatus=Uncleared,
|
||||
tstatus=Unmarked,
|
||||
tcode="*",
|
||||
tdescription="opening balance",
|
||||
tcomment="",
|
||||
@ -361,7 +361,7 @@ journal7 = nulljournal {jtxns =
|
||||
tsourcepos=nullsourcepos,
|
||||
tdate=parsedate "2007/02/01",
|
||||
tdate2=Nothing,
|
||||
tstatus=Uncleared,
|
||||
tstatus=Unmarked,
|
||||
tcode="*",
|
||||
tdescription="ayres suites",
|
||||
tcomment="",
|
||||
@ -378,7 +378,7 @@ journal7 = nulljournal {jtxns =
|
||||
tsourcepos=nullsourcepos,
|
||||
tdate=parsedate "2007/01/02",
|
||||
tdate2=Nothing,
|
||||
tstatus=Uncleared,
|
||||
tstatus=Unmarked,
|
||||
tcode="*",
|
||||
tdescription="auto transfer to savings",
|
||||
tcomment="",
|
||||
@ -395,7 +395,7 @@ journal7 = nulljournal {jtxns =
|
||||
tsourcepos=nullsourcepos,
|
||||
tdate=parsedate "2007/01/03",
|
||||
tdate2=Nothing,
|
||||
tstatus=Uncleared,
|
||||
tstatus=Unmarked,
|
||||
tcode="*",
|
||||
tdescription="poquito mas",
|
||||
tcomment="",
|
||||
@ -412,7 +412,7 @@ journal7 = nulljournal {jtxns =
|
||||
tsourcepos=nullsourcepos,
|
||||
tdate=parsedate "2007/01/03",
|
||||
tdate2=Nothing,
|
||||
tstatus=Uncleared,
|
||||
tstatus=Unmarked,
|
||||
tcode="*",
|
||||
tdescription="verizon",
|
||||
tcomment="",
|
||||
@ -429,7 +429,7 @@ journal7 = nulljournal {jtxns =
|
||||
tsourcepos=nullsourcepos,
|
||||
tdate=parsedate "2007/01/03",
|
||||
tdate2=Nothing,
|
||||
tstatus=Uncleared,
|
||||
tstatus=Unmarked,
|
||||
tcode="*",
|
||||
tdescription="discover",
|
||||
tcomment="",
|
||||
|
||||
@ -153,7 +153,7 @@ transactionWizard es@EntryState{..} = do
|
||||
balancedPostingsWizard = do
|
||||
ps <- postingsWizard es2{esPostings=[]}
|
||||
let t = nulltransaction{tdate=date
|
||||
,tstatus=Uncleared
|
||||
,tstatus=Unmarked
|
||||
,tcode=code
|
||||
,tdescription=desc
|
||||
,tcomment=comment
|
||||
|
||||
@ -141,7 +141,7 @@ reportflags = [
|
||||
|
||||
,flagNone ["cleared","C"] (setboolopt "cleared") "include only cleared postings/txns"
|
||||
,flagNone ["pending","P"] (setboolopt "pending") "include only pending postings/txns"
|
||||
,flagNone ["uncleared","U"] (setboolopt "uncleared") "include only unmarked postings/txns"
|
||||
,flagNone ["unmarked","U"] (setboolopt "unmarked") "include only unmarked postings/txns"
|
||||
,flagNone ["real","R"] (setboolopt "real") "include only non-virtual postings"
|
||||
,flagReq ["depth"] (\s opts -> Right $ setopt "depth" s opts) "N" "hide accounts/postings deeper than N"
|
||||
,flagNone ["empty","E"] (setboolopt "empty") "show items with zero amount, normally hidden"
|
||||
|
||||
@ -74,7 +74,7 @@ showLedgerStats l today span =
|
||||
,("Accounts", printf "%d (depth %d)" acctnum acctdepth)
|
||||
,("Commodities", printf "%s (%s)" (show $ length cs) (T.intercalate ", " cs))
|
||||
-- Transactions this month : %(monthtxns)s (last month in the same period: %(lastmonthtxns)s)
|
||||
-- Uncleared transactions : %(uncleared)s
|
||||
-- Unmarked transactions : %(unmarked)s
|
||||
-- Days since reconciliation : %(reconcileelapsed)s
|
||||
-- Days since last transaction : %(recentelapsed)s
|
||||
]
|
||||
|
||||
@ -178,7 +178,11 @@ or [balance assertions](manual.html#assertions-and-ordering).
|
||||
With hledger you can also specify start and/or end dates with a query argument,
|
||||
date:START-END, which probably doesn't combine perfectly with the options.
|
||||
|
||||
- in hledger version 1.3 onward, -U/--uncleared does not match pending things.
|
||||
- in hledger version 1.3 onward,
|
||||
the "uncleared" status has been renamed to "unmarked",
|
||||
it is matched by the -U/--unmarked flag.
|
||||
Also, the --unmarked/--pending/--cleared flags can be combined,
|
||||
so eg -UP matches unmarked and pending, similar to Ledger's --uncleared flag.
|
||||
(#564)
|
||||
|
||||
- hledger's -P flag is short for --pending. Ledger uses it for grouping by payee.
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
# 1. transactions and postings have status marks which are nothing, ! or *
|
||||
hledger -fstatus.journal print
|
||||
>>>
|
||||
2017/01/01 uncleared
|
||||
2017/01/01 unmarked
|
||||
(a) 1
|
||||
(b) 1
|
||||
|
||||
@ -46,26 +46,26 @@ hledger -fstatus.journal print --pending
|
||||
|
||||
>>>=0
|
||||
|
||||
# 5. --uncleared matches everything but *
|
||||
hledger -fstatus.journal print --uncleared
|
||||
# 5. --unmarked matches no status mark only
|
||||
hledger -fstatus.journal print --unmarked
|
||||
>>>
|
||||
2017/01/01 uncleared
|
||||
2017/01/01 unmarked
|
||||
(a) 1
|
||||
(b) 1
|
||||
|
||||
>>>=0
|
||||
|
||||
# 6. these flags can be combined
|
||||
hledger -fstatus.journal register --uncleared --pending
|
||||
hledger -fstatus.journal register --unmarked --pending
|
||||
>>>
|
||||
2017/01/01 uncleared (a) 1 1
|
||||
2017/01/01 unmarked (a) 1 1
|
||||
(b) 1 2
|
||||
2017/01/02 pending (a) 1 3
|
||||
(b) 1 4
|
||||
>>>= 0
|
||||
|
||||
# 7. these flags work with other commands
|
||||
hledger -fstatus.journal balance -N --uncleared
|
||||
hledger -fstatus.journal balance -N --unmarked
|
||||
>>>
|
||||
1 a
|
||||
1 b
|
||||
@ -94,7 +94,7 @@ hledger -fstatus.journal print status:!
|
||||
# 10. status: matches unmarked only
|
||||
hledger -fstatus.journal print status:
|
||||
>>>
|
||||
2017/01/01 uncleared
|
||||
2017/01/01 unmarked
|
||||
(a) 1
|
||||
(b) 1
|
||||
|
||||
@ -103,7 +103,7 @@ hledger -fstatus.journal print status:
|
||||
# 11. multiple status: queries are OR'd
|
||||
hledger -fstatus.journal print status: status:!
|
||||
>>>
|
||||
2017/01/01 uncleared
|
||||
2017/01/01 unmarked
|
||||
(a) 1
|
||||
(b) 1
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user