From 533ba31d0a03600f57ad46f6e55229a7f2b60994 Mon Sep 17 00:00:00 2001 From: Rutger Broekhoff Date: Sat, 29 Mar 2025 21:24:40 +0100 Subject: Rename --- app/Main.hs | 64 ++++++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 44 insertions(+), 20 deletions(-) (limited to 'app') diff --git a/app/Main.hs b/app/Main.hs index 7b4551a..bc8ad37 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -20,25 +20,49 @@ import Import.Ing.SavingsAccountCsv qualified import System.IO (IOMode (ReadMode), withFile) import Text.Pretty.Simple (pPrint) --- data AccountType = Asset | Equity | Liability | Expense | Income --- --- data TxAction = Inc | Dec --- --- txAopp :: TxAction -> TxAction --- txaOpp Inc = Dec --- txaOpp Dec = Inc --- --- onDebit :: AccountType -> TxAction --- onDebit Asset = Inc --- onDebit Equity = Dec --- onDebit Liability = Dec --- onDebit Expense = Inc --- onDebit Income = Dec --- --- onCredit :: AccountType -> TxAction --- onCredit = txaOpp . onDebit --- --- data Tx = Tx { txDebit :: [(Account, Decimal)], txCredit :: [(Account, Decimal)] } deriving Show +data AccountType = Asset | Equity | Liability | Expense | Income + +data TxAction = Inc | Dec + +txAopp :: TxAction -> TxAction +txaOpp Inc = Dec +txaOpp Dec = Inc + +onDebit :: AccountType -> TxAction +onDebit Asset = Inc +onDebit Equity = Dec +onDebit Liability = Dec +onDebit Expense = Inc +onDebit Income = Dec + +onCredit :: AccountType -> TxAction +onCredit = txaOpp . onDebit + +data Ledger = [LedgerEntry] + +data LedgerEntry = TxEntry Tx | BalAssertEntry BalAssert + +-- A balance assertion is only valid when all transactions before it have been +-- cleared and the balance of the account agrees with the amount in the +-- assertion. +data BalAssert = BalAssert { + amount :: Decimal, + tags :: Tags } + +data Tx = Tx { + txClearedAt :: Maybe UTCTime, + txCommodity :: Commodity, + txDebit :: [(Account, Commodity, Rate, Amount)], + txCredit :: [(Account, Commodity, Rate, Amount)] + -- Description + -- Type: + } deriving Show + +data Account = Account { + acName :: [T.Text], + acCommodity :: Commodity, + acBalance :: Amount } + data Choice = Red | Blue | Green deriving (Show) @@ -91,7 +115,7 @@ theApp = main :: IO () main = do - let filename = "/home/rutgerbrf/Code/P/wayligmative/test3.csv" + let filename = "/home/rutgerbrf/Code/P/rdcapsis/test3.csv" putStrLn $ "Reading " ++ filename withFile filename ReadMode $ \h -> do entries <- Import.Ing.CurrentAccountCsv.readFile h -- cgit v1.2.3