internetee-registry/app/models/invoice_item.rb
Artur Beljajev fa52001be6 Upgrade to Rails 5.0
Closes #377
2019-11-15 15:26:33 +02:00

19 lines
No EOL
333 B
Ruby

class InvoiceItem < ApplicationRecord
include Versions
belongs_to :invoice
delegate :vat_rate, to: :invoice
def item_sum_without_vat
(price * quantity).round(2)
end
alias_method :subtotal, :item_sum_without_vat
def vat_amount
subtotal * (vat_rate / 100)
end
def total
subtotal + vat_amount
end
end