Giter VIP home page Giter VIP logo

python-stdnum's People

Contributors

ahaeber avatar alexis-via avatar andrp92 avatar arthurdejong avatar cclauss avatar cedk avatar cormaza avatar dchoruzy avatar dimitripapadopoulos avatar gdalmau avatar gustavovalverde avatar jeffh92 avatar jeffryjdelarosa avatar jwilk avatar kurtkeller avatar larih avatar lemonsaurus avatar muhistheholvi avatar piruin avatar pokoli avatar raduborzea avatar romualdr avatar ronaldpaloschi avatar srikanthlogic avatar toivotuo avatar tonyseek avatar unho avatar vairag22 avatar vihtinsky avatar vokimon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-stdnum's Issues

1.9.0 has problem with Belgian IBANs

The new version has problem with the example IBAN:
https://www.ecbs.org/iban/belgium-bank-account-number.html
shows:
IBAN print format example | BE68 5390 0754 7034
Here is an example in ipython:

In [1]: import stdnum

In [2]: print (stdnum.__version__)
1.9

In [3]: from stdnum.be.iban import validate

In [4]: validate('BE68 5390 0754 7034')
---------------------------------------------------------------------------
InvalidComponent                          Traceback (most recent call last)
<ipython-input-....> in <module>()
----> 1 validate('BE68 5390 0754 7034')

/..../python-stdnum/stdnum/be/iban.pyc in validate(number)
     88         raise InvalidChecksum()
     89     if not info(number):
---> 90         raise InvalidComponent()
     91     return number
     92

InvalidComponent: One of the parts of the number are invalid or unknown.

TIN number from Monaco

Hello,

We are facing an issue with the validation of the following TIN numbers: FR40000066034, FR26000040583, FR28000113851 (more to be found at http://www.monaco-directory.com/)...
The number starts with FR, but is for a company in Monaco. You might already know the Monaco uses the French TIN structure.
Note that these numbers are valid according to VIES: http://ec.europa.eu/taxation_customs/vies/

However, the 9 last digits (SIREN number in France) do not pass the Luhn validity check. There doesn't seem to be any issue with the algorithm implemented in stdnum, since other external services don't validate this number either.

At this point, we couldn't find any resource specifying that this number should not verify the Luhn algorithm, the only known exception being La Poste (https://fr.wikipedia.org/wiki/Formule_de_Luhn#Cas_particulier). However, my hypothesis is that it is not the case for Monaco (at least for recent numbers).

Have you heard about this issue before?

Thanks

Add support for Panama TIN

This document details how the validation algorithm works: https://dgi.mef.gob.pa/N-prensa/Calculo_DV_RUC_20180523.pdf (This was found in https://dgi.mef.gob.pa/Registro.html )

  • Algorithm:

  • Video explaning how to get verification digit for a RUC: https://www.youtube.com/watch?v=KDEpYiXpT64 For example for querying a company with RUC 1870951-1-1751 and DV 18 enter 1870951 as "Rollo/Tomo", 1 as "Folio/Imagen" and 1751 as "Asiento/Ficha" and will give you 18 to be the DV.

  • Regarding the format the DV is always 2 digits.

    • Regarding RUC the limitation is 20 digits. There are two RUC numbers: regular RUC and the NT numbers.

      • Regular RUC is split into three parts with hyphens, the first being "Rollo/Tomo", second is "Folio/Imagen" and last one "Asiento/Ficha" (these names come from the online search tool for RUC numbers. Check Youtube video above).
      • According to https://dgi.mef.gob.pa/Registro/NT.html people that do not meet the conditions to get a RUC number are given NT (Número Tributario) numbers. NT numbers have four parts joined with hyphens (as the found examples suggest), the first part is the province code (from 0 to 13, both included), followed by the letters "NT", the third part is "Folio/Imagen" and the last part is "Asiento/Ficha" (these names come from the online search tool for RUC numbers. Check Youtube video above).

Examples (DV stands for "Digito Verificador", "Verifying Digit")

  • Lots of examples from https://dgi.mef.gob.pa/itbms/Pdf-Retencion/LISTADO%20DE%20AGENTES%20DE%20RETENCION%20DEL%20ITBMS%20(GRANDES%20COMPRADORES)%202022.pdf (attached here just in case it disappears
    LISTADO DE AGENTES DE RETENCION DEL ITBMS (GRANDES COMPRADORES) 2022.pdf)

    155628291-2-2016 DV32
    1724590-1-691090 DV93
    53688-13-328636 DV13
    48700-46-311921 DV69
    15430-249-148718 DV 9
    206-357-50180 DV52
    41883-11-285650 DV74
    946225-1-524816 DV74
    42473-2-287965 DV13
    817950-1-499559 DV23
    1740287-1-694190 DV 7
    292834-1-409023 DV62
    57983-20-340437 DV83
    171-377-40633 DV01
    277-83-60760 DV90
    574-14-102616 DV70
    723289-1-473588 DV55
    1621672-1-670343 DV70
    25280-23-217450 DV93
    65129-43-360172 DV89
    36940-56-265476 DV54
    752228-1-480172 DV33
    62285-22-351739 DV 0
    1956148-1-732006 DV58
    32476-40-247875 DV96
    40508-59-279820 DV 3
    125-103-33907 DV 0
    63491-67-355132 DV 0
    1144-157-124040 DV55
    155650394-2-2017 DV14
    454805-1-432117 DV82
    1896790-1-721932 DV 1
    155587102-2-2014 DV75
    628265-1-455977 DV19
    603-203-124985 DV 1
    662-358-135002 DV95
    194-127-47232 DV11
    789-493-142459 DV75
    47101-2-306017 DV99
    30686-2-239905 DV 9
    51013-40-319894 DV 7
    155639020-2-2016 DV49
    35090-124-258812 DV 0
    691048-1-466377 DV31
    1183-594-125546 DV01
    280-134-61098 DV 2
    1247-207-120963 DV 0
    52052-44-323244 DV96
    36633-66-264068 DV11
    1269902-1-597539 DV45
    1150858-1-571723 DV 0
    633197-1-456744 DV70
    325-581-71443 DV10
    334-118-72930 DV95
    61510-23-349564 DV24
    126-347-3293 DV50
    312291-1-411723 DV 7
    2458675-1-813221 DV92
    1224234-1-587146 DV50
    270-35-61112 DV23
    45480-104-300237 DV27
    42629-2-288648 DV94
    2536967-1-824337 DV47
    49-572-8631 DV19
    46004-187-302083 DV96
    30394-2-238626 DV22
    1722232-1-690575 DV68
    343-501-75237 DV 3
    2482442-1-816457 DV 8
    655-128-131705 DV 0
    1183324-1-578664 DV70
    122-395-32518 DV95
    30370-67-238459 DV24
    335-535-74021 DV24
    12293-62-122367 DV 9
    155589402-2-2014 DV16
    439-575-10813 DV90
    1129184-1-566509 DV26
    43085-133-290460 DV20
    59838-19-345377 DV 5
    59838-2-345376 DV12
    1038743-1-544512 DV99
    395593-1-423610 DV 4
    766-19-135058 DV50
    94331-1-377666 DV55
    155641197-2-2016 DV79
    555-328-101285 DV64
    121-472-33557 DV40
    155625764-2-2016 DV30
    2250848-1-781518 DV24
    2077798-1-1949 DV67
    2530931-1-823337 DV14
    155624611-2-2016 DV11
    66339-1-373342 DV60
    39-35-5021 DV79
    1513069-1-650069 DV77
    718163-1-472453 DV95
    2367438-1-800216 DV69
    994855-1-534959 DV48
    789182-1-490742 DV22
    150-291-38284 DV66
    539-153-116071 DV76
    69-210-21057 DV74
    693864-1-1196 DV93
    800998-1-494934 DV 9
    521-136-113133 DV 2
    1041-1-363971 DV80
    1254470-1-594004 DV90
    293-366-66713 DV59
    157217-1-246 DV71
    52731-193-325028 DV87
    31276-185-242477 DV 4
    256-148-57138 DV79
    69-554-21245 DV75
    2207107-1-774310 DV 2
    652-212-129962 DV35
    61321-17-348954 DV75
    130-377-34706 DV 2
    36452-64-263512 DV93
    1443115-1-636478 DV75
    408176-1-1104 DV65
    48152-13-309974 DV97
    2078063-1-752745 DV 8
    155618856-2-2015 DV65
    155597083-2-2015 DV85
    158-116-39692 DV69
    1639169-1-673402 DV80
    2025521-1-744067 DV18
    1761124-1-698272 DV45
    155663286-2-2018 DV74
    155647197-2-2017 DV36
    28956-128-233503 DV96
    19000-84-174431 DV65
    155637252-2-2016 DV90
    2025792-1-744101 DV64
    1507145-1-648925 DV62
    2440449-1-810753 DV30
    247403-1-402599 DV14
    1581018-1-662559 DV26
    986893-1-533381 DV91
    854789-1-506103 DV27
    155664688-2-2018 DV 4
    52877-115-326091 DV27
    56238-78-335605 DV32
    2534488-1-823930 DV60
    1633955-1-672391 DV97
    1912691-1-724747 DV 4
    62197-21-351482 DV69
    1924973-1-726927 DV 8
    1715863-1-689313 DV96
    155664223-2-2018 DV71
    2093250-1-755548 DV64
    44947-167-667 DV56
    1423328-1-632401 DV69
    31404-49-243102 DV49
    1173387-1-576582 DV94
    1837876-1-1727 DV62
    48192-119-320004 DV42
    1620775-1-670190 DV40
    56014-2-334942 DV57
    48854-14-312652 DV53
    19573-102-178376 DV78
    2605013-1-834447 DV16
    860-116-100257 DV 6
    2486668-1-817006 DV77
    280-319-61818 DV53
    1026161-1-541697 DV41
    155609091-2-2015 DV63
    42860-39-289557 DV42
    673-563-133317 DV43
    1529223-1-653120 DV85
    1-513-153 DV21
    649-529-117695 DV 1
    196-8-47222 DV21
    2978-2-46909 DV 9
    4360-163-58819 DV75
    256211-1-1035 DV89
    190229-1-393739 DV80
    2486790-1-817030 DV91
    155613062-2-2015 DV88
    9944-73-101955 DV 9
    37405-45-267330 DV75
    637-262-109021 DV 5
    4211-2-57599 DV28
    19784-57-180195 DV91
    273003-1-406331 DV38
    2228311-1-777565 DV27
    2407921-1-805942 DV39
    2152358-1-765533 DV91
    2520338-1-2351 DV81
    37909-2-269484 DV90
    5458-162-67519 DV 7
    253-580-58015 DV67
    985987-1-533212 DV95
    1072144-1-552402 DV89
    1197505-1-581331 DV60
    311-77-66961 DV53
    1034-189-113273 DV84
    155597688-2-2015 DV76
    554119-1-443889 DV87
    959966-1-527728 DV84
    155671985-2-2018 DV15
    822226-1-500338 DV30
    946321-1-524832 DV 4
    1070079-1-551873 DV75
    1502367-1-647955 DV 4
    2659472-1-842030 DV76
    253525-1-403482 DV83
    1352384-1-617663 DV55
    2365650-1-799916 DV26
    572-395-119290 DV30
    55250-11-333107 DV44
    50110-90-751 DV96
    12150-178-121154 DV50
    57983-56-340439 DV65
    53389-21-327631 DV94
    2885-2-45956 DV75
    912255-1-517351 DV80
    8091-204-85890 DV39
    1816-150-35131 DV 8
    446-504-97250 DV36
    57983-110-340442 DV31
    57983-2-340436 DV10
    650-529-126088 DV77
    172984-1-390438 DV 7
    155658593-2-2017 DV80
    244361-1-402185 DV03
    799-501-144983 DV 6
    346335-1-416918 DV 1
    1830365-1-710381 DV17
    1208781-1-583792 DV 3
    1634357-1-672463 DV 8
    1096259-1-558481 DV85
    2556783-1-827035 DV13
    346-266-76470 DV13
    655-419-132915 DV96
    155642971-2-2017 DV95
    838689-1-1227 DV83
    409464-1-1106 DV44
    2113546-1-758934 DV70
    155596428-2-2015 DV74
    46965-2-305596 DV84
    441-74-94389 DV76
    8-NT-2-3437 DV46
    15941-114-152468 DV 2
    17073-57-161121 DV67
    50110-29-752 DV93
    12657-192-125369 DV61
    14342-104-139493 DV16
    902-308-105023 DV92
    1968567-1-734899 DV14
    1566195-1-659905 DV90
    32423-34-247629 DV66
    155613068-2-2015 DV28
    155598964-2-2015 DV22
    814855-1-498995 DV84
    122-66-32044 DV 3
    138-289-35920 DV 4
    193-426-48244 DV 8
    40979-25-281810 DV34
    48870-93-312745 DV92
    243736-1-402080 DV78
    155600161-2-2015 DV18
    155650212-2-2017 DV 5
    155645799-2-2017 DV21
    54350-2-330635 DV79
    1112136-1-562326 DV50
    1618534-1-669844 DV92
    155591708-2-2015 DV 4
    2443890-1-811277 DV18
    959164-1-527572 DV68
    1613783-1-668894 DV42
    155604750-2-2015 DV39
    1255459-1-594255 DV87
    2634159-1-838588 DV15
    1264843-1-596415 DV80
    155628120-2-2016 DV 2
    1376703-1-622883 DV 9
    41416-2-283564 DV42
    1437404-1-635074 DV89
    2357-1-364165 DV93
    3394-105-50823 DV66
    682073-1-464676 DV33
    1683284-1-682766 DV 8
    1980171-1-736896 DV28
    533-555-116945 DV40
    155620166-2-2015 DV85
    1818848-1-708626 DV45
    44055-45-293941 DV 6
    280331-1-407350 DV 6
    2069791-1-751271 DV 7
    29658-1-368019 DV77
    1283112-1-601012 DV31
    1055712-1-548668 DV 7
    1111368-1-723 DV 0
    1300258-1-605400 DV36
    2065065-1-750454 DV23
    1722702-1-1624 DV27
    965423-1-528813 DV54
    121-261-33279 DV 6
    1294018-1-603887 DV62
    35226-2-259295 DV36
    510-302-109858 DV49
    558-472-101708 DV80
    434-15-93796 DV22
    32812-2-249262 DV63
    63961-21-356475 DV62
    13416-237-132168 DV16
    297-411-65651 DV44
    325-184-70973 DV42
    155591428-2-2015 DV50
    16097-92-153672 DV35
    1615238-1-669210 DV13
    29637-72-236658 DV51
    1911264-1-724536 DV95
    26408-2-223760 DV44
    1067-293-110051 DV17
    1961775-1-733746 DV91
    64919-2-359497 DV 9
    3393-136-50801 DV30
    541-81-118009 DV 6
    956-32-107593 DV41
    451283-1-431603 DV95
    1831632-1-710528 DV43
    37768-35-268853 DV 1
    1924089-1-726794 DV17
    48326-1-370814 DV30
    2020788-1-743331 DV 5
    42660-17-288805 DV 5
    578-536-121794 DV26
    735-383-117197 DV65
    1234448-1-589592 DV00
    1016702-1-539545 DV24
    46668-2-304466 DV 5
    834-70-131420 DV92
    1816794-1-708277 DV81
    17855-1-366482 DV37
    155643021-2-2017 DV97
    14704-236-142773 DV 4
    1110865-1-562008 DV10
    17365-9-163336 DV 1
    41620-12-284528 DV 7
    1899753-1-1790 DV42
    155612725-2-2015 DV74
    5044-11-64201 DV88
    542-72-13682 DV 3
    5837-93-70420 DV61
    53808-36-329105 DV67
    1324184-1-611278 DV70
    1460726-1-639840 DV45
    2124095-1-760828 DV47
    6490-23-74806 DV42
    1825769-1-709738 DV40
    32410-153-247549 DV76
    990776-1-534151 DV 8
    155585423-2-2014 DV17
    433-169-95685 DV25
    553-231-100703 DV 2
    1408703-1-629373 DV93
    986047-1-533223 DV20
    41871-56-285610 DV 8
    1470082-1-641778 DV37
    16831-38-159113 DV50
    2181780-1-770425 DV01
    155591597-2-2015 DV 9
    28936-2-233429 DV71
    155660230-2-2018 DV21
    1717346-1-689588 DV 3
    1995741-1-739366 DV15
    1207455-1-583557 DV26
    769318-1-484965 DV24
    981488-1-532202 DV30
    33739-33-253068 DV 7
    31844-219-245108 DV65
    32330-72-247193 DV98
    1620788-1-670194 DV24
    2504860-1-819564 DV70
    390-247-84722 DV99
    34573-11-256767 DV50
    1029014-1-542352 DV97
    2481871-1-816354 DV80
    702-437-15272 DV87
    155619483-2-2015 DV 3
    438-341-94672 DV13
    267-110-58681 DV55
    1060762-1-549583 DV81
    914084-1-517780 DV 0
    22480-45-201122 DV65
    155586395-2-2014 DV64
    605084-1-452330 DV30
    1005927-1-537107 DV80
    36765-2-264774 DV49
    324-329-70752 DV38
    155637214-2-2016 DV46
    82-30-15216 DV 4
    656-413-132700 DV15
    531092-1-440192 DV12
    407120-1-425377 DV84
    155623246-2-2016 DV64
    630-483-123250 DV16
    2099565-1-1970 DV10
    18317-162-169190 DV92
    577479-1-447566 DV23
    66159-91-363381 DV 5
    419758-1-427175 DV97
    2049827-1-747835 DV37
    866-176-101773 DV 1
    337-400-72743 DV78
    890666-1-512616 DV45
    1706379-1-687593 DV60
    283658-1-407733 DV63
    155625946-2-2016 DV00
    1454639-1-638870 DV93
    406984-1-425359 DV70
    29440-104-236201 DV20
    1019-225-108400 DV92
    30302-143-238170 DV78
    568933-1-446239 DV 3
    825-543-101039 DV95
    1574237-1-661345 DV 0
    219432-1-398251 DV 4
    2578686-1-830622 DV85
    24627-1-367362 DV40
    6606-136-75525 DV21
    155624335-2-2016 DV28
    370948-1-420312 DV29
    59849-1-372370 DV44
    539423-1-441401 DV40
    2218524-1-776090 DV 1
    898-241-102416 DV63
    1669246-1-679360 DV10
    212971-1-263 DV37
    30747-40-240144 DV93
    155593213-2-2015 DV 0
    18592-149-171941 DV78
    580-466-120204 DV33
    472-520-105024 DV39
    358157-1-418546 DV 7
    2278610-1-2148 DV20
    186-505-46878 DV80
    410-468-90986 DV47
    210550-1-396820 DV58
    644-570-114659 DV12
    155604285-2-2015 DV72
    2451381-1-812308 DV80
    515924-1-437913 DV75
    2182158-1-770482 DV 9
    990445-1-534073 DV 0
    2636962-1-838889 DV45
    2327456-1-793996 DV96
    511078-1-437311 DV94
    2424000-1-808259 DV 0
    63942-78-356454 DV47
    2301555-1-789993 DV19
    155647984-2-2017 DV60
    396-569-88934 DV99
    30170-22-237573 DV19
    1623537-1-670664 DV72
    835607-1-502581 DV22
    155657784-2-2017 DV70
    155589772-2-2014 DV 8
    297-154-64691 DV 1
    652-446-131292 DV 9
    50871-26-319483 DV54
    627-549-108161 DV 4
    2182171-1-770489 DV 7
    155668678-2-2018 DV84
    342-240-75526 DV50
    305-414-68335 DV49
    204-394-49730 DV 0
    939572-1-523411 DV40
    627-18-106521 DV23
    53286-102-327332 DV35
    1820287-1-1706 DV75
    1346970-1-616307 DV93
    2630377-1-837981 DV10
    404934-1-425041 DV12
    30773-73-240340 DV 8
    870-74-102345 DV77
    12793-123-126569 DV90
    1970964-1-735384 DV37
    1508-31-30247 DV 9
    155658360-2-2017 DV13
    820138-1-500016 DV 8
    31301-11-242424 DV 1
    798-434-122952 DV37
    1176195-1-577196 DV38
    521347-1-438253 DV70
    155698228-2-2020 DV68
    1245614-1-592096 DV29
    42928-69-289713 DV22
    1412728-1-1473 DV 2
    318-490-70786 DV85
    722-40-141442 DV11
    749185-1-479676 DV68
    21094-39-189991 DV48
    155671731-2-2018 DV 5
    276745-1-406809 DV 6
    39160-2-274372 DV03
    1486616-1-1504 DV39
    1647259-1-674887 DV 1
    12561-16-124551 DV78
    853111-1-505797 DV30
    356-19-77860 DV12
    155615059-2-2015 DV62
    300303-1-410024 DV20
    121-321-32351 DV45
    337-297-72453 DV95
    902679-1-515225 DV84
    62137-36-351360 DV54
    1817419-1-708382 DV51
    1277643-1-599680 DV72
    860-537-101447 DV 9
    2162963-1-767296 DV 0
    47028-19-305805 DV18
    30387-20-238537 DV 1
    417-139-92433 DV72
    42599-2-288539 DV90
    1031-503-116426 DV83
    2866-1-364241 DV84
    79324-1-960 DV40
    637305-1-457383 DV65
    242506-1-401841 DV60
    2158079-1-766480 DV11
    380241-1-421590 DV31
    32095-49-246231 DV30
    6709-169-76320 DV64
    65219-68-360495 DV20
    828-314-151242 DV 2
    155660186-2-2018 DV 4
    2451764-1-812364 DV93
    50033-16-316922 DV40
    1315587-1-609387 DV94
    456-145-98136 DV21
    50656-2-318866 DV55
    1617712-1-669626 DV14
    2503609-1-819377 DV88
    153843-1-386483 DV 9
    1091-157-111481 DV40
    67-501-20719 DV70
    1281233-1-600583 DV93
    155636329-2-2016 DV96
    203-438-49939 DV84
    38682-54-272473 DV 0
    155614464-2-2015 DV18
    155618602-2-2015 DV47
    1442235-1-636269 DV20
    2122574-1-1987 DV70
    1910501-1-724391 DV83
    1351606-1-617448 DV76
    963942-1-528502 DV19
    780179-1-487966 DV40

  • More examples https://www.presidencia.gob.pa/tmp/file/933/Informe-de-RendicinEn-de-Cuentas.pdf (attached here as well
    Informe-de-RendicinEn-de-Cuentas.pdf
    ) (copied here only a few examples that could be extracted using pdftotext)

    1570395-1-660585 D.V. 97
    3152-26-11756 D.V.60
    2413309-1-806698 D.V.89
    260141-1-404438 D.V.33
    2596686-1-833270 D.V.74
    43059-0023-290396 D.V.70
    27957-10-229660 D.V.5
    42819-60-289401 D.V.81
    8075-10-85775 D.V.49
    35751-78-261168 D.V.84
    811457-1-498110 D.V.88
    34932-2-258267 D.V.17
    545-496-119585 D.V. 22
    128877-1-382443 D.V.62
    1610553-1-668171 D.V.-22
    155660844-2-2018 D.V.3
    1066306-1-551009 D.V. 48
    64661-15-358683 D.V.40
    638-187-127806 D.V.27
    786-80-137748 D.V.6
    34401-28-255957 D.V.42
    155587169-2-2014 D.V. 9
    29838-41-235174 D.V.87
    19166-25-175181 D.V. 38
    1063-413-110270 D.V.87
    30240-120-237860 D.V.59
    673-355-132637 D.V.40
    776-228-140886 D.V.99
    60114-2-346008 D.V.81
    43059-13-290395 D.V.71
    8610-1-365164 D.V.86
    155660896-2-2018 D.V.6
    1991429-1-738739 D.V. 31
    541-81-118009 D.V. 6
    347621-1-417123 D.V. 58
    2464567-1-814023 D.V.2
    1305567-1-606868 D.V. 69
    85253-1-376213 D.V. 18
    2064-63-38048 D.V. 0
    2619425-1-836501 D.V. 76
    1848547-1-713252 D.V. 8
    822226-1-500338 D.V. 30
    652-212-129962 D.V. 35
    434-15-93796 D.V. 22
    32812-2-249262 D.V. 63
    356-19-77860 D.V. 12
    1848547-1-713252 D.V. 8
    521347-1-438253 D.V.70
    652-212-129962 D.V. 35
    12561-16-124551 D.V.78
    32812-2-249262 D.V. 63
    356-19-77860 D.V. 12
    155604680-2-2015 D.V.0
    4360-163-58819 D.V.75
    417-139-92433 D.V. 72
    2064-63-38048 D.V. 0
    20435-57-185073 D.V. 60
    85253 -1-376213 D.V. 18
    49511-149--315269 D.V.75
    1513069-1-650069 D.V. 09
    652-212-129952 D.V.35
    572-395-119290 D.V. 30
    155593964-2-2015 D.V.09
    105765-1-379278 D.V. 60
    1905219-1-723464 D.V.56
    822226-1-500338 D.V.30
    946321-1-524832 D.V. 04
    155599780-2-2015 D.V. 43
    533-555-116945 D.V. 40
    32812-2-249262 D.V. 63

  • Even more examples (not all of them with DV) on http://www.momentofiscal.com/images/DGI%20ENERO%202016%20AVISONOTIFICACIONES.pdf (attached
    DGI ENERO 2016 AVISONOTIFICACIONES.pdf
    )

  • Examples from https://www.gacetaoficial.gob.pa/pdfTemp/29103/80611.pdf (attached here as well
    80611.pdf
    )

  • More examples in https://www.superseguros.gob.pa/wp-content/uploads/2019/09/7.listado.pdf (attached
    7.listado.pdf
    )

    1702824-1-690294 DV 47
    30746-002-240130 DV 2
    1984263-1-3575 DV 90
    2117539-1-759645 DV 39
    46004-187-302083 DV96
    87524-6185 DV 09
    994855-1-534959 DV 48
    410-0018-001604 DV 26
    1002259-1-536336 DV 18
    1160940-1-53690 DV 21
    8-212-1552 DV 30
    247342-1-402582 DV 38
    1644095-1-674293 DV 97
    85253-1-376213 DV 18
    8-NT-2-25024 DV 36
    2110333-1-758424 DV 92
    36101-76-262338 DV 11
    2251567-0001-781630 DV 00
    15419-167-148643 DV 42
    PE-8-30 DV 23
    8-23-711 DV 73
    8-473-515 DV 70
    8 NT-1-22684 DV 98
    702-437-15272 DV 87
    2196897-1-37015 DV 80
    55462-2-333607 DV 81
    155630598-2-2016 DV30
    210-51-189871 DV 72
    1776638-1-01044 DV 03

  • Plenty of examples in http://www.css.gob.pa/PROVEEDORES%20CSS.pdf

  • Examples from http://docs.panamacompra.gob.pa/conveniomarco/Circulares/Pasajes%20A%C3%A9reos/Circulares%20y%20Documentos%20Nuevos%20Agosto%202014/GUIA%20DE%20COMPRADORES%20DE%20PASAJES%20AEREOS.pdf:

    • RUC 253-92-57027 DV 76
    • RUC 130-377-34706 DV 2
    • RUC 58223-2-855 DV04
    • RUC 356-146-78600 DV 90
    • RUC 499-238-1086-23 DV 92
    • RUC 1870951-1-1751 DV 18
  • Examples from https://www.superseguros.gob.pa/images/files/comunicados/BBA_Corp/7.listado.pdf

    • 1702824-1-690294 DV 47
    • 30746-002-240130 DV 72
    • 1984263-1-3575 DV 90
    • 2117539-1-759645 DV 39
    • 46004-187-302083 DV96
    • 87524-6185 DV 09
    • 994855-1-534959 DV 48
    • 410-0018-001604 DV 26
    • 1002259-1-536336 DV 18
    • 1160940-1-53690 DV 21
    • 8-212-1552 DV 30
    • 247342-1-402582 DV 38
    • 1644095-1-674293 DV 97
    • 85253-1-376213 DV 18
    • 8-NT-2-25024 DV 36
    • 2110333-1-758424 DV 92
    • 36101-76-262338 DV 11
    • 2251567-0001-781630 DV 00
    • 15419-167-148643 DV 42
    • PE-8-30 DV 23
    • 8-23-711 DV 73
    • 8-473-515 DV 70
    • 8-NT-1-22684 DV 98
    • 702-437-15272 DV 87
    • 2196897-1-37015 DV 80
    • 55462-2-333607 DV 81
    • 155630598-2-2016 DV30
    • 210-51-189871 DV 72
    • 1776638-1-01044 DV 03
  • Examples from https://www.superseguros.gob.pa/images/files/comunicados/BBA_Corp/6.listado.pdf

    • RUC 8-NT-1-12701DV89
    • RUC 8-NT-2-2039 DV 42
    • RUC 8-NT-0001-012571 DV 66
  • Other examples picked from the web:

    • RUC 16292-152-155203 D.V. 65
    • RUC 1384907-1-624944 D.V. 04
    • RUC 2612285-1-835546 DV 17
    • RUC 2456294-1-812932 DV 90
    • RUC 2357866-1-798817 DV 37
    • RUC: 693572-1-467020 DV: 59
    • RUC 2169546-1768436 DV: 18
    • RUC 1807352-1-706553 DV: 01
    • RUC 2344280-1-796794 DV: 38
    • RUC: 642212-1-458297 DV: 20
    • RUC: 1062338-1-549784 DV: 23
    • RUC: 2590659-1-832256 DV: 03
    • RUC 2152969-1-765657 DV 33
    • RUC 643441-1-458481 DV 58
    • RUC 1345575-1-616087 DV 80
    • RUC 8-305-117 DV 40
    • RUC 820138-1-500016 DV 8
    • R.U.C. 3724-0103-053659 D.V.43
    • RUC. 500189-1-435682 D.V. 95
    • RUC: 8-NT-1-10284-DV 85
    • R.U.C. 1818454-1-708570 D.V. 80
    • RUC 46004-0187-302083 D.V. 96
    • RUC: 2058-66-37967 D.V.80
    • R.U.C 4265-60-58061 D.V.00
    • R.U.C. 1897412-1-722027 DV 1
    • RUC. 280-134-61098 D.V.2
    • RUC: 15430-249-148718 DV. 09
    • RUC 2492633-1-817803 DV 36
    • RUC 2092063-1-755310 D.V. 00
    • RUC 2092695-1-755448 D.V. 00
    • RUC. 1407887-1-30747 D.V 18
    • R.U.C: 1647770-1-675008 D.V. 52
    • Ruc: 8-NT-2-726340 D.V.56
    • R.U.C. 2506296-1-819700 D.V. 19
    • R.U.C. 3724-0103-053659 D.V.43
    • Ruc: 699126-1-468330 DV. 17
    • R.U.C. 756-374-135990 D.V. 70
    • RUC: 8-257-1465 D.V. 84
    • Ruc. 1200810-1-582064 DV 42
    • R.U.C. 224080-4520-1122 D.V. 65
    • RUC 126634-1-382152 DV 92
    • RUC: 54920-21-332178 D.V. 07
    • RUC . 6763-10-76640 DV. 08
    • R.U.C. 315710-1-412268 D.V.59
    • RUC: 854254-1-506006 DV:45
    • RUC: 1410729-1-629832 DV. 92
    • RUC 757127-1-481594 DV 5
  • More examples (not retrieved):

  • List with RUC numbers but without DV: http://www.bdo.com.pa/getmedia/059cdd11-c76c-43a1-8de1-f5993d6d5193/Boletin-1-Enero-2017-Agentes-de-Retencion.pdf.aspx?ext=.pdf&disposition=attachment

  • Another list with RUC numbers but without DV: https://dgi.mef.gob.pa/_7FacturaElectronica/Listadofe.php

  • Another list without DV: https://www.rbc.com.pa/images/banners/RBC/LEYES_DECRETOS_GACETAS/LISTADO%20DE%20MOROSOS%202.pdf

