Skip to content

Commit

Permalink
Member.php: also properly resolve monthly and yearly payments
Browse files Browse the repository at this point in the history
Closes: #203
Signed-off-by: Nowa Ammerlaan <[email protected]>
  • Loading branch information
Nowa-Ammerlaan committed Nov 17, 2024
1 parent 4c31fe0 commit 48cc0e5
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/Entity/Member.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 48cc0e5

Please sign in to comment.