lib: Elide boring parents in tree mode even when using --empty.
This commit is contained in:
		
							parent
							
								
									05e33965d6
								
							
						
					
					
						commit
						32e184f9a8
					
				| @ -426,7 +426,7 @@ displayedAccounts ropts q valuedaccts | |||||||
|     | otherwise  = HM.mapWithKey (\a _ -> displayedName a) displayedAccts |     | otherwise  = HM.mapWithKey (\a _ -> displayedName a) displayedAccts | ||||||
|   where |   where | ||||||
|     -- Accounts which are to be displayed |     -- Accounts which are to be displayed | ||||||
|     displayedAccts = HM.filterWithKey keep valuedaccts |     displayedAccts = (if depth == 0 then id else HM.filterWithKey keep) valuedaccts | ||||||
|       where |       where | ||||||
|         keep name amts = isInteresting name amts || name `HM.member` interestingParents |         keep name amts = isInteresting name amts || name `HM.member` interestingParents | ||||||
| 
 | 
 | ||||||
| @ -446,23 +446,24 @@ displayedAccounts ropts q valuedaccts | |||||||
|     -- Accounts interesting for their own sake |     -- Accounts interesting for their own sake | ||||||
|     isInteresting name amts = |     isInteresting name amts = | ||||||
|         d <= depth                                     -- Throw out anything too deep |         d <= depth                                     -- Throw out anything too deep | ||||||
|         && (empty_ ropts || depth == 0 || not (isZeroRow balance amts))  -- Boring because has only zero entries |         && ((empty_ ropts && all (null . asubs) amts)  -- Keep all leaves when using empty_ | ||||||
|  |            || not (isZeroRow balance amts))            -- Throw out anything with zero balance | ||||||
|       where |       where | ||||||
|         d = accountNameLevel name |         d = accountNameLevel name | ||||||
|         balance | ALTree <- accountlistmode_ ropts, d == depth = aibalance |         balance | ALTree <- accountlistmode_ ropts, d == depth = aibalance | ||||||
|                 | otherwise = aebalance |                 | otherwise = aebalance | ||||||
| 
 | 
 | ||||||
|     -- Accounts interesting because they are a fork for interesting subaccounts |     -- Accounts interesting because they are a fork for interesting subaccounts | ||||||
|     interestingParents = dbg'' "interestingParents" $ HM.filterWithKey keepParent tallies |     interestingParents = dbg'' "interestingParents" $ case accountlistmode_ ropts of | ||||||
|  |         ALTree -> HM.filterWithKey hasEnoughSubs numSubs | ||||||
|  |         ALFlat -> mempty | ||||||
|       where |       where | ||||||
|         keepParent name subaccts |         hasEnoughSubs name nsubs = nsubs >= minSubs && accountNameLevel name > drop_ ropts | ||||||
|             | ALFlat <- accountlistmode_ ropts = False |         minSubs = if no_elide_ ropts then 1 else 2 | ||||||
|             | no_elide_ ropts = subaccts > 0 && accountNameLevel name > drop_ ropts |  | ||||||
|             | otherwise       = subaccts > 1 && accountNameLevel name > drop_ ropts |  | ||||||
|         tallies = subaccountTallies . HM.keys $ HM.filterWithKey isInteresting valuedaccts |  | ||||||
| 
 | 
 | ||||||
|     isZeroRow balance = all (mixedAmountLooksZero . balance) |     isZeroRow balance = all (mixedAmountLooksZero . balance) | ||||||
|     depth = fromMaybe maxBound $ queryDepth q |     depth = fromMaybe maxBound $ queryDepth q | ||||||
|  |     numSubs = subaccountTallies . HM.keys $ HM.filterWithKey isInteresting valuedaccts | ||||||
| 
 | 
 | ||||||
| -- | Sort the rows by amount or by account declaration order. | -- | Sort the rows by amount or by account declaration order. | ||||||
| sortRows :: ReportOpts -> Journal -> [MultiBalanceReportRow] -> [MultiBalanceReportRow] | sortRows :: ReportOpts -> Journal -> [MultiBalanceReportRow] -> [MultiBalanceReportRow] | ||||||
| @ -560,9 +561,8 @@ sortRowsLike sortedas rows = mapMaybe (`HM.lookup` rowMap) sortedas | |||||||
| -- | Given a list of account names, find all forking parent accounts, i.e. | -- | Given a list of account names, find all forking parent accounts, i.e. | ||||||
| -- those which fork between different branches | -- those which fork between different branches | ||||||
| subaccountTallies :: [AccountName] -> HashMap AccountName Int | subaccountTallies :: [AccountName] -> HashMap AccountName Int | ||||||
| subaccountTallies as = foldr incrementParent mempty allaccts | subaccountTallies = foldr incrementParent mempty . expandAccountNames | ||||||
|   where |   where | ||||||
|     allaccts = expandAccountNames as |  | ||||||
|     incrementParent a = HM.insertWith (+) (parentAccountName a) 1 |     incrementParent a = HM.insertWith (+) (parentAccountName a) 1 | ||||||
| 
 | 
 | ||||||
