From 604b820a1d327cc874bbe6baa215feb6aff18d01 Mon Sep 17 00:00:00 2001 From: Robin de Rooij Date: Sat, 27 Jul 2024 20:36:03 +0200 Subject: [PATCH] Fix the check if contribution is payed on quarterly payments (#204) The check was broken. In most cases, the contribution should be considered "payed" when at least one payment happened during the last 3 months when the subscription type is quarterly. --- src/Entity/Member.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Entity/Member.php b/src/Entity/Member.php index 02a3202..65108a8 100644 --- a/src/Entity/Member.php +++ b/src/Entity/Member.php @@ -271,8 +271,8 @@ public function isContributionCompleted(DateTime $when) { $payments = $this->contributionPayments->filter(fn($payment) => $payment->getPeriodYear() == $year && $payment->getPeriodMonthStart() == $month); break; case self::PERIOD_QUARTERLY: - $quarter = ceil($month / 3); - $payments = $this->contributionPayments->filter(fn($payment) => $payment->getPeriodYear() == $year && $payment->getPeriodMonthStart() <= $month && $payment->getPeriodMonthEnd() >= $month); + $when->modify('-3 months'); + $payments = $this->contributionPayments->filter(fn($payment) => $payment->getPaymentTime() >= $when); break; case self::PERIOD_ANNUALLY: $payments = $this->contributionPayments->filter(fn($payment) => $payment->getPeriodYear() == $year);