Sha256: c6d114141de2afcbabaf56663ccbded295419423eed561c82e8af05a2cad1764
Contents?: true
Size: 714 Bytes
Versions: 29
Compression:
Stored size: 714 Bytes
Contents
module Comee module Core class PurchaseRequisition < ApplicationRecord # before_save :calculate_total_price has_many :purchase_requisition_items enum :status, {draft: 0, submitted: 1, approved: 2, rejected: 3} validates :requisition_no, presence: true, uniqueness: true validates :requisition_date, :status, presence: true def self.ransackable_attributes(_auth_object = nil) %w[created_at id remark requisition_date requisition_no status total_price updated_at] end 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
29 entries across 29 versions & 1 rubygems