Sha256: c5119d3c8f60f2acc59c67ce7b4eb954d2b0f51bcfd371deb931615bdf103819
Contents?: true
Size: 904 Bytes
Versions: 3
Compression:
Stored size: 904 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} enum :purchase_status, {unprocessed: 0, processed: 1} validates :requisition_no, presence: true, uniqueness: true validates :requisition_date, :status, :purchase_status, presence: true def self.ransackable_attributes(_auth_object = nil) %w[created_at id remark requisition_date delivery_date requisition_no status purchase_status total_price updated_at] end def self.ransackable_associations(_auth_object = nil) [] 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
3 entries across 3 versions & 1 rubygems