Skip to content
Snippets Groups Projects
Commit 3e1ff553 authored by mattwire's avatar mattwire
Browse files

Add workaround for #17777 so receive_date is not updated on contribution...

Add workaround for #17777 so receive_date is not updated on contribution (<5.29). Wrap workaround for order_reference in (<5.27) block
parent a0592fcb
No related branches found
No related tags found
No related merge requests found
......@@ -408,13 +408,33 @@ function civicrm_api3_mjwpayment_create_payment($params) {
civicrm_api3('Payment', 'cancel', $params);
$params['total_amount'] = $amount;
}
// @todo #17777 - we store receive_date so we can fix it later
if (version_compare(CRM_Utils_System::version(), '5.29', '<')) {
$contributionReceiveDate = (string) civicrm_api3('Contribution', 'getvalue', [
'id' => $params['contribution_id'],
'return' => 'receive_date'
]);
}
$trxn = CRM_Financial_BAO_Payment::create($params);
// @todo Payment.create didn't support order_reference param until CiviCRM version 5.27 (https://github.com/civicrm/civicrm-core/pull/17278)
civicrm_api3('FinancialTrxn', 'create', [
'id' => $trxn->id,
'order_reference' => $params['order_reference'],
]);
if (version_compare(CRM_Utils_System::version(), '5.27', '<')) {
// @todo Payment.create didn't support order_reference param until CiviCRM version 5.27 (https://github.com/civicrm/civicrm-core/pull/17278)
civicrm_api3('FinancialTrxn', 'create', [
'id' => $trxn->id,
'order_reference' => $params['order_reference'],
]);
}
if (version_compare(CRM_Utils_System::version(), '5.29', '<')) {
// @todo Fix contribution receive date as it should not be updated by Payment.create https://github.com/civicrm/civicrm-core/pull/17777
$sql = 'UPDATE civicrm_contribution SET receive_date="%2" WHERE id=%1';
$sqlParams = [
1 => [$params['contribution_id'], 'Positive'],
2 => [CRM_Utils_Date::isoToMysql($contributionReceiveDate), 'Date']
];
CRM_Core_DAO::executeQuery($sql, $sqlParams);
}
$values = [];
_civicrm_api3_object_to_array_unique_fields($trxn, $values[$trxn->id]);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment