Skip to content

Commit

Permalink
Added refunded discount amount to the total revenue calculation and f…
Browse files Browse the repository at this point in the history
…ixed Negative order amount in dashboard when viewing particular store data
  • Loading branch information
rav-redchamps committed Feb 16, 2019
1 parent fb9e645 commit d79eb08
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,7 @@ 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->getSelect()->columns(['revenue' => $expr]);
Expand All @@ -795,6 +796,7 @@ 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)
);

Expand All @@ -813,20 +815,22 @@ public function addSumAvgTotals($storeId = 0)
* @param int $storeId
* @param string $baseSubtotalRefunded
* @param string $baseSubtotalCanceled
* @param string $baseDiscountRefunded
* @param string $baseDiscountCanceled
* @return string
*/
protected function getTotalsExpression(
$storeId,
$baseSubtotalRefunded,
$baseSubtotalCanceled,
$baseDiscountRefunded,
$baseDiscountCanceled
) {
$template = ($storeId != 0)
? '(main_table.base_subtotal - %2$s - %1$s - ABS(main_table.base_discount_amount) - %3$s)'
: '((main_table.base_subtotal - %1$s - %2$s - ABS(main_table.base_discount_amount) + %3$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, $baseDiscountCanceled);
return sprintf($template, $baseSubtotalRefunded, $baseSubtotalCanceled, $baseDiscountRefunded, $baseDiscountCanceled);
}

/**
Expand Down

0 comments on commit d79eb08

Please sign in to comment.