Skip to content

attilapalfi92/katanox-coding-challenge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Katanox Coding Challenge

The aim of this task is to refactor and extend an API using Java OR Kotlin and Spring Boot which allows users to search for available hotels and rooms.

We are looking for:

  • Simple, elegant code
  • Nice, clean architecture (assume this is something that would be put into production)
  • Comments to clarify anything ambiguous
  • Unit Tests
  • Instructions on how to build and run the code

Setup

You have the following tables: hotels, rooms, prices, flat_extra_charges, percentage_extra_charges

These tables are creating using the scripts under main/resources/db.migration, these files will be picked up by flyway db migration tool, another library we are using is jOOQ in which the tables files are autogenerated and you can find them under target/generated-sources/jooq then under pojos and records.

The hotels table holds some basic information about the hotels in your system. The room_types table holds rooms associated with each hotel, in a 1:N relationship. The prices table holds information about the price of a room for any given future night. Finally there are two extra charges tables, one which includes any flat extra charges that should be applied on top of the base price and one with percentage prices to be applied to the base price. When calculating the total price for a certain period, you need to take into account the extra charges of that room.

Example Scenario

Check in: 01-04-2022, Check out: 03-04-2022, Hotel: A

Hotel A has 2 room types and each type has a different price per day shown in the table below:

Room ID Date Available Rooms Price before tax
R1 01-04-2022 2 103
R1 02-04-2022 1 99
R1 03-04-2022 2 110
R2 01-04-2022 5 113
R2 02-04-2022 6 109
R2 03-04-2022 4 123

The extra flat charges table looks like the following table

Hotel ID Description Charge type Price
1 Cleaning fee Once 25
1 Wifi Per Night 5
2 Cleaning fee Once 25
2 Wifi Per Night 5

Therefore the total price for this scenario should be 237 for R1 and 257 for R2.

Task 1

Implement the search endpoint and allow the user to search for available rooms for any future time period. Make sure the rooms you return have availability for every night of that period and the extra charges are added on top.

Task 2

For this task, you should use the data returned from the search endpoint to create a new reservation. The booking service expects two prices, the before tax and after tax price. To calculate the before tax, you need to take into account the following:

  • The extra charges tables are not subject to VAT, so the price is always the same for before and after tax.
  • The base price found in the prices table includes VAT. You will need to get the VAT percentage from the hotels table for each hotel and calculate the before tax price. Then you can apply the extra charges on top to calculate the total before tax price to be sent.

In the example above, if the hotel has a 5% VAT, then the prices would be the following:

Room Before Tax After Tax
R1 216.9 237
R2 245.9 257

Important notes:

  • As you can see, all the boilerplate code is stored in a single package, deliberately. We expect you to refactor it, including the directory structure.

Submission

First push the initial repository to the master branch. Then develop your solution in a difference branch and, once ready, create a pull request to the master branch. This way, it will be easier for us to spot all the changes you've made. Finally send an invitation to the repository by email and assign us to the PR. If uploaded to Github, invite @KatanoxDevelopers.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published