Precise and accurate unified Social Credit code regular (JS)

Source: Internet
Author: User

Reference Standard:

"Gb_32100-2015_ legal person and other organizations unified Social Credit code coding rules."
Follow the coding rules:
The unified code is 18 bits, and the unified code consists of 18 digits or uppercase English letters (not applicable I 、O、Z、S、V ), consisting of five parts:
The first part (1th place) is the registration Management department code, 9 indicates the business sector; ( numeric or uppercase English letters )
The second part (2nd place) is the organization class code; ( numeric or uppercase English letters )
The third part (第3-8位) is the administrative division of the Registration Authority code; 数字
Part IV (第9-17位) is the National Organization Code; ( numeric or uppercase English letters )
Part V (18th digit) is a check code ( digit or uppercase English letter )

Regular writing:

Unified Social Credit code:/[^_iozsva-z\w]{2}\d{6}[^_iozsva-z\w]{10}$/g

On the net there is no that the $ number, I test out is the first to verify a correct, and then add something will continue to return true, and 91420000737944946L is true, then 91420000737944946Ltest is still true ... No finishing touches on length

You can use the: test method for a single checksum, and the match method when you use an array.

There is also an enterprise registration number of the regular, its rules are 15-digit alphanumeric composition:/^[a-za-z0-9]\w{14}$/g

the composition of a unified Social Credit code :

Composition of the unified Code 1 structure

The unified code consists of 18 digits of Arabic numerals or uppercase English letters ( not using I, O, Z, S, V).

1th Place: Register the Administrative Department code (a total of one character)
2nd place: Organization Class code (total one character)
3rd-8th place: administrative division of the Registration Office code (a total of six digits of Arabic numerals)
9th-17th bit: Body identifier (organization code) (nine characters total)
18th bit: Check code? (a total of one character)

2 code and description??

Register the Administrative Department code : use Arabic numerals or uppercase English letters to denote.?

Establishment: 1?
Home: 5?
Business: 9?
Other: Y

Agency Class Code : use Arabic numerals or uppercase English letters.?

Institutional establishment: 11??
Institution Establishment: 12?
Organization of the Central Office of the establishment of the direct management organization of mass groups: 13??
Institutional development Other: 19?

Civil society groups: 51?
Civil and private non-enterprise units: 52?
Civil Foundation: 53?
Civil other: 59?

Business: 91?
Industrial and commercial business: 92?
Professional cooperatives for industrial and commercial farmers: 93?

Other: Y1?

Registration Administrative Organs Administrative Division code : can only be used to denote Arabic numerals. According to gb/t2260 code.?

For example: Chengdu, Sichuan Province, this level is 510100; Zigong Ziliujin District in Sichuan Province is 510302.

principal identification Code (Organization code ): use Arabic numerals or uppercase letters in English. Code according to GB11714.

Before implementing a unified Social Credit code, the organization code on the previous organization code certificate is composed of nine characters. The format is xxxxxxxx-y. The first eight bits are referred to as the "Ontology Code"; The last one is called the "Check Code". The check code and the body code are connected by a hyphen (-). To make it easy to see the check code. But after the combination of the three, the organization's nine characters are all included in the unified Social Credit code 9th to 17th place, the original organization code of the hyphen does not bring into the unified Social Credit code.

The rules for calculating "check code" on the original organization code are:?

For example, the organization code of a company is: 59467239-9. How is the last organization Code check code 9 calculated?

The first step: take the organization code of the first eight-bit ontology code is the base. 5 9 4 6 7 2 3 9
Tip: If the body code contains an English capital letter. Then the cardinality of a is the base of the 10,b is the radix of 11,c is 12, and so on, until the cardinality of Z is 35.
Step two:?? Take a weighted factor value. Because the body code of the Organization code is altogether eight-bit characters. Then the eight-bit weighted factor values are from left to right: 3, 7, 9, 10, 5, 8, 4, 2.
The third step: the main body code base and the corresponding number of digits multiplied by the factor.
5X3=15,9X7=63,4X9=36,6X10=60,
7x5=35,2x8=16,3x4=12,9x2=18??
Fourth Step: Add the product sum.
15+63+36+60+35+16+12+18=255
Fifth step:? Divide the sum by 11 to find the remainder.
255÷11=33, the remainder is 2.??
The sixth step: subtract the remainder with the Arabic numeral 11, the value of the check code is obtained. When the value of the check code is 10 o'clock, the check code is denoted by an English capital letter X, and when the value of the check code is 11 o'clock, the check code is expressed as zero, and the remaining number of the check code is expressed by its own Arabic numerals.
11-2=9, so the company's complete organization code is 59467239-9.??

