Skip to main content
Version: v0.0.2

Function: get820Payments()

get820Payments(delimiters, tx): X12PremiumPayments | undefined

Extract a typed X12PremiumPayments from an 820 transaction set. Pure function - no I/O, no global state. Returns undefined only if the input transaction's ST-01 is not "820" (mis-routed call); every other deviation is recoverable and the verbatim segments remain on tx.segments.

Parameters

delimiters

Delimiters

tx

X12TransactionSet

Returns

X12PremiumPayments | undefined

Example

import { parseX12, get820Payments } from "@cosyte/x12";
const ix = parseX12(raw);
const tx = ix.groups[0]?.transactions.find((t) => t.st.elements[1] === "820");
if (tx !== undefined) {
const prem = get820Payments(ix.delimiters, tx);
prem?.payment.totalPremiumAmount.toString();
for (const r of prem?.remittances ?? []) {
r.openItems[0]?.amountPaid.toString();
}
}