Sha256: 9a77b1e830ab1dd22c143d258e67f0369d331b60efff72caf4082f02fed57b2d

Contents?: true

Size: 877 Bytes

Versions: 58

Compression:

Stored size: 877 Bytes

Contents

module Comee
  module Core
    class CustomerOrderItem < ApplicationRecord
      before_save :calculate_total_price

      belongs_to :customer_order
      belongs_to :product
      belongs_to :unit

      validates :customer_item_no, :customer_item_description, :quantity, :price, :delivery_date, presence: true
      validates :quantity, :price, numericality: {greater_than_or_equal_to: 0}
      validates :total_price, numericality: {greater_than_or_equal_to: 0}, allow_nil: true

      def calculate_total_price
        self.total_price = price * quantity
      end

      def self.ransackable_attributes(_auth_object = nil)
        %w[id customer_order_id product_id unit_id customer_item_no customer_item_description delivery_date]
      end

      def self.ransackable_associations(_auth_object = nil)
        %w[customer_order product unit]
      end
    end
  end
end

Version data entries

58 entries across 58 versions & 1 rubygems

Version Path
comee_core-0.2.50 app/models/comee/core/customer_order_item.rb
comee_core-0.2.49 app/models/comee/core/customer_order_item.rb
comee_core-0.2.48 app/models/comee/core/customer_order_item.rb
comee_core-0.2.47 app/models/comee/core/customer_order_item.rb
comee_core-0.2.46 app/models/comee/core/customer_order_item.rb
comee_core-0.2.45 app/models/comee/core/customer_order_item.rb
comee_core-0.2.44 app/models/comee/core/customer_order_item.rb
comee_core-0.2.43 app/models/comee/core/customer_order_item.rb
comee_core-0.2.42 app/models/comee/core/customer_order_item.rb
comee_core-0.2.41 app/models/comee/core/customer_order_item.rb
comee_core-0.2.40 app/models/comee/core/customer_order_item.rb
comee_core-0.2.39 app/models/comee/core/customer_order_item.rb
comee_core-0.2.38 app/models/comee/core/customer_order_item.rb
comee_core-0.2.37 app/models/comee/core/customer_order_item.rb
comee_core-0.2.36 app/models/comee/core/customer_order_item.rb
comee_core-0.2.35 app/models/comee/core/customer_order_item.rb
comee_core-0.2.34 app/models/comee/core/customer_order_item.rb
comee_core-0.2.33 app/models/comee/core/customer_order_item.rb
comee_core-0.2.32 app/models/comee/core/customer_order_item.rb
comee_core-0.2.31 app/models/comee/core/customer_order_item.rb