[stdnum.do] ncf: DGII is implementing a new sequence which has to pass validations

The new sequence will have 11 positions instead of 19, and it will start with B instead of A or P
image

In theory, this should be as simple as changing https://github.com/arthurdejong/python-stdnum/blob/master/stdnum/do/ncf.py#L66 to:

def validate(number):
    """Check if the number provided is a valid NCF."""
    number = compact(number)
    if len(number) not in [19, 11]:
        raise InvalidLength()
    if number[0] not in 'ABP' or not number[1:].isdigit():
        raise InvalidFormat()
    if number[9:11] not in (
            '01', '02', '03', '04', '11', '12', '13', '14', '15'):
        raise InvalidComponent()
    return number

This is effective on May 1st, so this change should be live as soon as possible, as validations on their side already consider this new structure.

ValueError raised on specific input

Not sure if you regard this as a bug or not.

When given input that:

  1. evaluates as a digit (input_string.isdigit())
  2. cannot be type casted to int (int(input_string))

...a ValueError is raised instead of a stdnum.exceptions.ValidationError.

Example:

from stdnum import isbn
isbn.validate('978-9024538²70')  # notice the superscript of 2 ('²')

Refactor for standard way of accessing submodules internatinally in autmated way

I'm working on an implementation to automatically detect the right check let's say for a tax number check in alll current (and future) supported countries, given that I have knowledge of the country code.

I would do therefore

try:
    import stdnum.COUNTRY_CODE
except:
    pass

validated = stdnum.COUNTRY_CODE.vat.validate(foo)

While I can trust on existence of the vat attribute (or a corresponding alias) in some modules, I cannot in others like ca (not imported in __init__.py). This reduces the potentialization of stdnum in automated scripts. And I really don't want to go to the filesystem level in order to detect the presence of some implementation. 😉

It would be great to be able to ensure by convention at least presence of the following aliases:

  • vat
  • personal
  • business
    And that they would return a NotImplemented error if not implemented.

What do you think?

LV birthdate parser failed

Example with LV personal code:

In [27]: stdnum.lv.pvn.get_birth_date('200390-11718')

ValueError Traceback (most recent call last)
in ()
----> 1 stdnum.lv.pvn.get_birth_date('200390-11718')

/.../lib/python2.7/site-packages/stdnum/lv/pvn.pyc in get_birth_date(number)
80 day = int(number[0:2])
81 month = int(number[2:4])
---> 82 year = int(number[4:6])
83 year += 1800 + int(number[6]) * 100
84 try:

ValueError: invalid literal for int() with base 10: '-'

The reason is '-'. Probably number = compact(number) can help if put it on 1st line in this function to replace '-'.

Python 3 support

