compucorp / uk.co.compucorp.membershipextras

Membership Extras for CiviCRM
Other
5 stars 8 forks source link

IO-122: Update hooks for creating payment plan when creating a new membership for the schedule new UI #340

Closed erawat closed 3 years ago

erawat commented 3 years ago

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

 'duration_interval' => 1,
 'duration_unit' => 'year',
 //01 Oct
 'fixed_period_start_day' => 1001,
 // 30 Sep
 'fixed_period_rollover_day' => 930,

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