worker-automate-hub 0.5.20__tar.gz → 0.5.22__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/PKG-INFO +1 -1
  2. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/pyproject.toml +1 -1
  3. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/tasks/jobs/entrada_de_notas_15.py +34 -35
  4. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/tasks/jobs/entrada_de_notas_16.py +12 -4
  5. worker_automate_hub-0.5.22/worker_automate_hub/tasks/jobs/login_emsys_versao_especifica.py +142 -0
  6. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/tasks/task_definitions.py +2 -0
  7. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/utils/utils_nfe_entrada.py +32 -3
  8. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/README.md +0 -0
  9. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/__init__.py +0 -0
  10. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/api/__init__.py +0 -0
  11. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/api/ahead_service.py +0 -0
  12. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/api/client.py +0 -0
  13. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/api/helpers/__init__.py +0 -0
  14. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/api/helpers/api_helpers.py +0 -0
  15. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/api/rdp_service.py +0 -0
  16. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/api/rpa_fila_service.py +0 -0
  17. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/api/rpa_historico_service.py +0 -0
  18. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/api/webhook_service.py +0 -0
  19. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/cli.py +0 -0
  20. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/config/__init__.py +0 -0
  21. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/config/settings.py +0 -0
  22. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/config.py +0 -0
  23. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/core/so_manipulation.py +0 -0
  24. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/decorators/__init__.py +0 -0
  25. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/decorators/deprecation.py +0 -0
  26. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/decorators/rate_limit.py +0 -0
  27. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/decorators/repeat.py +0 -0
  28. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/decorators/retry.py +0 -0
  29. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/decorators/singleton.py +0 -0
  30. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/decorators/timeit.py +0 -0
  31. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/models/__init__.py +0 -0
  32. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/models/dao/__init__.py +0 -0
  33. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/models/dao/rpa_configuracao.py +0 -0
  34. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/models/dao/rpa_fila.py +0 -0
  35. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/models/dao/rpa_historico.py +0 -0
  36. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/models/dao/rpa_processo.py +0 -0
  37. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/models/dto/__init__.py +0 -0
  38. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/models/dto/rpa_historico_request_dto.py +0 -0
  39. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/models/dto/rpa_processo_entrada_dto.py +0 -0
  40. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/models/dto/rpa_processo_rdp_dto.py +0 -0
  41. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/models/dto/rpa_sistema_dto.py +0 -0
  42. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/tasks/__init__.py +0 -0
  43. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/tasks/jobs/__init__.py +0 -0
  44. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/tasks/jobs/coleta_dje_process.py +0 -0
  45. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/tasks/jobs/conexao_rdp.py +0 -0
  46. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/tasks/jobs/descartes.py +0 -0
  47. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/tasks/jobs/ecac_estadual_go.py +0 -0
  48. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/tasks/jobs/ecac_estadual_main.py +0 -0
  49. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/tasks/jobs/ecac_estadual_mt.py +0 -0
  50. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/tasks/jobs/ecac_estadual_sc.py +0 -0
  51. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/tasks/jobs/ecac_estadual_sp.py +0 -0
  52. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/tasks/jobs/ecac_federal.py +0 -0
  53. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/tasks/jobs/entrada_de_notas_207.py +0 -0
  54. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/tasks/jobs/entrada_de_notas_32.py +0 -0
  55. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/tasks/jobs/entrada_de_notas_33.py +0 -0
  56. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/tasks/jobs/entrada_de_notas_34.py +0 -0
  57. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/tasks/jobs/entrada_de_notas_36.py +0 -0
  58. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/tasks/jobs/entrada_de_notas_39.py +0 -0
  59. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/tasks/jobs/entrada_de_notas_500.py +0 -0
  60. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/tasks/jobs/entrada_de_notas_505.py +0 -0
  61. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/tasks/jobs/entrada_de_notas_7139.py +0 -0
  62. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/tasks/jobs/entrada_de_notas_9.py +0 -0
  63. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/tasks/jobs/exemplo_processo.py +0 -0
  64. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/tasks/jobs/fechar_conexao_rdp.py +0 -0
  65. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/tasks/jobs/fidc_gerar_nosso_numero.py +0 -0
  66. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/tasks/jobs/fidc_remessa_cobranca_cnab240.py +0 -0
  67. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/tasks/jobs/login_emsys.py +0 -0
  68. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/tasks/jobs/playground.py +0 -0
  69. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/tasks/jobs/sped_fiscal.py +0 -0
  70. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/tasks/jobs/transferencias.py +0 -0
  71. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/tasks/task_executor.py +0 -0
  72. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/utils/__init__.py +0 -0
  73. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/utils/env.py +0 -0
  74. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/utils/get_creds_gworkspace.py +0 -0
  75. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/utils/logger.py +0 -0
  76. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/utils/toast.py +0 -0
  77. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/utils/updater.py +0 -0
  78. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/utils/util.py +0 -0
  79. {worker_automate_hub-0.5.20 → worker_automate_hub-0.5.22}/worker_automate_hub/worker.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: worker-automate-hub
