Sha256: 21f7ab5edff848c0b29aa4d170d22457f48f367ed32be791fa979daa736557e5
Contents?: true
Size: 523 Bytes
Versions: 3
Compression:
Stored size: 523 Bytes
Contents
module Comee module Core class PurchaseRequisition < ApplicationRecord # before_save :calculate_total_price has_many :purchase_requisition_items enum :status, {draft: 0, approved: 1} validates :requisition_no, presence: true, uniqueness: true validates :requisition_date, :status, presence: true def calculate_total_price items = PurchaseRequisitionItem.where(purchase_requisition_id: id) self.total_price = items.sum(&:total_price) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems