[MediaWiki-commits] [Gerrit] wikimedia...SmashPig[master]: Add AuditParser interface, other audit cleanup
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/369748 ) Change subject: Add AuditParser interface, other audit cleanup .. Add AuditParser interface, other audit cleanup Get rid of unnecessary / undeclared fields, fix missing 'use', reset fileData on each new parse. Breaking change: Amazon audit parser renamed, just have to update the class name in the amazon audit module within crm. Change-Id: Icf3f9d927b6d3623aaf3d5c072f7d0b2e15c4307 --- A Core/DataFiles/AuditParser.php M PaymentProviders/Adyen/Audit/AdyenAudit.php M PaymentProviders/Adyen/ReferenceData.php R PaymentProviders/Amazon/Audit/AmazonAudit.php M PaymentProviders/Amazon/Audit/RefundReport.php M PaymentProviders/Amazon/Audit/SettlementReport.php M PaymentProviders/Amazon/Tests/phpunit/AuditTest.php M PaymentProviders/AstroPay/Audit/AstroPayAudit.php M PaymentProviders/Ingenico/Audit/IngenicoAudit.php M PaymentProviders/Ingenico/ReferenceData.php 10 files changed, 108 insertions(+), 95 deletions(-) Approvals: Mepps: Looks good to me, approved jenkins-bot: Verified diff --git a/Core/DataFiles/AuditParser.php b/Core/DataFiles/AuditParser.php new file mode 100644 index 000..5dd777e --- /dev/null +++ b/Core/DataFiles/AuditParser.php @@ -0,0 +1,14 @@ +https://docs.adyen.com/manuals/reporting-manual/settlement-detail-report-structure/settlement-detail-report-journal-types */ -class AdyenAudit { +class AdyenAudit implements AuditParser { - protected $columnHeaders; - protected $ignoredStatuses; - protected $fileData = array(); + protected $columnHeaders = array( + 'Company Account', + 'Merchant Account', + 'Psp Reference', + 'Merchant Reference', + 'Payment Method', + 'Creation Date', + 'TimeZone', + 'Type', + 'Modification Reference', + 'Gross Currency', + 'Gross Debit (GC)', + 'Gross Credit (GC)', + 'Exchange Rate', + 'Net Currency', + 'Net Debit (NC)', + 'Net Credit (NC)', + 'Commission (NC)', + 'Markup (NC)', + 'Scheme Fees (NC)', + 'Interchange (NC)', + 'Payment Method Variant', + 'Modification Merchant Reference', + 'Batch Number', + 'Reserved4', + 'Reserved5', + 'Reserved6', + 'Reserved7', + 'Reserved8', + 'Reserved9', + 'Reserved10', + ); + protected static $ignoredTypes = array( 'fee', 'misccosts', @@ -38,52 +70,18 @@ 'paidoutreversed', ); - public function __construct() { - $this->columnHeaders = array( - 'Company Account', - 'Merchant Account', - 'Psp Reference', - 'Merchant Reference', - 'Payment Method', - 'Creation Date', - 'TimeZone', - 'Type', - 'Modification Reference', - 'Gross Currency', - 'Gross Debit (GC)', - 'Gross Credit (GC)', - 'Exchange Rate', - 'Net Currency', - 'Net Debit (NC)', - 'Net Credit (NC)', - 'Commission (NC)', - 'Markup (NC)', - 'Scheme Fees (NC)', - 'Interchange (NC)', - 'Payment Method Variant', - 'Modification Merchant Reference', - 'Batch Number', - 'Reserved4', - 'Reserved5', - 'Reserved6', - 'Reserved7', - 'Reserved8', - 'Reserved9', - 'Reserved10', - ); - } + protected $fileData; - // TODO base class this? public function parseFile( $path ) { - $this->path = $path; - $this->file = fopen( $path, 'r' ); + $this->fileData = array(); + $file = fopen( $path, 'r' ); $ignoreLines = 1; for ( $i = 0; $i < $ignoreLines; $i++ ) { - fgets( $this->file ); + fgets( $file ); } - while ( $line = fgetcsv( $this->file, 0, ',', '"', '\\' ) ) { + while ( $line = fgetcsv( $file, 0, ',', '"', '\\' ) ) { try { $this->parseLine( $line );
[MediaWiki-commits] [Gerrit] wikimedia...SmashPig[master]: Add AuditParser interface, other audit cleanup
Ejegg has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/369748 ) Change subject: Add AuditParser interface, other audit cleanup .. Add AuditParser interface, other audit cleanup Get rid of unnecessary / undeclared fields, fix missing 'use', reset fileData on each new parse. Change-Id: Icf3f9d927b6d3623aaf3d5c072f7d0b2e15c4307 --- A Core/DataFiles/AuditParser.php M PaymentProviders/Adyen/Audit/AdyenAudit.php R PaymentProviders/Amazon/Audit/AmazonAudit.php M PaymentProviders/Amazon/Tests/phpunit/AuditTest.php M PaymentProviders/AstroPay/Audit/AstroPayAudit.php M PaymentProviders/Ingenico/Audit/IngenicoAudit.php 6 files changed, 66 insertions(+), 53 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/SmashPig refs/changes/48/369748/1 diff --git a/Core/DataFiles/AuditParser.php b/Core/DataFiles/AuditParser.php new file mode 100644 index 000..5dd777e --- /dev/null +++ b/Core/DataFiles/AuditParser.php @@ -0,0 +1,14 @@ +https://docs.adyen.com/manuals/reporting-manual/settlement-detail-report-structure/settlement-detail-report-journal-types */ -class AdyenAudit { +class AdyenAudit implements AuditParser { protected $columnHeaders; protected $ignoredStatuses; @@ -73,17 +75,16 @@ ); } - // TODO base class this? public function parseFile( $path ) { - $this->path = $path; - $this->file = fopen( $path, 'r' ); + $this->fileData = array(); + $file = fopen( $path, 'r' ); $ignoreLines = 1; for ( $i = 0; $i < $ignoreLines; $i++ ) { - fgets( $this->file ); + fgets( $file ); } - while ( $line = fgetcsv( $this->file, 0, ',', '"', '\\' ) ) { + while ( $line = fgetcsv( $file, 0, ',', '"', '\\' ) ) { try { $this->parseLine( $line ); } catch ( NormalizationException $ex ) { @@ -91,7 +92,7 @@ Logger::error( $ex->getMessage() ); } } - fclose( $this->file ); + fclose( $file ); return $this->fileData; } diff --git a/PaymentProviders/Amazon/Audit/AuditParser.php b/PaymentProviders/Amazon/Audit/AmazonAudit.php similarity index 84% rename from PaymentProviders/Amazon/Audit/AuditParser.php rename to PaymentProviders/Amazon/Audit/AmazonAudit.php index d474c89..2d9db5d 100644 --- a/PaymentProviders/Amazon/Audit/AuditParser.php +++ b/PaymentProviders/Amazon/Audit/AmazonAudit.php @@ -1,11 +1,12 @@ getProviderConfiguration(); diff --git a/PaymentProviders/Amazon/Tests/phpunit/AuditTest.php b/PaymentProviders/Amazon/Tests/phpunit/AuditTest.php index 29f13b0..aca8e15 100644 --- a/PaymentProviders/Amazon/Tests/phpunit/AuditTest.php +++ b/PaymentProviders/Amazon/Tests/phpunit/AuditTest.php @@ -3,7 +3,7 @@ use SmashPig\Core\Context; use SmashPig\Tests\BaseSmashPigUnitTestCase; -use SmashPig\PaymentProviders\Amazon\Audit\AuditParser; +use SmashPig\PaymentProviders\Amazon\Audit\AmazonAudit; /** * Verify Amazon audit file processor functions @@ -20,7 +20,7 @@ * Normal donation */ public function testProcessDonation() { - $processor = new AuditParser(); + $processor = new AmazonAudit(); $output = $processor->parseFile( __DIR__ . '/../Data/audit/2015-10-01-SETTLEMENT_DATA_37127304077.csv' ); $this->assertEquals( 1, count( $output ), 'Should have found one donation' ); $actual = $output[0]; @@ -42,7 +42,7 @@ * Now try a refund */ public function testProcessRefund() { - $processor = new AuditParser(); + $processor = new AmazonAudit(); $output = $processor->parseFile( __DIR__ . '/../Data/audit/2015-10-06-REFUND_DATA_41474930002.csv' ); $this->assertEquals( 1, count( $output ), 'Should have found one refund' ); $actual = $output[0]; @@ -62,7 +62,7 @@ * And a chargeback */ public function testProcessChargeback() { - $processor = new AuditParser(); + $processor = new AmazonAudit(); $output = $processor->parseFile( __DIR__ . '/../Data/audit/2015-10-06-REFUND_DATA_41474930003.csv' ); $this->assertEquals( 1, count( $output ), 'Should have found one chargeback' ); $actual = $output[0]; diff --git a/PaymentProviders/AstroPay/Audit/AstroPayAudit.php b/PaymentProviders/AstroPay/Audit/AstroPayAudit.php index dc19101..771cb3f 100644 --- a/PaymentProviders/AstroPay/Audit/AstroPayAudit.php +++ b/PaymentProviders/AstroPay/Audit/AstroPayAudit.php @@ -1,59 +1,54 @@