From 9becb1c5c9748de6cef03779e57e1c089fb53d95 Mon Sep 17 00:00:00 2001 From: Finley Ghosh Date: Wed, 21 Jan 2026 18:43:55 +1100 Subject: [PATCH] Quote largely working --- go/internal/cmc/pdf/invoice_builder.go | 23 ++++++--- go/internal/cmc/pdf/quote_builder.go | 23 ++++++--- go/internal/cmc/pdf/templates/header.html | 26 ++++++++++ go/internal/cmc/pdf/templates/invoice.html | 25 +--------- go/internal/cmc/pdf/templates/quote.html | 55 +--------------------- 5 files changed, 61 insertions(+), 91 deletions(-) create mode 100644 go/internal/cmc/pdf/templates/header.html diff --git a/go/internal/cmc/pdf/invoice_builder.go b/go/internal/cmc/pdf/invoice_builder.go index c0ca026b..cdea972f 100644 --- a/go/internal/cmc/pdf/invoice_builder.go +++ b/go/internal/cmc/pdf/invoice_builder.go @@ -108,18 +108,27 @@ func (g *HTMLDocumentGenerator) BuildInvoiceHTML(data *InvoicePDFData, totalPage } // Parse and execute template - // Try multiple possible paths to find the template - possiblePaths := []string{ - filepath.Join("internal", "cmc", "pdf", "templates", "invoice.html"), - filepath.Join("go", "internal", "cmc", "pdf", "templates", "invoice.html"), - "/app/go/internal/cmc/pdf/templates/invoice.html", + // Try multiple possible path sets to find the invoice and shared header templates together + possiblePathSets := [][]string{ + { + filepath.Join("internal", "cmc", "pdf", "templates", "invoice.html"), + filepath.Join("internal", "cmc", "pdf", "templates", "header.html"), + }, + { + filepath.Join("go", "internal", "cmc", "pdf", "templates", "invoice.html"), + filepath.Join("go", "internal", "cmc", "pdf", "templates", "header.html"), + }, + { + "/app/go/internal/cmc/pdf/templates/invoice.html", + "/app/go/internal/cmc/pdf/templates/header.html", + }, } var tmpl *template.Template var err error - for _, tmplPath := range possiblePaths { - tmpl, err = template.New("invoice.html").Funcs(funcMap).ParseFiles(tmplPath) + for _, pathSet := range possiblePathSets { + tmpl, err = template.New("invoice.html").Funcs(funcMap).ParseFiles(pathSet...) if err == nil { break } diff --git a/go/internal/cmc/pdf/quote_builder.go b/go/internal/cmc/pdf/quote_builder.go index 0a17137d..2c1904e2 100644 --- a/go/internal/cmc/pdf/quote_builder.go +++ b/go/internal/cmc/pdf/quote_builder.go @@ -158,18 +158,27 @@ func (g *HTMLDocumentGenerator) BuildQuoteHTML(data *QuotePDFData, totalPages in } // Parse and execute template - // Try multiple possible paths to find the template - possiblePaths := []string{ - filepath.Join("internal", "cmc", "pdf", "templates", "quote.html"), - filepath.Join("go", "internal", "cmc", "pdf", "templates", "quote.html"), - "/app/go/internal/cmc/pdf/templates/quote.html", + // Try multiple possible path sets to find the quote and shared header templates together + possiblePathSets := [][]string{ + { + filepath.Join("internal", "cmc", "pdf", "templates", "quote.html"), + filepath.Join("internal", "cmc", "pdf", "templates", "header.html"), + }, + { + filepath.Join("go", "internal", "cmc", "pdf", "templates", "quote.html"), + filepath.Join("go", "internal", "cmc", "pdf", "templates", "header.html"), + }, + { + "/app/go/internal/cmc/pdf/templates/quote.html", + "/app/go/internal/cmc/pdf/templates/header.html", + }, } var tmpl *template.Template var err error - for _, tmplPath := range possiblePaths { - tmpl, err = template.New("quote.html").Funcs(funcMap).ParseFiles(tmplPath) + for _, pathSet := range possiblePathSets { + tmpl, err = template.New("quote.html").Funcs(funcMap).ParseFiles(pathSet...) if err == nil { break } diff --git a/go/internal/cmc/pdf/templates/header.html b/go/internal/cmc/pdf/templates/header.html new file mode 100644 index 00000000..9425b328 --- /dev/null +++ b/go/internal/cmc/pdf/templates/header.html @@ -0,0 +1,26 @@ +{{define "CompanyHeader"}} + +
+ +
+
+

CMC TECHNOLOGIES

+

PTY LIMITED ACN: 085 991 224  ABN: 47 085 991 224

+
+ +
+
+ Phone: +61 2 9669 4000
+ Fax: +61 2 9669 4111
+ Email: sales@cmctechnologies.com.au
+ Web Site: www.cmctechnologies.net.au +
+
+ Unit 19, 77 Bourke Rd
+ Alexandria NSW 2015
+ AUSTRALIA +
+
+
+
+{{end}} diff --git a/go/internal/cmc/pdf/templates/invoice.html b/go/internal/cmc/pdf/templates/invoice.html index 7ebb7cce..e2bdd473 100644 --- a/go/internal/cmc/pdf/templates/invoice.html +++ b/go/internal/cmc/pdf/templates/invoice.html @@ -308,30 +308,7 @@ - -
- -
-
-

CMC TECHNOLOGIES

-

PTY LIMITED ACN: 085 991 224  ABN: 47 085 991 224

-
- -
-
- Phone: +61 2 9669 4000
- Fax: +61 2 9669 4111
- Email: sales@cmctechnologies.com.au
- Web Site: www.cmctechnologies.net.au -
-
- Unit 19, 77 Bourke Rd
- Alexandria NSW 2015
- AUSTRALIA -
-
-
-
+ {{template "CompanyHeader" .}}
diff --git a/go/internal/cmc/pdf/templates/quote.html b/go/internal/cmc/pdf/templates/quote.html index 8d43953a..0aa212ac 100644 --- a/go/internal/cmc/pdf/templates/quote.html +++ b/go/internal/cmc/pdf/templates/quote.html @@ -8,29 +8,7 @@ size: A4; margin: 15mm; } - - body { - font-family: Helvetica, Arial, sans-serif; - font-size: 9pt; - line-height: 1.4; - margin: 0; - padding: 0; - color: #000; - } - - a { - color: #0000FF; - text-decoration: underline; - } - - .company-info { - display: flex; - align-items: flex-start; - gap: 10mm; - margin-bottom: 0; - padding-bottom: 0; - } - + .logo { width: 40mm; height: auto; @@ -328,36 +306,7 @@ - -
- {{if .LogoDataURI}} - - {{end}} -
-

CMC TECHNOLOGIES

-

PTY LIMITED ACN: 085 991 224    ABN: 47 085 991 224

-
-
- -
- - -
-
-
Engineering &
-
Industrial
-
Instrumentation
-
-
-
Phone: +61 2 9669 4000
-
Fax: +61 2 9669 4111
-
Email: sales@cmctechnologies.com.au
-
Web Site: www.cmctechnologies.net.au
-
Unit 19, 77 Bourke Rd
-
Alexandria NSW 2015
-
AUSTRALIA
-
-
+ {{template "CompanyHeader" .}}