Revert "feat: remove dunning as possible reference from payment entry"
This reverts commit b774d8d0e3c1e5a53b3422591b3f2d52ca959645.
diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py
index 5da89a3..5793ecf 100644
--- a/erpnext/accounts/doctype/payment_entry/payment_entry.py
+++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py
@@ -386,7 +386,7 @@
def get_valid_reference_doctypes(self):
if self.party_type == "Customer":
- return ("Sales Order", "Sales Invoice", "Journal Entry")
+ return ("Sales Order", "Sales Invoice", "Journal Entry", "Dunning")
elif self.party_type == "Supplier":
return ("Purchase Order", "Purchase Invoice", "Journal Entry")
elif self.party_type == "Shareholder":
@@ -1693,7 +1693,11 @@
ref_doc.company
)
- if reference_doctype == "Journal Entry" and ref_doc.docstatus == 1:
+ if reference_doctype == "Dunning":
+ total_amount = outstanding_amount = ref_doc.get("dunning_amount")
+ exchange_rate = 1
+
+ elif reference_doctype == "Journal Entry" and ref_doc.docstatus == 1:
total_amount = ref_doc.get("total_amount")
if ref_doc.multi_currency:
exchange_rate = get_exchange_rate(
@@ -1926,7 +1930,7 @@
def set_party_type(dt):
- if dt in ("Sales Invoice", "Sales Order"):
+ if dt in ("Sales Invoice", "Sales Order", "Dunning"):
party_type = "Customer"
elif dt in ("Purchase Invoice", "Purchase Order"):
party_type = "Supplier"
@@ -1953,7 +1957,7 @@
def set_payment_type(dt, doc):
if (
- dt == "Sales Order" or (dt == "Sales Invoice" and doc.outstanding_amount > 0)
+ dt == "Sales Order" or (dt in ("Sales Invoice", "Dunning") and doc.outstanding_amount > 0)
) or (dt == "Purchase Invoice" and doc.outstanding_amount < 0):
payment_type = "Receive"
else:
@@ -1971,6 +1975,9 @@
else:
grand_total = doc.rounded_total or doc.grand_total
outstanding_amount = doc.outstanding_amount
+ elif dt == "Dunning":
+ grand_total = doc.grand_total
+ outstanding_amount = doc.grand_total
else:
if party_account_currency == doc.company_currency:
grand_total = flt(doc.get("base_rounded_total") or doc.get("base_grand_total"))