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