pdf report formatting

This commit is contained in:
Ruidy 2024-03-20 15:53:27 +01:00
parent 491fd89471
commit 81647b7416
No known key found for this signature in database
GPG key ID: E00F51288CB857CC
3 changed files with 11 additions and 17 deletions

View file

@ -97,23 +97,23 @@ func (ps PdfService) BuildReport(r *booking.Report, period string, month, year i
Context: map[string]any{
"month": month,
"year": year,
"total": r.Total,
"total": strconv.FormatFloat(r.Total, 'f', 2, 64),
"platform_fees": r.PlatformFees,
"fee": r.Fee,
"profit": r.Profit,
"card_total": r.CardTotal,
"booking_fees": r.BookingFees,
"fee": strconv.FormatFloat(r.Fee, 'f', 2, 64),
"profit": strconv.FormatFloat(r.Profit, 'f', 2, 64),
"card_total": strconv.FormatFloat(r.CardTotal, 'f', 2, 64),
"booking_fees": strconv.FormatFloat(r.BookingFees, 'f', 2, 64),
"lines": u.Map(r.Lines, func(l *booking.Line) map[string]any {
return map[string]any{
"id": l.Id,
"name": l.CustomerName,
"from": l.From.Format("2006-01-02"),
"to": l.To.Format("2006-01-02"),
"total": l.Total,
"from": l.From.Format("02 01 2006"),
"to": l.To.Format("02 02 2006"),
"total": strconv.FormatFloat(l.Total, 'f', 2, 64),
"platform": l.Platform,
"platform_fees": l.PlatformFees,
"fee": l.Fee(),
"profit": l.Profit(),
"platform_fees": strconv.FormatFloat(l.PlatformFees, 'f', 2, 64),
"fee": strconv.FormatFloat(l.Fee(), 'f', 2, 64),
"profit": strconv.FormatFloat(l.Profit(), 'f', 2, 64),
}
}),
},

View file

@ -18,11 +18,6 @@ import (
func handleReportsPage() echo.HandlerFunc {
return func(c echo.Context) error {
period := c.QueryParam("period")
if !u.Contains([]string{"month", "year"}, period) {
period = "month"
}
monthStr := c.QueryParam("month")
month, err := strconv.Atoi(monthStr)
if err != nil || month < 1 || month > 12 {

View file

@ -27,7 +27,6 @@ type Server struct {
bs *booking.Service
ps *pdf.PdfService
hc *config.Host
fs *embed.FS
addr string
}