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

CRM-20676 Add tax_amount to contribution create params so it doesn't get added … #11461

Merged
merged 1 commit into from
Feb 8, 2018

Conversation

mattwire
Copy link
Contributor

@mattwire mattwire commented Dec 27, 2017

…to calculation

Overview

Follow on from #11455. This fixes an issue where tax is repeatedly added on contribution edit as it's not passed in the params to contribution create.

@mattwire mattwire changed the title Add tax_amount to contribution create params so it doesn't get added … WIP Add tax_amount to contribution create params so it doesn't get added … Dec 27, 2017
@mattwire mattwire changed the title WIP Add tax_amount to contribution create params so it doesn't get added … CRM-20676 Add tax_amount to contribution create params so it doesn't get added … Jan 4, 2018
@eileenmcnaughton
Copy link
Contributor

@mattwire can you explain the circumstances under which this is still required?

@mattwire
Copy link
Contributor Author

@eileenmcnaughton

  1. Create a membership price set containing a membership that has sales tax enabled.
  2. Click on "Add new membership" via backend and record payment.
  3. Find the newly created contribution and click "Edit".
  4. Now click "Save". You'll see that an additional line item has been created with a newly calculated tax amount. This happens each time you click "Edit" with latest master.

@eileenmcnaughton
Copy link
Contributor

@monishdeb ^^

@monishdeb
Copy link
Member

Yup, it fixed the issue, here's the before/after screencast:

Before

test-multiple-before

After

test-multiple-after

@monishdeb
Copy link
Member

monishdeb commented Jan 16, 2018

@eileenmcnaughton @mattwire now I am thinking how we could possibly add a unit test to capture this use-case. So here's my thought, I have added a unit-test testLineItemAmountOnSaleTax() here that has a initial steps for this issue to replicate, those are :

  1. Create a membership price set containing a membership that has sales tax enabled.
  2. Do a backoffice membership.

Now after #11521 is merged, we need to extend the UT to do these steps:
3. Simply save backoffice contribution in Edit mode.
4. Check the line-item and contribution details to ensure there is no additional record / surplus total amount respectively.

What do you think?

@monishdeb monishdeb added the merge ready PR will be merged after a few days if there are no objections label Jan 16, 2018
@monishdeb
Copy link
Member

I have added 'merged ready' tag as the fix is good to merge, but then we need unit-test to avoid any recurrence.

@mattwire
Copy link
Contributor Author

I just triggered the issue again running the Contribution.repeattransaction API - this issue fixes that too.

@eileenmcnaughton
Copy link
Contributor

sounds like repeattransaction will be the easiest place to do the test - there are a tonne already in api_v3_ContributionTest

@monishdeb
Copy link
Member

@mattwire I have extended a existing unit-test for this fix and this is the patch https://gist.github.com/monishdeb/ab5d62fb6799f4e3d99f8e75432a64ca

In addition to that, can you add a unit test with repeattransaction API?

@monishdeb
Copy link
Member

I have submitted a PR #11655 that has the UT for it, hence merging.

@monishdeb monishdeb merged commit 3ee8b77 into civicrm:master Feb 8, 2018
@monishdeb monishdeb mentioned this pull request Feb 8, 2018
@mlutfy mlutfy added this to the 4.7.31 milestone Feb 9, 2018
@mattwire mattwire deleted the tax_calcs_on_edit_contribution branch September 25, 2018 11:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
master merge ready PR will be merged after a few days if there are no objections
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants