Sha256: 53536436473a05fa6b4d6045f88ff2dd29ef7a3ee75bfd69aadd8e619bcba09f
Contents?: true
Size: 655 Bytes
Versions: 4
Compression:
Stored size: 655 Bytes
Contents
module Comee module Core class PurchaseRequisitionItem < ApplicationRecord before_save :calculate_total_price after_save :calculate_requisition_price belongs_to :product belongs_to :unit belongs_to :supplier belongs_to :purchase_requisition 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
4 entries across 4 versions & 1 rubygems