| -- | A helper: what percentage is the second mixed amount of the first ? | -- | A helper: what percentage is the second mixed amount of the first ? | ||||||
|  | |||||||
| @ -40,7 +40,6 @@ Budget performance in 2016-12-01..2016-12-03: | |||||||
| 
 | 
 | ||||||
|                   ||           2016-12-01            2016-12-02            2016-12-03                 Total  |                   ||           2016-12-01            2016-12-02            2016-12-03                 Total  | ||||||
| ==================++======================================================================================== | ==================++======================================================================================== | ||||||
|  assets           || $-10 [  40% of $-25]  $-14 [  56% of $-25]  $-51 [ 204% of $-25]  $-75 [ 100% of $-75]  |  | ||||||
|  assets:cash      || $-10 [  40% of $-25]  $-14 [  56% of $-25]  $-51 [ 204% of $-25]  $-75 [ 100% of $-75]  |  assets:cash      || $-10 [  40% of $-25]  $-14 [  56% of $-25]  $-51 [ 204% of $-25]  $-75 [ 100% of $-75]  | ||||||
|  expenses         ||  $10 [  40% of  $25]   $14 [  56% of  $25]   $51 [ 204% of  $25]   $75 [ 100% of  $75]  |  expenses         ||  $10 [  40% of  $25]   $14 [  56% of  $25]   $51 [ 204% of  $25]   $75 [ 100% of  $75]  | ||||||
|  expenses:food    ||  $10 [ 100% of  $10]    $9 [  90% of  $10]   $11 [ 110% of  $10]   $30 [ 100% of  $30]  |  expenses:food    ||  $10 [ 100% of  $10]    $9 [  90% of  $10]   $11 [ 110% of  $10]   $30 [ 100% of  $30]  | ||||||
| @ -89,7 +88,6 @@ Budget performance in 2016-12-01..2016-12-03: | |||||||
|  expenses         ||  $10 [  40% of  $25]   $14 [  56% of  $25]   $51 [ 204% of  $25]   $75 [ 100% of  $75]  |  expenses         ||  $10 [  40% of  $25]   $14 [  56% of  $25]   $51 [ 204% of  $25]   $75 [ 100% of  $75]  | ||||||
|  expenses:leisure ||    0 [   0% of  $15]    $5 [  33% of  $15]     0 [   0% of  $15]    $5 [  11% of  $45]  |  expenses:leisure ||    0 [   0% of  $15]    $5 [  33% of  $15]     0 [   0% of  $15]    $5 [  11% of  $45]  | ||||||
|  expenses:food    ||  $10 [ 100% of  $10]    $9 [  90% of  $10]   $11 [ 110% of  $10]   $30 [ 100% of  $30]  |  expenses:food    ||  $10 [ 100% of  $10]    $9 [  90% of  $10]   $11 [ 110% of  $10]   $30 [ 100% of  $30]  | ||||||
|  assets           || $-10 [  40% of $-25]  $-14 [  56% of $-25]  $-51 [ 204% of $-25]  $-75 [ 100% of $-75]  |  | ||||||
|  assets:cash      || $-10 [  40% of $-25]  $-14 [  56% of $-25]  $-51 [ 204% of $-25]  $-75 [ 100% of $-75]  |  assets:cash      || $-10 [  40% of $-25]  $-14 [  56% of $-25]  $-51 [ 204% of $-25]  $-75 [ 100% of $-75]  | ||||||
| 
 | 
 | ||||||
