@@ -168,7 +168,7 @@ protected function _prepareSummaryLive($range, $customStart, $customEnd, $isFilt
168
168
169
169
$ this ->getSelect ()
170
170
->columns ([
171
- 'quantity ' => 'COUNT(main_table.entity_id) ' ,
171
+ 'quantity ' => new Zend_Db_Expr ( 'COUNT(main_table.entity_id) ' ) ,
172
172
'range ' => $ tzRangeOffsetExpression ,
173
173
])
174
174
->where ('main_table.state NOT IN (?) ' , [
@@ -203,8 +203,8 @@ protected function _prepareSummaryAggregated($range, $customStart, $customEnd)
203
203
$ rangePeriod2 = str_replace ($ tableName , "MIN( $ tableName) " , $ rangePeriod );
204
204
205
205
$ this ->getSelect ()->columns ([
206
- 'revenue ' => 'SUM(main_table.total_revenue_amount) ' ,
207
- 'quantity ' => 'SUM(main_table.orders_count) ' ,
206
+ 'revenue ' => new Zend_Db_Expr ( 'SUM(main_table.total_revenue_amount) ' ) ,
207
+ 'quantity ' => new Zend_Db_Expr ( 'SUM(main_table.orders_count) ' ) ,
208
208
'range ' => $ rangePeriod2 ,
209
209
])
210
210
->order ('range ' )
@@ -512,7 +512,7 @@ public function calculateSales($isFilter = 0)
512
512
0
513
513
);
514
514
$ this ->getSelect ()->columns ([
515
- 'lifetime ' => 'SUM(main_table.total_revenue_amount) ' ,
515
+ 'lifetime ' => new Zend_Db_Expr ( 'SUM(main_table.total_revenue_amount) ' ) ,
516
516
'average ' => $ averageExpr
517
517
]);
518
518
@@ -535,8 +535,8 @@ public function calculateSales($isFilter = 0)
535
535
536
536
$ this ->getSelect ()
537
537
->columns ([
538
- 'lifetime ' => "SUM( {$ expr }) " ,
539
- 'average ' => "AVG( {$ expr }) "
538
+ 'lifetime ' => new Zend_Db_Expr ( "SUM( {$ expr }) " ) ,
539
+ 'average ' => new Zend_Db_Expr ( "AVG( {$ expr }) " )
540
540
])
541
541
->where ('main_table.status NOT IN(?) ' , $ statuses )
542
542
->where ('main_table.state NOT IN(?) ' , [
@@ -584,31 +584,31 @@ public function setStoreIds($storeIds)
584
584
$ baseTotalInvocedCost = $ adapter ->getIfNullSql ('main_table.base_total_invoiced_cost ' , 0 );
585
585
if ($ storeIds ) {
586
586
$ this ->getSelect ()->columns ([
587
- 'subtotal ' => 'SUM(main_table.base_subtotal) ' ,
588
- 'tax ' => 'SUM(main_table.base_tax_amount) ' ,
589
- 'shipping ' => 'SUM(main_table.base_shipping_amount) ' ,
590
- 'discount ' => 'SUM(main_table.base_discount_amount) ' ,
591
- 'total ' => 'SUM(main_table.base_grand_total) ' ,
592
- 'invoiced ' => 'SUM(main_table.base_total_paid) ' ,
593
- 'refunded ' => 'SUM(main_table.base_total_refunded) ' ,
594
- 'profit ' => "SUM( $ baseSubtotalInvoiced) "
587
+ 'subtotal ' => new Zend_Db_Expr ( 'SUM(main_table.base_subtotal) ' ) ,
588
+ 'tax ' => new Zend_Db_Expr ( 'SUM(main_table.base_tax_amount) ' ) ,
589
+ 'shipping ' => new Zend_Db_Expr ( 'SUM(main_table.base_shipping_amount) ' ) ,
590
+ 'discount ' => new Zend_Db_Expr ( 'SUM(main_table.base_discount_amount) ' ) ,
591
+ 'total ' => new Zend_Db_Expr ( 'SUM(main_table.base_grand_total) ' ) ,
592
+ 'invoiced ' => new Zend_Db_Expr ( 'SUM(main_table.base_total_paid) ' ) ,
593
+ 'refunded ' => new Zend_Db_Expr ( 'SUM(main_table.base_total_refunded) ' ) ,
594
+ 'profit ' => new Zend_Db_Expr ( "SUM( $ baseSubtotalInvoiced) "
595
595
. "+ SUM( {$ baseDiscountRefunded }) - SUM( {$ baseSubtotalRefunded }) "
596
- . "- SUM( {$ baseDiscountInvoiced }) - SUM( {$ baseTotalInvocedCost }) "
596
+ . "- SUM( {$ baseDiscountInvoiced }) - SUM( {$ baseTotalInvocedCost }) " )
597
597
]);
598
598
} else {
599
599
$ this ->getSelect ()->columns ([
600
- 'subtotal ' => 'SUM(main_table.base_subtotal * main_table.base_to_global_rate) ' ,
601
- 'tax ' => 'SUM(main_table.base_tax_amount * main_table.base_to_global_rate) ' ,
602
- 'shipping ' => 'SUM(main_table.base_shipping_amount * main_table.base_to_global_rate) ' ,
603
- 'discount ' => 'SUM(main_table.base_discount_amount * main_table.base_to_global_rate) ' ,
604
- 'total ' => 'SUM(main_table.base_grand_total * main_table.base_to_global_rate) ' ,
605
- 'invoiced ' => 'SUM(main_table.base_total_paid * main_table.base_to_global_rate) ' ,
606
- 'refunded ' => 'SUM(main_table.base_total_refunded * main_table.base_to_global_rate) ' ,
607
- 'profit ' => "SUM( {$ baseSubtotalInvoiced } * main_table.base_to_global_rate) "
600
+ 'subtotal ' => new Zend_Db_Expr ( 'SUM(main_table.base_subtotal * main_table.base_to_global_rate) ' ) ,
601
+ 'tax ' => new Zend_Db_Expr ( 'SUM(main_table.base_tax_amount * main_table.base_to_global_rate) ' ) ,
602
+ 'shipping ' => new Zend_Db_Expr ( 'SUM(main_table.base_shipping_amount * main_table.base_to_global_rate) ' ) ,
603
+ 'discount ' => new Zend_Db_Expr ( 'SUM(main_table.base_discount_amount * main_table.base_to_global_rate) ' ) ,
604
+ 'total ' => new Zend_Db_Expr ( 'SUM(main_table.base_grand_total * main_table.base_to_global_rate) ' ) ,
605
+ 'invoiced ' => new Zend_Db_Expr ( 'SUM(main_table.base_total_paid * main_table.base_to_global_rate) ' ) ,
606
+ 'refunded ' => new Zend_Db_Expr ( 'SUM(main_table.base_total_refunded * main_table.base_to_global_rate) ' ) ,
607
+ 'profit ' => new Zend_Db_Expr ( "SUM( {$ baseSubtotalInvoiced } * main_table.base_to_global_rate) "
608
608
. "+ SUM( {$ baseDiscountRefunded } * main_table.base_to_global_rate) "
609
609
. "- SUM( {$ baseSubtotalRefunded } * main_table.base_to_global_rate) "
610
610
. "- SUM( {$ baseDiscountInvoiced } * main_table.base_to_global_rate) "
611
- . "- SUM( {$ baseTotalInvocedCost } * main_table.base_to_global_rate) "
611
+ . "- SUM( {$ baseTotalInvocedCost } * main_table.base_to_global_rate) " )
612
612
]);
613
613
}
614
614
0 commit comments