compucorp / uk.co.compucorp.membershipextras

Membership Extras for CiviCRM
Other
5 stars 8 forks source link

MAE-382: Add pro-rata calucation for annual instalment #333

Closed erawat closed 3 years ago

erawat commented 3 years ago

Overview

This PR is to add calculation of pro-rata of fixed period membership type for annual schedule instalment API. The calculation is done based on fixed membership type configuration (by days or by months). The implementation should support other schedules (monthly, quarterly) but the test for these schedules will be done separately.

The PR also refactored the existing classes / functions as well as adding validation to validation membership types.

Before

The Payment schedule API only support rolling membership type.

After

The Payment schedule API will also support fixed membership type with pro-rata based on membership type configuration and schedule

Technical details

The technical details that worth mentioned in this PR are

1. The design and usage of Membership Period Type Calculator.

CRM_MembershipExtras_Service_MembershipPeriodType_PeriodTypeCalculatorInterface interface is created as a blueprint so any calculation of membership period types can be implemented.

2. Traits in Test

A Couple of traits were added as helpers for mocking settings and fabricating sale tax financial types, so they can be used to across the settings that required them.