| # # 2. -E | # # 2. -E | ||||||
| @ -163,7 +161,6 @@ Budget performance in 2016-12-01..2016-12-03: | |||||||
|  expenses         ||  $10 [  40% of  $25]   $14 [  56% of  $25]   $51 [ 204% of  $25]   $75 [ 100% of  $75]  |  expenses         ||  $10 [  40% of  $25]   $14 [  56% of  $25]   $51 [ 204% of  $25]   $75 [ 100% of  $75]  | ||||||
|  expenses:food    ||  $10 [ 100% of  $10]    $9 [  90% of  $10]   $11 [ 110% of  $10]   $30 [ 100% of  $30]  |  expenses:food    ||  $10 [ 100% of  $10]    $9 [  90% of  $10]   $11 [ 110% of  $10]   $30 [ 100% of  $30]  | ||||||
|  expenses:leisure ||    0 [   0% of  $15]    $5 [  33% of  $15]     0 [   0% of  $15]    $5 [  11% of  $45]  |  expenses:leisure ||    0 [   0% of  $15]    $5 [  33% of  $15]     0 [   0% of  $15]    $5 [  11% of  $45]  | ||||||
|  assets           || $-10 [  40% of $-25]  $-14 [  56% of $-25]  $-51 [ 204% of $-25]  $-75 [ 100% of $-75]  |  | ||||||
|  assets:cash      || $-10 [  40% of $-25]  $-14 [  56% of $-25]  $-51 [ 204% of $-25]  $-75 [ 100% of $-75]  |  assets:cash      || $-10 [  40% of $-25]  $-14 [  56% of $-25]  $-51 [ 204% of $-25]  $-75 [ 100% of $-75]  | ||||||
| 
 | 
 | ||||||
| #** Sort by actual amount, tree mode. | #** Sort by actual amount, tree mode. | ||||||
| @ -172,12 +169,11 @@ $ hledger -f- bal --budget -DTNS --tree | |||||||
| Budget performance in 2016-12-01..2016-12-03: | Budget performance in 2016-12-01..2016-12-03: | ||||||
| 
 | 
 | ||||||
|              ||           2016-12-01            2016-12-02            2016-12-03                 Total  |              ||           2016-12-01            2016-12-02            2016-12-03                 Total  | ||||||
| ===========++======================================================================================== | =============++======================================================================================== | ||||||
|  expenses    ||  $10 [  40% of  $25]   $14 [  56% of  $25]   $51 [ 204% of  $25]   $75 [ 100% of  $75]  |  expenses    ||  $10 [  40% of  $25]   $14 [  56% of  $25]   $51 [ 204% of  $25]   $75 [ 100% of  $75]  | ||||||
|    food      ||  $10 [ 100% of  $10]    $9 [  90% of  $10]   $11 [ 110% of  $10]   $30 [ 100% of  $30]  |    food      ||  $10 [ 100% of  $10]    $9 [  90% of  $10]   $11 [ 110% of  $10]   $30 [ 100% of  $30]  | ||||||
|    leisure   ||    0 [   0% of  $15]    $5 [  33% of  $15]     0 [   0% of  $15]    $5 [  11% of  $45]  |    leisure   ||    0 [   0% of  $15]    $5 [  33% of  $15]     0 [   0% of  $15]    $5 [  11% of  $45]  | ||||||
|  assets    || $-10 [  40% of $-25]  $-14 [  56% of $-25]  $-51 [ 204% of $-25]  $-75 [ 100% of $-75]  |  assets:cash || $-10 [  40% of $-25]  $-14 [  56% of $-25]  $-51 [ 204% of $-25]  $-75 [ 100% of $-75]  | ||||||
|    cash    || $-10 [  40% of $-25]  $-14 [  56% of $-25]  $-51 [ 204% of $-25]  $-75 [ 100% of $-75]  |  | ||||||
| 
 | 
 | ||||||
| #** other ? | #** other ? | ||||||
| # with -E | # with -E | ||||||
|  | |||||||
| @ -36,7 +36,6 @@ Budget performance in 2016-12-01..2016-12-03: | |||||||
| 
 | 
 | ||||||
|                   ||           2016-12-01            2016-12-02            2016-12-03  |                   ||           2016-12-01            2016-12-02            2016-12-03  | ||||||
| ==================++================================================================== | ==================++================================================================== | ||||||
|  assets           || $-10 [  40% of $-25]  $-14 [  56% of $-25]  $-51 [ 204% of $-25]  |  | ||||||
|  assets:cash      || $-10 [  40% of $-25]  $-14 [  56% of $-25]  $-51 [ 204% of $-25]  |  assets:cash      || $-10 [  40% of $-25]  $-14 [  56% of $-25]  $-51 [ 204% of $-25]  | ||||||
|  expenses         ||  $10 [  40% of  $25]   $14 [  56% of  $25]   $51 [ 204% of  $25]  |  expenses         ||  $10 [  40% of  $25]   $14 [  56% of  $25]   $51 [ 204% of  $25]  | ||||||
|  expenses:food    ||  $10 [ 100% of  $10]    $9 [  90% of  $10]   $11 [ 110% of  $10]  |  expenses:food    ||  $10 [ 100% of  $10]    $9 [  90% of  $10]   $11 [ 110% of  $10]  | ||||||
| @ -50,7 +49,6 @@ Budget performance in 2016-12-01..2016-12-03: | |||||||
| 
 | 
 | ||||||
