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

Abierto
#4,968 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 2 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
32/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
github-actions, node.js, typescript

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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/

Lenguaje dominante
TypeScript
Estrellas
30
Forks
10
Merge medio
2 d 12 h
PR fusionados (30 d)
276

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de Urigo/accounter-fullstack

Todos los issues de Urigo/accounter-fullstack

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.