arthurdejong / python-stdnum

A Python library to provide functions to handle, parse and validate standard numbers.
https://arthurdejong.org/python-stdnum/
GNU Lesser General Public License v2.1
498 stars 206 forks source link

Add support for Romanian ONRC #229

Closed dotbit1 closed 4 years ago

dotbit1 commented 4 years ago

We need a new identifier for Romanian companies: Romanian: https://www.onrc.ro/index.php/ro/ce-reprezinta-si-cum-se-obtin-numarul-de-ordine-in-registrul-comertului-cui-ul-si-cif-ul

I live in Romania and run a company and have discussed at great depth with my accountant. The nr de ordine de la registrul comertului identifier is obligatory and explicitly stated in Romanian law.

  1. numarul de ordine din registrul comertului -> This one is missing in stdnum. This is the subject of the current issue.

  2. codul unic de inregistrare fiscala (CUI): this is (sort of) ro_cf. I have some comments about this, but I will mention them after we solve the missing identifier.

The missing identifier:

numarul de ordine din registrul comertului can be translated as: order number from the commerce register

The linked page also describes the format:

(J|F|C)(1-40|51|52)/n/YYYY where n is an incrementing integer for each registration, I have not seen this number go above 4 digits, but I guess it could be bigger depending on the number of registrations that year. YYYY is the year.

for example: J52/750/2012 for my company J= Juridical person 52 = the number for the county where my company is 750 = we were the 750'th company that changed or registered during 2012 2012 = the year when we changed some aspect of the company, could also be the registration year

The code is usually abreviated and looks really ugly: like nr. ord. onrc. I guess the description should be the full description: order number from the commerce register

I am not sure what the best code would be, I guess just ro_onrc.

Should a maintainer compose this, or should I try to fumble, create a file and then sumbit it to be checked?

The use case is in Tryton which depends on stdnum.

arthurdejong commented 4 years ago

Hi Dimitrios,

It seems that this number does not have a check digit and just a fixed format. Do you know of an online registry that can be searched, queried, downloaded or similar?

After searching for numbers I found a lot that have a full date as last part (.../DD.MM.YYYY or even .../DD.MM.YY) and some only have two digits for the year (.../YY). Do you know if these are supposed to be valid?

I've had a look at https://achizitii.afir.info/ and about 10% of the numbers mention there do not match the pattern you provided (a lot seem to contain various typo's though so I don't know how good there data-set is).

Btw, feel free to create issues that you may be aware of in other number formats!

dotbit1 commented 4 years ago
  1. Regarding fixed format and no check digit: according to onrc, the middle number is a sequence for the year when the company was registered, starting with one. There is no mention of a check digit. I have checked a few numbers in sequence, ex. my company is J52/750/2012, so i checked J52/751/2012 - J52/755/2012 and also J52/650/2012 and they all exist, so it seems like this is a sequence that is incremented by one for each registration. I see no other place rather than the middle number to place a check digit. Conclusion is 99% certain there is just a fixed format and no check digit.

  2. Regarding online registry: The official site is a government pay site, however I use the finance ministry's page, which I would also consider official. On this site you can not search by Numar de inmatriculare la Registrul Comertului, only by cod unic de inregistrare. The onrc number is present in the company presentation, and seems to always be formatted ending with a year composed of 4 digits. https://www.mfinante.gov.ro/agenticod.html?pagina=domenii PS: I have found a government updated current csv with '^' (!?) as a separator with all the current romanian companies. I can run the identifier through the validator (after it is written) in order to check the if the validator is correct!

  3. Regarding afir: The first non-conforming entry in this list is prodcereal srl, Cod Unic Identificare: 7171040, Numar Inmatriculare ONRC: J51/89/21.02.1 . However if we go to mfinante and check nr 7171040, you can see that this company has: Numar de inmatriculare la Registrul Comertului: J51/89/1995. I would conclude that the data-set from afir is not 100% correct.

In my company's accounting (national accounting program SAGA) 100% of the numar de inmatriculare la registrul comertului are in the J52/750/2012 format.

I have tried to the best of my ability to get official information. Please do inform me if you feel additional justifying information from official sources is necessary.

PS: numarul de ordine din registrul comertului, Numar de inmatriculare la Registrul Comertului and Numar inmatriculare ONRC refer to the same number. It is very confusing when the fiscal administration use so many different terms to refer to the same number.

dotbit1 commented 4 years ago

wired$ awk -F'^' '{print $3}' 3open_data-neradiate_cu_sediu-02.05.2020.002.csv |awk -F'/' '{print $2}'|sort -un|tail -n 1 31821 This is the most companies that have been registered in a single year, 1992 after the revolution. I would set the check to 1-5 digits. Ok?

$ awk -F'^' '{print $3}' 3open_data-neradiate_cu_sediu-02.05.2020.002.csv |awk -F'/' '{print $3}'|sort -u This returns years between 1990 - current year. I propose doing check. Ok?

Total length of the onrc number: wired$ awk -F'^' '{print length($3)}' 3open_data-neradiate_cu_sediu-02.05.2020.002.csv |sort -un 0 9 10 11 12 13 14 Set length to 9-14 characters. Ok?

dotbit1 commented 4 years ago

Created a pull request. Please check the quality of the commit. All current romanian companies onrc numbers validate. Using datetime.datetime.now().year to check if reg year is in the future, ok?

It seems like something is failing but I do not understand what. continuous-integration/travis-ci/pr — The Travis CI build failed gives me: stdnum/ro/onrc.py 26 7 10 2 58% 55->56, 56, 65->66, 66-71