fix: clearance date update with permission checks

Refactor update_clearance_date to check permissions for payment documents before processing entries.
This commit is contained in:
rohitwaghchaure
2026-06-13 18:43:12 +05:30
committed by GitHub
parent 559c95c8a8
commit 46b3e0c385

View File

@@ -90,27 +90,14 @@ class BankClearance(Document):
@frappe.whitelist() @frappe.whitelist()
def update_clearance_date(self): def update_clearance_date(self):
<<<<<<< HEAD payment_docs = []
clearance_date_updated = False for d in self.get("payment_entries"):
======= if d.payment_document not in payment_docs:
self.check_permission("write") payment_docs.append(d.payment_document)
invalid_document = []
invalid_cheque_date = []
entries_to_update = []
def validate_entry(d): for doctype in payment_docs:
is_valid = True frappe.has_permission(doctype, "write", throw=True)
if not d.payment_document:
invalid_document.append(str(d.idx))
is_valid = False
if d.clearance_date and d.cheque_date and getdate(d.clearance_date) < getdate(d.cheque_date):
invalid_cheque_date.append(str(d.idx))
is_valid = False
return is_valid
>>>>>>> dd56e80512 (fix: pemission for whitelist functions)
for d in self.get("payment_entries"): for d in self.get("payment_entries"):
if d.clearance_date: if d.clearance_date:
if not d.payment_document: if not d.payment_document: