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 |     parse = \case | ||||||
|       "historical" -> Just HistoricalBalance |       "historical" -> Just HistoricalBalance | ||||||
|       "cumulative" -> Just CumulativeChange |       "cumulative" -> Just CumulativeChange | ||||||
|  |       "periodic"   -> Just PeriodChange | ||||||
|       _            -> Nothing |       _            -> Nothing | ||||||
| 
 | 
 | ||||||
| -- Get the period specified by any -b/--begin, -e/--end and/or -p/--period | -- 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 | hledger's balance command will show multiple columns when a reporting | ||||||
| interval is specified (eg with @--monthly@), one column for each sub-period. | 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 | * A \"period balance\" (or \"flow\") report (with @--periodic@, the default) shows the | ||||||
|   balance in each period, which is equivalent to the sum of postings in each |   change of account balance in each period, which is equivalent to the sum of postings | ||||||
|   period. Here, checking's balance increased by 10 in Feb: |   in each period. Here, checking's balance increased by 10 in Feb: | ||||||
| 
 | 
 | ||||||
|   > Change of balance (flow): |   > Change of balance (flow): | ||||||
|   > |   > | ||||||
| @ -279,12 +280,12 @@ import Hledger.Read.CsvReader (CSV, printCSV) | |||||||
| -- | Command line options for this command. | -- | Command line options for this command. | ||||||
| balancemode = hledgerCommandMode | balancemode = hledgerCommandMode | ||||||
|   $(embedFileRelative "Hledger/Cli/Commands/Balance.txt") |   $(embedFileRelative "Hledger/Cli/Commands/Balance.txt") | ||||||
|   ([flagNone ["change"] (setboolopt "change") |   ([flagNone ["periodic"] (setboolopt "periodic") | ||||||
|       "show balance change in each period (default)" |       "accumulate amounts from column start to column end (in multicolumn reports, default)" | ||||||
|    ,flagNone ["cumulative"] (setboolopt "cumulative") |    ,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") |    ,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 ++ |    ++ flattreeflags True ++ | ||||||
|    [flagReq  ["drop"] (\s opts -> Right $ setopt "drop" s opts) "N" "omit N leading account name parts (in flat mode)" |    [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 | registermode = hledgerCommandMode | ||||||
|   $(embedFileRelative "Hledger/Cli/Commands/Register.txt") |   $(embedFileRelative "Hledger/Cli/Commands/Register.txt") | ||||||
|   ([flagNone ["cumulative"] (setboolopt "change") |   ([flagNone ["cumulative"] (setboolopt "periodic") | ||||||
|      "show running total from report start date (default)" |      "show running total from report start date (default)" | ||||||
|   ,flagNone ["historical","H"] (setboolopt "historical") |   ,flagNone ["historical","H"] (setboolopt "historical") | ||||||
|      "show historical running total/balance (includes postings before report start date)\n " |      "show historical running total/balance (includes postings before report start date)\n " | ||||||
|  | |||||||
| @ -61,16 +61,15 @@ compoundBalanceCommandMode :: CompoundBalanceCommandSpec -> Mode RawOpts | |||||||
| compoundBalanceCommandMode CompoundBalanceCommandSpec{..} = | compoundBalanceCommandMode CompoundBalanceCommandSpec{..} = | ||||||
|   hledgerCommandMode |   hledgerCommandMode | ||||||
|    cbcdoc |    cbcdoc | ||||||
|    ([flagNone ["change"] (setboolopt "change") |    ([flagNone ["periodic"] (setboolopt "periodic") | ||||||
|        ("show balance change in each period" ++ defType PeriodChange) |        ("accumulate amounts from column start to column end (in multicolumn reports)" | ||||||
|  |            ++ defType PeriodChange) | ||||||
|     ,flagNone ["cumulative"] (setboolopt "cumulative") |     ,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" | ||||||
|            ++ defType CumulativeChange |            ++ defType CumulativeChange) | ||||||
|        ) |  | ||||||
|     ,flagNone ["historical","H"] (setboolopt "historical") |     ,flagNone ["historical","H"] (setboolopt "historical") | ||||||
|        ("show historical ending balance in each period (includes postings before report start date)" |        ("accumulate amounts from journal start to column end (includes postings before report start date)" | ||||||
|            ++ defType HistoricalBalance |            ++ defType HistoricalBalance ++ "\n ") | ||||||
|        ) |  | ||||||
|     ] |     ] | ||||||
|     ++ flattreeflags True ++ |     ++ flattreeflags True ++ | ||||||
|     [flagReq  ["drop"] (\s opts -> Right $ setopt "drop" s opts) "N" "flat mode: omit N leading account name parts" |     [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