solidus_brazilian_adaptations 1.0.6 → 1.0.8

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: 24fa67771b38cee0a4d92caf9fdae494846fb87023ddfce3f3ed4077433661e7
4
- data.tar.gz: 2adf6fce94c6ebdc966e6ff986daf61462e92dc0576de84f47b8e4d2ac2f0e22
3
+ metadata.gz: fa340352bf3bdbd83004ac7e1586475c97b711dc885a1ff863e56217c635077c
4
+ data.tar.gz: c8380825a0d218d87b7627aaeb4cc16c2a0d3f06224794f2b42065849072d527
5
5
  SHA512:
6
- metadata.gz: 77d168c0c7ad3c0cb2993817009a04a8cece0c88d1a5abf9ed9536ad594d34ca709d9069e7b4fb131fdf30c536c8362fd9f0755a46e75b185cdc4b5db87e7320
7
- data.tar.gz: c37f09bace53817ef175c4758c199767726c466ef2399327bbf24b7275fe3526b90d8869bb28827f58d448813b39843140cb9cfa3f025b8ce5cd4c33405984a8
6
+ metadata.gz: 664b659cc65a2681ccc34177e1eeecb049384cdd1bc5bd95103a252700c0e894b33461d5ebc144a8551c4c2e17444f18aab19ae23331f8b2910541205d785c4b
7
+ data.tar.gz: 95579b93f2e3ca2beec1d5e51aed4cec713a52080ae30a7a36203107fc4a155761a4a1aa31c238445c4dd97e236f8c6d557f59d1ca15747979f21192aea01dde
data/Gemfile CHANGED
@@ -1,42 +1,41 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- source 'https://rubygems.org'
3
+ source "https://rubygems.org"
4
4
  git_source(:github) { |repo| "https://github.com/#{repo}.git" }
5
5
 
6
- branch = ENV.fetch('SOLIDUS_BRANCH', 'main')
7
- gem 'solidus', github: 'solidusio/solidus', branch: branch
6
+ branch = ENV.fetch("SOLIDUS_BRANCH", "main")
7
+ gem "solidus", github: "solidusio/solidus", branch: branch
8
8
 
9
9
  # The solidus_frontend gem has been pulled out since v3.2
10
- if branch >= 'v3.2'
11
- gem 'solidus_frontend'
12
- elsif branch == 'main'
13
- gem 'solidus_frontend', github: 'solidusio/solidus_frontend'
10
+ if branch >= "v3.2"
11
+ gem "solidus_frontend"
12
+ elsif branch == "main"
13
+ gem "solidus_frontend", github: "solidusio/solidus_frontend"
14
14
  else
15
- gem 'solidus_frontend', github: 'solidusio/solidus', branch: branch
15
+ gem "solidus_frontend", github: "solidusio/solidus", branch: branch
16
16
  end
17
17
 
18
18
  # Needed to help Bundler figure out how to resolve dependencies,
19
19
  # otherwise it takes forever to resolve them.
20
20
  # See https://github.com/bundler/bundler/issues/6677
21
- gem 'rails', '>0.a'
22
-
21
+ gem "rails", ">0.a"
23
22
 
24
23
  # Provides basic authentication functionality for testing parts of your engine
25
- gem 'solidus_auth_devise'
24
+ gem "solidus_auth_devise"
26
25
 
27
- case ENV.fetch('DB', nil)
28
- when 'mysql'
29
- gem 'mysql2'
30
- when 'postgresql'
31
- gem 'pg'
26
+ case ENV.fetch("DB", nil)
27
+ when "mysql"
28
+ gem "mysql2"
29
+ when "postgresql"
30
+ gem "pg"
32
31
  else
33
- gem 'sqlite3'
32
+ gem "sqlite3"
34
33
  end
35
34
 
36
35
  # While we still support Ruby < 3 we need to workaround a limitation in
37
36
  # the 'async' gem that relies on the latest ruby, since RubyGems doesn't
38
37
  # resolve gems based on the required ruby version.
39
- gem 'async', '< 3' if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3')
38
+ gem "async", "< 3" if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("3")
40
39
 
41
40
  gemspec
42
41
 
@@ -45,4 +44,4 @@ gemspec
45
44
  #
46
45
  # We use `send` instead of calling `eval_gemfile` to work around an issue with
47
46
  # how Dependabot parses projects: https://github.com/dependabot/dependabot-core/issues/1658.
