worker-automate-hub 0.5.776__py3-none-any.whl → 0.5.777__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.
@@ -0,0 +1,619 @@
1
+ import difflib
2
+ import getpass
3
+ import os
4
+ import re
5
+ import warnings
6
+ import time
7
+ import uuid
8
+ import asyncio
9
+ from datetime import datetime, timedelta
10
+ import pyautogui
11
+ import pytesseract
12
+ import win32clipboard
13
+ from PIL import Image, ImageEnhance
14
+ from pywinauto.application import Application
15
+ from pywinauto import Desktop
16
+ from pywinauto.findwindows import ElementNotFoundError
17
+ from pywinauto.keyboard import send_keys
18
+ from pywinauto.timings import wait_until
19
+ from pywinauto_recorder.player import set_combobox
20
+ from rich.console import Console
21
+ import sys
22
+ # sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "..")))
23
+ from worker_automate_hub.api.ahead_service import save_xml_to_downloads
24
+ from worker_automate_hub.api.client import (
25
+ get_config_by_name,
26
+ get_status_nf_emsys,
27
+ )
28
+ from worker_automate_hub.models.dto.rpa_historico_request_dto import (
29
+ RpaHistoricoStatusEnum,
30
+ RpaRetornoProcessoDTO,
31
+ RpaTagDTO,
32
+ RpaTagEnum,
33
+ )
34
+ from worker_automate_hub.models.dto.rpa_processo_entrada_dto import (
35
+ RpaProcessoEntradaDTO,
36
+ )
37
+ from worker_automate_hub.utils.logger import logger
38
+ from worker_automate_hub.utils.util import (
39
+ cod_icms,
40
+ delete_xml,
41
+ error_after_xml_imported,
42
+ get_xml,
43
+ import_nfe,
44
+ incluir_registro,
45
+ is_window_open,
46
+ is_window_open_by_class,
47
+ itens_not_found_supplier,
48
+ kill_all_emsys,
49
+ login_emsys,
50
+ rateio_despesa,
51
+ select_documento_type,
52
+ set_variable,
53
+ tipo_despesa,
54
+ type_text_into_field,
55
+ warnings_after_xml_imported,
56
+ worker_sleep,
57
+ zerar_icms,
58
+ check_nota_importada,
59
+ )
60
+
61
+ pyautogui.PAUSE = 0.5
62
+ pyautogui.FAILSAFE = False
63
+ console = Console()
64
+
65
+
66
+ async def entrada_de_notas_37(task: RpaProcessoEntradaDTO) -> RpaRetornoProcessoDTO:
67
+ """
68
+ Processo que realiza entrada de notas no ERP EMSys(Linx).
69
+
70
+ """
71
+ try:
72
+ # Get config from BOF
73
+ config = await get_config_by_name("login_emsys")
74
+ console.print(task)
75
+
76
+ # Seta config entrada na var nota
77
+ nota = task.configEntrada
78
+ # conversão no formato certo: dd/mm/yyyy
79
+ data_vencimento = datetime.strptime(nota['dataVencimento'], "%d/%m/%Y").date()
80
+ hoje = datetime.today().date()
81
+
82
+ if data_vencimento <= hoje:
83
+ data_vencimento = hoje + timedelta(days=1)
84
+ while data_vencimento.weekday() >= 5: # 5 = sábado, 6 = domingo
85
+ data_vencimento += timedelta(days=1)
86
+
87
+ data_vencimento = data_vencimento.strftime("%d/%m/%Y")
88
+ print("Data ajustada:", data_vencimento)
89
+ valor_nota = nota['valorNota']
90
+ multiplicador_timeout = int(float(task.sistemas[0].timeout))
91
+ set_variable("timeout_multiplicador", multiplicador_timeout)
92
+
93
+ # Fecha a instancia do emsys - caso esteja aberta
94
+ await kill_all_emsys()
95
+
96
+ # Download XML
97
+ console.log("Realizando o download do XML..\n")
98
+ await save_xml_to_downloads(nota["nfe"])
99
+
100
+ app = Application(backend="win32").start("C:\\Rezende\\EMSys3\\EMSys3_10.exe")
101
+ warnings.filterwarnings(
102
+ "ignore",
103
+ category=UserWarning,
104
+ message="32-bit application should be automated using 32-bit Python",
105
+ )
106
+ console.print("\nEMSys iniciando...", style="bold green")
107
+ return_login = await login_emsys(config.conConfiguracao, app, task)
108
+
109
+ if return_login.sucesso == True:
110
+ type_text_into_field(
111
+ "Nota Fiscal de Entrada", app["TFrmMenuPrincipal"]["Edit"], True, "50"
112
+ )
113
+ pyautogui.press("enter")
114
+ await worker_sleep(2)
115
+ pyautogui.press("enter")
116
+ console.print(
117
+ f"\nPesquisa: 'Nota Fiscal de Entrada' realizada com sucesso",
118
+ style="bold green",
119
+ )
120
+ else:
121
+ logger.info(f"\nError Message: {return_login.retorno}")
122
+ console.print(f"\nError Message: {return_login.retorno}", style="bold red")
123
+ return return_login
124
+
125
+ await worker_sleep(6)
126
+
127
+ # Procura campo documento
128
+ console.print("Navegando pela Janela de Nota Fiscal de Entrada...\n")
129
+ document_type = await select_documento_type(
130
+ "NOTA FISCAL DE ENTRADA ELETRONICA - DANFE"
131
+ )
132
+ if document_type.sucesso == True:
133
+ console.log(document_type.retorno, style="bold green")
134
+ else:
135
+ return RpaRetornoProcessoDTO(
136
+ sucesso=False,
137
+ retorno=document_type.retorno,
138
+ status=RpaHistoricoStatusEnum.Falha,
139
+ tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
140
+ )
141
+
142
+ await worker_sleep(4)
143
+
144
+ # Clica em 'Importar-Nfe'
145
+ imported_nfe = await import_nfe()
146
+ if imported_nfe.sucesso == True:
147
+ console.log(imported_nfe.retorno, style="bold green")
148
+ else:
149
+ return RpaRetornoProcessoDTO(
150
+ sucesso=False,
151
+ retorno=imported_nfe.retorno,
152
+ status=RpaHistoricoStatusEnum.Falha,
153
+ tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
154
+ )
155
+
156
+ await worker_sleep(5)
157
+
158
+ await get_xml(nota.get("nfe"))
159
+ await worker_sleep(3)
160
+
161
+ # VERIFICANDO A EXISTENCIA DE WARNINGS
162
+ warning_pop_up = await is_window_open("Warning")
163
+ if warning_pop_up["IsOpened"] == True:
164
+ warning_work = await warnings_after_xml_imported()
165
+ if warning_work.sucesso == True:
166
+ console.log(warning_work.retorno, style="bold green")
167
+ else:
168
+ return RpaRetornoProcessoDTO(
169
+ sucesso=False,
170
+ retorno=warning_work.retorno,
171
+ status=RpaHistoricoStatusEnum.Falha,
172
+ tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
173
+ )
174
+
175
+ # VERIFICANDO A EXISTENCIA DE ERRO
176
+ erro_pop_up = await is_window_open("Erro")
177
+ if erro_pop_up["IsOpened"] == True:
178
+ error_work = await error_after_xml_imported()
179
+ return RpaRetornoProcessoDTO(
180
+ sucesso=error_work.sucesso,
181
+ retorno=error_work.retorno,
182
+ status=error_work.status,
183
+ tags=error_work.tags
184
+ )
185
+
186
+ app = Application().connect(
187
+ title="Informações para importação da Nota Fiscal Eletrônica"
188
+ )
189
+ main_window = app["Informações para importação da Nota Fiscal Eletrônica"]
190
+
191
+ # INTERAGINDO COM A DATA DE ENTRADA
192
+ await worker_sleep(2)
193
+ try:
194
+ recebimento_fisico = nota.get("recebimentoFisico", None)
195
+ if recebimento_fisico:
196
+ recebimento_fisico = nota["recebimentoFisico"].split(" ")
197
+ pyautogui.write(recebimento_fisico[0])
198
+ await worker_sleep(2)
199
+ except:
200
+ console.print(
201
+ f"A chave recebimentoFisico não está presente na config de entrada...\n"
202
+ )
203
+
204
+
205
+ # INTERAGINDO COM A NATUREZA DA OPERACAO
206
+ cfop = int(nota.get("cfop"))
207
+ console.print(f"Inserindo a informação da CFOP: {cfop} ...\n")
208
+ combo_box_natureza_operacao = main_window.child_window(
209
+ class_name="TDBIComboBox", found_index=0
210
+ )
211
+ combo_box_natureza_operacao.click()
212
+
213
+ await worker_sleep(3)
214
+
215
+ if str(cfop).startswith("6"):
216
+ set_combobox("||List", "2556-COMPRA DE MERCADORIAS SEM ESTOQUE- 2.556")
217
+ elif str(cfop).startswith("5"):
218
+ set_combobox("||List", "1556-COMPRA DE MERCADORIAS SEM ESTOQUE- 1.556")
219
+ else:
220
+ console.print(
221
+ "Erro mapeado, CFOP diferente de inicio com 540 ou 510, necessario ação manual ou ajuste no robo...\n"
222
+ )
223
+ return RpaRetornoProcessoDTO(
224
+ sucesso=False,
225
+ retorno=f"Erro mapeado, CFOP diferente de inicio com 540 ou 510, necessario ação manual ou ajuste no robo.",
226
+ status=RpaHistoricoStatusEnum.Falha,
227
+ tags=[RpaTagDTO(descricao=RpaTagEnum.Negocio)]
228
+ )
229
+
230
+ await worker_sleep(3)
231
+
232
+ # INTERAGINDO COM O CAMPO ALMOXARIFADO
233
+ fornecedor = nota.get("nomeFornecedor")
234
+ filialEmpresaOrigem = nota.get("filialEmpresaOrigem")
235
+ console.print(
236
+ f"Inserindo a informação do Almoxarifado {filialEmpresaOrigem} ...\n"
237
+ )
238
+ try:
239
+ new_app = Application(backend="uia").connect(
240
+ title="Informações para importação da Nota Fiscal Eletrônica"
241
+ )
242
+ window = new_app["Informações para importação da Nota Fiscal Eletrônica"]
243
+ edit = window.child_window(
244
+ class_name="TDBIEditCode", found_index=3, control_type="Edit"
245
+ )
246
+ if filialEmpresaOrigem != "1":
247
+ valor_almoxarifado = filialEmpresaOrigem + "50"
248
+ else:
249
+ valor_almoxarifado = filialEmpresaOrigem + "60"
250
+ edit.set_edit_text(valor_almoxarifado)
251
+ edit.type_keys("{TAB}")
252
+ except Exception as e:
253
+ console.print(f"Erro ao iterar itens de almoxarifado: {e}")
254
+ return RpaRetornoProcessoDTO(
255
+ sucesso=False,
256
+ retorno=f"Erro ao iterar itens de almoxarifado: {e}",
257
+ status=RpaHistoricoStatusEnum.Falha,
258
+ tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
259
+ )
260
+
261
+ await worker_sleep(1)
262
+ despesa = '249'
263
+
264
+ tipo_despesa_work = await tipo_despesa(despesa)
265
+ if tipo_despesa_work.sucesso == True:
266
+ console.log(tipo_despesa_work.retorno, style="bold green")
267
+ else:
268
+ return RpaRetornoProcessoDTO(
269
+ sucesso=False,
270
+ retorno=tipo_despesa_work.retorno,
271
+ status=RpaHistoricoStatusEnum.Falha,
272
+ tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
273
+ )
274
+
275
+ # INTERAGINDO COM O CHECKBOX ZERAR ICMS
276
+ checkbox_zerar_icms = await zerar_icms()
277
+ if checkbox_zerar_icms.sucesso == True:
278
+ console.log(checkbox_zerar_icms.retorno, style="bold green")
279
+ else:
280
+ return RpaRetornoProcessoDTO(
281
+ sucesso=False,
282
+ retorno=checkbox_zerar_icms.retorno,
283
+ status=RpaHistoricoStatusEnum.Falha,
284
+ tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
285
+ )
286
+
287
+ # INTERAGINDO COM O CAMPO DE CODIGO DO ICMS
288
+ cod_icms_work = await cod_icms("33")
289
+ if cod_icms_work.sucesso == True:
290
+ console.log(cod_icms_work.retorno, style="bold green")
291
+ else:
292
+ return RpaRetornoProcessoDTO(
293
+ sucesso=False,
294
+ retorno=cod_icms_work.retorno,
295
+ status=RpaHistoricoStatusEnum.Falha,
296
+ tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
297
+ )
298
+
299
+ # INTERAGINDO COM O CAMPO Manter Natureza de Operação selecionada
300
+ console.print(
301
+ f"Selecionando a opção 'Manter Natureza de Operação selecionada'...\n"
302
+ )
303
+ checkbox = window.child_window(
304
+ title="Manter Natureza de Operação selecionada",
305
+ class_name="TDBICheckBox",
306
+ )
307
+ if not checkbox.get_toggle_state() == 1:
308
+ checkbox.click()
309
+ console.print(
310
+ "A opção 'Manter Natureza de Operação selecionada' selecionado com sucesso... \n"
311
+ )
312
+
313
+ await worker_sleep(2)
314
+ console.print("Clicando em OK... \n")
315
+
316
+ max_attempts = 3
317
+ i = 0
318
+ while i < max_attempts:
319
+ console.print("Clicando no botão de OK...\n")
320
+ try:
321
+ try:
322
+ btn_ok = main_window.child_window(title="Ok")
323
+ btn_ok.click()
324
+ except:
325
+ btn_ok = main_window.child_window(title="&Ok")
326
+ btn_ok.click()
327
+ except:
328
+ console.print("Não foi possivel clicar no Botão OK... \n")
329
+
330
+ await worker_sleep(3)
331
+
332
+ console.print(
333
+ "Verificando a existencia da tela Informações para importação da Nota Fiscal Eletrônica...\n"
334
+ )
335
+
336
+ try:
337
+ informacao_nf_eletronica = await is_window_open(
338
+ "Informações para importação da Nota Fiscal Eletrônica"
339
+ )
340
+ if not informacao_nf_eletronica["IsOpened"]:
341
+ console.print(
342
+ "Tela Informações para importação da Nota Fiscal Eletrônica fechada, seguindo com o processo"
343
+ )
344
+ break
345
+ except Exception as e:
346
+ console.print(
347
+ f"Tela Informações para importação da Nota Fiscal Eletrônica encontrada. Tentativa {i + 1}/{max_attempts}."
348
+ )
349
+
350
+ i += 1
351
+
352
+ if i == max_attempts:
353
+ return RpaRetornoProcessoDTO(
354
+ sucesso=False,
355
+ retorno="Número máximo de tentativas atingido, Não foi possivel finalizar os trabalhos na tela de Informações para importação da Nota Fiscal Eletrônica",
356
+ status=RpaHistoricoStatusEnum.Falha,
357
+ tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
358
+ )
359
+
360
+ await worker_sleep(5)
361
+ try:
362
+ ##### Janela Information #####
363
+ app = Application(backend="win32").connect(title_re="Information")
364
+
365
+ # Seleciona a janela pelo título
366
+ dlg = app.window(title_re="Information")
367
+
368
+ # Clica no botão "Não"
369
+ dlg['&No'].click_input()
370
+
371
+ console.print("Clique em NÃO realizado com sucesso!")
372
+ except:
373
+ pass
374
+
375
+
376
+ await worker_sleep(2)
377
+ console.print("Navegando pela Janela de Nota Fiscal de Entrada...\n")
378
+ app = Application().connect(class_name="TFrmNotaFiscalEntrada")
379
+ main_window = app["TFrmNotaFiscalEntrada"]
380
+
381
+ pyautogui.click(621, 359)
382
+
383
+ await worker_sleep(5)
384
+
385
+ main_window.set_focus()
386
+
387
+ panel_TPage = main_window.child_window(class_name="TPage", title="Formulario")
388
+ panel_TTabSheet = panel_TPage.child_window(class_name="TPageControl")
389
+
390
+ panel_TabPagamento = panel_TTabSheet.child_window(title="Pagamento")
391
+
392
+ input_dt_vencimento = panel_TPage = main_window.child_window(class_name="TDBIEditDate", found_index=0).click()
393
+ send_keys(data_vencimento)
394
+
395
+ input_valor = panel_TPage = main_window.child_window(class_name="TDBIEditNumber", found_index=3).click()
396
+ send_keys('{RIGHT}')
397
+ send_keys('^a{BACKSPACE}')
398
+ await worker_sleep(1)
399
+ send_keys(valor_nota)
400
+
401
+ tipo_cobranca = panel_TTabSheet.child_window(
402
+ class_name="TDBIComboBox", found_index=0
403
+ )
404
+ tipo_cobranca.click()
405
+ try:
406
+ set_combobox("||List", "BANCO DO BRASIL BOLETO")
407
+ except:
408
+ set_combobox("||List", "BOLETO")
409
+
410
+ await worker_sleep(3)
411
+
412
+ # Clicar em incluir registro
413
+ pyautogui.click(1289, 530)
414
+
415
+ await worker_sleep(3)
416
+
417
+ console.print(f"Incluindo registro...\n")
418
+ try:
419
+ ASSETS_PATH = "assets"
420
+ inserir_registro = pyautogui.locateOnScreen(
421
+ r"assets\\entrada_notas\\IncluirRegistro.png", confidence=0.8
422
+ )
423
+ pyautogui.click(inserir_registro)
424
+ except Exception as e:
425
+ console.print(
426
+ f"Não foi possivel incluir o registro utilizando reconhecimento de imagem, Error: {e}...\n tentando inserir via posição...\n"
427
+ )
428
+
429
+ await worker_sleep(5)
430
+
431
+ console.print(
432
+ "Verificando a existencia de POP-UP de Itens que Ultrapassam a Variação Máxima de Custo ...\n"
433
+ )
434
+ itens_variacao_maxima = await is_window_open_by_class(
435
+ "TFrmTelaSelecao", "TFrmTelaSelecao"
436
+ )
437
+ if itens_variacao_maxima["IsOpened"] == True:
438
+ app = Application().connect(class_name="TFrmTelaSelecao")
439
+ main_window = app["TFrmTelaSelecao"]
440
+ send_keys("%o")
441
+
442
+ await worker_sleep(5)
443
+
444
+ console.print(
445
+ "Verificando a existencia de Warning informando que a Soma dos pagamentos não bate com o valor da nota. ...\n"
446
+ )
447
+ app = Application().connect(class_name="TFrmNotaFiscalEntrada")
448
+ main_window = app["TFrmNotaFiscalEntrada"]
449
+
450
+ # --- Verificação do pop-up "TMessageForm" ---
451
+ warning_existe = False
452
+ try:
453
+ # tenta conectar na janela do aviso
454
+ app = Application().connect(class_name="TMessageForm", timeout=3)
455
+ dlg = app.window(class_name="TMessageForm")
456
+
457
+ # confirma se a janela realmente existe/está visível
458
+ if dlg.exists(timeout=1):
459
+ warning_existe = True
460
+
461
+ except (ElementNotFoundError, Exception):
462
+ warning_existe = False
463
+
464
+ if warning_existe:
465
+ console.print(
466
+ "Erro: Warning informando que a Soma dos pagamentos não bate com o valor da nota. ...\n"
467
+ )
468
+ return RpaRetornoProcessoDTO(
469
+ sucesso=False,
470
+ retorno="A soma dos pagamentos não bate com o valor da nota.",
471
+ status=RpaHistoricoStatusEnum.Falha,
472
+ tags=[RpaTagDTO(descricao=RpaTagEnum.Negocio)]
473
+ )
474
+ else:
475
+ console.print(
476
+ "Warning informando que a Soma dos pagamentos não bate com o valor da nota não existe ...\n"
477
+ )
478
+
479
+ max_attempts = 7
480
+ i = 0
481
+ aguarde_rateio_despesa = True
482
+
483
+ while i < max_attempts:
484
+ await worker_sleep(3)
485
+
486
+ from pywinauto import Desktop
487
+
488
+ for window in Desktop(backend="uia").windows():
489
+ if "Rateio" in window.window_text():
490
+ aguarde_rateio_despesa = False
491
+ console.print(
492
+ "A janela 'Rateio da Despesas' foi encontrada. Continuando para andamento do processo...\n"
493
+ )
494
+ break
495
+
496
+ if not aguarde_rateio_despesa:
497
+ break
498
+
499
+ i += 1
500
+
501
+ if aguarde_rateio_despesa:
502
+ return RpaRetornoProcessoDTO(
503
+ sucesso=False,
504
+ retorno=f"Número máximo de tentativas atingido. A tela para Rateio da Despesa não foi encontrada.",
505
+ status=RpaHistoricoStatusEnum.Falha,
506
+ tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
507
+ )
508
+
509
+ despesa_rateio_work = await rateio_despesa(filialEmpresaOrigem)
510
+ if despesa_rateio_work.sucesso == True:
511
+ console.log(despesa_rateio_work.retorno, style="bold green")
512
+ else:
513
+ return RpaRetornoProcessoDTO(
514
+ sucesso=False,
515
+ retorno=despesa_rateio_work.retorno,
516
+ status=RpaHistoricoStatusEnum.Falha,
517
+ tags=despesa_rateio_work.tags
518
+ )
519
+
520
+ # Verifica se a info 'Nota fiscal incluida' está na tela
521
+ await worker_sleep(15)
522
+ warning_pop_up = await is_window_open("Warning")
523
+ if warning_pop_up["IsOpened"] == True:
524
+ app = Application().connect(title="Warning")
525
+ main_window = app["Warning"]
526
+ main_window.set_focus()
527
+
528
+ console.print(f"Obtendo texto do Warning...\n")
529
+ console.print(f"Tirando print da janela do warning para realização do OCR...\n")
530
+
531
+ window_rect = main_window.rectangle()
532
+ screenshot = pyautogui.screenshot(
533
+ region=(
534
+ window_rect.left,
535
+ window_rect.top,
536
+ window_rect.width(),
537
+ window_rect.height(),
538
+ )
539
+ )
540
+ username = getpass.getuser()
541
+ path_to_png = f"C:\\Users\\{username}\\Downloads\\warning_popup_{nota.get("nfe")}.png"
542
+ screenshot.save(path_to_png)
543
+ console.print(f"Print salvo em {path_to_png}...\n")
544
+
545
+ console.print(
546
+ f"Preparando a imagem para maior resolução e assertividade no OCR...\n"
547
+ )
548
+ image = Image.open(path_to_png)
549
+ image = image.convert("L")
550
+ enhancer = ImageEnhance.Contrast(image)
551
+ image = enhancer.enhance(2.0)
552
+ image.save(path_to_png)
553
+ console.print(f"Imagem preparada com sucesso...\n")
554
+ console.print(f"Realizando OCR...\n")
555
+ captured_text = pytesseract.image_to_string(Image.open(path_to_png))
556
+ console.print(
557
+ f"Texto Full capturado {captured_text}...\n"
558
+ )
559
+ os.remove(path_to_png)
560
+ if 'movimento não permitido' in captured_text.lower():
561
+ return RpaRetornoProcessoDTO(
562
+ sucesso=False,
563
+ retorno=f"Filial: {filialEmpresaOrigem} está com o livro fechado ou encerrado, verificar com o setor fiscal",
564
+ status=RpaHistoricoStatusEnum.Falha,
565
+ tags=[RpaTagDTO(descricao=RpaTagEnum.Negocio)]
566
+ )
567
+ else:
568
+ return RpaRetornoProcessoDTO(
569
+ sucesso=False,
570
+ retorno=f"Warning não mapeado para seguimento do robo, mensagem: {captured_text}",
571
+ status=RpaHistoricoStatusEnum.Falha,
572
+ tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
573
+ )
574
+
575
+ await worker_sleep(3)
576
+ nf_imported = await check_nota_importada(nota.get("nfe"))
577
+ if nf_imported.sucesso == True:
578
+ await worker_sleep(3)
579
+ console.print("\nVerifica se a nota ja foi lançada...")
580
+ nf_chave_acesso = int(nota.get("nfe"))
581
+ status_nf_emsys = await get_status_nf_emsys(nf_chave_acesso)
582
+ if status_nf_emsys.get("status") == "Lançada":
583
+ console.print("\nNota lançada com sucesso, processo finalizado...", style="bold green")
584
+ return RpaRetornoProcessoDTO(
585
+ sucesso=True,
586
+ retorno="Nota Lançada com sucesso!",
587
+ status=RpaHistoricoStatusEnum.Sucesso,
588
+ )
589
+ else:
590
+ console.print("Erro ao lançar nota", style="bold red")
591
+ return RpaRetornoProcessoDTO(
592
+ sucesso=False,
593
+ retorno=f"Pop-up nota incluida encontrada, porém nota encontrada como 'já lançada' trazendo as seguintes informações: {nf_imported.retorno} - {error_work}",
594
+ status=RpaHistoricoStatusEnum.Falha,
595
+ tags=[RpaTagDTO(descricao=RpaTagEnum.Negocio)]
596
+ )
597
+ else:
598
+ console.print("Erro ao lançar nota", style="bold red")
599
+ return RpaRetornoProcessoDTO(
600
+ sucesso=False,
601
+ retorno=f"Erro ao lançar nota, erro: {nf_imported.retorno}",
602
+ status=RpaHistoricoStatusEnum.Falha,
603
+ tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
604
+ )
605
+
606
+ except Exception as ex:
607
+ observacao = f"Erro Processo Entrada de Notas: {str(ex)}"
608
+ logger.error(observacao)
609
+ console.print(observacao, style="bold red")
610
+ return RpaRetornoProcessoDTO(
611
+ sucesso=False,
612
+ retorno=observacao,
613
+ status=RpaHistoricoStatusEnum.Falha,
614
+ tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
615
+ )
616
+
617
+ finally:
618
+ # Deleta o xml
619
+ await delete_xml(nota.get("nfe"))
@@ -30,6 +30,7 @@ from worker_automate_hub.tasks.jobs.entrada_de_notas_9 import entrada_de_notas_9
30
30
  from worker_automate_hub.tasks.jobs.entrada_de_notas_9000 import entrada_de_notas_9000
31
31
  from worker_automate_hub.tasks.jobs.entrada_de_notas_7139 import entrada_de_notas_7139
32
32
  from worker_automate_hub.tasks.jobs.entrada_de_notas_36 import entrada_de_notas_36
33
+ from worker_automate_hub.tasks.jobs.entrada_de_notas_37 import entrada_de_notas_37
33
34
  from worker_automate_hub.tasks.jobs.entrada_de_notas_503 import entrada_de_notas_503
34
35
  from worker_automate_hub.tasks.jobs.extracao_saldo_estoque import extracao_saldo_estoque
35
36
  from worker_automate_hub.tasks.jobs.extracao_saldo_estoque_fiscal import extracao_saldo_estoque_fiscal
@@ -201,7 +202,8 @@ task_definitions = {
201
202
  "ca7ac373-e8e7-4ac2-aa7e-298070e0d9a0": extracao_fechamento_contabil,
202
203
  "8c28726d-458d-4119-afa0-202695b79a8f": extracao_fechamento_emsys,
203
204
  "16debe45-3520-4f63-acfe-ef0e8784fcab": extracao_saldo_estoque,
204
- "9cbc6016-7c0e-4a3a-8ee9-fb9dc4b35e33": extracao_saldo_estoque_fiscal
205
+ "9cbc6016-7c0e-4a3a-8ee9-fb9dc4b35e33": extracao_saldo_estoque_fiscal,
206
+ "33d9edeb-7cb2-449b-9096-ed9cf3d3f6c3": entrada_de_notas_37,
205
207
  }
