# Several companies

> A Stadtwerk and its fibre subsidiary: each company keeps its own invoices, mandate and books; the customer signs in once and sees what is open with whom.

Many Stadtwerke sell fibre or charging from a subsidiary. A subsidiary is another legal
entity, so another creditor: its own Gläubiger-ID, number series, mandate, ledger and
courier. konto keeps every creditor apart and lets the customer see all of them in one
place.

## What stays apart

Each company issues its own invoice. An invoice names the full name and address of the
company that supplied the service [UStG § 14 Abs. 4 Satz 1 Nr. 1], and a SEPA mandate
names one creditor. So konto never merges documents, payments or dunning across
creditors. A clerk's token acts for one creditor and sees only its accounts, bills and
grants. Account and bill numbers may repeat across creditors.

## What the customer shares

One sign-in. The customer sets up a passkey with the first company's invitation, then,
signed in, enters the second company's invitation under „Konto eines weiteren Unternehmens
hinzufügen“ (`POST /v1/me/invitations`). Only the customer links the accounts; no clerk
does it for them.

`GET /v1/me` then lists every account with its company, what is open and how it is paid:

```json
{ "person": "…", "name": "Erika Mustermann", "accounts": [
  { "creditor": "musterstadt-glasfaser", "company": "Musterstadt Glasfaser GmbH", "account": "GF-2000777",
    "kind": "holder", "ends": null, "ends_de": null,
    "open": { "amount": "42.83", "text_de": "Offen 42,83 €", "due": "2027-01-18", "hint_de": "fällig am 18.01.2027" },
    "payment_de": "Per Überweisung auf DE12 5001 0517 0648 4898 90, Verwendungszweck: die Rechnungsnummer." },
  { "creditor": "stadtwerke-musterstadt", "company": "Stadtwerke Musterstadt GmbH", "account": "VK-1000123",
    "kind": "holder", "ends": null, "ends_de": null,
    "open": { "amount": "196.65", "text_de": "Offen 196,65 €", "due": "2027-01-18", "hint_de": "fällig am 18.01.2027" },
    "payment_de": "Wird per SEPA-Lastschrift von DE89 … 3000 eingezogen (Mandat VK-1000123-01)." } ] }
```

The debtor's IBAN is masked, and a delegate sees only that the amount is debited.
The [Kundenportal](portal.md) shows this list grouped by company.

## Naming the company

Every request of a session may name its creditor with `?creditor=`:

```text
GET /v1/accounts/VK-1000123/overview?creditor=stadtwerke-musterstadt
GET /v1/bills/R-2027-000001/pdf?creditor=stadtwerke-musterstadt
```

The session then reaches only that creditor's accounts of its current grants. A session
whose grants are all at one creditor may leave it out. One with grants at several gets
`creditor_required` on account and bill routes, because the same number can exist at both
companies. A creditor the person holds nothing at answers like an unknown account. A
token naming a creditor other than its own does too.

## Turn it on

List the creditors whose customers sign in at the shared origin:

```sh
export KONTO_SIGNIN_CREDITORS='stadtwerke-musterstadt,musterstadt-glasfaser'
```

With one creditor configured it defaults to that one. With several, kontod refuses to start
without it, so that no company joins the portal by accident. A grid operator that is part
of a vertically integrated undertaking must make sure in its communication and branding
that it cannot be confused with the supply business [EnWG § 7a Abs. 6]. Leave it out of
the list, or run it in its own deployment. A creditor outside the list can issue no
invitation (`signin_off`), and its earlier codes stop working.

The sign-in origin, the name in the passkey dialog and the portal's look are shared by
every creditor in the list.

## Clerks and lost devices

A clerk's access list shows its creditor's grants only, each with the name its own
invitation gave the person. A passkey is the person's, not a creditor's. Any creditor the
person has a grant with can remove it for a lost device, which ends every session
started with it, at every company. The person then sets up a new passkey with a new
invitation and adds the other companies' invitations again.
