Sha256: 29fbf6d43477081ed98870dcdd1ec70bb3d5e76028e5bb221fdc636647296660

Contents?: true

Size: 984 Bytes

Versions: 1

Compression:

Stored size: 984 Bytes

Contents

module Comee
  module Core
    class SalesOrder < ApplicationRecord
      belongs_to :client
      has_many :sales_order_items

      enum :status, {draft: 0, confirmed: 1, canceled: 2}

      validates :order_number, presence: true, uniqueness: true
      validates :order_date, :expected_delivery_date, :delivery_address, :invoice_address, :status, presence: true
      validates :payment_no_of_days,
        :payment_discount,
        :payment_penalty,
        presence: true,
        numericality: {greater_than_or_equal_to: 0, less_than_or_equal_to: 100}

      delegate(:name, to: :client, prefix: true)

      def self.ransackable_attributes(auth_object = nil)
        [
          "delivery_address",
          "expected_delivery_date",
          "invoice_address",
          "order_date",
          "order_number",
          "status",
          "client_id"
        ]
      end

      def self.ransackable_associations(auth_object = nil)
        []
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
comee_core-0.1.15 app/models/comee/core/sales_order.rb