Repository navigation
Conversation
clean() padded a one-digit county with a leading zero but also dropped the slash after it, so F5/1055/2013 became F051055/2013 and was rejected as InvalidFormat. The same happened to J/2/750/2012 and J1/384/13.05.2015. Keep the slash and anchor the pattern to the start of the number.
…on with python-stdnum Since 2024-07-26 the trade register uses a 14 character format without slashes (YAAAAXXXXXXJJC): register letter, registration year, 6 digit serial, county code and a check digit. Such numbers were rejected as InvalidFormat. Port the validation from python-stdnum (stdnum/ro/onrc.py, commit cd94bf11). For the new format the year must be from 1990 to the current year. The county must be 01 to 40, 51 or 52 before 2024, one of those or 00 in 2024, and 00 after 2024. The check digit is the letter's character code modulo 10 plus the other digits, modulo 10. Old format numbers now follow the same rules as python-stdnum: the whole number must match, so four-part numbers are rejected. Counties are 01 to 40, 51 and 52, so 00 and 41 are no longer accepted. The year must be from 1990 to 2024. Serials longer than 5 digits and years that are not 4 digits raise InvalidLength. Surrounding whitespace is trimmed first.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since 2024-07-26 the Romanian trade register (ONRC) assigns numbers in a 14-character format without slashes,
YAAAAXXXXXXJJC: register letter, registration year, 6-digit serial, county code (00for registrations after that date) and a check digit (ONRC announcement of 1 October 2024). Older companies move to the new format when they register certain changes, so both formats are in use. Currentlyvalidate('J2012000750528')returnsInvalidFormat.This aligns
ro/onrcwith python-stdnum (stdnum/ro/onrc.py; the new format came in cd94bf1). There are two commits, so they can be reviewed or taken separately:clean()padded a single-digit county but dropped the slash after it, turningF5/1055/2013intoF051055/2013. Numbers likeF5/1055/2013,J5/1243/2016andJ/2/750/2012were rejected.(ord(letter) % 10 + sum of digits) % 10. The old format now follows python-stdnum, which rejects some numbers the JS version accepted: county00or41, years outside 1990 to 2024, and four-part numbers such asJ22/1515/2007/123. Serials over 5 digits and short years raiseInvalidLength. Surrounding whitespace is trimmed, as in python-stdnum.Tests in
src/ro/onrc.spec.tsuse python-stdnum's vectors. All 139 numbers in the valid list of python-stdnum'stest_ro_onrc.doctestnow pass (113 before). The 24 explicit cases from that file and the module docstring return the same result and error type.