850 JSONata Example
{
"sender": {
"isaId": customer.prodIsaId
},
"receiver": {
"isaId": customer.testIsaId
},
"type": {
"name": "880_GROCERY_PRODUCTS_INVOICE"
},
"stream": customer.enabledTransactionTypes[documentType="880_GROCERY_PRODUCTS_INVOICE"].stream ~> $ifNullThen("TEST"),
"message": {
"transactionSets": [
{
"invoiceIdentification": [
{
"date": invoices[0].trandate ~> $formatDate("M/d/yyyy", "yyyyMMdd"),
"invoiceNumber": invoices[0].tranid,
"date1": invoices[0].custbody_orderful_edi_po_date ~> $formatDate("M/d/yyyy", "yyyyMMdd"),
"purchaseOrderNumber": invoices[0].otherrefnum,
"vendorOrderNumber": salesorders[0].tranid
}
],
"extendedReferenceInformation": [
{
"referenceIdentificationQualifier": "IA",
"referenceIdentification": invoices[0].custbody_orderful_n9_notes
}
],
"contact": [],
"dateTime": [
{
"dateQualifier": "11",
"date": invoices[0].shipdate ~> $formatDate("M/d/yyyy", "yyyyMMdd")
}
],
"carrierDetails": [
{
"transportationMethodTypeCode": "ZZ",
"standardCarrierAlphaCode": "",
"routing": invoices[0].shipcarrier
}
],
"termsOfSale": [
{
"termsTypeCode": "01",
"termsBasisDateCode": "3",
"termsStartDate": "",
"termsDueDateQualifier": "",
"termsDiscountPercent": "",
"termsDiscountDueDate": "",
"termsDiscountDaysDue": "",
"termsNetDueDate": invoices[0].duedate ~> $formatDate("M/d/yyyy", "yyyyMMdd"),
"termsNetDays": invoices[0].terms.daysuntilnetdue,
"termsDiscountAmount": "",
"discountedAmountDue": "",
"amountSubjectToTermsDiscount": invoices[0].totalaftertaxes,
"freeFormMessage": invoices[0].terms.name
}
],
"N1_loop": [
{
"partyIdentification": [
{
"entityIdentifierCode": "ST",
"name": invoices[0].shippingaddress.addressee,
"identificationCodeQualifier": "92",
"identificationCode": invoices[0].custbody_orderful_ship_dc_number
}
],
"partyLocation": [
{
"addressInformation": invoices[0].shippingaddress.addr1,
"addressInformation1": ""
}
],
"geographicLocation": [
{
"cityName": invoices[0].shippingaddress.city,
"stateOrProvinceCode": invoices[0].shippingaddress.state,
"postalCode": invoices[0].shippingaddress.zip,
"countryCode": invoices[0].shippingaddress.country
}
]
},
invoices[0].billingaddress ? {
"partyIdentification": [
{
"entityIdentifierCode": "BT",
"name": invoices[0].billingaddress.addressee,
"identificationCodeQualifier": "92",
"identificationCode": invoices[0].custbody_orderful_bill_dc_number
}
],
"partyLocation": [
{
"addressInformation": invoices[0].billingaddress.addr1,
"addressInformation1": ""
}
],
"geographicLocation": [
{
"cityName": invoices[0].billingaddress.city,
"stateOrProvinceCode": invoices[0].billingaddress.state,
"postalCode": invoices[0].billingaddress.zip,
"countryCode": invoices[0].billingaddress.country
}
]
} : invoices[0].custbody_orderful_bill_dc_number ? {
"partyIdentification": [
{
"entityIdentifierCode": "BT",
"name": invoices[0].shippingaddress.addressee,
"identificationCodeQualifier": "92",
"identificationCode": invoices[0].custbody_orderful_bill_dc_number
}
],
"partyLocation": [
{
"addressInformation": invoices[0].shippingaddress.addr1,
"addressInformation1": ""
}
],
"geographicLocation": [
{
"cityName": invoices[0].shippingaddress.city,
"stateOrProvinceCode": invoices[0].shippingaddress.state,
"postalCode": invoices[0].shippingaddress.zip,
"countryCode": invoices[0].shippingaddress.country
}
]
} : null,
{
"partyIdentification": [
{
"entityIdentifierCode": "SF",
"name": customer.companyName,
"identificationCodeQualifier": "92",
"identificationCode": ""
}
],
"partyLocation": [
{
"addressInformation": "",
"addressInformation1": ""
}
],
"geographicLocation": [
{
"cityName": "",
"stateOrProvinceCode": "",
"postalCode": "",
"countryCode": ""
}
]
}
],
"G72_loop": (
$discountLines := invoices[0].lines[accountinglinetype="DISCOUNT"];
$discountLines ? $discountLines.{
"allowanceOrCharge": [
{
"allowanceOrChargeCode": (
$lineItem := $;
$authorizedDiscounts[internalId=$lineItem.item].allowanceChargeCode ~> $ifNullThen($authorizedDiscounts[itemInternalId=$lineItem.item].allowanceChargeCode)
),
"allowanceOrChargeMethodOfHandlingCode": "02",
"allowanceOrChargeTotalAmount": $abs($number(foreignamount))
}
]
} : []
),
"G17_loop": invoices[0].lines[accountinglinetype!="DISCOUNT"].{
"itemDetail": [
{
"quantityInvoiced": $abs($number(quantity)),
"unitOrBasisForMeasurementCode": custcol_orderful_units,
"itemListCost": custcol_orderful_ordered_rate,
"number": $eval(custcol_orderful_item_identification).UPCCaseCode,
"productServiceIDQualifier": "UP",
"productServiceID": $eval(custcol_orderful_item_identification).UPCCaseCode,
"monetaryAmount": $abs($number(foreignamount))
}
],
"lineItemDetail": [
{
"freeFormDescription": memo
}
]
},
"totalInvoiceQuantity": [
{
"numberOfUnitsShipped": $sum(invoices[0].lines.($abs($number(quantity)))),
"unitOrBasisForMeasurementCode": invoices[0].lines[0].custcol_orderful_units,
"weight": "",
"unitOrBasisForMeasurementCode1": ""
}
],
"totalDollarsSummary": [
{
"amount": invoices[0].totalaftertaxes
}
]
}
]
}
}
Updated 7 days ago