woocommerce/plugins/woocommerce-admin/client/dashboard/dashboard-charts/config.js

106 lines
2.4 KiB
JavaScript
Raw Normal View History

/** @format */
2019-05-20 01:57:06 +00:00
/**
* External dependencies
*/
import { __ } from '@wordpress/i18n';
2019-05-20 01:57:06 +00:00
import { applyFilters } from '@wordpress/hooks';
/**
* Internal dependencies
*/
import { charts as ordersCharts } from 'analytics/report/orders/config';
import { charts as productsCharts } from 'analytics/report/products/config';
import { charts as revenueCharts } from 'analytics/report/revenue/config';
import { charts as couponsCharts } from 'analytics/report/coupons/config';
import { charts as taxesCharts } from 'analytics/report/taxes/config';
2019-05-20 01:57:06 +00:00
import { charts as downloadsCharts } from 'analytics/report/downloads/config';
const DASHBOARD_CHARTS_FILTER = 'woocommerce_admin_dashboard_charts_filter';
const charts = {
revenue: revenueCharts,
orders: ordersCharts,
products: productsCharts,
coupons: couponsCharts,
taxes: taxesCharts,
downloads: downloadsCharts,
};
const defaultCharts = [
{
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 15:06:14 +00:00
label: __( 'Total Sales', 'woocommerce-admin' ),
report: 'revenue',
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 15:06:14 +00:00
key: 'total_sales',
},
{
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 15:06:14 +00:00
label: __( 'Net Sales', 'woocommerce-admin' ),
report: 'revenue',
key: 'net_revenue',
},
{
label: __( 'Orders', 'woocommerce-admin' ),
report: 'orders',
key: 'orders_count',
},
{
label: __( 'Average Order Value', 'woocommerce-admin' ),
report: 'orders',
key: 'avg_order_value',
},
{
label: __( 'Items Sold', 'woocommerce-admin' ),
report: 'products',
key: 'items_sold',
},
{
label: __( 'Returns', 'woocommerce-admin' ),
report: 'revenue',
key: 'refunds',
},
{
label: __( 'Discounted Orders', 'woocommerce-admin' ),
report: 'coupons',
key: 'orders_count',
},
{
label: __( 'Gross discounted', 'woocommerce-admin' ),
report: 'coupons',
key: 'amount',
},
{
label: __( 'Total Tax', 'woocommerce-admin' ),
report: 'taxes',
key: 'total_tax',
},
{
label: __( 'Order Tax', 'woocommerce-admin' ),
report: 'taxes',
key: 'order_tax',
},
{
label: __( 'Shipping Tax', 'woocommerce-admin' ),
report: 'taxes',
key: 'shipping_tax',
},
{
label: __( 'Shipping', 'woocommerce-admin' ),
report: 'revenue',
key: 'shipping',
},
{
label: __( 'Downloads', 'woocommerce-admin' ),
report: 'downloads',
key: 'download_count',
},
];
export const uniqCharts = applyFilters(
DASHBOARD_CHARTS_FILTER,
defaultCharts.map( chartDef => ( {
...charts[ chartDef.report ].find( chart => chart.key === chartDef.key ),
label: chartDef.label,
endpoint: chartDef.report,
} ) )
);