Polish IBAN

A Polish IBAN is PL followed by 26 digits. Without PL, the same 26 digits are the account number written on a domestic transfer in Poland, the NRB.

What a Polish IBAN is

28 characters: PL, two check digits, an eight-digit bank sort code, and a sixteen-digit account number. The last digit of the sort code is a check digit of its own.

The check digits

  1. Move PL and the two check digits to the end.
  2. Replace P with 25 and L with 21.
  3. Read everything as one long number and divide it by 97. The IBAN is correct when the remainder is 1.

To work out the check digits, do the same with 00 in their place and subtract the remainder from 98.

For the sort code’s own check digit, multiply its first seven digits by 3, 9, 7, 1, 3, 9, 7, add up the products, and subtract the last digit of the total from 10. A result of 10 is written 0.

Valid Polish IBANs for your tests

terminal
$ qadg quick iban --count 5 --seed example
PL80816558320363473538345589
PL34770659753728965691254796
PL74204669013353772537401858
PL79994001897762573349868503
PL45315629888755186874673378

The program makes Polish IBANs only. Given an IBAN from another country, it checks the check digits and, when they are right, says it cannot judge the rest, because it carries no list of the lengths other countries use. The sort code is drawn rather than taken from a list of banks, yet it can still match a real bank’s, and the account number can match a real account: keep generated numbers in test systems.

What your application should do with a broken one

Refuse an IBAN whose check digits do not match. The damage changes one digit or swaps two neighbouring ones. When a swap leaves the check digits 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-iban.yaml
# Polish IBANs for testing, with one broken value asked for in about a fifth of
# the rows.
#
# An IBAN can match a real account, 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 polish-iban.yaml
#
# writes account.csv, expectation-manifest.json and run-note.json. The same seed
# breaks the same values on every machine.
version: "0.1"
seed: "polish-iban"
locale: pl-PL
entities:
  account:
    count: 100
    fields:
      iban: { generator: iban }
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.

terminal
$ qadg generate polish-iban.yaml
       account: 100 rows, 1 column
1 table, 100 rows written
18 defects ordered, 6 applied, manifest in expectation-manifest.json
12 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
  9 because this build has no implementation of them yet

What it damaged

The recipe ordered 18 defects, and this build applied the 6 below. The other 12 are in the manifest as not applied, each with its reason, and the run above counts them by reason.

L3.checksum.off_by_onereject

account 19, column iban

PL90388645394245894527669117 → PL90388645394245894527669118

L3.checksum.transposed_digitsreject

account 20, column iban

PL11133397351146076355659888 → PL11133397351146076355658988

L3.checksum.off_by_onereject

account 34, column iban

PL02968275899514556682753532 → PL02968275899514556682753533

L3.checksum.transposed_digitsreject

account 42, column iban

PL70755090441800483656829870 → PL70575090441800483656829870

L3.checksum.off_by_onereject

account 84, column iban

PL48917592348484996306717054 → PL48917592348484996306717055

L3.checksum.transposed_digitsreject

account 91, column iban

PL17448957255543149631315241 → PL17448957255543149631315421

Sources

  • Order No. 7/2017 of the President of Narodowy Bank Polski: § 13 and § 14 for the shape of the number, annex 2 for the sort code’s check digit.
  • Order No. 5/2002 of the President of Narodowy Bank Polski, annexes 1 and 2, for the check digits. The order has since been repealed.