|                   ||           2016-12-01            2016-12-02            2016-12-03  |                   ||           2016-12-01            2016-12-02            2016-12-03  | ||||||
| ==================++================================================================== | ==================++================================================================== | ||||||
|  assets           || $-10 [  40% of $-25]  $-14 [  56% of $-25]  $-51 [ 204% of $-25]  |  | ||||||
|  assets:cash      || $-10 [  40% of $-25]  $-14 [  56% of $-25]  $-51 [ 204% of $-25]  |  assets:cash      || $-10 [  40% of $-25]  $-14 [  56% of $-25]  $-51 [ 204% of $-25]  | ||||||
|  expenses         ||  $10 [  40% of  $25]   $14 [  56% of  $25]   $51 [ 204% of  $25]  |  expenses         ||  $10 [  40% of  $25]   $14 [  56% of  $25]   $51 [ 204% of  $25]  | ||||||
|  expenses:cab     ||    0                     0                   $15                  |  expenses:cab     ||    0                     0                   $15                  | ||||||
| @ -100,7 +98,6 @@ Budget performance in 2016-12-01..2016-12-03: | |||||||
| 
 | 
 | ||||||
|                   ||                 2016-12-01                    2016-12-02                  2016-12-03  |                   ||                 2016-12-01                    2016-12-02                  2016-12-03  | ||||||
| ==================++====================================================================================== | ==================++====================================================================================== | ||||||
|  assets           ||       $-15 [  60% of $-25]          $-26 [ 104% of $-25]        $-51 [ 204% of $-25]  |  | ||||||
|  assets:cash      ||       $-15 [  60% of $-25]          $-26 [ 104% of $-25]        $-51 [ 204% of $-25]  |  assets:cash      ||       $-15 [  60% of $-25]          $-26 [ 104% of $-25]        $-51 [ 204% of $-25]  | ||||||
|  expenses         ||        £10 [          $25]    $5, 20 CAD [          $25]         $51 [ 204% of  $25]  |  expenses         ||        £10 [          $25]    $5, 20 CAD [          $25]         $51 [ 204% of  $25]  | ||||||
|  expenses:food    ||        £10 [          $10]        20 CAD [          $10]         $11 [ 110% of  $10]  |  expenses:food    ||        £10 [          $10]        20 CAD [          $10]         $11 [ 110% of  $10]  | ||||||
| @ -300,7 +297,6 @@ Budget performance in 2018-01-01: | |||||||
|        ||       2018-01-01  |        ||       2018-01-01  | ||||||
| =======++================== | =======++================== | ||||||
|  a     || 2 [   2% of 101]  |  a     || 2 [   2% of 101]  | ||||||
|  a:b   || 1 [ 100% of   1]  |  | ||||||
|  a:b:c || 1 [ 100% of   1]  |  a:b:c || 1 [ 100% of   1]  | ||||||
| -------++------------------ | -------++------------------ | ||||||
|        || 2 [   2% of 101]  |        || 2 [   2% of 101]  | ||||||
| @ -312,8 +308,7 @@ Budget performance in 2018-01-01: | |||||||
|        ||       2018-01-01  |        ||       2018-01-01  | ||||||
| =======++================== | =======++================== | ||||||
|  a     || 2 [   2% of 101]  |  a     || 2 [   2% of 101]  | ||||||
|    b   || 1 [ 100% of   1]  |    b:c || 1 [ 100% of   1]  | ||||||
|      c || 1 [ 100% of   1]  |  | ||||||
| -------++------------------ | -------++------------------ | ||||||
|        || 2 [   2% of 101]  |        || 2 [   2% of 101]  | ||||||
| 
 | 
 | ||||||
| @ -372,7 +367,6 @@ Budget performance in 2019-01-01..2019-01-03: | |||||||
| 
 | 
 | ||||||
