Skip to content

Commit

Permalink
fix(registration date): fixed member registration date being 3 months…
Browse files Browse the repository at this point in the history
… into the future
  • Loading branch information
ikjelle committed Dec 23, 2024
1 parent 047517e commit 23005d0
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Controller/Admin/MembershipApplicationCrud.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,17 @@ public function acceptApplication(AdminContext $context)
$init_payment->setPaymentTime($member->getRegistrationTime());
$init_payment->setPeriodYear($member->getRegistrationTime()->format('Y'));
$init_payment->setPeriodMonthStart($member->getRegistrationTime()->format('n'));
# cloning object, so the original DateTime object will not be modified
$registration_date = clone $member->getRegistrationTime();
switch ($member->getContributionPeriod()) {
case $member::PERIOD_MONTHLY:
$init_payment->setPeriodMonthEnd($member->getRegistrationTime()->modify('+1 month')->format('n'));
$init_payment->setPeriodMonthEnd($registration_date->modify('+1 month')->format('n'));
break;
case $member::PERIOD_QUARTERLY:
$init_payment->setPeriodMonthEnd($member->getRegistrationTime()->modify('+3 month')->format('n'));
$init_payment->setPeriodMonthEnd($registration_date->modify('+3 month')->format('n'));
break;
case $member::PERIOD_ANNUALLY:
$init_payment->setPeriodMonthEnd($member->getRegistrationTime()->modify('+12 month')->format('n'));
$init_payment->setPeriodMonthEnd($registration_date->modify('+12 month')->format('n'));
break;
default:
throw new \Exception('Period must be PERIOD_MONTHLY, PERIOD_QUARTERLY or PERIOD_ANNUALLY');
Expand Down

0 comments on commit 23005d0

Please sign in to comment.