Class: SpeedeeManifest
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- SpeedeeManifest
- Defined in:
- app/models/speedee_manifest.rb
Overview
== Schema Information
Table name: speedee_manifests
Database name: primary
id :integer not null, primary key
filename :string not null
transmitted_at :datetime not null
created_at :datetime not null
updated_at :datetime not null
Indexes
index_speedee_manifests_on_filename (filename)
index_speedee_manifests_on_transmitted_at (transmitted_at)
Constant Summary
Constants included from Schedulable
Schedulable::SIMPLE_FORM_OPTIONS
Has many collapse
- #speedee_manifest_shipments ⇒ ActiveRecord::Relation<SpeedeeManifestShipment>
- #uploads ⇒ ActiveRecord::Relation<Upload>
Instance Method Summary collapse
- #cancel_manifest ⇒ Object
- #speedee_manifest_shipments_with_das ⇒ Object
- #upload_manifest_csv(manifest_csv_path) ⇒ Object
- #upload_summary_pdf(summary_pdf_path) ⇒ Object
Methods inherited from ApplicationRecord
ransackable_associations, ransackable_attributes, ransackable_scopes, ransortable_attributes, #to_relation
Methods included from Schedulable
Methods included from Models::AfterCommittable
Methods included from Models::EventPublishable
Instance Method Details
#cancel_manifest ⇒ Object
46 47 48 49 50 |
# File 'app/models/speedee_manifest.rb', line 46 def cancel_manifest dels = speedee_manifest_shipments.map(&:delivery).uniq dels.each(&:revert_to_pending_manifest_completion!) destroy! end |
#speedee_manifest_shipments ⇒ ActiveRecord::Relation<SpeedeeManifestShipment>
19 |
# File 'app/models/speedee_manifest.rb', line 19 has_many :speedee_manifest_shipments, dependent: :destroy |
#speedee_manifest_shipments_with_das ⇒ Object
22 23 24 25 26 |
# File 'app/models/speedee_manifest.rb', line 22 def speedee_manifest_shipments_with_das # doing it this way so I can fake it as a scope ie ActiveRecord CollectionProxy with_das_ids = speedee_manifest_shipments.select { |sms| SpeedeeDasZip.where(zip: sms.ship_to_zip).first.present? }.map(&:id).uniq SpeedeeManifestShipment.where(id: with_das_ids) end |
#upload_manifest_csv(manifest_csv_path) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'app/models/speedee_manifest.rb', line 37 def upload_manifest_csv(manifest_csv_path) upload = Upload.uploadify(manifest_csv_path, 'manifest_csv') if uploads << upload true else false end end |
#upload_summary_pdf(summary_pdf_path) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'app/models/speedee_manifest.rb', line 28 def upload_summary_pdf(summary_pdf_path) upload = Upload.uploadify(summary_pdf_path, 'summary_pdf') if uploads << upload true else false end end |
#uploads ⇒ ActiveRecord::Relation<Upload>
20 |
# File 'app/models/speedee_manifest.rb', line 20 has_many :uploads, -> { order(position: :asc, created_at: :desc) }, as: :resource, dependent: :destroy |