Sha256: 08b878e427e289366f09b32e8c2a17288f69e6960400b2e909254d42582cf952
Contents?: true
Size: 868 Bytes
Versions: 19
Compression:
Stored size: 868 Bytes
Contents
module Comee module Core class PurchaseRequisitionItem < ApplicationRecord before_save :calculate_total_price after_save :calculate_requisition_price enum processing_status: {unprocessed: 0, partially_processed: 1, fully_processed: 2} belongs_to :product belongs_to :unit belongs_to :supplier belongs_to :purchase_requisition belongs_to :purchase_order_item, optional: true validates :processing_status, :delivery_date, presence: true validates :quantity, :price, presence: true, numericality: {greater_than_or_equal_to: 0} def calculate_total_price self.total_price = price * quantity end def calculate_requisition_price purchase_requisition.total_price = purchase_requisition.calculate_total_price purchase_requisition.save! end end end end
Version data entries
19 entries across 19 versions & 1 rubygems