diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml
new file mode 100644
index 0000000..9274b9e
--- /dev/null
+++ b/.github/workflows/lint.yaml
@@ -0,0 +1,25 @@
+name: Lint
+on:
+ push:
+ tags:
+ - v*
+ branches:
+ - main
+ pull_request:
+jobs:
+ lint:
+ name: golangci-lint
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Check out code
+ uses: actions/checkout@v3
+
+ - uses: actions/setup-go@v4
+ with:
+ go-version-file: "go.mod"
+
+ - name: Lint
+ uses: golangci/golangci-lint-action@v3
+ with:
+ version: v1.55
diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml
new file mode 100644
index 0000000..9d7a9b6
--- /dev/null
+++ b/.github/workflows/release.yaml
@@ -0,0 +1,30 @@
+#
+# Automatically tag a merge with main.
+#
+
+name: Release
+
+on:
+ push:
+ branches:
+ - main
+ paths-ignore:
+ - "README.md"
+
+jobs:
+ release:
+ name: Tag
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v3
+ with:
+ fetch-depth: "0" # make sure we get all commits!
+
+ - name: Bump version and push tag
+ id: bump
+ uses: anothrNick/github-tag-action@1.52.0
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ RELEASE_BRANCHES: release
+ WITH_V: true
diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml
new file mode 100644
index 0000000..8c72412
--- /dev/null
+++ b/.github/workflows/test.yaml
@@ -0,0 +1,24 @@
+name: Test Go
+on: [push]
+jobs:
+ test:
+ name: Test
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Check out code
+ uses: actions/checkout@v3
+
+ - name: Set up Go
+ uses: actions/setup-go@v4
+ with:
+ go-version-file: "go.mod"
+ id: go
+
+ - name: Install Dependencies
+ env:
+ GOPROXY: https://proxy.golang.org,direct
+ run: go mod download
+
+ - name: Test
+ run: go test -tags unit -race ./...
diff --git a/.gitignore b/.gitignore
index 3915f0f..26b61a3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -19,6 +19,7 @@
# vendor/
*.hide.json
+*.hide.html
# Go workspace file
go.work
diff --git a/README.md b/README.md
index 4f0dd9a..9a73d2c 100644
--- a/README.md
+++ b/README.md
@@ -8,7 +8,7 @@ Released under the Apache 2.0 [LICENSE](https://github.com/invopop/gobl/blob/mai
### Generate Templates
-GOBL HTML uses [templ](https://templ.guide/) to define a set of components in Go. To genera the templates, run:
+GOBL HTML uses [templ](https://templ.guide/) to define a set of components in Go. To generate the templates, run:
```bash
templ generate
@@ -19,3 +19,11 @@ During development, it can help massive to have hot reload to be able to make ch
```bash
templ generate --watch --cmd="go run ./cmd/gobl.html serve --pdf prince"
```
+
+### Testing
+
+Tests are currently pretty limited. To ensure the basics are covered, the contents of the `examples` directory are converted to HTML, pretty printed, and output to the `examples/out` directory. The tests will ensure the output is as expected. To update the output test data run:
+
+```bash
+go test ./... --update
+```
diff --git a/cmd/gobl.html/main.go b/cmd/gobl.html/main.go
index e77c508..2287ec8 100644
--- a/cmd/gobl.html/main.go
+++ b/cmd/gobl.html/main.go
@@ -6,9 +6,6 @@ import (
"os"
"os/signal"
"syscall"
-
- "github.com/invopop/ctxi18n"
- "github.com/invopop/gobl.html/locales"
)
// build data provided by goreleaser and mage setup
@@ -28,10 +25,6 @@ func run() error {
ctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
defer cancel()
- if err := ctxi18n.LoadWithDefault(locales.Content, "en"); err != nil {
- return fmt.Errorf("loading locales: %w", err)
- }
-
return root().cmd().ExecuteContext(ctx)
}
diff --git a/components/bill/invoice/invoice.templ b/components/bill/invoice/invoice.templ
index e8ba2e2..d6a9a16 100644
--- a/components/bill/invoice/invoice.templ
+++ b/components/bill/invoice/invoice.templ
@@ -8,17 +8,15 @@ import (
"github.com/invopop/gobl/org"
"github.com/invopop/gobl/tax"
"github.com/invopop/gobl.html/components/t"
-
"github.com/invopop/gobl.html/components/regimes/es"
"github.com/invopop/gobl.html/components/regimes/co"
"github.com/invopop/gobl.html/components/regimes/mx"
+ "github.com/invopop/gobl.html/internal"
)
// Invoice renders a complete GOBL bill.Invoice object.
templ Invoice(env *gobl.Envelope, inv *bill.Invoice) {
+
+
+
+
+
+
+
+
+
+
+
+
+ Credit Note
+
+
+ FR-012
+
+
+
+
+ Summary
+
+
+ -
+
+ Issue Date
+
+
+ 2022-02-01
+
+
+ -
+
+ Currency
+
+
+ Euro (EUR)
+
+
+ -
+
+ Previous Invoice
+
+
+ SAMPLE-085
+
+
+ 2022-01-10
+
+
+
+
+
+
+
+
+
+ Lines
+
+
+
+
+
+ #
+ |
+
+ Description
+ |
+
+ Qty.
+ |
+
+ Unit
+ |
+
+ Price
+ |
+
+ VAT
+ |
+
+ Disc.
+ |
+
+ Total
+ |
+
+
+
+
+
+ 1
+ |
+
+
+ Development services
+
+ |
+
+ 20
+ |
+
+ h
+ |
+
+ €90,00
+ |
+
+ 21,0%
+ |
+
+ 10%
+ |
+
+ €1.620,00
+ |
+
+
+
+ 2
+ |
+
+
+ Financial service
+
+ |
+
+ 1
+ |
+
+
+ |
+
+ €10,00
+ |
+
+ 0,0%
+ |
+ |
+
+ €10,00
+ |
+
+
+
+
+
+
+
+ Totals
+
+
+
+
+
+ Sum
+ |
+
+ €1.630,00
+ |
+
+
+
+ Tax
+ |
+
+ €340,20
+ |
+
+
+
+ Total
+ |
+
+ €1.970,20
+ |
+
+
+
+
+
+
+ Taxes
+
+
+
+
+
+ Tax
+ |
+
+ Base
+ |
+
+ Rate
+ |
+
+ Amount
+ |
+
+
+
+
+
+ VAT
+ |
+
+ €1.620,00
+ |
+
+ 21,0%
+ |
+
+ €340,20
+ |
+
+
+
+ €10,00
+ |
+
+ 0,0%
+ |
+
+ €0,00
+ |
+
+
+
+
+
+
+
+ Notes
+
+
+
+ Some random description
+
+
+
+
+
+
+
+
+