48
- send(:eval_gemfile, 'Gemfile-local') if File.exist? 'Gemfile-local'
47
+ send(:eval_gemfile, "Gemfile-local") if File.exist? "Gemfile-local"
data/README.md CHANGED
@@ -21,6 +21,25 @@ bin/rails generate solidus_brazilian_adaptations:install
21
21
 
22
22
  ## Usage
23
23
 
24
+ ### Tradução e moeda padrão
25
+ Editar `config/initializers/spree.rb` adicionando as seguintes configurações
26
+ ```ruby
27
+ config.currency = "BRL"
28
+ # Preenche automaticamente o campo de pais que vamos remover do formulário de endereço:
29
+ config.default_country_iso = "BR"
30
+ ```
31
+ Incluir no `config/application.rb`
32
+ ```ruby
33
+ config.i18n.available_locales = ['pt-BR']
34
+ config.i18n.default_locale = 'pt-BR'
35
+ ```
36
+ E para interface admin, no initializer do spree
37
+ ```ruby
38
+ Spree::Backend::Config.configure do |config|
39
+ config.locale = 'pt-BR'
40
+ end
41
+ ```
42
+
24
43
  ### Configurações
25
44
  A partir do initializer da gem é possivel configurar se será permitido efetuar compras utilizando CNPJ. Por padrão é essa opção é `true`.
26
45
 
@@ -2,8 +2,17 @@ module AddressValidations
2
2
  extend ActiveSupport::Concern
3
3
 
4
4
  prepended do
5
- validates :number, presence: true
6
- validates :district, presence: true
5
+ validates :number, presence: true, if: -> { country.iso == "BR" }
6
+ validates :district, presence: true, if: -> { country.iso == "BR" }
7
+ validate :compatible_zipcode_and_state
8
+
9
+ def compatible_zipcode_and_state
10
+ return if country.iso != "BR"
11
+ cep = CodigoPostal.new(zipcode)
12
+ unless cep.state_code == state.abbr
13
+ errors.add(:base, "CEP não corresponde ao Estado.")
14
+ end
15
+ end
7
16
  end
8
17
 
9
18
  ::Spree::Address.prepend self
@@ -3,16 +3,8 @@ module OrderValidations
3
3
 
4
4
  prepended do
5
5
  validate :check_tax_id, if: :email_required?
6
- validate :check_compatible_zipcode_and_state
7
6
  before_update :format_tax_id
8
7
 
9
- def check_compatible_zipcode_and_state
10
- cep = CodigoPostal.new(ship_address.zipcode)
11
- unless cep.state_code == ship_address.state.abbr
12
- errors.add(:base, "CEP não corresponde ao Estado.")
13
- end
14
- end
15
-
16
8
  def check_tax_id
17
9
  cnpj_allowed = SolidusBrazilianAdaptations.config.allow_cnpj
18
10
  document = TaxIdBr.new(tax_id)
@@ -1,5 +1,5 @@
1
1
  class AddTaxIdToSpreeOrders < ActiveRecord::Migration[7.0]
2
2
  def change
3
- add_column :spree_orders, :tax_id, :string, default: "", if_not_exists: true
3
+ add_column :spree_orders, :tax_id, :string, if_not_exists: true
4
4
  end
5
5
  end
@@ -0,0 +1,6 @@
1
+ class AddDeliveryTimeToSpreeShippingRate < ActiveRecord::Migration[7.0]
2
+ def change
3
+ add_column :spree_shipping_rates, :min_delivery_time, :integer, if_not_exists: true
4
+ add_column :spree_shipping_rates, :max_delivery_time, :integer, if_not_exists: true
5
+ end
6
+ end
data/db/seeds.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'thor'
1
+ require "thor"
2
2
  shell = Thor::Base.shell.new
3
3
 
4
4
  %w[
@@ -15,4 +15,4 @@ shell = Thor::Base.shell.new
15
15
  ].each do |seed|
16
16
  shell.say_status :seed, seed
17
17
  require_relative "spree_br/#{seed}"
18
- end
18
+ end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'carmen'
3
+ require "carmen"
4
4
 
5
5
  # Insert Countries into the spree_countries table, checking to ensure that no
6
6
  # duplicates are created, using as few SQL statements as possible (2)
@@ -8,11 +8,11 @@ require 'carmen'
8
8
  connection = Spree::Base.connection
9
9
 
10
10
  country_mapper = ->(country) do
