fix: delete exchange gain loss journal entry while deleting payment entry

(cherry picked from commit 9886cf0d46)
This commit is contained in:
Navin-S-R
2024-09-12 15:25:54 +05:30
committed by Mergify
parent 77bdf18c23
commit 62f12861f1
2 changed files with 71 additions and 32 deletions

View File

@@ -326,11 +326,16 @@ class AccountsController(TransactionBase):
repost_doc.save(ignore_permissions=True)
def on_trash(self):
from erpnext.accounts.utils import delete_exchange_gain_loss_journal
self._remove_references_in_repost_doctypes()
self._remove_references_in_unreconcile()
# delete sl and gl entries on deletion of transaction
if frappe.db.get_single_value("Accounts Settings", "delete_linked_ledger_entries"):
# delete linked exchange gain/loss journal
delete_exchange_gain_loss_journal(self)
ple = frappe.qb.DocType("Payment Ledger Entry")
frappe.qb.from_(ple).delete().where(
(ple.voucher_type == self.doctype) & (ple.voucher_no == self.name)