mirror of
https://github.com/rjNemo/rentease.git
synced 2026-06-12 13:46:51 +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.
|
bs.db.
|
||||||
Raw(`
|
Raw(`
|
||||||
select id, customer_name, "from", "to", platform, total, platform_fees
|
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
|
from bookings
|
||||||
join items on bookings.id = items.booking_id
|
join items on bookings.id = items.booking_id
|
||||||
where "from" between ? and ?
|
where "from" between ? and ?
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
@ -68,10 +69,10 @@ func handleComputeReport(bs *booking.Service, hc *config.Host) echo.HandlerFunc
|
||||||
res := bs.BuildReport(period, month, year)
|
res := bs.BuildReport(period, month, year)
|
||||||
|
|
||||||
reportVm := u.Map(res, func(r *booking.Line) *views.ReportViewModel {
|
reportVm := u.Map(res, func(r *booking.Line) *views.ReportViewModel {
|
||||||
|
log.Printf("%+v", r)
|
||||||
return &views.ReportViewModel{
|
return &views.ReportViewModel{
|
||||||
Id: r.InvoiceNumber(hc),
|
Id: r.InvoiceNumber(hc),
|
||||||
Url: templ.SafeURL(fmt.Sprintf("%s/%s", constants.RouteBooking, r.Id)),
|
Url: templ.SafeURL(fmt.Sprintf("%s/%s", constants.RouteBooking, r.Id)),
|
||||||
// TODO: return the full invoice amount including lines
|
|
||||||
Total: strconv.FormatFloat(r.Total, 'f', 2, 64),
|
Total: strconv.FormatFloat(r.Total, 'f', 2, 64),
|
||||||
CustomerName: r.CustomerName,
|
CustomerName: r.CustomerName,
|
||||||
From: r.From.Format("2006-01-02"),
|
From: r.From.Format("2006-01-02"),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue