Initial commit
This commit is contained in:
28
elixir/freelancer-rates/lib/freelancer_rates.ex
Normal file
28
elixir/freelancer-rates/lib/freelancer_rates.ex
Normal file
@@ -0,0 +1,28 @@
|
||||
defmodule FreelancerRates do
|
||||
def daily_rate(hourly_rate) do
|
||||
8.0 * hourly_rate
|
||||
end
|
||||
|
||||
def monthly_rate(hourly_rate) do
|
||||
22.0 * daily_rate(hourly_rate)
|
||||
end
|
||||
|
||||
def monthly_rate(hourly_rate, discount) do
|
||||
hourly_rate
|
||||
|> monthly_rate()
|
||||
|> apply_discount(discount)
|
||||
|> ceil()
|
||||
end
|
||||
|
||||
def apply_discount(before_discount, discount) do
|
||||
before_discount - (before_discount * (discount / 100))
|
||||
end
|
||||
|
||||
def days_in_budget(budget, hourly_rate, discount) do
|
||||
hourly_rate
|
||||
|> daily_rate()
|
||||
|> apply_discount(discount)
|
||||
|> then(fn rate -> budget / rate end)
|
||||
|> Float.floor(1)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user