206
208
 
207
209
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: worker-automate-hub
3
- Version: 0.5.776
3
+ Version: 0.5.777
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
@@ -60,6 +60,7 @@ worker_automate_hub/tasks/jobs/entrada_de_notas_32.py,sha256=lku233FqwOknXF14HHC
60
60
  worker_automate_hub/tasks/jobs/entrada_de_notas_33.py,sha256=ODp82BkWaiF40t6uZLJYxG2nGGnvDyeQBHhkkh9ZgPI,35994
61
61
  worker_automate_hub/tasks/jobs/entrada_de_notas_34.py,sha256=AXUL8DakrDeTxWW8dn36W830XfIuO47MFUusbUkrnUc,33586
62
62
  worker_automate_hub/tasks/jobs/entrada_de_notas_36.py,sha256=z494n0SUyxorjhvpbat2ELnj7lbhtWPb9JOIsattwA8,35216
63
+ worker_automate_hub/tasks/jobs/entrada_de_notas_37.py,sha256=63nSsCt3Rc2faiMLffNhyb0RMifE2agpA7sgMKvgHWU,24331
63
64
  worker_automate_hub/tasks/jobs/entrada_de_notas_39.py,sha256=cuIKcQJctyFhfm9vjxA8kIPAqUxMaitu8Uj9vIvJ46I,48693
