Sha256: 493dfde0342b985e7b39a256ec941988ffdb723f3f4671aeff4f55c8fbbf4507
Contents?: true
Size: 772 Bytes
Versions: 65
Compression:
Stored size: 772 Bytes
Contents
module Comee module Core class ReceivedItem < ApplicationRecord belongs_to :goods_received_note belongs_to :purchase_order_item before_save :update_total_price validate :check_quantity_received validates :quantity_ordered, :quantity_received, :unit_price, :total_price, presence: true, numericality: {greater_than_or_equal_to: 0} def update_total_price self.total_price ||= 0 self.total_price = unit_price * quantity_received end def check_quantity_received errors.add(:quantity_received, "can't be greater than quantity ordered") if quantity_received.to_i > quantity_ordered.to_i end end end end
Version data entries
65 entries across 65 versions & 1 rubygems