You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
2.6 KiB

--[[
Desde el menu principal de AFIP se ingresa a la funcionalidad de Generacion de Comprobantes.
{
"uid": "53935f27-5cf0-4281-9a29-a68f100ee981",
"execution_status": "Borrador",
"tipo_comprobante": "factura c",
"fecha_comprobante": "13/11/2025",
"tipo_concepto": "servicios",
"servicio_fecha_desde": "01/10/2025",
"servicio_fecha_hasta": "01/10/2025",
"servicio_fecha_vencimiento_pago": "13/11/2025",
"referencia": "",
"tipo_iva_receptor": "consumidor final",
"cuit_receptor": "",
"forma_pago": "contado",
"monto_unitario": "10000",
"cantidad": "1",
"descripcion": "Clase de apoyo"
}
--]]
local json = require("json")
----------------------------------------------------------------------
-- Helpers
----------------------------------------------------------------------
local function logErrorAndExit(message)
log(message)
error(message)
end
----------------------------------------------------------------------
-- Main logic
----------------------------------------------------------------------
local function main()
log("afip_ingresar_generacion_comprobantes: starting")
--------------------------------------------------------------------
-- Decode payload (currently unused but kept for future extensibility)
--------------------------------------------------------------------
local payload, err = json.decode(json_payload or "{}")
if err then
logErrorAndExit("afip_ingresar_generacion_comprobantes: error decoding payload: " .. err)
end
--------------------------------------------------------------------
-- Click on the Generar Comprobantes button
-- This mirrors the Go logic that waits for and clicks the element
-- with id="btn_gen_cmp" using chromedp.
--------------------------------------------------------------------
local btnId = "btn_gen_cmp"
-- Ensure the element is visible first
err = waitVisibleById(btnId)
if err then
logErrorAndExit(
"afip_ingresar_generacion_comprobantes: waitVisibleById failed for btnId= " ..
tostring(btnId) .. ": " .. tostring(err)
)
end
-- Click using id
err = clickElementById(btnId)
if err then
logErrorAndExit(
"afip_ingresar_generacion_comprobantes: clickElementById failed for btnId= " ..
tostring(btnId) .. ": " .. tostring(err)
)
end
log("afip_ingresar_generacion_comprobantes: completed successfully")
end
local ok, err = pcall(main)
if not ok then
-- Let Go see this as a Lua error so it can fall back to legacy
logErrorAndExit("afip_ingresar_generacion_comprobantes failed: " .. tostring(err))
end