internetee/registry

View on GitHub
app/models/invoice_item.rb

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
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