Awight has uploaded a new change for review.
https://gerrit.wikimedia.org/r/148272
Change subject: (FR #1819) Updated Coinbase report format
......................................................................
(FR #1819) Updated Coinbase report format
Handles subscriptions and refunds.
Change-Id: I117624bc6b3b4b7c406d618592fbf337d77a6d24
---
M sites/all/modules/offline2civicrm/ChecksFile.php
M sites/all/modules/offline2civicrm/CoinbaseFile.php
M sites/all/modules/offline2civicrm/upload_form.js
3 files changed, 37 insertions(+), 5 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/crm
refs/changes/72/148272/1
diff --git a/sites/all/modules/offline2civicrm/ChecksFile.php
b/sites/all/modules/offline2civicrm/ChecksFile.php
index 8034a71..893f73c 100644
--- a/sites/all/modules/offline2civicrm/ChecksFile.php
+++ b/sites/all/modules/offline2civicrm/ChecksFile.php
@@ -78,6 +78,7 @@
// tha business.
$contribution = wmf_civicrm_contribution_message_import( $msg );
+ $this->mungeContribution( $contribution );
watchdog( 'offline2civicrm',
'Import checks: Contribution imported successfully (@id):
!msg', array(
@@ -222,6 +223,16 @@
) );
}
+ /**
+ * Do fancy stuff with the contribution we just created
+ *
+ * FIXME: We need to wrap each loop iteration in a transaction to
+ * make this safe. Otherwise we can easily die before adding the
+ * second message, and skip it when resuming the import.
+ */
+ protected function mungeContribution( $contribution ) {
+ }
+
protected function getDefaultValues() {
return array(
'contact_source' => 'check',
diff --git a/sites/all/modules/offline2civicrm/CoinbaseFile.php
b/sites/all/modules/offline2civicrm/CoinbaseFile.php
index 0d35560..9e6f746 100644
--- a/sites/all/modules/offline2civicrm/CoinbaseFile.php
+++ b/sites/all/modules/offline2civicrm/CoinbaseFile.php
@@ -6,7 +6,8 @@
* See https://coinbase.com/reports
*/
class CoinbaseFile extends ChecksFile {
- protected $numSkippedRows = 3;
+ protected $numSkippedRows = 2;
+ protected $refundLastTransaction = false;
protected function getRequiredColumns() {
return array(
@@ -16,6 +17,8 @@
'Customer Email',
'Native Price',
'Phone Number',
+ 'Recurring Payment ID',
+ 'Refund Transaction ID',
'Shipping Address 1',
'Shipping Address 2',
'Shipping City',
@@ -50,8 +53,24 @@
$msg['first_name'] = $msg['full_name'];
- if ( $msg['gross'] < 0 ) {
- $msg['contribution_type'] = 'refund';
+ if ( !empty( $msg['gateway_refund_id'] ) ) {
+ $this->refundLastTransaction = true;
+ unset( $msg['gateway_refund_id'] );
+ }
+ }
+
+ protected function mungeContribution( $contribution ) {
+ if ( $this->refundLastTransaction ) {
+ wmf_civicrm_mark_refund(
+ $contribution['id'],
+ 'refund',
+ true
+ );
+ watchdog( 'offline2civicrm', 'Refunding contribution @id', array(
+ '@id' => $contribution['id'],
+ ), WATCHDOG_INFO );
+
+ $this->refundLastTransaction = false;
}
}
@@ -64,14 +83,16 @@
'date' => 'Timestamp',
'email' => 'Customer Email',
'full_name' => 'Shipping Name',
- //'gateway_status_raw' => 'Status', // TODO
+ 'gateway_status_raw' => 'Status',
'gateway_txn_id' => 'Tracking Code',
+ 'gateway_refund_id' => 'Refund Transaction ID',
'gross' => 'Native Price',
'original_gross' => 'BTC Price',
'phone' => 'Phone Number', // TODO: not stored
'postal_code' => 'Shipping Postal Code',
'state_province' => 'Shipping State',
'street_address' => 'Shipping Address 1',
+ 'subscr_id' => 'Recurring Payment ID',
'supplemental_address_1' => 'Shipping Address 2',
);
}
diff --git a/sites/all/modules/offline2civicrm/upload_form.js
b/sites/all/modules/offline2civicrm/upload_form.js
index 92b995a..54a2e10 100644
--- a/sites/all/modules/offline2civicrm/upload_form.js
+++ b/sites/all/modules/offline2civicrm/upload_form.js
@@ -11,7 +11,7 @@
if ( uploadFile ) {
$submitButton.removeAttr( "disabled" );
- if ( /Coinbase|Orders-Report/.test( uploadFile ) ) {
+ if ( /Coinbase|Orders-Report|\(Orders\)/.test( uploadFile ) ) {
fileType = "coinbase";
} else if ( /JPMorgan/.test( uploadFile ) ) {
fileType = "jpmorgan";
--
To view, visit https://gerrit.wikimedia.org/r/148272
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I117624bc6b3b4b7c406d618592fbf337d77a6d24
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/crm
Gerrit-Branch: master
Gerrit-Owner: Awight <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits