1 {-# LANGUAGE DeriveAnyClass #-}
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,
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
19 type Euro = Amount 100 (UnitName "€")
21 data Movement meta account amounts
23 { moveDescription :: Text
24 , moveDate :: LocalTime
25 , movePostings :: [Posting meta account amounts]
26 , moveMeta :: Set meta
30 data Posting meta account amounts
32 { postingAccount :: account
33 , postingFlow :: Flow amounts
34 , postingMeta :: Set meta
36 deriving (Eq, Show, NFData, Generic)
38 equalPostings :: account -> account -> amounts -> [Posting meta account amounts]
39 equalPostings from to amts =
41 { postingAccount = from
42 , postingFlow = FlowOrigin amts
43 , postingMeta = Set.empty
47 , postingFlow = FlowTarget amts
48 , postingMeta = Set.empty