Skip to content

Fix Issue #215#225

Open
JeanCarlosChavarriaHughes wants to merge 1 commit into
CRLibre:v4.4from
JeanCarlosChavarriaHughes:v4.4
Open

Fix Issue #215#225
JeanCarlosChavarriaHughes wants to merge 1 commit into
CRLibre:v4.4from
JeanCarlosChavarriaHughes:v4.4

Conversation

@JeanCarlosChavarriaHughes

@JeanCarlosChavarriaHughes JeanCarlosChavarriaHughes commented Mar 26, 2026

Copy link
Copy Markdown
Collaborator

Bug Fix for issue #215

Signed-off-by: JeanCarlos Chavarria <jeancarlos.chavarria19@gmail.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Fixes Issue #215 by correcting how the emitter (“emisor”) phone number is validated/serialized so it appears in generated XML when it meets the intended digit-length constraints.

Changes:

  • Update emisor phone validation from numeric range comparison to string-length checks (8–20 chars) across multiple XML generators.
  • Add a PHPUnit assertion verifying <Emisor><Telefono><NumTelefono> is present for genXMLFe() output.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
api/contrib/genXML/genXML.php Fixes the phone inclusion condition in several XML generator functions to use length-based validation.
tests/api_contrib_genXML_FE.php Adds an assertion ensuring the emisor phone number is included in FE XML output.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

}

if ($emisorCodPaisTel != '' && $emisorTel != '' && $emisorTel >= EMISORNUMEROTELMIN && $emisorTel <= EMISORNUMEROTELMAX) {
if ($emisorCodPaisTel != '' && $emisorTel != '' && strlen($emisorTel) >= EMISORNUMEROTELMIN && strlen($emisorTel) <= EMISORNUMEROTELMAX) {

Copilot AI Mar 26, 2026

Copy link

Choose a reason for hiding this comment

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

The telefono inclusion check only validates length; it doesn’t trim or ensure the value is numeric. Per the v4.4 XSD, is xs:integer, so values like "2222-3333" or trailing spaces would now be emitted and cause schema validation failures. Consider normalizing (trim) and validating digits-only (e.g., ctype_digit after trim, or strip non-digits) before adding , and avoid calling strlen() twice by computing the length once.

Copilot uses AI. Check for mistakes.
}

if ($emisorCodPaisTel != '' && $emisorTel != '' && $emisorTel >= EMISORNUMEROTELMIN && $emisorTel <= EMISORNUMEROTELMAX) {
if ($emisorCodPaisTel != '' && $emisorTel != '' && strlen($emisorTel) >= EMISORNUMEROTELMIN && strlen($emisorTel) <= EMISORNUMEROTELMAX) {

Copilot AI Mar 26, 2026

Copy link

Choose a reason for hiding this comment

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

This PR changes the emisor telefono validation/serialization not only for genXMLFe(), but also for genXMLNC/ND/TE/Fec/Fee. There are PHPUnit tests for genXMLFe(), but no coverage for the other generators, so regressions in those document types won’t be caught. Please add at least a minimal test (or a data-driven test) asserting that is included when emisor_tel is 8–20 digits for each affected generator.

Copilot uses AI. Check for mistakes.
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