Skip to content

Commit

Permalink
CRM-19585, added test
Browse files Browse the repository at this point in the history
----------------------------------------
* CRM-19585: Sales tax issue
  https://issues.civicrm.org/jira/browse/CRM-19585
  • Loading branch information
pradpnayak committed Jan 16, 2017
1 parent 24ce181 commit 6a52ffd
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions tests/phpunit/CRM/Contribute/BAO/ContributionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1228,4 +1228,60 @@ public function createContributionWithTax() {
return array($contribution, $financialAccount);
}

/*
* test for change in FT
*/
public function testChangePaymentInstrumentTax() {
$contactId = $this->individualCreate();
$this->enableTaxAndInvoicing();
$financialType = $this->createFinancialType();
$financialAccount = $this->relationForFinancialTypeWithFinancialAccount($financialType['id']);
$params = array(
'contact_id' => $contactId,
'currency' => 'USD',
'financial_type_id' => 1,
'contribution_status_id' => 1,
'payment_instrument_id' => 1,
'total_amount' => 200.00,
'fee_amount' => 0,
'non_deductible_amount' => 0,
);
$id = $this->contributionCreate($params);
$financialTrxn = $this->callAPISuccess('financial_trxn', 'get', array(
'trxn_id' => 12345,
));
$this->assertEquals($financialTrxn['count'], 1, 'Counts do not match.');
$this->assertEquals($financialTrxn['values'][1]['payment_instrument_id'], 1, 'Payment Instrument is not the same.');
$this->assertEquals($financialTrxn['values'][1]['total_amount'], 220.00, 'Amount does not match.');
$financialItem = $this->callAPISuccess('financial_item', 'get', array(
'contact_id' => $contactId,
));
$this->assertEquals($financialItem['count'], 2, 'Counts do not match.');
$this->assertEquals($financialItem['values'][1]['amount'], 200.00, 'Amount does not match.');
$this->assertEquals($financialItem['values'][2]['amount'], 20.00, 'Amount does not match.');
$this->assertEquals($financialItem['values'][2]['financial_account_id'], $financialAccount->financial_account_id, 'Account is not sales tax related.');
$this->assertEquals($financialItem['values'][2]['description'], 'Sales Tax', 'Account is not sales tax.');
// Change payment instrument.
$params['id'] = $id;
$params['payment_instrument_id'] = 2;
$this->contributionCreate($params);
$financialTrxn = $this->callAPISuccess('financial_trxn', 'get', array(
'trxn_id' => 12345,
));
$this->assertEquals($financialTrxn['count'], 3, 'Counts do not match.');
$this->assertEquals($financialTrxn['values'][2]['payment_instrument_id'], 1, 'Payment Instrument is not the same.');
$this->assertEquals($financialTrxn['values'][2]['total_amount'], -220.00, 'Amount does not match.');
$this->assertEquals($financialTrxn['values'][3]['total_amount'], 220.00, 'Amount does not match.');
$this->assertEquals($financialTrxn['values'][3]['payment_instrument_id'], 2, 'Payment Instrument is not the same.');
// Asserting no changes in financial item.
$financialItem = $this->callAPISuccess('financial_item', 'get', array(
'contact_id' => $contactId,
));
$this->assertEquals($financialItem['count'], 2, 'Counts do not match.');
$this->assertEquals($financialItem['values'][1]['amount'], 200.00, 'Amount does not match.');
$this->assertEquals($financialItem['values'][2]['amount'], 20.00, 'Amount does not match.');
$this->assertEquals($financialItem['values'][2]['financial_account_id'], $financialAccount->financial_account_id, 'Account is not sales tax related.');
$this->assertEquals($financialItem['values'][2]['description'], 'Sales Tax', 'Account is not sales tax.');
}

}

0 comments on commit 6a52ffd

Please sign in to comment.