Skip to content
This repository has been archived by the owner on Aug 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #418 from beabee-communityrm/fix/paid-only-stats
Browse files Browse the repository at this point in the history
fix: filter for successful payments in stats
  • Loading branch information
wpf500 authored May 9, 2024
2 parents e232503 + 0b27415 commit d35d25b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/api/controllers/StatsController.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { PaymentStatus } from "@beabee/beabee-common";
import { plainToInstance } from "class-transformer";
import {
Authorized,
Expand Down Expand Up @@ -26,7 +27,10 @@ export class StatsController {
const payments = await createQueryBuilder(Payment, "p")
.select("SUM(p.amount)", "total")
.addSelect("AVG(p.amount)", "average")
.where("p.chargeDate BETWEEN :from AND :to", query)
.where("p.chargeDate BETWEEN :from AND :to AND status = :status", {
...query,
status: PaymentStatus.Successful
})
.getRawOne<{ total: number | null; average: number | null }>();

if (!payments) {
Expand Down

0 comments on commit d35d25b

Please sign in to comment.