Skip to content

Commit

Permalink
Fixed bug that total amount is showing negative when order with disco…
Browse files Browse the repository at this point in the history
…unt is partially refunded
  • Loading branch information
rav-redchamps committed Feb 16, 2019
1 parent d79eb08 commit d1e71b9
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -773,8 +773,8 @@ public function addRevenueToSelect($convertCurrency = false)
!$convertCurrency,
$this->getConnection()->getIfNullSql('main_table.base_subtotal_refunded', 0),
$this->getConnection()->getIfNullSql('main_table.base_subtotal_canceled', 0),
$this->getConnection()->getIfNullSql('main_table.base_discount_refunded', 0),
$this->getConnection()->getIfNullSql('main_table.base_discount_canceled', 0)
$this->getConnection()->getIfNullSql('ABS(main_table.base_discount_refunded)', 0),
$this->getConnection()->getIfNullSql('ABS(main_table.base_discount_canceled)', 0)
);
$this->getSelect()->columns(['revenue' => $expr]);

Expand All @@ -796,8 +796,8 @@ public function addSumAvgTotals($storeId = 0)
$storeId,
$this->getConnection()->getIfNullSql('main_table.base_subtotal_refunded', 0),
$this->getConnection()->getIfNullSql('main_table.base_subtotal_canceled', 0),
$this->getConnection()->getIfNullSql('main_table.base_discount_refunded', 0),
$this->getConnection()->getIfNullSql('main_table.base_discount_canceled', 0)
$this->getConnection()->getIfNullSql('ABS(main_table.base_discount_refunded)', 0),
$this->getConnection()->getIfNullSql('ABS(main_table.base_discount_canceled)', 0)
);

$this->getSelect()->columns(
Expand Down Expand Up @@ -827,8 +827,8 @@ protected function getTotalsExpression(
$baseDiscountCanceled
) {
$template = ($storeId != 0)
? '(main_table.base_subtotal - %2$s - %1$s - ABS(main_table.base_discount_amount) + %3$s + %4$s)'
: '((main_table.base_subtotal - %1$s - %2$s - ABS(main_table.base_discount_amount) + %3$s + %4$s) '
? '(main_table.base_subtotal - %2$s - %1$s - (ABS(main_table.base_discount_amount) - %3$s - %4$s))'
: '((main_table.base_subtotal - %1$s - %2$s - (ABS(main_table.base_discount_amount) - %3$s - %4$s)) '
. ' * main_table.base_to_global_rate)';
return sprintf($template, $baseSubtotalRefunded, $baseSubtotalCanceled, $baseDiscountRefunded, $baseDiscountCanceled);
}
Expand Down

0 comments on commit d1e71b9

Please sign in to comment.