Skip to content

Conversation

@pmenendz
Copy link
Contributor

@pmenendz pmenendz commented Nov 24, 2025

This PR improves validations for Verifactu invoices:

Simplified Invoices (F2 or R5)

  • Verifactu will return an error if these invoice types include a destinatario.
  • The gobl.verifactu implementation only adds a destinatario if it has a tax ID.
  • If an invoice has the tag simplified and includes customer tax id, the simplified_art7273 extension is set to S.

Taxes Validation

  • Verifactu rejects invoices without a Desglose field (i.e., missing tax breakdown in GOBL).
  • A new validation ensures that invoices include at least one non-retained tax, preventing errors on submission.

Pre-Review Checklist

  • I've read the CONTRIBUTING.md guide.
  • I have performed a self-review of my code.
  • I have added thorough tests with at least 90% code coverage.
  • I've modified or created example GOBL documents to show my changes in use, if appropriate.
  • When adding or modifying a tax regime or addon, I've added links to the source of the changes, either structured or in the comments.
  • I've run go generate . to ensure that the Schemas and Regime data are up to date.
  • All linter warnings have been reviewed and fixed.
  • I've been obsessive with pointer nil checks to avoid panics.
  • The CHANGELOG.md has been updated with an overview of my changes.
  • Requested a review from @samlown.

@pmenendz pmenendz requested review from Copilot and samlown November 24, 2025 17:18
Copilot finished reviewing on behalf of pmenendz November 24, 2025 17:20
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR enhances Verifactu invoice validations by adding stricter rules for simplified invoices (F2 and R5 types) and ensuring tax breakdown requirements are met. The changes align with Verifactu API requirements that reject invoices with prohibited customer information in simplified invoices and require at least one non-retained tax category.

Key changes:

  • Simplified invoices (F2/R5) now explicitly prohibit customers with tax IDs or identity documents
  • New validation ensures invoices contain at least one non-retained tax category
  • Comprehensive test coverage for all new validation scenarios

Reviewed changes

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

File Description
addons/es/verifactu/bill.go Refactored customer validation to use conditional logic based on document type (F2/R5 vs others), added new validateInvoiceCustomerSimplified function to enforce simplified invoice restrictions, and added validateInvoiceTotals to ensure invoices have required tax categories
addons/es/verifactu/bill_test.go Added comprehensive test coverage for simplified invoice customer restrictions (with/without tax ID and identities), tax category requirements (no taxes, only retained taxes, valid combinations), and updated existing test to remove customer identifiers for R5 invoices

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

@codecov
Copy link

codecov bot commented Nov 24, 2025

Codecov Report

❌ Patch coverage is 96.77419% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.51%. Comparing base (3132119) to head (2ee9966).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
addons/es/verifactu/bill.go 95.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #654      +/-   ##
==========================================
+ Coverage   92.48%   92.51%   +0.02%     
==========================================
  Files         313      313              
  Lines       15338    15452     +114     
==========================================
+ Hits        14185    14295     +110     
- Misses        827      829       +2     
- Partials      326      328       +2     

☔ 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.

pmenendz and others added 2 commits November 24, 2025 17:28
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Collaborator

@samlown samlown left a comment

Choose a reason for hiding this comment

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

Not totally convinced here. So for two things that are happening:

  1. If there is something the user can do with the simplified invoice, why not just do it for them?
  2. I wouldn't produce errors in once place while suggest the user needs to fix it somewhere else, that'll get really confusing. It could be that each line needs to have a tax combo set and the validation should be there. Special charges, like with the key set to outlay, would need to be exceptions.

@pmenendz pmenendz requested a review from samlown November 27, 2025 15:31
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.

3 participants