@@ -773,8 +773,8 @@ public function addRevenueToSelect($convertCurrency = false)
773773 !$ convertCurrency ,
774774 $ this ->getConnection ()->getIfNullSql ('main_table.base_subtotal_refunded ' , 0 ),
775775 $ this ->getConnection ()->getIfNullSql ('main_table.base_subtotal_canceled ' , 0 ),
776- $ this ->getConnection ()->getIfNullSql ('main_table.base_discount_refunded ' , 0 ),
777- $ this ->getConnection ()->getIfNullSql ('main_table.base_discount_canceled ' , 0 )
776+ $ this ->getConnection ()->getIfNullSql ('ABS( main_table.base_discount_refunded) ' , 0 ),
777+ $ this ->getConnection ()->getIfNullSql ('ABS( main_table.base_discount_canceled) ' , 0 )
778778 );
779779 $ this ->getSelect ()->columns (['revenue ' => $ expr ]);
780780
@@ -796,8 +796,8 @@ public function addSumAvgTotals($storeId = 0)
796796 $ storeId ,
797797 $ this ->getConnection ()->getIfNullSql ('main_table.base_subtotal_refunded ' , 0 ),
798798 $ this ->getConnection ()->getIfNullSql ('main_table.base_subtotal_canceled ' , 0 ),
799- $ this ->getConnection ()->getIfNullSql ('main_table.base_discount_refunded ' , 0 ),
800- $ this ->getConnection ()->getIfNullSql ('main_table.base_discount_canceled ' , 0 )
799+ $ this ->getConnection ()->getIfNullSql ('ABS( main_table.base_discount_refunded) ' , 0 ),
800+ $ this ->getConnection ()->getIfNullSql ('ABS( main_table.base_discount_canceled) ' , 0 )
801801 );
802802
803803 $ this ->getSelect ()->columns (
@@ -827,8 +827,8 @@ protected function getTotalsExpression(
827827 $ baseDiscountCanceled
828828 ) {
829829 $ template = ($ storeId != 0 )
830- ? '(main_table.base_subtotal - %2$s - %1$s - ABS(main_table.base_discount_amount) + %3$s + %4$s) '
831- : '((main_table.base_subtotal - %1$s - %2$s - ABS(main_table.base_discount_amount) + %3$s + %4$s) '
830+ ? '(main_table.base_subtotal - %2$s - %1$s - ( ABS(main_table.base_discount_amount) - %3$s - %4$s) ) '
831+ : '((main_table.base_subtotal - %1$s - %2$s - ( ABS(main_table.base_discount_amount) - %3$s - %4$s) ) '
832832 . ' * main_table.base_to_global_rate) ' ;
833833 return sprintf ($ template , $ baseSubtotalRefunded , $ baseSubtotalCanceled , $ baseDiscountRefunded , $ baseDiscountCanceled );
834834 }
0 commit comments