Class: EdiDocument

Inherits:
ApplicationRecord show all
Defined in:
app/models/edi_document.rb

Overview

== Schema Information

Table name: edi_documents
Database name: primary

id :integer not null, primary key
note :string
resource_type :string
created_at :datetime not null
updated_at :datetime not null
legacy_amazon_variation_id :integer
catalog_item_id :integer
edi_communication_log_id :integer not null
invoice_id :integer
item_id :integer
order_id :integer
receipt_id :integer
resource_id :integer

Indexes

idx_unique_edi_documents (resource_type,resource_id,edi_communication_log_id) UNIQUE
index_edi_documents_on_legacy_amazon_variation_id (legacy_amazon_variation_id) WHERE (legacy_amazon_variation_id IS NOT NULL)
index_edi_documents_on_catalog_item_id (catalog_item_id) WHERE (catalog_item_id IS NOT NULL)
index_edi_documents_on_edi_communication_log_id (edi_communication_log_id)
index_edi_documents_on_invoice_id (invoice_id) WHERE (invoice_id IS NOT NULL)
index_edi_documents_on_item_id (item_id) WHERE (item_id IS NOT NULL)
index_edi_documents_on_order_id (order_id) WHERE (order_id IS NOT NULL)
index_edi_documents_on_receipt_id (receipt_id) WHERE (receipt_id IS NOT NULL)

Foreign Keys

fk_rails_... (legacy_amazon_variation_id => legacy_amazon_variations.id) ON DELETE => cascade
fk_rails_... (catalog_item_id => catalog_items.id) ON DELETE => cascade
fk_rails_... (edi_communication_log_id => edi_communication_logs.id) ON DELETE => cascade
fk_rails_... (invoice_id => invoices.id) ON DELETE => cascade
fk_rails_... (item_id => items.id) ON DELETE => cascade
fk_rails_... (order_id => orders.id) ON DELETE => cascade
fk_rails_... (receipt_id => receipts.id) ON DELETE => cascade

Constant Summary

Constants included from Models::Schedulable

Models::Schedulable::SIMPLE_FORM_OPTIONS

Belongs to collapse

Instance Method Summary collapse

Methods inherited from ApplicationRecord

ransackable_associations, ransackable_attributes, ransackable_scopes, ransortable_attributes, #to_relation

Methods included from Models::Schedulable

config

Methods included from Models::AfterCommittable

#after_commit

Methods included from Models::EventPublishable

#publish_event

Instance Method Details

#catalog_itemCatalogItem?

Returns:



48
# File 'app/models/edi_document.rb', line 48

belongs_to :catalog_item, optional: true

#edi_communication_logEdiCommunicationLog

belongs_to :resource, polymorphic: true, optional: true

Returns:



46
# File 'app/models/edi_document.rb', line 46

belongs_to :edi_communication_log

#invoiceInvoice?

Returns:



54
# File 'app/models/edi_document.rb', line 54

belongs_to :invoice, optional: true

#itemItem?

Returns:



50
# File 'app/models/edi_document.rb', line 50

belongs_to :item, optional: true

#orderOrder?

Returns:



52
# File 'app/models/edi_document.rb', line 52

belongs_to :order, optional: true

#receiptReceipt?

Returns:



56
# File 'app/models/edi_document.rb', line 56

belongs_to :receipt, optional: true

#resourceApplicationRecord?

Returns:



63
64
65
# File 'app/models/edi_document.rb', line 63

def resource
  catalog_item || item || order || invoice || receipt || variant_group
end

#resource=(val) ⇒ void

This method returns an undefined value.



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'app/models/edi_document.rb', line 69

def resource=(val)
  case val
  when CatalogItem
    self.catalog_item = val
  when Item
    self.item = val
  when Order
    self.order = val
  when Invoice
    self.invoice = val
  when Receipt
    self.receipt = val
  when VariantGroup
    self.variant_group = val
  else
    raise ArgumentError, "Unsupported resource type: #{val.class.name}"
  end
end

#variant_groupVariantGroup?

Returns:



58
# File 'app/models/edi_document.rb', line 58

belongs_to :variant_group, optional: true