);
$contribution = $this->callAPISuccess('contribution', 'update', $newParams);
$this->assertAPISuccess($contribution);
- $this->_checkFinancialTrxn($contribution, 'paymentInstrument');
+ $this->_checkFinancialTrxn($contribution, 'paymentInstrument', $instrumentId);
}
/*
}
}
- function _checkFinancialTrxn($contribution, $context) {
+ function _checkFinancialTrxn($contribution, $context, $instrumentId = NULL) {
$trxnParams = array(
'entity_id' => $contribution['id'],
'entity_table' => 'civicrm_contribution',
'from_financial_account_id' => CRM_Contribute_PseudoConstant::financialAccountType($contribution['financial_type_id'], $relationTypeId),
);
}
- elseif ($context == 'paymentInstrument') {
- $compareParams = array(
- 'from_financial_account_id' => 6,
- 'to_financial_account_id' => 7,
- );
- }
elseif ($context == 'refund') {
$compareParams = array(
'to_financial_account_id' => 6,
'status_id' => 3,
);
}
- elseif ($context == 'changeFinancial') {
+ elseif ($context == 'changeFinancial' || $context == 'paymentInstrument') {
$entityParams = array(
'entity_id' => $contribution['id'],
'entity_table' => 'civicrm_contribution',
'id' => $trxn['financial_trxn_id'],
);
$compareParams = array(
- 'to_financial_account_id' => 12,
'total_amount' => -100,
'status_id' => 1,
);
+ if ($context == 'paymentInstrument') {
+ $compareParams += array(
+ 'to_financial_account_id' => CRM_Financial_BAO_FinancialTypeAccount::getInstrumentFinancialAccount(4),
+ 'payment_instrument_id' => 4,
+ );
+ }
+ else {
+ $compareParams['to_financial_account_id'] = 12;
+ }
$this->assertDBCompareValues('CRM_Financial_DAO_FinancialTrxn', $trxnParams1, $compareParams);
- $compareParams = array(
- 'to_financial_account_id' => 12,
- 'total_amount' => 100,
- 'status_id' => 1,
- );
+ $compareParams['total_amount'] = 100;
+ if ($context == 'paymentInstrument') {
+ $compareParams['to_financial_account_id'] = CRM_Financial_BAO_FinancialTypeAccount::getInstrumentFinancialAccount($instrumentId);
+ $compareParams['payment_instrument_id'] = $instrumentId;
+ }
+ else {
+ $compareParams['to_financial_account_id'] = 12;
+ }
}
$this->assertDBCompareValues('CRM_Financial_DAO_FinancialTrxn', $params, $compareParams);