chore(bank-integration): remove completed standard_field code migration
migrate_standard_field_codes_to_labels() rewrote Bank Integration Excel Column Mapping.standard_field from old machine codes to human-readable labels — a one-time compatibility fix after the storage format changed. The migration has done its job: the preset fixture already ships labels, and new sites create mappings via the UI dropdown (labels from the start), so old codes can only exist on databases that predate the format change. Drop the function, its code->label map, and the after_migrate call. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
3e2f9d7c66
commit
e88ab56df0
|
|
@ -152,22 +152,6 @@ def rename_bip_purposes():
|
||||||
_rename_to_readable("Bank Integration Supplier", "BIS", "supplier_name")
|
_rename_to_readable("Bank Integration Supplier", "BIS", "supplier_name")
|
||||||
|
|
||||||
|
|
||||||
_STANDARD_FIELD_CODE_TO_LABEL = {
|
|
||||||
"date": "Date",
|
|
||||||
"reference_number": "Reference Number",
|
|
||||||
"counterparty": "Counterparty",
|
|
||||||
"counterparty_tax_id": "Counterparty Tax ID (VOEN)",
|
|
||||||
"counterparty_iban": "Counterparty IBAN",
|
|
||||||
"amount": "Amount",
|
|
||||||
"debit": "Debit",
|
|
||||||
"credit": "Credit",
|
|
||||||
"direction": "Direction",
|
|
||||||
"currency": "Currency",
|
|
||||||
"purpose": "Purpose",
|
|
||||||
"description": "Description",
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
_PRESET_FIELDS_TO_COPY = (
|
_PRESET_FIELDS_TO_COPY = (
|
||||||
"header_row",
|
"header_row",
|
||||||
"amount_mode",
|
"amount_mode",
|
||||||
|
|
@ -243,29 +227,3 @@ def copy_excel_preset_into_bank_integration():
|
||||||
if copied:
|
if copied:
|
||||||
frappe.db.commit()
|
frappe.db.commit()
|
||||||
print(f"BI: copied File Format from preset '{chosen_preset_name}' into {copied} Bank Integration(s)")
|
print(f"BI: copied File Format from preset '{chosen_preset_name}' into {copied} Bank Integration(s)")
|
||||||
|
|
||||||
|
|
||||||
def migrate_standard_field_codes_to_labels():
|
|
||||||
"""Rewrite Bank Integration Excel Column Mapping.standard_field from the old
|
|
||||||
machine codes ('date', 'reference_number', ...) to the new human-readable
|
|
||||||
labels stored by the doctype select options. Idempotent: rows already on a
|
|
||||||
label value are left alone."""
|
|
||||||
if not frappe.db.exists("DocType", "Bank Integration Excel Column Mapping"):
|
|
||||||
return
|
|
||||||
rows = frappe.get_all(
|
|
||||||
"Bank Integration Excel Column Mapping",
|
|
||||||
filters={"standard_field": ["in", list(_STANDARD_FIELD_CODE_TO_LABEL.keys())]},
|
|
||||||
fields=["name", "standard_field"],
|
|
||||||
)
|
|
||||||
if not rows:
|
|
||||||
return
|
|
||||||
for r in rows:
|
|
||||||
label = _STANDARD_FIELD_CODE_TO_LABEL.get(r.standard_field)
|
|
||||||
if not label:
|
|
||||||
continue
|
|
||||||
frappe.db.set_value(
|
|
||||||
"Bank Integration Excel Column Mapping", r.name,
|
|
||||||
"standard_field", label, update_modified=False,
|
|
||||||
)
|
|
||||||
frappe.db.commit()
|
|
||||||
print(f"BI: migrated {len(rows)} Excel column mapping(s) to human-readable labels")
|
|
||||||
|
|
|
||||||
|
|
@ -142,13 +142,11 @@ def after_migrate_combined():
|
||||||
from jey_erp.bank_integration.migrations import (
|
from jey_erp.bank_integration.migrations import (
|
||||||
link_kb_bank_accounts_to_bi,
|
link_kb_bank_accounts_to_bi,
|
||||||
rename_bip_purposes,
|
rename_bip_purposes,
|
||||||
migrate_standard_field_codes_to_labels,
|
|
||||||
copy_excel_preset_into_bank_integration,
|
copy_excel_preset_into_bank_integration,
|
||||||
add_importer_link_to_invoicing_workspace,
|
add_importer_link_to_invoicing_workspace,
|
||||||
)
|
)
|
||||||
link_kb_bank_accounts_to_bi()
|
link_kb_bank_accounts_to_bi()
|
||||||
rename_bip_purposes()
|
rename_bip_purposes()
|
||||||
migrate_standard_field_codes_to_labels()
|
|
||||||
copy_excel_preset_into_bank_integration()
|
copy_excel_preset_into_bank_integration()
|
||||||
add_importer_link_to_invoicing_workspace()
|
add_importer_link_to_invoicing_workspace()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue