Class: ShipmentDAO

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/shipping_backup_client/models/shipping_backup_dao.rb

Overview

Schema Information

Table name: shipments

id                          :integer          not null, primary key
type                        :string(255)
delivery_type               :string(255)
state                       :string(255)
sla                         :integer
merchant_facility_id        :integer
fkl_origin_facility_id      :integer
fkl_destination_facility_id :integer
vendor_facility_id          :integer
payment_type                :string(255)
estimated_ship_cost         :decimal(10, 2)
shipment_value              :decimal(10, 2)
tax_paid                    :decimal(10, 2)
merchant_code               :string(255)
customer_id                 :integer
vendor_id                   :integer
merchant_reference_id       :string(255)
vendor_tracking_id          :string(255)
service_instructions        :string(4096)
special_instructions        :string(4096)
postal_code                 :string(255)
flags                       :integer          default(0)
created_at                  :datetime
updated_at                  :datetime
fkl_current_facility_id     :integer
dispatched_date             :datetime
vendor_receive_date         :datetime
amount_to_collect           :decimal(10, 2)   default(0.0)
fkl_current_station_id      :integer
request_type                :string(255)

Constant Summary collapse

LZN_MAP =
{ "l" => "local", "z" => "zonal", "n" => "national" }
NON_FA_SERVICE_TYPE =
"non_fa"
FOUR_HOUR_DELIVERY_HUB =
"blr_hsr_01"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#is_fsd_outscannedObject

Returns the value of attribute is_fsd_outscanned.



110
111
112
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 110

def is_fsd_outscanned
  @is_fsd_outscanned
end

Class Method Details

.by_city(name) ⇒ Object



182
183
184
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 182

def self.by_city(name)
  name ? joins(:customer => :postal_addresses).where("postal_addresses.city = '#{name}'").group("shipments.id") : Shipment.scoped
end

.by_cs_status(status) ⇒ Object



129
130
131
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 129

def self.by_cs_status(status)
  status ? joins(:cs_ticket).where('cs_tickets.status' => status) : Shipment.scoped
end

.by_delivery_type(delivery_type) ⇒ Object



260
261
262
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 260

def self.by_delivery_type(delivery_type)
  delivery_type ? where("shipments.delivery_type = '#{delivery_type}'") : Shipment.scoped
end

.by_dispatched_date(dispatched_date) ⇒ Object



166
167
168
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 166

def self.by_dispatched_date(dispatched_date)
  where("shipments.dispatched_date #{self.build_date_filter(dispatched_date)}")
end

.by_flag_1Object



563
564
565
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 563

def self.by_flag_1
  where("flags = 1")
end

.by_history_status(status_string) ⇒ Object



547
548
549
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 547

def self.by_history_status(status_string)
  joins("JOIN shipment_status_histories force index (index_shipment_status_histories_on_status_date) on shipments.id = shipment_status_histories.shipment_id").where("new_status IN (#{status_string}) and status_type = 'SHIPMENT'")
end

.by_kerala_postal_codesObject



378
379
380
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 378

def self.by_kerala_postal_codes
  where("shipments.postal_code BETWEEN '670001' AND '699999' ")
end

.by_limit(per_page) ⇒ Object



186
187
188
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 186

def self.by_limit(per_page)
  per_page ? limit(per_page) : Shipment.scoped
end

.by_merchant(code) ⇒ Object



264
265
266
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 264

def self.by_merchant(code)
  code ? where("shipments.merchant_code = '#{code}'") : Shipment.scoped
end

.by_merchant_ref_and_tracking_id(merchant_ref_id, tracking_id) ⇒ Object



244
245
246
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 244

def self.by_merchant_ref_and_tracking_id(merchant_ref_id, tracking_id)
  (merchant_ref_id && tracking_id) ? where("shipments.merchant_reference_id = ? and shipments.vendor_tracking_id = ?", merchant_ref_id, tracking_id) : Shipment.scoped
end

.by_merchant_ref_id(merchant_ref_id) ⇒ Object



288
289
290
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 288

def self.by_merchant_ref_id(merchant_ref_id)
  merchant_ref_id ? where(:merchant_reference_id => merchant_ref_id) : Shipment.scoped
end

.by_merchant_ref_or_tracking_id(id) ⇒ Object



240
241
242
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 240

def self.by_merchant_ref_or_tracking_id(id)
  id ? where("shipments.merchant_reference_id = ? or shipments.vendor_tracking_id = ?", id, id) : Shipment.scoped
end

.by_merchant_ref_or_tracking_ids(ids) ⇒ Object



252
253
254
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 252

def self.by_merchant_ref_or_tracking_ids(ids)
  ids ? where("shipments.merchant_reference_id IN (#{ids}) or shipments.vendor_tracking_id IN (#{ids})") : Shipment.scoped
end

.by_offset(page, offset) ⇒ Object



190
191
192
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 190

def self.by_offset(page, offset)
  page ? offset(offset) : Shipment.scoped
end

.by_payment_type(type) ⇒ Object



256
257
258
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 256

def self.by_payment_type(type)
  type ? where("shipments.payment_type = '#{type}'") : Shipment.scoped
end

.by_priority(priority) ⇒ Object



593
594
595
596
597
598
599
600
601
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 593

