52cb35f4de
* 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. |
||
---|---|---|
.. | ||
src | ||
.npmrc | ||
CHANGELOG.md | ||
README.md | ||
package.json |
README.md
CSV Export
A set of functions to convert data into CSV values, and enable a browser download of the CSV data.
Installation
Install the module
npm install @woocommerce/csv-export --save
Usage
onClick = () => {
// Create a file name based on a title and optional query. Will return a timestamped
// name, for example: revenue-2018-11-01-interval-month.csv
const name = generateCSVFileName( 'revenue', { interval: 'month' } );
// Create a string of CSV data, `headers` is an array of row headers, put at the top
// of the file. `rows` is a 2 dimensional array. Each array is a line in the file,
// separated by newlines. The second-level arrays are the data points in each row.
// For header format, see https://woocommerce.github.io/woocommerce-admin/#/components/table?id=headers-2
// For rows format, see https://woocommerce.github.io/woocommerce-admin/#/components/table?id=rows-1
const data = generateCSVDataFromTable( headers, rows );
// Triggers a browser UI to save a file, named the first argument, with the contents of
// the second argument.
downloadCSVFile( name, data );
}
generateCSVDataFromTable(headers, rows) ⇒ String
Generates a CSV string from table contents
Returns: String
- Table contents in a CSV format
Param | Type | Description |
---|---|---|
headers | Array.<Object> |
Object with table header information |
rows | Array.Array.<Object> |
Object with table rows information |
generateCSVFileName([name], [params]) ⇒ String
Generates a file name for CSV files based on the provided name, the current date and the provided params, which are all appended with hyphens.
Returns: String
- Formatted file name
Param | Type | Default | Description |
---|---|---|---|
[name] | String |
'' |
Name of the file |
[params] | Object |
{} |
Object of key-values to append to the file name |
downloadCSVFile(fileName, content)
Downloads a CSV file with the given file name and contents
Param | Type | Description |
---|---|---|
fileName | String |
Name of the file to download |
content | String |
Contents of the file to download |