Delete a cancelled document that has ledger entries
When you cancel a document, ERPNext keeps the original ledger entries and adds reversing entries. Both stay in the ledger as an audit trail. By default, ERPNext does not let you delete a cancelled document that has these entries.
Usually you do not need to delete. To correct a submitted document, cancel it and select Amend. The original, its reversal, and the correction stay visible for audit.
Prerequisites
- The document is cancelled.
- No legal or audit rule requires you to keep it.
- You have a backup of the site.
- You have the System Manager role, or another role that can change Accounts Settings.
Delete the document and its ledger entries
- In Accounts Settings, select Delete Accounting and Stock Ledger entries on deletion of transaction.
- Open the cancelled document and delete it. ERPNext deletes its General Ledger, Payment Ledger, and Stock Ledger entries, and any exchange gain or loss Journal Entry that the document created.
- In Accounts Settings, clear Delete Accounting and Stock Ledger entries on deletion of transaction again.
WARNING
Deleted ledger entries cannot be restored, except from a backup. Turn the setting off after a one-time cleanup, so that no one deletes ledger history by mistake.
Troubleshooting
ERPNext says the document is linked to another document
Another document refers to this one, for example a return, an amended document, or a payment allocation. Open the Connections of the document and cancel or delete the dependent documents first, in reverse order of creation. Do not delete rows in the database directly.