Cdentinger has uploaded a new change for review. https://gerrit.wikimedia.org/r/224737
Change subject: handle duplicate refunds, strip comma from amounts ...................................................................... handle duplicate refunds, strip comma from amounts Change-Id: I6759f924d18b6827729831df6df7d4d01d75b230 --- M sites/all/modules/offline2civicrm/SquareFile.php 1 file changed, 15 insertions(+), 5 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/crm refs/changes/37/224737/1 diff --git a/sites/all/modules/offline2civicrm/SquareFile.php b/sites/all/modules/offline2civicrm/SquareFile.php index 44c6298..356333b 100644 --- a/sites/all/modules/offline2civicrm/SquareFile.php +++ b/sites/all/modules/offline2civicrm/SquareFile.php @@ -54,9 +54,11 @@ $msg['contribution_type'] = 'cash'; $msg['gross'] = ltrim( $msg['gross'], '$' ); + $msg['gross'] = preg_replace( '/,/', '', $msg['gross'] ); if ( array_key_exists('net', $msg) ) { $msg['net'] = ltrim( $msg['net'], '$' ); + $msg['net'] = preg_replace( '/,/', '', $msg['net'] ); } list($msg['first_name'], $msg['last_name']) = wmf_civicrm_janky_split_name( $msg['full_name'] ); @@ -88,11 +90,19 @@ // square sends refund rows with the same transaction ID as // the parent contribution. so in this case we still want to // ignore the sent row but also insert a wmf approved refund. - wmf_civicrm_mark_refund( - $duplicate[0]['id'], - 'refund', - true - ); + try { + wmf_civicrm_mark_refund( + $duplicate[0]['id'], + 'refund', + true + ); + } catch ( WmfException $ex ) { + // TODO DuplicateRowException? + if ( $ex->extra['type'] = 'DUPLICATE_CONTRIBUTION' ) { + return true; // duplicate refund + } + } + watchdog( 'offline2civicrm', 'Refunding contribution @id', array( '@id' => $duplicate[0]['id'], ), WATCHDOG_INFO ); -- To view, visit https://gerrit.wikimedia.org/r/224737 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I6759f924d18b6827729831df6df7d4d01d75b230 Gerrit-PatchSet: 1 Gerrit-Project: wikimedia/fundraising/crm Gerrit-Branch: master Gerrit-Owner: Cdentinger <cdentin...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits