hledger/hledger/test/balancesheet.test
Stephen Morgan bf3e82f780 imp: pretty: Replace --pretty-tables argument with --pretty=WHEN
argument, which takes yes or no. Default is no for now.
2021-09-21 14:53:52 -10:00

365 lines
22 KiB
Plaintext

# 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 ||
-------------++------------
-------------++------------
||
=============++============
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 ||
-------------++------------
-------------++------------
||
=============++============
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'
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
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
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 ||
-------------++------------
-------------++------------
||
=============++============
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 ||
-------------++------------
-------------++------------
||
=============++============
Net: || 1
# 8. An empty section does not disrupt the overall totals, #588
<
2017/1/1
(assets) $1
$ hledger -f- balancesheet -YA
Balance Sheet 2017-12-31
|| 2017-12-31 Average
=============++=====================
Assets ||
-------------++---------------------
assets || $1 $1
-------------++---------------------
|| $1 $1
=============++=====================
Liabilities ||
-------------++---------------------
-------------++---------------------
||
=============++=====================
Net: || $1 $1
# 9. --pretty=yes uses unicode chars for borders
<
2016/1/1
assets 1
b
$ hledger -f - balancesheet -M --pretty=yes
Balance Sheet 2016-01-31
║ 2016-01-31
═════════════╬════════════
Assets ║
─────────────╫────────────
assets ║ 1
─────────────╫────────────
║ 1
═════════════╬════════════
Liabilities ║
─────────────╫────────────
─────────────╫────────────
═════════════╬════════════
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 ||
-------------------------------------++------------
-------------------------------------++------------
||
=====================================++============
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 ||
-------------++------------
-------------++------------
||
=============++============
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"
"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"
"Net:","$1"
# 14. When declaring account types, we want boring parents to include their
# interesting children, including their historical postings. (#1698)
<
account assets:foobar:reserve ; type: Cash
account assets:foobar:current ; type: Cash
account assets:receivable:anon ; type: Asset
2018-12-06
assets:foobar:current 1 A
expenses:example
2019-01-04
assets:foobar:current 1 A
expenses:example
$ hledger -f - balancesheet --tree --no-elide --begin 2019-01-01
Balance Sheet 2019-01-04
|| 2019-01-04
=============++============
Assets ||
-------------++------------
assets || 2 A
foobar || 2 A
current || 2 A
-------------++------------
|| 2 A
=============++============
Liabilities ||
-------------++------------
-------------++------------
||
=============++============
Net: || 2 A