Enhance InvoiceItem

#329
This commit is contained in:
Artur Beljajev 2019-05-20 17:33:24 +03:00
parent d85e57d800
commit c807bb9fcd
2 changed files with 36 additions and 3 deletions

View file

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