From 4bb840a0f327a66fc414718462507da70c5ea18f Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Wed, 22 Jan 2020 14:05:28 -0800 Subject: [PATCH] close: use the same default equity account for both (#1165) And some doc cleanups. "equity:opening/closing balances" is now the default account for both. --- hledger/Hledger/Cli/Commands/Close.hs | 22 +++++++++-------- hledger/Hledger/Cli/Commands/Close.md | 34 +++++++++++++-------------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/hledger/Hledger/Cli/Commands/Close.hs b/hledger/Hledger/Cli/Commands/Close.hs index 5a63bd494..366c041b5 100755 --- a/hledger/Hledger/Cli/Commands/Close.hs +++ b/hledger/Hledger/Cli/Commands/Close.hs @@ -18,18 +18,20 @@ import System.Console.CmdArgs.Explicit as C import Hledger import Hledger.Cli.CliOptions -defclosingacct = "equity:closing balances" -defopeningacct = "equity:opening balances" +defclosingdesc = "closing balances" +defopeningdesc = "opening balances" +defclosingacct = "equity:opening/closing balances" +defopeningacct = defclosingacct 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++")") + [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++")") ,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" + ,flagNone ["interleaved"] (setboolopt "interleaved") "keep equity and non-equity postings adjacent" + ,flagNone ["show-costs"] (setboolopt "show-costs") "keep balances with different costs separate" ] [generalflagsgroup1] hiddenflags @@ -82,7 +84,7 @@ close CliOpts{rawopts_=rawopts, reportopts_=ropts} j = do interleaved = boolopt "interleaved" rawopts -- the closing transaction - closingtxn = nulltransaction{tdate=closingdate, tdescription="closing balances", tpostings=closingps} + closingtxn = nulltransaction{tdate=closingdate, tdescription=defclosingdesc, tpostings=closingps} closingps = concat [ [posting{paccount = a @@ -112,7 +114,7 @@ close CliOpts{rawopts_=rawopts, reportopts_=ropts} j = do ++ [posting{paccount=closingacct, pamount=if explicit then mapMixedAmount precise totalamt else missingmixedamt} | not interleaved] -- the opening transaction - openingtxn = nulltransaction{tdate=openingdate, tdescription="opening balances", tpostings=openingps} + openingtxn = nulltransaction{tdate=openingdate, tdescription=defopeningdesc, tpostings=openingps} openingps = concat [ [posting{paccount = a diff --git a/hledger/Hledger/Cli/Commands/Close.md b/hledger/Hledger/Cli/Commands/Close.md index eceb84fb7..6e443a32d 100644 --- a/hledger/Hledger/Cli/Commands/Close.md +++ b/hledger/Hledger/Cli/Commands/Close.md @@ -1,31 +1,29 @@ close, equity\ Prints a "closing balances" transaction and an "opening balances" transaction that bring account balances to and from zero, respectively. -Useful for bringing asset/liability balances forward into a new journal file, -or for closing out revenues/expenses to retained earnings at the end of a -period. +These can be added to your journal file(s), eg to bring +asset/liability balances forward into a new journal file, or to +close out revenues/expenses to retained earnings at the end of a period. _FLAGS -You can choose to print just one of the transactions by using the +You can choose to print just one of these transactions by using the `--opening` or `--closing` flag. -The closing transaction transfers balances to `equity:closing balances`, -and the opening transaction transfers balances from `equity:opening balances`, -by default. You can choose different account names with the -`--close-to` and `--open-from` options. If you specify only one of -these, it is used for both. +One posting to `equity:opening/closing balances`, +with an implicit amount, is added to balance these transactions, +by default. +You can choose different closing/opening account names with the +`--close-to` and `--open-from` options. +If you specify only one, it is used for both. -By default, a single balancing equity posting is added at the end of -these journal entries, with the amount left implicit. +With `--x/--explicit`, the equity posting's amount will be shown. +If it involves multiple commodities, a posting for each commodity +will be shown (like the print command). -With `--x/--explicit`, the balancing amount is shown, and if -multiple commodities are involved, multiple single-commodity equity -postings are shown (like the print command). - -With `--interleaved`, the equity postings are shown next to each -posting they balance, which can be better for troubleshooting (and can -generate more postings). +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.