Skip to content

feat(ro/onrc): support the new 14-character format - #174

Open
vicuts wants to merge 2 commits into
koblas:mainfrom
vicuts:feat/ro-onrc-new-format
Open

vicuts wants to merge 2 commits into
koblas:mainfrom
vicuts:feat/ro-onrc-new-format

Conversation

@vicuts

@vicuts vicuts commented Oct 14, 2026

Copy link
Copy Markdown

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 (00 for 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. Currently validate('J2012000750528') returns InvalidFormat.

This aligns ro/onrc with python-stdnum (stdnum/ro/onrc.py; the new format came in cd94bf1). There are two commits, so they can be reviewed or taken separately:

  1. Slash fix. clean() padded a single-digit county but dropped the slash after it, turning F5/1055/2013 into F051055/2013. Numbers like F5/1055/2013, J5/1243/2016 and J/2/750/2012 were rejected.
  2. New format and old-format parity. New format: year from 1990 to the current year, county allowed by registration year, check digit (ord(letter) % 10 + sum of digits) % 10. The old format now follows python-stdnum, which rejects some numbers the JS version accepted: county 00 or 41, years outside 1990 to 2024, and four-part numbers such as J22/1515/2007/123. Serials over 5 digits and short years raise InvalidLength. Surrounding whitespace is trimmed, as in python-stdnum.

Tests in src/ro/onrc.spec.ts use python-stdnum's vectors. All 139 numbers in the valid list of python-stdnum's test_ro_onrc.doctest now pass (113 before). The 24 explicit cases from that file and the module docstring return the same result and error type.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant