mirror of
https://github.com/rjNemo/rentease.git
synced 2026-06-11 05:06:52 +00:00
fix booking total in report preview
This commit is contained in:
parent
d5654f808c
commit
8c9886991e
2 changed files with 5 additions and 4 deletions
|
|
@ -88,7 +88,7 @@ func (bs Service) BuildReport(period string, month, year int) []*Line {
|
|||
bs.db.
|
||||
Raw(`
|
||||
select id, customer_name, "from", "to", platform, total, platform_fees
|
||||
from (select sum(price) as total, booking_id
|
||||
from (select sum(price*quantity) as total, booking_id
|
||||
from bookings
|
||||
join items on bookings.id = items.booking_id
|
||||
where "from" between ? and ?
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package server
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
|
|
@ -68,10 +69,10 @@ func handleComputeReport(bs *booking.Service, hc *config.Host) echo.HandlerFunc
|
|||
res := bs.BuildReport(period, month, year)
|
||||
|
||||
reportVm := u.Map(res, func(r *booking.Line) *views.ReportViewModel {
|
||||
log.Printf("%+v", r)
|
||||
return &views.ReportViewModel{
|
||||
Id: r.InvoiceNumber(hc),
|
||||
Url: templ.SafeURL(fmt.Sprintf("%s/%s", constants.RouteBooking, r.Id)),
|
||||
// TODO: return the full invoice amount including lines
|
||||
Id: r.InvoiceNumber(hc),
|
||||
Url: templ.SafeURL(fmt.Sprintf("%s/%s", constants.RouteBooking, r.Id)),
|
||||
Total: strconv.FormatFloat(r.Total, 'f', 2, 64),
|
||||
CustomerName: r.CustomerName,
|
||||
From: r.From.Format("2006-01-02"),
|
||||
|
|
|
|||
Loading…
Reference in a new issue