Fixed wrong gross sales calculation on sales by date report.

The order amounts should exclude refunds.

Fixes #9125.
This commit is contained in:
Akeda Bagus 2015-10-02 11:08:41 +02:00
parent 81f787e13b
commit dc0d5362cd
1 changed files with 15 additions and 10 deletions

View File

@ -479,22 +479,27 @@ class WC_Report_Sales_By_Date extends WC_Admin_Report {
$shipping_tax_amounts = $this->prepare_chart_data( $this->report_data->orders, 'post_date', 'total_shipping_tax', $this->chart_interval, $this->start_date, $this->chart_groupby ); $shipping_tax_amounts = $this->prepare_chart_data( $this->report_data->orders, 'post_date', 'total_shipping_tax', $this->chart_interval, $this->start_date, $this->chart_groupby );
$tax_amounts = $this->prepare_chart_data( $this->report_data->orders, 'post_date', 'total_tax', $this->chart_interval, $this->start_date, $this->chart_groupby ); $tax_amounts = $this->prepare_chart_data( $this->report_data->orders, 'post_date', 'total_tax', $this->chart_interval, $this->start_date, $this->chart_groupby );
$net_order_amounts = array(); $net_order_amounts = array();
$gross_order_amounts = array();
foreach ( $order_amounts as $order_amount_key => $order_amount_value ) { foreach ( $order_amounts as $order_amount_key => $order_amount_value ) {
$gross_order_amounts[ $order_amount_key ] = $order_amount_value;
$gross_order_amounts[ $order_amount_key ][1] = $gross_order_amounts[ $order_amount_key ][1] - $refund_amounts[ $order_amount_key ][1];
$net_order_amounts[ $order_amount_key ] = $order_amount_value; $net_order_amounts[ $order_amount_key ] = $order_amount_value;
$net_order_amounts[ $order_amount_key ][1] = $net_order_amounts[ $order_amount_key ][1] - $shipping_amounts[ $order_amount_key ][1] - $shipping_tax_amounts[ $order_amount_key ][1] - $tax_amounts[ $order_amount_key ][1]; $net_order_amounts[ $order_amount_key ][1] = $net_order_amounts[ $order_amount_key ][1] - $refund_amounts[ $order_amount_key ][1] - $shipping_amounts[ $order_amount_key ][1] - $shipping_tax_amounts[ $order_amount_key ][1] - $tax_amounts[ $order_amount_key ][1];
} }
// Encode in json format // Encode in json format
$chart_data = json_encode( array( $chart_data = json_encode( array(
'order_counts' => array_values( $order_counts ), 'order_counts' => array_values( $order_counts ),
'order_item_counts' => array_values( $order_item_counts ), 'order_item_counts' => array_values( $order_item_counts ),
'order_amounts' => array_map( array( $this, 'round_chart_totals' ), array_values( $order_amounts ) ), 'order_amounts' => array_map( array( $this, 'round_chart_totals' ), array_values( $order_amounts ) ),
'net_order_amounts' => array_map( array( $this, 'round_chart_totals' ), array_values( $net_order_amounts ) ), 'gross_order_amounts' => array_map( array( $this, 'round_chart_totals' ), array_values( $gross_order_amounts ) ),
'shipping_amounts' => array_map( array( $this, 'round_chart_totals' ), array_values( $shipping_amounts ) ), 'net_order_amounts' => array_map( array( $this, 'round_chart_totals' ), array_values( $net_order_amounts ) ),
'coupon_amounts' => array_map( array( $this, 'round_chart_totals' ), array_values( $coupon_amounts ) ), 'shipping_amounts' => array_map( array( $this, 'round_chart_totals' ), array_values( $shipping_amounts ) ),
'refund_amounts' => array_map( array( $this, 'round_chart_totals' ), array_values( $refund_amounts ) ) 'coupon_amounts' => array_map( array( $this, 'round_chart_totals' ), array_values( $coupon_amounts ) ),
'refund_amounts' => array_map( array( $this, 'round_chart_totals' ), array_values( $refund_amounts ) )
) ); ) );
?> ?>
<div class="chart-container"> <div class="chart-container">
@ -556,7 +561,7 @@ class WC_Report_Sales_By_Date extends WC_Admin_Report {
}, },
{ {
label: "<?php echo esc_js( __( 'Gross Sales amount', 'woocommerce' ) ) ?>", label: "<?php echo esc_js( __( 'Gross Sales amount', 'woocommerce' ) ) ?>",
data: order_data.order_amounts, data: order_data.gross_order_amounts,
yaxis: 2, yaxis: 2,
color: '<?php echo $this->chart_colours['sales_amount']; ?>', color: '<?php echo $this->chart_colours['sales_amount']; ?>',
points: { show: true, radius: 5, lineWidth: 2, fillColor: '#fff', fill: true }, points: { show: true, radius: 5, lineWidth: 2, fillColor: '#fff', fill: true },