worker-automate-hub 0.5.77__py3-none-any.whl → 0.5.78__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -256,540 +256,545 @@ async def devolucao_prazo_a_faturar(task: RpaProcessoEntradaDTO) -> RpaRetornoPr
256
256
  )
257
257
 
258
258
 
259
- #ETAPA 14 A 18
260
- #STEP 2 - EMISSAO DA NOTA
261
- type_text_into_field("Nota Fiscal de Entrada", app["TFrmMenuPrincipal"]["Edit"], True, "50")
262
- pyautogui.press("enter")
263
- await worker_sleep(2)
264
- pyautogui.press("enter")
265
- console.print(f"\nPesquisa: 'Nota Fiscal de Entrada' realizada com sucesso",style="bold green",
266
- )
267
-
268
- # Procura campo documento
269
- console.print("Navegando pela Janela de Nota Fiscal de Entrada...\n")
270
- document_type = await select_documento_type("NFe - NOTA FISCAL ELETRONICA PROPRIA - DANFE SERIE 077")
271
- if document_type.sucesso == True:
272
- console.log(document_type.retorno, style="bold green")
273
- else:
274
- retorno = f"{document_type.retorno} \nEtapas Executadas:\n{steps}"
275
- return RpaRetornoProcessoDTO(
276
- sucesso=False,
277
- retorno=retorno,
278
- status=RpaHistoricoStatusEnum.Falha,
279
- tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
259
+ #ETAPA 14 A 18
260
+ #STEP 2 - EMISSAO DA NOTA
261
+ type_text_into_field("Nota Fiscal de Entrada", app["TFrmMenuPrincipal"]["Edit"], True, "50")
262
+ pyautogui.press("enter")
263
+ await worker_sleep(2)
264
+ pyautogui.press("enter")
265
+ console.print(f"\nPesquisa: 'Nota Fiscal de Entrada' realizada com sucesso",style="bold green",
280
266
  )
281
267
 
282
- await worker_sleep(4)
283
-
284
- app = Application().connect(class_name="TFrmNotaFiscalEntrada", timeout=60)
285
- main_window = app["TFrmNotaFiscalEntrada"]
286
-
287
- main_window.set_focus()
288
- await worker_sleep(3)
289
-
290
- console.print("Controles encontrados na janela 'Nota Fiscal de Entrada, navegando entre eles...\n")
291
- panel_TNotebook = main_window.child_window(class_name="TNotebook", found_index=0)
292
- panel_TPage = panel_TNotebook.child_window(class_name="TPage", found_index=0)
293
- panel_TPageControl = panel_TPage.child_window(class_name="TPageControl", found_index=0)
294
- panel_TTabSheet = panel_TPageControl.child_window(class_name="TTabSheet", found_index=0)
295
-
296
- #SELECIONANDO O TIPO NOTA
297
- console.print("SELECIONANDO O TIPO NOTA...\n")
298
- panel_tipo_nota = panel_TPageControl.child_window(class_name="TDBIGroupBox", found_index=1)
299
- radio_nota_devolucao = panel_tipo_nota.child_window(class_name="TDBIRadioButton", found_index=1)
300
- radio_nota_devolucao.click()
301
- await worker_sleep(1)
302
-
303
- #INSERINDO A ENTRADA E EMISSÃO
304
- console.print("INSERINDO A ENTRADA E EMISSÃO ...\n")
305
- field_entrada = main_window.child_window(class_name="TDBIEditDate", found_index=1)
306
- field_emissao = main_window.child_window(class_name="TDBIEditDate", found_index=2)
307
- field_entrada.set_edit_text(data_hoje)
308
- await worker_sleep(1)
309
- field_emissao.set_edit_text(data_hoje)
310
- await worker_sleep(1)
268
+ # Procura campo documento
269
+ console.print("Navegando pela Janela de Nota Fiscal de Entrada...\n")
270
+ document_type = await select_documento_type("NFe - NOTA FISCAL ELETRONICA PROPRIA - DANFE SERIE 077")
271
+ if document_type.sucesso == True:
272
+ console.log(document_type.retorno, style="bold green")
273
+ else:
274
+ retorno = f"{document_type.retorno} \nEtapas Executadas:\n{steps}"
275
+ return RpaRetornoProcessoDTO(
276
+ sucesso=False,
277
+ retorno=retorno,
278
+ status=RpaHistoricoStatusEnum.Falha,
279
+ tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
280
+ )
311
281
 
312
- #INSERINDO CODIGO DO FORNECEDOR
313
- console.print("INSERINDO CODIGO DO FORNECEDOR ...\n")
314
- field_fornecedor = main_window.child_window(class_name="TDBIEditCode", found_index=0)
315
- field_fornecedor.click()
316
- field_fornecedor.set_edit_text(cod_cliente_incorreto)
317
- pyautogui.press("tab")
282
+ await worker_sleep(4)
318
283
 
319
- #SELECIONAO A NOP
320
- console.print("SELECIONAO A NOP...\n")
321
- select_box_nop_select = main_window.child_window(class_name="TDBIComboBox", found_index=0)
322
- select_box_nop_select.click()
323
- set_combobox("||List", "1662 - DEVOLUÇÃO DE VENDA MERC. ADQ. TERCEIROS- 1.662 DEV COMB C/FI")
324
- await worker_sleep(4)
284
+ app = Application().connect(class_name="TFrmNotaFiscalEntrada", timeout=60)
285
+ main_window = app["TFrmNotaFiscalEntrada"]
325
286
 
326
- try:
327
- pesquisar_icon = pyautogui.locateOnScreen(ASSETS_PATH + "\\emsys\\selecionar_venda.png", confidence=0.8)
328
- pyautogui.click(pesquisar_icon)
329
- await worker_sleep(5)
330
- except Exception as e:
331
- retorno = f"Não foi possivel clicar no botão Selecionar Venda, erro: {e} \nEtapas Executadas:\n{steps}"
332
- return RpaRetornoProcessoDTO(
333
- sucesso=False,
334
- retorno=retorno,
335
- status=RpaHistoricoStatusEnum.Falha,
336
- tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
337
- )
338
-
339
- await worker_sleep(2)
340
- pesquisar_venda_devolucao = await is_window_open_by_class("TFrmPesquisarVendaDevolucao", "TFrmPesquisarVendaDevolucao")
341
- if pesquisar_venda_devolucao["IsOpened"] == True:
342
- app = Application().connect(class_name="TFrmPesquisarVendaDevolucao", timeout=60)
343
- main_window = app["TFrmPesquisarVendaDevolucao"]
344
287
  main_window.set_focus()
345
-
346
- panel_filtro = main_window.child_window(class_name="TGroupBox", found_index=0)
347
- #INSERINDO O NUMERO VENDA
348
- console.print("INSERINDO O NUMERO VENDA...\n")
349
- field_num_venda = panel_filtro.child_window(class_name="TDBIEditString", found_index=0)
350
- field_num_venda.set_edit_text(numero_cupom_fiscal)
288
+ await worker_sleep(3)
289
+
290
+ console.print("Controles encontrados na janela 'Nota Fiscal de Entrada, navegando entre eles...\n")
291
+ panel_TNotebook = main_window.child_window(class_name="TNotebook", found_index=0)
292
+ panel_TPage = panel_TNotebook.child_window(class_name="TPage", found_index=0)
293
+ panel_TPageControl = panel_TPage.child_window(class_name="TPageControl", found_index=0)
294
+ panel_TTabSheet = panel_TPageControl.child_window(class_name="TTabSheet", found_index=0)
295
+
296
+ #SELECIONANDO O TIPO NOTA
297
+ console.print("SELECIONANDO O TIPO NOTA...\n")
298
+ panel_tipo_nota = panel_TPageControl.child_window(class_name="TDBIGroupBox", found_index=1)
299
+ radio_nota_devolucao = panel_tipo_nota.child_window(class_name="TDBIRadioButton", found_index=1)
300
+ radio_nota_devolucao.click()
351
301
  await worker_sleep(1)
352
302
 
353
- #INSERINDO O CODIGO DO CLIENTE
354
- console.print("INSERINDO O CODIGO DO CLIENTE...\n")
355
- field_cliente = panel_filtro.child_window(class_name="TDBIEditCode", found_index=0)
356
- field_cliente.set_edit_text(cod_cliente_incorreto)
303
+ #INSERINDO A ENTRADA E EMISSÃO
304
+ console.print("INSERINDO A ENTRADA E EMISSÃO ...\n")
305
+ field_entrada = main_window.child_window(class_name="TDBIEditDate", found_index=1)
306
+ field_emissao = main_window.child_window(class_name="TDBIEditDate", found_index=2)
307
+ field_entrada.set_edit_text(data_hoje)
308
+ await worker_sleep(1)
309
+ field_emissao.set_edit_text(data_hoje)
357
310
  await worker_sleep(1)
358
311
 
312
+ #INSERINDO CODIGO DO FORNECEDOR
313
+ console.print("INSERINDO CODIGO DO FORNECEDOR ...\n")
314
+ field_fornecedor = main_window.child_window(class_name="TDBIEditCode", found_index=0)
315
+ field_fornecedor.click()
316
+ field_fornecedor.set_edit_text(cod_cliente_incorreto)
317
+ pyautogui.press("tab")
318
+
319
+ #SELECIONAO A NOP
320
+ console.print("SELECIONAO A NOP...\n")
321
+ select_box_nop_select = main_window.child_window(class_name="TDBIComboBox", found_index=0)
322
+ select_box_nop_select.click()
323
+ set_combobox("||List", "1662 - DEVOLUÇÃO DE VENDA MERC. ADQ. TERCEIROS- 1.662 DEV COMB C/FI")
324
+ await worker_sleep(4)
325
+
359
326
  try:
360
- pesquisar_icon = pyautogui.locateOnScreen(ASSETS_PATH + "\\notas_saida\\icon_pesquisa_nota_saida.png", confidence=0.8)
327
+ pesquisar_icon = pyautogui.locateOnScreen(ASSETS_PATH + "\\emsys\\selecionar_venda.png", confidence=0.8)
361
328
  pyautogui.click(pesquisar_icon)
362
329
  await worker_sleep(5)
363
330
  except Exception as e:
364
- retorno = f"Não foi possivel clicar na Lupa para buscar a nota fiscal, erro: {e} \nEtapas Executadas:\n{steps}"
331
+ retorno = f"Não foi possivel clicar no botão Selecionar Venda, erro: {e} \nEtapas Executadas:\n{steps}"
365
332
  return RpaRetornoProcessoDTO(
366
333
  sucesso=False,
367
334
  retorno=retorno,
368
335
  status=RpaHistoricoStatusEnum.Falha,
369
336
  tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
370
337
  )
371
-
372
- i = 0
373
- max_attempts = 17
338
+
339
+ await worker_sleep(2)
340
+ pesquisar_venda_devolucao = await is_window_open_by_class("TFrmPesquisarVendaDevolucao", "TFrmPesquisarVendaDevolucao")
341
+ if pesquisar_venda_devolucao["IsOpened"] == True:
342
+ app = Application().connect(class_name="TFrmPesquisarVendaDevolucao", timeout=60)
343
+ main_window = app["TFrmPesquisarVendaDevolucao"]
344
+ main_window.set_focus()
374
345
 
375
- while i < max_attempts:
376
- i += 1
377
- console.print("Verificando se a nota foi encontrada...\n")
378
- try:
379
- main_window.set_focus()
380
- no_data_full_path = "assets\\entrada_notas\\no_data_display.png"
381
- img_no_data = pyautogui.locateCenterOnScreen(no_data_full_path, confidence=0.6)
382
- if img_no_data:
383
- console.print("'No data display' ainda aparente. Tentando novamente...")
384
- await worker_sleep(10)
385
- except pyautogui.ImageNotFoundException:
386
- console.print("'No data display' não encontrado na tela!")
387
- break
346
+ panel_filtro = main_window.child_window(class_name="TGroupBox", found_index=0)
347
+ #INSERINDO O NUMERO VENDA
348
+ console.print("INSERINDO O NUMERO VENDA...\n")
349
+ field_num_venda = panel_filtro.child_window(class_name="TDBIEditString", found_index=0)
350
+ field_num_venda.set_edit_text(numero_cupom_fiscal)
351
+ await worker_sleep(1)
352
+
353
+ #INSERINDO O CODIGO DO CLIENTE
354
+ console.print("INSERINDO O CODIGO DO CLIENTE...\n")
355
+ field_cliente = panel_filtro.child_window(class_name="TDBIEditCode", found_index=0)
356
+ field_cliente.set_edit_text(cod_cliente_incorreto)
357
+ await worker_sleep(1)
388
358
 
359
+ try:
360
+ pesquisar_icon = pyautogui.locateOnScreen(ASSETS_PATH + "\\notas_saida\\icon_pesquisa_nota_saida.png", confidence=0.8)
361
+ pyautogui.click(pesquisar_icon)
362
+ await worker_sleep(5)
389
363
  except Exception as e:
390
- console.print(f"Ocorreu um erro: {e}")
391
-
364
+ retorno = f"Não foi possivel clicar na Lupa para buscar a nota fiscal, erro: {e} \nEtapas Executadas:\n{steps}"
365
+ return RpaRetornoProcessoDTO(
366
+ sucesso=False,
367
+ retorno=retorno,
368
+ status=RpaHistoricoStatusEnum.Falha,
369
+ tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
370
+ )
392
371
 
393
- await worker_sleep(5)
394
- # VERIFICANDO A EXISTENCIA DE ERRO
395
- erro_pop_up = await is_window_open_by_class("TMessageForm","TMessageForm")
396
- if erro_pop_up["IsOpened"] == True:
397
- retorno = f"Nota não encontrada no EMsys na tela de Pesquisa Vendas para Devolução \nEtapas Executadas:\n{steps}"
398
- return RpaRetornoProcessoDTO(
399
- sucesso=False,
400
- retorno=retorno,
401
- status=RpaHistoricoStatusEnum.Falha,
402
- tags=[RpaTagDTO(descricao=RpaTagEnum.Negocio)]
403
- )
372
+ i = 0
373
+ max_attempts = 17
404
374
 
405
- main_window.set_focus()
406
- try:
407
- selecionar_todos_itens = pyautogui.locateOnScreen(ASSETS_PATH + "\\emsys\\selecinar_todos_itens_quadro_azul.png", confidence=0.8)
408
- pyautogui.click(selecionar_todos_itens)
409
- await worker_sleep(5)
410
- except Exception as e:
411
- retorno = f"Não foi possivel clicar em selecionar todos os itens na tela de Pesquisar Vendas para Devolução, erro: {e} \nEtapas Executadas:\n{steps}"
412
- return RpaRetornoProcessoDTO(
413
- sucesso=False,
414
- retorno=retorno,
415
- status=RpaHistoricoStatusEnum.Falha,
416
- tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
417
- )
375
+ while i < max_attempts:
376
+ i += 1
377
+ console.print("Verificando se a nota foi encontrada...\n")
378
+ try:
379
+ main_window.set_focus()
380
+ no_data_full_path = "assets\\entrada_notas\\no_data_display.png"
381
+ img_no_data = pyautogui.locateCenterOnScreen(no_data_full_path, confidence=0.6)
382
+ if img_no_data:
383
+ console.print("'No data display' ainda aparente. Tentando novamente...")
384
+ await worker_sleep(10)
385
+ except pyautogui.ImageNotFoundException:
386
+ console.print("'No data display' não encontrado na tela!")
387
+ break
418
388
 
419
- try:
420
- pesquisar_icon = pyautogui.locateOnScreen(ASSETS_PATH + "\\emsys\\inserir.png", confidence=0.8)
421
- pyautogui.click(pesquisar_icon)
389
+ except Exception as e:
390
+ console.print(f"Ocorreu um erro: {e}")
391
+
392
+
422
393
  await worker_sleep(5)
423
- except Exception as e:
424
- retorno = f"Não foi possivel clicar em Inserir para selecionar a nota fiscal, erro: {e} \nEtapas Executadas:\n{steps}"
425
- return RpaRetornoProcessoDTO(
426
- sucesso=False,
427
- retorno=retorno,
428
- status=RpaHistoricoStatusEnum.Falha,
429
- tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
430
- )
431
-
432
- await worker_sleep(5)
433
- console.print("Navegando pela Janela de Nota Fiscal de Entrada...\n")
434
- app = Application().connect(class_name="TFrmNotaFiscalEntrada")
435
- main_window = app["TFrmNotaFiscalEntrada"]
394
+ # VERIFICANDO A EXISTENCIA DE ERRO
395
+ erro_pop_up = await is_window_open_by_class("TMessageForm","TMessageForm")
396
+ if erro_pop_up["IsOpened"] == True:
397
+ retorno = f"Nota não encontrada no EMsys na tela de Pesquisa Vendas para Devolução \nEtapas Executadas:\n{steps}"
398
+ return RpaRetornoProcessoDTO(
399
+ sucesso=False,
400
+ retorno=retorno,
401
+ status=RpaHistoricoStatusEnum.Falha,
402
+ tags=[RpaTagDTO(descricao=RpaTagEnum.Negocio)]
403
+ )
436
404
 
437
- main_window.set_focus()
438
- console.print("Acessando os itens da nota... \n")
439
- panel_TPage = main_window.child_window(class_name="TPage", title="Formulario")
440
- panel_TTabSheet = panel_TPage.child_window(class_name="TcxCustomInnerTreeView")
441
- panel_TTabSheet.wait("visible")
442
- panel_TTabSheet.click()
443
- send_keys("^({HOME})")
444
- await worker_sleep(1)
445
- send_keys("{DOWN " + ("5") + "}")
446
-
447
- # CONFIRMANDO SE A ABA DE ITENS FOI ACESSADA COM SUCESSO
448
- panel_TPage = main_window.child_window(class_name="TPage", title="Formulario")
449
- panel_TPage.wait("visible")
450
- panel_TTabSheet = panel_TPage.child_window(class_name="TTabSheet")
451
- title_n_serie = panel_TPage.child_window(title="N° Série")
452
-
453
- console.print("Verificando se os itens foram abertos com sucesso... \n")
454
- if not title_n_serie:
455
- retorno = f"Não foi possivel acessar a aba de 'Itens da nota \nEtapas Executadas:\n{steps}"
456
- console.print(f"Não foi possivel acessar a aba de 'Itens da nota...\n")
457
- return RpaRetornoProcessoDTO(
458
- sucesso=False,
459
- retorno=retorno,
460
- status=RpaHistoricoStatusEnum.Falha,
461
- tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
462
- )
405
+ main_window.set_focus()
406
+ try:
407
+ selecionar_todos_itens = pyautogui.locateOnScreen(ASSETS_PATH + "\\emsys\\selecinar_todos_itens_quadro_azul.png", confidence=0.8)
408
+ pyautogui.click(selecionar_todos_itens)
409
+ await worker_sleep(5)
410
+ except Exception as e:
411
+ retorno = f"Não foi possivel clicar em selecionar todos os itens na tela de Pesquisar Vendas para Devolução, erro: {e} \nEtapas Executadas:\n{steps}"
412
+ return RpaRetornoProcessoDTO(
413
+ sucesso=False,
414
+ retorno=retorno,
415
+ status=RpaHistoricoStatusEnum.Falha,
416
+ tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
417
+ )
463
418
 
464
- await worker_sleep(2)
419
+ try:
420
+ pesquisar_icon = pyautogui.locateOnScreen(ASSETS_PATH + "\\emsys\\inserir.png", confidence=0.8)
421
+ pyautogui.click(pesquisar_icon)
422
+ await worker_sleep(5)
423
+ except Exception as e:
424
+ retorno = f"Não foi possivel clicar em Inserir para selecionar a nota fiscal, erro: {e} \nEtapas Executadas:\n{steps}"
425
+ return RpaRetornoProcessoDTO(
426
+ sucesso=False,
427
+ retorno=retorno,
428
+ status=RpaHistoricoStatusEnum.Falha,
429
+ tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
430
+ )
465
431
 
466
- console.print("Acessando os itens indivualmente... \n")
467
- send_keys("{TAB 2}", pause=0.1)
468
- await worker_sleep(2)
432
+ await worker_sleep(5)
433
+ console.print("Navegando pela Janela de Nota Fiscal de Entrada...\n")
434
+ app = Application().connect(class_name="TFrmNotaFiscalEntrada")
435
+ main_window = app["TFrmNotaFiscalEntrada"]
469
436
 
470
- index = 0
471
- last_line_item_emsys = 'x'
472
-
473
- try:
474
- while True:
475
- await worker_sleep(2)
476
- send_keys("^({HOME})")
477
- await worker_sleep(1)
478
- send_keys("{DOWN " + str(index) + "}", pause=0.1)
479
- await worker_sleep(3)
437
+ main_window.set_focus()
438
+ console.print("Acessando os itens da nota... \n")
439
+ panel_TPage = main_window.child_window(class_name="TPage", title="Formulario")
440
+ panel_TTabSheet = panel_TPage.child_window(class_name="TcxCustomInnerTreeView")
441
+ panel_TTabSheet.wait("visible")
442
+ panel_TTabSheet.click()
443
+ send_keys("^({HOME})")
444
+ await worker_sleep(1)
445
+ send_keys("{DOWN " + ("5") + "}")
480
446
 
481
- with pyautogui.hold('ctrl'):
482
- pyautogui.press('c')
483
- await worker_sleep(1)
484
- with pyautogui.hold('ctrl'):
485
- pyautogui.press('c')
447
+ # CONFIRMANDO SE A ABA DE ITENS FOI ACESSADA COM SUCESSO
448
+ panel_TPage = main_window.child_window(class_name="TPage", title="Formulario")
449
+ panel_TPage.wait("visible")
450
+ panel_TTabSheet = panel_TPage.child_window(class_name="TTabSheet")
451
+ title_n_serie = panel_TPage.child_window(title="N° Série")
452
+
453
+ console.print("Verificando se os itens foram abertos com sucesso... \n")
454
+ if not title_n_serie:
455
+ retorno = f"Não foi possivel acessar a aba de 'Itens da nota \nEtapas Executadas:\n{steps}"
456
+ console.print(f"Não foi possivel acessar a aba de 'Itens da nota...\n")
457
+ return RpaRetornoProcessoDTO(
458
+ sucesso=False,
459
+ retorno=retorno,
460
+ status=RpaHistoricoStatusEnum.Falha,
461
+ tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
462
+ )
486
463
 
487
- win32clipboard.OpenClipboard()
488
- line_itens_emsys = win32clipboard.GetClipboardData().strip()
489
- win32clipboard.CloseClipboard()
490
- console.print(f"Linha atual copiada do Emsys: {line_itens_emsys}\nUltima Linha copiada: {last_line_item_emsys}")
464
+ await worker_sleep(2)
491
465
 
492
- if bool(line_itens_emsys):
493
- if last_line_item_emsys == line_itens_emsys:
494
- break
495
- else:
496
- last_line_item_emsys = line_itens_emsys
466
+ console.print("Acessando os itens indivualmente... \n")
467
+ send_keys("{TAB 2}", pause=0.1)
468
+ await worker_sleep(2)
497
469
 
498
- send_keys("+{F10}")
499
- await worker_sleep(1)
500
- send_keys("{DOWN 2}")
501
- await worker_sleep(1)
502
- send_keys("{ENTER}")
503
- await worker_sleep(4)
470
+ index = 0
471
+ last_line_item_emsys = 'x'
472
+
473
+ try:
474
+ while True:
475
+ await worker_sleep(2)
476
+ send_keys("^({HOME})")
477
+ await worker_sleep(1)
478
+ send_keys("{DOWN " + str(index) + "}", pause=0.1)
479
+ await worker_sleep(3)
504
480
 
505
- app = Application().connect(title="Alteração de Item")
506
- main_window = app["Alteração de Item"]
507
- main_window.set_focus()
481
+ with pyautogui.hold('ctrl'):
482
+ pyautogui.press('c')
483
+ await worker_sleep(1)
484
+ with pyautogui.hold('ctrl'):
485
+ pyautogui.press('c')
508
486
 
509
- # ITERAGINDO COM O IPI
510
- tpage_ipi = main_window.child_window(class_name="TPanel", found_index=0)
511
- ipi = tpage_ipi.child_window(class_name="TDBIComboBox", found_index=2)
512
- ipi_value = ipi.window_text()
487
+ win32clipboard.OpenClipboard()
488
+ line_itens_emsys = win32clipboard.GetClipboardData().strip()
489
+ win32clipboard.CloseClipboard()
490
+ console.print(f"Linha atual copiada do Emsys: {line_itens_emsys}\nUltima Linha copiada: {last_line_item_emsys}")
513
491
 
514
- console.print(f"Trabalhando com os itens, valor do IP {ipi_value}... \n")
515
- if "IPI - ENTRADAS OUTROS" in ipi_value:
516
- console.print(f"Iten selecionado com sucesso, clicando em Cancelar ...\n")
517
- try:
518
- btn_alterar = main_window.child_window(title="&Cancelar")
519
- btn_alterar.click()
520
- except:
521
- btn_alterar = main_window.child_window(title="Cancelar")
522
- btn_alterar.click()
523
- await worker_sleep(3)
524
- else:
525
- console.print(f"Trabalhando com os itens, valor do IP em branco, selecionando IPI 0% ... \n")
526
- ipi.click_input()
527
- set_combobox("||List", "IPI - ENTRADAS OUTROS")
492
+ if bool(line_itens_emsys):
493
+ if last_line_item_emsys == line_itens_emsys:
494
+ break
495
+ else:
496
+ last_line_item_emsys = line_itens_emsys
528
497
 
498
+ send_keys("+{F10}")
499
+ await worker_sleep(1)
500
+ send_keys("{DOWN 2}")
501
+ await worker_sleep(1)
502
+ send_keys("{ENTER}")
529
503
  await worker_sleep(4)
504
+
505
+ app = Application().connect(title="Alteração de Item")
506
+ main_window = app["Alteração de Item"]
507
+ main_window.set_focus()
508
+
509
+ # ITERAGINDO COM O IPI
530
510
  tpage_ipi = main_window.child_window(class_name="TPanel", found_index=0)
531
511
  ipi = tpage_ipi.child_window(class_name="TDBIComboBox", found_index=2)
532
512
  ipi_value = ipi.window_text()
533
513
 
514
+ console.print(f"Trabalhando com os itens, valor do IP {ipi_value}... \n")
534
515
  if "IPI - ENTRADAS OUTROS" in ipi_value:
535
- console.print(f"Trabalhando com os itens, sucesso ao selecionar o valor do IPI ... \n")
516
+ console.print(f"Iten selecionado com sucesso, clicando em Cancelar ...\n")
517
+ try:
518
+ btn_alterar = main_window.child_window(title="&Cancelar")
519
+ btn_alterar.click()
520
+ except:
521
+ btn_alterar = main_window.child_window(title="Cancelar")
522
+ btn_alterar.click()
523
+ await worker_sleep(3)
536
524
  else:
537
- return RpaRetornoProcessoDTO(
538
- sucesso=False,
539
- retorno=f"Erro ao selecionar o IPI de unidade nos itens, IPI: {ipi_value}",
540
- status=RpaHistoricoStatusEnum.Falha,
541
- tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
542
- )
543
-
544
- await worker_sleep(4)
545
-
546
- console.print(f"Iten selecionado com sucesso, clicando em alterar ...\n")
547
- try:
548
- btn_alterar = main_window.child_window(title="&Alterar")
549
- btn_alterar.click()
550
- except:
551
- btn_alterar = main_window.child_window(title="Alterar")
552
- btn_alterar.click()
553
- await worker_sleep(3)
525
+ console.print(f"Trabalhando com os itens, valor do IP em branco, selecionando IPI 0% ... \n")
526
+ ipi.click_input()
527
+ set_combobox("||List", "IPI - ENTRADAS OUTROS")
554
528
 
555
- confirm_pop_up = await is_window_open_by_class("TMessageForm","TMessageForm")
556
- if confirm_pop_up["IsOpened"] == True:
557
- app_confirm = Application().connect(
558
- class_name="TMessageForm"
559
- )
560
- main_window_confirm = app_confirm["TMessageForm"]
529
+ await worker_sleep(4)
530
+ tpage_ipi = main_window.child_window(class_name="TPanel", found_index=0)
531
+ ipi = tpage_ipi.child_window(class_name="TDBIComboBox", found_index=2)
532
+ ipi_value = ipi.window_text()
561
533
 
562
- btn_yes = main_window_confirm["&Yes"]
563
- try:
564
- btn_yes.click()
565
- await worker_sleep(3)
566
- console.print("O botão Yes foi clicado com sucesso.", style="green")
567
- main_window.close()
568
- except:
534
+ if "IPI - ENTRADAS OUTROS" in ipi_value:
535
+ console.print(f"Trabalhando com os itens, sucesso ao selecionar o valor do IPI ... \n")
536
+ else:
569
537
  return RpaRetornoProcessoDTO(
570
538
  sucesso=False,
571
- retorno=f"Não foi possivel clicar em Yes durante a alteração da tributação IPI",
539
+ retorno=f"Erro ao selecionar o IPI de unidade nos itens, IPI: {ipi_value}",
572
540
  status=RpaHistoricoStatusEnum.Falha,
573
541
  tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
574
542
  )
575
- index = index+1
576
- except Exception as e:
577
- retorno = f"Erro ao trabalhar nas alterações dos itens, erro: {e} \nEtapas Executadas:\n{steps}"
578
- return RpaRetornoProcessoDTO(
579
- sucesso=False,
580
- retorno=retorno,
581
- status=RpaHistoricoStatusEnum.Falha,
582
- tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
583
- )
584
-
585
- await worker_sleep(5)
586
- console.print("Navegando pela Janela de Nota Fiscal de Entrada - Acessando a Janela de Pagamento...\n")
587
- app = Application().connect(class_name="TFrmNotaFiscalEntrada")
588
- main_window = app["TFrmNotaFiscalEntrada"]
589
-
590
- main_window.set_focus()
591
- console.log("Seleciona Pagamento", style="bold yellow")
592
- try:
593
- pyautogui.click(623, 374)
594
- await worker_sleep(1)
595
- send_keys("{DOWN " + ("4") + "}")
596
- except Exception as e:
597
- panel_TPage = main_window.child_window(class_name="TPage", title="Formulario")
598
- panel_TTabSheet = panel_TPage.child_window(class_name="TcxCustomInnerTreeView")
599
- panel_TTabSheet.wait("visible")
600
- panel_TTabSheet.click()
601
- send_keys("{DOWN " + ("2") + "}")
602
-
603
-
604
- if nota.get("clienteFIDC").lower() == 'não':
605
- try:
606
- panel_TPage = main_window.child_window(class_name="TPage", title="Formulario")
607
- panel_TTabSheet = panel_TPage.child_window(class_name="TPageControl")
608
- panel_TabPagamento = panel_TTabSheet.child_window(class_name="TTabSheet")
609
- panel_TabPagamentoCaixa = panel_TTabSheet.child_window(title="Pagamento Pelo Caixa")
610
- tipo_cobranca = panel_TabPagamentoCaixa.child_window(class_name="TDBIComboBox", found_index=0)
611
543
 
612
- console.print(f"Selecionando a Especie de Caixa... \n")
613
- tipo_cobranca.click()
614
- await worker_sleep(1)
615
- set_combobox("||List", "13 - DEVOLUCAO DE VENDA")
616
-
617
- await worker_sleep(2)
544
+ await worker_sleep(4)
618
545
 
619
- console.print(f"Capturando o valor em Valores Restante... \n")
620
- tab_valores = panel_TabPagamento.child_window(title="Valores")
621
- valores_restantes = tab_valores.child_window(
622
- class_name="TDBIEditNumber", found_index=1
623
- )
624
- valores_restantes_text = valores_restantes.window_text()
625
- valor_nota_fiscal = valores_restantes_text
626
- console.print(f"Valor capturado {valores_restantes_text}, inserindo no campo Valor em Pagamento pelo Caixa... \n")
546
+ console.print(f"Iten selecionado com sucesso, clicando em alterar ...\n")
547
+ try:
548
+ btn_alterar = main_window.child_window(title="&Alterar")
549
+ btn_alterar.click()
550
+ except:
551
+ btn_alterar = main_window.child_window(title="Alterar")
552
+ btn_alterar.click()
553
+ await worker_sleep(3)
554
+
555
+ confirm_pop_up = await is_window_open_by_class("TMessageForm","TMessageForm")
556
+ if confirm_pop_up["IsOpened"] == True:
557
+ app_confirm = Application().connect(
558
+ class_name="TMessageForm"
559
+ )
560
+ main_window_confirm = app_confirm["TMessageForm"]
627
561
 
628
- valor = panel_TabPagamentoCaixa.child_window(class_name="TDBIEditNumber", found_index=0)
629
- valor.set_edit_text(valores_restantes_text)
562
+ btn_yes = main_window_confirm["&Yes"]
563
+ try:
564
+ btn_yes.click()
565
+ await worker_sleep(3)
566
+ console.print("O botão Yes foi clicado com sucesso.", style="green")
567
+ main_window.close()
568
+ except:
569
+ return RpaRetornoProcessoDTO(
570
+ sucesso=False,
571
+ retorno=f"Não foi possivel clicar em Yes durante a alteração da tributação IPI",
572
+ status=RpaHistoricoStatusEnum.Falha,
573
+ tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
574
+ )
575
+ index = index+1
630
576
  except Exception as e:
631
- retorno = f"Não foi possivel realizar as atividades na aba de 'Pagamento', erro: {e} \nEtapas Executadas:\n{steps}"
577
+ retorno = f"Erro ao trabalhar nas alterações dos itens, erro: {e} \nEtapas Executadas:\n{steps}"
632
578
  return RpaRetornoProcessoDTO(
633
579
  sucesso=False,
634
580
  retorno=retorno,
635
581
  status=RpaHistoricoStatusEnum.Falha,
636
582
  tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
637
583
  )
638
- else:
584
+
585
+ await worker_sleep(5)
586
+ console.print("Navegando pela Janela de Nota Fiscal de Entrada - Acessando a Janela de Pagamento...\n")
587
+ app = Application().connect(class_name="TFrmNotaFiscalEntrada")
588
+ main_window = app["TFrmNotaFiscalEntrada"]
589
+
590
+ main_window.set_focus()
591
+ console.log("Seleciona Pagamento", style="bold yellow")
639
592
  try:
593
+ pyautogui.click(623, 374)
594
+ await worker_sleep(1)
595
+ send_keys("{DOWN " + ("4") + "}")
596
+ except Exception as e:
640
597
  panel_TPage = main_window.child_window(class_name="TPage", title="Formulario")
641
- panel_TTabSheet = panel_TPage.child_window(class_name="TPageControl")
642
- panel_TabPagamento = panel_TTabSheet.child_window(class_name="TTabSheet")
643
- panel_TabParcelamento = panel_TTabSheet.child_window(title="Parcelamento")
644
- tipo_cobranca = panel_TabParcelamento.child_window(class_name="TDBIComboBox", found_index=0)
645
-
646
- console.print("Verificando o tipo de cobrança selecionado... \n")
647
- tipo_selecionado = tipo_cobranca.window_text()
648
- if "boleto" in tipo_selecionado.lower():
649
- console.print(f"Tipo de cobrança corretamente selecionado {tipo_selecionado}... \n")
650
- else:
651
- console.print(f"Tipo de cobrança não foi selecionado corretamente, interagindo com o campo para selecionar o campo corretamente... \n")
598
+ panel_TTabSheet = panel_TPage.child_window(class_name="TcxCustomInnerTreeView")
599
+ panel_TTabSheet.wait("visible")
600
+ panel_TTabSheet.click()
601
+ send_keys("{DOWN " + ("2") + "}")
602
+
603
+
604
+ if nota.get("clienteFIDC").lower() == 'não':
605
+ try:
606
+ panel_TPage = main_window.child_window(class_name="TPage", title="Formulario")
607
+ panel_TTabSheet = panel_TPage.child_window(class_name="TPageControl")
608
+ panel_TabPagamento = panel_TTabSheet.child_window(class_name="TTabSheet")
609
+ panel_TabPagamentoCaixa = panel_TTabSheet.child_window(title="Pagamento Pelo Caixa")
610
+ tipo_cobranca = panel_TabPagamentoCaixa.child_window(class_name="TDBIComboBox", found_index=0)
611
+
612
+ console.print(f"Selecionando a Especie de Caixa... \n")
652
613
  tipo_cobranca.click()
653
614
  await worker_sleep(1)
654
- set_combobox("||List", "BANCO DO BRASIL BOLETO")
655
-
615
+ set_combobox("||List", "13 - DEVOLUCAO DE VENDA")
656
616
 
657
- tab_valores = panel_TabPagamento.child_window(title="Valores")
658
- valores_restantes = tab_valores.child_window(class_name="TDBIEditNumber", found_index=1)
659
- valores_informado = tab_valores.child_window(class_name="TDBIEditNumber", found_index=2)
617
+ await worker_sleep(2)
660
618
 
661
- vencimento = panel_TabParcelamento.child_window(class_name="TDBIEditDate")
662
- data_hoje_obj = datetime.strptime(data_hoje, '%d/%m/%Y')
663
- nova_data = data_hoje_obj + timedelta(days=5)
664
- data_vencimento = nova_data.strftime('%d/%m/%Y')
665
- console.print(f'Data de Vencimento a ser inserida: {data_vencimento}')
666
- vencimento.set_edit_text(data_vencimento)
619
+ console.print(f"Capturando o valor em Valores Restante... \n")
620
+ tab_valores = panel_TabPagamento.child_window(title="Valores")
621
+ valores_restantes = tab_valores.child_window(
622
+ class_name="TDBIEditNumber", found_index=1
623
+ )
624
+ valores_restantes_text = valores_restantes.window_text()
625
+ valor_nota_fiscal = valores_restantes_text
626
+ console.print(f"Valor capturado {valores_restantes_text}, inserindo no campo Valor em Pagamento pelo Caixa... \n")
667
627
 
668
- await worker_sleep(2)
669
- console.print(f"Inserindo o valor {valores_restantes_text}... \n")
670
- valor = panel_TabParcelamento.child_window(class_name="TDBIEditNumber", found_index=3)
671
- valor.set_edit_text(valores_restantes_text)
628
+ valor = panel_TabPagamentoCaixa.child_window(class_name="TDBIEditNumber", found_index=0)
629
+ valor.set_edit_text(valores_restantes_text)
630
+ except Exception as e:
631
+ retorno = f"Não foi possivel realizar as atividades na aba de 'Pagamento', erro: {e} \nEtapas Executadas:\n{steps}"
632
+ return RpaRetornoProcessoDTO(
633
+ sucesso=False,
634
+ retorno=retorno,
635
+ status=RpaHistoricoStatusEnum.Falha,
636
+ tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
637
+ )
638
+ else:
639
+ try:
640
+ panel_TPage = main_window.child_window(class_name="TPage", title="Formulario")
641
+ panel_TTabSheet = panel_TPage.child_window(class_name="TPageControl")
642
+ panel_TabPagamento = panel_TTabSheet.child_window(class_name="TTabSheet")
643
+ panel_TabParcelamento = panel_TTabSheet.child_window(title="Parcelamento")
644
+ tipo_cobranca = panel_TabParcelamento.child_window(class_name="TDBIComboBox", found_index=0)
645
+
646
+ console.print("Verificando o tipo de cobrança selecionado... \n")
647
+ tipo_selecionado = tipo_cobranca.window_text()
648
+ if "boleto" in tipo_selecionado.lower():
649
+ console.print(f"Tipo de cobrança corretamente selecionado {tipo_selecionado}... \n")
650
+ else:
651
+ console.print(f"Tipo de cobrança não foi selecionado corretamente, interagindo com o campo para selecionar o campo corretamente... \n")
652
+ tipo_cobranca.click()
653
+ await worker_sleep(1)
654
+ set_combobox("||List", "BANCO DO BRASIL BOLETO")
655
+
672
656
 
673
- await worker_sleep(2)
674
- console.print(f"Adicionando o pagamento... \n")
675
- btn_add = panel_TabParcelamento.child_window(class_name="TDBIBitBtn", found_index=1)
676
- btn_add.click()
677
-
678
- await worker_sleep(4)
679
- console.print(f"Verificando se o pagamento foi adicionado com sucesso... \n")
680
- valores_informado = tab_valores.child_window(class_name="TDBIEditNumber", found_index=2)
681
- valores_informado_text = valores_informado.window_text()
682
- if '0,00' in valores_informado_text and len(valores_informado_text) == 3:
657
+ tab_valores = panel_TabPagamento.child_window(title="Valores")
658
+ valores_restantes = tab_valores.child_window(class_name="TDBIEditNumber", found_index=1)
659
+ valores_informado = tab_valores.child_window(class_name="TDBIEditNumber", found_index=2)
660
+
661
+ vencimento = panel_TabParcelamento.child_window(class_name="TDBIEditDate")
662
+ data_hoje_obj = datetime.strptime(data_hoje, '%d/%m/%Y')
663
+ nova_data = data_hoje_obj + timedelta(days=5)
664
+ data_vencimento = nova_data.strftime('%d/%m/%Y')
665
+ console.print(f'Data de Vencimento a ser inserida: {data_vencimento}')
666
+ vencimento.set_edit_text(data_vencimento)
667
+
668
+ await worker_sleep(2)
669
+ console.print(f"Inserindo o valor {valores_restantes_text}... \n")
670
+ valor = panel_TabParcelamento.child_window(class_name="TDBIEditNumber", found_index=3)
671
+ valor.set_edit_text(valores_restantes_text)
672
+
673
+ await worker_sleep(2)
674
+ console.print(f"Adicionando o pagamento... \n")
675
+ btn_add = panel_TabParcelamento.child_window(class_name="TDBIBitBtn", found_index=1)
676
+ btn_add.click()
677
+
678
+ await worker_sleep(4)
679
+ console.print(f"Verificando se o pagamento foi adicionado com sucesso... \n")
680
+ valores_informado = tab_valores.child_window(class_name="TDBIEditNumber", found_index=2)
681
+ valores_informado_text = valores_informado.window_text()
682
+ if '0,00' in valores_informado_text and len(valores_informado_text) == 3:
683
+ return RpaRetornoProcessoDTO(
684
+ sucesso=False,
685
+ retorno=f"Erro ao adicionar o pagamento, valor informado {valores_informado_text}.",
686
+ status=RpaHistoricoStatusEnum.Falha,
687
+ tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
688
+ )
689
+ console.print(f"Processo de incluir pagamento realizado com sucesso... \n")
690
+
691
+ except Exception as e:
692
+ retorno = f"Erro ao processar tela 'Pagamento', erro: {e} \nEtapas Executadas:\n{steps}"
683
693
  return RpaRetornoProcessoDTO(
684
694
  sucesso=False,
685
- retorno=f"Erro ao adicionar o pagamento, valor informado {valores_informado_text}.",
695
+ retorno=retorno,
686
696
  status=RpaHistoricoStatusEnum.Falha,
687
697
  tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
688
698
  )
689
- console.print(f"Processo de incluir pagamento realizado com sucesso... \n")
690
699
 
700
+ # Inclui registro
701
+ console.print(f"Incluindo registro...\n")
702
+ try:
703
+ ASSETS_PATH = "assets"
704
+ inserir_registro = pyautogui.locateOnScreen(ASSETS_PATH + "\\entrada_notas\\IncluirRegistro.png", confidence=0.8)
705
+ pyautogui.click(inserir_registro)
691
706
  except Exception as e:
692
- retorno = f"Erro ao processar tela 'Pagamento', erro: {e} \nEtapas Executadas:\n{steps}"
693
- return RpaRetornoProcessoDTO(
694
- sucesso=False,
695
- retorno=retorno,
696
- status=RpaHistoricoStatusEnum.Falha,
697
- tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
707
+ console.print(
708
+ f"Não foi possivel incluir o registro utilizando reconhecimento de imagem, Error: {e}...\n tentando inserir via posição...\n"
698
709
  )
710
+ await incluir_registro()
711
+
699
712
 
700
- # Inclui registro
701
- console.print(f"Incluindo registro...\n")
702
- try:
703
- ASSETS_PATH = "assets"
704
- inserir_registro = pyautogui.locateOnScreen(ASSETS_PATH + "\\entrada_notas\\IncluirRegistro.png", confidence=0.8)
705
- pyautogui.click(inserir_registro)
706
- except Exception as e:
707
- console.print(
708
- f"Não foi possivel incluir o registro utilizando reconhecimento de imagem, Error: {e}...\n tentando inserir via posição...\n"
709
- )
710
- await incluir_registro()
711
-
713
+ await worker_sleep(5)
714
+ console.print("Verificando a existencia de POP-UP de Itens que Ultrapassam a Variação Máxima de Custo ...\n")
715
+ itens_variacao_maxima = await is_window_open_by_class("TFrmTelaSelecao", "TFrmTelaSelecao")
716
+ if itens_variacao_maxima["IsOpened"] == True:
717
+ app = Application().connect(class_name="TFrmTelaSelecao")
718
+ main_window = app["TFrmTelaSelecao"]
719
+ send_keys("%o")
720
+
712
721
 
713
- await worker_sleep(5)
714
- console.print("Verificando a existencia de POP-UP de Itens que Ultrapassam a Variação Máxima de Custo ...\n")
715
- itens_variacao_maxima = await is_window_open_by_class("TFrmTelaSelecao", "TFrmTelaSelecao")
716
- if itens_variacao_maxima["IsOpened"] == True:
717
- app = Application().connect(class_name="TFrmTelaSelecao")
718
- main_window = app["TFrmTelaSelecao"]
719
- send_keys("%o")
720
-
722
+ #VERIFICANDO SE A NOTA FOI INCLUIDA COM SUCESSO
723
+ console.print("Verificando a se a Nota foi incluida com sucesso... \n")
724
+ try:
725
+ app = Application().connect(title="Information", timeout=180)
726
+ main_window = app["Information"]
727
+ main_window.set_focus()
721
728
 
722
- #VERIFICANDO SE A NOTA FOI INCLUIDA COM SUCESSO
723
- console.print("Verificando a se a Nota foi incluida com sucesso... \n")
724
- try:
725
- app = Application().connect(title="Information", timeout=180)
726
- main_window = app["Information"]
727
- main_window.set_focus()
729
+ #EXTRAINDO O NUMERO DA NOTA
730
+ window_rect = main_window.rectangle()
731
+ screenshot = pyautogui.screenshot(
732
+ region=(
733
+ window_rect.left,
734
+ window_rect.top,
735
+ window_rect.width(),
736
+ window_rect.height(),
737
+ )
738
+ )
739
+ username = getpass.getuser()
740
+ short_uuid = str(uuid.uuid4()).replace('-', '')[:6]
741
+ path_to_png = f"C:\\Users\\{username}\\Downloads\\aviso_popup_{short_uuid}.png"
742
+ screenshot.save(path_to_png)
743
+ console.print(f"Print salvo em {path_to_png}...\n")
728
744
 
729
- #EXTRAINDO O NUMERO DA NOTA
730
- window_rect = main_window.rectangle()
731
- screenshot = pyautogui.screenshot(
732
- region=(
733
- window_rect.left,
734
- window_rect.top,
735
- window_rect.width(),
736
- window_rect.height(),
745
+ console.print(
746
+ f"Preparando a imagem para maior resolução e assertividade no OCR...\n"
737
747
  )
738
- )
739
- username = getpass.getuser()
740
- short_uuid = str(uuid.uuid4()).replace('-', '')[:6]
741
- path_to_png = f"C:\\Users\\{username}\\Downloads\\aviso_popup_{short_uuid}.png"
742
- screenshot.save(path_to_png)
743
- console.print(f"Print salvo em {path_to_png}...\n")
748
+ image = Image.open(path_to_png)
749
+ image = image.convert("L")
750
+ enhancer = ImageEnhance.Contrast(image)
751
+ image = enhancer.enhance(2.0)
752
+ image.save(path_to_png)
753
+ console.print(f"Imagem preparada com sucesso...\n")
754
+ console.print(f"Realizando OCR...\n")
755
+ captured_text = pytesseract.image_to_string(Image.open(path_to_png))
756
+ console.print(f"Texto Full capturado {captured_text}...\n")
757
+ os.remove(path_to_png)
758
+ pattern = r"sequ[êe]ncia:\s*(\d+)"
759
+ match = re.search(pattern, captured_text)
760
+
761
+ if match:
762
+ numero_nota_fiscal = match.group(1)
744
763
 
745
- console.print(
746
- f"Preparando a imagem para maior resolução e assertividade no OCR...\n"
747
- )
748
- image = Image.open(path_to_png)
749
- image = image.convert("L")
750
- enhancer = ImageEnhance.Contrast(image)
751
- image = enhancer.enhance(2.0)
752
- image.save(path_to_png)
753
- console.print(f"Imagem preparada com sucesso...\n")
754
- console.print(f"Realizando OCR...\n")
755
- captured_text = pytesseract.image_to_string(Image.open(path_to_png))
756
- console.print(f"Texto Full capturado {captured_text}...\n")
757
- os.remove(path_to_png)
758
- pattern = r"sequ[êe]ncia:\s*(\d+)"
759
- match = re.search(pattern, captured_text)
760
-
761
- if match:
762
- numero_nota_fiscal = match.group(1)
763
-
764
-
765
- app = Application().connect(title="Information", timeout=180)
766
- main_window = app["Information"]
767
- main_window.set_focus()
768
- btn_ok = main_window.child_window(class_name="TButton", found_index=0)
769
- btn_ok.click()
770
- await worker_sleep(3)
771
- steps += 'ETAPA 02 - Nota fiscal de Entrada Incluida com sucesso'
772
- except Exception as e:
773
- retorno = f"Não foi possivel obter a confirmação de Nota fiscal incluida com sucesso \nEtapas Executadas:\n{steps}"
774
- return RpaRetornoProcessoDTO(
775
- sucesso=False,
776
- retorno=retorno,
777
- status=RpaHistoricoStatusEnum.Falha,
778
- tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
779
- )
780
- else:
781
- retorno = f"Não foi possivel obter a confirmação de Nota fiscal incluida com sucesso \nEtapas Executadas:\n{steps}"
782
- return RpaRetornoProcessoDTO(
783
- sucesso=False,
784
- retorno=f"Não foi possivel abrir a tela de Pesquisar Venda para Devolução, erro: {e}",
785
- status=RpaHistoricoStatusEnum.Falha,
786
- tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
787
- )
764
+
765
+ app = Application().connect(title="Information", timeout=180)
766
+ main_window = app["Information"]
767
+ main_window.set_focus()
768
+ pyautogui.press('enter')
769
+ # btn_ok = main_window.child_window(class_name="TButton", found_index=0)
770
+ # btn_ok.click()
771
+ await worker_sleep(3)
772
+ steps += 'ETAPA 02 - Nota fiscal de Entrada Incluida com sucesso'
773
+ except Exception as e:
774
+ retorno = f"Não foi possivel obter a confirmação de Nota fiscal incluida com sucesso \nEtapas Executadas:\n{steps}"
775
+ return RpaRetornoProcessoDTO(
776
+ sucesso=False,
777
+ retorno=retorno,
778
+ status=RpaHistoricoStatusEnum.Falha,
779
+ tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
780
+ )
781
+ else:
782
+ retorno = f"Não foi possivel obter a confirmação de Nota fiscal incluida com sucesso \nEtapas Executadas:\n{steps}"
783
+ return RpaRetornoProcessoDTO(
784
+ sucesso=False,
785
+ retorno=f"Não foi possivel abrir a tela de Pesquisar Venda para Devolução, erro: {e}",
786
+ status=RpaHistoricoStatusEnum.Falha,
787
+ tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
788
+ )
788
789
 
789
790
  app = Application().connect(class_name="TFrmNotaFiscalEntrada")
790
791
  main_window = app["TFrmNotaFiscalEntrada"]
791
792
  main_window.close()
792
-
793
+ await worker_sleep(1)
794
+ pyautogui.press('enter')
795
+
796
+ numero_nota_fiscal = "1777083"
797
+
793
798
  #STEP 3
794
799
  type_text_into_field("Gerenciador de Notas Fiscais", app["TFrmMenuPrincipal"]["Edit"], True, "50")
795
800
  pyautogui.press("enter")
@@ -1506,4 +1511,5 @@ async def devolucao_prazo_a_faturar(task: RpaProcessoEntradaDTO) -> RpaRetornoPr
1506
1511
  sucesso=False,
1507
1512
  retorno=retorno,
1508
1513
  status=RpaHistoricoStatusEnum.Falha,
1514
+ tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
1509
1515
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: worker-automate-hub
3
- Version: 0.5.77
3
+ Version: 0.5.78
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
@@ -37,7 +37,7 @@ worker_automate_hub/tasks/jobs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5
37
37
  worker_automate_hub/tasks/jobs/coleta_dje_process.py,sha256=UkLWTC5Ub2qBb0yY-8IZ0DLLOVJOfNTq_z9krx_t25Q,29476
38
38
  worker_automate_hub/tasks/jobs/conexao_rdp.py,sha256=S6QC4xhuo0pB5FjaUJZNMm1LIgEjpjifReCTBDqxH-U,11719
39
39
  worker_automate_hub/tasks/jobs/descartes.py,sha256=0bMCJ0xIcK8TLSgjF6taAbGFLMU-sGDVFIhUYSRtrbg,41092
40
- worker_automate_hub/tasks/jobs/devolucao_prazo_a_faturar.py,sha256=Z1udElaYSCcSI20jdEqDnzJ4wR9mrfmfSB_UnQvVAAs,79842
40
+ worker_automate_hub/tasks/jobs/devolucao_prazo_a_faturar.py,sha256=qBA0wBoWKLFmwEs4MGAVNrorAOf7E-Awc-KOUNw7Z9M,81959
41
41
  worker_automate_hub/tasks/jobs/ecac_estadual_go.py,sha256=dKkf22nH5gp3RErq5u0UzRsKyJ81fc6ZZ4vLtUuMwHA,21002
42
42
  worker_automate_hub/tasks/jobs/ecac_estadual_main.py,sha256=8WmKe4-MRtzHobXz2S4YBDNN8alfawkC-BBlRY-mn1g,1726
43
43
  worker_automate_hub/tasks/jobs/ecac_estadual_mt.py,sha256=C26zmpGQGUq6sP9lU9nanM3Fje-rkyx5tjwmRy4lyL8,25300
@@ -76,7 +76,7 @@ worker_automate_hub/utils/updater.py,sha256=en2FCGhI8aZ-JNP3LQm64NJDc4awCNW7UhbV
76
76
  worker_automate_hub/utils/util.py,sha256=_uPyZOzb8puEKXUmcFkaf7HesJBs8yITRQkOqViyugU,161430
77
77
  worker_automate_hub/utils/utils_nfe_entrada.py,sha256=iYpOs7fb7C3bY61QHySr00xlDNzrrCP0zaexOpBPuaQ,31930
78
78
  worker_automate_hub/worker.py,sha256=CT-poyP1ZYvubArYsnnNd9oJ53SPaDwgr6p6keS3nI4,6248
79
- worker_automate_hub-0.5.77.dist-info/entry_points.txt,sha256=sddyhjx57I08RY8X7UxcTpdoOsWULAWNKN9Xr6pp_Kw,54
80
- worker_automate_hub-0.5.77.dist-info/METADATA,sha256=dXFuJQuR7tiU7dZN0E8N0cdarC9Jm21hpt_JJQ1-AnY,2894
81
- worker_automate_hub-0.5.77.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
82
- worker_automate_hub-0.5.77.dist-info/RECORD,,
79
+ worker_automate_hub-0.5.78.dist-info/entry_points.txt,sha256=sddyhjx57I08RY8X7UxcTpdoOsWULAWNKN9Xr6pp_Kw,54
80
+ worker_automate_hub-0.5.78.dist-info/METADATA,sha256=tFCjID-W8QQs__STvRqQ-HR6DV5fAQ6DetJAM8I99qQ,2894
81
+ worker_automate_hub-0.5.78.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
82
+ worker_automate_hub-0.5.78.dist-info/RECORD,,