2018-11-14 21:04:59 +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';
|
2023-03-16 14:22:33 +00:00
|
|
|
import { STORE_KEY as CES_STORE_KEY } from '@woocommerce/customer-effort-score';
|
2020-09-03 21:45:40 +00:00
|
|
|
import { NAMESPACE } from '@woocommerce/data';
|
2021-04-22 20:06:46 +00:00
|
|
|
import { dispatch } from '@wordpress/data';
|
2018-12-06 22:18:46 +00:00
|
|
|
|
2018-11-14 21:04:59 +00:00
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
2020-08-13 02:05:22 +00:00
|
|
|
import { getRequestByIdString } from '../../../lib/async-requests';
|
2018-12-06 22:18:46 +00:00
|
|
|
import { getTaxCode } from './utils';
|
2018-11-14 21:04:59 +00:00
|
|
|
|
2019-08-28 14:55:55 +00:00
|
|
|
const TAXES_REPORT_CHARTS_FILTER = 'woocommerce_admin_taxes_report_charts';
|
2019-08-23 16:41:42 +00:00
|
|
|
const TAXES_REPORT_FILTERS_FILTER = 'woocommerce_admin_taxes_report_filters';
|
2020-02-14 02:23:21 +00:00
|
|
|
const TAXES_REPORT_ADVANCED_FILTERS_FILTER =
|
|
|
|
'woocommerce_admin_taxes_report_advanced_filters';
|
2019-05-20 01:57:06 +00:00
|
|
|
|
2021-04-22 20:06:46 +00:00
|
|
|
const { addCesSurveyForAnalytics } = dispatch( CES_STORE_KEY );
|
|
|
|
|
2022-02-11 14:38:38 +00:00
|
|
|
/**
|
|
|
|
* @typedef {import('../index.js').chart} chart
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Taxes Report charts filter.
|
|
|
|
*
|
|
|
|
* @filter woocommerce_admin_taxes_report_charts
|
|
|
|
* @param {Array.<chart>} charts Report charts.
|
|
|
|
*/
|
2019-08-28 14:55:55 +00:00
|
|
|
export const charts = applyFilters( TAXES_REPORT_CHARTS_FILTER, [
|
2018-11-14 21:04:59 +00:00
|
|
|
{
|
2019-01-22 15:49:17 +00:00
|
|
|
key: 'total_tax',
|
2022-03-30 09:00:04 +00:00
|
|
|
label: __( 'Total tax', 'woocommerce' ),
|
2019-02-15 10:54:41 +00:00
|
|
|
order: 'desc',
|
|
|
|
orderby: 'total_tax',
|
2018-11-14 21:04:59 +00:00
|
|
|
type: 'currency',
|
|
|
|
},
|
|
|
|
{
|
2019-01-22 15:49:17 +00:00
|
|
|
key: 'order_tax',
|
2022-03-30 09:00:04 +00:00
|
|
|
label: __( 'Order tax', 'woocommerce' ),
|
2019-02-15 10:54:41 +00:00
|
|
|
order: 'desc',
|
|
|
|
orderby: 'order_tax',
|
2018-11-14 21:04:59 +00:00
|
|
|
type: 'currency',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: 'shipping_tax',
|
2022-03-30 09:00:04 +00:00
|
|
|
label: __( 'Shipping tax', 'woocommerce' ),
|
2019-02-15 10:54:41 +00:00
|
|
|
order: 'desc',
|
|
|
|
orderby: 'shipping_tax',
|
2018-11-14 21:04:59 +00:00
|
|
|
type: 'currency',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: 'orders_count',
|
2022-03-30 09:00:04 +00:00
|
|
|
label: __( 'Orders', 'woocommerce' ),
|
2019-02-15 10:54:41 +00:00
|
|
|
order: 'desc',
|
|
|
|
orderby: 'orders_count',
|
2018-11-14 21:04:59 +00:00
|
|
|
type: 'number',
|
|
|
|
},
|
2019-05-20 01:57:06 +00:00
|
|
|
] );
|
2018-11-14 21:04:59 +00:00
|
|
|
|
2022-02-11 14:38:38 +00:00
|
|
|
/**
|
|
|
|
* Taxes Report Advanced Filters.
|
|
|
|
*
|
|
|
|
* @filter woocommerce_admin_taxes_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.
|
|
|
|
*/
|
2021-07-13 22:17:51 +00:00
|
|
|
export const advancedFilters = applyFilters(
|
|
|
|
TAXES_REPORT_ADVANCED_FILTERS_FILTER,
|
|
|
|
{
|
|
|
|
filters: {},
|
|
|
|
title: _x(
|
2023-04-26 10:58:14 +00:00
|
|
|
'Taxes match <select/> filters',
|
2021-07-13 22:17:51 +00:00
|
|
|
'A sentence describing filters for Taxes. 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
|
|
|
),
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
const filterValues = [
|
2022-03-30 09:00:04 +00:00
|
|
|
{ label: __( 'All taxes', 'woocommerce' ), value: 'all' },
|
2021-07-13 22:17:51 +00:00
|
|
|
{
|
2022-03-30 09:00:04 +00:00
|
|
|
label: __( 'Comparison', 'woocommerce' ),
|
2021-07-13 22:17:51 +00:00
|
|
|
value: 'compare-taxes',
|
|
|
|
chartMode: 'item-comparison',
|
|
|
|
settings: {
|
|
|
|
type: 'taxes',
|
|
|
|
param: 'taxes',
|
|
|
|
getLabels: getRequestByIdString(
|
|
|
|
NAMESPACE + '/taxes',
|
|
|
|
( tax ) => ( {
|
|
|
|
id: tax.id,
|
|
|
|
key: tax.id,
|
|
|
|
label: getTaxCode( tax ),
|
|
|
|
} )
|
|
|
|
),
|
|
|
|
labels: {
|
|
|
|
helpText: __(
|
|
|
|
'Check at least two tax codes below to compare',
|
2022-03-30 09:00:04 +00:00
|
|
|
'woocommerce'
|
2021-07-13 22:17:51 +00:00
|
|
|
),
|
|
|
|
placeholder: __(
|
|
|
|
'Search for tax codes to compare',
|
2022-03-30 09:00:04 +00:00
|
|
|
'woocommerce'
|
2021-07-13 22:17:51 +00:00
|
|
|
),
|
2022-03-30 09:00:04 +00:00
|
|
|
title: __( 'Compare Tax Codes', 'woocommerce' ),
|
|
|
|
update: __( 'Compare', 'woocommerce' ),
|
2021-07-13 22:17:51 +00:00
|
|
|
},
|
|
|
|
onClick: addCesSurveyForAnalytics,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
if ( Object.keys( advancedFilters.filters ).length ) {
|
|
|
|
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
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Coupons Report Filters.
|
|
|
|
*
|
|
|
|
* @filter woocommerce_admin_taxes_report_filters
|
|
|
|
* @param {Array.<filter>} filters Report filters.
|
|
|
|
*/
|
2019-08-23 16:41:42 +00:00
|
|
|
export const filters = applyFilters( TAXES_REPORT_FILTERS_FILTER, [
|
2018-11-14 21:04:59 +00:00
|
|
|
{
|
2022-03-30 09:00:04 +00:00
|
|
|
label: __( 'Show', 'woocommerce' ),
|
2020-07-08 00:38:50 +00:00
|
|
|
staticParams: [ 'chartType', 'paged', 'per_page' ],
|
2018-11-14 21:04:59 +00:00
|
|
|
param: 'filter',
|
|
|
|
showFilters: () => true,
|
2021-07-13 22:17:51 +00:00
|
|
|
filters: filterValues,
|
2018-11-14 21:04:59 +00:00
|
|
|
},
|
2019-08-23 16:41:42 +00:00
|
|
|
] );
|