1 {-# LANGUAGE OverloadedLists #-}
2 {-# LANGUAGE OverloadedStrings #-}
4 module Tests.Invoice where
6 import Data.Map.Strict qualified as Map
7 import Data.Text.Lazy qualified as Text.Lazy
8 import Literate.Accounting.Math
9 import Literate.Document qualified as Doc
10 import Literate.Document.HTML qualified as HTML
11 import Literate.Invoice.HTML qualified as HTML
12 import Literate.Invoice.Invoice
13 import Literate.Prelude
15 import Tests.Entity qualified
16 import Tests.Utils.Tests
17 import Text.Blaze.Renderer.Text qualified as Blaze.Text
18 import Text.Blaze.Renderer.Utf8 qualified as Blaze
19 import Prelude (undefined)
21 spec :: HasCallStack => Spec
23 -- aroundAll readDicts do
25 forM_ (invoices & Map.toList) \(invId, inv) -> do
26 let idS = invId & HTML.toHtml & Blaze.Text.renderMarkup & Text.Lazy.unpack
27 outPath <- goldenPath idS "html"
29 goldenByteStringBuilderFile outPath do
30 HTML.htmlIO (invId, inv) <&> Blaze.renderMarkupBuilder
34 [ InvoiceId{invoiceIdBuyer = Tests.Entity.nixosFoundationNGITeam, invoiceIdCount = 1} :=
36 { invoiceCreation = "2026-01-09"
37 , invoiceIssuer = Tests.Entity.julmInfo
38 , invoiceRecipient = Tests.Entity.nixosFoundationNGITeam
39 , invoiceCustomer = Tests.Entity.nixosFoundationNGITeam
40 , invoiceObjet = "Test"
44 { invoiceItemDescription = "Organize work"
45 , invoiceItemRate = 31.25
46 , invoiceItemPeriod = Period{periodBegin = "2025-11-15", periodEnd = "2025-12-15"}
47 , invoiceItemQuantity = 0.5 + 1 + 1 + 1 + 1 + 1
50 { invoiceItemDescription = "Share knowledge"
51 , invoiceItemPeriod = Period{periodBegin = "2025-11-15", periodEnd = "2025-12-15"}
52 , invoiceItemRate = 31.25
53 , invoiceItemQuantity = 0.5 + 1 + 2
56 { invoiceItemDescription = "Review others' work"
57 , invoiceItemPeriod = Period{periodBegin = "2025-11-15", periodEnd = "2025-12-15"}
58 , invoiceItemRate = 31.25
59 , invoiceItemQuantity = 2 + 2 + 1.5 + 1 + 0.5
62 { invoiceItemDescription =
63 [ "Make a package for Bonfire in NGIpkgs"
64 , Doc.inlineLinkExplicit "https://github.com/ngi-nix/ngipkgs/pull/1812" & Doc.toBlock
66 , invoiceItemPeriod = Period{periodBegin = "2025-11-15", periodEnd = "2025-12-15"}
67 , invoiceItemRate = 31.25
68 , invoiceItemQuantity = 4 + 8 + 0.1 + 8 + 4 + 6 + 4 + 5 + 6 + 4 + 8 + 8 + 4 + 4 + 4 + 10 + 8 + 5 + 4
71 { invoiceItemDescription =
72 [ "Make a service for Bonfire in NGIpkgs"
73 , Doc.inlineLinkExplicit "https://github.com/ngi-nix/ngipkgs/pull/1871" & Doc.toBlock
75 , invoiceItemPeriod = Period{periodBegin = "2025-11-15", periodEnd = "2025-12-15"}
76 , invoiceItemRate = 31.25
77 , invoiceItemQuantity = 5 + 4 + 8 + 5 + 2 + 4
81 { invoiceItemDescription = "Make manuals for NGIpkgs"
83 , invoiceItemQuantity = 0.5 + 2 + 4 + 4 + 4 + 8 + 4 + 2 + 4 + 4 + 2 + 6 + 1 + 2
87 , invoiceMentions = [InvoiceMentionTVANonApplicable]
89 , InvoiceId{invoiceIdBuyer = Tests.Entity.nixosFoundationNGITeam, invoiceIdCount = 2} :=
91 { invoiceCreation = "2026-01-09"
92 , invoiceIssuer = Tests.Entity.julmInfo
93 , invoiceRecipient = Tests.Entity.nixosFoundationNGITeam
94 , invoiceCustomer = Tests.Entity.nixosFoundationNGITeam
95 , invoiceObjet = "Test"
100 { invoiceItemDescription = ""
101 , invoiceItemQuantity = 0
102 , invoiceItemPeriod = Period{periodBegin = "2026-01-01", periodEnd = "2026-01-11"}
103 , invoiceItemRate = 31.25
106 { invoiceItemDescription = "Organize work"
107 , invoiceItemQuantity = 2
110 { invoiceItemDescription =
111 [ "Make a package for Bonfire in NGIpkgs"
112 , Doc.inlineLinkExplicit "https://github.com/ngi-nix/ngipkgs/pull/1812" & Doc.toBlock
114 , invoiceItemQuantity = 3 + 4 + 2 + 4 + 2 + 6 + 1 + 4 + 4 + 2 + 2 + 5 + 2
117 { invoiceItemDescription =
119 , Doc.InlineCode "import-from-derivation"
120 , " for Mirage unikernels in NGIpkgs and opam-nix"
123 , Doc.inlineLinkExplicit "https://github.com/linj-fork/ngipkgs/pull/1" & Doc.toBlock
125 , invoiceItemPeriod = Period{periodBegin = "2026-01-09", periodEnd = "2026-01-11"}
126 , invoiceItemQuantity = 5 + 5
129 , invoiceMentions = [InvoiceMentionTVANonApplicable]
132 & Map.fromListWith undefined