worker-automate-hub 0.5.455__py3-none-any.whl → 0.5.456__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/devolucao_ctf.py +1218 -1219
- {worker_automate_hub-0.5.455.dist-info → worker_automate_hub-0.5.456.dist-info}/METADATA +1 -1
- {worker_automate_hub-0.5.455.dist-info → worker_automate_hub-0.5.456.dist-info}/RECORD +5 -5
- {worker_automate_hub-0.5.455.dist-info → worker_automate_hub-0.5.456.dist-info}/WHEEL +0 -0
- {worker_automate_hub-0.5.455.dist-info → worker_automate_hub-0.5.456.dist-info}/entry_points.txt +0 -0
@@ -1160,7 +1160,7 @@ async def devolucao_ctf(task: RpaProcessoEntradaDTO) -> RpaRetornoProcessoDTO:
|
|
1160
1160
|
#STEP 4
|
1161
1161
|
#PRE VENDA
|
1162
1162
|
itens_nota_separada = []
|
1163
|
-
itens_nota_conjunta = []
|
1163
|
+
itens_nota_conjunta = []
|
1164
1164
|
for item in nota.get('itens'):
|
1165
1165
|
if item['notaSeparada']:
|
1166
1166
|
itens_nota_separada.append(item)
|
@@ -2449,417 +2449,299 @@ async def devolucao_ctf(task: RpaProcessoEntradaDTO) -> RpaRetornoProcessoDTO:
|
|
2449
2449
|
|
2450
2450
|
|
2451
2451
|
if len(itens_nota_conjunta) > 0:
|
2452
|
-
console.print(
|
2453
|
-
|
2454
|
-
|
2455
|
-
|
2456
|
-
|
2457
|
-
|
2458
|
-
|
2459
|
-
|
2460
|
-
|
2461
|
-
|
2462
|
-
|
2452
|
+
console.print(itens_nota_conjunta)
|
2453
|
+
type_text_into_field("Cadastro Pré venda", app["TFrmMenuPrincipal"]["Edit"], True, "50")
|
2454
|
+
pyautogui.press("enter")
|
2455
|
+
await worker_sleep(2)
|
2456
|
+
pyautogui.press("enter")
|
2457
|
+
await worker_sleep(4)
|
2458
|
+
console.print(f"\nPesquisa: 'Cadastro Pré venda' realizada com sucesso",style="bold green")
|
2459
|
+
cadastro_pre_venda = await is_window_open_by_class("TFrmPreVenda", "TFrmPreVenda")
|
2460
|
+
preenchimento_header_pre_venda = await cadastro_pre_venda_header("5667 - VENDA DE COMB OU LUBRI - SEM ESTOQ E COM FINANC", cod_cliente_correto, "A VISTA", "5656 - VENDA DE COMB OU LUB ADQ DE TERCEIRO C/ FIN S/ ESTOQUE")
|
2461
|
+
|
2462
|
+
if preenchimento_header_pre_venda.sucesso:
|
2463
|
+
try:
|
2464
|
+
cidade_cliente = preenchimento_header_pre_venda.retorno
|
2465
|
+
console.print(f"\nPreenchimento cabeçalho da pre venda preenchido com sucesso, seguindo com o processo.. ",style="bold green")
|
2466
|
+
app = Application().connect(class_name="TFrmPreVenda", timeout=60)
|
2467
|
+
main_window = app["TFrmPreVenda"]
|
2468
|
+
main_window.set_focus()
|
2469
|
+
|
2470
|
+
console.print("Navegando nos elementos...\n")
|
2471
|
+
panel_TPage= main_window.child_window(class_name="TPage", found_index=0)
|
2472
|
+
panel_menu_itens= main_window.child_window(class_name="TcxCustomInnerTreeView", found_index=0)
|
2473
|
+
|
2474
|
+
console.print("Acessando a janela de Itens...\n")
|
2475
|
+
panel_menu_itens.click()
|
2476
|
+
await worker_sleep(1)
|
2477
|
+
pyautogui.press('home')
|
2478
|
+
await worker_sleep(1)
|
2479
|
+
pyautogui.press('down')
|
2480
|
+
#console.print(nota.get('itens'))
|
2481
|
+
item_devolvido = ''
|
2482
|
+
|
2483
|
+
#FOR ITENS ENTRADA BACKOFFICE - Nota Conjunta
|
2484
|
+
for item in itens_nota_conjunta:
|
2485
|
+
quantidade = item['novaQuantidade']
|
2486
|
+
preco = item['novoPreco']
|
2487
|
+
descricao = item['descricao']
|
2488
|
+
descricao = 'Diesel Comum' if descricao == 'Diesel S500' else descricao
|
2489
|
+
quantidade = str(quantidade)
|
2490
|
+
preco = str(preco)
|
2491
|
+
#descricao = descricao.replace(".",",")
|
2492
|
+
console.print(quantidade, preco, descricao)
|
2493
|
+
item_devolvido = descricao
|
2494
|
+
|
2495
|
+
if 'arla' in descricao.lower():
|
2496
|
+
item_arla = True
|
2463
2497
|
|
2464
|
-
if preenchimento_header_pre_venda.sucesso:
|
2465
|
-
try:
|
2466
|
-
cidade_cliente = preenchimento_header_pre_venda.retorno
|
2467
|
-
console.print(f"\nPreenchimento cabeçalho da pre venda preenchido com sucesso, seguindo com o processo.. ",style="bold green")
|
2468
2498
|
app = Application().connect(class_name="TFrmPreVenda", timeout=60)
|
2469
2499
|
main_window = app["TFrmPreVenda"]
|
2470
2500
|
main_window.set_focus()
|
2471
2501
|
|
2472
|
-
console.print("
|
2473
|
-
|
2474
|
-
|
2475
|
-
|
2476
|
-
|
2477
|
-
|
2478
|
-
await worker_sleep(1)
|
2479
|
-
pyautogui.press('home')
|
2480
|
-
await worker_sleep(1)
|
2481
|
-
pyautogui.press('down')
|
2482
|
-
#console.print(nota.get('itens'))
|
2483
|
-
item_devolvido = ''
|
2484
|
-
|
2485
|
-
#FOR ITENS ENTRADA BACKOFFICE - Nota Conjunta
|
2486
|
-
for item in itens_nota_conjunta:
|
2487
|
-
quantidade = item['novaQuantidade']
|
2488
|
-
preco = item['novoPreco']
|
2489
|
-
descricao = item['descricao']
|
2490
|
-
descricao = 'Diesel Comum' if descricao == 'Diesel S500' else descricao
|
2491
|
-
quantidade = str(quantidade)
|
2492
|
-
preco = str(preco)
|
2493
|
-
#descricao = descricao.replace(".",",")
|
2494
|
-
console.print(quantidade, preco, descricao)
|
2495
|
-
item_devolvido = descricao
|
2496
|
-
|
2497
|
-
if 'arla' in descricao.lower():
|
2498
|
-
item_arla = True
|
2499
|
-
|
2500
|
-
app = Application().connect(class_name="TFrmPreVenda", timeout=60)
|
2501
|
-
main_window = app["TFrmPreVenda"]
|
2502
|
-
main_window.set_focus()
|
2503
|
-
|
2504
|
-
console.print("Itens acessado com sucesso, clicando em Incluir...\n")
|
2505
|
-
panel_TGroup_Box= panel_TPage.child_window(class_name="TGroupBox", found_index=0)
|
2506
|
-
btn_incluir = panel_TGroup_Box.child_window(class_name="TDBIBitBtn", found_index=4)
|
2507
|
-
btn_incluir.click()
|
2508
|
-
await worker_sleep(2)
|
2509
|
-
console.print("Incluir clicado com sucesso...\n")
|
2510
|
-
|
2511
|
-
#VERIFICANDO A EXISTENCIA DE WARNINGS
|
2512
|
-
console.print("Verificando a existência de Warning... \n")
|
2513
|
-
warning_pop_up = await is_window_open("Warning")
|
2514
|
-
if warning_pop_up["IsOpened"] == True:
|
2515
|
-
console.print("possui Pop-up de Warning, analisando... \n")
|
2516
|
-
ocr_pop_warning = await ocr_warnings(numero_cupom_fiscal)
|
2517
|
-
if ocr_pop_warning.sucesso == True:
|
2518
|
-
return RpaRetornoProcessoDTO(
|
2519
|
-
sucesso=False,
|
2520
|
-
retorno=f"POP UP Warning não mapeado para seguimento do processo, mensagem: {ocr_pop_warning.retorno}",
|
2521
|
-
status=RpaHistoricoStatusEnum.Falha,
|
2522
|
-
tags=[RpaTagDTO(descricao=RpaTagEnum.Negocio)]
|
2523
|
-
)
|
2524
|
-
else:
|
2525
|
-
return RpaRetornoProcessoDTO(
|
2526
|
-
sucesso=False,
|
2527
|
-
retorno=f"POP UP Warning não mapeado para seguimento do processo",
|
2528
|
-
status=RpaHistoricoStatusEnum.Falha,
|
2529
|
-
tags=[RpaTagDTO(descricao=RpaTagEnum.Negocio)]
|
2530
|
-
)
|
2531
|
-
|
2532
|
-
|
2533
|
-
i = 0
|
2534
|
-
while i < 7:
|
2535
|
-
try:
|
2536
|
-
console.print("Clicando sobre a lupa para inserir o almoxarifado...\n")
|
2537
|
-
app = Application().connect(class_name="TFrmIncluiItemPreVenda", timeout=130)
|
2538
|
-
main_window = app["TFrmIncluiItemPreVenda"]
|
2539
|
-
main_window.set_focus()
|
2540
|
-
panel_TGroup_Box= main_window.child_window(class_name="TPanel", found_index=2)
|
2541
|
-
lupa_almoxarifaco = panel_TGroup_Box.child_window(class_name="TDBIBitBtn", found_index=1)
|
2542
|
-
lupa_almoxarifaco.click()
|
2543
|
-
console.print("Lupa clicado com sucesso inserindo a descrição do almoxarifado...\n")
|
2544
|
-
await worker_sleep(2)
|
2545
|
-
|
2546
|
-
dialog_buscar = await is_window_open_by_class("TfrmDialogBuscaGeral", "TfrmDialogBuscaGeral")
|
2547
|
-
if dialog_buscar["IsOpened"] == True:
|
2548
|
-
break
|
2549
|
-
else:
|
2550
|
-
console.print("Não foi possivel abrir a janela de Busca Geral")
|
2551
|
-
i = i+1
|
2552
|
-
except Exception as e:
|
2553
|
-
console.print(f"Erro ao abrir a janela de Busca Geral: {e}")
|
2554
|
-
i = i+1
|
2502
|
+
console.print("Itens acessado com sucesso, clicando em Incluir...\n")
|
2503
|
+
panel_TGroup_Box= panel_TPage.child_window(class_name="TGroupBox", found_index=0)
|
2504
|
+
btn_incluir = panel_TGroup_Box.child_window(class_name="TDBIBitBtn", found_index=4)
|
2505
|
+
btn_incluir.click()
|
2506
|
+
await worker_sleep(2)
|
2507
|
+
console.print("Incluir clicado com sucesso...\n")
|
2555
2508
|
|
2556
|
-
|
2557
|
-
|
2558
|
-
|
2509
|
+
#VERIFICANDO A EXISTENCIA DE WARNINGS
|
2510
|
+
console.print("Verificando a existência de Warning... \n")
|
2511
|
+
warning_pop_up = await is_window_open("Warning")
|
2512
|
+
if warning_pop_up["IsOpened"] == True:
|
2513
|
+
console.print("possui Pop-up de Warning, analisando... \n")
|
2514
|
+
ocr_pop_warning = await ocr_warnings(numero_cupom_fiscal)
|
2515
|
+
if ocr_pop_warning.sucesso == True:
|
2559
2516
|
return RpaRetornoProcessoDTO(
|
2560
2517
|
sucesso=False,
|
2561
|
-
retorno=retorno,
|
2518
|
+
retorno=f"POP UP Warning não mapeado para seguimento do processo, mensagem: {ocr_pop_warning.retorno}",
|
2519
|
+
status=RpaHistoricoStatusEnum.Falha,
|
2520
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Negocio)]
|
2521
|
+
)
|
2522
|
+
else:
|
2523
|
+
return RpaRetornoProcessoDTO(
|
2524
|
+
sucesso=False,
|
2525
|
+
retorno=f"POP UP Warning não mapeado para seguimento do processo",
|
2562
2526
|
status=RpaHistoricoStatusEnum.Falha,
|
2563
2527
|
tags=[RpaTagDTO(descricao=RpaTagEnum.Negocio)]
|
2564
2528
|
)
|
2565
2529
|
|
2566
|
-
app = Application().connect(class_name="TfrmDialogBuscaGeral", timeout=60)
|
2567
|
-
main_window = app["TfrmDialogBuscaGeral"]
|
2568
|
-
main_window.set_focus()
|
2569
|
-
|
2570
|
-
console.print("Buscando a mercadoria baseado na descrição...\n")
|
2571
|
-
rect = main_window.rectangle()
|
2572
|
-
center_x = (rect.left + rect.right) // 2
|
2573
|
-
center_y = (rect.top + rect.bottom) // 2
|
2574
|
-
|
2575
|
-
#pyautogui.moveTo(center_x, center_y)
|
2576
|
-
await worker_sleep(1)
|
2577
|
-
pyautogui.click(center_x, center_y)
|
2578
|
-
await worker_sleep(1)
|
2579
|
-
send_keys("^({HOME})")
|
2580
|
-
item_arla_founded = False
|
2581
|
-
|
2582
|
-
last_line = ''
|
2583
|
-
max_attempts = 12
|
2584
|
-
attempts = 0
|
2585
|
-
|
2586
|
-
while attempts < max_attempts:
|
2587
|
-
with pyautogui.hold('ctrl'):
|
2588
|
-
pyautogui.press('c')
|
2589
|
-
await worker_sleep(1)
|
2590
|
-
with pyautogui.hold('ctrl'):
|
2591
|
-
pyautogui.press('c')
|
2592
|
-
|
2593
|
-
win32clipboard.OpenClipboard()
|
2594
|
-
descricao_item = win32clipboard.GetClipboardData().strip()
|
2595
|
-
win32clipboard.CloseClipboard()
|
2596
|
-
|
2597
|
-
if last_line == descricao_item:
|
2598
|
-
if item_arla:
|
2599
|
-
main_window.set_focus()
|
2600
|
-
send_keys("%r")
|
2601
|
-
await worker_sleep(1)
|
2602
2530
|
|
2603
|
-
|
2604
|
-
|
2605
|
-
|
2606
|
-
|
2607
|
-
|
2608
|
-
|
2609
|
-
|
2610
|
-
|
2611
|
-
|
2612
|
-
|
2613
|
-
|
2614
|
-
|
2615
|
-
pyautogui.write(str(cod_almoxarificado))
|
2616
|
-
pyautogui.press('tab')
|
2617
|
-
await worker_sleep(1)
|
2531
|
+
i = 0
|
2532
|
+
while i < 7:
|
2533
|
+
try:
|
2534
|
+
console.print("Clicando sobre a lupa para inserir o almoxarifado...\n")
|
2535
|
+
app = Application().connect(class_name="TFrmIncluiItemPreVenda", timeout=130)
|
2536
|
+
main_window = app["TFrmIncluiItemPreVenda"]
|
2537
|
+
main_window.set_focus()
|
2538
|
+
panel_TGroup_Box= main_window.child_window(class_name="TPanel", found_index=2)
|
2539
|
+
lupa_almoxarifaco = panel_TGroup_Box.child_window(class_name="TDBIBitBtn", found_index=1)
|
2540
|
+
lupa_almoxarifaco.click()
|
2541
|
+
console.print("Lupa clicado com sucesso inserindo a descrição do almoxarifado...\n")
|
2542
|
+
await worker_sleep(2)
|
2618
2543
|
|
2619
|
-
|
2620
|
-
|
2621
|
-
|
2622
|
-
for _ in range(5):
|
2623
|
-
pyautogui.press("del")
|
2624
|
-
pyautogui.press("backspace")
|
2625
|
-
await worker_sleep(1)
|
2626
|
-
pyautogui.write("1420")
|
2627
|
-
pyautogui.press('tab')
|
2628
|
-
await worker_sleep(1)
|
2629
|
-
break
|
2630
|
-
else:
|
2631
|
-
retorno = f"Todos os itens percorridos e não foi possivel encontrar a descrição condizente a {descricao} \nEtapas Executadas:\n{steps}"
|
2632
|
-
return RpaRetornoProcessoDTO(
|
2633
|
-
sucesso=False,
|
2634
|
-
retorno=retorno,
|
2635
|
-
status=RpaHistoricoStatusEnum.Falha,
|
2636
|
-
tags=[RpaTagDTO(descricao=RpaTagEnum.Negocio)]
|
2637
|
-
)
|
2544
|
+
dialog_buscar = await is_window_open_by_class("TfrmDialogBuscaGeral", "TfrmDialogBuscaGeral")
|
2545
|
+
if dialog_buscar["IsOpened"] == True:
|
2546
|
+
break
|
2638
2547
|
else:
|
2639
|
-
|
2640
|
-
|
2641
|
-
|
2642
|
-
|
2643
|
-
|
2644
|
-
else:
|
2645
|
-
last_line = descricao_item
|
2646
|
-
pyautogui.press('down')
|
2647
|
-
|
2648
|
-
|
2649
|
-
await worker_sleep(10)
|
2650
|
-
console.print("Processo finalizado com sucesso, seguindo com a seleção da natureza...\n")
|
2651
|
-
|
2652
|
-
app = Application().connect(class_name="TFrmIncluiItemPreVenda", timeout=60)
|
2653
|
-
main_window = app["TFrmIncluiItemPreVenda"]
|
2654
|
-
main_window.set_focus()
|
2655
|
-
panel_TGroup_Box= main_window.child_window(class_name="TPanel", found_index=2)
|
2656
|
-
natureza_oper_select = panel_TGroup_Box.child_window(class_name="TDBIComboBox", found_index=0)
|
2657
|
-
# natureza_oper_select.click()
|
2658
|
-
|
2659
|
-
console.print("Selecionando NOP: '5667 - VENDA DE COMB OU LUBRI - SEM ESTOQ E COM FINANC'")
|
2660
|
-
natureza_oper_select.select("5667 - VENDA DE COMB OU LUBRI - SEM ESTOQ E COM FINANC")
|
2661
|
-
|
2548
|
+
console.print("Não foi possivel abrir a janela de Busca Geral")
|
2549
|
+
i = i+1
|
2550
|
+
except Exception as e:
|
2551
|
+
console.print(f"Erro ao abrir a janela de Busca Geral: {e}")
|
2552
|
+
i = i+1
|
2662
2553
|
|
2663
|
-
|
2554
|
+
|
2555
|
+
if i == 7:
|
2556
|
+
retorno = f"Não foi possivel abrir a tela para buscar pelo item do produto na seleção do almoxarifado - \nEtapas Executadas:\n{steps}"
|
2557
|
+
return RpaRetornoProcessoDTO(
|
2558
|
+
sucesso=False,
|
2559
|
+
retorno=retorno,
|
2560
|
+
status=RpaHistoricoStatusEnum.Falha,
|
2561
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Negocio)]
|
2562
|
+
)
|
2664
2563
|
|
2665
|
-
|
2666
|
-
|
2667
|
-
|
2668
|
-
panel_tabSheet = panel_TPage_Control.child_window(class_name="TcxTabSheet", found_index=0)
|
2564
|
+
app = Application().connect(class_name="TfrmDialogBuscaGeral", timeout=60)
|
2565
|
+
main_window = app["TfrmDialogBuscaGeral"]
|
2566
|
+
main_window.set_focus()
|
2669
2567
|
|
2670
|
-
|
2671
|
-
|
2672
|
-
|
2673
|
-
|
2674
|
-
pyautogui.press('del')
|
2675
|
-
await worker_sleep(1)
|
2676
|
-
pyautogui.press('backspace')
|
2677
|
-
await worker_sleep(1)
|
2678
|
-
pyautogui.write(quantidade)
|
2679
|
-
#field_quantidade.set_edit_text(quantidade)
|
2680
|
-
await worker_sleep(1)
|
2681
|
-
pyautogui.press('tab')
|
2682
|
-
await worker_sleep(2)
|
2568
|
+
console.print("Buscando a mercadoria baseado na descrição...\n")
|
2569
|
+
rect = main_window.rectangle()
|
2570
|
+
center_x = (rect.left + rect.right) // 2
|
2571
|
+
center_y = (rect.top + rect.bottom) // 2
|
2683
2572
|
|
2684
|
-
|
2685
|
-
|
2686
|
-
|
2687
|
-
|
2688
|
-
|
2573
|
+
#pyautogui.moveTo(center_x, center_y)
|
2574
|
+
await worker_sleep(1)
|
2575
|
+
pyautogui.click(center_x, center_y)
|
2576
|
+
await worker_sleep(1)
|
2577
|
+
send_keys("^({HOME})")
|
2578
|
+
item_arla_founded = False
|
2689
2579
|
|
2690
|
-
|
2691
|
-
|
2692
|
-
|
2580
|
+
last_line = ''
|
2581
|
+
max_attempts = 12
|
2582
|
+
attempts = 0
|
2693
2583
|
|
2694
|
-
|
2695
|
-
|
2584
|
+
while attempts < max_attempts:
|
2585
|
+
with pyautogui.hold('ctrl'):
|
2586
|
+
pyautogui.press('c')
|
2696
2587
|
await worker_sleep(1)
|
2697
|
-
|
2698
|
-
pyautogui.press(
|
2699
|
-
pyautogui.press("backspace")
|
2700
|
-
pyautogui.write(preco)
|
2701
|
-
#field_valor.set_edit_text(preco)
|
2702
|
-
await worker_sleep(2)
|
2703
|
-
|
2704
|
-
main_window.set_focus()
|
2705
|
-
send_keys("%o")
|
2706
|
-
await worker_sleep(2)
|
2707
|
-
console.print("Valor inserido com sucesso...\n")
|
2708
|
-
|
2709
|
-
app = Application().connect(class_name="TFrmIncluiItemPreVenda", timeout=60)
|
2710
|
-
main_window = app["TFrmIncluiItemPreVenda"]
|
2711
|
-
main_window.set_focus()
|
2712
|
-
send_keys("%i")
|
2713
|
-
await worker_sleep(2)
|
2714
|
-
#Divergencia de nop na capa e no item
|
2715
|
-
await find_nop_divergence()
|
2716
|
-
await worker_sleep(5)
|
2717
|
-
main_window.close()
|
2718
|
-
await worker_sleep(5) #FIM DO LOOP ITENS NOTA CONJUNTA
|
2719
|
-
|
2720
|
-
#FOR OUTROS ITENS NOTA
|
2721
|
-
for item in itens_nota:
|
2722
|
-
quantidade = item['quantidade']
|
2723
|
-
preco = item['valor_unitario']
|
2724
|
-
descricao = item['descricao']
|
2725
|
-
descricao = 'Diesel Comum' if descricao == 'Diesel S500' else descricao
|
2726
|
-
item_cod = item['codigo']
|
2727
|
-
#descricao = descricao.replace(".",",")
|
2588
|
+
with pyautogui.hold('ctrl'):
|
2589
|
+
pyautogui.press('c')
|
2728
2590
|
|
2729
|
-
|
2730
|
-
|
2731
|
-
|
2591
|
+
win32clipboard.OpenClipboard()
|
2592
|
+
descricao_item = win32clipboard.GetClipboardData().strip()
|
2593
|
+
win32clipboard.CloseClipboard()
|
2732
2594
|
|
2733
|
-
|
2595
|
+
if last_line == descricao_item:
|
2596
|
+
if item_arla:
|
2597
|
+
main_window.set_focus()
|
2598
|
+
send_keys("%r")
|
2599
|
+
await worker_sleep(1)
|
2734
2600
|
|
2735
|
-
|
2736
|
-
|
2737
|
-
|
2738
|
-
|
2739
|
-
|
2740
|
-
|
2741
|
-
|
2742
|
-
|
2743
|
-
|
2744
|
-
|
2601
|
+
app = Application().connect(class_name="TFrmIncluiItemPreVenda", timeout=60)
|
2602
|
+
main_window = app["TFrmIncluiItemPreVenda"]
|
2603
|
+
main_window.set_focus()
|
2604
|
+
panel_TGroup_Box= main_window.child_window(class_name="TPanel", found_index=2)
|
2605
|
+
almoxarificado_index = panel_TGroup_Box.child_window(class_name="TDBIEditNumber", found_index=1)
|
2606
|
+
cod_almoxarificado = str(cod_empresa)+"50"
|
2607
|
+
almoxarificado_index.click()
|
2608
|
+
await worker_sleep(1)
|
2609
|
+
for _ in range(5):
|
2610
|
+
pyautogui.press("del")
|
2611
|
+
pyautogui.press("backspace")
|
2612
|
+
await worker_sleep(1)
|
2613
|
+
pyautogui.write(str(cod_almoxarificado))
|
2614
|
+
pyautogui.press('tab')
|
2615
|
+
await worker_sleep(1)
|
2745
2616
|
|
2746
|
-
|
2747
|
-
|
2748
|
-
|
2749
|
-
|
2750
|
-
|
2751
|
-
|
2752
|
-
|
2617
|
+
cod_item_index = panel_TGroup_Box.child_window(class_name="TDBIEditNumber", found_index=0)
|
2618
|
+
cod_item_index.click()
|
2619
|
+
await worker_sleep(1)
|
2620
|
+
for _ in range(5):
|
2621
|
+
pyautogui.press("del")
|
2622
|
+
pyautogui.press("backspace")
|
2623
|
+
await worker_sleep(1)
|
2624
|
+
pyautogui.write("1420")
|
2625
|
+
pyautogui.press('tab')
|
2626
|
+
await worker_sleep(1)
|
2627
|
+
break
|
2628
|
+
else:
|
2629
|
+
retorno = f"Todos os itens percorridos e não foi possivel encontrar a descrição condizente a {descricao} \nEtapas Executadas:\n{steps}"
|
2753
2630
|
return RpaRetornoProcessoDTO(
|
2754
2631
|
sucesso=False,
|
2755
|
-
retorno=
|
2756
|
-
status=RpaHistoricoStatusEnum.Falha,
|
2757
|
-
tags=[RpaTagDTO(descricao=RpaTagEnum.Negocio)]
|
2758
|
-
)
|
2759
|
-
else:
|
2760
|
-
return RpaRetornoProcessoDTO(
|
2761
|
-
sucesso=False,
|
2762
|
-
retorno=f"POP UP Warning não mapeado para seguimento do processo",
|
2632
|
+
retorno=retorno,
|
2763
2633
|
status=RpaHistoricoStatusEnum.Falha,
|
2764
2634
|
tags=[RpaTagDTO(descricao=RpaTagEnum.Negocio)]
|
2765
2635
|
)
|
2636
|
+
else:
|
2637
|
+
if descricao.lower() in descricao_item.lower():
|
2638
|
+
item_arla_founded = True
|
2639
|
+
main_window.set_focus()
|
2640
|
+
send_keys("%o")
|
2641
|
+
break
|
2642
|
+
else:
|
2643
|
+
last_line = descricao_item
|
2644
|
+
pyautogui.press('down')
|
2766
2645
|
|
2767
|
-
app = Application().connect(class_name="TFrmIncluiItemPreVenda", timeout=60)
|
2768
|
-
main_window = app["TFrmIncluiItemPreVenda"]
|
2769
|
-
main_window.set_focus()
|
2770
|
-
panel_TGroup_Box= main_window.child_window(class_name="TPanel", found_index=2)
|
2771
|
-
almoxarificado_index = panel_TGroup_Box.child_window(class_name="TDBIEditNumber", found_index=1)
|
2772
|
-
cod_almoxarificado = str(cod_empresa)+"50"
|
2773
|
-
almoxarificado_index.click()
|
2774
|
-
await worker_sleep(1)
|
2775
|
-
for _ in range(5):
|
2776
|
-
pyautogui.press("del")
|
2777
|
-
pyautogui.press("backspace")
|
2778
|
-
await worker_sleep(1)
|
2779
|
-
pyautogui.write(cod_almoxarificado)
|
2780
|
-
pyautogui.press('tab')
|
2781
|
-
await worker_sleep(3)
|
2782
2646
|
|
2783
|
-
|
2784
|
-
|
2785
|
-
await worker_sleep(1)
|
2647
|
+
await worker_sleep(10)
|
2648
|
+
console.print("Processo finalizado com sucesso, seguindo com a seleção da natureza...\n")
|
2786
2649
|
|
2787
|
-
|
2788
|
-
|
2789
|
-
|
2650
|
+
app = Application().connect(class_name="TFrmIncluiItemPreVenda", timeout=60)
|
2651
|
+
main_window = app["TFrmIncluiItemPreVenda"]
|
2652
|
+
main_window.set_focus()
|
2653
|
+
panel_TGroup_Box= main_window.child_window(class_name="TPanel", found_index=2)
|
2654
|
+
natureza_oper_select = panel_TGroup_Box.child_window(class_name="TDBIComboBox", found_index=0)
|
2655
|
+
# natureza_oper_select.click()
|
2656
|
+
|
2657
|
+
console.print("Selecionando NOP: '5667 - VENDA DE COMB OU LUBRI - SEM ESTOQ E COM FINANC'")
|
2658
|
+
natureza_oper_select.select("5667 - VENDA DE COMB OU LUBRI - SEM ESTOQ E COM FINANC")
|
2659
|
+
|
2790
2660
|
|
2791
|
-
|
2792
|
-
pyautogui.write(str(item_cod))
|
2793
|
-
pyautogui.press('tab')
|
2794
|
-
await worker_sleep(3)
|
2661
|
+
console.print("Natureza da operação selecionado com sucesso, preenchendo os itens...\n")
|
2795
2662
|
|
2663
|
+
#INSERINDO A QUANTIDADE
|
2664
|
+
main_window.set_focus()
|
2665
|
+
panel_TPage_Control= main_window.child_window(class_name="TcxPageControl", found_index=0)
|
2666
|
+
panel_tabSheet = panel_TPage_Control.child_window(class_name="TcxTabSheet", found_index=0)
|
2796
2667
|
|
2797
|
-
|
2798
|
-
|
2799
|
-
|
2668
|
+
field_quantidade = panel_tabSheet.child_window(class_name="TDBIEditNumber", found_index=8)
|
2669
|
+
console.print("Inserindo a quantidade de Itens...\n")
|
2670
|
+
field_quantidade.click()
|
2671
|
+
await worker_sleep(1)
|
2672
|
+
pyautogui.press('del')
|
2673
|
+
await worker_sleep(1)
|
2674
|
+
pyautogui.press('backspace')
|
2675
|
+
await worker_sleep(1)
|
2676
|
+
pyautogui.write(quantidade)
|
2677
|
+
#field_quantidade.set_edit_text(quantidade)
|
2678
|
+
await worker_sleep(1)
|
2679
|
+
pyautogui.press('tab')
|
2680
|
+
await worker_sleep(2)
|
2800
2681
|
|
2801
|
-
|
2802
|
-
|
2682
|
+
#INSERINDO O VALOR INDIVIDUAL DO ITEM
|
2683
|
+
console.print("Inserindo o valor indivual do Item...\n")
|
2684
|
+
btn_valor_unitario = panel_tabSheet.child_window(class_name="TDBIBitBtn", found_index=0)
|
2685
|
+
btn_valor_unitario.click()
|
2686
|
+
await worker_sleep(2)
|
2803
2687
|
|
2804
|
-
|
2805
|
-
|
2806
|
-
|
2807
|
-
break
|
2688
|
+
app = Application().connect(class_name="TFrmInputBoxNumero", timeout=60)
|
2689
|
+
main_window = app["TFrmInputBoxNumero"]
|
2690
|
+
main_window.set_focus()
|
2808
2691
|
|
2809
|
-
|
2810
|
-
|
2811
|
-
|
2812
|
-
|
2813
|
-
|
2814
|
-
|
2815
|
-
|
2816
|
-
|
2692
|
+
field_valor = main_window.child_window(class_name="TDBIEditNumber", found_index=0)
|
2693
|
+
field_valor.click()
|
2694
|
+
await worker_sleep(1)
|
2695
|
+
for _ in range(10):
|
2696
|
+
pyautogui.press("del")
|
2697
|
+
pyautogui.press("backspace")
|
2698
|
+
pyautogui.write(preco)
|
2699
|
+
#field_valor.set_edit_text(preco)
|
2700
|
+
await worker_sleep(2)
|
2817
2701
|
|
2818
|
-
|
2819
|
-
|
2820
|
-
|
2821
|
-
|
2702
|
+
main_window.set_focus()
|
2703
|
+
send_keys("%o")
|
2704
|
+
await worker_sleep(2)
|
2705
|
+
console.print("Valor inserido com sucesso...\n")
|
2822
2706
|
|
2823
|
-
|
2824
|
-
|
2825
|
-
|
2826
|
-
|
2827
|
-
|
2828
|
-
|
2829
|
-
|
2830
|
-
|
2831
|
-
|
2832
|
-
|
2833
|
-
await worker_sleep(1)
|
2834
|
-
pyautogui.press('tab')
|
2835
|
-
await worker_sleep(2)
|
2707
|
+
app = Application().connect(class_name="TFrmIncluiItemPreVenda", timeout=60)
|
2708
|
+
main_window = app["TFrmIncluiItemPreVenda"]
|
2709
|
+
main_window.set_focus()
|
2710
|
+
send_keys("%i")
|
2711
|
+
await worker_sleep(2)
|
2712
|
+
#Divergencia de nop na capa e no item
|
2713
|
+
await find_nop_divergence()
|
2714
|
+
await worker_sleep(5)
|
2715
|
+
main_window.close()
|
2716
|
+
await worker_sleep(5) #FIM DO LOOP ITENS NOTA CONJUNTA
|
2836
2717
|
|
2837
|
-
|
2838
|
-
|
2839
|
-
|
2840
|
-
|
2841
|
-
|
2842
|
-
|
2843
|
-
|
2844
|
-
|
2845
|
-
|
2846
|
-
|
2718
|
+
|
2719
|
+
#FOR OUTROS ITENS NOTA
|
2720
|
+
for item in itens_nota:
|
2721
|
+
quantidade = item['quantidade']
|
2722
|
+
preco = item['valor_unitario']
|
2723
|
+
descricao = item['descricao']
|
2724
|
+
descricao = 'Diesel Comum' if descricao == 'Diesel S500' else descricao
|
2725
|
+
item_cod = item['codigo']
|
2726
|
+
#descricao = descricao.replace(".",",")
|
2727
|
+
|
2728
|
+
if 'arla' in descricao.lower():
|
2729
|
+
item_arla = True
|
2730
|
+
continue #continue para pular o item arla
|
2731
|
+
|
2732
|
+
console.print(quantidade, preco, descricao)
|
2733
|
+
|
2734
|
+
app = Application().connect(class_name="TFrmPreVenda", timeout=60)
|
2735
|
+
main_window = app["TFrmPreVenda"]
|
2736
|
+
main_window.set_focus()
|
2847
2737
|
|
2848
|
-
|
2849
|
-
|
2850
|
-
|
2851
|
-
|
2852
|
-
|
2853
|
-
|
2854
|
-
|
2855
|
-
except Exception as e:
|
2856
|
-
console.print(
|
2857
|
-
f"Não foi possivel incluir o registro utilizando reconhecimento de imagem, Error: {e}...\n tentando inserir via posição...\n"
|
2858
|
-
)
|
2859
|
-
await incluir_registro()
|
2860
|
-
await worker_sleep(5)
|
2861
|
-
|
2862
|
-
await worker_sleep(8)
|
2738
|
+
console.print("Itens acessado com sucesso, clicando em Incluir...\n")
|
2739
|
+
panel_TGroup_Box= panel_TPage.child_window(class_name="TGroupBox", found_index=0)
|
2740
|
+
btn_incluir = panel_TGroup_Box.child_window(class_name="TDBIBitBtn", found_index=4)
|
2741
|
+
btn_incluir.click()
|
2742
|
+
await worker_sleep(5)
|
2743
|
+
console.print("Incluir clicado com sucesso...\n")
|
2744
|
+
|
2863
2745
|
#VERIFICANDO A EXISTENCIA DE WARNINGS
|
2864
2746
|
console.print("Verificando a existência de Warning... \n")
|
2865
2747
|
warning_pop_up = await is_window_open("Warning")
|
@@ -2867,1034 +2749,1151 @@ async def devolucao_ctf(task: RpaProcessoEntradaDTO) -> RpaRetornoProcessoDTO:
|
|
2867
2749
|
console.print("possui Pop-up de Warning, analisando... \n")
|
2868
2750
|
ocr_pop_warning = await ocr_warnings(numero_cupom_fiscal)
|
2869
2751
|
if ocr_pop_warning.sucesso == True:
|
2870
|
-
retorno = f"POP UP Warning não mapeado para seguimento do processo, mensagem: {ocr_pop_warning.retorno} \nEtapas Executadas:\n{steps}"
|
2871
2752
|
return RpaRetornoProcessoDTO(
|
2872
2753
|
sucesso=False,
|
2873
|
-
retorno=retorno,
|
2754
|
+
retorno=f"POP UP Warning não mapeado para seguimento do processo, mensagem: {ocr_pop_warning.retorno}",
|
2874
2755
|
status=RpaHistoricoStatusEnum.Falha,
|
2875
2756
|
tags=[RpaTagDTO(descricao=RpaTagEnum.Negocio)]
|
2876
2757
|
)
|
2877
2758
|
else:
|
2878
|
-
retorno = f"POP UP Warning não mapeado para seguimento do processo \nEtapas Executadas:\n{steps}"
|
2879
2759
|
return RpaRetornoProcessoDTO(
|
2880
2760
|
sucesso=False,
|
2881
|
-
retorno=
|
2761
|
+
retorno=f"POP UP Warning não mapeado para seguimento do processo",
|
2882
2762
|
status=RpaHistoricoStatusEnum.Falha,
|
2883
2763
|
tags=[RpaTagDTO(descricao=RpaTagEnum.Negocio)]
|
2884
2764
|
)
|
2885
|
-
await worker_sleep(5)
|
2886
|
-
#VERIFICANDO SE A PRÉ VENDA FOI INCLUIDA COM SUCESSO
|
2887
|
-
console.print("VERIFICANDO SE A PRÉ VENDA FOI INCLUIDA COM SUCESSO... \n")
|
2888
|
-
information_pop_up = await is_window_open("Informação")
|
2889
|
-
if information_pop_up["IsOpened"] == True:
|
2890
|
-
msg_pop_up = await ocr_title(numero_nota_fiscal, "Informação")
|
2891
|
-
console.print(f'retorno:{msg_pop_up.sucesso}')
|
2892
|
-
console.print(f'retorno:{msg_pop_up}')
|
2893
|
-
if msg_pop_up.sucesso == True:
|
2894
|
-
msg_retorno = msg_pop_up.retorno
|
2895
|
-
console.print(msg_retorno)
|
2896
|
-
if 'venda' in msg_retorno.lower():
|
2897
|
-
try:
|
2898
|
-
information_operacao_concluida = main_window.child_window(title="Informação")
|
2899
|
-
btn_ok = information_operacao_concluida.child_window(class_name="TButton")
|
2900
|
-
btn_ok.click()
|
2901
|
-
await worker_sleep(4)
|
2902
|
-
except:
|
2903
|
-
pyautogui.press('enter')
|
2904
|
-
await worker_sleep(4)
|
2905
|
-
else:
|
2906
|
-
retorno = f"Pop up nao mapeado para seguimento do robo {msg_pop_up.retorno} \nEtapas Executadas:\n{steps}"
|
2907
|
-
return RpaRetornoProcessoDTO(
|
2908
|
-
sucesso=False,
|
2909
|
-
retorno=retorno,
|
2910
|
-
status=RpaHistoricoStatusEnum.Falha,
|
2911
|
-
tags=[RpaTagDTO(descricao=RpaTagEnum.Negocio)]
|
2912
|
-
)
|
2913
|
-
else:
|
2914
|
-
retorno = f"Não foi possivel realizar a confirmação do msg do OCR \nEtapas Executadas:\n{steps}"
|
2915
|
-
return RpaRetornoProcessoDTO(
|
2916
|
-
sucesso=False,
|
2917
|
-
retorno=retorno,
|
2918
|
-
status=RpaHistoricoStatusEnum.Falha,
|
2919
|
-
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
2920
|
-
)
|
2921
|
-
else:
|
2922
|
-
retorno = f"Janela de confirmação de pre venda incluida nao encontrada \nEtapas Executadas:\n{steps}"
|
2923
|
-
return RpaRetornoProcessoDTO(
|
2924
|
-
sucesso=False,
|
2925
|
-
retorno=retorno,
|
2926
|
-
status=RpaHistoricoStatusEnum.Falha,
|
2927
|
-
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
2928
|
-
)
|
2929
|
-
|
2930
|
-
await worker_sleep(5)
|
2931
|
-
steps += ' ETAPA 04 - PRE VENDA INCLUIDA COM SUCESSO'
|
2932
|
-
#CONFIRMANDO POP UP DE PRÉ VENDA - PESQUISAR PRE VENDA
|
2933
|
-
try:
|
2934
|
-
console.print("CONFIRMANDO POP UP DE PRÉ VENDA - PESQUISAR PRE VENDA... \n")
|
2935
|
-
app = Application().connect(class_name="TFrmPreVenda", timeout=10)
|
2936
|
-
main_window = app["Confirm"]
|
2937
|
-
main_window.set_focus()
|
2938
2765
|
|
2939
|
-
|
2940
|
-
|
2941
|
-
|
2942
|
-
|
2943
|
-
|
2944
|
-
|
2945
|
-
|
2946
|
-
|
2947
|
-
|
2948
|
-
|
2949
|
-
)
|
2766
|
+
app = Application().connect(class_name="TFrmIncluiItemPreVenda", timeout=60)
|
2767
|
+
main_window = app["TFrmIncluiItemPreVenda"]
|
2768
|
+
main_window.set_focus()
|
2769
|
+
panel_TGroup_Box= main_window.child_window(class_name="TPanel", found_index=2)
|
2770
|
+
almoxarificado_index = panel_TGroup_Box.child_window(class_name="TDBIEditNumber", found_index=1)
|
2771
|
+
cod_almoxarificado = str(cod_empresa)+"50"
|
2772
|
+
almoxarificado_index.click()
|
2773
|
+
await worker_sleep(1)
|
2774
|
+
for _ in range(5):
|
2775
|
+
pyautogui.press("del")
|
2776
|
+
pyautogui.press("backspace")
|
2777
|
+
await worker_sleep(1)
|
2778
|
+
pyautogui.write(cod_almoxarificado)
|
2779
|
+
pyautogui.press('tab')
|
2780
|
+
await worker_sleep(3)
|
2950
2781
|
|
2782
|
+
cod_item_index = panel_TGroup_Box.child_window(class_name="TDBIEditNumber", found_index=0)
|
2783
|
+
cod_item_index.click()
|
2784
|
+
await worker_sleep(1)
|
2951
2785
|
|
2952
|
-
|
2953
|
-
|
2954
|
-
|
2955
|
-
app = Application().connect(class_name="TFrmPreVenda", timeout=60)
|
2956
|
-
main_window = app["TFrmPreVenda"]
|
2957
|
-
main_window.set_focus()
|
2786
|
+
for _ in range(5):
|
2787
|
+
pyautogui.press("del")
|
2788
|
+
pyautogui.press("backspace")
|
2958
2789
|
|
2959
|
-
|
2960
|
-
|
2961
|
-
|
2962
|
-
|
2963
|
-
console.print("CONFIRMAR CLICADO COM SUCESSO... \n")
|
2964
|
-
await worker_sleep(3)
|
2965
|
-
except Exception as e:
|
2966
|
-
retorno = f"Não foi possivel clicar em Confirma na tela de Pre Venda \nEtapas Executadas:\n{steps}"
|
2967
|
-
return RpaRetornoProcessoDTO(
|
2968
|
-
sucesso=False,
|
2969
|
-
retorno=retorno,
|
2970
|
-
status=RpaHistoricoStatusEnum.Falha,
|
2971
|
-
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
2972
|
-
)
|
2790
|
+
await worker_sleep(1)
|
2791
|
+
pyautogui.write(str(item_cod))
|
2792
|
+
pyautogui.press('tab')
|
2793
|
+
await worker_sleep(3)
|
2973
2794
|
|
2974
2795
|
|
2975
|
-
|
2976
|
-
|
2977
|
-
|
2978
|
-
app = Application().connect(class_name="TFrmPreVenda", timeout=10)
|
2979
|
-
main_window = app["Confirm"]
|
2980
|
-
main_window.set_focus()
|
2796
|
+
natureza_oper_select = panel_TGroup_Box.child_window(class_name="TDBIComboBox", found_index=0)
|
2797
|
+
nop_selected = natureza_oper_select.window_text()
|
2798
|
+
nop_selected_value = nop_selected[:4]
|
2981
2799
|
|
2982
|
-
|
2983
|
-
|
2984
|
-
await worker_sleep(3)
|
2985
|
-
except Exception as e:
|
2986
|
-
retorno = f"Não foi possivel clicar para confirmar a janela 'Deseja realmente confirmar esta pre-venda' \nEtapas Executadas:\n{steps}"
|
2987
|
-
return RpaRetornoProcessoDTO(
|
2988
|
-
sucesso=False,
|
2989
|
-
retorno=retorno,
|
2990
|
-
status=RpaHistoricoStatusEnum.Falha,
|
2991
|
-
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
2992
|
-
)
|
2800
|
+
itens_to_select = natureza_oper_select.texts()
|
2801
|
+
nop_to_be_select = ''
|
2993
2802
|
|
2803
|
+
for item in itens_to_select:
|
2804
|
+
if nop_selected_value in item and (('c/' in item.lower() or 'c /' in item.lower()) and ('s/' in item.lower() or 's /' in item.lower())):
|
2805
|
+
nop_to_be_select = item
|
2806
|
+
break
|
2994
2807
|
|
2995
|
-
|
2996
|
-
|
2997
|
-
|
2998
|
-
|
2999
|
-
|
3000
|
-
|
3001
|
-
btn_ok = main_window.child_window(class_name="TButton", found_index=0)
|
3002
|
-
btn_ok.click()
|
3003
|
-
await worker_sleep(3)
|
3004
|
-
else:
|
3005
|
-
console.print("Nenhum pop-up de Warning Encontrado... \n")
|
3006
|
-
|
3007
|
-
|
3008
|
-
#VERIFICANDO POP UP - DE ACORDO COM OS PARÂMETROS DO SISTEMA..
|
3009
|
-
console.print("VERIFICANDO POP UP - DE ACORDO COM OS PARÂMETROS DO SISTEMA... \n")
|
3010
|
-
information_pop_up = await is_window_open_by_class("TFrmPreVenda", "Confirm")
|
3011
|
-
if information_pop_up["IsOpened"] == True:
|
3012
|
-
msg_pop_up = await ocr_by_class(numero_nota_fiscal, "TFrmPreVenda", "Confirm")
|
3013
|
-
console.print(f'retorno:{msg_pop_up.sucesso}')
|
3014
|
-
console.print(f'retorno:{msg_pop_up}')
|
3015
|
-
if msg_pop_up.sucesso == True:
|
3016
|
-
msg_retorno = msg_pop_up.retorno
|
3017
|
-
console.print(msg_retorno)
|
3018
|
-
if 'finan' in msg_retorno.lower():
|
3019
|
-
app = Application().connect(class_name="TFrmPreVenda", timeout=10)
|
3020
|
-
main_window = app["Confirm"]
|
3021
|
-
main_window.set_focus()
|
3022
|
-
|
3023
|
-
btn_yes = main_window.child_window(class_name="TButton", found_index=1)
|
3024
|
-
btn_yes.click()
|
3025
|
-
else:
|
3026
|
-
retorno = f"Pop up nao mapeado para seguimento do robo {msg_pop_up.retorno} \nEtapas Executadas:\n{steps}"
|
3027
|
-
return RpaRetornoProcessoDTO(
|
3028
|
-
sucesso=False,
|
3029
|
-
retorno=retorno,
|
3030
|
-
status=RpaHistoricoStatusEnum.Falha,
|
3031
|
-
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
3032
|
-
)
|
3033
|
-
else:
|
3034
|
-
retorno = f"Não foi possivel realizar a confirmação do msg do OCR \nEtapas Executadas:\n{steps}"
|
3035
|
-
return RpaRetornoProcessoDTO(
|
3036
|
-
sucesso=False,
|
3037
|
-
retorno=retorno,
|
3038
|
-
status=RpaHistoricoStatusEnum.Falha,
|
3039
|
-
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
3040
|
-
)
|
2808
|
+
natureza_oper_select.click()
|
2809
|
+
await worker_sleep(1)
|
2810
|
+
console.print(f"Descrição: {descricao}")
|
2811
|
+
console.print("Selecionando NOP do item: '5667 - VENDA DE COMB OU LUBRI - SEM ESTOQ E COM FINANC'")
|
2812
|
+
natureza_oper_select.select("5667 - VENDA DE COMB OU LUBRI - SEM ESTOQ E COM FINANC")
|
3041
2813
|
|
2814
|
+
await worker_sleep(1)
|
2815
|
+
console.print("Natureza da operação selecionado com sucesso, preenchendo os itens...\n")
|
3042
2816
|
|
3043
|
-
#
|
3044
|
-
|
3045
|
-
|
3046
|
-
|
3047
|
-
main_window = app["TFrmPreVenda"]
|
3048
|
-
main_window.set_focus()
|
2817
|
+
#INSERINDO A QUANTIDADE
|
2818
|
+
main_window.set_focus()
|
2819
|
+
panel_TPage_Control= main_window.child_window(class_name="TcxPageControl", found_index=0)
|
2820
|
+
panel_tabSheet = panel_TPage_Control.child_window(class_name="TcxTabSheet", found_index=0)
|
3049
2821
|
|
3050
|
-
|
3051
|
-
|
3052
|
-
|
3053
|
-
|
3054
|
-
|
3055
|
-
|
3056
|
-
|
3057
|
-
|
2822
|
+
field_quantidade = panel_tabSheet.child_window(class_name="TDBIEditNumber", found_index=8)
|
2823
|
+
console.print("Inserindo a quantidade de Itens...\n")
|
2824
|
+
field_quantidade.click()
|
2825
|
+
await worker_sleep(1)
|
2826
|
+
pyautogui.press('del')
|
2827
|
+
await worker_sleep(1)
|
2828
|
+
pyautogui.press('backspace')
|
2829
|
+
await worker_sleep(1)
|
2830
|
+
pyautogui.write(quantidade)
|
2831
|
+
#field_quantidade.set_edit_text(quantidade)
|
2832
|
+
await worker_sleep(1)
|
2833
|
+
pyautogui.press('tab')
|
2834
|
+
await worker_sleep(2)
|
2835
|
+
|
2836
|
+
console.print("Verificando inclui itiem Pre Venda")
|
2837
|
+
app = Application().connect(class_name="TFrmIncluiItemPreVenda", timeout=60)
|
2838
|
+
main_window = app["TFrmIncluiItemPreVenda"]
|
2839
|
+
main_window.set_focus()
|
2840
|
+
send_keys("%i")
|
2841
|
+
await worker_sleep(2)
|
2842
|
+
#Divergencia de nop na capa e no item
|
2843
|
+
await find_nop_divergence()
|
2844
|
+
await worker_sleep(5)
|
2845
|
+
main_window.close()
|
2846
|
+
|
2847
|
+
# Inclui registro
|
2848
|
+
console.print(f"Incluindo registro...\n")
|
2849
|
+
try:
|
2850
|
+
ASSETS_PATH = "assets"
|
2851
|
+
inserir_registro = pyautogui.locateOnScreen(ASSETS_PATH + "\\entrada_notas\\IncluirRegistro.png", confidence=0.8)
|
2852
|
+
pyautogui.click(inserir_registro)
|
2853
|
+
|
2854
|
+
except Exception as e:
|
2855
|
+
console.print(
|
2856
|
+
f"Não foi possivel incluir o registro utilizando reconhecimento de imagem, Error: {e}...\n tentando inserir via posição...\n"
|
2857
|
+
)
|
2858
|
+
await incluir_registro()
|
2859
|
+
await worker_sleep(5)
|
2860
|
+
|
2861
|
+
await worker_sleep(8)
|
2862
|
+
#VERIFICANDO A EXISTENCIA DE WARNINGS
|
2863
|
+
console.print("Verificando a existência de Warning... \n")
|
2864
|
+
warning_pop_up = await is_window_open("Warning")
|
2865
|
+
if warning_pop_up["IsOpened"] == True:
|
2866
|
+
console.print("possui Pop-up de Warning, analisando... \n")
|
2867
|
+
ocr_pop_warning = await ocr_warnings(numero_cupom_fiscal)
|
2868
|
+
if ocr_pop_warning.sucesso == True:
|
2869
|
+
retorno = f"POP UP Warning não mapeado para seguimento do processo, mensagem: {ocr_pop_warning.retorno} \nEtapas Executadas:\n{steps}"
|
3058
2870
|
return RpaRetornoProcessoDTO(
|
3059
2871
|
sucesso=False,
|
3060
2872
|
retorno=retorno,
|
3061
2873
|
status=RpaHistoricoStatusEnum.Falha,
|
3062
|
-
tags=[RpaTagDTO(descricao=RpaTagEnum.
|
2874
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Negocio)]
|
3063
2875
|
)
|
3064
|
-
|
3065
|
-
|
3066
|
-
console.print("O valor desta pré venda exige uma aprovação... \n")
|
3067
|
-
try:
|
3068
|
-
app = Application().connect(class_name="TFrmPreVenda", timeout=10)
|
3069
|
-
main_window = app["Confirm"]
|
3070
|
-
main_window.set_focus()
|
3071
|
-
|
3072
|
-
btn_yes = main_window.child_window(class_name="TButton", found_index=1)
|
3073
|
-
btn_yes.click()
|
3074
|
-
await worker_sleep(3)
|
3075
|
-
except:
|
3076
|
-
retorno = f"Não foi possivel clicar no pop-up 'O valor desta pré venda exige uma aprovação financeira' na tela de Pre venda \nEtapas Executadas:\n{steps}"
|
2876
|
+
else:
|
2877
|
+
retorno = f"POP UP Warning não mapeado para seguimento do processo \nEtapas Executadas:\n{steps}"
|
3077
2878
|
return RpaRetornoProcessoDTO(
|
3078
2879
|
sucesso=False,
|
3079
2880
|
retorno=retorno,
|
3080
2881
|
status=RpaHistoricoStatusEnum.Falha,
|
3081
|
-
tags=[RpaTagDTO(descricao=RpaTagEnum.
|
2882
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Negocio)]
|
3082
2883
|
)
|
3083
|
-
|
3084
|
-
|
3085
|
-
|
3086
|
-
|
3087
|
-
|
3088
|
-
|
3089
|
-
|
3090
|
-
|
3091
|
-
|
3092
|
-
|
3093
|
-
|
3094
|
-
|
3095
|
-
|
3096
|
-
|
3097
|
-
|
3098
|
-
|
3099
|
-
|
3100
|
-
|
3101
|
-
|
3102
|
-
|
3103
|
-
await worker_sleep(4)
|
3104
|
-
else:
|
3105
|
-
retorno = f"Pop up nao mapeado para seguimento do robo {msg_pop_up.retorno} \nEtapas Executadas:\n{steps}"
|
3106
|
-
return RpaRetornoProcessoDTO(
|
3107
|
-
sucesso=False,
|
3108
|
-
retorno=retorno,
|
3109
|
-
status=RpaHistoricoStatusEnum.Falha,
|
3110
|
-
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
3111
|
-
)
|
2884
|
+
await worker_sleep(5)
|
2885
|
+
#VERIFICANDO SE A PRÉ VENDA FOI INCLUIDA COM SUCESSO
|
2886
|
+
console.print("VERIFICANDO SE A PRÉ VENDA FOI INCLUIDA COM SUCESSO... \n")
|
2887
|
+
information_pop_up = await is_window_open("Informação")
|
2888
|
+
if information_pop_up["IsOpened"] == True:
|
2889
|
+
msg_pop_up = await ocr_title(numero_nota_fiscal, "Informação")
|
2890
|
+
console.print(f'retorno:{msg_pop_up.sucesso}')
|
2891
|
+
console.print(f'retorno:{msg_pop_up}')
|
2892
|
+
if msg_pop_up.sucesso == True:
|
2893
|
+
msg_retorno = msg_pop_up.retorno
|
2894
|
+
console.print(msg_retorno)
|
2895
|
+
if 'venda' in msg_retorno.lower():
|
2896
|
+
try:
|
2897
|
+
information_operacao_concluida = main_window.child_window(title="Informação")
|
2898
|
+
btn_ok = information_operacao_concluida.child_window(class_name="TButton")
|
2899
|
+
btn_ok.click()
|
2900
|
+
await worker_sleep(4)
|
2901
|
+
except:
|
2902
|
+
pyautogui.press('enter')
|
2903
|
+
await worker_sleep(4)
|
3112
2904
|
else:
|
3113
|
-
retorno = f"
|
2905
|
+
retorno = f"Pop up nao mapeado para seguimento do robo {msg_pop_up.retorno} \nEtapas Executadas:\n{steps}"
|
3114
2906
|
return RpaRetornoProcessoDTO(
|
3115
2907
|
sucesso=False,
|
3116
2908
|
retorno=retorno,
|
3117
2909
|
status=RpaHistoricoStatusEnum.Falha,
|
3118
|
-
tags=[RpaTagDTO(descricao=RpaTagEnum.
|
2910
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Negocio)]
|
3119
2911
|
)
|
3120
2912
|
else:
|
3121
|
-
retorno = f"
|
3122
|
-
return RpaRetornoProcessoDTO(
|
3123
|
-
sucesso=False,
|
3124
|
-
retorno=retorno,
|
3125
|
-
status=RpaHistoricoStatusEnum.Falha,
|
3126
|
-
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
3127
|
-
)
|
3128
|
-
await worker_sleep(3)
|
3129
|
-
|
3130
|
-
|
3131
|
-
#FATURAR
|
3132
|
-
try:
|
3133
|
-
console.print("FATURAR... \n")
|
3134
|
-
app = Application().connect(class_name="TFrmPreVenda", timeout=10)
|
3135
|
-
main_window = app["TFrmPreVenda"]
|
3136
|
-
main_window.set_focus()
|
3137
|
-
|
3138
|
-
panel_Tnotebook = main_window.child_window(class_name="TNotebook", found_index=0)
|
3139
|
-
panel_Tnotebook = panel_Tnotebook.child_window(class_name="TPage", found_index=0)
|
3140
|
-
btn_faturar = panel_Tnotebook.child_window(class_name="TBitBtn", found_index=7)
|
3141
|
-
btn_faturar.click()
|
3142
|
-
console.print("BOTAO FATURAR CLICADO COM SUCESSO... \n")
|
3143
|
-
await worker_sleep(5)
|
3144
|
-
except Exception as e:
|
3145
|
-
retorno = f"Não foi possivel clicar em Faturar na tela de pre venda, erro: {e} \nEtapas Executadas:\n{steps}"
|
2913
|
+
retorno = f"Não foi possivel realizar a confirmação do msg do OCR \nEtapas Executadas:\n{steps}"
|
3146
2914
|
return RpaRetornoProcessoDTO(
|
3147
2915
|
sucesso=False,
|
3148
2916
|
retorno=retorno,
|
3149
2917
|
status=RpaHistoricoStatusEnum.Falha,
|
3150
2918
|
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
3151
2919
|
)
|
3152
|
-
|
3153
|
-
|
3154
|
-
|
3155
|
-
try:
|
3156
|
-
app = Application().connect(class_name="TFrmPreVenda", timeout=40)
|
3157
|
-
main_window = app["Confirm"]
|
3158
|
-
main_window.set_focus()
|
3159
|
-
|
3160
|
-
btn_no = main_window.child_window(class_name="TButton", found_index=0)
|
3161
|
-
btn_no.click()
|
3162
|
-
try:
|
3163
|
-
btn_no.click()
|
3164
|
-
except:
|
3165
|
-
pass
|
3166
|
-
await worker_sleep(3)
|
3167
|
-
except:
|
3168
|
-
retorno = f"Não foi possivel clicar no pop-up 'Recalcular Parcelas da Pre venda' na tela de Pre venda \nEtapas Executadas:\n{steps}"
|
3169
|
-
return RpaRetornoProcessoDTO(
|
2920
|
+
else:
|
2921
|
+
retorno = f"Janela de confirmação de pre venda incluida nao encontrada \nEtapas Executadas:\n{steps}"
|
2922
|
+
return RpaRetornoProcessoDTO(
|
3170
2923
|
sucesso=False,
|
3171
2924
|
retorno=retorno,
|
3172
2925
|
status=RpaHistoricoStatusEnum.Falha,
|
3173
2926
|
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
3174
2927
|
)
|
2928
|
+
|
2929
|
+
await worker_sleep(5)
|
2930
|
+
steps += ' ETAPA 04 - PRE VENDA INCLUIDA COM SUCESSO'
|
2931
|
+
#CONFIRMANDO POP UP DE PRÉ VENDA - PESQUISAR PRE VENDA
|
2932
|
+
try:
|
2933
|
+
console.print("CONFIRMANDO POP UP DE PRÉ VENDA - PESQUISAR PRE VENDA... \n")
|
2934
|
+
app = Application().connect(class_name="TFrmPreVenda", timeout=10)
|
2935
|
+
main_window = app["Confirm"]
|
2936
|
+
main_window.set_focus()
|
3175
2937
|
|
2938
|
+
btn_yes = main_window.child_window(class_name="TButton", found_index=1)
|
2939
|
+
btn_yes.click()
|
2940
|
+
await worker_sleep(3)
|
2941
|
+
except Exception as e:
|
2942
|
+
retorno = f"Pop Up de Confirm (Deseja pesquisar a Pré Venda ?) não encontrado \nEtapas Executadas:\n{steps}"
|
2943
|
+
return RpaRetornoProcessoDTO(
|
2944
|
+
sucesso=False,
|
2945
|
+
retorno=retorno,
|
2946
|
+
status=RpaHistoricoStatusEnum.Falha,
|
2947
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
2948
|
+
)
|
3176
2949
|
|
3177
|
-
parcelas_nf_saida_pop_up = await is_window_open("Parcelas - Nota Fiscal Saída")
|
3178
|
-
if parcelas_nf_saida_pop_up["IsOpened"] == True:
|
3179
|
-
app = Application().connect(title="Parcelas - Nota Fiscal Saída", timeout=60)
|
3180
|
-
main_window = app.window(title="Parcelas - Nota Fiscal Saída")
|
3181
|
-
main_window.set_focus()
|
3182
|
-
send_keys("%n")
|
3183
|
-
await worker_sleep(3)
|
3184
|
-
else:
|
3185
|
-
retorno = f"Não foi encontrada a Janela de Parcelas - Nota Fiscal Saída \nEtapas Executadas:\n{steps}"
|
3186
|
-
return RpaRetornoProcessoDTO(
|
3187
|
-
sucesso=False,
|
3188
|
-
retorno=retorno,
|
3189
|
-
status=RpaHistoricoStatusEnum.Falha,
|
3190
|
-
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
3191
|
-
)
|
3192
2950
|
|
2951
|
+
#CONFIRMANDO NA TELA DE PRE VENDA
|
2952
|
+
try:
|
2953
|
+
console.print("CLICANDO EM CONFIRMAR... \n")
|
2954
|
+
app = Application().connect(class_name="TFrmPreVenda", timeout=60)
|
2955
|
+
main_window = app["TFrmPreVenda"]
|
2956
|
+
main_window.set_focus()
|
3193
2957
|
|
3194
|
-
|
3195
|
-
|
3196
|
-
|
3197
|
-
|
3198
|
-
|
3199
|
-
|
3200
|
-
|
2958
|
+
panel_Tnotebook = main_window.child_window(class_name="TNotebook", found_index=0)
|
2959
|
+
panel_Tnotebook = panel_Tnotebook.child_window(class_name="TPage", found_index=0)
|
2960
|
+
btn_confirmar = panel_Tnotebook.child_window(class_name="TBitBtn", found_index=11)
|
2961
|
+
btn_confirmar.click()
|
2962
|
+
console.print("CONFIRMAR CLICADO COM SUCESSO... \n")
|
2963
|
+
await worker_sleep(3)
|
2964
|
+
except Exception as e:
|
2965
|
+
retorno = f"Não foi possivel clicar em Confirma na tela de Pre Venda \nEtapas Executadas:\n{steps}"
|
2966
|
+
return RpaRetornoProcessoDTO(
|
2967
|
+
sucesso=False,
|
2968
|
+
retorno=retorno,
|
2969
|
+
status=RpaHistoricoStatusEnum.Falha,
|
2970
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
2971
|
+
)
|
3201
2972
|
|
3202
2973
|
|
3203
|
-
|
2974
|
+
#CONFIRMANDO NA TELA DE PRE VENDA
|
2975
|
+
try:
|
2976
|
+
console.print("CONFIRMANDO POP UP DE Deseja realmente confirmar esta PRÉ VENDA ... \n")
|
2977
|
+
app = Application().connect(class_name="TFrmPreVenda", timeout=10)
|
2978
|
+
main_window = app["Confirm"]
|
2979
|
+
main_window.set_focus()
|
3204
2980
|
|
2981
|
+
btn_yes = main_window.child_window(class_name="TButton", found_index=1)
|
2982
|
+
btn_yes.click()
|
2983
|
+
await worker_sleep(3)
|
2984
|
+
except Exception as e:
|
2985
|
+
retorno = f"Não foi possivel clicar para confirmar a janela 'Deseja realmente confirmar esta pre-venda' \nEtapas Executadas:\n{steps}"
|
2986
|
+
return RpaRetornoProcessoDTO(
|
2987
|
+
sucesso=False,
|
2988
|
+
retorno=retorno,
|
2989
|
+
status=RpaHistoricoStatusEnum.Falha,
|
2990
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
2991
|
+
)
|
3205
2992
|
|
3206
|
-
|
3207
|
-
|
3208
|
-
|
3209
|
-
|
3210
|
-
|
3211
|
-
|
3212
|
-
|
3213
|
-
|
2993
|
+
|
2994
|
+
warning_pop = await is_window_open_by_class("TFrmPreVenda", "Warning")
|
2995
|
+
if warning_pop["IsOpened"] == True:
|
2996
|
+
app = Application().connect(class_name="TFrmPreVenda", timeout=10)
|
2997
|
+
main_window = app["Warning"]
|
2998
|
+
main_window.set_focus()
|
2999
|
+
|
3000
|
+
btn_ok = main_window.child_window(class_name="TButton", found_index=0)
|
3001
|
+
btn_ok.click()
|
3002
|
+
await worker_sleep(3)
|
3003
|
+
else:
|
3004
|
+
console.print("Nenhum pop-up de Warning Encontrado... \n")
|
3005
|
+
|
3006
|
+
|
3007
|
+
#VERIFICANDO POP UP - DE ACORDO COM OS PARÂMETROS DO SISTEMA..
|
3008
|
+
console.print("VERIFICANDO POP UP - DE ACORDO COM OS PARÂMETROS DO SISTEMA... \n")
|
3009
|
+
information_pop_up = await is_window_open_by_class("TFrmPreVenda", "Confirm")
|
3010
|
+
if information_pop_up["IsOpened"] == True:
|
3011
|
+
msg_pop_up = await ocr_by_class(numero_nota_fiscal, "TFrmPreVenda", "Confirm")
|
3012
|
+
console.print(f'retorno:{msg_pop_up.sucesso}')
|
3013
|
+
console.print(f'retorno:{msg_pop_up}')
|
3014
|
+
if msg_pop_up.sucesso == True:
|
3015
|
+
msg_retorno = msg_pop_up.retorno
|
3016
|
+
console.print(msg_retorno)
|
3017
|
+
if 'finan' in msg_retorno.lower():
|
3018
|
+
app = Application().connect(class_name="TFrmPreVenda", timeout=10)
|
3019
|
+
main_window = app["Confirm"]
|
3020
|
+
main_window.set_focus()
|
3021
|
+
|
3022
|
+
btn_yes = main_window.child_window(class_name="TButton", found_index=1)
|
3023
|
+
btn_yes.click()
|
3024
|
+
else:
|
3025
|
+
retorno = f"Pop up nao mapeado para seguimento do robo {msg_pop_up.retorno} \nEtapas Executadas:\n{steps}"
|
3026
|
+
return RpaRetornoProcessoDTO(
|
3027
|
+
sucesso=False,
|
3028
|
+
retorno=retorno,
|
3029
|
+
status=RpaHistoricoStatusEnum.Falha,
|
3030
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
3031
|
+
)
|
3032
|
+
else:
|
3033
|
+
retorno = f"Não foi possivel realizar a confirmação do msg do OCR \nEtapas Executadas:\n{steps}"
|
3214
3034
|
return RpaRetornoProcessoDTO(
|
3215
3035
|
sucesso=False,
|
3216
|
-
retorno=
|
3036
|
+
retorno=retorno,
|
3217
3037
|
status=RpaHistoricoStatusEnum.Falha,
|
3218
3038
|
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
3219
3039
|
)
|
3220
|
-
await worker_sleep(2)
|
3221
|
-
await find_warning_nop_divergence()
|
3222
|
-
await worker_sleep(2)
|
3223
|
-
#VERIFICANDO SE POSSUI POP UP WARNING
|
3224
|
-
console.print("Verificando a presença de Warning... \n")
|
3225
|
-
warning_boo = False
|
3226
|
-
await worker_sleep(5)
|
3227
|
-
try:
|
3228
|
-
try:
|
3229
|
-
app = Application().connect(class_name="TFrmDadosFaturamentoPreVenda", timeout=10)
|
3230
|
-
main_window = app["Warning"]
|
3231
|
-
main_window.set_focus()
|
3232
|
-
|
3233
|
-
except:
|
3234
|
-
console.print('Except Verificando warnings... \n')
|
3235
|
-
app = Application().connect(class_name="Warning", timeout=10)
|
3236
|
-
main_window = app["Warning"]
|
3237
|
-
main_window.set_focus()
|
3238
|
-
console.print("Possui Warning... \n")
|
3239
|
-
await worker_sleep(2)
|
3240
|
-
await find_warning_nop_divergence()
|
3241
|
-
btn_ok = main_window.child_window(class_name="TButton", found_index=0)
|
3242
|
-
btn_ok.click()
|
3243
|
-
await worker_sleep(3)
|
3244
|
-
warning_boo = True
|
3245
|
-
except:
|
3246
|
-
console.print("Não Possui Warning... \n")
|
3247
3040
|
|
3248
|
-
#ALTERANDO TRIBUTO DOS ITENS
|
3249
|
-
if warning_boo:
|
3250
|
-
try:
|
3251
|
-
console.print('Acessando a tela de Itens')
|
3252
|
-
app = Application().connect(class_name="TFrmDadosFaturamentoPreVenda", timeout=60)
|
3253
|
-
main_window = app["TFrmDadosFaturamentoPreVenda"]
|
3254
|
-
main_window.set_focus()
|
3255
|
-
send_keys("%i")
|
3256
|
-
await worker_sleep(2)
|
3257
|
-
send_keys("%g")
|
3258
|
-
await worker_sleep(2)
|
3259
3041
|
|
3260
|
-
|
3261
|
-
|
3262
|
-
|
3042
|
+
#APROVAR CREDITO
|
3043
|
+
try:
|
3044
|
+
console.print("Aprovar Credito... \n")
|
3045
|
+
app = Application().connect(class_name="TFrmPreVenda", timeout=10)
|
3046
|
+
main_window = app["TFrmPreVenda"]
|
3047
|
+
main_window.set_focus()
|
3263
3048
|
|
3264
|
-
|
3265
|
-
|
3049
|
+
panel_Tnotebook = main_window.child_window(class_name="TNotebook", found_index=0)
|
3050
|
+
panel_Tnotebook = panel_Tnotebook.child_window(class_name="TPage", found_index=0)
|
3051
|
+
btn_aprovar_credito = panel_Tnotebook.child_window(class_name="TBitBtn", found_index=8)
|
3052
|
+
console.print("Clicando em aprovar Credito... \n")
|
3053
|
+
btn_aprovar_credito.click()
|
3054
|
+
await worker_sleep(2)
|
3055
|
+
except Exception as e:
|
3056
|
+
retorno = f"Não foi possivel clicar em aprovar credito na tela de Pre venda \nEtapas Executadas:\n{steps}"
|
3057
|
+
return RpaRetornoProcessoDTO(
|
3058
|
+
sucesso=False,
|
3059
|
+
retorno=retorno,
|
3060
|
+
status=RpaHistoricoStatusEnum.Falha,
|
3061
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
3062
|
+
)
|
3266
3063
|
|
3267
3064
|
|
3268
|
-
|
3269
|
-
|
3270
|
-
|
3271
|
-
|
3272
|
-
|
3273
|
-
else:
|
3274
|
-
console.print("Item Arla buscando pela aliquota do estado... \n")
|
3275
|
-
aliquota = None
|
3276
|
-
for item in conconfig_aliquota_icms:
|
3277
|
-
if cidade_cliente in item["estado"]:
|
3278
|
-
aliquota = item["aliquota"]
|
3279
|
-
break
|
3065
|
+
console.print("O valor desta pré venda exige uma aprovação... \n")
|
3066
|
+
try:
|
3067
|
+
app = Application().connect(class_name="TFrmPreVenda", timeout=10)
|
3068
|
+
main_window = app["Confirm"]
|
3069
|
+
main_window.set_focus()
|
3280
3070
|
|
3281
|
-
|
3282
|
-
|
3283
|
-
|
3284
|
-
|
3285
|
-
|
3286
|
-
|
3287
|
-
|
3288
|
-
|
3289
|
-
|
3290
|
-
|
3291
|
-
|
3292
|
-
|
3293
|
-
|
3294
|
-
|
3295
|
-
|
3296
|
-
|
3297
|
-
|
3298
|
-
|
3071
|
+
btn_yes = main_window.child_window(class_name="TButton", found_index=1)
|
3072
|
+
btn_yes.click()
|
3073
|
+
await worker_sleep(3)
|
3074
|
+
except:
|
3075
|
+
retorno = f"Não foi possivel clicar no pop-up 'O valor desta pré venda exige uma aprovação financeira' na tela de Pre venda \nEtapas Executadas:\n{steps}"
|
3076
|
+
return RpaRetornoProcessoDTO(
|
3077
|
+
sucesso=False,
|
3078
|
+
retorno=retorno,
|
3079
|
+
status=RpaHistoricoStatusEnum.Falha,
|
3080
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
3081
|
+
)
|
3082
|
+
|
3083
|
+
|
3084
|
+
#VERIFICANDO SE A PRÉ VENDA FOI INCLUIDA COM SUCESSO
|
3085
|
+
console.print("VERIFICANDO SE A APROVAÇÃO FINANCEIRA FOI REALIZADA COM SUCESSO... \n")
|
3086
|
+
information_pop_up = await is_window_open("Information")
|
3087
|
+
if information_pop_up["IsOpened"] == True:
|
3088
|
+
msg_pop_up = await ocr_title(numero_nota_fiscal, "Information")
|
3089
|
+
console.print(f'retorno:{msg_pop_up.sucesso}')
|
3090
|
+
console.print(f'retorno:{msg_pop_up}')
|
3091
|
+
if msg_pop_up.sucesso == True:
|
3092
|
+
msg_retorno = msg_pop_up.retorno
|
3093
|
+
console.print(msg_retorno)
|
3094
|
+
if 'sucesso' in msg_retorno.lower():
|
3095
|
+
try:
|
3096
|
+
information_operacao_concluida = main_window.child_window(title="Information")
|
3097
|
+
btn_ok = information_operacao_concluida.child_window(class_name="TButton")
|
3098
|
+
btn_ok.click()
|
3099
|
+
await worker_sleep(4)
|
3100
|
+
except:
|
3101
|
+
pyautogui.press('enter')
|
3102
|
+
await worker_sleep(4)
|
3103
|
+
else:
|
3104
|
+
retorno = f"Pop up nao mapeado para seguimento do robo {msg_pop_up.retorno} \nEtapas Executadas:\n{steps}"
|
3299
3105
|
return RpaRetornoProcessoDTO(
|
3300
3106
|
sucesso=False,
|
3301
|
-
retorno=
|
3107
|
+
retorno=retorno,
|
3302
3108
|
status=RpaHistoricoStatusEnum.Falha,
|
3303
3109
|
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
3304
3110
|
)
|
3305
|
-
|
3111
|
+
else:
|
3112
|
+
retorno = f"Não foi possivel realizar a confirmação do msg do OCR \nEtapas Executadas:\n{steps}"
|
3113
|
+
return RpaRetornoProcessoDTO(
|
3114
|
+
sucesso=False,
|
3115
|
+
retorno=retorno,
|
3116
|
+
status=RpaHistoricoStatusEnum.Falha,
|
3117
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
3118
|
+
)
|
3119
|
+
else:
|
3120
|
+
retorno = f"Janela de confirmação de Aprovação financeira realizada com sucesso \nEtapas Executadas:\n{steps}"
|
3121
|
+
return RpaRetornoProcessoDTO(
|
3122
|
+
sucesso=False,
|
3123
|
+
retorno=retorno,
|
3124
|
+
status=RpaHistoricoStatusEnum.Falha,
|
3125
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
3126
|
+
)
|
3127
|
+
await worker_sleep(3)
|
3306
3128
|
|
3307
|
-
|
3129
|
+
|
3130
|
+
#FATURAR
|
3131
|
+
try:
|
3132
|
+
console.print("FATURAR... \n")
|
3133
|
+
app = Application().connect(class_name="TFrmPreVenda", timeout=10)
|
3134
|
+
main_window = app["TFrmPreVenda"]
|
3135
|
+
main_window.set_focus()
|
3136
|
+
|
3137
|
+
panel_Tnotebook = main_window.child_window(class_name="TNotebook", found_index=0)
|
3138
|
+
panel_Tnotebook = panel_Tnotebook.child_window(class_name="TPage", found_index=0)
|
3139
|
+
btn_faturar = panel_Tnotebook.child_window(class_name="TBitBtn", found_index=7)
|
3140
|
+
btn_faturar.click()
|
3141
|
+
console.print("BOTAO FATURAR CLICADO COM SUCESSO... \n")
|
3142
|
+
await worker_sleep(5)
|
3143
|
+
except Exception as e:
|
3144
|
+
retorno = f"Não foi possivel clicar em Faturar na tela de pre venda, erro: {e} \nEtapas Executadas:\n{steps}"
|
3145
|
+
return RpaRetornoProcessoDTO(
|
3146
|
+
sucesso=False,
|
3147
|
+
retorno=retorno,
|
3148
|
+
status=RpaHistoricoStatusEnum.Falha,
|
3149
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
3150
|
+
)
|
3151
|
+
|
3152
|
+
|
3153
|
+
console.print("Recalcular Parcelas da Pre venda... \n")
|
3154
|
+
try:
|
3155
|
+
app = Application().connect(class_name="TFrmPreVenda", timeout=40)
|
3156
|
+
main_window = app["Confirm"]
|
3157
|
+
main_window.set_focus()
|
3158
|
+
|
3159
|
+
btn_no = main_window.child_window(class_name="TButton", found_index=0)
|
3160
|
+
btn_no.click()
|
3308
3161
|
try:
|
3309
|
-
|
3162
|
+
btn_no.click()
|
3163
|
+
except:
|
3164
|
+
pass
|
3165
|
+
await worker_sleep(3)
|
3166
|
+
except:
|
3167
|
+
retorno = f"Não foi possivel clicar no pop-up 'Recalcular Parcelas da Pre venda' na tela de Pre venda \nEtapas Executadas:\n{steps}"
|
3168
|
+
return RpaRetornoProcessoDTO(
|
3169
|
+
sucesso=False,
|
3170
|
+
retorno=retorno,
|
3171
|
+
status=RpaHistoricoStatusEnum.Falha,
|
3172
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
3173
|
+
)
|
3174
|
+
|
3175
|
+
|
3176
|
+
parcelas_nf_saida_pop_up = await is_window_open("Parcelas - Nota Fiscal Saída")
|
3177
|
+
if parcelas_nf_saida_pop_up["IsOpened"] == True:
|
3178
|
+
app = Application().connect(title="Parcelas - Nota Fiscal Saída", timeout=60)
|
3179
|
+
main_window = app.window(title="Parcelas - Nota Fiscal Saída")
|
3180
|
+
main_window.set_focus()
|
3181
|
+
send_keys("%n")
|
3182
|
+
await worker_sleep(3)
|
3183
|
+
else:
|
3184
|
+
retorno = f"Não foi encontrada a Janela de Parcelas - Nota Fiscal Saída \nEtapas Executadas:\n{steps}"
|
3185
|
+
return RpaRetornoProcessoDTO(
|
3186
|
+
sucesso=False,
|
3187
|
+
retorno=retorno,
|
3188
|
+
status=RpaHistoricoStatusEnum.Falha,
|
3189
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
3190
|
+
)
|
3191
|
+
|
3192
|
+
|
3193
|
+
information_pop_up = await is_window_open("Information")
|
3194
|
+
if information_pop_up["IsOpened"] == True:
|
3195
|
+
app = Application().connect(title="Information", timeout=30)
|
3196
|
+
main_window = app["Information"]
|
3197
|
+
main_window.set_focus()
|
3198
|
+
btn_ok = main_window.child_window(class_name="TButton", found_index=0)
|
3199
|
+
btn_ok.click()
|
3200
|
+
|
3201
|
+
|
3202
|
+
await worker_sleep(15)
|
3203
|
+
|
3204
|
+
|
3205
|
+
#FATURAMENTO PRÉ-VENDA
|
3206
|
+
try:
|
3207
|
+
console.print("FATURAMENTO PRÉ-VENDA... \n")
|
3208
|
+
app = Application().connect(class_name="TFrmDadosFaturamentoPreVenda", timeout=60)
|
3209
|
+
main_window = app["TFrmDadosFaturamentoPreVenda"]
|
3210
|
+
main_window.set_focus()
|
3211
|
+
except Exception as e:
|
3212
|
+
retorno = f"Não foi encontrada a Janela Faturamento de Pré Venda \nEtapas Executadas:\n{steps}"
|
3213
|
+
return RpaRetornoProcessoDTO(
|
3214
|
+
sucesso=False,
|
3215
|
+
retorno=result,
|
3216
|
+
status=RpaHistoricoStatusEnum.Falha,
|
3217
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
3218
|
+
)
|
3219
|
+
await worker_sleep(2)
|
3220
|
+
await find_warning_nop_divergence()
|
3221
|
+
await worker_sleep(2)
|
3222
|
+
#VERIFICANDO SE POSSUI POP UP WARNING
|
3223
|
+
console.print("Verificando a presença de Warning... \n")
|
3224
|
+
warning_boo = False
|
3225
|
+
await worker_sleep(5)
|
3226
|
+
try:
|
3227
|
+
try:
|
3228
|
+
app = Application().connect(class_name="TFrmDadosFaturamentoPreVenda", timeout=10)
|
3229
|
+
main_window = app["Warning"]
|
3230
|
+
main_window.set_focus()
|
3231
|
+
|
3232
|
+
except:
|
3233
|
+
console.print('Except Verificando warnings... \n')
|
3234
|
+
app = Application().connect(class_name="Warning", timeout=10)
|
3235
|
+
main_window = app["Warning"]
|
3236
|
+
main_window.set_focus()
|
3237
|
+
console.print("Possui Warning... \n")
|
3238
|
+
await worker_sleep(2)
|
3239
|
+
await find_warning_nop_divergence()
|
3240
|
+
btn_ok = main_window.child_window(class_name="TButton", found_index=0)
|
3241
|
+
btn_ok.click()
|
3242
|
+
await worker_sleep(3)
|
3243
|
+
warning_boo = True
|
3244
|
+
except:
|
3245
|
+
console.print("Não Possui Warning... \n")
|
3246
|
+
|
3247
|
+
#ALTERANDO TRIBUTO DOS ITENS
|
3248
|
+
if warning_boo:
|
3249
|
+
try:
|
3250
|
+
console.print('Acessando a tela de Itens')
|
3310
3251
|
app = Application().connect(class_name="TFrmDadosFaturamentoPreVenda", timeout=60)
|
3311
3252
|
main_window = app["TFrmDadosFaturamentoPreVenda"]
|
3312
3253
|
main_window.set_focus()
|
3313
|
-
send_keys("%
|
3254
|
+
send_keys("%i")
|
3255
|
+
await worker_sleep(2)
|
3256
|
+
send_keys("%g")
|
3314
3257
|
await worker_sleep(2)
|
3315
3258
|
|
3316
|
-
|
3317
|
-
|
3318
|
-
|
3319
|
-
await worker_sleep(4)
|
3320
|
-
else:
|
3321
|
-
retorno = f"Não foi possivel localizar o campo 'Mensagem' \nEtapas Executadas:\n{steps}"
|
3322
|
-
return RpaRetornoProcessoDTO(
|
3323
|
-
sucesso=False,
|
3324
|
-
retorno=retorno,
|
3325
|
-
status=RpaHistoricoStatusEnum.Falha, tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
3326
|
-
)
|
3259
|
+
console.print("Conectando para realizar a alteração da tributação do produto... \n")
|
3260
|
+
app = Application().connect(class_name="TFrmDadosTributacaoProdutoPreVenda", timeout=60)
|
3261
|
+
main_window = app["TFrmDadosTributacaoProdutoPreVenda"]
|
3327
3262
|
|
3263
|
+
tpanel_dados_tributacao = main_window.child_window(class_name="TPanel", found_index=1)
|
3264
|
+
tributacao_icms_select = tpanel_dados_tributacao.child_window(class_name="TDBIComboBox", found_index=4)
|
3328
3265
|
|
3329
|
-
panel_tab_sheet = main_window.child_window(class_name="TcxTabSheet", found_index=0)
|
3330
|
-
field_observacao = panel_tab_sheet.child_window(class_name="TDBIMemo", found_index=0)
|
3331
|
-
console.print(f"Mensagem a ser adicionada\n")
|
3332
|
-
text_campo_observacao = f"Nome do Motorista: {nota.get("nomeMotorista")} - Placa: {nota.get("placaClienteCorreto")} - Quilometragem do Veículo: {nota.get("quilometragemVeiculo")}"
|
3333
|
-
console.print(f"{text_campo_observacao}\n")
|
3334
|
-
field_observacao.click()
|
3335
|
-
await worker_sleep(2)
|
3336
|
-
pyautogui.write(text_campo_observacao)
|
3337
|
-
await worker_sleep(2)
|
3338
|
-
|
3339
|
-
try:
|
3340
|
-
app = Application().connect(class_name="TFrmDadosFaturamentoPreVenda", timeout=60)
|
3341
|
-
main_window = app["TFrmDadosFaturamentoPreVenda"]
|
3342
|
-
main_window.set_focus()
|
3343
|
-
btn_ok = main_window.child_window(class_name="TBitBtn", found_index=1)
|
3344
|
-
btn_ok.click()
|
3345
|
-
except:
|
3346
|
-
btn_ok = main_window.child_window(title="&Ok")
|
3347
|
-
btn_ok.click()
|
3348
|
-
await worker_sleep(5)
|
3349
3266
|
|
3350
|
-
|
3351
|
-
|
3352
|
-
|
3353
|
-
|
3354
|
-
|
3355
|
-
|
3356
|
-
|
3357
|
-
|
3358
|
-
|
3359
|
-
|
3360
|
-
|
3361
|
-
|
3362
|
-
if btn_ok.exists() and btn_ok.is_enabled():
|
3363
|
-
btn_ok.click()
|
3364
|
-
#Este click pode ser desnecessário, é apanas uma garantia
|
3365
|
-
pyautogui.click(961, 562)
|
3366
|
-
await worker_sleep(2)
|
3367
|
-
else:
|
3368
|
-
log_msg = "Warning - Erro ao clicar em Ok, na tela de warning...\n"
|
3369
|
-
console.print(log_msg, style="bold red")
|
3370
|
-
return RpaRetornoProcessoDTO(
|
3371
|
-
sucesso=False, retorno=log_msg, status=RpaHistoricoStatusEnum.Falha, tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
3372
|
-
)
|
3373
|
-
await worker_sleep(1)
|
3374
|
-
#SELECIONANDO O TIPO DE DOCUMENTO
|
3375
|
-
try:
|
3376
|
-
console.print("Conectando a janela de pre venda para colocar modelo \n")
|
3377
|
-
app = Application().connect(class_name="TFrmDadosFaturamentoPreVenda", timeout=10)
|
3378
|
-
main_window = app["TFrmDadosFaturamentoPreVenda"]
|
3379
|
-
main_window.set_focus()
|
3380
|
-
send_keys("%p")
|
3381
|
-
await worker_sleep(2)
|
3267
|
+
if not item_arla:
|
3268
|
+
console.print("Não é item Arla ajustando tributacao... \n")
|
3269
|
+
tributacao_icms_select.click()
|
3270
|
+
await worker_sleep(1)
|
3271
|
+
set_combobox("||List", "061 - 061- MONOFASICO")
|
3272
|
+
else:
|
3273
|
+
console.print("Item Arla buscando pela aliquota do estado... \n")
|
3274
|
+
aliquota = None
|
3275
|
+
for item in conconfig_aliquota_icms:
|
3276
|
+
if cidade_cliente in item["estado"]:
|
3277
|
+
aliquota = item["aliquota"]
|
3278
|
+
break
|
3382
3279
|
|
3383
|
-
|
3384
|
-
|
3385
|
-
|
3386
|
-
modelo_select.click()
|
3280
|
+
if aliquota:
|
3281
|
+
console.print(f"A alíquota para o estado {cidade_cliente} é: {aliquota}")
|
3282
|
+
tributacao_icms_select.click()
|
3387
3283
|
await worker_sleep(1)
|
3388
|
-
|
3389
|
-
|
3390
|
-
|
3391
|
-
|
3392
|
-
tipo_selecionado = modelo_select.window_text()
|
3393
|
-
if "077" in tipo_selecionado.lower():
|
3394
|
-
console.print(f"Tipo de cobrança corretamente selecionado {tipo_selecionado}... \n")
|
3395
|
-
else:
|
3396
|
-
retorno = f"Não foi possivel selecionar o modelo do documento, tipo selecionado {tipo_selecionado}' \nEtapas Executadas:\n{steps}"
|
3397
|
-
return RpaRetornoProcessoDTO(
|
3398
|
-
sucesso=False,
|
3399
|
-
retorno=retorno,
|
3400
|
-
status=RpaHistoricoStatusEnum.Falha,
|
3401
|
-
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
3402
|
-
)
|
3403
|
-
|
3404
|
-
main_window.set_focus()
|
3405
|
-
try:
|
3406
|
-
#Clcica no OK para seguir a transmissão da pré-venda
|
3407
|
-
app = Application().connect(class_name="TFrmDadosFaturamentoPreVenda", timeout=60)
|
3408
|
-
main_window = app["TFrmDadosFaturamentoPreVenda"]
|
3409
|
-
main_window.set_focus()
|
3410
|
-
btn_ok = main_window.child_window(class_name="TBitBtn", found_index=1)
|
3411
|
-
btn_ok.click()
|
3412
|
-
except:
|
3413
|
-
btn_ok = main_window.child_window(title="&Ok")
|
3414
|
-
btn_ok.click()
|
3415
|
-
await worker_sleep(5)
|
3416
|
-
|
3417
|
-
except Exception as e:
|
3418
|
-
retorno = f"Não foi possivel selecionar o modelo do documento {e}' \nEtapas Executadas:\n{steps}"
|
3284
|
+
tributacao = f"000 - 000- ICMS - {aliquota}%"
|
3285
|
+
set_combobox("||List", tributacao)
|
3286
|
+
else:
|
3287
|
+
retorno = f"Estado {cidade_cliente} não encontrado \nEtapas Executadas:\n{steps}"
|
3419
3288
|
return RpaRetornoProcessoDTO(
|
3420
3289
|
sucesso=False,
|
3421
3290
|
retorno=retorno,
|
3422
3291
|
status=RpaHistoricoStatusEnum.Falha,
|
3423
3292
|
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
3424
|
-
|
3425
|
-
|
3426
|
-
|
3427
|
-
|
3428
|
-
|
3429
|
-
|
3430
|
-
|
3431
|
-
|
3432
|
-
|
3433
|
-
|
3434
|
-
|
3435
|
-
try:
|
3436
|
-
try:
|
3437
|
-
app = Application().connect(class_name="TFrmDadosFaturamentoPreVenda", timeout=30)
|
3438
|
-
main_window = app["Warning"]
|
3439
|
-
main_window.set_focus()
|
3440
|
-
except:
|
3441
|
-
console.print('Except')
|
3442
|
-
app = Application().connect(class_name="Warning", timeout=10)
|
3443
|
-
main_window = app["Warning"]
|
3444
|
-
main_window.set_focus()
|
3445
|
-
console.print("Possui Warning... \n")
|
3446
|
-
await find_warning_nop_divergence()
|
3447
|
-
btn_ok = main_window.child_window(class_name="TButton", found_index=0)
|
3448
|
-
btn_ok.click()
|
3449
|
-
await worker_sleep(3)
|
3450
|
-
warning_boo = True
|
3451
|
-
except:
|
3452
|
-
console.print("Não Possui Warning... \n")
|
3453
|
-
|
3293
|
+
)
|
3294
|
+
main_window.set_focus()
|
3295
|
+
send_keys("%o")
|
3296
|
+
except Exception as e:
|
3297
|
+
retorno = f"Não foi possivel corrigir a tributação do itens na Janela Faturamento de Pré Venda, erro {e} \nEtapas Executadas:\n{steps}"
|
3298
|
+
return RpaRetornoProcessoDTO(
|
3299
|
+
sucesso=False,
|
3300
|
+
retorno=result,
|
3301
|
+
status=RpaHistoricoStatusEnum.Falha,
|
3302
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
3303
|
+
)
|
3454
3304
|
|
3455
|
-
#ALTERANDO TRIBUTO DOS ITENS
|
3456
|
-
if warning_boo:
|
3457
|
-
try:
|
3458
|
-
console.print('Acessando a tela de Itens')
|
3459
|
-
app = Application().connect(class_name="TFrmDadosFaturamentoPreVenda", timeout=60)
|
3460
|
-
main_window = app["TFrmDadosFaturamentoPreVenda"]
|
3461
|
-
main_window.set_focus()
|
3462
|
-
send_keys("%i")
|
3463
|
-
await worker_sleep(2)
|
3464
|
-
send_keys("%g")
|
3465
|
-
await worker_sleep(2)
|
3466
3305
|
|
3467
|
-
|
3468
|
-
|
3469
|
-
|
3470
|
-
|
3471
|
-
|
3306
|
+
console.print("Processo de ajustar aliquota realizado com sucesso, adicionando a mensagem... \n")
|
3307
|
+
try:
|
3308
|
+
console.print("Conectando a janela de pre venda... \n")
|
3309
|
+
app = Application().connect(class_name="TFrmDadosFaturamentoPreVenda", timeout=60)
|
3310
|
+
main_window = app["TFrmDadosFaturamentoPreVenda"]
|
3311
|
+
main_window.set_focus()
|
3312
|
+
send_keys("%m")
|
3313
|
+
await worker_sleep(2)
|
3472
3314
|
|
3473
|
-
|
3474
|
-
|
3315
|
+
mensagem_tab = pyautogui.locateOnScreen(ASSETS_PATH + "\\notas_saida\\icon_mensagem.png", confidence=0.7)
|
3316
|
+
if mensagem_tab:
|
3317
|
+
pyautogui.click(mensagem_tab)
|
3318
|
+
await worker_sleep(4)
|
3319
|
+
else:
|
3320
|
+
retorno = f"Não foi possivel localizar o campo 'Mensagem' \nEtapas Executadas:\n{steps}"
|
3321
|
+
return RpaRetornoProcessoDTO(
|
3322
|
+
sucesso=False,
|
3323
|
+
retorno=retorno,
|
3324
|
+
status=RpaHistoricoStatusEnum.Falha, tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
3325
|
+
)
|
3475
3326
|
|
3476
3327
|
|
3477
|
-
|
3478
|
-
|
3479
|
-
|
3480
|
-
|
3481
|
-
|
3482
|
-
|
3483
|
-
|
3484
|
-
|
3485
|
-
|
3486
|
-
|
3487
|
-
|
3488
|
-
|
3328
|
+
panel_tab_sheet = main_window.child_window(class_name="TcxTabSheet", found_index=0)
|
3329
|
+
field_observacao = panel_tab_sheet.child_window(class_name="TDBIMemo", found_index=0)
|
3330
|
+
console.print(f"Mensagem a ser adicionada\n")
|
3331
|
+
text_campo_observacao = f"Nome do Motorista: {nota.get("nomeMotorista")} - Placa: {nota.get("placaClienteCorreto")} - Quilometragem do Veículo: {nota.get("quilometragemVeiculo")}"
|
3332
|
+
console.print(f"{text_campo_observacao}\n")
|
3333
|
+
field_observacao.click()
|
3334
|
+
await worker_sleep(2)
|
3335
|
+
pyautogui.write(text_campo_observacao)
|
3336
|
+
await worker_sleep(2)
|
3337
|
+
|
3338
|
+
try:
|
3339
|
+
app = Application().connect(class_name="TFrmDadosFaturamentoPreVenda", timeout=60)
|
3340
|
+
main_window = app["TFrmDadosFaturamentoPreVenda"]
|
3341
|
+
main_window.set_focus()
|
3342
|
+
btn_ok = main_window.child_window(class_name="TBitBtn", found_index=1)
|
3343
|
+
btn_ok.click()
|
3344
|
+
except:
|
3345
|
+
btn_ok = main_window.child_window(title="&Ok")
|
3346
|
+
btn_ok.click()
|
3347
|
+
await worker_sleep(5)
|
3489
3348
|
|
3490
|
-
|
3491
|
-
|
3492
|
-
|
3493
|
-
|
3494
|
-
|
3495
|
-
|
3496
|
-
|
3497
|
-
|
3498
|
-
|
3499
|
-
|
3500
|
-
|
3501
|
-
|
3502
|
-
|
3503
|
-
|
3504
|
-
|
3505
|
-
|
3506
|
-
|
3507
|
-
|
3508
|
-
|
3509
|
-
|
3510
|
-
|
3511
|
-
|
3512
|
-
|
3513
|
-
|
3514
|
-
|
3515
|
-
|
3349
|
+
await worker_sleep(10)
|
3350
|
+
await find_warning_nop_divergence()
|
3351
|
+
await worker_sleep(2)
|
3352
|
+
warning_pop_up = await is_window_open("Warning")
|
3353
|
+
if warning_pop_up["IsOpened"] == True:
|
3354
|
+
console.print("possui Pop-up de Warning, analisando... \n")
|
3355
|
+
app = Application().connect(title="Warning")
|
3356
|
+
main_window = app["Warning"]
|
3357
|
+
await worker_sleep(2)
|
3358
|
+
main_window.set_focus()
|
3359
|
+
console.print("Clicando em OK, para andamento do processo...\n")
|
3360
|
+
btn_ok = main_window.child_window(title="OK", class_name="TButton")
|
3361
|
+
if btn_ok.exists() and btn_ok.is_enabled():
|
3362
|
+
btn_ok.click()
|
3363
|
+
#Este click pode ser desnecessário, é apanas uma garantia
|
3364
|
+
pyautogui.click(961, 562)
|
3365
|
+
await worker_sleep(2)
|
3366
|
+
else:
|
3367
|
+
log_msg = "Warning - Erro ao clicar em Ok, na tela de warning...\n"
|
3368
|
+
console.print(log_msg, style="bold red")
|
3369
|
+
return RpaRetornoProcessoDTO(
|
3370
|
+
sucesso=False, retorno=log_msg, status=RpaHistoricoStatusEnum.Falha, tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
3371
|
+
)
|
3372
|
+
await worker_sleep(1)
|
3373
|
+
#SELECIONANDO O TIPO DE DOCUMENTO
|
3374
|
+
try:
|
3375
|
+
console.print("Conectando a janela de pre venda para colocar modelo \n")
|
3376
|
+
app = Application().connect(class_name="TFrmDadosFaturamentoPreVenda", timeout=10)
|
3377
|
+
main_window = app["TFrmDadosFaturamentoPreVenda"]
|
3378
|
+
main_window.set_focus()
|
3379
|
+
send_keys("%p")
|
3380
|
+
await worker_sleep(2)
|
3516
3381
|
|
3517
|
-
|
3518
|
-
|
3382
|
+
panel_TPage= main_window.child_window(class_name="TPageControl", found_index=0)
|
3383
|
+
panel_Ttabsheet= panel_TPage.child_window(class_name="TTabSheet", found_index=0)
|
3384
|
+
modelo_select = panel_Ttabsheet.child_window(class_name="TDBIComboBox", found_index=1)
|
3385
|
+
modelo_select.click()
|
3386
|
+
await worker_sleep(1)
|
3387
|
+
set_combobox("||List", "NFe - NOTA FISCAL ELETRONICA PROPRIA - DANFE SERIE 077")
|
3388
|
+
await worker_sleep(3)
|
3389
|
+
console.print("Verificando se o tipo de nota foi selecionado corretamente \n")
|
3390
|
+
modelo_select = panel_Ttabsheet.child_window(class_name="TDBIComboBox", found_index=1)
|
3391
|
+
tipo_selecionado = modelo_select.window_text()
|
3392
|
+
if "077" in tipo_selecionado.lower():
|
3393
|
+
console.print(f"Tipo de cobrança corretamente selecionado {tipo_selecionado}... \n")
|
3394
|
+
else:
|
3395
|
+
retorno = f"Não foi possivel selecionar o modelo do documento, tipo selecionado {tipo_selecionado}' \nEtapas Executadas:\n{steps}"
|
3519
3396
|
return RpaRetornoProcessoDTO(
|
3520
3397
|
sucesso=False,
|
3521
|
-
retorno=
|
3398
|
+
retorno=retorno,
|
3522
3399
|
status=RpaHistoricoStatusEnum.Falha,
|
3523
3400
|
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
3524
3401
|
)
|
3525
|
-
|
3526
|
-
console.print("Não possui warning para alterar tributação... \n")
|
3527
|
-
|
3528
|
-
|
3529
|
-
#ADICIONANDO MENSAGEM
|
3530
|
-
await worker_sleep(5)
|
3531
|
-
try:
|
3532
|
-
console.print("Identificando - TFrmDadosFaturamentoPreVenda 3")
|
3533
|
-
app = Application().connect(class_name="TFrmDadosFaturamentoPreVenda", timeout=10)
|
3534
|
-
main_window = app["Confirm"]
|
3402
|
+
|
3535
3403
|
main_window.set_focus()
|
3536
|
-
except:
|
3537
|
-
console.print("Identificando - TMessageForm 8")
|
3538
3404
|
try:
|
3539
|
-
|
3540
|
-
app = Application().connect(class_name="
|
3541
|
-
main_window = app["
|
3405
|
+
#Clcica no OK para seguir a transmissão da pré-venda
|
3406
|
+
app = Application().connect(class_name="TFrmDadosFaturamentoPreVenda", timeout=60)
|
3407
|
+
main_window = app["TFrmDadosFaturamentoPreVenda"]
|
3542
3408
|
main_window.set_focus()
|
3409
|
+
btn_ok = main_window.child_window(class_name="TBitBtn", found_index=1)
|
3410
|
+
btn_ok.click()
|
3543
3411
|
except:
|
3544
|
-
|
3545
|
-
|
3412
|
+
btn_ok = main_window.child_window(title="&Ok")
|
3413
|
+
btn_ok.click()
|
3414
|
+
await worker_sleep(5)
|
3415
|
+
|
3416
|
+
except Exception as e:
|
3417
|
+
retorno = f"Não foi possivel selecionar o modelo do documento {e}' \nEtapas Executadas:\n{steps}"
|
3418
|
+
return RpaRetornoProcessoDTO(
|
3419
|
+
sucesso=False,
|
3420
|
+
retorno=retorno,
|
3421
|
+
status=RpaHistoricoStatusEnum.Falha,
|
3422
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
3423
|
+
)
|
3424
|
+
else:
|
3425
|
+
console.print("Não possui pop de Warning...\n")
|
3426
|
+
|
3427
|
+
|
3428
|
+
await worker_sleep(2)
|
3429
|
+
await find_warning_nop_divergence()
|
3430
|
+
await worker_sleep(2)
|
3431
|
+
#VERIFICANDO SE POSSUI POP UP WARNING
|
3432
|
+
console.print("Verificando a presença de Warning... \n")
|
3433
|
+
warning_boo = False
|
3434
|
+
try:
|
3546
3435
|
try:
|
3547
|
-
|
3548
|
-
|
3549
|
-
|
3436
|
+
app = Application().connect(class_name="TFrmDadosFaturamentoPreVenda", timeout=30)
|
3437
|
+
main_window = app["Warning"]
|
3438
|
+
main_window.set_focus()
|
3550
3439
|
except:
|
3551
|
-
|
3552
|
-
|
3553
|
-
|
3554
|
-
main_window = app["TFrmDadosFaturamentoPreVenda"]
|
3440
|
+
console.print('Except')
|
3441
|
+
app = Application().connect(class_name="Warning", timeout=10)
|
3442
|
+
main_window = app["Warning"]
|
3555
3443
|
main_window.set_focus()
|
3556
|
-
|
3557
|
-
|
3444
|
+
console.print("Possui Warning... \n")
|
3445
|
+
await find_warning_nop_divergence()
|
3446
|
+
btn_ok = main_window.child_window(class_name="TButton", found_index=0)
|
3447
|
+
btn_ok.click()
|
3448
|
+
await worker_sleep(3)
|
3449
|
+
warning_boo = True
|
3450
|
+
except:
|
3451
|
+
console.print("Não Possui Warning... \n")
|
3558
3452
|
|
3559
|
-
|
3453
|
+
|
3454
|
+
#ALTERANDO TRIBUTO DOS ITENS
|
3455
|
+
if warning_boo:
|
3560
3456
|
try:
|
3561
|
-
console.print(
|
3562
|
-
app = Application().connect(class_name="
|
3563
|
-
main_window = app["
|
3457
|
+
console.print('Acessando a tela de Itens')
|
3458
|
+
app = Application().connect(class_name="TFrmDadosFaturamentoPreVenda", timeout=60)
|
3459
|
+
main_window = app["TFrmDadosFaturamentoPreVenda"]
|
3564
3460
|
main_window.set_focus()
|
3461
|
+
send_keys("%i")
|
3462
|
+
await worker_sleep(2)
|
3463
|
+
send_keys("%g")
|
3464
|
+
await worker_sleep(2)
|
3565
3465
|
|
3566
|
-
|
3567
|
-
|
3568
|
-
|
3569
|
-
|
3570
|
-
|
3571
|
-
|
3572
|
-
|
3573
|
-
|
3574
|
-
|
3575
|
-
|
3466
|
+
await find_warning_nop_divergence()
|
3467
|
+
await worker_sleep(2)
|
3468
|
+
console.print("Conectando para realizar a alteração da tributação do produto... \n")
|
3469
|
+
app = Application().connect(class_name="TFrmDadosTributacaoProdutoPreVenda", timeout=60)
|
3470
|
+
main_window = app["TFrmDadosTributacaoProdutoPreVenda"]
|
3471
|
+
|
3472
|
+
tpanel_dados_tributacao = main_window.child_window(class_name="TPanel", found_index=1)
|
3473
|
+
tributacao_icms_select = tpanel_dados_tributacao.child_window(class_name="TDBIComboBox", found_index=4)
|
3474
|
+
|
3475
|
+
|
3476
|
+
if not item_arla:
|
3477
|
+
console.print("Não é item Arla ajustando tributacao... \n")
|
3478
|
+
tributacao_icms_select.click()
|
3479
|
+
await worker_sleep(1)
|
3480
|
+
set_combobox("||List", "061 - 061- MONOFASICO")
|
3576
3481
|
else:
|
3577
|
-
|
3578
|
-
|
3579
|
-
|
3580
|
-
|
3581
|
-
|
3582
|
-
|
3583
|
-
|
3482
|
+
console.print("Item Arla buscando pela aliquota do estado... \n")
|
3483
|
+
aliquota = None
|
3484
|
+
for item in conconfig_aliquota_icms:
|
3485
|
+
if cidade_cliente in item["estado"]:
|
3486
|
+
aliquota = item["aliquota"]
|
3487
|
+
break
|
3488
|
+
|
3489
|
+
if aliquota:
|
3490
|
+
console.print(f"A alíquota para o estado {cidade_cliente} é: {aliquota}")
|
3491
|
+
tributacao_icms_select.click()
|
3492
|
+
await worker_sleep(1)
|
3493
|
+
tributacao = f"000 - 000- ICMS - {aliquota}%"
|
3494
|
+
set_combobox("||List", tributacao)
|
3495
|
+
else:
|
3496
|
+
retorno = f"Estado {cidade_cliente} não encontrado \nEtapas Executadas:\n{steps}"
|
3497
|
+
return RpaRetornoProcessoDTO(
|
3498
|
+
sucesso=False,
|
3499
|
+
retorno=retorno,
|
3500
|
+
status=RpaHistoricoStatusEnum.Falha,
|
3501
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
3502
|
+
)
|
3503
|
+
main_window.set_focus()
|
3504
|
+
send_keys("%o")
|
3505
|
+
await worker_sleep(1)
|
3506
|
+
try:
|
3507
|
+
#find Message corrigir tributação
|
3508
|
+
app = Application().connect(title="Corrige tributação", timeout=60)
|
3509
|
+
corrige_tribute = app["Corrige tributação"]
|
3510
|
+
corrige_tribute.child_window(title="&Não").click()
|
3511
|
+
pyautogui.click(1109, 602)
|
3512
|
+
except:
|
3513
|
+
pyautogui.click(1109, 602)
|
3514
|
+
console.print("Não encontrou a mensagem de corrigir tributacao\n")
|
3584
3515
|
|
3585
|
-
#Transmitir e imprimir
|
3586
|
-
try:
|
3587
|
-
app = Application().connect(title="Transmição NF-e!",class_name="TMessageForm", timeout=10)
|
3588
|
-
transmission_window = app["Transmição NF-e!"]
|
3589
|
-
transmission_window.set_focus()
|
3590
|
-
transmission_window.child_window(title='Transmitir e &Imprimir', class_name="TButton").click()
|
3591
3516
|
except Exception as e:
|
3592
|
-
retorno = f"Não
|
3517
|
+
retorno = f"Não foi possivel corrigir a tributação do itens na Janela Faturamento de Pré Venda, erro {e} \nEtapas Executadas:\n{steps}"
|
3593
3518
|
return RpaRetornoProcessoDTO(
|
3594
3519
|
sucesso=False,
|
3595
|
-
retorno=
|
3596
|
-
status=RpaHistoricoStatusEnum.Falha,
|
3520
|
+
retorno=result,
|
3521
|
+
status=RpaHistoricoStatusEnum.Falha,
|
3522
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
3597
3523
|
)
|
3524
|
+
else:
|
3525
|
+
console.print("Não possui warning para alterar tributação... \n")
|
3526
|
+
|
3598
3527
|
|
3599
|
-
|
3528
|
+
#ADICIONANDO MENSAGEM
|
3529
|
+
await worker_sleep(5)
|
3530
|
+
try:
|
3531
|
+
console.print("Identificando - TFrmDadosFaturamentoPreVenda 3")
|
3532
|
+
app = Application().connect(class_name="TFrmDadosFaturamentoPreVenda", timeout=10)
|
3533
|
+
main_window = app["Confirm"]
|
3534
|
+
main_window.set_focus()
|
3535
|
+
except:
|
3536
|
+
console.print("Identificando - TMessageForm 8")
|
3537
|
+
try:
|
3538
|
+
await worker_sleep(3)
|
3539
|
+
app = Application().connect(class_name="TMessageForm", timeout=10, title='Confirm')
|
3540
|
+
main_window = app["TMessageForm"]
|
3541
|
+
main_window.set_focus()
|
3542
|
+
except:
|
3543
|
+
console.print("TMessageForm não encontrado")
|
3544
|
+
|
3545
|
+
try:
|
3546
|
+
btn_yes = main_window.child_window(class_name="TButton", title="&Yes")
|
3547
|
+
btn_yes.click()
|
3548
|
+
console.print("Clicou Yes")
|
3549
|
+
except:
|
3550
|
+
await worker_sleep(3)
|
3551
|
+
console.print("Clicando em 'OK' na tela de faturamente pré-venda")
|
3552
|
+
app = Application().connect(class_name="TFrmDadosFaturamentoPreVenda", timeout=10)
|
3553
|
+
main_window = app["TFrmDadosFaturamentoPreVenda"]
|
3554
|
+
main_window.set_focus()
|
3555
|
+
main_window.child_window(title="&OK", class_name="TBitBtn").click()
|
3556
|
+
await find_warning_nop_divergence()
|
3557
|
+
|
3558
|
+
#CONFIRMANDO NA TELA DE PRE VENDA
|
3559
|
+
try:
|
3560
|
+
console.print("CONFIRMANDO POP UP DE Deseja realmente confirmar esta PRÉ VENDA ... \n")
|
3561
|
+
app = Application().connect(class_name="TFrmPreVenda", timeout=10)
|
3562
|
+
main_window = app["Confirm"]
|
3563
|
+
main_window.set_focus()
|
3564
|
+
|
3565
|
+
btn_yes = main_window.child_window(class_name="TButton", found_index=1)
|
3566
|
+
btn_yes.click()
|
3567
|
+
await worker_sleep(3)
|
3568
|
+
except Exception as e:
|
3569
|
+
await worker_sleep(6)
|
3570
|
+
app = Application().connect(title="Transmição NF-e!",class_name="TMessageForm", timeout=10)
|
3571
|
+
transmission_window = app["Transmição NF-e!"]
|
3572
|
+
transmission_window.set_focus()
|
3573
|
+
if transmission_window.exists():
|
3574
|
+
console.print("Encontrou a tela de Transmissão da NF-e")
|
3575
|
+
else:
|
3576
|
+
retorno = f"Não foi possivel clicar para confirmar a janela 'Deseja realmente confirmar esta pre-venda' \nEtapas Executadas:\n{steps}"
|
3577
|
+
return RpaRetornoProcessoDTO(
|
3578
|
+
sucesso=False,
|
3579
|
+
retorno=retorno,
|
3580
|
+
status=RpaHistoricoStatusEnum.Falha,
|
3581
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
3582
|
+
)
|
3600
3583
|
|
3584
|
+
#Transmitir e imprimir
|
3585
|
+
try:
|
3586
|
+
app = Application().connect(title="Transmição NF-e!",class_name="TMessageForm", timeout=10)
|
3587
|
+
transmission_window = app["Transmição NF-e!"]
|
3588
|
+
transmission_window.set_focus()
|
3589
|
+
transmission_window.child_window(title='Transmitir e &Imprimir', class_name="TButton").click()
|
3601
3590
|
except Exception as e:
|
3602
|
-
retorno = f"Não
|
3591
|
+
retorno = f"Não encontrou a tela de Transmissão da NF-e, erro {e} \nEtapas Executadas:\n{steps}"
|
3603
3592
|
return RpaRetornoProcessoDTO(
|
3604
3593
|
sucesso=False,
|
3605
3594
|
retorno=retorno,
|
3606
3595
|
status=RpaHistoricoStatusEnum.Falha, tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
3607
3596
|
)
|
3608
3597
|
|
3609
|
-
await worker_sleep(
|
3598
|
+
await worker_sleep(25)
|
3610
3599
|
|
3611
|
-
|
3612
|
-
|
3613
|
-
|
3614
|
-
|
3615
|
-
|
3616
|
-
|
3617
|
-
|
3618
|
-
|
3619
|
-
|
3620
|
-
await worker_sleep(3)
|
3621
|
-
break
|
3622
|
-
except Exception as e:
|
3623
|
-
console.print(f"Tela 'Print' nao encontrada. Tentativa: {current_try_print+1} de {try_print} \n")
|
3624
|
-
current_try_print+=1
|
3625
|
-
await worker_sleep(25)
|
3626
|
-
|
3600
|
+
except Exception as e:
|
3601
|
+
retorno = f"Não foi possivel adicionar a 'Mensagem' na tela de Faturamento de pre venda, erro {e} \nEtapas Executadas:\n{steps}"
|
3602
|
+
return RpaRetornoProcessoDTO(
|
3603
|
+
sucesso=False,
|
3604
|
+
retorno=retorno,
|
3605
|
+
status=RpaHistoricoStatusEnum.Falha, tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
3606
|
+
)
|
3607
|
+
|
3608
|
+
await worker_sleep(20)
|
3627
3609
|
|
3628
|
-
|
3629
|
-
|
3630
|
-
|
3631
|
-
sucesso=False,
|
3632
|
-
retorno=retorno,
|
3633
|
-
status=RpaHistoricoStatusEnum.Falha,
|
3634
|
-
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
3635
|
-
)
|
3636
|
-
|
3637
|
-
console.print(f"NAVEGANDO NA TELA DE SALVAR RELATORIO\n")
|
3638
|
-
#INSERINDO O DIRETORIO E SALVANDO O ARQUIVO
|
3610
|
+
try_print=10
|
3611
|
+
current_try_print=0
|
3612
|
+
while current_try_print <= try_print:
|
3639
3613
|
try:
|
3640
|
-
app = Application().connect(
|
3641
|
-
main_window = app["
|
3642
|
-
|
3614
|
+
app = Application().connect(class_name="TFrmAguarde", timeout=60)
|
3615
|
+
main_window = app["TppPrintDialog"]
|
3616
|
+
tpanel_btn_ok = main_window.child_window(class_name="TPanel", found_index=1)
|
3617
|
+
btn_ok_print_screen = tpanel_btn_ok.child_window(class_name="TButton", found_index=1)
|
3618
|
+
btn_ok_print_screen.click()
|
3619
|
+
await worker_sleep(3)
|
3620
|
+
break
|
3621
|
+
except Exception as e:
|
3622
|
+
console.print(f"Tela 'Print' nao encontrada. Tentativa: {current_try_print+1} de {try_print} \n")
|
3623
|
+
current_try_print+=1
|
3624
|
+
await worker_sleep(25)
|
3625
|
+
|
3643
3626
|
|
3644
|
-
|
3645
|
-
|
3646
|
-
|
3627
|
+
if current_try_print >= try_print:
|
3628
|
+
retorno = f"Não foi encontrada a tela para a impressão da nova venda \nEtapas Executadas:\n{steps}"
|
3629
|
+
return RpaRetornoProcessoDTO(
|
3630
|
+
sucesso=False,
|
3631
|
+
retorno=retorno,
|
3632
|
+
status=RpaHistoricoStatusEnum.Falha,
|
3633
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
3634
|
+
)
|
3635
|
+
|
3636
|
+
console.print(f"NAVEGANDO NA TELA DE SALVAR RELATORIO\n")
|
3637
|
+
#INSERINDO O DIRETORIO E SALVANDO O ARQUIVO
|
3638
|
+
try:
|
3639
|
+
app = Application().connect(title="Salvar Saída de Impressão como")
|
3640
|
+
main_window = app["Dialog"]
|
3641
|
+
console.print("Tela 'Salvar' encontrada!")
|
3647
3642
|
|
3648
|
-
|
3649
|
-
|
3650
|
-
|
3651
|
-
main_window.type_keys("%l")
|
3652
|
-
console.print("Arquivo salvo com sucesso...\n")
|
3653
|
-
await worker_sleep(8)
|
3654
|
-
except Exception as e:
|
3655
|
-
retorno = f"Não foi salvar o arquivo com a nova venda, erro {e} \nEtapas Executadas:\n{steps}"
|
3656
|
-
return RpaRetornoProcessoDTO(
|
3657
|
-
sucesso=False,
|
3658
|
-
retorno=result,
|
3659
|
-
status=RpaHistoricoStatusEnum.Falha,
|
3660
|
-
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
3661
|
-
)
|
3643
|
+
console.print("Interagindo com a tela 'Salvar'...\n")
|
3644
|
+
username = getpass.getuser()
|
3645
|
+
path_to_txt = f"C:\\Users\\{username}\\Downloads\\NOVA VENDA {numero_cupom_fiscal}"
|
3662
3646
|
|
3663
|
-
|
3664
|
-
|
3647
|
+
main_window.type_keys("%n")
|
3648
|
+
pyautogui.write(path_to_txt)
|
3649
|
+
await worker_sleep(1)
|
3650
|
+
main_window.type_keys("%l")
|
3651
|
+
console.print("Arquivo salvo com sucesso...\n")
|
3652
|
+
await worker_sleep(8)
|
3653
|
+
except Exception as e:
|
3654
|
+
retorno = f"Não foi salvar o arquivo com a nova venda, erro {e} \nEtapas Executadas:\n{steps}"
|
3655
|
+
return RpaRetornoProcessoDTO(
|
3656
|
+
sucesso=False,
|
3657
|
+
retorno=result,
|
3658
|
+
status=RpaHistoricoStatusEnum.Falha,
|
3659
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
3660
|
+
)
|
3665
3661
|
|
3666
|
-
|
3667
|
-
|
3668
|
-
|
3669
|
-
|
3670
|
-
|
3671
|
-
|
3672
|
-
|
3673
|
-
|
3674
|
-
|
3675
|
-
|
3676
|
-
|
3677
|
-
|
3678
|
-
|
3679
|
-
|
3662
|
+
with open(f"{path_to_txt}.pdf", 'rb') as file:
|
3663
|
+
file_bytes = io.BytesIO(file.read())
|
3664
|
+
|
3665
|
+
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
3666
|
+
desArquivo = f"NOVA VENDA {numero_cupom_fiscal}.pdf"
|
3667
|
+
try:
|
3668
|
+
await send_file(historico_id, desArquivo, "pdf", file_bytes, file_extension="pdf")
|
3669
|
+
os.remove(f"{path_to_txt}.pdf")
|
3670
|
+
except Exception as e:
|
3671
|
+
result = f"Arquivo NOVA VENDA gerado com sucesso, porém gerou erro ao realizar o envio para o backoffice {e} - Arquivo ainda salvo na dispositivo utilizado no diretório {path_to_txt} !"
|
3672
|
+
console.print(result, style="bold red")
|
3673
|
+
return RpaRetornoProcessoDTO(
|
3674
|
+
sucesso=False,
|
3675
|
+
retorno=result,
|
3676
|
+
status=RpaHistoricoStatusEnum.Falha,
|
3677
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
3678
|
+
)
|
3680
3679
|
|
3681
|
-
|
3682
|
-
|
3683
|
-
|
3684
|
-
|
3685
|
-
|
3686
|
-
|
3687
|
-
|
3680
|
+
information_pop_up = await is_window_open("Information")
|
3681
|
+
if information_pop_up["IsOpened"] == True:
|
3682
|
+
app = Application().connect(title="Information", timeout=30)
|
3683
|
+
main_window = app["Information"]
|
3684
|
+
main_window.set_focus()
|
3685
|
+
btn_ok = main_window.child_window(class_name="TButton", found_index=0)
|
3686
|
+
btn_ok.click()
|
3688
3687
|
|
3689
3688
|
|
3690
|
-
|
3691
|
-
|
3692
|
-
|
3693
|
-
|
3694
|
-
|
3695
|
-
|
3689
|
+
try:
|
3690
|
+
app = Application().connect(class_name="TFrmProcessamentoFEe2", timeout=10)
|
3691
|
+
main_window = app["TFrmProcessamentoFEe2"]
|
3692
|
+
main_window.close()
|
3693
|
+
except Exception as e:
|
3694
|
+
console.print("Janela TFrmDadosFaturamentoPreVenda ja fechada")
|
3696
3695
|
|
3697
3696
|
|
3698
|
-
|
3699
|
-
|
3700
|
-
|
3701
|
-
|
3702
|
-
|
3703
|
-
|
3704
|
-
|
3705
|
-
|
3697
|
+
await worker_sleep(5)
|
3698
|
+
is_confirm_pop_up = False
|
3699
|
+
try:
|
3700
|
+
app = Application().connect(class_name="TFrmGerenciadorNFe2", timeout=10)
|
3701
|
+
main_window = app["Confirm"]
|
3702
|
+
is_confirm_pop_up = True
|
3703
|
+
except:
|
3704
|
+
pass
|
3706
3705
|
|
3707
3706
|
|
3708
|
-
|
3709
|
-
|
3710
|
-
|
3711
|
-
|
3712
|
-
|
3713
|
-
|
3714
|
-
|
3715
|
-
|
3707
|
+
if is_confirm_pop_up == True:
|
3708
|
+
msg_text = await ocr_by_class(numero_cupom_fiscal,"TFrmGerenciadorNFe2", "Confirm")
|
3709
|
+
if 'imprimir' in msg_text.retorno.lower():
|
3710
|
+
app = Application().connect(class_name="TFrmGerenciadorNFe2", timeout=10)
|
3711
|
+
main_window = app["Confirm"]
|
3712
|
+
main_window.set_focus()
|
3713
|
+
send_keys("%n")
|
3714
|
+
|
3716
3715
|
|
3717
|
-
|
3718
|
-
|
3716
|
+
#Fechar telas Antes de fazer nova pesquisa
|
3717
|
+
await worker_sleep(10)
|
3718
|
+
try:
|
3719
|
+
app = Application().connect(class_name="TFrmProcessamentoNFe2", timeout=10)
|
3720
|
+
window_lancando_nota = app["TFrmProcessamentoNFe2"]
|
3721
|
+
window_lancando_nota.set_focus()
|
3722
|
+
fechar_tela_processamento = "assets\\emsys\\button_fechar.PNG"
|
3719
3723
|
try:
|
3720
|
-
|
3721
|
-
|
3722
|
-
|
3723
|
-
|
3724
|
+
button_location = pyautogui.locateCenterOnScreen(
|
3725
|
+
fechar_tela_processamento, confidence=0.6
|
3726
|
+
)
|
3727
|
+
if button_location:
|
3728
|
+
pyautogui.click(button_location)
|
3729
|
+
console.print("Botão 'Fechar' clicado com sucesso!")
|
3730
|
+
except pyautogui.ImageNotFoundException:
|
3731
|
+
window_rect = main_window.rectangle()
|
3732
|
+
console.print(f"Area que sera utulizada para o recorte {window_rect}...\n")
|
3724
3733
|
try:
|
3725
3734
|
button_location = pyautogui.locateCenterOnScreen(
|
3726
|
-
fechar_tela_processamento,
|
3735
|
+
fechar_tela_processamento,
|
3736
|
+
region=(
|
3737
|
+
window_rect.left,
|
3738
|
+
window_rect.top,
|
3739
|
+
window_rect.width(),
|
3740
|
+
window_rect.height(),
|
3741
|
+
),
|
3727
3742
|
)
|
3728
3743
|
if button_location:
|
3729
|
-
|
3730
|
-
|
3731
|
-
|
3732
|
-
window_rect = main_window.rectangle()
|
3733
|
-
console.print(f"Area que sera utulizada para o recorte {window_rect}...\n")
|
3734
|
-
try:
|
3735
|
-
button_location = pyautogui.locateCenterOnScreen(
|
3736
|
-
fechar_tela_processamento,
|
3737
|
-
region=(
|
3738
|
-
window_rect.left,
|
3739
|
-
window_rect.top,
|
3740
|
-
window_rect.width(),
|
3741
|
-
window_rect.height(),
|
3742
|
-
),
|
3744
|
+
button_location = (
|
3745
|
+
button_location.x + window_rect.left,
|
3746
|
+
button_location.y + window_rect.top,
|
3743
3747
|
)
|
3744
|
-
|
3745
|
-
|
3746
|
-
button_location.x + window_rect.left,
|
3747
|
-
button_location.y + window_rect.top,
|
3748
|
-
)
|
3749
|
-
console.print(
|
3750
|
-
f"Botão encontrado nas coordenadas: {button_location}"
|
3751
|
-
)
|
3752
|
-
pyautogui.click(button_location)
|
3753
|
-
await worker_sleep(10)
|
3754
|
-
except pyautogui.ImageNotFoundException:
|
3755
|
-
retorno = f"Não foi possivel fechar a tela de processamento, Error: {e} \nEtapas Executadas:\n{steps}"
|
3756
|
-
console.print(f"Não foi possivel fechar a tela de processamento, Error: {e}...\n tentando inserir via posição...\n")
|
3757
|
-
return RpaRetornoProcessoDTO(
|
3758
|
-
sucesso=False,
|
3759
|
-
retorno=retorno,
|
3760
|
-
status=RpaHistoricoStatusEnum.Falha,
|
3761
|
-
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
3748
|
+
console.print(
|
3749
|
+
f"Botão encontrado nas coordenadas: {button_location}"
|
3762
3750
|
)
|
3763
|
-
|
3764
|
-
|
3765
|
-
|
3751
|
+
pyautogui.click(button_location)
|
3752
|
+
await worker_sleep(10)
|
3753
|
+
except pyautogui.ImageNotFoundException:
|
3754
|
+
retorno = f"Não foi possivel fechar a tela de processamento, Error: {e} \nEtapas Executadas:\n{steps}"
|
3755
|
+
console.print(f"Não foi possivel fechar a tela de processamento, Error: {e}...\n tentando inserir via posição...\n")
|
3766
3756
|
return RpaRetornoProcessoDTO(
|
3767
3757
|
sucesso=False,
|
3768
3758
|
retorno=retorno,
|
3769
3759
|
status=RpaHistoricoStatusEnum.Falha,
|
3770
3760
|
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
3771
3761
|
)
|
3762
|
+
except Exception as e:
|
3763
|
+
retorno = f"Não foi possivel fechar a tela de processamento, Error:{e} \nEtapas Executadas:\n{steps}"
|
3764
|
+
console.print(f"Não foi possivel fechar a tela de processamento, Error:{e}...\n tentando inserir via posição...\n")
|
3765
|
+
return RpaRetornoProcessoDTO(
|
3766
|
+
sucesso=False,
|
3767
|
+
retorno=retorno,
|
3768
|
+
status=RpaHistoricoStatusEnum.Falha,
|
3769
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
3770
|
+
)
|
3771
|
+
except:
|
3772
|
+
console.print("Janela TFrmProcessamentoNFe2 ja fechada")
|
3773
|
+
|
3774
|
+
|
3775
|
+
console.print("Verificando se possui pop-up imprimir boleta")
|
3776
|
+
boleta_screen = await is_window_open("Confirm")
|
3777
|
+
if boleta_screen["IsOpened"] == True:
|
3778
|
+
console.print("Janela aberta, fechando")
|
3779
|
+
try:
|
3780
|
+
console.print("Confirm")
|
3781
|
+
app = Application().connect(title="Confirm", timeout=10)
|
3782
|
+
main_window = app["Confirm"]
|
3783
|
+
main_window.set_focus()
|
3772
3784
|
except:
|
3773
|
-
console.print("
|
3785
|
+
console.print("Identificando - TMessageForm 7")
|
3786
|
+
app = Application().connect(class_name="TMessageForm", timeout=10, title='Confirm')
|
3787
|
+
main_window = app["TMessageForm"]
|
3788
|
+
main_window.set_focus()
|
3774
3789
|
|
3775
|
-
|
3776
|
-
|
3777
|
-
boleta_screen = await is_window_open("Confirm")
|
3778
|
-
if boleta_screen["IsOpened"] == True:
|
3779
|
-
console.print("Janela aberta, fechando")
|
3780
|
-
try:
|
3781
|
-
console.print("Confirm")
|
3782
|
-
app = Application().connect(title="Confirm", timeout=10)
|
3783
|
-
main_window = app["Confirm"]
|
3784
|
-
main_window.set_focus()
|
3785
|
-
except:
|
3786
|
-
console.print("Identificando - TMessageForm 7")
|
3787
|
-
app = Application().connect(class_name="TMessageForm", timeout=10, title='Confirm')
|
3788
|
-
main_window = app["TMessageForm"]
|
3789
|
-
main_window.set_focus()
|
3790
|
+
btn_no = main_window.child_window(class_name="TButton", title="&No")
|
3791
|
+
btn_no.click()
|
3790
3792
|
|
3791
|
-
btn_no = main_window.child_window(class_name="TButton", title="&No")
|
3792
|
-
btn_no.click()
|
3793
3793
|
|
3794
|
+
await worker_sleep(7)
|
3795
|
+
erro_screen = await is_window_open_by_class("TFrmDadosFaturamentoPreVenda","Confirm")
|
3796
|
+
if erro_screen["IsOpened"] == True:
|
3797
|
+
console.print("Janela aberta, fechando")
|
3798
|
+
try:
|
3799
|
+
console.print("Identificando - TFrmDadosFaturamentoPreVenda 4")
|
3800
|
+
app = Application().connect(class_name="TFrmDadosFaturamentoPreVenda", timeout=10)
|
3801
|
+
main_window = app["Confirm"]
|
3802
|
+
main_window.set_focus()
|
3803
|
+
except:
|
3804
|
+
console.print("Identificando - TMessageForm 9")
|
3805
|
+
app = Application().connect(class_name="TMessageForm", timeout=10, title='Confirm')
|
3806
|
+
main_window = app["TMessageForm"]
|
3807
|
+
main_window.set_focus()
|
3794
3808
|
|
3795
|
-
|
3796
|
-
|
3797
|
-
|
3798
|
-
console.print("Janela aberta, fechando")
|
3799
|
-
try:
|
3800
|
-
console.print("Identificando - TFrmDadosFaturamentoPreVenda 4")
|
3801
|
-
app = Application().connect(class_name="TFrmDadosFaturamentoPreVenda", timeout=10)
|
3802
|
-
main_window = app["Confirm"]
|
3803
|
-
main_window.set_focus()
|
3804
|
-
except:
|
3805
|
-
console.print("Identificando - TMessageForm 9")
|
3806
|
-
app = Application().connect(class_name="TMessageForm", timeout=10, title='Confirm')
|
3807
|
-
main_window = app["TMessageForm"]
|
3808
|
-
main_window.set_focus()
|
3809
|
+
btn_no = main_window.child_window(class_name="TButton", title="&No")
|
3810
|
+
btn_no.click()
|
3811
|
+
|
3809
3812
|
|
3810
|
-
|
3811
|
-
|
3812
|
-
|
3813
|
+
await worker_sleep(10)
|
3814
|
+
console.print("Verificando se a tela de Mensagem esta aberta")
|
3815
|
+
erro_screen = await is_window_open_by_class("TMemo","TMemo")
|
3816
|
+
if erro_screen["IsOpened"] == True:
|
3817
|
+
console.print("Janela aberta, fechando")
|
3818
|
+
app = Application().connect(class_name="TMemo", timeout=10)
|
3819
|
+
main_window = app["TMemo"]
|
3820
|
+
main_window.set_focus()
|
3821
|
+
await worker_sleep(5)
|
3822
|
+
main_window.close()
|
3823
|
+
|
3813
3824
|
|
3814
|
-
|
3815
|
-
|
3816
|
-
|
3817
|
-
|
3818
|
-
|
3819
|
-
app = Application().connect(class_name="
|
3820
|
-
main_window = app["
|
3825
|
+
console.print("Verificando se a tela de Faturamento Pre venda esta aberta")
|
3826
|
+
close_dados_faturamento = await is_window_open_by_class("TFrmDadosFaturamentoPreVenda","TFrmDadosFaturamentoPreVenda")
|
3827
|
+
if close_dados_faturamento["IsOpened"] == True:
|
3828
|
+
console.print("Janela aberta, fechando")
|
3829
|
+
try:
|
3830
|
+
app = Application().connect(class_name="TFrmDadosFaturamentoPreVenda", timeout=60)
|
3831
|
+
main_window = app["TFrmDadosFaturamentoPreVenda"]
|
3821
3832
|
main_window.set_focus()
|
3822
|
-
|
3823
|
-
|
3824
|
-
|
3825
|
-
|
3826
|
-
|
3827
|
-
|
3828
|
-
if close_dados_faturamento["IsOpened"] == True:
|
3829
|
-
console.print("Janela aberta, fechando")
|
3830
|
-
try:
|
3831
|
-
app = Application().connect(class_name="TFrmDadosFaturamentoPreVenda", timeout=60)
|
3832
|
-
main_window = app["TFrmDadosFaturamentoPreVenda"]
|
3833
|
-
main_window.set_focus()
|
3834
|
-
btn_cancelar = main_window.child_window(class_name="TBitBtn", found_index=0)
|
3835
|
-
btn_cancelar.click()
|
3836
|
-
except:
|
3837
|
-
btn_cancelar = main_window.child_window(title="&Cancela")
|
3838
|
-
btn_cancelar.click()
|
3839
|
-
|
3833
|
+
btn_cancelar = main_window.child_window(class_name="TBitBtn", found_index=0)
|
3834
|
+
btn_cancelar.click()
|
3835
|
+
except:
|
3836
|
+
btn_cancelar = main_window.child_window(title="&Cancela")
|
3837
|
+
btn_cancelar.click()
|
3838
|
+
|
3840
3839
|
|
3841
|
-
|
3842
|
-
|
3843
|
-
|
3844
|
-
|
3845
|
-
|
3846
|
-
|
3847
|
-
|
3848
|
-
|
3849
|
-
|
3850
|
-
|
3851
|
-
|
3852
|
-
|
3853
|
-
|
3840
|
+
await worker_sleep(10)
|
3841
|
+
console.print("Verificando se a tela de Faturamento Pre venda esta aberta")
|
3842
|
+
close_dados_faturamento = await is_window_open_by_class("TFrmDadosFaturamentoPreVenda","TFrmDadosFaturamentoPreVenda")
|
3843
|
+
if close_dados_faturamento["IsOpened"] == True:
|
3844
|
+
console.print("Janela aberta, fechando")
|
3845
|
+
try:
|
3846
|
+
app = Application().connect(class_name="TFrmDadosFaturamentoPreVenda", timeout=180)
|
3847
|
+
main_window = app["TFrmDadosFaturamentoPreVenda"]
|
3848
|
+
main_window.set_focus()
|
3849
|
+
await worker_sleep(2)
|
3850
|
+
main_window.close()
|
3851
|
+
except Exception as e:
|
3852
|
+
console.print(f"Erro ao fechar a janela de dados faturamento pre venda {e}")
|
3854
3853
|
|
3855
3854
|
|
3856
|
-
|
3857
|
-
|
3858
|
-
|
3859
|
-
|
3860
|
-
|
3861
|
-
|
3862
|
-
|
3863
|
-
|
3864
|
-
|
3865
|
-
|
3866
|
-
|
3855
|
+
await worker_sleep(5)
|
3856
|
+
console.print("Verificando se a tela de Gerenciador esta aberta")
|
3857
|
+
window_gerenciador_screen = await is_window_open_by_class("TFrmGerenciadorNFe2","TFrmGerenciadorNFe2")
|
3858
|
+
if window_gerenciador_screen["IsOpened"] == True:
|
3859
|
+
app = Application().connect(class_name="TFrmGerenciadorNFe2", timeout=10)
|
3860
|
+
window_gerenciador = app["TFrmGerenciadorNFe2"]
|
3861
|
+
window_gerenciador.set_focus()
|
3862
|
+
await worker_sleep(2)
|
3863
|
+
window_gerenciador.close()
|
3864
|
+
else:
|
3865
|
+
console.print("Janela TFrmGerenciadorNFe2 ja fechada")
|
3867
3866
|
|
3868
3867
|
|
3869
|
-
|
3870
|
-
|
3871
|
-
|
3872
|
-
|
3873
|
-
|
3874
|
-
|
3875
|
-
|
3876
|
-
|
3877
|
-
|
3878
|
-
|
3879
|
-
|
3868
|
+
await worker_sleep(10)
|
3869
|
+
console.print("Verificando se a tela de Pre venda esta aberta")
|
3870
|
+
window_gerenciador_screen = await is_window_open_by_class("TFrmPreVenda","TFrmPreVenda")
|
3871
|
+
if window_gerenciador_screen["IsOpened"] == True:
|
3872
|
+
app = Application().connect(class_name="TFrmPreVenda", timeout=10)
|
3873
|
+
window_gerenciador = app["TFrmPreVenda"]
|
3874
|
+
window_gerenciador.set_focus()
|
3875
|
+
await worker_sleep(2)
|
3876
|
+
window_gerenciador.close()
|
3877
|
+
else:
|
3878
|
+
console.print("Janela TFrmPreVenda ja fechada")
|
3879
|
+
|
3880
3880
|
|
3881
|
-
|
3882
|
-
|
3883
|
-
retorno = f"Não foi possivel concluir o processo de pré venda {e} \nEtapas Executadas:\n{steps}"
|
3884
|
-
return RpaRetornoProcessoDTO(
|
3885
|
-
sucesso=False,
|
3886
|
-
retorno=retorno,
|
3887
|
-
status=RpaHistoricoStatusEnum.Falha,
|
3888
|
-
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
3889
|
-
)
|
3890
|
-
else:
|
3891
|
-
retorno = f"{preenchimento_header_pre_venda.retorno} \nEtapas Executadas:\n{steps}"
|
3881
|
+
except Exception as e:
|
3882
|
+
retorno = f"Não foi possivel concluir o processo de pré venda {e} \nEtapas Executadas:\n{steps}"
|
3892
3883
|
return RpaRetornoProcessoDTO(
|
3893
3884
|
sucesso=False,
|
3894
3885
|
retorno=retorno,
|
3895
3886
|
status=RpaHistoricoStatusEnum.Falha,
|
3896
3887
|
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
3897
|
-
|
3888
|
+
)
|
3889
|
+
else:
|
3890
|
+
retorno = f"{preenchimento_header_pre_venda.retorno} \nEtapas Executadas:\n{steps}"
|
3891
|
+
return RpaRetornoProcessoDTO(
|
3892
|
+
sucesso=False,
|
3893
|
+
retorno=retorno,
|
3894
|
+
status=RpaHistoricoStatusEnum.Falha,
|
3895
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
3896
|
+
)
|
3898
3897
|
else:
|
3899
3898
|
console.print(f"\nPesquisa: 'Não possui item para nota conjunta",style="bold green")
|
3900
3899
|
|