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
|
|
|
|
2022-02-11 14:38:38 +00:00
|
|
|
/**
|
|
|
|
* @typedef {import('../index.js').chart} chart
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Revenue Report charts filter.
|
|
|
|
*
|
|
|
|
* @filter woocommerce_admin_revenue_report_charts
|
|
|
|
* @param {Array.<chart>} charts Report charts.
|
|
|
|
*/
|
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',
|
2022-03-30 09:00:04 +00:00
|
|
|
label: __( 'Gross sales', 'woocommerce' ),
|
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',
|
2022-03-30 09:00:04 +00:00
|
|
|
label: __( 'Returns', 'woocommerce' ),
|
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',
|
2022-03-30 09:00:04 +00:00
|
|
|
label: __( 'Coupons', 'woocommerce' ),
|
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',
|
2022-03-30 09:00:04 +00:00
|
|
|
label: __( 'Net sales', 'woocommerce' ),
|
2019-11-22 15:06:14 +00:00
|
|
|
orderby: 'net_revenue',
|
|
|
|
type: 'currency',
|
2021-07-28 00:50:01 +00:00
|
|
|
isReverseTrend: false,
|
2022-01-18 20:07:32 +00:00
|
|
|
labelTooltipText: __(
|
|
|
|
'Full refunds are not deducted from tax or net sales totals',
|
2022-03-30 09:00:04 +00:00
|
|
|
'woocommerce'
|
2022-01-18 20:07:32 +00:00
|
|
|
),
|
2019-11-22 15:06:14 +00:00
|
|
|
},
|
2018-11-12 16:27:19 +00:00
|
|
|
{
|
|
|
|
key: 'taxes',
|
2022-03-30 09:00:04 +00:00
|
|
|
label: __( 'Taxes', 'woocommerce' ),
|
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,
|
2022-01-18 20:07:32 +00:00
|
|
|
labelTooltipText: __(
|
|
|
|
'Full refunds are not deducted from tax or net sales totals',
|
2022-03-30 09:00:04 +00:00
|
|
|
'woocommerce'
|
2022-01-18 20:07:32 +00:00
|
|
|
),
|
2018-11-12 16:27:19 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
key: 'shipping',
|
2022-03-30 09:00:04 +00:00
|
|
|
label: __( 'Shipping', 'woocommerce' ),
|
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',
|
2022-03-30 09:00:04 +00:00
|
|
|
label: __( 'Total sales', 'woocommerce' ),
|
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
|
|
|
|
2022-02-11 14:38:38 +00:00
|
|
|
/**
|
|
|
|
* Revenue Report Advanced Filters.
|
|
|
|
*
|
|
|
|
* @filter woocommerce_admin_revenue_report_advanced_filters
|
2022-03-18 11:45:14 +00:00
|
|
|
* @param {Object} advancedFilters Report Advanced Filters.
|
|
|
|
* @param {string} advancedFilters.title Interpolated component string for Advanced Filters title.
|
2022-02-11 14:38:38 +00:00
|
|
|
* @param {Object} advancedFilters.filters An object specifying a report's Advanced Filters.
|
|
|
|
*/
|
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',
|
2022-03-30 09:00:04 +00:00
|
|
|
'woocommerce'
|
2021-07-13 22:17:51 +00:00
|
|
|
),
|
|
|
|
}
|
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( {
|
2022-03-30 09:00:04 +00:00
|
|
|
label: __( 'All Revenue', 'woocommerce' ),
|
2021-07-13 22:17:51 +00:00
|
|
|
value: 'all',
|
|
|
|
} );
|
|
|
|
filterValues.push( {
|
2022-03-30 09:00:04 +00:00
|
|
|
label: __( 'Advanced Filters', 'woocommerce' ),
|
2021-07-13 22:17:51 +00:00
|
|
|
value: 'advanced',
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
|
2022-02-11 14:38:38 +00:00
|
|
|
/**
|
|
|
|
* @typedef {import('../index.js').filter} filter
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Revenue Report Filters.
|
|
|
|
*
|
|
|
|
* @filter woocommerce_admin_revenue_report_filters
|
|
|
|
* @param {Array.<filter>} filters Report filters.
|
|
|
|
*/
|
2021-07-13 22:17:51 +00:00
|
|
|
export const filters = applyFilters( REVENUE_REPORT_FILTERS_FILTER, [
|
|
|
|
{
|
2022-03-30 09:00:04 +00:00
|
|
|
label: __( 'Show', 'woocommerce' ),
|
2021-07-13 22:17:51 +00:00
|
|
|
staticParams: [ 'chartType', 'paged', 'per_page' ],
|
|
|
|
param: 'filter',
|
|
|
|
showFilters: () => filterValues.length > 0,
|
|
|
|
filters: filterValues,
|
|
|
|
},
|
|
|
|
] );
|