Sha256: 09005cfece110cd78f9e8bf34d5a2fd24d3c2956612db4a94f705b21302989dd

Contents?: true

Size: 984 Bytes

Versions: 1

Compression:

Stored size: 984 Bytes

Contents

module Comee
  module Core
    class PurchaseOrderItem < ApplicationRecord
      enum status: {active: 0, canceled: 1}

      belongs_to :purchase_order
      belongs_to :unit
      belongs_to :source, polymorphic: true

      validates :quantity, :confirmed_quantity, presence: true, numericality: {greater_than: 0}
      validates :price, :confirmed_price, presence: true, numericality: {greater_than_or_equal_to: 0}
      validates :status, :delivery_date, :confirmed_delivery_date, presence: true

      def self.ransackable_attributes(_auth_object = nil)
        %w[
          id
          purchase_order_id
          unit_id
          quantity
          confirmed_quantity
          price
          confirmed_price
          delivery_date
          confirmed_delivery_date
          status
        ]
      end

      def self.ransackable_associations(_auth_object = nil)
        %w[
          purchase_order
          source
          unit
        ]
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
comee_core-0.2.35 app/models/comee/core/purchase_order_item.rb