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 +4 -4
- data/Gemfile +18 -19
- data/README.md +19 -0
- data/app/overrides/address_validations.rb +11 -2
- data/app/overrides/order_validations.rb +0 -8
- data/db/migrate/20230911133000_add_tax_id_to_spree_orders.rb +1 -1
- data/db/migrate/20231107142354_add_delivery_time_to_spree_shipping_rate.rb +6 -0
- 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
- data/solidus_brazilian_adaptations.gemspec +3 -0
- metadata +45 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa340352bf3bdbd83004ac7e1586475c97b711dc885a1ff863e56217c635077c
|
4
|
+
data.tar.gz: c8380825a0d218d87b7627aaeb4cc16c2a0d3f06224794f2b42065849072d527
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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"
|
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)
|
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
|
@@ -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.
|
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-
|
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
|