use booking.com logic for reports

This commit is contained in:
Ruidy 2024-02-29 15:27:21 +01:00
parent 788711e8c9
commit da38546c3d
No known key found for this signature in database
GPG key ID: E00F51288CB857CC
2 changed files with 7 additions and 3 deletions

View file

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

View file

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