solidus_tec_estimator 0.0.1 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/solidus_tec_estimator/estimator.rb +3 -25
- data/app/models/solidus_tec_estimator/providers/local_delivery.rb +11 -0
- data/lib/generators/solidus_tec_estimator/install/templates/initializer.rb +0 -2
- data/lib/solidus_tec_estimator/configuration.rb +1 -1
- data/lib/solidus_tec_estimator/version.rb +1 -1
- metadata +2 -3
- data/app/models/solidus_tec_estimator/providers/planilha.rb +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e767590fc01f411d98c20069d71a1ed850c8dd32682e59d8d3c33c1cc397179
|
4
|
+
data.tar.gz: 44d790f17cb9e358db130f4ce66b2dd4512144b5524fde2f743887a57fe1591d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8bf77f7f25fd6af4032075c76b0e5370b00432555730a7ead5710070752f06a084782edbecdddd449b98a7dbe26d266c129c7bfb4debd23face30361fcb02ea
|
7
|
+
data.tar.gz: 252cd3f1e914d7e00fb954b30bd3dd4453f86eb756cd41ce4c5684b442d82db4a0d353e4f751fdcc5b7181f212f8251d97301d740e499caa05609eb3e728e4a3
|
@@ -8,9 +8,7 @@ module SolidusTecEstimator
|
|
8
8
|
if cost
|
9
9
|
rate = shipping_method.shipping_rates.new(
|
10
10
|
cost: cost,
|
11
|
-
shipment: package.shipment
|
12
|
-
min_delivery_time: DateTime.now + (SolidusTecEstimator.config.min_delivery_time || 8),
|
13
|
-
max_delivery_time: DateTime.now + (SolidusTecEstimator.config.max_delivery_time || 10)
|
11
|
+
shipment: package.shipment
|
14
12
|
)
|
15
13
|
rate
|
16
14
|
end
|
@@ -19,9 +17,9 @@ module SolidusTecEstimator
|
|
19
17
|
provider_shipping_methods = provider.spree_shipping_methods.available_in_stock_location(package.stock_location)
|
20
18
|
provider.class_name.constantize.new(package, provider_shipping_methods).shipping_rates
|
21
19
|
end.flatten.compact
|
22
|
-
|
20
|
+
|
23
21
|
choose_default_shipping_rate(rates)
|
24
|
-
|
22
|
+
rates
|
25
23
|
end
|
26
24
|
|
27
25
|
private
|
@@ -49,25 +47,5 @@ module SolidusTecEstimator
|
|
49
47
|
SolidusTecEstimator::Provider.where(active: true)
|
50
48
|
end
|
51
49
|
|
52
|
-
def build_default_shipping_rate package
|
53
|
-
shipping_method = Spree::ShippingMethod.find_or_create_by(
|
54
|
-
carrier: "Frete Padrão",
|
55
|
-
service_level: ""
|
56
|
-
) do |shipping_method|
|
57
|
-
shipping_method.name = "Frete Padrão"
|
58
|
-
shipping_method.calculator = Spree::Calculator::Shipping::FlatRate.create
|
59
|
-
shipping_method.shipping_categories = Spree::ShippingCategory.all
|
60
|
-
shipping_method.available_to_users = true
|
61
|
-
end
|
62
|
-
|
63
|
-
Spree::ShippingRate.new(
|
64
|
-
shipment: package.shipment,
|
65
|
-
shipping_method: shipping_method,
|
66
|
-
cost: 15.00,
|
67
|
-
min_delivery_time: 8,
|
68
|
-
max_delivery_time: 10
|
69
|
-
)
|
70
|
-
end
|
71
|
-
|
72
50
|
end
|
73
51
|
end
|
@@ -61,6 +61,17 @@ module SolidusTecEstimator
|
|
61
61
|
def ship_address_city
|
62
62
|
Cep.find_by(codigo_postal: package.order.last_zipcode).try(:localidade) || package.order.ship_address.city
|
63
63
|
end
|
64
|
+
|
65
|
+
def self.calculate_delivery_time rate
|
66
|
+
if rate.max_delivery_time.today?
|
67
|
+
"Chegará em até 2 horas"
|
68
|
+
elsif rate.max_delivery_time.tomorrow?
|
69
|
+
"Chegará amanhã até às 10h"
|
70
|
+
else
|
71
|
+
"Chegará em #{ActionController::Base.helpers.pluralize((rate.max_delivery_time.to_datetime.end_of_day - DateTime.now).to_i, "dia", plural: "dias")}"
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
64
75
|
end
|
65
76
|
end
|
66
77
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solidus_tec_estimator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ulysses
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-08-
|
11
|
+
date: 2024-08-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: solidus_core
|
@@ -79,7 +79,6 @@ files:
|
|
79
79
|
- app/models/solidus_tec_estimator/estimator.rb
|
80
80
|
- app/models/solidus_tec_estimator/provider.rb
|
81
81
|
- app/models/solidus_tec_estimator/providers/local_delivery.rb
|
82
|
-
- app/models/solidus_tec_estimator/providers/planilha.rb
|
83
82
|
- app/views/spree/admin/solidus_tec_estimator/providers/_form.html.erb
|
84
83
|
- app/views/spree/admin/solidus_tec_estimator/providers/edit.html.erb
|
85
84
|
- app/views/spree/admin/solidus_tec_estimator/providers/index.html.erb
|
File without changes
|