 
     tax_ded = gra_income_tax(taxable_income, tax_year)
 
-    overtime_tax = gra_overtime_tax(emp.overtime_earned, emp.base_salary)
+    overtime_tax = gra_overtime_tax(emp.overtime_earned, earned_salary)
 
     total_tax = Decimal.add(tax_ded, overtime_tax)
 

  @expat_salary "/home/hvaria/backup/salary.csv"
  @employee_master "H1EMP.DBF"
  @calculated_payroll "H1DETPAY.DBF"

  @decimal_50 Decimal.new("50")

  def get_management_payroll(month), do: get_management_pay(determine_management_month(month))
  defp get_management_pay(nil), do: []

  end

  defp gra_overtime_tax(o, earned_salary) do
    half_earned_salary = Decimal.div(earned_salary, 2)

    case Decimal.compare(o, half_earned_salary) do
      :gt ->
        excess_tax = Decimal.mult(Decimal.sub(o, half_earned_salary), Decimal.new("0.1"))

        Decimal.round(
          Decimal.add(excess_tax, Decimal.mult(half_earned_salary, Decimal.new("0.05"))),
          2
        )

      _ ->
        Decimal.round(Decimal.mult(o, Decimal.new("0.05")), 2)
