Adamw has uploaded a new change for review. https://gerrit.wikimedia.org/r/96675
Change subject: (FR #807) Recurring contributions keep the original contribution's gateway account name ...................................................................... (FR #807) Recurring contributions keep the original contribution's gateway account name Change-Id: Id53c0373e3c17fe90176e762e9836364b6512d3d --- M sites/all/modules/wmf_common/wmf_civicrm/wmf_civicrm.module 1 file changed, 25 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/crm refs/changes/75/96675/1 diff --git a/sites/all/modules/wmf_common/wmf_civicrm/wmf_civicrm.module b/sites/all/modules/wmf_common/wmf_civicrm/wmf_civicrm.module index f5911de..81e1d66 100644 --- a/sites/all/modules/wmf_common/wmf_civicrm/wmf_civicrm.module +++ b/sites/all/modules/wmf_common/wmf_civicrm/wmf_civicrm.module @@ -137,6 +137,7 @@ $field_map[ $field ] = $name; } $result = CRM_Core_BAO_CustomValueTable::getValues( $params ); + $ret = array(); foreach ( $result as $field => $value ) { if ( array_key_exists( $field, $field_map ) ) { $ret[ $field_map[ $field ] ] = $value; @@ -256,6 +257,30 @@ throw new WmfException("INVALID_MESSAGE", "No payment type found for message." ); } + // Carry info over from the earliest recorded recurring contribution. + if ( $recur_id ) { + $dbs = wmf_civicrm_get_dbs(); + $dbs->push( 'civicrm' ); + + $query = <<<EOS +SELECT MIN(id) AS contrib_id +FROM civicrm_contribution +WHERE contribution_recur_id = :recur_id +EOS; + $res = db_query( $query, array( + ':recur_id' => $recur_id, + ) ); + $original_contribution_id = $res->fetch()->contrib_id; + if ( $original_contribution_id ) { + $original_custom_values = wmf_civicrm_contribution_get_custom_values( + $original_contribution_id, array( 'gateway_account', ) + ); + if ( !empty( $original_custom_values['gateway_account'] ) ) { + $msg['gateway_account'] = $original_custom_values['gateway_account']; + } + } + } + $contribution = array( 'contact_id' => $contact[ 'id' ], 'total_amount' => $msg['gross'], -- To view, visit https://gerrit.wikimedia.org/r/96675 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id53c0373e3c17fe90176e762e9836364b6512d3d Gerrit-PatchSet: 1 Gerrit-Project: wikimedia/fundraising/crm Gerrit-Branch: master Gerrit-Owner: Adamw <awi...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits