package pdf import ( "bytes" "fmt" "os" "text/template" "github.com/rjNemo/rentease/internal/service/booking" ) type HtmlPdfClient struct{} func NewPdfClient() (*HtmlPdfClient, error) { return &HtmlPdfClient{}, nil } func (pc *HtmlPdfClient) BuildInvoice(data booking.Invoice) (string, error) { tmpl, err := template.ParseFiles("assets/html/invoice.html") if err != nil { return "", fmt.Errorf("Error parsing template: %v", err) } // Create a buffer to hold the rendered HTML. var buf bytes.Buffer if err := tmpl.Execute(&buf, data); err != nil { return "", fmt.Errorf("error executing template: %v", err) } outputPath := fmt.Sprintf("%s.html", data.ID) if err := os.WriteFile(outputPath, buf.Bytes(), 0644); err != nil { return "", fmt.Errorf("error writing HTML file: %v", err) } return outputPath, nil } func (pc *HtmlPdfClient) BuildReport(context map[string]any, period string, month int, year int) error { panic("unimplemented") }