From cda8909aae1b1109bc8052679760d532a7c0c156 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Wed, 22 Jan 2020 15:04:05 -0800 Subject: [PATCH] close: don't repeat the description by default (#1165) You'll almost certainly want the opening/closing descriptions to be different, for filtering, so making --close-desc and --open-desc fully independent is a better default. And more doc cleanups. --- hledger/Hledger/Cli/Commands/Close.hs | 19 ++++++------------- hledger/Hledger/Cli/Commands/Close.md | 15 +++++++-------- 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/hledger/Hledger/Cli/Commands/Close.hs b/hledger/Hledger/Cli/Commands/Close.hs index 7d91b0db3..74f8801a8 100755 --- a/hledger/Hledger/Cli/Commands/Close.hs +++ b/hledger/Hledger/Cli/Commands/Close.hs @@ -27,10 +27,10 @@ closemode = hledgerCommandMode $(embedFileRelative "Hledger/Cli/Commands/Close.txt") [flagNone ["closing"] (setboolopt "closing") "show just closing transaction" ,flagNone ["opening"] (setboolopt "opening") "show just opening transaction" - ,flagReq ["close-to"] (\s opts -> Right $ setopt "close-to" s opts) "ACCT" ("account to transfer closing balances to (default: "++defclosingacct++")") - ,flagReq ["open-from"] (\s opts -> Right $ setopt "open-from" s opts) "ACCT" ("account to transfer opening balances from (default: "++defopeningacct++")") ,flagReq ["close-desc"] (\s opts -> Right $ setopt "close-desc" s opts) "DESC" ("description for closing transaction (default: "++defclosingdesc++")") ,flagReq ["open-desc"] (\s opts -> Right $ setopt "open-desc" s opts) "DESC" ("description for opening transaction (default: "++defopeningdesc++")") + ,flagReq ["close-to"] (\s opts -> Right $ setopt "close-to" s opts) "ACCT" ("account to transfer closing balances to (default: "++defclosingacct++")") + ,flagReq ["open-from"] (\s opts -> Right $ setopt "open-from" s opts) "ACCT" ("account to transfer opening balances from (default: "++defopeningacct++")") ,flagNone ["explicit","x"] (setboolopt "explicit") "show all amounts explicitly" ,flagNone ["interleaved"] (setboolopt "interleaved") "keep equity and non-equity postings adjacent" ,flagNone ["show-costs"] (setboolopt "show-costs") "keep balances with different costs separate" @@ -50,6 +50,10 @@ close CliOpts{rawopts_=rawopts, reportopts_=ropts} j = do (False, False) -> (True, True) (o, c) -> (o, c) + -- descriptions to use for the closing/opening transactions + closingdesc = fromMaybe (T.pack defclosingdesc) $ T.pack <$> maybestringopt "close-desc" rawopts + openingdesc = fromMaybe (T.pack defopeningdesc) $ T.pack <$> maybestringopt "open-desc" rawopts + -- accounts to close to and open from -- if only one is specified, it is used for both (closingacct, openingacct) = @@ -61,17 +65,6 @@ close CliOpts{rawopts_=rawopts, reportopts_=ropts} j = do (Nothing, Just o) -> (o, o) (Nothing, Nothing) -> (T.pack defclosingacct, T.pack defopeningacct) - -- descriptions to use for the closing/opening transactions - -- if only one is specified, it is used for both - (closingdesc, openingdesc) = - let (mc, mo) = - (T.pack <$> maybestringopt "close-desc" rawopts, T.pack <$> maybestringopt "open-desc" rawopts) - in case (mc, mo) of - (Just c, Just o) -> (c, o) - (Just c, Nothing) -> (c, c) - (Nothing, Just o) -> (o, o) - (Nothing, Nothing) -> (T.pack defclosingdesc, T.pack defopeningdesc) - -- dates of the closing and opening transactions ropts_ = ropts{balancetype_=HistoricalBalance, accountlistmode_=ALFlat} q = queryFromOpts today ropts_ diff --git a/hledger/Hledger/Cli/Commands/Close.md b/hledger/Hledger/Cli/Commands/Close.md index 715900fed..d7498ee83 100644 --- a/hledger/Hledger/Cli/Commands/Close.md +++ b/hledger/Hledger/Cli/Commands/Close.md @@ -8,22 +8,21 @@ close out revenues/expenses to retained earnings at the end of a period. _FLAGS You can print just one of these transactions by using the -`--opening` or `--closing` flag. +`--closing` or `--opening` flag. +You can customise their descriptions with the +`--close-desc` and `--open-desc` options. -One amountless posting to `equity:opening/closing balances` is added +One amountless posting to "equity:opening/closing balances" is added to balance the transactions, by default. -You can customise this account name with the `--close-to` and -`--open-from` options. (If you specify only one, it is used for both.) -Similarly, you can customise the transaction descriptions with -`--close-desc` and `--open-desc`. +You can customise this account name with `--close-to` and `--open-from`; +if you specify only one of these, it will be used for both. With `--x/--explicit`, the equity posting's amount will be shown. And if it involves multiple commodities, a posting for each commodity -will be shown (as with the print command). +will be shown, as with the print command. With `--interleaved`, the equity postings are shown next to the postings they balance, which makes troubleshooting easier. -(It can also generate more postings.) By default, transaction prices in the journal are ignored when generating the closing/opening transactions.