package main import ( "bytes" "html/template" "log" "os" "time" "github.com/rjNemo/rentease/internal/config" "github.com/rjNemo/rentease/internal/service/booking" ) func main() { type Invoice struct { Host struct { Name string Address string ZipCode string City string Phone string Email string } Name string PhoneNumber string CustomersNumber int Platform string ID string From string To string Total string AmountPaid string BalanceDue string Lines []struct { Name string Quantity int Price string Total string } Payments []struct { Date string Method string Amount string } } // Assume these values come from your application's context. host := config.NewHost() booking := booking.Booking{ Name: "Michel Le Corre", PhoneNumber: "+590 690 44 15 30", CustomerNumber: 2, Platform: "Privée", From: time.Date(2025, time.January, 15, 0, 0, 0, 0, time.UTC), To: time.Date(2025, time.March, 15, 0, 0, 0, 0, time.UTC), Items: []booking.Item{ {Item: "T2", Quantity: 59, Price: 35.00}, }, } // Get dynamic invoice data from the booking via Serialize. invoiceData := booking.Serialize(host) // Parse the HTML template. tmpl, err := template.ParseFiles("assets/html/invoice.html") if err != nil { log.Fatalf("Error parsing template: %v", err) } // Create a buffer to hold the rendered HTML. var buf bytes.Buffer if err := tmpl.Execute(&buf, invoiceData); err != nil { log.Fatalf("Error executing template: %v", err) } // Write the rendered HTML to an output file. outputPath := "output.html" if err := os.WriteFile(outputPath, buf.Bytes(), 0644); err != nil { log.Fatalf("Error writing HTML file: %v", err) } log.Printf("HTML file created successfully: %s", outputPath) }