Skip to content

Commit

Permalink
fix: remove validation (#194)
Browse files Browse the repository at this point in the history
  • Loading branch information
agritheory authored Jan 18, 2024
1 parent 844217b commit efda8ae
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 28 deletions.
1 change: 0 additions & 1 deletion check_run/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down
28 changes: 1 addition & 27 deletions check_run/overrides/payment_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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 = "</li><li>".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:<br><br><ul><li>{list_items}</li></ul><br>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(
Expand Down

0 comments on commit efda8ae

Please sign in to comment.