diff --git a/CRM/Member/Form/MembershipRenewal.php b/CRM/Member/Form/MembershipRenewal.php index 5c73bca4367..3f7b106c6ae 100644 --- a/CRM/Member/Form/MembershipRenewal.php +++ b/CRM/Member/Form/MembershipRenewal.php @@ -639,6 +639,10 @@ protected function submit() { 'membership_id' => $renewMembership->id, 'contribution_recur_id' => $contributionRecurID, )); + //Remove `tax_amount` if it is not calculated. + if (CRM_Utils_Array::value('tax_amount', $temporaryParams) === 0) { + unset($temporaryParams['tax_amount']); + } CRM_Member_BAO_Membership::recordMembershipContribution($temporaryParams); } diff --git a/tests/phpunit/CRM/Member/Form/MembershipRenewalTest.php b/tests/phpunit/CRM/Member/Form/MembershipRenewalTest.php index 45e08918a88..0178ed745f4 100644 --- a/tests/phpunit/CRM/Member/Form/MembershipRenewalTest.php +++ b/tests/phpunit/CRM/Member/Form/MembershipRenewalTest.php @@ -404,8 +404,10 @@ public function testSubmitPayLater() { $contribution = $this->callAPISuccessGetSingle('Contribution', array( 'contact_id' => $this->_individualId, 'contribution_status_id' => 2, + 'return' => array("tax_amount", "trxn_id"), )); $this->assertEquals($contribution['trxn_id'], 777); + $this->assertEquals($contribution['tax_amount'], NULL); $this->callAPISuccessGetCount('LineItem', array( 'entity_id' => $membership['id'],