3
- Version: 0.5.20
3
+ Version: 0.5.22
4
4
  Summary: Worker Automate HUB é uma aplicação para automatizar rotinas de RPA nos ambientes Argenta.
5
5
  Author: Joel Paim
6
6
  Requires-Python: >=3.12,<4.0
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "worker-automate-hub"
3
- version = "0.5.20"
3
+ version = "0.5.22"
4
4
  description = "Worker Automate HUB é uma aplicação para automatizar rotinas de RPA nos ambientes Argenta."
5
5
  authors = ["Joel Paim"]
6
6
  readme = "README.md"
@@ -329,47 +329,46 @@ async def entrada_de_notas_15(task: RpaProcessoEntradaDTO) -> RpaRetornoProcesso
329
329
  except:
330
330
  console.print("Erros não foram encontrados após incluir o registro")
331
331
 
332
- # Verifica se a info 'Nota fiscal incluida' está na tela
333
- await worker_sleep(6)
334
- try:
335
- app = Application().connect(class_name="TFrmNotaFiscalEntrada")
336
- main_window = app["Information"]
337
-
338
- main_window.set_focus()
339
-
340
- console.print(f"Tentando clicar no Botão OK...\n")
341
- btn_ok = main_window.child_window(class_name="TButton")
342
-
343
- if btn_ok.exists():
344
- btn_ok.click()
345
- else:
346
- console.print(f" botão OK Não enontrado")
347
- except Exception as e:
348
- try:
349
- await worker_sleep(5)
350
- await emsys.verify_warning_and_error("Aviso", "OK")
351
- alterar_nop = await emsys.alterar_nop(nota["cfop"])
352
-
353
- if alterar_nop:
354
- return alterar_nop
355
- except Exception as error:
356
- observacao = f"Erro Processo Entrada de Notas: {str(error)}"
357
- logger.error(observacao)
358
- console.print(observacao, style="bold red")
359
- return RpaRetornoProcessoDTO(
360
- sucesso=False,
361
- retorno=observacao,
362
- status=RpaHistoricoStatusEnum.Falha,
363
- tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
364
- )
365
-
366
332
  max_attempts = 60
367
333
  i = 0
368
334
 
369
335
  while i < max_attempts:
370
336
  information_pop_up = await is_window_open("Information")
371
337
  if information_pop_up["IsOpened"] == True:
372
- break
338
+ # Verifica se a info 'Nota fiscal incluida' está na tela
339
+ try:
340
+ app = Application().connect(class_name="TFrmNotaFiscalEntrada")
341
+ main_window = app["Information"]
342
+
343
+ main_window.set_focus()
344
+
345
+ console.print(f"Tentando clicar no Botão OK...\n")
346
+ btn_ok = main_window.child_window(class_name="TButton")
347
+
348
+ if btn_ok.exists():
349
+ btn_ok.click()
350
+ break
351
+ else:
352
+ console.print(f" botão OK Não enontrado")
353
+ except Exception as e:
354
+ try:
355
+ await worker_sleep(5)
356
+ await emsys.verify_warning_and_error("Warning", "OK")
357
+ await emsys.verify_warning_and_error("Aviso", "OK")
358
+ alterar_nop = await emsys.alterar_nop(nota["cfop"], nota["nfe"])
359
+
360
+ if alterar_nop:
361
+ return alterar_nop
362
+ except Exception as error:
363
+ observacao = f"Erro Processo Entrada de Notas: {str(error)}"
364
+ logger.error(observacao)
365
+ console.print(observacao, style="bold red")
366
+ return RpaRetornoProcessoDTO(
367
+ sucesso=False,
368
+ retorno=observacao,
369
+ status=RpaHistoricoStatusEnum.Falha,
370
+ tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
371
+ )
373
372
  else:
374
373
  console.print(f"Aguardando confirmação de nota incluida...\n")
375
374
  await worker_sleep(5)
@@ -391,14 +391,21 @@ async def entrada_de_notas_16(task: RpaProcessoEntradaDTO) -> RpaRetornoProcesso
391
391
 
392
392
  except Exception as e:
393
393
  try:
394
- await worker_sleep(5)
395
- await emsys.verify_warning_and_error("Aviso", "OK")
396
- alterar_nop_result = await emsys.alterar_nop(nota.get("cfop"))
397
-
394
+ alterar_nop_result = await emsys.alterar_nop(nota.get("cfop"), nota.get("nfe"))
398
395
  if alterar_nop_result:
399
396
  await worker_sleep(5)
400
397
  resultado = await emsys.verify_max_variation()
401
398
  return alterar_nop_result
399
+ except ValueError as ve:
400
+ observacao = f"Erro Processo Entrada de Notas: {str(ve)}"
401
+ logger.error(observacao)
402
+ console.print(observacao, style="bold red")
403
+ return RpaRetornoProcessoDTO(
404
+ sucesso=False,
405
+ retorno=observacao,
406
+ status=RpaHistoricoStatusEnum.Falha,
407
+ tags=[RpaTagDTO(descricao=RpaTagEnum.Negocio)]
408
+ )
402
409
  except Exception as error:
403
410
  observacao = f"Erro Processo Entrada de Notas: {str(error)}"
404
411
  logger.error(observacao)
@@ -409,6 +416,7 @@ async def entrada_de_notas_16(task: RpaProcessoEntradaDTO) -> RpaRetornoProcesso
409
416
  status=RpaHistoricoStatusEnum.Falha,
410
417
  tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
411
418
  )
419
+
412
420
  try:
413
421
 
414
422
  await emsys.verify_warning_and_error("Warning", "OK")