Some kind of Python 3 support would be nice, since its already widely used.

In [1]: from stdnum.eu import vat
In [2]: vat.check_vies("FI 2297826-1")
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-2-a5ad14006baf> in <module>()
----> 1 vat.check_vies("FI 2297826-1")

/home/jrasanen/development/envs/canny33/src/python-stdnum/stdnum/eu/vat.py in check_vies(number)
    126     if not _vies_client:
    127         from suds.client import Client
--> 128         from urllib import getproxies
    129         _vies_client = Client(vies_wsdl, proxy=getproxies())
    130     return _vies_client.service.checkVat(number[:2], number[2:])

ImportError: cannot import name getproxies

IBAN account number check

The iban module returns 'BE41091811735141' as a valid iban, whilst it is not, because it does not have a valid account number check (Using https://www.ibancalculator.com/iban_validieren.html as validator shows the error)

Here is a psuedo-code representation of how an account number should be checked:

Belgian IBAN number: BEkk BBBC CCCC CCxx (16 characters)

k = check digit for the entire IBAN
B = bank code
C = Account Number
x = check digit for the Account Number

Example: BE68 5390 0754 7034

ISO Country Code = BE (Belgium)
IBAN Check Digits = 68
BBAN = 5390 0754 7034 -> 12 characters, the usual BBAN format = 999-9999999-99
Bank Identifier = 539
Account Number = 0075470
Account Number check digits = 34 -> 2 digits MOD97

Check algorithm which is applied on the account number

The entered check digit (CD1) is the last two digits of the Account Number.

The calculated check digit (CD2) is derived by concatenating the first two sections of the Account Number and calculating the remainder on dividing this by 97. If the remainder is equal to '0', then the calculated check digit is taken to be '97'.

If the entered check digit (CD1) and calculated check digit (CD2) are equal, then the Account Number is valid, else the check has failed.

Additionally, if the entered check digit (that is, the last section) is '00', then the Account Number is invalid because the calculated check digit can never be '00' as per the 3rd point.

Example using Account Number '123-4567890-78':

The entered check digit (CD1) is '78'.
The concatenation of the first two sections gives '1234567890'.
Divide the result by '97'.
1234567890 / 97 = 12727504
Derive the remainder.
1234567890 - (12727504 * 97) = 2
Therefore CD2 = 2.
Here CD1 <> CD2, therefore the Account Number is not valid.
In this case, a valid Account Number would be '123-4567890-02'.

Any hope for a list of all validation functions?

Suppose that we are given a random number and don't know the format. It would be nice if we could try every validate() function in turn, to provide heuristics for what kind of number we're looking at.

Add support for South Korea TIN

Online search:

  • http://www.ftc.go.kr/www/bizCommList.do?key=232

  • Examples:

    • List with plenty of examples: https://www.psys.co.kr/index.php?pname=myvender&type=wide
    • I was unable to find any list of numbers online, but the number is specified in some certificate, and searching for images of such certificate (using its korean name) we can extract a bunch of examples: https://www.google.com/search?q=%EC%82%AC%EC%97%85%EC%9E%90%EB%93%B1%EB%A1%9D%EC%A6%9D&tbm=isch

      214-87-98889
      617-86-11575
      114-86-00579
      221-83-01195
      220-87-57205
      116-82-00276
      615-82-11718
      220-82-05060
      129-81-16573
      119-86-79111
      134-86-72683
      206-18-12345
      148-05-00404
      209-82-06382
      124-86-85333
      383-37-00143
      321-81-00982
      113-02-43949
      113-86-21886
      133-81-32077
      220-87-18070
      116-82-00276
      128-81-63302
      375-10-00859
      311-81-22413
      305-81-38564
      193-86-00010
      220-81-66148
      221-81-32210
      113-85-26486
      312-12-25168
      119-87-08063
      156-23-00883
      649-82-00117
      503-86-09407
      122-81-62455
      504-81-85233
      514-81-68599
      130-81-92528
      680-87-00210
      279-81-01263
      134-86-24634
      409-86-33769
      135-81-06333
      133-81-40621
      134-86-44004
      615-86-09068
      374-81-01516
      106-82-07200
      231-81-02896
      128-39-49844
      682-85-00885
      639-86-00985
      183-98-00113
      119-02-43947
      133-81-29441
      415-06-83258
      114-86-61464
      130-86-79710
      110-12-39727
      533-85-00526
      135-09-24640
      301-82-62166
      766-88-00563
      621-15-41743
      515-81-10315
      214-87-78980
      609-81-99124
      303-82-07378
      109-81-33637
      314-86-53230
      110-14-16596
      138-81-44092
      141-81-18585
      219-01-39810
      308-81-41001
      616-24-46281
      130-86-89294
      201-81-54845
      884-17-01026
      156-23-00883
      202-81-42420
      760-06-00079
      312-81-95317
      120-81-57465
      120-86-39706
      515-07-68272
      301-81-14992
      201-81-76228
      417-85-07912
      130-81-92528
      402-82-15272
      169-86-00394
      410-25-53731
      735-85-00501
      515-04-62016
      131-86-40843
      632-11-01006
      140-81-67744
      204-06-91556
      112-81-30811
      201-86-25781
      317-81-04543
      305-81-70638
      128-02-41206
      312-30-06675
      105-17-41513
      410-86-53770
      132-81-38608
      121-81-25326
      119-82-08146
      606-81-54507
      610-81-04971
      568-41-00305
      314-86-00956
      114-86-00579
      107-82-09351
      113-86-60856
      314-81-25684
      124-86-65341
      616-25-12643
      110-12-39727
      109-81-62393
      301-81-91475
      121-81-78347
      504-85-11802
      130-47-17700
      402-82-15272
      416-81-48042
      314-86-42432
      119-19-96781
      314-86-63209
      214-88-49333
      219-01-39810
      303-81-44911
      303-12-73313
      301-86-12266
      410-25-53731
      143-81-10463
      124-86-13144
      118-81-09714
      306-81-22629
      603-81-24270
      610-09-84339
      606-86-06989
      348-13-00692
      201-81-99798
      224-81-41168
      113-81-92367
      582-90-00497
      375-88-00519
      580-21-00836
      110-81-07390
      515-05-32580
      138-81-03499
      533-87-01306
      305-81-87876
      121-81-42209
      275-87-01259
      669-81-00996
      137-86-39058
      214-11-58465
      135-29-80067
      415-82-11025
      501-26-78904
      214-87-99743

    • It is possible to find some more examples in https://www.google.com/search?q=%22Business+registration+number%22+site%3A.kr

      129-86-38970
      506-82-06755
      102-81-03525
      1208200052
      131-82-00372
      314-82-01980
      420-87-00883
      144-81-25090
      782-86-00130
      113-86-46500
      364-81-00669
      114-86-04968
      214-81-04230
      415-81-19511
      124-81-79802
      602-81-66559
      109-81-39795
      220-88-88699
      215-87-86862
      105-86-61489
      107-87-70962
      114-81-44645
      317 - 81 - 11175
      129-81-85385
      130-86-35857
      816-81-00840
      117-81-77714
      217-81-14493
      220 88 69974
      104-81-25258
      306-82-00417
      280-86-01410
      209-82-05326
      201-85-17396

    • Find more examples in https://www.google.com/search?q=%22Business+registration+No%22+site%3A.kr

      220-81-83676
      129-86-39907
      318-81-02096
      107-87-13471
      206-86-50913
      220-81-83676
      208-81-24115
      132-86-04520
      728-86-00316
      113-86-38602
      129-81-23356
      114-82-62150
      110-84-02173
      104-84-03406
      110-81-05034
      119-82-63265
      222-81-03192
      101-82-13065
      515-81-40648
      104-81-36565
      394-92-00410
      205-81-26341
      102-81-42945
      134-81-06679
      128-81-77295
      202-81-04367
      138-81-44277
      809-81-01574
      214-88-51159
      220-87-18070
      410-82-83844
      119-86-44529
      110-81-40725
      187-82-00055
      398-85-00113
      127-11-87351
      211-86-23306
      211-87-67960
      204-86-46427
      102-81-42945
      108-19-83613
      211-86-08983
      102-81-42945
      211-86-39754
      110-81-05034
      129-81-30691
      220-88-75699

Mexican RFC check digit

The Mexican RFC check digit is being miscalculated when it should be an "A".
The example to check that is: "MAHM670102NJA".

From the document that is in the comments:
"Si el residuo es igual a 10 el dígito verificador será “ A”."

If the remainder equals 10, then the check digit is an "A".
But the function that calculates the check digit returns "1".

[stdnum.do] ncf.check_dgii is throwing an AttributeError

Doing:

from stdnum.do import cedula, ncf, rnc
ncf.check_dgii('101566332','A010010010100000001')

Throws:

Traceback (most recent call last):
  File "C:\Users\gvalv\rnc-cedula.py", line 3, in <module>
    ncf.check_dgii('101566332','A010010010100000001')
  File "C:\Users\gvalv\AppData\Local\Programs\Python\Python36-32\lib\site-packages\stdnum\do\ncf.py", line 132, in check_dgii
    return _convert_result(result)
  File "C:\Users\gvalv\AppData\Local\Programs\Python\Python36-32\lib\site-packages\stdnum\do\ncf.py", line 99, in _convert_result
    for key, value in json.loads(result.replace('\t', '\\t')).items())
