erick:~$ cat bienvenido.md
Inicio chevron_right Contabilidad chevron_right Plan Contable PCGE para ERPNext v16 — Guía y Prompt de Implementación Perú

Plan Contable PCGE para ERPNext v16 — Guía y Prompt de Implementación Perú

ERPNext Contabilidad 2 jun 2026 • 5 min de lectura

Contexto de Negocio e Implementación Local

Configurar la contabilidad en ERPNext v16 para Perú exige reemplazar el catálogo de cuentas genérico que viene por defecto por el Plan Contable General Empresarial (PCGE) 2020 vigente por la SUNAT. Hacer esta depuración de manera local en tu máquina de desarrollo te permite validar el árbol contable, probar asientos de apertura y verificar el flujo del IGV antes de subir cualquier cambio a producción.

Este artículo presenta la especificación contable completa. A continuación se encuentra el Prompt de Automatización listo para ser copiado.


terminal Prompt de Automatización (.md)

Actúa como un Consultor Contable y Funcional Senior de ERPNext con experiencia en la legislación tributaria y el PCGE de Perú.

Objetivo

Crear y ejecutar de forma autónoma un script de Python de bench local para configurar el catálogo contable del Plan Contable General Empresarial (PCGE) 2020 en ERPNext v16, eliminando cuentas genéricas duplicadas y configurando las cuentas raíz y por defecto de la empresa.

Parámetros de Entrada

  • Nombre del Sitio Local: development.localhost
  • Abreviatura de la Empresa: ERK
  • Nombre de la Empresa: Erick Puente S.A.C.

Instrucciones de Ejecución para el Agente

  1. Localización de rutas: Localizar de forma dinámica el directorio raíz de la instalación de frappe-bench en el entorno actual. No asumas rutas estáticas fijas. Puedes utilizar como guía rutas de referencia típicas como ~/frappe-bench/ o carpetas locales afines, pero debes confirmar la ubicación exacta buscando las subcarpetas apps/frappe e apps/erpnext antes de escribir o ejecutar cualquier script.
  2. Generación del Script: Generar el script Python /tmp/pcge_cleanup_[ABBR].py conteniendo toda la estructura contable detallada en las secciones de mapeo, tipos de sistema y merges del PCGE.
  3. Ejecución del Script: Ejecutar de forma autónoma el script utilizando el intérprete de Python del entorno virtual (env) resuelto dinámicamente dentro de la instalación de bench encontrada (por ejemplo, ./env/bin/python o la ruta de entorno virtual correspondiente en el sistema operativo local).
  4. Validación del Árbol: Validar el árbol contable resultante mediante comandos de base de datos o API de Frappe, asegurando que no existan cuentas huérfanas y que la estructura visual coincida con el árbol jerárquico.
  5. Cierre de Ejecución: Reportar el estado final sin requerir entradas adicionales del usuario.

ESPECIFICACIÓN TÉCNICA DETALLADA

1. Requisitos previos de empresa

  • País: Peru
  • Moneda: PEN (Sol)
  • Zona hora: America/Lima

2. Estructura de raíces ERPNext (parent_account = NULL)

Cuenta raízroot_typeClases PCGE que contiene
Aplicación de Fondos (Activos) - {ABBR}Asset10, 12, 14, 16, 18, 20, 25, 33, 34, 37, 39
Fuente de los fondos (Pasivo) - {ABBR}Liability40, 41, 42, 44, 45, 46, 48, 49
Patrimonio - {ABBR}Equity50, 52, 58, 59
Gastos - {ABBR}Expense60, 61, 62, 63, 64, 65, 67, 68, 69
Ingresos - {ABBR}Income70, 75, 77

3. Tipos de cuenta del sistema -> equivalente PCGE (Correcciones PCGE 2020)

[!NOTE] Correcciones críticas aplicadas para Perú:

  • Depreciación Acumulada: Va en la cuenta 395 (Depreciación acumulada - PPE) y NO en la 391 (propiedades de inversión).
  • Gasto de Depreciación: Va en la cuenta 684 (Depreciación de propiedad, planta y equipo) y NO en la 681 (propiedades de inversión).
  • Construcciones en Curso (CWIP): Va bajo la cuenta 339 (Obras en curso) y NO en la 338 (Unidades por recibir).
