solidus_tec_estimator 0.0.1 → 0.0.2
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 +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 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b4e558e657b45c97df0640084d2a25a0e5ae9e67da800f738a26213924e10c5
|
4
|
+
data.tar.gz: cac274effc49b8da2fe3873544aa630206155daf27eb67913fd86c5dcbb85d4b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a6d0083c289e617b8ec8610c9854c9349befcc873b286faa3c8015ff34b9cfeb2e89fdb040de7cb69eae3b417c1669ab422d235bea2239ecec98109e642c505
|
7
|
+
data.tar.gz: 7108b6c7e62bca135f6a7a7f9360b7351ed7abfebbbbb2fc2f71c56a47dc354198fa8e7312a64bd098f925d85beaa5c7db630f090564b1560b40545c1eb12045
|
@@ -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.2
|
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-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: solidus_core
|