mirror of
https://github.com/simonmichael/hledger.git
synced 2024-11-09 21:22:26 +03:00
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
|
||||
[here| equity
|
||||
Print a "closing balances" transaction that brings all accounts (or with
|
||||
query arguments, just the matched accounts) to a zero balance, followed by an
|
||||
opposite "opening balances" transaction that restores the balances from zero.
|
||||
query arguments, just the matched accounts) to a zero (historical) balance,
|
||||
followed by an opposite "opening balances" transaction that restores the
|
||||
balances from zero.
|
||||
|
||||
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
|
||||
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:
|
||||
```
|
||||
@ -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
|
||||
```
|
||||
|
||||
Possible issues/complications/todos:
|
||||
- -p or date: should work as well as -e, but can be buggy
|
||||
- a begin date should have no effect. Closed balances should be historical.
|
||||
- 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:
|
||||
Some things to be aware of:
|
||||
- you probably shouldn't filter by status or realness, or assertions will fail
|
||||
- transactions spanning a file boundary may be tricky, eg:
|
||||
```
|
||||
2017/12/31
|
||||
expenses:food 1
|
||||
@ -66,12 +65,11 @@ Possible issues/complications/todos:
|
||||
equity CliOpts{reportopts_=ropts} j = do
|
||||
today <- getCurrentDay
|
||||
let
|
||||
-- TODO: this query is sometimes wrong
|
||||
ropts_ = ropts{accountlistmode_=ALFlat}
|
||||
ropts_ = ropts{balancetype_=HistoricalBalance, accountlistmode_=ALFlat}
|
||||
q = queryFromOpts today ropts_
|
||||
openingdate = fromMaybe today $ queryEndDate False q
|
||||
closingdate = addDays (-1) openingdate
|
||||
(acctbals,_) = balanceReport ropts_ q j
|
||||
(acctbals,_) = singleBalanceReport ropts_ q j
|
||||
balancingamt = negate $ sum $ map (\(_,_,_,b) -> normaliseMixedAmountSquashPricesForDisplay b) acctbals
|
||||
ps = [posting{paccount=a
|
||||
,pamount=mixed [b]
|
||||
|
@ -70,38 +70,24 @@ Y2016
|
||||
|
||||
>>>=0
|
||||
|
||||
# Verify effect of period
|
||||
hledger equity -f- -p 2016 assets liabilities
|
||||
# A begin date should be ignored
|
||||
hledger equity -f- -b2017/6/1 -e2018
|
||||
<<<
|
||||
2015/12/31 open
|
||||
assets:bank $100
|
||||
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
|
||||
2017/1/1
|
||||
(a) 1
|
||||
>>>
|
||||
2016/12/31 closing balances
|
||||
assets:bank $20 = $0
|
||||
assets:cash $-15 = $0
|
||||
2017/12/31 closing balances
|
||||
a -1 = 0
|
||||
equity:closing balances
|
||||
|
||||
2017/01/01 opening balances
|
||||
assets:bank $-20 = $-20
|
||||
assets:cash $15 = $15
|
||||
2018/01/01 opening balances
|
||||
a 1 = 1
|
||||
equity:opening balances
|
||||
|
||||
>>>=0
|
||||
|
||||
|
||||
|
||||
# # Tear transaction across periods
|
||||
# # TODO: clarify what should we see for this case
|
||||
# ../../bin/hledger-equity -f- -p 2016 assets liabilities
|
||||
|
Loading…
Reference in New Issue
Block a user