account_type ERPNextCuenta PCGEDescripción contable
Cash10111 - CAJA MNCaja en soles
Bank10411 - CUENTAS CORRIENTESCuentas bancarias operativas
Receivable12121 - FACTURAS POR COBRAR MNClientes nacionales
Payable42121 - CUENTAS POR PAGAR MNProveedores nacionales
Stock20111 - MERCADERÍAS MANUFACTURADASInventario principal
Fixed Asset33611 - EQUIPO DE CÓMPUTOActivos fijos (o el que aplique)
Accumulated Depreciation39525 - EQUIPO DE CÓMPUTOBajo clase 395 (Depreciación acumulada - PPE)
Depreciation68415 - EQUIPO DE CÓMPUTOGasto de depreciación (Bajo clase 684)
Cost of Goods Sold69111 - MERCADERÍAS MANUFACTURADAS MNCosto de ventas
Stock Adjustment61111 - MERCADERÍAS MANUFACTURADASVariación de existencias
Tax40111 - IGV CUENTA PROPIAIGV 18%
Chargeable63111 - DE CARGAGastos de transporte cargables
Round Off6591 - GASTOS DE REDONDEORedondeo de decimales
Expenses Included In Valuation60911 - MERCADERÍA MANUFACTURADAFletes en costo de inventario
Expenses Included In Asset Valuation6593 - GASTOS EN VALORACIÓN DE ACTIVOSCostos de puesta en marcha
Capital Work in Progress33921 - CONSTRUCCIONES EN CURSOActivos en construcción
Stock Received But Not Billed42113 - INVENTARIO RECIBIDO NO FACTURADOCompras pendientes de factura
Asset Received But Not Billed42114 - ACTIVO RECIBIDO NO FACTURADOActivos pendientes de factura
Temporary59131 - SALDO DE APERTURASaldos iniciales / apertura
Equity50111 - ACCIONESPatrimonio del accionista

4. Cuentas PCGE adicionales para tipos de sistema a crear jerárquicamente

  • Gastos - {ABBR}
    • 65 - OTROS GASTOS DE GESTIÓN [grupo]
      • 656 - ENAJENACIÓN DE ACTIVOS [grupo]
        • 6561 - ACTIVOS INMOVILIZADOS [grupo]
          • 65611 - COSTO NETO DE ENAJENACIÓN [hoja]
      • 659 - OTROS GASTOS DE GESTIÓN [grupo]
        • 6591 - GASTOS DE REDONDEO [hoja, Round Off]
        • 6592 - DESAJUSTE [hoja]
        • 6593 - GASTOS EN VALORACIÓN DE ACTIVOS [hoja, Expenses Included In Asset Valuation]
  • 60 - COMPRAS - {ABBR}
    • 609 - GASTOS VINCULADOS CON COMPRAS [grupo]
      • 6091 - FLETES [grupo]
        • 60911 - MERCADERÍA MANUFACTURADA [hoja, Expenses Included In Valuation]
  • 33 - INMUEBLES, MAQUINARIA Y EQUIPO - {ABBR}
    • 339 - OBRAS EN CURSO [grupo]
      • 3392 - OBRAS EN CURSO - PPE [grupo]
        • 33921 - CONSTRUCCIONES EN CURSO [hoja, Capital Work in Progress]
  • 39 - DEPRECIACIÓN Y AMORTIZACIÓN ACUMULADA - {ABBR}
    • 395 - DEPRECIACIÓN ACUMULADA - PPE [grupo]
      • 3952 - DEPRECIACIÓN ACUMULADA - PPE [grupo]
        • 39525 - EQUIPO DE CÓMPUTO [hoja, Accumulated Depreciation]
  • 68 - VALORACIÓN Y DETERIORO DE ACTIVOS Y PROVISIONES - {ABBR}
    • 684 - DEPRECIACIÓN - GASTO [grupo]
      • 6841 - DEPRECIACIÓN - GASTO - PPE [grupo]
        • 68415 - EQUIPO DE CÓMPUTO [hoja, Depreciation]
  • 42 - CUENTAS POR PAGAR COMERCIALES - {ABBR}
    • 421 - FACTURAS, BOLETAS Y OTROS
      • 4211 - NO EMITIDAS
        • 42113 - INVENTARIO RECIBIDO NO FACTURADO [hoja, Stock Received But Not Billed]
        • 42114 - ACTIVO RECIBIDO NO FACTURADO [hoja, Asset Received But Not Billed]
  • 59 - RESULTADOS ACUMULADOS - {ABBR}
    • 591 - UTILIDADES NO DISTRIBUIDAS
      • 5913 - SALDO DE APERTURA [grupo]
        • 59131 - SALDO DE APERTURA [hoja, Temporary]

