> For the complete documentation index, see [llms.txt](https://host2host.onibonje.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://host2host.onibonje.com/docs/24-transformation-and-messaging.md).

# Transformation and Messaging Standards

## 1. Overview

**Modules:** `h2h-transform-core`, `h2h-transform-iso20022`, `h2h-transform-mt940`

Transforms map external formats ↔ [canonical model](/docs/29-canonical-data-model.md). Specifications stored in `transform_spec` — not in code.

***

## 2. Supported Standards

| Standard               | Direction        | Module                | Message types            |
| ---------------------- | ---------------- | --------------------- | ------------------------ |
| **CSV**                | Inbound/Outbound | transform-core        | Bulk payments, ACK       |
| **Fixed-width**        | Inbound          | transform-core        | Legacy corporates        |
| **JSON**               | API              | transform-core        | REST payloads            |
| **XML**                | Inbound/Outbound | transform-core + XSLT | Custom corporate         |
| **ISO 20022 pain.001** | Inbound          | iso20022              | Customer credit transfer |
| **ISO 20022 pacs.008** | Inbound          | iso20022              | FI credit transfer       |
| **ISO 20022 camt.053** | Outbound         | iso20022              | Account statement        |
| **ISO 20022 pain.002** | Outbound         | iso20022              | Payment status           |
| **SWIFT MT940**        | Outbound         | mt940                 | End-of-day statement     |
| **SWIFT MT942**        | Outbound         | mt940                 | Interim statement        |

***

## 3. Transform Pipeline

```mermaid
flowchart LR
  IN[Inbound format] --> ENG[Engine JOLT JSONata XSLT]
  ENG --> CAN[Canonical model]
  CAN --> ENG2[Engine]
  ENG2 --> OUT[Finacle or ACK format]
```

| Engine      | Best for                  |
| ----------- | ------------------------- |
| **JOLT**    | JSON/CSV → JSON canonical |
| **JSONata** | Expressions, API payloads |
| **XSLT**    | ISO 20022 XML, MT940      |

***

## 4. ISO 20022 Mapping (pain.001 → Canonical)

| ISO element                       | Canonical field           |
| --------------------------------- | ------------------------- |
| `GrpHdr.MsgId`                    | batchId (or mapped)       |
| `GrpHdr.NbOfTxs`                  | totalCount                |
| `GrpHdr.CtrlSum`                  | totalAmount               |
| `PmtInf.CdtTrfTxInf.Amt.InstdAmt` | instruction.amount        |
| `CdtrAcct.Id.IBAN`                | instruction.creditAccount |
| `DbtrAcct.Id.IBAN`                | instruction.debitAccount  |
| `RmtInf.Ustrd`                    | instruction.narrative     |

Specs in `transform_spec.spec_body` (JOLT chain).

***

## 5. MT940 Generation (Canonical → MT940)

| MT940 tag | Source                          |
| --------- | ------------------------------- |
| `:20:`    | batch/statement reference       |
| `:25:`    | account number                  |
| `:28C:`   | statement sequence              |
| `:60F:`   | opening balance                 |
| `:61:`    | transaction lines from postings |
| `:62F:`   | closing balance                 |

Module: `h2h-transform-mt940`

***

## 6. Validation Before Transform

1. File structure / XSD (ISO XML)
2. `validation_rule` on canonical (post-transform)
3. Business rules / scripts

Order: structural → transform → business validate.

***

## 7. ACK Transform (Canonical → Partner CSV)

Partner-specific ACK via `ack_template` + `transform_spec` targeting outbound CSV/XML.

***

## 8. Extensibility

| Need                     | Approach                                      |
| ------------------------ | --------------------------------------------- |
| New corporate CSV layout | New `transform_spec` in admin                 |
| New ISO message type     | `TransformEngineProvider` plugin or XSLT spec |
| Country variant          | Country-scoped transform in country pack      |

***

## 9. Related Documents

* [29 Canonical Data Model](/docs/29-canonical-data-model.md)
* [25 ACK/NACK Framework](/docs/25-ack-nack-framework.md)
* [04 Database-Driven Configuration](/docs/04-database-driven-configuration.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://host2host.onibonje.com/docs/24-transformation-and-messaging.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
