{-# LANGUAGE OverloadedLists #-} {-# LANGUAGE OverloadedStrings #-} module Tests.Invoice where import Data.Map.Strict qualified as Map import Data.Text.Lazy qualified as Text.Lazy import Literate.Accounting.Math import Literate.Document qualified as Doc import Literate.Document.HTML qualified as HTML import Literate.Invoice.HTML qualified as HTML import Literate.Invoice.Invoice import Literate.Prelude import Test.Syd import Tests.Entity qualified import Tests.Utils.Tests import Text.Blaze.Renderer.Text qualified as Blaze.Text import Text.Blaze.Renderer.Utf8 qualified as Blaze import Prelude (undefined) spec :: HasCallStack => Spec spec = -- aroundAll readDicts do describe "Invoice" do forM_ (invoices & Map.toList) \(invId, inv) -> do let idS = invId & HTML.toHtml & Blaze.Text.renderMarkup & Text.Lazy.unpack outPath <- goldenPath idS "html" it idS do goldenByteStringBuilderFile outPath do HTML.htmlIO (invId, inv) <&> Blaze.renderMarkupBuilder invoices :: Invoices invoices = [ InvoiceId{invoiceIdBuyer = Tests.Entity.nixosFoundationNGITeam, invoiceIdCount = 1} := invoice { invoiceCreation = "2026-01-09" , invoiceIssuer = Tests.Entity.julmInfo , invoiceRecipient = Tests.Entity.nixosFoundationNGITeam , invoiceCustomer = Tests.Entity.nixosFoundationNGITeam , invoiceObjet = "Test" , invoiceDetails = "" , invoiceItems = [ InvoiceItem { invoiceItemDescription = "Organize work" , invoiceItemRate = 31.25 , invoiceItemPeriod = Period{periodBegin = "2025-11-15", periodEnd = "2025-12-15"} , invoiceItemQuantity = 0.5 + 1 + 1 + 1 + 1 + 1 } , InvoiceItem { invoiceItemDescription = "Share knowledge" , invoiceItemPeriod = Period{periodBegin = "2025-11-15", periodEnd = "2025-12-15"} , invoiceItemRate = 31.25 , invoiceItemQuantity = 0.5 + 1 + 2 } , InvoiceItem { invoiceItemDescription = "Review others' work" , invoiceItemPeriod = Period{periodBegin = "2025-11-15", periodEnd = "2025-12-15"} , invoiceItemRate = 31.25 , invoiceItemQuantity = 2 + 2 + 1.5 + 1 + 0.5 } , InvoiceItem { invoiceItemDescription = [ "Make a package for Bonfire in NGIpkgs" , Doc.inlineLinkExplicit "https://github.com/ngi-nix/ngipkgs/pull/1812" & Doc.toBlock ] , invoiceItemPeriod = Period{periodBegin = "2025-11-15", periodEnd = "2025-12-15"} , invoiceItemRate = 31.25 , invoiceItemQuantity = 4 + 8 + 0.1 + 8 + 4 + 6 + 4 + 5 + 6 + 4 + 8 + 8 + 4 + 4 + 4 + 10 + 8 + 5 + 4 } , InvoiceItem { invoiceItemDescription = [ "Make a service for Bonfire in NGIpkgs" , Doc.inlineLinkExplicit "https://github.com/ngi-nix/ngipkgs/pull/1871" & Doc.toBlock ] , invoiceItemPeriod = Period{periodBegin = "2025-11-15", periodEnd = "2025-12-15"} , invoiceItemRate = 31.25 , invoiceItemQuantity = 5 + 4 + 8 + 5 + 2 + 4 } {- , InvoiceItem { invoiceItemDescription = "Make manuals for NGIpkgs" , invoiceItemRate = 0 , invoiceItemQuantity = 0.5 + 2 + 4 + 4 + 4 + 8 + 4 + 2 + 4 + 4 + 2 + 6 + 1 + 2 } -} ] , invoiceMentions = [InvoiceMentionTVANonApplicable] } , InvoiceId{invoiceIdBuyer = Tests.Entity.nixosFoundationNGITeam, invoiceIdCount = 2} := invoice { invoiceCreation = "2026-01-09" , invoiceIssuer = Tests.Entity.julmInfo , invoiceRecipient = Tests.Entity.nixosFoundationNGITeam , invoiceCustomer = Tests.Entity.nixosFoundationNGITeam , invoiceObjet = "Test" , invoiceDetails = "" , invoiceItems = let invoiceItem = InvoiceItem { invoiceItemDescription = "" , invoiceItemQuantity = 0 , invoiceItemPeriod = Period{periodBegin = "2026-01-01", periodEnd = "2026-01-11"} , invoiceItemRate = 31.25 } in [ invoiceItem { invoiceItemDescription = "Organize work" , invoiceItemQuantity = 2 } , invoiceItem { invoiceItemDescription = [ "Make a package for Bonfire in NGIpkgs" , Doc.inlineLinkExplicit "https://github.com/ngi-nix/ngipkgs/pull/1812" & Doc.toBlock ] , invoiceItemQuantity = 3 + 4 + 2 + 4 + 2 + 6 + 1 + 4 + 4 + 2 + 2 + 5 + 2 } , invoiceItem { invoiceItemDescription = [ [ "Remove " , Doc.InlineCode "import-from-derivation" , " for Mirage unikernels in NGIpkgs and opam-nix" ] & Doc.BlockPara , Doc.inlineLinkExplicit "https://github.com/linj-fork/ngipkgs/pull/1" & Doc.toBlock ] , invoiceItemPeriod = Period{periodBegin = "2026-01-09", periodEnd = "2026-01-11"} , invoiceItemQuantity = 5 + 5 } ] , invoiceMentions = [InvoiceMentionTVANonApplicable] } ] & Map.fromListWith undefined