feat(nexa_coa_setup): renumber l10n_ca bank/AR/AP/tax legacy accounts to 4-digit

Final batch of code conversions — 12 l10n_ca accounts that we kept active
because they have historical postings. Renaming preserves all FK
references (account_id stays the same), just changes the displayed code.

  112005 Scotia Current 9309     -> 1010  (primary operating bank)
  112004 BMO                     -> 1030
  112007 RBC                     -> 1040
  112008 Scotia Credit Card 5890 -> 1070
  112006 RBC VISA                -> 1071
  112002 Outstanding Receipts    -> 1080  (in-transit receipts)
  112003 Outstanding Payments    -> 1081  (in-transit payments)
  112001 Bank Suspense Account   -> 1090
  115100 Customers Account       -> 1100  (AR control)
  118310 HST receivable - 13%    -> 1215  (legacy HST receivable, near new 1210 ITC)
  211100 Vendors Account         -> 2010  (AP control)
  213310 HST to pay - 13%        -> 2115  (legacy HST collected, near new 2110)

Verification: 140/140 active accounts now use 4-digit codes. All four
end-to-end test invoices still post correctly.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
gsinghpal
2026-05-12 20:10:47 -04:00
parent 86e89ca419
commit 0230670bdc

View File

@@ -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()