solidus_tec_estimator 0.0.1 → 0.0.2

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: 3b4e558e657b45c97df0640084d2a25a0e5ae9e67da800f738a26213924e10c5
4
+ data.tar.gz: cac274effc49b8da2fe3873544aa630206155daf27eb67913fd86c5dcbb85d4b
5
5
  SHA512:
6
- metadata.gz: 8c41adbb7bbf0f8df9ecca9eafe8b7160543445c47f6f0fadb359f55fd08239b7b8fbcc49e9e4f042ddbd161c212063e1e474e383a728ce4b138c2f8b92d010c
7
- data.tar.gz: 68ac4b5ac09c7b77b989736d45e32732d229e366d7f04016d4f1aa23b18e61b4a04371058134a83aae75455cf82edfa34cc53c761a37cd3dbe72f69b64e01526
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
- 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.2'
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.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-09 00:00:00.000000000 Z
11
+ date: 2024-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: solidus_core