]> Git — Sourcephile - haskell/symantic-compta.git/blob - src/Symantic/Compta/Demo.hs
init
[haskell/symantic-compta.git] / src / Symantic / Compta / Demo.hs
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
10
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
18
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
25
26 {-
27 evalChart :: Tree.Forest (Account Tree.Tree) -> Tree.Forest (Account Tree.Tree)
28 evalChart = id
29 journalTree :: [Eval (Transaction Eval)] -> [Eval (Transaction Eval)]
30 journalTree = id
31 --data Balance amt account where
32
33 instance Applicative repr => Minusable Year Month (Year,Month) repr where
34 y-m = (,) <$> y <*> m
35 instance Applicative repr => Minusable (Year,Month) DayOfMonth Day repr where
36 dy-dom = (\(d,y) -> Time.fromGregorianValid) <$> dy <*> dom
37
38 j = day 01 do
39 get @Day
40
41 j2020 :: [Eval (Transaction Eval)]
42 j2020 =
43 [ year 2020 \= [
44 month 03 \= [
45 day 01 \=
46 [ c1_Capital -= 32
47 , c2_Immo += 32
48 ]
49 ]
50 ]
51 ]
52 -}
53
54 {-
55 j =
56 --year 2020 do
57 --month 03 do
58 day 01 do
59 transaction "libellé" do
60 c1_Capital -= 32
61 c2_Immo += 32
62 -}
63 --demo = chartTree pcf
64 --demo :: [Transaction Eval]
65 --demo = j2020
66 --demo = ()
67 {-
68 p0s ::
69 Postable post acct amt repr =>
70 EUR amt qty repr =>
71 --Literable repr =>
72 IsString section =>
73 acct ~ Account =>
74 amt ~ Amount =>
75 qty ~ Quantity Decimal =>
76 section ~ AccountSegment =>
77 unit ~ Unit =>
78 Liftable (Balance section unit qty) repr =>
79 [repr post]
80 -}
81 --p0s :: [R () Amount AccountSegment ()]
82 --p0s_ = runJournalM chart p0
83 --p0s = runJournalM chart (p0 :: JournalM (Chart.ChartPath AccountSegment) Amount R [TyPost])
84
85 {-
86 p0 ::
87 forall repr post acct section amt unit qty.
88 amt ~ Map unit qty =>
89 Negable 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
95 -}
96 {-
97 p0 = unit ("$"::Unit) do
98 1 -= 10
99 31
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
104 --"Tiers" += eur 10
105 p1 = [ 1 -= 42, 2 ]
106 j = year 2020 do
107 1 -= 3
108 2 += 3
109 07/02 Alimentation ; F:Sitis
110 Tiers:Julien:Dépense -4,78
111 Charge:Achat:Fourniture:Alimentation 4,78
112 -}
113 t0 = {-unit ("$"::Unit)-} do
114 --move (cons (101 -= 10) (cons 41 nil))
115 move do
116 101 -= 10
117 41
118 move do
119 101 -= 10
120 41
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 ]
127 , move do
128 1018 -= 5
129 41
130 ]
131
132 {-
133 instance IsList (repr [TyPost acct amt]) where
134 type Item (repr [TyPost acct amt]) =
135 repr (TyPost acct amt)
136 -}
137
138 t0s = PCG.journal @Eval.Journal PCG.chart t0
139 --t1s = PCG.journal PCG.chart t1
140
141 b0 = PCG.balance t0s
142
143 demo = do
144 IO.print ()
145 --IO.print PCG.chart
146 --IO.putStrLn $ Tree.drawForest $ (show <$>) <$> chart
147 --IO.print p0s
148 --IO.print (Chart.filter (\s -> PCG.sectionSystem s == Just PCG.SystemAbrege) PCG.chart)
149 IO.print t0s
150 IO.print b0
151 --IO.print $ tableBalance tb0
152 --IO.putStrLn $ View.table (tableBalance tb0)
153 {-
154 IO.putStrLn $ View.table
155 [ ["compte", "débit", "crédit", "solde"]
156 , ["1", "-10", "+30", "20"]
157 , ["-3", "+2", "0"]
158 , ["1", "2", "3", "40000", "5000", "6"]
159 , ["420000000"]
160 ]
161 -}