define Ledger's exports
This commit is contained in:
		
							parent
							
								
									7acd389624
								
							
						
					
					
						commit
						a7b1269d86
					
				| @ -5,7 +5,23 @@ names, a map from account names to 'Account's, and the display precision. | ||||
| 
 | ||||
| -} | ||||
| 
 | ||||
| module Ledger.Ledger | ||||
| module Ledger.Ledger ( | ||||
| cacheLedger, | ||||
| filterLedgerEntries, | ||||
| filterLedgerTransactions, | ||||
| accountnames, | ||||
| ledgerAccount, | ||||
| ledgerTransactions, | ||||
| ledgerAccountTree, | ||||
| addDataToAccountNameTree, | ||||
| printentries, | ||||
| printregister, | ||||
| showLedgerAccounts, | ||||
| showAccountTree, | ||||
| isBoringInnerAccount, | ||||
| isBoringInnerAccountName, | ||||
| pruneBoringBranches, | ||||
| ) | ||||
| where | ||||
| import qualified Data.Map as Map | ||||
| import Data.Map ((!)) | ||||
| @ -19,22 +35,6 @@ import Ledger.RawLedger | ||||
| import Ledger.Entry | ||||
| 
 | ||||
| 
 | ||||
| rawLedgerTransactions :: RawLedger -> [Transaction] | ||||
| rawLedgerTransactions = txns . entries | ||||
|     where | ||||
|       txns :: [Entry] -> [Transaction] | ||||
|       txns es = concat $ map flattenEntry $ zip es (iterate (+1) 1) | ||||
| 
 | ||||
| rawLedgerAccountNamesUsed :: RawLedger -> [AccountName] | ||||
| rawLedgerAccountNamesUsed = accountNamesFromTransactions . rawLedgerTransactions | ||||
| 
 | ||||
| rawLedgerAccountNames :: RawLedger -> [AccountName] | ||||
| rawLedgerAccountNames = sort . expandAccountNames . rawLedgerAccountNamesUsed | ||||
| 
 | ||||
| rawLedgerAccountNameTree :: RawLedger -> Tree AccountName | ||||
| rawLedgerAccountNameTree l = accountNameTreeFrom $ rawLedgerAccountNames l | ||||
| 
 | ||||
| 
 | ||||
| instance Show Ledger where | ||||
|     show l = printf "Ledger with %d entries, %d accounts" | ||||
|              ((length $ entries $ rawledger l) + | ||||
| @ -266,3 +266,21 @@ pruneBoringBranches = | ||||
|       hasbalance = (/= 0) . abalance | ||||
|       hastxns = (> 0) . length . atransactions | ||||
| 
 | ||||
| -- helpers | ||||
| 
 | ||||
| rawLedgerTransactions :: RawLedger -> [Transaction] | ||||
| rawLedgerTransactions = txns . entries | ||||
|     where | ||||
|       txns :: [Entry] -> [Transaction] | ||||
|       txns es = concat $ map flattenEntry $ zip es (iterate (+1) 1) | ||||
| 
 | ||||
| rawLedgerAccountNamesUsed :: RawLedger -> [AccountName] | ||||
| rawLedgerAccountNamesUsed = accountNamesFromTransactions . rawLedgerTransactions | ||||
| 
 | ||||
| rawLedgerAccountNames :: RawLedger -> [AccountName] | ||||
| rawLedgerAccountNames = sort . expandAccountNames . rawLedgerAccountNamesUsed | ||||
| 
 | ||||
| rawLedgerAccountNameTree :: RawLedger -> Tree AccountName | ||||
| rawLedgerAccountNameTree l = accountNameTreeFrom $ rawLedgerAccountNames l | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
							
								
								
									
										2
									
								
								Tests.hs
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								Tests.hs
									
									
									
									
									
								
							| @ -372,7 +372,7 @@ test_ledgerAccountNames = | ||||
|     ["assets","assets:cash","assets:checking","assets:saving","equity","equity:opening balances", | ||||
|     "expenses","expenses:food","expenses:food:dining","expenses:phone","expenses:vacation", | ||||
|      "liabilities","liabilities:credit cards","liabilities:credit cards:discover"] | ||||
|     (rawLedgerAccountNames ledger7) | ||||
|     (accountnames l7) | ||||
| 
 | ||||
| test_cacheLedger = | ||||
|     assertEqual' 15 (length $ Map.keys $ accounts $ cacheLedger ledger7 nullpats) | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user