@getpeppr/cli 0.5.3 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1161,7 +1161,7 @@ function statusFamily(status) {
1161
1161
  var TERMINAL_FAILURE_STATUSES = STATUS_PRECEDENCE.filter((e) => e.family === "terminal-failure").map((e) => e.status);
1162
1162
 
1163
1163
  // ../sdk/dist/version.js
1164
- var SDK_VERSION = "2.4.0";
1164
+ var SDK_VERSION = "3.2.0";
1165
1165
 
1166
1166
  // ../sdk/dist/core/client.js
1167
1167
  function findHeaderCaseInsensitive(headers, name) {
@@ -1408,7 +1408,18 @@ var GetpepprAdapter = class {
1408
1408
  }
1409
1409
  async searchDirectory(params) {
1410
1410
  const query = new URLSearchParams(params).toString();
1411
- return this.request("GET", `/directory/search?${query}`);
1411
+ const result = await this.request("GET", `/directory/search?${query}`);
1412
+ const data = result.data ?? [];
1413
+ const meta = result.meta;
1414
+ return {
1415
+ data,
1416
+ meta: {
1417
+ totalCount: Number(meta?.total_count ?? meta?.totalCount ?? data.length),
1418
+ offset: Number(meta?.offset ?? params.offset ?? 0),
1419
+ limit: Number(meta?.limit ?? params.limit ?? 20),
1420
+ hasMore: meta?.has_more != null || meta?.hasMore != null ? Boolean(meta.has_more ?? meta.hasMore) : Number(meta?.total_count ?? meta?.totalCount ?? 0) > Number(meta?.offset ?? 0) + Number(meta?.limit ?? 0)
1421
+ }
1422
+ };
1412
1423
  }
1413
1424
  async getInvoiceAs(id, format) {
1414
1425
  const { maxRetries, initialDelayMs, maxDelayMs } = this.retryConfig;
@@ -2800,7 +2811,9 @@ function getKnownUnitCodes() {
2800
2811
  }
2801
2812
  return _knownUnitCodes;
2802
2813
  }
2803
- var VALID_VAT_CATEGORIES = /* @__PURE__ */ new Set(["S", "Z", "E", "AE", "K", "G", "O", "L", "M"]);
2814
+ var VALID_VAT_CATEGORIES = /* @__PURE__ */ new Set(["S", "Z", "E", "AE", "K", "G", "O", "L", "M", "B"]);
2815
+ var SENDABLE_VAT_CATEGORIES = ["S", "Z", "E", "AE", "K", "G", "O"];
2816
+ var UNROUTABLE_VAT_CATEGORIES = /* @__PURE__ */ new Set(["L", "M", "B"]);
2804
2817
  function computeLineNet(line) {
2805
2818
  const baseQty = line.baseQuantity ?? 1;
2806
2819
  if (baseQty === 0)
@@ -3030,29 +3043,24 @@ var peppolR004 = (input) => {
3030
3043
  }
3031
3044
  return [];
3032
3045
  };
3033
- var peppolR006 = (input) => {
3046
+ var vatCategoryCodes = (input) => {
3034
3047
  const violations = [];
3035
- if (!input.lines)
3036
- return violations;
3037
- for (let i = 0; i < input.lines.length; i++) {
3038
- const line = input.lines[i];
3039
- const cat = line.vatCategory;
3040
- if (cat !== void 0 && !VALID_VAT_CATEGORIES.has(cat)) {
3041
- violations.push(violation("PEPPOL-EN16931-R006", "error", `Line ${i}: invalid VAT category "${cat}". Must be one of: S, Z, E, AE, K, G, O, L, M.`, `lines[${i}].vatCategory`));
3048
+ const sendable = SENDABLE_VAT_CATEGORIES.join(", ");
3049
+ const echo = (v) => v.length <= 16 ? v : `${v.slice(0, 16)}\u2026`;
3050
+ const check = (cat, field, label) => {
3051
+ if (cat === void 0 || cat === null)
3052
+ return;
3053
+ if (!VALID_VAT_CATEGORIES.has(cat)) {
3054
+ violations.push(violation("BR-CL-17", "error", `${label}: "${echo(cat)}" is not a VAT category code. Use one of: ${sendable}. Codes are case-sensitive \u2014 "AE" is reverse charge, "ae" is not a category.`, field));
3055
+ return;
3042
3056
  }
3043
- }
3044
- for (let i = 0; i < (input.allowances ?? []).length; i++) {
3045
- const cat = input.allowances[i].vatCategory;
3046
- if (cat !== void 0 && !VALID_VAT_CATEGORIES.has(cat)) {
3047
- violations.push(violation("PEPPOL-EN16931-R006", "error", `Allowance ${i}: invalid VAT category "${cat}".`, `allowances[${i}].vatCategory`));
3057
+ if (UNROUTABLE_VAT_CATEGORIES.has(cat)) {
3058
+ violations.push(violation("unsupported_vat_category", "error", `${label}: VAT category "${echo(cat)}" is valid under EN 16931 but getpeppr cannot route it \u2014 our provider has no vocabulary for it. Sendable categories: ${sendable}.`, field));
3048
3059
  }
3049
- }
3050
- for (let i = 0; i < (input.charges ?? []).length; i++) {
3051
- const cat = input.charges[i].vatCategory;
3052
- if (cat !== void 0 && !VALID_VAT_CATEGORIES.has(cat)) {
3053
- violations.push(violation("PEPPOL-EN16931-R006", "error", `Charge ${i}: invalid VAT category "${cat}".`, `charges[${i}].vatCategory`));
3054
- }
3055
- }
3060
+ };
3061
+ (input.lines ?? []).forEach((line, i) => check(line.vatCategory, `lines[${i}].vatCategory`, `Line ${i}`));
3062
+ (input.allowances ?? []).forEach((a, i) => check(a.vatCategory, `allowances[${i}].vatCategory`, `Allowance ${i}`));
3063
+ (input.charges ?? []).forEach((c, i) => check(c.vatCategory, `charges[${i}].vatCategory`, `Charge ${i}`));
3056
3064
  return violations;
3057
3065
  };
3058
3066
  var peppolR080 = (input) => {
@@ -3092,7 +3100,7 @@ var ALL_RULES = [
3092
3100
  brS08,
3093
3101
  // Peppol-specific
3094
3102
  peppolR004,
3095
- peppolR006,
3103
+ vatCategoryCodes,
3096
3104
  peppolR080
3097
3105
  ];
3098
3106
  function validateSchematron(input) {