solidus_brazilian_adaptations 1.0.6 → 1.0.7

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: 24fa67771b38cee0a4d92caf9fdae494846fb87023ddfce3f3ed4077433661e7
4
- data.tar.gz: 2adf6fce94c6ebdc966e6ff986daf61462e92dc0576de84f47b8e4d2ac2f0e22
3
+ metadata.gz: a76efff4ad9d953e3b825eb176e237621450b260742c756eefa2d4f0af0619dd
4
+ data.tar.gz: a6b045f77cc4be284a6070fb9b65d02571f1511190b74b63bc9b0be64d62cb74
5
5
  SHA512:
6
- metadata.gz: 77d168c0c7ad3c0cb2993817009a04a8cece0c88d1a5abf9ed9536ad594d34ca709d9069e7b4fb131fdf30c536c8362fd9f0755a46e75b185cdc4b5db87e7320
7
- data.tar.gz: c37f09bace53817ef175c4758c199767726c466ef2399327bbf24b7275fe3526b90d8869bb28827f58d448813b39843140cb9cfa3f025b8ce5cd4c33405984a8
6
+ metadata.gz: 959e7bb2737a3f8a90d93f5c30c0ca35195ec03876e3c2574f3a90998e651d006b9224eac771cb4cb4823203e871fa4f202209be81a0371662cbb940b8e0c783
7
+ data.tar.gz: 61fdc3b8035422d5379d84117aa6f372053e83d069108c4fcb75f36df1fd92c5ccba43c510967fff0f59b2077fca2e0626470fb3f1c79df83956e142047779eb
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"
@@ -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)
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.7"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
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.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - ulysses-bull