Sha256: dbcf67668cbc54d7d80a26d7debf55349c83b8e02b46c710416d8e59d84f04d9
Contents?: true
Size: 1.67 KB
Versions: 6
Compression:
Stored size: 1.67 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 consolidator_date shipping_date ] end def self.ransackable_associations(_auth_object = nil) %w[client customer_order_items shipment_address] 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
6 entries across 6 versions & 1 rubygems