AttributeError: 'dict' object has no attribute 'replace'

Czech VAT number marked as invalid, but OK in VIES

Hi, first of all thanks for maintaining an invaluable library that is underappreciated.

The problem I'm having is with the VAT number CZ 682127228, which stdnum reports as invalid but VIES says is OK, and even returns info about its registrant. Curiously, the number used as an example of the special case in the documentation ("640903926") is considered invalid by VIES.

Unfortunately, I was unable to find the official formula for verifying Czech VAT numbers.

check_vies is not working anymore

i'm using the following code:

from stdnum.eu import vat
print vat.check_vies('FR 75483487112')

and get the following error:

raceback (most recent call last):
  File "t.py", line 2, in <module>
    print vat.check_vies('FR 75483487112')
  File "/Users/sebest/.virtualenvs/pxlapi/lib/python2.7/site-packages/stdnum/eu/vat.py", line 144, in check_vies
    return _get_client().checkVat(number[:2], number[2:])
  File "/Users/sebest/.virtualenvs/pxlapi/lib/python2.7/site-packages/stdnum/eu/vat.py", line 128, in _get_client
    _vies_client = Client(vies_wsdl, proxy=getproxies()).service
  File "/Users/sebest/.virtualenvs/pxlapi/lib/python2.7/site-packages/suds/client.py", line 112, in __init__
    self.wsdl = reader.open(url)
  File "/Users/sebest/.virtualenvs/pxlapi/lib/python2.7/site-packages/suds/reader.py", line 152, in open
    d = self.fn(url, self.options)
  File "/Users/sebest/.virtualenvs/pxlapi/lib/python2.7/site-packages/suds/wsdl.py", line 136, in __init__
    d = reader.open(url)
  File "/Users/sebest/.virtualenvs/pxlapi/lib/python2.7/site-packages/suds/reader.py", line 79, in open
    d = self.download(url)
  File "/Users/sebest/.virtualenvs/pxlapi/lib/python2.7/site-packages/suds/reader.py", line 101, in download
    return sax.parse(string=content)
  File "/Users/sebest/.virtualenvs/pxlapi/lib/python2.7/site-packages/suds/sax/parser.py", line 136, in parse
    sax.parse(source)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/sax/expatreader.py", line 110, in parse
    xmlreader.IncrementalParser.parse(self, source)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/sax/xmlreader.py", line 123, in parse
    self.feed(buffer)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/sax/expatreader.py", line 217, in feed
    self._err_handler.fatalError(exc)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/sax/handler.py", line 38, in fatalError
    raise exception
