lib: bal --value=end without --historical should not report on fluctuation in value of historical postings.
This commit is contained in:
		
							parent
							
								
									c005655311
								
							
						
					
					
						commit
						9cf5015958
					
				| @ -50,7 +50,7 @@ import Data.Semigroup ((<>)) | |||||||
| #endif | #endif | ||||||
| import Data.Semigroup (sconcat) | import Data.Semigroup (sconcat) | ||||||
| import Data.Time.Calendar (Day, addDays, fromGregorian) | import Data.Time.Calendar (Day, addDays, fromGregorian) | ||||||
| import Safe (headMay, lastDef, lastMay, minimumMay) | import Safe (headMay, lastDef, lastMay) | ||||||
| 
 | 
 | ||||||
| import Hledger.Data | import Hledger.Data | ||||||
| import Hledger.Query | import Hledger.Query | ||||||
| @ -317,14 +317,13 @@ calculateReportMatrix rspec@ReportSpec{rsOpts=ropts} j priceoracle startbals col | |||||||
|         CumulativeChange  -> cumulative |         CumulativeChange  -> cumulative | ||||||
|         HistoricalBalance -> historical |         HistoricalBalance -> historical | ||||||
|       where |       where | ||||||
|         historical                           = cumulativeSum avalue startingBalance changes |         historical = cumulativeSum avalue startingBalance changes | ||||||
|         cumulative | changingValuation ropts = fmap (`subtractAcct` valuedStart) historical |         cumulative = cumulativeSum avalue nullacct changes | ||||||
|                    | otherwise               = cumulativeSum avalue nullacct changes |         changeamts = if changingValuation ropts | ||||||
|         changeamts | changingValuation ropts = periodChanges valuedStart historical |                         then periodChanges nullacct cumulative | ||||||
|                    | otherwise               = changes |                         else changes | ||||||
| 
 | 
 | ||||||
|         startingBalance = HM.lookupDefault nullacct name startbals |         startingBalance = HM.lookupDefault nullacct name startbals | ||||||
|         valuedStart = avalue (DateSpan Nothing historicalDate) startingBalance |  | ||||||
| 
 | 
 | ||||||
|     -- Transpose to get each account's balance changes across all columns, then |     -- Transpose to get each account's balance changes across all columns, then | ||||||
|     -- pad with zeros |     -- pad with zeros | ||||||
| @ -335,7 +334,6 @@ calculateReportMatrix rspec@ReportSpec{rsOpts=ropts} j priceoracle startbals col | |||||||
| 
 | 
 | ||||||
|     (pvalue, avalue) = postingAndAccountValuations rspec j priceoracle |     (pvalue, avalue) = postingAndAccountValuations rspec j priceoracle | ||||||
|     addElided = if queryDepth (rsQuery rspec) == Just 0 then HM.insert "..." zeros else id |     addElided = if queryDepth (rsQuery rspec) == Just 0 then HM.insert "..." zeros else id | ||||||
|     historicalDate = minimumMay $ mapMaybe spanStart colspans |  | ||||||
|     zeros = M.fromList [(span, nullacct) | span <- colspans] |     zeros = M.fromList [(span, nullacct) | span <- colspans] | ||||||
|     colspans = M.keys colps |     colspans = M.keys colps | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -219,7 +219,7 @@ $ hledger -f- reg --value=cost | |||||||
| 2000-01-01                      (a)                            6 B           6 B | 2000-01-01                      (a)                            6 B           6 B | ||||||
| 2000-02-01                      (a)                            7 B          13 B | 2000-02-01                      (a)                            7 B          13 B | ||||||
| 2000-03-01                      (a)                            8 B          21 B | 2000-03-01                      (a)                            8 B          21 B | ||||||
|   | 
 | ||||||
| # 16. register report valued at posting dates | # 16. register report valued at posting dates | ||||||
| $ hledger -f- reg --value=then | $ hledger -f- reg --value=then | ||||||
| 2000-01-01                      (a)                            1 B           1 B | 2000-01-01                      (a)                            1 B           1 B | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user