javascript workshop based on french startup https://www.convargo.com
Table of Contents generated with DocToc
- Introduction
- Objectives
- Just tell me what to do
- Don't forget:
- Exercises
- Source
- Licence
Convargo wants to revolutionise the freight industry, by connecting shippers with truckers in real time via a web application.
The Goods freight transport sector is a key sector of the Europe (even worldwilde) economy:
- 300 billion euros in Europe
- 43 billion euros in France
- highly fragmented with more than 40,000 road transport companies in France
- under efficient: ⅓ trucks drive empty on Fance roads!
The Convargo platform allows shippers to:
- access directy to a wide range of road transport companies with available loading capacity
- compute and display the transport price calculated according to the best opportunities on the market at a time T
- track in real-time the goods delivery
- access to proof of transport and dematerialized invoices
We focus on this platform feature: compute and display the transport price calculated according to the best opportunities on the market at a time T
.
The next exercises goals are to
- compute the ship price for the
shippers
- compute the profit of the road transport company, the
truckers
- compute the commission of
convargo
- Fork the project via
github
- Clone the project
git clone https://github.com/YOUR_USERNAME/convargo
- Solve each exercises inside ./public/index.js file with JavaScript
- Once the exercise is solved, commit something like
git add -A && git commit -m "feat(price): decrease pricing for longer rentals"
(why following a convention?) - 5 exercises, so ideally 5 commits
- Don't forget to push before the end of the workshop
- Check that your codebase works by opening /public/index.html in your browser
- Check the ouput in your browser console
- DRY - Don't repeat yourself
- DOT - Do One Thing
- KISS - Keep It Simple Stupid
- LIM - Less Is More
- English only: codebase, variables, comments...
**Focus only on coding, forgot the browser display (next workshop!).
Use console.log
to display results (for the moment)**
The shipper books the trucker for an itinerary and volume.
The shipping price is the sum of the distance component and the volume component with
- distance component: the number of kilometers multiplied by the trucker price per km
- volume component: the used volume multiplied by the trucker price per m3
shipping price = distance + volume
Write JS code that generates the shpping price for each shipper
from index.js
file:
const deliveries = ...;
...
console.log(deliveries);
//example output from console.log
[
{
"id": "bba9500c-fd9e-453f-abf1-4cd8f52af377",
...
"price": ?
},
{
"id": "65203b0a-a864-4dea-81e2-e389515752a8",
...
"price": ?
},
{
"id": "165d65ec-5e3f-488e-b371-d56ee100aa58",
...
"price": ?
}
]
To be as competitive as possible, convargo decide to have a decreasing pricing for high volumes.
price per m3
- decreases by 10% after 5 m3
- decreases by 30% after 10 m3
- decreases by 50% after 25 m3
Adapt the shipping price computation to take these new rules into account.
const deliveries = ...;
...
console.log(deliveries);
//example output from console.log
[
{
"id": "bba9500c-fd9e-453f-abf1-4cd8f52af377",
...
"price": ?
},
{
"id": "65203b0a-a864-4dea-81e2-e389515752a8",
...
"price": ?
},
{
"id": "165d65ec-5e3f-488e-b371-d56ee100aa58",
...
"price": ?
}
]
Now, it's time to pay the truckers
Convargo take a 30% commission on the shipping price to cover their costs.
The commission is split like this:
- insurance: half of commission
- the Treasury: 1€ by 500km range
- convargo: the rest
Compute the amount that belongs to the insurance, to the assistance and to convargo.
const deliveries = ...;
...
console.log(deliveries);
//example output from console.log
[
{
"id": "bba9500c-fd9e-453f-abf1-4cd8f52af377",
...
"commission": {
"insurance": ?,
"treasury": ?
"convargo": ?
}
},
...
]
In case of an accident/theft, convargo applies a 1000€ deductible.
The shipper can reduce the deductible amount from 1000€ to 200€ with a deductible option
for a few more euros per volume.
The driver is charged an additional 1€/m3 when he chooses the deductible reduction
option.
The additional charge goes to convargo, not to the trucker.
Compute the new amount price if the shipper subscribed to deductible option
.
const deliveries = ...;
...
console.log(rentals);
//example output from console.log
[
{
"id": "bba9500c-fd9e-453f-abf1-4cd8f52af377",
'options': {
'deductibleReduction': true
},
...
"price": ?
},
...
]
It's time to debit/credit each actor!
- the shipper must pay the shipping price and the (optional) deductible reduction
- the trucker receives the shipping price minus the commission
- the insurance receives its part of the commission
- the Treasury receives its part of the tax commission
- convargo receives its part of the commission, plus the deductible reduction
- Compute the debit for the
shipper
- Compute the credit of the car
trucker
,insurance
, andconvargo
.
const actors = ...;
...
console.log(actors);
//example output from console.log
[
{
"deliveryId": "bba9500c-fd9e-453f-abf1-4cd8f52af377",
"payment": [
{
"who": "shipper",
"type": "debit",
"amount": ?
},
{
"who": "owner",
"type": "credit",
"amount": ?
},
{
"who": "insurance",
"type": "credit",
"amount": ?
},
{
"who": "treasury",
"type": "credit",
"amount": ?
},
{
"who": "convargo",
"type": "credit",
"amount": ?
}
]
},
...
]