From bcc0dc793487019c2c8ae2afd19a80ff556d922b Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Fri, 24 Nov 2023 17:32:52 +1300 Subject: [PATCH] Specify tax when lines not being passed to contributon create --- .../Form/Contribution/ConfirmTest.php | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/phpunit/CRM/Contribute/Form/Contribution/ConfirmTest.php b/tests/phpunit/CRM/Contribute/Form/Contribution/ConfirmTest.php index a5b96ead08..8c4d109108 100644 --- a/tests/phpunit/CRM/Contribute/Form/Contribution/ConfirmTest.php +++ b/tests/phpunit/CRM/Contribute/Form/Contribution/ConfirmTest.php @@ -242,6 +242,27 @@ class CRM_Contribute_Form_Contribution_ConfirmTest extends CiviUnitTestCase { $this->assertEquals(127.5, $contribution['total_amount']); } + /** + * Test the tax calculation when using a quick config price set with a membership selection & a contribution (radio) selection. + * + * Expected amount is $100 non-tax deductible + $100 with an additional $10 tax. + */ + public function testSeparatePaymentWithTaxOtherAmount(): void { + $this->enableTaxAndInvoicing(); + $this->addTaxAccountToFinancialType(CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'financial_type_id', 'Donation')); + $this->contributionPageQuickConfigCreate([], [], FALSE, TRUE, TRUE, TRUE); + $this->submitOnlineContributionForm([ + 'payment_processor_id' => $this->ids['PaymentProcessor']['dummy'], + 'price_' . $this->ids['PriceField']['other_amount'] => 100, + 'price_' . $this->ids['PriceField']['membership_amount'] => $this->ids['PriceFieldValue']['membership_general'], + 'id' => $this->getContributionPageID(), + ] + $this->getBillingSubmitValues(), $this->getContributionPageID()); + + $contribution = $this->callAPISuccessGetSingle('Contribution', ['contribution_page_id' => $this->getContributionPageID(), 'version' => 4]); + $this->assertEquals(10, $contribution['tax_amount']); + $this->assertEquals(210, $contribution['total_amount']); + } + /** * Test the confirm form with a separate membership payment configured. */ -- 2.25.1