The General Ledger chart of accounts is mastered exclusively in the Hechizo hub database.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/FCS-Consultores/hechizo-SAP-intercompany/llms.txt
Use this file to discover all available pages before exploring further.
ProcesarCuentasdesdeHechizoV2 is responsible for propagating those account definitions to all nine branch companies, ensuring that every GL account referenced by an automatically created document — purchase orders, AP invoices, AP credit notes, and incoming payments — already exists in the target company before any posting is attempted. The method runs in two sequential phases per execution cycle: a Crear pass that inserts accounts missing from the branch, followed by an Actualizar pass that patches the attributes of accounts that are already present.
GL account synchronization runs after all document processing steps (purchase requests, sales orders, purchase orders, invoices, and credit notes), but before incoming payments. This sequencing is intentional: accounts must exist before they are referenced in transactions, and the document processing steps themselves may trigger SAP B1 to auto-create posting lines that reference Hechizo-mastered accounts.
Method signature
Parameters
| Parameter | Type | Description |
|---|---|---|
bdDestino | string | The company key string identifying the target branch (e.g., "hogar", "sur", "omdo"). Resolved internally to the full HANA schema name via ConsultarBD. |
tokenDestino | string | Basic Auth token for the target branch’s SAP B1 Service Layer instance. Passed directly in the Authorization header of each Service Layer request. |
proceso | ProcesoCuenta | Enum value controlling the operation mode. ProcesoCuenta.Crear inserts missing accounts; ProcesoCuenta.Actualizar updates existing ones. |
ProcesoCuenta enum
Inter_Hechiz.Data.Intercompany and is therefore referenced in call sites as Data.Intercompany.ProcesoCuenta.Crear and Data.Intercompany.ProcesoCuenta.Actualizar.
Two-phase call pattern
Each execution cycle invokesProcesarCuentasdesdeHechizoV2 eighteen times — nine branches × two phases. Both phases must complete for the account definitions in all branches to be consistent with Hechizo.
Internal behavior
Whenproceso == ProcesoCuenta.Crear, the method:
- Queries Hechizo’s chart of accounts via HANA for all active GL accounts.
- Compares each account code against the destination branch’s
OACTtable. - For any account that does not yet exist in the branch, constructs a JSON object containing the account code (
AccCode), account name, account type (ActType, mapped to the Service Layer enum value), and relevant control flags. - Posts the object to the branch’s
ChartOfAccountsService Layer endpoint.
proceso == ProcesoCuenta.Actualizar, the method:
- Retrieves the same set of accounts from Hechizo.
- For each account that already exists in the branch (based on
AccCode), sends a PATCH request toChartOfAccounts('{AccCode}')with updated field values. - Errors for individual accounts are logged to the application log with the account code, destination database, and Service Layer error message, but processing continues for remaining accounts.
Operational guidelines
Run Crear before Actualizar
The two phases are designed to be executed in order within the same cycle. Running Actualizar on an account that does not yet exist in the branch will produce a Service Layer 404 error and the account will remain unsynchronized until the next Crear pass.
Validate after first deployment
After running the chart of accounts sync for the first time on a new branch, open the SAP B1 Chart of Accounts screen in that branch and verify that account types, control flags, and hierarchical positions are correct before allowing financial transactions to post.
Account type mapping
The
ActType field from Hechizo’s HANA query is mapped to the Service Layer enum expected by the ChartOfAccounts endpoint. If Hechizo introduces a new account type not covered by the current mapping, the method will log an error. Review Intercompany.cs around line 5689 to add new mappings.Error isolation
Failures on individual accounts do not abort the entire sync pass. Each account is processed in its own try/catch block and errors are written to the application log (
RegistroLog). Review the log after each cycle to identify accounts that consistently fail.