Skip to content

Commit 52d3b2d

Browse files
committed
Merge remote-tracking branch 'mpi/MAGETWO-53211' into MPI-PR-3005
2 parents 696a64e + b627095 commit 52d3b2d

File tree

3 files changed

+27
-5
lines changed

3 files changed

+27
-5
lines changed

app/code/Magento/Paypal/Model/Report/Settlement.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,13 @@ class Settlement extends \Magento\Framework\Model\AbstractModel
170170
*/
171171
private $dateTimeColumns = ['transaction_initiation_date', 'transaction_completion_date'];
172172

173+
/**
174+
* Columns with amount type
175+
*
176+
* @var array
177+
*/
178+
private $amountColumns = ['gross_transaction_amount', 'fee_amount'];
179+
173180
/**
174181
* @param \Magento\Framework\Model\Context $context
175182
* @param \Magento\Framework\Registry $registry
@@ -406,6 +413,9 @@ private function getBodyItems(array $line, array $sectionColumns, array $rowMap)
406413
if (in_array($rowMap[$sectionColumns[$i]], $this->dateTimeColumns)) {
407414
$line[$i] = $this->formatDateTimeColumns($line[$i]);
408415
}
416+
if (in_array($rowMap[$sectionColumns[$i]], $this->amountColumns)) {
417+
$line[$i] = $this->formatAmountColumn($line[$i]);
418+
}
409419
$bodyItem[$rowMap[$sectionColumns[$i]]] = $line[$i];
410420
}
411421
}
@@ -425,6 +435,19 @@ private function formatDateTimeColumns($lineItem)
425435
return $date->format(\Magento\Framework\Stdlib\DateTime::DATETIME_PHP_FORMAT);
426436
}
427437

438+
/**
439+
* Format amount columns
440+
*
441+
* PayPal api returns amounts in cents, hence the values need to be divided by 100
442+
*
443+
* @param string $lineItem
444+
* @return float
445+
*/
446+
private function formatAmountColumn($lineItem)
447+
{
448+
return intval($lineItem) / 100;
449+
}
450+
428451
/**
429452
* Load report by unique key (accoutn + report date)
430453
*

app/code/Magento/Paypal/Model/Report/Settlement/Row.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,7 @@ public function getDebitCreditText($code)
122122
/**
123123
* Cast amounts of the specified keys
124124
*
125-
* PayPal settlement reports contain amounts in cents, hence the values need to be divided by 100
126-
* Also if the "credit" value is detected, it will be casted to negative amount
125+
* If the "credit" value is detected, it will be casted to negative amount
127126
*
128127
* @param string $key
129128
* @return float|null
@@ -137,7 +136,7 @@ public function getCastedAmount($key)
137136
return null;
138137
}
139138

140-
$amount = $this->_data[$key] / 100;
139+
$amount = $this->_data[$key];
141140
if ('CR' == $this->_data[$this->castAmountRelation[$key]]) {
142141
$amount = -1 * $amount;
143142
}

app/code/Magento/Paypal/Test/Unit/Model/Report/Settlement/RowTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ public function getDebitCreditTextDataProvider()
107107
public function getCastedAmountDataProvider()
108108
{
109109
return [
110-
['fee_amount', ['fee_amount' => 100, 'fee_debit_or_credit' => 'CR'], -1],
111-
['fee_amount', ['fee_amount' => 100, 'fee_debit_or_credit' => 'DB'], 1]
110+
['fee_amount', ['fee_amount' => 1, 'fee_debit_or_credit' => 'CR'], -1],
111+
['fee_amount', ['fee_amount' => 1, 'fee_debit_or_credit' => 'DB'], 1]
112112
];
113113
}
114114
}

0 commit comments

Comments
 (0)