fix that refactoring for web handlers
This commit is contained in:
		
							parent
							
								
									3885b30681
								
							
						
					
					
						commit
						eb6395e91c
					
				@ -132,8 +132,7 @@ type BalanceReportItem = (AccountName  -- full account name
 | 
				
			|||||||
balance :: [Opt] -> [String] -> Journal -> IO ()
 | 
					balance :: [Opt] -> [String] -> Journal -> IO ()
 | 
				
			||||||
balance opts args j = do
 | 
					balance opts args j = do
 | 
				
			||||||
  t <- getCurrentLocalTime
 | 
					  t <- getCurrentLocalTime
 | 
				
			||||||
  let j' = journalSelectingDate (whichDateFromOpts opts) j
 | 
					  putStr $ balanceReportAsText opts $ balanceReport opts (optsToFilterSpec opts args t) j
 | 
				
			||||||
  putStr $ balanceReportAsText opts $ balanceReport opts (optsToFilterSpec opts args t) j'
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- | Render a balance report as plain text suitable for console output.
 | 
					-- | Render a balance report as plain text suitable for console output.
 | 
				
			||||||
balanceReportAsText :: [Opt] -> BalanceReport -> String
 | 
					balanceReportAsText :: [Opt] -> BalanceReport -> String
 | 
				
			||||||
@ -166,7 +165,8 @@ balanceReport opts filterspec j = (items, total)
 | 
				
			|||||||
      acctnames = sort $ tail $ flatten $ treemap aname accttree
 | 
					      acctnames = sort $ tail $ flatten $ treemap aname accttree
 | 
				
			||||||
      accttree = ledgerAccountTree (fromMaybe 99999 $ depthFromOpts opts) l
 | 
					      accttree = ledgerAccountTree (fromMaybe 99999 $ depthFromOpts opts) l
 | 
				
			||||||
      total = sum $ map abalance $ ledgerTopAccounts l
 | 
					      total = sum $ map abalance $ ledgerTopAccounts l
 | 
				
			||||||
      l = journalToLedger filterspec j
 | 
					      l = journalToLedger filterspec j'
 | 
				
			||||||
 | 
					      j' = journalSelectingDate (whichDateFromOpts opts) j
 | 
				
			||||||
      -- | Get data for one balance report line item.
 | 
					      -- | Get data for one balance report line item.
 | 
				
			||||||
      mkitem :: AccountName -> BalanceReportItem
 | 
					      mkitem :: AccountName -> BalanceReportItem
 | 
				
			||||||
      mkitem a = (a, adisplay, indent, abal)
 | 
					      mkitem a = (a, adisplay, indent, abal)
 | 
				
			||||||
 | 
				
			|||||||
@ -32,15 +32,16 @@ type JournalReportItem = Transaction
 | 
				
			|||||||
print' :: [Opt] -> [String] -> Journal -> IO ()
 | 
					print' :: [Opt] -> [String] -> Journal -> IO ()
 | 
				
			||||||
print' opts args j = do
 | 
					print' opts args j = do
 | 
				
			||||||
  t <- getCurrentLocalTime
 | 
					  t <- getCurrentLocalTime
 | 
				
			||||||
  let j' = journalSelectingDate (whichDateFromOpts opts) j
 | 
					  putStr $ showTransactions opts (optsToFilterSpec opts args t) j
 | 
				
			||||||
  putStr $ showTransactions opts (optsToFilterSpec opts args t) j'
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
showTransactions :: [Opt] -> FilterSpec -> Journal -> String
 | 
					showTransactions :: [Opt] -> FilterSpec -> Journal -> String
 | 
				
			||||||
showTransactions opts fspec j = journalReportAsText opts fspec $ journalReport [] fspec j
 | 
					showTransactions opts fspec j = journalReportAsText opts fspec $ journalReport opts fspec j
 | 
				
			||||||
 | 
					
 | 
				
			||||||
journalReportAsText :: [Opt] -> FilterSpec -> JournalReport -> String
 | 
					journalReportAsText :: [Opt] -> FilterSpec -> JournalReport -> String
 | 
				
			||||||
journalReportAsText opts _ items = concatMap (showTransactionForPrint effective) items
 | 
					journalReportAsText opts _ items = concatMap (showTransactionForPrint effective) items
 | 
				
			||||||
    where effective = Effective `elem` opts
 | 
					    where effective = Effective `elem` opts
 | 
				
			||||||
 | 
					
 | 
				
			||||||
journalReport :: [Opt] -> FilterSpec -> Journal -> JournalReport
 | 
					journalReport :: [Opt] -> FilterSpec -> Journal -> JournalReport
 | 
				
			||||||
journalReport _ fspec j = sortBy (comparing tdate) $ jtxns $ filterJournalTransactions fspec j
 | 
					journalReport opts fspec j = sortBy (comparing tdate) $ jtxns $ filterJournalTransactions fspec j'
 | 
				
			||||||
 | 
					    where j' = journalSelectingDate (whichDateFromOpts opts) j
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user