5. Defaults de empresa a configurar en tabCompany

CampoCuenta PCGE
default_cash_account10111 - CAJA MN - {ABBR}
default_receivable_account12121 - FACTURAS POR COBRAR MN - {ABBR}
default_payable_account42121 - CUENTAS POR PAGAR MN - {ABBR}
default_payroll_payable_account41111 - SUELDOS Y SALARIOS POR PAGAR - {ABBR}
default_income_account70111 - MERCADERÍAS MANUFACTURADAS MN - {ABBR}
default_expense_account69111 - MERCADERÍAS MANUFACTURADAS MN - {ABBR}
round_off_account6591 - GASTOS DE REDONDEO - {ABBR}
write_off_account6592 - DESAJUSTE - {ABBR}
capital_work_in_progress_account33921 - CONSTRUCCIONES EN CURSO - {ABBR}

6. Cuentas genéricas a mergear (rename_doc con merge=True)

Cuenta genérica (origen)Cuenta PCGE destino
Efectivo - {ABBR}10111 - CAJA MN - {ABBR}
Deudores - {ABBR}12121 - FACTURAS POR COBRAR MN - {ABBR}
Avances de Empleado - {ABBR}14121 - ADELANTO DE REMUNERACIONES - {ABBR}
Stock en mano - {ABBR}20111 - MERCADERÍAS MANUFACTURADAS - {ABBR}
Equipos de oficina - {ABBR}33611 - EQUIPO DE CÓMPUTO - {ABBR}
Cuenta CWIP - {ABBR}33921 - CONSTRUCCIONES EN CURSO - {ABBR}
Acreedores - {ABBR}42121 - CUENTAS POR PAGAR MN - {ABBR}
Inventario Recibido pero no facturados - {ABBR}42113 - INVENTARIO RECIBIDO NO FACTURADO - {ABBR}
Activo recibido pero no facturado - {ABBR}42114 - ACTIVO RECIBIDO NO FACTURADO - {ABBR}
Nómina por Pagar - {ABBR}41111 - SUELDOS Y SALARIOS POR PAGAR - {ABBR}
Ajuste de existencias - {ABBR}61111 - MERCADERÍAS MANUFACTURADAS - {ABBR}
Costo de las Ventas - {ABBR}69111 - MERCADERÍAS MANUFACTURADAS MN - {ABBR}
Venta - {ABBR}70111 - MERCADERÍAS MANUFACTURADAS MN - {ABBR}
Gastos de Comercialización - {ABBR}63111 - DE CARGA - {ABBR}
Gastos dentro de la valoración - {ABBR}60911 - MERCADERÍA MANUFACTURADA - {ABBR}
Gastos incluidos en la valoración de activos - {ABBR}6593 - GASTOS EN VALORACIÓN DE ACTIVOS - {ABBR}
Redondear - {ABBR}6591 - GASTOS DE REDONDEO - {ABBR}
Desajuste - {ABBR}6592 - DESAJUSTE - {ABBR}
Apertura temporal - {ABBR}59131 - SALDO DE APERTURA - {ABBR}
Ganancia/Pérdida por enajenación de activos fijos - {ABBR}65611 - COSTO NETO DE ENAJENACIÓN - {ABBR}

7. Grupos genéricos vacíos a eliminar

Ingresos indirectos - {ABBR}, Ingreso directo - {ABBR}, Egresos indirectos - {ABBR}, Inventario de Gastos - {ABBR}, Gastos directos - {ABBR}, Inventario de Pasivos - {ABBR}, Cuentas por Pagar - {ABBR}, Derechos e Impuestos - {ABBR}, Préstamos (Pasivos) - {ABBR}, Pasivo Corriente - {ABBR}, Activos fijos - {ABBR}, Cuentas temporales - {ABBR}, Activo Corriente - {ABBR}, Dinero Ganado - {ABBR}, Valores y Depósitos - {ABBR}

8. Script Python de Referencia

import sys
import os

sys.path.insert(0, './apps/frappe')
sys.path.insert(0, './apps/erpnext')
import frappe

# CONFIGURACIÓN
SITE    = 'development.localhost'
COMPANY = 'Erick Puente S.A.C.'
ABBR    = 'ERK'

frappe.init(site=SITE, sites_path='./sites')
frappe.connect()