def self.by_priority(priority)
  if (priority.present? && priority.try(:downcase) == Shipment::CostOfBreach::SDD)
    joins("INNER JOIN shipment_attributes ON shipment_attributes.shipment_id = shipments.id").where("shipment_attributes.name = 'tier_type' and shipment_attributes.value = '#{Shipment::CostOfBreachValue::SDD}'")
  elsif (priority.present? && priority.try(:downcase) == Shipment::CostOfBreach::NDD)
    joins("INNER JOIN shipment_attributes ON shipment_attributes.shipment_id = shipments.id").where("shipment_attributes.name = 'tier_type' and shipment_attributes.value = '#{Shipment::CostOfBreachValue::NDD}'")
  else
    scoped
  end
end

.by_rto_type(type) ⇒ Object



194
195
196
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 194

def self.by_rto_type(type)
  type ? (type == 'merchant_reship' ? where("(flags & 32) =32") : rto_detail.merge(RtoDetail.by_type(type))) : Shipment.scoped
end

.by_source_type(source_type) ⇒ Object



583
584
585
586
587
588
589
590
591
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 583

def self.by_source_type(source_type)
  if (!source_type.present?)
    scoped
  elsif (source_type.try(:downcase) == "fbf")
    where("shipments.source_type = ?", Shipment::SourceTypes::FBF)
  else # nonfbf
    where("shipments.source_type = ? OR shipments.source_type IS NULL", Shipment::SourceTypes::WSR)
  end
end

.by_unreceived_rtoObject



198
199
200
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 198

def self.by_unreceived_rto()
  joins("LEFT JOIN `rto_details` on rto_details.shipment_id = shipments.id").where(" rto_details.received_date is null OR rto_details.received_date < shipments.dispatched_date")
end

.by_vendor_id(id) ⇒ Object



236
237
238
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 236

def self.by_vendor_id(id)
  id ? where("shipments.vendor_id = ?", id) : Shipment.scoped
end

.by_vendor_id_and_merchant_ref_or_tracking_id(vid, alt_vid, id) ⇒ Object



248
249
250
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 248

def self.by_vendor_id_and_merchant_ref_or_tracking_id(vid, alt_vid, id)
  id ? where("shipments.vendor_id in (?,?) and (shipments.merchant_reference_id = ? or shipments.vendor_tracking_id = ?)", vid, alt_vid, id, id) : Shipment.scoped
end

.by_vendor_tracking_id(vendor_tracking_id) ⇒ Object



296
297
298
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 296

def self.by_vendor_tracking_id(vendor_tracking_id)
  vendor_tracking_id ? where(:vendor_tracking_id => vendor_tracking_id) : Shipment.scoped
end

.by_vendor_tracking_vendor_id(vendor_tracking_id, vendor_id) ⇒ Object



292
293
294
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 292

def self.by_vendor_tracking_vendor_id(vendor_tracking_id, vendor_id)
  vendor_tracking_id && vendor_id ? where(:vendor_tracking_id => vendor_tracking_id, :vendor_id => vendor_id).first : Shipment.scoped
end

.created_after(start_time) ⇒ Object



124
125
126
127
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 124

def self.created_after(start_time)
  start_time = DateTime.parse(start_time.to_s).strftime("%Y-%m-%d %H:%M:%S") if start_time.present?
  start_time.present? ? where("shipments.created_at >= '#{start_time}'") : Shipment.scoped
end

.created_before(end_time) ⇒ Object



119
120
121
122
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 119

def self.created_before(end_time)
  end_time = DateTime.parse(end_time.to_s).strftime("%Y-%m-%d %H:%M:%S") if end_time.present?
  end_time.present? ? where("shipments.created_at < '#{end_time}'") : Shipment.scoped
end

.dispatched_after(start_time) ⇒ Object



137
138
139
140
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 137

def self.dispatched_after(start_time)
  start_time = DateTime.parse(start_time.to_s).strftime("%Y-%m-%d %H:%M:%S") if start_time.present?
  start_time.present? ? where("shipments.dispatched_date >= '#{start_time}'") : Shipment.scoped
end

.dispatched_bef(end_time) ⇒ Object



142
143
144
145
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 142

def self.dispatched_bef(end_time)
  end_time = DateTime.parse(end_time.to_s).strftime("%Y-%m-%d %H:%M:%S") if end_time.present?
  end_time.present? ? where("shipments.dispatched_date < '#{end_time}'") : Shipment.scoped
end

.dispatched_before(days) ⇒ Object



133
134
135
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 133

def self.dispatched_before(days)
  days ? where("shipments.dispatched_date <= '#{(Time.now + 1.day).midnight - days.days}'") : Shipment.scoped
end

.dispatched_before_time(days) ⇒ Object



162
163
164
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 162

def self.dispatched_before_time(days)
  days ? where("shipments.dispatched_date <= '#{Time.now - days.days}'") : Shipment.scoped
end

.dispatched_between(start_time, end_time) ⇒ Object



147
148
149
150
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 147

def self.dispatched_between(start_time, end_time)
  start_time.present? && end_time.present? ?
      where("shipments.dispatched_date BETWEEN ? and ?", start_time, end_time) : Shipment.scoped
end

.dispatched_fwd(from_date, to_date) ⇒ Object



391
392
393
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 391

def self.dispatched_fwd(from_date, to_date)
  from_date(from_date).where("shipments.state IN ('#{States::DISPATCHED_TO_VENDOR}','#{States::DISPATCHED_TO_FACILITY}') AND shipments.type = 'OutgoingShipment' AND flags & 32 != 32").by_history_status("'#{States::DISPATCHED_TO_VENDOR}','#{States::DISPATCHED_TO_FACILITY}'").from_status_date(from_date).to_status_date(to_date)
end

.dispatched_fwd_with_after_dispatch_to_vendor_status(from_date, days) ⇒ Object



420
421
422
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 420

def self.dispatched_fwd_with_after_dispatch_to_vendor_status(from_date, days)
  from_date(from_date).dispatched_before_time(days).where("shipments.state IN ('#{States::UNDELIVERED_ATTEMPTED}','#{States::UNDELIVERED_UNATTEMPTED}') AND shipments.type in ('OutgoingShipment') AND flags & 32 != 32")
end

.dispatched_fwd_with_dispatch_to_vendor_status(from_date, days) ⇒ Object



412
413
414
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 412

def self.dispatched_fwd_with_dispatch_to_vendor_status(from_date, days)
  from_date(from_date).dispatched_before_time(days).where("shipments.state IN ('#{States::DISPATCHED_TO_VENDOR}','#{States::DISPATCHED_TO_FACILITY}') AND shipments.type in ('OutgoingShipment') AND flags & 32 != 32")
end

.dispatched_fwd_with_non_terminal_status(from_date, days) ⇒ Object



395
396
397
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 395

def self.dispatched_fwd_with_non_terminal_status(from_date, days)
  from_date(from_date).dispatched_before_time(days).where("shipments.state IN ('#{States::DISPATCHED_TO_VENDOR}','#{States::DISPATCHED_TO_FACILITY}','#{States::UNDELIVERED_ATTEMPTED}','#{States::UNDELIVERED_UNATTEMPTED}') AND shipments.type in ('OutgoingShipment') AND flags & 32 != 32")
end

.dispatched_rvp_with_after_dispatch_to_vendor_status(from_date, days) ⇒ Object



424
425
426
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 424

def self.dispatched_rvp_with_after_dispatch_to_vendor_status(from_date, days)
  from_date(from_date).dispatched_before_time(days).where("shipments.state IN ('#{States::UNDELIVERED_ATTEMPTED}','#{States::UNDELIVERED_UNATTEMPTED}') AND shipments.type in ('IncomingShipment') AND flags & 32 != 32")
end

.dispatched_rvp_with_dispatch_to_vendor_status(from_date, days) ⇒ Object



416
417
418
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 416

def self.dispatched_rvp_with_dispatch_to_vendor_status(from_date, days)
  from_date(from_date).dispatched_before_time(days).where("shipments.state IN ('#{States::DISPATCHED_TO_VENDOR}','#{States::DISPATCHED_TO_FACILITY}') AND shipments.type in ('IncomingShipment') AND flags & 32 != 32")
end

.dispatched_rvp_with_non_terminal_status(from_date, days) ⇒ Object



399
400
401
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 399

def self.dispatched_rvp_with_non_terminal_status(from_date, days)
  from_date(from_date).dispatched_before_time(days).where("shipments.state IN ('#{States::DISPATCHED_TO_VENDOR}','#{States::DISPATCHED_TO_FACILITY}','#{States::UNDELIVERED_ATTEMPTED}','#{States::UNDELIVERED_UNATTEMPTED}') AND shipments.type in ('IncomingShipment') AND flags & 32 != 32")
end

.dispatched_todayObject

def self.filter_rvp_scoped(args = {})

scope = Shipment.scoped
scope = scope.incoming_shipment_requested if args[:rvp_requested]
scope = scope.incoming_shipment_cancelled if args[:rvp_cancelled]
scope = scope.incoming_shipment_scheduled_rescheduled if args[:rvp_scheduled_rescheduled]
scope = scope.incoming_shipment_partially_scheduled if args[:rvp_partially_scheduled]
scope = scope.incoming_shipment_received if args[:rvp_received]
scope

end



476
477
478
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 476

def self.dispatched_today
  where("shipments.state IN ('#{States::DISPATCHED_TO_VENDOR}','#{States::DISPATCHED_TO_FACILITY}') AND shipments.type = 'OutgoingShipment' AND shipments.updated_at #{self.build_date_filter(Time.now.to_date.to_s)}  AND flags & 1 != 1 and flags & 32 != 32")
end

.expected_fwd(from_date, to_date) ⇒ Object



504
505
506
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 504

def self.expected_fwd(from_date, to_date)
  from_date(from_date).by_history_status("'#{States::EXPECTED}'").from_status_date(from_date).to_status_date(to_date).where("shipments.state = '#{States::EXPECTED}' AND shipments.type = 'OutgoingShipment' AND flags & 32 != 32")
end

.expected_fwd_before(from_date) ⇒ Object



508
509
510
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 508

def self.expected_fwd_before(from_date)
  by_history_status("'#{States::EXPECTED}'").to_status_date_v1(from_date).where("shipments.state = '#{States::EXPECTED}' AND shipments.type = 'OutgoingShipment' AND flags & 32 != 32")
end

.failed_shipments_in_vendor_service_request(request_type) ⇒ Object



456
457
458
459
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 456

def self.failed_shipments_in_vendor_service_request(request_type)
  request_type_condition = request_type.present? ? " and vendor_service_requests.request_type='#{request_type}'" : ""
  joins("LEFT OUTER JOIN vendor_service_requests on shipments.id = vendor_service_requests.shipment_id").where("vendor_service_requests.no_of_attempts <= '#{States::THRESHOLD_NUMBER_OF_ATTEMPT}' AND vendor_service_requests.state in ('failed') #{request_type_condition}")
end

.filter(args = {}) ⇒ Object



