]> Git — Sourcephile - tmp/julm/literate-invoice.git/blob - tests/Tests/Organization.hs
maint/correctness(Entity): use sum type for EntityId
[tmp/julm/literate-invoice.git] / tests / Tests / Organization.hs
1 {-# LANGUAGE DeriveAnyClass #-}
2 {-# LANGUAGE OverloadedStrings #-}
3
4 module Tests.Organization where
5
6 import Country.Identifier qualified as Country
7 import Literate.Document qualified as Doc
8 import Literate.Organization
9 import Literate.Prelude
10
11 bureau1 =
12 Address
13 { addressText =
14 [ "3, place du Monument"
15 , "Mairie - Bureau 1"
16 ]
17 , addressCity = "Gentioux-Pigerolles"
18 , addressZipCode = "23340"
19 , addressCountry = Country.france
20 }
21
22 -- | Warning: the order of the constructors matters,
23 -- `Enum` being used to generate identifying numbers sent to entities.
24 data EntityId
25 = EntityJulmInfo
26 | EntityJulm
27 | EntityUrssaf
28 | EntityNixOSFoundationNGITeam
29 | EntityNixOSFoundation
30 | EntityNixOSFoundationFinance
31 | EntityUpwork
32 | EntityDanielRamirez
33 deriving (Eq, Ord, Show, Enum, Generic, NFData)
34
35 instance Doc.ToInline EntityId where
36 toInline = fromEnum >>> Doc.toInline
37
38 instance GetEntity EntityId where
39 getEntity entityId = case entityId of
40 EntityJulmInfo ->
41 (entity entityId)
42 { entityName = Just "julminfo"
43 , entityAddress = Just bureau1
44 , entitySIREN = Just "942798083"
45 , entityIBAN =
46 Just
47 IBAN
48 { ibanCountry = Country.france
49 , ibanCheckDigits = 18
50 , ibanBasicBankAccountNumber = "20041010082037353D02912"
51 }
52 }
53 EntityJulm ->
54 (entity entityId)
55 { entityName = Just "Julien Moutinho"
56 , entityEmail = Just "julm@sourcephile.fr"
57 -- , entityPhone = Just "+33 7 55 60 42 77"
58 }
59 EntityUrssaf ->
60 (entity entityId)
61 { entityName = Just "Urssaf"
62 , entityAddress = Nothing
63 , entitySIREN = Nothing
64 , entityIBAN = Nothing
65 }
66 EntityNixOSFoundation ->
67 (entity entityId)
68 { entityName = Just "Stichting NixOS Foundation"
69 , entityAddress =
70 Just
71 Address
72 { addressText =
73 [ "Korte Lijnbaanssteeg 1-4318"
74 ]
75 , addressZipCode = "1012 SL"
76 , addressCity = "Amsterdam"
77 , addressCountry = Country.netherlands
78 }
79 }
80 EntityNixOSFoundationNGITeam ->
81 (entity entityId)
82 { entityName = Just "Nix@NGI Team"
83 , entityEmail = Just "ngi@nixos.org"
84 }
85 EntityNixOSFoundationFinance ->
86 (entity entityId)
87 { entityEmail = Just "finance@nixos.org"
88 }
89 EntityUpwork ->
90 (entity entityId)
91 { entityName = Just "Upwork"
92 , entityAddress = Nothing
93 , entitySIREN = Nothing
94 , entityIBAN = Nothing
95 }
96 EntityDanielRamirez ->
97 (entity entityId)
98 { entityName = Just "Daniel Ramirez"
99 , entityEmail = Just "danielramirez5@protonmail.com"
100 }
101
102 instance GetOrganization EntityId where
103 getOrganization orgEntity = case orgEntity of
104 EntityJulmInfo ->
105 Organization
106 { orgEntity
107 , orgParts =
108 [ "Admin" := getOrganization EntityJulm
109 ]
110 }
111 EntityJulm ->
112 Organization{orgEntity, orgParts = []}
113 EntityUrssaf ->
114 Organization{orgEntity, orgParts = []}
115 EntityNixOSFoundation ->
116 Organization
117 { orgEntity
118 , orgParts =
119 [ "Admin" := getOrganization EntityNixOSFoundationFinance
120 , "Department" := getOrganization EntityNixOSFoundationNGITeam
121 ]
122 }
123 EntityNixOSFoundationFinance ->
124 Organization{orgEntity, orgParts = []}
125 EntityNixOSFoundationNGITeam ->
126 Organization
127 { orgEntity = EntityNixOSFoundationNGITeam
128 , orgParts =
129 [ "Admin" := getOrganization EntityDanielRamirez
130 ]
131 }
132 EntityUpwork ->
133 Organization
134 { orgEntity
135 , orgParts = []
136 }
137 EntityDanielRamirez ->
138 Organization
139 { orgEntity = EntityDanielRamirez
140 , orgParts = []
141 }