compucorp / uk.co.compucorp.membershipextras

Membership Extras for CiviCRM
Other
5 stars 8 forks source link

IO-56: Improve Direct Debit payment plan date calculations #338

Closed MiyaNoctem closed 3 years ago

MiyaNoctem commented 3 years ago

Overview

We need to improve the Direct Debit Start Date. The Start date of the DD payment plan should occur in the same month of sign up when possible. When it is not possible, the second and first instalment should be taken in the same month to match the membership and payments duration, though this should be an optional setting.

The is a final release into master of the work done for:

Before

Functionality to calculate first and second instalment dates according to new instruction and payment run dates was not implemented.

After

  1. Added a new setting so the admin can choose the second instalment to wither be:
    • 1 month after first contribution
    • Force on second month of membership
  2. Created new hook that is dispatched in ME extension before creating a contribution for a payment plan, so the hook can be used to alter the calculated receive date of each contribution.
  3. Implemented the new hook on DD extension to change the receive date of each contribution, depending on the new setting so:
    1. First contribution: receive date will be first available payment run date after first instruction run date + min days before payment run date.
    2. Second contribution: if setting is force on second month, it will check the start date of the membership and add 1 instalment frequency to calculate the receive date. Other wise it'll be one month after first contribution.
    3. Other contributions: for instalments > 2, receive date will always be 1 month after previous instalment.