File tree Expand file tree Collapse file tree 7 files changed +34
-18
lines changed
Reports/Block/Adminhtml/Grid
Sales/Model/Resource/Report
Tax/Model/Resource/Report
dev/tests/functional/tests/app/Magento/Reports/Test/Constraint Expand file tree Collapse file tree 7 files changed +34
-18
lines changed Original file line number Diff line number Diff line change @@ -303,7 +303,7 @@ public function getCountTotals()
303
303
304
304
$ this ->_addOrderStatusFilter ($ totalsCollection , $ filterData );
305
305
306
- if (count ( $ totalsCollection ->getItems () ) < 1 || !$ filterData ->getData ('from ' )) {
306
+ if ($ totalsCollection ->load ()-> getSize ( ) < 1 || !$ filterData ->getData ('from ' )) {
307
307
$ this ->setTotals (new \Magento \Framework \Object ());
308
308
$ this ->setCountTotals (false );
309
309
} else {
Original file line number Diff line number Diff line change @@ -102,16 +102,16 @@ protected function _getSelectedColumns()
102
102
}
103
103
104
104
/**
105
- * Add selected data
105
+ * Apply custom columns before load
106
106
*
107
107
* @return $this
108
108
*/
109
- protected function _initSelect ()
109
+ protected function _beforeLoad ()
110
110
{
111
111
$ this ->getSelect ()->from ($ this ->getResource ()->getMainTable (), $ this ->_getSelectedColumns ());
112
112
if (!$ this ->isTotals ()) {
113
113
$ this ->getSelect ()->group ($ this ->_periodFormat );
114
114
}
115
- return parent ::_initSelect ();
115
+ return parent ::_beforeLoad ();
116
116
}
117
117
}
Original file line number Diff line number Diff line change @@ -83,16 +83,16 @@ protected function _getSelectedColumns()
83
83
}
84
84
85
85
/**
86
- * Add selected data
86
+ * Apply custom columns before load
87
87
*
88
- * @return \Magento\Sales\Model\Resource\Report\Refunded\Collection\Order
88
+ * @return $this
89
89
*/
90
- protected function _initSelect ()
90
+ protected function _beforeLoad ()
91
91
{
92
92
$ this ->getSelect ()->from ($ this ->getResource ()->getMainTable (), $ this ->_getSelectedColumns ());
93
93
if (!$ this ->isTotals ()) {
94
94
$ this ->getSelect ()->group ($ this ->_periodFormat );
95
95
}
96
- return parent ::_initSelect ();
96
+ return parent ::_beforeLoad ();
97
97
}
98
98
}
Original file line number Diff line number Diff line change @@ -87,11 +87,11 @@ protected function _getSelectedColumns()
87
87
}
88
88
89
89
/**
90
- * Add selected data
90
+ * Apply custom columns before load
91
91
*
92
92
* @return $this
93
93
*/
94
- protected function _initSelect ()
94
+ protected function _beforeLoad ()
95
95
{
96
96
$ this ->getSelect ()->from ($ this ->getResource ()->getMainTable (), $ this ->_getSelectedColumns ());
97
97
@@ -101,6 +101,6 @@ protected function _initSelect()
101
101
if ($ this ->isSubTotals ()) {
102
102
$ this ->getSelect ()->group ([$ this ->_periodFormat ]);
103
103
}
104
- return parent ::_initSelect ();
104
+ return parent ::_beforeLoad ();
105
105
}
106
106
}
Original file line number Diff line number Diff line change @@ -85,11 +85,11 @@ protected function _getSelectedColumns()
85
85
}
86
86
87
87
/**
88
- * Add selected data
88
+ * Apply custom columns before load
89
89
*
90
90
* @return $this
91
91
*/
92
- protected function _initSelect ()
92
+ protected function _beforeLoad ()
93
93
{
94
94
$ this ->getSelect ()->from ($ this ->getResource ()->getMainTable (), $ this ->_getSelectedColumns ());
95
95
if (!$ this ->isTotals () && !$ this ->isSubTotals ()) {
@@ -99,6 +99,6 @@ protected function _initSelect()
99
99
if ($ this ->isSubTotals ()) {
100
100
$ this ->getSelect ()->group ([$ this ->_periodFormat ]);
101
101
}
102
- return parent ::_initSelect ();
102
+ return parent ::_beforeLoad ();
103
103
}
104
104
}
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ public function processAssert(
34
34
$ this ->order = $ order ;
35
35
$ this ->searchInSalesReportGrid ($ salesReport );
36
36
$ salesResult = $ this ->prepareSalesResult ($ salesReportPage ->getGridBlock ()->getLastResult ());
37
- $ prepareInitialResult = $ this ->prepareExpectedResult ($ initialSalesResult );
37
+ $ prepareInitialResult = $ this ->prepareSalesResult ( $ this -> prepareExpectedResult ($ initialSalesResult) );
38
38
\PHPUnit_Framework_Assert::assertEquals (
39
39
$ prepareInitialResult ,
40
40
$ salesResult ,
@@ -52,7 +52,7 @@ protected function prepareSalesResult($salesResult)
52
52
{
53
53
$ data = [];
54
54
foreach ($ salesResult as $ key => $ result ) {
55
- $ data [$ key ] = intval ($ result );
55
+ $ data [$ key ] = floatval ($ result );
56
56
}
57
57
58
58
return $ data ;
Original file line number Diff line number Diff line change @@ -33,15 +33,31 @@ public function processAssert(
33
33
$ this ->salesReportPage = $ salesReportPage ;
34
34
$ this ->order = $ order ;
35
35
$ this ->searchInSalesReportGrid ($ salesReport );
36
- $ salesResult = $ salesReportPage ->getGridBlock ()->getTotalResult ();
37
- $ prepareInitialResult = $ this ->prepareExpectedResult ($ initialSalesTotalResult );
36
+ $ salesResult = $ this -> prepareSalesResult ( $ salesReportPage ->getGridBlock ()->getTotalResult () );
37
+ $ prepareInitialResult = $ this ->prepareSalesResult ( $ this -> prepareExpectedResult ($ initialSalesTotalResult) );
38
38
\PHPUnit_Framework_Assert::assertEquals (
39
39
$ prepareInitialResult ,
40
40
$ salesResult ,
41
41
"Grand total Sales result is not correct. "
42
42
);
43
43
}
44
44
45
+ /**
46
+ * Prepare sales result.
47
+ *
48
+ * @param array $salesResult
49
+ * @return array
50
+ */
51
+ protected function prepareSalesResult ($ salesResult )
52
+ {
53
+ $ data = [];
54
+ foreach ($ salesResult as $ key => $ result ) {
55
+ $ data [$ key ] = floatval ($ result );
56
+ }
57
+
58
+ return $ data ;
59
+ }
60
+
45
61
/**
46
62
* Returns a string representation of the object
47
63
*
You can’t perform that action at this time.
0 commit comments