fix the report query

This commit is contained in:
Ruidy 2024-02-28 22:50:26 +01:00
parent 3cf56095b7
commit 322f440716
No known key found for this signature in database
GPG key ID: E00F51288CB857CC

View file

@ -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)