diff --git a/nexa_coa_setup/scripts/convert_l10nca_to_4digit.py b/nexa_coa_setup/scripts/convert_l10nca_to_4digit.py new file mode 100644 index 00000000..811f327a --- /dev/null +++ b/nexa_coa_setup/scripts/convert_l10nca_to_4digit.py @@ -0,0 +1,34 @@ +"""Rename the l10n_ca bank/AR/AP/tax legacy accounts to 4-digit codes.""" +LEGACY_MAP = [ + # (old_code, new_code, expected_name_substring) + ("112005", "1010", "Scotia Current"), # Primary operating (most-used) + ("112004", "1030", "BMO"), # BMO bank + ("112007", "1040", "RBC"), # RBC bank (NOT visa) + ("112008", "1070", "Scotia Credit Card"), # Scotia CC + ("112006", "1071", "RBC VISA"), # RBC visa + ("112002", "1080", "Outstanding Receipts"), # In-transit receipts + ("112003", "1081", "Outstanding Payments"), # In-transit payments + ("112001", "1090", "Bank Suspense"), # Catch-all suspense + ("115100", "1100", "Customers Account"), # AR control + ("118310", "1215", "HST receivable - 13%"), # Legacy 13% HST receivable (near new 1210) + ("211100", "2010", "Vendors Account"), # AP control + ("213310", "2115", "HST to pay - 13%"), # Legacy 13% HST collected (near new 2110) +] +ok = 0; skipped = 0; missing = 0 +for old, new, hint in LEGACY_MAP: + acc = env['account.account'].search([('code', '=', old)], limit=1) + if not acc: + print(f"MISS {old} -> {new}: not found") + missing += 1; continue + if hint.lower() not in (acc.name or '').lower(): + print(f"SKIP {old} -> {new}: name '{acc.name}' doesn't match '{hint}'") + skipped += 1; continue + conflict = env['account.account'].with_context(active_test=False).search([('code', '=', new)], limit=1) + if conflict: + print(f"SKIP {old} -> {new}: target occupied by {conflict.name}") + skipped += 1; continue + acc.code = new + ok += 1 + print(f"OK {old} -> {new}: {acc.name}") +print(f">>> Renumbered {ok}, skipped {skipped}, missing {missing} of {len(LEGACY_MAP)}") +env.cr.commit()