compucorp / uk.co.compucorp.membershipextras

Membership Extras for CiviCRM
Other
5 stars 8 forks source link

IO-122: Add API to support price field values option #326

Closed erawat closed 3 years ago

erawat commented 3 years ago

Overview

This PR adds / refactors existing Payment Schedule API to support getByPriceFieldValues and getByMembershipType actions.

This PR also includes new fabricators, refactoring code and add more testes to the instalment schedule classes as well adding API helper that shares usage by both actions.

Before

Payment Schedule API only supports membership type as parameters

After

Payment Schedule API supports membership type and price field values through different actions.

Technical Details

There are details that worth mentioning on this section.

APIs

PaymentSchedule.getByPriceFieldValues - This API requires selected price field values which can be multiple, so the field price_field_values must be that passed to the API as an array that includes selected quantity for non membership type price field value and quantity equals 1 if a membership type is attached to price field values. Since we only support an array of price_field_values, an operator "IN" is the only operators that support for this API.

PaymentSchedule.getByMembershipTypeId - This API requires selected membership type ID

More details about how to use the API can be found in the API unit tests https://github.com/compucorp/uk.co.compucorp.membershipextras/blob/IO-122-simplify-admin-ui/tests/phpunit/api/v3/PaymentScheduleTest.php

as well as the implementation on the PaymentPlanToggler https://github.com/compucorp/uk.co.compucorp.membershipextras/blob/IO-122-simplify-admin-ui/templates/CRM/Member/Form/PaymentPlanToggler.tpl#L109

Comments

This PR supports only rolling membership type as the fixed membership type as prorata will be implemented in the next stage.