Skip to content

feat: add validation to prevent transmitting edocuments with mismatched invoice IDs#6

Merged
pritambiswal merged 1 commit intoprilk-consulting:developfrom
maasanto:feat-validate-source
Feb 4, 2026
Merged

feat: add validation to prevent transmitting edocuments with mismatched invoice IDs#6
pritambiswal merged 1 commit intoprilk-consulting:developfrom
maasanto:feat-validate-source

Conversation

@maasanto
Copy link

@maasanto maasanto commented Jan 8, 2026

Problem

If an invoice is submitted after its edocument is created, the source document reference may be updated but the XML content still contains the old draft invoice ID. This could result in transmitting incorrect invoice data.

Solution

Added comprehensive validation to transmit_edocument() through a new _validate_edocument_for_transmission() function that verifies:

  1. Edocument profile is configured
  2. XML validation status is successful
  3. Source document is submitted (docstatus == 1) for outgoing documents
  4. Invoice ID in XML content matches the source document name for outgoing documents

If validation fails, transmission is blocked with a clear error message instructing the user to regenerate the edocument.

Technical Details

  • Extracted existing validation checks into dedicated _validate_edocument_for_transmission() function
  • Added XML parsing to extract invoice ID using XPath for both UBL (cbc:ID) and CII (rsm:ExchangedDocument/ram:ID) formats
  • ValidationErrors are re-raised without wrapping to provide clean error messages to users
  • Only validates source document status and XML ID for outgoing documents with source documents

Related

@maasanto maasanto changed the title feat: validate source before transmission feat: add validation to prevent transmitting edocuments with mismatched invoice IDs Jan 8, 2026
@pritambiswal pritambiswal merged commit ad002cf into prilk-consulting:develop Feb 4, 2026
3 of 4 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