mirror of
https://github.com/rjNemo/rentease.git
synced 2026-06-10 12:46:53 +00:00
28 lines
570 B
Go
28 lines
570 B
Go
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")
|
|
}
|
|
}
|