diff --git a/src/controllers/processStatusController.js b/src/controllers/processStatusController.js index 5ad2399..7141b63 100644 --- a/src/controllers/processStatusController.js +++ b/src/controllers/processStatusController.js @@ -41,7 +41,7 @@ const processStatusAndClosureController = async () => { const snIsFinalState = snCurrentStatus === 'Resolvido' || snCurrentStatus === 'Encerrado' || snCurrentStatus === 'Encerrado - Omitido'; let effectiveSourceLast = ticket.source_last; - if (snIsFinalState) { + if (snIsFinalState && ticket.source_last !== 'GLPI') { effectiveSourceLast = 'SNOW'; } @@ -87,10 +87,10 @@ const processStatusAndClosureController = async () => { logInfo(`SN ${ticketSnDetails.ticket_number} foi Resolvido. Enviando nota para GLPI sem fechar o chamado...`); // Regra de negocio: resolucao vinda do SN nao fecha no GLPI. - // Apenas registra uma nota e remove o ticket do monitoramento da integracao. + // Apenas registra uma nota e marca o fluxo como solucionado. const collaboratorName = ticketSnDetails.updated_by || ticketSnDetails.closed_by || null; await addServiceNowClosureNoteToGlpi(ticket, collaboratorName, 'solucionado'); - await TicketSyncModel.updateStatusAndSourceLast(ticket.sn_ticket_id, 'closed', 'closed', 'SNOW'); + await TicketSyncModel.updateStatusAndSourceLast(ticket.sn_ticket_id, 'solved', 'solved', 'SNOW'); } else if (snCurrentStatus === 'Encerrado - Omitido' || snCurrentStatus === 'Encerrado') { // SN foi para 'Closed' logInfo(`SN ${ticketSnDetails.ticket_number} foi Fechado. Enviando nota para GLPI sem fechar o chamado...`);