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