solidus_brazilian_adaptations 1.0.6 → 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +18 -19
- data/app/overrides/address_validations.rb +11 -2
- data/app/overrides/order_validations.rb +0 -8
- data/db/seeds.rb +2 -2
- data/db/spree_br/countries.rb +8 -8
- data/db/spree_br/return_reasons.rb +9 -9
- data/db/spree_br/stock_locations.rb +1 -1
- data/db/spree_br/store_credit.rb +3 -4
- data/db/spree_br/stores.rb +1 -1
- data/lib/generators/solidus_brazilian_adaptations/install/install_generator.rb +6 -6
- data/lib/solidus_brazilian_adaptations/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a76efff4ad9d953e3b825eb176e237621450b260742c756eefa2d4f0af0619dd
|
4
|
+
data.tar.gz: a6b045f77cc4be284a6070fb9b65d02571f1511190b74b63bc9b0be64d62cb74
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
3
|
+
source "https://rubygems.org"
|
4
4
|
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
5
5
|
|
6
|
-
branch = ENV.fetch(
|
7
|
-
gem
|
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 >=
|
11
|
-
gem
|
12
|
-
elsif branch ==
|
13
|
-
gem
|
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
|
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
|
22
|
-
|
21
|
+
gem "rails", ">0.a"
|
23
22
|
|
24
23
|
# Provides basic authentication functionality for testing parts of your engine
|
25
|
-
gem
|
24
|
+
gem "solidus_auth_devise"
|
26
25
|
|
27
|
-
case ENV.fetch(
|
28
|
-
when
|
29
|
-
gem
|
30
|
-
when
|
31
|
-
gem
|
26
|
+
case ENV.fetch("DB", nil)
|
27
|
+
when "mysql"
|
28
|
+
gem "mysql2"
|
29
|
+
when "postgresql"
|
30
|
+
gem "pg"
|
32
31
|
else
|
33
|
-
gem
|
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
|
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,
|
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
data/db/spree_br/countries.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
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
|
12
|
-
iso3
|
13
|
-
iso
|
14
|
-
iso_name
|
15
|
-
numcode
|
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 !=
|
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
|
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:
|
4
|
-
Spree::ReturnReason.find_or_create_by(name:
|
5
|
-
Spree::ReturnReason.find_or_create_by(name:
|
6
|
-
Spree::ReturnReason.find_or_create_by(name:
|
7
|
-
Spree::ReturnReason.find_or_create_by(name:
|
8
|
-
Spree::ReturnReason.find_or_create_by(name:
|
9
|
-
Spree::ReturnReason.find_or_create_by(name:
|
10
|
-
Spree::ReturnReason.find_or_create_by(name:
|
11
|
-
Spree::ReturnReason.find_or_create_by(name:
|
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")
|
data/db/spree_br/store_credit.rb
CHANGED
@@ -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:
|
18
|
-
Spree::ReimbursementType.create_with(name: "Original").find_or_create_by!(type:
|
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:
|
22
|
+
Spree::StoreCreditReason.find_or_create_by!(name: "Credit Given In Error")
|
data/db/spree_br/stores.rb
CHANGED
@@ -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(
|
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
|
14
|
+
template "initializer.rb", "config/initializers/solidus_brazilian_adaptations.rb"
|
15
15
|
end
|
16
16
|
|
17
17
|
def add_migrations
|
18
|
-
run
|
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] || [
|
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
|
24
|
+
run "bin/rails db:migrate"
|
25
25
|
else
|
26
|
-
puts
|
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
|