1 {-# LANGUAGE DeriveAnyClass #-}
2 {-# LANGUAGE OverloadedLists #-}
3 {-# LANGUAGE OverloadedStrings #-}
5 module Tests.Invoice where
7 import Data.List qualified as List
8 import Data.Text.Lazy qualified as Text.Lazy
9 import Data.Time.Clock qualified as Time
10 import Data.Time.LocalTime qualified as Time
11 import Literate.Accounting (Amount, Unit (UnitName))
12 import Literate.Document qualified as Doc
13 import Literate.Document.HTML qualified as HTML
14 import Literate.Invoice
15 import Literate.Invoice.HTML (invoiceIdInline)
16 import Literate.Invoice.HTML qualified as HTML
17 import Literate.Prelude
18 import Test.Syd (Spec, describe, goldenByteStringBuilderFile, it)
19 import Tests.Organization qualified as Orga
20 import Tests.Utils.Tests (goldenPath)
21 import Text.Blaze.Renderer.Text qualified as Blaze.Text
22 import Text.Blaze.Renderer.Utf8 qualified as Blaze
25 spec :: HasCallStack => Spec
27 -- aroundAll readDicts do
29 forM_ invoices \invId -> do
31 inv = invId & getInvoice @Orga.EntityId
36 & Blaze.Text.renderMarkup
38 outPath <- goldenPath idS "html"
40 goldenByteStringBuilderFile outPath do
41 inv & HTML.htmlIO <&> Blaze.renderMarkupBuilder
43 works_NGIpkgs :: [Work]
46 { workDate = "2025-11-06"
48 , workAction = ["organization"]
49 , workScope = ["NGIpkgs"]
50 , workReferences = ["https://meet.google.com/hii-druc-tjp"]
51 , workDescription = "first meeting"
54 { workDate = "2025-11-06"
56 , workAction = ["development"]
57 , workScope = ["NGIpkgs", "Bonfire"]
58 , workReferences = ["https://github.com/ju1m/bonfire-app/commits/nix"]
59 , workDescription = "focus on the hardest part first"
62 { workDate = "2025-11-07"
64 , workAction = ["development"]
65 , workScope = ["NGIpkgs", "Bonfire"]
66 , workReferences = ["https://github.com/ju1m/bonfire-app/commits/nix"]
67 , workDescription = "continuing to package Bonfire deps"
70 { workDate = "2025-11-08"
72 , workAction = ["development"]
73 , workScope = ["Nixpkgs", "opencv"]
74 , workReferences = ["https://github.com/NixOS/nixpkgs/pull/459592"]
75 , workDescription = "fix opencv in nixpkgs"
78 { workDate = "2025-11-09"
80 , workAction = ["development"]
81 , workScope = ["NGIpkgs", "Bonfire"]
82 , workReferences = ["https://github.com/ju1m/bonfire-app/commits/nix"]
83 , workDescription = "continue to fix deps"
86 { workDate = "2025-11-09"
88 , workAction = ["development"]
89 , workScope = ["NGIpkgs", "Bonfire"]
90 , workReferences = ["https://github.com/ju1m/bonfire-app/commits/nix"]
91 , workDescription = "continue to fix deps"
94 { workDate = "2025-11-11"
96 , workAction = ["development"]
97 , workScope = ["NGIpkgs", "Bonfire"]
98 , workReferences = ["https://github.com/ju1m/bonfire-app/commits/nix"]
99 , workDescription = "continue to fix deps"
102 { workDate = "2025-11-12"
104 , workAction = ["development"]
105 , workScope = ["NGIpkgs", "Bonfire"]
106 , workReferences = ["https://github.com/ju1m/bonfire-app/commits/nix"]
107 , workDescription = "continue to fix deps"
110 { workDate = "2025-11-14"
112 , workAction = ["development"]
113 , workScope = ["NGIpkgs", "Bonfire"]
114 , workReferences = ["https://github.com/ngi-nix/ngipkgs/pull/1812"]
115 , workDescription = "continue to fix deps and move into ngipkgs"
118 { workDate = "2025-11-14"
120 , workAction = ["organization"]
121 , workScope = ["NGIpkgs"]
122 , workReferences = ["https://www.notion.so/nixos-foundation/Nix-NGI-weekly-review-34-2ab59d49e1be80939503c655b009e934"]
123 , workDescription = "weekly meeting"
126 { workDate = "2025-11-15"
128 , workAction = ["development"]
129 , workScope = ["NGIpkgs", "Bonfire"]
130 , workReferences = []
131 , workDescription = "finish to build Bonfire and start to fix runtime bugs"
134 { workDate = "2025-11-16"
136 , workAction = ["development"]
137 , workScope = ["NGIpkgs", "Bonfire"]
138 , workReferences = ["https://github.com/ngi-nix/ngipkgs/pull/1812#issuecomment-3537609170"]
139 , workDescription = "workaround and contribute upstream"
142 { workDate = "2025-11-17"
144 , workAction = ["development"]
145 , workScope = ["NGIpkgs", "Bonfire"]
146 , workReferences = []
147 , workDescription = "add updateScript and fix opencv"
150 { workDate = "2025-11-19"
152 , workAction = ["development"]
153 , workScope = ["NGIpkgs", "Bonfire"]
154 , workReferences = ["https://github.com/ngi-nix/ngipkgs/pull/1812#issuecomment-3554376221"]
155 , workDescription = "continue to fix startup crashes"
158 { workDate = "2025-11-21"
160 , workAction = ["development"]
161 , workScope = ["NGIpkgs", "Bonfire"]
162 , workReferences = []
163 , workDescription = "begin to package yarn assets. Upstream likes convoluted code and fake libraries."
166 { workDate = "2025-11-21"
168 , workAction = ["organization"]
169 , workScope = ["NGIpkgs"]
170 , workReferences = []
171 , workDescription = "weekly meeting"
174 { workDate = "2025-11-21"
176 , workAction = ["development"]
177 , workScope = ["NGIpkgs", "Bonfire"]
178 , workReferences = []
179 , workDescription = "continue to package assets"
182 { workDate = "2025-11-23"
184 , workAction = ["development"]
185 , workScope = ["NGIpkgs", "Bonfire"]
186 , workReferences = []
187 , workDescription = "continue to package assets and try to get Bonfire to work"
190 { workDate = "2025-11-24"
192 , workAction = ["development"]
193 , workScope = ["NGIpkgs", "Bonfire"]
194 , workReferences = ["https://github.com/surface-ui/surface/issues/762#issuecomment-3577030748"]
195 , workDescription = "continue to solve problems with Bonfire packaging"
198 { workDate = "2025-11-27"
200 , workAction = ["development"]
201 , workScope = ["NGIpkgs", "Bonfire"]
202 , workReferences = ["https://github.com/ngi-nix/ngipkgs/pull/1812#issuecomment-3584319056"]
203 , workDescription = "successfully auto-update and build Bonfire"
206 { workDate = "2025-11-28"
208 , workAction = ["organization"]
209 , workScope = ["NGIpkgs"]
210 , workReferences = ["https://www.notion.so/nixos-foundation/Nix-NGI-weekly-review-36-2b959d49e1be80fa823cd4d83581fda5#2b959d49e1be80fc85eed38c9a9dca86"]
211 , workDescription = "weekly meeting"
214 { workDate = "2025-11-29"
216 , workAction = ["development"]
217 , workScope = ["NGIpkgs", "Bonfire"]
218 , workReferences = []
219 , workDescription = "begin the service module"
222 { workDate = "2025-12-02"
224 , workAction = ["development"]
225 , workScope = ["NGIpkgs", "Bonfire"]
226 , workReferences = []
227 , workDescription = "continue the service module"
230 { workDate = "2025-12-03"
232 , workAction = ["development"]
233 , workScope = ["NGIpkgs", "Bonfire"]
234 , workReferences = []
235 , workDescription = "first working service module"
238 { workDate = "2025-12-04"
240 , workAction = ["development"]
241 , workScope = ["NGIpkgs", "Bonfire"]
242 , workReferences = ["https://github.com/ngi-nix/ngipkgs/pull/1871"]
243 , workDescription = "improve service module"
246 { workDate = "2025-12-05"
248 , workAction = ["organization"]
249 , workScope = ["NGIpkgs"]
250 , workReferences = ["https://www.notion.so/nixos-foundation/Nix-NGI-weekly-review-36-2b959d49e1be80fa823cd4d83581fda5"]
251 , workDescription = "weekly meeting"
254 { workDate = "2025-12-05"
256 , workAction = ["documentation"]
257 , workScope = ["NGIpkgs", "Manuals"]
258 , workReferences = ["https://github.com/ngi-nix/ngipkgs/pull/1954"]
259 , workDescription = "meeting"
262 { workDate = "2025-12-06"
264 , workAction = ["documentation"]
265 , workScope = ["NGIpkgs", "Manuals"]
266 , workReferences = []
267 , workDescription = "prepare wednesday meeting"
270 { workDate = "2025-12-07"
272 , workAction = ["documentation"]
273 , workScope = ["NGIpkgs", "Manuals"]
274 , workReferences = []
275 , workDescription = "prepare demo for wednesday meeting"
278 { workDate = "2025-12-08"
280 , workAction = ["documentation"]
281 , workScope = ["NGIpkgs", "Manuals"]
282 , workReferences = ["https://github.com/ngi-nix/ngipkgs/pull/1891"]
283 , workDescription = "prepare demo for wednesday meeting"
286 { workDate = "2025-12-09"
288 , workAction = ["documentation"]
289 , workScope = ["NGIpkgs", "Manuals"]
290 , workReferences = ["https://github.com/ngi-nix/ngipkgs/pull/1891"]
291 , workDescription = "continue to document"
294 { workDate = "2025-12-10"
296 , workAction = ["review"]
297 , workScope = ["NGIpkgs"]
298 , workReferences = ["https://www.notion.so/nixos-foundation/Nix-NGI-best-practices-for-NixOS-modules-implementation-2c559d49e1be80a8a499f21abb203d6f"]
299 , workDescription = "visio on “best practices”"
302 { workDate = "2025-12-12"
304 , workAction = ["organization"]
305 , workScope = ["NGIpkgs"]
306 , workReferences = []
307 , workDescription = "weekly visio meeting"
310 { workDate = "2025-12-11"
312 , workAction = ["documentation"]
313 , workScope = ["NGIpkgs", "Manuals"]
314 , workReferences = []
315 , workDescription = "continue to document"
318 { workDate = "2025-12-12"
320 , workAction = ["documentation"]
321 , workScope = ["NGIpkgs", "Manuals"]
322 , workReferences = []
323 , workDescription = "continue to document"
326 { workDate = "2025-12-13"
328 , workAction = ["documentation"]
329 , workScope = ["NGIpkgs", "Manuals"]
330 , workReferences = []
332 [ "setup sphinx like "
334 { Doc.inlineLinkTarget = "https://nix.dev"
335 , Doc.inlineLinkText = "nix.dev"
341 { workDate = "2025-12-13"
343 , workAction = ["development"]
344 , workScope = ["NGIpkgs", "Bonfire"]
345 , workReferences = ["https://github.com/bonfire-networks/bonfire-app/issues/1670#issuecomment-3650762914"]
346 , workDescription = "update to latest; overcoming new bugs introduced by upstream"
349 { workDate = "2025-12-15"
351 , workAction = ["development"]
352 , workScope = ["NGIpkgs", "Bonfire"]
353 , workReferences = []
354 , workDescription = "improving the update script and still overcoming upstream bugs"
357 { workDate = "2025-12-16"
359 , workAction = ["development"]
360 , workScope = ["NGIpkgs", "Bonfire"]
361 , workReferences = []
362 , workDescription = "overcoming bugs, again"
365 { workDate = "2025-12-16"
367 , workAction = ["review"]
368 , workScope = ["NGIpkgs"]
369 , workReferences = []
370 , workDescription = "visio to review PRs"
373 { workDate = "2025-12-16"
375 , workAction = ["review"]
376 , workScope = ["NGIpkgs"]
377 , workReferences = []
378 , workDescription = "visio to review PRs"
381 { workDate = "2025-12-17"
383 , workAction = ["review"]
384 , workScope = ["NGIpkgs"]
385 , workReferences = []
386 , workDescription = "visio to review PRs"
389 { workDate = "2025-12-18"
391 , workAction = ["review"]
392 , workScope = ["NGIpkgs", "dnsvizor"]
393 , workReferences = []
394 , workDescription = "review linj’s PR"
397 { workDate = "2025-12-19"
399 , workAction = ["organization"]
400 , workScope = ["NGIpkgs"]
401 , workReferences = []
402 , workDescription = "weekly meeting"
405 { workDate = "2025-12-21"
407 , workAction = ["development"]
408 , workScope = ["NGIpkgs", "Bonfire"]
409 , workReferences = []
412 , "__structuredAttrs" & Doc.InlineCode
416 { workDate = "2025-12-23"
418 , workAction = ["documentation"]
419 , workScope = ["NGIpkgs", "Manuals"]
420 , workReferences = []
421 , workDescription = "improve building the manuals"
424 { workDate = "2025-12-23"
426 , workAction = ["development"]
427 , workScope = ["NGIpkgs", "Bonfire"]
428 , workReferences = []
429 , workDescription = "address reviewers’ concerns"
432 { workDate = "2025-12-24"
434 , workAction = ["development"]
435 , workScope = ["NGIpkgs", "Bonfire"]
436 , workReferences = []
437 , workDescription = "update Bonfire and report issues upstream"
440 { workDate = "2025-12-24"
442 , workAction = ["documentation"]
443 , workScope = ["NGIpkgs", "Manuals"]
444 , workReferences = []
445 , workDescription = "document"
448 { workDate = "2025-12-24"
450 , workAction = ["development"]
451 , workScope = ["NGIpkgs", "Bonfire"]
452 , workReferences = []
453 , workDescription = "update Bonfire to fix bugs"
456 { workDate = "2025-12-25"
458 , workAction = ["documentation"]
459 , workScope = ["NGIpkgs", "Manuals"]
460 , workReferences = []
461 , workDescription = "document"
464 { workDate = "2025-12-25"
466 , workAction = ["development"]
467 , workScope = ["NGIpkgs", "Bonfire"]
468 , workReferences = ["https://github.com/bonfire-networks/bonfire-app/issues/1698#issuecomment-3692147409"]
469 , workDescription = "update and fix bugs"
472 { workDate = "2025-12-26"
474 , workAction = ["development"]
475 , workScope = ["NGIpkgs", "Bonfire"]
476 , workReferences = []
477 , workDescription = "update to fix bugs"
480 { workDate = "2025-12-28"
482 , workAction = ["documentation"]
483 , workScope = ["NGIpkgs", "Manuals"]
484 , workReferences = []
485 , workDescription = "document"
488 { workDate = "2025-12-29"
490 , workAction = ["development"]
491 , workScope = ["NGIpkgs", "Bonfire"]
492 , workReferences = []
493 , workDescription = "add more tests"
496 { workDate = "2025-12-29"
498 , workAction = ["review"]
499 , workScope = ["NGIpkgs", "Funkwhale"] -- goes into NGI Review
500 , workReferences = ["https://github.com/ngi-nix/ngipkgs/pull/1707#discussion_r2651644145"]
501 , workDescription = ""
504 { workDate = "2025-12-30"
506 , workAction = ["development"]
507 , workScope = ["NGIpkgs", "BEAM"]
508 , workReferences = []
509 , workDescription = ["improve ", Doc.InlineCode "buildMix", " & ", Doc.InlineCode "mixRelease", " for packaging Elixir software"]
512 { workDate = "2026-01-01"
514 , workAction = ["development"]
515 , workScope = ["NGIpkgs", "Bonfire"]
516 , workReferences = []
517 , workDescription = "support other flavours"
520 { workDate = "2026-01-03"
522 , workAction = ["development"]
523 , workScope = ["NGIpkgs", "Bonfire"]
524 , workReferences = []
525 , workDescription = "support other flavours, and make update more resilient"
528 { workDate = "2026-01-04"
530 , workAction = ["development"]
531 , workScope = ["NGIpkgs", "Bonfire"]
532 , workReferences = []
533 , workDescription = "provide upstream with reproducers"
536 { workDate = "2026-01-05"
538 , workAction = ["development"]
539 , workScope = ["NGIpkgs", "Bonfire"]
540 , workReferences = []
541 , workDescription = "update to latest version"
544 { workDate = "2026-01-07"
546 , workAction = ["development"]
547 , workScope = ["NGIpkgs", "Bonfire"]
548 , workReferences = []
549 , workDescription = "fix updating"
552 { workDate = "2026-01-07"
554 , workAction = ["documentation"]
555 , workScope = ["NGIpkgs", "Manuals"] -- goes into NGI Core
556 , workReferences = ["https://github.com/ngi-nix/ngipkgs/pull/1891"]
557 , workDescription = "address reviewer’s comment"
560 { workDate = "2026-01-09"
562 , workAction = ["documentation"]
563 , workScope = ["NGIpkgs", "Manuals"] -- goes into NGI Core
564 , workReferences = []
565 , workDescription = "address reviewer’s comments"
568 { workDate = "2026-01-09"
570 , workAction = ["development"]
571 , workScope = ["NGIpkgs", "Bonfire"]
572 , workReferences = ["https://github.com/bonfire-networks/bonfire-app/issues/1730"]
573 , workDescription = "answer upstream’s questions"
576 { workDate = "2026-01-11"
578 , workAction = ["development"]
579 , workScope = ["NGIpkgs", "dnsvizor"]
580 , workReferences = []
581 , workDescription = ["replace ", Doc.InlineCode "hillingar", " to package MirageOS unikernels"]
584 { workDate = "2026-01-09"
586 , workAction = ["organization"]
587 , workScope = ["NGIpkgs"]
588 , workReferences = []
589 , workDescription = "weekly meeting"
592 { workDate = "2026-01-12"
594 , workAction = ["development"]
595 , workScope = ["NGIpkgs", "dnsvizor"]
596 , workReferences = ["https://github.com/ju1m/ngipkgs/commits/dnsvizor/"]
597 , workDescription = ["remove the need for ", Doc.InlineCode "--allow-import-from-derivation"]
600 { workDate = "2026-01-12"
602 , workAction = ["documentation"]
603 , workScope = ["NGIpkgs", "Manuals"] -- goes into NGI Core
604 , workReferences = []
605 , workDescription = "render options"
608 { workDate = "2026-01-13"
610 , workAction = ["documentation"]
611 , workScope = ["NGIpkgs", "Manuals"] -- goes into NGI Core
612 , workReferences = []
613 , workDescription = "update"
616 { workDate = "2026-01-16"
618 , workAction = ["organization"]
619 , workScope = ["NGIpkgs"]
620 , workReferences = []
621 , workDescription = "weekly meeting"
624 { workDate = "2026-01-19"
626 , workAction = ["documentation"]
627 , workScope = ["NGIpkgs", "Manuals"] -- goes into NGI Core
628 , workReferences = []
629 , workDescription = "split into several PDF"
632 { workDate = "2026-01-22"
634 , workAction = ["development"]
635 , workScope = ["NGIpkgs", "Manuals"] -- goes into NGI Core
636 , workReferences = ["https://github.com/ngi-nix/ngipkgs/pull/2010"]
637 , workDescription = "address reviewers’ concerns"
640 { workDate = "2026-01-23"
642 , workAction = ["organization"]
643 , workScope = ["NGIpkgs"]
644 , workReferences = []
645 , workDescription = "weekly meeting"
648 { workDate = "2026-01-25"
650 , workAction = ["development"]
651 , workScope = ["NGIpkgs", "Seppo"]
652 , workReferences = []
653 , workDescription = "begin packaging"
656 { workDate = "2026-01-26"
658 , workAction = ["development"]
659 , workScope = ["NGIpkgs", "Seppo"]
660 , workReferences = []
661 , workDescription = "continue packaging"
664 { workDate = "2026-01-27"
666 , workAction = ["development"]
667 , workScope = ["NGIpkgs", "Seppo"]
668 , workReferences = []
669 , workDescription = "continue packaging"
677 deriving (Eq, Ord, Show, Generic, Enum, NFData)
679 invoiceRate_NGIpkgs =
680 [ ["organization"] := 31.25
681 , ["development"] := 31.25
682 , ["documentation"] := 31.25
683 , ["review"] := 31.25
686 instance GetInvoice Orga.EntityId InvoiceId where
687 getInvoice invoiceId = case invoiceId of
691 , invoiceType = InvoiceTypeSale
692 , invoiceOrders = ["Contract n°2025-24"]
694 , invoicePaymentDueBefore = invoiceEmittedOn & Time.addLocalTime (31 * Time.nominalDay)
695 , invoiceIssuer = Orga.EntityJulmInfo
696 , invoiceRecipient = Orga.EntityNixOSFoundationNGITeam
697 , invoiceRates = invoiceRate_NGIpkgs
699 [ InvoiceMentionTVANonApplicable
700 , InvoiceMentionIndemnitéForfaitaire
701 , InvoiceMentionIndemnitéTaux (12.15 :: Amount 100 (UnitName "%"))
705 & List.filter \work ->
708 [ work & workDate & (>= "2025-11-06")
709 , work & workDate & (<= "2025-12-22")
710 , work & workScope & (/= ["NGIpkgs", "Manuals"])
714 invoiceEmittedOn = "2026-01-22"
718 , invoiceType = InvoiceTypeSale
719 , invoiceOrders = ["contract n°2026-03"]
721 , invoicePaymentDueBefore = invoiceEmittedOn & Time.addLocalTime (31 * Time.nominalDay)
722 , invoiceIssuer = Orga.EntityJulmInfo
723 , invoiceRecipient = Orga.EntityNixOSFoundationNGITeam
724 , invoiceRates = invoiceRate_NGIpkgs
726 [ InvoiceMentionTVANonApplicable
727 , InvoiceMentionIndemnitéForfaitaire
728 , InvoiceMentionIndemnitéTaux (12.15 :: Amount 100 (UnitName "%"))
732 & List.filter \work ->
734 [ work & workDate & (>= "2025-12-23")
735 , work & workDate & (<= "2026-12-31")
736 , work & workScope & (/= ["NGIpkgs", "Manuals"])
737 , work & workScope & (/= ["NGIpkgs", "Funkwhale"])
740 [ work & workDate & (>= "2026-01-09")
741 , work & workDate & (<= "2026-01-28")
742 , work & workAction & (== ["organization"])
743 , work & workScope & (== ["NGIpkgs"])
750 invoiceEmittedOn = "2026-01-27"
754 , invoiceType = InvoiceTypeSale
755 , invoiceOrders = ["contract n°2026-FixMe"]
757 , invoicePaymentDueBefore = invoiceEmittedOn & Time.addLocalTime (31 * Time.nominalDay)
758 , invoiceIssuer = Orga.EntityJulmInfo
759 , invoiceRecipient = Orga.EntityNixOSFoundationNGITeam
760 , invoiceRates = invoiceRate_NGIpkgs
762 [ InvoiceMentionTVANonApplicable
763 , InvoiceMentionIndemnitéForfaitaire
764 , InvoiceMentionIndemnitéTaux (12.15 :: Amount 100 (UnitName "%"))
768 & List.filter \work ->
771 [ work & workDate & (>= "2026-01-21")
772 , work & workDate & (<= "2026-12-31")
773 , work & workScope & (== ["NGIpkgs", "Manuals"])
777 [ work & workDate & (>= "2025-12-29")
778 , work & workDate & (<= "2026-12-31")
779 , work & workScope & (== ["NGIpkgs", "Funkwhale"])
783 [ work & workDate & (>= "2026-01-09")
784 , work & workDate & (<= "2026-01-28")
785 , work & workAction & (== ["organization"])
786 , work & workScope & (== ["NGIpkgs"])
793 invoiceEmittedOn = "2026-01-28"
795 invoices :: [InvoiceId]