]> Git — Sourcephile - tmp/julm/literate-invoice.git/blob - src/Literate/Accounting.hs
feat(accounting/PCG): init
[tmp/julm/literate-invoice.git] / src / Literate / Accounting.hs
1 {-# LANGUAGE DeriveAnyClass #-}
2
3 module Literate.Accounting (
4 module Literate.Accounting,
5 module Literate.Accounting.Amount,
6 module Literate.Accounting.Flow,
7 module Literate.Accounting.Quantity,
8 module Literate.Accounting.Unit,
9 ) where
10
11 import Literate.Accounting.Amount
12 import Literate.Accounting.Flow
13 import Literate.Accounting.Quantity
14 import Literate.Accounting.Unit
15 import Literate.Prelude
16 import Literate.Time
17
18 type Euro = Amount 100 (UnitName "€")
19
20 data Movement cause account amounts
21 = Movement
22 { moveDescription :: Text
23 , moveDate :: LocalTime
24 , movePostings :: [Posting account amounts]
25 , moveCause :: Set cause
26 }
27 deriving (Eq, Show)
28
29 data Posting account amounts
30 = Posting
31 { postingAccount :: account
32 , postingFlow :: Flow amounts
33 }
34 deriving (Eq, Show, NFData, Generic)
35
36 equalPostings :: account -> account -> amounts -> [Posting account amounts]
37 equalPostings from to amts =
38 [ Posting
39 { postingAccount = from
40 , postingFlow = FlowSource amts
41 }
42 , Posting
43 { postingAccount = to
44 , postingFlow = FlowDest amts
45 }
46 ]