From b9a02b466be52de4403916e68e9abdbdc0ba5f19 Mon Sep 17 00:00:00 2001 From: Abdeali Chharchhoda Date: Tue, 29 Apr 2025 18:44:39 +0530 Subject: [PATCH] fix: do not allocate amount when ref's doctype or name are not set --- erpnext/accounts/doctype/payment_entry/payment_entry.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py index 46da7c947cc..d991cb128e0 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.py +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py @@ -2081,7 +2081,7 @@ class PaymentEntry(AccountsController): # Re allocate amount to those references which have PR set (Higher priority) for ref in self.references: - if not ref.payment_request: + if not (ref.reference_doctype and ref.reference_name and ref.payment_request): continue # fetch outstanding_amount of `Reference` (Payment Term) and `Payment Request` to allocate new amount @@ -2132,7 +2132,7 @@ class PaymentEntry(AccountsController): ) # Re allocate amount to those references which have no PR (Lower priority) for ref in self.references: - if ref.payment_request: + if ref.payment_request or not (ref.reference_doctype and ref.reference_name): continue key = (ref.reference_doctype, ref.reference_name, ref.get("payment_term"))