Sha256: 2d5f294f5440b6b3be173605a1f25b8de74539b2836c2c69aef8816cb5b4f18c

Contents?: true

Size: 558 Bytes

Versions: 10

Compression:

Stored size: 558 Bytes

Contents

module Comee
  module Core
    class SalesOrderItem < ApplicationRecord
      before_validation :set_delivery_date, if: proc { delivery_date.nil? }

      belongs_to :sales_order
      belongs_to :product

      validates :delivery_date, presence: true
      validates :quantity, :price, presence: true, numericality: {greater_than: 0}

      delegate(:name, to: :product, prefix: true)
      delegate(:code, to: :product, prefix: true)

      def set_delivery_date
        self.delivery_date = sales_order.expected_delivery_date
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
comee_core-0.1.22 app/models/comee/core/sales_order_item.rb
comee_core-0.1.21 app/models/comee/core/sales_order_item.rb
comee_core-0.1.20 app/models/comee/core/sales_order_item.rb
comee_core-0.1.19 app/models/comee/core/sales_order_item.rb
comee_core-0.1.18 app/models/comee/core/sales_order_item.rb
comee_core-0.1.17 app/models/comee/core/sales_order_item.rb
comee_core-0.1.16 app/models/comee/core/sales_order_item.rb
comee_core-0.1.15 app/models/comee/core/sales_order_item.rb
comee_core-0.1.14 app/models/comee/core/sales_order_item.rb
comee_core-0.1.13 app/models/comee/core/sales_order_item.rb