From ed516a99a71b45f26a3c9b41cbf42e8c80317a56 Mon Sep 17 00:00:00 2001 From: Jelle Date: Mon, 23 Dec 2024 17:26:52 +0100 Subject: [PATCH] fix(registration date): fixed member registration date being 3 months into the future --- src/Controller/Admin/MembershipApplicationCrud.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Controller/Admin/MembershipApplicationCrud.php b/src/Controller/Admin/MembershipApplicationCrud.php index 2224de7..fd01c07 100644 --- a/src/Controller/Admin/MembershipApplicationCrud.php +++ b/src/Controller/Admin/MembershipApplicationCrud.php @@ -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 original date 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('+9 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');