package server import ( "strconv" "github.com/labstack/echo/v4" "github.com/rjNemo/rentease/config" "github.com/rjNemo/rentease/internal/booking" "github.com/rjNemo/rentease/internal/pdf" ) func handleCreateInvoicePdf(bs *booking.Service, ps *pdf.PdfService, hc *config.Host) echo.HandlerFunc { return func(c echo.Context) error { idStr := c.Param("id") id, err := strconv.Atoi(idStr) if err != nil { return err } b := bs.One(id) err = ps.BuildInvoice(b, hc) if err != nil { return err } return c.Attachment("tmp.pdf", "tmp.pdf") } }