;lib: journalConvertAmountsToCost -> journalToCost
This commit is contained in:
		
							parent
							
								
									54e1caebf1
								
							
						
					
					
						commit
						2e3b51c03f
					
				@ -24,7 +24,7 @@ module Hledger.Data.Journal (
 | 
			
		||||
  journalApplyCommodityStyles,
 | 
			
		||||
  commodityStylesFromAmounts,
 | 
			
		||||
  journalCommodityStyles,
 | 
			
		||||
  journalConvertAmountsToCost,
 | 
			
		||||
  journalToCost,
 | 
			
		||||
  journalReverse,
 | 
			
		||||
  journalSetLastReadTime,
 | 
			
		||||
  journalPivot,
 | 
			
		||||
@ -1011,8 +1011,8 @@ canonicalStyleFrom ss@(s:_) =
 | 
			
		||||
 | 
			
		||||
-- | Convert all this journal's amounts to cost using the transaction prices, if any.
 | 
			
		||||
-- The journal's commodity styles are applied to the resulting amounts.
 | 
			
		||||
journalConvertAmountsToCost :: Journal -> Journal
 | 
			
		||||
journalConvertAmountsToCost j@Journal{jtxns=ts} = j{jtxns=map (transactionToCost styles) ts}
 | 
			
		||||
journalToCost :: Journal -> Journal
 | 
			
		||||
journalToCost j@Journal{jtxns=ts} = j{jtxns=map (transactionToCost styles) ts}
 | 
			
		||||
    where
 | 
			
		||||
      styles = journalCommodityStyles j
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -413,7 +413,7 @@ tests_BalanceReport = tests "BalanceReport" [
 | 
			
		||||
                ,"  a:b          10h @ $50"
 | 
			
		||||
                ,"  c:d                   "
 | 
			
		||||
                ]) >>= either error' return
 | 
			
		||||
         let j' = journalCanonicaliseAmounts $ journalConvertAmountsToCost j -- enable cost basis adjustment
 | 
			
		||||
         let j' = journalCanonicaliseAmounts $ journalToCost j -- enable cost basis adjustment
 | 
			
		||||
         balanceReportAsText defreportopts (balanceReport defreportopts Any j') `is`
 | 
			
		||||
           ["                $500  a:b"
 | 
			
		||||
           ,"               $-500  c:d"
 | 
			
		||||
 | 
			
		||||
@ -416,7 +416,7 @@ flat_ = (==ALFlat) . accountlistmode_
 | 
			
		||||
journalSelectingAmountFromOpts :: ReportOpts -> Journal -> Journal
 | 
			
		||||
journalSelectingAmountFromOpts opts =
 | 
			
		||||
  case value_ opts of
 | 
			
		||||
    Just (AtCost _) -> journalConvertAmountsToCost
 | 
			
		||||
    Just (AtCost _) -> journalToCost
 | 
			
		||||
    _               -> id
 | 
			
		||||
 | 
			
		||||
-- | Convert report options and arguments to a query.
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user