dev/core#193: Ensure that tax amount is calculated when checking for order API line item #13091
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.
The PR Replaces the following :
Overview
When creating an Order using Order API a check is done to compare Contribution's total_amount against the sum of line item's line_total's. If Contribution total amount and Line Items' total are not equal, Order creation will fail.
Before
As we know:
The line item line_total do not include any tax. Tax will be recorded separately in line item tax_amount field.
The contribution total_amount do include tax. A separate contribution tax_amount field also records the amount of tax.
Since the validation only compares the sum of line_totals with contribution total_amount, whenever there is tax, the validation will fail.
For illustration consider following data set that should create 1 contribution with 2 line items for memberships.
Currently Calling the Order API to create Order with the above data results with "Line item total doesn't match with total amount". This is because total_amount (22.0) <> sum of line_totals (18.33)
After
The Line Items check now consider tax_amounts of line_items and order API works fine with the parameters above.