From 77641de400a7e9e99b7eb03f66876e9e1612c27c Mon Sep 17 00:00:00 2001 From: Pradeep Nayak Date: Tue, 3 Jan 2017 19:59:46 +0530 Subject: [PATCH] CRM-19585, added test to check if line items are proportinally assigned when PI is changed for contribution having tax ---------------------------------------- * CRM-19585: Sales tax issue https://issues.civicrm.org/jira/browse/CRM-19585 --- .../CRM/Contribute/BAO/ContributionTest.php | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/phpunit/CRM/Contribute/BAO/ContributionTest.php b/tests/phpunit/CRM/Contribute/BAO/ContributionTest.php index 7f3ccdaf31..88b400f33c 100644 --- a/tests/phpunit/CRM/Contribute/BAO/ContributionTest.php +++ b/tests/phpunit/CRM/Contribute/BAO/ContributionTest.php @@ -1175,6 +1175,29 @@ WHERE eft.entity_id = %1 AND ft.to_financial_account_id <> %2"; } } + /** + * Test to check if amount is proportionally asigned for PI change. + */ + public function testProportionallyAssignedForPIChange() { + list($contribution, $financialAccount) = $this->createContributionWithTax(); + $params = array( + 'id' => $contribution['id'], + 'payment_instrument_id' => 3, + ); + $this->callAPISuccess('Contribution', 'create', $params); + $lastFinancialTrxnId = CRM_Core_BAO_FinancialTrxn::getFinancialTrxnId($contribution['id'], 'DESC'); + $eftParams = array( + 'entity_table' => 'civicrm_financial_item', + 'financial_trxn_id' => $lastFinancialTrxnId['financialTrxnId'], + ); + $entityFinancialTrxn = $this->callAPISuccess('EntityFinancialTrxn', 'Get', $eftParams); + $this->assertEquals($entityFinancialTrxn['count'], 2, 'Invalid count.'); + $testAmount = array(10, 100); + foreach ($entityFinancialTrxn['values'] as $value) { + $this->assertEquals($value['amount'], array_pop($testAmount), 'Invalid amount stored in civicrm_entity_financial_trxn.'); + } + } + /** * Function to create contribution with tax. */ -- 2.25.1