def sql_insert(num, desc, parent_full_name, root_type, is_group, acct_type=''):
    account_name = f"{num} - {desc}"
    name = f"{account_name} - {ABBR}"
    if frappe.db.exists('Account', name):
        print(f"  [EXISTS] {name}")
        return name
    frappe.db.sql("""
        INSERT INTO `tabAccount`
        (name, creation, modified, modified_by, owner, docstatus,
         account_name, account_number, parent_account, root_type,
         is_group, company, account_currency, account_type, lft, rgt)
        VALUES (%s, NOW(), NOW(), 'Administrator', 'Administrator', 0,
                %s, %s, %s, %s, %s, %s, 'PEN', %s, 0, 0)
    """, (name, account_name, num, parent_full_name,
          root_type, is_group, COMPANY, acct_type))
    frappe.db.commit()
    print(f"  [CREATE] {name}")
    return name

def ensure_root(display_name, root_type):
    name = f"{display_name} - {ABBR}"
    if not frappe.db.exists('Account', name):
        frappe.db.sql("""
            INSERT INTO `tabAccount`
            (name, creation, modified, modified_by, owner, docstatus,
             account_name, account_number, parent_account, root_type,
             is_group, company, account_currency, account_type, lft, rgt)
            VALUES (%s, NOW(), NOW(), 'Administrator', 'Administrator', 0,
                    %s, '', NULL, %s, 1, %s, 'PEN', '', 0, 0)
        """, (name, display_name, root_type, COMPANY))
        frappe.db.commit()
        print(f"  [ROOT] {name}")
    return name

def delete_if_empty(name):
    if not frappe.db.exists('Account', name):
        return
    children = frappe.db.sql("SELECT COUNT(*) FROM tabAccount WHERE parent_account=%s", name)[0][0]
    gl = frappe.db.sql("SELECT COUNT(*) FROM `tabGL Entry` WHERE account=%s", name)[0][0]
    if children == 0 and gl == 0:
        frappe.db.sql("DELETE FROM tabAccount WHERE name=%s", name)
        frappe.db.commit()
        print(f"  [DEL] {name}")

# PASO 0: Asegurar raíces
ROOT_ASSET     = ensure_root('Aplicación de Fondos (Activos)', 'Asset')
ROOT_LIABILITY = ensure_root('Fuente de los fondos (Pasivo)',  'Liability')
ROOT_EQUITY    = ensure_root('Patrimonio',                      'Equity')
ROOT_EXPENSE   = ensure_root('Gastos',                          'Expense')
ROOT_INCOME    = ensure_root('Ingresos',                        'Income')

# PASO 1: Crear cuentas específicas PCGE 2020 para ERPNext v16
sql_insert('65',    'OTROS GASTOS DE GESTIÓN',        ROOT_EXPENSE, 'Expense', 1)
sql_insert('656',   'ENAJENACIÓN DE ACTIVOS',          f'65 - OTROS GASTOS DE GESTIÓN - {ABBR}', 'Expense', 1)
sql_insert('6561',  'ACTIVOS INMOVILIZADOS',           f'656 - ENAJENACIÓN DE ACTIVOS - {ABBR}', 'Expense', 1)
sql_insert('65611', 'COSTO NETO DE ENAJENACIÓN',       f'6561 - ACTIVOS INMOVILIZADOS - {ABBR}', 'Expense', 0)
sql_insert('659',   'OTROS GASTOS DE GESTIÓN',         f'65 - OTROS GASTOS DE GESTIÓN - {ABBR}', 'Expense', 1)
sql_insert('6591',  'GASTOS DE REDONDEO',              f'659 - OTROS GASTOS DE GESTIÓN - {ABBR}', 'Expense', 0, 'Round Off')
sql_insert('6592',  'DESAJUSTE',                       f'659 - OTROS GASTOS DE GESTIÓN - {ABBR}', 'Expense', 0)
sql_insert('6593',  'GASTOS EN VALORACIÓN DE ACTIVOS', f'659 - OTROS GASTOS DE GESTIÓN - {ABBR}', 'Expense', 0, 'Expenses Included In Asset Valuation')

sql_insert('609',   'GASTOS VINCULADOS CON COMPRAS',   ROOT_EXPENSE, 'Expense', 1)
sql_insert('6091',  'FLETES',                          f'609 - GASTOS VINCULADOS CON COMPRAS - {ABBR}', 'Expense', 1)
sql_insert('60911', 'MERCADERÍA MANUFACTURADA',        f'6091 - FLETES - {ABBR}', 'Expense', 0, 'Expenses Included In Valuation')

sql_insert('339',   'OBRAS EN CURSO',                  ROOT_ASSET, 'Asset', 1)
sql_insert('3392',  'OBRAS EN CURSO - PPE',            f'339 - OBRAS EN CURSO - {ABBR}', 'Asset', 1)
sql_insert('33921', 'CONSTRUCCIONES EN CURSO',         f'3392 - OBRAS EN CURSO - PPE - {ABBR}', 'Asset', 0, 'Capital Work in Progress')

sql_insert('395',   'DEPRECIACIÓN ACUMULADA',          ROOT_ASSET, 'Asset', 1)
sql_insert('3952',  'DEPRECIACIÓN ACUMULADA - PPE',    f'395 - DEPRECIACIÓN ACUMULADA - {ABBR}', 'Asset', 1)
sql_insert('39525', 'EQUIPO DE CÓMPUTO',               f'3952 - DEPRECIACIÓN ACUMULADA - PPE - {ABBR}', 'Asset', 0, 'Accumulated Depreciation')

sql_insert('684',   'DEPRECIACIÓN - GASTO',            ROOT_EXPENSE, 'Expense', 1)
sql_insert('6841',  'DEPRECIACIÓN - GASTO - PPE',      f'684 - DEPRECIACIÓN - GASTO - {ABBR}', 'Expense', 1)
sql_insert('68415', 'EQUIPO DE CÓMPUTO',               f'6841 - DEPRECIACIÓN - GASTO - PPE - {ABBR}', 'Expense', 0, 'Depreciation')

sql_insert('4211',  'FACTURAS NO EMITIDAS',            ROOT_LIABILITY, 'Liability', 1)
sql_insert('42113', 'INVENTARIO RECIBIDO NO FACTURADO', f'4211 - FACTURAS NO EMITIDAS - {ABBR}', 'Liability', 0, 'Stock Received But Not Billed')
sql_insert('42114', 'ACTIVO RECIBIDO NO FACTURADO',     f'4211 - FACTURAS NO EMITIDAS - {ABBR}', 'Liability', 0, 'Asset Received But Not Billed')

sql_insert('5913',  'SALDO DE APERTURA',               f'591 - UTILIDADES NO DISTRIBUIDAS - {ABBR}', 'Equity', 1)
sql_insert('59131', 'SALDO DE APERTURA',               f'5913 - SALDO DE APERTURA - {ABBR}', 'Equity', 0, 'Temporary')

# PASO 2: Convertir grupos
prep = [
    (f'14121 - ADELANTO DE REMUNERACIONES - {ABBR}', 'Receivable'),
    (f'63111 - DE CARGA - {ABBR}',                   'Chargeable'),
    (f'20111 - MERCADERÍAS MANUFACTURADAS - {ABBR}', 'Stock'),
    (f'33611 - EQUIPO DE CÓMPUTO - {ABBR}',          'Fixed Asset'),
    (f'61111 - MERCADERÍAS MANUFACTURADAS - {ABBR}', 'Stock Adjustment'),
]
for name, acct_type in prep:
    frappe.db.sql("UPDATE `tabAccount` SET is_group = 0, account_type = %s WHERE name = %s AND is_group = 1", (acct_type, name))
frappe.db.commit()

