Merge pull request #39196 from ruthra-kumar/incorrect_status_in_bank_transaction
fix: bank transaction status upon reconciliation
diff --git a/erpnext/accounts/doctype/bank_reconciliation_tool/bank_reconciliation_tool.py b/erpnext/accounts/doctype/bank_reconciliation_tool/bank_reconciliation_tool.py
index 0779a09..9e6b51d 100644
--- a/erpnext/accounts/doctype/bank_reconciliation_tool/bank_reconciliation_tool.py
+++ b/erpnext/accounts/doctype/bank_reconciliation_tool/bank_reconciliation_tool.py
@@ -444,6 +444,10 @@
vouchers = json.loads(vouchers)
transaction = frappe.get_doc("Bank Transaction", bank_transaction_name)
transaction.add_payment_entries(vouchers)
+ transaction.validate_duplicate_references()
+ transaction.allocate_payment_entries()
+ transaction.update_allocated_amount()
+ transaction.set_status()
transaction.save()
return transaction
diff --git a/erpnext/accounts/doctype/bank_transaction/bank_transaction.py b/erpnext/accounts/doctype/bank_transaction/bank_transaction.py
index 57f7c0e..8d82123 100644
--- a/erpnext/accounts/doctype/bank_transaction/bank_transaction.py
+++ b/erpnext/accounts/doctype/bank_transaction/bank_transaction.py
@@ -3,12 +3,11 @@
import frappe
from frappe import _
+from frappe.model.document import Document
from frappe.utils import flt
-from erpnext.controllers.status_updater import StatusUpdater
-
-class BankTransaction(StatusUpdater):
+class BankTransaction(Document):
# begin: auto-generated types
# This code is auto-generated. Do not modify anything in this block.
@@ -50,6 +49,15 @@
def validate(self):
self.validate_duplicate_references()
+ def set_status(self):
+ if self.docstatus == 2:
+ self.db_set("status", "Cancelled")
+ elif self.docstatus == 1:
+ if self.unallocated_amount > 0:
+ self.db_set("status", "Unreconciled")
+ elif self.unallocated_amount <= 0:
+ self.db_set("status", "Reconciled")
+
def validate_duplicate_references(self):
"""Make sure the same voucher is not allocated twice within the same Bank Transaction"""
if not self.payment_entries:
@@ -88,7 +96,7 @@
for payment_entry in self.payment_entries:
self.clear_linked_payment_entry(payment_entry, for_cancel=True)
- self.set_status(update=True)
+ self.set_status()
def add_payment_entries(self, vouchers):
"Add the vouchers with zero allocation. Save() will perform the allocations and clearance"
diff --git a/erpnext/controllers/status_updater.py b/erpnext/controllers/status_updater.py
index d09001c..297f8c2 100644
--- a/erpnext/controllers/status_updater.py
+++ b/erpnext/controllers/status_updater.py
@@ -131,11 +131,6 @@
"eval:self.status != 'Stopped' and self.per_ordered == 100 and self.docstatus == 1 and self.material_request_type == 'Manufacture'",
],
],
- "Bank Transaction": [
- ["Unreconciled", "eval:self.docstatus == 1 and self.unallocated_amount>0"],
- ["Reconciled", "eval:self.docstatus == 1 and self.unallocated_amount<=0"],
- ["Cancelled", "eval:self.docstatus == 2"],
- ],
"POS Opening Entry": [
["Draft", None],
["Open", "eval:self.docstatus == 1 and not self.pos_closing_entry"],