Class: ShippingLiteShipmentDAO

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

Class Method Summary collapse

Class Method Details

.by_merchant_ref_and_tracking_id(merchant_reference_id, vendor_tracking_id) ⇒ Object



17
18
19
# File 'lib/shipping_backup_client/models/shipping_lite_backup_dao.rb', line 17

def self.by_merchant_ref_and_tracking_id(merchant_reference_id, vendor_tracking_id)
  (merchant_reference_id && vendor_tracking_id) ? where("shipping_lite_shipments.merchant_reference_id = ? and shipping_lite_shipments.vendor_tracking_id = ?", merchant_reference_id, vendor_tracking_id) : []
end

.by_merchant_ref_id(id, is_active = true) ⇒ Object



21
22
23
# File 'lib/shipping_backup_client/models/shipping_lite_backup_dao.rb', line 21

def self.by_merchant_ref_id(id,is_active=true)
  id ? where("shipping_lite_shipments.merchant_reference_id = ? and shipping_lite_shipments.active = ?", id,is_active) : []
end

.by_merchant_ref_id_or_tracking_id_active(id, is_active = true) ⇒ Object



33
34
35
# File 'lib/shipping_backup_client/models/shipping_lite_backup_dao.rb', line 33

def self.by_merchant_ref_id_or_tracking_id_active(id,is_active=true)
  id ? where("(shipping_lite_shipments.merchant_reference_id = ? or shipping_lite_shipments.vendor_tracking_id = ?  ) and shipping_lite_shipments.active = ?", id, id,is_active) : []
end

.by_merchant_ref_ids_or_tracking_ids_active(ids, is_active = true) ⇒ Object



37
38
39
# File 'lib/shipping_backup_client/models/shipping_lite_backup_dao.rb', line 37

def self.by_merchant_ref_ids_or_tracking_ids_active(ids, is_active=true)
  ids ? where("(shipping_lite_shipments.merchant_reference_id IN (#{ids}) or shipping_lite_shipments.vendor_tracking_id IN (#{ids})  ) and shipping_lite_shipments.active = ?", is_active) : []
end

.by_merchant_ref_or_tracking_id(id) ⇒ Object



13
14
15
# File 'lib/shipping_backup_client/models/shipping_lite_backup_dao.rb', line 13

def self.by_merchant_ref_or_tracking_id(id)
  id ? where("shipping_lite_shipments.merchant_reference_id = ? or shipping_lite_shipments.vendor_tracking_id = ?", id, id) : []
end

.by_vendor_track_id(id, is_active = true) ⇒ Object



25
26
27
# File 'lib/shipping_backup_client/models/shipping_lite_backup_dao.rb', line 25

def self.by_vendor_track_id(id,is_active=true)
  id ? where("shipping_lite_shipments.vendor_tracking_id = ? and shipping_lite_shipments.active = ?", id,is_active) : []
end

.find_existing_lite_shipment(merchant_reference_id, vendor_tracking_id, vendor_id) ⇒ Object



41
42
43
44
45
46
47
48
49
# File 'lib/shipping_backup_client/models/shipping_lite_backup_dao.rb', line 41

def self.find_existing_lite_shipment(merchant_reference_id,vendor_tracking_id,vendor_id)
  shipment = ShipmentDAO.by_vendor_tracking_id(vendor_tracking_id)

  if(shipment.first.present? && shipment.first.is_mh_offload_shipment?)
    !(shipment.first.flags == 64) # Enabling only for seller return DMH
  else
    where("shipping_lite_shipments.merchant_reference_id = ? and shipping_lite_shipments.vendor_tracking_id = ? and shipping_lite_shipments.vendor_id = ?",merchant_reference_id,vendor_tracking_id,vendor_id).first
  end
end

.is_idempotent(service_request_id, merchant_reference_id, vendor_tracking_id, vendor_id) ⇒ Object



29
30
31
# File 'lib/shipping_backup_client/models/shipping_lite_backup_dao.rb', line 29

def self.is_idempotent(service_request_id,merchant_reference_id,vendor_tracking_id,vendor_id)
  where("shipping_lite_shipments.service_request_id = ? and shipping_lite_shipments.merchant_reference_id = ? and shipping_lite_shipments.vendor_tracking_id = ? and shipping_lite_shipments.vendor_id = ?",service_request_id,merchant_reference_id,vendor_tracking_id,vendor_id)
end