openfatture

OpenFatture 2.3.0

Highlights

What’s New

Nota di Credito (TD04)

OpenFatture 2.3.0 adds first-class support for Italian credit notes (nota di credito, document type TD04):

Real XML Generation CLI

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

Upgrade Notes

Database Migration

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.

CLI Command Change

The generate-xml command behavior has changed:

If you had scripts or workflows that relied on the old stub behavior, update them to expect real XML output.

Verification

Credit Note Workflow

# 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

XML Generation

# 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

Test Suite

# 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

Future Work

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

Tag and Release

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.