Class: Formulas::PAYE

Inherits:
WithholdingTax show all
Defined in:
lib/formulas/paye.rb

Overview

Calculate basic salary in frequency paye = Formulas::PAYE.new(gross_pay: 52_000, frequency: Formulas::ANNUAL)

paye.tax(:monthly)

> 718.33

Provide a way to calculate pay as you earn calculator

Constant Summary collapse

TAX_RATES =

Provide a way to calculate PAYE tax

[
  [[0, 14_000], 10.5],
  [[14_000, 48_000], 17.5],
  [[48_000, 70_000], 30],
  [[70_000, 180_000], 33],
  [[180_000], 39]
]
MAX_ACC_LEVY_PAYABLE =
130_911

Instance Attribute Summary

Attributes inherited from WithholdingTax

#origin_frequency

Instance Method Summary collapse

Methods inherited from WithholdingTax

#net_pay

Methods included from FrequencyConversions

#convert_annually_to_annually, #convert_annually_to_fortnightly, #convert_annually_to_monthly, #convert_annually_to_weekly, #convert_fortnightly_to_annually, #convert_fortnightly_to_monthly, #convert_fortnightly_to_weekly, #convert_monthly_to_annually, #convert_monthly_to_fortnightly, #convert_monthly_to_weekly, #convert_weekly_to_annually, #convert_weekly_to_fortnightly, #convert_weekly_to_monthly

Constructor Details

#initialize(gross_pay:, frequency: Formulas::MONTHLY) ⇒ PAYE

Returns a new instance of PAYE.



24
25
26
# File 'lib/formulas/paye.rb', line 24

def initialize(gross_pay:, frequency: Formulas::MONTHLY)
  super(gross_pay, frequency, TAX_RATES)
end

Instance Method Details

#acc_payableObject



36
37
38
# File 'lib/formulas/paye.rb', line 36

def acc_payable
  annual_gross_pay > MAX_ACC_LEVY_PAYABLE ? MAX_ACC_LEVY_PAYABLE : annual_gross_pay
end

#levyObject



32
33
34
# File 'lib/formulas/paye.rb', line 32

def levy
  0.0139
end

#tax(request_frequency: Formulas::WEEKLY) ⇒ Object



28
29
30
# File 'lib/formulas/paye.rb', line 28

def tax(request_frequency: Formulas::WEEKLY)
  calculate_tax(request_frequency)
end