301
302
303
304
305
306
307
308
309
310
311
312
313
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 301

def self.filter(args = {})
  offset = args[:per_page].to_i * (args[:page].to_i - 1) if (args[:per_page] && args[:page])
  by_vendor(args[:by_vendor]).by_merchant(args[:by_merchant]).by_type(
      args[:by_type]).by_cs_status(args[:by_cs_status]).by_delivery_type(
      args[:by_delivery_type]).pending_for(args[:pending_for]).by_city(
      args[:by_city]).by_state(args[:by_state]).by_rto_type(
      args[:by_rto_type]).by_fkl_facility(args[:by_fkl_facility]).by_fkl_station(
      args[:by_fkl_station]).from_date(
      args[:by_from_date]).to_date(args[:by_to_date]).by_limit(
      args[:per_page]).by_offset(args[:page], offset.to_i).merge(
      (Shipment.get_multiple_shipments_by_id(args[:by_tracking_id]) if args[:by_tracking_id])
  )
end

.filter_forward(args = {}) ⇒ Object



362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 362

def self.filter_forward(args = {})
  scope = Shipment.scoped
  from_date, to_date = args[:from_date], args[:to_date]
  source_type = args[:by_source_type]
  priority = args[:by_priority]

  scope = scope.forward_shipments_with_rto_created.pending_fwd_before(from_date).by_source_type(source_type).group("shipments.id") if args[:pending_till_yesterday_fwd]
  scope = scope.forward_shipments_with_rto_created.pending_fwd_for(from_date, to_date).by_source_type(source_type).group("shipments.id") if args[:received_today_fwd]
  scope = scope.forward_shipments_with_rto_created.dispatched_fwd(from_date, to_date).by_source_type(source_type).group("shipments.id") if args[:dispatched_to_vendor_fwd]
  scope = scope.forward_shipments_with_rto_created.expected_fwd(from_date, to_date).by_source_type(source_type).group("shipments.id") if args[:expected_today_fwd]
  scope = scope.forward_shipments_with_rto_created.expected_fwd_before(from_date).by_source_type(source_type).group("shipments.id") if args[:expected_till_yesterday_fwd]
  scope = scope.new_filter(args).group("shipments.id") if args[:actual_dispatched_to_vendor_fwd_count]

  scope
end

.filter_merchant_reship(args = {}) ⇒ Object



354
355
356
357
358
359
360
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 354

def self.filter_merchant_reship(args = {})
  scope = Shipment.scoped
  scope = scope.merchant_reship_pending_till_yesterday(args[:by_rto_from_date]) if args[:pending_till_yesterday_rto]
  scope = scope.merchant_reship_pending_today(args[:by_rto_from_date], args[:by_rto_to_date]) if args[:pending_today_rto]
  scope = scope.merchant_reship_dispatched_today(args[:by_rto_from_date], args[:by_rto_to_date]) if args[:returned_rto]
  scope
end

.filter_rto(args = {}) ⇒ Object



341
342
343
344
345
346
347
348
349
350
351
352
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 341

def self.filter_rto(args = {})
  scope = Shipment.scoped
  source_type = args[:by_source_type]
  merchant_code = args[:by_merchant]
  scope = scope.rto_expected(args[:by_rto_from_date], args[:by_rto_to_date]).by_source_type(source_type) if args[:rto_expected]
  scope = scope.pending_till_yesterday_rto(args[:by_rto_from_date]).by_source_type(source_type) if args[:pending_till_yesterday_rto]
  scope = scope.pending_today_rto(args[:by_rto_from_date], args[:by_rto_to_date]).by_source_type(source_type) if args[:pending_today_rto]
  scope = scope.returned_rto(args[:by_rto_from_date], args[:by_rto_to_date]).by_source_type(source_type) if args[:returned_rto]
  scope = scope.received_by_merchant_rto(args[:by_rto_from_date], args[:by_rto_to_date]).by_source_type(source_type) if args[:received_by_merchant_rto]
  scope = scope.reshipped_rto(args[:by_rto_from_date], args[:by_rto_to_date]).by_source_type(source_type) if args[:reshipped_rto]
  scope
end

.forward_dashboard_filters(from_date, to_date) ⇒ Object



383
384
385
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 383

def self.forward_dashboard_filters(from_date, to_date)
  from_date(from_date).to_date_time_non_inclusive(to_date).where("shipments.state IN ('#{States::RECEIVED}','#{States::RECEIVED_WITH_ERROR}', '#{States::EXPECTED}', '#{States::DISPATCHED_TO_VENDOR}','#{States::DISPATCHED_TO_FACILITY}') AND shipments.type = 'OutgoingShipment' AND flags & 32 != 32")
end

.forward_dashboard_filters_new(from_date, to_date) ⇒ Object



387
388
389
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 387

def self.forward_dashboard_filters_new(from_date, to_date)
  from_date(from_date).from_status_date(from_date).to_status_date(to_date).where("shipments.state IN ('#{States::RECEIVED}','#{States::RECEIVED_WITH_ERROR}', '#{States::EXPECTED}', '#{States::DISPATCHED_TO_VENDOR}','#{States::DISPATCHED_TO_FACILITY}') AND shipments.type = 'OutgoingShipment' AND shipment_status_histories.new_status = shipments.state AND flags & 32 != 32")
end

.forward_shipments_with_rto_createdObject



579
580
581
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 579

