diff --git a/hledger/Hledger/Cli/Commands/Close.hs b/hledger/Hledger/Cli/Commands/Close.hs index 7e6b4d632..c366f3a27 100755 --- a/hledger/Hledger/Cli/Commands/Close.hs +++ b/hledger/Hledger/Cli/Commands/Close.hs @@ -42,11 +42,17 @@ close CliOpts{rawopts_=rawopts, reportopts_=ropts} j = do (opening, closing) = case (boolopt "opening" rawopts, boolopt "closing" rawopts) of (False, False) -> (True, True) - (o, c) -> (o, c) + (o, c) -> (o, c) -- accounts to close to and open from - closingacct = T.pack $ fromMaybe defclosingacct $ maybestringopt "close-to" rawopts - openingacct = T.pack $ fromMaybe defopeningacct $ maybestringopt "open-from" rawopts + -- if a name is specified for only one, it is used for both + (closingacct, openingacct) = + let (mc, mo) = (T.pack <$> maybestringopt "close-to" rawopts, T.pack <$> maybestringopt "open-from" 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 defclosingacct, T.pack defopeningacct) -- interleave equity postings next to the corresponding closing posting, or put them all at the end ? interleaved = boolopt "interleaved" rawopts diff --git a/hledger/Hledger/Cli/Commands/Close.md b/hledger/Hledger/Cli/Commands/Close.md index 6229f657a..bd01eba78 100644 --- a/hledger/Hledger/Cli/Commands/Close.md +++ b/hledger/Hledger/Cli/Commands/Close.md @@ -7,14 +7,21 @@ period. _FLAGS -The closing transaction transfers balances to "equity:closing balances", -and the opening transaction transfers balances from "equity:opening balances", -or you can customise these with the `--close-to` and `--open-from` options. You can choose to print just one of the transactions by using the `--opening` or `--closing` flag. -The equity postings appear at the end of the transaction by default; -with `--interleaved`, they appear beside their corresponding closing postings. +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. + +The "equity" postings are shown at the end of the transaction +by default (and are combined when possible). +With `--interleaved`, they are shown next to each posting they +balance, instead (better for troubleshooting). + +### close usage If you split your journal files by time (eg yearly), you will typically run this command at the end of the year, and save the