]> Git — Sourcephile - tmp/julm/literate-invoice.git/blob - src/Literate/Accounting.hs
maint/correctness(Entity): use sum type for EntityId
[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 Data.Set qualified as Set
12 import Literate.Accounting.Amount
13 import Literate.Accounting.Flow
14 import Literate.Accounting.Quantity
15 import Literate.Accounting.Unit
16 import Literate.Prelude
17 import Literate.Time
18
19 type Euro = Amount 100 (UnitName "€")
20
21 data Movement meta account amounts
22 = Movement
23 { moveDescription :: Text
24 , moveDate :: LocalTime
25 , movePostings :: [Posting meta account amounts]
26 , moveMeta :: Set meta
27 }
28 deriving (Eq, Show)
29
30 data Posting meta account amounts
31 = Posting
32 { postingAccount :: account
33 , postingFlow :: Flow amounts
34 , postingMeta :: Set meta
35 }
36 deriving (Eq, Show, NFData, Generic)
37
38 equalPostings :: account -> account -> amounts -> [Posting meta account amounts]
39 equalPostings from to amts =
40 [ Posting
41 { postingAccount = from
42 , postingFlow = FlowOrigin amts
43 , postingMeta = Set.empty
44 }
45 , Posting
46 { postingAccount = to
47 , postingFlow = FlowTarget amts
48 , postingMeta = Set.empty
49 }
50 ]