hledger/tests/balance/balance.test
Simon Michael 3de8c11de1 journal: a new account sorting mechanism, and a bunch of sorting fixes
A bunch of account sorting changes that got intermingled.

First, account codes have been dropped. They can still be parsed and
will be ignored, for now. I don't know if anyone used them.
Instead, account display order is now controlled by the order of account
directives, if any. From the mail list:

  I'd like to drop account codes, introduced in hledger 1.9 to control
  the display order of accounts. In my experience,

  - they are tedious to maintain
  - they duplicate/compete with the natural tendency to arrange account
    directives to match your mental chart of accounts
  - they duplicate/compete with the tree structure created by account
    names

  and it gets worse if you think about using them more extensively,
  eg to classify accounts by type.

  Instead, I plan to just let the position (parse order) of account
  directives determine the display order of those declared accounts.
  Undeclared accounts will be displayed after declared accounts,
  sorted alphabetically as usual.

Second, the various account sorting modes have been implemented more
widely and more correctly. All sorting modes (alphabetically, by account
declaration, by amount) should now work correctly in almost all commands
and modes (non-tabular and tabular balance reports, tree and flat modes,
the accounts command). Sorting bugs have been fixed, eg #875.
Only the budget report (balance --budget) does not yet support sorting.

Comprehensive functional tests for sorting in the accounts and balance
commands have been added. If you are confused by some sorting behaviour,
studying these tests is recommended, as sorting gets tricky.
2018-09-22 21:45:07 -10:00

152 lines
3.7 KiB
Plaintext

# 1.
hledger -f sample.journal balance
>>>
$-1 assets
$1 bank:saving
$-2 cash
$2 expenses
$1 food
$1 supplies
$-2 income
$-1 gifts
$-1 salary
$1 liabilities:debts
--------------------
0
>>>=0
# 2.
hledger -f sample.journal balance o
>>>
$1 expenses:food
$-2 income
$-1 gifts
$-1 salary
--------------------
$-1
>>>=0
# 3. Period reporting works for a specific year
hledger -f - balance -b 2016 -e 2017
<<<
2015/10/10 Client A | Invoice #1
assets:receivables $10,000.00
revenue:clients:A -$10,000.00
2015/11/02 Deposit | Invoice #1
assets:checking $10,000.00
assets:receivables -$10,000.00
2016/02/01 Client B | Invoice #2
assets:receivables $10.00
revenue:clients:B -$10.00
2016/02/15 ACME | Hosting Costs
expense:hosting $50.00
assets:checking -$50.00
2016/03/01 Deposit | Invoice #2
assets:checking $10.00
assets:receivables -$10.00
>>>
$-40.00 assets:checking
$50.00 expense:hosting
$-10.00 revenue:clients:B
--------------------
0
>>>2
>>>= 0
# 4. Period reporting works for two years
hledger -f - balance -b 2015 -e 2017
<<<
2015/10/10 Client A | Invoice #1
assets:receivables $10,000.00
revenue:clients:A -$10,000.00
2015/11/02 Deposit | Invoice #1
assets:checking $10,000.00
assets:receivables -$10,000.00
2016/02/01 Client B | Invoice #2
assets:receivables $10.00
revenue:clients:B -$10.00
2016/02/15 ACME | Hosting Costs
expense:hosting $50.00
assets:checking -$50.00
2016/03/01 Deposit | Invoice #2
assets:checking $10.00
assets:receivables -$10.00
>>>
$9,960.00 assets:checking
$50.00 expense:hosting
$-10,010.00 revenue:clients
$-10,000.00 A
$-10.00 B
--------------------
0
>>>2
>>>= 0
# 5. Period reporting works for one month
hledger -f - balance -b 2015/11 -e 2015/12
<<<
2015/10/10 Client A | Invoice #1
assets:receivables $10,000.00
revenue:clients:A -$10,000.00
2015/11/02 Deposit | Invoice #1
assets:checking $10,000.00
assets:receivables -$10,000.00
2016/02/01 Client B | Invoice #2
assets:receivables $10.00
revenue:clients:B -$10.00
2016/02/15 ACME | Hosting Costs
expense:hosting $50.00
assets:checking -$50.00
2016/03/01 Deposit | Invoice #2
assets:checking $10.00
assets:receivables -$10.00
>>>
0 assets
$10,000.00 checking
$-10,000.00 receivables
--------------------
0
>>>2
>>>= 0
# 6. Period reporting works for one month in another year
hledger -f - balance -b 2016/10 -e 2016/11
<<<
2015/10/10 Client A | Invoice #1
assets:receivables $10,000.00
revenue:clients:A -$10,000.00
2015/11/02 Deposit | Invoice #1
assets:checking $10,000.00
assets:receivables -$10,000.00
2016/02/01 Client B | Invoice #2
assets:receivables $10.00
revenue:clients:B -$10.00
2016/02/15 ACME | Hosting Costs
expense:hosting $50.00
assets:checking -$50.00
2016/03/01 Deposit | Invoice #2
assets:checking $10.00
assets:receivables -$10.00
>>>
--------------------
0
>>>2
>>>= 0