|                    ||       2019-01-01..2019-01-03  |                    ||       2019-01-01..2019-01-03  | ||||||
| ===================++============================== | ===================++============================== | ||||||
|  expenses          ||  $50.00 [   5% of $1,000.00]  |  | ||||||
|  expenses:personal ||  $50.00 [   5% of $1,000.00]  |  expenses:personal ||  $50.00 [   5% of $1,000.00]  | ||||||
|  liabilities       || $-50.00 [   5% of $-1000.00]  |  liabilities       || $-50.00 [   5% of $-1000.00]  | ||||||
| -------------------++------------------------------ | -------------------++------------------------------ | ||||||
| @ -384,7 +378,6 @@ Budget performance in 2019-01-01..2019-01-03: | |||||||
| 
 | 
 | ||||||
|                                         ||       2019-01-01..2019-01-03  |                                         ||       2019-01-01..2019-01-03  | ||||||
| ========================================++============================== | ========================================++============================== | ||||||
|  expenses                               ||  $50.00 [   5% of $1,000.00]  |  | ||||||
|  expenses:personal                      ||  $50.00 [   5% of $1,000.00]  |  expenses:personal                      ||  $50.00 [   5% of $1,000.00]  | ||||||
|  expenses:personal:electronics          ||  $20.00                       |  expenses:personal:electronics          ||  $20.00                       | ||||||
|  expenses:personal:electronics:upgrades ||  $10.00                       |  expenses:personal:electronics:upgrades ||  $10.00                       | ||||||
| @ -397,11 +390,10 @@ $ hledger -f- bal --budget --tree | |||||||
| Budget performance in 2019-01-01..2019-01-03: | Budget performance in 2019-01-01..2019-01-03: | ||||||
| 
 | 
 | ||||||
|                    ||       2019-01-01..2019-01-03  |                    ||       2019-01-01..2019-01-03  | ||||||
| =============++============================== | ===================++============================== | ||||||
|  expenses    ||  $50.00 [   5% of $1,000.00]  |  expenses:personal ||  $50.00 [   5% of $1,000.00]  | ||||||
|    personal  ||  $50.00 [   5% of $1,000.00]  |  | ||||||
|  liabilities       || $-50.00 [   5% of $-1000.00]  |  liabilities       || $-50.00 [   5% of $-1000.00]  | ||||||
| -------------++------------------------------ | -------------------++------------------------------ | ||||||
|                    ||       0 [                 0]  |                    ||       0 [                 0]  | ||||||
| 
 | 
 | ||||||
| # 19. | # 19. | ||||||
| @ -409,13 +401,12 @@ $ hledger -f- bal --budget --tree -E | |||||||
| Budget performance in 2019-01-01..2019-01-03: | Budget performance in 2019-01-01..2019-01-03: | ||||||
| 
 | 
 | ||||||
|                    ||       2019-01-01..2019-01-03  |                    ||       2019-01-01..2019-01-03  | ||||||
| =================++============================== | ===================++============================== | ||||||
|  expenses        ||  $50.00 [   5% of $1,000.00]  |  expenses:personal ||  $50.00 [   5% of $1,000.00]  | ||||||
|    personal      ||  $50.00 [   5% of $1,000.00]  |  | ||||||
|    electronics     ||  $20.00                       |    electronics     ||  $20.00                       | ||||||
|      upgrades      ||  $10.00                       |      upgrades      ||  $10.00                       | ||||||
|  liabilities       || $-50.00 [   5% of $-1000.00]  |  liabilities       || $-50.00 [   5% of $-1000.00]  | ||||||
| -----------------++------------------------------ | -------------------++------------------------------ | ||||||
|                    ||       0 [                 0]  |                    ||       0 [                 0]  | ||||||
| 
 | 
 | ||||||
| # 20. Subaccounts + nested budgets | # 20. Subaccounts + nested budgets | ||||||
| @ -442,7 +433,6 @@ Budget performance in 2019-01-01..2019-01-03: | |||||||
| 
 | 
 | ||||||
|                                ||       2019-01-01..2019-01-03  |                                ||       2019-01-01..2019-01-03  | ||||||
| ===============================++============================== | ===============================++============================== | ||||||
|  expenses                      ||  $50.00 [   5% of  $1100.00]  |  | ||||||
|  expenses:personal             ||  $50.00 [   5% of  $1100.00]  |  expenses:personal             ||  $50.00 [   5% of  $1100.00]  | ||||||
|  expenses:personal:electronics ||  $20.00 [  20% of   $100.00]  |  expenses:personal:electronics ||  $20.00 [  20% of   $100.00]  | ||||||
|  liabilities                   || $-50.00 [   5% of $-1100.00]  |  liabilities                   || $-50.00 [   5% of $-1100.00]  | ||||||
| @ -455,7 +445,6 @@ Budget performance in 2019-01-01..2019-01-03: | |||||||
| 
 | 
 | ||||||
