From 48cc0e542b41e8d0d4c2736fdc393593bb96ec07 Mon Sep 17 00:00:00 2001 From: Nowa Ammerlaan Date: Sun, 17 Nov 2024 16:41:39 +0100 Subject: [PATCH] Member.php: also properly resolve monthly and yearly payments Closes: https://github.com/roodjong/mijnrood/issues/203 Signed-off-by: Nowa Ammerlaan --- src/Entity/Member.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Entity/Member.php b/src/Entity/Member.php index 65108a8..ac1d03b 100644 --- a/src/Entity/Member.php +++ b/src/Entity/Member.php @@ -264,20 +264,18 @@ public function setIsAdmin(bool $isAdmin): void { } public function isContributionCompleted(DateTime $when) { - $year = $when->format('Y'); - $month = $when->format('n'); switch ($this->getContributionPeriod()) { case self::PERIOD_MONTHLY: - $payments = $this->contributionPayments->filter(fn($payment) => $payment->getPeriodYear() == $year && $payment->getPeriodMonthStart() == $month); + $when->modify('-1 month'); break; case self::PERIOD_QUARTERLY: $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); + $when->modify('-12 months'); break; } + $payments = $this->contributionPayments->filter(fn($payment) => $payment->getPaymentTime() >= $when); $payments = $payments->filter(fn($payment) => $payment->getStatus() == ContributionPayment::STATUS_PAID); return count($payments) > 0; }