11
- name = connection.quote country.name
12
- iso3 = connection.quote country.alpha_3_code
13
- iso = connection.quote country.alpha_2_code
14
- iso_name = connection.quote country.name.upcase
15
- numcode = connection.quote country.numeric_code
11
+ name = connection.quote country.name
12
+ iso3 = connection.quote country.alpha_3_code
13
+ iso = connection.quote country.alpha_2_code
14
+ iso_name = connection.quote country.name.upcase
15
+ numcode = connection.quote country.numeric_code
16
16
  states_required = connection.quote country.subregions?
17
17
 
18
18
  [name, iso3, iso, iso_name, numcode, states_required].join(", ")
@@ -27,12 +27,12 @@ country_values = -> do
27
27
 
28
28
  # create VALUES statements for each country _not_ already in the database
29
29
  carmen_countries
30
- .reject { |c| existing_country_isos.include?(c.alpha_2_code) || c.alpha_2_code != 'BR' }
30
+ .reject { |c| existing_country_isos.include?(c.alpha_2_code) || c.alpha_2_code != "BR" }
31
31
  .map(&country_mapper)
32
32
  .join("), (")
33
33
  end
34
34
 
35
- country_columns = %w(name iso3 iso iso_name numcode states_required).join(', ')
35
+ country_columns = %w[name iso3 iso iso_name numcode states_required].join(", ")
36
36
  country_vals = country_values.call
37
37
 
38
38
  if country_vals.present?
@@ -1,11 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- Spree::ReturnReason.find_or_create_by(name: 'Better price available')
4
- Spree::ReturnReason.find_or_create_by(name: 'Missed estimated delivery date')
5
- Spree::ReturnReason.find_or_create_by(name: 'Missing parts or accessories')
6
- Spree::ReturnReason.find_or_create_by(name: 'Damaged/Defective')
7
- Spree::ReturnReason.find_or_create_by(name: 'Different from what was ordered')
8
- Spree::ReturnReason.find_or_create_by(name: 'Different from description')
9
- Spree::ReturnReason.find_or_create_by(name: 'No longer needed/wanted')
10
- Spree::ReturnReason.find_or_create_by(name: 'Accidental order')
11
- Spree::ReturnReason.find_or_create_by(name: 'Unauthorized purchase')
3
+ Spree::ReturnReason.find_or_create_by(name: "Better price available")
4
+ Spree::ReturnReason.find_or_create_by(name: "Missed estimated delivery date")
5
+ Spree::ReturnReason.find_or_create_by(name: "Missing parts or accessories")
6
+ Spree::ReturnReason.find_or_create_by(name: "Damaged/Defective")
7
+ Spree::ReturnReason.find_or_create_by(name: "Different from what was ordered")
8
+ Spree::ReturnReason.find_or_create_by(name: "Different from description")
9
+ Spree::ReturnReason.find_or_create_by(name: "No longer needed/wanted")
10
+ Spree::ReturnReason.find_or_create_by(name: "Accidental order")
11
+ Spree::ReturnReason.find_or_create_by(name: "Unauthorized purchase")
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  Spree::StockLocation.create_with(backorderable_default: true)
4
- .find_or_create_by!(name: 'default')
4
+ .find_or_create_by!(name: "default")
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
-
4
3
  Spree::PaymentMethod.create_with(
5
4
  name: "Store Credit",
6
5
  description: "Store credit",
@@ -14,10 +13,10 @@ Spree::PaymentMethod.create_with(
14
13
  Spree::StoreCreditType.create_with(priority: 1).find_or_create_by!(name: Spree::StoreCreditType::EXPIRING)
15
14
  Spree::StoreCreditType.create_with(priority: 2).find_or_create_by!(name: Spree::StoreCreditType::NON_EXPIRING)
16
15
 
17
- Spree::ReimbursementType.create_with(name: "Store Credit").find_or_create_by!(type: 'Spree::ReimbursementType::StoreCredit')
18
- Spree::ReimbursementType.create_with(name: "Original").find_or_create_by!(type: 'Spree::ReimbursementType::OriginalPayment')
16
+ Spree::ReimbursementType.create_with(name: "Store Credit").find_or_create_by!(type: "Spree::ReimbursementType::StoreCredit")
17
+ Spree::ReimbursementType.create_with(name: "Original").find_or_create_by!(type: "Spree::ReimbursementType::OriginalPayment")
19
18
 
20
19
  Spree::StoreCreditCategory.find_or_create_by!(name: Spree::StoreCreditCategory::GIFT_CARD)
21
20
  Spree::StoreCreditCategory.find_or_create_by!(name: Spree::StoreCreditCategory::REIMBURSEMENT)
22
21
 
23
- Spree::StoreCreditReason.find_or_create_by!(name: 'Credit Given In Error')
22
+ Spree::StoreCreditReason.find_or_create_by!(name: "Credit Given In Error")
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- unless Spree::Store.where(code: 'sample-store').exists?
3
+ unless Spree::Store.where(code: "sample-store").exists?
4
4
  Spree::Store.create!(
5
5
  name: "Sample Store",
6
6
  code: "sample-store",
@@ -4,26 +4,26 @@ module SolidusBrazilianAdaptations
4
4
  module Generators
5
5
  class InstallGenerator < Rails::Generators::Base
6
6
  class_option :auto_run_migrations, type: :boolean, default: false
7
- source_root File.expand_path('templates', __dir__)
7
+ source_root File.expand_path("templates", __dir__)
8
8
 
9
9
  def self.exit_on_failure?
10
10
  true
11
11
  end
12
12
 
13
13
  def copy_initializer
14
- template 'initializer.rb', 'config/initializers/solidus_brazilian_adaptations.rb'
14
+ template "initializer.rb", "config/initializers/solidus_brazilian_adaptations.rb"
15
15
  end
16
16
 
17
17
  def add_migrations
18
- run 'bin/rails railties:install:migrations FROM=solidus_brazilian_adaptations'
18
+ run "bin/rails railties:install:migrations FROM=solidus_brazilian_adaptations"
19
19
  end
20
20
 
21
21
  def run_migrations
22
- run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask('Would you like to run the migrations now? [Y/n]')) # rubocop:disable Layout/LineLength
22
+ run_migrations = options[:auto_run_migrations] || ["", "y", "Y"].include?(ask("Would you like to run the migrations now? [Y/n]")) # rubocop:disable Layout/LineLength
23
23
  if run_migrations
24
- run 'bin/rails db:migrate'
24
+ run "bin/rails db:migrate"
25
25
  else
26
- puts 'Skipping bin/rails db:migrate, don\'t forget to run it!' # rubocop:disable Rails/Output
26
+ puts "Skipping bin/rails db:migrate, don't forget to run it!" # rubocop:disable Rails/Output
27
27
  end
28
28
  end
29
29
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SolidusBrazilianAdaptations
4
- VERSION = "1.0.6"
4
+ VERSION = "1.0.8"
5
5
  end
@@ -31,6 +31,9 @@ Gem::Specification.new do |spec|
31
31
  spec.add_dependency "solidus_support", "~> 0.5"
32
32
  spec.add_dependency "cpf_cnpj"
33
33
  spec.add_dependency "codigo_postal"
34
+ spec.add_dependency "solidus_i18n"
35
+ spec.add_dependency "rails-i18n"
36
+ spec.add_dependency "kaminari-i18n"
34
37
 
35
38
  spec.add_development_dependency "solidus_dev_support", "~> 2.7"
36
39
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidus_brazilian_adaptations
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - ulysses-bull
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-10-25 00:00:00.000000000 Z
11
+ date: 2023-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: solidus_core
@@ -72,6 +72,48 @@ dependencies:
72
72
  - - ">="
73
73
  - !ruby/object:Gem::Version
74
74
  version: '0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: solidus_i18n
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ type: :runtime
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ - !ruby/object:Gem::Dependency
90
+ name: rails-i18n
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ type: :runtime
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ - !ruby/object:Gem::Dependency
104
+ name: kaminari-i18n
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ type: :runtime
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
75
117
  - !ruby/object:Gem::Dependency
76
118
  name: solidus_dev_support
77
119
  requirement: !ruby/object:Gem::Requirement
@@ -117,6 +159,7 @@ files:
117
159
  - config/routes.rb
118
160
  - db/migrate/20230911133000_add_tax_id_to_spree_orders.rb
119
161
  - db/migrate/20230911133157_add_number_district_to_addresses.rb
162
+ - db/migrate/20231107142354_add_delivery_time_to_spree_shipping_rate.rb
120
163
  - db/seeds.rb
121
164
  - db/spree_br/countries.rb
122
165
  - db/spree_br/payment.rb