Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESEB-137: Fix 'Next Contribution Date' for webform fixed memberships #516

Merged
merged 1 commit into from
Jan 29, 2024

Conversation

omarabuhussein
Copy link
Member

@omarabuhussein omarabuhussein commented Jan 26, 2024

Before

If you configure a webform with a payment plan and a fixed 1 year membership that starts at 1st of January and ends at 31th of December:

2024-01-27 00_46_25-

then the created recurring contribution "Next Scheduled Contribution Date" will be:

  • The first instalment receive date + 1 year (in case of single instalment payment plans)

Or

  • The last instalment receive date + 1 month (in case of monthly payment plan).

2024-01-27 00_46_04-ksaadka@ad com ksaadka@ad com _ Site-Install

2024-01-27 00_46_41-ksaadka@ad com ksaadka@ad com _ Site-Install

This shouldn't be the case, and instead the "Next Scheduled Contribution Date" should be:

  • The membership end date + 1 day

After

The "Next Scheduled Contribution Date" is : The membership end date + 1 day

2024-01-27 00_47_11-Settings

Technical Details

The PaymentPlanNextContributionDateUpdater Webform API passes the word "Creation" as 2nd argument to the PaymentPlanNextContributionDate Service that is responsible for calculating the "Next Scheduled Contribution Date"
instead of "creation" (all letters should be lower case), so this part of the code that is responsible for calculating the date for fixed memberships did not run:

if ($atLeastOneFixedMembershipExist && strtolower($this->operation) == 'creation') {
$nextScheduledDate = date('Y-m-d', strtotime($calculationMembership['end_date'] . '00:00:00 +1 day'));
$nextScheduledDateCycleDay = CRM_MembershipExtras_Service_CycleDayCalculator::calculate($nextScheduledDate, 'month');
$paymentPlanCycleDay = $this->recurContribution['cycle_day'];
$adjustmentDaysAmount = $paymentPlanCycleDay - $nextScheduledDateCycleDay;
$nextScheduledDate = new DateTime($nextScheduledDate);
$nextScheduledDate->modify("$adjustmentDaysAmount day");
return $nextScheduledDate->format('Y-m-d 00:00:00');

So I fixed this by passing the right operation name which is "creation" instead of "Creation", and as fail-safe I also change the $operation parameter letters to be lower case before using it.

@omarabuhussein omarabuhussein changed the base branch from master to ESEB-53-workstream January 26, 2024 22:17
@omarabuhussein omarabuhussein merged commit cbfc5d6 into ESEB-53-workstream Jan 29, 2024
2 checks passed
@omarabuhussein omarabuhussein deleted the ESEB-137-fix-webform-recur-date branch January 29, 2024 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants