mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-30 07:08:24 +00:00
fix(accounts): clear clearance date when amending reconciled voucher (backport #55947)
When a reconciled voucher (Payment Entry / Journal Entry / Purchase Invoice / Sales Invoice) is cancelled, amended and resubmitted, the stale clearance date was carried into the amended draft because the framework ignores `no_copy` while amending. Add a shared `before_insert` hook on AccountsController that clears `clearance_date` (top-level field and Sales Invoice `payments` rows) on amendment. Reconciliation still sets the value post-submit via `frappe.db.set_value`, which bypasses this path. Manual backport of #55947 to version-15-hotfix (Mergify's auto-backport #55972 committed conflict markers; this replaces it).
This commit is contained in:
@@ -141,6 +141,26 @@ class AccountsController(TransactionBase):
|
||||
if self.doctype in relevant_docs:
|
||||
self.set_payment_schedule()
|
||||
|
||||
def before_insert(self):
|
||||
self.clear_clearance_date_on_amend()
|
||||
|
||||
def clear_clearance_date_on_amend(self):
|
||||
"""Drop the bank reconciliation clearance date copied over while amending.
|
||||
|
||||
The framework copies `no_copy` fields when amending, so a reconciled
|
||||
voucher would carry a stale clearance date into its amendment even though
|
||||
the linked bank transaction gets unreconciled on cancellation.
|
||||
"""
|
||||
if not self.get("amended_from"):
|
||||
return
|
||||
|
||||
if self.meta.has_field("clearance_date"):
|
||||
self.clearance_date = None
|
||||
|
||||
for payment in self.get("payments") or []:
|
||||
if payment.meta.has_field("clearance_date"):
|
||||
payment.clearance_date = None
|
||||
|
||||
def remove_bundle_for_non_stock_invoices(self):
|
||||
has_sabb = False
|
||||
if self.doctype in ("Sales Invoice", "Purchase Invoice") and not self.update_stock:
|
||||
|
||||
Reference in New Issue
Block a user