valken-shipping 1.1.2 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 836864919e7e6f3dcb1762f14ea620afd0c56429040ad133fa7b01bf032cc6a3
|
4
|
+
data.tar.gz: 1f0addf9f86025e5f59232cbce1cdefd9dd7b56709969823264c3e50578251b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 465f4ab7305bc7c8efa1e8de744ff6a058f05f0afe389d91e8a0f79a126d12c9a2ba5109869fc39bdda63a4027c78742f6711c37a8e7aa57b2c283735ce4b9c6
|
7
|
+
data.tar.gz: ba70cb673db53d2c44ec47ffec89785538e9fbe1e78acca8599bcecf7d0233ca1849f979c811b17348631918a953e6f6f3ab34595eb35cda55aa43506c479c37
|
@@ -150,36 +150,34 @@ module Workarea
|
|
150
150
|
end
|
151
151
|
end
|
152
152
|
|
153
|
-
#
|
153
|
+
# Sort rates by delevry date and pick 1st three rates
|
154
|
+
# Find cheapest rate for those three rates
|
154
155
|
# Push all the cheap option for 1, 2, & 3 days into an array and return
|
155
156
|
def filter_shipping_rates(rates, service_code)
|
156
157
|
filtered_rates = []
|
157
158
|
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
159
|
+
# find and sort all delivery dates and pick 1st three
|
160
|
+
all_delivery_dates = rates.map { |rate| rate.delivery_date }
|
161
|
+
uniq_delivery_dates = all_delivery_dates.compact.sort.uniq[0..2]
|
162
|
+
|
163
|
+
# For each delivery dates, find cheapest rates and create shipping option and push
|
164
|
+
uniq_delivery_dates.each_with_index do |date, index|
|
165
|
+
selected_rates = rates.select {|rate| rate.delivery_date.present? && rate.delivery_date == date}
|
166
|
+
cheap_rate = selected_rates.sort_by(&:price).first
|
167
|
+
description = "#{cheap_rate.delivery_date.strftime('%a, %d %b %Y')}"
|
168
|
+
shipping_option = create_shipping_options(cheap_rate, service_code[index], description)
|
169
|
+
filtered_rates.push(shipping_option)
|
170
|
+
end
|
166
171
|
filtered_rates
|
167
172
|
end
|
168
173
|
|
169
|
-
# Select all rates based on deliver date and given date
|
170
|
-
# Find cheapest rate from selected rates
|
171
|
-
# Create shipping option for cheatest rate
|
172
|
-
def get_cheapest_option(rates, date, label)
|
173
|
-
selected_rates = rates.select { |item| item.delivery_date == date }
|
174
|
-
cheap_option = create_shipping_options(selected_rates.sort_by(&:price).first, label) if selected_rates.length > 0
|
175
|
-
end
|
176
|
-
|
177
174
|
# creating a ShippingOption
|
178
|
-
def create_shipping_options(rate, rate_label = nil)
|
175
|
+
def create_shipping_options(rate, rate_label = nil, description = nil)
|
179
176
|
ShippingOption.new(
|
180
177
|
carrier: rate.carrier,
|
181
178
|
name: rate_label || rate.service_name,
|
182
179
|
service_code: rate.service_code,
|
180
|
+
description: description,
|
183
181
|
price: Money.new(rate.price, rate.currency),
|
184
182
|
tax_code: Shipping::Service.find_tax_code(
|
185
183
|
rate.carrier,
|
@@ -3,11 +3,12 @@ Workarea.configure do |config|
|
|
3
3
|
|
4
4
|
config.weight_table = {"2": 5, "15": 15, "200": 1, "2500": 200}
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
|
7
|
+
config.shipping_rates = [
|
8
|
+
"Overnight",
|
9
|
+
"2 Day",
|
10
|
+
"3 Day"
|
11
|
+
]
|
11
12
|
config.ups_options = {"12"=> "3 Day", "01"=> "Overnight", "02"=> "2 Day"}
|
12
13
|
config.fedex_options = {"STANDARD_OVERNIGHT"=> "Overnight", "FEDEX_2_DAY"=> "2 Day", "GROUND_HOME_DELIVERY"=> "3 Day"}
|
13
14
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: valken-shipping
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sushmitha02
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-08-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -43,6 +43,7 @@ files:
|
|
43
43
|
- app/assets/config/valken_shipping_manifest.js
|
44
44
|
- app/models/workarea/checkout/shipping_options.decorator
|
45
45
|
- app/models/workarea/shipping.decorator
|
46
|
+
- app/models/workarea/shipping_option.decorator
|
46
47
|
- app/services/workarea/packaging.decorator
|
47
48
|
- config/initializers/workarea.rb
|
48
49
|
- config/routes.rb
|