We have a service that takes the function of calculating salaries based on the number of hours worked, then calculates and pays all employees their salaries. The return value is the total amount of money paid:
trait Payouts {
def payEveryoneBy(hoursToSalary: Int => BigDecimal): BigDecimal
}
We also have a service that calculates this formula for the current week:
trait Salaries {
def calculateHoursToSalary: Int => BigDecimal
}
Some weeks the team produces better results and we want to make a separate function that will also add $50 to each employee regardless of the number of hours.
Implement the function so that its result can simply be passed to Payouts and salaries will be calculated correctly.
val formula = getFormulaWithBonus(salaries, bonus = 50)
val amount = payouts.payEveryoneBy(formula)