]> Git — Sourcephile - tmp/julm/literate-invoice.git/blob - tests/Tests/Invoice.hs
feat(invoice): add what I need
[tmp/julm/literate-invoice.git] / tests / Tests / Invoice.hs
1 {-# LANGUAGE OverloadedLists #-}
2 {-# LANGUAGE OverloadedStrings #-}
3
4 module Tests.Invoice where
5
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
14 import Test.Syd
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)
20
21 spec :: HasCallStack => Spec
22 spec =
23 -- aroundAll readDicts do
24 describe "Invoice" 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"
28 it idS do
29 goldenByteStringBuilderFile outPath do
30 HTML.htmlIO (invId, inv) <&> Blaze.renderMarkupBuilder
31
32 invoices :: Invoices
33 invoices =
34 [ InvoiceId{invoiceIdBuyer = Tests.Entity.nixosFoundationNGITeam, invoiceIdCount = 1} :=
35 invoice
36 { invoiceCreation = "2026-01-09"
37 , invoiceIssuer = Tests.Entity.julmInfo
38 , invoiceRecipient = Tests.Entity.nixosFoundationNGITeam
39 , invoiceCustomer = Tests.Entity.nixosFoundationNGITeam
40 , invoiceObjet = "Test"
41 , invoiceDetails = ""
42 , invoiceItems =
43 [ InvoiceItem
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
48 }
49 , InvoiceItem
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
54 }
55 , InvoiceItem
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
60 }
61 , InvoiceItem
62 { invoiceItemDescription =
63 [ "Make a package for Bonfire in NGIpkgs"
64 , Doc.inlineLinkExplicit "https://github.com/ngi-nix/ngipkgs/pull/1812" & Doc.toBlock
65 ]
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
69 }
70 , InvoiceItem
71 { invoiceItemDescription =
72 [ "Make a service for Bonfire in NGIpkgs"
73 , Doc.inlineLinkExplicit "https://github.com/ngi-nix/ngipkgs/pull/1871" & Doc.toBlock
74 ]
75 , invoiceItemPeriod = Period{periodBegin = "2025-11-15", periodEnd = "2025-12-15"}
76 , invoiceItemRate = 31.25
77 , invoiceItemQuantity = 5 + 4 + 8 + 5 + 2 + 4
78 }
79 {-
80 , InvoiceItem
81 { invoiceItemDescription = "Make manuals for NGIpkgs"
82 , invoiceItemRate = 0
83 , invoiceItemQuantity = 0.5 + 2 + 4 + 4 + 4 + 8 + 4 + 2 + 4 + 4 + 2 + 6 + 1 + 2
84 }
85 -}
86 ]
87 , invoiceMentions = [InvoiceMentionTVANonApplicable]
88 }
89 , InvoiceId{invoiceIdBuyer = Tests.Entity.nixosFoundationNGITeam, invoiceIdCount = 2} :=
90 invoice
91 { invoiceCreation = "2026-01-09"
92 , invoiceIssuer = Tests.Entity.julmInfo
93 , invoiceRecipient = Tests.Entity.nixosFoundationNGITeam
94 , invoiceCustomer = Tests.Entity.nixosFoundationNGITeam
95 , invoiceObjet = "Test"
96 , invoiceDetails = ""
97 , invoiceItems =
98 let invoiceItem =
99 InvoiceItem
100 { invoiceItemDescription = ""
101 , invoiceItemQuantity = 0
102 , invoiceItemPeriod = Period{periodBegin = "2026-01-01", periodEnd = "2026-01-11"}
103 , invoiceItemRate = 31.25
104 }
105 in [ invoiceItem
106 { invoiceItemDescription = "Organize work"
107 , invoiceItemQuantity = 2
108 }
109 , invoiceItem
110 { invoiceItemDescription =
111 [ "Make a package for Bonfire in NGIpkgs"
112 , Doc.inlineLinkExplicit "https://github.com/ngi-nix/ngipkgs/pull/1812" & Doc.toBlock
113 ]
114 , invoiceItemQuantity = 3 + 4 + 2 + 4 + 2 + 6 + 1 + 4 + 4 + 2 + 2 + 5 + 2
115 }
116 , invoiceItem
117 { invoiceItemDescription =
118 [ [ "Remove "
119 , Doc.InlineCode "import-from-derivation"
120 , " for Mirage unikernels in NGIpkgs and opam-nix"
121 ]
122 & Doc.BlockPara
123 , Doc.inlineLinkExplicit "https://github.com/linj-fork/ngipkgs/pull/1" & Doc.toBlock
124 ]
125 , invoiceItemPeriod = Period{periodBegin = "2026-01-09", periodEnd = "2026-01-11"}
126 , invoiceItemQuantity = 5 + 5
127 }
128 ]
129 , invoiceMentions = [InvoiceMentionTVANonApplicable]
130 }
131 ]
132 & Map.fromListWith undefined