[Deadlock] Cancelled Payment Entry leaves active GL Entry

Hi everyone,

I am running into a strict system deadlock on Version 16 (hosted on Frappe Cloud) involving the MCA Audit Trail and a glitched General Ledger entry. I’m completely locked out of fixing a ghost balance on my Accounts Payable report and am hoping someone here has a workaround or if a maintainer can take a look.

The Core Issue

A Payment Entry was submitted, its clearance date was updated, and then the document was cancelled. However, the underlying GL Entry failed to cancel (Is Cancelled: No).

This has stranded a negative outstanding balance on our Accounts Payable report. Because the parent document is marked as “Cancelled,” but the GL Entry is active, standard accounting tools refuse to interact with it.

The Catch-22 (Why standard fixes fail):

  1. Force Deletion is Blocked: Because the strict Indian compliance Audit Trail is enabled, the system strictly forbids deleting the Payment Entry or the orphaned GL Entry to clear the database.

  2. Reposting Tools are Blocked: If I try to use the Repost Accounting Ledger or Repost Payment Ledger to force the system to recalculate the cancelled voucher, I get a strict framework validation error: Cannot link cancelled document: Row #1: Voucher No...

  3. Reconciliation is Blocked: I tried creating a zero-sum Journal Entry to wash the ghost balance. However, the Payment Reconciliation tool completely filters out “Cancelled” documents, meaning I cannot link the Journal Entry to the ghost payment to clear it from the AP report. If I try to link it manually via the Journal Entry “Reference” table, I get the same Cannot link cancelled document error.

Steps to Reproduce:

  1. Submit a Payment Entry against a Purchase Invoice.

  2. Update the Clearance Date on the submitted Payment Entry.

  3. Cancel the Payment Entry.

  4. Check the GL Ledger → The underlying GL Entry remains active.

  5. Attempt to resolve via Reposting or Reconciliation (blocked by status) or Deletion (blocked by Audit Trail).

Because I am on Frappe Cloud without direct bench/database access to run an is_cancelled = 1 SQL patch, I am stuck with this ghost balance permanently throwing off the AP report.

Has anyone encountered this specific sync failure before? Is there any frontend UI workaround that I am missing to wash this balance, or does this require a core framework fix to allow reposting tools to target cancelled documents?

Thanks in advance for any insights!

Hi @Archit

Not sure if it will work but worth a try. From client script can you try running frappe.db.set_value ( Server Calls (AJAX) )

Ensure you backup your data first and if possible experiment on a test site

Hope it helps and best of luck

Use the system console to mark gl_entry as is_cancelled using frappe.db.set_value.

2 Likes

This worked! Thanks a ton!

# Find all GL Entries linked to the cancelled ghost payment
gl_entries = frappe.get_all('GL Entry', filters={'voucher_no': 'WI/PAY/25-26/01641'})

# Loop through and forcefully cancel each one
for entry in gl_entries:
    frappe.db.set_value('GL Entry', entry.name, 'is_cancelled', 1)

# Commit the changes to the database
frappe.db.commit()

# Output a success message
log("Successfully cancelled orphaned GL Entries.")
# Find all Payment Ledger Entries linked to the cancelled ghost payment
ple_entries = frappe.get_all('Payment Ledger Entry', filters={'voucher_no': 'WI/PAY/25-26/01641'})

# Loop through and forcefully delink and cancel each one
for entry in ple_entries:
    frappe.db.set_value('Payment Ledger Entry', entry.name, 'delinked', 1)
    frappe.db.set_value('Payment Ledger Entry', entry.name, 'docstatus', 2)

# Commit the changes to the database
frappe.db.commit()

# Output a success message
log("Successfully neutralized orphaned Payment Ledger Entries.")

How to avoid this in future?