diff --git a/check_run/hooks.py b/check_run/hooks.py index 063d9a5c..a8e0d564 100644 --- a/check_run/hooks.py +++ b/check_run/hooks.py @@ -109,7 +109,6 @@ "Bank": {"validate": ["check_run.overrides.bank.validate"]}, "Payment Entry": { "validate": [ - "check_run.overrides.payment_entry.validate_outstanding_payment_terms", "check_run.overrides.payment_entry.validate_duplicate_check_number", ], "on_submit": ["check_run.overrides.payment_entry.update_check_number"], diff --git a/check_run/overrides/payment_entry.py b/check_run/overrides/payment_entry.py index 92d508cf..dbcae5cc 100644 --- a/check_run/overrides/payment_entry.py +++ b/check_run/overrides/payment_entry.py @@ -5,7 +5,7 @@ from frappe.utils import get_link_to_form from erpnext.accounts.doctype.payment_entry.payment_entry import PaymentEntry from erpnext.accounts.general_ledger import make_gl_entries, process_gl_map -from frappe.utils.data import getdate, flt +from frappe.utils.data import getdate class CustomPaymentEntry(PaymentEntry): @@ -60,32 +60,6 @@ def update_check_number(doc: PaymentEntry, method: str | None = None) -> None: frappe.db.set_value("Bank Account", doc.bank_account, "check_number", doc.reference_no) -@frappe.whitelist() -def validate_outstanding_payment_terms(doc: PaymentEntry, method: str | None = None) -> None: - references = doc.get("references") - errors = [] - for r in references: - if r.reference_doctype != "Purchase Invoice": - continue - pmt_terms = frappe.get_all( - "Payment Schedule", - [ - ["parent", "=", r.reference_name], - ["outstanding", "NOT IN", [0.0, flt(r.allocated_amount)]], - ], - debug=True, - ) - if doc.check_run and pmt_terms and not r.payment_term: - errors.append((r.idx, r.reference_name)) - - if errors: - list_items = "
  • ".join([f"Row {row}: {inv}" for row, inv in errors]) - message = frappe._( - f"There is at least one outstanding Payment Schedule Payment Term for the following Purchase Invoices in the Payment References table:


    Please update the Payment Term field to tie this Payment Entry to the invoice's Payment Schedule and prevent paid invoice portions from showing up in a Check Run." - ) - frappe.throw(msg=message, title=frappe._("Partially Paid Invoices")) - - @frappe.whitelist() def validate_duplicate_check_number(doc: PaymentEntry, method: str | None = None) -> None: check_run_settings = frappe.db.exists(