lib,cli: Add --periodic option to indicate PeriodChange accumulation (renamed from --change).
This commit is contained in:
		
							parent
							
								
									18623ec287
								
							
						
					
					
						commit
						351648e4fa
					
				| @ -281,6 +281,7 @@ balancetypeopt = | ||||
|     parse = \case | ||||
|       "historical" -> Just HistoricalBalance | ||||
|       "cumulative" -> Just CumulativeChange | ||||
|       "periodic"   -> Just PeriodChange | ||||
|       _            -> Nothing | ||||
| 
 | ||||
| -- Get the period specified by any -b/--begin, -e/--end and/or -p/--period | ||||
|  | ||||
| @ -122,11 +122,12 @@ and subaccounts. Eg, adding the pattern @o@ to the first example gives: | ||||
| hledger's balance command will show multiple columns when a reporting | ||||
| interval is specified (eg with @--monthly@), one column for each sub-period. | ||||
| 
 | ||||
| There are three kinds of multi-column balance report, indicated by the heading: | ||||
| There are three accumulation strategies for multi-column balance report, indicated by | ||||
| the heading: | ||||
| 
 | ||||
| * A \"period balance\" (or \"flow\") report (the default) shows the change of account | ||||
|   balance in each period, which is equivalent to the sum of postings in each | ||||
|   period. Here, checking's balance increased by 10 in Feb: | ||||
| * A \"period balance\" (or \"flow\") report (with @--periodic@, the default) shows the | ||||
|   change of account balance in each period, which is equivalent to the sum of postings | ||||
|   in each period. Here, checking's balance increased by 10 in Feb: | ||||
| 
 | ||||
|   > Change of balance (flow): | ||||
|   > | ||||
| @ -279,12 +280,12 @@ import Hledger.Read.CsvReader (CSV, printCSV) | ||||
| -- | Command line options for this command. | ||||
| balancemode = hledgerCommandMode | ||||
|   $(embedFileRelative "Hledger/Cli/Commands/Balance.txt") | ||||
|   ([flagNone ["change"] (setboolopt "change") | ||||
|       "show balance change in each period (default)" | ||||
|   ([flagNone ["periodic"] (setboolopt "periodic") | ||||
|       "accumulate amounts from column start to column end (in multicolumn reports, default)" | ||||
|    ,flagNone ["cumulative"] (setboolopt "cumulative") | ||||
|       "show balance change accumulated across periods (in multicolumn reports)" | ||||
|       "accumulate amounts from report start (specified by e.g. -b/--begin) to column end" | ||||
|    ,flagNone ["historical","H"] (setboolopt "historical") | ||||
|       "show historical ending balance in each period (includes postings before report start date)\n " | ||||
|       "accumulate amounts from journal start to column end (includes postings before report start date)\n " | ||||
|    ] | ||||
|    ++ flattreeflags True ++ | ||||
|    [flagReq  ["drop"] (\s opts -> Right $ setopt "drop" s opts) "N" "omit N leading account name parts (in flat mode)" | ||||
|  | ||||
| @ -36,7 +36,7 @@ import Hledger.Cli.Utils | ||||
| 
 | ||||
| registermode = hledgerCommandMode | ||||
|   $(embedFileRelative "Hledger/Cli/Commands/Register.txt") | ||||
|   ([flagNone ["cumulative"] (setboolopt "change") | ||||
|   ([flagNone ["cumulative"] (setboolopt "periodic") | ||||
|      "show running total from report start date (default)" | ||||
|   ,flagNone ["historical","H"] (setboolopt "historical") | ||||
|      "show historical running total/balance (includes postings before report start date)\n " | ||||
|  | ||||
| @ -61,16 +61,15 @@ compoundBalanceCommandMode :: CompoundBalanceCommandSpec -> Mode RawOpts | ||||
| compoundBalanceCommandMode CompoundBalanceCommandSpec{..} = | ||||
|   hledgerCommandMode | ||||
|    cbcdoc | ||||
|    ([flagNone ["change"] (setboolopt "change") | ||||
|        ("show balance change in each period" ++ defType PeriodChange) | ||||
|    ([flagNone ["periodic"] (setboolopt "periodic") | ||||
|        ("accumulate amounts from column start to column end (in multicolumn reports)" | ||||
|            ++ defType PeriodChange) | ||||
|     ,flagNone ["cumulative"] (setboolopt "cumulative") | ||||
|        ("show balance change accumulated across periods (in multicolumn reports)" | ||||
|            ++ defType CumulativeChange | ||||
|        ) | ||||
|        ("accumulate amounts from report start (specified by e.g. -b/--begin) to column end" | ||||
|            ++ defType CumulativeChange) | ||||
|     ,flagNone ["historical","H"] (setboolopt "historical") | ||||
|        ("show historical ending balance in each period (includes postings before report start date)" | ||||
|            ++ defType HistoricalBalance | ||||
|        ) | ||||
|        ("accumulate amounts from journal start to column end (includes postings before report start date)" | ||||
|            ++ defType HistoricalBalance ++ "\n ") | ||||
|     ] | ||||
|     ++ flattreeflags True ++ | ||||
|     [flagReq  ["drop"] (\s opts -> Right $ setopt "drop" s opts) "N" "flat mode: omit N leading account name parts" | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user