Sha256: df890fbac3501d61ad5fe38f24b0640dfe28410779562b4c4603f2d4978d3635
Contents?: true
Size: 619 Bytes
Versions: 24
Compression:
Stored size: 619 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 :shipment_instruction_item 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
24 entries across 24 versions & 1 rubygems