Commit Graph

112 Commits

Author SHA1 Message Date
Chi-Hsuan Huang ae0ea6df2c Fix php unit test "test_deleted_coupons" for wc >= 6.1.0 (https://github.com/woocommerce/woocommerce-admin/pull/8162)
* Fix bin/install-wp-tests.sh for wc >= 6.0.0

* Fix php unit test "test_deleted_coupons" for wc >= 6.1.0

* Update WC_Tests_Reports_Coupons test_populate_and_query test

Fix test
2022-01-18 13:31:21 +08:00
Joshua T Flowers b8b7c94bd1 Fix unsecured report files (https://github.com/woocommerce/woocommerce-admin/pull/7691)
* Fix unsecured report files

* Add changelog entry
2021-09-21 12:06:49 -07:00
Moon 59f0ffd1a6 Fix broken tests with the latest WC (https://github.com/woocommerce/woocommerce-admin/pull/7582) 2021-08-30 12:02:38 -07:00
David Levin c728cced1f Sentence case all the things analytics (https://github.com/woocommerce/woocommerce-admin/pull/6501)
* Sentence case all the things

* Update a few more things that were missed on the first round

* update documentation titles to use title case

* Add changelog

* Handle PR feedback

* Revert readme changelog changes

* Revert changes to ALT text in dev documentation

* Revert a change to ALT text in dev documentation

* Fix failing tests

Co-authored-by: David Levin <davidlevin@Davids-MacBook-Pro-2.local>
Co-authored-by: Joshua Flowers <joshuatf@gmail.com>
Co-authored-by: Adrian Duffell <9312929+adrianduffell@users.noreply.github.com>
2021-08-13 14:54:24 -04:00
Jeff Stieler 9f63719baa Fix attribute filter for "any X" variations. (https://github.com/woocommerce/woocommerce-admin/pull/7046)
* Use order item data to match attributes.

Fixes matching on products with "any x" attributes.

* Fix attribute query on variations report.

* Fix variations report item count.

* Add test coverage.

* Add changelog entry.

* Fix non-string query prop warning in SelectControl component.

* Move custom attribute retrieval to a reusable Trait.

* Ensure all custom attribute terms are included in the API response.

* Combine all terms from custom attributes.

When they're split across multiple products.
2021-06-22 08:45:08 -04:00
Jeff Stieler b5f397fa89 Fix report arguments handling in CSV export. (https://github.com/woocommerce/woocommerce-admin/pull/7165)
* Ensure report args are mapped and sanitized before CSV export.

* Add test.

* Fix products query when there are no products in the specified categories.

* Add changelog.
2021-06-18 10:53:52 -06:00
Jeff Stieler d3fd2f36d0 Include orders without coupons when excluding specific coupon IDs. (https://github.com/woocommerce/woocommerce-admin/pull/7021)
* Include orders without coupons when excluding specific coupon IDs.

* Add changelog entry.

* Fix default Orders before/after query args.

* Specify date range for test query.
2021-06-08 14:56:23 -04:00
Fernando 0ebccd674b Fixed associated Order Number for refunds (https://github.com/woocommerce/woocommerce-admin/pull/6428)
* Fixed related orders problem

This commit fixes the related orders problem

* Fixed customer type query

* Fixed get_order_number filtering

* Added a default value to totalResults

This commit adds a default value to totalResults (in order to avoid errors)

* Added testing instructions

# Conflicts:
#	TESTING-INSTRUCTIONS.md

* Added changelog

# Conflicts:
#	readme.txt

* Fixed orders without products

* Added tests

Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
2021-03-09 15:57:50 -03:00
Adrian Duffell 300504ea94 Fix inconsistent customer Type parameter in REST endpoints (https://github.com/woocommerce/woocommerce-admin/pull/5823)
The wc-analytics/reports/orders and /wc-analytics/reports/orders/stats endpoints have inconsistent parameter names for filtering the customer type: customer_type vs customer.

This was affecting the Customer Type filter in the orders analytics, reported in issue woocommerce/woocommerce-admin#5803, where the component expects the parameter names to be the same. This is because it uses a parameter name based on the key in the filter configuration (customer_type).

To resolve this, this PR updates /wc-analytics/reports/orders/stats to accept both customer_type and customer as parameter names for this filter. The customer parameter has however been deprecated in its description to discourage usage.

Co-authored-by: Sam Seay <samueljseay@gmail.com>
2020-12-07 06:39:29 +08:00
Adrian Duffell f08ccc57d7 Remove customer analytics data upon order deletion (https://github.com/woocommerce/woocommerce-admin/pull/5171)
This deletes the associated customer record when an order is deleted, provided that this is the only order for the customer.
2020-10-01 20:09:04 +08:00
Jeff Stieler bc39bdf646 Show full variation name instead of parent product in orders report. (https://github.com/woocommerce/woocommerce-admin/pull/5056) 2020-09-01 08:22:36 -04:00
Claudio Sanches 073a3f706f Fix usage of "package" tag in file headers (https://github.com/woocommerce/woocommerce-admin/pull/4940)
* Don't require package tag or file comment inside src

* Removed package tag from files inside src

* Fixed tests directory in phpcs.xml.dist

* Fixed usage of package tag

* Fixed new classes

* Fixed coding standards

* Fixed coding standards in tests
2020-08-11 16:18:47 -03:00
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