Sha256: 2e603823fa60a621ea7c2550445ad2b781b741968e4da1778d5320e931250e19
Contents?: true
Size: 624 Bytes
Versions: 17
Compression:
Stored size: 624 Bytes
Contents
module Comee module Core class InvoiceItem < ApplicationRecord before_save { self.total_price = unit_price * quantity } after_save :update_invoice after_destroy :update_invoice belongs_to :invoiceable, polymorphic: true belongs_to :invoice belongs_to :unit validates :quantity, :unit_price, presence: true, numericality: {greater_than: 0} validates :total_price, numericality: {greater_than_or_equal_to: 0, allow_nil: true} def update_invoice invoice.calculate_total_price invoice.calculate_vat invoice.save! end end end end
Version data entries
17 entries across 17 versions & 1 rubygems