# * aregister command

<
2021-01-01
  (b)  1

2021-01-02
  a   1
  b  -1

# ** 1. aregister only shows transactions matching the account query, and displays other accounts involved
$ hledger -f- areg a
Transactions in a and subaccounts:
2021-01-02                      b                                1             1

<
2023-01-01
    assets:checking   1
    income:salary    -1

2023-01-02
    assets:checking  -2
    expenses:food     2

# ** 2. aregister ignores a depth limit, always showing transactions in subaccounts. #1448
$ hledger -f- areg checking depth:1
Transactions in assets:checking and subaccounts:
2023-01-01                      in:salary                        1             1
2023-01-02                      ex:food                         -2            -1

#1634:

# ** 3. aregister is always in historical mode, showing balance from prior transactions.
$ hledger -f- areg checking -b 2023-01-02
Transactions in assets:checking and subaccounts:
2023-01-02                      ex:food                         -2            -1

# ** 4. Any additional arguments are a query filtering the transactions. #2007
# This can cause the running balance to diverge from the real-world running balance.
# For non-date/date2/depth queries, a hint is shown in the title.
$ hledger -f- areg checking expenses
Transactions in assets:checking and subaccounts (matching query):
2023-01-02                      ex:food                         -2            -2

# ** 5. Sorts transactions first by transaction date (earliest date of the
# matching postings) then by parse order. (#1642)
# Also, make sure to use the posting date of matching transactions, if it
# differs from the transaction date.
<
~ 2021-01-03  sixth, because forecast transactions come after normal transactions
    (a)           6

2021-01-03 fifth
    (a)           5

2021-01-02 third
    (a)           3

2021-01-02 fourth, because same day is in parse order
    (a)           4

2021-01-01 first
    (a)           1

2021-01-03 second, because of posting date
    (a)           2  ; date:2021-01-01

2021-01-04 seventh, because posting date is not matching
    (a)           7
    (b)           0  ; date:2021-01-01


$ hledger -f- areg a --forecast="2021-01..2021-02"
Transactions in a and subaccounts:
2021-01-01 first                a                                1             1
2021-01-01 second, because o..  a                                2             3
2021-01-02 third                a                                3             6
2021-01-02 fourth, because s..  a                                4            10
2021-01-03 fifth                a                                5            15
2021-01-03 sixth, because fo..  a                                6            21
2021-01-04 seventh, because ..  b                                7            28

<
2021-01-01
  a    1 A
  a   -1 B
  b    1 B
  c   -1 A

2021-01-02
  a    1 C
  b   -1 C

# ** 6. aregister correctly aligns amounts when there are multiple commodities (#1656).
$ hledger -f- areg a
Transactions in a and subaccounts:
2021-01-01                      b, c                           1 A           1 A
                                                              -1 B          -1 B
2021-01-02                      b                              1 C           1 A
                                                                            -1 B
                                                                             1 C

# aregister respects --date2 (#1731).
<
2021-01-01=2021-02-02
  (a)   1

# ** 7. With --date2, it should show the secondary transaction date.
$ hledger -f- areg a --date2
Transactions in a and subaccounts:
2021-02-02                      a                                1             1

# # 8. With --date2, it should match on the secondary transaction date.
# $ hledger -f- areg a --date2 date:202102
# 2021-02-02                      a                                1             1

# # 9. ditto
# $ hledger -f- areg a --date2 date2:202102
# 2021-02-02                      a                                1             1

# # 10. should show the transaction, with the january date (?)
# $ hledger -f- areg a date2:202102
# 2021-01-01                      a                                1             1
