Mwalker has submitted this change and it was merged.

Change subject: distinguish duplicate refund from illegal reverse refund
......................................................................


distinguish duplicate refund from illegal reverse refund

Change-Id: I8485a73b7136088860b6258f154f48e90065a0a4
---
M sites/all/modules/wmf_common/wmf_civicrm/wmf_civicrm.module
1 file changed, 15 insertions(+), 3 deletions(-)

Approvals:
  Mwalker: Looks good to me, approved
  jenkins-bot: Verified



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 aaf40c7..2576f80 100644
--- a/sites/all/modules/wmf_common/wmf_civicrm/wmf_civicrm.module
+++ b/sites/all/modules/wmf_common/wmf_civicrm/wmf_civicrm.module
@@ -1195,14 +1195,26 @@
     $query = "
 SELECT id FROM wmf_contribution_extra
 WHERE
-    parent_contribution_id = %1
-    OR (entity_id = %1 AND COALESCE(parent_contribution_id, 0))";
+    parent_contribution_id = %1";
 
     $dao = CRM_Core_DAO::executeQuery( $query, array(
         1 => array( $contribution_id, 'Integer' ),
     ) );
     if ( $dao->fetch() ) {
-        throw new WmfException( 'INVALID_MESSAGE', "Contribution is already 
linked to a refund, or is itself a refund: $contribution_id" );
+        throw new WmfException( 'DUPLICATE_CONTRIBUTION', "Contribution is 
already refunded: $contribution_id" );
+    }
+
+    // Look for existing refunds
+    $query = "
+SELECT id FROM wmf_contribution_extra
+WHERE
+    entity_id = %1 AND COALESCE(parent_contribution_id, 0)";
+
+    $dao = CRM_Core_DAO::executeQuery( $query, array(
+        1 => array( $contribution_id, 'Integer' ),
+    ) );
+    if ( $dao->fetch() ) {
+        throw new WmfException( 'INVALID_MESSAGE', "Contribution to refund is 
itself a refund: $contribution_id" );
     }
 
     // Should we restore?

-- 
To view, visit https://gerrit.wikimedia.org/r/104173
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I8485a73b7136088860b6258f154f48e90065a0a4
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/crm
Gerrit-Branch: master
Gerrit-Owner: Adamw <awi...@wikimedia.org>
Gerrit-Reviewer: Katie Horn <kh...@wikimedia.org>
Gerrit-Reviewer: Mwalker <mwal...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to