mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-25 07:54:46 +00:00
refactor: combine the return conditions
This commit is contained in:
@@ -208,21 +208,12 @@ def resolve_dunning_for_credit_note(doc, state):
|
|||||||
Check if dunning should be resolved when a credit note is issued against a Sales Invoice.
|
Check if dunning should be resolved when a credit note is issued against a Sales Invoice.
|
||||||
Only process if update_outstanding_for_self is False (credit note is being applied against the original invoice).
|
Only process if update_outstanding_for_self is False (credit note is being applied against the original invoice).
|
||||||
"""
|
"""
|
||||||
if not doc.is_return or doc.get("update_outstanding_for_self"):
|
if not doc.is_return or doc.get("update_outstanding_for_self") or not doc.get("return_against"):
|
||||||
return
|
return
|
||||||
|
|
||||||
if not doc.get("return_against"):
|
state = "Resolved" if doc.docstatus == 2 else "Unresolved"
|
||||||
return
|
|
||||||
|
|
||||||
original_invoice = doc.return_against
|
dunnings = get_linked_dunnings_as_per_state(doc.return_against, state)
|
||||||
if doc.docstatus == 1:
|
|
||||||
state = "Unresolved"
|
|
||||||
elif doc.docstatus == 2:
|
|
||||||
state = "Resolved"
|
|
||||||
else:
|
|
||||||
return
|
|
||||||
|
|
||||||
dunnings = get_linked_dunnings_as_per_state(original_invoice, state)
|
|
||||||
|
|
||||||
for dunning in dunnings:
|
for dunning in dunnings:
|
||||||
resolve = True
|
resolve = True
|
||||||
|
|||||||
Reference in New Issue
Block a user