JavaScript workshop based on the french startup https://www.privateaser.com
Table of Contents generated with DocToc
- π£ Introduction
- π― Objectives
- π©βπ» Just tell me what to do
- πββοΈ Steps to do
- Source and inspiration
- Licence
Privateaser is a marketplace that digitizes the world of event planning for bars, restaurants and venues (+3,000 locations), via a web application.
The Event management is a key sector of the Europe economy:
- 100 billion euros in Europe
- 20 billion euros in France
- historically complex
- not much digitized: you have to pick up your phone, wait to be called back, go to visit
Privateaser is a trusted third party between the bars and the bookers. The marketplace allows them to:
- the bookers to find, to compare or to contact a place
- the bookers to book with an one-click a place for an event
- the bookers to manage all their events expenses
- the managers to maximize the occupancy rate and therefore the revenue of their business
We focus on this marketplace feature: to book with an one-click a place for an event.
The workshop goals are to
- compute the booking price of the
booker - compute the profit of the
bar - compute the profit of
privateaser
- Fork the project via
github
- Clone your forked repository project
https://github.com/YOUR_USERNAME/privateaser
β― cd /path/to/workspace
β― git clone [email protected]:YOUR_USERNAME/privateaser.git- Open the entry point /public/index.html in your browser (that loads the
index.jsfile)
# macos cli
β― open public/index.html
# linux cli
β― xdg-open public/index.html
# or by double-clicking in your browser files- Check the ouput in your browser console (Use
Ctrl + Shift + JorCmd + Opt + Jto focus to your console devtools) - Solve each steps inside ./public/index.js file with JavaScript
- Once a step is solved, commit your modification:
β― cd /path/to/workspace/privateaser
β― git add -A && git commit -m "feat(price): decrease pricing according people"(why following a commit message convention?
- 5 steps, so ideally 5 commits
- Don't forget to push before the end of the workshop
β― git push origin masterNote: if you catch an error about authentication, add your ssh to your github profile.
- Check that your codebase works by checking the console output
- If you need some helps on git commands, read git - the simple guide
- 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 booker books a place for an specific time range and a set of persons.
The booking price is the sum of the time component and the people component with
- time component: the number of booked time multiplied by the
barprice per hour - people component: the number of persons multiplied by the
barprice per person
booking price = time + people
Write JS code that generates the booking price for each booker from index.js file:
//example output from console.log
[
{
"id": "bba9500c-fd9e-453f-abf1-4cd8f52af377",
...
"price": ?
},
{
"id": "65203b0a-a864-4dea-81e2-e389515752a8",
...
"price": ?
},
{
"id": "94dab739-bd93-44c0-9be1-52dd07baa9f6",
...
"price": ?
}
]To be as competitive as possible, Privateaser decide to have a decreasing pricing for groups of important people
price per people
- decreases by 10% after 10 persons
- decreases by 30% after 20 persons
- decreases by 50% after 60 persons
Adapt the booking price computation to take these new rules into account.
//example output from console.log
[
{
"id": "bba9500c-fd9e-453f-abf1-4cd8f52af377",
...
"price": ?
},
{
"id": "65203b0a-a864-4dea-81e2-e389515752a8",
...
"price": ?
},
{
"id": "94dab739-bd93-44c0-9be1-52dd07baa9f6",
...
"price": ?
}
]Now, it's time to pay the bar
There is a 30% commission on the booking price to cover the costs.
The commission is split like this:
- insurance: half of commission
- the Treasury: 1β¬ by person
- Privateaser: the rest
Compute the amount that belongs to the insurance, to the Treasury and to Privateaser.
//example output from console.log
[
{
"id": "bba9500c-fd9e-453f-abf1-4cd8f52af377",
...
"commission": {
"insurance": ?,
"treasury": ?
"privateaser": ?
}
},
...
]In case of an accident/theft, Privateaser applies a 5000β¬ deductible.
The booker can reduce the deductible amount from 5000β¬ to 200β¬ with a deductible option for a few more euros per person.
The booker is charged an additional 1β¬/person when he chooses the deductible reduction option.
The additional charge goes to Privateaser, not to the bar.
Compute the new amount price if the booker subscribed to deductible option.
//example output from console.log
[
{
"id": "bba9500c-fd9e-453f-abf1-4cd8f52af377",
'options': {
'deductibleReduction': true
},
...
"price": ?
},
...
]It's time to debit/credit each actor!
- the booker must pay the booking price and the (optional) deductible reduction
- the bar receives the booking price minus the commission
- the insurance receives its part of the commission
- the Treasury receives its part of the tax commission
- Privateaser receives its part of the commission, plus the deductible reduction
- Compute the debit for the
booker - Compute the credit of the
bar,insurance,TreasuryandPrivateaser.
//example output from console.log
[
{
"deliveryId": "bba9500c-fd9e-453f-abf1-4cd8f52af377",
"payment": [
{
"who": "booker",
"type": "debit",
"amount": ?
},
{
"who": "bar",
"type": "credit",
"amount": ?
},
{
"who": "insurance",
"type": "credit",
"amount": ?
},
{
"who": "treasury",
"type": "credit",
"amount": ?
},
{
"who": "privateaser",
"type": "credit",
"amount": ?
}
]
},
...
]
