fix: clearing a mapping row's ERP/Bank Account link resets the registry record
The on_update reverse-sync only treated a row as "mapped" if its key field was present, so clearing erp_customer / erp_supplier / bank_account (without deleting the row) left the Kapital Bank Customer/Supplier/ Account/Card still marked Mapped. Now a row counts as mapped only when both the key and the ERP/Bank Account link are set. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
d9d033bfe1
commit
bb49b5915a
|
|
@ -10,8 +10,9 @@ class KapitalBankSettings(Document):
|
||||||
self._sync_card_statuses()
|
self._sync_card_statuses()
|
||||||
|
|
||||||
def _sync_account_statuses(self):
|
def _sync_account_statuses(self):
|
||||||
"""Reset Kapital Bank Account status to 'New' for accounts removed from account_mappings."""
|
"""Reset Kapital Bank Account status to 'New' when its mapping row is removed
|
||||||
mapped_ibans = {row.iban for row in self.account_mappings if row.iban}
|
from account_mappings, or when the row's Bank Account link is cleared."""
|
||||||
|
mapped_ibans = {row.iban for row in self.account_mappings if row.iban and row.bank_account}
|
||||||
|
|
||||||
orphaned = frappe.get_all(
|
orphaned = frappe.get_all(
|
||||||
"Kapital Bank Account",
|
"Kapital Bank Account",
|
||||||
|
|
@ -32,8 +33,9 @@ class KapitalBankSettings(Document):
|
||||||
)
|
)
|
||||||
|
|
||||||
def _sync_customer_statuses(self):
|
def _sync_customer_statuses(self):
|
||||||
"""Reset Kapital Bank Customer status to 'New' for customers removed from customer_mappings."""
|
"""Reset Kapital Bank Customer status to 'New' when its mapping row is removed
|
||||||
mapped_names = {row.kb_customer_name for row in self.customer_mappings if row.kb_customer_name}
|
from customer_mappings, or when the row's ERP Customer link is cleared."""
|
||||||
|
mapped_names = {row.kb_customer_name for row in self.customer_mappings if row.kb_customer_name and row.erp_customer}
|
||||||
|
|
||||||
orphaned = frappe.get_all(
|
orphaned = frappe.get_all(
|
||||||
"Kapital Bank Customer",
|
"Kapital Bank Customer",
|
||||||
|
|
@ -57,8 +59,9 @@ class KapitalBankSettings(Document):
|
||||||
)
|
)
|
||||||
|
|
||||||
def _sync_supplier_statuses(self):
|
def _sync_supplier_statuses(self):
|
||||||
"""Reset Kapital Bank Supplier status to 'New' for suppliers removed from supplier_mappings."""
|
"""Reset Kapital Bank Supplier status to 'New' when its mapping row is removed
|
||||||
mapped_names = {row.kb_supplier_name for row in self.supplier_mappings if row.kb_supplier_name}
|
from supplier_mappings, or when the row's ERP Supplier link is cleared."""
|
||||||
|
mapped_names = {row.kb_supplier_name for row in self.supplier_mappings if row.kb_supplier_name and row.erp_supplier}
|
||||||
|
|
||||||
orphaned = frappe.get_all(
|
orphaned = frappe.get_all(
|
||||||
"Kapital Bank Supplier",
|
"Kapital Bank Supplier",
|
||||||
|
|
@ -81,8 +84,9 @@ class KapitalBankSettings(Document):
|
||||||
)
|
)
|
||||||
|
|
||||||
def _sync_card_statuses(self):
|
def _sync_card_statuses(self):
|
||||||
"""Reset Kapital Bank Card status to 'New' for cards removed from card_mappings."""
|
"""Reset Kapital Bank Card status to 'New' when its mapping row is removed
|
||||||
mapped_accounts = {row.account_number for row in self.card_mappings if row.account_number}
|
from card_mappings, or when the row's Bank Account link is cleared."""
|
||||||
|
mapped_accounts = {row.account_number for row in self.card_mappings if row.account_number and row.bank_account}
|
||||||
|
|
||||||
orphaned = frappe.get_all(
|
orphaned = frappe.get_all(
|
||||||
"Kapital Bank Card",
|
"Kapital Bank Card",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue