Skip to content

HubfiscalLogSageBatch

Place it after the SageX3Soap node (save operation). It stores Sage’s response and the grouped invoice number (VCRNUM) in the batch, and copies that number to every document in the batch. This way, from an order you can see which Sage invoice it belongs to and, from a Sage invoice, which orders make it up.

It is part of the daily Hub Fiscal → Sage X3 posting process, together with HubfiscalAggregateSales.

Key features:

  • Traceability both ways: stores sage_vcrnum and the posting date in the batch and in each document.
  • Idempotent: if the batch is already recorded, it does not overwrite the stored number.
  • Failure handling: if Sage returned an error, the batch is left as failed with the reason, including Sage’s business message.
  • Warning if the number is missing: if Sage answers OK but without VCRNUM, the batch is left sent with a warning so you can complete it by hand.
FieldTypeRequiredDescription
credentials_idcredentialsYesHub Fiscal MySQL/MariaDB credential (sqlQuery type)
batch_idtextNoBatch id. Default {{item.batch_id}}; inside an Iterator over batches you can use {{batch_id}}

The data from the previous step, which must include:

The invoice number is looked up at any level of the response, whether Sage returns JSON or XML.

{
"logged": true,
"batch_id": 102,
"batch_status": "sent",
"sage_vcrnum": "FTC0000123",
"message": "Lote 102 enviado a Sage (FTC0000123)"
}
FieldDescription
loggedtrue if it was written; false if the batch was already recorded or it was a simulation
batch_statussent or failed
sage_vcrnumNumber of the grouped invoice in Sage
warningOnly if Sage answered OK without an invoice number

The message text is in Spanish, as it appears in the product.

In the batch: status, Sage’s response, grouped invoice number, error reason if it failed and sent date. In each document of the batch: Sage’s invoice number and the date it was posted.

Traceability query (example):

-- Which Sage invoice is order 17513 in?
SELECT order_number, fiscal_doc_number, sage_vcrnum, sage_posted_at
FROM documents WHERE order_number = '17513';
  • It records nothing in simulation: if the entry is flagged as simulated, the node ends without writing.
  • When the SageX3Soap node fails, the flow for that entry is cut and this node never runs: the batch stays pending and is resent on the next run of the same day.
  • A batch that does not exist returns a clear error (Lote N no encontrado).