{-# LANGUAGE BlockArguments #-} {-# LANGUAGE OverloadedLists #-} {-# LANGUAGE OverloadedStrings #-} {-# OPTIONS_GHC -Wno-missing-signatures #-} {-# OPTIONS_GHC -Wno-unused-do-bind #-} {-# OPTIONS_GHC -Wno-orphans #-} {-# OPTIONS_GHC -Wno-unused-imports #-} {-# OPTIONS_GHC -Wno-name-shadowing #-} module Symantic.Compta.Demo where import Data.Eq (Eq(..)) import Data.Maybe (Maybe(..)) import Control.Monad (Monad(..)) import Data.Function (($)) import Data.Functor ((<$>)) import qualified Control.Monad as Monad import qualified System.IO as IO import Symantic.Compta import Symantic.Compta.Calc import qualified Symantic.Compta.Calc.Chart as Chart import qualified Symantic.Compta.Eval as Eval import qualified Symantic.Compta.Norm.PCG as PCG import qualified Symantic.Compta.View as View {- evalChart :: Tree.Forest (Account Tree.Tree) -> Tree.Forest (Account Tree.Tree) evalChart = id journalTree :: [Eval (Transaction Eval)] -> [Eval (Transaction Eval)] journalTree = id --data Balance amt account where instance Applicative repr => Minusable Year Month (Year,Month) repr where y-m = (,) <$> y <*> m instance Applicative repr => Minusable (Year,Month) DayOfMonth Day repr where dy-dom = (\(d,y) -> Time.fromGregorianValid) <$> dy <*> dom j = day 01 do get @Day j2020 :: [Eval (Transaction Eval)] j2020 = [ year 2020 \= [ month 03 \= [ day 01 \= [ c1_Capital -= 32 , c2_Immo += 32 ] ] ] ] -} {- j = --year 2020 do --month 03 do day 01 do transaction "libellé" do c1_Capital -= 32 c2_Immo += 32 -} --demo = chartTree pcf --demo :: [Transaction Eval] --demo = j2020 --demo = () {- p0s :: Postable post acct amt repr => EUR amt qty repr => --Literable repr => IsString section => acct ~ Account => amt ~ Amount => qty ~ Quantity Decimal => section ~ AccountSegment => unit ~ Unit => Liftable (Balance section unit qty) repr => [repr post] -} --p0s :: [R () Amount AccountSegment ()] --p0s_ = runJournalM chart p0 --p0s = runJournalM chart (p0 :: JournalM (Chart.ChartPath AccountSegment) Amount R [TyPost]) {- p0 :: forall repr post acct section amt unit qty. amt ~ Map unit qty => Negable qty => FromInteger (JournalM post acct section amt unit qty repr qty) => FromInteger (JournalM post acct section amt unit qty repr acct) => Postable post acct amt (JournalM post acct section amt unit qty repr) => EUR amt (JournalM post acct section amt unit qty repr) => JournalM post acct section amt unit qty repr post -} {- p0 = unit ("$"::Unit) do 1 -= 10 31 --1 += (eur 10 + usd 10) --2 -= eur @_ @qty (neg <$> 10) --2 -= (JournalM (return Map.empty) + eur 5) --"Tiers/Client" -= eur 10 --"Tiers" += eur 10 p1 = [ 1 -= 42, 2 ] j = year 2020 do 1 -= 3 2 += 3 07/02 Alimentation ; F:Sitis Tiers:Julien:Dépense -4,78 Charge:Achat:Fourniture:Alimentation 4,78 -} t0 = {-unit ("$"::Unit)-} do --move (cons (101 -= 10) (cons 41 nil)) move do 101 -= 10 41 move do 101 -= 10 41 move [ 631 -= 42, 41 ] move [ 1018 -= 5, 41 ] t1 = unit ("$"::Unit) --move (cons (101 -= 10) (cons 41 nil)) [ move [ 631 -= 42, 41 ] , move [ 1018 -= 5, 41 ] , move do 1018 -= 5 41 ] {- instance IsList (repr [TyPost acct amt]) where type Item (repr [TyPost acct amt]) = repr (TyPost acct amt) -} t0s = PCG.journal @Eval.Journal PCG.chart t0 --t1s = PCG.journal PCG.chart t1 b0 = PCG.balance t0s demo = do IO.print () --IO.print PCG.chart --IO.putStrLn $ Tree.drawForest $ (show <$>) <$> chart --IO.print p0s --IO.print (Chart.filter (\s -> PCG.sectionSystem s == Just PCG.SystemAbrege) PCG.chart) IO.print t0s IO.print b0 --IO.print $ tableBalance tb0 --IO.putStrLn $ View.table (tableBalance tb0) {- IO.putStrLn $ View.table [ ["compte", "débit", "crédit", "solde"] , ["1", "-10", "+30", "20"] , ["-3", "+2", "0"] , ["1", "2", "3", "40000", "5000", "6"] , ["420000000"] ] -}