* @param CRM_Contribute_BAO_Contribution $contribution
* @param array $input
* @param array $contributionParams
- * @param int $paymentProcessorID
*
- * @return bool
+ * @return bool|array
* @throws CiviCRM_API3_Exception
*/
- protected static function repeatTransaction(&$contribution, &$input, $contributionParams, $paymentProcessorID) {
+ protected static function repeatTransaction(&$contribution, &$input, $contributionParams) {
if (!empty($contribution->id)) {
return FALSE;
}
$contribution->id = $createContribution['id'];
$contribution->copyCustomFields($templateContribution['id'], $contribution->id);
self::handleMembershipIDOverride($contribution->id, $input);
- return TRUE;
+ return $createContribution;
}
}
}
$changeDate = CRM_Utils_Array::value('trxn_date', $input, date('YmdHis'));
- self::repeatTransaction($contribution, $input, $contributionParams, $paymentProcessorId);
+ $contributionResult = self::repeatTransaction($contribution, $input, $contributionParams);
$contributionParams['financial_type_id'] = $contribution->financial_type_id;
$values = [];
// CRM-19309 - if you update the contribution here with financial_type_id it can/will mess with $lineItem
// unsetting it here does NOT cause any other contribution test to fail!
unset($contributionParams['financial_type_id']);
- $contributionResult = civicrm_api3('Contribution', 'create', $contributionParams);
+ if (!$contributionResult) {
+ $contributionResult = civicrm_api3('Contribution', 'create', $contributionParams);
+ }
// Add new soft credit against current $contribution.
if (!empty($objects['contributionRecur']) && $objects['contributionRecur']->id) {
'contribution_recur_id' => $contributionRecur['id'],
'total_amount' => '3.00',
'financial_type_id' => 1,
+ 'source' => 'Template Contribution',
'payment_instrument_id' => 1,
'currency' => 'USD',
'contact_id' => $this->individualCreate(),
'contribution_recur_id' => $contributionRecur['id'],
'total_amount' => '3.00',
'financial_type_id' => 1,
+ 'source' => 'Non-template Contribution',
'payment_instrument_id' => 1,
'currency' => 'USD',
'contact_id' => $this->individualCreate(),
$fetchedTemplate = CRM_Contribute_BAO_ContributionRecur::getTemplateContribution($contributionRecur['id']);
// Fetched template should be the is_template, not the latest contrib
$this->assertEquals($fetchedTemplate['id'], $templateContrib['id']);
+
+ $repeatContribution = $this->callAPISuccess('Contribution', 'repeattransaction', [
+ 'contribution_status_id' => 'Completed',
+ 'contribution_recur_id' => $contributionRecur['id'],
+ ]);
+ $this->assertEquals('Template Contribution', $repeatContribution['values'][$repeatContribution['id']]['source']);
}
/**