solidus_tec_estimator 1.0.2 → 1.0.3
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: 7b79cba56f610c4413e114eade5575811b3d9807c4f4b41f7dc2b61beae3419b
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: bd67403d4b0b66386773eb4c101fb5ef2c0b95215bfcd0e67c081cc435ec2e84
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: a1b7a5c830056dcd7dc828e7d2c85efa6271b913654ed590400d5735bff145a20402bacbf1a93de462f4dcec3a7bb9e87370c319278bf943879002d2202fedc8
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 8d365668eb83ed8d7a0836f6d706ea4b14ecde1ea933afe74b43489b319c74d527288813ef424bcd1eeceb025daf64e901085672ac332e763f9c3dff39044076
         
     | 
| 
         @@ -14,7 +14,7 @@ module SolidusTecEstimator 
     | 
|
| 
       14 
14 
     | 
    
         
             
                    end
         
     | 
| 
       15 
15 
     | 
    
         
             
                  end.compact
         
     | 
| 
       16 
16 
     | 
    
         
             
                  rates += providers(package).map do |provider|
         
     | 
| 
       17 
     | 
    
         
            -
                    provider_shipping_methods = provider.spree_shipping_methods 
     | 
| 
      
 17 
     | 
    
         
            +
                    provider_shipping_methods = remove_unavailable_methods(shipping_methods: provider.spree_shipping_methods, package: package)
         
     | 
| 
       18 
18 
     | 
    
         
             
                    provider.class_name.constantize.new(package, provider_shipping_methods).shipping_rates
         
     | 
| 
       19 
19 
     | 
    
         
             
                  end.flatten.compact
         
     | 
| 
       20 
20 
     | 
    
         | 
| 
         @@ -32,10 +32,8 @@ module SolidusTecEstimator 
     | 
|
| 
       32 
32 
     | 
    
         
             
                end
         
     | 
| 
       33 
33 
     | 
    
         | 
| 
       34 
34 
     | 
    
         
             
                def shipping_methods(package)
         
     | 
| 
       35 
     | 
    
         
            -
                  package.shipping_methods
         
     | 
| 
       36 
     | 
    
         
            -
                    . 
     | 
| 
       37 
     | 
    
         
            -
                    .available_for_address(package.shipment.order.ship_address)
         
     | 
| 
       38 
     | 
    
         
            -
                    .where(available_to_users: true)
         
     | 
| 
      
 35 
     | 
    
         
            +
                  remove_unavailable_methods(shipping_methods: package.shipping_methods, package: package)
         
     | 
| 
      
 36 
     | 
    
         
            +
                    .where(provider_id: nil)
         
     | 
| 
       39 
37 
     | 
    
         
             
                    .includes(:calculator)
         
     | 
| 
       40 
38 
     | 
    
         
             
                    .to_a.select do |ship_method|
         
     | 
| 
       41 
39 
     | 
    
         
             
                      calculator = ship_method.calculator
         
     | 
| 
         @@ -47,5 +45,12 @@ module SolidusTecEstimator 
     | 
|
| 
       47 
45 
     | 
    
         
             
                  SolidusTecEstimator::Provider.where(active: true)
         
     | 
| 
       48 
46 
     | 
    
         
             
                end
         
     | 
| 
       49 
47 
     | 
    
         | 
| 
      
 48 
     | 
    
         
            +
                def remove_unavailable_methods shipping_methods:, package:
         
     | 
| 
      
 49 
     | 
    
         
            +
                  shipping_methods.available_to_store(package.shipment.order.store)
         
     | 
| 
      
 50 
     | 
    
         
            +
                  .available_in_stock_location(package.stock_location)
         
     | 
| 
      
 51 
     | 
    
         
            +
                  .available_for_address(package.shipment.order.ship_address)
         
     | 
| 
      
 52 
     | 
    
         
            +
                  .where(available_to_users: true)
         
     | 
| 
      
 53 
     | 
    
         
            +
                end
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
       50 
55 
     | 
    
         
             
              end
         
     | 
| 
       51 
56 
     | 
    
         
             
            end
         
     | 
| 
         @@ -8,6 +8,18 @@ module SolidusTecEstimator 
     | 
|
| 
       8 
8 
     | 
    
         
             
                    @shipping_methods = shipping_methods
         
     | 
| 
       9 
9 
     | 
    
         
             
                  end
         
     | 
| 
       10 
10 
     | 
    
         | 
| 
      
 11 
     | 
    
         
            +
                  def self.install
         
     | 
| 
      
 12 
     | 
    
         
            +
                    Spree::ShippingMethod.find_or_create_by(code: self.name.underscore) do |shipping_method|
         
     | 
| 
      
 13 
     | 
    
         
            +
                      shipping_method.name = "Entrega de moto"
         
     | 
| 
      
 14 
     | 
    
         
            +
                      shipping_method.carrier = "Entrega local"
         
     | 
| 
      
 15 
     | 
    
         
            +
                      shipping_method.code = self.name.underscore
         
     | 
| 
      
 16 
     | 
    
         
            +
                      shipping_method.calculator = Spree::Calculator::Shipping::FlatRate.create
         
     | 
| 
      
 17 
     | 
    
         
            +
                      shipping_method.shipping_categories = [Spree::ShippingCategory.first]
         
     | 
| 
      
 18 
     | 
    
         
            +
                      shipping_method.available_to_users = false
         
     | 
| 
      
 19 
     | 
    
         
            +
                      shipping_method.provider_id = SolidusTecEstimator::Provider.find_by(class_name: self.to_s).id
         
     | 
| 
      
 20 
     | 
    
         
            +
                    end
         
     | 
| 
      
 21 
     | 
    
         
            +
                  end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
       11 
23 
     | 
    
         
             
                  def shipping_rates
         
     | 
| 
       12 
24 
     | 
    
         
             
                    shipping_rates = []
         
     | 
| 
       13 
25 
     | 
    
         
             
                    if ship_address_city == "São João da Boa Vista" && tem_estoque_na_f1? && package.weight <= 10000
         
     | 
| 
         @@ -27,16 +39,7 @@ module SolidusTecEstimator 
     | 
|
| 
       27 
39 
     | 
    
         
             
                  end
         
     | 
| 
       28 
40 
     | 
    
         | 
| 
       29 
41 
     | 
    
         
             
                  def build_shipping_rate(package)
         
     | 
| 
       30 
     | 
    
         
            -
                    shipping_method = Spree::ShippingMethod. 
     | 
| 
       31 
     | 
    
         
            -
                      carrier: "Entrega local",
         
     | 
| 
       32 
     | 
    
         
            -
                      service_level: ""
         
     | 
| 
       33 
     | 
    
         
            -
                    ) do |shipping_method|
         
     | 
| 
       34 
     | 
    
         
            -
                      shipping_method.name = "Entrega de moto"
         
     | 
| 
       35 
     | 
    
         
            -
                      shipping_method.calculator = Spree::Calculator::Shipping::FlatRate.create
         
     | 
| 
       36 
     | 
    
         
            -
                      shipping_method.shipping_categories = Spree::ShippingCategory.all
         
     | 
| 
       37 
     | 
    
         
            -
                      shipping_method.available_to_users = true
         
     | 
| 
       38 
     | 
    
         
            -
                      shipping_method.provider_id = SolidusTecEstimator::Provider.find_by(class_name: self.class.to_s).id
         
     | 
| 
       39 
     | 
    
         
            -
                    end
         
     | 
| 
      
 42 
     | 
    
         
            +
                    shipping_method = Spree::ShippingMethod.find_by(code: self.class.to_s.underscore)
         
     | 
| 
       40 
43 
     | 
    
         | 
| 
       41 
44 
     | 
    
         
             
                    time_now = Time.now.in_time_zone('America/Sao_Paulo')
         
     | 
| 
       42 
45 
     | 
    
         
             
                    if time_now < time_now.change({hour: 16}) && time_now.on_weekday?
         
     | 
    
        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: 1.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.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- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2024-09-11 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: solidus_core
         
     |