fix: Partial PLE cancellation
diff --git a/erpnext/accounts/doctype/payment_ledger_entry/payment_ledger_entry.json b/erpnext/accounts/doctype/payment_ledger_entry/payment_ledger_entry.json
index 22842ce..9cf2ac6 100644
--- a/erpnext/accounts/doctype/payment_ledger_entry/payment_ledger_entry.json
+++ b/erpnext/accounts/doctype/payment_ledger_entry/payment_ledger_entry.json
@@ -13,6 +13,7 @@
"party_type",
"party",
"due_date",
+ "voucher_detail_no",
"cost_center",
"finance_book",
"voucher_type",
@@ -142,12 +143,17 @@
"fieldname": "remarks",
"fieldtype": "Text",
"label": "Remarks"
+ },
+ {
+ "fieldname": "voucher_detail_no",
+ "fieldtype": "Data",
+ "label": "Voucher Detail No"
}
],
"in_create": 1,
"index_web_pages_for_search": 1,
"links": [],
- "modified": "2022-08-22 15:32:56.629430",
+ "modified": "2023-06-29 12:24:20.500632",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Payment Ledger Entry",
diff --git a/erpnext/accounts/general_ledger.py b/erpnext/accounts/general_ledger.py
index 22f3959..f1dad87 100644
--- a/erpnext/accounts/general_ledger.py
+++ b/erpnext/accounts/general_ledger.py
@@ -526,7 +526,11 @@
if gl_entries:
create_payment_ledger_entry(
- gl_entries, cancel=1, adv_adj=adv_adj, update_outstanding=update_outstanding
+ gl_entries,
+ cancel=1,
+ adv_adj=adv_adj,
+ update_outstanding=update_outstanding,
+ partial_cancel=partial_cancel,
)
validate_accounting_period(gl_entries)
check_freezing_date(gl_entries[0]["posting_date"], adv_adj)
diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py
index 1fa0e86..2a40a3a 100644
--- a/erpnext/accounts/utils.py
+++ b/erpnext/accounts/utils.py
@@ -1467,6 +1467,7 @@
due_date=gle.due_date,
voucher_type=gle.voucher_type,
voucher_no=gle.voucher_no,
+ voucher_detail_no=gle.voucher_detail_no,
against_voucher_type=gle.against_voucher_type
if gle.against_voucher_type
else gle.voucher_type,
@@ -1488,7 +1489,7 @@
def create_payment_ledger_entry(
- gl_entries, cancel=0, adv_adj=0, update_outstanding="Yes", from_repost=0
+ gl_entries, cancel=0, adv_adj=0, update_outstanding="Yes", from_repost=0, partial_cancel=False
):
if gl_entries:
ple_map = get_payment_ledger_entries(gl_entries, cancel=cancel)
@@ -1498,7 +1499,7 @@
ple = frappe.get_doc(entry)
if cancel:
- delink_original_entry(ple)
+ delink_original_entry(ple, partial_cancel=partial_cancel)
ple.flags.ignore_permissions = 1
ple.flags.adv_adj = adv_adj
@@ -1545,7 +1546,7 @@
ref_doc.set_status(update=True)
-def delink_original_entry(pl_entry):
+def delink_original_entry(pl_entry, partial_cancel=False):
if pl_entry:
ple = qb.DocType("Payment Ledger Entry")
query = (
@@ -1565,6 +1566,10 @@
& (ple.against_voucher_no == pl_entry.against_voucher_no)
)
)
+
+ if partial_cancel:
+ query = query.where(ple.voucher_detail_no == pl_entry.voucher_detail_no)
+
query.run()