1 {-# LANGUAGE BlockArguments #-}
2 {-# LANGUAGE OverloadedLists #-}
3 {-# LANGUAGE OverloadedStrings #-}
4 {-# OPTIONS_GHC -Wno-missing-signatures #-}
5 {-# OPTIONS_GHC -Wno-unused-do-bind #-}
6 {-# OPTIONS_GHC -Wno-orphans #-}
7 {-# OPTIONS_GHC -Wno-unused-imports #-}
8 {-# OPTIONS_GHC -Wno-name-shadowing #-}
9 module Symantic.Compta.Demo where
11 import Data.Eq (Eq(..))
12 import Data.Maybe (Maybe(..))
13 import Control.Monad (Monad(..))
14 import Data.Function (($))
15 import Data.Functor ((<$>))
16 import qualified Control.Monad as Monad
17 import qualified System.IO as IO
19 import Symantic.Compta
20 import Symantic.Compta.Calc
21 import qualified Symantic.Compta.Calc.Chart as Chart
22 import qualified Symantic.Compta.Eval as Eval
23 import qualified Symantic.Compta.Norm.PCG as PCG
24 import qualified Symantic.Compta.View as View
27 evalChart :: Tree.Forest (Account Tree.Tree) -> Tree.Forest (Account Tree.Tree)
29 journalTree :: [Eval (Transaction Eval)] -> [Eval (Transaction Eval)]
31 --data Balance amt account where
33 instance Applicative repr => Minusable Year Month (Year,Month) repr where
35 instance Applicative repr => Minusable (Year,Month) DayOfMonth Day repr where
36 dy-dom = (\(d,y) -> Time.fromGregorianValid) <$> dy <*> dom
41 j2020 :: [Eval (Transaction Eval)]
59 transaction "libellé" do
63 --demo = chartTree pcf
64 --demo :: [Transaction Eval]
69 Postable post acct amt repr =>
75 qty ~ Quantity Decimal =>
76 section ~ AccountSegment =>
78 Liftable (Balance section unit qty) repr =>
81 --p0s :: [R () Amount AccountSegment ()]
82 --p0s_ = runJournalM chart p0
83 --p0s = runJournalM chart (p0 :: JournalM (Chart.ChartPath AccountSegment) Amount R [TyPost])
87 forall repr post acct section amt unit qty.
90 FromInteger (JournalM post acct section amt unit qty repr qty) =>
91 FromInteger (JournalM post acct section amt unit qty repr acct) =>
92 Postable post acct amt (JournalM post acct section amt unit qty repr) =>
93 EUR amt (JournalM post acct section amt unit qty repr) =>
94 JournalM post acct section amt unit qty repr post
97 p0 = unit ("$"::Unit) do
100 --1 += (eur 10 + usd 10)
101 --2 -= eur @_ @qty (neg <$> 10)
102 --2 -= (JournalM (return Map.empty) + eur 5)
103 --"Tiers/Client" -= eur 10
109 07/02 Alimentation ; F:Sitis
110 Tiers:Julien:Dépense -4,78
111 Charge:Achat:Fourniture:Alimentation 4,78
113 t0 = {-unit ("$"::Unit)-} do
114 --move (cons (101 -= 10) (cons 41 nil))
121 move [ 631 -= 42, 41 ]
122 move [ 1018 -= 5, 41 ]
123 t1 = unit ("$"::Unit)
124 --move (cons (101 -= 10) (cons 41 nil))
125 [ move [ 631 -= 42, 41 ]
126 , move [ 1018 -= 5, 41 ]
133 instance IsList (repr [TyPost acct amt]) where
134 type Item (repr [TyPost acct amt]) =
135 repr (TyPost acct amt)
138 t0s = PCG.journal @Eval.Journal PCG.chart t0
139 --t1s = PCG.journal PCG.chart t1
146 --IO.putStrLn $ Tree.drawForest $ (show <$>) <$> chart
148 --IO.print (Chart.filter (\s -> PCG.sectionSystem s == Just PCG.SystemAbrege) PCG.chart)
151 --IO.print $ tableBalance tb0
152 --IO.putStrLn $ View.table (tableBalance tb0)
154 IO.putStrLn $ View.table
155 [ ["compte", "débit", "crédit", "solde"]
156 , ["1", "-10", "+30", "20"]
158 , ["1", "2", "3", "40000", "5000", "6"]