;close: --close-to also sets --open-from and vice versa (#1165)

This commit is contained in:
Simon Michael 2020-01-22 08:52:20 -08:00
parent aa8c18fcc8
commit dee9c0f150
2 changed files with 21 additions and 8 deletions

View File

@ -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

View File

@ -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