def self.forward_shipments_with_rto_created
  joins("LEFT OUTER JOIN rto_details on shipments.id = rto_details.shipment_id").where("rto_details.status IS NULL or rto_details.status = '#{RtoDetail::Statuses::CREATED}' or  rto_details.status = '#{RtoDetail::Statuses::IN_TRANSIT}' or rto_details.status = '#{RtoDetail::Statuses::CANCELLED}' ")
end

.forward_shipments_without_rto_detailsObject



575
576
577
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 575

def self.forward_shipments_without_rto_details
  joins("LEFT OUTER JOIN rto_details on shipments.id = rto_details.shipment_id").where("rto_details.id is null")
end

.from_date(from_date) ⇒ Object



512
513
514
515
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 512

def self.from_date(from_date)
  from_date = DateTime.parse(from_date).strftime("%Y-%m-%d %H:%M:%S") if from_date
  from_date ? where("shipments.updated_at >= '#{from_date}'") : Shipment.scoped
end

.from_status_date(from_date) ⇒ Object



532
533
534
535
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 532

def self.from_status_date(from_date)
  from_date = DateTime.parse(from_date).strftime("%Y-%m-%d %H:%M:%S") if from_date
  from_date ? where("shipment_status_histories.status_date >= '#{from_date}'") : Shipment.scoped
end

.get_dispatched_outgoing_shipmentsObject



428
429
430
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 428

def self.get_dispatched_outgoing_shipments
  where("shipments.state IN ('#{States::DISPATCHED_TO_VENDOR}','#{States::DISPATCHED_TO_FACILITY}') AND shipments.type in ('OutgoingShipment') AND flags & 32 != 32")
end

.get_dispatched_outgoing_shipments_fedexObject



431
432
433
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 431

def self.get_dispatched_outgoing_shipments_fedex
  where("shipments.state IN ('#{States::DISPATCHED_TO_VENDOR}','#{States::DISPATCHED_TO_FACILITY}','#{States::UNDELIVERED_ATTEMPTED}','#{States::UNDELIVERED_UNATTEMPTED}','#{States::DELIVERED}') AND shipments.type in ('OutgoingShipment') AND flags & 32 != 32")
end

.include_shipment_detailsObject



440
441
442
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 440

def self.include_shipment_details
  includes(:shipment_items,:customer => :postal_addresses,:customer => :telecom_numbers,:seller => :shipment_seller_mapping)
end

.join_shipment_status_history_with_history_status_date_indexObject



492
493
494
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 492

def self.join_shipment_status_history_with_history_status_date_index
  joins("INNER JOIN shipment_status_histories FORCE INDEX for join (`index_shipment_status_histories_on_status_date`) ON shipment_status_histories.shipment_id = shipments.id")
end

.join_shipment_status_history_with_history_status_date_index_with_shipment_typeObject



496
497
498
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 496

def self.join_shipment_status_history_with_history_status_date_index_with_shipment_type
  joins("INNER JOIN shipment_status_histories FORCE INDEX for join (`index_shipment_status_histories_on_status_date`) ON shipment_status_histories.shipment_id = shipments.id").where("new_status IN ('received','received_with_error', 'expected','dispatched_to_vendor','dispatched_to_facility') and status_type = 'SHIPMENT'")
end

.merchant_reship_dispatched_today(from_date, to_date) ⇒ Object



273
274
275
276
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 273

def self.merchant_reship_dispatched_today(from_date, to_date)
  where_clause = where("shipments.state = ('#{States::DISPATCHED_TO_MERCHANT}') AND flags & 32 = 32")
  from_date || to_date ? where_clause.merge(Shipment.from_date(from_date)).merge(Shipment.to_date(to_date)) : where_clause.where("shipments.updated_at #{self.build_date_filter(Time.now.to_date.to_s)}")
end

.merchant_reship_pending_till_yesterday(from_date) ⇒ Object



278
279
280
281
282
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 278

def self.merchant_reship_pending_till_yesterday(from_date)
  from_date = DateTime.parse(from_date).strftime("%Y-%m-%d %H:%M:%S") if from_date
  where_clause = where("shipments.state IN ('#{States::MERCHANT_RESHIP_REQUESTED}','#{States::DISPATCHED_TO_MERCHANT}','#{States::EXPECTED}') AND flags & 32 = 32")
  from_date ? where_clause.where("shipments.updated_at < '#{from_date}'") : where_clause.where("shipments.updated_at < '#{Time.now.to_date.to_s} 00:00:00'")
end

.merchant_reship_pending_today(from_date, to_date) ⇒ Object



268
269
270
271
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 268

def self.merchant_reship_pending_today(from_date, to_date)
  where_clause = where("shipments.state IN ('#{States::MERCHANT_RESHIP_REQUESTED}','#{States::EXPECTED}') AND flags & 32 = 32")
  from_date || to_date ? where_clause.merge(Shipment.from_date(from_date)).merge(Shipment.to_date(to_date)) : where_clause.where("shipments.updated_at #{self.build_date_filter(Time.now.to_date.to_s)}")
end

.new_filter(args = {}) ⇒ Object



330
331
332
333
334
335
336
337
338
339
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 330

def self.new_filter(args = {})
  offset = args[:per_page].to_i * (args[:page].to_i - 1) if (args[:per_page] && args[:page])
  by_vendor(args[:by_vendor]).by_merchant(args[:by_merchant]).by_type(
      args[:by_type]).by_fkl_origin_facility(args[:by_fkl_facility]).by_unreceived_rto().dispatched_after(
      args[:from_date]).dispatched_bef(args[:to_date]).by_fkl_station(
      args[:by_fkl_station]).by_limit(
      args[:per_page]).by_offset(args[:page], offset.to_i).merge(
      (Shipment.get_multiple_shipments_by_id(args[:by_tracking_id]) if args[:by_tracking_id])
  )
