unidom-certificate-china 1.3 → 1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -0
- data/app/controllers/unidom/certificate/china/application_controller.rb +4 -4
- data/app/jobs/unidom/certificate/china/application_job.rb +3 -0
- data/app/mailers/unidom/certificate/china/application_mailer.rb +3 -0
- data/app/models/unidom/certificate/china/application_record.rb +3 -0
- data/app/models/unidom/certificate/china/business_license.rb +1 -0
- data/app/validators/unidom/certificate/china/unified_social_credit_identifier_validator.rb +22 -0
- data/lib/unidom/certificate/china/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d8ba2d2b978a505a66994e6e14e1cb64784f91f
|
4
|
+
data.tar.gz: 4691fe8b019b9764363068bb915e43e635c64788
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ae7e9e702bc26fb27ff80ddbc904cfdfc5f2cfdafafef2f222c172e8b97c6066bc1427fb078c593e13eedea3b16df94d5a2514db660253ff2b0aa2ae49c46e0
|
7
|
+
data.tar.gz: ddf4272aed977244a73064ad8fb41a6ae2b2f5a63826521d3188ffba6bf3220e7ba59e1dacac46644fdbea55209bcad32ec9a2f9d4d7ffe0398c46e35358f85d
|
data/README.md
CHANGED
@@ -82,13 +82,17 @@ include Unidom::Certificate::China::Concerns::AsIdentityCardCertificated
|
|
82
82
|
### As Business License Certificated
|
83
83
|
|
84
84
|
The As Business License Certificated do the following tasks for the includer automatically:
|
85
|
+
|
85
86
|
1. Include the [As Certificated](http://https://github.com/topbitdu/unidom-certificated) concern
|
87
|
+
|
86
88
|
2. Define the has_many :china_business_licenses macro as: ``has_many :china_business_licenses, through: :certificatings, source: :certification, source_type: 'Unidom::Certificate::China::BusinessLicense'``
|
87
89
|
|
88
90
|
### As Identity Card Certificated
|
89
91
|
|
90
92
|
The As Identity Card Certificated do the following tasks for the includer automatically:
|
93
|
+
|
91
94
|
1. Include the [As Certificated](http://https://github.com/topbitdu/unidom-certificated) concern
|
95
|
+
|
92
96
|
2. Define the has_many :china_identity_cards macro as: ``has_many :china_identity_cards, through: :certificatings, source: :certification, source_type: 'Unidom::Certificate::China::IdentityCard'``
|
93
97
|
|
94
98
|
|
@@ -1,6 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
protect_from_forgery with: :exception
|
4
|
-
end
|
1
|
+
##
|
2
|
+
# Application controller 是模块内所有控制器的基类。
|
5
3
|
|
4
|
+
class Unidom::Certificate::China::ApplicationController < ActionController::Base
|
5
|
+
protect_from_forgery with: :exception
|
6
6
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# GB 32100-2015《法人和其他组织统一社会信用代码编码规则》
|
2
|
+
# http://qyj.saic.gov.cn/wjfb/201509/t20150929_162430.html
|
3
|
+
|
4
|
+
class Unidom::Certificate::China::UnifiedSocialCreditIdentifierValidator < ActiveModel::EachValidator
|
5
|
+
|
6
|
+
WEIGHTS = [ 1, 3, 9, 27, 19, 26, 16, 17, 20, 29, 25, 13, 8, 24, 10, 30, 28 ].freeze
|
7
|
+
VALUES = '0123456789ABCDEFGHJKLMNPQRTUWXY'.freeze
|
8
|
+
|
9
|
+
def validate_each(record, attribute, value)
|
10
|
+
|
11
|
+
value = value.to_s
|
12
|
+
sum = 0
|
13
|
+
value[0..16].chars.each_with_index do |char, index| sum += VALUES.index(char)*WEIGHTS[index] end
|
14
|
+
checksum = sum % 31
|
15
|
+
checksum = 0==checksum ? 31 : checksum
|
16
|
+
checksum = 31-checksum
|
17
|
+
|
18
|
+
record.errors[attribute] << (options[:message]||'is invalid') unless VALUES[checksum]==value[17]
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unidom-certificate-china
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1.
|
4
|
+
version: '1.4'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Topbit Du
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: unidom-certificate
|
@@ -55,6 +55,7 @@ files:
|
|
55
55
|
- app/models/unidom/certificate/china/concerns/as_identity_card_certificated.rb
|
56
56
|
- app/models/unidom/certificate/china/identity_card.rb
|
57
57
|
- app/validators/unidom/certificate/china/identification_number_validator.rb
|
58
|
+
- app/validators/unidom/certificate/china/unified_social_credit_identifier_validator.rb
|
58
59
|
- app/views/layouts/unidom/certificate/china/application.html.erb
|
59
60
|
- config/routes.rb
|
60
61
|
- db/migrate/20010291560010_create_unidom_china_identity_cards.rb
|