Sha256: 0034cac2e8f1cb3c2420f262c93fdf47f0668e2b027c524b3235fc9f41517f82

Contents?: true

Size: 969 Bytes

Versions: 18

Compression:

Stored size: 969 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 :serial_no, :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
      validates :serial_no, numericality: {greater_than: 0, only_integer: 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

18 entries across 18 versions & 1 rubygems

Version Path
comee_core-0.2.93 app/models/comee/core/customer_order_item.rb
comee_core-0.2.92 app/models/comee/core/customer_order_item.rb
comee_core-0.2.91 app/models/comee/core/customer_order_item.rb
comee_core-0.2.90 app/models/comee/core/customer_order_item.rb
comee_core-0.2.89 app/models/comee/core/customer_order_item.rb
comee_core-0.2.88 app/models/comee/core/customer_order_item.rb
comee_core-0.2.87 app/models/comee/core/customer_order_item.rb
comee_core-0.2.86 app/models/comee/core/customer_order_item.rb
comee_core-0.2.85 app/models/comee/core/customer_order_item.rb
comee_core-0.2.84 app/models/comee/core/customer_order_item.rb
comee_core-0.2.83 app/models/comee/core/customer_order_item.rb
comee_core-0.2.82 app/models/comee/core/customer_order_item.rb
comee_core-0.2.81 app/models/comee/core/customer_order_item.rb
comee_core-0.2.80 app/models/comee/core/customer_order_item.rb
comee_core-0.2.78 app/models/comee/core/customer_order_item.rb
comee_core-0.2.77 app/models/comee/core/customer_order_item.rb
comee_core-0.2.76 app/models/comee/core/customer_order_item.rb
comee_core-0.2.75 app/models/comee/core/customer_order_item.rb