We'd like you to finish building the Rails application with a few key components to demonstrate proficiency in many common Ruby and Rails patterns, which you'll find yourself using day-to-day here.
Though each engineer does specialize in either front-end or back-end, we still sometimes have full-stack responsibilities. So we'd also like you to implement some basic functionality in the given Vue app.
We expect this exercise to take 2-4 hours at the most. If you ran out of time, please comment on what remains to be done in the README.
Since this is a backend-focused challenge, we are not looking for styling or CSS, but will notice if any improvements are made. Also, don't concern yourself with configuring everything perfectly. This is just an exercise, so if you don't need to tweak something in order to meet the criteria below, leave it at the defaults.
At Koho, we work with money in most world currencies across our data model. For reporting purposes, we need to be able to work with all money amounts in a common currency of US dollars, in addition to the original currency it was stored with. For example, it should be easy to get a sum of all amounts in USD.
Although we'll leave it to you to otherwise decide which gems to bring in, we do recommend money-rails
. For this exercise, you'll need to add some currency conversion data. Assume USD -> EUR is 0.84663
, and EUR -> USD is 1.18115
. Don’t worry about any other currencies.
Please utilize the Rails app which stores and looks up rates from carriers.
To run the app:
yarn
bundle
bin/rails db:create
bin/rails db:migrate
bin/rails s
Your app should have these properties:
- A model to represent a carrier. It should have these attributes:
- Name of company
- A flat shipping rate as a monetary value with currency
- A model to represent shipping rates that each carrier has (different from the carrier's flat rate). It should have these attributes:
- Rate as monetary value with currency (per kilo)
- Origin, as two-letter country code
- Destination, as two-letter country code
- Relationship to the carrier
-
Create Carrier and Rate models.
-
Create a way to load the CSV's
carrier_data.csv
andrate_data.csv
into the database using these models. -
Make sure all the converted monetary USD amounts are stored.
-
Implement a reusable way to ensure that whenever a configurable money column is assigned the original value is stored along with a conversion to a 'default' currency (i.e. USD). It should be easy to include this functionality into any other model that works with currency. Bring this functionality into both the shipping rate model and the carrier model. Below is an example of how it should behave:
-
Create API endpoints to fetch and update rates.
some_model = SomeModel.new some_model.amount = 15.0 some_model.currency = "EUR" some_model.save! some_model.amount # => 15.00 EUR some_model.common_amount # => 17.72 USD some_model.amount = 30.0 some_model.currency = "EUR" some_model.save! some_model.amount # => 30.0 EUR some_model.common_amount # => 35.43 USD
-
Write any specs you deem necessary.
The repo has Vue already installed with Webpacker.
- Fetch the data from the Rails app on page load.
- Update the simple index view with a list of: carrier's name, origin, destination, formatted rate as a monetary value, formatted common rate in USD.
- Create a simple bare-bones form that allows editing and updating a rate. Allow changing all attributes except the common USD rate.
- Update the README.MD with how to run your app and how to load your data.
- Any details or decisions you want us to know about.
- In a short paragraph: if you had more time, how would you improve your implementation and what would you do differently?
We encourage you to demonstrate your workflow via Git commits with good messages.
When you are done, please zip up your repo and email it to [email protected]. If you need to clarify anything regarding this challenge, feel free to email us as [email protected].