solidus_tec_estimator 2.1.0 → 2.1.1
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 01f391cb4bb52df6f01250564d8982d2b58f646236d1a2dabe6e90558f27b285
|
4
|
+
data.tar.gz: 993c715f555ae3de46a8ff9272c8ea40398511a6acea331cb4b6ea92f4660753
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7256f7b0993700d345240c197a0b57d39ffc99dbbb3f001d324cb8de081971b1e7de2d202270129cbc37f67a01b6d5a0f77d358fb9621d62d437c5ac0a77ea93
|
7
|
+
data.tar.gz: 82650da43a3a7041cd722a2a53e9a4dfdb6e1dc7139a30d2792f23d37496acefa6cecc9a18fd955a1fbb083ce75d92a2e0ba43e8fcfb0a530a24aa49555905f6
|
@@ -1,8 +1,6 @@
|
|
1
1
|
module SolidusTecEstimator
|
2
2
|
class Estimator
|
3
|
-
|
4
3
|
def shipping_rates(package, _frontend_only = true)
|
5
|
-
|
6
4
|
rates = shipping_methods(package).map do |shipping_method|
|
7
5
|
cost = shipping_method.calculator.compute(package)
|
8
6
|
if cost
|
@@ -47,10 +45,9 @@ module SolidusTecEstimator
|
|
47
45
|
|
48
46
|
def remove_unavailable_methods shipping_methods:, package:
|
49
47
|
shipping_methods.available_to_store(package.shipment.order.store)
|
50
|
-
|
51
|
-
|
52
|
-
|
48
|
+
.available_in_stock_location(package.stock_location)
|
49
|
+
.available_for_address(package.shipment.order.ship_address)
|
50
|
+
.where(available_to_users: true)
|
53
51
|
end
|
54
|
-
|
55
52
|
end
|
56
53
|
end
|
@@ -1,35 +1,35 @@
|
|
1
1
|
module SolidusTecEstimator
|
2
2
|
module Providers
|
3
3
|
class LocalDelivery
|
4
|
-
|
5
4
|
attr_accessor :package, :shipping_methods
|
5
|
+
|
6
6
|
def initialize package, shipping_methods
|
7
7
|
@package = package
|
8
8
|
@shipping_methods = shipping_methods
|
9
9
|
end
|
10
10
|
|
11
11
|
def self.install
|
12
|
-
Spree::ShippingMethod.find_or_create_by(code:
|
12
|
+
Spree::ShippingMethod.find_or_create_by(code: name.underscore) do |shipping_method|
|
13
13
|
shipping_method.name = "Entrega de moto"
|
14
14
|
shipping_method.carrier = "Entrega local"
|
15
|
-
shipping_method.code =
|
15
|
+
shipping_method.code = name.underscore
|
16
16
|
shipping_method.calculator = Spree::Calculator::Shipping::FlatRate.create
|
17
17
|
shipping_method.shipping_categories = [Spree::ShippingCategory.first]
|
18
18
|
shipping_method.available_to_users = false
|
19
|
-
shipping_method.provider_id = SolidusTecEstimator::Provider.find_by(class_name:
|
19
|
+
shipping_method.provider_id = SolidusTecEstimator::Provider.find_by(class_name: to_s).id
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
23
|
def shipping_rates
|
24
24
|
shipping_rates = []
|
25
|
-
if cep_de_sjbv? && tem_estoque_na_f1? && package.weight <=
|
25
|
+
if cep_de_sjbv? && tem_estoque_na_f1? && package.weight <= 40_000
|
26
26
|
shipping_rates << build_shipping_rate(package)
|
27
27
|
end
|
28
28
|
shipping_rates.select { |rate| shipping_methods.include?(rate.shipping_method) }
|
29
29
|
end
|
30
30
|
|
31
31
|
def tem_estoque_na_f1?
|
32
|
-
package_quantity = package.contents.map {|c| c.inventory_unit.variant_id }.tally
|
32
|
+
package_quantity = package.contents.map { |c| c.inventory_unit.variant_id }.tally
|
33
33
|
variants = package.contents.map(&:variant)
|
34
34
|
variants.all? do |variant|
|
35
35
|
product_stock = ProductStock.find_by(sku: variant.sku.strip)
|
@@ -41,7 +41,7 @@ module SolidusTecEstimator
|
|
41
41
|
def build_shipping_rate(package)
|
42
42
|
shipping_method = Spree::ShippingMethod.find_by(code: self.class.to_s.underscore)
|
43
43
|
|
44
|
-
time_now = Time.now.in_time_zone(
|
44
|
+
time_now = Time.now.in_time_zone("America/Sao_Paulo")
|
45
45
|
if time_now < time_now.change({hour: 16}) && time_now.on_weekday?
|
46
46
|
min_delivery_time = (time_now + 30.minutes)
|
47
47
|
max_delivery_time = (time_now + 2.hours)
|
@@ -80,7 +80,6 @@ module SolidusTecEstimator
|
|
80
80
|
"Chegará em #{ActionController::Base.helpers.pluralize((delivery_time.to_datetime.end_of_day - DateTime.now).to_i, "dia", plural: "dias")}"
|
81
81
|
end
|
82
82
|
end
|
83
|
-
|
84
83
|
end
|
85
84
|
end
|
86
85
|
end
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solidus_tec_estimator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ulysses
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-06-20 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: solidus_brazilian_adaptations
|
@@ -52,7 +51,6 @@ homepage: https://github.com/todasessascoisas/solidus_tec_estimator#readme
|
|
52
51
|
licenses:
|
53
52
|
- BSD-3-Clause
|
54
53
|
metadata: {}
|
55
|
-
post_install_message:
|
56
54
|
rdoc_options: []
|
57
55
|
require_paths:
|
58
56
|
- lib
|
@@ -67,8 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
67
65
|
- !ruby/object:Gem::Version
|
68
66
|
version: '0'
|
69
67
|
requirements: []
|
70
|
-
rubygems_version: 3.
|
71
|
-
signing_key:
|
68
|
+
rubygems_version: 3.6.2
|
72
69
|
specification_version: 4
|
73
70
|
summary: ''
|
74
71
|
test_files: []
|