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))
122 move [ 631 -= 42, 41 ]
123 move [ 1018 -= 5, 41 ]
124 t1 = unit ("$"::Unit)
125 --move (cons (101 -= 10) (cons 41 nil))
126 [ move [ 631 -= 42, 41 ]
127 , move [ 1018 -= 5, 41 ]
134 instance IsList (repr [TyPost acct amt]) where
135 type Item (repr [TyPost acct amt]) =
136 repr (TyPost acct amt)
139 t0s = PCG.journal @Eval.Journal PCG.chart t0
140 --t1s = PCG.journal PCG.chart t1
144 {- | >>> balanceByAccount b0
145 + 1 Trickle {exclusive = fromList [], inclusive = fromList [("",Out -25)]}
146 | ` 0 Trickle {exclusive = fromList [], inclusive = fromList [("",Out -25)]}
147 | ` 1 Trickle {exclusive = fromList [("",Out -20)], inclusive = fromList [("",Out -25)]}
148 | ` 8 Trickle {exclusive = fromList [("",Out -5)], inclusive = fromList [("",Out -5)]}
149 + 4 Trickle {exclusive = fromList [], inclusive = fromList [("",In 67)]}
150 | ` 1 Trickle {exclusive = fromList [("",In 67)], inclusive = fromList [("",In 67)]}
151 ` 6 Trickle {exclusive = fromList [], inclusive = fromList [("",Out -42)]}
152 ` 3 Trickle {exclusive = fromList [], inclusive = fromList [("",Out -42)]}
153 ` 1 Trickle {exclusive = fromList [("",Out -42)], inclusive = fromList [("",Out -42)]}
158 --IO.putStrLn $ Tree.drawForest $ (show <$>) <$> chart
160 --IO.print (Chart.filter (\s -> PCG.sectionSystem s == Just PCG.SystemAbrege) PCG.chart)
163 --IO.print $ tableBalance tb0
164 --IO.putStrLn $ View.table (tableBalance tb0)
166 IO.putStrLn $ View.table
167 [ ["compte", "débit", "crédit", "solde"]
168 , ["1", "-10", "+30", "20"]
170 , ["1", "2", "3", "40000", "5000", "6"]