|                                         ||       2019-01-01..2019-01-03  |                                         ||       2019-01-01..2019-01-03  | ||||||
| ========================================++============================== | ========================================++============================== | ||||||
|  expenses                               ||  $50.00 [   5% of  $1100.00]  |  | ||||||
|  expenses:personal                      ||  $50.00 [   5% of  $1100.00]  |  expenses:personal                      ||  $50.00 [   5% of  $1100.00]  | ||||||
|  expenses:personal:electronics          ||  $20.00 [  20% of   $100.00]  |  expenses:personal:electronics          ||  $20.00 [  20% of   $100.00]  | ||||||
|  expenses:personal:electronics:upgrades ||  $10.00                       |  expenses:personal:electronics:upgrades ||  $10.00                       | ||||||
| @ -468,12 +457,11 @@ $ hledger -f- bal --budget --tree | |||||||
| Budget performance in 2019-01-01..2019-01-03: | Budget performance in 2019-01-01..2019-01-03: | ||||||
| 
 | 
 | ||||||
|                    ||       2019-01-01..2019-01-03  |                    ||       2019-01-01..2019-01-03  | ||||||
| =================++============================== | ===================++============================== | ||||||
|  expenses        ||  $50.00 [   5% of  $1100.00]  |  expenses:personal ||  $50.00 [   5% of  $1100.00]  | ||||||
|    personal      ||  $50.00 [   5% of  $1100.00]  |  | ||||||
|    electronics     ||  $20.00 [  20% of   $100.00]  |    electronics     ||  $20.00 [  20% of   $100.00]  | ||||||
|  liabilities       || $-50.00 [   5% of $-1100.00]  |  liabilities       || $-50.00 [   5% of $-1100.00]  | ||||||
| -----------------++------------------------------ | -------------------++------------------------------ | ||||||
|                    ||       0 [                 0]  |                    ||       0 [                 0]  | ||||||
| 
 | 
 | ||||||
| # 23. | # 23. | ||||||
| @ -481,13 +469,12 @@ $ hledger -f- bal --budget --tree -E | |||||||
| Budget performance in 2019-01-01..2019-01-03: | Budget performance in 2019-01-01..2019-01-03: | ||||||
| 
 | 
 | ||||||
|                    ||       2019-01-01..2019-01-03  |                    ||       2019-01-01..2019-01-03  | ||||||
| =================++============================== | ===================++============================== | ||||||
|  expenses        ||  $50.00 [   5% of  $1100.00]  |  expenses:personal ||  $50.00 [   5% of  $1100.00]  | ||||||
|    personal      ||  $50.00 [   5% of  $1100.00]  |  | ||||||
|    electronics     ||  $20.00 [  20% of   $100.00]  |    electronics     ||  $20.00 [  20% of   $100.00]  | ||||||
|      upgrades      ||  $10.00                       |      upgrades      ||  $10.00                       | ||||||
|  liabilities       || $-50.00 [   5% of $-1100.00]  |  liabilities       || $-50.00 [   5% of $-1100.00]  | ||||||
| -----------------++------------------------------ | -------------------++------------------------------ | ||||||
|                    ||       0 [                 0]  |                    ||       0 [                 0]  | ||||||
| 
 | 
 | ||||||
| ## 24. Zero budget == no budget | ## 24. Zero budget == no budget | ||||||
| @ -519,13 +506,11 @@ Budget performance in 2019-01-01..2019-01-02: | |||||||
| 
 | 
 | ||||||
|                   || 2019-01-01..2019-01-02  |                   || 2019-01-01..2019-01-02  | ||||||
| ==================++======================== | ==================++======================== | ||||||
|  expenses         ||   $80 [  22% of  $370]  |  | ||||||
|  expenses:bills   ||   $80 [  22% of  $370]  |  expenses:bills   ||   $80 [  22% of  $370]  | ||||||
|  expenses:bills:a ||   $10 [  50% of   $20]  |  expenses:bills:a ||   $10 [  50% of   $20]  | ||||||
|  expenses:bills:b ||   $40 [  20% of  $200]  |  expenses:bills:b ||   $40 [  20% of  $200]  | ||||||
|  expenses:bills:c ||     0 [   0% of   $50]  |  expenses:bills:c ||     0 [   0% of   $50]  | ||||||
|  expenses:bills:f ||   $10 [             0]  |  expenses:bills:f ||   $10 [             0]  | ||||||
|  income           ||  $-80 [  22% of $-370]  |  | ||||||
|  income:cash      ||  $-80 [  22% of $-370]  |  income:cash      ||  $-80 [  22% of $-370]  | ||||||
| ------------------++------------------------ | ------------------++------------------------ | ||||||
|                   ||     0 [             0]  |                   ||     0 [             0]  | ||||||
| @ -536,7 +521,6 @@ Budget performance in 2019-01-01..2019-01-02: | |||||||
| 
 | 
 | ||||||
