Skip to content
This repository has been archived by the owner on Jan 31, 2024. It is now read-only.

SpiffInc/sales_commission_kata_ruby

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sales Commission Kata - Prefer using more flexible version here

Purpose

These coding exercises are meant to help Spiff gain insight into how you would tackle actual feature requests by the product team. The exercises are relatively simple, but you are encouraged to treat them as if you were working on the Spiff codebase. This means applying the same attention to code quality, tests, pull requests, commits, etc as you normally would.

Quality is valued above quantity. We value simple and readable code

Instructions

You have been hired to work on a commission calculator for a sales team. The commission is calculated based on the total sales made by the team and the individual sales made by each sales representative. The commission rates are as follows:

  • If the total sales made by the team are less than $100,000, the commission rate is 10%.
  • If the total sales made by the team are between $100,000 and $200,000, the commission rate is 15%.
  • If the total sales made by the team are greater than $200,000, the commission rate is 20%.

In addition, each sales representative has an individual commission rate based on their performance:

  • If the sales representative's individual sales are less than $10,000, their commission rate is 5%.
  • If the sales representative's individual sales are between $10,000 and $20,000, their commission rate is 7.5%.
  • If the sales representative's individual sales are greater than $20,000, their commission rate is 10%.

The commission for each sales representative is calculated by the following forumla:

(sales_representative.sales * individual_comission_rate * team_commission_rate)

For example, if a Sales Representative made $5,000 and the team made $50,000 the calculation would ($5,000 * 5% * 10%) for a commission of $25.

You have been given a Ruby program that calculates the commission for each sales representative based on the total sales made by the team and their individual sales. The code is working, but it is hard to read, difficult to understand, and hard to maintain. Your task is to refactor the code to make it easier to read and maintain while preserving its behavior.

Setup

  1. Clone the repo (don't fork)
  2. Point the remote origin to a new repo under your account
bundle install
bundle exec rspec
  1. Refactor, testing and committing along the way
  2. Create a pull request on your repo when finished

Guidelines

  • Please leave any comments that will help the reader understand important decisions you made, shortcuts taken, or things you would do differently in the future.
  • Please talk out loud while pairing, explaining your intentions and decision making.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages