{-# LANGUAGE ImplicitParams #-} {-# LANGUAGE OverloadedLabels #-} {-# LANGUAGE OverloadedRecordDot #-} {-# LANGUAGE OverloadedStrings #-} module Main where import Control.Monad (void) import Data.GI.Base import GI.Adw qualified as Adw import GI.Adw.Objects.ApplicationWindow import GI.Gtk qualified as Gtk import Import.Ing.CurrentAccountCsv qualified 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 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 { -- account :: Account, -- amount :: Decimal, -- tags :: Tags } -- -- data Tx = Tx { -- txClearedAt :: Maybe UTCTime, -- txCommodity :: Commodity, -- the commodity w.r.t. which rates are calculated -- txDebit :: [(Account, Rate, Amount)], -- txCredit :: [(Account, Rate, Amount)] -- -- Description -- -- Type: -- } deriving Show -- -- data Account = Account { -- acName :: [T.Text], -- acBalance :: Amount } activate :: Adw.Application -> IO () activate app = do button <- new Gtk.Button [ #label := "Click me", On #clicked ( ?self `set` [ #sensitive := False, #label := "Thanks for clicking me" ] ) ] button2 <- new Gtk.Button [ #label := "Click me", On #clicked ( ?self `set` [ #sensitive := False, #label := "Thanks for clicking me" ] ) ] title <- new Adw.WindowTitle [ #title := "rdcapsis" ] topBar <- new Adw.HeaderBar [ #titleWidget := title ] sidebarToolbarView <- new Adw.ToolbarView [ #content := button ] mainToolbarView <- new Adw.ToolbarView [] mainToolbarView.addTopBar topBar sidebarNavPage <- new Adw.NavigationPage [ #title := "Accounts", #tag := "sidebar", #child := sidebarToolbarView ] mainNavPage <- new Adw.NavigationPage [ #title := "Content", #tag := "content", #child := mainToolbarView ] splitView <- new Adw.NavigationSplitView [ #sidebar := sidebarNavPage, #content := mainNavPage ] window <- new Adw.ApplicationWindow [ #application := app, #content := splitView, #widthRequest := 280, #heightRequest := 200, #defaultWidth := 800, #defaultHeight := 800 ] cond <- Adw.breakpointConditionParse "max-width: 400sp" breakpoint <- new Adw.Breakpoint [ #condition := cond, On #apply (splitView.setCollapsed True), On #unapply (splitView.setCollapsed False) ] window.addBreakpoint breakpoint window.present main :: IO () main = do app <- new Adw.Application [ #applicationId := "eu.fautchen.rdcapsis", On #activate (activate ?self) ] void $ app.run Nothing -- window <- applicationWindowNew