Function: build820()
build820(
spec):X12Interchange
build820 - assemble a 005010X218 820 around the supplied spec.
Refused via "./build-errors.js".Premium820BuildError with code
X12_820_BUILD_INVALID_SPEC:
- no TRN trace, or no remittance loop;
- a remittance with neither an
entitynor anindividual(nothing opens its loop), or with noopenItems; - an open item with empty
qualifierAND emptyreferenceId(the read side drops it); - an over-long (> 9 char) interchange control number.
Parameters
spec
Returns
Example
import { build820, X12Decimal } from "@cosyte/x12";
const ix = build820({
envelope: {
senderId: "EMPLOYERCO", receiverId: "MEDPAY",
interchangeDate: "260601", interchangeTime: "1200",
interchangeControlNumber: "000000001",
groupControlNumber: "1", transactionSetControlNumber: "0001",
},
payment: {
transactionHandlingCode: "I",
totalPremiumAmount: X12Decimal.fromString("250.00")!,
creditDebitFlag: "C", method: "ACH", paymentDate: "20260601",
},
traces: [{ traceTypeCode: "1", referenceId: "PREM-202606" }],
remittances: [{
individual: { entityIdentifierCode: "IL", lastName: "DOE", idQualifier: "34", idCode: "MBR0001" },
openItems: [{ qualifier: "AZ", referenceId: "POL-0001", amountPaid: X12Decimal.fromString("250.00")! }],
}],
});