Reputation: 3814
I have the following existing helper in my Invoice model of my Rails application:
def total_price
line_items.to_a.sum(&:full_price)
end
What I would like to do is have an additional helper called total_vat
which adds 20% to the total_price helper. Is this possible?
I will eventually be adding a third helper which calculates the difference so I can print just the amount of VAT due.
Upvotes: 1
Views: 246
Reputation: 10856
Creating multiple helpers is absolutely possible.
def vat
total_price * 0.2
end
def total_price_including_vat
total_price + vat
end
Upvotes: 2