CLI Commands
The module provides CLI commands to generate and verify e-invoices.
einvoice:generate
Generate e-invoices on demand for one or more invoices / credit memos.
php bin/magento einvoice:generate --invoice-id=123
php bin/magento einvoice:generate --creditmemo-id=456
Options:
--invoice-id/-i(single invoice entity ID)--creditmemo-id/-c(single credit memo entity ID)--invoice-ids(comma-separated list, e.g.1,2,3)--creditmemo-ids(comma-separated list, e.g.10,11,12)
Verbose output (shows a per-entity table for bulk runs):
php bin/magento einvoice:generate --invoice-ids=1,2,3 -v
Note: IDs are entity IDs (numeric), not increment IDs. Already generated documents are skipped.
einvoice:verify-amounts
Cross-check XML summation totals against Magento invoice / credit memo values. Useful for catching rounding drift, mapping errors, and EN16931 arithmetic violations before a customer complains.
# Verify a standalone XML file
php bin/magento einvoice:verify-amounts --file=/path/to/invoice.xml
# Verify an invoice against its Magento counterpart
php bin/magento einvoice:verify-amounts --invoice-id=123
# Verify a credit memo
php bin/magento einvoice:verify-amounts --creditmemo-id=456
# Override tolerance (default: 0.01)
php bin/magento einvoice:verify-amounts --file=/path/to/invoice.xml --tolerance=0.05
Options:
--file/-f(path to XML file, absolute or relative to Magento root)--invoice-id/-i(loads XML frompub/media/einvoice/invoice/<id>.xml)--creditmemo-id/-c(loads XML frompub/media/einvoice/creditmemo/<id>.xml)--tolerance(absolute tolerance per field; defaults to0.01)
What it checks
Three EN16931 business rules (BR-CO):
| Rule | Invariant |
|---|---|
| BR-CO-13 | TaxBasisTotal == LineTotal − AllowanceTotal + ChargeTotal |
| BR-CO-15 | GrandTotal == TaxBasisTotal + TaxTotal + Rounding |
| BR-CO-16 | DuePayableAmount == GrandTotal − PrepaidAmount |
When an invoice or credit memo ID is passed, the command also compares the XML fields against the Magento values for grand_total, subtotal, and tax_amount.
Output
XML summation (BT-106..112):
+-----------------+--------+
| field | value |
+-----------------+--------+
| grand_total | 119.00 |
| tax_basis_total | 100.00 |
| tax_total | 19.00 |
...
Magento vs XML:
+-------------+---------+--------+---------+--------+
| field | magento | xml | diff | status |
+-------------+---------+--------+---------+--------+
| grand_total | 119.00 | 119.00 | +0.0000 | OK |
| subtotal | 100.00 | 100.00 | +0.0000 | OK |
| tax_amount | 19.00 | 19.00 | +0.0000 | OK |
+-------------+---------+--------+---------+--------+
All checks passed.
Exit code 0 on match, 1 on any mismatch.