MAE-928: Fix discount when the payment plan tab is selected #458
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This PR does the following:
Apply the discount when the discount applied on payment plan tab
Before
Rolling + Tax (20%) + Discount (50Percent) = discount not applied

After
Rolling + Tax (20%) + Discount (50Percent) = discount is applied

Before
Fixed + Tax (20%) + Discount (50Percent) = discount not applied
After
Fixed + Tax (20%) + Discount (50Percent) = discount is applied
Technical Details
PaymentSchedule
API to display the instalments, so I modify the api by adding an extra fieldtotal_amount
, in which when the Membership Type and Payment Plan tab are selected, it will take the value oftotal_amount
input from the Contribution Tab (CiviDiscount when it applies the discount it modifies this value) which later will be used to calculate the discount and display the instalments schedule.total_amount
to the Contribution and LineItem which they send the values to thePeriodCalculatorType
to calculate the discount amount and calculate the new amount and tax.total_amount
(which the total amount after the discount) / (amount + tax) which is the total amount before the discount