equity: ignore any begin date; closed balances are historical
This commit is contained in:
parent
0d3d5ff71e
commit
31effcd731
@ -16,8 +16,9 @@ import Hledger.Cli.CliOptions
|
|||||||
equitymode = hledgerCommandMode
|
equitymode = hledgerCommandMode
|
||||||
[here| equity
|
[here| equity
|
||||||
Print a "closing balances" transaction that brings all accounts (or with
|
Print a "closing balances" transaction that brings all accounts (or with
|
||||||
query arguments, just the matched accounts) to a zero balance, followed by an
|
query arguments, just the matched accounts) to a zero (historical) balance,
|
||||||
opposite "opening balances" transaction that restores the balances from zero.
|
followed by an opposite "opening balances" transaction that restores the
|
||||||
|
balances from zero.
|
||||||
|
|
||||||
FLAGS
|
FLAGS
|
||||||
|
|
||||||
@ -34,7 +35,8 @@ The closing transaction asserts a zero balance for each closed account.
|
|||||||
|
|
||||||
By default, the closing transaction is dated yesterday, with balances
|
By default, the closing transaction is dated yesterday, with balances
|
||||||
calculated as of end of yesterday, and the opening transaction is dated today.
|
calculated as of end of yesterday, and the opening transaction is dated today.
|
||||||
To close on some other date, use: `hledger close -e OPENINGDATE ...`
|
To close on some other date, use: `hledger close -e OPENINGDATE ...`.
|
||||||
|
(-p or date: can also be used, but any begin date is ignored.)
|
||||||
|
|
||||||
For example, carrying asset/liability balances into a new file for 2018:
|
For example, carrying asset/liability balances into a new file for 2018:
|
||||||
```
|
```
|
||||||
@ -46,12 +48,9 @@ $ hledger bs -f 2018.journal -f 2017.journal # still correct
|
|||||||
$ hledger bs -f 2017.journal not:desc:closing # must exclude closing txn
|
$ hledger bs -f 2017.journal not:desc:closing # must exclude closing txn
|
||||||
```
|
```
|
||||||
|
|
||||||
Possible issues/complications/todos:
|
Some things to be aware of:
|
||||||
- -p or date: should work as well as -e, but can be buggy
|
- you probably shouldn't filter by status or realness, or assertions will fail
|
||||||
- a begin date should have no effect. Closed balances should be historical.
|
- transactions spanning a file boundary may be tricky, eg:
|
||||||
- transactions on the opening date should be excluded from closed balances
|
|
||||||
- balance assertions can fail due to filtering by status or realness
|
|
||||||
- transactions spanning a file boundary, eg:
|
|
||||||
```
|
```
|
||||||
2017/12/31
|
2017/12/31
|
||||||
expenses:food 1
|
expenses:food 1
|
||||||
@ -66,12 +65,11 @@ Possible issues/complications/todos:
|
|||||||
equity CliOpts{reportopts_=ropts} j = do
|
equity CliOpts{reportopts_=ropts} j = do
|
||||||
today <- getCurrentDay
|
today <- getCurrentDay
|
||||||
let
|
let
|
||||||
-- TODO: this query is sometimes wrong
|
ropts_ = ropts{balancetype_=HistoricalBalance, accountlistmode_=ALFlat}
|
||||||
ropts_ = ropts{accountlistmode_=ALFlat}
|
|
||||||
q = queryFromOpts today ropts_
|
q = queryFromOpts today ropts_
|
||||||
openingdate = fromMaybe today $ queryEndDate False q
|
openingdate = fromMaybe today $ queryEndDate False q
|
||||||
closingdate = addDays (-1) openingdate
|
closingdate = addDays (-1) openingdate
|
||||||
(acctbals,_) = balanceReport ropts_ q j
|
(acctbals,_) = singleBalanceReport ropts_ q j
|
||||||
balancingamt = negate $ sum $ map (\(_,_,_,b) -> normaliseMixedAmountSquashPricesForDisplay b) acctbals
|
balancingamt = negate $ sum $ map (\(_,_,_,b) -> normaliseMixedAmountSquashPricesForDisplay b) acctbals
|
||||||
ps = [posting{paccount=a
|
ps = [posting{paccount=a
|
||||||
,pamount=mixed [b]
|
,pamount=mixed [b]
|
||||||
|
|||||||
@ -70,38 +70,24 @@ Y2016
|
|||||||
|
|
||||||
>>>=0
|
>>>=0
|
||||||
|
|
||||||
# Verify effect of period
|
# A begin date should be ignored
|
||||||
hledger equity -f- -p 2016 assets liabilities
|
hledger equity -f- -b2017/6/1 -e2018
|
||||||
<<<
|
<<<
|
||||||
2015/12/31 open
|
2017/1/1
|
||||||
assets:bank $100
|
(a) 1
|
||||||
assets:cash $20
|
|
||||||
equity:opening
|
|
||||||
|
|
||||||
2016/1/15 spend
|
|
||||||
expenses:sweets $5
|
|
||||||
assets:cash
|
|
||||||
|
|
||||||
2016/1/19 withdraw
|
|
||||||
assets:cash $20
|
|
||||||
assets:bank
|
|
||||||
|
|
||||||
2017/1/1 lend
|
|
||||||
liabilities $25
|
|
||||||
assets:cash
|
|
||||||
>>>
|
>>>
|
||||||
2016/12/31 closing balances
|
2017/12/31 closing balances
|
||||||
assets:bank $20 = $0
|
a -1 = 0
|
||||||
assets:cash $-15 = $0
|
|
||||||
equity:closing balances
|
equity:closing balances
|
||||||
|
|
||||||
2017/01/01 opening balances
|
2018/01/01 opening balances
|
||||||
assets:bank $-20 = $-20
|
a 1 = 1
|
||||||
assets:cash $15 = $15
|
|
||||||
equity:opening balances
|
equity:opening balances
|
||||||
|
|
||||||
>>>=0
|
>>>=0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# # Tear transaction across periods
|
# # Tear transaction across periods
|
||||||
# # TODO: clarify what should we see for this case
|
# # TODO: clarify what should we see for this case
|
||||||
# ../../bin/hledger-equity -f- -p 2016 assets liabilities
|
# ../../bin/hledger-equity -f- -p 2016 assets liabilities
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user