pr: [Nightly Fix] - Bug - Fix Double Tax Amount in Coupon Discount Calculation#58
Open
jewel-claw wants to merge 1 commit into
Open
Conversation
…lculation $paymentTotal is accumulated from all line items in the loop above, which includes tax line items ($paymentItem['type'] == 'tax_line'). So $paymentTotal already equals (subtotal + tax). When a coupon is applied, the old formula was: $paymentTotal = ($paymentTotal - $paymentTotal * $discountPercent/100) + $taxTotal This re-adds $taxTotal after the discount, causing tax to be counted twice in the transaction record. For example, with a $100 subtotal, $10 tax, and 10% coupon: correct total = $99, but old code produced $99 + $10 = $109. The original comment even flagged this: '//issue on bottom line'. Fix: remove the erroneous $taxTotal addition. Tax is already included in $paymentTotal and should be discounted proportionally along with the rest.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Bug: Tax is double-counted in the transaction record when a coupon is applied.
Root cause
In
SubmissionHandler::handleSubmission(),$paymentTotalis built by summing all line items including tax line items:So
$paymentTotal = subtotal + tax.When a coupon was applied, the old formula was:
This re-adds
$taxTotalafter applying the discount — double-counting tax in the stored transaction.Example: $100 subtotal, $10 tax, 10% coupon
$paymentTotalbefore = $110The original developer even commented
//issue on bottom lineflagging the problem.Fix: Remove the erroneous
+ $taxTotal. Tax is already included in$paymentTotaland is correctly discounted proportionally.