Merge pull request #32137 from ruthra-kumar/delete_payment_ledger_entries_on_src_doc_delete

refactor(minor): delete linked payment ledger entries on source doc deletion
This commit is contained in:
ruthra kumar 2022-09-11 11:21:24 +05:30 committed by GitHub
commit 4576c1ebc3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -205,6 +205,10 @@ class AccountsController(TransactionBase):
def on_trash(self):
# delete sl and gl entries on deletion of transaction
if frappe.db.get_single_value("Accounts Settings", "delete_linked_ledger_entries"):
ple = frappe.qb.DocType("Payment Ledger Entry")
frappe.qb.from_(ple).delete().where(
(ple.voucher_type == self.doctype) & (ple.voucher_no == self.name)
).run()
frappe.db.sql(
"delete from `tabGL Entry` where voucher_type=%s and voucher_no=%s", (self.doctype, self.name)
)