valken-shipping 2.0.4 → 2.0.9

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: de87f21281f76ad4ff9f00e829c028e2e1ba1f4813c821d89664f11024725171
4
- data.tar.gz: 98658fd8e5aef01ad8f763751cb577ee5ca2fd94818605926a49713dce77be23
3
+ metadata.gz: dc10c599481dc98cee8685adb0b8b321b27e49461965605af4f5b326fdbe73d5
4
+ data.tar.gz: 8841aaf757d728ca2eb93845fb8e38bf95f9a5e7fbf8c848850997fce824fb4e
5
5
  SHA512:
6
- metadata.gz: 7c6dd426e9a1631da60b4c1acd121ac0ace51837c7e94c5bf06e18a8698c7a8b0cdbc113c7f28962cd8b65f9922e388fc5ff3db6a17f4e49fd31c325bf8ce0ed
7
- data.tar.gz: 6c7fa9cd69747eb934f40231ebc829aea8a0c0d60705c5bb172f9d5296bc3ede35a2c2c490a3a88adf6853de0edb5957f537b968c7d12ede5c6f8ec0f9288c9b
6
+ metadata.gz: 601e1c833f65e3dc73746c42ec82794c132bb15af5bcdf9ec78dd5dae7e3004d102625943202f127fa19b6a35d94626d6c5f95d272396bd1fe28db488b59cb4c
7
+ data.tar.gz: 6796e2e1c7c0a16d6097908c0b1619cd76c055af403d4adbc356033bc5f84b577aeb289792a1f11aa8b4a537f5bed925cbd88ade4fe997be306fb441e326fdd4
@@ -1,7 +1,6 @@
1
1
  module Workarea
2
2
  module AddressesHelper
3
3
  def country_options
4
- return [[Country['US'].name, Country['US'].alpha2]] if is_usa_only?
5
4
  Workarea.config.countries.map do |country|
6
5
  [country.name, country.alpha2]
7
6
  end
@@ -13,7 +12,14 @@ module Workarea
13
12
  .map { |id, region| [region.translations[I18n.locale.to_s] || region.name, id] }
14
13
  .sort_by { |name, id| name || id }
15
14
 
16
- memo << [country.name, regions]
15
+ if country.name == "United States of America"
16
+ region = regions.reject do |state|
17
+ Workarea.config.shipping_state_exclude.include?(state.last)
18
+ end
19
+ memo << [country.name, region]
20
+ else
21
+ memo << [country.name, regions]
22
+ end
17
23
  memo
18
24
  end
19
25
  end
@@ -41,7 +47,6 @@ module Workarea
41
47
  postalcode: address.postal_code,
42
48
  country: address.country.alpha2
43
49
  }
44
-
45
50
  address_format = address.country.address_format || Country['US'].address_format
46
51
  result = pieces.reduce(address_format) do |memo, (name, value)|
47
52
  memo.gsub(/{{#{name}}}/, html_escape(value.to_s))
@@ -41,6 +41,10 @@ module Workarea
41
41
 
42
42
  return default_options(packaging.packages) if Workarea.config.gateways.ups_carrier.class == ActiveShipping::Workarea
43
43
 
44
+ if is_special_region?
45
+ return [get_shipping_for_special_region]
46
+ end
47
+
44
48
  shipping_options_api = get_final_shipping_options(collect_carrier_data)
45
49
  return [] if @error.present?
46
50
 
@@ -81,9 +85,10 @@ module Workarea
81
85
  # If the carrier is ups then it will print ups data...or if carrier is fedex then prinnt fedex data...
82
86
  # else if it is not both then choose cheapest price.
83
87
  def collect_carrier_data
84
- return get_ups_data if is_ups
85
- return get_fedex_data if is_fedex
86
- return get_none_data unless is_ups && is_fedex
88
+ return get_ups_data
89
+ # Temporarily disabling fedex and cheaper
90
+ # return get_fedex_data if is_fedex
91
+ # return get_none_data unless is_ups && is_fedex
87
92
  end
88
93
 
89
94
  # UPS data.
@@ -150,6 +155,30 @@ module Workarea
150
155
  )
151
156
  end
152
157
 
158
+ def get_shipping_for_special_region
159
+ puts "weight_convertion",weight_convertion
160
+ weight_price = 0
161
+ case weight_convertion
162
+ when 0..15
163
+ weight_price = 50
164
+ when 15..200
165
+ weight_price = (1 * weight_convertion)
166
+ when 200..2500
167
+ weight_price = 200
168
+ else
169
+ weight_price = ((weight_convertion / 2500).ceil()) * 200
170
+ end
171
+
172
+ ShippingOption.new(
173
+ carrier: "LTL Shipping",
174
+ name: "Valken Standard",
175
+ sub_name: "3 - 5 Business Days",
176
+ service_code: "LTL01",
177
+ price: Money.new(weight_price * 100, "USD"),
178
+ tax_code: "TAX01"
179
+ )
180
+ end
181
+
153
182
  # Returns the total weight.
154
183
  def weight_convertion
155
184
  packaging = Packaging.new(order, shipping)
@@ -252,7 +281,11 @@ module Workarea
252
281
  product_carrier_type = product_details.map{ |item| item[:en][ground_ship_attribute] }.flatten
253
282
  product_carrier_type.include?("true")
254
283
  end
255
-
284
+
285
+ def is_special_region?
286
+ Workarea.config.special_region.include?(@shipping.address.region)
287
+ end
288
+
256
289
  def product_details
257
290
  # product_attributes = @order.items.map(&:product_attributes)
258
291
 
@@ -8,5 +8,10 @@ Workarea::Configuration.define_fields do
8
8
  'ground_shipping_only' => 'ground shipping only'
9
9
  },
10
10
  description: 'Mapping of product details keys with shipping logic. Note: This maps only the keys not the values.'
11
+
12
+ field 'Shipping State Exclude',
13
+ type: :array,
14
+ default: ["AK", "HI", "PR"],
15
+ description: 'Shipping Excluded States'
11
16
  end
12
17
  end
@@ -1,4 +1,7 @@
1
1
  Workarea.configure do |config|
2
+
3
+ config.countries = [Country['US']]
4
+
2
5
  ActiveShipping::Carriers.register :UPS, 'active_shipping/carriers/ups'
3
6
 
4
7
  config.weight_table = {"2": 5, "15": 15, "200": 1, "2500": 200}
@@ -1,5 +1,5 @@
1
1
  module Valken
2
2
  module Shipping
3
- VERSION = '2.0.4'
3
+ VERSION = '2.0.9'
4
4
  end
5
5
  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: 2.0.4
4
+ version: 2.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - sushmitha02
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-11 00:00:00.000000000 Z
11
+ date: 2020-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -72,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
72
72
  - !ruby/object:Gem::Version
73
73
  version: '0'
74
74
  requirements: []
75
- rubygems_version: 3.0.8
75
+ rubygems_version: 3.0.6
76
76
  signing_key:
77
77
  specification_version: 4
78
78
  summary: shipping options