# PASO 3: Merges
merges = [
    (f'Efectivo - {ABBR}',                                            f'10111 - CAJA MN - {ABBR}'),
    (f'Deudores - {ABBR}',                                            f'12121 - FACTURAS POR COBRAR MN - {ABBR}'),
    (f'Avances de Empleado - {ABBR}',                                 f'14121 - ADELANTO DE REMUNERACIONES - {ABBR}'),
    (f'Stock en mano - {ABBR}',                                       f'20111 - MERCADERÍAS MANUFACTURADAS - {ABBR}'),
    (f'Equipos de oficina - {ABBR}',                                  f'33611 - EQUIPO DE CÓMPUTO - {ABBR}'),
    (f'Cuenta CWIP - {ABBR}',                                         f'33921 - CONSTRUCCIONES EN CURSO - {ABBR}'),
    (f'Acreedores - {ABBR}',                                          f'42121 - CUENTAS POR PAGAR MN - {ABBR}'),
    (f'Inventario Recibido pero no facturados - {ABBR}',              f'42113 - INVENTARIO RECIBIDO NO FACTURADO - {ABBR}'),
    (f'Activo recibido pero no facturado - {ABBR}',                   f'42114 - ACTIVO RECIBIDO NO FACTURADO - {ABBR}'),
    (f'Nómina por Pagar - {ABBR}',                                    f'41111 - SUELDOS Y SALARIOS POR PAGAR - {ABBR}'),
    (f'Ajuste de existencias - {ABBR}',                               f'61111 - MERCADERÍAS MANUFACTURADAS - {ABBR}'),
    (f'Costo de las Ventas - {ABBR}',                                 f'69111 - MERCADERÍAS MANUFACTURADAS MN - {ABBR}'),
    (f'Venta - {ABBR}',                                               f'70111 - MERCADERÍAS MANUFACTURADAS MN - {ABBR}'),
    (f'Gastos de Comercialización - {ABBR}',                          f'63111 - DE CARGA - {ABBR}'),
    (f'Gastos dentro de la valoración - {ABBR}',                      f'60911 - MERCADERÍA MANUFACTURADA - {ABBR}'),
    (f'Gastos incluidos en la valoración de activos - {ABBR}',        f'6593 - GASTOS EN VALORACIÓN DE ACTIVOS - {ABBR}'),
    (f'Redondear - {ABBR}',                                           f'6591 - GASTOS DE REDONDEO - {ABBR}'),
    (f'Desajuste - {ABBR}',                                           f'6592 - DESAJUSTE - {ABBR}'),
    (f'Apertura temporal - {ABBR}',                                   f'59131 - SALDO DE APERTURA - {ABBR}'),
]
for source, target in merges:
    if frappe.db.exists('Account', source):
        frappe.rename_doc('Account', source, target, merge=True, force=True)
frappe.db.commit()

# PASO 4: Defaults
company_defaults = {
    'default_cash_account':                f'10111 - CAJA MN - {ABBR}',
    'default_receivable_account':          f'12121 - FACTURAS POR COBRAR MN - {ABBR}',
    'default_payable_account':             f'42121 - CUENTAS POR PAGAR MN - {ABBR}',
    'default_payroll_payable_account':     f'41111 - SUELDOS Y SALARIOS POR PAGAR - {ABBR}',
    'default_income_account':              f'70111 - MERCADERÍAS MANUFACTURADAS MN - {ABBR}',
    'default_expense_account':             f'69111 - MERCADERÍAS MANUFACTURADAS MN - {ABBR}',
    'round_off_account':                   f'6591 - GASTOS DE REDONDEO - {ABBR}',
    'write_off_account':                   f'6592 - DESAJUSTE - {ABBR}',
    'capital_work_in_progress_account':    f'33921 - CONSTRUCCIONES EN CURSO - {ABBR}',
}
for field, account in company_defaults.items():
    if frappe.db.exists('Account', account):
        frappe.db.set_value('Company', COMPANY, field, account)
frappe.db.commit()

# PASO 5: Eliminar vacíos
to_delete = [
    f'Ingresos indirectos - {ABBR}', f'Ingreso directo - {ABBR}', f'Egresos indirectos - {ABBR}',
    f'Inventario de Gastos - {ABBR}', f'Gastos directos - {ABBR}', f'Inventario de Pasivos - {ABBR}',
    f'Cuentas por Pagar - {ABBR}', f'Derechos e Impuestos - {ABBR}', f'Préstamos (Pasivos) - {ABBR}',
    f'Pasivo Corriente - {ABBR}', f'Activos fijos - {ABBR}', f'Cuentas temporales - {ABBR}',
    f'Activo Corriente - {ABBR}', f'Dinero Ganado - {ABBR}', f'Valores y Depósitos - {ABBR}'
]
for name in to_delete:
    delete_if_empty(name)

from frappe.utils.nestedset import rebuild_tree
rebuild_tree('Account', 'parent_account')
frappe.db.commit()

print("¡Proceso completado exitosamente!")
frappe.destroy()

9. Verificación final

  • Crear Journal Entry de apertura con 59131 - SALDO DE APERTURA.
  • Verificar tipos de cuenta críticos en la BD:
SELECT account_type, name FROM tabAccount
WHERE company = 'Erick Puente S.A.C.'
  AND account_type IN (
    'Round Off', 'Temporary', 'Expenses Included In Valuation',
    'Expenses Included In Asset Valuation', 'Capital Work in Progress',
    'Stock Received But Not Billed', 'Asset Received But Not Billed',
    'Accumulated Depreciation', 'Depreciation'
  )
ORDER BY account_type;