Skip to content

fix: Handle TD1 embedded document check digits in optional1 for non-compliant documents like PRT and BEL IDs#70

Merged
stropitek merged 1 commit intocheminfo:mainfrom
uwolfer:td1-embedded-check-digit
Mar 10, 2026
Merged

fix: Handle TD1 embedded document check digits in optional1 for non-compliant documents like PRT and BEL IDs#70
stropitek merged 1 commit intocheminfo:mainfrom
uwolfer:td1-embedded-check-digit

Conversation

@uwolfer
Copy link
Contributor

@uwolfer uwolfer commented Mar 6, 2026

Some TD1 issuers embed the document number check digit inside optional1 when the check-digit slot is <. This update validates the embedded digit against the concatenated document number + optional prefix before falling back to the ICAO-style separator variant.

Notes:

  • No official public specification found for embedded document‑number check digits in optional1.
  • The anonymized test case is derived from a real example that cannot be shared.

This is related to #66.

@codecov
Copy link

codecov bot commented Mar 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.35%. Comparing base (f716198) to head (f89e4b7).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #70      +/-   ##
==========================================
+ Coverage   88.66%   89.35%   +0.69%     
==========================================
  Files          48       48              
  Lines         450      451       +1     
  Branches      123      122       -1     
==========================================
+ Hits          399      403       +4     
+ Misses         51       48       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@targos targos requested a review from stropitek March 6, 2026 09:21
Copy link
Contributor

@stropitek stropitek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The title of the PR is a bit misleading here. We are already handling check digits which are in the optional field, but this is about how the check digit of the document number is calculated, specifically how the input of the check digit calculation is constructed.

I found a PRADO example which indeed has other logic for computing the check digit: https://www.consilium.europa.eu/prado/en/BEL-BO-03003/index.html

Can you use this one instead of your custom built one for the unit test?

The logic you added in parseDocumentNumberCheckDigit SGTM. Could you add a comment there on the part you added that it handles older non-compliant documents like PRT and BEL IDs. A reference to https://www.icao.int/sites/default/files/publications/DocSeries/9303_p11_cons_en.pdf page 88 to support that would also be useful for future reference.

@uwolfer uwolfer changed the title fix: Handle TD1 embedded document check digits in optional1 fix: Handle TD1 embedded document check digits in optional1 for non-compliant documents like PRT and BEL IDs Mar 9, 2026
…ompliant documents like PRT and BEL IDs

Some TD1 issuers embed the document number check digit inside optional1 when the check-digit slot is `<`. This update validates the embedded digit against the concatenated document number + optional prefix before falling back to the ICAO-style separator variant.

This is related to cheminfo#66.
@uwolfer uwolfer force-pushed the td1-embedded-check-digit branch from 8a5475d to f89e4b7 Compare March 9, 2026 16:16
@uwolfer uwolfer requested a review from stropitek March 9, 2026 16:17
@stropitek stropitek merged commit 8d0aa52 into cheminfo:main Mar 10, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants