Adamw has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/104173


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(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/crm 
refs/changes/73/104173/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 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: newchange
Gerrit-Change-Id: I8485a73b7136088860b6258f154f48e90065a0a4
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/crm
Gerrit-Branch: master
Gerrit-Owner: Adamw <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to