opcn1214-generator: parse.derivedMismatch rejects a valid file with bank codes 277/278 but no 280

Aperta
#5,258 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
typescript
Ambito
backend

Direzione di ricerca

Start with packages/opcn1214-generator/src/validate/parse-rules.ts and trace derivedMismatches, then read the bank account parsing and generation paths in packages/opcn1214-generator. Run the parser and round-trip tests for codes 277, 278, and 280; add coverage for 277/278 without 280 and 280 without 277/278. Done means the specified behavior is decided and tested, and the unchanged-account case round-trips to identical bytes.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

1214 annual-audit-workflow

Problem

packages/opcn1214-generator/src/validate/parse-rules.ts:147-152 (parse.derivedMismatch) compares each derived code of a parsed 1000 record with the value the generator would write. That is wrong for code 280. Code 280 isn't derived from 277/278. It is the filer's mark that the bank account changed:

  • PDF p.20, code 280: "מקבל ערכים: 1 (במקרה ששונה חשבון הבנק וצורפה אסמכתא מתאימה)". It is filled when the account changed and a supporting document is attached.
  • PDF p.19, on 277/278: "רק אם שדה 280 מלא, נלקחים הערכים שמולאו בקודים 277 278, אחרת פרטי חשבון בנק נלקחים מהתל"ם". Without 280, SHAAM takes the account from its own records.

So a file with 277/278 and no 280 is valid, and other software could easily write one. parse1214 throws on it: "Code 280 of record 1000 is absent; derived from the file it is 1."

Repro:

  1. Generate minimalInput({ bankAccount: { bank: '12', branch: '345', account: '123456' } }).
  2. Remove the 280 pair from the 1000 code section: shift the rest left and pad with 0.

Before H1 (#5073) this file parsed; now parse1214 throws. The reverse case, 280 = 1 with no 277/278, parses with no issue.

A related case: a 277 longer than 9 digits (p.19 allows at most 9) produces three mismatches, on 277, 278 and 280. The main.bankAccount.format notice that would explain them is dropped.

The input model has the same gap

denormalize (from D3, #5058) builds a bankAccount whenever any of 277/278/280 is present, and reads missing codes as zeros. So:

  • 280 = 1 on its own parses to the account 000000000, with no issue;
  • 277/278 without 280 regenerates with 280 = 1. That changes the file's meaning: it asks SHAAM to replace the account it has.

bankAccount has no way to say "account details given, no change requested".

Fix

  1. In derivedMismatches, skip an absent 280 but still flag any 280 other than 1. The existing "a bank code 280 other than 1" test still passes with this change:

    for (const code of codes) {
      const actual = record.codes.get(code);
      const wanted = expected.codes.get(code);
      // 280 marks a changed bank account (p.20); without it SHAAM takes the account from its own
      // records and ignores 277/278 (p.19), so a file may hold 277/278 and no 280.
      if (actual === wanted || (code === '280' && actual === undefined)) {
        continue;
      }
    
  2. Let the input model express "account given, unchanged", for example with an explicit flag on bankAccount that drives 280. Then parse → generate keeps such a file byte for byte.

  3. Decide whether 280 = 1 without 277/278 should be reported, instead of becoming an all-zero account.

Done when

  • A file with 277/278 and no 280 parses with no issue.
  • That file round-trips (parse → generate) to the same bytes.
  • 280 = 1 without 277/278 has a decided, tested behaviour.

Raised in the review of #5073 (H1). The input-model part belongs to D3 (#5058). Neither was posted before the PRs merged. Re-checked on main at 31245bc7f.

Lingua principale
TypeScript
Stelle
30
Fork
10
Merge medio
2g 12h
PR unite (30g)
276

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Urigo/accounter-fullstack

Tutte le issue di Urigo/accounter-fullstack

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.