Skip to content
Back to News
Changelog

SDK 6.5.2 writes XPK for a pack, not the retired PK

sdk

6.5.2 is a patch. No method, type or export changes. Two lookups the SDK runs on your machine change: the unit "pack", and unit names that match a property of a plain JavaScript object.

"pack" now resolves to XPK

unit: "pack" and unit: "packs" resolved to PK in 6.5.1. PK is no longer a UN/ECE Recommendation 20 code, and the Peppol rule BR-CL-23, which is fatal, refuses it. On 9 November we measured a worse outcome than a refusal: our network provider accepted PK and rewrote it to C62 (« one ») in the document it transmitted. An invoice for packs left as an invoice for units.

In 6.5.2, "pack" and "packs" resolve to XPK (UN/ECE Recommendation 21, « Package »). This applies where the SDK resolves units on your machine:

  • resolveUnit("pack") returns "XPK";
  • getAllUnits() lists { code: "XPK", name: "Package" } in place of { code: "PK", name: "Pack" };
  • peppol.toXml(), buildInvoiceXml() and buildCreditNoteXml() write unitCode="XPK" for unit: "pack", and for baseQuantityUnit: "pack";
  • validateSchematron() now warns on a line that passes unit: "PK" directly, with rule GETPEPPR-UNIT-CODE-RECOGNISED, and no longer warns on unit: "XPK". The warning does not change valid. The SDK still writes a code you pass as-is unchanged, so replace "PK" with "XPK" (package) or "C62" (one).

Sending does not depend on this release

peppol.invoices.send() sends your unit to the API as you wrote it, and the API resolves the alias itself. Since 10 November, the hosted API at api.getpeppr.dev refuses PK before anything is sent, whichever SDK version you use. If you point baseUrl at another deployment, the refusal depends on that deployment's version, not on the SDK's:

{
  "error": "unit_code_invalid",
  "message": "A line's unit is not a unit code the Peppol network accepts (UN/ECE Recommendation 20 or 21, rule BR-CL-23). Use a code such as EA (each), C62 (one), HUR (hour), KGM (kilogram) or XPK (package). Nothing was sent.",
  "field": "lines[0].unit",
  "rule": "BR-CL-23",
  "docs": "https://getpeppr.dev/docs/error-handling/#unit-code-invalid"
}

The response is a 422. See unit_code_invalid.

resolveUnit("constructor") returns "constructor"

The alias table is a plain object, and the lookup read through its prototype. resolveUnit("constructor") returned the Object function instead of a string, and resolveUnit("__proto__") returned an object. The local XML builder had the same lookup: toXml() on a line with unit: "constructor" threw TypeError: str.replace is not a function. Both now read only their own aliases, and an unknown unit comes back unchanged, as the documentation already said.

Upgrade if you build XML with the SDK or list units with getAllUnits():

npm install @getpeppr/sdk@6.5.2