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

This commit is contained in:
Navin-S-R
2024-09-12 15:25:54 +05:30
parent 1bf60248d9
commit 9886cf0d46
2 changed files with 71 additions and 32 deletions

View File

@@ -346,12 +346,17 @@ 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()
self.remove_serial_and_batch_bundle()
# 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)