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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8075ac792c8dac51fa3711d40d07c0fc2fb0e3b5ff02897175cfe9cc73e6f5f9
4
- data.tar.gz: a226fea6c4785db4fb17d4fd37e77e1fa3e47e3fc516ed2f7b7481c4253cb5c4
3
+ metadata.gz: 7e767590fc01f411d98c20069d71a1ed850c8dd32682e59d8d3c33c1cc397179
4
+ data.tar.gz: 44d790f17cb9e358db130f4ce66b2dd4512144b5524fde2f743887a57fe1591d
5
5
  SHA512:
6
- metadata.gz: 8c41adbb7bbf0f8df9ecca9eafe8b7160543445c47f6f0fadb359f55fd08239b7b8fbcc49e9e4f042ddbd161c212063e1e474e383a728ce4b138c2f8b92d010c
7
- data.tar.gz: 68ac4b5ac09c7b77b989736d45e32732d229e366d7f04016d4f1aa23b18e61b4a04371058134a83aae75455cf82edfa34cc53c761a37cd3dbe72f69b64e01526
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
- Spree::Config.shipping_rate_sorter_class.new(rates).sort
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
@@ -1,5 +1,3 @@
1
1
  SolidusTecEstimator.configure do |config|
2
- config.min_delivery_time = 8
3
- config.max_delivery_time = 10
4
2
  config.providers_classes = ["SolidusTecEstimator::Providers::LocalDelivery"]
5
3
  end
@@ -1,6 +1,6 @@
1
1
  module SolidusTecEstimator
2
2
  class Configuration
3
- attr_accessor :min_delivery_time, :max_delivery_time, :providers_classes
3
+ attr_accessor :providers_classes
4
4
  end
5
5
 
6
6
  class << self
@@ -1,3 +1,3 @@
1
1
  module SolidusTecEstimator
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.3'
3
3
  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.1
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-09 00:00:00.000000000 Z
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