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)