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

Đang mở
#5,258 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
48/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
typescript
Lĩnh vực
backend

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
TypeScript
Star
30
Fork
10
Merge trung bình
2 ngày 12 giờ
Pull request đã merge (30 ngày)
276

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của Urigo/accounter-fullstack

Tất cả issue của Urigo/accounter-fullstack

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.