hledger/hledger/test/balancesheet.test
Simon Michael 165e70df7a imp: bs,cf,is: show interval in report title
This makes the report interval clearer, eg when it's set unexpectedly
by a config file.
2024-07-17 08:26:43 +01:00

379 lines
22 KiB
Plaintext

# * balancesheet command
# ** 1. A trivial balance sheet. With no accounts of type Asset declared,
# a top-level "assets" account is autodetected as an Asset.
<
2016/1/1
assets 1
b
$ hledger -f - balancesheet
Balance Sheet 2016-01-01
|| 2016-01-01
=============++============
Assets ||
-------------++------------
assets || 1
-------------++------------
|| 1
=============++============
Liabilities ||
-------------++------------
-------------++------------
|| 0
=============++============
Net: || 1
# ** 2. Account type autodetection is case insensitive.
<
2016/1/1
ASSETS 1
b
$ hledger -f - balancesheet
Balance Sheet 2016-01-01
|| 2016-01-01
=============++============
Assets ||
-------------++------------
ASSETS || 1
-------------++------------
|| 1
=============++============
Liabilities ||
-------------++------------
-------------++------------
|| 0
=============++============
Net: || 1
# ** 3. monthly balance sheet, normal positive sign
# old (arithmetic sign):
#Balance Sheet
#
# || 2008/01/31 2008/02/29 2008/03/31 2008/04/30 2008/05/31 2008/06/30 2008/07/31 2008/08/31 2008/09/30 2008/10/31 2008/11/30 2008/12/31
#======================++================================================================================================================================================
# Assets ||
#----------------------++------------------------------------------------------------------------------------------------------------------------------------------------
# assets:bank:checking || $1 $1 $1 $1 $1 $1 $1 $1 $1 $1 $1 0
# assets:bank:saving || 0 0 0 0 0 $1 $1 $1 $1 $1 $1 $1
# assets:cash || 0 0 0 0 0 $-2 $-2 $-2 $-2 $-2 $-2 $-2
#----------------------++------------------------------------------------------------------------------------------------------------------------------------------------
# || $1 $1 $1 $1 $1 0 0 0 0 0 0 $-1
#======================++================================================================================================================================================
# Liabilities ||
#----------------------++------------------------------------------------------------------------------------------------------------------------------------------------
# liabilities:debts || 0 0 0 0 0 0 0 0 0 0 0 $1
#----------------------++------------------------------------------------------------------------------------------------------------------------------------------------
# || 0 0 0 0 0 0 0 0 0 0 0 $1
#======================++================================================================================================================================================
# Total || $1 $1 $1 $1 $1 0 0 0 0 0 0 0
#
$ hledger -f sample.journal balancesheet -p 'monthly in 2008'
Monthly Balance Sheet 2008-01-31..2008-12-31
|| 2008-01-31 2008-02-29 2008-03-31 2008-04-30 2008-05-31 2008-06-30 2008-07-31 2008-08-31 2008-09-30 2008-10-31 2008-11-30 2008-12-31
======================++================================================================================================================================================
Assets ||
----------------------++------------------------------------------------------------------------------------------------------------------------------------------------
assets:bank:checking || $1 $1 $1 $1 $1 $1 $1 $1 $1 $1 $1 0
assets:bank:saving || 0 0 0 0 0 $1 $1 $1 $1 $1 $1 $1
assets:cash || 0 0 0 0 0 $-2 $-2 $-2 $-2 $-2 $-2 $-2
----------------------++------------------------------------------------------------------------------------------------------------------------------------------------
|| $1 $1 $1 $1 $1 0 0 0 0 0 0 $-1
======================++================================================================================================================================================
Liabilities ||
----------------------++------------------------------------------------------------------------------------------------------------------------------------------------
liabilities:debts || 0 0 0 0 0 0 0 0 0 0 0 $-1
----------------------++------------------------------------------------------------------------------------------------------------------------------------------------
|| 0 0 0 0 0 0 0 0 0 0 0 $-1
======================++================================================================================================================================================
Net: || $1 $1 $1 $1 $1 0 0 0 0 0 0 0
# ** 4. monthly balance sheet in tree mode
# old (arithmetic sign):
# || 2008/01/31 2008/02/29 2008/03/31 2008/04/30 2008/05/31 2008/06/30 2008/07/31 2008/08/31 2008/09/30 2008/10/31 2008/11/30 2008/12/31
#==============++================================================================================================================================================
# Assets ||
#--------------++------------------------------------------------------------------------------------------------------------------------------------------------
# assets || $1 $1 $1 $1 $1 0 0 0 0 0 0 $-1
# bank || $1 $1 $1 $1 $1 $2 $2 $2 $2 $2 $2 $1
# checking || $1 $1 $1 $1 $1 $1 $1 $1 $1 $1 $1 0
# saving || 0 0 0 0 0 $1 $1 $1 $1 $1 $1 $1
# cash || 0 0 0 0 0 $-2 $-2 $-2 $-2 $-2 $-2 $-2
#--------------++------------------------------------------------------------------------------------------------------------------------------------------------
# || $1 $1 $1 $1 $1 0 0 0 0 0 0 $-1
#==============++================================================================================================================================================
# Liabilities ||
#--------------++------------------------------------------------------------------------------------------------------------------------------------------------
# liabilities || 0 0 0 0 0 0 0 0 0 0 0 $1
# debts || 0 0 0 0 0 0 0 0 0 0 0 $1
#--------------++------------------------------------------------------------------------------------------------------------------------------------------------
# || 0 0 0 0 0 0 0 0 0 0 0 $1
#==============++================================================================================================================================================
# Total || $1 $1 $1 $1 $1 0 0 0 0 0 0 0
#
$ hledger -f sample.journal balancesheet -p 'monthly in 2008' --tree
Monthly Balance Sheet 2008-01-31..2008-12-31
|| 2008-01-31 2008-02-29 2008-03-31 2008-04-30 2008-05-31 2008-06-30 2008-07-31 2008-08-31 2008-09-30 2008-10-31 2008-11-30 2008-12-31
===================++================================================================================================================================================
Assets ||
-------------------++------------------------------------------------------------------------------------------------------------------------------------------------
assets || $1 $1 $1 $1 $1 0 0 0 0 0 0 $-1
bank || $1 $1 $1 $1 $1 $2 $2 $2 $2 $2 $2 $1
checking || $1 $1 $1 $1 $1 $1 $1 $1 $1 $1 $1 0
saving || 0 0 0 0 0 $1 $1 $1 $1 $1 $1 $1
cash || 0 0 0 0 0 $-2 $-2 $-2 $-2 $-2 $-2 $-2
-------------------++------------------------------------------------------------------------------------------------------------------------------------------------
|| $1 $1 $1 $1 $1 0 0 0 0 0 0 $-1
===================++================================================================================================================================================
Liabilities ||
-------------------++------------------------------------------------------------------------------------------------------------------------------------------------
liabilities:debts || 0 0 0 0 0 0 0 0 0 0 0 $-1
-------------------++------------------------------------------------------------------------------------------------------------------------------------------------
|| 0 0 0 0 0 0 0 0 0 0 0 $-1
===================++================================================================================================================================================
Net: || $1 $1 $1 $1 $1 0 0 0 0 0 0 0
# ** 5. monthly balancesheet with average column and without overall totals row.
# Total column is requested but not shown because balancesheet is in historical mode
# by default (shows ending balances).
$ hledger -f sample.journal balancesheet -p 'monthly in 2008' -NAT
Monthly Balance Sheet 2008-01-31..2008-12-31
|| 2008-01-31 2008-02-29 2008-03-31 2008-04-30 2008-05-31 2008-06-30 2008-07-31 2008-08-31 2008-09-30 2008-10-31 2008-11-30 2008-12-31 Average
======================++=========================================================================================================================================================
Assets ||
----------------------++---------------------------------------------------------------------------------------------------------------------------------------------------------
assets:bank:checking || $1 $1 $1 $1 $1 $1 $1 $1 $1 $1 $1 0 $1
assets:bank:saving || 0 0 0 0 0 $1 $1 $1 $1 $1 $1 $1 $1
assets:cash || 0 0 0 0 0 $-2 $-2 $-2 $-2 $-2 $-2 $-2 $-1
======================++=========================================================================================================================================================
Liabilities ||
----------------------++---------------------------------------------------------------------------------------------------------------------------------------------------------
liabilities:debts || 0 0 0 0 0 0 0 0 0 0 0 $-1 0
# ** 6. Tree output still works, #565
<
2017/1/1
(assets:b) 1
$ hledger -f- balancesheet
Balance Sheet 2017-01-01
|| 2017-01-01
=============++============
Assets ||
-------------++------------
assets:b || 1
-------------++------------
|| 1
=============++============
Liabilities ||
-------------++------------
-------------++------------
|| 0
=============++============
Net: || 1
# ** 7. Flat output still works, #552
<
2017/1/1
(assets:b) 1
$ hledger -f- balancesheet --flat
Balance Sheet 2017-01-01
|| 2017-01-01
=============++============
Assets ||
-------------++------------
assets:b || 1
-------------++------------
|| 1
=============++============
Liabilities ||
-------------++------------
-------------++------------
|| 0
=============++============
Net: || 1
# ** 8. An empty section does not disrupt the overall totals, #588
<
2017/1/1
(assets) $1
$ hledger -f- balancesheet -YA
Yearly Balance Sheet 2017-12-31
|| 2017-12-31 Average
=============++=====================
Assets ||
-------------++---------------------
assets || $1 $1
-------------++---------------------
|| $1 $1
=============++=====================
Liabilities ||
-------------++---------------------
-------------++---------------------
|| 0 0
=============++=====================
Net: || $1 $1
# ** 9. With --pretty, tables use box-drawing characters and more borders.
<
2016/1/1
assets 1
b
$ hledger -f - balancesheet -M --pretty
Monthly Balance Sheet 2016-01-31
┌─────────────╥────────────┐
│ ║ 2016-01-31 │
╞═════════════╬════════════╡
│ Assets ║ │
├─────────────╫────────────┤
│ assets ║ 1 │
├─────────────╫────────────┤
│ ║ 1 │
╞═════════════╬════════════╡
│ Liabilities ║ │
├─────────────╫────────────┤
├─────────────╫────────────┤
│ ║ 0 │
╞═════════════╬════════════╡
│ Net: ║ 1 │
└─────────────╨────────────┘
# ** 10. Check that accounts brought to zero by subaccount balances
# are not erased from balancesheet
<
2018-10-01
income:whatever
assets:bank $100
assets:bank:subaccount $10
assets:bank:this subaccount should disappear $10
2018-10-02
assets:bank:this subaccount should disappear -$10
assets:bank
2018-10-03
assets:this account should not disappear:subaccount -$10
assets:this account should not disappear
$ hledger -f - balancesheet --tree
Balance Sheet 2018-10-03
|| 2018-10-03
=====================================++============
Assets ||
-------------------------------------++------------
assets || $120
bank || $120
subaccount || $10
this account should not disappear || 0
subaccount || $-10
-------------------------------------++------------
|| $120
=====================================++============
Liabilities ||
-------------------------------------++------------
-------------------------------------++------------
|| 0
=====================================++============
Net: || $120
# ** 11. Check that starting balances are also filtered by subreport query. (See issue #1335)
<
2020-03-01 * Rent
assets:a -$1
expenses
2020-03-25 * Salary
assets:a $2
income
$ hledger -f - balancesheet --begin 2020-03-02
Balance Sheet 2020-03-25
|| 2020-03-25
=============++============
Assets ||
-------------++------------
assets:a || $1
-------------++------------
|| $1
=============++============
Liabilities ||
-------------++------------
-------------++------------
|| 0
=============++============
Net: || $1
# ** 12. CSV output. It always shows full account names, even in tree mode (#1566).
$ hledger -f - balancesheet --tree --output-format=csv
"Balance Sheet 2020-03-25",""
"Account","2020-03-25"
"Assets",""
"assets:a","$1"
"Total:","$1"
"Liabilities",""
"Total:","0"
"Net:","$1"
# ** 13. CSV output supports --drop.
$ hledger -f - balancesheet --tree --output-format=csv --drop 1
"Balance Sheet 2020-03-25",""
"Account","2020-03-25"
"Assets",""
"a","$1"
"Total:","$1"
"Liabilities",""
"Total:","0"
"Net:","$1"
<
2020-03-01 * Rent
assets:a -$10 000.00
expenses
# ** 14. CSV output drops thousands separators
$ hledger -f - balancesheet --output-format=csv
"Balance Sheet 2020-03-01",""
"Account","2020-03-01"
"Assets",""
"assets:a","$-10000.00"
"Total:","$-10000.00"
"Liabilities",""
"Total:","0"
"Net:","$-10000.00"
# ** 15. In compound reports like balancesheet, parent accounts might not have
# the appropriate type for a subreport, but in tree reports they should be
# displayed anyway, and with the right inclusive amounts and starting
# balances. (#1698)
<
account assets:cash ; type: Cash
account assets:checking ; type: Asset
; ^ disables auto-detection of Asset type, "assets" will not be considered an Asset
2019-12-01
(assets:cash) 3
2020-01-01
(assets:cash) 2
$ hledger -f - bs -N -t --no-elide -b 2020
Balance Sheet 2020-01-01
|| 2020-01-01
=============++============
Assets ||
-------------++------------
assets || 5
cash || 5
=============++============
Liabilities ||
-------------++------------