shipping_backup_client 1.0.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Gemfile +31 -0
- data/Gemfile.lock +125 -0
- data/Rakefile +13 -0
- data/config/shipping_backup_sample_config.yml +10 -0
- data/lib/shipping_backup_client/client/shipping_backup_client.rb +198 -0
- data/lib/shipping_backup_client/config/shipping_backup_config.rb +63 -0
- data/lib/shipping_backup_client/db/shipping_backup_db.rb +60 -0
- data/lib/shipping_backup_client/helpers/shipping_backup_logger.rb +32 -0
- data/lib/shipping_backup_client/models/customer_backup_dao.rb +25 -0
- data/lib/shipping_backup_client/models/electronic_address_dao.rb +11 -0
- data/lib/shipping_backup_client/models/postal_address_dao.rb +11 -0
- data/lib/shipping_backup_client/models/return_seller_backup_dao.rb +19 -0
- data/lib/shipping_backup_client/models/seller_backup_dao.rb +24 -0
- data/lib/shipping_backup_client/models/shipment_note_dao.rb +47 -0
- data/lib/shipping_backup_client/models/shipment_return_seller_mappings_dao.rb +22 -0
- data/lib/shipping_backup_client/models/shipment_scan_audit_dao.rb +28 -0
- data/lib/shipping_backup_client/models/shipment_seller_mapping_dao.rb +22 -0
- data/lib/shipping_backup_client/models/shipment_status_history_dao.rb +54 -0
- data/lib/shipping_backup_client/models/shipping_backup_dao.rb +606 -0
- data/lib/shipping_backup_client/models/shipping_lite_backup_dao.rb +50 -0
- data/lib/shipping_backup_client/models/telecom_numbers_dao.rb +5 -0
- data/lib/shipping_backup_client.rb +14 -0
- metadata +121 -0
@@ -0,0 +1,47 @@
|
|
1
|
+
# == Schema Information
|
2
|
+
#
|
3
|
+
# Table name: shipment_notes
|
4
|
+
#
|
5
|
+
# id :integer not null, primary key
|
6
|
+
# shipment_id :integer not null
|
7
|
+
# note_type :string(255)
|
8
|
+
# note :string(255)
|
9
|
+
# shipment_status_history_id :integer
|
10
|
+
# created_at :datetime
|
11
|
+
# updated_at :datetime
|
12
|
+
#
|
13
|
+
|
14
|
+
class ShipmentNoteDAO < ActiveRecord::Base
|
15
|
+
self.table_name = "shipment_notes"
|
16
|
+
|
17
|
+
belongs_to :shipment_status_history, :class_name => "ShipmentStatusHistoryDAO" , :foreign_key => :shipment_status_history_id
|
18
|
+
belongs_to :shipment, :class_name => "ShipmentDAO", :foreign_key => :shipment_id
|
19
|
+
|
20
|
+
validates_presence_of :shipment_id
|
21
|
+
validates_presence_of :note
|
22
|
+
validates_presence_of :shipment_status_history_id
|
23
|
+
validates_presence_of :note_type
|
24
|
+
|
25
|
+
def self.matching_shipment_id(shipment_id)
|
26
|
+
ShipmentNoteDAO.find_by_shipment_id(shipment_id)
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.by_type(type)
|
30
|
+
ShipmentNoteDAO.where(:note_type => type)
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.by_types(types)
|
34
|
+
ShipmentNoteDAO.where("note_type IN (#{types.map{|type| "'#{type}'"}.join(',')})")
|
35
|
+
end
|
36
|
+
|
37
|
+
module Types
|
38
|
+
VENDOR = "vendor"
|
39
|
+
MERCHANT = "merchant"
|
40
|
+
CS = "cs"
|
41
|
+
FKL = "fkl"
|
42
|
+
PL = "Pickup_Reattempt_Reason"
|
43
|
+
LOCATION = "vendor_location"
|
44
|
+
ALL = [VENDOR,MERCHANT,CS,FKL]
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# == Schema Information
|
2
|
+
#
|
3
|
+
# Table name: shipment_returnSeller_mappings
|
4
|
+
#
|
5
|
+
# id :integer not null, primary key
|
6
|
+
# shipment_id :integer not null
|
7
|
+
# seller_id :integer not null
|
8
|
+
# created_at :datetime
|
9
|
+
# updated_at :datetime
|
10
|
+
#
|
11
|
+
|
12
|
+
class ShipmentReturnSellerMappingsDAO < ActiveRecord::Base
|
13
|
+
|
14
|
+
self.table_name = "shipment_return_seller_mappings"
|
15
|
+
|
16
|
+
validates_presence_of :shipment_id
|
17
|
+
validates_presence_of :return_seller_id
|
18
|
+
|
19
|
+
belongs_to :shipment, :class_name => 'ShipmentDAO', :foreign_key => :shipment_id
|
20
|
+
belongs_to :return_seller, :class_name => 'ReturnSellerDAO', :foreign_key => :return_seller_id
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# == Schema Information
|
2
|
+
#
|
3
|
+
# Table name: shipment_scan_audits
|
4
|
+
#
|
5
|
+
# id :integer not null, primary key
|
6
|
+
# shipment_id :string(255) not null
|
7
|
+
# scanning_type :string(255)
|
8
|
+
# station_id :integer
|
9
|
+
# status :string(255)
|
10
|
+
# remark :string(255)
|
11
|
+
# username :string(255)
|
12
|
+
# created_at :datetime
|
13
|
+
# updated_at :datetime
|
14
|
+
#
|
15
|
+
|
16
|
+
class ShipmentScanAuditDAO < ActiveRecord::Base
|
17
|
+
|
18
|
+
self.table_name = "shipment_scan_audits"
|
19
|
+
|
20
|
+
belongs_to :shipment
|
21
|
+
validates_presence_of :shipment_id
|
22
|
+
validates_presence_of :scanning_type
|
23
|
+
validates_presence_of :status
|
24
|
+
|
25
|
+
scope :inscan_audit, where(:scanning_type => "inscan")
|
26
|
+
scope :outscan_audit, where(:scanning_type => "outscan")
|
27
|
+
scope :recent, lambda { where("created_at > now() - interval 1 day") }
|
28
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# == Schema Information
|
2
|
+
#
|
3
|
+
# Table name: shipment_seller_mappings
|
4
|
+
#
|
5
|
+
# id :integer not null, primary key
|
6
|
+
# shipment_id :integer not null
|
7
|
+
# seller_id :integer not null
|
8
|
+
# created_at :datetime
|
9
|
+
# updated_at :datetime
|
10
|
+
#
|
11
|
+
|
12
|
+
class ShipmentSellerMappingDAO < ActiveRecord::Base
|
13
|
+
|
14
|
+
self.table_name = "shipment_seller_mappings"
|
15
|
+
|
16
|
+
validates_presence_of :shipment_id
|
17
|
+
validates_presence_of :seller_id
|
18
|
+
|
19
|
+
belongs_to :shipment, :class_name => 'ShipmentDAO' , :foreign_key => :shipment_id
|
20
|
+
belongs_to :seller, :class_name => 'SellerDAO' , :foreign_key => :seller_id
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# == Schema Information
|
2
|
+
#
|
3
|
+
# Table name: shipment_status_histories
|
4
|
+
#
|
5
|
+
# id :integer not null, primary key
|
6
|
+
# shipment_id :integer not null
|
7
|
+
# old_status :string(255)
|
8
|
+
# location :string(255)
|
9
|
+
# remarks :string(255)
|
10
|
+
# created_at :datetime
|
11
|
+
# updated_at :datetime
|
12
|
+
# new_status :string(255)
|
13
|
+
# status_type :string(255)
|
14
|
+
# status_date :datetime
|
15
|
+
# updated_by :string(255)
|
16
|
+
#
|
17
|
+
|
18
|
+
class ShipmentStatusHistoryDAO < ActiveRecord::Base
|
19
|
+
self.table_name = "shipment_status_histories"
|
20
|
+
|
21
|
+
belongs_to :shipment, :class_name => 'ShipmentDAO', :foreign_key => :shipment_id
|
22
|
+
#validates_presence_of :old_status
|
23
|
+
validates_presence_of :new_status
|
24
|
+
validates_presence_of :status_type
|
25
|
+
validates_presence_of :status_date
|
26
|
+
has_many :shipment_notes, :class_name => 'ShipmentNoteDAO'
|
27
|
+
|
28
|
+
scope :shipment_histories, where(:status_type => "SHIPMENT")
|
29
|
+
scope :rto_histories, where(:status_type => "RTO")
|
30
|
+
scope :rvp_histories, where(:status_type => "RVP")
|
31
|
+
|
32
|
+
module StatusTypes
|
33
|
+
SHIPMENT = "SHIPMENT"
|
34
|
+
RTO = "RTO"
|
35
|
+
RVP = "RVP"
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.build_shipment_status_history_object(old_status,new_status,location,remarks,status_date=Time.now)
|
39
|
+
facility_display_name = Fkl::Client::LogisticsClient.get_facility_from_name(location).try(:display_name) if location.present?
|
40
|
+
ShipmentStatusHistoryDAO.new(:old_status => old_status,:new_status => new_status, :location => facility_display_name, :remarks => remarks, :status_type => StatusTypes::SHIPMENT, :status_date => status_date || Time.now)
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
def self.from_date(from_date)
|
45
|
+
from_date = DateTime.parse(from_date).strftime("%Y-%m-%d %H:%M:%S") if from_date
|
46
|
+
from_date ? where("shipment_status_histories.status_date >= '#{from_date}'") : ShipmentStatusHistoryDAO.scoped
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.to_date(to_date)
|
50
|
+
to_date = DateTime.parse(to_date).strftime("%Y-%m-%d %H:%M:%S") if to_date
|
51
|
+
to_date ? where("shipment_status_histories.status_date < '#{to_date}' + interval 1 day") : ShipmentStatusHistoryDAO.scoped
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|