xml.sax._exceptions.SAXParseException: <unknown>:21:6: mismatched tag

Support USB IDs

Please, support looking up vendor and model for USB ID. These can be found at http://www.linux-usb.org/ The data can be retrieved via an API or included in the package. Note that most POSIX systems have this data already available in e.g. /usr/share/misc/usb.ids

stdnum 1.8 installation fails on windows

$ pip install  python-stdnum
Collecting python-stdnum
  Downloading python-stdnum-1.8.tar.gz (421kB)
    100% |████████████████████████████████| 430kB 640kB/s
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\a\AppData\Local\Temp\pip-build-ziqc4_ov\python-stdnum\setup.py", line 38, in <module>
        long_description = fp.read()
      File "c:\users\a\appdata\local\programs\python\python36\lib\encodings\cp1252.py", line 23, in decode
        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
    UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 967: character maps to <undefined>

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\a\AppData\Local\Temp\pip-build-ziqc4_ov\python-stdnum\

[stdnum.do] check_dgii on rnc is giving JSONDecodeError

Traceback (most recent call last):
  File "C:\Users\gvalv\rnc-cedula.py", line 3, in <module>
    rnc.check_dgii('131566332')
  File "C:\Users\gvalv\AppData\Local\Programs\Python\Python36-32\lib\site-packages\stdnum\do\rnc.py", line 149, in check_dgii
    return _convert_result(result)
  File "C:\Users\gvalv\AppData\Local\Programs\Python\Python36-32\lib\site-packages\stdnum\do\rnc.py", line 115, in _convert_result
    for key, value in json.loads(result.replace('\t', '\\t')).items())
  File "C:\Users\gvalv\AppData\Local\Programs\Python\Python36-32\lib\json\__init__.py", line 354, in loads
    return _default_decoder.decode(s)
  File "C:\Users\gvalv\AppData\Local\Programs\Python\Python36-32\lib\json\decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Users\gvalv\AppData\Local\Programs\Python\Python36-32\lib\json\decoder.py", line 355, in raw_decode
    obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 2 (char 1)

Validate Bitcoin addresses?

Hi. Would it be interesting to add code to validate bitcoin addresses in this library? It would be useful when asking users to provide a bitcoin address in a web application.

I do not know how to properly validate them myself, but see that valid length of a BTC is 26 to 35 characters, according to https://en.bitcoin.it/wiki/Address, while https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki#Reference_implementations shows 42 character long addresses. A complicating factor is Lightning addresses explained in https://github.com/lightningnetwork/lightning-rfc/blob/master/11-payment-encoding.md .

DNI as Argentinian ID number

Hi,
Do you think that for Argentina we could add validation for DNI?
DNI numbers are used to identify physical people in Argentina, but the only thing we have to validate is that there are no letters, and that the number has 7 or 8 digits at least.
Best

Support mac addresses

Support lookup of vendor and model for a mac address. Data is available under aaronjwood/PortAuthority#84 but best is to contact the author. He has made a FOSS collection, especially for these purposes. This service can be called via the API or can be included. Best to ask him.

Venezuela VATs

Hello,

Do you think it would be possible to at VAT numbers of Venezuela. The validation in JS can be seen here: https://github.com/formvalidation/formvalidation/blob/master/src/js/validator/vat.js#L1378 and tested here: https://formvalidation.io/guide/validators/vat/venezuelan-vat-number/

At the moment I'm just using something similar to this:

def validate_ve_vat_number(number):
    def compact(number):
        number = clean(number, ' -').upper().strip()
        if number.startswith('VE'):
            number = number[2:]
        return number

    number = compact(number)
    if number[0] not in 'VEJPG': #or not isdigits(number):
        raise InvalidFormat()
    if len(number) != 10:
        raise InvalidLength()
    company_type = {
        'V': 4,
        'E': 8,
        'J': 12,
        'P': 16,
        'G': 20
    }
    base_sum = company_type[number[0]]
    weights = (3, 2, 7, 6, 5, 4, 3, 2)
    base_sum += sum(weights[i] * int(n)
                   for i, n in enumerate(number[1:9]))
    base_sum = 11 - base_sum % 11
    if base_sum == 11 or base_sum == 10:
        base_sum = 0
    if base_sum != int(number[9]):
        raise InvalidChecksum()
    return number

And some additional information for format is here: https://en.wikipedia.org/wiki/VAT_identification_number#VAT_numbers_of_Latin_American_countries

Add support for Indonesia TIN

Validation:

