worker-automate-hub 0.5.598__py3-none-any.whl → 0.5.599__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 +1100 -1101
- {worker_automate_hub-0.5.598.dist-info → worker_automate_hub-0.5.599.dist-info}/METADATA +1 -1
- {worker_automate_hub-0.5.598.dist-info → worker_automate_hub-0.5.599.dist-info}/RECORD +5 -5
- {worker_automate_hub-0.5.598.dist-info → worker_automate_hub-0.5.599.dist-info}/WHEEL +0 -0
- {worker_automate_hub-0.5.598.dist-info → worker_automate_hub-0.5.599.dist-info}/entry_points.txt +0 -0
@@ -1459,831 +1459,619 @@ async def devolucao_ctf(task: RpaProcessoEntradaDTO) -> RpaRetornoProcessoDTO:
|
|
1459
1459
|
if 'arla' in descricao.lower():
|
1460
1460
|
item_arla = True
|
1461
1461
|
|
1462
|
-
|
1463
|
-
|
1464
|
-
|
1465
|
-
|
1466
|
-
console.print("Itens acessado com sucesso, clicando em Incluir...\n")
|
1467
|
-
panel_TGroup_Box= panel_TPage.child_window(class_name="TGroupBox", found_index=0)
|
1468
|
-
btn_incluir = panel_TGroup_Box.child_window(class_name="TDBIBitBtn", found_index=4)
|
1469
|
-
btn_incluir.click()
|
1470
|
-
await worker_sleep(2)
|
1471
|
-
console.print("Incluir clicado com sucesso...\n")
|
1472
|
-
|
1473
|
-
#VERIFICANDO A EXISTENCIA DE WARNINGS
|
1474
|
-
console.print("Verificando a existência de Warning... \n")
|
1475
|
-
warning_pop_up = await is_window_open("Warning")
|
1476
|
-
if warning_pop_up["IsOpened"] == True:
|
1477
|
-
console.print("possui Pop-up de Warning, analisando... \n")
|
1478
|
-
ocr_pop_warning = await ocr_warnings(numero_cupom_fiscal)
|
1479
|
-
if ocr_pop_warning.sucesso == True:
|
1480
|
-
return RpaRetornoProcessoDTO(
|
1481
|
-
sucesso=False,
|
1482
|
-
retorno=f"POP UP Warning não mapeado para seguimento do processo, mensagem: {ocr_pop_warning.retorno}",
|
1483
|
-
status=RpaHistoricoStatusEnum.Falha,
|
1484
|
-
tags=[RpaTagDTO(descricao=RpaTagEnum.Negocio)]
|
1485
|
-
)
|
1486
|
-
else:
|
1487
|
-
return RpaRetornoProcessoDTO(
|
1488
|
-
sucesso=False,
|
1489
|
-
retorno=f"POP UP Warning não mapeado para seguimento do processo",
|
1490
|
-
status=RpaHistoricoStatusEnum.Falha,
|
1491
|
-
tags=[RpaTagDTO(descricao=RpaTagEnum.Negocio)]
|
1492
|
-
)
|
1493
|
-
|
1494
|
-
|
1495
|
-
i = 0
|
1496
|
-
while i <= 7:
|
1497
|
-
try:
|
1498
|
-
console.print("Clicando sobre a lupa para inserir o almoxarifado...\n")
|
1499
|
-
app = Application().connect(class_name="TFrmIncluiItemPreVenda", timeout=130)
|
1500
|
-
main_window = app["TFrmIncluiItemPreVenda"]
|
1501
|
-
main_window.set_focus()
|
1502
|
-
panel_TGroup_Box= main_window.child_window(class_name="TPanel", found_index=2)
|
1503
|
-
lupa_almoxarifaco = panel_TGroup_Box.child_window(class_name="TDBIBitBtn", found_index=1)
|
1504
|
-
lupa_almoxarifaco.click()
|
1505
|
-
console.print("Lupa clicado com sucesso inserindo a descrição do almoxarifado...\n")
|
1506
|
-
await worker_sleep(2)
|
1507
|
-
|
1508
|
-
dialog_buscar = await is_window_open_by_class("TfrmDialogBuscaGeral", "TfrmDialogBuscaGeral")
|
1509
|
-
if dialog_buscar["IsOpened"] == True:
|
1510
|
-
break
|
1511
|
-
else:
|
1512
|
-
console.print("Não foi possivel abrir a janela de Busca Geral")
|
1513
|
-
i = i+1
|
1514
|
-
except Exception as e:
|
1515
|
-
console.print(f"Erro ao abrir a janela de Busca Geral: {e}")
|
1516
|
-
i = i+1
|
1517
|
-
|
1518
|
-
|
1519
|
-
if i == 7:
|
1520
|
-
retorno = f"Não foi possivel abrir a tela para buscar pelo item do produto na seleção do almoxarifado - \nEtapas Executadas:\n{steps}"
|
1521
|
-
return RpaRetornoProcessoDTO(
|
1522
|
-
sucesso=False,
|
1523
|
-
retorno=retorno,
|
1524
|
-
status=RpaHistoricoStatusEnum.Falha,
|
1525
|
-
tags=[RpaTagDTO(descricao=RpaTagEnum.Negocio)]
|
1526
|
-
)
|
1527
|
-
|
1528
|
-
app = Application().connect(class_name="TfrmDialogBuscaGeral", timeout=60)
|
1529
|
-
main_window = app["TfrmDialogBuscaGeral"]
|
1530
|
-
main_window.set_focus()
|
1531
|
-
|
1532
|
-
console.print("Buscando a mercadoria baseado na descrição...\n")
|
1533
|
-
rect = main_window.rectangle()
|
1534
|
-
center_x = (rect.left + rect.right) // 2
|
1535
|
-
center_y = (rect.top + rect.bottom) // 2
|
1536
|
-
|
1537
|
-
#pyautogui.moveTo(center_x, center_y)
|
1538
|
-
await worker_sleep(1)
|
1539
|
-
pyautogui.click(center_x, center_y)
|
1540
|
-
await worker_sleep(1)
|
1541
|
-
send_keys("^({HOME})")
|
1542
|
-
item_arla_founded = False
|
1543
|
-
|
1544
|
-
last_line = ''
|
1545
|
-
max_attempts = 12
|
1546
|
-
attempts = 0
|
1547
|
-
|
1548
|
-
while attempts < max_attempts:
|
1549
|
-
with pyautogui.hold('ctrl'):
|
1550
|
-
pyautogui.press('c')
|
1551
|
-
await worker_sleep(1)
|
1552
|
-
with pyautogui.hold('ctrl'):
|
1553
|
-
pyautogui.press('c')
|
1554
|
-
|
1555
|
-
win32clipboard.OpenClipboard()
|
1556
|
-
descricao_item = win32clipboard.GetClipboardData().strip()
|
1557
|
-
win32clipboard.CloseClipboard()
|
1558
|
-
|
1559
|
-
if last_line == descricao_item:
|
1560
|
-
if item_arla:
|
1561
|
-
console.print("Todos os itens percorridos e o item é Arla...\n")
|
1562
|
-
main_window.set_focus()
|
1563
|
-
send_keys("%r")
|
1564
|
-
await worker_sleep(1)
|
1462
|
+
if 'gasolina' in descricao.lower() or 'diesel' in descricao.lower() or 'gnv' in descricao.lower() or 'etanol' in descricao.lower() or 'arla' in descricao.lower():
|
1463
|
+
app = Application().connect(class_name="TFrmPreVenda", timeout=60)
|
1464
|
+
main_window = app["TFrmPreVenda"]
|
1465
|
+
main_window.set_focus()
|
1565
1466
|
|
1566
|
-
|
1567
|
-
|
1568
|
-
|
1569
|
-
|
1570
|
-
|
1571
|
-
|
1572
|
-
almoxarificado_index.click()
|
1573
|
-
await worker_sleep(1)
|
1574
|
-
for _ in range(5):
|
1575
|
-
pyautogui.press("del")
|
1576
|
-
pyautogui.press("backspace")
|
1577
|
-
await worker_sleep(1)
|
1578
|
-
pyautogui.write(str(cod_almoxarificado))
|
1579
|
-
await worker_sleep(1)
|
1580
|
-
pyautogui.press('tab')
|
1581
|
-
await worker_sleep(4)
|
1467
|
+
console.print("Itens acessado com sucesso, clicando em Incluir...\n")
|
1468
|
+
panel_TGroup_Box= panel_TPage.child_window(class_name="TGroupBox", found_index=0)
|
1469
|
+
btn_incluir = panel_TGroup_Box.child_window(class_name="TDBIBitBtn", found_index=4)
|
1470
|
+
btn_incluir.click()
|
1471
|
+
await worker_sleep(2)
|
1472
|
+
console.print("Incluir clicado com sucesso...\n")
|
1582
1473
|
|
1583
|
-
|
1584
|
-
|
1585
|
-
|
1586
|
-
|
1587
|
-
|
1588
|
-
|
1589
|
-
|
1590
|
-
await worker_sleep(1)
|
1591
|
-
pyautogui.press('tab')
|
1592
|
-
await worker_sleep(3)
|
1593
|
-
console.print("Cod do item e Almoxarifado inserido com sucesso, saindo...\n")
|
1594
|
-
break
|
1595
|
-
else:
|
1596
|
-
retorno = f"Todos os itens percorridos e não foi possivel encontrar a descrição condizente a {descricao} \nEtapas Executadas:\n{steps}"
|
1474
|
+
#VERIFICANDO A EXISTENCIA DE WARNINGS
|
1475
|
+
console.print("Verificando a existência de Warning... \n")
|
1476
|
+
warning_pop_up = await is_window_open("Warning")
|
1477
|
+
if warning_pop_up["IsOpened"] == True:
|
1478
|
+
console.print("possui Pop-up de Warning, analisando... \n")
|
1479
|
+
ocr_pop_warning = await ocr_warnings(numero_cupom_fiscal)
|
1480
|
+
if ocr_pop_warning.sucesso == True:
|
1597
1481
|
return RpaRetornoProcessoDTO(
|
1598
1482
|
sucesso=False,
|
1599
|
-
retorno=retorno,
|
1483
|
+
retorno=f"POP UP Warning não mapeado para seguimento do processo, mensagem: {ocr_pop_warning.retorno}",
|
1600
1484
|
status=RpaHistoricoStatusEnum.Falha,
|
1601
1485
|
tags=[RpaTagDTO(descricao=RpaTagEnum.Negocio)]
|
1602
1486
|
)
|
1603
|
-
else:
|
1604
|
-
if descricao.lower() in descricao_item.lower():
|
1605
|
-
console.print("Descrição do item encontrada, saindo...\n")
|
1606
|
-
item_arla_founded = True
|
1607
|
-
main_window.set_focus()
|
1608
|
-
send_keys("%o")
|
1609
|
-
break
|
1610
1487
|
else:
|
1611
|
-
|
1612
|
-
|
1613
|
-
|
1614
|
-
|
1615
|
-
|
1616
|
-
|
1617
|
-
await worker_sleep(10)
|
1618
|
-
console.print("Processo finalizado com sucesso, seguindo com a seleção da natureza...\n")
|
1619
|
-
|
1620
|
-
app = Application().connect(class_name="TFrmIncluiItemPreVenda", timeout=60)
|
1621
|
-
main_window = app["TFrmIncluiItemPreVenda"]
|
1622
|
-
main_window.set_focus()
|
1623
|
-
panel_TGroup_Box= main_window.child_window(class_name="TPanel", found_index=2)
|
1624
|
-
natureza_oper_select = panel_TGroup_Box.child_window(class_name="TDBIComboBox", found_index=0)
|
1625
|
-
nop_selected = natureza_oper_select.window_text()
|
1626
|
-
nop_selected_value = nop_selected[:4]
|
1627
|
-
await worker_sleep(1)
|
1488
|
+
return RpaRetornoProcessoDTO(
|
1489
|
+
sucesso=False,
|
1490
|
+
retorno=f"POP UP Warning não mapeado para seguimento do processo",
|
1491
|
+
status=RpaHistoricoStatusEnum.Falha,
|
1492
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Negocio)]
|
1493
|
+
)
|
1628
1494
|
|
1629
|
-
itens_to_select = natureza_oper_select.texts()
|
1630
|
-
nop_to_be_select = ''
|
1631
1495
|
|
1632
|
-
|
1633
|
-
|
1634
|
-
|
1635
|
-
|
1496
|
+
i = 0
|
1497
|
+
while i <= 7:
|
1498
|
+
try:
|
1499
|
+
console.print("Clicando sobre a lupa para inserir o almoxarifado...\n")
|
1500
|
+
app = Application().connect(class_name="TFrmIncluiItemPreVenda", timeout=130)
|
1501
|
+
main_window = app["TFrmIncluiItemPreVenda"]
|
1502
|
+
main_window.set_focus()
|
1503
|
+
panel_TGroup_Box= main_window.child_window(class_name="TPanel", found_index=2)
|
1504
|
+
lupa_almoxarifaco = panel_TGroup_Box.child_window(class_name="TDBIBitBtn", found_index=1)
|
1505
|
+
lupa_almoxarifaco.click()
|
1506
|
+
console.print("Lupa clicado com sucesso inserindo a descrição do almoxarifado...\n")
|
1507
|
+
await worker_sleep(2)
|
1636
1508
|
|
1637
|
-
|
1638
|
-
|
1509
|
+
dialog_buscar = await is_window_open_by_class("TfrmDialogBuscaGeral", "TfrmDialogBuscaGeral")
|
1510
|
+
if dialog_buscar["IsOpened"] == True:
|
1511
|
+
break
|
1512
|
+
else:
|
1513
|
+
console.print("Não foi possivel abrir a janela de Busca Geral")
|
1514
|
+
i = i+1
|
1515
|
+
except Exception as e:
|
1516
|
+
console.print(f"Erro ao abrir a janela de Busca Geral: {e}")
|
1517
|
+
i = i+1
|
1639
1518
|
|
1640
|
-
|
1641
|
-
|
1642
|
-
|
1643
|
-
console.print("Selecionando NOP do item: '5667 - VENDA DE COMB OU LUBRI - SEM ESTOQ E COM FINANC'")
|
1644
|
-
natureza_oper_select.select("5667 - VENDA DE COMB OU LUBRI - SEM ESTOQ E COM FINANC")
|
1645
|
-
except:
|
1646
|
-
console.print("Selecionando NOP: 5656 - VENDA DE COMB OU LUB ADQ DE TERCEIRO C/ FIN S/ ESTOQUE")
|
1647
|
-
natureza_oper_select.select("5656 - VENDA DE COMB OU LUB ADQ DE TERCEIRO C/ FIN S/ ESTOQUE")
|
1648
|
-
elif 'arla' in descricao.lower():
|
1649
|
-
try:
|
1650
|
-
#PRECISA DO ESPAÇO NO FINAL!!
|
1651
|
-
console.print("Selecionando NOP do item: '5102 - VENDA MERCAD. ADQ. DE TERCEIRO- 5.102 S/ ESTOQ C/ FINAN '")
|
1652
|
-
natureza_oper_select.select("5102 - VENDA MERCAD. ADQ. DE TERCEIRO- 5.102 S/ ESTOQ C/ FINAN ")
|
1653
|
-
except:
|
1654
|
-
console.print("Selecionando NOP do item: '5102 - VENDA MERCAD. ADQ. DE TERCEIRO- 5.102 S/ ESTOQ C/ FINAN FE'")
|
1655
|
-
natureza_oper_select.select("5102 - VENDA MERCAD. ADQ. DE TERCEIRO- 5.102 S/ ESTOQ C/ FINAN FE")
|
1656
|
-
else:
|
1657
|
-
if nop_to_be_select != '':
|
1658
|
-
console.print(f"Selecionando NOP do item: '{nop_to_be_select}'")
|
1659
|
-
natureza_oper_select.select(nop_to_be_select)
|
1660
|
-
else:
|
1661
|
-
retorno = f"Não foi possivel encontrar a nop para o item, nop original {nop_selected} \nEtapas Executadas:\n{steps}"
|
1519
|
+
|
1520
|
+
if i == 7:
|
1521
|
+
retorno = f"Não foi possivel abrir a tela para buscar pelo item do produto na seleção do almoxarifado - \nEtapas Executadas:\n{steps}"
|
1662
1522
|
return RpaRetornoProcessoDTO(
|
1663
1523
|
sucesso=False,
|
1664
1524
|
retorno=retorno,
|
1665
1525
|
status=RpaHistoricoStatusEnum.Falha,
|
1666
1526
|
tags=[RpaTagDTO(descricao=RpaTagEnum.Negocio)]
|
1667
1527
|
)
|
1668
|
-
# console.print("Selecionando NOP do item: '5667 - VENDA DE COMB OU LUBRI - SEM ESTOQ E COM FINANC'")
|
1669
|
-
# natureza_oper_select.select("5667 - VENDA DE COMB OU LUBRI - SEM ESTOQ E COM FINANC")
|
1670
|
-
|
1671
|
-
|
1672
|
-
await worker_sleep(1)
|
1673
|
-
console.print("Natureza da operação selecionado com sucesso, preenchendo os itens...\n")
|
1674
|
-
|
1675
|
-
#INSERINDO A QUANTIDADE
|
1676
|
-
main_window.set_focus()
|
1677
|
-
panel_TPage_Control= main_window.child_window(class_name="TcxPageControl", found_index=0)
|
1678
|
-
panel_tabSheet = panel_TPage_Control.child_window(class_name="TcxTabSheet", found_index=0)
|
1679
|
-
|
1680
|
-
field_quantidade = panel_tabSheet.child_window(class_name="TDBIEditNumber", found_index=8)
|
1681
|
-
console.print("Inserindo a quantidade de Itens...\n")
|
1682
|
-
field_quantidade.click()
|
1683
|
-
await worker_sleep(1)
|
1684
|
-
pyautogui.press('del')
|
1685
|
-
await worker_sleep(1)
|
1686
|
-
pyautogui.press('backspace')
|
1687
|
-
await worker_sleep(1)
|
1688
|
-
pyautogui.write(quantidade)
|
1689
|
-
#field_quantidade.set_edit_text(quantidade)
|
1690
|
-
await worker_sleep(1)
|
1691
|
-
pyautogui.press('tab')
|
1692
|
-
await worker_sleep(2)
|
1693
|
-
|
1694
|
-
#INSERINDO O VALOR INDIVIDUAL DO ITEM
|
1695
|
-
console.print("Inserindo o valor indivual do Item...\n")
|
1696
|
-
i = 0
|
1697
|
-
while i < 3:
|
1698
|
-
btn_valor_unitario = panel_tabSheet.child_window(class_name="TDBIBitBtn", found_index=0)
|
1699
|
-
btn_valor_unitario.click()
|
1700
|
-
console.print("Garantindo o click em valor individual")
|
1701
|
-
pyautogui.click(973, 658)
|
1702
|
-
await worker_sleep(3)
|
1703
1528
|
|
1704
|
-
|
1705
|
-
|
1706
|
-
|
1707
|
-
else:
|
1708
|
-
i = i + 1
|
1709
|
-
|
1710
|
-
console.print("Conectado a caixa para inserir o valor ")
|
1711
|
-
app = Application().connect(class_name="TFrmInputBoxNumero", timeout=60)
|
1712
|
-
main_window = app["TFrmInputBoxNumero"]
|
1713
|
-
main_window.set_focus()
|
1714
|
-
console.print("Caixa para inserir o valor conectada corretamento ")
|
1715
|
-
|
1716
|
-
field_valor = main_window.child_window(class_name="TDBIEditNumber", found_index=0)
|
1717
|
-
field_valor.click()
|
1718
|
-
await worker_sleep(1)
|
1719
|
-
for _ in range(10):
|
1720
|
-
pyautogui.press("del")
|
1721
|
-
pyautogui.press("backspace")
|
1722
|
-
pyautogui.write(preco)
|
1723
|
-
#field_valor.set_edit_text(preco)
|
1724
|
-
await worker_sleep(2)
|
1725
|
-
|
1726
|
-
main_window.set_focus()
|
1727
|
-
send_keys("%o")
|
1728
|
-
await worker_sleep(2)
|
1729
|
-
console.print("Valor inserido com sucesso...\n")
|
1730
|
-
|
1731
|
-
console.print("Fechando tela de incluir item pre venda...\n")
|
1732
|
-
app = Application().connect(class_name="TFrmIncluiItemPreVenda", timeout=60)
|
1733
|
-
main_window = app["TFrmIncluiItemPreVenda"]
|
1734
|
-
main_window.set_focus()
|
1735
|
-
send_keys("%i")
|
1736
|
-
await worker_sleep(2)
|
1737
|
-
#Divergencia de nop na capa e no item
|
1738
|
-
await find_nop_divergence()
|
1739
|
-
await worker_sleep(5)
|
1740
|
-
main_window.close()
|
1741
|
-
|
1742
|
-
|
1743
|
-
#INSERINDO O VALOR
|
1744
|
-
console.print(f"\nNavegando para inserir o valor... ",style="bold green")
|
1745
|
-
app = Application().connect(class_name="TFrmPreVenda", timeout=60)
|
1746
|
-
main_window = app["TFrmPreVenda"]
|
1747
|
-
main_window.set_focus()
|
1748
|
-
|
1749
|
-
console.print("Navegando nos elementos...\n")
|
1750
|
-
panel_TPage= main_window.child_window(class_name="TPage", found_index=0)
|
1751
|
-
panel_menu_itens= main_window.child_window(class_name="TcxCustomInnerTreeView", found_index=0)
|
1752
|
-
|
1753
|
-
console.print("Acessando a janela de Itens...\n")
|
1754
|
-
panel_menu_itens.click()
|
1755
|
-
await worker_sleep(1)
|
1756
|
-
pyautogui.press('home')
|
1757
|
-
await worker_sleep(1)
|
1758
|
-
send_keys("{DOWN " + ("3") + "}")
|
1759
|
-
await worker_sleep(3)
|
1760
|
-
|
1761
|
-
app = Application().connect(class_name="TFrmPreVenda", timeout=60)
|
1762
|
-
main_window = app["TFrmPreVenda"]
|
1763
|
-
main_window.set_focus()
|
1529
|
+
app = Application().connect(class_name="TfrmDialogBuscaGeral", timeout=60)
|
1530
|
+
main_window = app["TfrmDialogBuscaGeral"]
|
1531
|
+
main_window.set_focus()
|
1764
1532
|
|
1765
|
-
|
1766
|
-
|
1767
|
-
|
1768
|
-
|
1769
|
-
especie_btn.select("13 - DEVOLUCAO DE VENDA")
|
1533
|
+
console.print("Buscando a mercadoria baseado na descrição...\n")
|
1534
|
+
rect = main_window.rectangle()
|
1535
|
+
center_x = (rect.left + rect.right) // 2
|
1536
|
+
center_y = (rect.top + rect.bottom) // 2
|
1770
1537
|
|
1771
|
-
|
1538
|
+
#pyautogui.moveTo(center_x, center_y)
|
1539
|
+
await worker_sleep(1)
|
1540
|
+
pyautogui.click(center_x, center_y)
|
1541
|
+
await worker_sleep(1)
|
1542
|
+
send_keys("^({HOME})")
|
1543
|
+
item_arla_founded = False
|
1772
1544
|
|
1773
|
-
|
1774
|
-
|
1545
|
+
last_line = ''
|
1546
|
+
max_attempts = 12
|
1547
|
+
attempts = 0
|
1775
1548
|
|
1776
|
-
|
1777
|
-
|
1549
|
+
while attempts < max_attempts:
|
1550
|
+
with pyautogui.hold('ctrl'):
|
1551
|
+
pyautogui.press('c')
|
1552
|
+
await worker_sleep(1)
|
1553
|
+
with pyautogui.hold('ctrl'):
|
1554
|
+
pyautogui.press('c')
|
1778
1555
|
|
1779
|
-
|
1556
|
+
win32clipboard.OpenClipboard()
|
1557
|
+
descricao_item = win32clipboard.GetClipboardData().strip()
|
1558
|
+
win32clipboard.CloseClipboard()
|
1780
1559
|
|
1781
|
-
|
1560
|
+
if last_line == descricao_item:
|
1561
|
+
if item_arla:
|
1562
|
+
console.print("Todos os itens percorridos e o item é Arla...\n")
|
1563
|
+
main_window.set_focus()
|
1564
|
+
send_keys("%r")
|
1565
|
+
await worker_sleep(1)
|
1782
1566
|
|
1783
|
-
|
1784
|
-
|
1785
|
-
|
1786
|
-
|
1567
|
+
app = Application().connect(class_name="TFrmIncluiItemPreVenda", timeout=60)
|
1568
|
+
main_window = app["TFrmIncluiItemPreVenda"]
|
1569
|
+
main_window.set_focus()
|
1570
|
+
panel_TGroup_Box= main_window.child_window(class_name="TPanel", found_index=2)
|
1571
|
+
almoxarificado_index = panel_TGroup_Box.child_window(class_name="TDBIEditNumber", found_index=1)
|
1572
|
+
cod_almoxarificado = str(cod_empresa)+"50"
|
1573
|
+
almoxarificado_index.click()
|
1574
|
+
await worker_sleep(1)
|
1575
|
+
for _ in range(5):
|
1576
|
+
pyautogui.press("del")
|
1577
|
+
pyautogui.press("backspace")
|
1578
|
+
await worker_sleep(1)
|
1579
|
+
pyautogui.write(str(cod_almoxarificado))
|
1580
|
+
await worker_sleep(1)
|
1581
|
+
pyautogui.press('tab')
|
1582
|
+
await worker_sleep(4)
|
1787
1583
|
|
1788
|
-
|
1584
|
+
cod_item_index = panel_TGroup_Box.child_window(class_name="TDBIEditNumber", found_index=0)
|
1585
|
+
cod_item_index.click()
|
1586
|
+
await worker_sleep(1)
|
1587
|
+
for _ in range(5):
|
1588
|
+
pyautogui.press("del")
|
1589
|
+
pyautogui.press("backspace")
|
1590
|
+
pyautogui.write("1420")
|
1591
|
+
await worker_sleep(1)
|
1592
|
+
pyautogui.press('tab')
|
1593
|
+
await worker_sleep(3)
|
1594
|
+
console.print("Cod do item e Almoxarifado inserido com sucesso, saindo...\n")
|
1595
|
+
break
|
1596
|
+
else:
|
1597
|
+
retorno = f"Todos os itens percorridos e não foi possivel encontrar a descrição condizente a {descricao} \nEtapas Executadas:\n{steps}"
|
1598
|
+
return RpaRetornoProcessoDTO(
|
1599
|
+
sucesso=False,
|
1600
|
+
retorno=retorno,
|
1601
|
+
status=RpaHistoricoStatusEnum.Falha,
|
1602
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Negocio)]
|
1603
|
+
)
|
1604
|
+
else:
|
1605
|
+
if descricao.lower() in descricao_item.lower():
|
1606
|
+
console.print("Descrição do item encontrada, saindo...\n")
|
1607
|
+
item_arla_founded = True
|
1608
|
+
main_window.set_focus()
|
1609
|
+
send_keys("%o")
|
1610
|
+
break
|
1611
|
+
else:
|
1612
|
+
console.print("Descrição do item não encontrada, saindo...\n")
|
1613
|
+
last_line = descricao_item
|
1614
|
+
pyautogui.press('down')
|
1615
|
+
attempts += 1
|
1789
1616
|
|
1790
|
-
console.print(f'Valor inserido: {valor_total_value}')
|
1791
1617
|
|
1792
|
-
|
1618
|
+
await worker_sleep(10)
|
1619
|
+
console.print("Processo finalizado com sucesso, seguindo com a seleção da natureza...\n")
|
1793
1620
|
|
1794
|
-
|
1621
|
+
app = Application().connect(class_name="TFrmIncluiItemPreVenda", timeout=60)
|
1622
|
+
main_window = app["TFrmIncluiItemPreVenda"]
|
1623
|
+
main_window.set_focus()
|
1624
|
+
panel_TGroup_Box= main_window.child_window(class_name="TPanel", found_index=2)
|
1625
|
+
natureza_oper_select = panel_TGroup_Box.child_window(class_name="TDBIComboBox", found_index=0)
|
1626
|
+
nop_selected = natureza_oper_select.window_text()
|
1627
|
+
nop_selected_value = nop_selected[:4]
|
1628
|
+
await worker_sleep(1)
|
1795
1629
|
|
1796
|
-
|
1797
|
-
|
1630
|
+
itens_to_select = natureza_oper_select.texts()
|
1631
|
+
nop_to_be_select = ''
|
1798
1632
|
|
1799
|
-
|
1633
|
+
for item in itens_to_select:
|
1634
|
+
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())):
|
1635
|
+
nop_to_be_select = item
|
1636
|
+
break
|
1800
1637
|
|
1638
|
+
# natureza_oper_select.click()
|
1639
|
+
await worker_sleep(1)
|
1801
1640
|
|
1802
|
-
|
1803
|
-
|
1804
|
-
|
1805
|
-
|
1806
|
-
|
1807
|
-
|
1808
|
-
|
1809
|
-
|
1810
|
-
|
1811
|
-
|
1812
|
-
|
1813
|
-
|
1814
|
-
|
1815
|
-
|
1641
|
+
console.print(f"Descrição: {descricao}")
|
1642
|
+
if 'gasolina' in descricao.lower() or 'diesel' in descricao.lower() or 'gnv' in descricao.lower() or 'etanol' in descricao.lower():
|
1643
|
+
try:
|
1644
|
+
console.print("Selecionando NOP do item: '5667 - VENDA DE COMB OU LUBRI - SEM ESTOQ E COM FINANC'")
|
1645
|
+
natureza_oper_select.select("5667 - VENDA DE COMB OU LUBRI - SEM ESTOQ E COM FINANC")
|
1646
|
+
except:
|
1647
|
+
console.print("Selecionando NOP: 5656 - VENDA DE COMB OU LUB ADQ DE TERCEIRO C/ FIN S/ ESTOQUE")
|
1648
|
+
natureza_oper_select.select("5656 - VENDA DE COMB OU LUB ADQ DE TERCEIRO C/ FIN S/ ESTOQUE")
|
1649
|
+
elif 'arla' in descricao.lower():
|
1650
|
+
try:
|
1651
|
+
#PRECISA DO ESPAÇO NO FINAL!!
|
1652
|
+
console.print("Selecionando NOP do item: '5102 - VENDA MERCAD. ADQ. DE TERCEIRO- 5.102 S/ ESTOQ C/ FINAN '")
|
1653
|
+
natureza_oper_select.select("5102 - VENDA MERCAD. ADQ. DE TERCEIRO- 5.102 S/ ESTOQ C/ FINAN ")
|
1654
|
+
except:
|
1655
|
+
console.print("Selecionando NOP do item: '5102 - VENDA MERCAD. ADQ. DE TERCEIRO- 5.102 S/ ESTOQ C/ FINAN FE'")
|
1656
|
+
natureza_oper_select.select("5102 - VENDA MERCAD. ADQ. DE TERCEIRO- 5.102 S/ ESTOQ C/ FINAN FE")
|
1816
1657
|
else:
|
1817
|
-
retorno = f"{
|
1658
|
+
retorno = f"Não é combustivel {nop_selected} \nEtapas Executadas:\n{steps}"
|
1818
1659
|
return RpaRetornoProcessoDTO(
|
1819
1660
|
sucesso=False,
|
1820
1661
|
retorno=retorno,
|
1821
1662
|
status=RpaHistoricoStatusEnum.Falha,
|
1822
|
-
tags=[RpaTagDTO(descricao=RpaTagEnum.
|
1663
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Negocio)]
|
1823
1664
|
)
|
1824
|
-
|
1825
|
-
|
1826
|
-
|
1665
|
+
# console.print("Selecionando NOP do item: '5667 - VENDA DE COMB OU LUBRI - SEM ESTOQ E COM FINANC'")
|
1666
|
+
# natureza_oper_select.select("5667 - VENDA DE COMB OU LUBRI - SEM ESTOQ E COM FINANC")
|
1827
1667
|
|
1828
|
-
# #CONFIRMANDO NA TELA DE PRE VENDA
|
1829
|
-
# try:
|
1830
|
-
# console.print("CLICANDO EM CONFIRMAR... \n")
|
1831
|
-
# app = Application().connect(class_name="TFrmPreVenda", timeout=60)
|
1832
|
-
# main_window = app["TFrmPreVenda"]
|
1833
|
-
# main_window.set_focus()
|
1834
|
-
|
1835
|
-
# panel_Tnotebook = main_window.child_window(class_name="TNotebook", found_index=0)
|
1836
|
-
# panel_Tnotebook = panel_Tnotebook.child_window(class_name="TPage", found_index=0)
|
1837
|
-
# btn_confirmar = panel_Tnotebook.child_window(class_name="TBitBtn", found_index=11)
|
1838
|
-
# btn_confirmar.click()
|
1839
|
-
# console.print("CONFIRMAR CLICADO COM SUCESSO... \n")
|
1840
|
-
# await worker_sleep(3)
|
1841
|
-
# except Exception as e:
|
1842
|
-
# retorno = f"Não foi possivel clicar em Confirma na tela de Pre Venda \nEtapas Executadas:\n{steps}"
|
1843
|
-
# return RpaRetornoProcessoDTO(
|
1844
|
-
# sucesso=False,
|
1845
|
-
# retorno=retorno,
|
1846
|
-
# status=RpaHistoricoStatusEnum.Falha,
|
1847
|
-
# tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
1848
|
-
# )
|
1849
|
-
|
1850
|
-
|
1851
|
-
# Inclui registro
|
1852
|
-
console.print(f"Incluindo registro...\n")
|
1853
|
-
try:
|
1854
|
-
ASSETS_PATH = "assets"
|
1855
|
-
inserir_registro = pyautogui.locateOnScreen(ASSETS_PATH + "\\entrada_notas\\IncluirRegistro.png", confidence=0.8)
|
1856
|
-
pyautogui.click(inserir_registro)
|
1857
|
-
|
1858
|
-
except Exception as e:
|
1859
|
-
console.print(
|
1860
|
-
f"Não foi possivel incluir o registro utilizando reconhecimento de imagem, Error: {e}...\n tentando inserir via posição...\n"
|
1861
|
-
)
|
1862
|
-
await incluir_registro()
|
1863
|
-
await worker_sleep(5)
|
1864
|
-
|
1865
1668
|
|
1866
|
-
|
1867
|
-
|
1868
|
-
console.print("Verificando a existência de Warning... \n")
|
1869
|
-
warning_pop_up = await is_window_open("Warning")
|
1870
|
-
if warning_pop_up["IsOpened"] == True:
|
1871
|
-
console.print("possui Pop-up de Warning, analisando... \n")
|
1872
|
-
ocr_pop_warning = await ocr_warnings(numero_cupom_fiscal)
|
1873
|
-
if ocr_pop_warning.sucesso == True:
|
1874
|
-
retorno = f"POP UP Warning não mapeado para seguimento do processo, mensagem: {ocr_pop_warning.retorno} \nEtapas Executadas:\n{steps}"
|
1875
|
-
return RpaRetornoProcessoDTO(
|
1876
|
-
sucesso=False,
|
1877
|
-
retorno=retorno,
|
1878
|
-
status=RpaHistoricoStatusEnum.Falha,
|
1879
|
-
tags=[RpaTagDTO(descricao=RpaTagEnum.Negocio)]
|
1880
|
-
)
|
1881
|
-
else:
|
1882
|
-
retorno = f"POP UP Warning não mapeado para seguimento do processo \nEtapas Executadas:\n{steps}"
|
1883
|
-
return RpaRetornoProcessoDTO(
|
1884
|
-
sucesso=False,
|
1885
|
-
retorno=retorno,
|
1886
|
-
status=RpaHistoricoStatusEnum.Falha,
|
1887
|
-
tags=[RpaTagDTO(descricao=RpaTagEnum.Negocio)]
|
1888
|
-
)
|
1889
|
-
await worker_sleep(10)
|
1890
|
-
#VERIFICANDO SE A PRÉ VENDA FOI INCLUIDA COM SUCESSO
|
1891
|
-
console.print("VERIFICANDO SE A PRÉ VENDA FOI INCLUIDA COM SUCESSO... \n")
|
1892
|
-
information_pop_up = await is_window_open("Informação")
|
1893
|
-
if information_pop_up["IsOpened"] == True:
|
1894
|
-
msg_pop_up = await ocr_title(numero_nota_fiscal, "Informação")
|
1895
|
-
console.print(f'retorno:{msg_pop_up.sucesso}')
|
1896
|
-
console.print(f'retorno:{msg_pop_up}')
|
1897
|
-
if msg_pop_up.sucesso == True:
|
1898
|
-
msg_retorno = msg_pop_up.retorno
|
1899
|
-
console.print(msg_retorno)
|
1900
|
-
if 'venda' in msg_retorno.lower():
|
1901
|
-
try:
|
1902
|
-
information_operacao_concluida = main_window.child_window(title="Informação")
|
1903
|
-
btn_ok = information_operacao_concluida.child_window(class_name="TButton")
|
1904
|
-
btn_ok.click()
|
1905
|
-
await worker_sleep(4)
|
1906
|
-
except:
|
1907
|
-
pyautogui.press('enter')
|
1908
|
-
await worker_sleep(4)
|
1909
|
-
else:
|
1910
|
-
retorno = f"Pop up nao mapeado para seguimento do robo {msg_pop_up.retorno} \nEtapas Executadas:\n{steps}"
|
1911
|
-
return RpaRetornoProcessoDTO(
|
1912
|
-
sucesso=False,
|
1913
|
-
retorno=retorno,
|
1914
|
-
status=RpaHistoricoStatusEnum.Falha,
|
1915
|
-
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
1916
|
-
)
|
1917
|
-
else:
|
1918
|
-
retorno = f"Não foi possivel realizar a confirmação do msg do OCR \nEtapas Executadas:\n{steps}"
|
1919
|
-
return RpaRetornoProcessoDTO(
|
1920
|
-
sucesso=False,
|
1921
|
-
retorno=retorno,
|
1922
|
-
status=RpaHistoricoStatusEnum.Falha,
|
1923
|
-
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
1924
|
-
)
|
1925
|
-
else:
|
1926
|
-
retorno = f"Janela de confirmação de pre venda incluida nao encontrada \nEtapas Executadas:\n{steps}"
|
1927
|
-
return RpaRetornoProcessoDTO(
|
1928
|
-
sucesso=False,
|
1929
|
-
retorno=retorno,
|
1930
|
-
status=RpaHistoricoStatusEnum.Falha,
|
1931
|
-
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
1932
|
-
)
|
1933
|
-
|
1669
|
+
await worker_sleep(1)
|
1670
|
+
console.print("Natureza da operação selecionado com sucesso, preenchendo os itens...\n")
|
1934
1671
|
|
1935
|
-
|
1936
|
-
#CONFIRMANDO POP UP DE PRÉ VENDA - PESQUISAR PRE VENDA
|
1937
|
-
try:
|
1938
|
-
console.print("CONFIRMANDO POP UP DE PRÉ VENDA - PESQUISAR PRE VENDA... \n")
|
1939
|
-
app = Application().connect(class_name="TFrmPreVenda", timeout=10)
|
1940
|
-
main_window = app["Confirm"]
|
1672
|
+
#INSERINDO A QUANTIDADE
|
1941
1673
|
main_window.set_focus()
|
1674
|
+
panel_TPage_Control= main_window.child_window(class_name="TcxPageControl", found_index=0)
|
1675
|
+
panel_tabSheet = panel_TPage_Control.child_window(class_name="TcxTabSheet", found_index=0)
|
1942
1676
|
|
1943
|
-
|
1944
|
-
|
1945
|
-
|
1946
|
-
|
1947
|
-
|
1948
|
-
|
1949
|
-
|
1950
|
-
|
1951
|
-
|
1952
|
-
|
1953
|
-
)
|
1677
|
+
field_quantidade = panel_tabSheet.child_window(class_name="TDBIEditNumber", found_index=8)
|
1678
|
+
console.print("Inserindo a quantidade de Itens...\n")
|
1679
|
+
field_quantidade.click()
|
1680
|
+
await worker_sleep(1)
|
1681
|
+
pyautogui.press('del')
|
1682
|
+
await worker_sleep(1)
|
1683
|
+
pyautogui.press('backspace')
|
1684
|
+
await worker_sleep(1)
|
1685
|
+
pyautogui.write(quantidade)
|
1686
|
+
#field_quantidade.set_edit_text(quantidade)
|
1687
|
+
await worker_sleep(1)
|
1688
|
+
pyautogui.press('tab')
|
1689
|
+
await worker_sleep(2)
|
1954
1690
|
|
1691
|
+
#INSERINDO O VALOR INDIVIDUAL DO ITEM
|
1692
|
+
console.print("Inserindo o valor indivual do Item...\n")
|
1693
|
+
i = 0
|
1694
|
+
while i < 3:
|
1695
|
+
btn_valor_unitario = panel_tabSheet.child_window(class_name="TDBIBitBtn", found_index=0)
|
1696
|
+
btn_valor_unitario.click()
|
1697
|
+
console.print("Garantindo o click em valor individual")
|
1698
|
+
pyautogui.click(973, 658)
|
1699
|
+
await worker_sleep(3)
|
1955
1700
|
|
1956
|
-
|
1957
|
-
|
1958
|
-
|
1959
|
-
|
1960
|
-
|
1961
|
-
main_window.set_focus()
|
1701
|
+
caixa_valor_aberta = await is_window_open_by_class("TFrmInputBoxNumero", "TFrmInputBoxNumero")
|
1702
|
+
if caixa_valor_aberta["IsOpened"] == True:
|
1703
|
+
break
|
1704
|
+
else:
|
1705
|
+
i = i + 1
|
1962
1706
|
|
1963
|
-
|
1964
|
-
|
1965
|
-
|
1966
|
-
|
1967
|
-
console.print("
|
1968
|
-
await worker_sleep(3)
|
1969
|
-
except Exception as e:
|
1970
|
-
retorno = f"Não foi possivel clicar em Confirma na tela de Pre Venda \nEtapas Executadas:\n{steps}"
|
1971
|
-
return RpaRetornoProcessoDTO(
|
1972
|
-
sucesso=False,
|
1973
|
-
retorno=retorno,
|
1974
|
-
status=RpaHistoricoStatusEnum.Falha,
|
1975
|
-
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
1976
|
-
)
|
1707
|
+
console.print("Conectado a caixa para inserir o valor ")
|
1708
|
+
app = Application().connect(class_name="TFrmInputBoxNumero", timeout=60)
|
1709
|
+
main_window = app["TFrmInputBoxNumero"]
|
1710
|
+
main_window.set_focus()
|
1711
|
+
console.print("Caixa para inserir o valor conectada corretamento ")
|
1977
1712
|
|
1713
|
+
field_valor = main_window.child_window(class_name="TDBIEditNumber", found_index=0)
|
1714
|
+
field_valor.click()
|
1715
|
+
await worker_sleep(1)
|
1716
|
+
for _ in range(10):
|
1717
|
+
pyautogui.press("del")
|
1718
|
+
pyautogui.press("backspace")
|
1719
|
+
pyautogui.write(preco)
|
1720
|
+
#field_valor.set_edit_text(preco)
|
1721
|
+
await worker_sleep(2)
|
1978
1722
|
|
1979
|
-
#CONFIRMANDO NA TELA DE PRE VENDA
|
1980
|
-
try:
|
1981
|
-
console.print("CONFIRMANDO POP UP DE Deseja realmente confirmar esta PRÉ VENDA ... \n")
|
1982
|
-
app = Application().connect(class_name="TFrmPreVenda", timeout=10)
|
1983
|
-
main_window = app["Confirm"]
|
1984
1723
|
main_window.set_focus()
|
1724
|
+
send_keys("%o")
|
1725
|
+
await worker_sleep(2)
|
1726
|
+
console.print("Valor inserido com sucesso...\n")
|
1985
1727
|
|
1986
|
-
|
1987
|
-
|
1988
|
-
|
1989
|
-
|
1990
|
-
|
1991
|
-
|
1992
|
-
|
1993
|
-
|
1994
|
-
|
1995
|
-
)
|
1728
|
+
console.print("Fechando tela de incluir item pre venda...\n")
|
1729
|
+
app = Application().connect(class_name="TFrmIncluiItemPreVenda", timeout=60)
|
1730
|
+
main_window = app["TFrmIncluiItemPreVenda"]
|
1731
|
+
main_window.set_focus()
|
1732
|
+
send_keys("%i")
|
1733
|
+
await worker_sleep(2)
|
1734
|
+
#Divergencia de nop na capa e no item
|
1735
|
+
await find_nop_divergence()
|
1736
|
+
await worker_sleep(5)
|
1737
|
+
main_window.close()
|
1996
1738
|
|
1997
1739
|
|
1998
|
-
|
1999
|
-
|
2000
|
-
|
2001
|
-
|
2002
|
-
|
2003
|
-
|
2004
|
-
|
2005
|
-
|
2006
|
-
|
2007
|
-
finally:
|
2008
|
-
pyautogui.press('enter')
|
1740
|
+
#INSERINDO O VALOR
|
1741
|
+
console.print(f"\nNavegando para inserir o valor... ",style="bold green")
|
1742
|
+
app = Application().connect(class_name="TFrmPreVenda", timeout=60)
|
1743
|
+
main_window = app["TFrmPreVenda"]
|
1744
|
+
main_window.set_focus()
|
1745
|
+
|
1746
|
+
console.print("Navegando nos elementos...\n")
|
1747
|
+
panel_TPage= main_window.child_window(class_name="TPage", found_index=0)
|
1748
|
+
panel_menu_itens= main_window.child_window(class_name="TcxCustomInnerTreeView", found_index=0)
|
2009
1749
|
|
1750
|
+
console.print("Acessando a janela de Itens...\n")
|
1751
|
+
panel_menu_itens.click()
|
1752
|
+
await worker_sleep(1)
|
1753
|
+
pyautogui.press('home')
|
1754
|
+
await worker_sleep(1)
|
1755
|
+
send_keys("{DOWN " + ("3") + "}")
|
1756
|
+
await worker_sleep(3)
|
2010
1757
|
|
2011
|
-
|
2012
|
-
try:
|
2013
|
-
console.print("FATURAR... \n")
|
2014
|
-
app = Application().connect(class_name="TFrmPreVenda", timeout=10)
|
1758
|
+
app = Application().connect(class_name="TFrmPreVenda", timeout=60)
|
2015
1759
|
main_window = app["TFrmPreVenda"]
|
2016
1760
|
main_window.set_focus()
|
2017
1761
|
|
2018
|
-
|
2019
|
-
|
2020
|
-
|
2021
|
-
|
2022
|
-
|
2023
|
-
await worker_sleep(5)
|
2024
|
-
except Exception as e:
|
2025
|
-
retorno = f"Não foi possivel clicar em Faturar na tela de pre venda, erro: {e} \nEtapas Executadas:\n{steps}"
|
2026
|
-
return RpaRetornoProcessoDTO(
|
2027
|
-
sucesso=False,
|
2028
|
-
retorno=retorno,
|
2029
|
-
status=RpaHistoricoStatusEnum.Falha,
|
2030
|
-
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
2031
|
-
)
|
2032
|
-
|
1762
|
+
console.print("Navegando nos elementos...\n")
|
1763
|
+
panel_TNotebook = main_window.child_window(class_name="TNotebook", found_index=0)
|
1764
|
+
recebimento_caixa_panel = panel_TNotebook.child_window(title="Recebimento Pelo Caixa")
|
1765
|
+
especie_btn = recebimento_caixa_panel.child_window(class_name="TDBIComboBox", found_index=0)
|
1766
|
+
especie_btn.select("13 - DEVOLUCAO DE VENDA")
|
2033
1767
|
|
2034
|
-
|
2035
|
-
warning_pop = await is_window_open_by_class("TFrmPreVenda", "Warning")
|
2036
|
-
if warning_pop["IsOpened"] == True:
|
2037
|
-
app = Application().connect(class_name="TFrmPreVenda", timeout=10)
|
2038
|
-
try:
|
2039
|
-
main_window = app["Warning"]
|
2040
|
-
main_window.set_focus()
|
2041
|
-
retorno = f"Cliente Cliente sem permissão para realizar a emissão da nota fiscal, por favor verificar o cadastro do mesmo \nEtapas Executadas:\n{steps}"
|
2042
|
-
return RpaRetornoProcessoDTO(
|
2043
|
-
sucesso=False,
|
2044
|
-
retorno=retorno,
|
2045
|
-
status=RpaHistoricoStatusEnum.Falha,
|
2046
|
-
tags=[RpaTagDTO(descricao=RpaTagEnum.Negocio)]
|
2047
|
-
)
|
2048
|
-
except Exception as e:
|
2049
|
-
console.print('Não possui tela de Warning')
|
2050
|
-
else:
|
2051
|
-
console.print("Nenhum pop-up de Warning Encontrado... \n")
|
1768
|
+
await worker_sleep(2)
|
2052
1769
|
|
1770
|
+
totais_panel = panel_TNotebook.child_window(title="Totais")
|
1771
|
+
totais_panel.set_focus()
|
2053
1772
|
|
2054
|
-
|
2055
|
-
|
2056
|
-
app = Application().connect(title="Information", timeout=30)
|
2057
|
-
main_window = app["Information"]
|
2058
|
-
main_window.set_focus()
|
2059
|
-
btn_ok = main_window.child_window(class_name="TButton", found_index=0)
|
2060
|
-
btn_ok.click()
|
1773
|
+
total_pre_venda_field = totais_panel.child_window(class_name="TDBIEditNumber", found_index=4)
|
1774
|
+
valor_total_value = total_pre_venda_field.window_text()
|
2061
1775
|
|
1776
|
+
console.print(f'Valor capturado: {valor_total_value}')
|
2062
1777
|
|
2063
|
-
|
2064
|
-
#FATURAMENTO PRÉ-VENDA
|
2065
|
-
try:
|
2066
|
-
console.print("FATURAMENTO PRÉ-VENDA... \n")
|
2067
|
-
app = Application().connect(class_name="TFrmDadosFaturamentoPreVenda", timeout=60)
|
2068
|
-
main_window = app["TFrmDadosFaturamentoPreVenda"]
|
2069
|
-
main_window.set_focus()
|
2070
|
-
except Exception as e:
|
2071
|
-
retorno = f"Não foi encontrada a Janela Faturamento de Pré Venda \nEtapas Executadas:\n{steps}"
|
2072
|
-
return RpaRetornoProcessoDTO(
|
2073
|
-
sucesso=False,
|
2074
|
-
retorno=result,
|
2075
|
-
status=RpaHistoricoStatusEnum.Falha,
|
2076
|
-
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
2077
|
-
)
|
2078
|
-
|
2079
|
-
await find_warning_nop_divergence()
|
2080
|
-
await worker_sleep(2)
|
2081
|
-
#VERIFICANDO SE POSSUI POP UP WARNING
|
2082
|
-
console.print("Verificando a presença de Warning... \n")
|
2083
|
-
warning_boo = False
|
2084
|
-
try:
|
2085
|
-
try:
|
2086
|
-
app = Application().connect(class_name="TFrmDadosFaturamentoPreVenda", timeout=10)
|
2087
|
-
main_window = app["Warning"]
|
2088
|
-
main_window.set_focus()
|
2089
|
-
except:
|
2090
|
-
console.print('Except')
|
2091
|
-
app = Application().connect(class_name="Warning", timeout=10)
|
2092
|
-
main_window = app["Warning"]
|
2093
|
-
main_window.set_focus()
|
2094
|
-
console.print("Possui Warning... \n")
|
2095
|
-
await find_warning_nop_divergence()
|
2096
|
-
btn_ok = main_window.child_window(class_name="TButton", found_index=0)
|
2097
|
-
btn_ok.click()
|
2098
|
-
await worker_sleep(3)
|
2099
|
-
warning_boo = True
|
2100
|
-
except:
|
2101
|
-
console.print("Não Possui Warning... \n")
|
2102
|
-
|
2103
|
-
await find_warning_nop_divergence()
|
2104
|
-
await worker_sleep(2)
|
2105
|
-
#ALTERANDO TRIBUTO DOS ITENS
|
2106
|
-
if warning_boo:
|
2107
|
-
try:
|
2108
|
-
console.print('Acessando a tela de Itens')
|
2109
|
-
app = Application().connect(class_name="TFrmDadosFaturamentoPreVenda", timeout=60)
|
2110
|
-
main_window = app["TFrmDadosFaturamentoPreVenda"]
|
2111
|
-
main_window.set_focus()
|
2112
|
-
send_keys("%i")
|
2113
|
-
await worker_sleep(2)
|
2114
|
-
send_keys("%g")
|
2115
|
-
await worker_sleep(2)
|
2116
|
-
|
2117
|
-
await find_warning_nop_divergence()
|
2118
|
-
await worker_sleep(2)
|
2119
|
-
console.print("Conectando para realizar a alteração da tributação do produto... \n")
|
2120
|
-
app = Application().connect(class_name="TFrmDadosTributacaoProdutoPreVenda", timeout=60)
|
2121
|
-
main_window = app["TFrmDadosTributacaoProdutoPreVenda"]
|
1778
|
+
await worker_sleep(1)
|
2122
1779
|
|
2123
|
-
|
2124
|
-
|
1780
|
+
recebimento_caixa_panel = panel_TNotebook.child_window(title="Recebimento Pelo Caixa")
|
1781
|
+
valor_field = recebimento_caixa_panel.child_window(class_name="TDBIEditNumber", found_index=0)
|
1782
|
+
valor_field.click()
|
1783
|
+
await worker_sleep(1)
|
2125
1784
|
|
1785
|
+
valor_field.set_edit_text(valor_total_value)
|
2126
1786
|
|
2127
|
-
|
2128
|
-
|
2129
|
-
|
2130
|
-
|
2131
|
-
|
1787
|
+
console.print(f'Valor inserido: {valor_total_value}')
|
1788
|
+
|
1789
|
+
await worker_sleep(2)
|
1790
|
+
|
1791
|
+
console.print(f'Incluindo registro')
|
1792
|
+
|
1793
|
+
incluir_registro_btn = recebimento_caixa_panel.child_window(class_name="TDBIBitBtn", found_index=2)
|
1794
|
+
incluir_registro_btn.click()
|
1795
|
+
|
1796
|
+
await worker_sleep(2)
|
1797
|
+
|
1798
|
+
|
1799
|
+
#VERIFICANDO A EXISTENCIA DE WARNINGS
|
1800
|
+
console.print("Verificando a existência de Warning... \n")
|
1801
|
+
warning_pop_up = await is_window_open("Warning")
|
1802
|
+
if warning_pop_up["IsOpened"] == True:
|
1803
|
+
console.print("possui Pop-up de Warning, analisando... \n")
|
1804
|
+
ocr_pop_warning = await ocr_warnings(numero_cupom_fiscal)
|
1805
|
+
if ocr_pop_warning.sucesso == True:
|
1806
|
+
retorno = f"POP UP Warning não mapeado para seguimento do processo, mensagem: {ocr_pop_warning.retorno} \nEtapas Executadas:\n{steps}"
|
1807
|
+
return RpaRetornoProcessoDTO(
|
1808
|
+
sucesso=False,
|
1809
|
+
retorno=retorno,
|
1810
|
+
status=RpaHistoricoStatusEnum.Falha,
|
1811
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Negocio)]
|
1812
|
+
)
|
2132
1813
|
else:
|
2133
|
-
|
2134
|
-
|
2135
|
-
|
2136
|
-
|
2137
|
-
|
2138
|
-
|
1814
|
+
retorno = f"{ocr_pop_warning.retorno} \nEtapas Executadas:\n{steps}"
|
1815
|
+
return RpaRetornoProcessoDTO(
|
1816
|
+
sucesso=False,
|
1817
|
+
retorno=retorno,
|
1818
|
+
status=RpaHistoricoStatusEnum.Falha,
|
1819
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
1820
|
+
)
|
1821
|
+
else:
|
1822
|
+
console.print("Não possui pop de Warning...\n")
|
2139
1823
|
|
2140
|
-
|
2141
|
-
|
2142
|
-
|
2143
|
-
|
2144
|
-
|
2145
|
-
|
1824
|
+
|
1825
|
+
# #CONFIRMANDO NA TELA DE PRE VENDA
|
1826
|
+
# try:
|
1827
|
+
# console.print("CLICANDO EM CONFIRMAR... \n")
|
1828
|
+
# app = Application().connect(class_name="TFrmPreVenda", timeout=60)
|
1829
|
+
# main_window = app["TFrmPreVenda"]
|
1830
|
+
# main_window.set_focus()
|
1831
|
+
|
1832
|
+
# panel_Tnotebook = main_window.child_window(class_name="TNotebook", found_index=0)
|
1833
|
+
# panel_Tnotebook = panel_Tnotebook.child_window(class_name="TPage", found_index=0)
|
1834
|
+
# btn_confirmar = panel_Tnotebook.child_window(class_name="TBitBtn", found_index=11)
|
1835
|
+
# btn_confirmar.click()
|
1836
|
+
# console.print("CONFIRMAR CLICADO COM SUCESSO... \n")
|
1837
|
+
# await worker_sleep(3)
|
1838
|
+
# except Exception as e:
|
1839
|
+
# retorno = f"Não foi possivel clicar em Confirma na tela de Pre Venda \nEtapas Executadas:\n{steps}"
|
1840
|
+
# return RpaRetornoProcessoDTO(
|
1841
|
+
# sucesso=False,
|
1842
|
+
# retorno=retorno,
|
1843
|
+
# status=RpaHistoricoStatusEnum.Falha,
|
1844
|
+
# tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
1845
|
+
# )
|
1846
|
+
|
1847
|
+
|
1848
|
+
# Inclui registro
|
1849
|
+
console.print(f"Incluindo registro...\n")
|
1850
|
+
try:
|
1851
|
+
ASSETS_PATH = "assets"
|
1852
|
+
inserir_registro = pyautogui.locateOnScreen(ASSETS_PATH + "\\entrada_notas\\IncluirRegistro.png", confidence=0.8)
|
1853
|
+
pyautogui.click(inserir_registro)
|
1854
|
+
|
1855
|
+
except Exception as e:
|
1856
|
+
console.print(
|
1857
|
+
f"Não foi possivel incluir o registro utilizando reconhecimento de imagem, Error: {e}...\n tentando inserir via posição...\n"
|
1858
|
+
)
|
1859
|
+
await incluir_registro()
|
1860
|
+
await worker_sleep(5)
|
1861
|
+
|
1862
|
+
|
1863
|
+
await worker_sleep(10)
|
1864
|
+
#VERIFICANDO A EXISTENCIA DE WARNINGS
|
1865
|
+
console.print("Verificando a existência de Warning... \n")
|
1866
|
+
warning_pop_up = await is_window_open("Warning")
|
1867
|
+
if warning_pop_up["IsOpened"] == True:
|
1868
|
+
console.print("possui Pop-up de Warning, analisando... \n")
|
1869
|
+
ocr_pop_warning = await ocr_warnings(numero_cupom_fiscal)
|
1870
|
+
if ocr_pop_warning.sucesso == True:
|
1871
|
+
retorno = f"POP UP Warning não mapeado para seguimento do processo, mensagem: {ocr_pop_warning.retorno} \nEtapas Executadas:\n{steps}"
|
1872
|
+
return RpaRetornoProcessoDTO(
|
1873
|
+
sucesso=False,
|
1874
|
+
retorno=retorno,
|
1875
|
+
status=RpaHistoricoStatusEnum.Falha,
|
1876
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Negocio)]
|
1877
|
+
)
|
1878
|
+
else:
|
1879
|
+
retorno = f"POP UP Warning não mapeado para seguimento do processo \nEtapas Executadas:\n{steps}"
|
1880
|
+
return RpaRetornoProcessoDTO(
|
1881
|
+
sucesso=False,
|
1882
|
+
retorno=retorno,
|
1883
|
+
status=RpaHistoricoStatusEnum.Falha,
|
1884
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Negocio)]
|
1885
|
+
)
|
1886
|
+
await worker_sleep(10)
|
1887
|
+
#VERIFICANDO SE A PRÉ VENDA FOI INCLUIDA COM SUCESSO
|
1888
|
+
console.print("VERIFICANDO SE A PRÉ VENDA FOI INCLUIDA COM SUCESSO... \n")
|
1889
|
+
information_pop_up = await is_window_open("Informação")
|
1890
|
+
if information_pop_up["IsOpened"] == True:
|
1891
|
+
msg_pop_up = await ocr_title(numero_nota_fiscal, "Informação")
|
1892
|
+
console.print(f'retorno:{msg_pop_up.sucesso}')
|
1893
|
+
console.print(f'retorno:{msg_pop_up}')
|
1894
|
+
if msg_pop_up.sucesso == True:
|
1895
|
+
msg_retorno = msg_pop_up.retorno
|
1896
|
+
console.print(msg_retorno)
|
1897
|
+
if 'venda' in msg_retorno.lower():
|
1898
|
+
try:
|
1899
|
+
information_operacao_concluida = main_window.child_window(title="Informação")
|
1900
|
+
btn_ok = information_operacao_concluida.child_window(class_name="TButton")
|
1901
|
+
btn_ok.click()
|
1902
|
+
await worker_sleep(4)
|
1903
|
+
except:
|
1904
|
+
pyautogui.press('enter')
|
1905
|
+
await worker_sleep(4)
|
2146
1906
|
else:
|
2147
|
-
retorno = f"
|
1907
|
+
retorno = f"Pop up nao mapeado para seguimento do robo {msg_pop_up.retorno} \nEtapas Executadas:\n{steps}"
|
2148
1908
|
return RpaRetornoProcessoDTO(
|
2149
1909
|
sucesso=False,
|
2150
1910
|
retorno=retorno,
|
2151
1911
|
status=RpaHistoricoStatusEnum.Falha,
|
2152
1912
|
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
2153
1913
|
)
|
1914
|
+
else:
|
1915
|
+
retorno = f"Não foi possivel realizar a confirmação do msg do OCR \nEtapas Executadas:\n{steps}"
|
1916
|
+
return RpaRetornoProcessoDTO(
|
1917
|
+
sucesso=False,
|
1918
|
+
retorno=retorno,
|
1919
|
+
status=RpaHistoricoStatusEnum.Falha,
|
1920
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
1921
|
+
)
|
1922
|
+
else:
|
1923
|
+
retorno = f"Janela de confirmação de pre venda incluida nao encontrada \nEtapas Executadas:\n{steps}"
|
1924
|
+
return RpaRetornoProcessoDTO(
|
1925
|
+
sucesso=False,
|
1926
|
+
retorno=retorno,
|
1927
|
+
status=RpaHistoricoStatusEnum.Falha,
|
1928
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
1929
|
+
)
|
1930
|
+
|
1931
|
+
|
1932
|
+
steps += ' ETAPA 04 - PRE VENDA INCLUIDA COM SUCESSO'
|
1933
|
+
#CONFIRMANDO POP UP DE PRÉ VENDA - PESQUISAR PRE VENDA
|
1934
|
+
try:
|
1935
|
+
console.print("CONFIRMANDO POP UP DE PRÉ VENDA - PESQUISAR PRE VENDA... \n")
|
1936
|
+
app = Application().connect(class_name="TFrmPreVenda", timeout=10)
|
1937
|
+
main_window = app["Confirm"]
|
2154
1938
|
main_window.set_focus()
|
2155
|
-
|
1939
|
+
|
1940
|
+
btn_yes = main_window.child_window(class_name="TButton", found_index=1)
|
1941
|
+
btn_yes.click()
|
1942
|
+
await worker_sleep(3)
|
2156
1943
|
except Exception as e:
|
2157
|
-
retorno = f"
|
1944
|
+
retorno = f"Pop Up de Confirm (Deseja pesquisar a Pré Venda ?) não encontrado \nEtapas Executadas:\n{steps}"
|
2158
1945
|
return RpaRetornoProcessoDTO(
|
2159
1946
|
sucesso=False,
|
2160
|
-
retorno=
|
1947
|
+
retorno=retorno,
|
2161
1948
|
status=RpaHistoricoStatusEnum.Falha,
|
2162
1949
|
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
2163
1950
|
)
|
2164
|
-
|
2165
1951
|
|
2166
|
-
console.print("Processo de ajustar aliquota realizado com sucesso, adicionando a mensagem... \n")
|
2167
|
-
try:
|
2168
|
-
console.print("Conectando a janela de pre venda... \n")
|
2169
|
-
app = Application().connect(class_name="TFrmDadosFaturamentoPreVenda", timeout=60)
|
2170
|
-
main_window = app["TFrmDadosFaturamentoPreVenda"]
|
2171
|
-
main_window.set_focus()
|
2172
|
-
send_keys("%m")
|
2173
|
-
await worker_sleep(2)
|
2174
1952
|
|
2175
|
-
|
2176
|
-
|
2177
|
-
|
2178
|
-
|
2179
|
-
|
2180
|
-
|
1953
|
+
#CONFIRMANDO NA TELA DE PRE VENDA
|
1954
|
+
try:
|
1955
|
+
console.print("CLICANDO EM CONFIRMAR... \n")
|
1956
|
+
app = Application().connect(class_name="TFrmPreVenda", timeout=60)
|
1957
|
+
main_window = app["TFrmPreVenda"]
|
1958
|
+
main_window.set_focus()
|
1959
|
+
|
1960
|
+
panel_Tnotebook = main_window.child_window(class_name="TNotebook", found_index=0)
|
1961
|
+
panel_Tnotebook = panel_Tnotebook.child_window(class_name="TPage", found_index=0)
|
1962
|
+
btn_confirmar = panel_Tnotebook.child_window(class_name="TBitBtn", found_index=11)
|
1963
|
+
btn_confirmar.click()
|
1964
|
+
console.print("CONFIRMAR CLICADO COM SUCESSO... \n")
|
1965
|
+
await worker_sleep(3)
|
1966
|
+
except Exception as e:
|
1967
|
+
retorno = f"Não foi possivel clicar em Confirma na tela de Pre Venda \nEtapas Executadas:\n{steps}"
|
2181
1968
|
return RpaRetornoProcessoDTO(
|
2182
1969
|
sucesso=False,
|
2183
1970
|
retorno=retorno,
|
2184
|
-
status=RpaHistoricoStatusEnum.Falha,
|
1971
|
+
status=RpaHistoricoStatusEnum.Falha,
|
1972
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
2185
1973
|
)
|
2186
1974
|
|
2187
1975
|
|
2188
|
-
|
2189
|
-
field_observacao = panel_tab_sheet.child_window(class_name="TDBIMemo", found_index=0)
|
2190
|
-
console.print(f"Mensagem a ser adicionada\n")
|
2191
|
-
text_campo_observacao = f"Nome do Motorista: {nota.get("nomeMotorista")} - Placa: {nota.get("placaClienteCorreto")} - Quilometragem do Veículo: {nota.get("quilometragemVeiculo")}"
|
2192
|
-
console.print(f"{text_campo_observacao}\n")
|
2193
|
-
field_observacao.click()
|
2194
|
-
await worker_sleep(2)
|
2195
|
-
pyautogui.write(text_campo_observacao)
|
2196
|
-
await worker_sleep(2)
|
2197
|
-
|
1976
|
+
#CONFIRMANDO NA TELA DE PRE VENDA
|
2198
1977
|
try:
|
2199
|
-
|
2200
|
-
|
1978
|
+
console.print("CONFIRMANDO POP UP DE Deseja realmente confirmar esta PRÉ VENDA ... \n")
|
1979
|
+
app = Application().connect(class_name="TFrmPreVenda", timeout=10)
|
1980
|
+
main_window = app["Confirm"]
|
2201
1981
|
main_window.set_focus()
|
2202
|
-
|
2203
|
-
|
2204
|
-
|
2205
|
-
|
1982
|
+
|
1983
|
+
btn_yes = main_window.child_window(class_name="TButton", found_index=1)
|
1984
|
+
btn_yes.click()
|
1985
|
+
except Exception as e:
|
1986
|
+
retorno = f"Não foi possivel clicar para confirmar a janela 'Deseja realmente confirmar esta pre-venda' \nEtapas Executadas:\n{steps}"
|
1987
|
+
return RpaRetornoProcessoDTO(
|
1988
|
+
sucesso=False,
|
1989
|
+
retorno=retorno,
|
1990
|
+
status=RpaHistoricoStatusEnum.Falha,
|
1991
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
1992
|
+
)
|
1993
|
+
|
1994
|
+
|
1995
|
+
await worker_sleep(5)
|
1996
|
+
app = Application().connect(title="Information", timeout=180)
|
1997
|
+
main_window = app["Information"]
|
1998
|
+
main_window.set_focus()
|
1999
|
+
try:
|
2000
|
+
btn_ok = main_window.child_window(class_name="TButton", found_index=0)
|
2206
2001
|
btn_ok.click()
|
2207
|
-
|
2002
|
+
except Exception as e:
|
2003
|
+
pyautogui.press('enter')
|
2004
|
+
finally:
|
2005
|
+
pyautogui.press('enter')
|
2208
2006
|
|
2209
|
-
|
2210
|
-
|
2211
|
-
|
2212
|
-
|
2213
|
-
|
2214
|
-
|
2215
|
-
app = Application().connect(title="Warning")
|
2216
|
-
main_window = app["Warning"]
|
2217
|
-
await worker_sleep(2)
|
2007
|
+
|
2008
|
+
#FATURAR
|
2009
|
+
try:
|
2010
|
+
console.print("FATURAR... \n")
|
2011
|
+
app = Application().connect(class_name="TFrmPreVenda", timeout=10)
|
2012
|
+
main_window = app["TFrmPreVenda"]
|
2218
2013
|
main_window.set_focus()
|
2219
|
-
|
2220
|
-
|
2221
|
-
|
2222
|
-
|
2223
|
-
|
2224
|
-
|
2225
|
-
|
2226
|
-
|
2227
|
-
|
2228
|
-
|
2229
|
-
|
2230
|
-
|
2014
|
+
|
2015
|
+
panel_Tnotebook = main_window.child_window(class_name="TNotebook", found_index=0)
|
2016
|
+
panel_Tnotebook = panel_Tnotebook.child_window(class_name="TPage", found_index=0)
|
2017
|
+
btn_faturar = panel_Tnotebook.child_window(class_name="TBitBtn", found_index=7)
|
2018
|
+
btn_faturar.click()
|
2019
|
+
console.print("BOTAO FATURAR CLICADO COM SUCESSO... \n")
|
2020
|
+
await worker_sleep(5)
|
2021
|
+
except Exception as e:
|
2022
|
+
retorno = f"Não foi possivel clicar em Faturar na tela de pre venda, erro: {e} \nEtapas Executadas:\n{steps}"
|
2023
|
+
return RpaRetornoProcessoDTO(
|
2024
|
+
sucesso=False,
|
2025
|
+
retorno=retorno,
|
2026
|
+
status=RpaHistoricoStatusEnum.Falha,
|
2027
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
2231
2028
|
)
|
2232
|
-
|
2233
|
-
#SELECIONANDO O TIPO DE DOCUMENTO
|
2234
|
-
try:
|
2235
|
-
console.print("Conectando a janela de pre venda para colocar modelo \n")
|
2236
|
-
app = Application().connect(class_name="TFrmDadosFaturamentoPreVenda", timeout=10)
|
2237
|
-
main_window = app["TFrmDadosFaturamentoPreVenda"]
|
2238
|
-
main_window.set_focus()
|
2239
|
-
send_keys("%p")
|
2240
|
-
await worker_sleep(2)
|
2029
|
+
|
2241
2030
|
|
2242
|
-
|
2243
|
-
|
2244
|
-
|
2245
|
-
|
2246
|
-
|
2247
|
-
|
2248
|
-
await worker_sleep(3)
|
2249
|
-
console.print("Verificando se o tipo de nota foi selecionado corretamente \n")
|
2250
|
-
modelo_select = panel_Ttabsheet.child_window(class_name="TDBIComboBox", found_index=1)
|
2251
|
-
tipo_selecionado = modelo_select.window_text()
|
2252
|
-
if "077" in tipo_selecionado.lower():
|
2253
|
-
console.print(f"Tipo de cobrança corretamente selecionado {tipo_selecionado}... \n")
|
2254
|
-
else:
|
2255
|
-
retorno = f"Não foi possivel selecionar o modelo do documento, tipo selecionado {tipo_selecionado}' \nEtapas Executadas:\n{steps}"
|
2256
|
-
return RpaRetornoProcessoDTO(
|
2257
|
-
sucesso=False,
|
2258
|
-
retorno=retorno,
|
2259
|
-
status=RpaHistoricoStatusEnum.Falha,
|
2260
|
-
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
2261
|
-
)
|
2262
|
-
|
2031
|
+
await worker_sleep(10)
|
2032
|
+
warning_pop = await is_window_open_by_class("TFrmPreVenda", "Warning")
|
2033
|
+
if warning_pop["IsOpened"] == True:
|
2034
|
+
app = Application().connect(class_name="TFrmPreVenda", timeout=10)
|
2035
|
+
try:
|
2036
|
+
main_window = app["Warning"]
|
2263
2037
|
main_window.set_focus()
|
2264
|
-
|
2265
|
-
#Clcica no OK para seguir a transmissão da pré-venda
|
2266
|
-
app = Application().connect(class_name="TFrmDadosFaturamentoPreVenda", timeout=60)
|
2267
|
-
main_window = app["TFrmDadosFaturamentoPreVenda"]
|
2268
|
-
main_window.set_focus()
|
2269
|
-
btn_ok = main_window.child_window(class_name="TBitBtn", found_index=1)
|
2270
|
-
btn_ok.click()
|
2271
|
-
except:
|
2272
|
-
btn_ok = main_window.child_window(title="&Ok")
|
2273
|
-
btn_ok.click()
|
2274
|
-
await worker_sleep(5)
|
2275
|
-
|
2276
|
-
except Exception as e:
|
2277
|
-
retorno = f"Não foi possivel selecionar o modelo do documento {e}' \nEtapas Executadas:\n{steps}"
|
2038
|
+
retorno = f"Cliente Cliente sem permissão para realizar a emissão da nota fiscal, por favor verificar o cadastro do mesmo \nEtapas Executadas:\n{steps}"
|
2278
2039
|
return RpaRetornoProcessoDTO(
|
2279
2040
|
sucesso=False,
|
2280
2041
|
retorno=retorno,
|
2281
2042
|
status=RpaHistoricoStatusEnum.Falha,
|
2282
|
-
tags=[RpaTagDTO(descricao=RpaTagEnum.
|
2283
|
-
|
2043
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Negocio)]
|
2044
|
+
)
|
2045
|
+
except Exception as e:
|
2046
|
+
console.print('Não possui tela de Warning')
|
2284
2047
|
else:
|
2285
|
-
console.print("
|
2048
|
+
console.print("Nenhum pop-up de Warning Encontrado... \n")
|
2049
|
+
|
2050
|
+
|
2051
|
+
information_pop_up = await is_window_open("Information")
|
2052
|
+
if information_pop_up["IsOpened"] == True:
|
2053
|
+
app = Application().connect(title="Information", timeout=30)
|
2054
|
+
main_window = app["Information"]
|
2055
|
+
main_window.set_focus()
|
2056
|
+
btn_ok = main_window.child_window(class_name="TButton", found_index=0)
|
2057
|
+
btn_ok.click()
|
2286
2058
|
|
2059
|
+
|
2060
|
+
await worker_sleep(15)
|
2061
|
+
#FATURAMENTO PRÉ-VENDA
|
2062
|
+
try:
|
2063
|
+
console.print("FATURAMENTO PRÉ-VENDA... \n")
|
2064
|
+
app = Application().connect(class_name="TFrmDadosFaturamentoPreVenda", timeout=60)
|
2065
|
+
main_window = app["TFrmDadosFaturamentoPreVenda"]
|
2066
|
+
main_window.set_focus()
|
2067
|
+
except Exception as e:
|
2068
|
+
retorno = f"Não foi encontrada a Janela Faturamento de Pré Venda \nEtapas Executadas:\n{steps}"
|
2069
|
+
return RpaRetornoProcessoDTO(
|
2070
|
+
sucesso=False,
|
2071
|
+
retorno=result,
|
2072
|
+
status=RpaHistoricoStatusEnum.Falha,
|
2073
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
2074
|
+
)
|
2287
2075
|
|
2288
2076
|
await find_warning_nop_divergence()
|
2289
2077
|
await worker_sleep(2)
|
@@ -2292,7 +2080,7 @@ async def devolucao_ctf(task: RpaProcessoEntradaDTO) -> RpaRetornoProcessoDTO:
|
|
2292
2080
|
warning_boo = False
|
2293
2081
|
try:
|
2294
2082
|
try:
|
2295
|
-
app = Application().connect(class_name="TFrmDadosFaturamentoPreVenda", timeout=
|
2083
|
+
app = Application().connect(class_name="TFrmDadosFaturamentoPreVenda", timeout=10)
|
2296
2084
|
main_window = app["Warning"]
|
2297
2085
|
main_window.set_focus()
|
2298
2086
|
except:
|
@@ -2308,8 +2096,9 @@ async def devolucao_ctf(task: RpaProcessoEntradaDTO) -> RpaRetornoProcessoDTO:
|
|
2308
2096
|
warning_boo = True
|
2309
2097
|
except:
|
2310
2098
|
console.print("Não Possui Warning... \n")
|
2311
|
-
|
2312
|
-
|
2099
|
+
|
2100
|
+
await find_warning_nop_divergence()
|
2101
|
+
await worker_sleep(2)
|
2313
2102
|
#ALTERANDO TRIBUTO DOS ITENS
|
2314
2103
|
if warning_boo:
|
2315
2104
|
try:
|
@@ -2322,7 +2111,8 @@ async def devolucao_ctf(task: RpaProcessoEntradaDTO) -> RpaRetornoProcessoDTO:
|
|
2322
2111
|
send_keys("%g")
|
2323
2112
|
await worker_sleep(2)
|
2324
2113
|
|
2325
|
-
|
2114
|
+
await find_warning_nop_divergence()
|
2115
|
+
await worker_sleep(2)
|
2326
2116
|
console.print("Conectando para realizar a alteração da tributação do produto... \n")
|
2327
2117
|
app = Application().connect(class_name="TFrmDadosTributacaoProdutoPreVenda", timeout=60)
|
2328
2118
|
main_window = app["TFrmDadosTributacaoProdutoPreVenda"]
|
@@ -2368,308 +2158,517 @@ async def devolucao_ctf(task: RpaProcessoEntradaDTO) -> RpaRetornoProcessoDTO:
|
|
2368
2158
|
status=RpaHistoricoStatusEnum.Falha,
|
2369
2159
|
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
2370
2160
|
)
|
2371
|
-
|
2372
|
-
|
2373
|
-
|
2374
|
-
#ADICIONANDO MENSAGEM
|
2375
|
-
await worker_sleep(5)
|
2161
|
+
|
2162
|
+
|
2163
|
+
console.print("Processo de ajustar aliquota realizado com sucesso, adicionando a mensagem... \n")
|
2376
2164
|
try:
|
2377
|
-
console.print("
|
2378
|
-
app = Application().connect(class_name="TFrmDadosFaturamentoPreVenda", timeout=
|
2379
|
-
main_window = app["
|
2380
|
-
main_window.set_focus()
|
2381
|
-
except:
|
2382
|
-
console.print("Identificando - TMessageForm 1")
|
2383
|
-
app = Application().connect(class_name="TMessageForm", timeout=10, title='Confirm')
|
2384
|
-
main_window = app["TMessageForm"]
|
2165
|
+
console.print("Conectando a janela de pre venda... \n")
|
2166
|
+
app = Application().connect(class_name="TFrmDadosFaturamentoPreVenda", timeout=60)
|
2167
|
+
main_window = app["TFrmDadosFaturamentoPreVenda"]
|
2385
2168
|
main_window.set_focus()
|
2169
|
+
send_keys("%m")
|
2170
|
+
await worker_sleep(2)
|
2386
2171
|
|
2387
|
-
|
2388
|
-
|
2172
|
+
mensagem_tab = pyautogui.locateOnScreen(ASSETS_PATH + "\\notas_saida\\icon_mensagem.png", confidence=0.7)
|
2173
|
+
if mensagem_tab:
|
2174
|
+
pyautogui.click(mensagem_tab)
|
2175
|
+
await worker_sleep(4)
|
2176
|
+
else:
|
2177
|
+
retorno = f"Não foi possivel localizar o campo 'Mensagem' \nEtapas Executadas:\n{steps}"
|
2178
|
+
return RpaRetornoProcessoDTO(
|
2179
|
+
sucesso=False,
|
2180
|
+
retorno=retorno,
|
2181
|
+
status=RpaHistoricoStatusEnum.Falha, tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
2182
|
+
)
|
2389
2183
|
|
2390
|
-
await worker_sleep(5)
|
2391
2184
|
|
2392
|
-
|
2393
|
-
|
2394
|
-
|
2395
|
-
|
2396
|
-
|
2397
|
-
|
2398
|
-
|
2399
|
-
|
2400
|
-
|
2401
|
-
|
2402
|
-
|
2403
|
-
|
2185
|
+
panel_tab_sheet = main_window.child_window(class_name="TcxTabSheet", found_index=0)
|
2186
|
+
field_observacao = panel_tab_sheet.child_window(class_name="TDBIMemo", found_index=0)
|
2187
|
+
console.print(f"Mensagem a ser adicionada\n")
|
2188
|
+
text_campo_observacao = f"Nome do Motorista: {nota.get("nomeMotorista")} - Placa: {nota.get("placaClienteCorreto")} - Quilometragem do Veículo: {nota.get("quilometragemVeiculo")}"
|
2189
|
+
console.print(f"{text_campo_observacao}\n")
|
2190
|
+
field_observacao.click()
|
2191
|
+
await worker_sleep(2)
|
2192
|
+
pyautogui.write(text_campo_observacao)
|
2193
|
+
await worker_sleep(2)
|
2194
|
+
|
2195
|
+
try:
|
2196
|
+
app = Application().connect(class_name="TFrmDadosFaturamentoPreVenda", timeout=60)
|
2197
|
+
main_window = app["TFrmDadosFaturamentoPreVenda"]
|
2198
|
+
main_window.set_focus()
|
2199
|
+
btn_ok = main_window.child_window(class_name="TBitBtn", found_index=1)
|
2200
|
+
btn_ok.click()
|
2201
|
+
except:
|
2202
|
+
btn_ok = main_window.child_window(title="&Ok")
|
2203
|
+
btn_ok.click()
|
2204
|
+
await worker_sleep(5)
|
2404
2205
|
|
2405
|
-
|
2406
|
-
|
2407
|
-
|
2408
|
-
|
2409
|
-
|
2410
|
-
|
2411
|
-
|
2412
|
-
|
2413
|
-
|
2414
|
-
|
2415
|
-
|
2416
|
-
|
2417
|
-
|
2418
|
-
|
2419
|
-
|
2420
|
-
|
2421
|
-
|
2422
|
-
|
2423
|
-
|
2424
|
-
|
2425
|
-
|
2426
|
-
|
2427
|
-
|
2206
|
+
await worker_sleep(10)
|
2207
|
+
await find_warning_nop_divergence()
|
2208
|
+
await worker_sleep(2)
|
2209
|
+
warning_pop_up = await is_window_open("Warning")
|
2210
|
+
if warning_pop_up["IsOpened"] == True:
|
2211
|
+
console.print("possui Pop-up de Warning, analisando... \n")
|
2212
|
+
app = Application().connect(title="Warning")
|
2213
|
+
main_window = app["Warning"]
|
2214
|
+
await worker_sleep(2)
|
2215
|
+
main_window.set_focus()
|
2216
|
+
console.print("Clicando em OK, para andamento do processo...\n")
|
2217
|
+
btn_ok = main_window.child_window(title="OK", class_name="TButton")
|
2218
|
+
if btn_ok.exists() and btn_ok.is_enabled():
|
2219
|
+
btn_ok.click()
|
2220
|
+
#Este click pode ser desnecessário, é apanas uma garantia
|
2221
|
+
pyautogui.click(961, 562)
|
2222
|
+
await worker_sleep(2)
|
2223
|
+
else:
|
2224
|
+
log_msg = "Warning - Erro ao clicar em Ok, na tela de warning...\n"
|
2225
|
+
console.print(log_msg, style="bold red")
|
2226
|
+
return RpaRetornoProcessoDTO(
|
2227
|
+
sucesso=False, retorno=log_msg, status=RpaHistoricoStatusEnum.Falha, tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
2228
|
+
)
|
2229
|
+
await worker_sleep(1)
|
2230
|
+
#SELECIONANDO O TIPO DE DOCUMENTO
|
2231
|
+
try:
|
2232
|
+
console.print("Conectando a janela de pre venda para colocar modelo \n")
|
2233
|
+
app = Application().connect(class_name="TFrmDadosFaturamentoPreVenda", timeout=10)
|
2234
|
+
main_window = app["TFrmDadosFaturamentoPreVenda"]
|
2235
|
+
main_window.set_focus()
|
2236
|
+
send_keys("%p")
|
2237
|
+
await worker_sleep(2)
|
2428
2238
|
|
2239
|
+
panel_TPage= main_window.child_window(class_name="TPageControl", found_index=0)
|
2240
|
+
panel_Ttabsheet= panel_TPage.child_window(class_name="TTabSheet", found_index=0)
|
2241
|
+
modelo_select = panel_Ttabsheet.child_window(class_name="TDBIComboBox", found_index=1)
|
2242
|
+
modelo_select.click()
|
2243
|
+
await worker_sleep(1)
|
2244
|
+
set_combobox("||List", "NFe - NOTA FISCAL ELETRONICA PROPRIA - DANFE SERIE 077")
|
2245
|
+
await worker_sleep(3)
|
2246
|
+
console.print("Verificando se o tipo de nota foi selecionado corretamente \n")
|
2247
|
+
modelo_select = panel_Ttabsheet.child_window(class_name="TDBIComboBox", found_index=1)
|
2248
|
+
tipo_selecionado = modelo_select.window_text()
|
2249
|
+
if "077" in tipo_selecionado.lower():
|
2250
|
+
console.print(f"Tipo de cobrança corretamente selecionado {tipo_selecionado}... \n")
|
2251
|
+
else:
|
2252
|
+
retorno = f"Não foi possivel selecionar o modelo do documento, tipo selecionado {tipo_selecionado}' \nEtapas Executadas:\n{steps}"
|
2253
|
+
return RpaRetornoProcessoDTO(
|
2254
|
+
sucesso=False,
|
2255
|
+
retorno=retorno,
|
2256
|
+
status=RpaHistoricoStatusEnum.Falha,
|
2257
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
2258
|
+
)
|
2259
|
+
|
2260
|
+
main_window.set_focus()
|
2261
|
+
try:
|
2262
|
+
#Clcica no OK para seguir a transmissão da pré-venda
|
2263
|
+
app = Application().connect(class_name="TFrmDadosFaturamentoPreVenda", timeout=60)
|
2264
|
+
main_window = app["TFrmDadosFaturamentoPreVenda"]
|
2265
|
+
main_window.set_focus()
|
2266
|
+
btn_ok = main_window.child_window(class_name="TBitBtn", found_index=1)
|
2267
|
+
btn_ok.click()
|
2268
|
+
except:
|
2269
|
+
btn_ok = main_window.child_window(title="&Ok")
|
2270
|
+
btn_ok.click()
|
2271
|
+
await worker_sleep(5)
|
2429
2272
|
|
2430
|
-
|
2431
|
-
|
2432
|
-
|
2433
|
-
|
2434
|
-
|
2435
|
-
|
2273
|
+
except Exception as e:
|
2274
|
+
retorno = f"Não foi possivel selecionar o modelo do documento {e}' \nEtapas Executadas:\n{steps}"
|
2275
|
+
return RpaRetornoProcessoDTO(
|
2276
|
+
sucesso=False,
|
2277
|
+
retorno=retorno,
|
2278
|
+
status=RpaHistoricoStatusEnum.Falha,
|
2279
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
2280
|
+
)
|
2281
|
+
else:
|
2282
|
+
console.print("Não possui pop de Warning...\n")
|
2436
2283
|
|
2437
|
-
|
2438
|
-
|
2439
|
-
|
2284
|
+
|
2285
|
+
await find_warning_nop_divergence()
|
2286
|
+
await worker_sleep(2)
|
2287
|
+
#VERIFICANDO SE POSSUI POP UP WARNING
|
2288
|
+
console.print("Verificando a presença de Warning... \n")
|
2289
|
+
warning_boo = False
|
2290
|
+
try:
|
2291
|
+
try:
|
2292
|
+
app = Application().connect(class_name="TFrmDadosFaturamentoPreVenda", timeout=30)
|
2293
|
+
main_window = app["Warning"]
|
2294
|
+
main_window.set_focus()
|
2295
|
+
except:
|
2296
|
+
console.print('Except')
|
2297
|
+
app = Application().connect(class_name="Warning", timeout=10)
|
2298
|
+
main_window = app["Warning"]
|
2299
|
+
main_window.set_focus()
|
2300
|
+
console.print("Possui Warning... \n")
|
2301
|
+
await find_warning_nop_divergence()
|
2302
|
+
btn_ok = main_window.child_window(class_name="TButton", found_index=0)
|
2303
|
+
btn_ok.click()
|
2304
|
+
await worker_sleep(3)
|
2305
|
+
warning_boo = True
|
2306
|
+
except:
|
2307
|
+
console.print("Não Possui Warning... \n")
|
2440
2308
|
|
2441
|
-
|
2442
|
-
|
2443
|
-
|
2444
|
-
|
2445
|
-
|
2446
|
-
|
2447
|
-
|
2448
|
-
|
2449
|
-
|
2450
|
-
|
2451
|
-
|
2452
|
-
|
2453
|
-
|
2454
|
-
|
2309
|
+
|
2310
|
+
#ALTERANDO TRIBUTO DOS ITENS
|
2311
|
+
if warning_boo:
|
2312
|
+
try:
|
2313
|
+
console.print('Acessando a tela de Itens')
|
2314
|
+
app = Application().connect(class_name="TFrmDadosFaturamentoPreVenda", timeout=60)
|
2315
|
+
main_window = app["TFrmDadosFaturamentoPreVenda"]
|
2316
|
+
main_window.set_focus()
|
2317
|
+
send_keys("%i")
|
2318
|
+
await worker_sleep(2)
|
2319
|
+
send_keys("%g")
|
2320
|
+
await worker_sleep(2)
|
2321
|
+
|
2322
|
+
|
2323
|
+
console.print("Conectando para realizar a alteração da tributação do produto... \n")
|
2324
|
+
app = Application().connect(class_name="TFrmDadosTributacaoProdutoPreVenda", timeout=60)
|
2325
|
+
main_window = app["TFrmDadosTributacaoProdutoPreVenda"]
|
2455
2326
|
|
2456
|
-
|
2457
|
-
|
2327
|
+
tpanel_dados_tributacao = main_window.child_window(class_name="TPanel", found_index=1)
|
2328
|
+
tributacao_icms_select = tpanel_dados_tributacao.child_window(class_name="TDBIComboBox", found_index=4)
|
2458
2329
|
|
2459
|
-
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
2460
|
-
desArquivo = f"NOVA VENDA {numero_cupom_fiscal}.pdf"
|
2461
|
-
try:
|
2462
|
-
await send_file(historico_id, desArquivo, "pdf", file_bytes, file_extension="pdf")
|
2463
|
-
os.remove(f"{path_to_txt}.pdf")
|
2464
|
-
except Exception as e:
|
2465
|
-
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} !"
|
2466
|
-
console.print(result, style="bold red")
|
2467
|
-
return RpaRetornoProcessoDTO(
|
2468
|
-
sucesso=False,
|
2469
|
-
retorno=result,
|
2470
|
-
status=RpaHistoricoStatusEnum.Falha,
|
2471
|
-
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
2472
|
-
)
|
2473
2330
|
|
2474
|
-
|
2475
|
-
|
2476
|
-
|
2477
|
-
|
2478
|
-
|
2479
|
-
|
2480
|
-
|
2331
|
+
if not item_arla:
|
2332
|
+
console.print("Não é item Arla ajustando tributacao... \n")
|
2333
|
+
tributacao_icms_select.click()
|
2334
|
+
await worker_sleep(1)
|
2335
|
+
set_combobox("||List", "061 - 061- MONOFASICO")
|
2336
|
+
else:
|
2337
|
+
console.print("Item Arla buscando pela aliquota do estado... \n")
|
2338
|
+
aliquota = None
|
2339
|
+
for item in conconfig_aliquota_icms:
|
2340
|
+
if cidade_cliente in item["estado"]:
|
2341
|
+
aliquota = item["aliquota"]
|
2342
|
+
break
|
2343
|
+
|
2344
|
+
if aliquota:
|
2345
|
+
console.print(f"A alíquota para o estado {cidade_cliente} é: {aliquota}")
|
2346
|
+
tributacao_icms_select.click()
|
2347
|
+
await worker_sleep(1)
|
2348
|
+
tributacao = f"000 - 000- ICMS - {aliquota}%"
|
2349
|
+
set_combobox("||List", tributacao)
|
2350
|
+
else:
|
2351
|
+
retorno = f"Estado {cidade_cliente} não encontrado \nEtapas Executadas:\n{steps}"
|
2352
|
+
return RpaRetornoProcessoDTO(
|
2353
|
+
sucesso=False,
|
2354
|
+
retorno=retorno,
|
2355
|
+
status=RpaHistoricoStatusEnum.Falha,
|
2356
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
2357
|
+
)
|
2358
|
+
main_window.set_focus()
|
2359
|
+
send_keys("%o")
|
2360
|
+
except Exception as e:
|
2361
|
+
retorno = f"Não foi possivel corrigir a tributação do itens na Janela Faturamento de Pré Venda, erro {e} \nEtapas Executadas:\n{steps}"
|
2362
|
+
return RpaRetornoProcessoDTO(
|
2363
|
+
sucesso=False,
|
2364
|
+
retorno=result,
|
2365
|
+
status=RpaHistoricoStatusEnum.Falha,
|
2366
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
2367
|
+
)
|
2368
|
+
else:
|
2369
|
+
console.print("Não possui warning para alterar tributação... \n")
|
2370
|
+
|
2371
|
+
#ADICIONANDO MENSAGEM
|
2372
|
+
await worker_sleep(5)
|
2373
|
+
try:
|
2374
|
+
console.print("Identificando - TFrmDadosFaturamentoPreVenda 1")
|
2375
|
+
app = Application().connect(class_name="TFrmDadosFaturamentoPreVenda", timeout=10)
|
2376
|
+
main_window = app["Confirm"]
|
2377
|
+
main_window.set_focus()
|
2378
|
+
except:
|
2379
|
+
console.print("Identificando - TMessageForm 1")
|
2380
|
+
app = Application().connect(class_name="TMessageForm", timeout=10, title='Confirm')
|
2381
|
+
main_window = app["TMessageForm"]
|
2382
|
+
main_window.set_focus()
|
2383
|
+
|
2384
|
+
btn_yes = main_window.child_window(class_name="TButton", title="&Yes")
|
2385
|
+
btn_yes.click()
|
2386
|
+
|
2387
|
+
await worker_sleep(5)
|
2388
|
+
|
2389
|
+
try:
|
2390
|
+
console.print('Identificando - TFrmDadosFaturamentoPreVenda 1')
|
2391
|
+
app = Application().connect(class_name="TFrmDadosFaturamentoPreVenda", timeout=10)
|
2392
|
+
main_window = app["TMessageForm"]
|
2393
|
+
except Exception as ex:
|
2394
|
+
console.print(f'{ex} - TMessageForm 4')
|
2395
|
+
app = Application().connect(class_name="TMessageForm", timeout=10)
|
2396
|
+
main_window = app["TMessageForm"]
|
2397
|
+
|
2398
|
+
main_window.set_focus()
|
2399
|
+
send_keys("%i")
|
2400
|
+
await worker_sleep(15)
|
2401
|
+
|
2402
|
+
except Exception as e:
|
2403
|
+
retorno = f"Não foi possivel adicionar a 'Mensagem' na tela de Faturamento de pre venda, erro {e} \nEtapas Executadas:\n{steps}"
|
2404
|
+
return RpaRetornoProcessoDTO(
|
2405
|
+
sucesso=False,
|
2406
|
+
retorno=retorno,
|
2407
|
+
status=RpaHistoricoStatusEnum.Falha, tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
2408
|
+
)
|
2409
|
+
|
2410
|
+
try:
|
2411
|
+
app = Application().connect(class_name="TFrmAguarde", timeout=60)
|
2412
|
+
main_window = app["TppPrintDialog"]
|
2413
|
+
tpanel_btn_ok = main_window.child_window(class_name="TPanel", found_index=1)
|
2414
|
+
btn_ok_print_screen = tpanel_btn_ok.child_window(class_name="TButton", found_index=1)
|
2415
|
+
btn_ok_print_screen.click()
|
2416
|
+
await worker_sleep(3)
|
2417
|
+
except Exception as e:
|
2418
|
+
retorno = f"Não foi encontrada a para a impressão da nova venda \nEtapas Executadas:\n{steps}"
|
2419
|
+
return RpaRetornoProcessoDTO(
|
2420
|
+
sucesso=False,
|
2421
|
+
retorno=result,
|
2422
|
+
status=RpaHistoricoStatusEnum.Falha,
|
2423
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
2424
|
+
)
|
2425
|
+
|
2481
2426
|
|
2427
|
+
console.print(f"NAVEGANDO NA TELA DE SALVAR RELATORIO\n")
|
2428
|
+
#INSERINDO O DIRETORIO E SALVANDO O ARQUIVO
|
2429
|
+
try:
|
2430
|
+
app = Application().connect(title="Salvar Saída de Impressão como")
|
2431
|
+
main_window = app["Dialog"]
|
2432
|
+
console.print("Tela 'Salvar' encontrada!")
|
2482
2433
|
|
2483
|
-
|
2484
|
-
|
2485
|
-
|
2486
|
-
|
2487
|
-
|
2488
|
-
|
2434
|
+
console.print("Interagindo com a tela 'Salvar'...\n")
|
2435
|
+
username = getpass.getuser()
|
2436
|
+
path_to_txt = f"C:\\Users\\{username}\\Downloads\\NOVA VENDA {numero_cupom_fiscal}"
|
2437
|
+
|
2438
|
+
main_window.type_keys("%n")
|
2439
|
+
pyautogui.write(path_to_txt)
|
2440
|
+
await worker_sleep(1)
|
2441
|
+
main_window.type_keys("%l")
|
2442
|
+
console.print("Arquivo salvo com sucesso...\n")
|
2443
|
+
await worker_sleep(8)
|
2444
|
+
except Exception as e:
|
2445
|
+
retorno = f"Não foi salvar o arquivo com a nova venda, erro {e} \nEtapas Executadas:\n{steps}"
|
2446
|
+
return RpaRetornoProcessoDTO(
|
2447
|
+
sucesso=False,
|
2448
|
+
retorno=result,
|
2449
|
+
status=RpaHistoricoStatusEnum.Falha,
|
2450
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
2451
|
+
)
|
2489
2452
|
|
2453
|
+
with open(f"{path_to_txt}.pdf", 'rb') as file:
|
2454
|
+
file_bytes = io.BytesIO(file.read())
|
2490
2455
|
|
2491
|
-
|
2492
|
-
|
2493
|
-
|
2494
|
-
|
2495
|
-
|
2496
|
-
|
2497
|
-
|
2498
|
-
|
2456
|
+
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
2457
|
+
desArquivo = f"NOVA VENDA {numero_cupom_fiscal}.pdf"
|
2458
|
+
try:
|
2459
|
+
await send_file(historico_id, desArquivo, "pdf", file_bytes, file_extension="pdf")
|
2460
|
+
os.remove(f"{path_to_txt}.pdf")
|
2461
|
+
except Exception as e:
|
2462
|
+
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} !"
|
2463
|
+
console.print(result, style="bold red")
|
2464
|
+
return RpaRetornoProcessoDTO(
|
2465
|
+
sucesso=False,
|
2466
|
+
retorno=result,
|
2467
|
+
status=RpaHistoricoStatusEnum.Falha,
|
2468
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
2469
|
+
)
|
2470
|
+
|
2471
|
+
information_pop_up = await is_window_open("Information")
|
2472
|
+
if information_pop_up["IsOpened"] == True:
|
2473
|
+
app = Application().connect(title="Information", timeout=30)
|
2474
|
+
main_window = app["Information"]
|
2475
|
+
main_window.set_focus()
|
2476
|
+
btn_ok = main_window.child_window(class_name="TButton", found_index=0)
|
2477
|
+
btn_ok.click()
|
2478
|
+
|
2479
|
+
|
2480
|
+
try:
|
2481
|
+
app = Application().connect(class_name="TFrmProcessamentoFEe2", timeout=10)
|
2482
|
+
main_window = app["TFrmProcessamentoFEe2"]
|
2483
|
+
main_window.close()
|
2484
|
+
except Exception as e:
|
2485
|
+
console.print("Janela TFrmDadosFaturamentoPreVenda ja fechada")
|
2499
2486
|
|
2500
2487
|
|
2501
|
-
|
2502
|
-
|
2503
|
-
|
2488
|
+
await worker_sleep(5)
|
2489
|
+
is_confirm_pop_up = False
|
2490
|
+
try:
|
2504
2491
|
app = Application().connect(class_name="TFrmGerenciadorNFe2", timeout=10)
|
2505
2492
|
main_window = app["Confirm"]
|
2506
|
-
|
2507
|
-
|
2508
|
-
|
2493
|
+
is_confirm_pop_up = True
|
2494
|
+
except:
|
2495
|
+
pass
|
2509
2496
|
|
2510
|
-
|
2511
|
-
|
2512
|
-
|
2513
|
-
|
2514
|
-
|
2515
|
-
|
2516
|
-
|
2497
|
+
|
2498
|
+
if is_confirm_pop_up == True:
|
2499
|
+
msg_text = await ocr_by_class(numero_cupom_fiscal,"TFrmGerenciadorNFe2", "Confirm")
|
2500
|
+
if 'imprimir' in msg_text.retorno.lower():
|
2501
|
+
app = Application().connect(class_name="TFrmGerenciadorNFe2", timeout=10)
|
2502
|
+
main_window = app["Confirm"]
|
2503
|
+
main_window.set_focus()
|
2504
|
+
send_keys("%n")
|
2505
|
+
|
2506
|
+
|
2507
|
+
#Fechar telas Antes de fazer nova pesquisa
|
2508
|
+
await worker_sleep(10)
|
2517
2509
|
try:
|
2518
|
-
|
2519
|
-
|
2520
|
-
)
|
2521
|
-
|
2522
|
-
pyautogui.click(button_location)
|
2523
|
-
console.print("Botão 'Fechar' clicado com sucesso!")
|
2524
|
-
except pyautogui.ImageNotFoundException:
|
2525
|
-
window_rect = main_window.rectangle()
|
2526
|
-
console.print(f"Area que sera utulizada para o recorte {window_rect}...\n")
|
2510
|
+
app = Application().connect(class_name="TFrmProcessamentoNFe2", timeout=10)
|
2511
|
+
window_lancando_nota = app["TFrmProcessamentoNFe2"]
|
2512
|
+
window_lancando_nota.set_focus()
|
2513
|
+
fechar_tela_processamento = "assets\\emsys\\button_fechar.PNG"
|
2527
2514
|
try:
|
2528
2515
|
button_location = pyautogui.locateCenterOnScreen(
|
2529
|
-
fechar_tela_processamento,
|
2530
|
-
region=(
|
2531
|
-
window_rect.left,
|
2532
|
-
window_rect.top,
|
2533
|
-
window_rect.width(),
|
2534
|
-
window_rect.height(),
|
2535
|
-
),
|
2516
|
+
fechar_tela_processamento, confidence=0.6
|
2536
2517
|
)
|
2537
2518
|
if button_location:
|
2538
|
-
button_location = (
|
2539
|
-
button_location.x + window_rect.left,
|
2540
|
-
button_location.y + window_rect.top,
|
2541
|
-
)
|
2542
|
-
console.print(
|
2543
|
-
f"Botão encontrado nas coordenadas: {button_location}"
|
2544
|
-
)
|
2545
2519
|
pyautogui.click(button_location)
|
2546
|
-
|
2520
|
+
console.print("Botão 'Fechar' clicado com sucesso!")
|
2547
2521
|
except pyautogui.ImageNotFoundException:
|
2548
|
-
|
2549
|
-
console.print(f"
|
2522
|
+
window_rect = main_window.rectangle()
|
2523
|
+
console.print(f"Area que sera utulizada para o recorte {window_rect}...\n")
|
2524
|
+
try:
|
2525
|
+
button_location = pyautogui.locateCenterOnScreen(
|
2526
|
+
fechar_tela_processamento,
|
2527
|
+
region=(
|
2528
|
+
window_rect.left,
|
2529
|
+
window_rect.top,
|
2530
|
+
window_rect.width(),
|
2531
|
+
window_rect.height(),
|
2532
|
+
),
|
2533
|
+
)
|
2534
|
+
if button_location:
|
2535
|
+
button_location = (
|
2536
|
+
button_location.x + window_rect.left,
|
2537
|
+
button_location.y + window_rect.top,
|
2538
|
+
)
|
2539
|
+
console.print(
|
2540
|
+
f"Botão encontrado nas coordenadas: {button_location}"
|
2541
|
+
)
|
2542
|
+
pyautogui.click(button_location)
|
2543
|
+
await worker_sleep(10)
|
2544
|
+
except pyautogui.ImageNotFoundException:
|
2545
|
+
retorno = f"Não foi possivel fechar a tela de processamento, Error: {e} \nEtapas Executadas:\n{steps}"
|
2546
|
+
console.print(f"Não foi possivel fechar a tela de processamento, Error: {e}...\n tentando inserir via posição...\n")
|
2547
|
+
return RpaRetornoProcessoDTO(
|
2548
|
+
sucesso=False,
|
2549
|
+
retorno=retorno,
|
2550
|
+
status=RpaHistoricoStatusEnum.Falha,
|
2551
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
2552
|
+
)
|
2553
|
+
except Exception as e:
|
2554
|
+
retorno = f"Não foi possivel fechar a tela de processamento, Error:{e} \nEtapas Executadas:\n{steps}"
|
2555
|
+
console.print(f"Não foi possivel fechar a tela de processamento, Error:{e}...\n tentando inserir via posição...\n")
|
2550
2556
|
return RpaRetornoProcessoDTO(
|
2551
2557
|
sucesso=False,
|
2552
2558
|
retorno=retorno,
|
2553
2559
|
status=RpaHistoricoStatusEnum.Falha,
|
2554
2560
|
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
2555
2561
|
)
|
2556
|
-
except Exception as e:
|
2557
|
-
retorno = f"Não foi possivel fechar a tela de processamento, Error:{e} \nEtapas Executadas:\n{steps}"
|
2558
|
-
console.print(f"Não foi possivel fechar a tela de processamento, Error:{e}...\n tentando inserir via posição...\n")
|
2559
|
-
return RpaRetornoProcessoDTO(
|
2560
|
-
sucesso=False,
|
2561
|
-
retorno=retorno,
|
2562
|
-
status=RpaHistoricoStatusEnum.Falha,
|
2563
|
-
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
2564
|
-
)
|
2565
|
-
except:
|
2566
|
-
console.print("Janela TFrmProcessamentoNFe2 ja fechada")
|
2567
|
-
|
2568
|
-
await worker_sleep(10)
|
2569
|
-
console.print("Verificando se possui pop-up imprimir boleta")
|
2570
|
-
boleta_screen = await is_window_open("Confirm")
|
2571
|
-
if boleta_screen["IsOpened"] == True:
|
2572
|
-
console.print("Janela aberta, fechando")
|
2573
|
-
try:
|
2574
|
-
console.print("Confirm")
|
2575
|
-
app = Application().connect(title="Confirm", timeout=10)
|
2576
|
-
main_window = app["Confirm"]
|
2577
|
-
main_window.set_focus()
|
2578
2562
|
except:
|
2579
|
-
console.print("
|
2580
|
-
app = Application().connect(class_name="TMessageForm", timeout=10, title='Confirm')
|
2581
|
-
main_window = app["TMessageForm"]
|
2582
|
-
main_window.set_focus()
|
2563
|
+
console.print("Janela TFrmProcessamentoNFe2 ja fechada")
|
2583
2564
|
|
2584
|
-
|
2585
|
-
|
2565
|
+
await worker_sleep(10)
|
2566
|
+
console.print("Verificando se possui pop-up imprimir boleta")
|
2567
|
+
boleta_screen = await is_window_open("Confirm")
|
2568
|
+
if boleta_screen["IsOpened"] == True:
|
2569
|
+
console.print("Janela aberta, fechando")
|
2570
|
+
try:
|
2571
|
+
console.print("Confirm")
|
2572
|
+
app = Application().connect(title="Confirm", timeout=10)
|
2573
|
+
main_window = app["Confirm"]
|
2574
|
+
main_window.set_focus()
|
2575
|
+
except:
|
2576
|
+
console.print("Identificando - TMessageForm 5")
|
2577
|
+
app = Application().connect(class_name="TMessageForm", timeout=10, title='Confirm')
|
2578
|
+
main_window = app["TMessageForm"]
|
2579
|
+
main_window.set_focus()
|
2586
2580
|
|
2581
|
+
btn_no = main_window.child_window(class_name="TButton", title="&No")
|
2582
|
+
btn_no.click()
|
2587
2583
|
|
2588
|
-
await worker_sleep(7)
|
2589
|
-
erro_screen = await is_window_open_by_class("TFrmDadosFaturamentoPreVenda","Confirm")
|
2590
|
-
if erro_screen["IsOpened"] == True:
|
2591
|
-
console.print("Janela aberta, fechando")
|
2592
|
-
try:
|
2593
|
-
console.print("Identificando - TFrmDadosFaturamentoPreVenda 2")
|
2594
|
-
app = Application().connect(class_name="TFrmDadosFaturamentoPreVenda", timeout=10)
|
2595
|
-
main_window = app["Confirm"]
|
2596
|
-
main_window.set_focus()
|
2597
|
-
except:
|
2598
|
-
console.print("Identificando - TMessageForm 3")
|
2599
|
-
app = Application().connect(class_name="TMessageForm", timeout=10, title='Confirm')
|
2600
|
-
main_window = app["TMessageForm"]
|
2601
|
-
main_window.set_focus()
|
2602
2584
|
|
2603
|
-
|
2604
|
-
|
2605
|
-
|
2585
|
+
await worker_sleep(7)
|
2586
|
+
erro_screen = await is_window_open_by_class("TFrmDadosFaturamentoPreVenda","Confirm")
|
2587
|
+
if erro_screen["IsOpened"] == True:
|
2588
|
+
console.print("Janela aberta, fechando")
|
2589
|
+
try:
|
2590
|
+
console.print("Identificando - TFrmDadosFaturamentoPreVenda 2")
|
2591
|
+
app = Application().connect(class_name="TFrmDadosFaturamentoPreVenda", timeout=10)
|
2592
|
+
main_window = app["Confirm"]
|
2593
|
+
main_window.set_focus()
|
2594
|
+
except:
|
2595
|
+
console.print("Identificando - TMessageForm 3")
|
2596
|
+
app = Application().connect(class_name="TMessageForm", timeout=10, title='Confirm')
|
2597
|
+
main_window = app["TMessageForm"]
|
2598
|
+
main_window.set_focus()
|
2606
2599
|
|
2607
|
-
|
2608
|
-
|
2609
|
-
|
2610
|
-
if erro_screen["IsOpened"] == True:
|
2611
|
-
console.print("Janela aberta, fechando")
|
2612
|
-
app = Application().connect(class_name="TMemo", timeout=10)
|
2613
|
-
main_window = app["TMemo"]
|
2614
|
-
main_window.set_focus()
|
2615
|
-
await worker_sleep(5)
|
2616
|
-
main_window.close()
|
2617
|
-
|
2618
|
-
await worker_sleep(5)
|
2619
|
-
console.print("Verificando se a tela de Faturamento Pre venda esta aberta")
|
2620
|
-
close_dados_faturamento = await is_window_open_by_class("TFrmDadosFaturamentoPreVenda","TFrmDadosFaturamentoPreVenda")
|
2621
|
-
if close_dados_faturamento["IsOpened"] == True:
|
2622
|
-
console.print("Janela aberta, fechando")
|
2623
|
-
try:
|
2624
|
-
app = Application().connect(class_name="TFrmDadosFaturamentoPreVenda", timeout=60)
|
2625
|
-
main_window = app["TFrmDadosFaturamentoPreVenda"]
|
2626
|
-
main_window.set_focus()
|
2627
|
-
btn_cancelar = main_window.child_window(class_name="TBitBtn", found_index=0)
|
2628
|
-
btn_cancelar.click()
|
2629
|
-
except:
|
2630
|
-
btn_cancelar = main_window.child_window(title="&Cancela")
|
2631
|
-
btn_cancelar.click()
|
2632
|
-
|
2600
|
+
btn_no = main_window.child_window(class_name="TButton", title="&No")
|
2601
|
+
btn_no.click()
|
2602
|
+
|
2633
2603
|
|
2634
|
-
|
2635
|
-
|
2636
|
-
|
2637
|
-
|
2638
|
-
|
2639
|
-
|
2640
|
-
|
2641
|
-
main_window = app["TFrmDadosFaturamentoPreVenda"]
|
2604
|
+
await worker_sleep(10)
|
2605
|
+
console.print("Verificando se a tela de Mensagem esta aberta")
|
2606
|
+
erro_screen = await is_window_open_by_class("TMemo","TMemo")
|
2607
|
+
if erro_screen["IsOpened"] == True:
|
2608
|
+
console.print("Janela aberta, fechando")
|
2609
|
+
app = Application().connect(class_name="TMemo", timeout=10)
|
2610
|
+
main_window = app["TMemo"]
|
2642
2611
|
main_window.set_focus()
|
2643
|
-
await worker_sleep(
|
2612
|
+
await worker_sleep(5)
|
2644
2613
|
main_window.close()
|
2645
|
-
|
2646
|
-
|
2614
|
+
|
2615
|
+
await worker_sleep(5)
|
2616
|
+
console.print("Verificando se a tela de Faturamento Pre venda esta aberta")
|
2617
|
+
close_dados_faturamento = await is_window_open_by_class("TFrmDadosFaturamentoPreVenda","TFrmDadosFaturamentoPreVenda")
|
2618
|
+
if close_dados_faturamento["IsOpened"] == True:
|
2619
|
+
console.print("Janela aberta, fechando")
|
2620
|
+
try:
|
2621
|
+
app = Application().connect(class_name="TFrmDadosFaturamentoPreVenda", timeout=60)
|
2622
|
+
main_window = app["TFrmDadosFaturamentoPreVenda"]
|
2623
|
+
main_window.set_focus()
|
2624
|
+
btn_cancelar = main_window.child_window(class_name="TBitBtn", found_index=0)
|
2625
|
+
btn_cancelar.click()
|
2626
|
+
except:
|
2627
|
+
btn_cancelar = main_window.child_window(title="&Cancela")
|
2628
|
+
btn_cancelar.click()
|
2629
|
+
|
2647
2630
|
|
2631
|
+
await worker_sleep(10)
|
2632
|
+
console.print("Verificando se a tela de Faturamento Pre venda esta aberta")
|
2633
|
+
close_dados_faturamento = await is_window_open_by_class("TFrmDadosFaturamentoPreVenda","TFrmDadosFaturamentoPreVenda")
|
2634
|
+
if close_dados_faturamento["IsOpened"] == True:
|
2635
|
+
console.print("Janela aberta, fechando")
|
2636
|
+
try:
|
2637
|
+
app = Application().connect(class_name="TFrmDadosFaturamentoPreVenda", timeout=180)
|
2638
|
+
main_window = app["TFrmDadosFaturamentoPreVenda"]
|
2639
|
+
main_window.set_focus()
|
2640
|
+
await worker_sleep(2)
|
2641
|
+
main_window.close()
|
2642
|
+
except Exception as e:
|
2643
|
+
console.print(f"Erro ao fechar a janela de dados faturamento pre venda {e}")
|
2648
2644
|
|
2649
|
-
await worker_sleep(10)
|
2650
|
-
console.print("Verificando se a tela de Gerenciador esta aberta")
|
2651
|
-
window_gerenciador_screen = await is_window_open_by_class("TFrmGerenciadorNFe2","TFrmGerenciadorNFe2")
|
2652
|
-
if window_gerenciador_screen["IsOpened"] == True:
|
2653
|
-
app = Application().connect(class_name="TFrmGerenciadorNFe2", timeout=10)
|
2654
|
-
window_gerenciador = app["TFrmGerenciadorNFe2"]
|
2655
|
-
window_gerenciador.set_focus()
|
2656
|
-
await worker_sleep(2)
|
2657
|
-
window_gerenciador.close()
|
2658
|
-
else:
|
2659
|
-
console.print("Janela TFrmGerenciadorNFe2 ja fechada")
|
2660
2645
|
|
2646
|
+
await worker_sleep(10)
|
2647
|
+
console.print("Verificando se a tela de Gerenciador esta aberta")
|
2648
|
+
window_gerenciador_screen = await is_window_open_by_class("TFrmGerenciadorNFe2","TFrmGerenciadorNFe2")
|
2649
|
+
if window_gerenciador_screen["IsOpened"] == True:
|
2650
|
+
app = Application().connect(class_name="TFrmGerenciadorNFe2", timeout=10)
|
2651
|
+
window_gerenciador = app["TFrmGerenciadorNFe2"]
|
2652
|
+
window_gerenciador.set_focus()
|
2653
|
+
await worker_sleep(2)
|
2654
|
+
window_gerenciador.close()
|
2655
|
+
else:
|
2656
|
+
console.print("Janela TFrmGerenciadorNFe2 ja fechada")
|
2661
2657
|
|
2662
|
-
|
2663
|
-
|
2664
|
-
|
2665
|
-
|
2666
|
-
|
2667
|
-
|
2668
|
-
|
2669
|
-
|
2670
|
-
|
2658
|
+
|
2659
|
+
await worker_sleep(10)
|
2660
|
+
console.print("Verificando se a tela de Pre venda esta aberta")
|
2661
|
+
window_gerenciador_screen = await is_window_open_by_class("TFrmPreVenda","TFrmPreVenda")
|
2662
|
+
if window_gerenciador_screen["IsOpened"] == True:
|
2663
|
+
app = Application().connect(class_name="TFrmPreVenda", timeout=10)
|
2664
|
+
window_gerenciador = app["TFrmPreVenda"]
|
2665
|
+
window_gerenciador.set_focus()
|
2666
|
+
await worker_sleep(2)
|
2667
|
+
window_gerenciador.close()
|
2668
|
+
else:
|
2669
|
+
console.print("Janela TFrmPreVenda ja fechada")
|
2671
2670
|
else:
|
2672
|
-
console.print("
|
2671
|
+
console.print("Não é combustivel")
|
2673
2672
|
|
2674
2673
|
|
2675
2674
|
except Exception as e:
|
@@ -2998,132 +2997,132 @@ async def devolucao_ctf(task: RpaProcessoEntradaDTO) -> RpaRetornoProcessoDTO:
|
|
2998
2997
|
|
2999
2998
|
|
3000
2999
|
#FOR OUTROS ITENS NOTA
|
3001
|
-
for item in itens_nota:
|
3002
|
-
|
3003
|
-
|
3004
|
-
|
3005
|
-
|
3006
|
-
|
3007
|
-
|
3008
|
-
|
3009
|
-
|
3010
|
-
|
3011
|
-
|
3012
|
-
|
3013
|
-
|
3014
|
-
|
3015
|
-
|
3016
|
-
|
3017
|
-
|
3000
|
+
# for item in itens_nota:
|
3001
|
+
# quantidade = item['quantidade']
|
3002
|
+
# preco = item['valor_unitario']
|
3003
|
+
# descricao = item['descricao']
|
3004
|
+
# descricao = 'Diesel Comum' if descricao == 'Diesel S500' else descricao
|
3005
|
+
# item_cod = item['codigo']
|
3006
|
+
# #descricao = descricao.replace(".",",")
|
3007
|
+
|
3008
|
+
# if 'arla' in descricao.lower():
|
3009
|
+
# item_arla = True
|
3010
|
+
# continue #continue para pular o item arla
|
3011
|
+
|
3012
|
+
# console.print(quantidade, preco, descricao)
|
3013
|
+
|
3014
|
+
# app = Application().connect(class_name="TFrmPreVenda", timeout=60)
|
3015
|
+
# main_window = app["TFrmPreVenda"]
|
3016
|
+
# main_window.set_focus()
|
3018
3017
|
|
3019
|
-
|
3020
|
-
|
3021
|
-
|
3022
|
-
|
3023
|
-
|
3024
|
-
|
3025
|
-
|
3026
|
-
|
3027
|
-
|
3028
|
-
|
3029
|
-
|
3030
|
-
|
3031
|
-
|
3032
|
-
|
3033
|
-
|
3034
|
-
|
3035
|
-
|
3036
|
-
|
3037
|
-
|
3038
|
-
|
3039
|
-
|
3040
|
-
|
3041
|
-
|
3042
|
-
|
3043
|
-
|
3044
|
-
|
3045
|
-
|
3046
|
-
|
3047
|
-
|
3048
|
-
|
3049
|
-
|
3050
|
-
|
3051
|
-
|
3052
|
-
|
3053
|
-
|
3054
|
-
|
3055
|
-
|
3056
|
-
|
3057
|
-
|
3058
|
-
|
3059
|
-
|
3060
|
-
|
3061
|
-
|
3062
|
-
|
3063
|
-
|
3064
|
-
|
3065
|
-
|
3066
|
-
|
3067
|
-
|
3068
|
-
|
3069
|
-
|
3070
|
-
|
3071
|
-
|
3072
|
-
|
3073
|
-
|
3074
|
-
|
3075
|
-
|
3076
|
-
|
3077
|
-
|
3078
|
-
|
3079
|
-
|
3080
|
-
|
3081
|
-
|
3082
|
-
|
3083
|
-
|
3084
|
-
|
3085
|
-
|
3086
|
-
|
3087
|
-
|
3088
|
-
|
3089
|
-
|
3090
|
-
|
3091
|
-
|
3092
|
-
|
3093
|
-
|
3018
|
+
# console.print("Itens acessado com sucesso, clicando em Incluir...\n")
|
3019
|
+
# panel_TGroup_Box= panel_TPage.child_window(class_name="TGroupBox", found_index=0)
|
3020
|
+
# btn_incluir = panel_TGroup_Box.child_window(class_name="TDBIBitBtn", found_index=4)
|
3021
|
+
# btn_incluir.click()
|
3022
|
+
# await worker_sleep(5)
|
3023
|
+
# console.print("Incluir clicado com sucesso...\n")
|
3024
|
+
|
3025
|
+
# #VERIFICANDO A EXISTENCIA DE WARNINGS
|
3026
|
+
# console.print("Verificando a existência de Warning... \n")
|
3027
|
+
# warning_pop_up = await is_window_open("Warning")
|
3028
|
+
# if warning_pop_up["IsOpened"] == True:
|
3029
|
+
# console.print("possui Pop-up de Warning, analisando... \n")
|
3030
|
+
# ocr_pop_warning = await ocr_warnings(numero_cupom_fiscal)
|
3031
|
+
# if ocr_pop_warning.sucesso == True:
|
3032
|
+
# return RpaRetornoProcessoDTO(
|
3033
|
+
# sucesso=False,
|
3034
|
+
# retorno=f"POP UP Warning não mapeado para seguimento do processo, mensagem: {ocr_pop_warning.retorno}",
|
3035
|
+
# status=RpaHistoricoStatusEnum.Falha,
|
3036
|
+
# tags=[RpaTagDTO(descricao=RpaTagEnum.Negocio)]
|
3037
|
+
# )
|
3038
|
+
# else:
|
3039
|
+
# return RpaRetornoProcessoDTO(
|
3040
|
+
# sucesso=False,
|
3041
|
+
# retorno=f"POP UP Warning não mapeado para seguimento do processo",
|
3042
|
+
# status=RpaHistoricoStatusEnum.Falha,
|
3043
|
+
# tags=[RpaTagDTO(descricao=RpaTagEnum.Negocio)]
|
3044
|
+
# )
|
3045
|
+
|
3046
|
+
# app = Application().connect(class_name="TFrmIncluiItemPreVenda", timeout=60)
|
3047
|
+
# main_window = app["TFrmIncluiItemPreVenda"]
|
3048
|
+
# main_window.set_focus()
|
3049
|
+
# panel_TGroup_Box= main_window.child_window(class_name="TPanel", found_index=2)
|
3050
|
+
# almoxarificado_index = panel_TGroup_Box.child_window(class_name="TDBIEditNumber", found_index=1)
|
3051
|
+
# cod_almoxarificado = str(cod_empresa)+"50"
|
3052
|
+
# almoxarificado_index.click()
|
3053
|
+
# await worker_sleep(1)
|
3054
|
+
# for _ in range(5):
|
3055
|
+
# pyautogui.press("del")
|
3056
|
+
# pyautogui.press("backspace")
|
3057
|
+
# await worker_sleep(1)
|
3058
|
+
# pyautogui.write(cod_almoxarificado)
|
3059
|
+
# pyautogui.press('tab')
|
3060
|
+
# await worker_sleep(3)
|
3061
|
+
|
3062
|
+
# cod_item_index = panel_TGroup_Box.child_window(class_name="TDBIEditNumber", found_index=0)
|
3063
|
+
# cod_item_index.click()
|
3064
|
+
# await worker_sleep(1)
|
3065
|
+
|
3066
|
+
# for _ in range(5):
|
3067
|
+
# pyautogui.press("del")
|
3068
|
+
# pyautogui.press("backspace")
|
3069
|
+
|
3070
|
+
# await worker_sleep(1)
|
3071
|
+
# pyautogui.write(str(item_cod))
|
3072
|
+
# pyautogui.press('tab')
|
3073
|
+
# await worker_sleep(3)
|
3074
|
+
|
3075
|
+
|
3076
|
+
# natureza_oper_select = panel_TGroup_Box.child_window(class_name="TDBIComboBox", found_index=0)
|
3077
|
+
# nop_selected = natureza_oper_select.window_text()
|
3078
|
+
# nop_selected_value = nop_selected[:4]
|
3079
|
+
|
3080
|
+
# itens_to_select = natureza_oper_select.texts()
|
3081
|
+
# nop_to_be_select = ''
|
3082
|
+
|
3083
|
+
# for item in itens_to_select:
|
3084
|
+
# 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())):
|
3085
|
+
# nop_to_be_select = item
|
3086
|
+
# break
|
3087
|
+
|
3088
|
+
# natureza_oper_select.click()
|
3089
|
+
# await worker_sleep(1)
|
3090
|
+
# console.print(f"Descrição: {descricao}")
|
3091
|
+
# console.print("Selecionando NOP do item: '5667 - VENDA DE COMB OU LUBRI - SEM ESTOQ E COM FINANC'")
|
3092
|
+
# natureza_oper_select.select("5667 - VENDA DE COMB OU LUBRI - SEM ESTOQ E COM FINANC")
|
3094
3093
|
|
3095
|
-
|
3096
|
-
|
3097
|
-
|
3098
|
-
|
3099
|
-
|
3100
|
-
|
3101
|
-
|
3102
|
-
|
3103
|
-
|
3104
|
-
|
3105
|
-
|
3106
|
-
|
3107
|
-
|
3108
|
-
|
3109
|
-
|
3110
|
-
|
3111
|
-
|
3112
|
-
|
3113
|
-
|
3114
|
-
|
3115
|
-
|
3116
|
-
|
3117
|
-
|
3118
|
-
|
3119
|
-
|
3120
|
-
|
3121
|
-
|
3122
|
-
|
3123
|
-
|
3124
|
-
|
3125
|
-
|
3126
|
-
|
3094
|
+
# await worker_sleep(1)
|
3095
|
+
# console.print("Natureza da operação selecionado com sucesso, preenchendo os itens...\n")
|
3096
|
+
|
3097
|
+
# #INSERINDO A QUANTIDADE
|
3098
|
+
# main_window.set_focus()
|
3099
|
+
# panel_TPage_Control= main_window.child_window(class_name="TcxPageControl", found_index=0)
|
3100
|
+
# panel_tabSheet = panel_TPage_Control.child_window(class_name="TcxTabSheet", found_index=0)
|
3101
|
+
|
3102
|
+
# field_quantidade = panel_tabSheet.child_window(class_name="TDBIEditNumber", found_index=8)
|
3103
|
+
# console.print("Inserindo a quantidade de Itens...\n")
|
3104
|
+
# field_quantidade.click()
|
3105
|
+
# await worker_sleep(1)
|
3106
|
+
# pyautogui.press('del')
|
3107
|
+
# await worker_sleep(1)
|
3108
|
+
# pyautogui.press('backspace')
|
3109
|
+
# await worker_sleep(1)
|
3110
|
+
# pyautogui.write(quantidade)
|
3111
|
+
# #field_quantidade.set_edit_text(quantidade)
|
3112
|
+
# await worker_sleep(1)
|
3113
|
+
# pyautogui.press('tab')
|
3114
|
+
# await worker_sleep(2)
|
3115
|
+
|
3116
|
+
# console.print("Verificando inclui itiem Pre Venda")
|
3117
|
+
# app = Application().connect(class_name="TFrmIncluiItemPreVenda", timeout=60)
|
3118
|
+
# main_window = app["TFrmIncluiItemPreVenda"]
|
3119
|
+
# main_window.set_focus()
|
3120
|
+
# send_keys("%i")
|
3121
|
+
# await worker_sleep(2)
|
3122
|
+
# #Divergencia de nop na capa e no item
|
3123
|
+
# await find_nop_divergence()
|
3124
|
+
# await worker_sleep(5)
|
3125
|
+
# main_window.close()
|
3127
3126
|
|
3128
3127
|
|
3129
3128
|
#INSERINDO O VALOR
|