worker-automate-hub 0.4.395__py3-none-any.whl → 0.4.397__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.
@@ -3,18 +3,22 @@ import warnings
3
3
  import os
4
4
  import io
5
5
  import uuid
6
- from datetime import datetime
6
+ from datetime import datetime,date
7
+ import calendar
7
8
 
8
9
  import pyautogui
10
+ import pyperclip
9
11
  import pytesseract
10
12
  from pywinauto.application import Application
13
+ from pywinauto.mouse import double_click
14
+ from pywinauto.keyboard import send_keys
15
+ import win32clipboard
11
16
  from PIL import Image, ImageEnhance
12
17
  from rich.console import Console
13
18
 
14
19
  from worker_automate_hub.api.client import (
15
20
  get_config_by_name,
16
21
  send_file,
17
- get_historico_by_processo_identificador,
18
22
  )
19
23
 
20
24
  from worker_automate_hub.models.dto.rpa_historico_request_dto import (
@@ -49,6 +53,25 @@ async def sped_fiscal(task: RpaProcessoEntradaDTO) -> RpaRetornoProcessoDTO:
49
53
  # Get config from BOF
50
54
  config = await get_config_by_name("login_emsys")
51
55
  console.print(task)
56
+ try:
57
+ get_config_gerar_inventario = await get_config_by_name("SPED_gerar_inventario")
58
+ console.print(get_config_gerar_inventario)
59
+ con_config = get_config_gerar_inventario.get("conConfiguracao")
60
+ if con_config is not None:
61
+ gerar_inventario = con_config.get("gerar")
62
+ else:
63
+ return RpaRetornoProcessoDTO(
64
+ sucesso=False,
65
+ retorno="Não foi possivel recuperar o valor da configuração Gerar Inventario, não sendo possivel seguir com o processo.",
66
+ status=RpaHistoricoStatusEnum.Falha,
67
+ )
68
+ except Exception as e:
69
+ return RpaRetornoProcessoDTO(
70
+ sucesso=False,
71
+ retorno=f"Não foi possivel recuperar o valor da configuração Gerar Inventario, erro: {e}.",
72
+ status=RpaHistoricoStatusEnum.Falha,
73
+ )
74
+
52
75
 
53
76
  # Seta config entrada na var sped_processar para melhor entendimento
54
77
  sped_processar = task.configEntrada
@@ -210,9 +233,114 @@ async def sped_fiscal(task: RpaProcessoEntradaDTO) -> RpaRetornoProcessoDTO:
210
233
  retorno=f"Erro ao interagir com a tela de gerar sped fiscal, erro: {e}",
211
234
  status=RpaHistoricoStatusEnum.Falha,
212
235
  )
236
+
237
+ ano_atual = datetime.now().year
238
+ if str(periodo_dt) == f"02/{ano_atual}":
239
+ console.print("Filtrando período pelo Inventario...\n")
240
+ ano_passado = ano_atual - 1
241
+ data_busca = f"31/12/{ano_passado}"
213
242
 
243
+ periodo_filtro_inicio = main_window.child_window(class_name="TEditDate", found_index=1)
244
+ periodo_filtro_inicio.set_edit_text(data_busca)
245
+ await worker_sleep(2)
246
+ periodo_filtro_fim = main_window.child_window(class_name="TEditDate", found_index=0)
247
+ periodo_filtro_fim.set_edit_text(data_busca)
248
+ await worker_sleep(2)
249
+ periodo_btn_buscar = main_window.child_window(class_name="TBitBtn", found_index=0)
250
+ periodo_btn_buscar.click()
251
+ await worker_sleep(2)
252
+ periodo_btn_buscar = main_window.child_window(class_name="TcxGrid", found_index=0)
253
+ rect = periodo_btn_buscar.rectangle()
254
+ center_x = (rect.left + rect.right) // 2
255
+ center_y = (rect.top + rect.bottom) // 2
256
+ double_click(coords=(center_x, center_y))
257
+ elif gerar_inventario:
258
+ mes_atual = datetime.now().month
259
+ if mes_atual == 1:
260
+ mes_anterior = 12
261
+ ano_anterior = ano_atual - 1
262
+ else:
263
+ mes_anterior = mes_atual - 1
264
+ ano_anterior = ano_atual
265
+
266
+ ultimo_dia = calendar.monthrange(ano_anterior, mes_anterior)[1]
267
+ data_ultimo_dia = date(ano_anterior, mes_anterior, ultimo_dia)
268
+ data_formatada = data_ultimo_dia.strftime("%d/%m/%Y")
269
+
270
+ periodo_filtro_inicio = main_window.child_window(class_name="TEditDate", found_index=1)
271
+ periodo_filtro_inicio.set_edit_text(data_formatada)
272
+ await worker_sleep(2)
273
+ periodo_filtro_fim = main_window.child_window(class_name="TEditDate", found_index=0)
274
+ periodo_filtro_fim.set_edit_text(data_formatada)
275
+ await worker_sleep(2)
276
+ periodo_btn_buscar = main_window.child_window(class_name="TBitBtn", found_index=0)
277
+ periodo_btn_buscar.click()
278
+ await worker_sleep(2)
279
+ grid_inventario = main_window.child_window(class_name="TcxGrid", found_index=0)
280
+ rect = grid_inventario.rectangle()
281
+ center_x = (rect.left + rect.right) // 2
282
+ center_y = (rect.top + rect.bottom) // 2
283
+ grid_inventario.click_input(coords=(center_x, center_y))
284
+ await worker_sleep(2)
285
+ send_keys("^({HOME})")
286
+ pyperclip.copy('')
287
+ await worker_sleep(3)
214
288
 
215
- await worker_sleep(2)
289
+ while True:
290
+ last_line_inventario_emsys_fiscal = 'x'
291
+ await worker_sleep(1)
292
+ with pyautogui.hold('ctrl'):
293
+ pyautogui.press('c')
294
+
295
+ await worker_sleep(1)
296
+
297
+ with pyautogui.hold('ctrl'):
298
+ pyautogui.press('c')
299
+
300
+ win32clipboard.OpenClipboard()
301
+ line_inventario_emsys_fiscal = win32clipboard.GetClipboardData().strip()
302
+ win32clipboard.CloseClipboard()
303
+ console.print(f"Linha atual copiada do Emsys Fiscal: {line_inventario_emsys_fiscal}\nUltima Linha copiada: {last_line_inventario_emsys_fiscal}")
304
+
305
+ if len(line_inventario_emsys_fiscal) <= 4:
306
+ return RpaRetornoProcessoDTO(
307
+ sucesso=False,
308
+ retorno=f"Erro: Nenhum registro encontrado com a data informada {periodo_btn_buscar}.",
309
+ status=RpaHistoricoStatusEnum.Falha,
310
+ )
311
+
312
+
313
+ if 'no final do' in line_inventario_emsys_fiscal.lower():
314
+ selecionar_registro_full_path = "assets\\emsys\\button_selecionar_registro_fiscal.png"
315
+ try:
316
+ button_location = pyautogui.locateCenterOnScreen(selecionar_registro_full_path, confidence=0.6)
317
+ if button_location:
318
+ pyautogui.click(button_location)
319
+ console.print("Botão 'Selecionar Registro' clicado com sucesso!")
320
+ break
321
+ except Exception as e:
322
+ return RpaRetornoProcessoDTO(
323
+ sucesso=False,
324
+ retorno=f"Erro: Não foi clicar na opção Selecionar Registro no Inventario, erro: {e}.",
325
+ status=RpaHistoricoStatusEnum.Falha,
326
+ )
327
+
328
+
329
+ if bool(line_inventario_emsys_fiscal):
330
+ if last_line_inventario_emsys_fiscal == line_inventario_emsys_fiscal:
331
+ return RpaRetornoProcessoDTO(
332
+ sucesso=False,
333
+ retorno=f"Erro: Não foi encontrado a opção do período de busca {periodo_filtro_inicio} nas opções do inventário.",
334
+ status=RpaHistoricoStatusEnum.Falha,
335
+ )
336
+ else:
337
+ last_line_inventario_emsys_fiscal = line_inventario_emsys_fiscal
338
+ pyautogui.press('down')
339
+
340
+ else:
341
+ console.print("Mês não é igual a Fevereiro e SPED Inventario é falso, seguindo com a geração do SPED...\n")
342
+
343
+ await worker_sleep(3)
216
344
  pesquisar_full_path = "assets\\emsys\\button_gerar_sped_fiscal.png"
217
345
  try:
218
346
  button_location = pyautogui.locateCenterOnScreen(pesquisar_full_path, confidence=0.6)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: worker-automate-hub
3
- Version: 0.4.395
3
+ Version: 0.4.397
4
4
  Summary: Worker Automate HUB é uma aplicação para automatizar rotinas de RPA nos ambientes Argenta.
5
5
  Author: Joel Paim
6
6
  Requires-Python: >=3.12,<4.0
@@ -54,7 +54,7 @@ worker_automate_hub/tasks/jobs/fidc_gerar_nosso_numero.py,sha256=Y-mKYcgX1kwcy_s
54
54
  worker_automate_hub/tasks/jobs/fidc_remessa_cobranca_cnab240.py,sha256=QBGm6eS5JghgNWNqZlk1g2a2iV8LnBLiOTBBL3Giet0,4181
55
55
  worker_automate_hub/tasks/jobs/login_emsys.py,sha256=IoGCIvO4UwmuxOZEn3cvYJlKyhsWvtHvbFk8vwjTroQ,5620
56
56
  worker_automate_hub/tasks/jobs/playground.py,sha256=bdnXv3C7WLQUxt4edGZDfAbRJJ2-q4zuIQaK3GLnaUc,1765
57
- worker_automate_hub/tasks/jobs/sped_fiscal.py,sha256=RM0O2B-4qtmjtVLfEy76q7tosD4VA-euI319oYbTi6I,19417
57
+ worker_automate_hub/tasks/jobs/sped_fiscal.py,sha256=yJtZqd-Xwida1w15sPchoF7JStIgsBchgt_-BWdAsfM,25942
58
58
  worker_automate_hub/tasks/jobs/transferencias.py,sha256=keCUlvbPhLrTiZQ9Co_r6IqL5wjYqVGB_-mgvdDe9pM,36080
59
59
  worker_automate_hub/tasks/task_definitions.py,sha256=2Jp1H4_qJZqqGyaP6MA87KLt4QNrtWBYWbXu-2gymFo,4459
60
60
  worker_automate_hub/tasks/task_executor.py,sha256=eXFgWbcM8aMPwENvNix8KyFv7BqvIwhXUDkBSI1ul7M,8873
@@ -67,7 +67,7 @@ worker_automate_hub/utils/updater.py,sha256=en2FCGhI8aZ-JNP3LQm64NJDc4awCNW7UhbV
67
67
  worker_automate_hub/utils/util.py,sha256=YCbgMMBwhp9LD6NUmE5S2K6S12TNEpGJm25FqfsIKPE,119544
68
68
  worker_automate_hub/utils/utils_nfe_entrada.py,sha256=GsvN7XMWAmCFHqC0YMZsjsb0myL-7ahuzHN4jPNn0zc,27623
69
69
  worker_automate_hub/worker.py,sha256=KDBU3L2kVobndrnN5coRZFTwVmBLKmPJjRv20sCo5Hc,4697
70
- worker_automate_hub-0.4.395.dist-info/entry_points.txt,sha256=sddyhjx57I08RY8X7UxcTpdoOsWULAWNKN9Xr6pp_Kw,54
71
- worker_automate_hub-0.4.395.dist-info/METADATA,sha256=Ahw3881HIuavhCHE3Gs1I3crOoSfPcA9bu6hFtOaljQ,2895
72
- worker_automate_hub-0.4.395.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
73
- worker_automate_hub-0.4.395.dist-info/RECORD,,
70
+ worker_automate_hub-0.4.397.dist-info/entry_points.txt,sha256=sddyhjx57I08RY8X7UxcTpdoOsWULAWNKN9Xr6pp_Kw,54
71
+ worker_automate_hub-0.4.397.dist-info/METADATA,sha256=61U9xgS_Xa5YoslRTFpojHVsaZkXbvBdmKWtT7ypm8k,2895
72
+ worker_automate_hub-0.4.397.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
73
+ worker_automate_hub-0.4.397.dist-info/RECORD,,