mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-06 05:39:12 +00:00
Merge pull request #55360 from khushi8112/validate-pe-cancel-on-bank-reconciliation
fix: block cancellation if reconciled with a Bank Transaction
This commit is contained in:
@@ -97,12 +97,14 @@ class TestBankTransaction(ERPNextTestSuite):
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
reconcile_vouchers(bank_transaction.name, vouchers)
|
reconcile_vouchers(bank_transaction.name, vouchers)
|
||||||
payment.reload()
|
|
||||||
payment.cancel()
|
|
||||||
bank_transaction.reload()
|
bank_transaction.reload()
|
||||||
self.assertEqual(bank_transaction.docstatus, DocStatus.submitted())
|
bank_transaction.remove_payment_entries()
|
||||||
|
bank_transaction.reload()
|
||||||
self.assertEqual(bank_transaction.unallocated_amount, 1700)
|
self.assertEqual(bank_transaction.unallocated_amount, 1700)
|
||||||
self.assertEqual(bank_transaction.payment_entries, [])
|
self.assertEqual(bank_transaction.payment_entries, [])
|
||||||
|
payment.reload()
|
||||||
|
payment.cancel()
|
||||||
|
self.assertEqual(bank_transaction.docstatus, DocStatus.submitted())
|
||||||
|
|
||||||
# Check if ERPNext can correctly filter a linked payments based on the debit/credit amount
|
# Check if ERPNext can correctly filter a linked payments based on the debit/credit amount
|
||||||
def test_debit_credit_output(self):
|
def test_debit_credit_output(self):
|
||||||
|
|||||||
@@ -292,6 +292,30 @@ class PaymentEntry(AccountsController):
|
|||||||
alert=True,
|
alert=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def before_cancel(self):
|
||||||
|
from erpnext.accounts.doctype.bank_transaction.bank_transaction import (
|
||||||
|
get_reconciled_bank_transactions,
|
||||||
|
)
|
||||||
|
|
||||||
|
linked_bank_transactions = get_reconciled_bank_transactions(self.doctype, self.name)
|
||||||
|
|
||||||
|
active_bank_transactions = []
|
||||||
|
if linked_bank_transactions:
|
||||||
|
active_bank_transactions = frappe.get_all(
|
||||||
|
"Bank Transaction",
|
||||||
|
filters={"name": ("in", linked_bank_transactions), "docstatus": 1},
|
||||||
|
pluck="name",
|
||||||
|
)
|
||||||
|
if active_bank_transactions:
|
||||||
|
frappe.throw(
|
||||||
|
_(
|
||||||
|
"Payment Entry {0} is reconciled with Bank Transaction(s): {1}. Please unreconcile it before cancelling."
|
||||||
|
).format(
|
||||||
|
frappe.bold(self.name),
|
||||||
|
", ".join(frappe.bold(bt) for bt in active_bank_transactions),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
def on_cancel(self):
|
def on_cancel(self):
|
||||||
self.ignore_linked_doctypes = (
|
self.ignore_linked_doctypes = (
|
||||||
"GL Entry",
|
"GL Entry",
|
||||||
|
|||||||
Reference in New Issue
Block a user