solidus_brazilian_adaptations 1.0.5 → 1.0.6
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 +4 -4
- data/app/overrides/address_validations.rb +10 -0
- data/app/overrides/order_validations.rb +35 -0
- data/lib/solidus_brazilian_adaptations/version.rb +1 -1
- data/lib/solidus_brazilian_adaptations.rb +1 -0
- data/solidus_brazilian_adaptations.gemspec +1 -0
- metadata +19 -4
- data/app/decorators/models/solidus_brazilian_adaptations/spree/order_decorator.rb +0 -33
- /data/app/{modules → models}/tax_id_br.rb +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 24fa67771b38cee0a4d92caf9fdae494846fb87023ddfce3f3ed4077433661e7
|
|
4
|
+
data.tar.gz: 2adf6fce94c6ebdc966e6ff986daf61462e92dc0576de84f47b8e4d2ac2f0e22
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 77d168c0c7ad3c0cb2993817009a04a8cece0c88d1a5abf9ed9536ad594d34ca709d9069e7b4fb131fdf30c536c8362fd9f0755a46e75b185cdc4b5db87e7320
|
|
7
|
+
data.tar.gz: c37f09bace53817ef175c4758c199767726c466ef2399327bbf24b7275fe3526b90d8869bb28827f58d448813b39843140cb9cfa3f025b8ce5cd4c33405984a8
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
module OrderValidations
|
|
2
|
+
extend ActiveSupport::Concern
|
|
3
|
+
|
|
4
|
+
prepended do
|
|
5
|
+
validate :check_tax_id, if: :email_required?
|
|
6
|
+
validate :check_compatible_zipcode_and_state
|
|
7
|
+
before_update :format_tax_id
|
|
8
|
+
|
|
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
|
+
def check_tax_id
|
|
17
|
+
cnpj_allowed = SolidusBrazilianAdaptations.config.allow_cnpj
|
|
18
|
+
document = TaxIdBr.new(tax_id)
|
|
19
|
+
if document.valid?
|
|
20
|
+
if document.document_type == :cnpj && cnpj_allowed == false
|
|
21
|
+
errors.add(:base, "Insira um CPF, não um CNPJ.")
|
|
22
|
+
end
|
|
23
|
+
else
|
|
24
|
+
errors.add(:base, "#{cnpj_allowed ? "CPF/CPNJ" : "CPF"} inválido.")
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def format_tax_id
|
|
29
|
+
document = TaxIdBr.new(tax_id)
|
|
30
|
+
self.tax_id = document.formatted
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
::Spree::Order.prepend self
|
|
35
|
+
end
|
|
@@ -30,6 +30,7 @@ Gem::Specification.new do |spec|
|
|
|
30
30
|
spec.add_dependency "solidus_core", [">= 2.0.0", "< 5"]
|
|
31
31
|
spec.add_dependency "solidus_support", "~> 0.5"
|
|
32
32
|
spec.add_dependency "cpf_cnpj"
|
|
33
|
+
spec.add_dependency "codigo_postal"
|
|
33
34
|
|
|
34
35
|
spec.add_development_dependency "solidus_dev_support", "~> 2.7"
|
|
35
36
|
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.6
|
|
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-
|
|
11
|
+
date: 2023-10-25 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: solidus_core
|
|
@@ -58,6 +58,20 @@ dependencies:
|
|
|
58
58
|
- - ">="
|
|
59
59
|
- !ruby/object:Gem::Version
|
|
60
60
|
version: '0'
|
|
61
|
+
- !ruby/object:Gem::Dependency
|
|
62
|
+
name: codigo_postal
|
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
|
64
|
+
requirements:
|
|
65
|
+
- - ">="
|
|
66
|
+
- !ruby/object:Gem::Version
|
|
67
|
+
version: '0'
|
|
68
|
+
type: :runtime
|
|
69
|
+
prerelease: false
|
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
71
|
+
requirements:
|
|
72
|
+
- - ">="
|
|
73
|
+
- !ruby/object:Gem::Version
|
|
74
|
+
version: '0'
|
|
61
75
|
- !ruby/object:Gem::Dependency
|
|
62
76
|
name: solidus_dev_support
|
|
63
77
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -89,8 +103,9 @@ files:
|
|
|
89
103
|
- LICENSE
|
|
90
104
|
- README.md
|
|
91
105
|
- Rakefile
|
|
92
|
-
- app/
|
|
93
|
-
- app/
|
|
106
|
+
- app/models/tax_id_br.rb
|
|
107
|
+
- app/overrides/address_validations.rb
|
|
108
|
+
- app/overrides/order_validations.rb
|
|
94
109
|
- bin/console
|
|
95
110
|
- bin/rails
|
|
96
111
|
- bin/rails-engine
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module SolidusBrazilianAdaptations
|
|
4
|
-
module Spree
|
|
5
|
-
module OrderDecorator
|
|
6
|
-
def self.prepended(base)
|
|
7
|
-
base.class_eval do
|
|
8
|
-
validate :verify, if: :email_required?
|
|
9
|
-
before_update :format_tax_id
|
|
10
|
-
|
|
11
|
-
def verify
|
|
12
|
-
cnpj_allowed = SolidusBrazilianAdaptations.config.allow_cnpj
|
|
13
|
-
document = TaxIdBr.new(tax_id)
|
|
14
|
-
if document.valid?
|
|
15
|
-
if document.document_type == :cnpj && cnpj_allowed == false
|
|
16
|
-
errors.add(:base, "Insira um CPF, não um CNPJ.")
|
|
17
|
-
end
|
|
18
|
-
else
|
|
19
|
-
errors.add(:base, "#{cnpj_allowed ? "CPF/CPNJ" : "CPF"} inválido.")
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def format_tax_id
|
|
24
|
-
document = TaxIdBr.new(tax_id)
|
|
25
|
-
self.tax_id = document.formatted
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
::Spree::Order.prepend self
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
File without changes
|