{-# LANGUAGE DeriveAnyClass #-} {-# LANGUAGE OverloadedLists #-} module Tests.Accounting where import Literate.Accounting import Literate.Accounting.PlanComptableGénéral qualified as PCG import Literate.Database import Literate.Invoice import Literate.Prelude import Tests.Invoice import Tests.Organization import Tests.Work data Account = Account { accountOwner :: Maybe EntityId , accountScope :: Set (Set ScopeId) , accountPCG :: Maybe PCG.PCG } deriving (Eq, Ord, Show, Generic, NFData) account = Account { accountOwner = Nothing , accountScope = [] , accountPCG = Nothing } data Meta = Meta { metaCause :: Ands (Ors Cause) , metaOwner :: Set Cause } deriving (Eq, Ord, Show, Generic, NFData) data Cause = Cause { causeEntity :: Maybe EntityId , causePeriod :: Maybe Period , causeInvoice :: Maybe InvoiceId } deriving (Eq, Ord, Show, Generic, NFData) cause = Cause { causeEntity = Nothing , causeInvoice = Nothing , causePeriod = Nothing } data Amounts = Amounts { amountsEuro :: Amount 100 (UnitName "€") } deriving (Eq, Ord, Show, Generic, NFData) instance FromRational Amounts where fromRational r = Amounts{amountsEuro = fromRational r} accounting :: [Movement Cause Account Amounts] accounting = [ Movement { moveDescription = "Liquidation" , moveMeta = [] , moveDate = "2026-01-27" , movePostings = equalPostings account{accountOwner = Just EntityUpwork} account{accountOwner = Just EntityJulmInfo} 174.30 } , Movement { moveDescription = "" , moveMeta = [ cause{causeInvoice = Just Invoice_org3sale2} ] , moveDate = "2026-01-28" , movePostings = equalPostings account{accountOwner = Just EntityNixOSFoundationNGITeam} account{accountOwner = Just EntityJulmInfo} 2000.00 } , Movement { moveDescription = "" , moveMeta = [ cause{causeInvoice = Just Invoice_org3sale1} ] , moveDate = "2026-01-29" , movePostings = equalPostings account{accountOwner = Just EntityNixOSFoundationNGITeam} account{accountOwner = Just EntityJulmInfo} 4643.75 } , Movement { moveDescription = "Cotisation URSSAF" , moveMeta = [ cause { causeEntity = Just EntityUrssaf , causePeriod = Just Period{periodBeginning = "2026-01-01", periodEnd = "2026-01-31"} } ] , moveDate = "2026-02-01" , movePostings = [ Posting { postingAccount = account { accountOwner = Just EntityJulmInfo , accountPCG = Just PCG.pcg2025_5121 } , postingFlow = FlowOrigin 1691.00 , postingMeta = [] } , Posting { postingAccount = account { accountOwner = Just EntityUrssaf , accountPCG = Just PCG.pcg2025_6451 } , postingFlow = FlowTarget 1677.00 , postingMeta = [] } , Posting { postingAccount = account{accountOwner = Just EntityUrssaf} , postingFlow = FlowTarget 14.00 , postingMeta = [] } ] } ]