@@ -773,6 +773,7 @@ public function addRevenueToSelect($convertCurrency = false)
773
773
!$ convertCurrency ,
774
774
$ this ->getConnection ()->getIfNullSql ('main_table.base_subtotal_refunded ' , 0 ),
775
775
$ this ->getConnection ()->getIfNullSql ('main_table.base_subtotal_canceled ' , 0 ),
776
+ $ this ->getConnection ()->getIfNullSql ('main_table.base_discount_refunded ' , 0 ),
776
777
$ this ->getConnection ()->getIfNullSql ('main_table.base_discount_canceled ' , 0 )
777
778
);
778
779
$ this ->getSelect ()->columns (['revenue ' => $ expr ]);
@@ -795,6 +796,7 @@ public function addSumAvgTotals($storeId = 0)
795
796
$ storeId ,
796
797
$ this ->getConnection ()->getIfNullSql ('main_table.base_subtotal_refunded ' , 0 ),
797
798
$ this ->getConnection ()->getIfNullSql ('main_table.base_subtotal_canceled ' , 0 ),
799
+ $ this ->getConnection ()->getIfNullSql ('main_table.base_discount_refunded ' , 0 ),
798
800
$ this ->getConnection ()->getIfNullSql ('main_table.base_discount_canceled ' , 0 )
799
801
);
800
802
@@ -813,20 +815,22 @@ public function addSumAvgTotals($storeId = 0)
813
815
* @param int $storeId
814
816
* @param string $baseSubtotalRefunded
815
817
* @param string $baseSubtotalCanceled
818
+ * @param string $baseDiscountRefunded
816
819
* @param string $baseDiscountCanceled
817
820
* @return string
818
821
*/
819
822
protected function getTotalsExpression (
820
823
$ storeId ,
821
824
$ baseSubtotalRefunded ,
822
825
$ baseSubtotalCanceled ,
826
+ $ baseDiscountRefunded ,
823
827
$ baseDiscountCanceled
824
828
) {
825
829
$ template = ($ storeId != 0 )
826
- ? '(main_table.base_subtotal - %2$s - %1$s - ABS(main_table.base_discount_amount) - %3$s) '
827
- : '((main_table.base_subtotal - %1$s - %2$s - ABS(main_table.base_discount_amount) + %3$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 ) '
828
832
. ' * main_table.base_to_global_rate) ' ;
829
- return sprintf ($ template , $ baseSubtotalRefunded , $ baseSubtotalCanceled , $ baseDiscountCanceled );
833
+ return sprintf ($ template , $ baseSubtotalRefunded , $ baseSubtotalCanceled , $ baseDiscountRefunded , $ baseDiscountCanceled );
830
834
}
831
835
832
836
/**
0 commit comments