2018-11-14 21:04:59 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { __ } from '@wordpress/i18n';
|
2019-05-20 01:57:06 +00:00
|
|
|
import { applyFilters } from '@wordpress/hooks';
|
2018-12-06 22:18:46 +00:00
|
|
|
|
2018-11-14 21:04:59 +00:00
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
2019-02-27 02:37:24 +00:00
|
|
|
import { getRequestByIdString } from 'lib/async-requests';
|
2018-12-06 22:18:46 +00:00
|
|
|
import { getTaxCode } from './utils';
|
2019-01-30 07:22:10 +00:00
|
|
|
import { NAMESPACE } from 'wc-api/constants';
|
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
|
|
|
|
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',
|
2019-03-13 17:14:02 +00:00
|
|
|
label: __( 'Total Tax', 'woocommerce-admin' ),
|
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',
|
2019-03-13 17:14:02 +00:00
|
|
|
label: __( 'Order Tax', 'woocommerce-admin' ),
|
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',
|
2019-03-13 17:14:02 +00:00
|
|
|
label: __( 'Shipping Tax', 'woocommerce-admin' ),
|
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',
|
2019-08-26 22:37:16 +00:00
|
|
|
label: __( 'Orders', 'woocommerce-admin' ),
|
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
|
|
|
|
2019-08-23 16:41:42 +00:00
|
|
|
export const filters = applyFilters( TAXES_REPORT_FILTERS_FILTER, [
|
2018-11-14 21:04:59 +00:00
|
|
|
{
|
2019-03-13 17:14:02 +00:00
|
|
|
label: __( 'Show', 'woocommerce-admin' ),
|
2018-11-14 21:04:59 +00:00
|
|
|
staticParams: [ 'chart' ],
|
|
|
|
param: 'filter',
|
|
|
|
showFilters: () => true,
|
2018-12-06 22:18:46 +00:00
|
|
|
filters: [
|
2019-03-13 17:14:02 +00:00
|
|
|
{ label: __( 'All Taxes', 'woocommerce-admin' ), value: 'all' },
|
2018-12-06 22:18:46 +00:00
|
|
|
{
|
2019-03-13 17:14:02 +00:00
|
|
|
label: __( 'Comparison', 'woocommerce-admin' ),
|
2019-02-14 04:03:00 +00:00
|
|
|
value: 'compare-taxes',
|
2018-12-06 22:18:46 +00:00
|
|
|
chartMode: 'item-comparison',
|
|
|
|
settings: {
|
|
|
|
type: 'taxes',
|
|
|
|
param: 'taxes',
|
2020-02-14 02:23:21 +00:00
|
|
|
getLabels: getRequestByIdString(
|
|
|
|
NAMESPACE + '/taxes',
|
|
|
|
( tax ) => ( {
|
|
|
|
id: tax.id,
|
|
|
|
label: getTaxCode( tax ),
|
|
|
|
} )
|
|
|
|
),
|
2018-12-06 22:18:46 +00:00
|
|
|
labels: {
|
2020-02-14 02:23:21 +00:00
|
|
|
helpText: __(
|
|
|
|
'Check at least two tax codes below to compare',
|
|
|
|
'woocommerce-admin'
|
|
|
|
),
|
|
|
|
placeholder: __(
|
|
|
|
'Search for tax codes to compare',
|
|
|
|
'woocommerce-admin'
|
|
|
|
),
|
2019-03-13 17:14:02 +00:00
|
|
|
title: __( 'Compare Tax Codes', 'woocommerce-admin' ),
|
|
|
|
update: __( 'Compare', 'woocommerce-admin' ),
|
2018-12-06 22:18:46 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
2018-11-14 21:04:59 +00:00
|
|
|
},
|
2019-08-23 16:41:42 +00:00
|
|
|
] );
|
2019-08-27 19:33:31 +00:00
|
|
|
|
2020-02-14 02:23:21 +00:00
|
|
|
export const advancedFilters = applyFilters(
|
|
|
|
TAXES_REPORT_ADVANCED_FILTERS_FILTER,
|
|
|
|
{}
|
|
|
|
);
|