|                   || 2019-01-01..2019-01-02  |                   || 2019-01-01..2019-01-02  | ||||||
| ==================++======================== | ==================++======================== | ||||||
|  expenses         ||   $80 [  22% of  $370]  |  | ||||||
|  expenses:bills   ||   $80 [  22% of  $370]  |  expenses:bills   ||   $80 [  22% of  $370]  | ||||||
|  expenses:bills:a ||   $10 [  50% of   $20]  |  expenses:bills:a ||   $10 [  50% of   $20]  | ||||||
|  expenses:bills:b ||   $40 [  20% of  $200]  |  expenses:bills:b ||   $40 [  20% of  $200]  | ||||||
| @ -544,7 +528,6 @@ Budget performance in 2019-01-01..2019-01-02: | |||||||
|  expenses:bills:d ||   $20                   |  expenses:bills:d ||   $20                   | ||||||
|  expenses:bills:e ||     0                   |  expenses:bills:e ||     0                   | ||||||
|  expenses:bills:f ||   $10 [             0]  |  expenses:bills:f ||   $10 [             0]  | ||||||
|  income           ||  $-80 [  22% of $-370]  |  | ||||||
|  income:cash      ||  $-80 [  22% of $-370]  |  income:cash      ||  $-80 [  22% of $-370]  | ||||||
| ------------------++------------------------ | ------------------++------------------------ | ||||||
|                   ||     0 [             0]  |                   ||     0 [             0]  | ||||||
|  | |||||||
| @ -1,7 +1,6 @@ | |||||||
| #!/usr/bin/env shelltest | #!/usr/bin/env shelltest | ||||||
| # 1. One commodity. Zero accounts should be elided but the final total should not. | # | ||||||
| hledger -f - balance | < | ||||||
| <<< |  | ||||||
| 2010/04/01 tr1 | 2010/04/01 tr1 | ||||||
|   a   16$ |   a   16$ | ||||||
|   b   -16$ |   b   -16$ | ||||||
| @ -9,52 +8,93 @@ hledger -f - balance | |||||||
| 2010/04/02 tr2 | 2010/04/02 tr2 | ||||||
|   a   -16$ |   a   -16$ | ||||||
|   b   16$ |   b   16$ | ||||||
| >>> | 
 | ||||||
|  | # 1. One commodity. Zero accounts should be elided but the final total should not. | ||||||
|  | $ hledger -f - balance | ||||||
|  | > | ||||||
| -------------------- | -------------------- | ||||||
|                    0 |                    0 | ||||||
| >>>=0 | >=0 | ||||||
|  | 
 | ||||||
|  | < | ||||||
|  | 1/1 | ||||||
|  |   (a:b)   1 | ||||||
| 
 | 
 | ||||||
| # 2. An uninteresting parent account (with same balance as its single subaccount) is elided by default, like ledger | # 2. An uninteresting parent account (with same balance as its single subaccount) is elided by default, like ledger | ||||||
| hledger -f - balance --no-total | $ hledger -f - balance --no-total | ||||||
| <<< | > | ||||||
| 1/1 |  | ||||||
|   (a:b)   1 |  | ||||||
| >>> |  | ||||||
|                    1  a:b |                    1  a:b | ||||||
| >>>=0 | >=0 | ||||||
| 
 | 
 | ||||||
| # 3. But not with --no-elide | # 3. But not with --no-elide | ||||||
| hledger -f - balance --no-total --tree --no-elide | $ hledger -f - balance --no-total --tree --no-elide | ||||||
| <<< | > | ||||||
| 1/1 |  | ||||||
|   (a:b)   1 |  | ||||||
| >>> |  | ||||||
|                    1  a |                    1  a | ||||||
|                    1    b |                    1    b | ||||||
| >>>=0 | >=0 | ||||||
| 
 | 
 | ||||||
| # 4. Nor when it has more than one subaccount | < | ||||||
| hledger -f - balance --tree --no-total |  | ||||||
| <<< |  | ||||||
| 1/1 | 1/1 | ||||||
|   (a:b)    1 |   (a:b)    1 | ||||||
|   (a:c)   -1 |   (a:c)   -1 | ||||||
| >>> | 
 | ||||||
