Merge pull request #1209 from internetee/enhance-invoice-item

Enhance `InvoiceItem`
This commit is contained in:
Timo Võhmar 2019-05-21 18:26:05 +03:00 committed by GitHub
commit 5cadd1d917
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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