From 322f440716a48eeec7034b7212dcee1d686ee551 Mon Sep 17 00:00:00 2001 From: Ruidy Date: Wed, 28 Feb 2024 22:50:26 +0100 Subject: [PATCH] fix the report query --- internal/booking/service.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/booking/service.go b/internal/booking/service.go index 10d72c7..1b401ce 100644 --- a/internal/booking/service.go +++ b/internal/booking/service.go @@ -111,7 +111,7 @@ func (bs Service) BuildReport(period string, month, year int) *Report { if period == "month" { startDate = time.Date(year, time.Month(month), 1, 0, 0, 0, 0, time.UTC) - endDate = time.Date(year, time.Month(month), 31, 0, 0, 0, 0, time.UTC) + endDate = time.Date(year, time.Month(month)+1, 1, 0, 0, 0, 0, time.UTC).Add(-24 * time.Hour) } else { startDate = time.Date(year, time.January, 1, 0, 0, 0, 0, time.UTC) endDate = time.Date(year, time.December, 31, 0, 0, 0, 0, time.UTC) @@ -122,7 +122,8 @@ func (bs Service) BuildReport(period string, month, year int) *Report { from bookings join items on bookings.id = items.booking_id where "from" between ? and ? - group by bookings.id; + group by bookings.id + order by bookings.id; `, startDate.Format("2006-01-02"), endDate.Format("2006-01-02")). Scan(&lines)