konto

The ledger

Open items per bill and contract, payments allocated in the statutory order of § 366 BGB, review-then-confirm, and the Kontoauszug with a running balance.

On this page

konto-ledger keeps one creditor's books on the append-only, hash-chained journal of the doubleentry crate. It ties every receivable to the sealed bill it came from, and hands open claims to collections.

Open items

A sealed bill is booked once. It becomes one open item per contract on the bill: the contract's net amount plus its share of each VAT group, split by largest remainder so the items add up to the bill's gross exactly. The bill's prepaid Abschläge are cleared against it in the same booking.

Each posting carries the dimensions bill, contract and due; the journal entry carries the bill number and its digest. Every receivable therefore traces back to a bill that proves itself.

Payments and allocation

A received payment is booked from the bank to the account's receivables, keyed by its payment id, so a retried payment books nothing twice. Allocating it to open items follows the statutory order [BGB § 366 Abs. 1, 2]:

  1. what the customer named (a bill or a contract);
  2. otherwise items already due before items not yet due;
  3. among those, the oldest first;
  4. items due on the same day, in proportion.

The proportional rule also meets the telecom rule that a partial payment is split across the services of a bill [TKG § 62 Abs. 3]. What remains is an open credit, a Guthaben.

Allocation is reviewed, then confirmed. The review is bound to the open amounts it read; if a booking changed them in between, the confirm is stale.

use konto_ledger::{Books, Purpose};

let mut books = Books::new(&creditor, 2026..=2028)?;
books.receive(&abschlag)?;
books.post_bill(&sealed)?;
let (review, plan) = books.review_allocation(&key, id, "clerk:anna", &account, &payment, &Purpose::None, today)?;
println!("{}", plan.summary_de());
// 27,71 € auf 3 offene Posten verteilt, 2,29 € bleiben als Guthaben.
books.confirm_allocation(&key, &review, "clerk:anna", &account, &payment, &Purpose::None, today, false)?;

The Kontoauszug

statement gives one line per journal entry with its date, kind (bill, payment, booking), reference (the bill number or payment id), German text, signed amount and running balance, and closes with „Offen …“, „Guthaben …“ or „Ausgeglichen“:

02.01.2027  Zahlung: Abschlag Januar Strom  −80,00 €  −80,00 €
15.01.2027  Zahlung: Abschlag Januar Glasfaser und Wasser  −80,00 €  −160,00 €
03.02.2027  Rechnung R-2027-000042  +187,71 €  27,71 €
Offen 27,71 €

The account screen's Verlauf is this statement, newest first, each bill linked.

To collections

claims turns the open debit items into the claims konto-collect assesses, with the disputes the caller passes in. See Collections.

In the service

kontod stores every booking with its journal head and replays the commands on first use; see Run kontod.

This page as Markdown · Improve this page