|  | # 4. Nor when it has more than one subaccount | ||||||
|  | $ hledger -f - balance --tree --no-total | ||||||
|  | > | ||||||
|                    0  a |                    0  a | ||||||
|                    1    b |                    1    b | ||||||
|                   -1    c |                   -1    c | ||||||
| >>>2 | >2 | ||||||
| >>>=0 | >=0 | ||||||
| 
 | 
 | ||||||
| # 5. Zero-balance leaves should also be hidden by default. | < | ||||||
| hledger -f - balance --no-total |  | ||||||
| <<< |  | ||||||
| 1/1 | 1/1 | ||||||
|  (a)          1 |  (a)          1 | ||||||
|  (a:aa)       1 |  (a:aa)       1 | ||||||
|  (a:aa)      -1 |  (a:aa)      -1 | ||||||
|  (a:aa:aaa)   1 |  (a:aa:aaa)   1 | ||||||
|  (a:aa:aaa)  -1 |  (a:aa:aaa)  -1 | ||||||
| >>> | 
 | ||||||
|  | # 5. Zero-balance leaves should also be hidden by default. | ||||||
|  | $ hledger -f - balance --tree --no-total | ||||||
|                    1  a |                    1  a | ||||||
| >>>=0 | 
 | ||||||
|  | # 6. Zero-balance leaves should be displayed in tree mode when --empty | ||||||
|  | # is called, but zero-balance uninteresting parent accounts are elided | ||||||
|  | # by default. | ||||||
|  | $ hledger -f - balance --tree --no-total --empty | ||||||
|  |                    1  a | ||||||
|  |                    0    aa:aaa | ||||||
|  | 
 | ||||||
|  | # 7. But displayed with --no-elide | ||||||
|  | $ hledger -f - balance --tree --no-total --empty --no-elide | ||||||
|  |                    1  a | ||||||
|  |                    0    aa | ||||||
|  |                    0      aaa | ||||||
|  | 
 | ||||||
|  | # 8. Same as 5 for multiperiod | ||||||
|  | $ hledger -f - balance --tree --no-total -Y | ||||||
|  | Balance changes in 2020: | ||||||
|  | 
 | ||||||
|  |    || 2020  | ||||||
|  | ===++====== | ||||||
|  |  a ||    1  | ||||||
|  | 
 | ||||||
|  | # 9. Same as 6 for mulitperiod | ||||||
|  | $ hledger -f - balance --tree --no-total -Y --empty | ||||||
|  | Balance changes in 2020: | ||||||
|  | 
 | ||||||
|  |           || 2020  | ||||||
|  | ==========++====== | ||||||
|  |  a        ||    1  | ||||||
|  |    aa:aaa ||    0  | ||||||
|  | 
 | ||||||
|  | # 10. Same as 7 for multiperiod | ||||||
|  | $ hledger -f - balance --tree --no-total -Y --empty --no-elide | ||||||
|  | Balance changes in 2020: | ||||||
|  | 
 | ||||||
|  |          || 2020  | ||||||
|  | =========++====== | ||||||
|  |  a       ||    1  | ||||||
|  |    aa    ||    0  | ||||||
|  |      aaa ||    0  | ||||||
|  | |||||||
| @ -57,7 +57,6 @@ Budget performance in 2016-12-01..2016-12-03: | |||||||
| 
 | 
 | ||||||
|                   ||           2016-12-01            2016-12-02            2016-12-03  |                   ||           2016-12-01            2016-12-02            2016-12-03  | ||||||
| ==================++================================================================== | ==================++================================================================== | ||||||
|  assets           || $-10 [  40% of $-25]  $-14 [  56% of $-25]  $-51 [ 204% of $-25]  |  | ||||||
|  assets:cash      || $-10 [  40% of $-25]  $-14 [  56% of $-25]  $-51 [ 204% of $-25]  |  assets:cash      || $-10 [  40% of $-25]  $-14 [  56% of $-25]  $-51 [ 204% of $-25]  | ||||||
|  expenses         ||  $10 [  40% of  $25]   $14 [  56% of  $25]   $51 [ 204% of  $25]  |  expenses         ||  $10 [  40% of  $25]   $14 [  56% of  $25]   $51 [ 204% of  $25]  | ||||||
|  expenses:food    ||  $10 [ 100% of  $10]    $9 [  90% of  $10]   $11 [ 110% of  $10]  |  expenses:food    ||  $10 [ 100% of  $10]    $9 [  90% of  $10]   $11 [ 110% of  $10]  | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user