reafctor: validate instead of postprocess

This commit is contained in:
barredterra
2021-09-17 11:58:24 +02:00
parent c8c10ef06b
commit ad1fad068e

View File

@@ -2049,8 +2049,7 @@ def create_dunning(source_name, target_doc=None, ignore_permissions=False):
target.closing_text = letter_text.get('closing_text')
target.language = letter_text.get('language')
def postprocess_overdue_payment(source, target, source_parent):
target.overdue_days = (getdate(nowdate()) - getdate(source.due_date)).days
target.validate()
return get_mapped_doc(
from_doctype="Sales Invoice",
@@ -2069,8 +2068,7 @@ def create_dunning(source_name, target_doc=None, ignore_permissions=False):
"name": "payment_schedule",
"parent": "sales_invoice"
},
"condition": lambda doc: doc.outstanding > 0,
"postprocess": postprocess_overdue_payment
"condition": lambda doc: doc.outstanding > 0
}
},
target_doc=target_doc,