DatiFattureCollegateopenfatture fattura generate-xml now actually generates FatturaPA XML (no longer a stub)OpenFatture 2.3.0 adds first-class support for Italian credit notes (nota di credito, document type TD04):
create_nota_credito_from_fattura creates a credit note from an existing invoiceopenfatture fattura create-credit-note --from-invoice <id> [--note "reason"] [--full]DatiFattureCollegate element linking back to the original invoicefattura_originale_id, fattura_originale_numero, fattura_originale_data) track the relationshipThe openfatture fattura generate-xml command is now a production-ready tool:
| Before (2.2.0) | After (2.3.0) |
|---|---|
| Stub that prints “not yet implemented” message | Real XML generation via InvoiceService and FatturaPABuilder |
| Tells user to use the assistant | Honors --output and --dry-run flags |
| No tests | Full test coverage (normal, custom output, dry-run, error cases) |
# Generate XML to default path (archivio/xml/IT<partita-iva>_<numero>.xml)
openfatture fattura generate-xml <invoice-id>
# Generate XML to custom path
openfatture fattura generate-xml <invoice-id> --output /path/to/custom.xml
# Preview XML without writing to disk
openfatture fattura generate-xml <invoice-id> --dry-run
The command uses the same battle-tested XML builder that the assistant and application layer use—no mocks, no fake SDI, no stub logic.
This release includes an Alembic migration for TD04 linkage columns. If you manage database migrations manually, run:
alembic upgrade head
The migration adds three nullable columns to the fatture table. Existing invoices are unaffected; the columns are only populated for credit notes.
The generate-xml command behavior has changed:
--dry-run)If you had scripts or workflows that relied on the old stub behavior, update them to expect real XML output.
# Create a credit note from an existing invoice
openfatture fattura create-credit-note --from-invoice 42 --note "Customer cancellation"
# Generate XML for the credit note (will include DatiFattureCollegate)
openfatture fattura generate-xml <credit-note-id> --output nota_credito.xml
# Verify TD04 document type and linkage in XML
grep -A5 "DatiFattureCollegate" nota_credito.xml
# Test normal generation
openfatture fattura generate-xml 1
# Test custom output path
openfatture fattura generate-xml 1 --output /tmp/test_invoice.xml
# Test dry-run mode (no file written, XML printed to console)
openfatture fattura generate-xml 1 --dry-run
# Run credit note integration tests
uv run python -m pytest tests/integration/test_nota_credito_workflow.py -xvs
# Run CLI generate-xml tests
uv run python -m pytest tests/cli/test_fattura_commands.py -k generate_xml -xvs
# Run full test suite
uv run python -m pytest -q
This release does not include:
These remain product-decision items and are not scheduled for implementation. The 2.3.0 focus is on honesty in documentation (TD04 is shipped, not planned) and closing the one real CLI gap (generate-xml).
The git tag and GitHub release for 2.3.0 will be created by the coordinator after PR merge. Do not create tags or publish PyPI packages manually.