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 call to validateAllContributions & fix getTotalAmount #20391

Merged
merged 1 commit into from
May 24, 2021

Conversation

eileenmcnaughton
Copy link
Contributor

@eileenmcnaughton eileenmcnaughton commented May 24, 2021

Overview

Add call to validateAllContributions & fix getTotalAmount

Before

The check in validateAllContributions is checking that the contribution.total_amount = SUM(line_item.line_total) but in fact it should be SUM(line_item.line_total) + SUM(line_item.tax_amount). On fixing that (to allow the check to be added to testCompleteTransactionFeeAmount & pass I found that testSubmitContributionPageWithPriceSetQuantity was failing - however the failure is in the part that is used by the unit tests & the (unused out side of tests ? ) ContributionPage.submit api.

After

$order->getTotalAmount() fixed to be SUM(line_item.line_total) + SUM(line_item.tax_amount)

Technical Details

I found this trying to extend test cover to allow us to deal with #20357 - it's possible this could be a regression in the back office membership class which does use this function - but I'm unclear about that and am on the fence about putting this against master or the rc

Comments

@civibot
Copy link

civibot bot commented May 24, 2021

(Standard links)

@civibot civibot bot added the master label May 24, 2021
$contribution1 = $this->callAPISuccess('contribution', 'get', ['id' => $contribution['id'], 'return' => 'tax_amount', 'sequential' => 1]);
$this->callAPISuccess('contribution', 'completetransaction', [
'id' => $contribution['id'],
$params = array_merge($this->_params, ['contribution_status_id' => 2, 'sequential' => 1, 'financial_type_id' => $financialTypeId]);
Copy link
Member

@monishdeb monishdeb May 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eileenmcnaughton can you please change the 2 to 'Pending' !!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just moved it down - see it's a few lines above - - but it should be Pending if I'm changing it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops I mean changing 2 to 'Pending'.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK - updated - I actually flicked it over to Order.create which no longer requires contribution_status_id (forces it to pending)

I've updated 2 tests for readability and extended one to call
validateAllContributions. The call failed and it turned out to
be the check was wrong. Fixing that caused a test to fail.
I have fixed the test by fixing getTotalAmount on the internal
helper BAO_Order class to include the tax_amount for each line
in the total.

I think this would most affect tests - but it might affect the
Membership_Form due to changes made recently to that
form so I'm on the fence about going for the rc with this
one
@eileenmcnaughton
Copy link
Contributor Author

@monishdeb well at least this one has passed!

@monishdeb
Copy link
Member

Looks good, tested on local. r-run passed.

@monishdeb monishdeb merged commit 9ab168f into civicrm:master May 24, 2021
@eileenmcnaughton eileenmcnaughton deleted the tax_valid branch May 24, 2021 06:53
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.

2 participants