From da38546c3d3aa4fa5cfa7da7448de77cdd7f849a Mon Sep 17 00:00:00 2001 From: Ruidy Date: Thu, 29 Feb 2024 15:27:21 +0100 Subject: [PATCH] use booking.com logic for reports --- README.md | 4 ++++ internal/booking/service.go | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 456856e..396e0a1 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,10 @@ Manage your holiday rental - [x] Seed the database with the existing data before using the new system with customer data - [ ] Create a dashboard page with the Host details, bookings and revenue this month - [x] Edit campaigns and lines +- [ ] Filter bookings per date, name +- [ ] Paginate booking list +- [ ] Add a note field +- [ ] Update booking and lines ## Built With diff --git a/internal/booking/service.go b/internal/booking/service.go index c546810..1b9f67d 100644 --- a/internal/booking/service.go +++ b/internal/booking/service.go @@ -121,7 +121,7 @@ func (bs Service) BuildReport(period string, month, year int) *Report { select bookings.id, customer_name, "from", "to", platform, sum(price * quantity) as total, platform_fees from bookings join items on bookings.id = items.booking_id - where "from" between ? and ? + where "to" between ? and ? group by bookings.id order by bookings.id; `, @@ -134,9 +134,9 @@ func (bs Service) BuildReport(period string, month, year int) *Report { from (select sum(price * quantity) as total from bookings join items on bookings.id = items.booking_id - where "from" between ? and ? + where "to" between ? and ? and payment_method = 'Card' - group by booking_id); + group by booking_id) as t; `, startDate.Format("2006-01-02"), endDate.Format("2006-01-02")). Scan(&cardTotal)