diff options
author | Rutger Broekhoff | 2025-03-18 15:29:27 +0100 |
---|---|---|
committer | Rutger Broekhoff | 2025-03-18 15:31:11 +0100 |
commit | 86c8896ee69b068368b4ef9a4c3923285907c328 (patch) | |
tree | dc6e4f58a511c58e2910e9f7ea900165da7d47c6 /app/Main.hs | |
download | rdcapsis-86c8896ee69b068368b4ef9a4c3923285907c328.tar.gz rdcapsis-86c8896ee69b068368b4ef9a4c3923285907c328.zip |
Parsing ING statements (POC)
Diffstat (limited to 'app/Main.hs')
-rw-r--r-- | app/Main.hs | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/app/Main.hs b/app/Main.hs new file mode 100644 index 0000000..2438203 --- /dev/null +++ b/app/Main.hs | |||
@@ -0,0 +1,100 @@ | |||
1 | module Main where | ||
2 | |||
3 | import Brick.AttrMap qualified as A | ||
4 | import Brick.Main qualified as M | ||
5 | import Brick.Types | ||
6 | ( BrickEvent (..), | ||
7 | Widget, | ||
8 | ) | ||
9 | import Brick.Types qualified as T | ||
10 | import Brick.Util (bg, on) | ||
11 | import Brick.Widgets.Center qualified as C | ||
12 | import Brick.Widgets.Core | ||
13 | ( padAll, | ||
14 | str, | ||
15 | ) | ||
16 | import Brick.Widgets.Dialog qualified as D | ||
17 | import Graphics.Vty qualified as V | ||
18 | import Import.Ing.SavingsAccountCsv qualified | ||
19 | import System.IO (IOMode (ReadMode), withFile) | ||
20 | import Text.Pretty.Simple (pPrint) | ||
21 | |||
22 | -- data AccountType = Asset | Equity | Liability | Expense | Income | ||
23 | -- | ||
24 | -- data TxAction = Inc | Dec | ||
25 | -- | ||
26 | -- txAopp :: TxAction -> TxAction | ||
27 | -- txaOpp Inc = Dec | ||
28 | -- txaOpp Dec = Inc | ||
29 | -- | ||
30 | -- onDebit :: AccountType -> TxAction | ||
31 | -- onDebit Asset = Inc | ||
32 | -- onDebit Equity = Dec | ||
33 | -- onDebit Liability = Dec | ||
34 | -- onDebit Expense = Inc | ||
35 | -- onDebit Income = Dec | ||
36 | -- | ||
37 | -- onCredit :: AccountType -> TxAction | ||
38 | -- onCredit = txaOpp . onDebit | ||
39 | -- | ||
40 | -- data Tx = Tx { txDebit :: [(Account, Decimal)], txCredit :: [(Account, Decimal)] } deriving Show | ||
41 | data Choice = Red | Blue | Green | ||
42 | deriving (Show) | ||
43 | |||
44 | data Name | ||
45 | = RedButton | ||
46 | | BlueButton | ||
47 | | GreenButton | ||
48 | deriving (Show, Eq, Ord) | ||
49 | |||
50 | drawUI :: D.Dialog Choice Name -> [Widget Name] | ||
51 | drawUI d = [ui] | ||
52 | where | ||
53 | ui = D.renderDialog d $ C.hCenter $ padAll 1 $ str "This is the dialog body." | ||
54 | |||
55 | appEvent :: BrickEvent Name e -> T.EventM Name (D.Dialog Choice Name) () | ||
56 | appEvent (VtyEvent ev) = | ||
57 | case ev of | ||
58 | V.EvKey V.KEsc [] -> M.halt | ||
59 | V.EvKey V.KEnter [] -> M.halt | ||
60 | _ -> D.handleDialogEvent ev | ||
61 | appEvent _ = return () | ||
62 | |||
63 | initialState :: D.Dialog Choice Name | ||
64 | initialState = D.dialog (Just $ str "Title") (Just (RedButton, choices)) 50 | ||
65 | where | ||
66 | choices = | ||
67 | [ ("Red", RedButton, Red), | ||
68 | ("Blue", BlueButton, Blue), | ||
69 | ("Green", GreenButton, Green) | ||
70 | ] | ||
71 | |||
72 | theMap :: A.AttrMap | ||
73 | theMap = | ||
74 | A.attrMap | ||
75 | V.defAttr | ||
76 | [ (D.dialogAttr, V.white `on` V.blue), | ||
77 | (D.buttonAttr, V.black `on` V.white), | ||
78 | (D.buttonSelectedAttr, bg V.yellow) | ||
79 | ] | ||
80 | |||
81 | theApp :: M.App (D.Dialog Choice Name) e Name | ||
82 | theApp = | ||
83 | M.App | ||
84 | { M.appDraw = drawUI, | ||
85 | M.appChooseCursor = M.showFirstCursor, | ||
86 | M.appHandleEvent = appEvent, | ||
87 | M.appStartEvent = return (), | ||
88 | M.appAttrMap = const theMap | ||
89 | } | ||
90 | |||
91 | main :: IO () | ||
92 | main = do | ||
93 | let filename = "/home/rutgerbrf/Code/P/wayligmative/test.csv" | ||
94 | putStrLn $ "Reading " ++ filename | ||
95 | withFile filename ReadMode $ \h -> do | ||
96 | entries <- Import.Ing.SavingsAccountCsv.readFile h | ||
97 | pPrint entries | ||
98 | |||
99 | -- d <- M.defaultMain theApp initialState | ||
100 | -- putStrLn $ "You chose: " <> show (D.dialogSelection d) | ||