mirror of
https://github.com/rjNemo/rentease.git
synced 2026-06-12 13:46:51 +00:00
fix: the card total reporting
This commit is contained in:
parent
aa436542c4
commit
106aa475d6
2 changed files with 15 additions and 14 deletions
16
README.md
16
README.md
|
|
@ -5,14 +5,14 @@
|
||||||
<!--toc:start-->
|
<!--toc:start-->
|
||||||
|
|
||||||
- [Rentease](#rentease)
|
- [Rentease](#rentease)
|
||||||
- [Features](#features)
|
- [Features](#features)
|
||||||
- [Getting Started](#getting-started)
|
- [Getting Started](#getting-started)
|
||||||
- [Prerequisites](#prerequisites)
|
- [Prerequisites](#prerequisites)
|
||||||
- [Installation](#installation)
|
- [Installation](#installation)
|
||||||
- [Built With](#built-with)
|
- [Built With](#built-with)
|
||||||
- [Roadmap](#roadmap)
|
- [Roadmap](#roadmap)
|
||||||
- [Contributing](#contributing)
|
- [Contributing](#contributing)
|
||||||
- [License](#license)
|
- [License](#license)
|
||||||
<!--toc:end-->
|
<!--toc:end-->
|
||||||
|
|
||||||
Rentease is a property-management application to help landlords to manage your rental
|
Rentease is a property-management application to help landlords to manage your rental
|
||||||
|
|
|
||||||
|
|
@ -64,12 +64,13 @@ 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(price * quantity)
|
select sum(total)
|
||||||
from bookings
|
from (select sum(price * quantity) as total
|
||||||
join items on bookings.id = items.booking_id
|
from bookings
|
||||||
join payments on bookings.id = payments.booking_id
|
join items on bookings.id = items.booking_id
|
||||||
where payments.method = 'card'
|
where "to" between ? and ?
|
||||||
and "to" between ? and ?;
|
and payment_method = 'Card'
|
||||||
|
group by booking_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)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue