Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev/core#1972 Fix tax_amount calclation on renewal form #18271

Merged
merged 1 commit into from
Aug 28, 2020

Conversation

eileenmcnaughton
Copy link
Contributor

@eileenmcnaughton eileenmcnaughton commented Aug 28, 2020

Overview

Fixes a regression whereby the tax_amount was incorrectly calculated on the membership renewal form

Before

Tax (for a 10% rate) was calculated as

tax = totalAmount * .10

After

tax = totalAmount - (totalAmount / 1.1)

Technical Details

If the PR involves technical details/changes/considerations which would not be manifest to a casual developer skimming the above sections, please describe the details here.

Comments

@KarinG has detailed this well in https://lab.civicrm.org/dev/core/-/issues/1972

We should backport this once merged

@civibot
Copy link

civibot bot commented Aug 28, 2020

(Standard links)

@civibot civibot bot added the master label Aug 28, 2020
@eileenmcnaughton eileenmcnaughton changed the base branch from master to 5.29 August 28, 2020 01:06
@civibot civibot bot added 5.29 and removed master labels Aug 28, 2020
@KarinG
Copy link
Contributor

KarinG commented Aug 28, 2020

Documenting that I've tested this extensively - have had this in our repo for >48h - it fixes renewal with Tax issues:

[karin@ectemnia BAO]$ git diff Order.php.DIST Order.php
diff --git a/CRM/Financial/BAO/Order.php b/CRM/Financial/BAO/Order.php
index cb43851..1faea92 100644
--- a/CRM/Financial/BAO/Order.php
+++ b/CRM/Financial/BAO/Order.php
@@ -248,7 +248,7 @@ class CRM_Financial_BAO_Order {
       if ($this->getOverrideTotalAmount() !== FALSE) {
         if ($taxRate) {
           // Total is tax inclusive.
-          $lineItem['tax_amount'] = ($taxRate / 100) * $this->getOverrideTotalAmount();
+          $lineItem['tax_amount'] = ($taxRate / 100) * $this->getOverrideTotalAmount() / (1 + ($taxRate / 100));
           $lineItem['line_total'] = $lineItem['unit_price'] = $this->getOverrideTotalAmount() - $lineItem['tax_amount'];
         }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants