fix: ignore repost payment ledger on basic documents cancellation (#34054)

fix: ignore repost payment ledger on cancel/delete of Inv/Pay/JE's

Co-authored-by: Deepesh Garg <deepeshgarg6@gmail.com>
This commit is contained in:
ruthra kumar
2023-02-19 12:09:10 +05:30
committed by GitHub
parent 5b7d23de15
commit c722f2819c
9 changed files with 28 additions and 6 deletions

View File

@@ -204,6 +204,12 @@ class AccountsController(TransactionBase):
validate_einvoice_fields(self)
def on_trash(self):
# delete references in 'Repost Payment Ledger'
rpi = frappe.qb.DocType("Repost Payment Ledger Items")
frappe.qb.from_(rpi).delete().where(
(rpi.voucher_type == self.doctype) & (rpi.voucher_no == self.name)
).run()
# 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")