end

.not_marked_for_reshipmentObject



284
285
286
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 284

def self.not_marked_for_reshipment
  where("shipments.state NOT IN ('#{States::MARKED_FOR_RESHIPMENT}', '#{States::RESHIPPED}')")
end

.not_rtoObject



555
556
557
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 555

def self.not_rto
  where("(flags & 1) != 1")
end

.pending_for(days) ⇒ Object



178
179
180
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 178

def self.pending_for(days)
  days ? dispatched_before(days).undelivered : Shipment.scoped
end

.pending_fwdObject



551
552
553
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 551

def self.pending_fwd
  where("shipments.state in ('received') and flags & 1 != 1")
end

.pending_fwd_before(from_date) ⇒ Object



500
501
502
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 500

def self.pending_fwd_before(from_date)
  by_history_status("'#{States::RECEIVED}','#{States::RECEIVED_WITH_ERROR}'").to_status_date_v1(from_date).where("shipments.state IN ('#{States::RECEIVED}','#{States::RECEIVED_WITH_ERROR}') AND shipments.type = 'OutgoingShipment' AND flags & 32 != 32 ")
end

.pending_fwd_for(from_date, to_date) ⇒ Object



480
481
482
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 480

def self.pending_fwd_for(from_date, to_date)
  from_date(from_date).by_history_status("'#{States::RECEIVED}','#{States::RECEIVED_WITH_ERROR}'").from_status_date(from_date).to_status_date(to_date).where("shipments.state IN ('#{States::RECEIVED}','#{States::RECEIVED_WITH_ERROR}') AND shipments.type = 'OutgoingShipment' AND flags & 32 != 32")
end

.pending_till_yesterday_rto(from_date) ⇒ Object



217
218
219
220
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 217

def self.pending_till_yesterday_rto(from_date)
  where_clause = rto_detail.where("shipments.state IN ('#{States::RECEIVED}','#{States::RECEIVED_WITH_ERROR}','#{States::MARKED_FOR_MERCHANT_DISPATCH}','#{States::MARKED_FOR_RESHIPMENT}','#{States::MARKED_FOR_SELLER_RETURN}')").where("rto_details.id is NOT NULL").merge(RtoDetail.by_status(RtoDetail::Statuses::RECEIVED))
  from_date ? where_clause.merge(RtoDetail.before_date(from_date)) : where_clause.merge(RtoDetail.before_date(Time.now.to_date.to_s))
end

.pending_today_rto(from_date, to_date) ⇒ Object



212
213
214
215
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 212

def self.pending_today_rto(from_date, to_date)
  where_clause = rto_detail.where("shipments.state IN ('#{States::RECEIVED}','#{States::RECEIVED_WITH_ERROR}','#{States::MARKED_FOR_MERCHANT_DISPATCH}','#{States::MARKED_FOR_RESHIPMENT}','#{States::MARKED_FOR_SELLER_RETURN}')").where("rto_details.id is NOT NULL").merge(RtoDetail.by_status(RtoDetail::Statuses::RECEIVED))
  from_date || to_date ? where_clause.merge(RtoDetail.by_rto_received_from_date(from_date)).merge(RtoDetail.by_rto_received_to_date(to_date)) : where_clause.merge(RtoDetail.by_rto_received_from_date(Time.now.to_date.to_s)).merge(RtoDetail.by_rto_received_to_date(Time.now.to_date.to_s))
end

.pickup_rvp_incoming_shipmentsObject



444
445
446
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 444

def self.pickup_rvp_incoming_shipments
  joins( "INNER JOIN incoming_shipment_pickup_details on shipments.id = incoming_shipment_pickup_details.incoming_shipment_id ").where ("shipments.state IN ('#{States::EXPECTED}') AND shipments.type in ('IncomingShipment') AND flags & 32 != 32 AND incoming_shipment_pickup_details.state IN ('#{States::PARTIALLY_SCHEDULED}') AND incoming_shipment_pickup_details.pickup_type IN ('#{States::PICKUP_TYPE_ONLY}')")
end

.pickup_rvp_incoming_shipments_scheduled_stateObject



448
449
450
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 448

def self.pickup_rvp_incoming_shipments_scheduled_state
  joins( "INNER JOIN incoming_shipment_pickup_details on shipments.id = incoming_shipment_pickup_details.incoming_shipment_id ").where ("shipments.state IN ('#{States::EXPECTED}') AND shipments.type in ('IncomingShipment') AND flags & 32 != 32 AND incoming_shipment_pickup_details.state IN ('#{States::SCHEDULED}') AND incoming_shipment_pickup_details.pickup_type IN ('#{States::PICKUP_TYPE_ONLY}')")
end

.processing_shipments_in_vendor_service_request(request_type) ⇒ Object



461
462
463
464
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 461

def self.processing_shipments_in_vendor_service_request(request_type)
  request_type_condition = request_type.present? ? " and vendor_service_requests.request_type='#{request_type}'" : ""
  joins("LEFT OUTER JOIN vendor_service_requests on shipments.id = vendor_service_requests.shipment_id").where("vendor_service_requests.updated_at <= '#{Time.now-(States::THRESHOLD_TIME).hours}' AND vendor_service_requests.state in ('processing') #{request_type_condition}")
end

.receivedObject



174
175
176
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 174

def self.received
  where("(shipments.state in ('#{Shipment::States::RECEIVED}','#{Shipment::States::RECEIVED_WITH_ERROR}'))")
end

.received_by_merchant_rto(from_date, to_date) ⇒ Object



222
223
224
225
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 222

def self.received_by_merchant_rto(from_date, to_date)
  where_clause = rto_detail.join_shipment_status_history_with_history_status_date_index.where("shipments.state IN ('#{States::RECEIVED_BY_MERCHANT}','#{States::RETURNED_TO_SELLER}') ").where("rto_details.id is NOT NULL").merge(RtoDetail.by_status(RtoDetail::Statuses::COMPLETED)).merge(ShipmentStatusHistory.shipment_histories.where("new_status IN ('#{States::RECEIVED_BY_MERCHANT}','#{States::RETURNED_TO_SELLER}')")).group("shipments.id")
  from_date || to_date ? where_clause.merge(ShipmentStatusHistory.from_date(from_date)).merge(ShipmentStatusHistory.to_date(to_date)) : where_clause.where("shipment_status_histories.status_date #{self.build_date_filter(Time.now.to_date.to_s)}")
end

.reshipmentObject



232
233
234
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 232

def self.reshipment
  by_state(States::RECEIVED).where("(flags & 8) = 8")
end

.reshipped_rto(from_date, to_date) ⇒ Object



202
203
204
205
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 202

def self.reshipped_rto(from_date, to_date)
  where_clause = rto_detail.join_shipment_status_history_with_history_status_date_index.merge(by_state(States::RESHIPPED)).where("rto_details.id is NOT NULL").merge(RtoDetail.by_status(RtoDetail::Statuses::COMPLETED)).merge(ShipmentStatusHistory.shipment_histories.where("new_status = '#{States::RESHIPPED}'")).group("shipments.id")
  from_date || to_date ? where_clause.merge(ShipmentStatusHistory.from_date(from_date)).merge(ShipmentStatusHistory.to_date(to_date)) : where_clause.where("shipment_status_histories.status_date #{self.build_date_filter(Time.now.to_date.to_s)}")
end

.returned_rto(from_date, to_date) ⇒ Object



207
208
209
210
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 207

def self.returned_rto(from_date, to_date)
  where_clause = rto_detail.join_shipment_status_history_with_history_status_date_index.where("shipments.state IN ('#{States::DISPATCHED_TO_MERCHANT}','#{States::DISPATCHED_TO_FACILITY}','#{States::DISPATCHED_TO_SELLER}')").where("rto_details.id is NOT NULL").merge(RtoDetail.by_statuses([RtoDetail::Statuses::COMPLETED, RtoDetail::Statuses::RECEIVED])).merge(ShipmentStatusHistory.shipment_histories.where("new_status IN ('#{States::DISPATCHED_TO_MERCHANT}','#{States::DISPATCHED_TO_FACILITY}','#{States::DISPATCHED_TO_SELLER}')")).group("shipments.id")
  from_date || to_date ? where_clause.merge(ShipmentStatusHistory.from_date(from_date)).merge(ShipmentStatusHistory.to_date(to_date)) : where_clause.where("shipment_status_histories.status_date #{self.build_date_filter(Time.now.to_date.to_s)}")
end

.rto_expected(from_date, to_date) ⇒ Object



227
228
229
230
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 227

def self.rto_expected(from_date, to_date)
  where_clause = rto_detail.where("shipments.state NOT IN ('#{States::RECEIVED}','#{States::LOST}','#{States::DELIVERED}')").merge(RtoDetail.by_status(RtoDetail::Statuses::CREATED))
  from_date || to_date ? where_clause.merge(RtoDetail.from_date(from_date)).merge(RtoDetail.to_date(to_date)) : where_clause.merge(RtoDetail.to_date(Time.now.to_date.to_s))
end

.rto_shipmentsObject



559
560
561
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 559

def self.rto_shipments
  where("(flags & 1) = 1")
end

.rvp_scheduled_shipments(from_date, days) ⇒ Object



404
405
406
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 404

def self.rvp_scheduled_shipments(from_date, days)
  from_date(from_date).joins( "INNER JOIN incoming_shipment_pickup_details on shipments.id = incoming_shipment_pickup_details.incoming_shipment_id ").where ("shipments.state IN ('#{States::EXPECTED}','#{States::SCHEDULED}','#{States::REVERSE_PICKUP_SCHEDULED}','#{States::REQUEST_FOR_RESCHEDULE}','#{States::REQUEST_FOR_CANCELLATION}','#{States::REVERSE_PICKUP_COMPLETED}','#{States::VENDOR_RECEIVED}') AND shipments.type in ('IncomingShipment') AND flags & 32 != 32 AND incoming_shipment_pickup_details.pickup_type IN ('#{States::PICKUP_TYPE_ONLY}')")
end

.rvp_scheduled_shipments_gati(from_date, days) ⇒ Object



408
409
410
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 408

def self.rvp_scheduled_shipments_gati(from_date, days)
  from_date(from_date).joins( "INNER JOIN incoming_shipment_pickup_details on shipments.id = incoming_shipment_pickup_details.incoming_shipment_id ").where ("shipments.state IN ('#{States::EXPECTED}','#{States::SCHEDULED}','#{States::REVERSE_PICKUP_SCHEDULED}','#{States::REQUEST_FOR_RESCHEDULE}','#{States::REQUEST_FOR_CANCELLATION}') AND shipments.type in ('IncomingShipment') AND flags & 32 != 32 AND incoming_shipment_pickup_details.pickup_type IN ('#{States::PICKUP_TYPE_ONLY}')")
