DEV Community

Michal Novotný
Michal Novotný

Posted on

A Czech invoice check needs three answers

A supplier account either matches a published account, differs from every published account, or cannot be checked with the data available. A surprisingly easy way to lose the third outcome is to return an empty list when a registry request times out. Every downstream payment check then treats the outage as a mismatch.

Start with the supplier identifier

An ISDOC electronic invoice carries the supplier identifier and the payment details on the document. To look up a Czech supplier's registered name, you can call ARES directly. Keep the IČO as a string so the leading zeros survive. This example uses the public identifier of the Moravian Library in Brno.

import json
from urllib.request import urlopen

ico = "00094943"
url = f"https://ares.gov.cz/ekonomicke-subjekty-v-be/rest/ekonomicke-subjekty/{ico}"
with urlopen(url, timeout=10) as response:
    company = json.load(response)
print(company["ico"], company["obchodniJmeno"])
Enter fullscreen mode Exit fullscreen mode

For published bank accounts and VAT reliability, the workflow queries the Czech Financial Administration's VAT register. The company name from ARES remains useful even when the VAT register is unavailable. Keeping the two results separate lets the caller display the name and send the account for manual review.

Make uncertainty an explicit input

The comparison below assumes both sides have already been normalized. A Czech domestic account string includes a bank code, an optional prefix and an account number. For a Czech IBAN and a domestic account to compare equal, those components must be represented consistently.

def compare_account(invoice_account, published_accounts):
    if published_accounts is None:
        return "UNKNOWN"
    if invoice_account in published_accounts:
        return "MATCH"
    return "NO_MATCH"

assert compare_account("account-A", ["account-A"]) == "MATCH"
assert compare_account("account-A", []) == "NO_MATCH"
assert compare_account("account-A", None) == "UNKNOWN"
Enter fullscreen mode Exit fullscreen mode

Only pass an empty list after a successful, complete lookup. Pass None if the upstream response omits the field you need. In a production workflow, keep the source, lookup time and status alongside the result. Even a successful match only establishes that the account appeared in the source at lookup time.

Test the webhook response as well as the business rule

In a running n8n instance, we tried a CZK 100 invoice, a EUR 50 invoice using the Czech National Bank rate for 16 November 2026, and an unavailable VAT register. The CZK amount stayed at 100. The foreign invoice converted to CZK 1,221.50. For the outage test we replaced the upstream response with a controlled fixture. The workflow returned VAT_STATUS_UNKNOWN and UNKNOWN_ADIS.

The clear invoice initially triggered an unexpected HTTP 500. A terminal IF node returned no item on the clear branch, leaving the webhook with nothing to send. Returning one result from a shared final node fixed the response. The caller can now route all three outcomes explicitly.

I maintain EuroKYB. The standalone Python examples above run without a EuroKYB account. The project also exposes these lookups through an open-source MCP bridge. This article was prepared with AI assistance and draws on the live workflow tests described above.

Top comments (0)