Remove coupon_total from order stats table (https://github.com/woocommerce/woocommerce-admin/pull/1975)
* Remove coupons_total from order stats table * Replace discount amount with coupon objects in stat tests
This commit is contained in:
parent
b885ae4157
commit
0c5c1c3db4
|
@ -93,7 +93,6 @@ class WC_Admin_Install {
|
|||
date_created datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
|
||||
num_items_sold int(11) UNSIGNED DEFAULT 0 NOT NULL,
|
||||
gross_total double DEFAULT 0 NOT NULL,
|
||||
coupon_total double DEFAULT 0 NOT NULL,
|
||||
refund_total double DEFAULT 0 NOT NULL,
|
||||
tax_total double DEFAULT 0 NOT NULL,
|
||||
shipping_total double DEFAULT 0 NOT NULL,
|
||||
|
|
|
@ -23,7 +23,7 @@ class WC_Admin_Reports_Orders_Stats_Segmenting extends WC_Admin_Reports_Segmenti
|
|||
$columns_mapping = array(
|
||||
'num_items_sold' => "SUM($products_table.product_qty) as num_items_sold",
|
||||
'gross_revenue' => "SUM($products_table.product_gross_revenue) AS gross_revenue",
|
||||
'coupons' => "SUM($products_table.coupon_amount) AS coupons",
|
||||
'coupons' => 'SUM( coupon_lookup_left_join.discount_amount ) AS coupons',
|
||||
'coupons_count' => 'COUNT( DISTINCT( coupon_lookup_left_join.coupon_id ) ) AS coupons_count',
|
||||
'refunds' => "SUM($products_table.refund_amount) AS refunds",
|
||||
'taxes' => "SUM($products_table.tax_amount) AS taxes",
|
||||
|
@ -66,7 +66,7 @@ class WC_Admin_Reports_Orders_Stats_Segmenting extends WC_Admin_Reports_Segmenti
|
|||
$columns_mapping = array(
|
||||
'num_items_sold' => "SUM($order_stats_table.num_items_sold) as num_items_sold",
|
||||
'gross_revenue' => "SUM($order_stats_table.gross_total) AS gross_revenue",
|
||||
'coupons' => "SUM($order_stats_table.coupon_total) AS coupons",
|
||||
'coupons' => "SUM($order_stats_table.discount_amount) AS coupons",
|
||||
'coupons_count' => 'COUNT( DISTINCT(coupon_lookup_left_join.coupon_id) ) AS coupons_count',
|
||||
'refunds' => "SUM($order_stats_table.refund_total) AS refunds",
|
||||
'taxes' => "SUM($order_stats_table.tax_total) AS taxes",
|
||||
|
|
|
@ -58,7 +58,7 @@ class WC_Admin_Reports_Orders_Stats_Data_Store extends WC_Admin_Reports_Data_Sto
|
|||
'orders_count' => 'COUNT(*) as orders_count',
|
||||
'num_items_sold' => 'SUM(num_items_sold) as num_items_sold',
|
||||
'gross_revenue' => 'SUM(gross_total) AS gross_revenue',
|
||||
'coupons' => 'SUM(coupon_total) AS coupons',
|
||||
'coupons' => 'SUM(discount_amount) AS coupons',
|
||||
'coupons_count' => 'COUNT(DISTINCT coupon_id) as coupons_count',
|
||||
'refunds' => 'SUM(refund_total) AS refunds',
|
||||
'taxes' => 'SUM(tax_total) AS taxes',
|
||||
|
@ -408,7 +408,6 @@ class WC_Admin_Reports_Orders_Stats_Data_Store extends WC_Admin_Reports_Data_Sto
|
|||
'date_created' => $order->get_date_created()->date( 'Y-m-d H:i:s' ),
|
||||
'num_items_sold' => self::get_num_items_sold( $order ),
|
||||
'gross_total' => $order->get_total(),
|
||||
'coupon_total' => $order->get_total_discount(),
|
||||
'refund_total' => $order->get_total_refunded(),
|
||||
'tax_total' => $order->get_total_tax(),
|
||||
'shipping_total' => $order->get_shipping_total(),
|
||||
|
@ -426,7 +425,6 @@ class WC_Admin_Reports_Orders_Stats_Data_Store extends WC_Admin_Reports_Data_Sto
|
|||
'%f',
|
||||
'%f',
|
||||
'%f',
|
||||
'%f',
|
||||
'%d',
|
||||
'%s',
|
||||
'%d',
|
||||
|
|
|
@ -24,11 +24,14 @@ class WC_Tests_Reports_Orders_Stats extends WC_Unit_Test_Case {
|
|||
$product->set_regular_price( 25 );
|
||||
$product->save();
|
||||
|
||||
$coupon = WC_Helper_Coupon::create_coupon( 'test-coupon' );
|
||||
$coupon->set_amount( 20 );
|
||||
$coupon->save();
|
||||
|
||||
$order = WC_Helper_Order::create_order( 1, $product );
|
||||
$order->set_status( 'completed' );
|
||||
$order->set_shipping_total( 10 );
|
||||
$order->set_discount_total( 20 );
|
||||
$order->set_discount_tax( 0 );
|
||||
$order->apply_coupon( $coupon );
|
||||
$order->set_cart_tax( 5 );
|
||||
$order->set_shipping_tax( 2 );
|
||||
$order->set_total( 97 ); // $25x4 products + $10 shipping - $20 discount + $7 tax.
|
||||
|
@ -61,7 +64,7 @@ class WC_Tests_Reports_Orders_Stats extends WC_Unit_Test_Case {
|
|||
'avg_order_value' => 56,
|
||||
'gross_revenue' => 97,
|
||||
'coupons' => 20,
|
||||
'coupons_count' => 0,
|
||||
'coupons_count' => 1,
|
||||
'refunds' => 12,
|
||||
'taxes' => 7,
|
||||
'shipping' => 10,
|
||||
|
@ -82,7 +85,7 @@ class WC_Tests_Reports_Orders_Stats extends WC_Unit_Test_Case {
|
|||
'gross_revenue' => 97,
|
||||
'net_revenue' => 56,
|
||||
'coupons' => 20,
|
||||
'coupons_count' => 0,
|
||||
'coupons_count' => 1,
|
||||
'shipping' => 10,
|
||||
'taxes' => 7,
|
||||
'refunds' => 12,
|
||||
|
@ -114,7 +117,7 @@ class WC_Tests_Reports_Orders_Stats extends WC_Unit_Test_Case {
|
|||
'avg_items_per_order' => 4,
|
||||
'num_items_sold' => 4,
|
||||
'coupons' => 20,
|
||||
'coupons_count' => 0,
|
||||
'coupons_count' => 1,
|
||||
'num_returning_customers' => 0,
|
||||
'num_new_customers' => 1,
|
||||
'products' => '1',
|
||||
|
@ -134,7 +137,7 @@ class WC_Tests_Reports_Orders_Stats extends WC_Unit_Test_Case {
|
|||
'avg_items_per_order' => 4,
|
||||
'num_items_sold' => 4,
|
||||
'coupons' => 20,
|
||||
'coupons_count' => 0,
|
||||
'coupons_count' => 1,
|
||||
'num_returning_customers' => 0,
|
||||
'num_new_customers' => 1,
|
||||
'segments' => array(),
|
||||
|
|
|
@ -27,11 +27,14 @@ class WC_Admin_Tests_Reports_Revenue_Stats extends WC_Unit_Test_Case {
|
|||
$product->set_regular_price( 25 );
|
||||
$product->save();
|
||||
|
||||
$coupon = WC_Helper_Coupon::create_coupon( 'test-coupon' );
|
||||
$coupon->set_amount( 20 );
|
||||
$coupon->save();
|
||||
|
||||
$order = WC_Helper_Order::create_order( 1, $product );
|
||||
$order->set_status( 'completed' );
|
||||
$order->set_shipping_total( 10 );
|
||||
$order->set_discount_total( 20 );
|
||||
$order->set_discount_tax( 0 );
|
||||
$order->apply_coupon( $coupon );
|
||||
$order->set_cart_tax( 5 );
|
||||
$order->set_shipping_tax( 2 );
|
||||
$order->set_total( 97 ); // $25x4 products + $10 shipping - $20 discount + $7 tax.
|
||||
|
@ -56,7 +59,7 @@ class WC_Admin_Tests_Reports_Revenue_Stats extends WC_Unit_Test_Case {
|
|||
'num_items_sold' => 4,
|
||||
'gross_revenue' => 97,
|
||||
'coupons' => 20,
|
||||
'coupons_count' => 0,
|
||||
'coupons_count' => 1,
|
||||
'refunds' => 0,
|
||||
'taxes' => 7,
|
||||
'shipping' => 10,
|
||||
|
@ -80,7 +83,7 @@ class WC_Admin_Tests_Reports_Revenue_Stats extends WC_Unit_Test_Case {
|
|||
'num_items_sold' => 4,
|
||||
'gross_revenue' => 97,
|
||||
'coupons' => 20,
|
||||
'coupons_count' => 0,
|
||||
'coupons_count' => 1,
|
||||
'refunds' => 0,
|
||||
'taxes' => 7,
|
||||
'shipping' => 10,
|
||||
|
@ -108,7 +111,7 @@ class WC_Admin_Tests_Reports_Revenue_Stats extends WC_Unit_Test_Case {
|
|||
'num_items_sold' => 4,
|
||||
'gross_revenue' => 97,
|
||||
'coupons' => 20,
|
||||
'coupons_count' => 0,
|
||||
'coupons_count' => 1,
|
||||
'refunds' => 0,
|
||||
'taxes' => 7,
|
||||
'shipping' => 10,
|
||||
|
@ -128,7 +131,7 @@ class WC_Admin_Tests_Reports_Revenue_Stats extends WC_Unit_Test_Case {
|
|||
'num_items_sold' => 4,
|
||||
'gross_revenue' => 97,
|
||||
'coupons' => 20,
|
||||
'coupons_count' => 0,
|
||||
'coupons_count' => 1,
|
||||
'refunds' => 0,
|
||||
'taxes' => 7,
|
||||
'shipping' => 10,
|
||||
|
|
Loading…
Reference in New Issue