lib: add some debug output for market prices (#453)
This commit is contained in:
		
							parent
							
								
									547e6d5438
								
							
						
					
					
						commit
						ce8046bdb4
					
				| @ -30,6 +30,7 @@ import Data.List (sort) | |||||||
| import Data.Maybe | import Data.Maybe | ||||||
| import Data.Time.Calendar | import Data.Time.Calendar | ||||||
| import Test.HUnit | import Test.HUnit | ||||||
|  | import qualified Data.Text as T | ||||||
| 
 | 
 | ||||||
| import Hledger.Data | import Hledger.Data | ||||||
| import Hledger.Read (mamountp') | import Hledger.Read (mamountp') | ||||||
| @ -148,8 +149,10 @@ balanceReportValue :: Journal -> Day -> BalanceReport -> BalanceReport | |||||||
| balanceReportValue j d r = r' | balanceReportValue j d r = r' | ||||||
|   where |   where | ||||||
|     (items,total) = r |     (items,total) = r | ||||||
|     r' = dbg8 "balanceReportValue" |     r' = | ||||||
|          ([(n, n', i, mixedAmountValue j d a) |(n,n',i,a) <- items], mixedAmountValue j d total) |       dbg9 "known market prices" (jmarketprices j) `seq` | ||||||
|  |       dbg8 "balanceReportValue" | ||||||
|  |         ([(n, n', i, mixedAmountValue j d a) |(n,n',i,a) <- items], mixedAmountValue j d total) | ||||||
| 
 | 
 | ||||||
| mixedAmountValue :: Journal -> Day -> MixedAmount -> MixedAmount | mixedAmountValue :: Journal -> Day -> MixedAmount -> MixedAmount | ||||||
| mixedAmountValue j d (Mixed as) = Mixed $ map (amountValue j d) as | mixedAmountValue j d (Mixed as) = Mixed $ map (amountValue j d) as | ||||||
| @ -172,11 +175,11 @@ amountValue j d a = | |||||||
| -- applicable market price directive before this date). | -- applicable market price directive before this date). | ||||||
| commodityValue :: Journal -> Day -> CommoditySymbol -> Maybe Amount | commodityValue :: Journal -> Day -> CommoditySymbol -> Maybe Amount | ||||||
| commodityValue j d c | commodityValue j d c | ||||||
|     | null applicableprices = Nothing |     | null applicableprices = dbg Nothing | ||||||
|     | otherwise             = Just $ mpamount $ last applicableprices |     | otherwise             = dbg $ Just $ mpamount $ last applicableprices | ||||||
|   where |   where | ||||||
|     applicableprices = [p | p <- sort $ jmarketprices j, mpcommodity p == c, mpdate p <= d] |     applicableprices = [p | p <- sort $ jmarketprices j, mpcommodity p == c, mpdate p <= d] | ||||||
| 
 |     dbg = dbg8 ("using market price for "++T.unpack c) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user