Merge pull request #4 from rjNemo/2-pdf-report

2: Formatting for PDF report
This commit is contained in:
Ruidy 2024-03-20 15:55:46 +01:00 committed by GitHub
commit 3ece623a27
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
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{ Context: map[string]any{
"month": month, "month": month,
"year": year, "year": year,
"total": r.Total, "total": strconv.FormatFloat(r.Total, 'f', 2, 64),
"platform_fees": r.PlatformFees, "platform_fees": r.PlatformFees,
"fee": r.Fee, "fee": strconv.FormatFloat(r.Fee, 'f', 2, 64),
"profit": r.Profit, "profit": strconv.FormatFloat(r.Profit, 'f', 2, 64),
"card_total": r.CardTotal, "card_total": strconv.FormatFloat(r.CardTotal, 'f', 2, 64),
"booking_fees": r.BookingFees, "booking_fees": strconv.FormatFloat(r.BookingFees, 'f', 2, 64),
"lines": u.Map(r.Lines, func(l *booking.Line) map[string]any { "lines": u.Map(r.Lines, func(l *booking.Line) map[string]any {
return map[string]any{ return map[string]any{
"id": l.Id, "id": l.Id,
"name": l.CustomerName, "name": l.CustomerName,
"from": l.From.Format("2006-01-02"), "from": l.From.Format("02 01 2006"),
"to": l.To.Format("2006-01-02"), "to": l.To.Format("02 02 2006"),
"total": l.Total, "total": strconv.FormatFloat(l.Total, 'f', 2, 64),
"platform": l.Platform, "platform": l.Platform,
"platform_fees": l.PlatformFees, "platform_fees": strconv.FormatFloat(l.PlatformFees, 'f', 2, 64),
"fee": l.Fee(), "fee": strconv.FormatFloat(l.Fee(), 'f', 2, 64),
"profit": l.Profit(), "profit": strconv.FormatFloat(l.Profit(), 'f', 2, 64),
} }
}), }),
}, },

View file

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

View file

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