cli: Allow overriding with --periodic (rather than the old --change) and properly calculate requestedspan in CompoundBalanceReport.
This commit is contained in:
		
							parent
							
								
									e9f04d5ed6
								
							
						
					
					
						commit
						d931e4919e
					
				| @ -111,7 +111,7 @@ compoundBalanceCommand CompoundBalanceCommandSpec{..} opts@CliOpts{reportspec_=r | ||||
|         parse = \case | ||||
|           "historical" -> Just HistoricalBalance | ||||
|           "cumulative" -> Just CumulativeChange | ||||
|           "change"     -> Just PeriodChange | ||||
|           "periodic"   -> Just PeriodChange | ||||
|           _            -> Nothing | ||||
|     balancetype = fromMaybe cbctype mBalanceTypeOverride | ||||
|     -- Set balance type in the report options. | ||||
| @ -135,8 +135,7 @@ compoundBalanceCommand CompoundBalanceCommandSpec{..} opts@CliOpts{reportspec_=r | ||||
|             _                 -> showDateSpan requestedspan | ||||
|           where | ||||
|             enddates = map (addDays (-1)) . mapMaybe spanEnd $ cbrDates cbr  -- these spans will always have a definite end date | ||||
|             requestedspan = queryDateSpan date2_ (rsQuery rspec) | ||||
|                                 `spanDefaultsFrom` journalDateSpan date2_ j | ||||
|             requestedspan = reportSpan j rspec | ||||
| 
 | ||||
|         -- when user overrides, add an indication to the report title | ||||
|         -- Do we need to deal with overridden ReportType? | ||||
|  | ||||
| @ -7,16 +7,16 @@ P 2000/03/01 A  3 B | ||||
| P 2000/04/01 A  4 B | ||||
| 
 | ||||
| 1999/01/01 | ||||
|   (a)      2 A @ 4 B | ||||
|   (assets)      2 A @ 4 B | ||||
| 
 | ||||
| 2000/01/01 | ||||
|   (a)      1 A @ 6 B | ||||
|   (assets)      1 A @ 6 B | ||||
| 
 | ||||
| 2000/02/01 | ||||
|   (a)      1 A @ 7 B | ||||
|   (assets)      1 A @ 7 B | ||||
| 
 | ||||
| 2000/03/01 | ||||
|   (a)      1 A @ 8 B | ||||
|   (assets)      1 A @ 8 B | ||||
| 
 | ||||
| # 1. multicolumn balance report showing changes in period-end values | ||||
| # Initial balance 2 A, valued at 10 B each, total 20 B | ||||
| @ -27,29 +27,42 @@ P 2000/04/01 A  4 B | ||||
| $ hledger -f- bal -M --valuechange -b 2000 | ||||
| Period-end value changes in 2000-01-01..2000-04-30: | ||||
| 
 | ||||
|    ||  Jan   Feb  Mar  Apr  | ||||
| ===++====================== | ||||
|  a || -5 B  -7 B  7 B  5 B  | ||||
| ---++---------------------- | ||||
|    || -5 B  -7 B  7 B  5 B  | ||||
|         ||  Jan   Feb  Mar  Apr  | ||||
| ========++====================== | ||||
|  assets || -5 B  -7 B  7 B  5 B  | ||||
| --------++---------------------- | ||||
|         || -5 B  -7 B  7 B  5 B  | ||||
| 
 | ||||
| # 2. Cumulative multicolumn balance report showing changes in period-end values | ||||
| $ hledger -f- bal -M --valuechange --cumulative -b 2000 | ||||
| Cumulative period-end value changes in 2000-01-01..2000-04-30: | ||||
| 
 | ||||
|    || 2000-01-31  2000-02-29  2000-03-31  2000-04-30  | ||||
| ===++================================================ | ||||
|  a ||       -5 B       -12 B        -5 B           0  | ||||
| ---++------------------------------------------------ | ||||
|    ||       -5 B       -12 B        -5 B           0  | ||||
|         || 2000-01-31  2000-02-29  2000-03-31  2000-04-30  | ||||
| ========++================================================ | ||||
|  assets ||       -5 B       -12 B        -5 B           0  | ||||
| --------++------------------------------------------------ | ||||
|         ||       -5 B       -12 B        -5 B           0  | ||||
| 
 | ||||
| # 3. Historical multicolumn balance report showing changes in period-end values is | ||||
| # the same as a historical report | ||||
| $ hledger -f- bal -M --valuechange --historical -b 2000 | ||||
| Ending balances (historical) in 2000-01-01..2000-04-30, valued at period ends: | ||||
| 
 | ||||
|    || 2000-01-31  2000-02-29  2000-03-31  2000-04-30  | ||||
| ===++================================================ | ||||
|  a ||       15 B         8 B        15 B        20 B  | ||||
| ---++------------------------------------------------ | ||||
|    ||       15 B         8 B        15 B        20 B  | ||||
|         || 2000-01-31  2000-02-29  2000-03-31  2000-04-30  | ||||
| ========++================================================ | ||||
|  assets ||       15 B         8 B        15 B        20 B  | ||||
| --------++------------------------------------------------ | ||||
|         ||       15 B         8 B        15 B        20 B  | ||||
| 
 | ||||
| # 4. Balance sheet also reports on value change | ||||
| $ hledger -f- balancesheet -MN --valuechange --periodic -b 2000 | ||||
| Balance Sheet 2000-01-01..2000-04-30 (Period-End Value Changes) | ||||
| 
 | ||||
|              ||  Jan   Feb  Mar  Apr  | ||||
| =============++====================== | ||||
|  Assets      ||                       | ||||
| -------------++---------------------- | ||||
|  assets      || -5 B  -7 B  7 B  5 B  | ||||
| =============++====================== | ||||
|  Liabilities ||                       | ||||
| -------------++---------------------- | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user