worker-automate-hub 0.5.820__py3-none-any.whl → 0.5.822__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/api/client.py +3 -2
- worker_automate_hub/tasks/jobs/extracao_saldo_estoque_fiscal.py +90 -11
- worker_automate_hub/tasks/jobs/opex_capex.py +9 -1
- {worker_automate_hub-0.5.820.dist-info → worker_automate_hub-0.5.822.dist-info}/METADATA +1 -1
- {worker_automate_hub-0.5.820.dist-info → worker_automate_hub-0.5.822.dist-info}/RECORD +7 -7
- {worker_automate_hub-0.5.820.dist-info → worker_automate_hub-0.5.822.dist-info}/WHEEL +0 -0
- {worker_automate_hub-0.5.820.dist-info → worker_automate_hub-0.5.822.dist-info}/entry_points.txt +0 -0
|
@@ -582,8 +582,9 @@ async def get_dados_nf_emsys(
|
|
|
582
582
|
) as session:
|
|
583
583
|
async with session.get(url, headers=headers_basic, params=params) as response:
|
|
584
584
|
if response.status != 200:
|
|
585
|
+
body = await response.text() # ✅ lê o conteúdo do body
|
|
585
586
|
raise Exception(
|
|
586
|
-
f"
|
|
587
|
+
f"({response.status}): {body}"
|
|
587
588
|
)
|
|
588
589
|
|
|
589
590
|
data = await response.json()
|
|
@@ -656,7 +657,7 @@ async def get_dados_nf_emsys(
|
|
|
656
657
|
return resultado
|
|
657
658
|
|
|
658
659
|
except Exception as e:
|
|
659
|
-
raise Exception(f"
|
|
660
|
+
raise Exception(f"{e}")
|
|
660
661
|
|
|
661
662
|
|
|
662
663
|
|
|
@@ -5,6 +5,8 @@ from pywinauto import Application, timings, findwindows, keyboard, Desktop
|
|
|
5
5
|
import sys
|
|
6
6
|
import io
|
|
7
7
|
import win32gui
|
|
8
|
+
import pyperclip
|
|
9
|
+
from unidecode import unidecode
|
|
8
10
|
|
|
9
11
|
# sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..')))
|
|
10
12
|
|
|
@@ -44,6 +46,88 @@ console = Console()
|
|
|
44
46
|
pyautogui.PAUSE = 0.5
|
|
45
47
|
pyautogui.FAILSAFE = False
|
|
46
48
|
|
|
49
|
+
# -------- Configs de velocidade --------
|
|
50
|
+
SLEEP_BETWEEN_KEYS = 0.03 # 30ms entre DOWNs
|
|
51
|
+
SLEEP_AFTER_COPY = 0.06 # 60ms após Ctrl+C
|
|
52
|
+
|
|
53
|
+
# -------- Utilidades --------
|
|
54
|
+
def _get_main_window_by_class(timeout_s: int = 5):
|
|
55
|
+
app = Application(backend="win32").connect(class_name="TFrmMovtoLivroFiscal", timeout=timeout_s)
|
|
56
|
+
win = app.window(class_name="TFrmMovtoLivroFiscal")
|
|
57
|
+
try: win.set_focus()
|
|
58
|
+
except Exception: pass
|
|
59
|
+
return app, win
|
|
60
|
+
|
|
61
|
+
def _find_grid_descendant(win):
|
|
62
|
+
# pega o maior TcxGridSite/TcxGrid
|
|
63
|
+
best, best_area = None, -1
|
|
64
|
+
for d in win.descendants():
|
|
65
|
+
try:
|
|
66
|
+
cls = (d.class_name() or "").lower()
|
|
67
|
+
if "tcxgridsite" in cls or "tcxgrid" in cls:
|
|
68
|
+
r = d.rectangle()
|
|
69
|
+
area = max(0,(r.right-r.left)) * max(0,(r.bottom-r.top))
|
|
70
|
+
if area > best_area:
|
|
71
|
+
best, best_area = d, area
|
|
72
|
+
except:
|
|
73
|
+
pass
|
|
74
|
+
if not best:
|
|
75
|
+
raise RuntimeError("Grid não localizado (TcxGrid/TcxGridSite).")
|
|
76
|
+
return best
|
|
77
|
+
|
|
78
|
+
def _copy_active_row_text(retries: int = 1) -> str:
|
|
79
|
+
pyperclip.copy("")
|
|
80
|
+
send_keys("^c")
|
|
81
|
+
time.sleep(SLEEP_AFTER_COPY)
|
|
82
|
+
txt = pyperclip.paste().strip()
|
|
83
|
+
if txt or retries <= 0:
|
|
84
|
+
return txt
|
|
85
|
+
# 1 tentativa extra (às vezes a 1ª vem vazia)
|
|
86
|
+
return _copy_active_row_text(retries-1)
|
|
87
|
+
|
|
88
|
+
def _linha_bate_criterio(txt: str, mes: str, ano: str) -> bool:
|
|
89
|
+
if not txt:
|
|
90
|
+
return False
|
|
91
|
+
t = unidecode(re.sub(r"\s+"," ", txt)).lower()
|
|
92
|
+
# dd/MM/AAAA do mês/ano desejado
|
|
93
|
+
if not re.search(rf"\b(0[1-9]|[12]\d|3[01])/{mes}/{ano}\b", t):
|
|
94
|
+
return False
|
|
95
|
+
return "livro - inventario" in t
|
|
96
|
+
|
|
97
|
+
# -------- Varredura assumindo que JÁ ESTÁ na 1ª linha --------
|
|
98
|
+
def selecionar_inventario_por_competencia(competencia_mm_aaaa: str, max_linhas: int = 800) -> bool:
|
|
99
|
+
"""
|
|
100
|
+
Pré-condição: o foco já está na PRIMEIRA LINHA do grid (você clicou por coordenada).
|
|
101
|
+
A função só navega com SETA-PARA-BAIXO até encontrar a linha alvo e PARA.
|
|
102
|
+
"""
|
|
103
|
+
# Selecionar primeira linha inventario
|
|
104
|
+
pyautogui.click(928, 475)
|
|
105
|
+
time.sleep(1)
|
|
106
|
+
m = re.fullmatch(r"(\d{2})/(\d{4})", competencia_mm_aaaa.strip())
|
|
107
|
+
if not m:
|
|
108
|
+
raise ValueError("Competência deve ser MM/AAAA (ex.: '09/2025').")
|
|
109
|
+
mes, ano = m.groups()
|
|
110
|
+
|
|
111
|
+
# garantir foco na janela/grid (não move o cursor de linha)
|
|
112
|
+
_, win = _get_main_window_by_class()
|
|
113
|
+
grid = _find_grid_descendant(win)
|
|
114
|
+
try:
|
|
115
|
+
grid.set_focus()
|
|
116
|
+
except Exception:
|
|
117
|
+
pass
|
|
118
|
+
|
|
119
|
+
for i in range(max_linhas):
|
|
120
|
+
linha = _copy_active_row_text()
|
|
121
|
+
if _linha_bate_criterio(linha, mes, ano):
|
|
122
|
+
# ✅ Linha correta já está selecionada (sem cliques)
|
|
123
|
+
# print(f"[OK] Encontrado em {i+1} passos: {linha}")
|
|
124
|
+
return True
|
|
125
|
+
send_keys("{DOWN}")
|
|
126
|
+
time.sleep(SLEEP_BETWEEN_KEYS)
|
|
127
|
+
|
|
128
|
+
# print("[WARN] Não encontrado dentro do limite de linhas.")
|
|
129
|
+
return False
|
|
130
|
+
|
|
47
131
|
|
|
48
132
|
async def extracao_saldo_estoque_fiscal(
|
|
49
133
|
task: RpaProcessoEntradaDTO,
|
|
@@ -131,6 +215,7 @@ async def extracao_saldo_estoque_fiscal(
|
|
|
131
215
|
|
|
132
216
|
# Caminho da imagem do botão
|
|
133
217
|
imagem_botao = r"assets\\extracao_relatorios\\btn_incluir_livro.png"
|
|
218
|
+
# imagem_botao = r"C:\Users\automatehub\Documents\GitHub\worker-automate-hub\assets\extracao_relatorios\btn_incluir_livro.png"
|
|
134
219
|
|
|
135
220
|
if os.path.exists(imagem_botao):
|
|
136
221
|
try:
|
|
@@ -214,27 +299,19 @@ async def extracao_saldo_estoque_fiscal(
|
|
|
214
299
|
if win is None:
|
|
215
300
|
raise TimeoutError(f"Janela '{CLASS}' não apareceu dentro do timeout.")
|
|
216
301
|
|
|
217
|
-
|
|
218
|
-
app = Application(backend="win32").connect(handle=win.handle)
|
|
219
|
-
main_window = app.window(handle=win.handle)
|
|
220
|
-
|
|
221
|
-
# Dá o foco na janela
|
|
222
|
-
main_window.set_focus()
|
|
223
|
-
|
|
224
|
-
await worker_sleep(2)
|
|
225
|
-
|
|
226
|
-
main_window.close()
|
|
302
|
+
w.close()
|
|
227
303
|
|
|
228
304
|
await worker_sleep(2)
|
|
229
305
|
|
|
230
306
|
##### Janela Movimento Livro Fiscal #####
|
|
231
307
|
# Selecionar primeira linha inventario
|
|
232
|
-
|
|
308
|
+
selecionar_inventario_por_competencia(periodo)
|
|
233
309
|
|
|
234
310
|
await worker_sleep(2)
|
|
235
311
|
|
|
236
312
|
# Clicar em visualizar livro
|
|
237
313
|
caminho = r"assets\\extracao_relatorios\\btn_visu_livros.png"
|
|
314
|
+
# caminho =r"C:\Users\automatehub\Documents\GitHub\worker-automate-hub\assets\extracao_relatorios\btn_visu_livros.png"
|
|
238
315
|
# Verifica se o arquivo existe
|
|
239
316
|
if os.path.isfile(caminho):
|
|
240
317
|
print("A imagem existe:", caminho)
|
|
@@ -313,6 +390,7 @@ async def extracao_saldo_estoque_fiscal(
|
|
|
313
390
|
# 1) Abrir o picker pelo botão (imagem)
|
|
314
391
|
console.print("Procurando botão de salvar (imagem)...", style="bold cyan")
|
|
315
392
|
caminho_img = r"assets\\extracao_relatorios\btn_salvar.png"
|
|
393
|
+
# caminho_img = r"C:\Users\automatehub\Documents\GitHub\worker-automate-hub\assets\extracao_relatorios\btn_salvar.png"
|
|
316
394
|
if os.path.isfile(caminho_img):
|
|
317
395
|
pos = pyautogui.locateCenterOnScreen(caminho_img, confidence=0.9)
|
|
318
396
|
if pos:
|
|
@@ -607,3 +685,4 @@ async def extracao_saldo_estoque_fiscal(
|
|
|
607
685
|
status=RpaHistoricoStatusEnum.Falha,
|
|
608
686
|
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)],
|
|
609
687
|
)
|
|
688
|
+
|
|
@@ -135,8 +135,16 @@ async def opex_capex(task: RpaProcessoEntradaDTO) -> RpaRetornoProcessoDTO:
|
|
|
135
135
|
console.print("Chave da NF:", nf_chave_acesso)
|
|
136
136
|
|
|
137
137
|
except Exception as e:
|
|
138
|
+
observacao = f"Erro ao lançar nota, erro: {e}"
|
|
138
139
|
console.print("Erro inesperado ao buscar nota:", str(e))
|
|
139
|
-
|
|
140
|
+
return RpaRetornoProcessoDTO(
|
|
141
|
+
sucesso=False,
|
|
142
|
+
retorno=observacao, # <- use 'retorno'
|
|
143
|
+
status=RpaHistoricoStatusEnum.Falha,
|
|
144
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Negocio)]
|
|
145
|
+
)
|
|
146
|
+
|
|
147
|
+
|
|
140
148
|
|
|
141
149
|
# Download XML
|
|
142
150
|
console.log("Realizando o download do XML..\n")
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
worker_automate_hub/__init__.py,sha256=LV28uQvBfpPIqudGIMJmVB8E941MjXHcu8DMoX5n8AM,25
|
|
2
2
|
worker_automate_hub/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
3
|
worker_automate_hub/api/ahead_service.py,sha256=QbNrZf9q7fS0s-S5fZVytqC7dINi9u2f6aB6SDrGVVA,2231
|
|
4
|
-
worker_automate_hub/api/client.py,sha256=
|
|
4
|
+
worker_automate_hub/api/client.py,sha256=FAjwte64gV8EGY9uaZAw1CiZQUcV2pZ9plcDyiv2tqU,32075
|
|
5
5
|
worker_automate_hub/api/datalake_service.py,sha256=qw_N_OOgDKDuPbI-fdYkWWTlT4CUtFTl0VVlZ0fLM-M,3001
|
|
6
6
|
worker_automate_hub/api/helpers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
7
|
worker_automate_hub/api/helpers/api_helpers.py,sha256=SkheO2fXexeh-a4shr8Qzsz_kZhuSG0DJ7kbODctRbM,3696
|
|
@@ -73,7 +73,7 @@ worker_automate_hub/tasks/jobs/exemplo_processo.py,sha256=nV0iLoip2FH2-FhLmhX3nP
|
|
|
73
73
|
worker_automate_hub/tasks/jobs/extracao_fechamento_contabil.py,sha256=6Kr5DKjKLqtFvGzyiXtt7xrQsuU898l8pQXDq9C6AX8,19567
|
|
74
74
|
worker_automate_hub/tasks/jobs/extracao_fechamento_emsys.py,sha256=-T2nZUDiFrUGm_KLxJd_4qcrageDxVpWW3KAAniLFC4,21448
|
|
75
75
|
worker_automate_hub/tasks/jobs/extracao_saldo_estoque.py,sha256=Pviu3Tt5VTx6LzM1Xl8YOXOMwPH2uIbsRlch7aZVN8g,15747
|
|
76
|
-
worker_automate_hub/tasks/jobs/extracao_saldo_estoque_fiscal.py,sha256=
|
|
76
|
+
worker_automate_hub/tasks/jobs/extracao_saldo_estoque_fiscal.py,sha256=_mAey2urQo7BlXxKnDrw7uXkURV55lMdcxWEfvy2vC4,26858
|
|
77
77
|
worker_automate_hub/tasks/jobs/fechar_conexao_rdp.py,sha256=UWAKCS2dbfgDlSQOBdjmVJXfD1MMuUrOi3weDgB0CAc,5718
|
|
78
78
|
worker_automate_hub/tasks/jobs/fidc_exportacao_docs_portal_b2b.py,sha256=tWUmYy3Zhi3JEt8AoqTsWpU-wbf5-OxhCrTOooh1WH4,15616
|
|
79
79
|
worker_automate_hub/tasks/jobs/fidc_gerar_nosso_numero.py,sha256=FAmcCqKVjedf7wIped8XRLIZ9S3oWc6fakF-r1Zm0kg,12637
|
|
@@ -89,7 +89,7 @@ worker_automate_hub/tasks/jobs/lancamento_rateio.py,sha256=0cvbpuJiHl5mca5gpZudX
|
|
|
89
89
|
worker_automate_hub/tasks/jobs/login_emsys.py,sha256=dO9S027qRTtjOfytF6IWO-m6hDld8kZqOVAsn91l1YA,5684
|
|
90
90
|
worker_automate_hub/tasks/jobs/login_emsys_versao_especifica.py,sha256=_6CFh79eaW9KdPGR6FMV01ASPjJzNzzBK1MvC_uiSOo,5625
|
|
91
91
|
worker_automate_hub/tasks/jobs/notas_faturamento_sap.py,sha256=p6tVE027FHHXBxt2sIDxqLInpf_0wS-8TcACnS34p7w,13961
|
|
92
|
-
worker_automate_hub/tasks/jobs/opex_capex.py,sha256=
|
|
92
|
+
worker_automate_hub/tasks/jobs/opex_capex.py,sha256=RbifCpmacvWAbV3tAabee_I0dxb9lKXMXRrYNRNbMVM,37173
|
|
93
93
|
worker_automate_hub/tasks/jobs/playground.py,sha256=7vWDg9DwToHwGJ6_XOa8TQ6LmfRV5Qz2TaOV3q3P9sA,1918
|
|
94
94
|
worker_automate_hub/tasks/jobs/sped_fiscal.py,sha256=rinyHCF7QYHUc6oWACJgnQiAv0S-_Fel9Z0bImiHUoM,31064
|
|
95
95
|
worker_automate_hub/tasks/jobs/transferencias.py,sha256=5TIktufkvUPnVTR2gf7GFQJ5KQP6PWnmoWiE08WiVDQ,46191
|
|
@@ -104,7 +104,7 @@ worker_automate_hub/utils/updater.py,sha256=en2FCGhI8aZ-JNP3LQm64NJDc4awCNW7UhbV
|
|
|
104
104
|
worker_automate_hub/utils/util.py,sha256=p15z2pqyV-fPD8lL6ulurecsWQw9XpKPFf_xEr4U5lM,210781
|
|
105
105
|
worker_automate_hub/utils/utils_nfe_entrada.py,sha256=F7jk95LpDwl5WfaQXahCA5yDdnySnWdctDqczHXwGqE,38195
|
|
106
106
|
worker_automate_hub/worker.py,sha256=zEnYUrm5kY2cHbbee15QJkwkx4euD2SB2zRvUIbjS90,6850
|
|
107
|
-
worker_automate_hub-0.5.
|
|
108
|
-
worker_automate_hub-0.5.
|
|
109
|
-
worker_automate_hub-0.5.
|
|
110
|
-
worker_automate_hub-0.5.
|
|
107
|
+
worker_automate_hub-0.5.822.dist-info/entry_points.txt,sha256=sddyhjx57I08RY8X7UxcTpdoOsWULAWNKN9Xr6pp_Kw,54
|
|
108
|
+
worker_automate_hub-0.5.822.dist-info/METADATA,sha256=dhevG3lSyca8SFf7-9tpP7dNXqFr3hMGgunwByyTbL0,3100
|
|
109
|
+
worker_automate_hub-0.5.822.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
|
|
110
|
+
worker_automate_hub-0.5.822.dist-info/RECORD,,
|
|
File without changes
|
{worker_automate_hub-0.5.820.dist-info → worker_automate_hub-0.5.822.dist-info}/entry_points.txt
RENAMED
|
File without changes
|