64
65
  worker_automate_hub/tasks/jobs/entrada_de_notas_500.py,sha256=WBsCRbH7ANiCjEn0aEDc5AqGf6grEFhxyBoAIh3zJ40,44160
65
66
  worker_automate_hub/tasks/jobs/entrada_de_notas_503.py,sha256=bcNKy6X1aaVe6lxW-TMyUKJ_GXzHEK-8V6x9SOzOshw,48365
@@ -90,7 +91,7 @@ worker_automate_hub/tasks/jobs/opex_capex.py,sha256=8iOhWY0BUXugitJa-a0jtsPh656L
90
91
  worker_automate_hub/tasks/jobs/playground.py,sha256=7vWDg9DwToHwGJ6_XOa8TQ6LmfRV5Qz2TaOV3q3P9sA,1918
91
92
  worker_automate_hub/tasks/jobs/sped_fiscal.py,sha256=Zsq-IwKxA0b2tikO6Rri4WXVj10jK-Jd0-gxk8yVBH0,31064
92
93
  worker_automate_hub/tasks/jobs/transferencias.py,sha256=5TIktufkvUPnVTR2gf7GFQJ5KQP6PWnmoWiE08WiVDQ,46191
93
- worker_automate_hub/tasks/task_definitions.py,sha256=wn8gqEjmTLkm4m5Cw8NOhgcw8h9uROev95iPglBx5FM,12295
94
+ worker_automate_hub/tasks/task_definitions.py,sha256=HwwHZG6CbnVnltT_THEwsWQv466STtLnIbMrMg3pDDg,12446
94
95
  worker_automate_hub/tasks/task_executor.py,sha256=9dmLUlMpJOI7FhbaFE593TcWnDxBvuXbGVecs1aaJxE,5728
95
96
  worker_automate_hub/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
96
97
  worker_automate_hub/utils/env.py,sha256=TacQjGRO7PUNpttrhTAc5Gnegaiysl2Knsv1P8qfkfs,57
@@ -101,7 +102,7 @@ worker_automate_hub/utils/updater.py,sha256=en2FCGhI8aZ-JNP3LQm64NJDc4awCNW7UhbV
101
102
  worker_automate_hub/utils/util.py,sha256=f0lkFbPyg5kAtNI4RHOZ12iIxfmtbq6uuS3sBUqszE8,210055
102
103
  worker_automate_hub/utils/utils_nfe_entrada.py,sha256=TOXKSHOPxy8N3-ROpTGjNIHstX0i2b8qekcj1tRvjG8,38174
103
104
  worker_automate_hub/worker.py,sha256=uhZ3f-iaQ1i8cANbljp50vkYl-Xm0_sHtjwwF_2y72o,7191
104
- worker_automate_hub-0.5.776.dist-info/entry_points.txt,sha256=sddyhjx57I08RY8X7UxcTpdoOsWULAWNKN9Xr6pp_Kw,54
105
- worker_automate_hub-0.5.776.dist-info/METADATA,sha256=07C23Qb3GrNPpS9TJEgaPLBhVLqii4Mt0Dvw1gwTXlc,3049
106
- worker_automate_hub-0.5.776.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
107
- worker_automate_hub-0.5.776.dist-info/RECORD,,
105
+ worker_automate_hub-0.5.777.dist-info/entry_points.txt,sha256=sddyhjx57I08RY8X7UxcTpdoOsWULAWNKN9Xr6pp_Kw,54
106
+ worker_automate_hub-0.5.777.dist-info/METADATA,sha256=4qCRlnFpjlSbaGz_1SiBKReTsuvKHbd_YNYl1TOXzew,3049
107
+ worker_automate_hub-0.5.777.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
108
+ worker_automate_hub-0.5.777.dist-info/RECORD,,