From e0b16d8d07deefb2e7caba6c138af35f3f02e8f3 Mon Sep 17 00:00:00 2001 From: Obinna Ikeh Date: Sun, 15 Dec 2024 02:00:11 +0100 Subject: [PATCH] Fix Payment Overview display - Fix query on paymenthistory endpoint --- src/backend/app/Models/PaymentHistory.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/backend/app/Models/PaymentHistory.php b/src/backend/app/Models/PaymentHistory.php index 7db95fdfb..4fde2fc61 100644 --- a/src/backend/app/Models/PaymentHistory.php +++ b/src/backend/app/Models/PaymentHistory.php @@ -34,9 +34,10 @@ public function transaction(): BelongsTo { } public function getFlow(string $payer_type, int $payer_id, string $period, $limit = null, string $order = 'ASC') { - $sql = 'SELECT sum(amount) as amount, payment_type, CONCAT_WS("/", '.$period.') as aperiod from'. - ' payment_histories where payer_id=:payer_id and payer_type=:payer_type '. - 'GROUP by concat( '.$period.'), payment_type ORDER BY created_at '.$order; + $sql = 'SELECT sum(amount) as amount, payment_type, CONCAT_WS("/", '.$period.') as aperiod '. + 'FROM payment_histories '. + 'WHERE payer_id=:payer_id AND payer_type=:payer_type '. + 'GROUP by aperiod, payment_type ORDER BY aperiod '.$order; if ($limit !== null) { $sql .= ' limit '.(int) $limit;