Crate sales

Crate sales 

Source
Expand description

Crate Docs CI Audit Maintenance

The sales crate provides a command-line tool, and library, for reporting and aggregating sales data (for example, from CSV files).

§Installation

cargo install sales

§Usage

Download your sales data for the relevant period to a file, for example, data.csv, and run:

sales data.csv

Example output:

Product / Group                                       Units      Revenue
------------------------------------------------------------------------
Go mentoring                                             11      3134.45
Code For Your Life                                        2        79.90
For the Love of Go (2023)                                 1        39.95
For the Love of Go: Video/Book Bundle (2023 edition)      1        74.95
The Power of Go: Tests                                    1        39.95
The Power of Go: Tools                                    1        39.95
------------------------------------------------------------------------
Total                                                    17      3409.15

§Sorting by revenue

The default sorting is by unit sales, descending, and then alphabetically. To sort by revenue instead, use the --revenue flag:

sales --revenue data.csv
Product / Group                                       Units      Revenue
------------------------------------------------------------------------
Go mentoring                                             11      3134.45
Code For Your Life                                        2        79.90
For the Love of Go: Video/Book Bundle (2023 edition)      1        74.95
For the Love of Go (2023)                                 1        39.95
The Power of Go: Tests                                    1        39.95
The Power of Go: Tools                                    1        39.95
------------------------------------------------------------------------
Total                                                    17      3409.15

To aggregate the sales data for a group of related products, create a group specification file with the following format:

GROUP_NAME | GROUP_REGEX

A simple example, which groups two sets of products by matching shared substrings in their names:

For the Love of Go | For the Love
Power of Go Series | The Power of Go

Use the --groups flag to apply this group specification, and rerun the tool to see the result:

sales --groups groups.txt data.csv
Product / Group     Units      Revenue
--------------------------------------
Go mentoring           11      3134.45
Code For Your Life      2        79.90
For the Love of Go      2       114.90
Power of Go Series      2        79.90
--------------------------------------
Total                  17      3409.15

§Input formats

sales can interpret CSV data produced by Squarespace, Gumroad, and similar platforms. It reads only the product name, price, and quantity columns.

  • The product name column heading should be “Lineitem name” or “Item Name”.

  • The product price column heading should be “Lineitem price” or “Item Price ($)”.

  • The product quantity column heading should be “Lineitem quantity” or “Quantity”.

Structs§

Report
Holds sales data.