mirror of
https://github.com/rjNemo/rentease.git
synced 2026-06-06 02:36:49 +00:00
fix card calculation sql (#44)
This commit is contained in:
parent
44cf04bac7
commit
6bdbd36869
2 changed files with 7 additions and 7 deletions
|
|
@ -65,14 +65,14 @@ func (ps *PgStore) List(from, to time.Time) ([]*booking.Line, error) {
|
|||
func (ps *PgStore) CardTotal(from, to time.Time) (float64, error) {
|
||||
var total float64
|
||||
if err := ps.db.Raw(`
|
||||
select sum(total)
|
||||
from (select sum(price * quantity) as total
|
||||
from bookings
|
||||
join items on bookings.id = items.booking_id
|
||||
select sum(total)
|
||||
from (select sum(amount) as total
|
||||
from bookings as b
|
||||
join payments as p on b.id = p.booking_id
|
||||
where "to" between ? and ?
|
||||
and canceled = false
|
||||
and payment_method = 'Card'
|
||||
group by booking_id) as t;
|
||||
and p.payment_method = 'Card'
|
||||
group by b.id) as t;
|
||||
`, from, to).
|
||||
Scan(&total).Error; err != nil {
|
||||
return 0, fmt.Errorf("failed to get card total: %w", err)
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ func handlePdfCreateReport(bs *booking.Service) echo.HandlerFunc {
|
|||
}
|
||||
|
||||
report := bs.Report(period, month, year)
|
||||
filePath,err := bs.BuildReport(report, period, month, year)
|
||||
filePath, err := bs.BuildReport(report, period, month, year)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue