Instructions for participants

Slicing

To calculate the bill, you need to consider the tax of the country from which the order came from and the reduction.

Taxes

Here is the tax table used in the exercise:

Country Code Tax
Spain ES 19%
France FR 20%
Germany DE 20%
United Kingdom UK 21%
Italy IT 25%

For the order {"prices":[15.99],"quantities":[1],"country":"ES","reduction":"STANDARD"}, for example, the response should be {"total":19.03}.

Reductions

Following the STANDARD reductions applied for the most part of the orders:

Total Reduction
>= 50 000 EUR 15 %
>= 10 000 EUR 10 %
>= 7 000 EUR 7 %
>= 5 000 EUR 5 %
>= 1 000 EUR 3 %

For the order {"prices":[4.1,8.03,86.83,65.62,44.82],"quantities":[10,3,5,4,5],"country":"FR","reduction":"STANDARD"}, for example, the response should be {"total":1147.49}.

Note that:

  1. discounts are applied after taxes;
  2. other types of discounts may appear. Plan the code to be scalable if further discounts are needed.

Project Structure

You should only change the src folder in this repository. All other folders and files should remain as they are today.

  • api is the folder where the mock came from.
  • dist is the output generated by your code in src once you run the command line to build or develop the project.
  • scripts is used to create helpers for the repository.
  • The src source folder is where you should create the code to solve this exercise, feel free to organise it as you wish. The mandatory file is main.js which is the entry point for your application code.

Coding

  • Install project dependencies npm run install

  • Run server and mock data npm run dev

  1. In order to play, you will need to GET the API located at http://localhost:3000/api/orders.
  2. By opening the following url http://localhost:8080/ you will land on the destination page.
  3. We don't need a user interface for this exercise, you can open the console and view the result.