Stockman: my favourite set of exercises to learn a new programming language.
- Read a CSV file into memory which contain sales invoice lines.
- Pretty print the invoices.
done
$ rebar3 escriptize
$ _build/default/bin/stockman v1 ./test/resources/sales-invoices-tiny.csv
- Read a CSV file into memory which contain sales invoice lines.
- Find the total sales.
- Find the most expensive invoice and pretty print it.
- Find the most expensive product and print its code.
- Calculate the average price of each product, and print the the list of prices descendingly.
- Find the total sales per customer and print a descending list in the form "customer, total".
- Find the customer with the largest total sales.
- Find the 3 customers with the least total sales and print a descending list in the form "customer, total".
- Find the date with the largest total sales amount.
done
$ rebar3 escriptize
$ _build/default/bin/stockman v2 ./test/resources/sales-invoices-tiny.csv
- Read a CSV file into memory which contains product inventory.
- Read a CSV file into memory which contain sales invoice lines.
- Check if the product referenced on each line has enough inventory.
- If no, do not import the invoice to which the line belongs.
- If yes, import the invoice line and update the inventory of the product accordingly.
- It is important to process the invoices in the order they appear in the CSV.
- Print a list of invoices listing the problematic line(s) for each invoice.
done
## use datagen to generate dummy data
$ rebar3 as datagen escriptize
$ mkdir dummy-data
$ _build/datagen/bin/datagen -o dummy-data --inventories 50 --customers 20 --sales-invoices 100 --invoice-lines 12
## feed the data into stockman
$ rebar3 escriptize
$ _build/default/bin/stockman v3 dummy-data/invoices.csv dummy-data/inventory.csv
- Read a CSV file into memory which contains product inventory.
- Read a CSV file into memory which contain sales invoice lines, where each invoice has a timestamp denoting the transaction date and time.
- Check if the product referenced on each line has enough inventory.
- If no, do not import the invoice to which the line belongs.
- If yes, import the invoice line and update the inventory of the product accordingly.
- It is important to process any given invoice only once all the other invoices with earlier timestamps have been processed.
- Print a list of invoices listing the problematic line(s) for each invoice.
done
## use datagen to generate dummy data
$ rebar3 as datagen escriptize
$ mkdir dummy-data
$ _build/datagen/bin/datagen -o dummy-data --inventories 50 --customers 20 --sales-invoices 100 --invoice-lines 12
## feed the data into stockman
$ rebar3 escriptize
$ _build/default/bin/stockman v4 --sales-invoices dummy-data/invoices.csv --inventories dummy-data/inventory.csv
- Read a CSV file into memory which contains product inventory.
- Read two CSV files into memory, one containing sales invoice lines and the other purchase invoice lines. Each invoice has a timestamp which denotes the transaction date and time.
- Check if the product referenced on each sales invoice line has enough inventory.
- If no, do not import the sales invoice to which the line belongs.
- If yes, import the invoice line and update the inventory of the product accordingly.
- It is important to process any given invoice only once all the other invoices (sales and purchase) with earlier timestamps have been processed.
- Print a list of sales invoices listing the problematic line(s) for each invoice.
done
All files are under Apache License v2.0, unless otherwise specified.