1 {-# LANGUAGE DeriveAnyClass #-}
2 {-# LANGUAGE OverloadedLists #-}
3 {-# LANGUAGE OverloadedStrings #-}
5 module Tests.Invoice where
7 import Data.List qualified as List
8 import Data.Map.Strict qualified as Map
9 import Data.Text.Lazy qualified as Text.Lazy
10 import Data.Time.Clock qualified as Time
11 import Data.Time.LocalTime qualified as Time
12 import Literate.Accounting
13 import Literate.Document qualified as Doc
14 import Literate.Document.HTML qualified as HTML
15 import Literate.Invoice
16 import Literate.Invoice.HTML qualified as HTML
17 import Literate.Prelude
19 import Tests.Organization qualified as Orga
20 import Tests.Utils.Tests
21 import Text.Blaze.Renderer.Text qualified as Blaze.Text
22 import Text.Blaze.Renderer.Utf8 qualified as Blaze
23 import Prelude (undefined, (*))
25 spec :: HasCallStack => Spec
27 -- aroundAll readDicts do
29 forM_ (invoices & Map.toList) \(invId, inv) -> do
30 let idS = invId & Doc.toInline & HTML.toHtml & Blaze.Text.renderMarkup & Text.Lazy.unpack
31 outPath <- goldenPath idS "html"
33 goldenByteStringBuilderFile outPath do
34 HTML.htmlIO (invId, inv) <&> Blaze.renderMarkupBuilder
36 works_NGIpkgs :: [Work]
39 { workDate = "2025-11-06"
41 , workAction = ["organization"]
42 , workScope = ["NGIpkgs"]
43 , workReferences = ["https://meet.google.com/hii-druc-tjp"]
44 , workDescription = "first meeting"
47 { workDate = "2025-11-06"
49 , workAction = ["development"]
50 , workScope = ["NGIpkgs", "Bonfire"]
51 , workReferences = ["https://github.com/ju1m/bonfire-app/commits/nix"]
52 , workDescription = "focus on the hardest part first"
55 { workDate = "2025-11-07"
57 , workAction = ["development"]
58 , workScope = ["NGIpkgs", "Bonfire"]
59 , workReferences = ["https://github.com/ju1m/bonfire-app/commits/nix"]
60 , workDescription = "continuing to package Bonfire deps"
63 { workDate = "2025-11-08"
65 , workAction = ["development"]
66 , workScope = ["Nixpkgs", "opencv"]
67 , workReferences = ["https://github.com/NixOS/nixpkgs/pull/459592"]
68 , workDescription = "fix opencv in nixpkgs"
71 { workDate = "2025-11-09"
73 , workAction = ["development"]
74 , workScope = ["NGIpkgs", "Bonfire"]
75 , workReferences = ["https://github.com/ju1m/bonfire-app/commits/nix"]
76 , workDescription = "continue to fix deps"
79 { workDate = "2025-11-09"
81 , workAction = ["development"]
82 , workScope = ["NGIpkgs", "Bonfire"]
83 , workReferences = ["https://github.com/ju1m/bonfire-app/commits/nix"]
84 , workDescription = "continue to fix deps"
87 { workDate = "2025-11-11"
89 , workAction = ["development"]
90 , workScope = ["NGIpkgs", "Bonfire"]
91 , workReferences = ["https://github.com/ju1m/bonfire-app/commits/nix"]
92 , workDescription = "continue to fix deps"
95 { workDate = "2025-11-12"
97 , workAction = ["development"]
98 , workScope = ["NGIpkgs", "Bonfire"]
99 , workReferences = ["https://github.com/ju1m/bonfire-app/commits/nix"]
100 , workDescription = "continue to fix deps"
103 { workDate = "2025-11-14"
105 , workAction = ["development"]
106 , workScope = ["NGIpkgs", "Bonfire"]
107 , workReferences = ["https://github.com/ngi-nix/ngipkgs/pull/1812"]
108 , workDescription = "continue to fix deps and move into ngipkgs"
111 { workDate = "2025-11-14"
113 , workAction = ["organization"]
114 , workScope = ["NGIpkgs"]
115 , workReferences = ["https://www.notion.so/nixos-foundation/Nix-NGI-weekly-review-34-2ab59d49e1be80939503c655b009e934"]
116 , workDescription = "weekly meeting"
119 { workDate = "2025-11-15"
121 , workAction = ["development"]
122 , workScope = ["NGIpkgs", "Bonfire"]
123 , workReferences = []
124 , workDescription = "finish to build Bonfire and start to fix runtime bugs"
127 { workDate = "2025-11-16"
129 , workAction = ["development"]
130 , workScope = ["NGIpkgs", "Bonfire"]
131 , workReferences = ["https://github.com/ngi-nix/ngipkgs/pull/1812#issuecomment-3537609170"]
132 , workDescription = "workaround and contribute upstream"
135 { workDate = "2025-11-17"
137 , workAction = ["development"]
138 , workScope = ["NGIpkgs", "Bonfire"]
139 , workReferences = []
140 , workDescription = "add updateScript and fix opencv"
143 { workDate = "2025-11-19"
145 , workAction = ["development"]
146 , workScope = ["NGIpkgs", "Bonfire"]
147 , workReferences = ["https://github.com/ngi-nix/ngipkgs/pull/1812#issuecomment-3554376221"]
148 , workDescription = "continue to fix startup crashes"
151 { workDate = "2025-11-21"
153 , workAction = ["development"]
154 , workScope = ["NGIpkgs", "Bonfire"]
155 , workReferences = []
156 , workDescription = "begin to package yarn assets. Upstream likes convoluted code and fake libraries."
159 { workDate = "2025-11-21"
161 , workAction = ["organization"]
162 , workScope = ["NGIpkgs"]
163 , workReferences = []
164 , workDescription = "weekly meeting"
167 { workDate = "2025-11-21"
169 , workAction = ["development"]
170 , workScope = ["NGIpkgs", "Bonfire"]
171 , workReferences = []
172 , workDescription = "continue to package assets"
175 { workDate = "2025-11-23"
177 , workAction = ["development"]
178 , workScope = ["NGIpkgs", "Bonfire"]
179 , workReferences = []
180 , workDescription = "continue to package assets and try to get Bonfire to work"
183 { workDate = "2025-11-24"
185 , workAction = ["development"]
186 , workScope = ["NGIpkgs", "Bonfire"]
187 , workReferences = ["https://github.com/surface-ui/surface/issues/762#issuecomment-3577030748"]
188 , workDescription = "continue to solve problems with Bonfire packaging"
191 { workDate = "2025-11-27"
193 , workAction = ["development"]
194 , workScope = ["NGIpkgs", "Bonfire"]
195 , workReferences = ["https://github.com/ngi-nix/ngipkgs/pull/1812#issuecomment-3584319056"]
196 , workDescription = "successfully auto-update and build Bonfire"
199 { workDate = "2025-11-28"
201 , workAction = ["organization"]
202 , workScope = ["NGIpkgs"]
203 , workReferences = ["https://www.notion.so/nixos-foundation/Nix-NGI-weekly-review-36-2b959d49e1be80fa823cd4d83581fda5#2b959d49e1be80fc85eed38c9a9dca86"]
204 , workDescription = "weekly meeting"
207 { workDate = "2025-11-29"
209 , workAction = ["development"]
210 , workScope = ["NGIpkgs", "Bonfire"]
211 , workReferences = []
212 , workDescription = "begin the service module"
215 { workDate = "2025-12-02"
217 , workAction = ["development"]
218 , workScope = ["NGIpkgs", "Bonfire"]
219 , workReferences = []
220 , workDescription = "continue the service module"
223 { workDate = "2025-12-03"
225 , workAction = ["development"]
226 , workScope = ["NGIpkgs", "Bonfire"]
227 , workReferences = []
228 , workDescription = "first working service module"
231 { workDate = "2025-12-04"
233 , workAction = ["development"]
234 , workScope = ["NGIpkgs", "Bonfire"]
235 , workReferences = ["https://github.com/ngi-nix/ngipkgs/pull/1871"]
236 , workDescription = "improve service module"
239 { workDate = "2025-12-05"
241 , workAction = ["organization"]
242 , workScope = ["NGIpkgs"]
243 , workReferences = ["https://www.notion.so/nixos-foundation/Nix-NGI-weekly-review-36-2b959d49e1be80fa823cd4d83581fda5"]
244 , workDescription = "weekly meeting"
247 { workDate = "2025-12-05"
249 , workAction = ["documentation"]
250 , workScope = ["NGIpkgs", "Manuals"]
251 , workReferences = ["https://github.com/ngi-nix/ngipkgs/pull/1954"]
252 , workDescription = "meeting"
255 { workDate = "2025-12-06"
257 , workAction = ["documentation"]
258 , workScope = ["NGIpkgs", "Manuals"]
259 , workReferences = []
260 , workDescription = "prepare wednesday meeting"
263 { workDate = "2025-12-07"
265 , workAction = ["documentation"]
266 , workScope = ["NGIpkgs", "Manuals"]
267 , workReferences = []
268 , workDescription = "prepare demo for wednesday meeting"
271 { workDate = "2025-12-08"
273 , workAction = ["documentation"]
274 , workScope = ["NGIpkgs", "Manuals"]
275 , workReferences = ["https://github.com/ngi-nix/ngipkgs/pull/1891"]
276 , workDescription = "prepare demo for wednesday meeting"
279 { workDate = "2025-12-09"
281 , workAction = ["documentation"]
282 , workScope = ["NGIpkgs", "Manuals"]
283 , workReferences = ["https://github.com/ngi-nix/ngipkgs/pull/1891"]
284 , workDescription = "continue to document"
287 { workDate = "2025-12-10"
289 , workAction = ["review"]
290 , workScope = ["NGIpkgs"]
291 , workReferences = ["https://www.notion.so/nixos-foundation/Nix-NGI-best-practices-for-NixOS-modules-implementation-2c559d49e1be80a8a499f21abb203d6f"]
292 , workDescription = "visio on “best practices”"
295 { workDate = "2025-12-12"
297 , workAction = ["organization"]
298 , workScope = ["NGIpkgs"]
299 , workReferences = []
300 , workDescription = "weekly visio meeting"
303 { workDate = "2025-12-11"
305 , workAction = ["documentation"]
306 , workScope = ["NGIpkgs", "Manuals"]
307 , workReferences = []
308 , workDescription = "continue to document"
311 { workDate = "2025-12-12"
313 , workAction = ["documentation"]
314 , workScope = ["NGIpkgs", "Manuals"]
315 , workReferences = []
316 , workDescription = "continue to document"
319 { workDate = "2025-12-13"
321 , workAction = ["documentation"]
322 , workScope = ["NGIpkgs", "Manuals"]
323 , workReferences = []
325 [ "setup sphinx like "
327 { Doc.inlineLinkTarget = "https://nix.dev"
328 , Doc.inlineLinkText = "nix.dev"
334 { workDate = "2025-12-13"
336 , workAction = ["development"]
337 , workScope = ["NGIpkgs", "Bonfire"]
338 , workReferences = ["https://github.com/bonfire-networks/bonfire-app/issues/1670#issuecomment-3650762914"]
339 , workDescription = "update to latest; overcoming new bugs introduced by upstream"
342 { workDate = "2025-12-15"
344 , workAction = ["development"]
345 , workScope = ["NGIpkgs", "Bonfire"]
346 , workReferences = []
347 , workDescription = "improving the update script and still overcoming upstream bugs"
350 { workDate = "2025-12-16"
352 , workAction = ["development"]
353 , workScope = ["NGIpkgs", "Bonfire"]
354 , workReferences = []
355 , workDescription = "overcoming bugs, again"
358 { workDate = "2025-12-16"
360 , workAction = ["review"]
361 , workScope = ["NGIpkgs"]
362 , workReferences = []
363 , workDescription = "visio to review PRs"
366 { workDate = "2025-12-16"
368 , workAction = ["review"]
369 , workScope = ["NGIpkgs"]
370 , workReferences = []
371 , workDescription = "visio to review PRs"
374 { workDate = "2025-12-17"
376 , workAction = ["review"]
377 , workScope = ["NGIpkgs"]
378 , workReferences = []
379 , workDescription = "visio to review PRs"
382 { workDate = "2025-12-18"
384 , workAction = ["review"]
385 , workScope = ["NGIpkgs", "dnsvizor"]
386 , workReferences = []
387 , workDescription = "review linj’s PR"
390 { workDate = "2025-12-19"
392 , workAction = ["organization"]
393 , workScope = ["NGIpkgs"]
394 , workReferences = []
395 , workDescription = "weekly meeting"
398 { workDate = "2025-12-21"
400 , workAction = ["development"]
401 , workScope = ["NGIpkgs", "Bonfire"]
402 , workReferences = []
405 , "__structuredAttrs" & Doc.InlineCode
409 { workDate = "2025-12-23"
411 , workAction = ["documentation"]
412 , workScope = ["NGIpkgs", "Manuals"]
413 , workReferences = []
414 , workDescription = "improve building the manuals"
417 { workDate = "2025-12-23"
419 , workAction = ["development"]
420 , workScope = ["NGIpkgs", "Bonfire"]
421 , workReferences = []
422 , workDescription = "address reviewers’ concerns"
425 { workDate = "2025-12-24"
427 , workAction = ["development"]
428 , workScope = ["NGIpkgs", "Bonfire"]
429 , workReferences = []
430 , workDescription = "update Bonfire and report issues upstream"
433 { workDate = "2025-12-24"
435 , workAction = ["documentation"]
436 , workScope = ["NGIpkgs", "Manuals"]
437 , workReferences = []
438 , workDescription = "document"
441 { workDate = "2025-12-24"
443 , workAction = ["development"]
444 , workScope = ["NGIpkgs", "Bonfire"]
445 , workReferences = []
446 , workDescription = "update Bonfire to fix bugs"
449 { workDate = "2025-12-25"
451 , workAction = ["documentation"]
452 , workScope = ["NGIpkgs", "Manuals"]
453 , workReferences = []
454 , workDescription = "document"
457 { workDate = "2025-12-25"
459 , workAction = ["development"]
460 , workScope = ["NGIpkgs", "Bonfire"]
461 , workReferences = ["https://github.com/bonfire-networks/bonfire-app/issues/1698#issuecomment-3692147409"]
462 , workDescription = "update and fix bugs"
465 { workDate = "2025-12-26"
467 , workAction = ["development"]
468 , workScope = ["NGIpkgs", "Bonfire"]
469 , workReferences = []
470 , workDescription = "update to fix bugs"
473 { workDate = "2025-12-28"
475 , workAction = ["documentation"]
476 , workScope = ["NGIpkgs", "Manuals"]
477 , workReferences = []
478 , workDescription = "document"
481 { workDate = "2025-12-29"
483 , workAction = ["development"]
484 , workScope = ["NGIpkgs", "Bonfire"]
485 , workReferences = []
486 , workDescription = "add more tests"
489 { workDate = "2025-12-29"
491 , workAction = ["review"]
492 , workScope = ["NGIpkgs", "Funkwhale"] -- goes into NGI Review
493 , workReferences = ["https://github.com/ngi-nix/ngipkgs/pull/1707#discussion_r2651644145"]
494 , workDescription = ""
497 { workDate = "2025-12-30"
499 , workAction = ["development"]
500 , workScope = ["NGIpkgs", "BEAM"]
501 , workReferences = []
502 , workDescription = ["improve ", Doc.InlineCode "buildMix", " & ", Doc.InlineCode "mixRelease", " for packaging Elixir software"]
505 { workDate = "2026-01-01"
507 , workAction = ["development"]
508 , workScope = ["NGIpkgs", "Bonfire"]
509 , workReferences = []
510 , workDescription = "support other flavours"
513 { workDate = "2026-01-03"
515 , workAction = ["development"]
516 , workScope = ["NGIpkgs", "Bonfire"]
517 , workReferences = []
518 , workDescription = "support other flavours, and make update more resilient"
521 { workDate = "2026-01-04"
523 , workAction = ["development"]
524 , workScope = ["NGIpkgs", "Bonfire"]
525 , workReferences = []
526 , workDescription = "provide upstream with reproducers"
529 { workDate = "2026-01-05"
531 , workAction = ["development"]
532 , workScope = ["NGIpkgs", "Bonfire"]
533 , workReferences = []
534 , workDescription = "update to latest version"
537 { workDate = "2026-01-07"
539 , workAction = ["development"]
540 , workScope = ["NGIpkgs", "Bonfire"]
541 , workReferences = []
542 , workDescription = "fix updating"
545 { workDate = "2026-01-07"
547 , workAction = ["documentation"]
548 , workScope = ["NGIpkgs", "Manuals"] -- goes into NGI Core
549 , workReferences = ["https://github.com/ngi-nix/ngipkgs/pull/1891"]
550 , workDescription = "address reviewer’s comment"
553 { workDate = "2026-01-09"
555 , workAction = ["documentation"]
556 , workScope = ["NGIpkgs", "Manuals"] -- goes into NGI Core
557 , workReferences = []
558 , workDescription = "address reviewer’s comments"
561 { workDate = "2026-01-09"
563 , workAction = ["development"]
564 , workScope = ["NGIpkgs", "Bonfire"]
565 , workReferences = ["https://github.com/bonfire-networks/bonfire-app/issues/1730"]
566 , workDescription = "answer upstream’s questions"
569 { workDate = "2026-01-11"
571 , workAction = ["development"]
572 , workScope = ["NGIpkgs", "dnsvizor"]
573 , workReferences = []
574 , workDescription = ["replace ", Doc.InlineCode "hillingar", " to package MirageOS unikernels"]
577 { workDate = "2026-01-09"
579 , workAction = ["organization"]
580 , workScope = ["NGIpkgs"]
581 , workReferences = []
582 , workDescription = "weekly meeting"
585 { workDate = "2026-01-12"
587 , workAction = ["development"]
588 , workScope = ["NGIpkgs", "dnsvizor"]
589 , workReferences = ["https://github.com/ju1m/ngipkgs/commits/dnsvizor/"]
590 , workDescription = ["remove the need for ", Doc.InlineCode "--allow-import-from-derivation"]
593 { workDate = "2026-01-12"
595 , workAction = ["documentation"]
596 , workScope = ["NGIpkgs", "Manuals"] -- goes into NGI Core
597 , workReferences = []
598 , workDescription = "render options"
601 { workDate = "2026-01-13"
603 , workAction = ["documentation"]
604 , workScope = ["NGIpkgs", "Manuals"] -- goes into NGI Core
605 , workReferences = []
606 , workDescription = "update"
609 { workDate = "2026-01-16"
611 , workAction = ["organization"]
612 , workScope = ["NGIpkgs"]
613 , workReferences = []
614 , workDescription = "weekly meeting"
617 { workDate = "2026-01-19"
619 , workAction = ["documentation"]
620 , workScope = ["NGIpkgs", "Manuals"] -- goes into NGI Core
621 , workReferences = []
622 , workDescription = "split into several PDF"
625 { workDate = "2026-01-22"
627 , workAction = ["development"]
628 , workScope = ["NGIpkgs", "Manuals"] -- goes into NGI Core
629 , workReferences = ["https://github.com/ngi-nix/ngipkgs/pull/2010"]
630 , workDescription = "address reviewers’ concerns"
633 { workDate = "2026-01-23"
635 , workAction = ["organization"]
636 , workScope = ["NGIpkgs"]
637 , workReferences = []
638 , workDescription = "weekly meeting"
641 { workDate = "2026-01-25"
643 , workAction = ["development"]
644 , workScope = ["NGIpkgs", "Seppo"]
645 , workReferences = []
646 , workDescription = "begin packaging"
649 { workDate = "2026-01-26"
651 , workAction = ["development"]
652 , workScope = ["NGIpkgs", "Seppo"]
653 , workReferences = []
654 , workDescription = "continue packaging"
657 { workDate = "2026-01-27"
659 , workAction = ["development"]
660 , workScope = ["NGIpkgs", "Seppo"]
661 , workReferences = []
662 , workDescription = "continue packaging"
666 invoiceRate_NGIpkgs =
667 [ ["organization"] := 31.25
668 , ["development"] := 31.25
669 , ["documentation"] := 31.25
670 , ["review"] := 31.25
675 { invoiceIdRecipient = Orga.nixosFoundationNGITeam
676 , invoiceIdType = InvoiceTypeSale
679 := let invoiceEmittedOn = "2026-01-22"
681 { invoiceOrders = ["Contract n°2025-24"]
683 , invoicePaymentDueBefore = invoiceEmittedOn & Time.addLocalTime (31 * Time.nominalDay)
684 , invoiceIssuer = Orga.julmInfo
685 , invoiceRecipient = Orga.nixosFoundationNGITeam
686 , invoiceRates = invoiceRate_NGIpkgs
688 [ InvoiceMentionTVANonApplicable
689 , InvoiceMentionIndemnitéForfaitaire
690 , InvoiceMentionIndemnitéTaux (12.15 :: Amount 100 (UnitName "%"))
694 & List.filter \work ->
697 [ work & workDate & (>= "2025-11-06")
698 , work & workDate & (<= "2025-12-22")
699 , work & workScope & (/= ["NGIpkgs", "Manuals"])
704 { invoiceIdRecipient = Orga.nixosFoundationNGITeam
705 , invoiceIdType = InvoiceTypeSale
708 := let invoiceEmittedOn = "2026-01-27"
710 { invoiceOrders = ["contract n°2026-03"]
712 , invoicePaymentDueBefore = invoiceEmittedOn & Time.addLocalTime (31 * Time.nominalDay)
713 , invoiceIssuer = Orga.julmInfo
714 , invoiceRecipient = Orga.nixosFoundationNGITeam
715 , invoiceRates = invoiceRate_NGIpkgs
717 [ InvoiceMentionTVANonApplicable
718 , InvoiceMentionIndemnitéForfaitaire
719 , InvoiceMentionIndemnitéTaux (12.15 :: Amount 100 (UnitName "%"))
723 & List.filter \work ->
725 [ work & workDate & (>= "2025-12-23")
726 , work & workDate & (<= "2026-12-31")
727 , work & workScope & (/= ["NGIpkgs", "Manuals"])
728 , work & workScope & (/= ["NGIpkgs", "Funkwhale"])
731 [ work & workDate & (>= "2026-01-09")
732 , work & workDate & (<= "2026-01-28")
733 , work & workAction & (== ["organization"])
734 , work & workScope & (== ["NGIpkgs"])
742 { invoiceIdRecipient = Orga.nixosFoundationNGITeam
743 , invoiceIdType = InvoiceTypeSale
746 := let invoiceEmittedOn = "2026-01-28"
748 { invoiceOrders = ["contract n°2026-FixMe"]
750 , invoicePaymentDueBefore = invoiceEmittedOn & Time.addLocalTime (31 * Time.nominalDay)
751 , invoiceIssuer = Orga.julmInfo
752 , invoiceRecipient = Orga.nixosFoundationNGITeam
753 , invoiceRates = invoiceRate_NGIpkgs
755 [ InvoiceMentionTVANonApplicable
756 , InvoiceMentionIndemnitéForfaitaire
757 , InvoiceMentionIndemnitéTaux (12.15 :: Amount 100 (UnitName "%"))
761 & List.filter \work ->
764 [ work & workDate & (>= "2026-01-21")
765 , work & workDate & (<= "2026-12-31")
766 , work & workScope & (== ["NGIpkgs", "Manuals"])
770 [ work & workDate & (>= "2025-12-29")
771 , work & workDate & (<= "2026-12-31")
772 , work & workScope & (== ["NGIpkgs", "Funkwhale"])
776 [ work & workDate & (>= "2026-01-09")
777 , work & workDate & (<= "2026-01-28")
778 , work & workAction & (== ["organization"])
779 , work & workScope & (== ["NGIpkgs"])
792 & Map.fromListWith undefined