1 changed files with 96 additions and 0 deletions
@ -0,0 +1,96 @@ |
|||
|
|||
-- Sample json payload |
|||
--[[ |
|||
{ |
|||
"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", |
|||
"execution_request": { |
|||
"request_uid": "f976aa76-8d49-4564-8e44-2100819bae77", |
|||
"execution_status": "Fallido", |
|||
"user_uid": "bc31ddeb-b8c7-48e1-b569-20bbd8e7ec12", |
|||
"options": { |
|||
"automatic_confirmation_flag": false |
|||
}, |
|||
"csv_data": "factura c,16/11/2025,servicios,01/10/2025,01/10/2025,16/11/2025,,monotributo,27287630412,contado,10000,1,Clase de apoyo\\n", |
|||
"credentials": { |
|||
"cuit": "20292929092", |
|||
"password": "password", |
|||
"orden_punto_venta": 1, |
|||
"nombre_empresa": "NOMBRE DE EMPRESA" |
|||
} |
|||
} |
|||
} |
|||
--]] |
|||
|
|||
|
|||
---------------------------------------------------------------------- |
|||
-- Helpers |
|||
---------------------------------------------------------------------- |
|||
local function logErrorAndExit(message) |
|||
log(message) |
|||
error(message) |
|||
end |
|||
|
|||
---------------------------------------------------------------------- |
|||
-- Main logic |
|||
---------------------------------------------------------------------- |
|||
local function main() |
|||
log("afip_seleccionar_empresa: starting") |
|||
local json = require("json") |
|||
local payload, err = json.decode(json_payload) |
|||
|
|||
local nombre_empresa = payload["execution_request"]["credentials"]["nombre_empresa"] |
|||
-------------------------------------------------------------------- |
|||
-- 1) Navegar a la página de selección de empresa |
|||
-------------------------------------------------------------------- |
|||
local err = navigate("https://fe.afip.gob.ar/rcel/jsp/index_bis.jsp") |
|||
if err then |
|||
logErrorAndExit("afip_seleccionar_empresa: error navigating to URL: " .. tostring(err)) |
|||
end |
|||
|
|||
-------------------------------------------------------------------- |
|||
-- 2) Esperar 5 segundos para que la página cargue completamente |
|||
-------------------------------------------------------------------- |
|||
waitSecs(5) |
|||
|
|||
-------------------------------------------------------------------- |
|||
-- 3) Esperar a que el input de la empresa esté visible |
|||
-------------------------------------------------------------------- |
|||
local selector = "input[value=\"" .. nombre_empresa .. "\"]" |
|||
|
|||
err = waitVisibleByQuerySelector(selector) |
|||
if err then |
|||
logErrorAndExit("afip_seleccionar_empresa: error waiting for selector '" .. selector .. "': " .. tostring(err)) |
|||
end |
|||
|
|||
-------------------------------------------------------------------- |
|||
-- 4) Clickear el elemento |
|||
-------------------------------------------------------------------- |
|||
err = clickElementByQuerySelector(selector) |
|||
if err then |
|||
logErrorAndExit("afip_seleccionar_empresa: error clicking selector '" .. selector .. "': " .. tostring(err)) |
|||
end |
|||
|
|||
-------------------------------------------------------------------- |
|||
-- Done |
|||
-------------------------------------------------------------------- |
|||
log("afip_seleccionar_empresa: completed successfully") |
|||
end |
|||
|
|||
local ok, err = pcall(main) |
|||
if not ok then |
|||
logErrorAndExit("afip_seleccionar_empresa failed: " .. tostring(err)) |
|||
end |
|||
Loading…
Reference in new issue