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

Add test for mixed Order data #20241

Merged
merged 1 commit into from
May 20, 2021
Merged

Conversation

eileenmcnaughton
Copy link
Contributor

@eileenmcnaughton eileenmcnaughton commented May 6, 2021

Overview

This test is to try to capture & replicate an issue @christianwach is having with order api on taxes with more than one row - @christianwach I feel like this should be failing from your experience but it didn't locally

Before

Less tests

After

More tests

Technical Details

This didn't replicate the issue but it's useful as a test I think & I can build on it

Comments

@civibot
Copy link

civibot bot commented May 6, 2021

(Standard links)

@civibot civibot bot added the master label May 6, 2021
@christianwach
Copy link
Member

christianwach commented May 6, 2021

@eileenmcnaughton I've added a Gist with complete details of the mismatch:

https://gist.github.com/christianwach/ac8e8460c7f488a9a31f30a2c74eefc6

There isn't a Taxable Financial Type in the CiviCRM Sample Data by default but I've added one (ID: 5) as per instructions from @kcristiano

@christianwach
Copy link
Member

@eileenmcnaughton A bit more info... so... turns out my Order API call wasn't as clean as I thought it was. Elsewhere, just after the Order.create, there was an attempt to update the Contribution with a contribution_note. Seems this triggers the recalculation.

I can now confirm that with a Non-taxable Financial Type applied to the Contribution and mixed Line Item Financial Types all seems to be well.

I'll keep digging with other combinations, but it seems updating a Contribution with a contribution_note is big no-no.

@JoeMurray
Copy link
Contributor

@monishdeb could you work to ensure that a contribution update does not result in inappropriate recalculation of sales taxes, which I imagine involves calculating it differently on subsequent saves.

@christianwach
Copy link
Member

Recalculation seems to happen any time a Contribution is updated regardless of whether the Financial Type is taxable or not e.g. a trivial update to the "Source":

$result = civicrm_api3('Contribution', 'create', [
  'financial_type_id' => 5, // Happens to be a Taxable Financial Type but need not be.
  'contact_id' => 206,
  'id' => 103,
  'source' => "Something",
]);

All taxes will be recalculated and the errors in the Gist can be observed. I've updated it to reflect the situation better:

https://gist.github.com/christianwach/ac8e8460c7f488a9a31f30a2c74eefc6

@eileenmcnaughton
Copy link
Contributor Author

@christianwach thanks for narrowing it down - that helps

@eileenmcnaughton eileenmcnaughton changed the title [WIP] Add test for data from Haystack Add test for mixed Order data May 20, 2021
@eileenmcnaughton
Copy link
Contributor Author

OK - I can replicate this now - @seamuslee001 we might as well merge this as an extra test & I can build on it to fix Christian's actual problem

@seamuslee001 seamuslee001 merged commit 499b3e4 into civicrm:master May 20, 2021
@seamuslee001 seamuslee001 deleted the haystack branch May 20, 2021 03:00
@christianwach
Copy link
Member

I can build on it to fix Christian's actual problem

@eileenmcnaughton That would be wonderful 🏅

@eileenmcnaughton
Copy link
Contributor Author

@christianwach I'm working on it over here - #20357 at this stage my fix assumes a lack of weird data being passed in which I am not sure is true :-)

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

Successfully merging this pull request may close these issues.

4 participants