mirror of
https://github.com/internetee/registry.git
synced 2025-07-25 03:58:27 +02:00
parent
d85e57d800
commit
c807bb9fcd
2 changed files with 36 additions and 3 deletions
|
@ -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
|
Loading…
Add table
Add a link
Reference in a new issue