compucorp / uk.co.compucorp.membershipextras

Membership Extras for CiviCRM
Other
5 stars 8 forks source link

IO-136: V5 contribution receive date calculation #380

Closed erawat closed 3 years ago

erawat commented 3 years ago

Overview

This PR modifies the custom CalculateContribuitonRecieveDate hook dispatches with an abstract params instead of dispatching contribution object.

Membership Extras version 5 provides a new payment schedule UI that virtualise the details of instalments that would be created as follow

screenshot-compuclient local-2021 04 14-15_17_57

The existing CalculateContribuitonRecieveDate hook did not support when the payment plan has not been created it yet therefore, the instalment date could not be modified to virtualise on the instalment schedule table.

This PR fixed that.

Before

Hook can only be dispatched after the membership form is submitted.

After

Hook can be dispatched either before and after the payment plan is created.

Technical Details

The parameter that was passed to the hook was the contribution object and the hook implementer that modify the instalment date (e.g. Manual Direct bit Extension) does not need all the information.

The new parameters that provide to hook are below, which would work when generating instalment schedule before and after submit the membership form.

    $params = [
      'membership_id' => NULL,
      'contribution_recur_id' => NULL,
      'previous_instalment_date' => NULL,
      'payment_schedule' => $this->schedule,
      'payment_instrument_id' => $paymentMethod,
      'membership_start_date' => $firstInstalmentDate,
      'frequency_interval' => $instalmentFrequencyInterval,
      'frequency_unit' => $instalmentFrequencyUnit,
    ];