diff --git a/hledger/Hledger/Cli/Commands/Aregister.hs b/hledger/Hledger/Cli/Commands/Aregister.hs index 0a880a9c6..3cfe264b9 100644 --- a/hledger/Hledger/Cli/Commands/Aregister.hs +++ b/hledger/Hledger/Cli/Commands/Aregister.hs @@ -83,16 +83,16 @@ aregister opts@CliOpts{rawopts_=rawopts,reportspec_=rspec} j = do -- gather report options inclusive = True -- tree_ ropts thisacctq = Acct $ (if inclusive then accountNameToAccountRegex else accountNameToAccountOnlyRegex) acct - rspec' = rspec{ rsQuery=simplifyQuery $ And [queryFromFlags ropts, argsquery] - , rsOpts=ropts' - } - ropts' = ropts - { -- remove a depth limit for reportq, as in RegisterScreen, I forget why XXX + ropts' = (rsOpts rspec) { + -- ignore any depth limit, as in postingsReport; allows register's total to match balance reports (cf #1468) depth_=Nothing -- always show historical balance , balancetype_= HistoricalBalance } - ropts = rsOpts rspec + -- and regenerate the ReportSpec, making sure to use the above + rspec' = rspec{ rsQuery=simplifyQuery $ And [queryFromFlags ropts', argsquery] + , rsOpts=ropts' + } reportq = And [rsQuery rspec', excludeforecastq (isJust $ forecast_ ropts')] where -- As in RegisterScreen, why ? XXX @@ -106,7 +106,7 @@ aregister opts@CliOpts{rawopts_=rawopts,reportspec_=rspec} j = do -- run the report -- TODO: need to also pass the queries so we can choose which date to render - move them into the report ? items = accountTransactionsReport rspec' j reportq thisacctq - items' = (if empty_ ropts then id else filter (not . mixedAmountLooksZero . fifth6)) $ + items' = (if empty_ ropts' then id else filter (not . mixedAmountLooksZero . fifth6)) $ reverse items -- select renderer render | fmt=="txt" = accountTransactionsReportAsText opts reportq thisacctq diff --git a/hledger/test/aregister.test b/hledger/test/aregister.test index aa63f240f..8d817d900 100644 --- a/hledger/test/aregister.test +++ b/hledger/test/aregister.test @@ -1,16 +1,16 @@ # aregister always includes transactions in subaccounts, ignoring a depth limit #1448 -#< -#2021-01-01 -# (a) 1 -# -#2021-01-02 -# (a:aa) 10 -# -#2021-01-03 -# (a:aa:aaa) 100 -# -#$ hledger -f- areg a -1 -w80 -#Transactions in a and subaccounts: -#2021-01-01 a 1 1 -#2021-01-02 a:aa 10 11 -#2021-01-03 a:aa:aaa 100 111 +< +2021-01-01 + (a) 1 + +2021-01-02 + (a:aa) 10 + +2021-01-03 + (a:aa:aaa) 100 + +$ hledger -f- areg a -1 -w80 +Transactions in a and subaccounts: +2021-01-01 a 1 1 +2021-01-02 a:aa 10 11 +2021-01-03 a:aa:aaa 100 111