🐛 Fix hash generation to comply with AEAT official field names #3
+172
−12
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.



🐛 Critical Bug Fix: AEAT Hash Compliance
This PR fixes a critical bug where the hash input string was using
snake_casefield names instead of the official AEAT XML field names, causing non-compliance with the official AEAT specification.📖 Reference
Document: "Detalle de las especificaciones técnicas para generación de la huella o hash de los registros de facturación"
❌ Problem (Before)
Generates:
issuer_tax_id=89890001K&invoice_number=12345678/G33&issue_date=01-01-2024&...❌✅ Solution (After)
Generates:
IDEmisorFactura=89890001K&NumSerieFactura=12345678/G33&FechaExpedicionFactura=01-01-2024&...✅🧪 Testing
Added comprehensive tests using official AEAT examples (spec pages 10-11):
3C464DAF61ACB827C65FDA19F352A4E3BDC2C640E9E9FC4CC058073F38F12F60)F7B94CFD8924EDFF273501B01EE5153E4CE8F259766F88CF6ACB8935802A2B97)All tests pass: 4 tests, 7 assertions ✅
Hashes generated with the previous version are not valid according to AEAT specifications. Systems already in production will need to regenerate hashes for all invoices.
📦 Changes
src/Helpers/HashHelper.php: Updated field names to match official AEAT XML specificationtests/Unit/HashHelperAeatComplianceTest.php: New compliance tests with official examples🔗 Related