{-# LANGUAGE DeriveAnyClass #-} module Literate.Accounting ( module Literate.Accounting, module Literate.Accounting.Amount, module Literate.Accounting.Flow, module Literate.Accounting.Quantity, module Literate.Accounting.Unit, ) where import Data.Set qualified as Set import Literate.Accounting.Amount import Literate.Accounting.Flow import Literate.Accounting.Quantity import Literate.Accounting.Unit import Literate.Prelude import Literate.Time type Euro = Amount 100 (UnitName "€") data Movement meta account amounts = Movement { moveDescription :: Text , moveDate :: LocalTime , movePostings :: [Posting meta account amounts] , moveMeta :: Set meta } deriving (Eq, Show) data Posting meta account amounts = Posting { postingAccount :: account , postingFlow :: Flow amounts , postingMeta :: Set meta } deriving (Eq, Show, NFData, Generic) equalPostings :: account -> account -> amounts -> [Posting meta account amounts] equalPostings from to amts = [ Posting { postingAccount = from , postingFlow = FlowOrigin amts , postingMeta = Set.empty } , Posting { postingAccount = to , postingFlow = FlowTarget amts , postingMeta = Set.empty } ]