Skip to content

Commit

Permalink
Remove paid document on Process check run (#202)
Browse files Browse the repository at this point in the history
* class name has been change

* fix: remove paid invoice and changes related to manually paid case

* changes to remove class name changes
  • Loading branch information
viralkansodiya authored and agritheory committed Feb 6, 2024
1 parent 8d46b53 commit 43cc33e
Showing 1 changed file with 32 additions and 7 deletions.
39 changes: 32 additions & 7 deletions check_run/check_run/doctype/check_run/check_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,18 @@ def process_check_run(self: Self) -> None:
self.run_method("validate")
self.status = "Submitting"
self.filter_transactions()
transactions = [t for t in json.loads(self.transactions) if t.get("pay")]
if len(transactions) < 1:
frappe.throw(frappe._("You must select at least one Invoice to pay."))
transactions = [
t
for t in json.loads(self.transactions)
if t.get("pay") and not self.not_outstanding_or_cancelled(t)
]
if not len(transactions):
frappe.msgprint(
"Please check; maybe you have not selected any document to pay, or the selected document has already been paid.<br><br>Kindly refresh the page."
)
return
# if len(transactions) < 1:
# frappe.throw(frappe._("You must select at least one Invoice to pay."))
self.print_count = 0
if self.ach_only().ach_only:
self.initial_check_number = "" # type: ignore
Expand Down Expand Up @@ -490,7 +499,14 @@ def get_entries(doc: CheckRun | str) -> dict:
if frappe.db.exists("Check Run", doc.name):
db_doc = frappe.get_doc("Check Run", doc.name)
if doc.end_date == db_doc.end_date and db_doc.transactions:
return {"transactions": json.loads(db_doc.transactions), "modes_of_payment": modes_of_payment}
if db_doc.docstatus == 0:
outstanding_transaction = []
for row in json.loads(db_doc.transactions):
if not db_doc.not_outstanding_or_cancelled(row):
outstanding_transaction.append(row)
else:
outstanding_transaction = json.loads(db_doc.transactions)
return {"transactions": outstanding_transaction, "modes_of_payment": modes_of_payment}

company = doc.company
pay_to_account = doc.pay_to_account
Expand Down Expand Up @@ -644,7 +660,9 @@ def get_entries(doc: CheckRun | str) -> dict:
attachment
for attachment in get_attachments(transaction.doctype, doc_name)
if attachment.file_url.endswith(".pdf")
] or [{"file_name": doc_name, "file_url": f"/app/Form/{transaction.doctype}/{doc_name}"}]
] or [
{"file_name": doc_name, "file_url": f"/app/Form/{transaction.doctype}/{doc_name}"}
]

if settings and settings.pre_check_overdue_items:
if transaction.due_date < doc.posting_date:
Expand All @@ -661,8 +679,15 @@ def get_entries(doc: CheckRun | str) -> dict:
transaction.mode_of_payment = (
frappe.get_value("Employee", transaction.party, "mode_of_payment") or settings.journal_entry
)

return {"transactions": transactions, "modes_of_payment": modes_of_payment}
# Process Unpaid Transaction
# start
outstanding_transaction = []
db_doc = frappe.get_doc("Check Run", doc.name)
for row in transactions:
if not db_doc.not_outstanding_or_cancelled(row):
outstanding_transaction.append(row)
# end
return {"transactions": outstanding_transaction, "modes_of_payment": modes_of_payment}


@frappe.whitelist()
Expand Down

0 comments on commit 43cc33e

Please sign in to comment.