@@ -0,0 +1,142 @@
1
+ import asyncio
2
+ import warnings
3
+
4
+ import pyautogui
5
+ from rich.console import Console
6
+
7
+ from worker_automate_hub.models.dto.rpa_historico_request_dto import RpaHistoricoStatusEnum, RpaRetornoProcessoDTO
8
+ from worker_automate_hub.models.dto.rpa_processo_entrada_dto import RpaProcessoEntradaDTO
9
+ from worker_automate_hub.utils.logger import logger
10
+ from worker_automate_hub.utils.util import (
11
+ find_element_center,
12
+ find_target_position,
13
+ kill_process,
14
+ take_screenshot,
15
+ type_text_into_field,
16
+ wait_element_ready_win,
17
+ )
18
+
19
+ console = Console()
20
+
21
+
22
+ async def login_emsys_versao_especifica(task: RpaProcessoEntradaDTO) -> RpaRetornoProcessoDTO:
23
+ from pywinauto.application import Application
24
+
25
+ warnings.filterwarnings(
26
+ "ignore",
27
+ category=UserWarning,
28
+ message="32-bit application should be automated using 32-bit Python",
29
+ )
30
+
31
+ try:
32
+ # Mata todos processos do emsys antes de abrir uma nova instancia
33
+ await kill_process("EMSys")
34
+
35
+ # Abre um novo emsys
36
+ app = Application().start("C:\\Rezende\\EMSys3\\EMSys3.977.exe")
37
+ console.print("\nEMSys iniciando...", style="bold green")
38
+
39
+ await asyncio.sleep(10)
40
+ # Testa se existe alguma mensagem no Emsys
41
+ window_message_login_emsys = await find_element_center(
42
+ "assets/emsys/window_message_login_emsys.png", (560, 487, 1121, 746), 10
43
+ )
44
+
45
+ # Obtém a resolução da tela
46
+ screen_width, screen_height = pyautogui.size()
47
+
48
+ pyautogui.click(screen_width / 2, screen_height / 2)
49
+
50
+ # Clica no "Não mostrar novamente" se existir
51
+ if window_message_login_emsys:
52
+ pyautogui.click(window_message_login_emsys.x, window_message_login_emsys.y)
53
+ pyautogui.click(
54
+ window_message_login_emsys.x + 383, window_message_login_emsys.y + 29
55
+ )
56
+ console.print("Mensagem de login encontrada e fechada.", style="bold green")
57
+
58
+ # Ve se o Emsys esta aberto no login
59
+ image_emsys_login = await find_element_center(
60
+ "assets/emsys/logo_emsys_login.png", (800, 200, 1400, 700), 600
61
+ )
62
+ # config_robot = await get_config_by_name("Login EmSys")
63
+ if image_emsys_login:
64
+ # await asyncio.sleep(10)
65
+ # type_text_into_field(
66
+ # config_robot["EmSys DB"], app["Login"]["ComboBox"], True, "50"
67
+ # )
68
+ # pyautogui.press("enter")
69
+ # await asyncio.sleep(2)
70
+
71
+ if await wait_element_ready_win(app["Login"]["Edit2"], 30):
72
+ disconect_database = await find_element_center(
73
+ "assets/emsys/disconect_database.png", (1123, 452, 1400, 578), 300
74
+ )
75
+
76
+ if disconect_database:
77
+ # Realiza login no Emsys
78
+ type_text_into_field(
79
+ task.configEntrada["user"], app["Login"]["Edit2"], True, "50"
80
+ )
81
+ pyautogui.press("tab")
82
+ type_text_into_field(
83
+ task.configEntrada["pass"],
84
+ app["Login"]["Edit1"],
85
+ True,
86
+ "50",
87
+ )
88
+ pyautogui.press("enter")
89
+
90
+ # Seleciona a filial do emsys
91
+ selecao_filial = await find_element_center(
92
+ "assets/emsys/selecao_filial.png", (480, 590, 820, 740), 15
93
+ )
94
+
95
+ if selecao_filial == None:
96
+ screenshot_path = take_screenshot()
97
+ selecao_filial = find_target_position(
98
+ screenshot_path, "Grupo", 0, -50, 15
99
+ )
100
+
101
+ if selecao_filial == None:
102
+ selecao_filial = (804, 640)
103
+
104
+ pyautogui.write(task.configEntrada["filial"])
105
+ pyautogui.press("enter")
106
+
107
+ else:
108
+ type_text_into_field(
109
+ task.configEntrada["filial"],
110
+ app["Seleção de Empresas"]["Edit"],
111
+ True,
112
+ "50",
113
+ )
114
+ pyautogui.press("enter")
115
+
116
+ button_logout = await find_element_center(
117
+ "assets/emsys/button_logout.png", (0, 0, 130, 150), 75
118
+ )
119
+
120
+ if button_logout:
121
+ console.print(
122
+ "Login realizado com sucesso.", style="bold green"
123
+ )
124
+ return RpaRetornoProcessoDTO(
125
+ sucesso=True,
126
+ retorno="Processo de login no EMSys executado com sucesso.",
127
+ status=RpaHistoricoStatusEnum.Sucesso,
128
+ )
129
+
130
+ else:
131
+ logger.info("login_emsys_win -> wait_element_ready_win [1]")
132
+ console.print("Elemento de login não está pronto.", style="bold red")
133
+
134
+ except Exception as ex:
135
+ logger.error("Erro em login_emsys: " + str(ex))
136
+ console.print(f"Erro em login_emsys: {str(ex)}", style="bold red")
137
+ return RpaRetornoProcessoDTO(
138
+ sucesso=False,
139
+ retorno=f"Erro em login_emsys: {str(ex)}",
140
+ status=RpaHistoricoStatusEnum.Falha,
141
+ )
142
+
@@ -52,6 +52,7 @@ from worker_automate_hub.tasks.jobs.entrada_de_notas_7139 import (
52
52
  )
53
53
  from worker_automate_hub.tasks.jobs.exemplo_processo import exemplo_processo
54
54
  from worker_automate_hub.tasks.jobs.login_emsys import login_emsys
55
+ from worker_automate_hub.tasks.jobs.login_emsys_versao_especifica import login_emsys_versao_especifica
55
56
  from worker_automate_hub.tasks.jobs.playground import playground
56
57
  from worker_automate_hub.tasks.jobs.transferencias import transferencias
57
58
  from worker_automate_hub.tasks.jobs.sped_fiscal import sped_fiscal
