REGON
REGON is the Polish statistical number of a business or an institution. The program makes the nine-digit form, whose last digit is a check digit.
What a REGON is
Nine digits for a business: an eight-digit serial number and a check digit. A local unit of a business gets fourteen digits, the first nine of which are the business’s own. The regulation that sets the number says its digits must carry no meaning about the business, so they encode neither a region nor a kind of business. The number of a business that is struck off is never given to another.
The program makes only the nine-digit form. The check digit rule for fourteen digits could not be checked against real numbers, so the program leaves it out rather than guess it.
The check digit
Multiply the first eight digits by 8, 9, 2, 3, 4, 5, 6, 7, add up the products and divide by 11. The remainder is the check digit, and a remainder of 10 is written 0.
None of the four official documents read when the program was written publishes this rule. These weights reproduce every one of 174 real numbers taken from two public registers, 15 of them with a remainder of 10.
Because 0 and 10 are written the same way, a changed digit goes unnoticed about once in 55 tries.
Valid REGON numbers for your tests
$ qadg quick regon --count 5 --seed example 066275151 770220679 599830312 229827446 170095230
No block of REGON numbers is set aside for testing, so a generated one can match a real business’s: keep it in test systems.
What your application should do with a broken one
Refuse a REGON whose check digit does not match. When a swap of two neighbouring digits leaves the check digit right, the program does not count it as damage and says so in the manifest.
Broken ones for your tests
The recipe below makes 100 values and asks for damage in 20% of the rows. Download it and run it as it is, then change the count or the share to fit your tests.
The recipe
# Polish REGON numbers for testing, with one broken value asked for in about a
# fifth of the rows.
#
# A REGON can match a real one, so keep the file in test systems. The damage
# changes a digit or swaps two, and the manifest says your application should
# reject each one. It also lists the damage this build could not carry out, with
# the reason.
#
# qadg generate regon.yaml
#
# writes company.csv, expectation-manifest.json and run-note.json. The same seed
# breaks the same values on every machine.
version: "0.1"
seed: "regon"
locale: pl-PL
entities:
company:
count: 100
fields:
regon: { generator: regon }
policy:
layers: [L3]
rows: 20%
per_row: exactly_one
output:
format: csv
Run it
Save the recipe, then run this in the same folder. This is what the program printed for it.
$ qadg generate regon.yaml company: 100 rows, 1 column 1 table, 100 rows written 21 defects ordered, 6 applied, manifest in expectation-manifest.json 15 defects could not be applied, and the manifest carries the reason for each one 3 because this run lacks something they need, and the manifest says what for each one 12 because this build has no implementation of them yet
What it damaged
The recipe ordered 21 defects, and this build applied the 6 below. The other 15 are in the manifest as not applied, each with its reason, and the run above counts them by reason.
L3.checksum.off_by_onerejectcompany 28, column regon
198467649 → 198467640
L3.checksum.transposed_digitsrejectcompany 38, column regon
035825265 → 305825265
L3.checksum.off_by_onerejectcompany 64, column regon
298263470 → 298263471
L3.checksum.transposed_digitsrejectcompany 67, column regon
886394866 → 886934866
L3.checksum.off_by_onerejectcompany 94, column regon
377787380 → 377787381
L3.checksum.transposed_digitsrejectcompany 95, column regon
723277779 → 723727779
Sources
- Regulation of the Council of Ministers of 30 November 2015, Dz.U. 2015 poz. 2009, § 12.