Skip to main content

Module partner

Module partner 

Source
Expand description

Trading-partner master data — the PartnerStore trait and supporting types.

§Why not just a HashMap<GLN, URL> in config?

The partners = ["GLN=URL", …] field in makod.toml works for development but falls short in production:

RequirementConfig-onlyPartnerStore
Survives restarts without re-deployment
Carries PARTIN-derived metadata (validity, contacts, bank)
Updatable from inbound PARTIN messages at runtime
Tenant-scoped isolation
Multiple communication channels per partner
Validity windows (Gültig Ab) for future-dated updates

§PARTIN data model

The German energy market uses EDIFACT PARTIN messages (PIDs 37000–37014) to distribute market-participant master data. Each PARTIN carries:

  • NAD → GLN, company name, country code
  • COM → communication channels: AS4 endpoint URL, email, fax (up to 5)
  • CCI/CAV → availability windows (Erreichbarkeit)
  • FII → bank account (IBAN, BIC)
  • RFF → tax number, VAT ID
  • CTA/NAD → contact persons (Ansprechpartner)
  • DTM → valid-from date (Gültig Ab)
  • CCI → associated Bilanzkreis

PartnerRecord captures all of these fields in a form that is both serializable to SlateDB and constructible from static config.

§Bootstrap pattern

// At startup — seed from makod.toml `[as4] partners` list:
for record in PartnerRecord::from_cli_pairs(&config.as4.partners)? {
    store.upsert(tenant_id, &record).await?;
}

// Later — update from inbound PARTIN message:
let record = parse_partin_37001(&edifact_interchange)?;
store.upsert(tenant_id, &record).await?;

// Outbound AS4 dispatch:
let partner = store.get(tenant_id, &gln).await?
    .ok_or(EngineError::partner(format!("no endpoint for {gln}")))?;
let endpoint = partner.as4_endpoint
    .ok_or(EngineError::partner(format!("{gln} has no AS4 endpoint")))?;

§Key schema (SlateDB)

pt/{tenant_id}/{gln}JSON(PartnerRecord)

Both TenantId and GLN are fixed-width strings, giving a pt/{36-chars}/{13-chars} prefix that bounds efficient per-tenant scans.

Structs§

CommunicationChannel
A single communication channel extracted from a PARTIN COM segment.
ContactPerson
A contact person extracted from a PARTIN CTA/NAD/COM group.
NoopPartnerStore
A PartnerStore that never persists anything.
PartnerRecord
Full trading-partner master record as stored in the PartnerStore.

Enums§

MarketRole
The market role of a trading partner as declared in their PARTIN message.

Traits§

PartnerStore
Durable store for trading-partner master records.