mirror of
https://github.com/internetee/registry.git
synced 2025-06-08 13:44:47 +02:00
19 lines
336 B
Ruby
19 lines
336 B
Ruby
class InvoiceItem < ApplicationRecord
|
|
include Versions
|
|
belongs_to :invoice
|
|
|
|
delegate :vat_rate, to: :invoice
|
|
|
|
def item_sum_without_vat
|
|
(price * quantity).round(3)
|
|
end
|
|
alias_method :subtotal, :item_sum_without_vat
|
|
|
|
def vat_amount
|
|
subtotal * (vat_rate / 100)
|
|
end
|
|
|
|
def total
|
|
(subtotal + vat_amount)
|
|
end
|
|
end
|