Sha256: d194ce2ef43894180e8483adfa88597dfe47099be4b4a6827a501c2fe213a6b2
Contents?: true
Size: 659 Bytes
Versions: 63
Compression:
Stored size: 659 Bytes
Contents
module Comee module Core class InvoiceItem < ApplicationRecord before_save { self.total_price = unit_price * quantity } after_save { invoice.update_total_price } 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_price # invoice.total_price = invoice.invoice_items.sum(:total_price) + invoice.additional_items.sum(:total_price) # invoice.save! # end end end end
Version data entries
63 entries across 63 versions & 1 rubygems