Sha256: a8776fcf5098a308ef225f96689cde843148484949bf467f22cbec5906ce04e6
Contents?: true
Size: 798 Bytes
Versions: 1
Compression:
Stored size: 798 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 validates :processing_status, 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
comee_core-0.2.35 | app/models/comee/core/purchase_requisition_item.rb |