Sha256: 6833e4057071e7cc1827005e060a6d52739197f5ffa4bc95dd751eedc0cad0f5
Contents?: true
Size: 1.52 KB
Versions: 29
Compression:
Stored size: 1.52 KB
Contents
module Comee module Core class CustomerOrder < ApplicationRecord OWN = "Own".freeze AGENT = "Agent".freeze SHIPPING_ARRANGEMENTS = [OWN, AGENT].freeze belongs_to :client belongs_to :shipment_address, -> { where(address_type: ClientAddress::SHIPPING_ADDRESS) }, class_name: "Comee::Core::ClientAddress", optional: true belongs_to :delivery_address, -> { where(address_type: ClientAddress::DELIVERY_ADDRESS) }, class_name: "Comee::Core::ClientAddress" belongs_to :invoice_address, -> { where(address_type: ClientAddress::INVOICING_ADDRESS) }, class_name: "Comee::Core::ClientAddress" has_many :customer_order_items has_one_attached :file enum :status, {draft: 0, submitted: 1, awaiting_confirmation: 2, accepted: 3, canceled: 4} validates :order_number, :order_date, :delivery_address, :invoice_address, :status, presence: true validates :shipping_arrangement, inclusion: {in: SHIPPING_ARRANGEMENTS}, allow_nil: true def self.ransackable_attributes(_auth_object = nil) %w[id client_id delivery_address invoice_address order_number status final_destination consignee] end def self.ransackable_associations(_auth_object = nil) %w[client customer_order_items] end def file_url file.attached? ? Rails.application.routes.url_helpers.rails_blob_url(file, only_path: false) : nil end end end end
Version data entries
29 entries across 29 versions & 1 rubygems