@@ -59,6 +60,7 @@ from worker_automate_hub.tasks.jobs.sped_fiscal import sped_fiscal
59
60
  task_definitions = {
60
61
  "5b295021-8df7-40a1-a45e-fe7109ae3902": exemplo_processo,
61
62
  "a0788650-de48-454f-acbf-3537ead2d8ed": login_emsys,
63
+ "7d319f61-5e12-425c-86ed-678f0d9e14bd": login_emsys_versao_especifica,
62
64
  "abcfa1ba-d580-465a-aefb-c15ac4514407": descartes,
63
65
  "2c8ee738-7447-4517-aee7-ce2c9d25cea9": transferencias,
64
66
  "855f9e0f-e972-4f52-bc1a-60d1fc244e79": conexao_rdp,
@@ -14,6 +14,7 @@ from pywinauto_recorder.player import set_combobox
14
14
  from rich.console import Console
15
15
  from datetime import datetime, timedelta
16
16
 
17
+ from worker_automate_hub.api.client import get_status_nf_emsys
17
18
  from worker_automate_hub.models.dao.rpa_configuracao import RpaConfiguracao
18
19
  from worker_automate_hub.models.dto.rpa_historico_request_dto import (
19
20
  RpaHistoricoStatusEnum,
@@ -28,6 +29,8 @@ from worker_automate_hub.utils.util import worker_sleep, is_window_open_by_class
28
29
  pyautogui.PAUSE = 0.5
29
30
  import pyperclip
30
31
 
32
+ ASSETS_PATH = "assets"
33
+
31
34
  console = Console()
32
35
 
33
36
 
@@ -674,7 +677,7 @@ class EMSys:
674
677
  f"Erro ao deletar o arquivo {xml_filename}: {str(e)}"
675
678
  ) from e
676
679
 
677
- async def alterar_nop(self, cfop: str) -> RpaRetornoProcessoDTO | None:
680
+ async def alterar_nop(self, cfop: str, chave_acesso=None) -> RpaRetornoProcessoDTO | None:
678
681
  await self.click_principal()
679
682
  console.print("Alterando a NOP...\n")
680
683
  pyautogui.click(945, 543)
@@ -700,6 +703,15 @@ class EMSys:
700
703
  pyautogui.hotkey("enter")
701
704
  await worker_sleep(6)
702
705
  await self.incluir_registro()
706
+ await worker_sleep(15)
707
+
708
+ if chave_acesso is not None:
709
+ console.print("\nVerifica se a nota ja foi lançada...")
710
+ nf_chave_acesso = int(chave_acesso)
711
+ status_nf_emsys = await get_status_nf_emsys(nf_chave_acesso)
712
+ if status_nf_emsys.get("status") != "Lançada":
713
+ raise ValueError("A nota não possui itens com o mesmo CFOP de capa. Necessário que ao menos um item possua este CFOP")
714
+
703
715
  else:
704
716
  pyautogui.hotkey("esc")
705
717
  observacao = f"Nota bonificada do tipo ({cfop}), está retornando diferença de itens sem o mesmo CFOP de capa. Por favor verifique a nota."
@@ -709,11 +721,28 @@ class EMSys:
709
721
  status=RpaHistoricoStatusEnum.Falha,
710
722
  tags=[RpaTagDTO(descricao=RpaTagEnum.Negocio)]
711
723
  )
712
- except:
713
- console.print("Falha ao alterar o NOP")
724
+ except ValueError as e:
725
+ console.print(f"Erro de validação ao alterar o NOP: {e}", style="bold red")
726
+ raise
727
+ except Exception as e:
728
+ console.print(f"Erro inesperado ao alterar o NOP: {e}", style="bold red")
729
+ raise
714
730
 
715
731
  return RpaRetornoProcessoDTO(
716
732
  sucesso=True,
717
733
  retorno="Nota lançada com sucesso!",
718
734
  status=RpaHistoricoStatusEnum.Sucesso,
719
735
  )
736
+
737
+ async def verify_nf_incuded(self) -> bool:
738
+ try:
739
+ nota_incluida = pyautogui.locateOnScreen(
740
+ ASSETS_PATH + "\\entrada_notas\\nota_fiscal_incluida.png", confidence=0.7
741
+ )
742
+ if nota_incluida:
743
+ return True
744
+ else:
745
+ return False
746
+ except Exception as e:
747
+ console.print(f"Error: {e}")
748
+ return False