Sha256: 681b601bdbe33a924779ebf0b0122128b1162a9e8748524ddb35691183254ab7
Contents?: true
Size: 540 Bytes
Versions: 63
Compression:
Stored size: 540 Bytes
Contents
module Comee module Core class AdditionalItem < ApplicationRecord before_save { self.total_price = unit_price * quantity } after_save { invoice.update_total_price } belongs_to :invoice validates :description, presence: true validates :quantity, :unit_price, presence: true, numericality: {greater_than: 0} 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