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

Version Path
comee_core-0.2.62 app/models/comee/core/purchase_requisition.rb
comee_core-0.2.61 app/models/comee/core/purchase_requisition.rb
comee_core-0.2.60 app/models/comee/core/purchase_requisition.rb
comee_core-0.2.59 app/models/comee/core/purchase_requisition.rb
comee_core-0.2.58 app/models/comee/core/purchase_requisition.rb
comee_core-0.2.57 app/models/comee/core/purchase_requisition.rb
comee_core-0.2.56 app/models/comee/core/purchase_requisition.rb
comee_core-0.2.55 app/models/comee/core/purchase_requisition.rb
comee_core-0.2.54 app/models/comee/core/purchase_requisition.rb
comee_core-0.2.53 app/models/comee/core/purchase_requisition.rb
comee_core-0.2.52 app/models/comee/core/purchase_requisition.rb
comee_core-0.2.51 app/models/comee/core/purchase_requisition.rb
comee_core-0.2.50 app/models/comee/core/purchase_requisition.rb
comee_core-0.2.49 app/models/comee/core/purchase_requisition.rb
comee_core-0.2.48 app/models/comee/core/purchase_requisition.rb
comee_core-0.2.47 app/models/comee/core/purchase_requisition.rb
comee_core-0.2.46 app/models/comee/core/purchase_requisition.rb
comee_core-0.2.45 app/models/comee/core/purchase_requisition.rb
comee_core-0.2.44 app/models/comee/core/purchase_requisition.rb
comee_core-0.2.43 app/models/comee/core/purchase_requisition.rb