Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions components/bill/invoice.templ
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/invopop/gobl.html/components/regimes/mx"
"github.com/invopop/gobl.html/components/regimes/pl"
"github.com/invopop/gobl.html/components/regimes/pt"
"github.com/invopop/gobl.html/components/regimes/sa"
"github.com/invopop/gobl.html/components/t"
"github.com/invopop/gobl.html/components/utils"
"github.com/invopop/gobl.html/internal"
Expand Down Expand Up @@ -50,6 +51,7 @@ templ Invoice(env *gobl.Envelope, inv *bill.Invoice) {
@mx.CFDI(env, inv)
@pl.KSeFQR(env)
@pt.ATQR(env)
@sa.ZATCAQR(env)
@gr.IAPR(env)
</div>
</div>
Expand Down
21 changes: 13 additions & 8 deletions components/bill/invoice_templ.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions components/regimes/sa/sa.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Package sa defines extra output for Saudi Arabian invoices.
package sa
42 changes: 42 additions & 0 deletions components/regimes/sa/zatca.templ
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package sa

import (
"github.com/invopop/gobl"
"github.com/invopop/gobl.html/components/images"
"github.com/invopop/gobl/addons/sa/zatca"
)

// ZATCAQR renders the ZATCA QR code carried as a stamp on the envelope
// header. The stamp value is the base64-encoded TLV payload defined by
// the ZATCA e-invoicing specification.
templ ZATCAQR(env *gobl.Envelope) {
if qr := zatcaQR(env); qr != "" {
@generateQR(qr)
}
}

templ generateQR(qr string) {
<style type="text/css">
.zatca-qr {
display: flex;
}
.zatca-qr img {
width: 28mm;
height: 28mm;
}
</style>
<section class="zatca-qr">
<div class="image">
@images.QR(qr)
</div>
</section>
}

func zatcaQR(env *gobl.Envelope) string {
for _, stamp := range env.Head.Stamps {
if stamp.Provider == zatca.StampQR {
return stamp.Value
}
}
return ""
}
97 changes: 97 additions & 0 deletions components/regimes/sa/zatca_templ.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 16 additions & 4 deletions examples/out/sa-invoice-simplified.html

Large diffs are not rendered by default.

19 changes: 13 additions & 6 deletions examples/sa-invoice-simplified.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,18 @@
"uuid": "3a8e2ae1-eab8-11ed-b735-3e7e00ce5635",
"dig": {
"alg": "sha256",
"val": "06f08895b0f7cf34392a0a17f67fb2f7efe162d0d283137b275c5b8e27228fe8"
}
"val": "31b900c32da25c7c5bd0363e8dbede8880d5f3a0b11e75d37f160b2acb2261be"
},
"stamps": [
{
"prv": "zatca-qr",
"val": "AS3Yp9mF2YrZitmF2YjYsyDYp9mE2LnYsdio2YrYqSDZhNmE2YHYudin2YTZitin2Kog2KfZhNiq2LHZgdmK2YfZitipAg8zMTE1ODgxMDcyMDAwMDMDEzIwMjUtMDktMjVUMDA6MDA6MDBaBAY5NDguNzUFBjEyMy43NQ=="
}
]
},
"doc": {
"$schema": "https://gobl.org/draft-0/bill/invoice",
"$regime": "SA",
"$tags": [
"simplified"
],
Expand Down Expand Up @@ -85,14 +92,14 @@
"payable": "948.75"
},
"notes": [
{
"text": "\u003cimg src='https://assets.invopop.com/misc/qr.png' width='100'\u003e"
},
{
"key": "legal",
"src": "simplified",
"text": "Simplified Tax Invoice"
}
]
}
},
"sigs": [
"eyJhbGciOiJFUzI1NiIsImtpZCI6ImUzNzFjMzBiLTNiMzMtNGNiMC04NzM5LThiOTUzMWM1NWM2NiJ9.eyJ1dWlkIjoiM2E4ZTJhZTEtZWFiOC0xMWVkLWI3MzUtM2U3ZTAwY2U1NjM1IiwiZGlnIjp7ImFsZyI6InNoYTI1NiIsInZhbCI6IjA2ZjA4ODk1YjBmN2NmMzQzOTJhMGExN2Y2N2ZiMmY3ZWZlMTYyZDBkMjgzMTM3YjI3NWM1YjhlMjcyMjhmZTgifSwic3RhbXBzIjpbeyJwcnYiOiJ6YXRjYS1xciIsInZhbCI6IkFTM1lwOW1GMllyWml0bUYyWWpZc3lEWXA5bUUyTGppU2RpbzJZclpxU0RaaE5tRTJZUFl1ZGluMllUWml0aW4yS29nMktmWmhOaXEyTGZaZ2RtSzJZZlppdGlwQWc4ek1URTFPRGd4TURjeU1EQXdNRE1ERXpJd01qVXRNRGt0TWpWVU1EQTZNREE2TURCYUJBWTVORGd1TnpVRkJqRXlNeTQzTlE9PSJ9XX0.PLACEHOLDER_SIGNATURE_FOR_EXAMPLE_RENDERING_NOT_CRYPTOGRAPHICALLY_VALIA"
]
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/a-h/templ v0.3.977
github.com/go-resty/resty/v2 v2.12.0
github.com/invopop/ctxi18n v0.9.0
github.com/invopop/gobl v0.403.0
github.com/invopop/gobl v0.403.1-0.20260514080559-652a479eb819
github.com/invopop/princepdf v0.0.0-20240408123340-585be3cab91a
github.com/labstack/echo/v4 v4.15.0
github.com/piglig/go-qr v0.2.4
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ github.com/invopop/ctxi18n v0.9.0 h1:BIia4u4OngaHVn/7gvK0w6lccOXVtad8xU0KgJ+mnVA
github.com/invopop/ctxi18n v0.9.0/go.mod h1:1Osw+JGYA+anHt0Z4reF36r5FtGHYjGQ+m1X7keIhPc=
github.com/invopop/gobl v0.403.0 h1:jLkqmPbeTxu4gXntjsCtczq3rGg6JnXBwyMF/TkvOhU=
github.com/invopop/gobl v0.403.0/go.mod h1:6jYbcNFgUcBXIsS3PIeZc99rrMLBaGzPsFEg7y2DyrQ=
github.com/invopop/gobl v0.403.1-0.20260514080559-652a479eb819 h1:Oae58LfslZNIWwphN+Z1QHoY5PuO1A5cUpFknbj8XNg=
github.com/invopop/gobl v0.403.1-0.20260514080559-652a479eb819/go.mod h1:6jYbcNFgUcBXIsS3PIeZc99rrMLBaGzPsFEg7y2DyrQ=
github.com/invopop/jsonschema v0.14.0 h1:MHQqLhvpNUZfw+hM3AZDYK7jxO8FZoQeQM77g8iyZjg=
github.com/invopop/jsonschema v0.14.0/go.mod h1:ygm6C2EaVNMBDPpaPlnOA2pFAxBnxGjFlMZABxm9n2I=
github.com/invopop/princepdf v0.0.0-20240408123340-585be3cab91a h1:xt18LlIfizLkFgLi+vK/m2SWOsAbQwVwQgbkzxKY0eU=
Expand Down
Loading