worker-automate-hub 0.4.414__py3-none-any.whl → 0.4.416__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.
- worker_automate_hub/tasks/jobs/entrada_de_notas_39.py +202 -183
- worker_automate_hub/tasks/jobs/entrada_de_notas_9.py +42 -31
- {worker_automate_hub-0.4.414.dist-info → worker_automate_hub-0.4.416.dist-info}/METADATA +1 -1
- {worker_automate_hub-0.4.414.dist-info → worker_automate_hub-0.4.416.dist-info}/RECORD +6 -6
- {worker_automate_hub-0.4.414.dist-info → worker_automate_hub-0.4.416.dist-info}/WHEEL +0 -0
- {worker_automate_hub-0.4.414.dist-info → worker_automate_hub-0.4.416.dist-info}/entry_points.txt +0 -0
@@ -1,5 +1,6 @@
|
|
1
1
|
import asyncio
|
2
|
-
import
|
2
|
+
import re
|
3
|
+
from datetime import datetime
|
3
4
|
import getpass
|
4
5
|
import os
|
5
6
|
import warnings
|
@@ -196,15 +197,20 @@ async def entrada_de_notas_39(task: RpaProcessoEntradaDTO) -> RpaRetornoProcesso
|
|
196
197
|
console.print('Inserindo a data de emissão da nota')
|
197
198
|
dt_emissao = nota.get("dataEmissao")
|
198
199
|
numero_nota = nota.get("numeroNota")
|
200
|
+
|
201
|
+
try:
|
202
|
+
data_formatada = datetime.fromisoformat(dt_emissao[:-6]).strftime("%d/%m/%Y")
|
203
|
+
except ValueError:
|
204
|
+
data_formatada = dt_emissao
|
199
205
|
|
200
206
|
edit = main_window.child_window(
|
201
207
|
class_name="TDBIEditDate", found_index=0
|
202
208
|
)
|
203
|
-
edit.set_edit_text(
|
209
|
+
edit.set_edit_text(data_formatada)
|
204
210
|
edit = main_window.child_window(
|
205
211
|
class_name="TDBIEditDate", found_index=1
|
206
212
|
)
|
207
|
-
edit.set_edit_text(
|
213
|
+
edit.set_edit_text(data_formatada)
|
208
214
|
|
209
215
|
console.print('Inserindo o numero da nota')
|
210
216
|
edit = main_window.child_window(
|
@@ -322,7 +328,7 @@ async def entrada_de_notas_39(task: RpaProcessoEntradaDTO) -> RpaRetornoProcesso
|
|
322
328
|
)
|
323
329
|
|
324
330
|
|
325
|
-
await worker_sleep(
|
331
|
+
await worker_sleep(10)
|
326
332
|
# VERIFICANDO A EXISTENCIA DE ERRO
|
327
333
|
erro_pop_up = await is_window_open("Erro")
|
328
334
|
if erro_pop_up["IsOpened"] == True:
|
@@ -335,7 +341,6 @@ async def entrada_de_notas_39(task: RpaProcessoEntradaDTO) -> RpaRetornoProcesso
|
|
335
341
|
|
336
342
|
max_attempts = 10
|
337
343
|
i = 0
|
338
|
-
|
339
344
|
while i < max_attempts:
|
340
345
|
information_pop_up = await is_window_open("Informações para importação da Nota Fiscal Eletrônica")
|
341
346
|
if information_pop_up["IsOpened"] == True:
|
@@ -352,7 +357,27 @@ async def entrada_de_notas_39(task: RpaProcessoEntradaDTO) -> RpaRetornoProcesso
|
|
352
357
|
status=RpaHistoricoStatusEnum.Falha,
|
353
358
|
)
|
354
359
|
|
355
|
-
|
360
|
+
|
361
|
+
console.print(
|
362
|
+
f"Marcando Manter calculo PIS/COFINS...\n"
|
363
|
+
)
|
364
|
+
app = Application(backend="uia").connect(title="Informações para importação da Nota Fiscal Eletrônica")
|
365
|
+
main_window = app["Informações para importação da Nota Fiscal Eletrônica"]
|
366
|
+
try:
|
367
|
+
checkbox = main_window.child_window(
|
368
|
+
title="Manter cálculo PIS/COFINS",
|
369
|
+
class_name="TCheckBox",
|
370
|
+
control_type="CheckBox",
|
371
|
+
)
|
372
|
+
except:
|
373
|
+
checkbox = main_window.child_window(
|
374
|
+
title=re.compile(".*PIS/COFINS.*"),
|
375
|
+
class_name="TCheckBox",
|
376
|
+
control_type="CheckBox"
|
377
|
+
)
|
378
|
+
if not checkbox.get_toggle_state() == 1:
|
379
|
+
checkbox.click()
|
380
|
+
console.print("Realizado com sucesso... \n")
|
356
381
|
|
357
382
|
if nota.get("existeDespesa") != "Não":
|
358
383
|
app = Application().connect(
|
@@ -381,10 +406,20 @@ async def entrada_de_notas_39(task: RpaProcessoEntradaDTO) -> RpaRetornoProcesso
|
|
381
406
|
status=RpaHistoricoStatusEnum.Falha,
|
382
407
|
)
|
383
408
|
|
384
|
-
|
385
|
-
|
409
|
+
# INTERAGINDO COM O CAMPO Manter Natureza de Operação selecionada
|
410
|
+
console.print(
|
411
|
+
f"Selecionando a opção 'Manter Natureza de Operação selecionada'...\n"
|
412
|
+
)
|
413
|
+
checkbox = main_window.child_window(
|
414
|
+
title="Manter Natureza de Operação selecionada",
|
415
|
+
class_name="TDBICheckBox",
|
416
|
+
)
|
417
|
+
if not checkbox.get_toggle_state() == 1:
|
418
|
+
checkbox.click()
|
419
|
+
console.print(
|
420
|
+
"A opção 'Manter Natureza de Operação selecionada' selecionado com sucesso... \n"
|
421
|
+
)
|
386
422
|
|
387
|
-
console.print("Clicando em OK... \n")
|
388
423
|
|
389
424
|
max_attempts = 3
|
390
425
|
i = 0
|
@@ -408,52 +443,34 @@ async def entrada_de_notas_39(task: RpaProcessoEntradaDTO) -> RpaRetornoProcesso
|
|
408
443
|
status=RpaHistoricoStatusEnum.Descartado,
|
409
444
|
)
|
410
445
|
|
411
|
-
await worker_sleep(
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
button_yes = window_itens.child_window(title="&Yes")
|
422
|
-
#Clicar em YES (ou sim)
|
423
|
-
button_yes.click()
|
424
|
-
#Aguarda Tela carregar
|
425
|
-
await worker_sleep(5)
|
426
|
-
#Conecta com tela de itens
|
427
|
-
app = Application().connect(title="Incluir Item Fornecedor")
|
428
|
-
window_incluir_itens = app["Incluir Item Fornecedor"]
|
429
|
-
#Garante que a tela esta em foco
|
430
|
-
window_incluir_itens.set_focus()
|
431
|
-
trys = 10
|
432
|
-
await worker_sleep(1)
|
433
|
-
error_itens = []
|
434
|
-
for i in range(trys):
|
435
|
-
pyautogui.hotkey('ctrl', 'c')
|
436
|
-
text_incluir_item_fornecedor = pyperclip.paste()
|
437
|
-
error_itens.append(text_incluir_item_fornecedor)
|
438
|
-
pyautogui.press('down', presses=1)
|
439
|
-
await worker_sleep(1)
|
440
|
-
|
441
|
-
return RpaRetornoProcessoDTO(
|
442
|
-
sucesso=False,
|
443
|
-
retorno=f"Itens nao localizados - \n{text_incluir_item_fornecedor}",
|
444
|
-
status=RpaHistoricoStatusEnum.Falha,
|
445
|
-
)
|
446
|
-
except Exception as e:
|
446
|
+
await worker_sleep(60)
|
447
|
+
console.print(
|
448
|
+
"Verificando a existencia de POP-UP de Itens não localizados ou NCM ...\n"
|
449
|
+
)
|
450
|
+
itens_by_supplier = await is_window_open_by_class("TFrmAguarde", "TMessageForm")
|
451
|
+
if itens_by_supplier["IsOpened"] == True:
|
452
|
+
itens_by_supplier_work = await itens_not_found_supplier(nota.get("nfe"))
|
453
|
+
if itens_by_supplier_work["window"] == "NCM" or itens_by_supplier_work["window"] == "MultiplasRef":
|
454
|
+
console.log(itens_by_supplier_work["retorno"], style="bold green")
|
455
|
+
else:
|
447
456
|
return RpaRetornoProcessoDTO(
|
448
457
|
sucesso=False,
|
449
|
-
retorno=
|
458
|
+
retorno=itens_by_supplier_work["retorno"],
|
450
459
|
status=RpaHistoricoStatusEnum.Falha,
|
451
460
|
)
|
452
461
|
|
453
|
-
await emsys.verify_warning_and_error("Information", "&No")
|
454
|
-
|
455
462
|
await worker_sleep(3)
|
456
463
|
|
464
|
+
# VERIFICANDO A EXISTENCIA DE ERRO
|
465
|
+
erro_pop_up = await is_window_open("Erro")
|
466
|
+
if erro_pop_up["IsOpened"] == True:
|
467
|
+
error_work = await error_after_xml_imported()
|
468
|
+
return RpaRetornoProcessoDTO(
|
469
|
+
sucesso=False,
|
470
|
+
retorno=error_work.retorno,
|
471
|
+
status=RpaHistoricoStatusEnum.Falha,
|
472
|
+
)
|
473
|
+
|
457
474
|
# Seleciona pagamento
|
458
475
|
console.log("Seleciona Pagamento", style="bold yellow")
|
459
476
|
pyautogui.click(623, 374)
|
@@ -465,29 +482,17 @@ async def entrada_de_notas_39(task: RpaProcessoEntradaDTO) -> RpaRetornoProcesso
|
|
465
482
|
pyautogui.hotkey("enter")
|
466
483
|
|
467
484
|
# Digita "Valor"
|
468
|
-
|
469
485
|
pyautogui.click(1285, 352)
|
470
486
|
await worker_sleep(1)
|
471
487
|
pyautogui.hotkey("ctrl", "a")
|
472
488
|
pyautogui.hotkey("del")
|
473
489
|
await worker_sleep(1)
|
474
490
|
pyautogui.write(nota["valorNota"])
|
491
|
+
await worker_sleep(3)
|
475
492
|
|
476
493
|
await emsys.incluir_registro()
|
477
|
-
await worker_sleep(
|
478
|
-
#TODO tratar tela de CFOP da capa
|
479
|
-
console.print(
|
480
|
-
"Verificando a existencia de POP-UP de Itens que Ultrapassam a Variação Máxima de Custo ...\n"
|
481
|
-
)
|
482
|
-
itens_variacao_maxima = await is_window_open_by_class(
|
483
|
-
"TFrmTelaSelecao", "TFrmTelaSelecao"
|
484
|
-
)
|
485
|
-
if itens_variacao_maxima["IsOpened"] == True:
|
486
|
-
app = Application().connect(class_name="TFrmTelaSelecao")
|
487
|
-
main_window = app["TFrmTelaSelecao"]
|
488
|
-
send_keys("%o")
|
494
|
+
await worker_sleep(10)
|
489
495
|
|
490
|
-
await worker_sleep(3)
|
491
496
|
console.print(
|
492
497
|
"Verificando a existencia de POP-UP de Itens que Ultrapassam a Variação Máxima de Custo ...\n"
|
493
498
|
)
|
@@ -499,36 +504,100 @@ async def entrada_de_notas_39(task: RpaProcessoEntradaDTO) -> RpaRetornoProcesso
|
|
499
504
|
main_window = app["TFrmTelaSelecao"]
|
500
505
|
send_keys("%o")
|
501
506
|
|
502
|
-
await worker_sleep(3)
|
503
507
|
|
504
|
-
await
|
508
|
+
await worker_sleep(5)
|
509
|
+
aviso_pop_up = await is_window_open("Aviso")
|
510
|
+
if aviso_pop_up["IsOpened"] == True:
|
511
|
+
await emsys.verify_warning_and_error("Aviso", "OK")
|
512
|
+
try:
|
513
|
+
pyautogui.click(623, 374)
|
514
|
+
await worker_sleep(1)
|
515
|
+
pyautogui.press('home')
|
516
|
+
console.print("Alterando a NOP...\n")
|
505
517
|
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
app = Application().connect(class_name="TFrmNotaFiscalEntrada")
|
510
|
-
main_window = app["TFrmNotaFiscalEntrada"]
|
518
|
+
app = Application().connect(class_name="TFrmNotaFiscalEntrada", timeout=30)
|
519
|
+
main_window = app["TFrmNotaFiscalEntrada"]
|
520
|
+
main_window.set_focus()
|
511
521
|
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
522
|
+
select_box_nop_select = main_window.child_window(class_name="TDBIComboBox", found_index=0)
|
523
|
+
select_box_nop_select.click()
|
524
|
+
nop_value = "1152 - ENTRADAS P/ TRANSFERENCIAS DE MERCADORIA- 1.152"
|
525
|
+
await worker_sleep(2)
|
526
|
+
set_combobox("||List", nop_value)
|
527
|
+
await worker_sleep(1)
|
528
|
+
pyautogui.press('down')
|
518
529
|
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
530
|
+
nop_selected = select_box_nop_select.window_text()
|
531
|
+
if '1152' in nop_selected:
|
532
|
+
console.print(f"NOP selecionada corretamente, {nop_selected} ...\n")
|
533
|
+
else:
|
534
|
+
select_box_nop_select.click()
|
535
|
+
console.print(f"Inserindo a informação da NOP: {nop_value} ...\n")
|
536
|
+
await worker_sleep(2)
|
537
|
+
set_combobox("||List", nop_value)
|
538
|
+
await worker_sleep(2)
|
539
|
+
pyautogui.hotkey("enter")
|
540
|
+
await worker_sleep(2)
|
541
|
+
console.print(f"Confirmando a NOP selecionada...\n")
|
542
|
+
main_window.set_focus()
|
543
|
+
await worker_sleep(1)
|
544
|
+
select_box_nop_select = main_window.child_window(class_name="TDBIComboBox", found_index=0)
|
545
|
+
nop_selected = select_box_nop_select.window_text()
|
546
|
+
if '1152' in nop_selected:
|
547
|
+
console.print(f"NOP selecionada corretamente, {nop_selected} ...\n")
|
548
|
+
else:
|
549
|
+
return RpaRetornoProcessoDTO(
|
550
|
+
sucesso=False,
|
551
|
+
retorno=f"Erro não foi possivel selecionar NOP correta, NOP selecionada: {nop_selected}",
|
552
|
+
status=RpaHistoricoStatusEnum.Falha,
|
553
|
+
)
|
554
|
+
|
555
|
+
await emsys.incluir_registro()
|
556
|
+
await worker_sleep(10)
|
557
|
+
|
558
|
+
console.print("Verificando a existencia de POP-UP de Itens que Ultrapassam a Variação Máxima de Custo ...\n")
|
559
|
+
itens_variacao_maxima = await is_window_open_by_class("TFrmTelaSelecao", "TFrmTelaSelecao")
|
560
|
+
if itens_variacao_maxima["IsOpened"] == True:
|
561
|
+
app = Application().connect(class_name="TFrmTelaSelecao")
|
562
|
+
main_window = app["TFrmTelaSelecao"]
|
563
|
+
send_keys("%o")
|
564
|
+
await worker_sleep(3)
|
565
|
+
|
566
|
+
aviso_pop_up = await is_window_open("Aviso")
|
567
|
+
if aviso_pop_up["IsOpened"] == True:
|
568
|
+
return RpaRetornoProcessoDTO(
|
569
|
+
sucesso=False,
|
570
|
+
retorno=f"Erro na validação de CFOP, foi encontrado mais de uma opção com a mesma informação",
|
571
|
+
status=RpaHistoricoStatusEnum.Falha,
|
572
|
+
)
|
573
|
+
|
574
|
+
console.print("Verificando a existencia de Warning informando que a Soma dos pagamentos não bate com o valor da nota. ...\n")
|
575
|
+
warning_pop_up_pagamentos = await is_window_open("Warning")
|
576
|
+
if warning_pop_up_pagamentos["IsOpened"] == True:
|
577
|
+
return RpaRetornoProcessoDTO(
|
578
|
+
sucesso=False,
|
579
|
+
retorno=f"A soma dos pagamentos não bate com o valor da nota.",
|
580
|
+
status=RpaHistoricoStatusEnum.Falha,
|
581
|
+
)
|
582
|
+
|
583
|
+
await worker_sleep(60)
|
584
|
+
console.print("\nVerifica se a nota ja foi lançada...")
|
585
|
+
nf_chave_acesso = int(nota.get("nfe"))
|
586
|
+
status_nf_emsys = await get_status_nf_emsys(nf_chave_acesso)
|
587
|
+
if status_nf_emsys.get("status") == "Lançada":
|
588
|
+
return RpaRetornoProcessoDTO(
|
589
|
+
sucesso=True,
|
590
|
+
retorno="Nota Lançada com sucesso!",
|
591
|
+
status=RpaHistoricoStatusEnum.Sucesso,
|
592
|
+
)
|
593
|
+
|
594
|
+
except Exception as e:
|
595
|
+
select_box_nop_select.click()
|
596
|
+
return RpaRetornoProcessoDTO(
|
597
|
+
sucesso=False,
|
598
|
+
retorno=f"Erro ao alterar o NOP, erro {e}",
|
599
|
+
status=RpaHistoricoStatusEnum.Falha,
|
600
|
+
)
|
532
601
|
|
533
602
|
try:
|
534
603
|
max_attempts = 7
|
@@ -562,6 +631,7 @@ async def entrada_de_notas_39(task: RpaProcessoEntradaDTO) -> RpaRetornoProcesso
|
|
562
631
|
console.log(despesa_rateio_work.retorno, style="bold green")
|
563
632
|
await emsys.verify_warning_and_error("Information", "OK")
|
564
633
|
await emsys.verify_warning_and_error("Informação", "OK")
|
634
|
+
await worker_sleep(15)
|
565
635
|
else:
|
566
636
|
return RpaRetornoProcessoDTO(
|
567
637
|
sucesso=False,
|
@@ -569,10 +639,14 @@ async def entrada_de_notas_39(task: RpaProcessoEntradaDTO) -> RpaRetornoProcesso
|
|
569
639
|
status=RpaHistoricoStatusEnum.Falha,
|
570
640
|
)
|
571
641
|
except Exception as error:
|
572
|
-
console.print("Falha ao realizar rateio {error}")
|
642
|
+
console.print(f"Falha ao realizar rateio {error}")
|
643
|
+
return RpaRetornoProcessoDTO(
|
644
|
+
sucesso=False,
|
645
|
+
retorno=f"Falha ao realizar rateio {error}",
|
646
|
+
status=RpaHistoricoStatusEnum.Falha,
|
647
|
+
)
|
648
|
+
|
573
649
|
|
574
|
-
# Verifica se a info 'Nota fiscal incluida' está na tela
|
575
|
-
await worker_sleep(15)
|
576
650
|
warning_pop_up = await is_window_open("Warning")
|
577
651
|
if warning_pop_up["IsOpened"] == True:
|
578
652
|
app = Application().connect(title="Warning")
|
@@ -624,103 +698,48 @@ async def entrada_de_notas_39(task: RpaProcessoEntradaDTO) -> RpaRetornoProcesso
|
|
624
698
|
status=RpaHistoricoStatusEnum.Falha,
|
625
699
|
)
|
626
700
|
|
627
|
-
await emsys.verify_warning_and_error("Aviso", "OK")
|
628
|
-
|
629
|
-
await worker_sleep(3)
|
630
|
-
|
631
|
-
#Alterar NOP
|
632
|
-
try:
|
633
|
-
pyautogui.click(623, 374)
|
634
|
-
await worker_sleep(1)
|
635
|
-
pyautogui.press('home')
|
636
|
-
console.print("Alterando a NOP...\n")
|
637
|
-
|
638
|
-
app = Application().connect(class_name="TFrmNotaFiscalEntrada", timeout=30)
|
639
|
-
main_window = app["TFrmNotaFiscalEntrada"]
|
640
|
-
main_window.set_focus()
|
641
|
-
|
642
|
-
select_box_nop_select = main_window.child_window(class_name="TDBIComboBox", found_index=0)
|
643
|
-
select_box_nop_select.click()
|
644
|
-
nop_value = "1152 - ENTRADAS P/ TRANSFERENCIAS DE MERCADORIA- 1.152"
|
645
|
-
await worker_sleep(2)
|
646
|
-
set_combobox("||List", nop_value)
|
647
|
-
await worker_sleep(1)
|
648
|
-
pyautogui.press('down')
|
649
701
|
|
650
|
-
|
651
|
-
|
652
|
-
|
702
|
+
console.print(
|
703
|
+
"Verificando a existencia de POP-UP de Itens que Ultrapassam a Variação Máxima de Custo ...\n"
|
704
|
+
)
|
705
|
+
itens_variacao_maxima = await is_window_open_by_class(
|
706
|
+
"TFrmTelaSelecao", "TFrmTelaSelecao"
|
707
|
+
)
|
708
|
+
if itens_variacao_maxima["IsOpened"] == True:
|
709
|
+
app = Application().connect(class_name="TFrmTelaSelecao")
|
710
|
+
main_window = app["TFrmTelaSelecao"]
|
711
|
+
send_keys("%o")
|
712
|
+
await worker_sleep(3)
|
713
|
+
|
714
|
+
max_attempts = 50
|
715
|
+
i = 0
|
716
|
+
while i < max_attempts:
|
717
|
+
information_pop_up = await is_window_open("Information")
|
718
|
+
if information_pop_up["IsOpened"] == True:
|
719
|
+
break
|
653
720
|
else:
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
console.print(f"NOP selecionada corretamente, {nop_selected} ...\n")
|
668
|
-
else:
|
669
|
-
return RpaRetornoProcessoDTO(
|
670
|
-
sucesso=False,
|
671
|
-
retorno=f"Erro não foi possivel selecionar NOP correta, NOP selecionada: {nop_selected}",
|
672
|
-
status=RpaHistoricoStatusEnum.Falha,
|
673
|
-
)
|
674
|
-
console.print(f"Clicando para incluir a nota...\n")
|
675
|
-
pyautogui.click(593, 297)
|
676
|
-
await worker_sleep(15)
|
677
|
-
console.print(
|
678
|
-
"Verificando a existencia de POP-UP de Itens que Ultrapassam a Variação Máxima de Custo ...\n"
|
679
|
-
)
|
680
|
-
itens_variacao_maxima = await is_window_open_by_class(
|
681
|
-
"TFrmTelaSelecao", "TFrmTelaSelecao"
|
721
|
+
console.print(f"Aguardando confirmação de nota incluida...\n")
|
722
|
+
await worker_sleep(4)
|
723
|
+
i += 1
|
724
|
+
|
725
|
+
await worker_sleep(15)
|
726
|
+
console.print("\nVerifica se a nota ja foi lançada...")
|
727
|
+
nf_chave_acesso = int(nota.get("nfe"))
|
728
|
+
status_nf_emsys = await get_status_nf_emsys(nf_chave_acesso)
|
729
|
+
if status_nf_emsys.get("status") != "Lançada":
|
730
|
+
return RpaRetornoProcessoDTO(
|
731
|
+
sucesso=False,
|
732
|
+
retorno=f"Erro ao lançar nota",
|
733
|
+
status=RpaHistoricoStatusEnum.Falha,
|
682
734
|
)
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
max_attempts = 50
|
690
|
-
i = 0
|
735
|
+
else:
|
736
|
+
return RpaRetornoProcessoDTO(
|
737
|
+
sucesso=True,
|
738
|
+
retorno="Nota Lançada com sucesso!",
|
739
|
+
status=RpaHistoricoStatusEnum.Sucesso,
|
740
|
+
)
|
691
741
|
|
692
|
-
while i < max_attempts:
|
693
|
-
information_pop_up = await is_window_open("Information")
|
694
|
-
if information_pop_up["IsOpened"] == True:
|
695
|
-
break
|
696
|
-
else:
|
697
|
-
console.print(f"Aguardando confirmação de nota incluida...\n")
|
698
|
-
await worker_sleep(4)
|
699
|
-
i += 1
|
700
|
-
|
701
|
-
await worker_sleep(15)
|
702
|
-
console.print("\nVerifica se a nota ja foi lançada...")
|
703
|
-
nf_chave_acesso = int(nota.get("nfe"))
|
704
|
-
status_nf_emsys = await get_status_nf_emsys(nf_chave_acesso)
|
705
|
-
if status_nf_emsys.get("status") != "Lançada":
|
706
|
-
return RpaRetornoProcessoDTO(
|
707
|
-
sucesso=False,
|
708
|
-
retorno=f"Erro na validação de CFOP, foi encontrado mais de uma opção com a mesma informação",
|
709
|
-
status=RpaHistoricoStatusEnum.Falha,
|
710
|
-
)
|
711
|
-
else:
|
712
|
-
return RpaRetornoProcessoDTO(
|
713
|
-
sucesso=True,
|
714
|
-
retorno="Nota Lançada com sucesso!",
|
715
|
-
status=RpaHistoricoStatusEnum.Sucesso,
|
716
|
-
)
|
717
742
|
|
718
|
-
except Exception as e:
|
719
|
-
return RpaRetornoProcessoDTO(
|
720
|
-
sucesso=False,
|
721
|
-
retorno=f"Erro ao alterar o NOP, erro {e}",
|
722
|
-
status=RpaHistoricoStatusEnum.Falha,
|
723
|
-
)
|
724
743
|
except Exception as ex:
|
725
744
|
observacao = f"Erro Processo Entrada de Notas: {str(ex)}"
|
726
745
|
logger.error(observacao)
|
@@ -7,7 +7,7 @@ import pyautogui
|
|
7
7
|
import pytesseract
|
8
8
|
from datetime import datetime, timedelta
|
9
9
|
from pywinauto.application import Application
|
10
|
-
from PIL import Image, ImageEnhance
|
10
|
+
from PIL import Image, ImageEnhance, ImageFilter
|
11
11
|
from pywinauto.keyboard import send_keys
|
12
12
|
import win32clipboard
|
13
13
|
from pywinauto_recorder.player import set_combobox
|
@@ -461,39 +461,50 @@ async def entrada_de_notas_9(task: RpaProcessoEntradaDTO) -> RpaRetornoProcessoD
|
|
461
461
|
if distribuiu_algo:
|
462
462
|
console.print(f"Extraindo informação da Janela de Distribuir Itens para realização do OCR...\n")
|
463
463
|
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
464
|
+
max_attempts = 3
|
465
|
+
attempts = 0
|
466
|
+
resultado = None
|
467
|
+
while attempts < max_attempts:
|
468
|
+
main_window.set_focus()
|
469
|
+
window_rect = main_window.rectangle()
|
470
|
+
screenshot = pyautogui.screenshot(
|
471
|
+
region=(
|
472
|
+
window_rect.left,
|
473
|
+
window_rect.top,
|
474
|
+
window_rect.width(),
|
475
|
+
window_rect.height(),
|
476
|
+
)
|
472
477
|
)
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
console.print(f"Print salvo em {path_to_png}...\n")
|
478
|
+
username = getpass.getuser()
|
479
|
+
path_to_png = f"C:\\Users\\{username}\\Downloads\\distribuir_iten_{nota.get("nfe")}.png"
|
480
|
+
screenshot.save(path_to_png)
|
481
|
+
console.print(f"Print salvo em {path_to_png}...\n")
|
478
482
|
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
483
|
+
console.print(
|
484
|
+
f"Preparando a imagem para maior resolução e assertividade no OCR...\n"
|
485
|
+
)
|
486
|
+
image = Image.open(path_to_png)
|
487
|
+
image = image.filter(ImageFilter.SHARPEN)
|
488
|
+
image = image.convert("L")
|
489
|
+
enhancer = ImageEnhance.Contrast(image)
|
490
|
+
image = enhancer.enhance(2.0)
|
491
|
+
image.save(path_to_png)
|
492
|
+
console.print(f"Imagem preparada com sucesso...\n")
|
493
|
+
console.print(f"Realizando OCR...\n")
|
494
|
+
await worker_sleep(1)
|
495
|
+
captured_text = pytesseract.image_to_string(Image.open(path_to_png))
|
496
|
+
console.print(
|
497
|
+
f"Texto Full capturado {captured_text}...\n"
|
498
|
+
)
|
499
|
+
os.remove(path_to_png)
|
494
500
|
|
495
|
-
|
496
|
-
|
501
|
+
pattern_qtd_restante = r"Quantidade restante:\s([\d,]+)"
|
502
|
+
resultado = re.search(pattern_qtd_restante, captured_text)
|
503
|
+
if resultado:
|
504
|
+
break
|
505
|
+
else:
|
506
|
+
await worker_sleep(2)
|
507
|
+
attempts += 1
|
497
508
|
|
498
509
|
try:
|
499
510
|
if resultado:
|
@@ -44,11 +44,11 @@ worker_automate_hub/tasks/jobs/entrada_de_notas_32.py,sha256=0cneKY6bQU5neo3TKlG
|
|
44
44
|
worker_automate_hub/tasks/jobs/entrada_de_notas_33.py,sha256=ktXc_kdMhlz9cbb7XjfMJhME29mgMFd_FnatxSZZU_s,31457
|
45
45
|
worker_automate_hub/tasks/jobs/entrada_de_notas_34.py,sha256=iaSmtWTWlazHDtGp22yTV5J5rHDhUCbEaCAnpU7UWyM,31808
|
46
46
|
worker_automate_hub/tasks/jobs/entrada_de_notas_36.py,sha256=vFkDcgJ9uxrMMLYdeONCMxh6_evnhgF1Sun5HEHAWa4,22716
|
47
|
-
worker_automate_hub/tasks/jobs/entrada_de_notas_39.py,sha256=
|
47
|
+
worker_automate_hub/tasks/jobs/entrada_de_notas_39.py,sha256=j_QE5v4t_D6jKWWaeSCCmIelPWc5vjGbC_gb13ovwLg,32579
|
48
48
|
worker_automate_hub/tasks/jobs/entrada_de_notas_500.py,sha256=ryl5AZ2617aROSVcS-N5wQIBlFQ1Bp0khUH9fP4DOzU,26542
|
49
49
|
worker_automate_hub/tasks/jobs/entrada_de_notas_505.py,sha256=jIml8gjXPdI6_x7S9VVV8IrKZRF7_PTNOMnhNmYMDTU,14490
|
50
50
|
worker_automate_hub/tasks/jobs/entrada_de_notas_7139.py,sha256=8XP9G3n0PUeshbRWkWKOMnyUGRWspIolPZVqQTR3SMI,14184
|
51
|
-
worker_automate_hub/tasks/jobs/entrada_de_notas_9.py,sha256=
|
51
|
+
worker_automate_hub/tasks/jobs/entrada_de_notas_9.py,sha256=DBzP8O-m7OvuBOmWGfmC7JwCQ29IkKFAWD6JnJI7BLE,48452
|
52
52
|
worker_automate_hub/tasks/jobs/exemplo_processo.py,sha256=3-zxbb-9YHPmSA_K1Qgxp_FwSqg2QDjGBRCLxDZ8QoQ,3451
|
53
53
|
worker_automate_hub/tasks/jobs/fidc_gerar_nosso_numero.py,sha256=iXIKBMNFPj3L6G5Iq5nyDKiZT3NAP5sIhRSzYdURpNw,9571
|
54
54
|
worker_automate_hub/tasks/jobs/fidc_remessa_cobranca_cnab240.py,sha256=QBGm6eS5JghgNWNqZlk1g2a2iV8LnBLiOTBBL3Giet0,4181
|
@@ -67,7 +67,7 @@ worker_automate_hub/utils/updater.py,sha256=en2FCGhI8aZ-JNP3LQm64NJDc4awCNW7UhbV
|
|
67
67
|
worker_automate_hub/utils/util.py,sha256=YQkdPMCgrwuCJG_069p1cIG7xTg8VgvSHlGnIQrlyHo,119625
|
68
68
|
worker_automate_hub/utils/utils_nfe_entrada.py,sha256=yQFyDzvXPSO-UYV1m38WLJ3AWQgZYcyUkHZdCKE1jG4,28360
|
69
69
|
worker_automate_hub/worker.py,sha256=KDBU3L2kVobndrnN5coRZFTwVmBLKmPJjRv20sCo5Hc,4697
|
70
|
-
worker_automate_hub-0.4.
|
71
|
-
worker_automate_hub-0.4.
|
72
|
-
worker_automate_hub-0.4.
|
73
|
-
worker_automate_hub-0.4.
|
70
|
+
worker_automate_hub-0.4.416.dist-info/entry_points.txt,sha256=sddyhjx57I08RY8X7UxcTpdoOsWULAWNKN9Xr6pp_Kw,54
|
71
|
+
worker_automate_hub-0.4.416.dist-info/METADATA,sha256=NENRDzoGSGgIAUcTWYNw0TlBANB-uL7FrW5a96ZyZRU,2895
|
72
|
+
worker_automate_hub-0.4.416.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
73
|
+
worker_automate_hub-0.4.416.dist-info/RECORD,,
|
File without changes
|
{worker_automate_hub-0.4.414.dist-info → worker_automate_hub-0.4.416.dist-info}/entry_points.txt
RENAMED
File without changes
|