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