Skip to content

Fix date format validation: accept YYYY-MM-DD, auto-convert to DD-MM-YYYY for AEAT XSD#49

Draft
Copilot wants to merge 3 commits intomasterfrom
copilot/fix-operation-date-validation
Draft

Fix date format validation: accept YYYY-MM-DD, auto-convert to DD-MM-YYYY for AEAT XSD#49
Copilot wants to merge 3 commits intomasterfrom
copilot/fix-operation-date-validation

Conversation

Copy link
Contributor

Copilot AI commented Mar 10, 2026

Validators were checking for DD-MM-YYYY via regex but error messages advertised YYYY-MM-DD, causing a paradoxical failure when users supplied the documented format. The AEAT XSD schema requires DD-MM-YYYY, but PHP's native date('Y-m-d') returns YYYY-MM-DD.

Changes

  • Validators (InvoiceId, InvoiceSubmission): Changed all date regexes from DD-MM-YYYY to YYYY-MM-DD (ISO 8601). Error messages now match what's actually accepted.
  • Serializer (InvoiceSerializer): Added formatDate() helper that converts YYYY-MM-DDDD-MM-YYYY before writing to XML, preserving XSD compliance transparently. Applied to all date fields: FechaExpedicionFactura, FechaOperacion, rectified/substituted invoice dates, chaining previous invoice dates, cancellation dates, and query dates.
  • Tests: Updated all hardcoded DD-MM-YYYY date strings and date('d-m-Y') calls to YYYY-MM-DD / date('Y-m-d'). Serializer test XML output assertions remain DD-MM-YYYY (correct expected output).

Example

// Previously failed validation with "Must be a valid date (YYYY-MM-DD)"
$invoice->operationDate = '2025-10-10';  // now passes
$invoiceId->issueDate   = '2025-10-10';  // now passes

// Serializer outputs correct DD-MM-YYYY in XML automatically:
// <sf:FechaOperacion>10-10-2025</sf:FechaOperacion>

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/Bacon/BaconQrCode/zipball/36a1cb2b81493fa5b82e50bf8068bf84d1542563
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/jjY3od /usr/bin/composer install (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/k9nSc4 /usr/bin/composer install --no-scripts (http block)
  • https://api.github.com/repos/DASPRiD/Enum/zipball/b5874fa9ed0043116c72162ec7f4fb50e02e7cce
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/jjY3od /usr/bin/composer install (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/k9nSc4 /usr/bin/composer install --no-scripts (http block)
  • https://api.github.com/repos/nikic/PHP-Parser/zipball/50f0d9c9d0e3cff1163c959c50aaaaa4a7115f08
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/k9nSc4 /usr/bin/composer install --no-scripts (http block)
  • https://api.github.com/repos/phar-io/version/zipball/4f7fd7836c6f332bb2933569e566a0d6c4cbed74
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/k9nSc4 /usr/bin/composer install --no-scripts (http block)
  • https://api.github.com/repos/phpstan/phpstan/zipball/3222c523fdb250b9f9a1f6d36f10e653c2d1b2e8
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/jjY3od /usr/bin/composer install (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/k9nSc4 /usr/bin/composer install --no-scripts (http block)
  • https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/079406160fa9290d5a7f585602e0fe5b5f003756
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/k9nSc4 /usr/bin/composer install --no-scripts (http block)
  • https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/9f7c12369107fdb7a91016bf88f27d39872a88ea
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/k9nSc4 /usr/bin/composer install --no-scripts (http block)
  • https://api.github.com/repos/sebastianbergmann/code-unit/zipball/807b5e65ab7b7b16e1928d924c7973aa451fa295
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/k9nSc4 /usr/bin/composer install --no-scripts (http block)
  • https://api.github.com/repos/sebastianbergmann/comparator/zipball/8d8209833d5f3f3eb8da4401a975302c58da4e64
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/k9nSc4 /usr/bin/composer install --no-scripts (http block)
  • https://api.github.com/repos/sebastianbergmann/complexity/zipball/72cbad467aed5fc740e4e4c00218f4f4a6ad4297
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/k9nSc4 /usr/bin/composer install --no-scripts (http block)
  • https://api.github.com/repos/sebastianbergmann/diff/zipball/74776e712e4b0c27d7e421b88af13875adb5999b
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/k9nSc4 /usr/bin/composer install --no-scripts (http block)
  • https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/f3a9f1083457e342c2f9a0b577c511d9c20be488
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/k9nSc4 /usr/bin/composer install --no-scripts (http block)
  • https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/ded04261fddbfb6755b7176685fd7975b874a128
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/jjY3od /usr/bin/composer install (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/k9nSc4 /usr/bin/composer install --no-scripts (http block)
  • https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/e16b906e486daae949005a62576318be23e31670
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/jjY3od /usr/bin/composer install (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/k9nSc4 /usr/bin/composer install --no-scripts (http block)
  • https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/11775ba4125a1e8ab6ab9c21e0607d9a484744dd
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/k9nSc4 /usr/bin/composer install --no-scripts (http block)
  • https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/97ecb4b0a29cf3befdf5bef6d7c5872a5f7129b4
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/k9nSc4 /usr/bin/composer install --no-scripts (http block)
  • https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/d1ddfa07b25ece41c8e5ee3f3bdd4fd969b0b395
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/k9nSc4 /usr/bin/composer install --no-scripts (http block)
  • https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/33ec41b1b3bc7b06f3e5443183d5be875a6a613c
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/k9nSc4 /usr/bin/composer install --no-scripts (http block)
  • https://api.github.com/repos/sebastianbergmann/php-timer/zipball/fb4639c8b216b81813c588d0adf1fe88ec66239e
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/k9nSc4 /usr/bin/composer install --no-scripts (http block)
  • https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/2b64fcfd962e68d303f86608aca2cf882adbca74
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/jjY3od /usr/bin/composer install (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/k9nSc4 /usr/bin/composer install --no-scripts (http block)
  • https://api.github.com/repos/sebastianbergmann/type/zipball/68153740a6f11fc82a96e260ef47041967ee1c58
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/jjY3od /usr/bin/composer install (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/k9nSc4 /usr/bin/composer install --no-scripts (http block)
  • https://api.github.com/repos/sebastianbergmann/version/zipball/c8104a729707d949f2132fad0a41c42b7cac080f
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/jjY3od /usr/bin/composer install (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/k9nSc4 /usr/bin/composer install --no-scripts (http block)
  • https://api.github.com/repos/symfony/polyfill-ctype/zipball/a3cc8b044a6ea513310cbd48ef7333b384945638
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/k9nSc4 /usr/bin/composer install --no-scripts (http block)
  • https://api.github.com/repos/theseer/tokenizer/zipball/b7489ce515e168639d17feec34b8847c326b0b3c
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/k9nSc4 /usr/bin/composer install --no-scripts (http block)
  • www.w3.org
    • Triggering command: /usr/bin/php php /usr/local/bin/phpunit --testsuite=Unit git ls-f�� --exclude-standa/home/REDACTED/.cache/composer/vcs/https---github.com-sebastianbergmann-code-unit-bash --others mann/object-reflector.git /https---github.git (dns block)
    • Triggering command: /usr/bin/php php /usr/local/bin/phpunit --testsuite=Unit git bran�� -a --no-color mann/code-unit.git /https---github.sh (dns block)
    • Triggering command: /usr/bin/php php /usr/local/bin/phpunit --testsuite=Unit owner --uid-owner 0 -j ACCEPT (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Error validación operationDate</issue_title>
<issue_description>Error validación operationDate
Array ( [eseperio\verifactu\models\InvoiceSubmission::$operationDate] => Array ( [0] => Must be a valid date (YYYY-MM-DD). ) )

Cuando en ese campo tengo:
$invoice->operationDate = '2025-10-10'; // Operation date

</issue_description>

<agent_instructions>Check this, since looks like a real problem where code is using american date format instead of european one. </agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits March 10, 2026 16:26
…ializer

Co-authored-by: Eseperio <5459366+Eseperio@users.noreply.github.com>
…e docs

Co-authored-by: Eseperio <5459366+Eseperio@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix operation date validation error for invoices Fix date format validation: accept YYYY-MM-DD, auto-convert to DD-MM-YYYY for AEAT XSD Mar 10, 2026
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.

Error validación operationDate

2 participants