Check code : use Arabic numerals or uppercase English letters to denote. The calculation method of the check code refers to gb/t17710.

For example: A company's unified Social Credit code for 91512081MA62K0260E, then its last check code E is how to calculate it?

Step one: Take the first 17 digits of the unified Social Credit code as the base. 9 1 5 1 2 0 8 1 6 2 0 2 Note: If the first 17-digit unified Social Credit code contains English capital letters (do not use the I, O, Z, S, V, five English letters). The English letters correspond to the following bases: a=10, b=11, c=12, d=13, e=14, f=15, g=16, h=17, j=18, k=19, l=20, m=21, n=22, p=23, q=24, r=25, t=26, u=27, w=28, X =29, y=30?
Step two:?? Take a weighted factor value. Because the unified Social Credit code is preceded by a 17-bit character. Then the 17-bit weighted factor values are from left to right: 1, 3, 9, 27, 19, 26, 16, 17, 20, 29, 25, 13, 8, 24, 10, 30, 2?8
The third step: the cardinality and the corresponding number of digits multiplied by the factor.
9x1=9,1x3=3,5x9=45,1x27=27,2x19=38,0x26=0,8x16=128?
1x17=17,21x20=420,10x29=290,6x25=150,2x13=26,19x8=152?
0x23=0,2x10=20,6x30=180,0x28=0

Fourth Step: Add the product sum. 9+3+45+27+38+0+128+17+420+290+150+26+152+0+20+180+0=1495

Fifth step:? Divide the sum by 31 to find the remainder.
1495÷31=48, the remainder is 17.??

The sixth step: subtract the remainder with the Arabic numeral 31, the value of the check code is obtained. When the value of the check code is 0~9, the value of the check code is used as the final check code of the unified Social Credit code; If the value of the checksum is 10~30, the check code is converted to the corresponding uppercase English letter. The corresponding relationships are: a=10, b=11, c=12, d=13, e=14, f=15, g=16, h=17, j=18, k=19, l=20, m=21, n=22, p=23, q=24, r=25, t=26, u=27, w=28, X=29, Y=30

Because, 31-17=14, so the company complete unified Social Credit code for 91512081MA62K0260E.

————————————————

Unified Social Credit code and the original business license registration number, tax registration number, organization code conversion relationship?

The 18-digit unified Social Credit code was formally introduced from October 1, 2015. There are still many systems that are not fully converted to the unified Social Credit code. How do you get information from a unified Social Credit code when you encounter a need to fill in your organization code or tax registration number?

Essentially:?
Unified Social Credit Code Nineth to 17th place is the original organization code.
Unified Social Credit Code of the third place to 17th most of the situation is the original tax registration certificate number. (However, the code for local administrative divisions is regulated by a few certification authorities.) Therefore, there are a small number of enterprises of the new unified Social Credit code is not necessarily the 3rd to 8th digit of the Arabic numerals and must be able to fully correspond to the previous tax registration certificate of the first six digits. )??
The unified Social Credit code cannot correspond to the registration number of the original business license. When you encounter a registration number that does not want you to fill in the business license, and temporarily cannot identify the unified Social Credit code. You only have to take out the previous old business license to view the registration number above.

For example: 91370200163562681G This unified Social Credit code.?

Its organization code is: 16356268-1?
The tax registration number is: 370200163562681 If there is a slight discrepancy with the previous tax registration number, it is generally 370200 inconsistent. Especially 00 of these two

Precise and accurate unified Social Credit code regular (JS)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.