This PR is to alter the existing Pre Process / Post Process hooks that used to create a payment plan based on the submitted values from the payment plan new form.
The PR also adds/includes:
Unit tests for existing hooks and service classes.
Instalment utility and traits helper.
New APIs for calculating payment schedule options based on selected membership type or price field values.
Functionalities for updating schedule on the payment plan template from the APIs instead of hard coded the options and calculated in the UI.
Improvement of the existing codes.
Re-wording installment to instalment of classes and variables.
Removal some validation hooks as they are longer needed.
Before
The pre process and pro process hooks did not work on the new payment plan form.
After
When the Membership form submitted the following scenarios / behavers have changed to:
Before contribution object being created:
Creating a Payment plan: instalments count, instalment frequency and instalment frequency unit are calculated based on the selected schedule (either monthly, quarterly and annual) and selected membership type or price field values.
Set first instalment (contribution) status to Pending and Pay Later to 1
Post process
Create remaining instalments (contributions) from the calculation based on membership dates, selected payment schedule, membership type.
Technical Details
Payment plan (recurring contribution) may have the different number of instalments from the actual instalment (contribution) as we may prorated the amount of instalment based on the membership type configuration.
For example, fixed membership type configured as below
and payment schedule is monthly and if membership is created today, the instalments recorded in recurring contribution shall be 12 and as the actual number of contribution created shall be 9 as we prorated the payment and once the membership is renewed, the number of instalments will be created as 12 instalments
9 is calculated from
Joined date or start date = 15-01-Y
Membership Period End day 30-09-Y
(30-09-Y) - (15-01-Y) = 9 months`
Unit tests are shipped the coverage of different scenarios which cover rolling / fixed membership type for different schedule, by days or by months for fixed annual schedule on different layers from APIs, Hooks and Services
Overview
This PR is to alter the existing Pre Process / Post Process hooks that used to create a payment plan based on the submitted values from the payment plan new form.
The PR also adds/includes:
Before
The pre process and pro process hooks did not work on the new payment plan form.
After
When the Membership form submitted the following scenarios / behavers have changed to:
Before contribution object being created:
Post process
Technical Details
Payment plan (recurring contribution) may have the different number of instalments from the actual instalment (contribution) as we may prorated the amount of instalment based on the membership type configuration.
For example, fixed membership type configured as below
and payment schedule is monthly and if membership is created today, the instalments recorded in recurring contribution shall be 12 and as the actual number of contribution created shall be 9 as we prorated the payment and once the membership is renewed, the number of instalments will be created as 12 instalments
9 is calculated from
Unit tests are shipped the coverage of different scenarios which cover rolling / fixed membership type for different schedule, by days or by months for fixed annual schedule on different layers from APIs, Hooks and Services