1 {-# LANGUAGE DeriveAnyClass #-}
2 {-# LANGUAGE OverloadedLists #-}
4 module Tests.Accounting where
6 import Literate.Accounting
7 import Literate.Accounting.PlanComptableGénéral qualified as PCG
8 import Literate.Database
9 import Literate.Invoice
10 import Literate.Prelude
13 import Tests.Organization
16 data Account = Account
17 { accountOwner :: Maybe EntityId
18 , accountScope :: Set (Set ScopeId)
19 , accountPCG :: Maybe PCG.PCG
21 deriving (Eq, Ord, Show, Generic, NFData)
24 { accountOwner = Nothing
26 , accountPCG = Nothing
31 { metaCause :: Ands (Ors Cause)
32 , metaOwner :: Set Cause
34 deriving (Eq, Ord, Show, Generic, NFData)
38 { causeEntity :: Maybe EntityId
39 , causePeriod :: Maybe Period
40 , causeInvoice :: Maybe InvoiceId
42 deriving (Eq, Ord, Show, Generic, NFData)
45 { causeEntity = Nothing
46 , causeInvoice = Nothing
47 , causePeriod = Nothing
52 { amountsEuro :: Amount 100 (UnitName "€")
54 deriving (Eq, Ord, Show, Generic, NFData)
55 instance FromRational Amounts where
56 fromRational r = Amounts{amountsEuro = fromRational r}
58 accounting :: [Movement Cause Account Amounts]
61 { moveDescription = "Liquidation"
63 , moveDate = "2026-01-27"
64 , movePostings = equalPostings account{accountOwner = Just EntityUpwork} account{accountOwner = Just EntityJulmInfo} 174.30
67 { moveDescription = ""
69 [ cause{causeInvoice = Just Invoice_org3sale2}
71 , moveDate = "2026-01-28"
72 , movePostings = equalPostings account{accountOwner = Just EntityNixOSFoundationNGITeam} account{accountOwner = Just EntityJulmInfo} 2000.00
75 { moveDescription = ""
77 [ cause{causeInvoice = Just Invoice_org3sale1}
79 , moveDate = "2026-01-29"
80 , movePostings = equalPostings account{accountOwner = Just EntityNixOSFoundationNGITeam} account{accountOwner = Just EntityJulmInfo} 4643.75
83 { moveDescription = "Cotisation URSSAF"
86 { causeEntity = Just EntityUrssaf
87 , causePeriod = Just Period{periodBeginning = "2026-01-01", periodEnd = "2026-01-31"}
90 , moveDate = "2026-02-01"
95 { accountOwner = Just EntityJulmInfo
96 , accountPCG = Just PCG.pcg2025_5121
98 , postingFlow = FlowOrigin 1691.00
104 { accountOwner = Just EntityUrssaf
105 , accountPCG = Just PCG.pcg2025_6451
107 , postingFlow = FlowTarget 1677.00
111 { postingAccount = account{accountOwner = Just EntityUrssaf}
112 , postingFlow = FlowTarget 14.00