2018-11-12 16:27:19 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
2021-07-13 22:17:51 +00:00
|
|
|
import { __, _x } from '@wordpress/i18n';
|
2019-05-20 01:57:06 +00:00
|
|
|
import { applyFilters } from '@wordpress/hooks';
|
2018-11-12 16:27:19 +00:00
|
|
|
|
2019-08-28 14:55:55 +00:00
|
|
|
const REVENUE_REPORT_CHARTS_FILTER = 'woocommerce_admin_revenue_report_charts';
|
2020-02-14 02:23:21 +00:00
|
|
|
const REVENUE_REPORT_FILTERS_FILTER =
|
|
|
|
'woocommerce_admin_revenue_report_filters';
|
|
|
|
const REVENUE_REPORT_ADVANCED_FILTERS_FILTER =
|
|
|
|
'woocommerce_admin_revenue_report_advanced_filters';
|
2019-05-20 01:57:06 +00:00
|
|
|
|
2019-08-28 14:55:55 +00:00
|
|
|
export const charts = applyFilters( REVENUE_REPORT_CHARTS_FILTER, [
|
2018-11-12 16:27:19 +00:00
|
|
|
{
|
2019-11-22 15:06:14 +00:00
|
|
|
key: 'gross_sales',
|
2021-08-13 18:54:24 +00:00
|
|
|
label: __( 'Gross sales', 'woocommerce-admin' ),
|
2019-02-15 10:54:41 +00:00
|
|
|
order: 'desc',
|
2019-11-22 15:06:14 +00:00
|
|
|
orderby: 'gross_sales',
|
2018-11-12 16:27:19 +00:00
|
|
|
type: 'currency',
|
2021-07-28 00:50:01 +00:00
|
|
|
isReverseTrend: false,
|
2018-11-12 16:27:19 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
key: 'refunds',
|
2019-11-22 15:06:14 +00:00
|
|
|
label: __( 'Returns', 'woocommerce-admin' ),
|
2019-02-15 10:54:41 +00:00
|
|
|
order: 'desc',
|
|
|
|
orderby: 'refunds',
|
2018-11-12 16:27:19 +00:00
|
|
|
type: 'currency',
|
2021-07-28 00:50:01 +00:00
|
|
|
isReverseTrend: true,
|
2018-11-12 16:27:19 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
key: 'coupons',
|
2019-03-13 17:14:02 +00:00
|
|
|
label: __( 'Coupons', 'woocommerce-admin' ),
|
2019-02-15 10:54:41 +00:00
|
|
|
order: 'desc',
|
|
|
|
orderby: 'coupons',
|
2018-11-12 16:27:19 +00:00
|
|
|
type: 'currency',
|
2021-07-28 00:50:01 +00:00
|
|
|
isReverseTrend: false,
|
2018-11-12 16:27:19 +00:00
|
|
|
},
|
2019-11-22 15:06:14 +00:00
|
|
|
{
|
|
|
|
key: 'net_revenue',
|
2021-08-13 18:54:24 +00:00
|
|
|
label: __( 'Net sales', 'woocommerce-admin' ),
|
2019-11-22 15:06:14 +00:00
|
|
|
orderby: 'net_revenue',
|
|
|
|
type: 'currency',
|
2021-07-28 00:50:01 +00:00
|
|
|
isReverseTrend: false,
|
2019-11-22 15:06:14 +00:00
|
|
|
},
|
2018-11-12 16:27:19 +00:00
|
|
|
{
|
|
|
|
key: 'taxes',
|
2019-03-13 17:14:02 +00:00
|
|
|
label: __( 'Taxes', 'woocommerce-admin' ),
|
2019-02-15 10:54:41 +00:00
|
|
|
order: 'desc',
|
|
|
|
orderby: 'taxes',
|
2018-11-12 16:27:19 +00:00
|
|
|
type: 'currency',
|
2021-07-28 00:50:01 +00:00
|
|
|
isReverseTrend: false,
|
2018-11-12 16:27:19 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
key: 'shipping',
|
2019-03-13 17:14:02 +00:00
|
|
|
label: __( 'Shipping', 'woocommerce-admin' ),
|
2019-02-15 10:54:41 +00:00
|
|
|
orderby: 'shipping',
|
2018-11-12 16:27:19 +00:00
|
|
|
type: 'currency',
|
2021-07-28 00:50:01 +00:00
|
|
|
isReverseTrend: false,
|
2018-11-12 16:27:19 +00:00
|
|
|
},
|
|
|
|
{
|
2019-11-22 15:06:14 +00:00
|
|
|
key: 'total_sales',
|
2021-08-13 18:54:24 +00:00
|
|
|
label: __( 'Total sales', 'woocommerce-admin' ),
|
2019-11-22 15:06:14 +00:00
|
|
|
order: 'desc',
|
|
|
|
orderby: 'total_sales',
|
2018-11-12 16:27:19 +00:00
|
|
|
type: 'currency',
|
2021-07-28 00:50:01 +00:00
|
|
|
isReverseTrend: false,
|
2018-11-12 16:27:19 +00:00
|
|
|
},
|
2019-05-20 01:57:06 +00:00
|
|
|
] );
|
2019-08-27 19:33:31 +00:00
|
|
|
|
2020-02-14 02:23:21 +00:00
|
|
|
export const advancedFilters = applyFilters(
|
|
|
|
REVENUE_REPORT_ADVANCED_FILTERS_FILTER,
|
2021-07-13 22:17:51 +00:00
|
|
|
{
|
|
|
|
filters: {},
|
|
|
|
title: _x(
|
|
|
|
'Revenue Matches {{select /}} Filters',
|
|
|
|
'A sentence describing filters for Revenue. See screen shot for context: https://cloudup.com/cSsUY9VeCVJ',
|
|
|
|
'woocommerce-admin'
|
|
|
|
),
|
|
|
|
}
|
2020-02-14 02:23:21 +00:00
|
|
|
);
|
2021-07-13 22:17:51 +00:00
|
|
|
|
|
|
|
const filterValues = [];
|
|
|
|
|
|
|
|
if ( Object.keys( advancedFilters.filters ).length ) {
|
|
|
|
filterValues.push( {
|
|
|
|
label: __( 'All Revenue', 'woocommerce-admin' ),
|
|
|
|
value: 'all',
|
|
|
|
} );
|
|
|
|
filterValues.push( {
|
|
|
|
label: __( 'Advanced Filters', 'woocommerce-admin' ),
|
|
|
|
value: 'advanced',
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
|
|
|
|
export const filters = applyFilters( REVENUE_REPORT_FILTERS_FILTER, [
|
|
|
|
{
|
|
|
|
label: __( 'Show', 'woocommerce-admin' ),
|
|
|
|
staticParams: [ 'chartType', 'paged', 'per_page' ],
|
|
|
|
param: 'filter',
|
|
|
|
showFilters: () => filterValues.length > 0,
|
|
|
|
filters: filterValues,
|
|
|
|
},
|
|
|
|
] );
|