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

Open
#5,258 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
typescript
Domain
backend

Research direction

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.

Written by the indexing model from the issue text.

Description

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.

Dominant language
TypeScript
Stars
30
Forks
10
Avg merge
2d 12h
Merged PRs (30d)
276

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Urigo/accounter-fullstack

All issues in Urigo/accounter-fullstack

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.