From 3924b63c8009a566e1c55d4887a043d7f38e18f7 Mon Sep 17 00:00:00 2001 From: Sam Lown Date: Tue, 15 Oct 2024 11:05:24 +0000 Subject: [PATCH 1/4] Hiding tax sum if no taxes --- cmd/gobl.html/serve.go | 3 +++ components/bill/invoice/totals.templ | 2 +- components/bill/invoice/totals_templ.go | 2 +- examples/out/us-invoice.html | 8 -------- go.mod | 1 + go.sum | 2 ++ 6 files changed, 8 insertions(+), 10 deletions(-) diff --git a/cmd/gobl.html/serve.go b/cmd/gobl.html/serve.go index d706e79..e073658 100644 --- a/cmd/gobl.html/serve.go +++ b/cmd/gobl.html/serve.go @@ -19,6 +19,7 @@ import ( "github.com/invopop/gobl.html/pkg/pdf" "github.com/invopop/gobl/org" "github.com/labstack/echo/v4" + "github.com/sevenNt/echo-pprof" "github.com/spf13/cobra" ) @@ -68,6 +69,8 @@ func (s *serveOpts) runE(cmd *cobra.Command, _ []string) error { e.StaticFS("/styles", echo.MustSubFS(assets.Content, "styles")) e.GET("/:filename", s.generate) + echopprof.Wrap(e) + var startErr error go func() { err := e.Start(":" + s.port) diff --git a/components/bill/invoice/totals.templ b/components/bill/invoice/totals.templ index 88e9cb5..9fbd61f 100644 --- a/components/bill/invoice/totals.templ +++ b/components/bill/invoice/totals.templ @@ -76,7 +76,7 @@ templ totalsBaseRows(inv *bill.Invoice, totals *bill.Totals) { } - if totals.TaxIncluded == nil || !totals.TaxIncluded.Equals(totals.Tax) { + if totals.Taxes != nil && len(totals.Taxes.Categories) > 0 && (totals.TaxIncluded == nil || !totals.TaxIncluded.Equals(totals.Tax)) { @t.T(".taxes") diff --git a/components/bill/invoice/totals_templ.go b/components/bill/invoice/totals_templ.go index 7b6eb53..8f2147e 100644 --- a/components/bill/invoice/totals_templ.go +++ b/components/bill/invoice/totals_templ.go @@ -220,7 +220,7 @@ func totalsBaseRows(inv *bill.Invoice, totals *bill.Totals) templ.Component { return templ_7745c5c3_Err } } - if totals.TaxIncluded == nil || !totals.TaxIncluded.Equals(totals.Tax) { + if totals.Taxes != nil && len(totals.Taxes.Categories) > 0 && (totals.TaxIncluded == nil || !totals.TaxIncluded.Equals(totals.Tax)) { _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err diff --git a/examples/out/us-invoice.html b/examples/out/us-invoice.html index 7b4409a..f6621f0 100644 --- a/examples/out/us-invoice.html +++ b/examples/out/us-invoice.html @@ -205,14 +205,6 @@

$4,800.00 - - - Tax - - - $0.00 - - Total to pay diff --git a/go.mod b/go.mod index 4d3f349..b49dc6b 100644 --- a/go.mod +++ b/go.mod @@ -11,6 +11,7 @@ require ( github.com/labstack/echo/v4 v4.12.0 github.com/piglig/go-qr v0.2.4 github.com/pmezard/go-difflib v1.0.0 + github.com/sevenNt/echo-pprof v0.1.1-0.20230131020615-4dd36891e14b github.com/spf13/cobra v1.8.1 github.com/stretchr/testify v1.9.0 github.com/yosssi/gohtml v0.0.0-20201013000340-ee4748c638f4 diff --git a/go.sum b/go.sum index 9f92270..0541a75 100644 --- a/go.sum +++ b/go.sum @@ -65,6 +65,8 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/rogpeppe/go-internal v1.12.1-0.20240709150035-ccf4b4329d21 h1:igWZJluD8KtEtAgRyF4x6lqcxDry1ULztksMJh2mnQE= github.com/rogpeppe/go-internal v1.12.1-0.20240709150035-ccf4b4329d21/go.mod h1:RMRJLmBOqWacUkmJHRMiPKh1S1m3PA7Zh4W80/kWPpg= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/sevenNt/echo-pprof v0.1.1-0.20230131020615-4dd36891e14b h1:IXGKwQZ6+llGbDFyTJvBXWGTkfrAqsbYwtVVm+Ax4WU= +github.com/sevenNt/echo-pprof v0.1.1-0.20230131020615-4dd36891e14b/go.mod h1:ArUb+H7+Tew7UUjK6x2xiAqFrznLrANIfz9M6m66J0c= github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM= github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= From b41fa7fd1b4a3f2b5dd7e50fc3c7714fcde701c3 Mon Sep 17 00:00:00 2001 From: Sam Lown Date: Tue, 15 Oct 2024 11:06:44 +0000 Subject: [PATCH 2/4] Updating linter action config --- .github/workflows/lint.yaml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 9274b9e..63a17b6 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -13,13 +13,15 @@ jobs: steps: - name: Check out code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - - uses: actions/setup-go@v4 + - name: Set up Go + uses: actions/setup-go@v5 with: go-version-file: "go.mod" + id: go - name: Lint - uses: golangci/golangci-lint-action@v3 + uses: golangci/golangci-lint-action@v6 with: - version: v1.55 + version: v1.58 From 52eee082b334a3495010012de5b064b107dd26d8 Mon Sep 17 00:00:00 2001 From: Sam Lown Date: Tue, 15 Oct 2024 11:07:42 +0000 Subject: [PATCH 3/4] lint fix --- cmd/gobl.html/serve.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/gobl.html/serve.go b/cmd/gobl.html/serve.go index e073658..d4c2ecb 100644 --- a/cmd/gobl.html/serve.go +++ b/cmd/gobl.html/serve.go @@ -19,7 +19,7 @@ import ( "github.com/invopop/gobl.html/pkg/pdf" "github.com/invopop/gobl/org" "github.com/labstack/echo/v4" - "github.com/sevenNt/echo-pprof" + echopprof "github.com/sevenNt/echo-pprof" "github.com/spf13/cobra" ) From 3365ba5bb45e1e830e52b6f570f5d7596c631dba Mon Sep 17 00:00:00 2001 From: Sam Lown Date: Tue, 15 Oct 2024 11:08:55 +0000 Subject: [PATCH 4/4] Removing profiling test --- cmd/gobl.html/serve.go | 3 --- go.mod | 1 - go.sum | 2 -- 3 files changed, 6 deletions(-) diff --git a/cmd/gobl.html/serve.go b/cmd/gobl.html/serve.go index d4c2ecb..d706e79 100644 --- a/cmd/gobl.html/serve.go +++ b/cmd/gobl.html/serve.go @@ -19,7 +19,6 @@ import ( "github.com/invopop/gobl.html/pkg/pdf" "github.com/invopop/gobl/org" "github.com/labstack/echo/v4" - echopprof "github.com/sevenNt/echo-pprof" "github.com/spf13/cobra" ) @@ -69,8 +68,6 @@ func (s *serveOpts) runE(cmd *cobra.Command, _ []string) error { e.StaticFS("/styles", echo.MustSubFS(assets.Content, "styles")) e.GET("/:filename", s.generate) - echopprof.Wrap(e) - var startErr error go func() { err := e.Start(":" + s.port) diff --git a/go.mod b/go.mod index b49dc6b..4d3f349 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,6 @@ require ( github.com/labstack/echo/v4 v4.12.0 github.com/piglig/go-qr v0.2.4 github.com/pmezard/go-difflib v1.0.0 - github.com/sevenNt/echo-pprof v0.1.1-0.20230131020615-4dd36891e14b github.com/spf13/cobra v1.8.1 github.com/stretchr/testify v1.9.0 github.com/yosssi/gohtml v0.0.0-20201013000340-ee4748c638f4 diff --git a/go.sum b/go.sum index 0541a75..9f92270 100644 --- a/go.sum +++ b/go.sum @@ -65,8 +65,6 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/rogpeppe/go-internal v1.12.1-0.20240709150035-ccf4b4329d21 h1:igWZJluD8KtEtAgRyF4x6lqcxDry1ULztksMJh2mnQE= github.com/rogpeppe/go-internal v1.12.1-0.20240709150035-ccf4b4329d21/go.mod h1:RMRJLmBOqWacUkmJHRMiPKh1S1m3PA7Zh4W80/kWPpg= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/sevenNt/echo-pprof v0.1.1-0.20230131020615-4dd36891e14b h1:IXGKwQZ6+llGbDFyTJvBXWGTkfrAqsbYwtVVm+Ax4WU= -github.com/sevenNt/echo-pprof v0.1.1-0.20230131020615-4dd36891e14b/go.mod h1:ArUb+H7+Tew7UUjK6x2xiAqFrznLrANIfz9M6m66J0c= github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM= github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=