shaam-uniform-format-generator: 0.2.7 ships incomplete `dist/`, and negative document amounts and Z900 record counts fail round-trip validation

オープン
#4,968 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
32/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
github-actions, node.js, typescript

調査の方向性

Three separate defects; start by reproducing with the gist against packages/shaam-uniform-format-generator. For the tarball, compare packages/shaam-uniform-format-generator/tsconfig.json with the root one and .github/actions/setup / publish.yml caching, then check whether tslib belongs in dependencies. For the round trip, read src/api/generate-report.ts alongside the C100Schema and D120Schema regexes and performCrossFileValidation in src/api/parse-files.ts against documentation/c100.csv, d120.csv and z900.csv. Done means a clean npm pack with full dist/, credit notes surviving parse, and no z900_total_records error in strict mode.

索引モデルが issue の本文から書いたものです。

説明

Describe the bug
  1. @accounter/[email protected] (npm latest) and 0.2.8-alpha-20261114140432-e9aa0de37e9a114ea1f604b8f8b5284c6afa2581 cannot be imported.
    The published tarball has 87 files, and dist/ contains only dist/cjs/index.js and dist/esm/index.js (0.2.6 had 228 files including all submodules and dist/typings/). Importing the package in ESM or CJS fails immediately because ./types/index.js, ./api/generate-report.js, ./api/parse-files.js, etc. are missing. In addition, dist/cjs/index.js (including in 0.2.6) emits require("tslib") via root importHelpers: true, while tslib is not listed in dependencies.

  2. Negative document amounts (credit notes, as in the README Complete Example) are emitted by generateUniformFormatReport and rejected by parseUniformFormatFiles.
    On 0.2.6 and main (bce9563), generateUniformFormatReport writes document.amount.toFixed(2) (e.g. "-100.00" for a credit note type: '330') into C100.amountIncludingVat and D120.lineAmount and succeeds under validationMode: 'fail-fast'. When parsing back, C100Schema and D120Schema validate against /^(\d{1,13}(\.\d{2})?|)$/ (unsigned only), so parseC100 and parseD120 fail with severity: 'error' and drop the credit note from data.documents. (documentation/c100.csv field 1223 and documentation/d120.csv field 1312 also specify signed X9(12)V99.)

  3. Z900 total-records cross-validation is off by one on every generated or spec-compliant report.
    generate-report.ts writes totalRecords: records.length + 1, counting A100 through Z900 inclusive per SHAAM 1.31 field 1155 (documentation/z900.csv: "Includes opening and closing records"). In src/api/parse-files.ts, performCrossFileValidation computes actualDataRecords without Z900 (// Z900 doesn't count itself), so every generated report sets summary.crossValidationPassed = false with Z900 total records mismatch: expected N, found N-1 (which becomes severity: 'error' under validationMode: 'strict', such as in ShaamImportProvider).

Your Example Website or App

https://gist.github.com/trackoor/66d1588886dcaaca7bf35e69d0b3d81b

Steps to Reproduce the Bug or Issue

Broken import on 0.2.7:

npm i @accounter/[email protected]
node --input-type=module -e "import '@accounter/shaam-uniform-format-generator'"

Actual output:

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '.../node_modules/@accounter/shaam-uniform-format-generator/dist/esm/types/index.js' imported from .../node_modules/@accounter/shaam-uniform-format-generator/dist/esm/index.js

Round-trip failures on 0.2.6 and main (bce9563):

import {
  generateUniformFormatReport,
  parseUniformFormatFiles,
} from "@accounter/shaam-uniform-format-generator";

const report = generateUniformFormatReport(
  {
    business: {
      businessId: "12345",
      name: "Example Ltd",
      taxId: "123456789",
      reportingPeriod: { startDate: "2023-01-01", endDate: "2023-12-31" },
    },
    documents: [{ id: "CN-1", type: "330", date: "2023-06-15", amount: -100 }],
    journalEntries: [
      { id: "JE-1", date: "2023-06-15", amount: -100, accountId: "1100" },
    ],
    accounts: [
      {
        id: "1100",
        name: "Revenue",
        sortCode: { key: "400" },
        accountOpeningBalance: 0,
      },
    ],
    inventory: [],
  },
  { validationMode: "fail-fast" },
);

const parsed = parseUniformFormatFiles(report.iniText, report.dataText, {
  validationMode: "strict",
});
console.log("documents:", parsed.data.documents);
console.log("crossValidationPassed:", parsed.summary.crossValidationPassed);
console.log(
  "errors:",
  parsed.summary.errors.map(e => `[${e.recordType}] ${e.field}: ${e.message}`),
);

const positiveOnly = generateUniformFormatReport({
  business: {
    businessId: "12345",
    name: "Example Ltd",
    taxId: "123456789",
    reportingPeriod: { startDate: "2023-01-01", endDate: "2023-12-31" },
  },
  documents: [{ id: "INV-1", type: "305", date: "2023-06-15", amount: 100 }],
  journalEntries: [],
  accounts: [],
  inventory: [],
});
const parsedPositive = parseUniformFormatFiles(
  positiveOnly.iniText,
  positiveOnly.dataText,
  { validationMode: "strict" },
);
console.log(
  "positive-only errors:",
  parsedPositive.summary.errors.map(
    e => `[${e.recordType}] ${e.field}: ${e.message}`,
  ),
);

Actual output:

documents: []
crossValidationPassed: false
errors: [
  '[C100] parsing: Failed to parse C100 record: [\n' +
    '  {\n' +
    '    "origin": "string",\n' +
    '    "code": "invalid_format",\n' +
    '    "format": "regex",\n' +
    '    "pattern": "/^(\\\\d{1,13}(\\\\.\\\\d{2})?|)$/",\n' +
    '    "path": [\n' +
    '      "amountIncludingVat"\n' +
    '    ],\n' +
    '    "message": "Invalid string: must match pattern /^(\\\\d{1,13}(\\\\.\\\\d{2})?|)$/"\n' +
    '  }\n' +
    ']',
  '[D120] parsing: Failed to parse D120 record: [\n' +
    '  {\n' +
    '    "origin": "string",\n' +
    '    "code": "invalid_format",\n' +
    '    "format": "regex",\n' +
    '    "pattern": "/^(\\\\d{1,13}(\\\\.\\\\d{2})?|)$/",\n' +
    '    "path": [\n' +
    '      "lineAmount"\n' +
    '    ],\n' +
    '    "message": "Invalid string: must match pattern /^(\\\\d{1,13}(\\\\.\\\\d{2})?|)$/"\n' +
    '  }\n' +
    ']',
  '[CrossValidation] C100_count: Record count mismatch for C100: expected 1, found 0',
  '[CrossValidation] D120_count: Record count mismatch for D120: expected 1, found 0',
  '[CrossValidation] z900_total_records: Z900 total records mismatch: expected 7, found 4'
]
positive-only errors: [
  '[CrossValidation] z900_total_records: Z900 total records mismatch: expected 5, found 4'
]
Expected behavior
  • @accounter/shaam-uniform-format-generator ships the full compiled dist/ tree (including dist/typings/) and declares tslib if CJS output imports it, so ESM import and CJS require both succeed.
  • Credit notes / negative document amounts accepted by generateUniformFormatReport round-trip through parseUniformFormatFiles without C100/D120 schema failures.
  • performCrossFileValidation includes Z900 (1 closing record) when comparing against Z900.totalRecords, so generated and spec-compliant reports pass cross-validation (crossValidationPassed: true, no z900_total_records error in strict mode).
Screenshots or Videos

N/A

Platform
  • OS: Linux x64
  • NodeJS: v26.13.0
  • @accounter/shaam-uniform-format-generator: 0.2.7, 0.2.8-alpha-20261114140432-e9aa0de37e9a114ea1f604b8f8b5284c6afa2581, 0.2.6, and main (bce9563582631e35463190922188d68ad879715c)
Additional context

For the incomplete 0.2.7 / 0.2.8-alpha tarball: packages/shaam-uniform-format-generator/tsconfig.json extends root tsconfig.json without overriding incremental: true or tsBuildInfoFile: "./node_modules/.cache/tsbuildinfo/root.tsbuildinfo", which .github/actions/setup restores from cache in publish.yml over a fresh checkout with no dist.

Credit: https://ucsbplse.github.io/

主要言語
TypeScript
スター
30
フォーク
10
平均マージ
2日 12時間
マージ済み PR(30日)
276

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Urigo/accounter-fullstack のほかの issue

Urigo/accounter-fullstack の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。