mirror of
https://github.com/rjNemo/rentease.git
synced 2026-06-12 13:46:51 +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) {
|
func (ps *PgStore) CardTotal(from, to time.Time) (float64, error) {
|
||||||
var total float64
|
var total float64
|
||||||
if err := ps.db.Raw(`
|
if err := ps.db.Raw(`
|
||||||
select sum(total)
|
select sum(total)
|
||||||
from (select sum(price * quantity) as total
|
from (select sum(amount) as total
|
||||||
from bookings
|
from bookings as b
|
||||||
join items on bookings.id = items.booking_id
|
join payments as p on b.id = p.booking_id
|
||||||
where "to" between ? and ?
|
where "to" between ? and ?
|
||||||
and canceled = false
|
and canceled = false
|
||||||
and payment_method = 'Card'
|
and p.payment_method = 'Card'
|
||||||
group by booking_id) as t;
|
group by b.id) as t;
|
||||||
`, from, to).
|
`, from, to).
|
||||||
Scan(&total).Error; err != nil {
|
Scan(&total).Error; err != nil {
|
||||||
return 0, fmt.Errorf("failed to get card total: %w", err)
|
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)
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue