worker-automate-hub 0.4.394__py3-none-any.whl → 0.4.396__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -925,7 +925,12 @@ async def entrada_de_notas_9(task: RpaProcessoEntradaDTO) -> RpaRetornoProcessoD
925
925
  observacao = f"Erro Processo Entrada de Notas: {str(ex)}"
926
926
  logger.error(observacao)
927
927
  console.print(observacao, style="bold red")
928
- return {"sucesso": False, "retorno": observacao}
928
+
929
+ return RpaRetornoProcessoDTO(
930
+ sucesso=False,
931
+ retorno=observacao,
932
+ status=RpaHistoricoStatusEnum.Falha,
933
+ )
929
934
 
930
935
  finally:
931
936
  # Deleta o xml
@@ -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 (
@@ -47,6 +51,8 @@ async def sped_fiscal(task: RpaProcessoEntradaDTO) -> RpaRetornoProcessoDTO:
47
51
  """
48
52
  try:
49
53
  # Get config from BOF
54
+ get_config_gerar_inventario = await get_config_by_name("SPED_gerar_inventario")
55
+ gerar_inventario = get_config_gerar_inventario["conConfiguracao"]["gerar"]
50
56
  config = await get_config_by_name("login_emsys")
51
57
  console.print(task)
52
58
 
@@ -210,9 +216,114 @@ async def sped_fiscal(task: RpaProcessoEntradaDTO) -> RpaRetornoProcessoDTO:
210
216
  retorno=f"Erro ao interagir com a tela de gerar sped fiscal, erro: {e}",
211
217
  status=RpaHistoricoStatusEnum.Falha,
212
218
  )
219
+
220
+ ano_atual = datetime.now().year
221
+ if str(periodo_dt) == f"02/{ano_atual}":
222
+ console.print("Filtrando período pelo Inventario...\n")
223
+ ano_passado = ano_atual - 1
224
+ data_busca = f"31/12/{ano_passado}"
213
225
 
226
+ periodo_filtro_inicio = main_window.child_window(class_name="TEditDate", found_index=1)
227
+ periodo_filtro_inicio.set_edit_text(data_busca)
228
+ await worker_sleep(2)
229
+ periodo_filtro_fim = main_window.child_window(class_name="TEditDate", found_index=0)
230
+ periodo_filtro_fim.set_edit_text(data_busca)
231
+ await worker_sleep(2)
232
+ periodo_btn_buscar = main_window.child_window(class_name="TBitBtn", found_index=0)
233
+ periodo_btn_buscar.click()
234
+ await worker_sleep(2)
235
+ periodo_btn_buscar = main_window.child_window(class_name="TcxGrid", found_index=0)
236
+ rect = periodo_btn_buscar.rectangle()
237
+ center_x = (rect.left + rect.right) // 2
238
+ center_y = (rect.top + rect.bottom) // 2
239
+ double_click(coords=(center_x, center_y))
240
+ elif gerar_inventario:
241
+ mes_atual = datetime.now().month
242
+ if mes_atual == 1:
243
+ mes_anterior = 12
244
+ ano_anterior = ano_atual - 1
245
+ else:
246
+ mes_anterior = mes_atual - 1
247
+ ano_anterior = ano_atual
248
+
249
+ ultimo_dia = calendar.monthrange(ano_anterior, mes_anterior)[1]
250
+ data_ultimo_dia = date(ano_anterior, mes_anterior, ultimo_dia)
251
+ data_formatada = data_ultimo_dia.strftime("%d/%m/%Y")
252
+
253
+ periodo_filtro_inicio = main_window.child_window(class_name="TEditDate", found_index=1)
254
+ periodo_filtro_inicio.set_edit_text(data_formatada)
255
+ await worker_sleep(2)
256
+ periodo_filtro_fim = main_window.child_window(class_name="TEditDate", found_index=0)
257
+ periodo_filtro_fim.set_edit_text(data_formatada)
258
+ await worker_sleep(2)
259
+ periodo_btn_buscar = main_window.child_window(class_name="TBitBtn", found_index=0)
260
+ periodo_btn_buscar.click()
261
+ await worker_sleep(2)
262
+ grid_inventario = main_window.child_window(class_name="TcxGrid", found_index=0)
263
+ rect = grid_inventario.rectangle()
264
+ center_x = (rect.left + rect.right) // 2
265
+ center_y = (rect.top + rect.bottom) // 2
266
+ grid_inventario.click_input(coords=(center_x, center_y))
267
+ await worker_sleep(2)
268
+ send_keys("^({HOME})")
269
+ pyperclip.copy('')
270
+ await worker_sleep(3)
214
271
 
215
- await worker_sleep(2)
272
+ while True:
273
+ last_line_inventario_emsys_fiscal = 'x'
274
+ await worker_sleep(1)
275
+ with pyautogui.hold('ctrl'):
276
+ pyautogui.press('c')
277
+
278
+ await worker_sleep(1)
279
+
280
+ with pyautogui.hold('ctrl'):
281
+ pyautogui.press('c')
282
+
283
+ win32clipboard.OpenClipboard()
284
+ line_inventario_emsys_fiscal = win32clipboard.GetClipboardData().strip()
285
+ win32clipboard.CloseClipboard()
286
+ console.print(f"Linha atual copiada do Emsys Fiscal: {line_inventario_emsys_fiscal}\nUltima Linha copiada: {last_line_inventario_emsys_fiscal}")
287
+
288
+ if len(line_inventario_emsys_fiscal) <= 4:
289
+ return RpaRetornoProcessoDTO(
290
+ sucesso=False,
291
+ retorno=f"Erro: Nenhum registro encontrado com a data informada {periodo_btn_buscar}.",
292
+ status=RpaHistoricoStatusEnum.Falha,
293
+ )
294
+
295
+
296
+ if 'no final do' in line_inventario_emsys_fiscal.lower():
297
+ selecionar_registro_full_path = "assets\\emsys\\button_selecionar_registro_fiscal.png"
298
+ try:
299
+ button_location = pyautogui.locateCenterOnScreen(selecionar_registro_full_path, confidence=0.6)
300
+ if button_location:
301
+ pyautogui.click(button_location)
302
+ console.print("Botão 'Selecionar Registro' clicado com sucesso!")
303
+ break
304
+ except Exception as e:
305
+ return RpaRetornoProcessoDTO(
306
+ sucesso=False,
307
+ retorno=f"Erro: Não foi clicar na opção Selecionar Registro no Inventario, erro: {e}.",
308
+ status=RpaHistoricoStatusEnum.Falha,
309
+ )
310
+
311
+
312
+ if bool(line_inventario_emsys_fiscal):
313
+ if last_line_inventario_emsys_fiscal == line_inventario_emsys_fiscal:
314
+ return RpaRetornoProcessoDTO(
315
+ sucesso=False,
316
+ retorno=f"Erro: Não foi encontrado a opção do período de busca {periodo_filtro_inicio} nas opções do inventário.",
317
+ status=RpaHistoricoStatusEnum.Falha,
318
+ )
319
+ else:
320
+ last_line_inventario_emsys_fiscal = line_inventario_emsys_fiscal
321
+ pyautogui.press('down')
322
+
323
+ else:
324
+ console.print("Mês não é igual a Fevereiro e SPED Inventario é falso, seguindo com a geração do SPED...\n")
325
+
326
+ await worker_sleep(3)
216
327
  pesquisar_full_path = "assets\\emsys\\button_gerar_sped_fiscal.png"
217
328
  try:
218
329
  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.394
3
+ Version: 0.4.396
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
@@ -48,13 +48,13 @@ worker_automate_hub/tasks/jobs/entrada_de_notas_39.py,sha256=XkSEe6Y2S5Zf8Eq619d
48
48
  worker_automate_hub/tasks/jobs/entrada_de_notas_500.py,sha256=ryl5AZ2617aROSVcS-N5wQIBlFQ1Bp0khUH9fP4DOzU,26542
49
49
  worker_automate_hub/tasks/jobs/entrada_de_notas_505.py,sha256=jIml8gjXPdI6_x7S9VVV8IrKZRF7_PTNOMnhNmYMDTU,14490
50
50
  worker_automate_hub/tasks/jobs/entrada_de_notas_7139.py,sha256=8XP9G3n0PUeshbRWkWKOMnyUGRWspIolPZVqQTR3SMI,14184
51
- worker_automate_hub/tasks/jobs/entrada_de_notas_9.py,sha256=q-jFf98aMh0RrMdV9iIY9I8QxUPaJlGpPe1ytEI3Uv8,43764
51
+ worker_automate_hub/tasks/jobs/entrada_de_notas_9.py,sha256=eAFBeEkhf7dLnj-vW7sEnxcBr1BJ6FkvIofNKaJcnyg,43877
52
52
  worker_automate_hub/tasks/jobs/exemplo_processo.py,sha256=3-zxbb-9YHPmSA_K1Qgxp_FwSqg2QDjGBRCLxDZ8QoQ,3451
53
53
  worker_automate_hub/tasks/jobs/fidc_gerar_nosso_numero.py,sha256=Y-mKYcgX1kwcy_sOHvctn7clXnY3O3fohvOs7tKPMkM,9484
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=66rE9JpGjXAcQoV2RfUpkzs6XbGQsuO86Pg7auo-QAA,25159
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.394.dist-info/entry_points.txt,sha256=sddyhjx57I08RY8X7UxcTpdoOsWULAWNKN9Xr6pp_Kw,54
71
- worker_automate_hub-0.4.394.dist-info/METADATA,sha256=qYSTJDhtF1a8FP-FtT7V5b2BmjfowOKjUpwt7a1rix0,2895
72
- worker_automate_hub-0.4.394.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
73
- worker_automate_hub-0.4.394.dist-info/RECORD,,
70
+ worker_automate_hub-0.4.396.dist-info/entry_points.txt,sha256=sddyhjx57I08RY8X7UxcTpdoOsWULAWNKN9Xr6pp_Kw,54
71
+ worker_automate_hub-0.4.396.dist-info/METADATA,sha256=MdcVWCeuNJnaPNio3F4pebCTKy4R1sDoBYg_aOwbnqw,2895
72
+ worker_automate_hub-0.4.396.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
73
+ worker_automate_hub-0.4.396.dist-info/RECORD,,