Invoicing in Greece requires knowing things about a company that only the tax authority knows, and the tax authority serves them over SOAP.

RgWsPublic2 returns a company’s record by VAT number: name, address, registration date, activity codes, cessation date. It also requires the credentials of the number doing the checking, and that requirement is legal rather than technical — every query is attributed. Errors come back as Greek strings with numeric codes, sometimes as a SOAP fault, sometimes as a 200 with a failure inside it.

An Elixir function that returns {:error, %{code: :invalid_vat, descr: "..."}} is worth the wrapper.

What it does about that

  • fetch/1 and fetch!/1 with one error shape: :invalid_vat for a checksum or length failure, :http_not_ok for a non-200, :transport_error for DNS, timeout or refused connections, and the service’s own string codes passed through when GSIS itself refuses. A caller should not have to learn SOAP to handle a failure.
  • VAT validated before the call, so an obvious typo costs nothing and the message says which digit is wrong.
  • Optional pretty: true, reshaping the raw response into named atoms. Without it you get the SOAP nesting, which is accurate and unreadable.
  • address_collapsed for the single-line address a UI needs, and is_active derived from the cessation date, because otherwise every view compares dates against today and one of them gets it wrong.
  • Optional Cachex caching, per-application TTL defaulting to one hour, errors never cached. A stale “not found” is worse than a slow answer.
  • VIES fallback: when GSIS is unavailable it delegates to VatchexVies rather than failing a checkout page.

86 unit tests, none touching the live service. That took longer than the client, and it is the reason the client can be trusted.

What it works against

The assumption that a tax registry is a stable API. It is a service that changes on its own schedule, with a legal requirement attached to each call and an error vocabulary in another language. The library exists so that only one project has to know that.

Installation

def deps do
  [
    {:vatchex_greece, "~> 1.2"}
  ]
end

Documentation on HexDocs, code on GitHub.

A volunteer effort, not affiliated with GSIS or the Greek Ministry of Finance. If you depend on it for invoices, test against the live service before you trust it.

blog-post
VatchexGreece 2024
/images/software/stack/Elixir.png Elixir

Related

Have something worth building?

A paragraph about what you are working on is enough to start.

Say hello