Commit Graph

100 Commits

Author SHA1 Message Date
Jeff Stieler 663fe9455e Fix failing order stats tests (https://github.com/woocommerce/woocommerce-admin/pull/4719)
* Fix missing uninstall usage in tests bootstrap.

Update test bootstrap using latest core WC version.

* Fix date offsets for test orders.

* Restore original test lib directory logic.

* Ensure that test runs near the bottom of the hour don't break.

* Update testing instructions in contributing docs.
2020-06-30 11:02:28 -04:00
Jeff Stieler a6195efad6 Fix Historical (deleted) Coupon Reporting (https://github.com/woocommerce/woocommerce-admin/pull/4671)
* Add (failing) test for deleted coupon amounts in reporting.

* Always sync an ID into the order-coupon lookup table.

* Don't remove coupon data from order analytics when the coupon is deleted.

* Fix coupon ID lookup from order item metadata.

* Allow negative coupon_id in the lookup table.

Representing deleted coupons.

* Handle deleted coupons when gathering extended info.

* Add more tests for deleted coupon handling.

* Handle deleted coupons in coupons report table.

* Fix lint errors.
2020-06-25 08:51:17 -04:00
Ron Rennick 8a22576a95 Count total unique customers instead of new/returning in order stats (https://github.com/woocommerce/woocommerce-admin/pull/4430)
* Count total unique customers instead of new/returning in order stats

* Add customer name to table instead of customer type

* Add customer total to segments

* Update tests for new stats

Co-authored-by: Joshua Flowers <joshuatf@gmail.com>
2020-06-18 20:43:56 +03:00
Jeff Stieler 162a8cd550 Allow report caching layer to be filtered off. (https://github.com/woocommerce/woocommerce-admin/pull/3434)
* Add filter to conditionally disable report caching.

* Disable caching for Orders Stats unit tests.

Fixes the display of the last query when tests fail.
2019-12-17 16:21:44 -05:00
David Levin 52cb35f4de Correcting and clarifying analytics terms and calculations (https://github.com/woocommerce/woocommerce-admin/pull/3104)
* Relabel Net Revenue to Net Sales, revert previous refund work on Gross revenue and rename to total sales. Update the orer of all the things

* Add gross sales calculation to revenue stats endpoint.

* Restore coupon_total when updating order stats.

* Wire up gross sales to revenue report.

* Fix revenue report refunds calculation when there are no refunds.

* update net sales labels and cases in order, product and category tables

* Subtract refunded shipping and taxes from gross sales.

* pluses to minuses to fix the gross revenue and refund totals when refunding

* Add gross_sales to revenue stats orderby enum.

* Change refund labels to Returns

* Remove usage of defunct coupon_total column.

* Store refunded amount in stats table.

* Rename "gross_total" column to "total_sales".

* Net total for refund orders can be used instead of a new column.

* Rename gross_revenue to total_sales.

* Coalesce coupons total in order stats query.

SUM()ing all nulls gives null, not zero.

* Use segmentation selections to backfill missing data.

Fo when report columns and segmentation columns don't match.

* Remove errant gross_sales from expected interval test data.

* Fix gross sales tests for revenue/stats.

* Move missing segment fills back to their original locations.

* Fix remaining tests failing because of gross sales.

* Fix db upgrade function rename of gross_total column.

* Fix linter errors.
2019-11-22 10:06:14 -05:00
Jeff Stieler 1ac8577fc2 Match server-side CSV export format to client-side (https://github.com/woocommerce/woocommerce-admin/pull/2987)
* Add "exportable" report interface for defining CSV export values.

* Define export values for Orders Report.

* Define export values for Products Report.

* Define export values for Categories Report.

* Define export values for Coupons Report.

* Allow commas and double quotes in CSV exported values.

* Fix in-browser export formatting of orders report products.

* Align server-side orders report export formatting with in-browser.

* Cover comma and double quote escaping in CSV export package tests.

* Define export values for Customers Report.

* Embed response links when requesting data for CSV exports.

* Define export values for Downloads Report.

* Move reusable report export functions to a trait.

* Define export values for Stock Report.

* Define export values for Taxes Report.

* Define export values for Variations Report.

* Define export values for Revenue Report.

* Always pass export row data through the filter.

* Fix formatting in test case for CSV coupon export.

* Quote escape CSV headers in client-side export.

Escape values with spaces as well.

* Check if inventory is managed at the product level before using the stock status/quantity.

* Prevent CSV injection in csv-export package.
2019-10-24 09:41:16 -07:00
Jeff Stieler bfefb2d647 Ignore refunded amounts when calculating gross total. 2019-08-20 11:41:28 -07:00
Jeff Stieler 953427bea5 Remove defunct filename prefix from remaining files.
Excluding the note classes for third party compatibility.
2019-08-12 15:06:36 -07:00
Jeff Stieler 7dd4d2b791 PSR-4ify the reports time interval class. 2019-08-12 15:03:21 -07:00
Jeff Stieler 88f6fd9d06 PSR-4ify report query classes. 2019-08-12 15:03:19 -07:00
Jeff Stieler b7912bc579 PSR4-ify the Reports data store classes. 2019-08-12 15:03:17 -07:00
Jeff Stieler ce7267b198 PSR-4ify the report exporter classes. 2019-08-12 15:03:10 -07:00
Ron Rennick 2260e60453 Merge pull request woocommerce/woocommerce-admin#2484 from woocommerce/fix/2400
use summary query to total coupons per order
2019-07-08 13:49:17 -03:00
Ron Rennick 3cc9232c2b add unit test for multiple coupons on orders 2019-07-05 14:44:08 -03:00
Jeff Stieler 466ddda1a6 Add a test of the CSV export to the coupons report. 2019-06-24 19:26:33 -06:00
Joshua T Flowers c6a6e737c4 Add refund filtering to order reports (https://github.com/woocommerce/woocommerce-admin/pull/2179)
* Add customer functions to order and refund classes

* Extract shared order and refund methods to trait

* Add refund filter to advanced filters in orders report

* Filter refund types in orders data store

* Extract refunds subquery to parent report data store method

* Add refund subquery filtering to order stats data store

* Add tests around refund type filtering

* Change the default option for the refunds filter
2019-05-10 14:56:57 +08:00
Joshua T Flowers 3382fb7011 Record refunds separate from order entries (https://github.com/woocommerce/woocommerce-admin/pull/2083)
* Sync refunds on order sync

* Separate order and refund class extensions

* Add customer functions to order and refund classes

* Change products store to work with refund amounts

* Return early for refunds in coupon data store

* Allow refund processing in tax data store

* Remove unused refund amounts from tables and data stores

* Change order counts to parse out refund entries

* Include refunded orders in default queried statuses

* Only process order number filter on shop order post types

* Extract shared order and refund methods to trait

* Fix renamed schedule_single_order_import method

* Bump PHP and WP version requirements
2019-05-10 14:39:25 +08:00
Kelly Dwan 18bb29e35d Fix warnings in travis: CSS lint error & phpunit warning (https://github.com/woocommerce/woocommerce-admin/pull/2109)
* Fix stylelint issue

* Use WC_Helper_Order to create the order, which will correctly populate customer info
2019-04-25 10:22:57 -04:00
Ron Rennick b384571afe Merge pull request woocommerce/woocommerce-admin#1984 from woocommerce/phpcs/tests
phpcs fixes class-wc-tests-reports-orders-stats.php
2019-04-03 10:21:38 -03:00
Joshua T Flowers 0c5c1c3db4 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
2019-04-03 09:37:17 +08:00
Ron Rennick 26b5ba2b89 phpcs fixes class-wc-tests-reports-orders-stats.php 2019-04-02 16:22:55 -03:00
Joshua T Flowers 42ddfc0108 Add coupons count to data store and hook up to summary numbers in orders report (https://github.com/woocommerce/woocommerce-admin/pull/1912)
* Change coupons sum to distinct coupon count in REST API

* Hook up unique coupon count to orders summary numbers

* Add coupons count to order segmenting

* Add coupons count to expected stats in order test and revenue tests
2019-04-01 10:16:57 +08:00
Jeff Stieler bfe5a75e98 Update text domain. (https://github.com/woocommerce/woocommerce-admin/pull/1795)
* Translation call text domain change from “wc-admin” to “woocommerce-admin”.

* Fix .pot file generation.

* Fix errantly closed array item in /revenue/stats controller.

* Rename plugin zip, main file, and repo name to "woocommerce-admin".
2019-03-13 11:14:02 -06:00
Peter Fabian 43e49ca704 Added test for registered customer. 2019-02-23 00:03:53 +01:00
Peter Fabian 4668734af7 Removed debugging var from test. 2019-02-23 00:02:40 +01:00
Peter Fabian 3ce686e6cd Updated is_returning_customer definition to use refactored function. 2019-02-22 22:06:21 +01:00
Joshua T Flowers 44604bcd02 Reduce net order total by refunded amount less tax and shipping refunds (https://github.com/woocommerce/woocommerce-admin/pull/1600)
* Reduce net order total by refunded amount less tax and shipping refunds

* Fix net_totals in tests with refunds
2019-02-20 09:39:42 +08:00
Ron Rennick e2b220bb54 Merge pull request woocommerce/woocommerce-admin#1570 from woocommerce/phpcs/tests
Phpcs sniff fixes for unit tests
2019-02-15 14:50:50 -04:00
Joshua T Flowers cba9ab61b2 Update returning customer values to respect excluded statuses (https://github.com/woocommerce/woocommerce-admin/pull/1557)
* Excluded statuses from customers oldest orders

* Fix tests for returning customer where excluded statuses are used

* Remove save_post hook used for testing

* Extract conditions for first order swapping
2019-02-15 10:09:16 +08:00
Ron Rennick 58cfde18a4 phpcs print_R use in class-wc-tests-reports-order-stats.php 2019-02-14 18:54:45 -04:00
Ron Rennick 12c42c7967 phpcs for class-wc-tests-reports-orders-stats.php except print_r 2019-02-14 17:14:52 -04:00
Ron Rennick 16c5cf8c77 phpcs for class-wc-tests-reports-revenue-stats.php 2019-02-14 16:34:38 -04:00
Joshua T Flowers 746d062f09 Check and update customer first orders to fix returning_customers (https://github.com/woocommerce/woocommerce-admin/pull/1517)
* Add get_oldest_orders function to customer data store

* Check if is first order in is_returning_customer()

* Check if the customers first order has changed and update all orders respectively

* Fix check for empty oldest_orders array

* Change avg_items_per_order to number instead of integer

* Fix failing tests for new/returning customers

Only the first orders with product 1 and without coupons should be new per each customer

* Remove sleep functions from tests

* Assign second order to a variable for legibility

* Fix second order assignment and check if set
2019-02-14 11:14:01 +08:00
Albert Juhé Lluveras e2b10bdb49 Fix test_variable_product_extended_info (https://github.com/woocommerce/woocommerce-admin/pull/1498) 2019-02-07 10:49:50 +01:00
Joshua T Flowers 8c3973a445 Add manage_stock to stock controller response (https://github.com/woocommerce/woocommerce-admin/pull/1475)
* Add manage_stock to stock controller response

* Add manage_stock property to stock report tests

* Add changelog entry

* Make stock quantity float instead of int

* Add manage_stock to the products API response

* Check for manage_stock in products table

* Add manage_stock property to product API tests
2019-02-07 16:29:01 +08:00
Albert Juhé Lluveras 79738b2022 Add 'variations' attribute in products 'extended_info' (https://github.com/woocommerce/woocommerce-admin/pull/1478)
* Add 'variations' attribute in products 'extended_info'

* Add tests
2019-02-07 09:27:02 +01:00
Joshua T Flowers 2b0c8089c0 Try: Fix failing returning customer test (https://github.com/woocommerce/woocommerce-admin/pull/1496)
* Don't check against same order when checking for returning customer

* Sleep between order creation

* Add todo removal comments for sleep functions
2019-02-07 15:49:56 +08:00
Peter Fabian 79e22bcefd Switched to creating orders from oldest to newest, not the other way around. (https://github.com/woocommerce/woocommerce-admin/pull/1495)
That should hopefully take care of the problem with strange new/returning customer values and failing tests.
2019-02-07 15:41:09 +08:00
Claudio Sanches d26e82b526 Merge branch 'master' into fix/1307 2019-02-05 16:20:08 -02:00
Claudio Sanches 86c3c00480 Clean tables when order is deleted 2019-02-05 16:15:39 -02:00
Justin Shreve 949afce248 Add Product Detail Report & Finish Comparison Chart Mode Functionality (https://github.com/woocommerce/woocommerce-admin/pull/1391)
Product detail report and comparison

Code cleanup

Fix 404 on product variations endpoint after rebase

Fix up tests

Fix loading indicators and add some checks around malformed variation response

Add date filtering SQL bits to the variations query

Handle PR feedback: Fix viewport, fix duplicate product issue, fix legend display reset, fix bargraph overflow, fix some coding standards/whitespace, add extra variation santiziation.

Fix scroll on wide charts, and fix undefined prop getting passed into report chart render
2019-02-05 13:12:58 -05:00
Claudio Sanches 10f40d4cf3 Merge branch 'master' into fix/1307 2019-02-05 15:48:59 -02:00
Peter Fabian 98e91966d5 Updated tests for code in master:
- added segment arrays and
- forced sync before running asserts.
2019-02-05 18:46:42 +01:00
Peter Fabian b69d2aa2ab Merge branch 'master' into fix/1012-2
# Conflicts:
#	tests/reports/class-wc-tests-reports-orders-stats.php
2019-02-05 18:34:15 +01:00
Jeff Stieler 7664612b57 Fix order stats report status filtering test case (returning customer value incorrect). 2019-02-04 16:59:08 -07:00
Jeff Stieler f938dd5708 Invoke queue test helper in new Order Stats and Products Report tests. 2019-02-04 11:46:46 -07:00
Jeff Stieler 21572698d8 Fix unit tests that rely on queued data updates. 2019-02-04 09:18:50 -07:00
Joshua T Flowers 0d4e42def0 Add segments to expected response in order stats (https://github.com/woocommerce/woocommerce-admin/pull/1466) 2019-02-04 18:39:33 +08:00
Joshua T Flowers 17179d41ff Add order status tests and refund tests (https://github.com/woocommerce/woocommerce-admin/pull/1443)
* Add default order status tests

* Test querying an excluded status

* Add tests for product line item refunds

* Update status test method comment

* Drop @since versioning from doc blocks
2019-02-04 10:52:29 +08:00
Claudio Sanches c1bb5802d1 Fixed coding standards 2019-02-01 18:48:54 -02:00