Skip to content

Commit

Permalink
fix: unlink payment on invoice cancellation
Browse files Browse the repository at this point in the history
(cherry picked from commit 537d953)
  • Loading branch information
ruthra-kumar authored and mergify[bot] committed Oct 10, 2022
1 parent 49cedca commit 8ba503b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions erpnext/accounts/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,16 @@ def unlink_ref_doc_from_payment_entries(ref_doc):
(now(), frappe.session.user, ref_doc.doctype, ref_doc.name),
)

ple = qb.DocType("Payment Ledger Entry")

qb.update(ple).set(ple.against_voucher_type, ple.voucher_type).set(
ple.against_voucher_no, ple.voucher_no
).set(ple.modified, now()).set(ple.modified_by, frappe.session.user).where(
(ple.against_voucher_type == ref_doc.doctype)
& (ple.against_voucher_no == ref_doc.name)
& (ple.delinked == 0)
).run()

if ref_doc.doctype in ("Sales Invoice", "Purchase Invoice"):
ref_doc.set("advances", [])

Expand Down

0 comments on commit 8ba503b

Please sign in to comment.