29 lines
618 B
Elixir
29 lines
618 B
Elixir
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
|