end

.to_date(to_date) ⇒ Object



527
528
529
530
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 527

def self.to_date(to_date)
  to_date = DateTime.parse(to_date).strftime("%Y-%m-%d %H:%M:%S") if to_date
  to_date ? where("shipments.updated_at < '#{to_date}' + interval 1 day") : Shipment.scoped
end

.to_date_time(date) ⇒ Object



517
518
519
520
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 517

def self.to_date_time(date)
  date = DateTime.parse(date).strftime("%Y-%m-%d %H:%M:%S") if date
  date ? where("shipments.updated_at <= '#{date}'") : Shipment.scoped
end

.to_date_time_non_inclusive(date) ⇒ Object



522
523
524
525
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 522

def self.to_date_time_non_inclusive(date)
  date = DateTime.parse(date).strftime("%Y-%m-%d %H:%M:%S") if date
  date ? where("shipments.updated_at < '#{date}'") : Shipment.scoped
end

.to_status_date(to_date) ⇒ Object



537
538
539
540
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 537

def self.to_status_date(to_date)
  to_date = DateTime.parse(to_date).strftime("%Y-%m-%d %H:%M:%S") if to_date
  to_date ? where("shipment_status_histories.status_date <= '#{to_date}'") : Shipment.scoped
end

.to_status_date_v1(to_date) ⇒ Object



542
543
544
545
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 542

def self.to_status_date_v1(to_date)
  to_date = DateTime.parse(to_date).strftime("%Y-%m-%d %H:%M:%S") if to_date
  to_date ? where("shipment_status_histories.status_date < '#{to_date}'") : Shipment.scoped
end

.undeliveredObject



170
171
172
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 170

def self.undelivered
  where("shipments.state in ('undelivered_attempted','undelivered_unattempted')")
end

.unit_filter(args = {}) ⇒ Object



315
316
317
318
319
320
321
322
323
324
325
326
327
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 315

def self.unit_filter(args = {})
  offset = args[:per_page].to_i * (args[:page].to_i - 1) if (args[:per_page] && args[:page])
  by_vendor(args[:by_vendor]).by_merchant(args[:by_merchant]).by_type(
      args[:by_type]).by_cs_status(args[:by_cs_status]).by_delivery_type(
      args[:by_delivery_type]).pending_for(args[:pending_for]).by_city(
      args[:by_city]).by_state(args[:by_state]).by_rto_type(
      args[:by_rto_type]).by_fkl_facility(args[:by_fkl_facility]).by_fkl_station(
      args[:by_fkl_station]).from_date(
      args[:by_from_date]).to_date(args[:by_to_date]).by_limit(
      args[:per_page]).by_offset(args[:page], offset.to_i).merge(
      (Shipment.by_merchant_ref_or_tracking_ids(args[:by_tracking_ids]) if args[:by_tracking_ids])
  )
end

.use_force_index_on_stateObject



484
485
486
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 484

def self.use_force_index_on_state
  from("shipments FORCE INDEX (index_shipments_on_state)")
end

.use_force_index_on_updated_atObject



488
489
490
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 488

def self.use_force_index_on_updated_at
  from("shipments FORCE INDEX (index_shipments_on_updated_at)")
end

.with_vendor_service_request_and_attemps_countObject



452
453
454
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 452

def self.with_vendor_service_request_and_attemps_count
  joins("LEFT OUTER JOIN vendor_service_requests on shipments.id = vendor_service_requests.shipment_id").where("vendor_service_requests.no_of_attempts <= '#{States::THRESHOLD_NUMBER_OF_ATTEMPT}' AND vendor_service_requests.state in ('processing', 'failed')")
end

.without_lite_shipments(ids) ⇒ Object



437
438
439
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 437

def self.without_lite_shipments(ids)
  joins("LEFT OUTER JOIN shipping_lite_shipments on shipments.merchant_reference_id=shipping_lite_shipments.merchant_reference_id where (shipments.vendor_tracking_id IN (#{ids}) OR shipments.merchant_reference_id IN (#{ids})) and shipping_lite_shipments.merchant_reference_id IS NULL")
end

.without_tracking_idObject



567
568
569
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 567

def self.without_tracking_id
  where("shipments.vendor_tracking_id IS NULL and shipments.vendor_id is NOT NULL")
end

.without_vendor_and_tracking_idObject



571
572
573
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 571

def self.without_vendor_and_tracking_id
  where("shipments.vendor_tracking_id IS NULL and shipments.vendor_id is NULL")
end

.without_vendor_service_requestObject



434
435
436
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 434

def self.without_vendor_service_request
  joins("LEFT OUTER JOIN vendor_service_requests on shipments.id = vendor_service_requests.shipment_id").where("vendor_service_requests.id is null")
end

Instance Method Details

#as_json(options = {}) ⇒ Object



115
116
117
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 115

def as_json(options = {})
  super.merge!(:pending_since => pending_since, :shipment_type => type)
end

#incoming_market_place_shipment?Boolean

Returns:

  • (Boolean)


603
604
605
# File 'lib/shipping_backup_client/models/shipping_backup_dao.rb', line 603

def incoming_market_place_shipment?
  rvp? && Shipment.market_place_merchant(self.merchant.name)
end