worker-automate-hub 0.5.816__py3-none-any.whl → 0.5.817__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.
Potentially problematic release.
This version of worker-automate-hub might be problematic. Click here for more details.
- worker_automate_hub/tasks/jobs/geracao_balancetes_filial.py +82 -47
- {worker_automate_hub-0.5.816.dist-info → worker_automate_hub-0.5.817.dist-info}/METADATA +1 -1
- {worker_automate_hub-0.5.816.dist-info → worker_automate_hub-0.5.817.dist-info}/RECORD +5 -5
- {worker_automate_hub-0.5.816.dist-info → worker_automate_hub-0.5.817.dist-info}/WHEEL +0 -0
- {worker_automate_hub-0.5.816.dist-info → worker_automate_hub-0.5.817.dist-info}/entry_points.txt +0 -0
|
@@ -4,6 +4,7 @@ import sys
|
|
|
4
4
|
import os
|
|
5
5
|
import io
|
|
6
6
|
from pywinauto.keyboard import send_keys
|
|
7
|
+
|
|
7
8
|
# sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..')))
|
|
8
9
|
from worker_automate_hub.models.dto.rpa_historico_request_dto import (
|
|
9
10
|
RpaHistoricoStatusEnum,
|
|
@@ -21,15 +22,14 @@ from worker_automate_hub.utils.util import (
|
|
|
21
22
|
from rich.console import Console
|
|
22
23
|
import pyautogui
|
|
23
24
|
from datetime import datetime
|
|
25
|
+
|
|
24
26
|
# from dateutil.relativedelta import relativedelta
|
|
25
27
|
from PIL import ImageFilter, ImageEnhance
|
|
26
28
|
from pytesseract import image_to_string
|
|
27
29
|
from pywinauto import Application, Desktop
|
|
28
30
|
import subprocess
|
|
29
31
|
import os
|
|
30
|
-
from worker_automate_hub.api.client import
|
|
31
|
-
get_config_by_name, send_file
|
|
32
|
-
)
|
|
32
|
+
from worker_automate_hub.api.client import get_config_by_name, send_file
|
|
33
33
|
from worker_automate_hub.utils.utils_nfe_entrada import EMSys
|
|
34
34
|
import psutil
|
|
35
35
|
from time import sleep
|
|
@@ -69,7 +69,9 @@ async def open_contabil_processes():
|
|
|
69
69
|
console.print(f"Error: {error}")
|
|
70
70
|
|
|
71
71
|
|
|
72
|
-
async def geracao_balancetes_filial(
|
|
72
|
+
async def geracao_balancetes_filial(
|
|
73
|
+
task: RpaProcessoEntradaDTO,
|
|
74
|
+
) -> RpaRetornoProcessoDTO:
|
|
73
75
|
try:
|
|
74
76
|
await kill_all_emsys()
|
|
75
77
|
await open_contabil_processes()
|
|
@@ -112,7 +114,7 @@ async def geracao_balancetes_filial(task: RpaProcessoEntradaDTO) -> RpaRetornoPr
|
|
|
112
114
|
await worker_sleep(4)
|
|
113
115
|
pyautogui.write(config.conConfiguracao.get("pass"))
|
|
114
116
|
pyautogui.press("enter")
|
|
115
|
-
|
|
117
|
+
|
|
116
118
|
await worker_sleep(10)
|
|
117
119
|
|
|
118
120
|
main_window = None
|
|
@@ -151,17 +153,23 @@ async def geracao_balancetes_filial(task: RpaProcessoEntradaDTO) -> RpaRetornoPr
|
|
|
151
153
|
win = app.window(class_name="TFrmBalancete")
|
|
152
154
|
|
|
153
155
|
# Seus índices: inicial = found_index=1, final = found_index=0
|
|
154
|
-
ctrl_inicial = win.child_window(
|
|
155
|
-
|
|
156
|
+
ctrl_inicial = win.child_window(
|
|
157
|
+
class_name="TRzEditDate", found_index=1
|
|
158
|
+
).wrapper_object()
|
|
159
|
+
ctrl_final = win.child_window(
|
|
160
|
+
class_name="TRzEditDate", found_index=0
|
|
161
|
+
).wrapper_object()
|
|
156
162
|
|
|
157
163
|
# ---- Inicial ----
|
|
158
164
|
try:
|
|
159
|
-
ctrl_inicial.set_edit_text(periodo_inicial)
|
|
165
|
+
ctrl_inicial.set_edit_text(periodo_inicial) # tenta via WM_SETTEXT
|
|
160
166
|
except Exception:
|
|
161
167
|
ctrl_inicial.set_focus()
|
|
162
168
|
ctrl_inicial.click_input()
|
|
163
|
-
send_keys(
|
|
164
|
-
send_keys(
|
|
169
|
+
send_keys("^a{DELETE}")
|
|
170
|
+
send_keys(
|
|
171
|
+
periodo_inicial.replace("/", "")
|
|
172
|
+
) # fallback: digita só dígitos (máscara)
|
|
165
173
|
|
|
166
174
|
# ---- Final ----
|
|
167
175
|
try:
|
|
@@ -169,58 +177,76 @@ async def geracao_balancetes_filial(task: RpaProcessoEntradaDTO) -> RpaRetornoPr
|
|
|
169
177
|
except Exception:
|
|
170
178
|
ctrl_final.set_focus()
|
|
171
179
|
ctrl_final.click_input()
|
|
172
|
-
send_keys(
|
|
173
|
-
send_keys(periodo_final.replace(
|
|
174
|
-
|
|
180
|
+
send_keys("^a{DELETE}")
|
|
181
|
+
send_keys(periodo_final.replace("/", ""))
|
|
182
|
+
|
|
175
183
|
await worker_sleep(2)
|
|
176
|
-
|
|
184
|
+
|
|
177
185
|
console.print("Selecionar detalhada por centro de custo..")
|
|
178
|
-
detalhada = win.child_window(
|
|
179
|
-
class_name="TRzComboBox", found_index=0
|
|
180
|
-
)
|
|
186
|
+
detalhada = win.child_window(class_name="TRzComboBox", found_index=0)
|
|
181
187
|
detalhada.select("Centro de Custo")
|
|
182
|
-
|
|
183
|
-
await worker_sleep(
|
|
188
|
+
|
|
189
|
+
await worker_sleep(6)
|
|
184
190
|
|
|
185
191
|
console.print("Selecionar considerar contas analíticas zerada")
|
|
186
|
-
contas_analit_zeradas = win.child_window(
|
|
192
|
+
contas_analit_zeradas = win.child_window(
|
|
193
|
+
class_name="TRzCheckBox", found_index=2
|
|
194
|
+
).click()
|
|
195
|
+
|
|
196
|
+
await worker_sleep(2)
|
|
187
197
|
|
|
188
198
|
console.print("Selecionar considerar contas sintéticas zerada")
|
|
189
|
-
contas_sint_zeradas = win.child_window(
|
|
199
|
+
contas_sint_zeradas = win.child_window(
|
|
200
|
+
class_name="TRzCheckBox", found_index=0
|
|
201
|
+
).click()
|
|
202
|
+
|
|
203
|
+
await worker_sleep(2)
|
|
190
204
|
|
|
191
205
|
console.print("Selecionar por filiais")
|
|
192
|
-
selec_filiais = win.child_window(
|
|
206
|
+
selec_filiais = win.child_window(
|
|
207
|
+
class_name="TRzCheckBox", found_index=3
|
|
208
|
+
).click()
|
|
209
|
+
|
|
210
|
+
await worker_sleep(2)
|
|
193
211
|
|
|
194
212
|
console.print("Selecionar CSV")
|
|
195
213
|
selec_csv = win.child_window(class_name="TRzComboBox", found_index=1)
|
|
196
214
|
selec_csv.select("Arquivo CSV")
|
|
197
215
|
|
|
216
|
+
await worker_sleep(2)
|
|
217
|
+
|
|
198
218
|
console.print("Clicar em gerar relatório")
|
|
199
|
-
btn_gerar_relatorio = win.child_window(
|
|
219
|
+
btn_gerar_relatorio = win.child_window(
|
|
220
|
+
class_name="TBitBtn", found_index=0
|
|
221
|
+
).click()
|
|
200
222
|
|
|
201
223
|
# Selecionar filial
|
|
202
|
-
app = Application(backend="win32").connect(
|
|
203
|
-
|
|
224
|
+
app = Application(backend="win32").connect(
|
|
225
|
+
title="Seleção de Empresas", timeout=10
|
|
226
|
+
)
|
|
227
|
+
dlg = app.window(title="Seleção de Empresas")
|
|
204
228
|
edit = dlg.child_window(class_name="TEdit", found_index=0).wrapper_object()
|
|
205
229
|
|
|
206
230
|
# Tenta via WM_SETTEXT
|
|
207
231
|
try:
|
|
208
232
|
edit.set_focus()
|
|
209
|
-
edit.set_edit_text("")
|
|
210
|
-
edit.set_edit_text("3")
|
|
233
|
+
edit.set_edit_text("") # limpa
|
|
234
|
+
edit.set_edit_text("3") # escreve
|
|
211
235
|
except Exception:
|
|
212
236
|
# Fallback: digita como teclado
|
|
213
237
|
edit.set_focus()
|
|
214
238
|
edit.click_input()
|
|
215
|
-
send_keys(
|
|
239
|
+
send_keys("^a{DELETE}")
|
|
216
240
|
send_keys("3", with_spaces=True)
|
|
217
241
|
|
|
218
242
|
await worker_sleep(3)
|
|
219
|
-
|
|
243
|
+
|
|
220
244
|
# Marcar filial
|
|
221
245
|
imagem_alvo = "assets\\geracao_bal_filial\\btn_selec_uma_filial.png"
|
|
222
246
|
|
|
223
|
-
btn_sect_uma = pyautogui.locateCenterOnScreen(
|
|
247
|
+
btn_sect_uma = pyautogui.locateCenterOnScreen(
|
|
248
|
+
imagem_alvo, confidence=0.9
|
|
249
|
+
) # requer opencv-python
|
|
224
250
|
if btn_sect_uma: # se achou, clica
|
|
225
251
|
pyautogui.click(btn_sect_uma)
|
|
226
252
|
|
|
@@ -228,53 +254,62 @@ async def geracao_balancetes_filial(task: RpaProcessoEntradaDTO) -> RpaRetornoPr
|
|
|
228
254
|
|
|
229
255
|
# aguarda até a janela "Gera Arquivo CSV (Excel)" existir (ou ficar visível)
|
|
230
256
|
csv_win = Desktop(backend="win32").window(title="Gera Arquivo CSV (Excel)")
|
|
231
|
-
csv_win.wait(
|
|
257
|
+
csv_win.wait("exists", timeout=3600)
|
|
232
258
|
|
|
233
259
|
app_csv = Application(backend="win32").connect(title="Gera Arquivo CSV (Excel)")
|
|
234
260
|
dlg_csv = app_csv.window(title="Gera Arquivo CSV (Excel)")
|
|
235
261
|
edit = dlg_csv.child_window(class_name="Edit", found_index=0)
|
|
236
262
|
# Tenta via WM_SETTEXT (mais estável)
|
|
237
263
|
try:
|
|
238
|
-
periodo_inicial = periodo_inicial.replace("/","")
|
|
239
|
-
periodo_final = periodo_final.replace("/","")
|
|
264
|
+
periodo_inicial = periodo_inicial.replace("/", "")
|
|
265
|
+
periodo_final = periodo_final.replace("/", "")
|
|
240
266
|
edit.set_focus()
|
|
241
|
-
edit.set_edit_text("")
|
|
242
|
-
edit.set_edit_text(
|
|
267
|
+
edit.set_edit_text("") # limpa
|
|
268
|
+
edit.set_edit_text(
|
|
269
|
+
rf"C:\Users\automatehub\Downloads\balancete_{periodo_inicial}_{periodo_final}_{filial}"
|
|
270
|
+
)
|
|
243
271
|
except Exception:
|
|
244
272
|
# Fallback: digita como teclado
|
|
245
273
|
edit.set_focus()
|
|
246
274
|
edit.click_input()
|
|
247
|
-
send_keys(
|
|
248
|
-
send_keys(
|
|
275
|
+
send_keys("^a{DELETE}")
|
|
276
|
+
send_keys(
|
|
277
|
+
rf"C:\Users\automatehub\Downloads\balancete_{periodo_inicial}_{periodo_final}_{filial}",
|
|
278
|
+
with_spaces=True,
|
|
279
|
+
)
|
|
249
280
|
|
|
250
281
|
# Clicar em salvar
|
|
251
|
-
app = Application(backend="win32").connect(
|
|
252
|
-
|
|
282
|
+
app = Application(backend="win32").connect(
|
|
283
|
+
title="Gera Arquivo CSV (Excel)", timeout=10
|
|
284
|
+
)
|
|
285
|
+
dlg = app.window(title="Gera Arquivo CSV (Excel)")
|
|
253
286
|
btn_salvar = dlg.child_window(class_name="Button", found_index=0).click()
|
|
254
287
|
|
|
255
288
|
await worker_sleep(3)
|
|
256
289
|
|
|
257
290
|
# Janela confirmação clicar em OK
|
|
258
291
|
app = Application(backend="win32").connect(title="Informação", timeout=10)
|
|
259
|
-
dlg = app.window(title
|
|
292
|
+
dlg = app.window(title="Informação")
|
|
260
293
|
btn_ok = dlg.child_window(class_name="Button", found_index=0).click()
|
|
261
294
|
|
|
262
295
|
console.print("Arquivo salvo com sucesso...\n")
|
|
263
296
|
await worker_sleep(3)
|
|
264
|
-
path_to_txt =
|
|
297
|
+
path_to_txt = rf"C:\Users\automatehub\Downloads\balancete_{periodo_inicial}_{periodo_final}_{filial}"
|
|
265
298
|
|
|
266
|
-
with open(f"{path_to_txt}.csv",
|
|
299
|
+
with open(f"{path_to_txt}.csv", "rb") as file:
|
|
267
300
|
file_bytes = io.BytesIO(file.read())
|
|
268
301
|
|
|
269
302
|
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
|
270
303
|
desArquivo = f"balancete_{periodo_inicial}_{periodo_final}_{filial}.csv"
|
|
271
304
|
try:
|
|
272
|
-
await send_file(
|
|
273
|
-
|
|
305
|
+
await send_file(
|
|
306
|
+
historico_id, desArquivo, "csv", file_bytes, file_extension="csv"
|
|
307
|
+
)
|
|
308
|
+
os.remove(path_to_txt + ".csv")
|
|
274
309
|
return RpaRetornoProcessoDTO(
|
|
275
310
|
sucesso=True,
|
|
276
311
|
retorno="Balancete gerado com sucesso",
|
|
277
|
-
status=RpaHistoricoStatusEnum.Sucesso
|
|
312
|
+
status=RpaHistoricoStatusEnum.Sucesso,
|
|
278
313
|
)
|
|
279
314
|
except Exception as e:
|
|
280
315
|
result = f"Arquivo balancete 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}!"
|
|
@@ -283,9 +318,9 @@ async def geracao_balancetes_filial(task: RpaProcessoEntradaDTO) -> RpaRetornoPr
|
|
|
283
318
|
sucesso=False,
|
|
284
319
|
retorno=result,
|
|
285
320
|
status=RpaHistoricoStatusEnum.Falha,
|
|
286
|
-
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
|
321
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)],
|
|
287
322
|
)
|
|
288
|
-
|
|
323
|
+
|
|
289
324
|
except Exception as erro:
|
|
290
325
|
return RpaRetornoProcessoDTO(
|
|
291
326
|
sucesso=False,
|
|
@@ -81,7 +81,7 @@ worker_automate_hub/tasks/jobs/fidc_remessa_cobranca_cnab240.py,sha256=CuyTBQOR8
|
|
|
81
81
|
worker_automate_hub/tasks/jobs/fidc_retorno_cobranca.py,sha256=mmBW7KetUeRjiZkjnrxMKGX32io3YLZ8KGaY5_o7new,11891
|
|
82
82
|
worker_automate_hub/tasks/jobs/geracao_aprovacao_pedidos.py,sha256=QzK2aG5d9pmFbb8cTaNm3LWf5NMkmCvBkgo70gcLu0c,14781
|
|
83
83
|
worker_automate_hub/tasks/jobs/geracao_aprovacao_pedidos_novo.py,sha256=4Rtm2uCfA6tZ-KW6aunKug7reTqbBX69CCBZCBnwbYc,21856
|
|
84
|
-
worker_automate_hub/tasks/jobs/geracao_balancetes_filial.py,sha256=
|
|
84
|
+
worker_automate_hub/tasks/jobs/geracao_balancetes_filial.py,sha256=sTqD8LHZu4nqyFo52GDzb3xiSM4ATtsRCbUi3rKdW6g,12564
|
|
85
85
|
worker_automate_hub/tasks/jobs/integracao_contabil.py,sha256=psoIU0tjtTJq2W8aGXjXrfkAOYlIpUtHZyNolI7dp-0,16263
|
|
86
86
|
worker_automate_hub/tasks/jobs/integracao_contabil_generica.py,sha256=cA41rQlqTkNo9XD1QM0xtSDhJQoWJenvNuA_WePW4OM,22048
|
|
87
87
|
worker_automate_hub/tasks/jobs/lancamento_pis_cofins.py,sha256=0mlu-oPwRd9qCocB-6tWsEI0-wd48mkBJn5juYqOAX8,40788
|
|
@@ -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.817.dist-info/entry_points.txt,sha256=sddyhjx57I08RY8X7UxcTpdoOsWULAWNKN9Xr6pp_Kw,54
|
|
108
|
+
worker_automate_hub-0.5.817.dist-info/METADATA,sha256=pqVAqLkp5bLe1I2EqGc7riz4elayIZ7-z6Lr7NnljOI,3100
|
|
109
|
+
worker_automate_hub-0.5.817.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
|
|
110
|
+
worker_automate_hub-0.5.817.dist-info/RECORD,,
|
|
File without changes
|
{worker_automate_hub-0.5.816.dist-info → worker_automate_hub-0.5.817.dist-info}/entry_points.txt
RENAMED
|
File without changes
|