Examples (some of them don't validate using Luhn, and there are repeated numbers):

  • Found on the Internet:

    01.001.634.3-093.000
    76.310.346.2-601.000
    02.037.103.5-502.000
    01.318.451.0-054.000

  • By clicking on the companies listed in https://www.idx.co.id/en-us/listed-companies/company-profiles/ we can get their NPWP.

    01.334.427.0-054.000
    01.609.052.4-017.000
    01.362.014.1-054.000
    02.504.191.4-054.000
    01.721.123.6-054.000
    01.709.626.4-054.000
    01.001.610.3-051.000
    01.326.008.8-092.000
    02.399.244.9-091.000
    02.881.392.1-036.000
    01.002.124.4-038.000
    01.347.428.3-018.000
    01.311.830.2-073.000
    01.360.902.9-054.000
    01.820.068.3-054.000
    01.504.513.1-054.000
    02.038.425.1-054.000
    01.000.863.9-054.000
    01.132.905.9-092.000
    01.349.129-5-054-000
    01.671.242.4-054.000
    01.000.166.7-054.000
    01.122.572.9-092.000
    01.761.303.5-405.000
    01.108.165.0-073.000
    01.000.161.8-092.000

  • https://lpse.jabarprov.go.id/eproc4/dl/92fd75e21cf1397a2f88893f0fc5c319a8853e5baa63b2a24dd80c290fdb2a98703a433ef980183a240354473681980f7cf3778c5a84d0eef92b55891b13a1f335f0de9cfc0af8b6f510ced0867c7cb7cb9a33dbd0218fcd611d7ca8cdb2b8c5

    02.554.459.4-422.000
    02.098.700.4-013.000
    02.098.788.9-013.000
    02.244.448.3-428.000
    01.210.739.7-424.000
    01.421.821.8-424.000
    01.436.246.1-429.000
    01.216.217.5-441.000
    02.207.332.6-606.000
    01.349.759.9-083.000
    31.281.245.8-423.000
    02.481.070.7-423.000
    02.972.041.4-428.000
    31.470.209.3-428.000
    03.187.078.5-201.000
    02.587.597.2-429.000
    02.567.804.6-428.000
    02.241.591.3-424.000
    01.455.616.1-424.000
    02.333.122.6-441.000

  • http://inatrade.kemendag.go.id/index.php/home/detail_hakAkses

    748575982452000
    846150324629000
    010692903641000
    811145994124000
    210614467418000
    764038907023000
    817434558048000
    825537079086000
    762278075077000
    017048299643001
    721437267602000
    813195435017000
    755023033513000
    014300040123000
    317784585606000

  • http://lpse.simeuluekab.go.id/eproc/lelang/pemenang/123383;jsessionid=A1BCFEB86E1D32263828B47C2A6E1E17

    01.931.919.3-101.000
    03.030.253.3-104.000
    02.071.363.2-101.000
    02.887.783.5-105.000
    02.650.677.4-101.000
    02.561.935.4-101.000
    03.128.360.9-101.000
    02.008.503.1-101.000
    01.548.452.0-429.000
    01.855.599.5-101.000
    02.151.039.1-106.000
    02.690.654.5-101.000
    01.452.340.1-101.000
    31.538.040.2-106.000
    02.071.326.9-101.000
    02.888.370.0-106.000
    02.932.094.2-101.000
    02.956.222.0-106.000
    02.976.331.5-103.000
    02.502.873.9-101.000
    31.496.676.3-106.000
    01.575.888.1-101.000
    01.657.878.3-101.000
    02.102.011.0-101.000
    02.956.223.8-106.000
    01.931.919.3-101.000
    02.719.242.6-106.000

  • http://lpse.pesisirselatankab.go.id/eproc/lelang/pemenang/1181599;jsessionid=UiSgKR0Sn_kk0k4UBDJGrt99qT-rXqpHKfhGNl23

    01.688.820.0-201.000
    02.872.808.7-201.000
    83.132.665.7-201.000
    02.551.560.2-201.000
    01.688.745.7-201.000
    02.585.033.0-216.000
    01.508.687.0-201.000
    02.717.384.8-201.000
    01.129.103.6-201.000
    76.326.884.4-205.000
    90.004.581.6-201.000
    02.718.070.2-201.000
    01.268.444.5-201.000
    03.244.868.0-201.000
    74.654.394.1-201.000
    02.998.227.9-201.000
    02.984.042.8-201.000
    84.054.217.9-609.000
    01.268.426.2-201.000
    01.987.068.2-216.000
    70.838.297.3-201.000
    01.580.769.6-201.000
    31.578.913.1-201.000
    71.269.216.9-203.000
    31.682.116.4-201.000
    01.129.154.9-201.000
    01.580.849.6-201.000
    01.622.873.6-201.000
    01.633.544.0-311.000
    82.790.415.2-205.000
    80.742.886.7-201.000
    31.696.264.6-201.000
    02.668.150.2-201.000
    01.917.470.5-201.000
    01.230.106.5-201.000
    01.258.022.1-201.000
    01.688.820.0-201.000

  • https://lpse.sulselprov.go.id/eproc/lelang/pemenang/5144036;jsessionid=1PCEq-7yB94OEiKXKzt_EcVPxT8pRqgOnkBhZ7Uv

    02.934.102.8-804.000
    02.679.257.2-801.000
    01.000.483.6-051.000
    01.796.259.8-805.000
    02.547.885.0-805.000
    02.661.025.3-805.000
    01.906.354.4-801.000
    02.056.129.6-801.000
    01.211.695.0-805.000
    01.211.695.0-805.000
    03.026.787.6-805.000
    20.811.634.1-801.000
    76.992.174.3-802.000
    01.690.679.4-801.000
    01.815.656.2-807.000
    01.502.718.8-805.000
    01.690.980.6-805.000
    02.934.102.8-804.000
    02.636.703.7-814.000
    01.773.770.1-805.000
    75.193.535.4-805.000
    03.217.024.3-805.000
    02.643.101.5-805.000
    01.125.612.0-805.000
    02.303.892.0-801.000
    02.974.105.5-801.000
    03.195.088.4-801.000
    01.562.420.8-805.000
    02.910.648.1-805.000
    01.966.099.2-801.000

  • http://lpse.bandung.go.id/eproc/lelang/pemenang/1711260;jsessionid=2516644769B29C45712599E4D222CC44

    02.480.884.2-444.000
    02.332.747.1-429.000
    01.436.246.1-441.000
    31.154.173.4-411.000
    01.450.058.1-423.000
    01.822.790.0-441.000
    31.777.549.2-429.000
    01.210.739.7-424.000
    02.300.607.5-429.000
    31.156.437.1-002.000
    02.173.740.8-002.000
    01.627.251.0-404.000
    31.729.429.6-542.000
    02.527.123.0-017.000
    31.460.812.6-071.000
    02.790.820.1-428.000
    02.065.356.4-429.000
    01.970.323.0-424.000
    02.203.654.5-429.000
    02.446.000.8-429.000
    01.822.790.0-441.000
    01.677.930.8-429.000
    01.548.436.3-423.000
    01.482.738.0-424.000
    01.677.956.3-428.000
    02.682.759.2-542.000
    01.216.271.5-441.000
    02.564.234.9-421.000
    66.487.591.1-071.000
    01.105.197.6-424.000
    02.083.962.7-422.000
    02.480.873.5-423.000
    21.078.367.6-424.000
    80.502.237.3-541.000
    01.555.547.7-429.000
    01.910.250.8-429.000
    01.977.486.8-429.000
    31.294.519.9-424.000
    01.455.616.1-441.000
    01.118.819.0-441.000
    01.421.821.8-424.000
    02.081.228.5-424.000
    02.241.591.3-424.000
    02.480.884.2-444.000

  • https://lpse.pu.go.id/eproc/lelang/pemenang/4013064;jsessionid=3U0P47ykTTRXOBNg7io5P9iF4LeTTwYUo2NR9Duk
  • https://lpse.slemankab.go.id/eproc/publicberitadetail/223054;jsessionid=FmMtmpcxskRz730GhDzR_DKkidQuuzclltHcjfUJ

    01.464.753.1-542.000
    01.544.103.3-545.000
    01.207.840.8-542.000
    02.755.249.6-541.000
    01.544.009.2.543.000

  • http://simpbj.cirebonkab.go.id/

    86.127.083.3-426.000
    01.997.870.9-038.000
    01.457.751.4-426.000
    01.457.751.4-426.000
    02.367.986.3-426.000

Adding a type or catogory flag

Hi Arthur,

Would you be open to adding a flag to the number to identify if they are a tax identifier for example or a bank identifier or just a number check? As well as an api to get a list of numbers that match a type?

U.S. state tax ID numbers

SSN (personal) and EIN/TIN (corporate) are numbers issued by the U.S. federal government.

For business tax-exempt status (i.e., business that buys goods for resale) are also required to have a state tax-exempt number in order to purchase goods from suppliers and not pay state sales tax for resale goods.

First state California:
Nine digits plus hyphen between 3rd and 4th digits: NNN-NNNNNN
Caveat: Older ID's will be 8 digits - validate by prepending a leading 0: 0NN-NNNNNN

The next question is how to designate numbers as U.S. state issued numbers since the U.S. states do not follow EU style rules a la VAT, but I suspect that will be an issue for applications (i.e., Tryton) to verify.

Add support for Saudi Arabia TIN

Examples:

IBAN check for experimental IBAN countries / unimplemented country exception?

https://www.iban.com/structure
I would like to like to let users enter IBANs of experimental IBAN countries into my application too, or If a country doesn't use IBANs, let him use other formats. Currently, it's not possible to detect, whether entered IBAN is invalid, or the country is not implemented.

Perhaps it would be better to return new exception (InvalidCountry) when info[0][1].get('bban', '') returns nothing instead of raising InvalidFormat?

[1.9] stdnum.do: Not validating NCF on with DGII's WebService

It seems that the regulator deprecated this validation from their SOAP WebService; now the only available method to do this validation is using this tool (manually):

http://www.dgii.gov.do/servicios/consultas/Paginas/ConsultaNCF.aspx

@arthurdejong If you could please have a look at this tool and let us know if it's possible to have this integrated into stdnum. This needs a different technique (scraping), which I don't know if it's under stdnum's approach to get information.

Let me know if this is possible.

Unclosed file warning

Running about ubuntu 16.04, python 3.5, i get this warning:

/home/psk/.virtualenvs/tryton40/lib/python3.5/site-packages/stdnum/numdb.py:202:
ResourceWarning: unclosed file <_io.BufferedReader name='/home/psk/.virtualenvs/tryton40/lib/python3.5/site-packages/stdnum/iban.dat'>
db = read(reader(resource_stream(name, name + '.dat')))

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.