diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..6769e21d --- /dev/null +++ b/.gitignore @@ -0,0 +1,160 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/#use-with-ide +.pdm.toml + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ \ No newline at end of file diff --git a/project/app/__pycache__/__init__.cpython-310.pyc b/project/app/__pycache__/__init__.cpython-310.pyc index 485edf8e..e84fc361 100644 Binary files a/project/app/__pycache__/__init__.cpython-310.pyc and b/project/app/__pycache__/__init__.cpython-310.pyc differ diff --git a/project/app/__pycache__/__init__.cpython-311.pyc b/project/app/__pycache__/__init__.cpython-311.pyc index 1b2ff895..d0891a13 100644 Binary files a/project/app/__pycache__/__init__.cpython-311.pyc and b/project/app/__pycache__/__init__.cpython-311.pyc differ diff --git a/project/app/__pycache__/__init__.cpython-38.pyc b/project/app/__pycache__/__init__.cpython-38.pyc new file mode 100644 index 00000000..2cc52291 Binary files /dev/null and b/project/app/__pycache__/__init__.cpython-38.pyc differ diff --git a/project/app/__pycache__/admin.cpython-310.pyc b/project/app/__pycache__/admin.cpython-310.pyc index 91891dcf..3afb4c85 100644 Binary files a/project/app/__pycache__/admin.cpython-310.pyc and b/project/app/__pycache__/admin.cpython-310.pyc differ diff --git a/project/app/__pycache__/admin.cpython-311.pyc b/project/app/__pycache__/admin.cpython-311.pyc index 0a7faa3a..e5ec7b0e 100644 Binary files a/project/app/__pycache__/admin.cpython-311.pyc and b/project/app/__pycache__/admin.cpython-311.pyc differ diff --git a/project/app/__pycache__/admin.cpython-38.pyc b/project/app/__pycache__/admin.cpython-38.pyc new file mode 100644 index 00000000..95a85748 Binary files /dev/null and b/project/app/__pycache__/admin.cpython-38.pyc differ diff --git a/project/app/__pycache__/apps.cpython-310.pyc b/project/app/__pycache__/apps.cpython-310.pyc index aabcd389..63e76c30 100644 Binary files a/project/app/__pycache__/apps.cpython-310.pyc and b/project/app/__pycache__/apps.cpython-310.pyc differ diff --git a/project/app/__pycache__/apps.cpython-311.pyc b/project/app/__pycache__/apps.cpython-311.pyc index 26e6a0f6..220056c8 100644 Binary files a/project/app/__pycache__/apps.cpython-311.pyc and b/project/app/__pycache__/apps.cpython-311.pyc differ diff --git a/project/app/__pycache__/apps.cpython-38.pyc b/project/app/__pycache__/apps.cpython-38.pyc new file mode 100644 index 00000000..bbc95296 Binary files /dev/null and b/project/app/__pycache__/apps.cpython-38.pyc differ diff --git a/project/app/__pycache__/capa.cpython-38.pyc b/project/app/__pycache__/capa.cpython-38.pyc new file mode 100644 index 00000000..1d709008 Binary files /dev/null and b/project/app/__pycache__/capa.cpython-38.pyc differ diff --git a/project/app/__pycache__/estilo.cpython-38.pyc b/project/app/__pycache__/estilo.cpython-38.pyc new file mode 100644 index 00000000..05a4664d Binary files /dev/null and b/project/app/__pycache__/estilo.cpython-38.pyc differ diff --git a/project/app/__pycache__/estilo_fundep.cpython-38.pyc b/project/app/__pycache__/estilo_fundep.cpython-38.pyc new file mode 100644 index 00000000..6b7ce0a0 Binary files /dev/null and b/project/app/__pycache__/estilo_fundep.cpython-38.pyc differ diff --git a/project/app/__pycache__/models.cpython-310.pyc b/project/app/__pycache__/models.cpython-310.pyc index 9a780135..aed424d3 100644 Binary files a/project/app/__pycache__/models.cpython-310.pyc and b/project/app/__pycache__/models.cpython-310.pyc differ diff --git a/project/app/__pycache__/models.cpython-311.pyc b/project/app/__pycache__/models.cpython-311.pyc index 6eada88f..faf18252 100644 Binary files a/project/app/__pycache__/models.cpython-311.pyc and b/project/app/__pycache__/models.cpython-311.pyc differ diff --git a/project/app/__pycache__/models.cpython-38.pyc b/project/app/__pycache__/models.cpython-38.pyc new file mode 100644 index 00000000..da00ce1f Binary files /dev/null and b/project/app/__pycache__/models.cpython-38.pyc differ diff --git a/project/app/__pycache__/new_dev.cpython-38.pyc b/project/app/__pycache__/new_dev.cpython-38.pyc new file mode 100644 index 00000000..ac7b4ac1 Binary files /dev/null and b/project/app/__pycache__/new_dev.cpython-38.pyc differ diff --git a/project/app/__pycache__/oracle_cruds.cpython-38.pyc b/project/app/__pycache__/oracle_cruds.cpython-38.pyc new file mode 100644 index 00000000..fb690a51 Binary files /dev/null and b/project/app/__pycache__/oracle_cruds.cpython-38.pyc differ diff --git a/project/app/__pycache__/preenche_fub.cpython-38.pyc b/project/app/__pycache__/preenche_fub.cpython-38.pyc new file mode 100644 index 00000000..593bdbb7 Binary files /dev/null and b/project/app/__pycache__/preenche_fub.cpython-38.pyc differ diff --git a/project/app/__pycache__/preenche_fundep.cpython-38.pyc b/project/app/__pycache__/preenche_fundep.cpython-38.pyc new file mode 100644 index 00000000..8b9cfb6b Binary files /dev/null and b/project/app/__pycache__/preenche_fundep.cpython-38.pyc differ diff --git a/project/app/__pycache__/preencher_colunas.cpython-38.pyc b/project/app/__pycache__/preencher_colunas.cpython-38.pyc new file mode 100644 index 00000000..b63d009f Binary files /dev/null and b/project/app/__pycache__/preencher_colunas.cpython-38.pyc differ diff --git a/project/app/__pycache__/urls.cpython-310.pyc b/project/app/__pycache__/urls.cpython-310.pyc index 83d53aad..67f4815d 100644 Binary files a/project/app/__pycache__/urls.cpython-310.pyc and b/project/app/__pycache__/urls.cpython-310.pyc differ diff --git a/project/app/__pycache__/urls.cpython-311.pyc b/project/app/__pycache__/urls.cpython-311.pyc index 4a8e7ef6..90817f00 100644 Binary files a/project/app/__pycache__/urls.cpython-311.pyc and b/project/app/__pycache__/urls.cpython-311.pyc differ diff --git a/project/app/__pycache__/urls.cpython-38.pyc b/project/app/__pycache__/urls.cpython-38.pyc new file mode 100644 index 00000000..78f94d4b Binary files /dev/null and b/project/app/__pycache__/urls.cpython-38.pyc differ diff --git a/project/app/__pycache__/views.cpython-310.pyc b/project/app/__pycache__/views.cpython-310.pyc index 76c36902..a1c16d54 100644 Binary files a/project/app/__pycache__/views.cpython-310.pyc and b/project/app/__pycache__/views.cpython-310.pyc differ diff --git a/project/app/__pycache__/views.cpython-311.pyc b/project/app/__pycache__/views.cpython-311.pyc index 42d3305c..3f43d846 100644 Binary files a/project/app/__pycache__/views.cpython-311.pyc and b/project/app/__pycache__/views.cpython-311.pyc differ diff --git a/project/app/__pycache__/views.cpython-38.pyc b/project/app/__pycache__/views.cpython-38.pyc new file mode 100644 index 00000000..ddbe8ce0 Binary files /dev/null and b/project/app/__pycache__/views.cpython-38.pyc differ diff --git a/project/app/capa.py b/project/app/capa.py new file mode 100644 index 00000000..f14af5f3 --- /dev/null +++ b/project/app/capa.py @@ -0,0 +1,329 @@ +import openpyxl +from openpyxl.styles import Font, PatternFill, Alignment,NamedStyle +from openpyxl.drawing.image import Image +from PIL import Image as PILImage +import os + + + + +def pegar_caminho(nome_arquivo): + + # Obter o caminho absoluto do arquivo Python em execução + caminho_script = os.path.abspath(__file__) + + # Obter o diretório da pasta onde o script está localizado + pasta_script = os.path.dirname(caminho_script) + + # Combinar o caminho da pasta com o nome do arquivo Excel + caminho = os.path.join(pasta_script, nome_arquivo) + + return caminho + +def preenche_planilha(planilha, dicionario): + + caminho = pegar_caminho(planilha) + Plan = planilha + # carrega a planilha de acordo com o caminho + workbook = openpyxl.load_workbook(caminho) + + # planilha_preenchida = pegar_caminho('preenchido-' + planilha) + for nomePlanilha, entradaDados in dicionario.items(): + planilhaAtual = workbook[nomePlanilha] + + for intervaloCelula, entradaCelula in entradaDados: + if ":" in intervaloCelula: + inicioCelula, fimCelula = intervaloCelula.split(":") + planilhaAtual = workbook[nomePlanilha] + planilhaAtual[inicioCelula] = entradaCelula + # planilhaAtual[inicioCelula].fill = color <--- teste com cores + else: + planilhaAtual[intervaloCelula] = entradaCelula + # planilhaAtual[intervaloCelula].fill = color <--- teste com cores + + + workbook.save(planilha) + + return planilha + + +def inserir_round_retangulo(planilha,data1,data2,dicionariofin): + + + + + # id_mapeamento + # codigo + # nome + # saldo + # data_assinatura + # data_vigencia + # data_encerramento + # tipo_contrato + # instituicao_executora + # processo + # subprocesso + # cod_proposta + # proposta + # objetivos + # valor_aprovado + # nome_tp_controle_saldo + # grupo_gestores + # gestor_resp + # coordenador + # procedimento_compra + # tab_frete + # tab_diarias + # custo_op + # nome_financiador + # departamento + # situacao + # banco + # agencia_bancaria + # conta_bancaria + # centro_custo + # conta_caixa + # categoria_projeto + # cod_convenio_conta + # cod_status + # ind_sub_projeto + # tipo_custo_op + # projeto_mae + # id_coordenador + # id_financiador + # id_instituicao + # id_departamento + # nome_instituicao + # id_instituicao_executora + # id_tipo + + planilha_local_dados = { + "Capa Finatec":[ + ("E6",'NOME_FINANCIADOR'), + ("E9",'NOME'), + ("E14",'COORDENADOR'), + ("E17",'PROCESSO'), + ("E19",'CODIGO'), + ("K17",'BANCO'), + ("K19",'CONTA_BANCARIA'), + ("K21",'AGENCIA_BANCARIA'), + ("E35",'Suellen Santos Diniz de Carvalho') + ] + } + + + + + + + # Create an empty dictionary to store the values from the second dictionary + result_dict = {} + + # Loop pra criar no formato dicionarario por exemplo + # Capa Finatec : [(E3:COORDENADOR)] + for key, value in planilha_local_dados["Capa Finatec"]: + if value in dicionariofin: + result_dict[key] = dicionariofin[value] + print(result_dict) + list_of_tuples = [(key, value) for key, value in result_dict.items()] + + novo_dict = {"Capa Finatec":list_of_tuples} + + preenche_planilha(planilha, novo_dict) + + caminho = pegar_caminho(planilha) + workbook = openpyxl.load_workbook(caminho) + worksheet = workbook['Capa Finatec'] + + + + # List of image names + image_names = [ + 'agencia.png',#0 + 'agencia_branco.png',#1 + 'agente.png',#2 + 'agente_branco.png',#3 + 'analista.png',#4 + 'analista_branco.png',#5 + 'assinaturas_responsaveis.png',#6 + 'assistente.png',#7 + 'assistente_branco.png',#8 + 'banco.png',#9 + 'banco_branco.png',#10 + 'conta_corrente.png',#11 + 'conta_corrente_branco.png',#12 + 'coordenador.png',#13 + 'coordenador_branco.png',#14 + 'dadosdoacordo.png',#15 + 'gerente.png',#16 + 'gerente_branco.png',#17 + 'periodo.png',#18 + 'periodo_branco.png',#19 + 'prestaçãodecontasparcial.png',#20 + 'processo.png',#21 + 'processo_branco.png',#22 + 'projeto.png',#23 + 'projeto_branco.png',#24, + 'centrodecusto.png',#25, + 'centrodecusto_branco.png' + ] + + # Path to the images + path = '/home/ubuntu/Desktop/entrega/05_PipelineFinatec/project/app/capa_60/' + + # List to hold Image objects + images = [] + + # Loop through the list of image names and create Image objects + for i, name in enumerate(image_names): + image_path = path + name + pil_image = PILImage.open(image_path) + pil_image.save(image_path) + img = Image(image_path) + images.append(img) + + + + + #estilo imagem + worksheet.add_image(images[20], "B2")#prestação + worksheet.merge_cells('B2:L2') + worksheet['B2'] = 'PRESTAÇÃO DE CONTAS PARCIAL' + worksheet['B2'].font = Font(name="Tahoma", size=17, color="204c80",bold=True) + worksheet['B2'].alignment = Alignment(horizontal="center",vertical="center") + + worksheet.add_image(images[15], "B4")#dados do acordo + worksheet.merge_cells('B4:L4') + worksheet['B4'] = 'DADOS DO ACORDO' + worksheet['B4'].font = Font(name="Tahoma", size=10, color="204c80",bold=True) + worksheet['B4'].alignment = Alignment(horizontal="center",vertical="center") + + worksheet.add_image(images[2], "B6")#agente + worksheet.merge_cells('B6:D7') + worksheet['B6'] = 'AGENTE FINANCIADOR' + worksheet['B6'].font = Font(name="Tahoma", size=10, color="204c80",bold=True) + worksheet['B6'].alignment = Alignment(horizontal="justify",vertical="center",wrap_text=True) + worksheet.add_image(images[3], "E6") + worksheet.merge_cells('E6:M7') + worksheet['E6'].font = Font(name="Tahoma", size=9, color="204c80",bold=False) + worksheet['E6'].alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + + worksheet.add_image(images[23], "B9")#projeto + worksheet.merge_cells('B9:D13') + worksheet['B9'] = 'PROJETO' + worksheet['B9'].font = Font(name="Tahoma", size=10, color="204c80",bold=True) + worksheet['B9'].alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + worksheet.add_image(images[24], "E9") + worksheet.merge_cells('E9:M13') + worksheet['E9'].font = Font(name="Tahoma", size=10, color="204c80",bold=False) + worksheet['E9'].alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + + worksheet.add_image(images[13], "B14")#coordenador + worksheet.merge_cells('B14:D15') + worksheet['B14'] = 'COORDENADOR' + worksheet['B14'].font = Font(name="Tahoma", size=10, color="204c80",bold=True) + worksheet['B14'].alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + worksheet.add_image(images[14], "E14") + worksheet.merge_cells('E14:M15') + worksheet['E14'].font = Font(name="Tahoma", size=10, color="204c80",bold=False) + worksheet['E14'].alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + + + worksheet.add_image(images[21], "B17")#processo + worksheet.merge_cells('B17:D18') + worksheet['B17'] = 'PROCESSO' + worksheet['B17'].font = Font(name="Tahoma", size=10, color="204c80",bold=True) + worksheet['B17'].alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + worksheet.add_image(images[22], "E17") + worksheet.merge_cells('E17:G18') + worksheet['E17'].font = Font(name="Tahoma", size=10, color="204c80",bold=False) + worksheet['E17'].alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + + worksheet.add_image(images[9], "H17")#Banco + worksheet.merge_cells('H17:J18') + worksheet['H17'] = 'BANCO' + worksheet['H17'].font = Font(name="Tahoma", size=10, color="204c80",bold=True) + worksheet['H17'].alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + worksheet.add_image(images[10], "K17") + worksheet.merge_cells('K17:M18') + worksheet['K17'].font = Font(name="Tahoma", size=10, color="204c80",bold=False) + worksheet['K17'].alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + + worksheet.add_image(images[11], "H19")#CoOtaCorreOte + worksheet.merge_cells('H19:J20') + worksheet['H19'] = 'CONTA CORRENTE' + worksheet['H19'].font = Font(name="Tahoma", size=10, color="204c80",bold=True) + worksheet['H19'].alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + worksheet.add_image(images[12], "K19") + worksheet.merge_cells('K19:M20') + worksheet['K19'].font = Font(name="Tahoma", size=10, color="204c80",bold=False) + worksheet['K19'].alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + + worksheet.add_image(images[0], "H21")#Agencia + worksheet.merge_cells('H21:J22') + worksheet['H21'] = 'AGÊNCIA' + worksheet['H21'].font = Font(name="Tahoma", size=10, color="204c80",bold=True) + worksheet['H21'].alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + worksheet.add_image(images[1], "K21") + worksheet.merge_cells('K21:M22') + worksheet['K21'].font = Font(name="Tahoma", size=10, color="204c80",bold=False) + worksheet['K21'].alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + + worksheet.add_image(images[25], "B19")#Centro de custo + worksheet.merge_cells('B19:D20') + worksheet['B19'] = 'CENTRO DE CUSTO' + worksheet['B19'].font = Font(name="Tahoma", size=10, color="204c80",bold=True) + worksheet['B19'].alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + worksheet.add_image(images[26], "E19")#Centro de custo + worksheet.merge_cells('E19:G20') + worksheet['E19'].font = Font(name="Tahoma", size=10, color="204c80",bold=False) + worksheet['E19'].alignment = Alignment(horizontal="center",vertical="center") + + + worksheet.add_image(images[18], "B21")#Periodo + worksheet.merge_cells('B21:D22') + worksheet['B21'] = 'PERIODO' + worksheet['B21'].font = Font(name="Tahoma", size=9, color="204c80",bold=True) + worksheet['B21'].alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + worksheet.add_image(images[19], "E21")#Periodo + worksheet.merge_cells('E21:G22') + worksheet['E21'] = f"{(data1)} a {(data2)}" + worksheet['E21'].font = Font(name="Tahoma", size=10, color="204c80",bold=False) + worksheet['E21'].alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + + worksheet.add_image(images[7], "B30")#Assistente + worksheet.merge_cells('B30:D32') + worksheet['B30'] = 'ASSISTENTE' + worksheet['B30'].font = Font(name="Tahoma", size=10, color="204c80",bold=True) + worksheet['B30'].alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + worksheet.add_image(images[8], "E30")#Assistente + worksheet['E30'].font = Font(name="Tahoma", size=10, color="204c80",bold=False) + worksheet['E30'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet.add_image(images[4], "B26")#Analista + worksheet.merge_cells('B26:D28') + worksheet['B26'] = 'ANALISTA' + worksheet['B26'].font = Font(name="Tahoma", size=10, color="204c80",bold=True) + worksheet['B26'].alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + worksheet.add_image(images[5], "E26")#Analista + worksheet.merge_cells('E26:M28') + worksheet['E26'].font = Font(name="Tahoma", size=10, color="204c80",bold=False) + worksheet['E26'].alignment = Alignment(horizontal="center",vertical="center") + + worksheet.add_image(images[16], "B34")#gerengte + worksheet.merge_cells('B34:D36') + worksheet['B34'] = 'COORDENADORA DE GESTÃO DE PROJETOS' + worksheet['B34'].font = Font(name="Tahoma", size=10, color="204c80",bold=True) + worksheet['B34'].alignment = Alignment(horizontal="left",vertical="center",wrap_text=True,shrink_to_fit=True ) + worksheet.add_image(images[17], "E34")#gerente + worksheet['E34'].font = Font(name="Tahoma", size=10, color="204c80",bold=False) + worksheet['E34'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet.add_image(images[6], "B23")#ASSINATURAS + worksheet.merge_cells('B23:M24') + worksheet['B23'] = 'ASSINATURAS - RESPONSAVEIS PELA PRESTAÇÃO DE CONTAS' + worksheet['B23'].font = Font(name="Tahoma", size=10, color="204c80",bold=True) + worksheet['B23'].alignment = Alignment(horizontal="center",vertical="center") + + # Save the workbook + workbook.save(planilha) diff --git a/project/app/capa_60/agencia.png b/project/app/capa_60/agencia.png new file mode 100644 index 00000000..5594d9f1 Binary files /dev/null and b/project/app/capa_60/agencia.png differ diff --git a/project/app/capa_60/agencia_branco.png b/project/app/capa_60/agencia_branco.png new file mode 100644 index 00000000..1966afb6 Binary files /dev/null and b/project/app/capa_60/agencia_branco.png differ diff --git a/project/app/capa_60/agente.png b/project/app/capa_60/agente.png new file mode 100644 index 00000000..38f85e28 Binary files /dev/null and b/project/app/capa_60/agente.png differ diff --git a/project/app/capa_60/agente_branco.png b/project/app/capa_60/agente_branco.png new file mode 100644 index 00000000..2714e44c Binary files /dev/null and b/project/app/capa_60/agente_branco.png differ diff --git a/project/app/capa_60/analista.png b/project/app/capa_60/analista.png new file mode 100644 index 00000000..2d85ce37 Binary files /dev/null and b/project/app/capa_60/analista.png differ diff --git a/project/app/capa_60/analista_branco.png b/project/app/capa_60/analista_branco.png new file mode 100644 index 00000000..a3f2c21b Binary files /dev/null and b/project/app/capa_60/analista_branco.png differ diff --git a/project/app/capa_60/assinaturas_responsaveis.png b/project/app/capa_60/assinaturas_responsaveis.png new file mode 100644 index 00000000..7216a55c Binary files /dev/null and b/project/app/capa_60/assinaturas_responsaveis.png differ diff --git a/project/app/capa_60/assistente.png b/project/app/capa_60/assistente.png new file mode 100644 index 00000000..573d4ad4 Binary files /dev/null and b/project/app/capa_60/assistente.png differ diff --git a/project/app/capa_60/assistente_branco.png b/project/app/capa_60/assistente_branco.png new file mode 100644 index 00000000..4e87a7ac Binary files /dev/null and b/project/app/capa_60/assistente_branco.png differ diff --git a/project/app/capa_60/banco.png b/project/app/capa_60/banco.png new file mode 100644 index 00000000..5594d9f1 Binary files /dev/null and b/project/app/capa_60/banco.png differ diff --git a/project/app/capa_60/banco_branco.png b/project/app/capa_60/banco_branco.png new file mode 100644 index 00000000..1966afb6 Binary files /dev/null and b/project/app/capa_60/banco_branco.png differ diff --git a/project/app/capa_60/centrodecusto.png b/project/app/capa_60/centrodecusto.png new file mode 100644 index 00000000..3f027ea6 Binary files /dev/null and b/project/app/capa_60/centrodecusto.png differ diff --git a/project/app/capa_60/centrodecusto_branco.png b/project/app/capa_60/centrodecusto_branco.png new file mode 100644 index 00000000..0d53683f Binary files /dev/null and b/project/app/capa_60/centrodecusto_branco.png differ diff --git a/project/app/capa_60/conta_corrente.png b/project/app/capa_60/conta_corrente.png new file mode 100644 index 00000000..0a0513b3 Binary files /dev/null and b/project/app/capa_60/conta_corrente.png differ diff --git a/project/app/capa_60/conta_corrente_branco.png b/project/app/capa_60/conta_corrente_branco.png new file mode 100644 index 00000000..1966afb6 Binary files /dev/null and b/project/app/capa_60/conta_corrente_branco.png differ diff --git a/project/app/capa_60/coordenador.png b/project/app/capa_60/coordenador.png new file mode 100644 index 00000000..83ef1f41 Binary files /dev/null and b/project/app/capa_60/coordenador.png differ diff --git a/project/app/capa_60/coordenador_branco.png b/project/app/capa_60/coordenador_branco.png new file mode 100644 index 00000000..ac2b643c Binary files /dev/null and b/project/app/capa_60/coordenador_branco.png differ diff --git a/project/app/capa_60/dadosdoacordo.png b/project/app/capa_60/dadosdoacordo.png new file mode 100644 index 00000000..9a638e47 Binary files /dev/null and b/project/app/capa_60/dadosdoacordo.png differ diff --git a/project/app/capa_60/gerente.png b/project/app/capa_60/gerente.png new file mode 100644 index 00000000..cbbdafd1 Binary files /dev/null and b/project/app/capa_60/gerente.png differ diff --git a/project/app/capa_60/gerente_branco.png b/project/app/capa_60/gerente_branco.png new file mode 100644 index 00000000..f9fa8e2e Binary files /dev/null and b/project/app/capa_60/gerente_branco.png differ diff --git a/project/app/capa_60/periodo.png b/project/app/capa_60/periodo.png new file mode 100644 index 00000000..cd1af862 Binary files /dev/null and b/project/app/capa_60/periodo.png differ diff --git a/project/app/capa_60/periodo_branco.png b/project/app/capa_60/periodo_branco.png new file mode 100644 index 00000000..7c3f0f92 Binary files /dev/null and b/project/app/capa_60/periodo_branco.png differ diff --git "a/project/app/capa_60/presta\303\247\303\243odecontasparcial.png" "b/project/app/capa_60/presta\303\247\303\243odecontasparcial.png" new file mode 100644 index 00000000..35f3b358 Binary files /dev/null and "b/project/app/capa_60/presta\303\247\303\243odecontasparcial.png" differ diff --git a/project/app/capa_60/processo.png b/project/app/capa_60/processo.png new file mode 100644 index 00000000..3f027ea6 Binary files /dev/null and b/project/app/capa_60/processo.png differ diff --git a/project/app/capa_60/processo_branco.png b/project/app/capa_60/processo_branco.png new file mode 100644 index 00000000..3937be94 Binary files /dev/null and b/project/app/capa_60/processo_branco.png differ diff --git a/project/app/capa_60/projeto.png b/project/app/capa_60/projeto.png new file mode 100644 index 00000000..99753c53 Binary files /dev/null and b/project/app/capa_60/projeto.png differ diff --git a/project/app/capa_60/projeto_branco.png b/project/app/capa_60/projeto_branco.png new file mode 100644 index 00000000..b80bd775 Binary files /dev/null and b/project/app/capa_60/projeto_branco.png differ diff --git a/project/app/estilo_fub.py b/project/app/estilo_fub.py new file mode 100644 index 00000000..e57c92a3 --- /dev/null +++ b/project/app/estilo_fub.py @@ -0,0 +1,3798 @@ +import openpyxl +from openpyxl.styles import Font, PatternFill, Alignment,NamedStyle,Border, Side +import os +#pegar o caminho do arquivo +def pegar_caminho(nome_arquivo): + + # Obter o caminho absoluto do arquivo Python em execução + caminho_script = os.path.abspath(__file__) + + # Obter o diretório da pasta onde o script está localizado + pasta_script = os.path.dirname(caminho_script) + + # Combinar o caminho da pasta com o nome do arquivo Excel + caminho = os.path.join(pasta_script, nome_arquivo) + + return caminho + +def create_variable(name1, name2): + # Create a dictionary to store values with keys based on inputs + variables = {} + variable_name = f"{name1}_{name2}" # Create a variable name based on + variables[variable_name] = [] + + # Assign the value to the dynamically created variable name + return variables + +def estiloGeral(tabela,tamanho,nomeVariavel,nomeTabela): + nomeSheet=nomeVariavel + caminho = pegar_caminho(tabela) + workbook = openpyxl.load_workbook(caminho) + worksheet = workbook[nomeTabela] + size = tamanho + 10 + cinza = "d9d9d9" + cinza_escuro = "bfbfbf" + azul = "336394" + azul_claro = '1c8cbc' + + borda = Border(right=Side(border_style="medium")) + worksheet.sheet_view.showGridLines = False + # + for row in worksheet.iter_rows(min_row=1, max_row=size+11,min_col=10,max_col=10): + for cell in row: + cell.border = borda + + + worksheet.column_dimensions['a'].width = 25 + worksheet.column_dimensions['b'].width = 25 + worksheet.column_dimensions['c'].width = 35 + worksheet.column_dimensions['d'].width = 35#descrição + worksheet.column_dimensions['e'].width = 65 #n do recibo ou qeuivalente + worksheet.column_dimensions['f'].width = 25 #data de emissão + worksheet.column_dimensions['g'].width = 25 #data de emissão + worksheet.column_dimensions['h'].width = 25 #data de emissão + worksheet.column_dimensions['i'].width = 25 #data de emissão + worksheet.column_dimensions['j'].width = 25 #data de emissão + + + #cabecario relação de pagamentos - outro servicoes de terceiros + worksheet.merge_cells('A1:J2') + if nomeSheet == "diarias": + worksheet['A1'] = f'R E L A Ç Ã O D E P A G A M E N T O S - DIÁRIAS' + elif nomeSheet == "pessoaFisica": + worksheet['A1'] = f'R E L A Ç Ã O D E P A G A M E N T O S - OUTROS SERVIÇOS DE TERCEIROS - PF' + elif nomeSheet == "pessoaJuridica": + worksheet['A1'] = f'R E L A Ç Ã O D E P A G A M E N T O S - OUTROS SERVIÇOS DE TERCEIROS - PESSOA JURÍDICA' + elif nomeSheet == "passagenDespLocomo": + worksheet['A1'] = f'R E L A Ç Ã O D E P A G A M E N T O S - PASSAGENS E DESPESAS COM LOCOMOÇÃO' + elif nomeSheet == "outrosServiçosTerceiros": + worksheet['A1'] = f'R E L A Ç Ã O D E P A G A M E N T O S - O U T R O S S E R V I Ç O S D E T E R C E I R O S - C E L E T I S T A S' + elif nomeSheet == "auxilioEstudante": + worksheet['A1'] = f'R E L A Ç Ã O D E P A G A M E N T O S - AUXÍLIO FINANCEIRO A ESTUDANTE' + elif nomeSheet == "bolsaExtensao": + worksheet['A1'] = f'R E L A Ç Ã O D E P A G A M E N T O S - BOLSA DE EXTENSÃO' + elif nomeSheet == "estagiario": + worksheet['A1'] = f'R E L A Ç Ã O D E P A G A M E N T O S - ESTAGIÁRIO' + elif nomeSheet == "custosIndiretos": + worksheet['A1'] = f'R E L A Ç Ã O D E P A G A M E N T O S - CUSTOS INDIRETOS - FUB' + elif nomeSheet == "materialDeConsumo": + worksheet['A1'] = f'R E L A Ç Ã O D E P A G A M E N T O S - MATERIAL DE CONSUMO' + elif nomeSheet == "equipamentoMaterialPermanente": + worksheet['A1'] = f'R E L A Ç Ã O D E P A G A M E N T O S - EQUIPAMENTO E MATERIAL PERMANENTE' + + + worksheet['A1'].font = Font(name="Arial", size=12, color="FFFFFF",bold=True) + worksheet['A1'].alignment = Alignment(horizontal="center",vertical="center") + worksheet['A1'].fill = PatternFill(start_color=azul_claro, end_color=azul_claro,fill_type = "solid") + + worksheet.merge_cells('A3:F3') + worksheet['A3'] = "='Receita x Despesa'!A3:J3" + worksheet['A3'].font = Font(name="Arial", size=12, color="000000") + worksheet['A3'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet.merge_cells('A4:F4') + worksheet['A4'] = "='Receita x Despesa'!A4:J4" + worksheet['A4'].font = Font(name="Arial", size=12, color="000000") + worksheet['A4'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet.merge_cells('A5:F5') + worksheet['A5'] = "='Receita x Despesa'!A5:J5" + worksheet['A5'].font = Font(name="Arial", size=12, color="000000") + worksheet['A5'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet.merge_cells('A6:F6') + worksheet['A6'] = "='Receita x Despesa'!A6:J6" + worksheet['A6'].font = Font(name="Arial", size=12, color="000000") + worksheet['A6'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet.merge_cells('A7:F7') + worksheet['A7'] = "='Receita x Despesa'!A7:J7" + worksheet['A7'].font = Font(name="Arial", size=12, color="000000") + worksheet['A7'].alignment = Alignment(horizontal="left",vertical="center") + + #variavel + + input2=f'rowStyle{nomeVariavel}' + + + #colunas azul cabecario + locals()[input2] = NamedStyle(name=f'{input2}') + locals()[input2].font = Font(name="Arial", size=12, color="FFFFFF",bold=True) + locals()[input2].fill = openpyxl.styles.PatternFill(start_color=azul_claro, end_color=azul_claro, fill_type='solid') + locals()[input2].alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + locals()[input2].border = Border(top=Side(border_style="medium") ,bottom=Side(border_style="thin") ) + locals()[input2].height = 20 + linha_number = 9 + for row in worksheet.iter_rows(min_row=linha_number, max_row=linha_number, min_col=1, max_col=10): + for cell in row: + cell.style = locals()[input2] + if cell.column == 10: + cell.border = Border(top=Side(border_style="medium") ,bottom=Side(border_style="thin"), right=Side(border_style="medium") ) + + valores = ["ITEM","NOME","CNPJ/CPF",'ESPECIFICAÇÃO DA DESPESA','DESCRIÇÃO',"Nº DO RECIBO OU EQUIVALENTE","DATA DE EMISSÃO",'CHEQUE / ORDEM BANCÁRIA','DATA DE PGTO','Valor'] + col = 1 + for a,b in enumerate(valores): + worksheet.cell(row=linha_number, column=col, value=b) + col = col + 1 + + + #Aumentar a altura das celulas + for row in worksheet.iter_rows(min_row=10, max_row=size, min_col=1, max_col=10): + worksheet.row_dimensions[row[0].row].height = 60 + input3 = f'customNumber{nomeVariavel}' + + # MASCARA R$ + + locals()[input3] = NamedStyle(name=f'{input3}') + locals()[input3].number_format = 'R$ #,##0.00' + locals()[input3].font = Font(name="Arial", size=12, color="000000") + locals()[input3].alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + + #estilocinzasimcinzanao + value_to_stop = size + start_row = 10 +# + for row in range(start_row,size+1): + cell = worksheet[f'J{row}'] + cell.style = locals()[input3] + + for rows in worksheet.iter_rows(min_row=10, max_row=size, min_col=1, max_col=10): + for cell in rows: + if cell.row % 2: + cell.fill = PatternFill(start_color=cinza, end_color=cinza, + fill_type = "solid") + if cell.column == 10: + cell.font = Font(name="Arial", size=12, color="000000") + cell.alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,right =Side(border_style="medium") ,bottom=Side(border_style="hair") ) + else: + cell.font = Font(name="Arial", size=12, color="000000") + cell.alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,right =Side(border_style="hair") ,bottom=Side(border_style="hair") ) + + + #subtotal + stringAfinarCelula =size+2 + worksheet.row_dimensions[size+2].height = 6 + celulas_mergidas_subtotal = f"A{size+2}:I{size+2}" + worksheet.merge_cells(celulas_mergidas_subtotal) + left_celula_cell = f"A{size+2}" + top_left_cell = worksheet[left_celula_cell] + top_left_cell.value = "Sub Total1" + top_left_cell.fill = PatternFill(start_color=cinza, end_color=cinza,fill_type = "solid") + top_left_cell.font = Font(name="Arial", size=12, color="000000",bold=True) + top_left_cell.alignment = Alignment(horizontal="center",vertical="center") + top_left_cell.border = Border(top=Side(border_style="thin") ,left = Side(border_style="medium") ,right =Side(border_style="thin") ,bottom=Side(border_style="medium") ) + + worksheet.row_dimensions[size+2].height = 56.25 + + # FORMULATOTAL + formula = f"=SUM(J10:J{size})" + celula = f'J{size+2}' + worksheet[celula] = formula + worksheet[celula].fill = PatternFill(start_color=cinza, end_color=cinza,fill_type = "solid") + worksheet[celula].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet[celula].border = Border(top=Side(border_style="thin") ,left = Side(border_style="thin") ,right =Side(border_style="medium") ,bottom=Side(border_style="medium") ) + worksheet[celula].number_format = 'R$ #,##0.00' + #restituições creditadas + restituicoes = size + 3 + celula_restituicoes=f'A{restituicoes}' + worksheet[celula_restituicoes].value = "RESTITUIÇÕES CREDITADAS" + worksheet[celula_restituicoes].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet.row_dimensions[restituicoes].height = 30 + + + input4 = f'row_style_diaria_append{nomeVariavel}' + #estilo colunas restitucoes creditadas + locals()[input4] = NamedStyle(name=f'{input4}') + locals()[input4].font = Font(name="Arial", size=12, color="FFFFFF",bold=True) + locals()[input4].fill = openpyxl.styles.PatternFill(start_color=azul_claro, end_color=azul_claro, fill_type='solid') + locals()[input4].alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + locals()[input4].height = 30 + locals()[input4].border = Border(top=Side(border_style="medium") ,bottom=Side(border_style="medium") ) + + + row_number = size + 4 + + for column in range(1, 11): + cell = worksheet.cell(row=row_number, column=column) + cell.style = locals()[input4] + if cell.column == 10: + cell.border = Border(top=Side(border_style="medium") ,right =Side(border_style="medium") ,bottom=Side(border_style="medium") ) + + + + values = ["Item","Restituidor","CNPJ/CPF",'Descrição',"Cheque equivalente","Data do Cheque",'Nº do Depósito','Data da Devolução','Valor'] + coluna = 1 + for a,b in enumerate(values): + worksheet.cell(row=row_number, column=coluna, value=b) + if coluna == 4: + coluna = coluna + 1 + coluna = coluna + 1 + + + merge_formula = f'D{row_number}:E{row_number}' + worksheet.merge_cells(merge_formula) + + + #subtotal2 + sub_total2_row = size + 5 + subtotal_merge_cells= f'A{sub_total2_row}:I{sub_total2_row}' + worksheet.merge_cells(subtotal_merge_cells) + top_left_subtotal2_cell_formula = f'A{sub_total2_row}' + top_left_subtotal2_cell = worksheet[top_left_subtotal2_cell_formula] + top_left_subtotal2_cell.value = "Sub Total 2" + top_left_subtotal2_cell.fill = PatternFill(start_color=cinza_escuro, end_color=cinza_escuro,fill_type = "solid") + top_left_subtotal2_cell.font = Font(name="Arial", size=12, color="000000",bold=True) + top_left_subtotal2_cell.alignment = Alignment(horizontal="center",vertical="center") + top_left_subtotal2_cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="medium") ,right =Side(border_style="hair") ,bottom=Side(border_style="medium") ) + + sub_formula_row_celula = f'J{sub_total2_row}' + worksheet[sub_formula_row_celula].fill = PatternFill(start_color=cinza_escuro, end_color=cinza_escuro,fill_type = "solid") + worksheet[sub_formula_row_celula].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet[sub_formula_row_celula].number_format = 'R$ #,##0.00' + worksheet[sub_formula_row_celula].border = Border(top=Side(border_style="thin") ,left = Side(border_style="thin") ,right =Side(border_style="medium") ,bottom=Side(border_style="medium") ) + + #total1-2 + total12_row = size + 6 + total12_merge_cells = f'A{total12_row}:I{total12_row}' + worksheet.merge_cells(total12_merge_cells) + top_left_total12_cell_formula = f'A{total12_row}' + top_left_total12_cell = worksheet[top_left_total12_cell_formula] + top_left_total12_cell.value = "Total(1-2)" + top_left_total12_cell.fill = PatternFill(start_color=azul_claro, end_color=azul_claro,fill_type = "solid") + top_left_total12_cell.font = Font(name="Arial", size=12, color="000000",bold=True) + top_left_total12_cell.alignment = Alignment(horizontal="center",vertical="center") + top_left_total12_cell.border = Border(top=Side(border_style="medium") ,left = Side(border_style="medium") ,bottom=Side(border_style="medium") ) + + + #total_formula + total_formula_row = size + 6 + total_formulaa = f'=J{size}' + total_formula_row_celula = f'J{total_formula_row}' + worksheet[total_formula_row_celula].fill = PatternFill(start_color=azul_claro, end_color=azul_claro,fill_type = "solid") + worksheet[total_formula_row_celula].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet[total_formula_row_celula].number_format = 'R$ #,##0.00' + worksheet[total_formula_row_celula].border = Border(top=Side(border_style="medium") ,bottom=Side(border_style="medium"),right=Side(border_style="medium") ) + + worksheet.row_dimensions[total_formula_row].height = 30 + worksheet[total_formula_row_celula] = total_formulaa + + + #brasilia + brasilia_row = size + 7 + brasilia_formula = f"='Receita x Despesa'!A42:J42" + brasilia_merge_cells = f'A{brasilia_row}:I{brasilia_row}' + worksheet.merge_cells(brasilia_merge_cells) + top_left_brasilia_cell_formula = f'A{brasilia_row}' + top_left_brasilia_cell = worksheet[top_left_brasilia_cell_formula] + top_left_brasilia_cell.value = brasilia_formula + top_left_brasilia_cell.alignment = Alignment(horizontal="center",vertical="center") + + #DiretorFinanceiro + diretor_row = size + 8 + diretor_cargo_row = size + 9 + diretor_cpf_row = size + 10 + diretor_nome_formula = f"='Receita x Despesa'!A45" + diretor_cargo_formula = f"='Receita x Despesa'!A46" + diretor_cpf_formula = f"='Receita x Despesa'!A47" + diretor_merge_cells = f'A{diretor_row}:D{diretor_row}' + diretor_cargo_merge_cells = f'A{diretor_cargo_row}:D{diretor_cargo_row}' + diretor_cpf_merge_cells = f'A{diretor_cpf_row}:D{diretor_cpf_row}' + worksheet.merge_cells(diretor_merge_cells) + worksheet.merge_cells(diretor_cargo_merge_cells) + worksheet.merge_cells(diretor_cpf_merge_cells) + top_left_diretor_cell_formula = f'A{diretor_row}' + top_left_diretor_cell_cargo_formula = f'A{diretor_cargo_row}' + top_left_diretor_cell_cpf_formula = f'A{diretor_cpf_row}' + top_left_diretor_cell = worksheet[top_left_diretor_cell_formula] + top_left_diretor_cell_cargo_formula = worksheet[top_left_diretor_cell_cargo_formula] + top_left_diretor_cell_cpf_formula = worksheet[top_left_diretor_cell_cpf_formula] + top_left_diretor_cell.value = diretor_nome_formula + top_left_diretor_cell_cargo_formula.value = diretor_cargo_formula + top_left_diretor_cell_cpf_formula.value = diretor_cpf_formula + top_left_diretor_cell.alignment = Alignment(horizontal="center",vertical="center") + top_left_diretor_cell.font = Font(bold=True) + top_left_diretor_cell_cargo_formula.alignment = Alignment(horizontal="center",vertical="center") + top_left_diretor_cell_cpf_formula.alignment = Alignment(horizontal="center",vertical="center") + #Coordenadora + coordenadora_row = size + 8 + coordenadora_cargo_row = size + 9 + coordenadora_cpf_row = size + 10 + coordenadora_nome_formula = f"='Receita x Despesa'!H45" + coordenadora_cargo_formula = f"='Receita x Despesa'!H46" + coordenadora_cpf_formula = f"='Receita x Despesa'!H47" + coordenadora_merge_cells = f'F{coordenadora_row}:J{coordenadora_row}' + coordenadora_cargo_merge_cells = f'F{coordenadora_cargo_row}:J{coordenadora_cargo_row}' + coordenadora_cpf_merge_cells = f'F{coordenadora_cpf_row}:J{coordenadora_cpf_row}' + worksheet.merge_cells(coordenadora_merge_cells) + worksheet.merge_cells(coordenadora_cargo_merge_cells) + worksheet.merge_cells(coordenadora_cpf_merge_cells) + top_left_coordenadora_cell_formula = f'F{coordenadora_row}' + top_left_coordenadora_cell_cargo_formula = f'F{coordenadora_cargo_row}' + top_left_coordenadora_cell_cpf_formula = f'F{coordenadora_cpf_row}' + top_left_coordenadora_cell = worksheet[top_left_coordenadora_cell_formula] + top_left_coordenadora_cell_cargo_formula = worksheet[top_left_coordenadora_cell_cargo_formula] + top_left_coordenadora_cell_cpf_formula = worksheet[top_left_coordenadora_cell_cpf_formula] + top_left_coordenadora_cell.value = coordenadora_nome_formula + top_left_coordenadora_cell_cargo_formula.value = coordenadora_cargo_formula + top_left_coordenadora_cell_cpf_formula.value = coordenadora_cpf_formula + top_left_coordenadora_cell.alignment = Alignment(horizontal="center",vertical="center") + top_left_coordenadora_cell.font= Font(bold = True) + top_left_coordenadora_cell_cargo_formula.alignment = Alignment(horizontal="center",vertical="center") + top_left_coordenadora_cell_cpf_formula.alignment = Alignment(horizontal="center",vertical="center") + + + # borda = Border(right=Side(border_style="medium")) + # worksheet.sheet_view.showGridLines = False + # # + # for row in worksheet.iter_rows(min_row=1, max_row=coordenadora_cpf_row+1,min_col=10,max_col=10): + # for cell in row: + # cell.border = borda + + + + for row in worksheet.iter_rows(min_row=coordenadora_cpf_row+1, max_row=coordenadora_cpf_row+1,min_col=1,max_col=10): + for cell in row: + if cell.column == 10: + cell.border = Border(top=Side(border_style="none") ,left = Side(border_style="none") ,right =Side(border_style="medium") ,bottom=Side(border_style="medium") ) + else: + cell.border = Border(top=Side(border_style="none") ,left = Side(border_style="none") ,right =Side(border_style="none") ,bottom=Side(border_style="medium") ) + + workbook.save(tabela) + workbook.close() + +def estilo_conciliacoes_bancaria(tabela,tamanho,tamanho2): + + + caminho = pegar_caminho(tabela) + workbook = openpyxl.load_workbook(caminho) + worksheet = workbook['Conciliação Bancária'] + + + size = tamanho + 16 + #worksheet.row_dimensions[27].height = 50 + cinza = "d9d9d9" + cinza_escuro = "bfbfbf" + azul = "336394" + azul_claro = '1c8cbc' + + borda = Border(right=Side(border_style="medium")) + worksheet.sheet_view.showGridLines = False + # + + + + worksheet.column_dimensions['a'].width = 25 + worksheet.column_dimensions['b'].width = 25 + worksheet.column_dimensions['c'].width = 35 + worksheet.column_dimensions['d'].width = 35 + worksheet.column_dimensions['e'].width = 20 + worksheet.column_dimensions['f'].width = 20 + + + #cabecario relação de pagamentos - outro servicoes de terceiros + worksheet.merge_cells('A1:F2') + worksheet['A1'] = f'C O N C I L I A Ç Ã O B A N C Á R I A' + worksheet['A1'].font = Font(name="Arial", size=12, color="FFFFFF",bold=True) + worksheet['A1'].alignment = Alignment(horizontal="center",vertical="center") + worksheet['A1'].fill = PatternFill(start_color=azul_claro, end_color=azul_claro,fill_type = "solid") + + worksheet.merge_cells('A3:F3') + worksheet['A3'] = "='Receita x Despesa'!A3:J3" + worksheet['A3'].font = Font(name="Arial", size=12, color="000000") + worksheet['A3'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet.merge_cells('A4:F4') + worksheet['A4'] = "='Receita x Despesa'!A4:J4" + worksheet['A4'].font = Font(name="Arial", size=12, color="000000") + worksheet['A4'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet.merge_cells('A5:F5') + worksheet['A5'] = "='Receita x Despesa'!A5:J5" + worksheet['A5'].font = Font(name="Arial", size=12, color="000000") + worksheet['A5'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet.merge_cells('A6:F6') + worksheet['A6'] = "='Receita x Despesa'!A6:J6" + worksheet['A6'].font = Font(name="Arial", size=12, color="000000") + worksheet['A6'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet.merge_cells('A7:F7') + worksheet['A7'] = "='Receita x Despesa'!A7:J7" + worksheet['A7'].font = Font(name="Arial", size=12, color="000000") + worksheet['A7'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet.merge_cells('A9:F9') + worksheet['A9'] = '1.Saldo conforme extratos bancários na data final do período' + worksheet['A9'].font = Font(name="Arial", size=12, color="FFFFFF",bold=True) + worksheet['A9'].alignment = Alignment(horizontal="left",vertical="center") + worksheet['A9'].fill = PatternFill(start_color=azul_claro, end_color=azul_claro,fill_type = "solid") + + worksheet.merge_cells('A10:E10') + worksheet['A10'] = 'Saldo de Conta Corrente(R$)' + worksheet['A10'].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet['A10'].alignment = Alignment(horizontal="right",vertical="center") + + worksheet.merge_cells('A11:E11') + worksheet['A11'] = 'Saldo de Aplicações Financeiras(R$)' + worksheet['A11'].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet['A11'].alignment = Alignment(horizontal="right",vertical="center") + + worksheet.merge_cells('A13:F13') + worksheet['A13'] = '2. Restituições não creditadas pelo banco até a data final do período' + worksheet['A13'].font = Font(name="Arial", size=12, color="FFFFFF",bold=True) + worksheet['A13'].alignment = Alignment(horizontal="left",vertical="center") + worksheet['A13'].fill = PatternFill(start_color=azul_claro, end_color=azul_claro,fill_type = "solid") + + for i in range(15,size): + sttring = f"D{i}:F{i}" + worksheet.merge_cells(sttring) + + for i in range(size+3,size+3+tamanho2): + sttring = f"D{i}:F{i}" + worksheet.merge_cells(sttring) + + custom_number_format_conciliacoes = [] + # MASCARA R$ + if custom_number_format_conciliacoes!= False: + custom_number_format_conciliacoes = NamedStyle(name='custom_number_format_conciliacoes') + custom_number_format_conciliacoes.number_format = 'R$ #,##0.00' + custom_number_format_conciliacoes.font = Font(name="Arial", size=12, color="000000") + custom_number_format_conciliacoes.alignment = Alignment(horizontal="general",vertical="bottom",wrap_text=True) + + #stylecinza + start_row = 15 + for row in range(start_row,size+1): + cell = worksheet[f'B{row}'] + cell.style = custom_number_format_conciliacoes + + for rows in worksheet.iter_rows(min_row=15, max_row=size, min_col=1, max_col=6): + for cell in rows: + if cell.row % 2: + cell.fill = PatternFill(start_color=cinza, end_color=cinza, + fill_type = "solid") + cell.font = Font(name="Arial", size=12, color="000000") + cell.alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + + + row_number = 15 + values = ["Data","Valor(R$)","Documento",'Descrição'] + coluna = 1 + for a,b in enumerate(values): + worksheet.cell(row=row_number, column=coluna, value=b) + + coluna = coluna + 1 + + # FORMULATOTAL + formula = f"=SUM(B16:B{size-1})" + celula = f'B{size}' + worksheet[celula] = formula + worksheet[celula].fill = PatternFill(start_color=cinza_escuro, end_color=cinza_escuro,fill_type = "solid") + worksheet[celula].font = Font(name="Arial", size=12, color="000000",bold=True) + #Total + celula_total = F'A{size}' + worksheet[celula_total] = f'TOTAL' + worksheet[celula_total].fill = PatternFill(start_color=cinza_escuro, end_color=cinza_escuro,fill_type = "solid") + worksheet[celula_total].font = Font(name="Arial", size=12, color="000000",bold=True) + #'3. Restituições não creditadas pelo banco até a data final do período' + string_reituicoes_creditadas = f'A{size+2}:F{size+2}' + row_creditadas = f'A{size+2}' + worksheet.merge_cells(string_reituicoes_creditadas) + + worksheet[row_creditadas] = '3. Restituições creditadas pelo banco até a data final do período' + worksheet[row_creditadas].font = Font(name="Arial", size=12, color="FFFFFF",bold=True) + worksheet[row_creditadas].alignment = Alignment(horizontal="left",vertical="center") + worksheet[row_creditadas].fill = PatternFill(start_color=azul_claro, end_color=azul_claro,fill_type = "solid") + + #data valor documento descrição + row_number = size+3 + values = ["Data","Valor(R$)","Documento",'Descrição'] + coluna = 1 + for a,b in enumerate(values): + worksheet.cell(row=row_number, column=coluna, value=b) + coluna = coluna + 1 + + for rows in worksheet.iter_rows(min_row=15, max_row=15, min_col=1, max_col=6): + for cell in rows: + cell.font = Font(name="Arial", size=12, color="000000",bold=True) + for rows in worksheet.iter_rows(min_row=row_number, max_row=row_number, min_col=1, max_col=6): + for cell in rows: + cell.font = Font(name="Arial", size=12, color="000000",bold=True) + + + + for row in range(size+4,size+4+tamanho2): + cell = worksheet[f'B{row}'] + cell.style = custom_number_format_conciliacoes + + for rows in worksheet.iter_rows(min_row=size+3, max_row=size+3+tamanho, min_col=1, max_col=6): + for cell in rows: + if cell.row % 2: + cell.fill = PatternFill(start_color=cinza, end_color=cinza, + fill_type = "solid") + cell.font = Font(name="Arial", size=12, color="000000") + cell.alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + if cell.column == 6: + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,right =Side(border_style="medium") ,bottom=Side(border_style="hair") ) + + + # FORMULATOTALrestituição + formula = f"=SUM(B{size+4}:B{size+tamanho2+3})" + celula = f'B{size+tamanho2+4}' + worksheet[celula] = formula + worksheet[celula].fill = PatternFill(start_color=cinza_escuro, end_color=cinza_escuro,fill_type = "solid") + worksheet[celula].font = Font(name="Arial", size=12, color="000000",bold=True) + #Total + celula_total = F'A{size+tamanho2+4}' + worksheet[celula_total] = f'TOTAL' + worksheet[celula_total].fill = PatternFill(start_color=cinza_escuro, end_color=cinza_escuro,fill_type = "solid") + worksheet[celula_total].font = Font(name="Arial", size=12, color="000000",bold=True) + #Saldo disponível p/ período seguinte (1 +2 - 3) + string_saldo_disponivel = f'A{size+3+tamanho2+3}:D{size+3+tamanho2+3}' + celula_string_saldo = f'A{size+tamanho2+6}' + worksheet[celula_string_saldo].fill = PatternFill(start_color=cinza_escuro, end_color=cinza_escuro,fill_type = "solid") + worksheet.merge_cells(string_saldo_disponivel) + worksheet[celula_string_saldo]= f'Saldo disponível p/ período seguinte (1 + 2 - 3)' + #total saldo diposnivel + string_merge_saldo_disponivel = f'E{size+3+tamanho2+3}:F{size+3+tamanho2+3}' + celula_string_total = f'E{size+tamanho2+6}' + worksheet.merge_cells(string_merge_saldo_disponivel) + saldodiposnivelformat_conciliacoes = NamedStyle(name='saldodiposnivelformat_conciliacoes') + saldodiposnivelformat_conciliacoes.number_format = 'R$ #,##0.00' + saldodiposnivelformat_conciliacoes.font = Font(name="Arial", size=12, color="000000") + saldodiposnivelformat_conciliacoes.alignment = Alignment(horizontal="general",vertical="bottom",wrap_text=True) + saldodiposnivelformat_conciliacoes.fill = PatternFill(start_color=cinza_escuro, end_color=cinza_escuro,fill_type = "solid") + celular = worksheet[celula_string_total] + celular.style = saldodiposnivelformat_conciliacoes + celular.value = f'=F10+F11+B{size} -B{size+tamanho2+4}' + + #brasilia + brasilia_row = size + tamanho2+ 8 + brasilia_formula = f"='Receita x Despesa'!A42:F42" + brasilia_merge_cells = f'A{brasilia_row}:F{brasilia_row}' + worksheet.merge_cells(brasilia_merge_cells) + top_left_brasilia_cell_formula = f'A{brasilia_row}' + top_left_brasilia_cell = worksheet[top_left_brasilia_cell_formula] + top_left_brasilia_cell.value = brasilia_formula + top_left_brasilia_cell.alignment = Alignment(horizontal="center",vertical="center") + + # #DiretorFinanceiro + diretor_row = size + 10 + tamanho2 + diretor_cargo_row = size + 11 + tamanho2 + diretor_cpf_row = size + 12 + tamanho2 + diretor_nome_formula = f"='Receita x Despesa'!A45" + diretor_cargo_formula = f"='Receita x Despesa'!A46" + diretor_cpf_formula = f"='Receita x Despesa'!A47" + diretor_merge_cells = f'A{diretor_row}:B{diretor_row}' + diretor_cargo_merge_cells = f'A{diretor_cargo_row}:B{diretor_cargo_row}' + diretor_cpf_merge_cells = f'A{diretor_cpf_row}:B{diretor_cpf_row}' + worksheet.merge_cells(diretor_merge_cells) + worksheet.merge_cells(diretor_cargo_merge_cells) + worksheet.merge_cells(diretor_cpf_merge_cells) + top_left_diretor_cell_formula = f'A{diretor_row}' + top_left_diretor_cell_cargo_formula = f'A{diretor_cargo_row}' + top_left_diretor_cell_cpf_formula = f'A{diretor_cpf_row}' + top_left_diretor_cell = worksheet[top_left_diretor_cell_formula] + top_left_diretor_cell_cargo_formula = worksheet[top_left_diretor_cell_cargo_formula] + top_left_diretor_cell_cpf_formula = worksheet[top_left_diretor_cell_cpf_formula] + top_left_diretor_cell.value = diretor_nome_formula + top_left_diretor_cell_cargo_formula.value = diretor_cargo_formula + top_left_diretor_cell_cpf_formula.value = diretor_cpf_formula + top_left_diretor_cell.alignment = Alignment(horizontal="center",vertical="center") + top_left_diretor_cell.font = Font(bold=True) + top_left_diretor_cell_cargo_formula.alignment = Alignment(horizontal="center",vertical="center") + top_left_diretor_cell_cpf_formula.alignment = Alignment(horizontal="center",vertical="center") + #Coordenadora + coordenadora_row = size + tamanho2 + 10 + coordenadora_cargo_row = size + 11 + tamanho2 + coordenadora_cpf_row = size + 12+ tamanho2 + coordenadora_nome_formula = f"='Receita x Despesa'!H45" + coordenadora_cargo_formula = f"='Receita x Despesa'!H46" + coordenadora_cpf_formula = f"='Receita x Despesa'!H47" + coordenadora_merge_cells = f'D{coordenadora_row}:F{coordenadora_row}' + coordenadora_cargo_merge_cells = f'D{coordenadora_cargo_row}:F{coordenadora_cargo_row}' + coordenadora_cpf_merge_cells = f'D{coordenadora_cpf_row}:F{coordenadora_cpf_row}' + worksheet.merge_cells(coordenadora_merge_cells) + worksheet.merge_cells(coordenadora_cargo_merge_cells) + worksheet.merge_cells(coordenadora_cpf_merge_cells) + top_left_coordenadora_cell_formula = f'D{coordenadora_row}' + top_left_coordenadora_cell_cargo_formula = f'D{coordenadora_cargo_row}' + top_left_coordenadora_cell_cpf_formula = f'D{coordenadora_cpf_row}' + top_left_coordenadora_cell = worksheet[top_left_coordenadora_cell_formula] + top_left_coordenadora_cell_cargo_formula = worksheet[top_left_coordenadora_cell_cargo_formula] + top_left_coordenadora_cell_cpf_formula = worksheet[top_left_coordenadora_cell_cpf_formula] + top_left_coordenadora_cell.value = coordenadora_nome_formula + top_left_coordenadora_cell_cargo_formula.value = coordenadora_cargo_formula + top_left_coordenadora_cell_cpf_formula.value = coordenadora_cpf_formula + top_left_coordenadora_cell.alignment = Alignment(horizontal="center",vertical="center") + top_left_coordenadora_cell.border = borda + top_left_coordenadora_cell.font= Font(bold = True) + top_left_coordenadora_cell_cargo_formula.alignment = Alignment(horizontal="center",vertical="center") + top_left_coordenadora_cell_cargo_formula.border = borda + top_left_coordenadora_cell_cpf_formula.alignment = Alignment(horizontal="center",vertical="center") + top_left_coordenadora_cell_cpf_formula.border = borda + + for row in worksheet.iter_rows(min_row=1, max_row=size+11,min_col=6,max_col=6): + for cell in row: + cell.border = borda + + for row in worksheet.iter_rows(min_row=coordenadora_cpf_row+1, max_row=coordenadora_cpf_row+1,min_col=1,max_col=6): + for cell in row: + if cell.column == 6: + cell.border = Border(top=Side(border_style="none") ,left = Side(border_style="none") ,right =Side(border_style="medium") ,bottom=Side(border_style="medium") ) + else: + cell.border = Border(top=Side(border_style="none") ,left = Side(border_style="none") ,right =Side(border_style="none") ,bottom=Side(border_style="medium") ) + + workbook.save(tabela) + workbook.close() + +def estilo_rendimento_de_aplicacao(tabela,tamanho): + caminho = pegar_caminho(tabela) + workbook = openpyxl.load_workbook(caminho) + worksheet = workbook['Rendimento de Aplicação'] + + + size = tamanho + 16 + worksheet.row_dimensions[10].height = 2 + worksheet.row_dimensions[9].height = 20 + + cinza = "d9d9d9" + cinza_escuro = "bfbfbf" + azul = "336394" + azul_claro = '1c8cbc' + borda = Border(right=Side(border_style="medium")) + worksheet.sheet_view.showGridLines = False + # + for row in worksheet.iter_rows(min_row=1, max_row=size+9,min_col=8,max_col=8): + for cell in row: + cell.border = borda + + + + worksheet.column_dimensions['a'].width = 20 + worksheet.column_dimensions['b'].width = 20 + worksheet.column_dimensions['c'].width = 20 + worksheet.column_dimensions['d'].width = 20 + worksheet.column_dimensions['e'].width = 20 + worksheet.column_dimensions['f'].width = 20 + worksheet.column_dimensions['g'].width = 20 + worksheet.column_dimensions['h'].width = 20 + + + #cabecario relação de pagamentos - outro servicoes de terceiros + worksheet.merge_cells('A1:H2') + worksheet['A1'] = f'D E M O N S T R A T I V O D E R E N D I M E N T O D E A P L I C A Ç Ã O F I N A N C E I R A' + worksheet['A1'].font = Font(name="Arial", size=12, color="FFFFFF",bold=True) + worksheet['A1'].alignment = Alignment(horizontal="center",vertical="center") + worksheet['A1'].fill = PatternFill(start_color=azul_claro, end_color=azul_claro,fill_type = "solid") + + worksheet.merge_cells('A3:H3') + worksheet['A3'] = "='Receita x Despesa'!A3:J3" + worksheet['A3'].font = Font(name="Arial", size=12, color="000000") + worksheet['A3'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet.merge_cells('A4:H4') + worksheet['A4'] = "='Receita x Despesa'!A4:J4" + worksheet['A4'].font = Font(name="Arial", size=12, color="000000") + worksheet['A4'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet.merge_cells('A5:H5') + worksheet['A5'] = "='Receita x Despesa'!A5:J5" + worksheet['A5'].font = Font(name="Arial", size=12, color="000000") + worksheet['A5'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet.merge_cells('A6:H6') + worksheet['A6'] = "='Receita x Despesa'!A6:J6" + worksheet['A6'].font = Font(name="Arial", size=12, color="000000") + worksheet['A6'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet.merge_cells('A7:H7') + worksheet['A7'] = "='Receita x Despesa'!A7:J7" + worksheet['A7'].font = Font(name="Arial", size=12, color="000000") + worksheet['A7'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet.merge_cells('A9:H9') + worksheet['A9'] = 'RF Ref DI Plus Ágil - CNP JRF REF DI PLUS ÁGIL' + worksheet['A9'].font = Font(name="Arial", size=12, color="FFFFFF",bold=True) + worksheet['A9'].alignment = Alignment(horizontal="center",vertical="center") + worksheet['A9'].fill = PatternFill(start_color=azul_claro, end_color=azul_claro,fill_type = "solid") + + + + + #stylecinza + start_row = 11 + for rows in worksheet.iter_rows(min_row=start_row, max_row=13, min_col=1, max_col=8): + for cell in rows: + if cell.row % 2: + cell.fill = PatternFill(start_color=cinza_escuro, end_color=cinza_escuro, + fill_type = "solid") + cell.font = Font(name="Arial", size=12, color="000000",bold=True) + cell.alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + + + row_number = 11 + values = ["Período","Saldo Anterior","Valor Aplicado no período",'Valor Resgatado no Período','Rendimento Bruto','Imposto de Renda / IOF','Rendimento Líquido','Saldo'] + coluna = 1 + for a,b in enumerate(values): + worksheet.cell(row=row_number, column=coluna, value=b) + + coluna = coluna + 1 + + for i in range(1,9): + worksheet.merge_cells(start_row=11,end_row=13,start_column=i,end_column=i) + #BARRAS DE DADOS + start_row = 14 + for rows in worksheet.iter_rows(min_row=start_row, max_row=size, min_col=1, max_col=8): + for cell in rows: + if cell.row % 2: + cell.fill = PatternFill(start_color=cinza_escuro, end_color=cinza_escuro, + fill_type = "solid") + cell.font = Font(name="Arial", size=12, color="000000") + cell.alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + #MASCARA VERMELHO + for rows in worksheet.iter_rows(min_row=start_row, max_row=size-1, min_col=6, max_col=6): + for cell in rows: + cell.font = Font(name="Arial", size=12, color="f90000") + #MASCARANEGRITO + for rows in worksheet.iter_rows(min_row=start_row, max_row=size-1, min_col=1, max_col=1): + for cell in rows: + cell.font = Font(name="Arial", size=12, color="000000",bold=True) + #MASCARA AZUL + for rows in worksheet.iter_rows(min_row=start_row, max_row=size-1, min_col=7, max_col=7): + for cell in rows: + cell.font = Font(name="Arial", size=12, color="141fca",bold=True) + + + #barra de totais + # FORMULATOTAL + #C + formula = f"=SUM(C14:C{size-1})" + celula = f'C{size}' + worksheet[celula] = formula + worksheet[celula].fill = PatternFill(start_color=cinza_escuro, end_color=cinza_escuro,fill_type = "solid") + worksheet[celula].font = Font(name="Arial", size=12, color="000000",bold=True) + #D + formula = f"=SUM(D14:D{size-1})" + celula = f'D{size}' + worksheet[celula] = formula + worksheet[celula].fill = PatternFill(start_color=cinza_escuro, end_color=cinza_escuro,fill_type = "solid") + worksheet[celula].font = Font(name="Arial", size=12, color="000000",bold=True) + #E + formula = f"=SUM(E14:E{size-1})" + celula = f'E{size}' + worksheet[celula] = formula + worksheet[celula].fill = PatternFill(start_color=cinza_escuro, end_color=cinza_escuro,fill_type = "solid") + worksheet[celula].font = Font(name="Arial", size=12, color="000000",bold=True) + #F + formula = f"=SUM(F14:F{size-1})" + celula = f'F{size}' + worksheet[celula] = formula + worksheet[celula].fill = PatternFill(start_color=cinza_escuro, end_color=cinza_escuro,fill_type = "solid") + worksheet[celula].font = Font(name="Arial", size=12, color="000000",bold=True) + #G + formula = f"=SUM(G14:G{size-1})" + celula = f'G{size}' + worksheet[celula] = formula + worksheet[celula].fill = PatternFill(start_color=cinza_escuro, end_color=cinza_escuro,fill_type = "solid") + worksheet[celula].font = Font(name="Arial", size=12, color="000000",bold=True) + #H + formula = f"=SUM(H14:H{size-1})" + celula = f'H{size}' + worksheet[celula] = formula + worksheet[celula].fill = PatternFill(start_color=cinza_escuro, end_color=cinza_escuro,fill_type = "solid") + worksheet[celula].font = Font(name="Arial", size=12, color="000000",bold=True) + + #Total + celula_total = F'A{size}' + worksheet[celula_total] = f'TOTAL' + worksheet[celula_total].fill = PatternFill(start_color=cinza_escuro, end_color=cinza_escuro,fill_type = "solid") + worksheet[celula_total].font = Font(name="Arial", size=12, color="000000",bold=True) + + #brasilia + brasilia_row = size + 2 + brasilia_formula = f"='Receita x Despesa'!A42:F42" + brasilia_merge_cells = f'A{brasilia_row}:F{brasilia_row}' + worksheet.merge_cells(brasilia_merge_cells) + top_left_brasilia_cell_formula = f'A{brasilia_row}' + top_left_brasilia_cell = worksheet[top_left_brasilia_cell_formula] + top_left_brasilia_cell.value = brasilia_formula + top_left_brasilia_cell.alignment = Alignment(horizontal="center",vertical="center") + + # #DiretorFinanceiro + diretor_row = size + 6 + diretor_cargo_row = size + 7 + diretor_cpf_row = size + 8 + diretor_nome_formula = f"='Receita x Despesa'!A45" + diretor_cargo_formula = f"='Receita x Despesa'!A46" + diretor_cpf_formula = f"='Receita x Despesa'!A47" + diretor_merge_cells = f'A{diretor_row}:C{diretor_row}' + diretor_cargo_merge_cells = f'A{diretor_cargo_row}:C{diretor_cargo_row}' + diretor_cpf_merge_cells = f'A{diretor_cpf_row}:C{diretor_cpf_row}' + worksheet.merge_cells(diretor_merge_cells) + worksheet.merge_cells(diretor_cargo_merge_cells) + worksheet.merge_cells(diretor_cpf_merge_cells) + top_left_diretor_cell_formula = f'A{diretor_row}' + top_left_diretor_cell_cargo_formula = f'A{diretor_cargo_row}' + top_left_diretor_cell_cpf_formula = f'A{diretor_cpf_row}' + top_left_diretor_cell = worksheet[top_left_diretor_cell_formula] + top_left_diretor_cell_cargo_formula = worksheet[top_left_diretor_cell_cargo_formula] + top_left_diretor_cell_cpf_formula = worksheet[top_left_diretor_cell_cpf_formula] + top_left_diretor_cell.value = diretor_nome_formula + top_left_diretor_cell_cargo_formula.value = diretor_cargo_formula + top_left_diretor_cell_cpf_formula.value = diretor_cpf_formula + top_left_diretor_cell.alignment = Alignment(horizontal="center",vertical="center") + top_left_diretor_cell.font = Font(bold=True) + top_left_diretor_cell_cargo_formula.alignment = Alignment(horizontal="center",vertical="center") + top_left_diretor_cell_cpf_formula.alignment = Alignment(horizontal="center",vertical="center") + #Coordenadora + coordenadora_row = size + 6 + coordenadora_cargo_row = size + 7 + coordenadora_cpf_row = size + 8 + coordenadora_nome_formula = f"='Receita x Despesa'!H45" + coordenadora_cargo_formula = f"='Receita x Despesa'!H46" + coordenadora_cpf_formula = f"='Receita x Despesa'!H47" + coordenadora_merge_cells = f'E{coordenadora_row}:G{coordenadora_row}' + coordenadora_cargo_merge_cells = f'E{coordenadora_cargo_row}:G{coordenadora_cargo_row}' + coordenadora_cpf_merge_cells = f'E{coordenadora_cpf_row}:G{coordenadora_cpf_row}' + worksheet.merge_cells(coordenadora_merge_cells) + worksheet.merge_cells(coordenadora_cargo_merge_cells) + worksheet.merge_cells(coordenadora_cpf_merge_cells) + top_left_coordenadora_cell_formula = f'E{coordenadora_row}' + top_left_coordenadora_cell_cargo_formula = f'E{coordenadora_cargo_row}' + top_left_coordenadora_cell_cpf_formula = f'E{coordenadora_cpf_row}' + top_left_coordenadora_cell = worksheet[top_left_coordenadora_cell_formula] + top_left_coordenadora_cell_cargo_formula = worksheet[top_left_coordenadora_cell_cargo_formula] + top_left_coordenadora_cell_cpf_formula = worksheet[top_left_coordenadora_cell_cpf_formula] + top_left_coordenadora_cell.value = coordenadora_nome_formula + top_left_coordenadora_cell_cargo_formula.value = coordenadora_cargo_formula + top_left_coordenadora_cell_cpf_formula.value = coordenadora_cpf_formula + top_left_coordenadora_cell.alignment = Alignment(horizontal="center",vertical="center") + top_left_coordenadora_cell.font= Font(bold = True) + top_left_coordenadora_cell_cargo_formula.alignment = Alignment(horizontal="center",vertical="center") + top_left_coordenadora_cell_cpf_formula.alignment = Alignment(horizontal="center",vertical="center") + + + for row in worksheet.iter_rows(min_row=coordenadora_cpf_row+1, max_row=coordenadora_cpf_row+1,min_col=1,max_col=8): + for cell in row: + if cell.column == 4: + cell.border = Border(top=Side(border_style="none") ,left = Side(border_style="none") ,right =Side(border_style="medium") ,bottom=Side(border_style="medium") ) + else: + cell.border = Border(top=Side(border_style="none") ,left = Side(border_style="none") ,right =Side(border_style="none") ,bottom=Side(border_style="medium") ) + + + workbook.save(tabela) + workbook.close() + +def estiloRelacaoBens(tabela,tamanho,nomeVariavel,nomeTabela): + nomeVariavel = f'material' + caminho = pegar_caminho(tabela) + workbook = openpyxl.load_workbook(caminho) + worksheet = workbook[nomeTabela] + size = tamanho + 1 + cinza = "d9d9d9" + cinza_escuro = "bfbfbf" + azul = "336394" + azul_claro = '1c8cbc' + + borda = Border(right=Side(border_style="medium")) + worksheet.sheet_view.showGridLines = False + # + for row in worksheet.iter_rows(min_row=1, max_row=size+11,min_col=10,max_col=10): + for cell in row: + cell.border = borda + + + worksheet.column_dimensions['a'].width = 25 + worksheet.column_dimensions['b'].width = 25 + worksheet.column_dimensions['c'].width = 35 + worksheet.column_dimensions['d'].width = 35#descrição + worksheet.column_dimensions['e'].width = 40 #n do recibo ou qeuivalente + worksheet.column_dimensions['f'].width = 25 #data de emissão + worksheet.column_dimensions['g'].width = 25 #data de emissão + worksheet.column_dimensions['h'].width = 25 #data de emissão + worksheet.column_dimensions['i'].width = 25 #data de emissão + worksheet.column_dimensions['j'].width = 25 #data de emissão + + + #cabecario relação de pagamentos - outro servicoes de terceiros + worksheet.merge_cells('A1:J2') + worksheet['A1'] = f'RELAÇÃO DE BENS' + worksheet['A1'].font = Font(name="Arial", size=12, color="FFFFFF",bold=True) + worksheet['A1'].alignment = Alignment(horizontal="center",vertical="center") + worksheet['A1'].fill = PatternFill(start_color=azul_claro, end_color=azul_claro,fill_type = "solid") + + worksheet.merge_cells('A3:J4') + worksheet['A3'] = f'(ADQUIRIDOS, PRODUZIDOS OU CONSTRUÍDOS COM RECURSOS)' + worksheet['A3'].font = Font(name="Arial", size=12, color="FFFFFF",bold=True) + worksheet['A3'].alignment = Alignment(horizontal="center",vertical="center") + worksheet['A3'].fill = PatternFill(start_color=cinza, end_color=cinza,fill_type = "solid") + + worksheet.merge_cells('A5:F5') + worksheet['A5'] = "='Receita x Despesa'!A3:J3" + worksheet['A5'].font = Font(name="Arial", size=12, color="000000") + worksheet['A5'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet.merge_cells('A6:F6') + worksheet['A6'] = "='Receita x Despesa'!A4:J4" + worksheet['A6'].font = Font(name="Arial", size=12, color="000000") + worksheet['A6'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet.merge_cells('A7:F7') + worksheet['A7'] = "='Receita x Despesa'!A5:J5" + worksheet['A7'].font = Font(name="Arial", size=12, color="000000") + worksheet['A7'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet.merge_cells('A8:F8') + worksheet['A8'] = "='Receita x Despesa'!A6:J6" + worksheet['A8'].font = Font(name="Arial", size=12, color="000000") + worksheet['A8'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet.merge_cells('A9:F9') + worksheet['A9'] = "='Receita x Despesa'!A7:J7" + worksheet['A9'].font = Font(name="Arial", size=12, color="000000") + worksheet['A9'].alignment = Alignment(horizontal="left",vertical="center") + + #variavel + + input2=f'rowStyle{nomeVariavel}' + + borda = Border( + left=Side(border_style='thin', color='FFFFFF'), + right=Side(border_style='thin', color='FFFFFF'), + top=Side(border_style='thin', color='FFFFFF'), + bottom=Side(border_style='thin', color='FFFFFF') +) + borda2 = Border( + left=Side(border_style='hair', color='000000'), + right=Side(border_style='hair', color='000000'), + top=Side(border_style='hair', color='000000'), + bottom=Side(border_style='hair', color='000000') +) + + #colunas azul cabecario + locals()[input2] = NamedStyle(name=f'{input2}') + locals()[input2].font = Font(name="Arial", size=12, color="FFFFFF",bold=True) + locals()[input2].fill = openpyxl.styles.PatternFill(start_color=azul_claro, end_color=azul_claro, fill_type='solid') + locals()[input2].alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + locals()[input2].border = Border(top=Side(border_style="medium") ,bottom=Side(border_style="thin") ) + locals()[input2].height = 20 + linha_number = 11 + for row in worksheet.iter_rows(min_row=linha_number, max_row=linha_number, min_col=1, max_col=10): + for cell in row: + cell.style = locals()[input2] + if cell.column == 10: + cell.border = Border(left=Side(border_style="thin", color='FFFFFF') ,bottom=Side(border_style="thin", color='FFFFFF'), right=Side(border_style="medium") ) + + + cell.border = borda + +##CABECARIO + + worksheet["A11"].fill = openpyxl.styles.PatternFill(start_color=azul_claro, end_color=azul_claro, fill_type='solid') + worksheet.merge_cells("A11:A12") + worksheet["A11"] ="Nº DO ITEM" + + + worksheet["B11"].fill = openpyxl.styles.PatternFill(start_color=azul_claro, end_color=azul_claro, fill_type='solid') + worksheet.merge_cells("B11:B12") + worksheet["B11"] = "DESCRIÇÃO DO BEM" + + worksheet["C11"].fill = openpyxl.styles.PatternFill(start_color=azul_claro, end_color=azul_claro, fill_type='solid') + worksheet.merge_cells("C11:C12") + worksheet["C11"] = "NÚMERO PATRIMONIAL DO BEM" + + worksheet["D11"].fill = openpyxl.styles.PatternFill(start_color=azul_claro, end_color=azul_claro, fill_type='solid') + worksheet.merge_cells("D11:E11") + worksheet["D11"] = "DOCUMENTAÇÃO FISCAL" + + worksheet["D12"].fill = openpyxl.styles.PatternFill(start_color=cinza, end_color=cinza, fill_type='solid') + worksheet["D12"] = "DATA" + worksheet["D12"].border = borda2 + + worksheet["E12"].fill = openpyxl.styles.PatternFill(start_color=cinza, end_color=cinza, fill_type='solid') + worksheet["E12"] = "Nº " + worksheet["E12"].border = borda2 + + worksheet["F11"].fill = openpyxl.styles.PatternFill(start_color=azul_claro, end_color=azul_claro, fill_type='solid') + worksheet.merge_cells("F11:F12") + worksheet["F11"] = "LOCALIZAÇÃO" + + worksheet["G11"].fill = openpyxl.styles.PatternFill(start_color=azul_claro, end_color=azul_claro, fill_type='solid') + worksheet.merge_cells("G11:G12") + worksheet["G11"] = "QTD." + + worksheet["H11"].fill = openpyxl.styles.PatternFill(start_color=azul_claro, end_color=azul_claro, fill_type='solid') + worksheet.merge_cells("H11:I11") + worksheet["H11"] = "VALOR (R$)" + + worksheet["H12"].fill = openpyxl.styles.PatternFill(start_color=cinza, end_color=cinza, fill_type='solid') + worksheet["H12"] = "Unitário" + worksheet["H12"].border = borda2 + worksheet["I12"].fill = openpyxl.styles.PatternFill(start_color=cinza, end_color=cinza, fill_type='solid') + worksheet["I12"] = "Total" + worksheet["I12"].border = borda2 + + #Aumentar a altura das celulas + for row in worksheet.iter_rows(min_row=10, max_row=size, min_col=1, max_col=10): + worksheet.row_dimensions[row[0].row].height = 35 + input3 = f'customNumber{nomeVariavel}' + + # MASCARA R$ + + locals()[input3] = NamedStyle(name=f'{input3}') + locals()[input3].number_format = 'R$ #,##0.00' + locals()[input3].font = Font(name="Arial", size=12, color="000000") + locals()[input3].alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + + #estilocinzasimcinzanao + value_to_stop = size + start_row = 10 +# + for row in range(start_row,size+1): + cell = worksheet[f'J{row}'] + cell.style = locals()[input3] + + for rows in worksheet.iter_rows(min_row=13, max_row=size, min_col=1, max_col=10): + for cell in rows: + if cell.row % 2: + cell.fill = PatternFill(start_color=cinza, end_color=cinza, + fill_type = "solid") + if cell.column == 10: + cell.font = Font(name="Arial", size=12, color="000000") + cell.alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,right =Side(border_style="medium") ,bottom=Side(border_style="hair") ) + else: + cell.font = Font(name="Arial", size=12, color="000000") + cell.alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,right =Side(border_style="hair") ,bottom=Side(border_style="hair") ) + + + #subtotal + stringAfinarCelula =size+2 + worksheet.row_dimensions[size+2].height = 6 + celulas_mergidas_subtotal = f"A{size+2}:I{size+2}" + worksheet.merge_cells(celulas_mergidas_subtotal) + left_celula_cell = f"A{size+2}" + top_left_cell = worksheet[left_celula_cell] + top_left_cell.value = "TOTAL" + top_left_cell.fill = PatternFill(start_color=cinza, end_color=cinza,fill_type = "solid") + top_left_cell.font = Font(name="Arial", size=12, color="000000",bold=True) + top_left_cell.alignment = Alignment(horizontal="center",vertical="center") + top_left_cell.border = Border(top=Side(border_style="thin") ,left = Side(border_style="medium") ,right =Side(border_style="thin") ,bottom=Side(border_style="medium") ) + + worksheet.row_dimensions[size+2].height = 56.25 + + # FORMULATOTAL + formula = f"=SUM(J10:J{size})" + celula = f'J{size+2}' + worksheet[celula] = formula + worksheet[celula].fill = PatternFill(start_color=cinza, end_color=cinza,fill_type = "solid") + worksheet[celula].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet[celula].border = Border(top=Side(border_style="thin") ,left = Side(border_style="thin") ,right =Side(border_style="medium") ,bottom=Side(border_style="medium") ) + worksheet[celula].number_format = 'R$ #,##0.00' + + + #brasilia + brasilia_row = size + 7 + brasilia_formula = f"='Receita x Despesa'!A42:J42" + brasilia_merge_cells = f'A{brasilia_row}:I{brasilia_row}' + worksheet.merge_cells(brasilia_merge_cells) + top_left_brasilia_cell_formula = f'A{brasilia_row}' + top_left_brasilia_cell = worksheet[top_left_brasilia_cell_formula] + top_left_brasilia_cell.value = brasilia_formula + top_left_brasilia_cell.alignment = Alignment(horizontal="center",vertical="center") + + #DiretorFinanceiro + diretor_row = size + 8 + diretor_cargo_row = size + 9 + diretor_cpf_row = size + 10 + diretor_nome_formula = f"='Receita x Despesa'!A45" + diretor_cargo_formula = f"='Receita x Despesa'!A46" + diretor_cpf_formula = f"='Receita x Despesa'!A47" + diretor_merge_cells = f'A{diretor_row}:D{diretor_row}' + diretor_cargo_merge_cells = f'A{diretor_cargo_row}:D{diretor_cargo_row}' + diretor_cpf_merge_cells = f'A{diretor_cpf_row}:D{diretor_cpf_row}' + worksheet.merge_cells(diretor_merge_cells) + worksheet.merge_cells(diretor_cargo_merge_cells) + worksheet.merge_cells(diretor_cpf_merge_cells) + top_left_diretor_cell_formula = f'A{diretor_row}' + top_left_diretor_cell_cargo_formula = f'A{diretor_cargo_row}' + top_left_diretor_cell_cpf_formula = f'A{diretor_cpf_row}' + top_left_diretor_cell = worksheet[top_left_diretor_cell_formula] + top_left_diretor_cell_cargo_formula = worksheet[top_left_diretor_cell_cargo_formula] + top_left_diretor_cell_cpf_formula = worksheet[top_left_diretor_cell_cpf_formula] + top_left_diretor_cell.value = diretor_nome_formula + top_left_diretor_cell_cargo_formula.value = diretor_cargo_formula + top_left_diretor_cell_cpf_formula.value = diretor_cpf_formula + top_left_diretor_cell.alignment = Alignment(horizontal="center",vertical="center") + top_left_diretor_cell.font = Font(bold=True) + top_left_diretor_cell_cargo_formula.alignment = Alignment(horizontal="center",vertical="center") + top_left_diretor_cell_cpf_formula.alignment = Alignment(horizontal="center",vertical="center") + #Coordenadora + coordenadora_row = size + 8 + coordenadora_cargo_row = size + 9 + coordenadora_cpf_row = size + 10 + coordenadora_nome_formula = f"='Receita x Despesa'!H45" + coordenadora_cargo_formula = f"='Receita x Despesa'!H46" + coordenadora_cpf_formula = f"='Receita x Despesa'!H47" + coordenadora_merge_cells = f'F{coordenadora_row}:J{coordenadora_row}' + coordenadora_cargo_merge_cells = f'F{coordenadora_cargo_row}:J{coordenadora_cargo_row}' + coordenadora_cpf_merge_cells = f'F{coordenadora_cpf_row}:J{coordenadora_cpf_row}' + worksheet.merge_cells(coordenadora_merge_cells) + worksheet.merge_cells(coordenadora_cargo_merge_cells) + worksheet.merge_cells(coordenadora_cpf_merge_cells) + top_left_coordenadora_cell_formula = f'F{coordenadora_row}' + top_left_coordenadora_cell_cargo_formula = f'F{coordenadora_cargo_row}' + top_left_coordenadora_cell_cpf_formula = f'F{coordenadora_cpf_row}' + top_left_coordenadora_cell = worksheet[top_left_coordenadora_cell_formula] + top_left_coordenadora_cell_cargo_formula = worksheet[top_left_coordenadora_cell_cargo_formula] + top_left_coordenadora_cell_cpf_formula = worksheet[top_left_coordenadora_cell_cpf_formula] + top_left_coordenadora_cell.value = coordenadora_nome_formula + top_left_coordenadora_cell_cargo_formula.value = coordenadora_cargo_formula + top_left_coordenadora_cell_cpf_formula.value = coordenadora_cpf_formula + top_left_coordenadora_cell.alignment = Alignment(horizontal="center",vertical="center") + top_left_coordenadora_cell.font= Font(bold = True) + top_left_coordenadora_cell_cargo_formula.alignment = Alignment(horizontal="center",vertical="center") + top_left_coordenadora_cell_cpf_formula.alignment = Alignment(horizontal="center",vertical="center") + + + # borda = Border(right=Side(border_style="medium")) + # worksheet.sheet_view.showGridLines = False + # # + # for row in worksheet.iter_rows(min_row=1, max_row=coordenadora_cpf_row+1,min_col=10,max_col=10): + # for cell in row: + # cell.border = borda + + + + for row in worksheet.iter_rows(min_row=coordenadora_cpf_row+1, max_row=coordenadora_cpf_row+1,min_col=1,max_col=10): + for cell in row: + if cell.column == 10: + cell.border = Border(top=Side(border_style="none") ,left = Side(border_style="none") ,right =Side(border_style="medium") ,bottom=Side(border_style="medium") ) + else: + cell.border = Border(top=Side(border_style="none") ,left = Side(border_style="none") ,right =Side(border_style="none") ,bottom=Side(border_style="medium") ) + + worksheet["J11"].fill = openpyxl.styles.PatternFill(start_color=azul_claro, end_color=azul_claro, fill_type='solid') + worksheet.merge_cells("J11:J12") + worksheet["J11"] = "RESPONSÁVEL PELA GUARDA DO BEM" + worksheet["J11"].border = Border(left=Side(border_style="thin", color='FFFFFF') ,bottom=Side(border_style="thin", color='FFFFFF'), right=Side(border_style="medium") ) + worksheet["J11"].font = Font(name="Arial", size=12, color="FFFFFF",bold=True) + worksheet["J10"].border = Border(right =Side(border_style="medium")) + worksheet.row_dimensions[10].height = 2 + + + workbook.save(tabela) + workbook.close() + +def estilo_demonstrativoDeReceita(tabela,tamanho): + caminho = pegar_caminho(tabela) + workbook = openpyxl.load_workbook(caminho) + worksheet = workbook['Demonstrativo de Receita'] + size = tamanho + 10 + cinza = "d9d9d9" + cinza_escuro = "bfbfbf" + azul = "336394" + azul_claro = '1c8cbc' + + borda = Border(right=Side(border_style="medium")) + worksheet.sheet_view.showGridLines = False + # + for row in worksheet.iter_rows(min_row=1, max_row=size+11,min_col=4,max_col=4): + for cell in row: + cell.border = borda + + + worksheet.column_dimensions['a'].width = 35 + worksheet.column_dimensions['b'].width = 35 + worksheet.column_dimensions['c'].width = 35 + worksheet.column_dimensions['d'].width = 35#descrição + + + #cabecario relação de pagamentos - outro servicoes de terceiros + worksheet.merge_cells('A1:D2') + worksheet['A1'] = f'D E M O N S T R A T I V O D E R E C E I T A' + worksheet['A1'].font = Font(name="Arial", size=12, color="FFFFFF",bold=True) + worksheet['A1'].alignment = Alignment(horizontal="center",vertical="center") + worksheet['A1'].fill = PatternFill(start_color=azul_claro, end_color=azul_claro,fill_type = "solid") + + worksheet.merge_cells('A3:D3') + worksheet['A3'] = "='Receita x Despesa'!A3:J3" + worksheet['A3'].font = Font(name="Arial", size=12, color="000000") + worksheet['A3'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet.merge_cells('A4:D4') + worksheet['A4'] = "='Receita x Despesa'!A4:J4" + worksheet['A4'].font = Font(name="Arial", size=12, color="000000") + worksheet['A4'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet.merge_cells('A5:D5') + worksheet['A5'] = "='Receita x Despesa'!A5:J5" + worksheet['A5'].font = Font(name="Arial", size=12, color="000000") + worksheet['A5'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet.merge_cells('A6:D6') + worksheet['A6'] = "='Receita x Despesa'!A6:J6" + worksheet['A6'].font = Font(name="Arial", size=12, color="000000") + worksheet['A6'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet.merge_cells('A7:D7') + worksheet['A7'] = "='Receita x Despesa'!A7:J7" + worksheet['A7'].font = Font(name="Arial", size=12, color="000000") + worksheet['A7'].alignment = Alignment(horizontal="left",vertical="center") + + #colunas azul cabecario + row_style_demonstrativo = NamedStyle(name='row_style_demonstrativo') + row_style_demonstrativo.font = Font(name="Arial", size=12, color="FFFFFF",bold=True) + row_style_demonstrativo.fill = openpyxl.styles.PatternFill(start_color=azul_claro, end_color=azul_claro, fill_type='solid') + row_style_demonstrativo.alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + row_style_demonstrativo.border = Border(top=Side(border_style="medium") ,bottom=Side(border_style="thin") ) + row_style_demonstrativo.height = 20 + linha_number = 9 + for row in worksheet.iter_rows(min_row=linha_number, max_row=linha_number, min_col=1, max_col=4): + for cell in row: + cell.style = row_style_demonstrativo + if cell.column == 4: + cell.border = Border(top=Side(border_style="medium") ,bottom=Side(border_style="thin"), right=Side(border_style="medium") ) + + valores = ["Data de Entrada","Cod.BB_Histórico","Documento",'Valor'] + col = 1 + for a,b in enumerate(valores): + worksheet.cell(row=linha_number, column=col, value=b) + col = col + 1 + + + #Aumentar a altura das celulas + for row in worksheet.iter_rows(min_row=10, max_row=size, min_col=1, max_col=4): + worksheet.row_dimensions[row[0].row].height = 35 + + custom_number_format_demonstrativo = [] + # MASCARA R$ + if custom_number_format_demonstrativo!= False: + custom_number_format_demonstrativo = NamedStyle(name='custom_number_format_demonstrativo') + custom_number_format_demonstrativo.number_format = 'R$ #,##0.00' + custom_number_format_demonstrativo.font = Font(name="Arial", size=12, color="000000") + custom_number_format_demonstrativo.alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + + #estilocinzasimcinzanao + value_to_stop = size + start_row = 10 +# + for row in range(start_row,size+1): + cell = worksheet[f'D{row}'] + cell.style = custom_number_format_demonstrativo + + for rows in worksheet.iter_rows(min_row=10, max_row=size, min_col=1, max_col=4): + for cell in rows: + if cell.row % 2: + cell.fill = PatternFill(start_color=cinza, end_color=cinza, + fill_type = "solid") + if cell.column == 4: + cell.font = Font(name="Arial", size=12, color="000000") + cell.alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,right =Side(border_style="medium") ,bottom=Side(border_style="hair") ) + else: + cell.font = Font(name="Arial", size=12, color="000000") + cell.alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,right =Side(border_style="hair") ,bottom=Side(border_style="hair") ) + + + #subtotal + stringAfinarCelula =size+2 + worksheet.row_dimensions[size+2].height = 6 + celulas_mergidas_subtotal = f"A{size+2}:C{size+2}" + worksheet.merge_cells(celulas_mergidas_subtotal) + left_celula_cell = f"A{size+2}" + top_left_cell = worksheet[left_celula_cell] + top_left_cell.value = "Sub Total1" + top_left_cell.fill = PatternFill(start_color=cinza, end_color=cinza,fill_type = "solid") + top_left_cell.font = Font(name="Arial", size=12, color="000000",bold=True) + top_left_cell.alignment = Alignment(horizontal="center",vertical="center") + top_left_cell.border = Border(top=Side(border_style="thin") ,left = Side(border_style="medium") ,right =Side(border_style="thin") ,bottom=Side(border_style="medium") ) + + worksheet.row_dimensions[size+2].height = 56.25 + + # FORMULATOTAL + formula = f"=SUM(D10:D{size})" + celula = f'D{size+2}' + worksheet[celula] = formula + worksheet[celula].fill = PatternFill(start_color=cinza, end_color=cinza,fill_type = "solid") + worksheet[celula].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet[celula].border = Border(top=Side(border_style="thin") ,left = Side(border_style="thin") ,right =Side(border_style="medium") ,bottom=Side(border_style="medium") ) + worksheet[celula].number_format = 'R$ #,##0.00' + #restituições creditadas + restituicoes = size + 3 + celula_restituicoes=f'A{restituicoes}' + worksheet[celula_restituicoes].value = "Estorno de Mensalidades" + worksheet[celula_restituicoes].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet.row_dimensions[restituicoes].height = 30 + + #estilo colunas restitucoes creditadas + row_style_demonstrativo_append = NamedStyle(name='row_style_demonstrativo_append') + row_style_demonstrativo_append.font = Font(name="Arial", size=12, color="FFFFFF",bold=True) + row_style_demonstrativo_append.fill = openpyxl.styles.PatternFill(start_color=azul_claro, end_color=azul_claro, fill_type='solid') + row_style_demonstrativo_append.alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + row_style_demonstrativo_append.height = 30 + row_style_demonstrativo_append.border = Border(top=Side(border_style="medium") ,bottom=Side(border_style="medium") ) + + + row_number = size + 4 + + for column in range(1, 5): + cell = worksheet.cell(row=row_number, column=column) + cell.style = row_style_demonstrativo_append + if cell.column == 4: + cell.border = Border(top=Side(border_style="medium") ,right =Side(border_style="medium") ,bottom=Side(border_style="medium") ) + + + + values = ["Data de Entrada","Cod.BB_Histórico","Documento",'Valor'] + coluna = 1 + for a,b in enumerate(values): + worksheet.cell(row=row_number, column=coluna, value=b) + if coluna == 4: + coluna = coluna + 1 + coluna = coluna + 1 + + + + + + #subtotal2 + sub_total2_row = size + 5 + subtotal_merge_cells= f'A{sub_total2_row}:C{sub_total2_row}' + worksheet.merge_cells(subtotal_merge_cells) + top_left_subtotal2_cell_formula = f'A{sub_total2_row}' + top_left_subtotal2_cell = worksheet[top_left_subtotal2_cell_formula] + top_left_subtotal2_cell.value = "Sub Total 2" + top_left_subtotal2_cell.fill = PatternFill(start_color=cinza_escuro, end_color=cinza_escuro,fill_type = "solid") + top_left_subtotal2_cell.font = Font(name="Arial", size=12, color="000000",bold=True) + top_left_subtotal2_cell.alignment = Alignment(horizontal="center",vertical="center") + top_left_subtotal2_cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="medium") ,right =Side(border_style="hair") ,bottom=Side(border_style="medium") ) + + sub_formula_row_celula = f'D{sub_total2_row}' + worksheet[sub_formula_row_celula].fill = PatternFill(start_color=cinza_escuro, end_color=cinza_escuro,fill_type = "solid") + worksheet[sub_formula_row_celula].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet[sub_formula_row_celula].number_format = 'R$ #,##0.00' + worksheet[sub_formula_row_celula].border = Border(top=Side(border_style="thin") ,left = Side(border_style="thin") ,right =Side(border_style="medium") ,bottom=Side(border_style="medium") ) + + #total1-2 + total12_row = size + 6 + total12_merge_cells = f'A{total12_row}:C{total12_row}' + worksheet.merge_cells(total12_merge_cells) + top_left_total12_cell_formula = f'A{total12_row}' + top_left_total12_cell = worksheet[top_left_total12_cell_formula] + top_left_total12_cell.value = "Total(1-2)" + top_left_total12_cell.fill = PatternFill(start_color=azul_claro, end_color=azul_claro,fill_type = "solid") + top_left_total12_cell.font = Font(name="Arial", size=12, color="000000",bold=True) + top_left_total12_cell.alignment = Alignment(horizontal="center",vertical="center") + top_left_total12_cell.border = Border(top=Side(border_style="medium") ,left = Side(border_style="medium") ,bottom=Side(border_style="medium") ) + + + #total_formula + total_formula_row = size + 6 + total_formulaa = f'=D{size}' + total_formula_row_celula = f'D{total_formula_row}' + worksheet[total_formula_row_celula].fill = PatternFill(start_color=azul_claro, end_color=azul_claro,fill_type = "solid") + worksheet[total_formula_row_celula].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet[total_formula_row_celula].number_format = 'R$ #,##0.00' + worksheet[total_formula_row_celula].border = Border(top=Side(border_style="medium") ,bottom=Side(border_style="medium"),right=Side(border_style="medium") ) + worksheet.row_dimensions[total_formula_row].height = 30 + worksheet[total_formula_row_celula] = total_formulaa + + + #brasilia + brasilia_row = size + 7 + brasilia_formula = f"='Receita x Despesa'!A42:D42" + brasilia_merge_cells = f'A{brasilia_row}:D{brasilia_row}' + worksheet.merge_cells(brasilia_merge_cells) + top_left_brasilia_cell_formula = f'A{brasilia_row}' + top_left_brasilia_cell = worksheet[top_left_brasilia_cell_formula] + top_left_brasilia_cell.value = brasilia_formula + top_left_brasilia_cell.alignment = Alignment(horizontal="center",vertical="center") + + #DiretorFinanceiro + diretor_row = size + 8 + diretor_cargo_row = size + 9 + diretor_cpf_row = size + 10 + diretor_nome_formula = f"='Receita x Despesa'!A45" + diretor_cargo_formula = f"='Receita x Despesa'!A46" + diretor_cpf_formula = f"='Receita x Despesa'!A47" + diretor_merge_cells = f'A{diretor_row}:B{diretor_row}' + diretor_cargo_merge_cells = f'A{diretor_cargo_row}:B{diretor_cargo_row}' + diretor_cpf_merge_cells = f'A{diretor_cpf_row}:B{diretor_cpf_row}' + worksheet.merge_cells(diretor_merge_cells) + worksheet.merge_cells(diretor_cargo_merge_cells) + worksheet.merge_cells(diretor_cpf_merge_cells) + top_left_diretor_cell_formula = f'A{diretor_row}' + top_left_diretor_cell_cargo_formula = f'A{diretor_cargo_row}' + top_left_diretor_cell_cpf_formula = f'A{diretor_cpf_row}' + top_left_diretor_cell = worksheet[top_left_diretor_cell_formula] + top_left_diretor_cell_cargo_formula = worksheet[top_left_diretor_cell_cargo_formula] + top_left_diretor_cell_cpf_formula = worksheet[top_left_diretor_cell_cpf_formula] + top_left_diretor_cell.value = diretor_nome_formula + top_left_diretor_cell_cargo_formula.value = diretor_cargo_formula + top_left_diretor_cell_cpf_formula.value = diretor_cpf_formula + top_left_diretor_cell.alignment = Alignment(horizontal="center",vertical="center") + top_left_diretor_cell.font = Font(bold=True) + top_left_diretor_cell_cargo_formula.alignment = Alignment(horizontal="center",vertical="center") + top_left_diretor_cell_cpf_formula.alignment = Alignment(horizontal="center",vertical="center") + #Coordenadora + coordenadora_row = size + 8 + coordenadora_cargo_row = size + 9 + coordenadora_cpf_row = size + 10 + coordenadora_nome_formula = f"='Receita x Despesa'!H45" + coordenadora_cargo_formula = f"='Receita x Despesa'!H46" + coordenadora_cpf_formula = f"='Receita x Despesa'!H47" + coordenadora_merge_cells = f'C{coordenadora_row}:D{coordenadora_row}' + coordenadora_cargo_merge_cells = f'C{coordenadora_cargo_row}:D{coordenadora_cargo_row}' + coordenadora_cpf_merge_cells = f'C{coordenadora_cpf_row}:D{coordenadora_cpf_row}' + worksheet.merge_cells(coordenadora_merge_cells) + worksheet.merge_cells(coordenadora_cargo_merge_cells) + worksheet.merge_cells(coordenadora_cpf_merge_cells) + top_left_coordenadora_cell_formula = f'C{coordenadora_row}' + top_left_coordenadora_cell_cargo_formula = f'C{coordenadora_cargo_row}' + top_left_coordenadora_cell_cpf_formula = f'C{coordenadora_cpf_row}' + top_left_coordenadora_cell = worksheet[top_left_coordenadora_cell_formula] + top_left_coordenadora_cell_cargo_formula = worksheet[top_left_coordenadora_cell_cargo_formula] + top_left_coordenadora_cell_cpf_formula = worksheet[top_left_coordenadora_cell_cpf_formula] + top_left_coordenadora_cell.value = coordenadora_nome_formula + top_left_coordenadora_cell_cargo_formula.value = coordenadora_cargo_formula + top_left_coordenadora_cell_cpf_formula.value = coordenadora_cpf_formula + top_left_coordenadora_cell.alignment = Alignment(horizontal="center",vertical="center") + top_left_coordenadora_cell.font= Font(bold = True) + top_left_coordenadora_cell_cargo_formula.alignment = Alignment(horizontal="center",vertical="center") + top_left_coordenadora_cell_cpf_formula.alignment = Alignment(horizontal="center",vertical="center") + + + # borda = Border(right=Side(border_style="medium")) + # worksheet.sheet_view.showGridLines = False + # # + # for row in worksheet.iter_rows(min_row=1, max_row=coordenadora_cpf_row+1,min_col=10,max_col=4): + # for cell in row: + # cell.border = borda + + + + for row in worksheet.iter_rows(min_row=coordenadora_cpf_row+1, max_row=coordenadora_cpf_row+1,min_col=1,max_col=4): + for cell in row: + if cell.column == 8: + cell.border = Border(top=Side(border_style="none") ,left = Side(border_style="none") ,right =Side(border_style="medium") ,bottom=Side(border_style="medium") ) + else: + cell.border = Border(top=Side(border_style="none") ,left = Side(border_style="none") ,right =Side(border_style="none") ,bottom=Side(border_style="medium") ) + + workbook.save(tabela) + workbook.close() + +# def estilo_fub_fisica(tabela,tamanho): + +# # caminho = pegar_caminho(tabela) +# workbook = openpyxl.load_workbook(tabela) +# worksheet = workbook['Pessoa Fisica'] + + +# size = tamanho + 10 +# #worksheet.row_dimensions[27].height = 50 + +# cinza = "979CA8" +# azul = "336394" + + + +# for row in worksheet.iter_rows(min_row=10, max_row=size, min_col=1, max_col=10): +# worksheet.row_dimensions[row[0].row].height = 35 + +# custom_number_format_fisica = [] +# # MASCARA R$ +# if custom_number_format_fisica!= False: +# custom_number_format_fisica = NamedStyle(name='custom_number_format_fisica') +# custom_number_format_fisica.number_format = 'R$ #,##0.00' +# custom_number_format_fisica.font = Font(name="Arial", size=12, color="000000") +# custom_number_format_fisica.alignment = Alignment(horizontal="general",vertical="bottom",wrap_text=True) + +# #stylecinza + + +# value_to_stop = size +# start_row = 10 + +# for row in range(start_row,size+1): +# cell = worksheet[f'J{row}'] +# cell.style = custom_number_format_fisica + +# for rows in worksheet.iter_rows(min_row=10, max_row=size, min_col=1, max_col=10): +# for cell in rows: +# if cell.row % 2: +# cell.fill = PatternFill(start_color=cinza, end_color=cinza, +# fill_type = "solid") +# cell.font = Font(name="Arial", size=12, color="000000") +# cell.alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) +# cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,right =Side(border_style="hair") ,bottom=Side(border_style="hair") ) + + + + + +# #subtotal +# celulas_mergidas_subtotal = f"A{size}:I{size}" +# worksheet.merge_cells(celulas_mergidas_subtotal) +# left_celula_cell = f"A{size}" +# top_left_cell = worksheet[left_celula_cell] +# top_left_cell.value = "Sub Total" +# top_left_cell.fill = PatternFill(start_color=cinza, end_color=cinza,fill_type = "solid") +# top_left_cell.font = Font(name="Arial", size=12, color="000000",bold=True) +# top_left_cell.alignment = Alignment(horizontal="center",vertical="center") + + + + +# # FORMULATOTAL +# formula = f"=SUM(J10:J{size-1})" +# celula = f'J{size}' +# worksheet[celula] = formula +# worksheet[celula].fill = PatternFill(start_color=cinza, end_color=cinza,fill_type = "solid") +# worksheet[celula].font = Font(name="Arial", size=12, color="000000",bold=True) + + +# #restituições creditadas +# restituicoes = size + 1 +# celula_restituicoes=f'A{restituicoes}' +# worksheet[celula_restituicoes].value = "RESTITUIÇÕES CREDITADAS" +# worksheet[celula_restituicoes].font = Font(name="Arial", size=12, color="000000",bold=True) +# worksheet.row_dimensions[restituicoes].height = 30 + + +# #colunas azul +# row_style_fisica = NamedStyle(name='row_style_fisica') +# row_style_fisica.font = Font(name="Arial", size=12, color="FFFFFF",bold=True) +# row_style_fisica.fill = openpyxl.styles.PatternFill(start_color=azul, end_color=azul, fill_type='solid') +# row_style_fisica.alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) +# row_style_fisica.height = 30 + +# row_number = size + 2 + +# for column in range(1, 11): +# cell = worksheet.cell(row=row_number, column=column) +# cell.style = row_style_fisica + + +# values = ["Item","Restituidor","CNPJ/CPF",'Descrição',"Cheque equivalente","Data do Cheque",'Nº do Depósito','Data da Devolução','Valor'] +# coluna = 1 +# for a,b in enumerate(values): +# worksheet.cell(row=row_number, column=coluna, value=b) +# if coluna == 4: +# coluna = coluna + 1 +# coluna = coluna + 1 + + +# merge_formula = f'D{row_number}:E{row_number}' +# worksheet.merge_cells(merge_formula) + +# #subtotal2 +# sub_total2_row = size + 4 +# subtotal_merge_cells= f'A{sub_total2_row}:I{sub_total2_row}' +# worksheet.merge_cells(subtotal_merge_cells) +# top_left_subtotal2_cell_formula = f'A{sub_total2_row}' +# top_left_subtotal2_cell = worksheet[top_left_subtotal2_cell_formula] +# top_left_subtotal2_cell.value = "Sub Total 2" +# top_left_subtotal2_cell.fill = PatternFill(start_color=cinza, end_color=cinza,fill_type = "solid") +# top_left_subtotal2_cell.font = Font(name="Arial", size=12, color="000000",bold=True) +# top_left_subtotal2_cell.alignment = Alignment(horizontal="center",vertical="center") +# sub_formula_row_celula = f'J{sub_total2_row}' +# worksheet[sub_formula_row_celula].fill = PatternFill(start_color=cinza, end_color=cinza,fill_type = "solid") +# worksheet[sub_formula_row_celula].font = Font(name="Arial", size=12, color="000000",bold=True) + +# #subtotal12_Formula +# # sub_formula_row = size + 4 +# # sub_formula = f'=SOMA(J{sub_formula_row}:J{sub_formula_row})' +# # sub_formula_row_celula = f'J{sub_formula_row}' +# # worksheet[sub_formula_row_celula].fill = PatternFill(start_color=cinza, end_color=cinza,fill_type = "solid") +# # worksheet[sub_formula_row_celula] = sub_formula + + +# #total1-2 +# total12_row = size + 5 +# total12_merge_cells = f'A{total12_row}:I{total12_row}' +# worksheet.merge_cells(total12_merge_cells) +# top_left_total12_cell_formula = f'A{total12_row}' +# top_left_total12_cell = worksheet[top_left_total12_cell_formula] +# top_left_total12_cell.value = "Total(1 -2)" +# top_left_total12_cell.fill = PatternFill(start_color=azul, end_color=azul,fill_type = "solid") +# top_left_total12_cell.font = Font(name="Arial", size=12, color="000000",bold=True) +# top_left_total12_cell.alignment = Alignment(horizontal="center",vertical="center") + +# #total_formula +# total_formula_row = size + 5 +# total_formulaa = f'=J{size}' +# total_formula_row_celula = f'J{total_formula_row}' +# worksheet[total_formula_row_celula].fill = PatternFill(start_color=azul, end_color=azul,fill_type = "solid") +# worksheet[total_formula_row_celula].font = Font(name="Arial", size=12, color="000000",bold=True) +# worksheet[total_formula_row_celula].number_format = 'R$ #,##0.00' +# worksheet.row_dimensions[total_formula_row].height = 30 +# worksheet[total_formula_row_celula] = total_formulaa + +# #brasilia +# brasilia_row = size + 7 +# brasilia_formula = f"='Receita x Despesa'!A42:J42" +# brasilia_merge_cells = f'A{brasilia_row}:I{brasilia_row}' +# worksheet.merge_cells(brasilia_merge_cells) +# top_left_brasilia_cell_formula = f'A{brasilia_row}' +# top_left_brasilia_cell = worksheet[top_left_brasilia_cell_formula] +# top_left_brasilia_cell.value = brasilia_formula +# top_left_brasilia_cell.alignment = Alignment(horizontal="center",vertical="center") + +# #DiretorFinanceiro +# diretor_row = size + 8 +# diretor_cargo_row = size + 9 +# diretor_cpf_row = size + 10 +# diretor_nome_formula = f"='Receita x Despesa'!A45" +# diretor_cargo_formula = f"='Receita x Despesa'!A46" +# diretor_cpf_formula = f"='Receita x Despesa'!A47" +# diretor_merge_cells = f'A{diretor_row}:D{diretor_row}' +# diretor_cargo_merge_cells = f'A{diretor_cargo_row}:D{diretor_cargo_row}' +# diretor_cpf_merge_cells = f'A{diretor_cpf_row}:D{diretor_cpf_row}' +# worksheet.merge_cells(diretor_merge_cells) +# worksheet.merge_cells(diretor_cargo_merge_cells) +# worksheet.merge_cells(diretor_cpf_merge_cells) +# top_left_diretor_cell_formula = f'A{diretor_row}' +# top_left_diretor_cell_cargo_formula = f'A{diretor_cargo_row}' +# top_left_diretor_cell_cpf_formula = f'A{diretor_cpf_row}' +# top_left_diretor_cell = worksheet[top_left_diretor_cell_formula] +# top_left_diretor_cell_cargo_formula = worksheet[top_left_diretor_cell_cargo_formula] +# top_left_diretor_cell_cpf_formula = worksheet[top_left_diretor_cell_cpf_formula] +# top_left_diretor_cell.value = diretor_nome_formula +# top_left_diretor_cell_cargo_formula.value = diretor_cargo_formula +# top_left_diretor_cell_cpf_formula.value = diretor_cpf_formula +# top_left_diretor_cell.alignment = Alignment(horizontal="center",vertical="center") +# top_left_diretor_cell.font = Font(bold=True) +# top_left_diretor_cell_cargo_formula.alignment = Alignment(horizontal="center",vertical="center") +# top_left_diretor_cell_cpf_formula.alignment = Alignment(horizontal="center",vertical="center") +# #Coordenadora +# coordenadora_row = size + 8 +# coordenadora_cargo_row = size + 9 +# coordenadora_cpf_row = size + 10 +# coordenadora_nome_formula = f"='Receita x Despesa'!H45" +# coordenadora_cargo_formula = f"='Receita x Despesa'!H46" +# coordenadora_cpf_formula = f"='Receita x Despesa'!H47" +# coordenadora_merge_cells = f'F{coordenadora_row}:J{coordenadora_row}' +# coordenadora_cargo_merge_cells = f'F{coordenadora_cargo_row}:J{coordenadora_cargo_row}' +# coordenadora_cpf_merge_cells = f'F{coordenadora_cpf_row}:J{coordenadora_cpf_row}' +# worksheet.merge_cells(coordenadora_merge_cells) +# worksheet.merge_cells(coordenadora_cargo_merge_cells) +# worksheet.merge_cells(coordenadora_cpf_merge_cells) +# top_left_coordenadora_cell_formula = f'F{coordenadora_row}' +# top_left_coordenadora_cell_cargo_formula = f'F{coordenadora_cargo_row}' +# top_left_coordenadora_cell_cpf_formula = f'F{coordenadora_cpf_row}' +# top_left_coordenadora_cell = worksheet[top_left_coordenadora_cell_formula] +# top_left_coordenadora_cell_cargo_formula = worksheet[top_left_coordenadora_cell_cargo_formula] +# top_left_coordenadora_cell_cpf_formula = worksheet[top_left_coordenadora_cell_cpf_formula] +# top_left_coordenadora_cell.value = coordenadora_nome_formula +# top_left_coordenadora_cell_cargo_formula.value = coordenadora_cargo_formula +# top_left_coordenadora_cell_cpf_formula.value = coordenadora_cpf_formula +# top_left_coordenadora_cell.alignment = Alignment(horizontal="center",vertical="center") +# top_left_coordenadora_cell.font= Font(bold = True) +# top_left_coordenadora_cell_cargo_formula.alignment = Alignment(horizontal="center",vertical="center") +# top_left_coordenadora_cell_cpf_formula.alignment = Alignment(horizontal="center",vertical="center") + +# #nome dos indices + +# azul_claro = '1c89b8' +# row_style_fisica_cabecario = NamedStyle(name='row_style_fisica_cabecario') +# row_style_fisica_cabecario.font = Font(name="Arial", size=12, color="FFFFFF",bold=True) +# row_style_fisica_cabecario.fill = openpyxl.styles.PatternFill(start_color=azul_claro, end_color=azul_claro, fill_type='solid') +# row_style_fisica_cabecario.alignment = Alignment(horizontal="center",vertical="center",wrap_text = True) +# worksheet.row_dimensions[9].height = 50 +# worksheet.column_dimensions['b'].width = 35 +# worksheet.column_dimensions['c'].width = 20 +# worksheet.column_dimensions['d'].width = 35 +# worksheet.column_dimensions['e'].width = 60 +# worksheet.column_dimensions['f'].width = 35 +# worksheet.column_dimensions['g'].width = 30 +# worksheet.column_dimensions['h'].width = 30 +# worksheet.column_dimensions['i'].width = 30 +# worksheet.column_dimensions['j'].width = 30 +# worksheet.column_dimensions['e'].height = 20 + + +# linha_number = 9 +# # Apply the style to each cell in the row +# for cell in worksheet[linha_number]: +# cell.style = row_style_fisica_cabecario + +# valores = ["ITEM","NOME","CNPJ/CPF",'ESPECIFICAÇÃO DA DESPESA','DESCRIÇÃO',"Nº DO RECIBO OU EQUIVALENTE","DATA DE EMISSÃO",'CHEQUE / ORDEM BANCÁRIA','DATA DE PGTO','Valor'] +# col = 1 +# for a,b in enumerate(valores): +# worksheet.cell(row=linha_number, column=col, value=b) +# col = col + 1 + + +# #cabecario relação de pagamentos - outro servicoes de terceiros +# worksheet.merge_cells('A1:J2') +# worksheet['A1'] = f'R E L A Ç Ã O D E P A G A M E N T O S - O U T R O S S E R V I Ç O S T E R C E I R O S - P E S S O A F Í S I C A ' +# worksheet['A1'].font = Font(name="Arial", size=12, color="FFFFFF",bold=True) +# worksheet['A1'].alignment = Alignment(horizontal="center",vertical="center") +# worksheet['A1'].fill = PatternFill(start_color=azul_claro, end_color=azul_claro,fill_type = "solid") +# worksheet.merge_cells('A3:I3') +# worksheet['A3'] = "='Receita x Despesa'!A3:J3" +# worksheet['A3'].font = Font(name="Arial", size=12, color="000000") +# worksheet['A3'].alignment = Alignment(horizontal="left",vertical="center") + +# worksheet.merge_cells('A4:I4') +# worksheet['A4'] = "='Receita x Despesa'!A4:J4" +# worksheet['A4'].font = Font(name="Arial", size=12, color="000000") +# worksheet['A4'].alignment = Alignment(horizontal="left",vertical="center") + +# worksheet.merge_cells('A5:I5') +# worksheet['A5'] = "='Receita x Despesa'!A5:J5" +# worksheet['A5'].font = Font(name="Arial", size=12, color="000000") +# worksheet['A5'].alignment = Alignment(horizontal="left",vertical="center") + +# worksheet.merge_cells('A6:I6') +# worksheet['A6'] = "='Receita x Despesa'!A6:J6" +# worksheet['A6'].font = Font(name="Arial", size=12, color="000000") +# worksheet['A6'].alignment = Alignment(horizontal="left",vertical="center") + +# worksheet.merge_cells('A7:I7') +# worksheet['A7'] = "='Receita x Despesa'!A7:J7" +# worksheet['A7'].font = Font(name="Arial", size=12, color="000000") +# worksheet['A7'].alignment = Alignment(horizontal="left",vertical="center") + +# altura = 45 +# linha_inicio = 9 +# for row_number in range(linha_inicio, linha_inicio + tamanho+1): +# worksheet.row_dimensions[row_number].height = altura + +# workbook.save('output.xlsx') +# workbook.close() + +# def estilo_fub_juridica(tabela,tamanho): + +# caminho = pegar_caminho(tabela) +# workbook = openpyxl.load_workbook(caminho) +# worksheet = workbook['Pessoa Fisica'] + + +# size = tamanho + 10 +# #worksheet.row_dimensions[27].height = 50 + +# cinza = "979CA8" +# azul = "336394" + + + +# for row in worksheet.iter_rows(min_row=10, max_row=size, min_col=1, max_col=10): +# worksheet.row_dimensions[row[0].row].height = 35 + +# custom_number_format_juridica = [] +# # MASCARA R$ +# if custom_number_format_juridica!= False: +# custom_number_format_juridica = NamedStyle(name='custom_number_format_juridica') +# custom_number_format_juridica.number_format = 'R$ #,##0.00' +# custom_number_format_juridica.font = Font(name="Arial", size=12, color="000000") +# custom_number_format_juridica.alignment = Alignment(horizontal="general",vertical="bottom",wrap_text=True) + +# #stylecinza + + +# value_to_stop = size +# start_row = 10 +# # +# for row in range(start_row,size+1): +# cell = worksheet[f'J{row}'] +# cell.style = custom_number_format_juridica + +# for rows in worksheet.iter_rows(min_row=10, max_row=size, min_col=1, max_col=10): +# for cell in rows: +# if cell.row % 2: +# cell.fill = PatternFill(start_color=cinza, end_color=cinza, +# fill_type = "solid") +# cell.font = Font(name="Arial", size=12, color="000000") +# cell.alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) +# cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,right =Side(border_style="hair") ,bottom=Side(border_style="hair") ) + + + + + +# #subtotal +# celulas_mergidas_subtotal = f"A{size}:I{size}" +# worksheet.merge_cells(celulas_mergidas_subtotal) +# left_celula_cell = f"A{size}" +# top_left_cell = worksheet[left_celula_cell] +# top_left_cell.value = "Sub Total" +# top_left_cell.fill = PatternFill(start_color=cinza, end_color=cinza,fill_type = "solid") +# top_left_cell.font = Font(name="Arial", size=12, color="000000",bold=True) +# top_left_cell.alignment = Alignment(horizontal="center",vertical="center") + + + + +# # FORMULATOTAL +# formula = f"=SUM(J10:J{size-1})" +# celula = f'J{size}' +# worksheet[celula] = formula +# worksheet[celula].fill = PatternFill(start_color=cinza, end_color=cinza,fill_type = "solid") +# worksheet[celula].font = Font(name="Arial", size=12, color="000000",bold=True) + + +# #restituições creditadas +# restituicoes = size + 1 +# celula_restituicoes=f'A{restituicoes}' +# worksheet[celula_restituicoes].value = "RESTITUIÇÕES CREDITADAS" +# worksheet[celula_restituicoes].font = Font(name="Arial", size=12, color="000000",bold=True) +# worksheet.row_dimensions[restituicoes].height = 30 + + +# #colunas azul +# row_style_juridica = NamedStyle(name='row_style_juridica') +# row_style_juridica.font = Font(name="Arial", size=12, color="FFFFFF",bold=True) +# row_style_juridica.fill = openpyxl.styles.PatternFill(start_color=azul, end_color=azul, fill_type='solid') +# row_style_juridica.alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) +# row_style_juridica.height = 30 + +# row_number = size + 2 + +# for column in range(1, 11): +# cell = worksheet.cell(row=row_number, column=column) +# cell.style = row_style_juridica + + +# values = ["Item","Restituidor","CNPJ/CPF",'Descrição',"Cheque equivalente","Data do Cheque",'Nº do Depósito','Data da Devolução','Valor'] +# coluna = 1 +# for a,b in enumerate(values): +# worksheet.cell(row=row_number, column=coluna, value=b) +# if coluna == 4: +# coluna = coluna + 1 +# coluna = coluna + 1 + + +# merge_formula = f'D{row_number}:E{row_number}' +# worksheet.merge_cells(merge_formula) + +# #subtotal2 +# sub_total2_row = size + 4 +# subtotal_merge_cells= f'A{sub_total2_row}:I{sub_total2_row}' +# worksheet.merge_cells(subtotal_merge_cells) +# top_left_subtotal2_cell_formula = f'A{sub_total2_row}' +# top_left_subtotal2_cell = worksheet[top_left_subtotal2_cell_formula] +# top_left_subtotal2_cell.value = "Sub Total 2" +# top_left_subtotal2_cell.fill = PatternFill(start_color=cinza, end_color=cinza,fill_type = "solid") +# top_left_subtotal2_cell.font = Font(name="Arial", size=12, color="000000",bold=True) +# top_left_subtotal2_cell.alignment = Alignment(horizontal="center",vertical="center") +# sub_formula_row_celula = f'J{sub_total2_row}' +# worksheet[sub_formula_row_celula].fill = PatternFill(start_color=cinza, end_color=cinza,fill_type = "solid") +# worksheet[sub_formula_row_celula].font = Font(name="Arial", size=12, color="000000",bold=True) + +# #subtotal12_Formula +# # sub_formula_row = size + 4 +# # sub_formula = f'=SOMA(J{sub_formula_row}:J{sub_formula_row})' +# # sub_formula_row_celula = f'J{sub_formula_row}' +# # worksheet[sub_formula_row_celula].fill = PatternFill(start_color=cinza, end_color=cinza,fill_type = "solid") +# # worksheet[sub_formula_row_celula] = sub_formula + + +# #total1-2 +# total12_row = size + 5 +# total12_merge_cells = f'A{total12_row}:I{total12_row}' +# worksheet.merge_cells(total12_merge_cells) +# top_left_total12_cell_formula = f'A{total12_row}' +# top_left_total12_cell = worksheet[top_left_total12_cell_formula] +# top_left_total12_cell.value = "Total(1 -2)" +# top_left_total12_cell.fill = PatternFill(start_color=azul, end_color=azul,fill_type = "solid") +# top_left_total12_cell.font = Font(name="Arial", size=12, color="000000",bold=True) +# top_left_total12_cell.alignment = Alignment(horizontal="center",vertical="center") + +# #total_formula +# total_formula_row = size + 5 +# total_formulaa = f'=J{size}' +# total_formula_row_celula = f'J{total_formula_row}' +# worksheet[total_formula_row_celula].fill = PatternFill(start_color=azul, end_color=azul,fill_type = "solid") +# worksheet[total_formula_row_celula].font = Font(name="Arial", size=12, color="000000",bold=True) +# worksheet[total_formula_row_celula].number_format = 'R$ #,##0.00' +# worksheet.row_dimensions[total_formula_row].height = 30 +# worksheet[total_formula_row_celula] = total_formulaa + +# #brasilia +# brasilia_row = size + 7 +# brasilia_formula = f"='Receita x Despesa'!A42:J42" +# brasilia_merge_cells = f'A{brasilia_row}:I{brasilia_row}' +# worksheet.merge_cells(brasilia_merge_cells) +# top_left_brasilia_cell_formula = f'A{brasilia_row}' +# top_left_brasilia_cell = worksheet[top_left_brasilia_cell_formula] +# top_left_brasilia_cell.value = brasilia_formula +# top_left_brasilia_cell.alignment = Alignment(horizontal="center",vertical="center") + +# #DiretorFinanceiro +# diretor_row = size + 8 +# diretor_cargo_row = size + 9 +# diretor_cpf_row = size + 10 +# diretor_nome_formula = f"='Receita x Despesa'!A45" +# diretor_cargo_formula = f"='Receita x Despesa'!A46" +# diretor_cpf_formula = f"='Receita x Despesa'!A47" +# diretor_merge_cells = f'A{diretor_row}:D{diretor_row}' +# diretor_cargo_merge_cells = f'A{diretor_cargo_row}:D{diretor_cargo_row}' +# diretor_cpf_merge_cells = f'A{diretor_cpf_row}:D{diretor_cpf_row}' +# worksheet.merge_cells(diretor_merge_cells) +# worksheet.merge_cells(diretor_cargo_merge_cells) +# worksheet.merge_cells(diretor_cpf_merge_cells) +# top_left_diretor_cell_formula = f'A{diretor_row}' +# top_left_diretor_cell_cargo_formula = f'A{diretor_cargo_row}' +# top_left_diretor_cell_cpf_formula = f'A{diretor_cpf_row}' +# top_left_diretor_cell = worksheet[top_left_diretor_cell_formula] +# top_left_diretor_cell_cargo_formula = worksheet[top_left_diretor_cell_cargo_formula] +# top_left_diretor_cell_cpf_formula = worksheet[top_left_diretor_cell_cpf_formula] +# top_left_diretor_cell.value = diretor_nome_formula +# top_left_diretor_cell_cargo_formula.value = diretor_cargo_formula +# top_left_diretor_cell_cpf_formula.value = diretor_cpf_formula +# top_left_diretor_cell.alignment = Alignment(horizontal="center",vertical="center") +# top_left_diretor_cell.font = Font(bold=True) +# top_left_diretor_cell_cargo_formula.alignment = Alignment(horizontal="center",vertical="center") +# top_left_diretor_cell_cpf_formula.alignment = Alignment(horizontal="center",vertical="center") +# #Coordenadora +# coordenadora_row = size + 8 +# coordenadora_cargo_row = size + 9 +# coordenadora_cpf_row = size + 10 +# coordenadora_nome_formula = f"='Receita x Despesa'!H45" +# coordenadora_cargo_formula = f"='Receita x Despesa'!H46" +# coordenadora_cpf_formula = f"='Receita x Despesa'!H47" +# coordenadora_merge_cells = f'F{coordenadora_row}:J{coordenadora_row}' +# coordenadora_cargo_merge_cells = f'F{coordenadora_cargo_row}:J{coordenadora_cargo_row}' +# coordenadora_cpf_merge_cells = f'F{coordenadora_cpf_row}:J{coordenadora_cpf_row}' +# worksheet.merge_cells(coordenadora_merge_cells) +# worksheet.merge_cells(coordenadora_cargo_merge_cells) +# worksheet.merge_cells(coordenadora_cpf_merge_cells) +# top_left_coordenadora_cell_formula = f'F{coordenadora_row}' +# top_left_coordenadora_cell_cargo_formula = f'F{coordenadora_cargo_row}' +# top_left_coordenadora_cell_cpf_formula = f'F{coordenadora_cpf_row}' +# top_left_coordenadora_cell = worksheet[top_left_coordenadora_cell_formula] +# top_left_coordenadora_cell_cargo_formula = worksheet[top_left_coordenadora_cell_cargo_formula] +# top_left_coordenadora_cell_cpf_formula = worksheet[top_left_coordenadora_cell_cpf_formula] +# top_left_coordenadora_cell.value = coordenadora_nome_formula +# top_left_coordenadora_cell_cargo_formula.value = coordenadora_cargo_formula +# top_left_coordenadora_cell_cpf_formula.value = coordenadora_cpf_formula +# top_left_coordenadora_cell.alignment = Alignment(horizontal="center",vertical="center") +# top_left_coordenadora_cell.font= Font(bold = True) +# top_left_coordenadora_cell_cargo_formula.alignment = Alignment(horizontal="center",vertical="center") +# top_left_coordenadora_cell_cpf_formula.alignment = Alignment(horizontal="center",vertical="center") + +# #nome dos indices + +# azul_claro = '1c89b8' +# row_style_cabecario_juridica = NamedStyle(name='row_style_cabecario_juridica') +# row_style_cabecario_juridica.font = Font(name="Arial", size=12, color="FFFFFF",bold=True) +# row_style_cabecario_juridica.fill = openpyxl.styles.PatternFill(start_color=azul_claro, end_color=azul_claro, fill_type='solid') +# row_style_cabecario_juridica.alignment = Alignment(horizontal="center",vertical="center",wrap_text = True) +# worksheet.row_dimensions[9].height = 50 +# worksheet.column_dimensions['b'].width = 35 +# worksheet.column_dimensions['c'].width = 20 +# worksheet.column_dimensions['d'].width = 35 +# worksheet.column_dimensions['e'].width = 60 +# worksheet.column_dimensions['f'].width = 35 +# worksheet.column_dimensions['g'].width = 30 +# worksheet.column_dimensions['h'].width = 30 +# worksheet.column_dimensions['i'].width = 30 +# worksheet.column_dimensions['j'].width = 30 +# worksheet.column_dimensions['e'].height = 20 + + +# linha_number = 9 +# # Apply the style to each cell in the row +# for cell in worksheet[linha_number]: +# cell.style = row_style_cabecario_juridica + +# valores = ["ITEM","NOME","CNPJ/CPF",'ESPECIFICAÇÃO DA DESPESA','DESCRIÇÃO',"Nº DO RECIBO OU EQUIVALENTE","DATA DE EMISSÃO",'CHEQUE / ORDEM BANCÁRIA','DATA DE PGTO','Valor'] +# col = 1 +# for a,b in enumerate(valores): +# worksheet.cell(row=linha_number, column=col, value=b) +# col = col + 1 + + +# #cabecario relação de pagamentos - outro servicoes de terceiros +# worksheet.merge_cells('A1:J2') +# worksheet['A1'] = f'R E L A Ç Ã O D E P A G A M E N T O S - O U T R O S S E R V I Ç O S T E R C E I R O S - P E S S O A F Í S I C A ' +# worksheet['A1'].font = Font(name="Arial", size=12, color="FFFFFF",bold=True) +# worksheet['A1'].alignment = Alignment(horizontal="center",vertical="center") +# worksheet['A1'].fill = PatternFill(start_color=azul_claro, end_color=azul_claro,fill_type = "solid") +# worksheet.merge_cells('A3:I3') +# worksheet['A3'] = "='Receita x Despesa'!A3:J3" +# worksheet['A3'].font = Font(name="Arial", size=12, color="000000") +# worksheet['A3'].alignment = Alignment(horizontal="left",vertical="center") + +# worksheet.merge_cells('A4:I4') +# worksheet['A4'] = "='Receita x Despesa'!A4:J4" +# worksheet['A4'].font = Font(name="Arial", size=12, color="000000") +# worksheet['A4'].alignment = Alignment(horizontal="left",vertical="center") + +# worksheet.merge_cells('A5:I5') +# worksheet['A5'] = "='Receita x Despesa'!A5:J5" +# worksheet['A5'].font = Font(name="Arial", size=12, color="000000") +# worksheet['A5'].alignment = Alignment(horizontal="left",vertical="center") + +# worksheet.merge_cells('A6:I6') +# worksheet['A6'] = "='Receita x Despesa'!A6:J6" +# worksheet['A6'].font = Font(name="Arial", size=12, color="000000") +# worksheet['A6'].alignment = Alignment(horizontal="left",vertical="center") + +# worksheet.merge_cells('A7:I7') +# worksheet['A7'] = "='Receita x Despesa'!A7:J7" +# worksheet['A7'].font = Font(name="Arial", size=12, color="000000") +# worksheet['A7'].alignment = Alignment(horizontal="left",vertical="center") + +# altura = 45 +# linha_inicio = 9 +# for row_number in range(linha_inicio, linha_inicio + tamanho+1): +# worksheet.row_dimensions[row_number].height = altura + + +# # Save the workbook to a file +# workbook.save(tabela) +# workbook.close() + +# def estilo_fub_juridica_juridica(tabela,tamanho): + +# caminho = pegar_caminho(tabela) +# workbook = openpyxl.load_workbook(caminho) +# worksheet = workbook['Pessoa Jurídica'] + + +# size = tamanho + 10 +# #worksheet.row_dimensions[27].height = 50 + +# cinza = "979CA8" +# azul = "336394" + + + +# for row in worksheet.iter_rows(min_row=10, max_row=size, min_col=1, max_col=10): +# worksheet.row_dimensions[row[0].row].height = 35 + +# custom_number_formatjuridica_juridica = [] +# # MASCARA R$ +# if custom_number_formatjuridica_juridica!= False: +# custom_number_formatjuridica_juridica = NamedStyle(name='custom_number_formatjuridica_juridica') +# custom_number_formatjuridica_juridica.number_format = 'R$ #,##0.00' +# custom_number_formatjuridica_juridica.font = Font(name="Arial", size=12, color="000000") +# custom_number_formatjuridica_juridica.alignment = Alignment(horizontal="general",vertical="bottom",wrap_text=True) + +# #stylecinza + + +# value_to_stop = size +# start_row = 10 +# # +# for row in range(start_row,size+1): +# cell = worksheet[f'J{row}'] +# cell.style = custom_number_formatjuridica_juridica + +# for rows in worksheet.iter_rows(min_row=10, max_row=size, min_col=1, max_col=10): +# for cell in rows: +# if cell.row % 2: +# cell.fill = PatternFill(start_color=cinza, end_color=cinza, +# fill_type = "solid") +# cell.font = Font(name="Arial", size=12, color="000000") +# cell.alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) +# cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,right =Side(border_style="hair") ,bottom=Side(border_style="hair") ) + + + + + +# #subtotal +# celulas_mergidas_subtotal = f"A{size}:I{size}" +# worksheet.merge_cells(celulas_mergidas_subtotal) +# left_celula_cell = f"A{size}" +# top_left_cell = worksheet[left_celula_cell] +# top_left_cell.value = "Sub Total" +# top_left_cell.fill = PatternFill(start_color=cinza, end_color=cinza,fill_type = "solid") +# top_left_cell.font = Font(name="Arial", size=12, color="000000",bold=True) +# top_left_cell.alignment = Alignment(horizontal="center",vertical="center") + + + + +# # FORMULATOTAL +# formula = f"=SUM(J10:J{size-1})" +# celula = f'J{size}' +# worksheet[celula] = formula +# worksheet[celula].fill = PatternFill(start_color=cinza, end_color=cinza,fill_type = "solid") +# worksheet[celula].font = Font(name="Arial", size=12, color="000000",bold=True) + + +# #restituições creditadas +# restituicoes = size + 1 +# celula_restituicoes=f'A{restituicoes}' +# worksheet[celula_restituicoes].value = "RESTITUIÇÕES CREDITADAS" +# worksheet[celula_restituicoes].font = Font(name="Arial", size=12, color="000000",bold=True) +# worksheet.row_dimensions[restituicoes].height = 30 + + +# #colunas azul +# row_stylejuridica_juridica = NamedStyle(name='row_stylejuridica_juridica') +# row_stylejuridica_juridica.font = Font(name="Arial", size=12, color="FFFFFF",bold=True) +# row_stylejuridica_juridica.fill = openpyxl.styles.PatternFill(start_color=azul, end_color=azul, fill_type='solid') +# row_stylejuridica_juridica.alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) +# row_stylejuridica_juridica.height = 30 + +# row_number = size + 2 + +# for column in range(1, 11): +# cell = worksheet.cell(row=row_number, column=column) +# cell.style = row_stylejuridica_juridica + + +# values = ["Item","Restituidor","CNPJ/CPF",'Descrição',"Cheque equivalente","Data do Cheque",'Nº do Depósito','Data da Devolução','Valor'] +# coluna = 1 +# for a,b in enumerate(values): +# worksheet.cell(row=row_number, column=coluna, value=b) +# if coluna == 4: +# coluna = coluna + 1 +# coluna = coluna + 1 + + +# merge_formula = f'D{row_number}:E{row_number}' +# worksheet.merge_cells(merge_formula) + +# #subtotal2 +# sub_total2_row = size + 4 +# subtotal_merge_cells= f'A{sub_total2_row}:I{sub_total2_row}' +# worksheet.merge_cells(subtotal_merge_cells) +# top_left_subtotal2_cell_formula = f'A{sub_total2_row}' +# top_left_subtotal2_cell = worksheet[top_left_subtotal2_cell_formula] +# top_left_subtotal2_cell.value = "Sub Total 2" +# top_left_subtotal2_cell.fill = PatternFill(start_color=cinza, end_color=cinza,fill_type = "solid") +# top_left_subtotal2_cell.font = Font(name="Arial", size=12, color="000000",bold=True) +# top_left_subtotal2_cell.alignment = Alignment(horizontal="center",vertical="center") +# sub_formula_row_celula = f'J{sub_total2_row}' +# worksheet[sub_formula_row_celula].fill = PatternFill(start_color=cinza, end_color=cinza,fill_type = "solid") +# worksheet[sub_formula_row_celula].font = Font(name="Arial", size=12, color="000000",bold=True) + +# #subtotal12_Formula +# # sub_formula_row = size + 4 +# # sub_formula = f'=SOMA(J{sub_formula_row}:J{sub_formula_row})' +# # sub_formula_row_celula = f'J{sub_formula_row}' +# # worksheet[sub_formula_row_celula].fill = PatternFill(start_color=cinza, end_color=cinza,fill_type = "solid") +# # worksheet[sub_formula_row_celula] = sub_formula + + +# #total1-2 +# total12_row = size + 5 +# total12_merge_cells = f'A{total12_row}:I{total12_row}' +# worksheet.merge_cells(total12_merge_cells) +# top_left_total12_cell_formula = f'A{total12_row}' +# top_left_total12_cell = worksheet[top_left_total12_cell_formula] +# top_left_total12_cell.value = "Total(1 -2)" +# top_left_total12_cell.fill = PatternFill(start_color=azul, end_color=azul,fill_type = "solid") +# top_left_total12_cell.font = Font(name="Arial", size=12, color="000000",bold=True) +# top_left_total12_cell.alignment = Alignment(horizontal="center",vertical="center") + +# #total_formula +# total_formula_row = size + 5 +# total_formulaa = f'=J{size}' +# total_formula_row_celula = f'J{total_formula_row}' +# worksheet[total_formula_row_celula].fill = PatternFill(start_color=azul, end_color=azul,fill_type = "solid") +# worksheet[total_formula_row_celula].font = Font(name="Arial", size=12, color="000000",bold=True) +# worksheet[total_formula_row_celula].number_format = 'R$ #,##0.00' +# worksheet.row_dimensions[total_formula_row].height = 30 +# worksheet[total_formula_row_celula] = total_formulaa + +# #brasilia +# brasilia_row = size + 7 +# brasilia_formula = f"='Receita x Despesa'!A42:J42" +# brasilia_merge_cells = f'A{brasilia_row}:I{brasilia_row}' +# worksheet.merge_cells(brasilia_merge_cells) +# top_left_brasilia_cell_formula = f'A{brasilia_row}' +# top_left_brasilia_cell = worksheet[top_left_brasilia_cell_formula] +# top_left_brasilia_cell.value = brasilia_formula +# top_left_brasilia_cell.alignment = Alignment(horizontal="center",vertical="center") + +# #DiretorFinanceiro +# diretor_row = size + 8 +# diretor_cargo_row = size + 9 +# diretor_cpf_row = size + 10 +# diretor_nome_formula = f"='Receita x Despesa'!A45" +# diretor_cargo_formula = f"='Receita x Despesa'!A46" +# diretor_cpf_formula = f"='Receita x Despesa'!A47" +# diretor_merge_cells = f'A{diretor_row}:D{diretor_row}' +# diretor_cargo_merge_cells = f'A{diretor_cargo_row}:D{diretor_cargo_row}' +# diretor_cpf_merge_cells = f'A{diretor_cpf_row}:D{diretor_cpf_row}' +# worksheet.merge_cells(diretor_merge_cells) +# worksheet.merge_cells(diretor_cargo_merge_cells) +# worksheet.merge_cells(diretor_cpf_merge_cells) +# top_left_diretor_cell_formula = f'A{diretor_row}' +# top_left_diretor_cell_cargo_formula = f'A{diretor_cargo_row}' +# top_left_diretor_cell_cpf_formula = f'A{diretor_cpf_row}' +# top_left_diretor_cell = worksheet[top_left_diretor_cell_formula] +# top_left_diretor_cell_cargo_formula = worksheet[top_left_diretor_cell_cargo_formula] +# top_left_diretor_cell_cpf_formula = worksheet[top_left_diretor_cell_cpf_formula] +# top_left_diretor_cell.value = diretor_nome_formula +# top_left_diretor_cell_cargo_formula.value = diretor_cargo_formula +# top_left_diretor_cell_cpf_formula.value = diretor_cpf_formula +# top_left_diretor_cell.alignment = Alignment(horizontal="center",vertical="center") +# top_left_diretor_cell.font = Font(bold=True) +# top_left_diretor_cell_cargo_formula.alignment = Alignment(horizontal="center",vertical="center") +# top_left_diretor_cell_cpf_formula.alignment = Alignment(horizontal="center",vertical="center") +# #Coordenadora +# coordenadora_row = size + 8 +# coordenadora_cargo_row = size + 9 +# coordenadora_cpf_row = size + 10 +# coordenadora_nome_formula = f"='Receita x Despesa'!H45" +# coordenadora_cargo_formula = f"='Receita x Despesa'!H46" +# coordenadora_cpf_formula = f"='Receita x Despesa'!H47" +# coordenadora_merge_cells = f'F{coordenadora_row}:J{coordenadora_row}' +# coordenadora_cargo_merge_cells = f'F{coordenadora_cargo_row}:J{coordenadora_cargo_row}' +# coordenadora_cpf_merge_cells = f'F{coordenadora_cpf_row}:J{coordenadora_cpf_row}' +# worksheet.merge_cells(coordenadora_merge_cells) +# worksheet.merge_cells(coordenadora_cargo_merge_cells) +# worksheet.merge_cells(coordenadora_cpf_merge_cells) +# top_left_coordenadora_cell_formula = f'F{coordenadora_row}' +# top_left_coordenadora_cell_cargo_formula = f'F{coordenadora_cargo_row}' +# top_left_coordenadora_cell_cpf_formula = f'F{coordenadora_cpf_row}' +# top_left_coordenadora_cell = worksheet[top_left_coordenadora_cell_formula] +# top_left_coordenadora_cell_cargo_formula = worksheet[top_left_coordenadora_cell_cargo_formula] +# top_left_coordenadora_cell_cpf_formula = worksheet[top_left_coordenadora_cell_cpf_formula] +# top_left_coordenadora_cell.value = coordenadora_nome_formula +# top_left_coordenadora_cell_cargo_formula.value = coordenadora_cargo_formula +# top_left_coordenadora_cell_cpf_formula.value = coordenadora_cpf_formula +# top_left_coordenadora_cell.alignment = Alignment(horizontal="center",vertical="center") +# top_left_coordenadora_cell.font= Font(bold = True) +# top_left_coordenadora_cell_cargo_formula.alignment = Alignment(horizontal="center",vertical="center") +# top_left_coordenadora_cell_cpf_formula.alignment = Alignment(horizontal="center",vertical="center") + +# #nome dos indices + +# azul_claro = '1c89b8' +# row_style_cabecariojuridica_juridica = NamedStyle(name='row_style_cabecariojuridica_juridica') +# row_style_cabecariojuridica_juridica.font = Font(name="Arial", size=12, color="FFFFFF",bold=True) +# row_style_cabecariojuridica_juridica.fill = openpyxl.styles.PatternFill(start_color=azul_claro, end_color=azul_claro, fill_type='solid') +# row_style_cabecariojuridica_juridica.alignment = Alignment(horizontal="center",vertical="center",wrap_text = True) +# worksheet.row_dimensions[9].height = 50 +# worksheet.column_dimensions['b'].width = 35 +# worksheet.column_dimensions['c'].width = 20 +# worksheet.column_dimensions['d'].width = 35 +# worksheet.column_dimensions['e'].width = 60 +# worksheet.column_dimensions['f'].width = 35 +# worksheet.column_dimensions['g'].width = 30 +# worksheet.column_dimensions['h'].width = 30 +# worksheet.column_dimensions['i'].width = 30 +# worksheet.column_dimensions['j'].width = 30 +# worksheet.column_dimensions['e'].height = 20 + + +# linha_number = 9 +# # Apply the style to each cell in the row +# for cell in worksheet[linha_number]: +# cell.style = row_style_cabecariojuridica_juridica + +# valores = ["ITEM","NOME","CNPJ/CPF",'ESPECIFICAÇÃO DA DESPESA','DESCRIÇÃO',"Nº DO RECIBO OU EQUIVALENTE","DATA DE EMISSÃO",'CHEQUE / ORDEM BANCÁRIA','DATA DE PGTO','Valor'] +# col = 1 +# for a,b in enumerate(valores): +# worksheet.cell(row=linha_number, column=col, value=b) +# col = col + 1 + + +# #cabecario relação de pagamentos - outro servicoes de terceiros +# worksheet.merge_cells('A1:J2') +# worksheet['A1'] = f'R E L A Ç Ã O D E P A G A M E N T O S - O U T R O S S E R V I Ç O S D E T E R C E I R O S - P E S S O A J U R Í D I C A ' +# worksheet['A1'].font = Font(name="Arial", size=12, color="FFFFFF",bold=True) +# worksheet['A1'].alignment = Alignment(horizontal="center",vertical="center") +# worksheet['A1'].fill = PatternFill(start_color=azul_claro, end_color=azul_claro,fill_type = "solid") +# worksheet.merge_cells('A3:I3') +# worksheet['A3'] = "='Receita x Despesa'!A3:J3" +# worksheet['A3'].font = Font(name="Arial", size=12, color="000000") +# worksheet['A3'].alignment = Alignment(horizontal="left",vertical="center") + +# worksheet.merge_cells('A4:I4') +# worksheet['A4'] = "='Receita x Despesa'!A4:J4" +# worksheet['A4'].font = Font(name="Arial", size=12, color="000000") +# worksheet['A4'].alignment = Alignment(horizontal="left",vertical="center") + +# worksheet.merge_cells('A5:I5') +# worksheet['A5'] = "='Receita x Despesa'!A5:J5" +# worksheet['A5'].font = Font(name="Arial", size=12, color="000000") +# worksheet['A5'].alignment = Alignment(horizontal="left",vertical="center") + +# worksheet.merge_cells('A6:I6') +# worksheet['A6'] = "='Receita x Despesa'!A6:J6" +# worksheet['A6'].font = Font(name="Arial", size=12, color="000000") +# worksheet['A6'].alignment = Alignment(horizontal="left",vertical="center") + +# worksheet.merge_cells('A7:I7') +# worksheet['A7'] = "='Receita x Despesa'!A7:J7" +# worksheet['A7'].font = Font(name="Arial", size=12, color="000000") +# worksheet['A7'].alignment = Alignment(horizontal="left",vertical="center") + +# altura = 45 +# linha_inicio = 9 +# for row_number in range(linha_inicio, linha_inicio + tamanho+1): +# worksheet.row_dimensions[row_number].height = altura + + +# # Save the workbook to a file +# workbook.save(tabela) +# workbook.close() + +# def estilo_serv_terceiro(tabela,tamanho): + +# caminho = pegar_caminho(tabela) +# workbook = openpyxl.load_workbook(caminho) +# worksheet = workbook['Outros Serviços Terceiros - PF'] + + +# size = tamanho + 10 +# #worksheet.row_dimensions[27].height = 50 + +# cinza = "979CA8" +# azul = "336394" + + + +# for row in worksheet.iter_rows(min_row=10, max_row=size, min_col=1, max_col=10): +# worksheet.row_dimensions[row[0].row].height = 35 + +# custom_number_format = [] +# # MASCARA R$ +# if custom_number_format!= False: +# custom_number_format = NamedStyle(name='custom_number_format') +# custom_number_format.number_format = 'R$ #,##0.00' +# custom_number_format.font = Font(name="Arial", size=12, color="000000") +# custom_number_format.alignment = Alignment(horizontal="general",vertical="bottom",wrap_text=True) + +# #stylecinza + + +# value_to_stop = size +# start_row = 10 +# # +# for row in range(start_row,size+1): +# cell = worksheet[f'J{row}'] +# cell.style = custom_number_format + +# for rows in worksheet.iter_rows(min_row=10, max_row=size, min_col=1, max_col=10): +# for cell in rows: +# if cell.row % 2: +# cell.fill = PatternFill(start_color=cinza, end_color=cinza, +# fill_type = "solid") +# cell.font = Font(name="Arial", size=12, color="000000") +# cell.alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) +# cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,right =Side(border_style="hair") ,bottom=Side(border_style="hair") ) + + + + + +# #subtotal +# celulas_mergidas_subtotal = f"A{size}:I{size}" +# worksheet.merge_cells(celulas_mergidas_subtotal) +# left_celula_cell = f"A{size}" +# top_left_cell = worksheet[left_celula_cell] +# top_left_cell.value = "Sub Total" +# top_left_cell.fill = PatternFill(start_color=cinza, end_color=cinza,fill_type = "solid") +# top_left_cell.font = Font(name="Arial", size=12, color="000000",bold=True) +# top_left_cell.alignment = Alignment(horizontal="center",vertical="center") + + + + +# # FORMULATOTAL +# formula = f"=SUM(J10:J{size-1})" +# celula = f'J{size}' +# worksheet[celula] = formula +# worksheet[celula].fill = PatternFill(start_color=cinza, end_color=cinza,fill_type = "solid") +# worksheet[celula].font = Font(name="Arial", size=12, color="000000",bold=True) + + +# #restituições creditadas +# restituicoes = size + 1 +# celula_restituicoes=f'A{restituicoes}' +# worksheet[celula_restituicoes].value = "RESTITUIÇÕES CREDITADAS" +# worksheet[celula_restituicoes].font = Font(name="Arial", size=12, color="000000",bold=True) +# worksheet.row_dimensions[restituicoes].height = 30 + + +# #colunas azul +# row_style = NamedStyle(name='row_style') +# row_style.font = Font(name="Arial", size=12, color="FFFFFF",bold=True) +# row_style.fill = openpyxl.styles.PatternFill(start_color=azul, end_color=azul, fill_type='solid') +# row_style.alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) +# row_style.height = 30 + +# row_number = size + 2 + +# for column in range(1, 11): +# cell = worksheet.cell(row=row_number, column=column) +# cell.style = row_style + + +# values = ["Item","Restituidor","CNPJ/CPF",'Descrição',"Cheque equivalente","Data do Cheque",'Nº do Depósito','Data da Devolução','Valor'] +# coluna = 1 +# for a,b in enumerate(values): +# worksheet.cell(row=row_number, column=coluna, value=b) +# if coluna == 4: +# coluna = coluna + 1 +# coluna = coluna + 1 + + +# merge_formula = f'D{row_number}:E{row_number}' +# worksheet.merge_cells(merge_formula) + +# #subtotal2 +# sub_total2_row = size + 4 +# subtotal_merge_cells= f'A{sub_total2_row}:I{sub_total2_row}' +# worksheet.merge_cells(subtotal_merge_cells) +# top_left_subtotal2_cell_formula = f'A{sub_total2_row}' +# top_left_subtotal2_cell = worksheet[top_left_subtotal2_cell_formula] +# top_left_subtotal2_cell.value = "Sub Total 2" +# top_left_subtotal2_cell.fill = PatternFill(start_color=cinza, end_color=cinza,fill_type = "solid") +# top_left_subtotal2_cell.font = Font(name="Arial", size=12, color="000000",bold=True) +# top_left_subtotal2_cell.alignment = Alignment(horizontal="center",vertical="center") +# sub_formula_row_celula = f'J{sub_total2_row}' +# worksheet[sub_formula_row_celula].fill = PatternFill(start_color=cinza, end_color=cinza,fill_type = "solid") +# worksheet[sub_formula_row_celula].font = Font(name="Arial", size=12, color="000000",bold=True) + +# #subtotal12_Formula +# # sub_formula_row = size + 4 +# # sub_formula = f'=SOMA(J{sub_formula_row}:J{sub_formula_row})' +# # sub_formula_row_celula = f'J{sub_formula_row}' +# # worksheet[sub_formula_row_celula].fill = PatternFill(start_color=cinza, end_color=cinza,fill_type = "solid") +# # worksheet[sub_formula_row_celula] = sub_formula + + +# #total1-2 +# total12_row = size + 5 +# total12_merge_cells = f'A{total12_row}:I{total12_row}' +# worksheet.merge_cells(total12_merge_cells) +# top_left_total12_cell_formula = f'A{total12_row}' +# top_left_total12_cell = worksheet[top_left_total12_cell_formula] +# top_left_total12_cell.value = "Total(1 -2)" +# top_left_total12_cell.fill = PatternFill(start_color=azul, end_color=azul,fill_type = "solid") +# top_left_total12_cell.font = Font(name="Arial", size=12, color="000000",bold=True) +# top_left_total12_cell.alignment = Alignment(horizontal="center",vertical="center") + +# #total_formula +# total_formula_row = size + 5 +# total_formulaa = f'=J{size}' +# total_formula_row_celula = f'J{total_formula_row}' +# worksheet[total_formula_row_celula].fill = PatternFill(start_color=azul, end_color=azul,fill_type = "solid") +# worksheet[total_formula_row_celula].font = Font(name="Arial", size=12, color="000000",bold=True) +# worksheet[total_formula_row_celula].number_format = 'R$ #,##0.00' +# worksheet.row_dimensions[total_formula_row].height = 30 +# worksheet[total_formula_row_celula] = total_formulaa + +# #brasilia +# brasilia_row = size + 7 +# brasilia_formula = f"='Receita x Despesa'!A42:J42" +# brasilia_merge_cells = f'A{brasilia_row}:I{brasilia_row}' +# worksheet.merge_cells(brasilia_merge_cells) +# top_left_brasilia_cell_formula = f'A{brasilia_row}' +# top_left_brasilia_cell = worksheet[top_left_brasilia_cell_formula] +# top_left_brasilia_cell.value = brasilia_formula +# top_left_brasilia_cell.alignment = Alignment(horizontal="center",vertical="center") + +# #DiretorFinanceiro +# diretor_row = size + 8 +# diretor_cargo_row = size + 9 +# diretor_cpf_row = size + 10 +# diretor_nome_formula = f"='Receita x Despesa'!A45" +# diretor_cargo_formula = f"='Receita x Despesa'!A46" +# diretor_cpf_formula = f"='Receita x Despesa'!A47" +# diretor_merge_cells = f'A{diretor_row}:D{diretor_row}' +# diretor_cargo_merge_cells = f'A{diretor_cargo_row}:D{diretor_cargo_row}' +# diretor_cpf_merge_cells = f'A{diretor_cpf_row}:D{diretor_cpf_row}' +# worksheet.merge_cells(diretor_merge_cells) +# worksheet.merge_cells(diretor_cargo_merge_cells) +# worksheet.merge_cells(diretor_cpf_merge_cells) +# top_left_diretor_cell_formula = f'A{diretor_row}' +# top_left_diretor_cell_cargo_formula = f'A{diretor_cargo_row}' +# top_left_diretor_cell_cpf_formula = f'A{diretor_cpf_row}' +# top_left_diretor_cell = worksheet[top_left_diretor_cell_formula] +# top_left_diretor_cell_cargo_formula = worksheet[top_left_diretor_cell_cargo_formula] +# top_left_diretor_cell_cpf_formula = worksheet[top_left_diretor_cell_cpf_formula] +# top_left_diretor_cell.value = diretor_nome_formula +# top_left_diretor_cell_cargo_formula.value = diretor_cargo_formula +# top_left_diretor_cell_cpf_formula.value = diretor_cpf_formula +# top_left_diretor_cell.alignment = Alignment(horizontal="center",vertical="center") +# top_left_diretor_cell.font = Font(bold=True) +# top_left_diretor_cell_cargo_formula.alignment = Alignment(horizontal="center",vertical="center") +# top_left_diretor_cell_cpf_formula.alignment = Alignment(horizontal="center",vertical="center") +# #Coordenadora +# coordenadora_row = size + 8 +# coordenadora_cargo_row = size + 9 +# coordenadora_cpf_row = size + 10 +# coordenadora_nome_formula = f"='Receita x Despesa'!H45" +# coordenadora_cargo_formula = f"='Receita x Despesa'!H46" +# coordenadora_cpf_formula = f"='Receita x Despesa'!H47" +# coordenadora_merge_cells = f'F{coordenadora_row}:J{coordenadora_row}' +# coordenadora_cargo_merge_cells = f'F{coordenadora_cargo_row}:J{coordenadora_cargo_row}' +# coordenadora_cpf_merge_cells = f'F{coordenadora_cpf_row}:J{coordenadora_cpf_row}' +# worksheet.merge_cells(coordenadora_merge_cells) +# worksheet.merge_cells(coordenadora_cargo_merge_cells) +# worksheet.merge_cells(coordenadora_cpf_merge_cells) +# top_left_coordenadora_cell_formula = f'F{coordenadora_row}' +# top_left_coordenadora_cell_cargo_formula = f'F{coordenadora_cargo_row}' +# top_left_coordenadora_cell_cpf_formula = f'F{coordenadora_cpf_row}' +# top_left_coordenadora_cell = worksheet[top_left_coordenadora_cell_formula] +# top_left_coordenadora_cell_cargo_formula = worksheet[top_left_coordenadora_cell_cargo_formula] +# top_left_coordenadora_cell_cpf_formula = worksheet[top_left_coordenadora_cell_cpf_formula] +# top_left_coordenadora_cell.value = coordenadora_nome_formula +# top_left_coordenadora_cell_cargo_formula.value = coordenadora_cargo_formula +# top_left_coordenadora_cell_cpf_formula.value = coordenadora_cpf_formula +# top_left_coordenadora_cell.alignment = Alignment(horizontal="center",vertical="center") +# top_left_coordenadora_cell.font= Font(bold = True) +# top_left_coordenadora_cell_cargo_formula.alignment = Alignment(horizontal="center",vertical="center") +# top_left_coordenadora_cell_cpf_formula.alignment = Alignment(horizontal="center",vertical="center") + +# #nome dos indices + +# azul_claro = '1c89b8' +# row_style_cabecario = NamedStyle(name='row_style_cabecario') +# row_style_cabecario.font = Font(name="Arial", size=12, color="FFFFFF",bold=True) +# row_style_cabecario.fill = openpyxl.styles.PatternFill(start_color=azul_claro, end_color=azul_claro, fill_type='solid') +# row_style_cabecario.alignment = Alignment(horizontal="center",vertical="center",wrap_text = True) +# worksheet.row_dimensions[9].height = 50 +# worksheet.column_dimensions['b'].width = 35 +# worksheet.column_dimensions['c'].width = 20 +# worksheet.column_dimensions['d'].width = 35 +# worksheet.column_dimensions['e'].width = 60 +# worksheet.column_dimensions['f'].width = 35 +# worksheet.column_dimensions['g'].width = 30 +# worksheet.column_dimensions['h'].width = 30 +# worksheet.column_dimensions['i'].width = 30 +# worksheet.column_dimensions['j'].width = 30 +# worksheet.column_dimensions['e'].height = 20 + + +# linha_number = 9 +# # Apply the style to each cell in the row +# for cell in worksheet[linha_number]: +# cell.style = row_style_cabecario + +# valores = ["ITEM","NOME","CNPJ/CPF",'ESPECIFICAÇÃO DA DESPESA','DESCRIÇÃO',"Nº DO RECIBO OU EQUIVALENTE","DATA DE EMISSÃO",'CHEQUE / ORDEM BANCÁRIA','DATA DE PGTO','Valor'] +# col = 1 +# for a,b in enumerate(valores): +# worksheet.cell(row=linha_number, column=col, value=b) +# col = col + 1 + + +# #cabecario relação de pagamentos - outro servicoes de terceiros +# worksheet.merge_cells('A1:J2') +# worksheet['A1'] = f'R E L A Ç Ã O D E P A G A M E N T O S - O U T R O S S E R V I Ç O S D E T E R C E I R O S - C E L E T I S T A S' +# worksheet['A1'].font = Font(name="Arial", size=12, color="FFFFFF",bold=True) +# worksheet['A1'].alignment = Alignment(horizontal="center",vertical="center") +# worksheet['A1'].fill = PatternFill(start_color=azul_claro, end_color=azul_claro,fill_type = "solid") +# worksheet.merge_cells('A3:I3') +# worksheet['A3'] = "='Receita x Despesa'!A3:J3" +# worksheet['A3'].font = Font(name="Arial", size=12, color="000000") +# worksheet['A3'].alignment = Alignment(horizontal="left",vertical="center") + +# worksheet.merge_cells('A4:I4') +# worksheet['A4'] = "='Receita x Despesa'!A4:J4" +# worksheet['A4'].font = Font(name="Arial", size=12, color="000000") +# worksheet['A4'].alignment = Alignment(horizontal="left",vertical="center") + +# worksheet.merge_cells('A5:I5') +# worksheet['A5'] = "='Receita x Despesa'!A5:J5" +# worksheet['A5'].font = Font(name="Arial", size=12, color="000000") +# worksheet['A5'].alignment = Alignment(horizontal="left",vertical="center") + +# worksheet.merge_cells('A6:I6') +# worksheet['A6'] = "='Receita x Despesa'!A6:J6" +# worksheet['A6'].font = Font(name="Arial", size=12, color="000000") +# worksheet['A6'].alignment = Alignment(horizontal="left",vertical="center") + +# worksheet.merge_cells('A7:I7') +# worksheet['A7'] = "='Receita x Despesa'!A7:J7" +# worksheet['A7'].font = Font(name="Arial", size=12, color="000000") +# worksheet['A7'].alignment = Alignment(horizontal="left",vertical="center") + +# altura = 45 +# linha_inicio = 9 +# for row_number in range(linha_inicio, linha_inicio + tamanho+1): +# worksheet.row_dimensions[row_number].height = altura + + +# # Save the workbook to a file +# workbook.save(tabela) +# workbook.close() + +# def estilo_Iss(tabela,tamanho): + +# caminho = pegar_caminho(tabela) +# workbook = openpyxl.load_workbook(caminho) +# worksheet = workbook['ISS'] + + +# size = tamanho + 10 +# #worksheet.row_dimensions[27].height = 50 + +# cinza = "979CA8" +# azul = "336394" + + + +# for row in worksheet.iter_rows(min_row=10, max_row=size, min_col=1, max_col=10): +# worksheet.row_dimensions[row[0].row].height = 35 + +# custom_number_format_iss = [] +# # MASCARA R$ +# if custom_number_format_iss!= False: +# custom_number_format_iss = NamedStyle(name='custom_number_format_iss') +# custom_number_format_iss.number_format = 'R$ #,##0.00' +# custom_number_format_iss.font = Font(name="Arial", size=12, color="000000") +# custom_number_format_iss.alignment = Alignment(horizontal="general",vertical="bottom",wrap_text=True) + +# #stylecinza + + +# value_to_stop = size +# start_row = 10 +# # +# for row in range(start_row,size+1): +# cell = worksheet[f'J{row}'] +# cell.style = custom_number_format_iss + +# for rows in worksheet.iter_rows(min_row=10, max_row=size, min_col=1, max_col=10): +# for cell in rows: +# if cell.row % 2: +# cell.fill = PatternFill(start_color=cinza, end_color=cinza, +# fill_type = "solid") +# cell.font = Font(name="Arial", size=12, color="000000") +# cell.alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) +# cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,right =Side(border_style="hair") ,bottom=Side(border_style="hair") ) + + + + + +# #subtotal +# celulas_mergidas_subtotal = f"A{size}:I{size}" +# worksheet.merge_cells(celulas_mergidas_subtotal) +# left_celula_cell = f"A{size}" +# top_left_cell = worksheet[left_celula_cell] +# top_left_cell.value = "Sub Total" +# top_left_cell.fill = PatternFill(start_color=cinza, end_color=cinza,fill_type = "solid") +# top_left_cell.font = Font(name="Arial", size=12, color="000000",bold=True) +# top_left_cell.alignment = Alignment(horizontal="center",vertical="center") + + + + +# # FORMULATOTAL +# formula = f"=SUM(J10:J{size-1})" +# celula = f'J{size}' +# worksheet[celula] = formula +# worksheet[celula].fill = PatternFill(start_color=cinza, end_color=cinza,fill_type = "solid") +# worksheet[celula].font = Font(name="Arial", size=12, color="000000",bold=True) + + +# #restituições creditadas +# restituicoes = size + 1 +# celula_restituicoes=f'A{restituicoes}' +# worksheet[celula_restituicoes].value = "RESTITUIÇÕES CREDITADAS" +# worksheet[celula_restituicoes].font = Font(name="Arial", size=12, color="000000",bold=True) +# worksheet.row_dimensions[restituicoes].height = 30 + + +# #colunas azul +# row_style_iss = NamedStyle(name='row_style_iss') +# row_style_iss.font = Font(name="Arial", size=12, color="FFFFFF",bold=True) +# row_style_iss.fill = openpyxl.styles.PatternFill(start_color=azul, end_color=azul, fill_type='solid') +# row_style_iss.alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) +# row_style_iss.height = 30 + +# row_number = size + 2 + +# for column in range(1, 11): +# cell = worksheet.cell(row=row_number, column=column) +# cell.style = row_style_iss + + +# values = ["Item","Restituidor","CNPJ/CPF",'Descrição',"Cheque equivalente","Data do Cheque",'Nº do Depósito','Data da Devolução','Valor'] +# coluna = 1 +# for a,b in enumerate(values): +# worksheet.cell(row=row_number, column=coluna, value=b) +# if coluna == 4: +# coluna = coluna + 1 +# coluna = coluna + 1 + + +# merge_formula = f'D{row_number}:E{row_number}' +# worksheet.merge_cells(merge_formula) + +# #subtotal2 +# sub_total2_row = size + 4 +# subtotal_merge_cells= f'A{sub_total2_row}:I{sub_total2_row}' +# worksheet.merge_cells(subtotal_merge_cells) +# top_left_subtotal2_cell_formula = f'A{sub_total2_row}' +# top_left_subtotal2_cell = worksheet[top_left_subtotal2_cell_formula] +# top_left_subtotal2_cell.value = "Sub Total 2" +# top_left_subtotal2_cell.fill = PatternFill(start_color=cinza, end_color=cinza,fill_type = "solid") +# top_left_subtotal2_cell.font = Font(name="Arial", size=12, color="000000",bold=True) +# top_left_subtotal2_cell.alignment = Alignment(horizontal="center",vertical="center") +# sub_formula_row_celula = f'J{sub_total2_row}' +# worksheet[sub_formula_row_celula].fill = PatternFill(start_color=cinza, end_color=cinza,fill_type = "solid") +# worksheet[sub_formula_row_celula].font = Font(name="Arial", size=12, color="000000",bold=True) + +# #subtotal12_Formula +# # sub_formula_row = size + 4 +# # sub_formula = f'=SOMA(J{sub_formula_row}:J{sub_formula_row})' +# # sub_formula_row_celula = f'J{sub_formula_row}' +# # worksheet[sub_formula_row_celula].fill = PatternFill(start_color=cinza, end_color=cinza,fill_type = "solid") +# # worksheet[sub_formula_row_celula] = sub_formula + + +# #total1-2 +# total12_row = size + 5 +# total12_merge_cells = f'A{total12_row}:I{total12_row}' +# worksheet.merge_cells(total12_merge_cells) +# top_left_total12_cell_formula = f'A{total12_row}' +# top_left_total12_cell = worksheet[top_left_total12_cell_formula] +# top_left_total12_cell.value = "Total(1 -2)" +# top_left_total12_cell.fill = PatternFill(start_color=azul, end_color=azul,fill_type = "solid") +# top_left_total12_cell.font = Font(name="Arial", size=12, color="000000",bold=True) +# top_left_total12_cell.alignment = Alignment(horizontal="center",vertical="center") + +# #total_formula +# total_formula_row = size + 5 +# total_formulaa = f'=J{size}' +# total_formula_row_celula = f'J{total_formula_row}' +# worksheet[total_formula_row_celula].fill = PatternFill(start_color=azul, end_color=azul,fill_type = "solid") +# worksheet[total_formula_row_celula].font = Font(name="Arial", size=12, color="000000",bold=True) +# worksheet[total_formula_row_celula].number_format = 'R$ #,##0.00' +# worksheet.row_dimensions[total_formula_row].height = 30 +# worksheet[total_formula_row_celula] = total_formulaa + +# #brasilia +# brasilia_row = size + 7 +# brasilia_formula = f"='Receita x Despesa'!A42:J42" +# brasilia_merge_cells = f'A{brasilia_row}:I{brasilia_row}' +# worksheet.merge_cells(brasilia_merge_cells) +# top_left_brasilia_cell_formula = f'A{brasilia_row}' +# top_left_brasilia_cell = worksheet[top_left_brasilia_cell_formula] +# top_left_brasilia_cell.value = brasilia_formula +# top_left_brasilia_cell.alignment = Alignment(horizontal="center",vertical="center") + +# #DiretorFinanceiro +# diretor_row = size + 8 +# diretor_cargo_row = size + 9 +# diretor_cpf_row = size + 10 +# diretor_nome_formula = f"='Receita x Despesa'!A45" +# diretor_cargo_formula = f"='Receita x Despesa'!A46" +# diretor_cpf_formula = f"='Receita x Despesa'!A47" +# diretor_merge_cells = f'A{diretor_row}:D{diretor_row}' +# diretor_cargo_merge_cells = f'A{diretor_cargo_row}:D{diretor_cargo_row}' +# diretor_cpf_merge_cells = f'A{diretor_cpf_row}:D{diretor_cpf_row}' +# worksheet.merge_cells(diretor_merge_cells) +# worksheet.merge_cells(diretor_cargo_merge_cells) +# worksheet.merge_cells(diretor_cpf_merge_cells) +# top_left_diretor_cell_formula = f'A{diretor_row}' +# top_left_diretor_cell_cargo_formula = f'A{diretor_cargo_row}' +# top_left_diretor_cell_cpf_formula = f'A{diretor_cpf_row}' +# top_left_diretor_cell = worksheet[top_left_diretor_cell_formula] +# top_left_diretor_cell_cargo_formula = worksheet[top_left_diretor_cell_cargo_formula] +# top_left_diretor_cell_cpf_formula = worksheet[top_left_diretor_cell_cpf_formula] +# top_left_diretor_cell.value = diretor_nome_formula +# top_left_diretor_cell_cargo_formula.value = diretor_cargo_formula +# top_left_diretor_cell_cpf_formula.value = diretor_cpf_formula +# top_left_diretor_cell.alignment = Alignment(horizontal="center",vertical="center") +# top_left_diretor_cell.font = Font(bold=True) +# top_left_diretor_cell_cargo_formula.alignment = Alignment(horizontal="center",vertical="center") +# top_left_diretor_cell_cpf_formula.alignment = Alignment(horizontal="center",vertical="center") +# #Coordenadora +# coordenadora_row = size + 8 +# coordenadora_cargo_row = size + 9 +# coordenadora_cpf_row = size + 10 +# coordenadora_nome_formula = f"='Receita x Despesa'!H45" +# coordenadora_cargo_formula = f"='Receita x Despesa'!H46" +# coordenadora_cpf_formula = f"='Receita x Despesa'!H47" +# coordenadora_merge_cells = f'F{coordenadora_row}:J{coordenadora_row}' +# coordenadora_cargo_merge_cells = f'F{coordenadora_cargo_row}:J{coordenadora_cargo_row}' +# coordenadora_cpf_merge_cells = f'F{coordenadora_cpf_row}:J{coordenadora_cpf_row}' +# worksheet.merge_cells(coordenadora_merge_cells) +# worksheet.merge_cells(coordenadora_cargo_merge_cells) +# worksheet.merge_cells(coordenadora_cpf_merge_cells) +# top_left_coordenadora_cell_formula = f'F{coordenadora_row}' +# top_left_coordenadora_cell_cargo_formula = f'F{coordenadora_cargo_row}' +# top_left_coordenadora_cell_cpf_formula = f'F{coordenadora_cpf_row}' +# top_left_coordenadora_cell = worksheet[top_left_coordenadora_cell_formula] +# top_left_coordenadora_cell_cargo_formula = worksheet[top_left_coordenadora_cell_cargo_formula] +# top_left_coordenadora_cell_cpf_formula = worksheet[top_left_coordenadora_cell_cpf_formula] +# top_left_coordenadora_cell.value = coordenadora_nome_formula +# top_left_coordenadora_cell_cargo_formula.value = coordenadora_cargo_formula +# top_left_coordenadora_cell_cpf_formula.value = coordenadora_cpf_formula +# top_left_coordenadora_cell.alignment = Alignment(horizontal="center",vertical="center") +# top_left_coordenadora_cell.font= Font(bold = True) +# top_left_coordenadora_cell_cargo_formula.alignment = Alignment(horizontal="center",vertical="center") +# top_left_coordenadora_cell_cpf_formula.alignment = Alignment(horizontal="center",vertical="center") + +# #nome dos indices + +# azul_claro = '1c89b8' +# row_style_cabecario_iss = NamedStyle(name='row_style_cabecario_iss') +# row_style_cabecario_iss.font = Font(name="Arial", size=12, color="FFFFFF",bold=True) +# row_style_cabecario_iss.fill = openpyxl.styles.PatternFill(start_color=azul_claro, end_color=azul_claro, fill_type='solid') +# row_style_cabecario_iss.alignment = Alignment(horizontal="center",vertical="center",wrap_text = True) +# worksheet.row_dimensions[9].height = 50 +# worksheet.column_dimensions['b'].width = 35 +# worksheet.column_dimensions['c'].width = 20 +# worksheet.column_dimensions['d'].width = 35 +# worksheet.column_dimensions['e'].width = 60 +# worksheet.column_dimensions['f'].width = 35 +# worksheet.column_dimensions['g'].width = 30 +# worksheet.column_dimensions['h'].width = 30 +# worksheet.column_dimensions['i'].width = 30 +# worksheet.column_dimensions['j'].width = 30 +# worksheet.column_dimensions['e'].height = 20 + + +# linha_number = 9 +# # Apply the style to each cell in the row +# for cell in worksheet[linha_number]: +# cell.style = row_style_cabecario_iss + +# valores = ["ITEM","NOME","CNPJ/CPF",'ESPECIFICAÇÃO DA DESPESA','DESCRIÇÃO',"Nº DO RECIBO OU EQUIVALENTE","DATA DE EMISSÃO",'CHEQUE / ORDEM BANCÁRIA','DATA DE PGTO','Valor'] +# col = 1 +# for a,b in enumerate(valores): +# worksheet.cell(row=linha_number, column=col, value=b) +# col = col + 1 + + +# #cabecario relação de pagamentos - outro servicoes de terceiros +# worksheet.merge_cells('A1:J2') +# worksheet['A1'] = f'R E L A Ç Ã O D E P A G A M E N T O S - A U X Í L I O F I N A N C E I R O A E S T U D A N T E ' +# worksheet['A1'].font = Font(name="Arial", size=12, color="FFFFFF",bold=True) +# worksheet['A1'].alignment = Alignment(horizontal="center",vertical="center") +# worksheet['A1'].fill = PatternFill(start_color=azul_claro, end_color=azul_claro,fill_type = "solid") +# worksheet.merge_cells('A3:I3') +# worksheet['A3'] = "='Receita x Despesa'!A3:J3" +# worksheet['A3'].font = Font(name="Arial", size=12, color="000000") +# worksheet['A3'].alignment = Alignment(horizontal="left",vertical="center") + +# worksheet.merge_cells('A4:I4') +# worksheet['A4'] = "='Receita x Despesa'!A4:J4" +# worksheet['A4'].font = Font(name="Arial", size=12, color="000000") +# worksheet['A4'].alignment = Alignment(horizontal="left",vertical="center") + +# worksheet.merge_cells('A5:I5') +# worksheet['A5'] = "='Receita x Despesa'!A5:J5" +# worksheet['A5'].font = Font(name="Arial", size=12, color="000000") +# worksheet['A5'].alignment = Alignment(horizontal="left",vertical="center") + +# worksheet.merge_cells('A6:I6') +# worksheet['A6'] = "='Receita x Despesa'!A6:J6" +# worksheet['A6'].font = Font(name="Arial", size=12, color="000000") +# worksheet['A6'].alignment = Alignment(horizontal="left",vertical="center") + +# worksheet.merge_cells('A7:I7') +# worksheet['A7'] = "='Receita x Despesa'!A7:J7" +# worksheet['A7'].font = Font(name="Arial", size=12, color="000000") +# worksheet['A7'].alignment = Alignment(horizontal="left",vertical="center") + +# altura = 45 +# linha_inicio = 9 +# for row_number in range(linha_inicio, linha_inicio + tamanho+1): +# worksheet.row_dimensions[row_number].height = altura + + +# # Save the workbook to a file +# workbook.save(tabela) +# workbook.close() + +# def estilo_passagens(tabela,tamanho): + +# caminho = pegar_caminho(tabela) +# workbook = openpyxl.load_workbook(caminho) +# worksheet = workbook['Passagens e Desp. Locomoção'] +# size = tamanho + 10 +# cinza = "d9d9d9" +# cinza_escuro = "bfbfbf" +# azul = "336394" +# azul_claro = '1c8cbc' + +# borda = Border(right=Side(border_style="medium")) +# worksheet.sheet_view.showGridLines = False +# # +# for row in worksheet.iter_rows(min_row=1, max_row=size+11,min_col=10,max_col=10): +# for cell in row: +# cell.border = borda + + +# worksheet.column_dimensions['a'].width = 25 +# worksheet.column_dimensions['b'].width = 25 +# worksheet.column_dimensions['c'].width = 35 +# worksheet.column_dimensions['d'].width = 40#descrição +# worksheet.column_dimensions['e'].width = 20 #n do recibo ou qeuivalente +# worksheet.column_dimensions['f'].width = 25 #data de emissão +# worksheet.column_dimensions['g'].width = 25 #data de emissão +# worksheet.column_dimensions['h'].width = 25 #data de emissão +# worksheet.column_dimensions['i'].width = 25 #data de emissão +# worksheet.column_dimensions['j'].width = 25 #data de emissão + + +# #cabecario relação de pagamentos - outro servicoes de terceiros +# worksheet.merge_cells('A1:J2') +# worksheet['A1'] = f'R E L A Ç Ã O D E P A G A M E N T O S - PASSAGENS E DESPESAS COM LOCOMOÇÃO' +# worksheet['A1'].font = Font(name="Arial", size=12, color="FFFFFF",bold=True) +# worksheet['A1'].alignment = Alignment(horizontal="center",vertical="center") +# worksheet['A1'].fill = PatternFill(start_color=azul_claro, end_color=azul_claro,fill_type = "solid") + +# worksheet.merge_cells('A3:F3') +# worksheet['A3'] = "='Receita x Despesa'!A3:J3" +# worksheet['A3'].font = Font(name="Arial", size=12, color="000000") +# worksheet['A3'].alignment = Alignment(horizontal="left",vertical="center") + +# worksheet.merge_cells('A4:F4') +# worksheet['A4'] = "='Receita x Despesa'!A4:J4" +# worksheet['A4'].font = Font(name="Arial", size=12, color="000000") +# worksheet['A4'].alignment = Alignment(horizontal="left",vertical="center") + +# worksheet.merge_cells('A5:F5') +# worksheet['A5'] = "='Receita x Despesa'!A5:J5" +# worksheet['A5'].font = Font(name="Arial", size=12, color="000000") +# worksheet['A5'].alignment = Alignment(horizontal="left",vertical="center") + +# worksheet.merge_cells('A6:F6') +# worksheet['A6'] = "='Receita x Despesa'!A6:J6" +# worksheet['A6'].font = Font(name="Arial", size=12, color="000000") +# worksheet['A6'].alignment = Alignment(horizontal="left",vertical="center") + +# worksheet.merge_cells('A7:F7') +# worksheet['A7'] = "='Receita x Despesa'!A7:J7" +# worksheet['A7'].font = Font(name="Arial", size=12, color="000000") +# worksheet['A7'].alignment = Alignment(horizontal="left",vertical="center") + +# #colunas azul cabecario +# row_style_passagens = NamedStyle(name='row_style_passagens') +# row_style_passagens.font = Font(name="Arial", size=12, color="FFFFFF",bold=True) +# row_style_passagens.fill = openpyxl.styles.PatternFill(start_color=azul_claro, end_color=azul_claro, fill_type='solid') +# row_style_passagens.alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) +# row_style_passagens.border = Border(top=Side(border_style="medium") ,bottom=Side(border_style="thin") ) +# row_style_passagens.height = 20 +# linha_number = 9 +# for row in worksheet.iter_rows(min_row=linha_number, max_row=linha_number, min_col=1, max_col=10): +# for cell in row: +# cell.style = row_style_passagens +# if cell.column == 10: +# cell.border = Border(top=Side(border_style="medium") ,bottom=Side(border_style="thin"), right=Side(border_style="medium") ) + +# valores = ["ITEM","NOME","CNPJ/CPF",'ESPECIFICAÇÃO DA DESPESA','DESCRIÇÃO',"Nº DO RECIBO OU EQUIVALENTE","DATA DE EMISSÃO",'CHEQUE / ORDEM BANCÁRIA','DATA DE PGTO','Valor'] +# col = 1 +# for a,b in enumerate(valores): +# worksheet.cell(row=linha_number, column=col, value=b) +# col = col + 1 + + +# #Aumentar a altura das celulas +# for row in worksheet.iter_rows(min_row=10, max_row=size, min_col=1, max_col=10): +# worksheet.row_dimensions[row[0].row].height = 35 + +# custom_number_format_passagens = [] +# # MASCARA R$ +# if custom_number_format_passagens!= False: +# custom_number_format_passagens = NamedStyle(name='custom_number_format_passagens') +# custom_number_format_passagens.number_format = 'R$ #,##0.00' +# custom_number_format_passagens.font = Font(name="Arial", size=12, color="000000") +# custom_number_format_passagens.alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + +# #estilocinzasimcinzanao +# value_to_stop = size +# start_row = 10 +# # +# for row in range(start_row,size+1): +# cell = worksheet[f'J{row}'] +# cell.style = custom_number_format_passagens + +# for rows in worksheet.iter_rows(min_row=10, max_row=size, min_col=1, max_col=10): +# for cell in rows: +# if cell.row % 2: +# cell.fill = PatternFill(start_color=cinza, end_color=cinza, +# fill_type = "solid") +# if cell.column == 10: +# cell.font = Font(name="Arial", size=12, color="000000") +# cell.alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) +# cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,right =Side(border_style="medium") ,bottom=Side(border_style="hair") ) +# else: +# cell.font = Font(name="Arial", size=12, color="000000") +# cell.alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) +# cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,right =Side(border_style="hair") ,bottom=Side(border_style="hair") ) + + +# #subtotal +# stringAfinarCelula =size+2 +# worksheet.row_dimensions[size+2].height = 6 +# celulas_mergidas_subtotal = f"A{size+2}:I{size+2}" +# worksheet.merge_cells(celulas_mergidas_subtotal) +# left_celula_cell = f"A{size+2}" +# top_left_cell = worksheet[left_celula_cell] +# top_left_cell.value = "Sub Total1" +# top_left_cell.fill = PatternFill(start_color=cinza, end_color=cinza,fill_type = "solid") +# top_left_cell.font = Font(name="Arial", size=12, color="000000",bold=True) +# top_left_cell.alignment = Alignment(horizontal="center",vertical="center") +# top_left_cell.border = Border(top=Side(border_style="thin") ,left = Side(border_style="medium") ,right =Side(border_style="thin") ,bottom=Side(border_style="medium") ) + +# worksheet.row_dimensions[size+2].height = 56.25 + +# # FORMULATOTAL +# formula = f"=SUM(J10:J{size})" +# celula = f'J{size+2}' +# worksheet[celula] = formula +# worksheet[celula].fill = PatternFill(start_color=cinza, end_color=cinza,fill_type = "solid") +# worksheet[celula].font = Font(name="Arial", size=12, color="000000",bold=True) +# worksheet[celula].border = Border(top=Side(border_style="thin") ,left = Side(border_style="thin") ,right =Side(border_style="medium") ,bottom=Side(border_style="medium") ) +# worksheet[celula].number_format = 'R$ #,##0.00' +# #restituições creditadas +# restituicoes = size + 3 +# celula_restituicoes=f'A{restituicoes}' +# worksheet[celula_restituicoes].value = "RESTITUIÇÕES CREDITADAS" +# worksheet[celula_restituicoes].font = Font(name="Arial", size=12, color="000000",bold=True) +# worksheet.row_dimensions[restituicoes].height = 30 + +# #estilo colunas restitucoes creditadas +# row_style_passagens_append = NamedStyle(name='row_style_passagens_append') +# row_style_passagens_append.font = Font(name="Arial", size=12, color="FFFFFF",bold=True) +# row_style_passagens_append.fill = openpyxl.styles.PatternFill(start_color=azul_claro, end_color=azul_claro, fill_type='solid') +# row_style_passagens_append.alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) +# row_style_passagens_append.height = 30 +# row_style_passagens_append.border = Border(top=Side(border_style="medium") ,bottom=Side(border_style="medium") ) + + +# row_number = size + 4 + +# for column in range(1, 11): +# cell = worksheet.cell(row=row_number, column=column) +# cell.style = row_style_passagens_append +# if cell.column == 10: +# cell.border = Border(top=Side(border_style="medium") ,right =Side(border_style="medium") ,bottom=Side(border_style="medium") ) + + + +# values = ["Item","Restituidor","CNPJ/CPF",'Descrição',"Cheque equivalente","Data do Cheque",'Nº do Depósito','Data da Devolução','Valor'] +# coluna = 1 +# for a,b in enumerate(values): +# worksheet.cell(row=row_number, column=coluna, value=b) +# if coluna == 4: +# coluna = coluna + 1 +# coluna = coluna + 1 + + +# merge_formula = f'D{row_number}:E{row_number}' +# worksheet.merge_cells(merge_formula) + + +# #subtotal2 +# sub_total2_row = size + 5 +# subtotal_merge_cells= f'A{sub_total2_row}:I{sub_total2_row}' +# worksheet.merge_cells(subtotal_merge_cells) +# top_left_subtotal2_cell_formula = f'A{sub_total2_row}' +# top_left_subtotal2_cell = worksheet[top_left_subtotal2_cell_formula] +# top_left_subtotal2_cell.value = "Sub Total 2" +# top_left_subtotal2_cell.fill = PatternFill(start_color=cinza_escuro, end_color=cinza_escuro,fill_type = "solid") +# top_left_subtotal2_cell.font = Font(name="Arial", size=12, color="000000",bold=True) +# top_left_subtotal2_cell.alignment = Alignment(horizontal="center",vertical="center") +# top_left_subtotal2_cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="medium") ,right =Side(border_style="hair") ,bottom=Side(border_style="medium") ) + +# sub_formula_row_celula = f'J{sub_total2_row}' +# worksheet[sub_formula_row_celula].fill = PatternFill(start_color=cinza_escuro, end_color=cinza_escuro,fill_type = "solid") +# worksheet[sub_formula_row_celula].font = Font(name="Arial", size=12, color="000000",bold=True) +# worksheet[sub_formula_row_celula].number_format = 'R$ #,##0.00' +# worksheet[sub_formula_row_celula].border = Border(top=Side(border_style="thin") ,left = Side(border_style="thin") ,right =Side(border_style="medium") ,bottom=Side(border_style="medium") ) + +# #total1-2 +# total12_row = size + 6 +# total12_merge_cells = f'A{total12_row}:I{total12_row}' +# worksheet.merge_cells(total12_merge_cells) +# top_left_total12_cell_formula = f'A{total12_row}' +# top_left_total12_cell = worksheet[top_left_total12_cell_formula] +# top_left_total12_cell.value = "Total(1-2)" +# top_left_total12_cell.fill = PatternFill(start_color=azul_claro, end_color=azul_claro,fill_type = "solid") +# top_left_total12_cell.font = Font(name="Arial", size=12, color="000000",bold=True) +# top_left_total12_cell.alignment = Alignment(horizontal="center",vertical="center") +# top_left_total12_cell.border = Border(top=Side(border_style="medium") ,left = Side(border_style="medium") ,bottom=Side(border_style="medium") ) + + +# #total_formula +# total_formula_row = size + 6 +# total_formulaa = f'=J{size+2}' +# total_formula_row_celula = f'J{total_formula_row}' +# worksheet[total_formula_row_celula].fill = PatternFill(start_color=azul_claro, end_color=azul_claro,fill_type = "solid") +# worksheet[total_formula_row_celula].font = Font(name="Arial", size=12, color="000000",bold=True) +# worksheet[total_formula_row_celula].number_format = 'R$ #,##0.00' +# worksheet[total_formula_row_celula].border = Border(top=Side(border_style="medium") ,bottom=Side(border_style="medium"),right=Side(border_style="medium") ) + +# worksheet.row_dimensions[total_formula_row].height = 30 +# worksheet[total_formula_row_celula] = total_formulaa + + +# #brasilia +# brasilia_row = size + 7 +# brasilia_formula = f"='Receita x Despesa'!A42:J42" +# brasilia_merge_cells = f'A{brasilia_row}:I{brasilia_row}' +# worksheet.merge_cells(brasilia_merge_cells) +# top_left_brasilia_cell_formula = f'A{brasilia_row}' +# top_left_brasilia_cell = worksheet[top_left_brasilia_cell_formula] +# top_left_brasilia_cell.value = brasilia_formula +# top_left_brasilia_cell.alignment = Alignment(horizontal="center",vertical="center") + +# #DiretorFinanceiro +# diretor_row = size + 8 +# diretor_cargo_row = size + 9 +# diretor_cpf_row = size + 10 +# diretor_nome_formula = f"='Receita x Despesa'!A45" +# diretor_cargo_formula = f"='Receita x Despesa'!A46" +# diretor_cpf_formula = f"='Receita x Despesa'!A47" +# diretor_merge_cells = f'A{diretor_row}:D{diretor_row}' +# diretor_cargo_merge_cells = f'A{diretor_cargo_row}:D{diretor_cargo_row}' +# diretor_cpf_merge_cells = f'A{diretor_cpf_row}:D{diretor_cpf_row}' +# worksheet.merge_cells(diretor_merge_cells) +# worksheet.merge_cells(diretor_cargo_merge_cells) +# worksheet.merge_cells(diretor_cpf_merge_cells) +# top_left_diretor_cell_formula = f'A{diretor_row}' +# top_left_diretor_cell_cargo_formula = f'A{diretor_cargo_row}' +# top_left_diretor_cell_cpf_formula = f'A{diretor_cpf_row}' +# top_left_diretor_cell = worksheet[top_left_diretor_cell_formula] +# top_left_diretor_cell_cargo_formula = worksheet[top_left_diretor_cell_cargo_formula] +# top_left_diretor_cell_cpf_formula = worksheet[top_left_diretor_cell_cpf_formula] +# top_left_diretor_cell.value = diretor_nome_formula +# top_left_diretor_cell_cargo_formula.value = diretor_cargo_formula +# top_left_diretor_cell_cpf_formula.value = diretor_cpf_formula +# top_left_diretor_cell.alignment = Alignment(horizontal="center",vertical="center") +# top_left_diretor_cell.font = Font(bold=True) +# top_left_diretor_cell_cargo_formula.alignment = Alignment(horizontal="center",vertical="center") +# top_left_diretor_cell_cpf_formula.alignment = Alignment(horizontal="center",vertical="center") +# #Coordenadora +# coordenadora_row = size + 8 +# coordenadora_cargo_row = size + 9 +# coordenadora_cpf_row = size + 10 +# coordenadora_nome_formula = f"='Receita x Despesa'!H45" +# coordenadora_cargo_formula = f"='Receita x Despesa'!H46" +# coordenadora_cpf_formula = f"='Receita x Despesa'!H47" +# coordenadora_merge_cells = f'F{coordenadora_row}:J{coordenadora_row}' +# coordenadora_cargo_merge_cells = f'F{coordenadora_cargo_row}:J{coordenadora_cargo_row}' +# coordenadora_cpf_merge_cells = f'F{coordenadora_cpf_row}:J{coordenadora_cpf_row}' +# worksheet.merge_cells(coordenadora_merge_cells) +# worksheet.merge_cells(coordenadora_cargo_merge_cells) +# worksheet.merge_cells(coordenadora_cpf_merge_cells) +# top_left_coordenadora_cell_formula = f'F{coordenadora_row}' +# top_left_coordenadora_cell_cargo_formula = f'F{coordenadora_cargo_row}' +# top_left_coordenadora_cell_cpf_formula = f'F{coordenadora_cpf_row}' +# top_left_coordenadora_cell = worksheet[top_left_coordenadora_cell_formula] +# top_left_coordenadora_cell_cargo_formula = worksheet[top_left_coordenadora_cell_cargo_formula] +# top_left_coordenadora_cell_cpf_formula = worksheet[top_left_coordenadora_cell_cpf_formula] +# top_left_coordenadora_cell.value = coordenadora_nome_formula +# top_left_coordenadora_cell_cargo_formula.value = coordenadora_cargo_formula +# top_left_coordenadora_cell_cpf_formula.value = coordenadora_cpf_formula +# top_left_coordenadora_cell.alignment = Alignment(horizontal="center",vertical="center") +# top_left_coordenadora_cell.font= Font(bold = True) +# top_left_coordenadora_cell_cargo_formula.alignment = Alignment(horizontal="center",vertical="center") +# top_left_coordenadora_cell_cpf_formula.alignment = Alignment(horizontal="center",vertical="center") + + +# # borda = Border(right=Side(border_style="medium")) +# # worksheet.sheet_view.showGridLines = False +# # # +# # for row in worksheet.iter_rows(min_row=1, max_row=coordenadora_cpf_row+1,min_col=10,max_col=10): +# # for cell in row: +# # cell.border = borda + + + +# for row in worksheet.iter_rows(min_row=coordenadora_cpf_row+1, max_row=coordenadora_cpf_row+1,min_col=1,max_col=10): +# for cell in row: +# if cell.column == 10: +# cell.border = Border(top=Side(border_style="none") ,left = Side(border_style="none") ,right =Side(border_style="medium") ,bottom=Side(border_style="medium") ) +# else: +# cell.border = Border(top=Side(border_style="none") ,left = Side(border_style="none") ,right =Side(border_style="none") ,bottom=Side(border_style="medium") ) + +# workbook.save(tabela) +# workbook.close() + +# def estilo_obrigacoes_tributarias(tabela,tamanho): +# caminho = pegar_caminho(tabela) +# workbook = openpyxl.load_workbook(caminho) +# worksheet = workbook['Obrigações Trib. - Encargos 20%'] + + +# size = tamanho + 10 +# #worksheet.row_dimensions[27].height = 50 + +# cinza = "979CA8" +# azul = "336394" + + + +# for row in worksheet.iter_rows(min_row=10, max_row=size, min_col=1, max_col=10): +# worksheet.row_dimensions[row[0].row].height = 35 + +# custom_number_format_obrig = [] +# # MASCARA R$ +# if custom_number_format_obrig!= False: +# custom_number_format_obrig = NamedStyle(name='custom_number_format_obrig') +# custom_number_format_obrig.number_format = 'R$ #,##0.00' +# custom_number_format_obrig.font = Font(name="Arial", size=12, color="000000") +# custom_number_format_obrig.alignment = Alignment(horizontal="general",vertical="bottom",wrap_text=True) + +# #stylecinza + + +# value_to_stop = size +# start_row = 10 +# # +# for row in range(start_row,size+1): +# cell = worksheet[f'J{row}'] +# cell.style = custom_number_format_obrig + +# for rows in worksheet.iter_rows(min_row=10, max_row=size, min_col=1, max_col=10): +# for cell in rows: +# if cell.row % 2: +# cell.fill = PatternFill(start_color=cinza, end_color=cinza, +# fill_type = "solid") +# cell.font = Font(name="Arial", size=12, color="000000") +# cell.alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) +# cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,right =Side(border_style="hair") ,bottom=Side(border_style="hair") ) + + + + + +# #subtotal +# celulas_mergidas_subtotal = f"A{size}:I{size}" +# worksheet.merge_cells(celulas_mergidas_subtotal) +# left_celula_cell = f"A{size}" +# top_left_cell = worksheet[left_celula_cell] +# top_left_cell.value = "Sub Total" +# top_left_cell.fill = PatternFill(start_color=cinza, end_color=cinza,fill_type = "solid") +# top_left_cell.font = Font(name="Arial", size=12, color="000000",bold=True) +# top_left_cell.alignment = Alignment(horizontal="center",vertical="center") + + + + +# # FORMULATOTAL +# formula = f"=SUM(J10:J{size-1})" +# celula = f'J{size}' +# worksheet[celula] = formula +# worksheet[celula].fill = PatternFill(start_color=cinza, end_color=cinza,fill_type = "solid") +# worksheet[celula].font = Font(name="Arial", size=12, color="000000",bold=True) + + +# #restituições creditadas +# restituicoes = size + 1 +# celula_restituicoes=f'A{restituicoes}' +# worksheet[celula_restituicoes].value = "RESTITUIÇÕES CREDITADAS" +# worksheet[celula_restituicoes].font = Font(name="Arial", size=12, color="000000",bold=True) +# worksheet.row_dimensions[restituicoes].height = 30 + + +# #colunas azul +# row_style_obrig = NamedStyle(name='row_style_obrig') +# row_style_obrig.font = Font(name="Arial", size=12, color="FFFFFF",bold=True) +# row_style_obrig.fill = openpyxl.styles.PatternFill(start_color=azul, end_color=azul, fill_type='solid') +# row_style_obrig.alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) +# row_style_obrig.height = 30 + +# row_number = size + 2 + +# for column in range(1, 11): +# cell = worksheet.cell(row=row_number, column=column) +# cell.style = row_style_obrig + + +# values = ["Item","Restituidor","CNPJ/CPF",'Descrição',"Cheque equivalente","Data do Cheque",'Nº do Depósito','Data da Devolução','Valor'] +# coluna = 1 +# for a,b in enumerate(values): +# worksheet.cell(row=row_number, column=coluna, value=b) +# if coluna == 4: +# coluna = coluna + 1 +# coluna = coluna + 1 + + +# merge_formula = f'D{row_number}:E{row_number}' +# worksheet.merge_cells(merge_formula) + +# #subtotal2 +# sub_total2_row = size + 4 +# subtotal_merge_cells= f'A{sub_total2_row}:I{sub_total2_row}' +# worksheet.merge_cells(subtotal_merge_cells) +# top_left_subtotal2_cell_formula = f'A{sub_total2_row}' +# top_left_subtotal2_cell = worksheet[top_left_subtotal2_cell_formula] +# top_left_subtotal2_cell.value = "Sub Total 2" +# top_left_subtotal2_cell.fill = PatternFill(start_color=cinza, end_color=cinza,fill_type = "solid") +# top_left_subtotal2_cell.font = Font(name="Arial", size=12, color="000000",bold=True) +# top_left_subtotal2_cell.alignment = Alignment(horizontal="center",vertical="center") +# sub_formula_row_celula = f'J{sub_total2_row}' +# worksheet[sub_formula_row_celula].fill = PatternFill(start_color=cinza, end_color=cinza,fill_type = "solid") +# worksheet[sub_formula_row_celula].font = Font(name="Arial", size=12, color="000000",bold=True) + +# #subtotal12_Formula +# # sub_formula_row = size + 4 +# # sub_formula = f'=SOMA(J{sub_formula_row}:J{sub_formula_row})' +# # sub_formula_row_celula = f'J{sub_formula_row}' +# # worksheet[sub_formula_row_celula].fill = PatternFill(start_color=cinza, end_color=cinza,fill_type = "solid") +# # worksheet[sub_formula_row_celula] = sub_formula + + +# #total1-2 +# total12_row = size + 5 +# total12_merge_cells = f'A{total12_row}:I{total12_row}' +# worksheet.merge_cells(total12_merge_cells) +# top_left_total12_cell_formula = f'A{total12_row}' +# top_left_total12_cell = worksheet[top_left_total12_cell_formula] +# top_left_total12_cell.value = "Total(1 -2)" +# top_left_total12_cell.fill = PatternFill(start_color=azul, end_color=azul,fill_type = "solid") +# top_left_total12_cell.font = Font(name="Arial", size=12, color="000000",bold=True) +# top_left_total12_cell.alignment = Alignment(horizontal="center",vertical="center") + +# #total_formula +# total_formula_row = size + 5 +# total_formulaa = f'=J{size}' +# total_formula_row_celula = f'J{total_formula_row}' +# worksheet[total_formula_row_celula].fill = PatternFill(start_color=azul, end_color=azul,fill_type = "solid") +# worksheet[total_formula_row_celula].font = Font(name="Arial", size=12, color="000000",bold=True) +# worksheet[total_formula_row_celula].number_format = 'R$ #,##0.00' +# worksheet.row_dimensions[total_formula_row].height = 30 +# worksheet[total_formula_row_celula] = total_formulaa + +# #brasilia +# brasilia_row = size + 7 +# brasilia_formula = f"='Receita x Despesa'!A42:J42" +# brasilia_merge_cells = f'A{brasilia_row}:I{brasilia_row}' +# worksheet.merge_cells(brasilia_merge_cells) +# top_left_brasilia_cell_formula = f'A{brasilia_row}' +# top_left_brasilia_cell = worksheet[top_left_brasilia_cell_formula] +# top_left_brasilia_cell.value = brasilia_formula +# top_left_brasilia_cell.alignment = Alignment(horizontal="center",vertical="center") + +# #DiretorFinanceiro +# diretor_row = size + 8 +# diretor_cargo_row = size + 9 +# diretor_cpf_row = size + 10 +# diretor_nome_formula = f"='Receita x Despesa'!A45" +# diretor_cargo_formula = f"='Receita x Despesa'!A46" +# diretor_cpf_formula = f"='Receita x Despesa'!A47" +# diretor_merge_cells = f'A{diretor_row}:D{diretor_row}' +# diretor_cargo_merge_cells = f'A{diretor_cargo_row}:D{diretor_cargo_row}' +# diretor_cpf_merge_cells = f'A{diretor_cpf_row}:D{diretor_cpf_row}' +# worksheet.merge_cells(diretor_merge_cells) +# worksheet.merge_cells(diretor_cargo_merge_cells) +# worksheet.merge_cells(diretor_cpf_merge_cells) +# top_left_diretor_cell_formula = f'A{diretor_row}' +# top_left_diretor_cell_cargo_formula = f'A{diretor_cargo_row}' +# top_left_diretor_cell_cpf_formula = f'A{diretor_cpf_row}' +# top_left_diretor_cell = worksheet[top_left_diretor_cell_formula] +# top_left_diretor_cell_cargo_formula = worksheet[top_left_diretor_cell_cargo_formula] +# top_left_diretor_cell_cpf_formula = worksheet[top_left_diretor_cell_cpf_formula] +# top_left_diretor_cell.value = diretor_nome_formula +# top_left_diretor_cell_cargo_formula.value = diretor_cargo_formula +# top_left_diretor_cell_cpf_formula.value = diretor_cpf_formula +# top_left_diretor_cell.alignment = Alignment(horizontal="center",vertical="center") +# top_left_diretor_cell.font = Font(bold=True) +# top_left_diretor_cell_cargo_formula.alignment = Alignment(horizontal="center",vertical="center") +# top_left_diretor_cell_cpf_formula.alignment = Alignment(horizontal="center",vertical="center") +# #Coordenadora +# coordenadora_row = size + 8 +# coordenadora_cargo_row = size + 9 +# coordenadora_cpf_row = size + 10 +# coordenadora_nome_formula = f"='Receita x Despesa'!H45" +# coordenadora_cargo_formula = f"='Receita x Despesa'!H46" +# coordenadora_cpf_formula = f"='Receita x Despesa'!H47" +# coordenadora_merge_cells = f'F{coordenadora_row}:J{coordenadora_row}' +# coordenadora_cargo_merge_cells = f'F{coordenadora_cargo_row}:J{coordenadora_cargo_row}' +# coordenadora_cpf_merge_cells = f'F{coordenadora_cpf_row}:J{coordenadora_cpf_row}' +# worksheet.merge_cells(coordenadora_merge_cells) +# worksheet.merge_cells(coordenadora_cargo_merge_cells) +# worksheet.merge_cells(coordenadora_cpf_merge_cells) +# top_left_coordenadora_cell_formula = f'F{coordenadora_row}' +# top_left_coordenadora_cell_cargo_formula = f'F{coordenadora_cargo_row}' +# top_left_coordenadora_cell_cpf_formula = f'F{coordenadora_cpf_row}' +# top_left_coordenadora_cell = worksheet[top_left_coordenadora_cell_formula] +# top_left_coordenadora_cell_cargo_formula = worksheet[top_left_coordenadora_cell_cargo_formula] +# top_left_coordenadora_cell_cpf_formula = worksheet[top_left_coordenadora_cell_cpf_formula] +# top_left_coordenadora_cell.value = coordenadora_nome_formula +# top_left_coordenadora_cell_cargo_formula.value = coordenadora_cargo_formula +# top_left_coordenadora_cell_cpf_formula.value = coordenadora_cpf_formula +# top_left_coordenadora_cell.alignment = Alignment(horizontal="center",vertical="center") +# top_left_coordenadora_cell.font= Font(bold = True) +# top_left_coordenadora_cell_cargo_formula.alignment = Alignment(horizontal="center",vertical="center") +# top_left_coordenadora_cell_cpf_formula.alignment = Alignment(horizontal="center",vertical="center") + +# #nome dos indices + +# azul_claro = '1c89b8' +# row_style_cabecario_obrig = NamedStyle(name='row_style_cabecario_obrig') +# row_style_cabecario_obrig.font = Font(name="Arial", size=12, color="FFFFFF",bold=True) +# row_style_cabecario_obrig.fill = openpyxl.styles.PatternFill(start_color=azul_claro, end_color=azul_claro, fill_type='solid') +# row_style_cabecario_obrig.alignment = Alignment(horizontal="center",vertical="center",wrap_text = True) +# worksheet.row_dimensions[9].height = 50 +# worksheet.column_dimensions['b'].width = 35 +# worksheet.column_dimensions['c'].width = 20 +# worksheet.column_dimensions['d'].width = 35 +# worksheet.column_dimensions['e'].width = 60 +# worksheet.column_dimensions['f'].width = 35 +# worksheet.column_dimensions['g'].width = 30 +# worksheet.column_dimensions['h'].width = 30 +# worksheet.column_dimensions['i'].width = 30 +# worksheet.column_dimensions['j'].width = 30 +# worksheet.column_dimensions['e'].height = 20 + + +# linha_number = 9 +# # Apply the style to each cell in the row +# for cell in worksheet[linha_number]: +# cell.style = row_style_cabecario_obrig + +# valores = ["ITEM","NOME","CNPJ/CPF",'ESPECIFICAÇÃO DA DESPESA','DESCRIÇÃO',"Nº DO RECIBO OU EQUIVALENTE","DATA DE EMISSÃO",'CHEQUE / ORDEM BANCÁRIA','DATA DE PGTO','Valor'] +# col = 1 +# for a,b in enumerate(valores): +# worksheet.cell(row=linha_number, column=col, value=b) +# col = col + 1 + + +# #cabecario relação de pagamentos - outro servicoes de terceiros +# worksheet.merge_cells('A1:J2') +# worksheet['A1'] = f'R E L A Ç Ã O D E P A G A M E N T O S - P A S S A G E N S E D E S P E S A S C O M L O C O M O Ç Ã O' +# worksheet['A1'].font = Font(name="Arial", size=12, color="FFFFFF",bold=True) +# worksheet['A1'].alignment = Alignment(horizontal="center",vertical="center") +# worksheet['A1'].fill = PatternFill(start_color=azul_claro, end_color=azul_claro,fill_type = "solid") +# worksheet.merge_cells('A3:I3') +# worksheet['A3'] = "='Receita x Despesa'!A3:J3" +# worksheet['A3'].font = Font(name="Arial", size=12, color="000000") +# worksheet['A3'].alignment = Alignment(horizontal="left",vertical="center") + +# worksheet.merge_cells('A4:I4') +# worksheet['A4'] = "='Receita x Despesa'!A4:J4" +# worksheet['A4'].font = Font(name="Arial", size=12, color="000000") +# worksheet['A4'].alignment = Alignment(horizontal="left",vertical="center") + +# worksheet.merge_cells('A5:I5') +# worksheet['A5'] = "='Receita x Despesa'!A5:J5" +# worksheet['A5'].font = Font(name="Arial", size=12, color="000000") +# worksheet['A5'].alignment = Alignment(horizontal="left",vertical="center") + +# worksheet.merge_cells('A6:I6') +# worksheet['A6'] = "='Receita x Despesa'!A6:J6" +# worksheet['A6'].font = Font(name="Arial", size=12, color="000000") +# worksheet['A6'].alignment = Alignment(horizontal="left",vertical="center") + +# worksheet.merge_cells('A7:I7') +# worksheet['A7'] = "='Receita x Despesa'!A7:J7" +# worksheet['A7'].font = Font(name="Arial", size=12, color="000000") +# worksheet['A7'].alignment = Alignment(horizontal="left",vertical="center") + +# altura = 45 +# linha_inicio = 9 +# for row_number in range(linha_inicio, linha_inicio + tamanho+1): +# worksheet.row_dimensions[row_number].height = altura + + +# # Save the workbook to a file +# workbook.save(tabela) +# workbook.close() + +# def estilo_diarias(tabela,tamanho): +# caminho = pegar_caminho(tabela) +# workbook = openpyxl.load_workbook(caminho) +# worksheet = workbook['Diárias'] +# size = tamanho + 10 +# cinza = "d9d9d9" +# cinza_escuro = "bfbfbf" +# azul = "336394" +# azul_claro = '1c8cbc' + +# borda = Border(right=Side(border_style="medium")) +# worksheet.sheet_view.showGridLines = False +# # +# for row in worksheet.iter_rows(min_row=1, max_row=size+11,min_col=10,max_col=10): +# for cell in row: +# cell.border = borda + + +# worksheet.column_dimensions['a'].width = 25 +# worksheet.column_dimensions['b'].width = 25 +# worksheet.column_dimensions['c'].width = 35 +# worksheet.column_dimensions['d'].width = 40#descrição +# worksheet.column_dimensions['e'].width = 20 #n do recibo ou qeuivalente +# worksheet.column_dimensions['f'].width = 25 #data de emissão +# worksheet.column_dimensions['g'].width = 25 #data de emissão +# worksheet.column_dimensions['h'].width = 25 #data de emissão +# worksheet.column_dimensions['i'].width = 25 #data de emissão +# worksheet.column_dimensions['j'].width = 25 #data de emissão + + +# #cabecario relação de pagamentos - outro servicoes de terceiros +# worksheet.merge_cells('A1:J2') +# worksheet['A1'] = f'R E L A Ç Ã O D E P A G A M E N T O S - DIÁRIAS' +# worksheet['A1'].font = Font(name="Arial", size=12, color="FFFFFF",bold=True) +# worksheet['A1'].alignment = Alignment(horizontal="center",vertical="center") +# worksheet['A1'].fill = PatternFill(start_color=azul_claro, end_color=azul_claro,fill_type = "solid") + +# worksheet.merge_cells('A3:F3') +# worksheet['A3'] = "='Receita x Despesa'!A3:J3" +# worksheet['A3'].font = Font(name="Arial", size=12, color="000000") +# worksheet['A3'].alignment = Alignment(horizontal="left",vertical="center") + +# worksheet.merge_cells('A4:F4') +# worksheet['A4'] = "='Receita x Despesa'!A4:J4" +# worksheet['A4'].font = Font(name="Arial", size=12, color="000000") +# worksheet['A4'].alignment = Alignment(horizontal="left",vertical="center") + +# worksheet.merge_cells('A5:F5') +# worksheet['A5'] = "='Receita x Despesa'!A5:J5" +# worksheet['A5'].font = Font(name="Arial", size=12, color="000000") +# worksheet['A5'].alignment = Alignment(horizontal="left",vertical="center") + +# worksheet.merge_cells('A6:F6') +# worksheet['A6'] = "='Receita x Despesa'!A6:J6" +# worksheet['A6'].font = Font(name="Arial", size=12, color="000000") +# worksheet['A6'].alignment = Alignment(horizontal="left",vertical="center") + +# worksheet.merge_cells('A7:F7') +# worksheet['A7'] = "='Receita x Despesa'!A7:J7" +# worksheet['A7'].font = Font(name="Arial", size=12, color="000000") +# worksheet['A7'].alignment = Alignment(horizontal="left",vertical="center") + +# #colunas azul cabecario +# row_style_diaria = NamedStyle(name='row_style_diaria') +# row_style_diaria.font = Font(name="Arial", size=12, color="FFFFFF",bold=True) +# row_style_diaria.fill = openpyxl.styles.PatternFill(start_color=azul_claro, end_color=azul_claro, fill_type='solid') +# row_style_diaria.alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) +# row_style_diaria.border = Border(top=Side(border_style="medium") ,bottom=Side(border_style="thin") ) +# row_style_diaria.height = 20 +# linha_number = 9 +# for row in worksheet.iter_rows(min_row=linha_number, max_row=linha_number, min_col=1, max_col=10): +# for cell in row: +# cell.style = row_style_diaria +# if cell.column == 10: +# cell.border = Border(top=Side(border_style="medium") ,bottom=Side(border_style="thin"), right=Side(border_style="medium") ) + +# valores = ["ITEM","NOME","CNPJ/CPF",'ESPECIFICAÇÃO DA DESPESA','DESCRIÇÃO',"Nº DO RECIBO OU EQUIVALENTE","DATA DE EMISSÃO",'CHEQUE / ORDEM BANCÁRIA','DATA DE PGTO','Valor'] +# col = 1 +# for a,b in enumerate(valores): +# worksheet.cell(row=linha_number, column=col, value=b) +# col = col + 1 + + +# #Aumentar a altura das celulas +# for row in worksheet.iter_rows(min_row=10, max_row=size, min_col=1, max_col=10): +# worksheet.row_dimensions[row[0].row].height = 35 + +# custom_number_format_diaria = [] +# # MASCARA R$ +# if custom_number_format_diaria!= False: +# custom_number_format_diaria = NamedStyle(name='custom_number_format_diaria') +# custom_number_format_diaria.number_format = 'R$ #,##0.00' +# custom_number_format_diaria.font = Font(name="Arial", size=12, color="000000") +# custom_number_format_diaria.alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + +# #estilocinzasimcinzanao +# value_to_stop = size +# start_row = 10 +# # +# for row in range(start_row,size+1): +# cell = worksheet[f'J{row}'] +# cell.style = custom_number_format_diaria + +# for rows in worksheet.iter_rows(min_row=10, max_row=size, min_col=1, max_col=10): +# for cell in rows: +# if cell.row % 2: +# cell.fill = PatternFill(start_color=cinza, end_color=cinza, +# fill_type = "solid") +# if cell.column == 10: +# cell.font = Font(name="Arial", size=12, color="000000") +# cell.alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) +# cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,right =Side(border_style="medium") ,bottom=Side(border_style="hair") ) +# else: +# cell.font = Font(name="Arial", size=12, color="000000") +# cell.alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) +# cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,right =Side(border_style="hair") ,bottom=Side(border_style="hair") ) + + +# #subtotal +# stringAfinarCelula =size+2 +# worksheet.row_dimensions[size+2].height = 6 +# celulas_mergidas_subtotal = f"A{size+2}:I{size+2}" +# worksheet.merge_cells(celulas_mergidas_subtotal) +# left_celula_cell = f"A{size+2}" +# top_left_cell = worksheet[left_celula_cell] +# top_left_cell.value = "Sub Total1" +# top_left_cell.fill = PatternFill(start_color=cinza, end_color=cinza,fill_type = "solid") +# top_left_cell.font = Font(name="Arial", size=12, color="000000",bold=True) +# top_left_cell.alignment = Alignment(horizontal="center",vertical="center") +# top_left_cell.border = Border(top=Side(border_style="thin") ,left = Side(border_style="medium") ,right =Side(border_style="thin") ,bottom=Side(border_style="medium") ) + +# worksheet.row_dimensions[size+2].height = 56.25 + +# # FORMULATOTAL +# formula = f"=SUM(J10:J{size})" +# celula = f'J{size+2}' +# worksheet[celula] = formula +# worksheet[celula].fill = PatternFill(start_color=cinza, end_color=cinza,fill_type = "solid") +# worksheet[celula].font = Font(name="Arial", size=12, color="000000",bold=True) +# worksheet[celula].border = Border(top=Side(border_style="thin") ,left = Side(border_style="thin") ,right =Side(border_style="medium") ,bottom=Side(border_style="medium") ) +# worksheet[celula].number_format = 'R$ #,##0.00' +# #restituições creditadas +# restituicoes = size + 3 +# celula_restituicoes=f'A{restituicoes}' +# worksheet[celula_restituicoes].value = "RESTITUIÇÕES CREDITADAS" +# worksheet[celula_restituicoes].font = Font(name="Arial", size=12, color="000000",bold=True) +# worksheet.row_dimensions[restituicoes].height = 30 + +# #estilo colunas restitucoes creditadas +# row_style_diaria_append = NamedStyle(name='row_style_diaria_append') +# row_style_diaria_append.font = Font(name="Arial", size=12, color="FFFFFF",bold=True) +# row_style_diaria_append.fill = openpyxl.styles.PatternFill(start_color=azul_claro, end_color=azul_claro, fill_type='solid') +# row_style_diaria_append.alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) +# row_style_diaria_append.height = 30 +# row_style_diaria_append.border = Border(top=Side(border_style="medium") ,bottom=Side(border_style="medium") ) + + +# row_number = size + 4 + +# for column in range(1, 11): +# cell = worksheet.cell(row=row_number, column=column) +# cell.style = row_style_diaria_append +# if cell.column == 10: +# cell.border = Border(top=Side(border_style="medium") ,right =Side(border_style="medium") ,bottom=Side(border_style="medium") ) + + + +# values = ["Item","Restituidor","CNPJ/CPF",'Descrição',"Cheque equivalente","Data do Cheque",'Nº do Depósito','Data da Devolução','Valor'] +# coluna = 1 +# for a,b in enumerate(values): +# worksheet.cell(row=row_number, column=coluna, value=b) +# if coluna == 4: +# coluna = coluna + 1 +# coluna = coluna + 1 + + +# merge_formula = f'D{row_number}:E{row_number}' +# worksheet.merge_cells(merge_formula) + + +# #subtotal2 +# sub_total2_row = size + 5 +# subtotal_merge_cells= f'A{sub_total2_row}:I{sub_total2_row}' +# worksheet.merge_cells(subtotal_merge_cells) +# top_left_subtotal2_cell_formula = f'A{sub_total2_row}' +# top_left_subtotal2_cell = worksheet[top_left_subtotal2_cell_formula] +# top_left_subtotal2_cell.value = "Sub Total 2" +# top_left_subtotal2_cell.fill = PatternFill(start_color=cinza_escuro, end_color=cinza_escuro,fill_type = "solid") +# top_left_subtotal2_cell.font = Font(name="Arial", size=12, color="000000",bold=True) +# top_left_subtotal2_cell.alignment = Alignment(horizontal="center",vertical="center") +# top_left_subtotal2_cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="medium") ,right =Side(border_style="hair") ,bottom=Side(border_style="medium") ) + +# sub_formula_row_celula = f'J{sub_total2_row}' +# worksheet[sub_formula_row_celula].fill = PatternFill(start_color=cinza_escuro, end_color=cinza_escuro,fill_type = "solid") +# worksheet[sub_formula_row_celula].font = Font(name="Arial", size=12, color="000000",bold=True) +# worksheet[sub_formula_row_celula].number_format = 'R$ #,##0.00' +# worksheet[sub_formula_row_celula].border = Border(top=Side(border_style="thin") ,left = Side(border_style="thin") ,right =Side(border_style="medium") ,bottom=Side(border_style="medium") ) + +# #total1-2 +# total12_row = size + 6 +# total12_merge_cells = f'A{total12_row}:I{total12_row}' +# worksheet.merge_cells(total12_merge_cells) +# top_left_total12_cell_formula = f'A{total12_row}' +# top_left_total12_cell = worksheet[top_left_total12_cell_formula] +# top_left_total12_cell.value = "Total(1-2)" +# top_left_total12_cell.fill = PatternFill(start_color=azul_claro, end_color=azul_claro,fill_type = "solid") +# top_left_total12_cell.font = Font(name="Arial", size=12, color="000000",bold=True) +# top_left_total12_cell.alignment = Alignment(horizontal="center",vertical="center") +# top_left_total12_cell.border = Border(top=Side(border_style="medium") ,left = Side(border_style="medium") ,bottom=Side(border_style="medium") ) + + +# #total_formula +# total_formula_row = size + 6 +# total_formulaa = f'=J{size}' +# total_formula_row_celula = f'J{total_formula_row}' +# worksheet[total_formula_row_celula].fill = PatternFill(start_color=azul_claro, end_color=azul_claro,fill_type = "solid") +# worksheet[total_formula_row_celula].font = Font(name="Arial", size=12, color="000000",bold=True) +# worksheet[total_formula_row_celula].number_format = 'R$ #,##0.00' +# worksheet[total_formula_row_celula].border = Border(top=Side(border_style="medium") ,bottom=Side(border_style="medium"),right=Side(border_style="medium") ) + +# worksheet.row_dimensions[total_formula_row].height = 30 +# worksheet[total_formula_row_celula] = total_formulaa + + +# #brasilia +# brasilia_row = size + 7 +# brasilia_formula = f"='Receita x Despesa'!A42:J42" +# brasilia_merge_cells = f'A{brasilia_row}:I{brasilia_row}' +# worksheet.merge_cells(brasilia_merge_cells) +# top_left_brasilia_cell_formula = f'A{brasilia_row}' +# top_left_brasilia_cell = worksheet[top_left_brasilia_cell_formula] +# top_left_brasilia_cell.value = brasilia_formula +# top_left_brasilia_cell.alignment = Alignment(horizontal="center",vertical="center") + +# #DiretorFinanceiro +# diretor_row = size + 8 +# diretor_cargo_row = size + 9 +# diretor_cpf_row = size + 10 +# diretor_nome_formula = f"='Receita x Despesa'!A45" +# diretor_cargo_formula = f"='Receita x Despesa'!A46" +# diretor_cpf_formula = f"='Receita x Despesa'!A47" +# diretor_merge_cells = f'A{diretor_row}:D{diretor_row}' +# diretor_cargo_merge_cells = f'A{diretor_cargo_row}:D{diretor_cargo_row}' +# diretor_cpf_merge_cells = f'A{diretor_cpf_row}:D{diretor_cpf_row}' +# worksheet.merge_cells(diretor_merge_cells) +# worksheet.merge_cells(diretor_cargo_merge_cells) +# worksheet.merge_cells(diretor_cpf_merge_cells) +# top_left_diretor_cell_formula = f'A{diretor_row}' +# top_left_diretor_cell_cargo_formula = f'A{diretor_cargo_row}' +# top_left_diretor_cell_cpf_formula = f'A{diretor_cpf_row}' +# top_left_diretor_cell = worksheet[top_left_diretor_cell_formula] +# top_left_diretor_cell_cargo_formula = worksheet[top_left_diretor_cell_cargo_formula] +# top_left_diretor_cell_cpf_formula = worksheet[top_left_diretor_cell_cpf_formula] +# top_left_diretor_cell.value = diretor_nome_formula +# top_left_diretor_cell_cargo_formula.value = diretor_cargo_formula +# top_left_diretor_cell_cpf_formula.value = diretor_cpf_formula +# top_left_diretor_cell.alignment = Alignment(horizontal="center",vertical="center") +# top_left_diretor_cell.font = Font(bold=True) +# top_left_diretor_cell_cargo_formula.alignment = Alignment(horizontal="center",vertical="center") +# top_left_diretor_cell_cpf_formula.alignment = Alignment(horizontal="center",vertical="center") +# #Coordenadora +# coordenadora_row = size + 8 +# coordenadora_cargo_row = size + 9 +# coordenadora_cpf_row = size + 10 +# coordenadora_nome_formula = f"='Receita x Despesa'!H45" +# coordenadora_cargo_formula = f"='Receita x Despesa'!H46" +# coordenadora_cpf_formula = f"='Receita x Despesa'!H47" +# coordenadora_merge_cells = f'F{coordenadora_row}:J{coordenadora_row}' +# coordenadora_cargo_merge_cells = f'F{coordenadora_cargo_row}:J{coordenadora_cargo_row}' +# coordenadora_cpf_merge_cells = f'F{coordenadora_cpf_row}:J{coordenadora_cpf_row}' +# worksheet.merge_cells(coordenadora_merge_cells) +# worksheet.merge_cells(coordenadora_cargo_merge_cells) +# worksheet.merge_cells(coordenadora_cpf_merge_cells) +# top_left_coordenadora_cell_formula = f'F{coordenadora_row}' +# top_left_coordenadora_cell_cargo_formula = f'F{coordenadora_cargo_row}' +# top_left_coordenadora_cell_cpf_formula = f'F{coordenadora_cpf_row}' +# top_left_coordenadora_cell = worksheet[top_left_coordenadora_cell_formula] +# top_left_coordenadora_cell_cargo_formula = worksheet[top_left_coordenadora_cell_cargo_formula] +# top_left_coordenadora_cell_cpf_formula = worksheet[top_left_coordenadora_cell_cpf_formula] +# top_left_coordenadora_cell.value = coordenadora_nome_formula +# top_left_coordenadora_cell_cargo_formula.value = coordenadora_cargo_formula +# top_left_coordenadora_cell_cpf_formula.value = coordenadora_cpf_formula +# top_left_coordenadora_cell.alignment = Alignment(horizontal="center",vertical="center") +# top_left_coordenadora_cell.font= Font(bold = True) +# top_left_coordenadora_cell_cargo_formula.alignment = Alignment(horizontal="center",vertical="center") +# top_left_coordenadora_cell_cpf_formula.alignment = Alignment(horizontal="center",vertical="center") + + +# # borda = Border(right=Side(border_style="medium")) +# # worksheet.sheet_view.showGridLines = False +# # # +# # for row in worksheet.iter_rows(min_row=1, max_row=coordenadora_cpf_row+1,min_col=10,max_col=10): +# # for cell in row: +# # cell.border = borda + + + +# for row in worksheet.iter_rows(min_row=coordenadora_cpf_row+1, max_row=coordenadora_cpf_row+1,min_col=1,max_col=10): +# for cell in row: +# if cell.column == 10: +# cell.border = Border(top=Side(border_style="none") ,left = Side(border_style="none") ,right =Side(border_style="medium") ,bottom=Side(border_style="medium") ) +# else: +# cell.border = Border(top=Side(border_style="none") ,left = Side(border_style="none") ,right =Side(border_style="none") ,bottom=Side(border_style="medium") ) + +# workbook.save(tabela) +# workbook.close() + + diff --git a/project/app/estilo_fundep.py b/project/app/estilo_fundep.py new file mode 100644 index 00000000..42bf8558 --- /dev/null +++ b/project/app/estilo_fundep.py @@ -0,0 +1,82 @@ +import openpyxl +from openpyxl.styles import Font, PatternFill, Alignment,NamedStyle,Border, Side +import os +from datetime import datetime,date + +def pegar_caminho(nome_arquivo): + + # Obter o caminho absoluto do arquivo Python em execução + caminho_script = os.path.abspath(__file__) + + # Obter o diretório da pasta onde o script está localizado + pasta_script = os.path.dirname(caminho_script) + + # Combinar o caminho da pasta com o nome do arquivo Excel + caminho = os.path.join(pasta_script, nome_arquivo) + + return caminho +def estilo_fundep(tabela,tamanho): + + # caminho = pegar_caminho(tabela) + workbook = openpyxl.load_workbook(tabela) + worksheet = workbook['Relação de despesas'] + ######periodo de prestação de contas + + + #corpo + size = tamanho + 6 + print(size) + + custom_number_format = [] + # MASCARA R$ + if custom_number_format!= False: + custom_number_format = NamedStyle(name='custom_number_format') + custom_number_format.number_format = 'R$ #,##0.00' + custom_number_format.font = Font(name="Calibri", size=11, color="000000") + custom_number_format.alignment = Alignment(horizontal="general",vertical="bottom",wrap_text=True) + + value_to_stop = size + start_row = 7 + for row in range(start_row,size+2): + cell = worksheet[f'J{row}'] + cell.style = custom_number_format + + #Bordas + for rows in worksheet.iter_rows(min_row=7, max_row=size, min_col=1, max_col=10): + for cell in rows: + cell.font = Font(name="Calibri", size=11, color="000000") + cell.alignment = Alignment(horizontal="general",vertical="bottom",wrap_text=True) + cell.border = Border(top=Side(border_style="thin") ,left = Side(border_style="thin") ,right =Side(border_style="thin") ,bottom=Side(border_style="thin") ) + + + #total despesas nesta + total_despesa_string_LOCATION_merge = f'A{size+1}:I{size+1}' + worksheet.merge_cells(total_despesa_string_LOCATION_merge) + total_despesa_string_LOCATION = f'A{size+1}' + worksheet[total_despesa_string_LOCATION] = f'TOTAL DE DESPESAS NESTA' + worksheet[total_despesa_string_LOCATION].alignment = Alignment(horizontal="right",vertical="center",wrap_text = True) + worksheet[total_despesa_string_LOCATION].fill= PatternFill(start_color='d9d9d9',end_color='d9d9d9',fill_type='solid') + + #Total Nessa + formula = f"=SUM(J7:J{size})" + formulat_total_location = f'J{size+1}' + worksheet[formulat_total_location]= formula = f"=SUM(J10:J{size-1})" + worksheet[formulat_total_location].font=Font(bold=True) + + #total de despesas Acumuladas + total_despesa_string_LOCATION_merge_acumuladas = f'A{size+2}:I{size+2}' + worksheet.merge_cells(total_despesa_string_LOCATION_merge_acumuladas) + total_despesa_string_LOCATION_acumuladas = f'A{size+2}' + worksheet[total_despesa_string_LOCATION_acumuladas] = f'TOTAL DE DESPESAS ACUMULADAS' + worksheet[total_despesa_string_LOCATION_acumuladas].alignment = Alignment(horizontal="right",vertical="center",wrap_text = True) + worksheet[total_despesa_string_LOCATION_acumuladas].fill= PatternFill(start_color='d9d9d9',end_color='d9d9d9',fill_type='solid') + + #Total de despesas Acumuladas + + total_despesa_string_LOCATION_acumuladas_valor = f'J{size+2}' + worksheet[total_despesa_string_LOCATION_acumuladas_valor].font=Font(bold=True) + + workbook.save(tabela) + workbook.close() + + diff --git a/project/app/migrations/0001_initial.py b/project/app/migrations/0001_initial.py new file mode 100644 index 00000000..de25f519 --- /dev/null +++ b/project/app/migrations/0001_initial.py @@ -0,0 +1,124 @@ +# Generated by Django 4.2.5 on 2023-10-27 11:29 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Export', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('data_export', models.DateTimeField(auto_now_add=True)), + ('formato', models.CharField(max_length=200)), + ('nome_template', models.CharField(max_length=200)), + ('nome_usuario', models.CharField(max_length=200)), + ('id_projeto', models.CharField(max_length=50)), + ], + ), + migrations.CreateModel( + name='Mapeamento', + fields=[ + ('id_mapeamento', models.IntegerField(primary_key=True, serialize=False)), + ('codigo', models.CharField(max_length=200)), + ('nome', models.CharField(max_length=200)), + ('saldo', models.CharField(max_length=200)), + ('data_assinatura', models.CharField(max_length=200)), + ('data_vigencia', models.CharField(max_length=200)), + ('data_encerramento', models.CharField(max_length=200)), + ('tipo_contrato', models.CharField(max_length=200)), + ('instituicao_executora', models.CharField(max_length=200)), + ('processo', models.CharField(max_length=200)), + ('subprocesso', models.CharField(max_length=200)), + ('cod_proposta', models.CharField(max_length=200)), + ('proposta', models.CharField(max_length=200)), + ('objetivos', models.CharField(max_length=200)), + ('valor_aprovado', models.CharField(max_length=200)), + ('nome_tp_controle_saldo', models.CharField(max_length=200)), + ('grupo_gestores', models.CharField(max_length=200)), + ('gestor_resp', models.CharField(max_length=200)), + ('coordenador', models.CharField(max_length=200)), + ('procedimento_compra', models.CharField(max_length=200)), + ('tab_frete', models.CharField(max_length=200)), + ('tab_diarias', models.CharField(max_length=200)), + ('custo_op', models.CharField(max_length=200)), + ('nome_financiador', models.CharField(max_length=200)), + ('departamento', models.CharField(max_length=200)), + ('situacao', models.CharField(max_length=200)), + ('banco', models.CharField(max_length=200)), + ('agencia_bancaria', models.CharField(max_length=200)), + ('conta_bancaria', models.CharField(max_length=200)), + ('centro_custo', models.CharField(max_length=200)), + ('conta_caixa', models.CharField(max_length=200)), + ('categoria_projeto', models.CharField(max_length=200)), + ('cod_convenio_conta', models.CharField(max_length=200)), + ('cod_status', models.CharField(max_length=200)), + ('ind_sub_projeto', models.CharField(max_length=200)), + ('tipo_custo_op', models.CharField(max_length=200)), + ('projeto_mae', models.CharField(max_length=200)), + ('id_coordenador', models.CharField(max_length=200)), + ('id_financiador', models.CharField(max_length=200)), + ('id_instituicao', models.CharField(max_length=200)), + ('id_departamento', models.CharField(max_length=200)), + ('nome_instituicao', models.CharField(max_length=200)), + ('id_instituicao_executora', models.CharField(max_length=200)), + ('id_tipo', models.CharField(max_length=201)), + ], + ), + migrations.CreateModel( + name='MapeamentoConveniar', + fields=[ + ('id_mapeamento', models.IntegerField(primary_key=True, serialize=False)), + ('id_favorecido', models.CharField(max_length=200)), + ('nome_favorecido', models.CharField(max_length=200)), + ('cnpj_favorecido', models.CharField(max_length=200)), + ('tipo_favorecido', models.CharField(max_length=200)), + ('valor_lancado', models.CharField(max_length=200)), + ('valor_pago', models.CharField(max_length=200)), + ('data_vencimento', models.CharField(max_length=200)), + ('id_status', models.CharField(max_length=200)), + ('status_lancamento', models.CharField(max_length=200)), + ('flag_receita', models.CharField(max_length=200)), + ('data_baixa', models.CharField(max_length=200)), + ('his_lancamento', models.CharField(max_length=200)), + ('data_emissao', models.CharField(max_length=200)), + ('num_doc_fin', models.CharField(max_length=200)), + ('data_cria', models.CharField(max_length=200)), + ('data_pagamento', models.CharField(max_length=200)), + ('id_lancamento', models.CharField(max_length=200)), + ('id_projeto', models.CharField(max_length=200)), + ('id_rubrica', models.CharField(max_length=200)), + ('nome_rubrica', models.CharField(max_length=200)), + ('tipo_movimento', models.CharField(max_length=200)), + ('id_tp_lancamento', models.CharField(max_length=200)), + ('tipo_lancamento', models.CharField(max_length=200)), + ], + ), + migrations.CreateModel( + name='Report', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('titulo', models.CharField(max_length=200)), + ('descricao', models.CharField(max_length=200)), + ('tipo_erro', models.CharField(choices=[('erro1', 'Falta de informação no projeto'), ('erro2', 'Campo preenchido incorretamente')], max_length=20)), + ('id_projeto', models.CharField(max_length=50)), + ('nome_usuario', models.CharField(max_length=200)), + ], + ), + migrations.CreateModel( + name='Template', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('nome_template', models.CharField(max_length=200)), + ('endereco_template', models.CharField(max_length=200)), + ('mapeamento', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='app.mapeamento')), + ], + ), + ] diff --git a/project/app/migrations/0002_rename_agencia_bancaria_mapeamento_agencia_bancaria_and_more.py b/project/app/migrations/0002_rename_agencia_bancaria_mapeamento_agencia_bancaria_and_more.py new file mode 100644 index 00000000..7f555884 --- /dev/null +++ b/project/app/migrations/0002_rename_agencia_bancaria_mapeamento_agencia_bancaria_and_more.py @@ -0,0 +1,17 @@ +# Generated by Django 4.2.5 on 2023-10-27 11:30 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('app', '0001_initial'), + ] + + operations = [ + migrations.RenameModel( + old_name='MapeamentoConveniar', + new_name='Lancamento', + ), + ] diff --git a/project/app/migrations/0003_alter_mapeamento_id_tipo.py b/project/app/migrations/0003_alter_mapeamento_id_tipo.py new file mode 100644 index 00000000..617f6ce0 --- /dev/null +++ b/project/app/migrations/0003_alter_mapeamento_id_tipo.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.7 on 2023-11-13 23:55 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('app', '0002_rename_agencia_bancaria_mapeamento_agencia_bancaria_and_more'), + ] + + operations = [ + migrations.AlterField( + model_name='mapeamento', + name='id_tipo', + field=models.CharField(max_length=200), + ), + ] diff --git a/project/app/migrations/__pycache__/0001_initial.cpython-38.pyc b/project/app/migrations/__pycache__/0001_initial.cpython-38.pyc new file mode 100644 index 00000000..f762d35b Binary files /dev/null and b/project/app/migrations/__pycache__/0001_initial.cpython-38.pyc differ diff --git a/project/app/migrations/__pycache__/0002_rename_agencia_bancaria_mapeamento_agencia_bancaria_and_more.cpython-38.pyc b/project/app/migrations/__pycache__/0002_rename_agencia_bancaria_mapeamento_agencia_bancaria_and_more.cpython-38.pyc new file mode 100644 index 00000000..1f16a19d Binary files /dev/null and b/project/app/migrations/__pycache__/0002_rename_agencia_bancaria_mapeamento_agencia_bancaria_and_more.cpython-38.pyc differ diff --git a/project/app/migrations/__pycache__/0003_alter_mapeamento_id_tipo.cpython-38.pyc b/project/app/migrations/__pycache__/0003_alter_mapeamento_id_tipo.cpython-38.pyc new file mode 100644 index 00000000..0b5eb3dc Binary files /dev/null and b/project/app/migrations/__pycache__/0003_alter_mapeamento_id_tipo.cpython-38.pyc differ diff --git a/project/app/migrations/__pycache__/__init__.cpython-310.pyc b/project/app/migrations/__pycache__/__init__.cpython-310.pyc index b421a4db..59e9df92 100644 Binary files a/project/app/migrations/__pycache__/__init__.cpython-310.pyc and b/project/app/migrations/__pycache__/__init__.cpython-310.pyc differ diff --git a/project/app/migrations/__pycache__/__init__.cpython-311.pyc b/project/app/migrations/__pycache__/__init__.cpython-311.pyc index 1e5eca08..f1933ca1 100644 Binary files a/project/app/migrations/__pycache__/__init__.cpython-311.pyc and b/project/app/migrations/__pycache__/__init__.cpython-311.pyc differ diff --git a/project/app/migrations/__pycache__/__init__.cpython-38.pyc b/project/app/migrations/__pycache__/__init__.cpython-38.pyc new file mode 100644 index 00000000..f4eaebd1 Binary files /dev/null and b/project/app/migrations/__pycache__/__init__.cpython-38.pyc differ diff --git a/project/app/models.py b/project/app/models.py index 71a83623..13aceae7 100644 --- a/project/app/models.py +++ b/project/app/models.py @@ -1,3 +1,98 @@ from django.db import models -# Create your models here. +class Mapeamento(models.Model): + id_mapeamento = models.IntegerField(primary_key=True) + codigo = models.CharField(max_length=200) + nome = models.CharField(max_length=200) + saldo = models.CharField(max_length=200) + data_assinatura = models.CharField(max_length=200) + data_vigencia = models.CharField(max_length=200) + data_encerramento = models.CharField(max_length=200) + tipo_contrato = models.CharField(max_length=200) + instituicao_executora = models.CharField(max_length=200) + processo = models.CharField(max_length=200) + subprocesso = models.CharField(max_length=200) + cod_proposta = models.CharField(max_length=200) + proposta = models.CharField(max_length=200) + objetivos = models.CharField(max_length=200) + valor_aprovado = models.CharField(max_length=200) + nome_tp_controle_saldo = models.CharField(max_length=200) + grupo_gestores = models.CharField(max_length=200) + gestor_resp = models.CharField(max_length=200) + coordenador = models.CharField(max_length=200) + procedimento_compra = models.CharField(max_length=200) + tab_frete = models.CharField(max_length=200) + tab_diarias = models.CharField(max_length=200) + custo_op = models.CharField(max_length=200) + nome_financiador = models.CharField(max_length=200) + departamento = models.CharField(max_length=200) + situacao = models.CharField(max_length=200) + banco = models.CharField(max_length=200) + agencia_bancaria = models.CharField(max_length=200) + conta_bancaria = models.CharField(max_length=200) + centro_custo = models.CharField(max_length=200) + conta_caixa = models.CharField(max_length=200) + categoria_projeto = models.CharField(max_length=200) + cod_convenio_conta = models.CharField(max_length=200) + cod_status = models.CharField(max_length=200) + ind_sub_projeto = models.CharField(max_length=200) + tipo_custo_op = models.CharField(max_length=200) + projeto_mae = models.CharField(max_length=200) + id_coordenador = models.CharField(max_length=200) + id_financiador = models.CharField(max_length=200) + id_instituicao = models.CharField(max_length=200) + id_departamento = models.CharField(max_length=200) + nome_instituicao = models.CharField(max_length=200) + id_instituicao_executora = models.CharField(max_length=200) + id_tipo = models.CharField(max_length=200) + +class Lancamento(models.Model): + id_mapeamento = models.IntegerField(primary_key=True) + id_favorecido = models.CharField(max_length=200) + nome_favorecido = models.CharField(max_length=200) + cnpj_favorecido = models.CharField(max_length=200) + tipo_favorecido = models.CharField(max_length=200) + valor_lancado = models.CharField(max_length=200) + valor_pago = models.CharField(max_length=200) + data_vencimento = models.CharField(max_length=200) + id_status = models.CharField(max_length=200) + status_lancamento = models.CharField(max_length=200) + flag_receita = models.CharField(max_length=200) + data_baixa = models.CharField(max_length=200) + his_lancamento = models.CharField(max_length=200) + data_emissao = models.CharField(max_length=200) + num_doc_fin = models.CharField(max_length=200) + data_cria = models.CharField(max_length=200) + data_pagamento = models.CharField(max_length=200) + id_lancamento = models.CharField(max_length=200) + id_projeto = models.CharField(max_length=200) + id_rubrica = models.CharField(max_length=200) + nome_rubrica = models.CharField(max_length=200) + tipo_movimento = models.CharField(max_length=200) + id_tp_lancamento = models.CharField(max_length=200) + tipo_lancamento = models.CharField(max_length=200) + +class Template(models.Model): + nome_template = models.CharField(max_length=200) + endereco_template = models.CharField(max_length=200) + mapeamento = models.ForeignKey(Mapeamento, on_delete=models.CASCADE) + +class Report(models.Model): + titulo = models.CharField(max_length=200) + descricao = models.CharField(max_length=200) + + TIPO_ERRO_CHOICES = ( + ('erro1', 'Falta de informação no projeto'), + ('erro2', 'Campo preenchido incorretamente'), + # Adicione mais opções conforme necessário + ) + tipo_erro = models.CharField(max_length=20, choices=TIPO_ERRO_CHOICES) + id_projeto = models.CharField(max_length=50) + nome_usuario = models.CharField(max_length=200) + +class Export(models.Model): + data_export = models.DateTimeField(auto_now_add=True) + formato = models.CharField(max_length=200) + nome_template = models.CharField(max_length=200) + nome_usuario = models.CharField(max_length=200) + id_projeto = models.CharField(max_length=50) diff --git a/project/app/new_dev.py b/project/app/new_dev.py new file mode 100644 index 00000000..c5f1e2dd --- /dev/null +++ b/project/app/new_dev.py @@ -0,0 +1,225 @@ +import openpyxl as op +import datetime +import os + + +def pegar_caminho(nome_arquivo): + + # Obter o caminho absoluto do arquivo Python em execução + caminho_script = os.path.abspath(__file__) + + # Obter o diretório da pasta onde o script está localizado + pasta_script = os.path.dirname(caminho_script) + + # Combinar o caminho da pasta com o nome do arquivo Excel + caminho = os.path.join(pasta_script, nome_arquivo) + + return caminho + +def preenche_planilha(planilha, dicionario): + + caminho = pegar_caminho(planilha) + Plan = planilha + # carrega a planilha de acordo com o caminho + workbook = op.load_workbook(caminho) + + # planilha_preenchida = pegar_caminho('preenchido-' + planilha) + for nomePlanilha, entradaDados in dicionario.items(): + planilhaAtual = workbook[nomePlanilha] + + for intervaloCelula, entradaCelula in entradaDados: + if ":" in intervaloCelula: + inicioCelula, fimCelula = intervaloCelula.split(":") + planilhaAtual = workbook[nomePlanilha] + planilhaAtual[inicioCelula] = entradaCelula + # planilhaAtual[inicioCelula].fill = color <--- teste com cores + else: + planilhaAtual[intervaloCelula] = entradaCelula + # planilhaAtual[intervaloCelula].fill = color <--- teste com cores + + + workbook.save(f"app/planilhas_preenchidas/{planilha}") + + print(f"arquivo salvo como planilhas_preenchidas/{planilha}") + return f"app/planilhas_preenchidas/{planilha}" + +# workbook = op.load_workbook('Modelo_Fub.xlsm') +# number = 3108 + +# value = datetime.datetime.strptime("2014-06-23", "%Y-%m-%d") +def extrair(text_list): + start_delimiter = "@@" + end_delimiter = "@@" + extracted_texts = [] + + for text in text_list: + start = text.find(start_delimiter) + if start != -1: + start += len(start_delimiter) + end = text.find(end_delimiter, start) + if end != -1: + extracted_texts.append(text[start:end]) + + return extracted_texts + + + +planilha_local_dados = { + "Receita x Despesa": [ + ("A3:J3", "Título do Projeto:String 1 A3:J3"), + ("A4:J4", "Executora: String 2 A4:J4"), + ("A5:J5", "Partícipe: String 3 A5:J5"), + ("A6:J6", "Período de Execução Físico-Financeiro: String 4 A6:J6"), + ("A7:J7", "Período que abrange esta prestação: String 5 A7:J7"), + ("A16:A25",datetime.datetime.strptime("2014-06-23", "%Y-%m-%d")), + ("B16:B25","STRINGB16B25"),# intervalo nao interfere + ("C16:C25","STRINGC16C25"),#intervalo nao interfere + ("E16:E25",200), + #("I16:I21",223), + ("I16", 23), + ("I17", 213), + ("I18", 223), + ("I19", 233), + ("I20", 243), + ("I21", 253), + ("I24", 263), + ("I26", 23787), + ("I27", 10), + ("I32", 100), + ("I33", 1000), + ("I38", 10000), + ("H45", "COORDENADORA_TESTE") + ], + "Exec. Receita e Despesa":[ + ("B16",200), + ("B17",201), + ("B18",202), + ("B19",203), + ("B20",204), + ("B21",205), + ("B22",206), + ("B23",207), + ("C16",205), + ("C17",206), + ("C18",207), + ("C19",208), + ("C20",209), + ("C21",210), + ("C22",211), + ("C23",212), + ("C24",213), + ("C25",214), + ("F16",2051), + ("F17",2061), + ("F18",2071), + ("F19",2081), + ("F20",2091), + ("F21",2101), + ("F22",2111), + ("F23",2121), + ("G16",20351), + ("G17",20361), + ("G18",20371), + ("G19",20381), + ("G20",20391), + ("G21",21301), + ("G22",21311), + ("G23",21321), + ("I26",2011), + ("I28",2001), + ("I29",2001), + ("B26",3011), + ("B28",3001), + ("B29",3001), + ("B31",3011), + ("C26",4011), + ("C29",4011), + ("C31",4011), + ("F26",5011), + ("F28",5001), + ("F29",5001), + ("F31",5011), + ("G26",6011), + ("G28",6001), + ("G29",6001), + ("G31",6011) + ], + "Pessoa Jurídica":[ + ("B11","TESTE_NOME"), + ("C11","TESTE_CPF"), + ("D11","TESTE_ESPECIFICACAO"), + ("E11","TESTE_DESCRICAO"), + ("F11","TESTE_DESCRICAO"), + ("F11","TESTE_RECIBO"), + ("G11",110101), + ("H11","TESTE_CHEQUE"), + ("I11",98765431), + ("J11",3000) + + ], + "Conciliação Bancária":[ + ("F10",5000), + ("F11",5000), + ("A15",120623), + ("A15",120623), + ("B15",9777), + ("C15","DOCUMENTO_TESTE"), + ("D15","DESCRIÇÃO_TESTE"), + ("B38",9777), + ("B39",7878), + ("C38","TESTESTRALEATORIOC38"), + ("C39",'TESTESTRALEATORIOC39'), + ("D38","TESTESTRALEATORIOD38"), + ("D39",'TESTESTRALEATORIOD39') + + ], + "Rendimento de Aplicação":[ + ("B12",2023), + ("C12",2024), + ("D12",2025), + ("E12",2026), + ("F12",2027), + ("G12",2028), + ("H12",2029) + ] + + +} + +modelo_fundep = { + "Relação e despesas" : [ + # campos cadastrais + ("C3", "Instituição Gestora"), + ("F3", "0000*XX"), + ("I3", "n_acordo"), + ("C4", "Titulo_Projeto"), + ("C5", "Nome_Coordenador"), + + # item beneficiarios + ("I5", "Dt_PeriodoPrestacao"), + ("C7", "Nome_Beneficiario"), + ("D7", "CNPJ-CPF-Baneficiario"), + ("E7", "Rubrica-Beneficiario"), + ("F7", "CH-OB-Beneficiario"), + ("G7", "dt-inicial-Beneficiario"), + ("H7", "NF-DOC.FISCAL-Beneficiario"), + ("I7", "dt-final-Beneficiario"), + ("J7", "valor-Beneficiario"), + ] +} + +# for nomePlanilha, entradaDados in planilha_local_dados.items(): +# planilhaAtual = workbook[nomePlanilha] + +# for intervaloCelula, entradaCelula in entradaDados: +# if ":" in intervaloCelula: +# inicioCelula, fimCelula = intervaloCelula.split(":") +# planilhaAtual = workbook[nomePlanilha] +# planilhaAtual[inicioCelula] = entradaCelula +# else: +# planilhaAtual[intervaloCelula] = entradaCelula + + +# workbook.save("modified_ModeloFub.xlsx") + +#preenche_planilha('planilhas/FUNDEP.xlsx', planilha_local_dados) diff --git a/project/app/oracle_cruds.py b/project/app/oracle_cruds.py new file mode 100644 index 00000000..51805a97 --- /dev/null +++ b/project/app/oracle_cruds.py @@ -0,0 +1,199 @@ +import oracledb + + +#connection string in the format +#/@:/ +file_path = "/home/ubuntu/Desktop/devfront/devfull/pass.txt" +conStr = '' +with open(file_path, 'r') as file: + conStr = file.readline().strip() + + + + +def getCollumNames(): + + #inicializando o objeto que ira conectar no db + conn = None + #criando o objeto de conexão das + conn = oracledb.connect(conStr) + #criar um objeto cursor necessario para fazer as consultas + cur = conn.cursor() + cur.execute("SELECT * FROM IDEA.STG_PROJETOS_CONVENIAR") + + return cur + +print("\n") + +# cur.close() +# #encerra a conexao +# conn.close() +# print("conexão db completa!") + +def getlimitedRows(numb): + consulta = {} + a=[] + try: + connection = oracledb.connect(conStr) + cursor = connection.cursor() + print("Connected to database") + sqlite_select_query = f"SELECT * FROM IDEA.STG_PROJETOS_CONVENIAR WHERE ROWNUM <={numb}" + + cursor.execute(sqlite_select_query) + records = cursor.fetchall() + collums = getCollumNames() + a=collums.description + + for i in range(0, numb): + # Create a dictionary to store the data for each i + i_data = {} + for j in range(len(a)): + key = a[j][0] + value = records[i][j] + + if key in i_data: + i_data[key].append(value) # If the key already exists, append the new value + else: + i_data[key] = value # If the key doesn't exist, create a list with the value + + # Add the i_data dictionary to the consulta dictionary under the i key + consulta[i] = i_data + + + #print(consulta) + + # print(f"\n \n {consulta['OBJETIVOS']} \n") + #consulta[0]['OBJETIVOS'] = str(consulta[0]['OBJETIVOS']) + + cursor.close() + + except oracledb.Error as error: + print("Failed to read data from table", error) + finally: + if connection: + connection.close() + print("The connection is closed") + + # return records + return consulta + +def getallRows(): + + try: + connection = oracledb.connect(conStr) + cursor = connection.cursor() + print("Connected to database") + sqlite_select_query = f"SELECT * FROM IDEA.STG_PROJETOS_CONVENIAR" + cursor.execute(sqlite_select_query) + records = cursor.fetchall() + length = len(records) + print(len(records)) + cursor.execute(sqlite_select_query) + + cursor.close() + + except oracledb.Error as error: + print("Failed to read data from table", error) + finally: + if connection: + connection.close() + print("The connection is closed") + + # return records + return length + +def consultaPorID(IDPROJETO): + consulta = {} + try: + connection = oracledb.connect(conStr) + cursor = connection.cursor() + print("Connected to database") + + # idProjeto = 6411 + sqlite_select_query = f"SELECT * FROM IDEA.STG_PROJETOS_CONVENIAR WHERE CODIGO='{IDPROJETO}'" + + cursor.execute(sqlite_select_query) + + records = cursor.fetchall() + + collums = getCollumNames() + + + + for i in range(len(collums.description)): + consulta[collums.description[i][0]] = records[0][i] + + #print(consulta) + + # print(f"\n \n {consulta['OBJETIVOS']} \n") + consulta['OBJETIVOS'] = str(consulta['OBJETIVOS']) + + cursor.close() + + except oracledb.Error as error: + print("Failed to read data from table", error) + finally: + if connection: + connection.close() + print("The connection is closed") + + # return records + return consulta + + +def getAnalistaDoProjetoECpfCoordenador(IDPROJETO): + #dados interessantes dessa tabela + #CPF_COORDENADOR + #NOME_ANALISTA + #VALOR_APROVADO + #CUSTOOPERACIONAL + + + #inicializando o objeto que ira conectar no db + conn = None + #criando o objeto de conexão das + conn = oracledb.connect(conStr) + #criar um objeto cursor necessario para fazer as consultas + cur = conn.cursor() + cur.execute("SELECT * FROM IDEA.FAT_PROJETO_CONVENIAR") + + + + + consulta = {} + try: + connection = oracledb.connect(conStr) + cursor = connection.cursor() + print("Connected to database") + + # idProjeto = 6411 + sqlite_select_query = f"SELECT * FROM IDEA.FAT_PROJETO_CONVENIAR WHERE IDPROJETO='{IDPROJETO}'" + + cursor.execute(sqlite_select_query) + + records = cursor.fetchall() + + collums = cur + + # print(records) + # print(collums.description) + + for i in range(len(collums.description)): + consulta[collums.description[i][0]] = records[0][i] + + #print(consulta) + + # print(f"\n \n {consulta['OBJETIVOS']} \n") + # consulta['NOME_ANALISTA'] = str(consulta['NOME_ANALISTA']) + + cursor.close() + + except oracledb.Error as error: + print("Failed to read data from table", error) + finally: + if connection: + connection.close() + print("The connection is closed") + + # return records + return consulta diff --git a/project/app/planilhas/ModeloFAP.xlsx b/project/app/planilhas/ModeloFAP.xlsx new file mode 100644 index 00000000..1de9600a Binary files /dev/null and b/project/app/planilhas/ModeloFAP.xlsx differ diff --git a/project/app/planilhas/ModeloFINEP.xlsx b/project/app/planilhas/ModeloFINEP.xlsx new file mode 100644 index 00000000..ff3c5ac1 Binary files /dev/null and b/project/app/planilhas/ModeloFINEP.xlsx differ diff --git a/project/app/planilhas/ModeloFUNDEP.xlsx b/project/app/planilhas/ModeloFUNDEP.xlsx new file mode 100644 index 00000000..cb930749 Binary files /dev/null and b/project/app/planilhas/ModeloFUNDEP.xlsx differ diff --git a/project/app/planilhas/ModeloOPAS.xlsx b/project/app/planilhas/ModeloOPAS.xlsx new file mode 100644 index 00000000..2837f2bd Binary files /dev/null and b/project/app/planilhas/ModeloOPAS.xlsx differ diff --git a/project/app/planilhas/Modelo_Fub.xlsx b/project/app/planilhas/Modelo_Fub.xlsx new file mode 100644 index 00000000..72984cad Binary files /dev/null and b/project/app/planilhas/Modelo_Fub.xlsx differ diff --git a/project/app/planilhas_preenchidas/planilhas/test.txt b/project/app/planilhas_preenchidas/planilhas/test.txt new file mode 100644 index 00000000..78981922 --- /dev/null +++ b/project/app/planilhas_preenchidas/planilhas/test.txt @@ -0,0 +1 @@ +a diff --git a/project/app/preenche_fub.py b/project/app/preenche_fub.py new file mode 100644 index 00000000..158b7a6c --- /dev/null +++ b/project/app/preenche_fub.py @@ -0,0 +1,876 @@ +import oracledb +from datetime import datetime,date +import openpyxl +import os +from .estilo_fub import (estilo_conciliacoes_bancaria,estilo_rendimento_de_aplicacao, +estilo_demonstrativoDeReceita,estiloGeral,estiloRelacaoBens) +from collections import defaultdict +from .oracle_cruds import consultaPorID,getAnalistaDoProjetoECpfCoordenador + +def formatar_cpf(cpf): + cpf_formatado = f'{cpf[:3]}.{cpf[3:6]}.{cpf[6:9]}-{cpf[9:]}' + return cpf_formatado +def check_format(time_data, format='%Y-%m-%d'): + try: + # Try to parse the time_data using the specified format + datetime.strptime(time_data, format) + return True # The time_data matches the format + except ValueError: + return False # The time_data does not match the format + +def pegar_caminho(nome_arquivo): + + # Obter o caminho absoluto do arquivo Python em execução + caminho_script = os.path.abspath(__file__) + + # Obter o diretório da pasta onde o script está localizado + pasta_script = os.path.dirname(caminho_script) + + # Combinar o caminho da pasta com o nome do arquivo Excel + caminho = os.path.join(pasta_script, nome_arquivo) + + return caminho + +def convert_datetime_to_string(value): + if isinstance(value, datetime): + return value.strftime('%d/%m/%Y') + return value +#connection string in the format +#/@:/ a[87] +def separarporrubrica(codigo,data1,data2): + valor = get_values_from_dict(codigo,data1,data2) + + + # # Step 1: Extract unique values from the 'ID_RUBRICA' key + unique_id_rubrica_values = set(item['ID_RUBRICA'] for item in valor) + + # # Step 2: Create separate lists of dictionaries for each unique 'ID_RUBRICA' value + categorized_data = {value: [] for value in unique_id_rubrica_values} + for item in valor: + categorized_data[item['ID_RUBRICA']].append(item) + + return categorized_data + +#separa por tipo de favorecido as rubricas 87 e 9 +def tipodefavorecido(codigo,data1,data2): + data_categorizada = separarporrubrica(codigo,data1,data2) + #print(data_categorizada) + if 87 not in data_categorizada or not data_categorizada[87]: + print("Data not available or empty.") + return None # or handle the case accordingly + separarportipodefavorecido = set(item['TIPO_FAVORECIDO'] for item in data_categorizada[87]) + #print(separarportipodefavorecido) + + # # Step 2: Create separate lists of dictionaries for each unique 'ID_RUBRICA' value + dict_favorecido_fisica_e_juridica = {value: [] for value in separarportipodefavorecido} + for item in data_categorizada[87]: + dict_favorecido_fisica_e_juridica[item['TIPO_FAVORECIDO']].append(item) + + #print(dict_favorecido_fisica_e_juridica) + return dict_favorecido_fisica_e_juridica + +def preencherCapa(codigo,planilha): + analista = getAnalistaDoProjetoECpfCoordenador(codigo) + caminho = pegar_caminho(planilha) + workbook = openpyxl.load_workbook(caminho) + sheet = workbook['Capa Finatec'] + sheet['E26'] = analista['NOME_ANALISTA'] + workbook.save(planilha) + workbook.close() + +#preenche planilha de referencia pra nome do coordenador e diretor +def criaout(planilha,codigo,data1,data2): + + caminho = pegar_caminho(planilha) + Plan = planilha + # carrega a planilha de acordo com o caminho + workbook = openpyxl.load_workbook(caminho) + sheet = workbook['Receita x Despesa'] + input_date = [] + output_date_str = [] + input_date2 = [] + output_date_str2 = [] + if check_format(data1): + input_date = datetime.strptime(data1, "%Y-%m-%d") + # Format the datetime object to a string in dd/mm/yyyy format + output_date_str = input_date.strftime("%d/%m/%Y") + else : + return None + if check_format(data2): + input_date2 = datetime.strptime(data2, "%Y-%m-%d") + # Format the datetime object to a string in dd/mm/yyyy format + output_date_str2 = input_date2.strftime("%d/%m/%Y") + else : + return None + + + + string_periodo = f"Período que abrange esta prestação: {output_date_str} a {output_date_str2}" + sheet['A7'] = string_periodo + consulta_coordenador = consultaPorID(codigo) + sheet['H45'] = consulta_coordenador['COORDENADOR'] + dadosquefaltam = getAnalistaDoProjetoECpfCoordenador(codigo) + #print(f'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{dadosquefaltam}') + sheet['H47'] = formatar_cpf(dadosquefaltam["CPF_COORDENADOR"]) + meses_dict = { + 1: "Janeiro", + 2: "Fevereiro", + 3: "Março", + 4: "Abril", + 5: "Maio", + 6: "Junho", + 7: "Julho", + 8: "Agosto", + 9: "Setembro", + 10: "Outubro", + 11: "Novembro", + 12: "Dezembro" +} + + hoje = date.today() + data_formatada = f"{hoje.day} de {meses_dict[hoje.month]} de {hoje.year}" + sheet["A42"] = f'Brasilia,{data_formatada}' + workbook.save(planilha) + workbook.close() + +# ##########################################Pessoa Fisica######################################### +def pessoa_fisica(codigo,data1,data2,keys,planilha): + tabela = pegar_caminho(planilha) + nomeTabela ="Pessoa Fisica" + tituloStyle = "pessoaFisica" + workbook = openpyxl.load_workbook(tabela) + sheet2 = workbook.create_sheet(title="Pessoa Fisica") + workbook.save(tabela) + workbook.close() + categorized_data= separarporrubrica(codigo,data1,data2) + + if 87 not in categorized_data or not categorized_data[87]: + maior = 1 + tabela = pegar_caminho(planilha) + estiloGeral(tabela,maior,tituloStyle,nomeTabela) + print("Data not available or empty.") + return None # or handle the case accordingly + maior = len(categorized_data[87]) + + print(len(categorized_data[87])) + tabela = pegar_caminho(planilha) + + estiloGeral(tabela,maior,tituloStyle,nomeTabela) + + coluna = 2 + # caminho = pegar_caminho(planilha) + + workb = openpyxl.load_workbook(tabela) + worksheet5 = workb['Pessoa Fisica'] + + for i in range(1,maior+1): + valor_coluna = 9 + i + worksheet5.cell(row=valor_coluna, column=1, value=i) # column index starts from 1 + + + for i in keys: + li = [i] + if 87 not in categorized_data or not categorized_data[87]: + print("Data not available or empty.") + maior = 1 + tabela = pegar_caminho(planilha) + estiloGeral(tabela,maior,tituloStyle,nomeTabela) + return None # or handle the case accordingly + valores_preenchimento = retornavalores(categorized_data[87],li) + + n = len(valores_preenchimento) + for rowkek, cell_data in enumerate(valores_preenchimento, start=10): + worksheet5.cell(row=rowkek, column=coluna, value=cell_data) + if coluna == 5 or coluna == 7 : + coluna = coluna + 1 + coluna = coluna + 1 + + workb.save(tabela) + workb.close() + +# ##########################################Pessoa Juridica######################################### +def pessoa_juridica(codigo,data1,data2,keys,planilha): + + + + tabela = pegar_caminho(planilha) + nomeTabela ="Pessoa Jurídica" + tituloStyle = "pessoaJuridica" + workbook = openpyxl.load_workbook(tabela) + sheet2 = workbook.create_sheet(title="Pessoa Jurídica") + workbook.save(tabela) + workbook.close() + categorized_data= separarporrubrica(codigo,data1,data2) + + tamanho = [] + + if 75 in categorized_data and 57 in categorized_data: + categorized_data[75].extend(categorized_data[57]) + elif 75 not in categorized_data and 57 in categorized_data: + categorized_data[75] = categorized_data[57] + else: + print("Data not available or empty.") + maior = 1 + tabela = pegar_caminho(planilha) + estiloGeral(tabela,maior,tituloStyle,nomeTabela) + return None # or handle the case accordingly + + if 75 not in categorized_data or not categorized_data[75]: + maior = 1 + tabela = pegar_caminho(planilha) + estiloGeral(tabela,maior,tituloStyle,nomeTabela) + print("Data not available or empty.") + return None # or handle the case accordingly + maior = len(categorized_data[75]) + print(maior) + print(len(categorized_data[75])) + tabela = pegar_caminho(planilha) + + estiloGeral(tabela,maior,tituloStyle,nomeTabela) + + + coluna = 2 + # caminho = pegar_caminho(planilha) + + workb = openpyxl.load_workbook(tabela) + worksheet5 = workb['Pessoa Jurídica'] + + for i in range(1,maior+1): + valor_coluna = 9 + i + worksheet5.cell(row=valor_coluna, column=1, value=i) # column index starts from 1 + + + for i in keys: + li = [i] + if 75 not in categorized_data or not categorized_data[75]: + print("Data not available or empty.") + maior = 1 + tabela = pegar_caminho(planilha) + estiloGeral(tabela,maior,tituloStyle,nomeTabela) + return None # or handle the case accordingly + valores_preenchimento = retornavalores(categorized_data[75],li) + + n = len(valores_preenchimento) + for rowkek, cell_data in enumerate(valores_preenchimento, start=10): + worksheet5.cell(row=rowkek, column=coluna, value=cell_data) + if coluna == 5 or coluna == 7 : + coluna = coluna + 1 + coluna = coluna + 1 + + workb.save(tabela) + workb.close() + +# ##########################################ISS######################################### +def iss(codigo,data1,data2,keys,planilha): + tabela = pegar_caminho(planilha) + nomeTabela ="ISS" + tituloStyle = "isss" + workbook = openpyxl.load_workbook(tabela) + sheet2 = workbook.create_sheet(title="ISS") + workbook.save(tabela) + workbook.close() + categorized_data= separarporrubrica(codigo,data1,data2) + + if 67 not in categorized_data or not categorized_data[67]: + maior = 1 + tabela = pegar_caminho(planilha) + estiloGeral(tabela,maior,tituloStyle,nomeTabela) + print("Data not available or empty.") + return None # or handle the case accordingly + maior = len(categorized_data[67]) + print(maior) + print(len(categorized_data[67])) + tabela = pegar_caminho(planilha) + + estiloGeral(tabela,maior,tituloStyle,nomeTabela) + + coluna = 2 + # caminho = pegar_caminho(planilha) + + workb = openpyxl.load_workbook(tabela) + worksheet5 = workb['ISS'] + + for i in range(1,maior+1): + valor_coluna = 9 + i + worksheet5.cell(row=valor_coluna, column=1, value=i) # column index starts from 1 + + + for i in keys: + li = [i] + if 67 not in categorized_data or not categorized_data[67]: + print("Data not available or empty.") + maior = 1 + tabela = pegar_caminho(planilha) + estiloGeral(tabela,maior,tituloStyle,nomeTabela) + return None # or handle the case accordingly + valores_preenchimento = retornavalores(categorized_data[67],li) + + n = len(valores_preenchimento) + for rowkek, cell_data in enumerate(valores_preenchimento, start=10): + worksheet5.cell(row=rowkek, column=coluna, value=cell_data) + if coluna == 5 or coluna == 7 : + coluna = coluna + 1 + coluna = coluna + 1 + + workb.save(tabela) + workb.close() + +# ##########################################Passagem Locomoção######################################### +def passagem_locomção(codigo,data1,data2,keys,planilha): + tabela = pegar_caminho(planilha) + nomeTabela ="Passagens e Desp. Locomoção" + tituloStyle = "passagenDespLocomo" + workbook = openpyxl.load_workbook(tabela) + sheet2 = workbook.create_sheet(title="Passagens e Desp. Locomoção") + workbook.save(tabela) + workbook.close() + categorized_data= separarporrubrica(codigo,data1,data2) + + if 7 not in categorized_data or not categorized_data[7]: + maior = 1 + tabela = pegar_caminho(planilha) + estiloGeral(tabela,maior,tituloStyle,nomeTabela) + print("Data not available or empty.") + return None # or handle the case accordingly + maior = len(categorized_data[7]) + print(maior) + print(len(categorized_data[7])) + tabela = pegar_caminho(planilha) + + estiloGeral(tabela,maior,tituloStyle,nomeTabela) + + + coluna = 2 + # caminho = pegar_caminho(planilha) + + workb = openpyxl.load_workbook(tabela) + worksheet3 = workb["Passagens e Desp. Locomoção"] + + for i in range(1,maior+1): + valor_coluna = 9 + i + worksheet3.cell(row=valor_coluna, column=1, value=i) # column index starts from 1 + + + for i in keys: + li = [i] + if 7 not in categorized_data or not categorized_data[7]: + print("Data not available or empty.") + maior = 1 + tabela = pegar_caminho(planilha) + estiloGeral(tabela,maior,tituloStyle,nomeTabela) + return None # or handle the case accordingly + valores_preenchimento = retornavalores(categorized_data[7],li) + + n = len(valores_preenchimento) + for rowkek, cell_data in enumerate(valores_preenchimento, start=10): + worksheet3.cell(row=rowkek, column=coluna, value=cell_data) + if coluna == 5 or coluna == 7 : + coluna = coluna + 1 + coluna = coluna + 1 + + + workb.save(tabela) + workb.close() + +# ##########################################Serv.Terceiro CLTa######################################### +def terclt(codigo,data1,data2,keys,planilha): + tabela = pegar_caminho(planilha) + nomeTabela ="Serv. Terceiro CLT" + tituloStyle = "outrosServiçosTerceiros" + workbook = openpyxl.load_workbook(tabela) + sheet2 = workbook.create_sheet(title="Serv. Terceiro CLT") + workbook.save(tabela) + workbook.close() + categorized_data= separarporrubrica(codigo,data1,data2) + + if 25 not in categorized_data or not categorized_data[25]: + maior = 1 + tabela = pegar_caminho(planilha) + estiloGeral(tabela,maior,tituloStyle,nomeTabela) + print("Data not available or empty.") + return None # or handle the case accordingly + maior = len(categorized_data[25]) + print(maior) + print(len(categorized_data[25])) + tabela = pegar_caminho(planilha) + + estiloGeral(tabela,maior,tituloStyle,nomeTabela) + + coluna = 2 + # caminho = pegar_caminho(planilha) + + workb = openpyxl.load_workbook(tabela) + worksheet4 = workb['Outros Serviços Terceiros - PF'] + + for i in range(1,maior+1): + valor_coluna = 9 + i + worksheet4.cell(row=valor_coluna, column=1, value=i) # column index starts from 1 + + + for i in keys: + li = [i] + if 25 not in categorized_data or not categorized_data[25]: + print("Data not available or empty.") + maior = 1 + tabela = pegar_caminho(planilha) + estiloGeral(tabela,maior,tituloStyle,nomeTabela) + return None # or handle the case accordingly + valores_preenchimento = retornavalores(categorized_data[25],li) + + n = len(valores_preenchimento) + for rowkek, cell_data in enumerate(valores_preenchimento, start=10): + worksheet4.cell(row=rowkek, column=coluna, value=cell_data) + if coluna == 5 or coluna == 7 : + coluna = coluna + 1 + coluna = coluna + 1 + + workb.save(planilha) + workb.close() + +# ##########################################Obrigaçoes tributárias ######################################### +def obricacao_tributaria(codigo,data1,data2,keys,planilha): + tabela = pegar_caminho(planilha) + nomeTabela ="Obrigações Trib. - Encargos 20%" + tituloStyle = "obrigacoesTribu" + workbook = openpyxl.load_workbook(tabela) + sheet2 = workbook.create_sheet(title="Obrigações Trib. - Encargos 20%") + workbook.save(tabela) + workbook.close() + categorized_data= separarporrubrica(codigo,data1,data2) + + if 66 not in categorized_data or not categorized_data[66]: + maior = 1 + tabela = pegar_caminho(planilha) + estiloGeral(tabela,maior,tituloStyle,nomeTabela) + print("Data not available or empty.") + return None # or handle the case accordingly + maior = len(categorized_data[66]) + print(maior) + print(len(categorized_data[66])) + tabela = pegar_caminho(planilha) + + estiloGeral(tabela,maior,tituloStyle,nomeTabela) + coluna = 2 + # caminho = pegar_caminho(planilha) + + workb = openpyxl.load_workbook(tabela) + worksheet4 = workb['Obrigações Trib. - Encargos 20%'] + + for i in range(1,maior+1): + valor_coluna = 9 + i + worksheet4.cell(row=valor_coluna, column=1, value=i) # column index starts from 1 + + + for i in keys: + li = [i] + if 66 not in categorized_data or not categorized_data[66]: + print("Data not available or empty.") + maior = 1 + tabela = pegar_caminho(planilha) + estiloGeral(tabela,maior,tituloStyle,nomeTabela) + + return None # or handle the case accordingly + valores_preenchimento = retornavalores(categorized_data[66],li) + + n = len(valores_preenchimento) + for rowkek, cell_data in enumerate(valores_preenchimento, start=10): + worksheet4.cell(row=rowkek, column=coluna, value=cell_data) + if coluna == 5 or coluna == 7 : + coluna = coluna + 1 + coluna = coluna + 1 + + workb.save(planilha) + workb.close() + +# ##########################################Conciliação Bancária ######################################### +def conciliacao_bancaria(codigo,data1,data2,planilha): + tabela = pegar_caminho(planilha) + workbook = openpyxl.load_workbook(tabela) + sheet2 = workbook.create_sheet(title="Conciliação Bancária") + workbook.save(tabela) + workbook.close() + tamanho = [] + categorized_data= separarporrubrica(codigo,data1,data2) + #####pergar os dados do db e separar por mes e ano###################3 + + grupos_por_ano_mes = defaultdict(list) + if 9 not in categorized_data or not categorized_data[9]: + print("Data not available or empty.") + maior = 1 + maior2= 2 + tabela = pegar_caminho(planilha) + estilo_conciliacoes_bancaria(tabela,maior,maior2) + return None # or handle the case accordingly + else: + + for item in categorized_data[9]: + data_criacao_str = item['DATA_CRIACAO'] + + # Converter a string de data para um objeto datetime + data_criacao = datetime.strptime(data_criacao_str, '%d/%m/%Y') + # Extrair o componente do ano e do mês + ano = data_criacao.year + mes = data_criacao.month + dia = data_criacao.day + # Adicionar o item ao grupo correspondente ao ano e mês + + grupos_por_ano_mes[(ano, mes,dia)].append(item) + + # Calcular a soma de VALOR_LANCADO e imprimir os resultados + + estorno = defaultdict(list) + + tamanho = len(grupos_por_ano_mes) + #print(tamanho) + ##loop pra calcular o tamanho do estorno + for (ano, mes,dia), items in sorted(grupos_por_ano_mes.items()): + #print(grupos_por_ano_mes) + for item in items: + if 'estorno' in item.get('HIS_LANCAMENTO', '').lower(): + estorno_valor = item['VALOR_LANCADO'] + estorno[(ano,mes,dia,item['VALOR_LANCADO'])].append(item) + + tamanho2 = len(estorno) + #print(tamanho) + #print(tamanho2) + tamanho = tamanho-tamanho2 + tabela = pegar_caminho(planilha) + #print(tabela) + estilo_conciliacoes_bancaria(tabela,tamanho,tamanho2) + + + workb = openpyxl.load_workbook(tabela) + worksheet3 = workb["Conciliação Bancária"] + i = 16 + j=0 + estorno_valor = 0 + estorno_dia = [] + estorno_mes = [] + estorno_ano = [] + for (ano, mes,dia), items in sorted(grupos_por_ano_mes.items()): + #print(grupos_por_ano_mes) + for item in items: + if 'estorno' in item.get('HIS_LANCAMENTO', '').lower(): + estorno_valor = item['VALOR_LANCADO'] + estorno_dia = dia + estorno_mes = mes + estorno_ano = ano + + + else: + valor_lancado = item['VALOR_LANCADO'] + + + anoss = {1:'jan', + 2:'fev', + 3:'mar', + 4:'abr', + 5:'mai', + 6:'jun', + 7:'jul', + 8:'ago', + 9:'sep', + 10:'out', + 11:'nov', + 12: 'dec' + + } + for a,b in anoss.items(): + #print(a) + if mes == a : + mes = b + cell_data = f'{dia}-{mes}-{ano}' + # print(cell_data) + # print(valor_lancado) + if(valor_lancado != 0): + worksheet3.cell(row=i, column=1, value=cell_data) + worksheet3.cell(row=i,column=2,value=valor_lancado) + worksheet3.cell(row=i,column=4,value= item['HIS_LANCAMENTO']) + else: + i = i - 1 + # print(estorno_valor) + # print(estorno_ano) + # print(estorno_mes) + # print(estorno_dia) + + if(estorno_valor != 0): + worksheet3.cell(row=16+tamanho+j+4, column=1, value=cell_data) + worksheet3.cell(row=16+tamanho+j+4, column=2, value=estorno_valor) + + j = j +1 + + i = i + 1 + valor_lancado = 0 + estorno_valor = 0 + #print(j) + workb.save(tabela) + workb.close + +# ##########################################Rendimento de Aplicação######################################### +def rendimentodeaplicacao(codigo,data1,data2,planilha): + tabela = pegar_caminho(planilha) + workbook = openpyxl.load_workbook(tabela) + sheet2 = workbook.create_sheet(title="Rendimento de Aplicação") + workbook.save(tabela) + workbook.close() + tamanho = [] + categorized_data= separarporrubrica(codigo,data1,data2) + #####pergar os dados do db e separar por mes e ano###################3 + + grupos_por_ano_mes = defaultdict(list) + if 3 not in categorized_data or not categorized_data[3]: + print("Data not available or empty.") + maior = 1 + maior2= 2 + tabela = pegar_caminho(planilha) + estilo_rendimento_de_aplicacao(tabela,maior) + return None # or handle the case accordingly + else: + + for item in categorized_data[3]: + data_criacao_str = item['DATA_CRIACAO'] + + # Converter a string de data para um objeto datetime + data_criacao = datetime.strptime(data_criacao_str, '%d/%m/%Y') + # Extrair o componente do ano e do mês + ano = data_criacao.year + mes = data_criacao.month + dia = data_criacao.day + # Adicionar o item ao grupo correspondente ao ano e mês + + grupos_por_ano_mes[(ano, mes,dia)].append(item) + + # Calcular a soma de VALOR_LANCADO e imprimir os resultados + + estorno = defaultdict(list) + + tamanho = len(grupos_por_ano_mes) + tabela = pegar_caminho(planilha) + #print(tabela) + estilo_rendimento_de_aplicacao(tabela,tamanho) + + + workb = openpyxl.load_workbook(tabela) + worksheet3 = workb["Rendimento de Aplicação"] + i = 14 + + for (ano, mes,dia), items in sorted(grupos_por_ano_mes.items()): + soma_valor_lancado = 0 + for item in items: + soma_valor_lancado += item['VALOR_LANCADO'] + + + anoss = {1:'jan', + 2:'fev', + 3:'mar', + 4:'abr', + 5:'mai', + 6:'jun', + 7:'jul', + 8:'ago', + 9:'sep', + 10:'out', + 11:'nov', + 12: 'dec' + + } + for a,b in anoss.items(): + if mes == a : + mes = b + cell_data = f'{mes}-{ano}' + # print(cell_data) + # print(valor_lancado) + + worksheet3.cell(row=i, column=1, value=cell_data) + worksheet3.cell(row=i,column=8,value=soma_valor_lancado) + + i = i + 1 + + + + workb.save(tabela) + workb.close + ############################## + +def diaria(codigo,data1,data2,planilha): + tabela = pegar_caminho(planilha) + workbook = openpyxl.load_workbook(tabela) + nomeTabela ="Diárias" + tituloStyle = "diarias" + sheet2 = workbook.create_sheet(title="Diárias") + workbook.save(tabela) + workbook.close() + maior = 20 + estiloGeral(tabela,maior,tituloStyle,nomeTabela) + +def auxilio(codigo,data1,data2,planilha): + tabela = pegar_caminho(planilha) + nomeTabela ="Auxílio Financeiro Estudante" + tituloStyle = "auxilioEstudante" + workbook = openpyxl.load_workbook(tabela) + sheet2 = workbook.create_sheet(title="Auxílio Financeiro Estudante") + workbook.save(tabela) + workbook.close() + tamanho = 20 + estiloGeral(tabela,tamanho,tituloStyle,nomeTabela) + +def bolsaExtensao(codigo,data1,data2,planilha): + tabela = pegar_caminho(planilha) + workbook = openpyxl.load_workbook(tabela) + nomeTabela ="Bolsa Extensão" + tituloStyle = "bolsaExtensao" + sheet2 = workbook.create_sheet(title="Bolsa Extensão") + workbook.save(tabela) + workbook.close() + tamanho = 20 + estiloGeral(tabela,tamanho,tituloStyle,nomeTabela) + +def estagiario(codigo,data1,data2,planilha): + tabela = pegar_caminho(planilha) + workbook = openpyxl.load_workbook(tabela) + nomeTabela ="Estagiário" + tituloStyle = "estagiario" + sheet2 = workbook.create_sheet(title="Estagiário") + workbook.save(tabela) + workbook.close() + tamanho = 20 + estiloGeral(tabela,tamanho,tituloStyle,nomeTabela) + +def custoIndireto(codigo,data1,data2,planilha): + tabela = pegar_caminho(planilha) + workbook = openpyxl.load_workbook(tabela) + nomeTabela ="Custos Indiretos - FUB" + tituloStyle = "custosIndiretos" + sheet2 = workbook.create_sheet(title="Custos Indiretos - FUB") + workbook.save(tabela) + workbook.close() + tamanho = 20 + estiloGeral(tabela,tamanho,tituloStyle,nomeTabela) + +def relacaodeBens(codigo,data1,data2,planilha): + tabela = pegar_caminho(planilha) + workbook = openpyxl.load_workbook(tabela) + nomeTabela ="Relação de Bens" + tituloStyle = "relacaoBEns" + sheet2 = workbook.create_sheet(title="Relação de Bens") + workbook.save(tabela) + workbook.close() + tamanho = 20 + estiloRelacaoBens(tabela,tamanho,tituloStyle,nomeTabela) + +def materialDeConsumo(codigo,data1,data2,planilha): + tabela = pegar_caminho(planilha) + workbook = openpyxl.load_workbook(tabela) + nomeTabela ="Material de Consumo" + tituloStyle = "materialDeConsumo" + sheet2 = workbook.create_sheet(title="Material de Consumo") + workbook.save(tabela) + workbook.close() + tamanho = 20 + estiloGeral(tabela,tamanho,tituloStyle,nomeTabela) + +def equipamentoMaterialPermanente(codigo,data1,data2,planilha): + tabela = pegar_caminho(planilha) + workbook = openpyxl.load_workbook(tabela) + nomeTabela ="Equipamento Material Permanente" + tituloStyle = "equipamentoMaterialPermanente" + sheet2 = workbook.create_sheet(title="Equipamento Material Permanente") + workbook.save(tabela) + workbook.close() + tamanho = 20 + estiloGeral(tabela,tamanho,tituloStyle,nomeTabela) + +def demonstrativo(codigo,data1,data2,planilha): + tabela = pegar_caminho(planilha) + workbook = openpyxl.load_workbook(tabela) + sheet2 = workbook.create_sheet(title="Demonstrativo de Receita") + workbook.save(tabela) + workbook.close() + tamanho = 20 + estilo_demonstrativoDeReceita(tabela,tamanho) + +def preencher_fub_teste(codigo,data1,data2,keys,tabela): + criaout(tabela,codigo,data1,data2) + preencherCapa(codigo,tabela) + pessoa_fisica(codigo,data1,data2,keys,tabela) + pessoa_juridica(codigo,data1,data2,keys,tabela) + #iss(codigo,data1,data2,keys,tabela) + passagem_locomção(codigo,data1,data2,keys,tabela) + terclt(codigo,data1,data2,keys,tabela) + obricacao_tributaria(codigo,data1,data2,keys,tabela) + conciliacao_bancaria(codigo,data1,data2,tabela) + rendimentodeaplicacao(codigo,data1,data2,tabela) + diaria(codigo,data1,data2,tabela) + auxilio(codigo,data1,data2,tabela) + bolsaExtensao(codigo,data1,data2,tabela) + estagiario(codigo,data1,data2,tabela) + custoIndireto(codigo,data1,data2,tabela) + materialDeConsumo(codigo,data1,data2,tabela) + equipamentoMaterialPermanente(codigo,data1,data2,tabela) + demonstrativo(codigo,data1,data2,tabela) + relacaodeBens(codigo,data1,data2,tabela) + + +# keys = ['NOME_FAVORECIDO','CNPJ_FAVORECIDO','TIPO_LANCAMENTO','HIS_LANCAMENTO','DATA_EMISSAO','DATA_PAGAMENTO', 'VALOR_PAGO'] +# tabela = pegar_caminho("Modelo_Fub.xlsx") +# preencher_fub_teste(6411,'2020-01-01','2024-01-31',keys,tabela) + +# pessoa_fisica(6858,'2022-09-09','2022-12-09',keys) diff --git a/project/app/preenche_fundep.py b/project/app/preenche_fundep.py new file mode 100644 index 00000000..302b7a31 --- /dev/null +++ b/project/app/preenche_fundep.py @@ -0,0 +1,157 @@ +import oracledb +from datetime import datetime,date +import openpyxl +import os +from .estilo_fundep import estilo_fundep +from .oracle_cruds import consultaPorID +from openpyxl.styles import Font,Alignment +def check_format(time_data, format='%Y-%m-%d'): + try: + # Try to parse the time_data using the specified format + datetime.strptime(time_data, format) + return True # The time_data matches the format + except ValueError: + return False # The time_data does not match the format + +def pegar_caminho(nome_arquivo): + + # Obter o caminho absoluto do arquivo Python em execução + caminho_script = os.path.abspath(__file__) + + # Obter o diretório da pasta onde o script está localizado + pasta_script = os.path.dirname(caminho_script) + + # Combinar o caminho da pasta com o nome do arquivo Excel + caminho = os.path.join(pasta_script, nome_arquivo) + + return caminho + +def convert_datetime_to_string(value): + if isinstance(value, datetime): + return value.strftime('%d/%m/%Y') + return value +#connection string in the format +#/@:/ a[87] + + +def preenche_fundep(codigo,data1,data2,keys,planilha): + dados_db = get_values_from_dict(codigo,data1,data2) + input_date = [] + output_date_str = [] + input_date2 = [] + output_date_str2 = [] + if check_format(data1): + input_date = datetime.strptime(data1, "%Y-%m-%d") + # Format the datetime object to a string in dd/mm/yyyy format + output_date_str = input_date.strftime("%d/%m/%Y") + else : + return None + if check_format(data2): + input_date2 = datetime.strptime(data2, "%Y-%m-%d") + # Format the datetime object to a string in dd/mm/yyyy format + output_date_str2 = input_date2.strftime("%d/%m/%Y") + else : + return None + + string_periodo = f"{output_date_str} a {output_date_str2}" + + + #dados_gerais = retornavalores(dados_db,keys) + tamanho = [] + for j in keys: + lj = [j] + valores_dboracle = retornavalores(dados_db,lj) + size = len(valores_dboracle) + tamanho.append(size) + maior = max(tamanho) + print(tamanho) + tabela = pegar_caminho(planilha) + estilo_fundep(tabela,maior) + + workb = openpyxl.load_workbook(tabela) + worksheet5 = workb['Relação de despesas'] + worksheet5['I5'] = string_periodo + worksheet5['I5'].font= Font(name="Calibri", size=10, color="000000") + worksheet5['I5'].alignment = Alignment(horizontal="left",vertical="bottom",wrap_text=True) + + for i in range(1,maior+1): + valor_coluna = 6 + i + worksheet5.cell(row=valor_coluna, column=2, value=i) # column index starts from 1 + + for i in range(1,maior+1): + valor_coluna = 6 + i + worksheet5.cell(row=valor_coluna, column=1, value=1) # column index starts from 1 + + coluna = 3 + for i in keys: + li = [i] + valores_preenchimento = retornavalores(dados_db,li) + for rowkek, cell_data in enumerate(valores_preenchimento, start=7): + worksheet5.cell(row=rowkek, column=coluna, value=cell_data) + if coluna == 5 or coluna == 7 : + coluna = coluna + 1 + + coluna = coluna + 1 + + + workb.save(tabela) + workb.close() + \ No newline at end of file diff --git a/project/app/static/css/cadastro.css b/project/app/static/css/cadastro.css new file mode 100644 index 00000000..98ecf9fb --- /dev/null +++ b/project/app/static/css/cadastro.css @@ -0,0 +1,192 @@ +* { + font-family: "Montserrat", sans-serif; +} + +body { + background-image: linear-gradient(#021842 50%, #253E6C); + flex-direction: column; + display: flex; + margin: 0; + height: 100vh; + width: 100vw; +} +header { + display: flex; + align-items: center; + justify-content: space-between; + background-color: #021842; + color: #ffffff; + height: 100px; + box-shadow: 10px 5px 5px #021233; +} + +.navButton{ + display: flex; + align-items: center; + justify-content: space-between; + margin-right: 100px; +} +.navButton p, a{ + text-decoration: none; + margin-left: 10px; +} + +/* .navButton .link.highlighted { + background-color: yellow; +} */ +img { + height: 20px; +} +.finatecLogo{ + margin-left: 100px; +} + +.profile{ + height: 38px; +} + +.logo { + width: 100px; + height: 100px; +} + +h1 { + font-size: 18px; +} + +/* estilizacao */ + +.content { + height: 100%; + width: 100%; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + /* background-image: url('{% static "imagem/fundoLogo.svg" %}'); + background-size: cover; + background-repeat: no-repeat; */ +} + +.footer { + padding: 20px 0px; + color: #ffffff; + align-self: center; +} + +.container { + display: flex; + align-items: center; + padding: 24px 72px; + width: 600px; + flex-direction: column; + flex-shrink: 0; + border-radius: 20px; + border: 1px solid #bcbcbc; + color: #000000; + background-color: #ffffff; + gap: 1em; +} + +.form { + display: flex; + flex-direction: column; + gap: 4em; + width: 100%; +} + +.inputGroup { + display: flex; + flex-direction: column; + gap: 1em; +} + +.input { + margin-left: 10px; + margin-right: 10px; + display: flex; + flex-direction: column; + gap: 0.5em; + width: 100%; +} +.button-submit { + color: #ffffff; + background: #021842; + border: none; + border-radius: 20px; + padding: 10px 20px; + width: 50%; + font-weight: 600; + transition: 0.3s; + cursor: pointer; +} +.cardSubmit{ + display: flex; + justify-content: center; +} + +.button-submit:hover { + background: #F39B00; +} + +.placeholder { + flex-shrink: 0; + border-radius: 20px; + border: 1px solid #bcbcbc; + background: rgba(0, 0, 0, 0); + padding: 10px 20px; + color: #323232; +} + +.name { + font-size: 12px; + font-weight: 600; +} + +.placeholder::placeholder { + color: #323232; +} + +.link { + color: #bcbcbc; +} + +.linkS{ + color: #f39b00; + } + +.otherLogin { + font-size: 12px; +} + +.placeholder option { + color: black; +} + +.button-logout { + color: #004661; + background: #ffffff; + border: none; + border-radius: 20px; + padding: 10px 20px; + width: 10%; + font-weight: 600; + transition: 0.3s; + cursor: pointer; + position: absolute; + right: 150px; + display: flex; + align-items: center; + justify-content: center; + margin-top: 30px; +} + +.button-logout:hover { + background: #ff3838; + color: #fff; +} + +.together{ + display: flex; + justify-content: space-between; +} \ No newline at end of file diff --git a/project/app/static/css/home.css b/project/app/static/css/home.css new file mode 100644 index 00000000..befcc660 --- /dev/null +++ b/project/app/static/css/home.css @@ -0,0 +1,262 @@ +* { + font-family: "Montserrat", sans-serif; +} + +body { + background: linear-gradient(#021842, #213A68); + flex-direction: column; + display: flex; + margin: 0; + height: 100vh; + width: 100vw; +} +header { + display: flex; + align-items: center; + justify-content: space-around; + background-color: #ffffff; + color: #004661; + height: 100px; +} + +img { + width: 203px; + height: 58px; +} + +.logo { + width: 100px; + height: 100px; +} + +h1 { + font-size: 18px; +} + +h2 { + font-size: 60px; + font-weight: bold; + margin: 0; +} +h3 { + font-size: 20px; + font-weight: 400; + margin-top: 10px; + margin-bottom: 30px; +} +/* estilizacao */ + +.content { + height: 100%; + width: 100%; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; +} + +.footer { + padding: 20px 0px; + color: #8a8989; + align-self: center; +} + +.container { + display: flex; + align-items: center; + padding: 24px 72px; + width: 280px; + flex-direction: column; + flex-shrink: 0; + border-radius: 20px; + border: 1px solid #bcbcbc; + color: #ffffff; + gap: 1em; +} + +.form { + display: flex; + flex-direction: column; + gap: 4em; + width: 100%; +} + +.inputGroup { + display: flex; + flex-direction: column; + gap: 1em; +} + +.input { + display: flex; + flex-direction: column; + gap: 0.5em; + width: 100%; +} + +.button-submit { + color: #004661; + background: #ffffff; + border: none; + border-radius: 20px; + padding: 10px 20px; + width: 100%; + font-weight: 600; + transition: 0.3s; + cursor: pointer; +} + +.button-submit:hover { + background: #bcbcbc; +} + +.placeholder { + flex-shrink: 0; + border-radius: 20px; + border: 1px solid #bcbcbc; + background: rgba(0, 0, 0, 0); + padding: 10px 20px; + color: #ffffff; +} + +.name { + font-size: 12px; + font-weight: 600; +} + +.placeholder::placeholder { + color: #ffffff; +} + +.link { + color: #bcbcbc; +} + +.otherLogin { + font-size: 12px; +} + +.placeholder option { + color: black; +} + +.button-logout{ + color: #004661; + background: #ffffff; + border: none; + border-radius: 20px; + padding: 10px 20px; + width: 10%; + font-weight: 600; + transition: 0.3s; + cursor: pointer; + position: absolute; + right: 150px; + display: flex; + align-items: center; + justify-content: center; + margin-top: 30px; +} + +.button-logout:hover { + background: #FF3838; + color: #FFF; +} + +/* navbar */ +.navButton { + display: flex; + align-items: center; + justify-content: space-between; + margin-right: 100px; +} +.navButton p, +a { + text-decoration: none; + margin-left: 10px; +} + +.otherLogin { + font-size: 12px; +} + +.finatecLogo { + margin-left: 100px; +} + + +/* home */ + +.content2 { + height: 100%; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; +} + +.div-lado-a-lado { + display: flex; + align-items: center; + color: #ffffff; + gap: 1em; +} + +.div1 { + flex: 1; + justify-content: center; + align-items: center; + flex-direction: column; + width: 500px; + padding-left: 60px; +} +.div2 { + flex: 1; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; +} + +.logo2 { + width: 400px; + height: auto; + align-items: center; +} + +.button-submit3 { + flex: 1; + color: #021842; + background: #ffffff; + border: none; + border-radius: 20px; + width: 200px; + height: 60px; + font-weight: 600; + font-size: 20px; + transition: 0.3s; + cursor: pointer; +} + +.button-submit3:hover { + background: #F39B00; +} + +.button-submit4 { + flex: 1; + color: #ffffff; + background: #021842; + border: none; + border-radius: 20px; + width: 200px; + height: 60px; + font-weight: 600; + font-size: 20px; + transition: 0.3s; + cursor: pointer; +} + +.button-submit4:hover { + background: #F39B00; +} + diff --git a/project/app/static/css/style.css b/project/app/static/css/style.css index 38aac279..79fb97cf 100644 --- a/project/app/static/css/style.css +++ b/project/app/static/css/style.css @@ -3,7 +3,7 @@ } body { - background-color: #021842; + background-image: linear-gradient(#021842 50%, #253e6c); flex-direction: column; display: flex; margin: 0; @@ -13,15 +13,38 @@ body { header { display: flex; align-items: center; - justify-content: space-around; - background-color: #ffffff; - color: #004661; + justify-content: space-between; + background-color: #021842; + color: #ffffff; height: 100px; + box-shadow: 10px 5px 5px #021233; +} + +.navButton { + display: flex; + align-items: center; + justify-content: space-between; + margin-right: 100px; +} +.navButton p, +a { + text-decoration: none; + margin-left: 10px; } +/* .navButton .link.highlighted { + background-color: yellow; +} */ img { - width: 203px; - height: 58px; + height: 20px; +} + +.finatecLogo { + margin-left: 100px; +} + +.profile { + height: 38px; } .logo { @@ -46,7 +69,7 @@ h1 { .footer { padding: 20px 0px; - color: #8a8989; + color: #ffffff; align-self: center; } @@ -59,7 +82,20 @@ h1 { flex-shrink: 0; border-radius: 20px; border: 1px solid #bcbcbc; - color: #ffffff; + color: #000000; + background-color: #ffffff; + gap: 1em; +} +.containerProject { + display: flex; + align-items: center; + padding: 24px 72px; + width: 280px; + flex-direction: column; + flex-shrink: 0; + border-radius: 20px; + border: 1px solid #bcbcbc; + color: white; gap: 1em; } @@ -82,21 +118,29 @@ h1 { gap: 0.5em; width: 100%; } +.inputExport { + display: flex; + justify-content: end; +} .button-submit { - color: #004661; - background: #ffffff; + color: #ffffff; + background: #021842; border: none; border-radius: 20px; padding: 10px 20px; - width: 100%; + width: 50%; font-weight: 600; transition: 0.3s; cursor: pointer; } .button-submit:hover { - background: #bcbcbc; + background: #f39b00; +} +.cardSubmit { + display: flex; + justify-content: center; } .placeholder { @@ -105,7 +149,15 @@ h1 { border: 1px solid #bcbcbc; background: rgba(0, 0, 0, 0); padding: 10px 20px; - color: #ffffff; + color: #323232; +} +.placeholderProject { + flex-shrink: 0; + border-radius: 20px; + border: 1px solid #bcbcbc; + background: rgba(0, 0, 0, 0); + padding: 10px 20px; + color: white; } .name { @@ -114,13 +166,20 @@ h1 { } .placeholder::placeholder { - color: #ffffff; + color: #323232; +} +.placeholderProject::placeholder { + color: white; } .link { color: #bcbcbc; } +.linkS{ + color: #f39b00; + } + .otherLogin { font-size: 12px; } @@ -128,27 +187,87 @@ h1 { .placeholder option { color: black; } +.placeholderProject option { + color: white; +} + +.placeholderProject .option-model{ + color: black; +} -.button-logout{ +.button-logout { color: #004661; background: #ffffff; border: none; - border-radius: 20px; - padding: 10px 20px; - width: 10%; + border-radius: 5px; + /* padding: 10px 20px; */ + width: 80px; + height: 30px; font-weight: 600; transition: 0.3s; cursor: pointer; - position: absolute; - right: 150px; + /* position: absolute; */ + /* right: 150px; */ display: flex; align-items: center; justify-content: center; - margin-top: 30px; + /* margin-top: 30px; */ } -.button-logout:hover { - background: #FF3838; - color: #FFF; +/* .button-logout:hover { + background: #ff3838; + color: #fff; +} */ + +/* ul { + list-style: none; +} +ul li { + display: inline-block; + position: relative; +} +ul li a { + display: block; + text-decoration: none; + text-align: center; +} +ul li ul.dropdown li { + display: block; } +ul li ul.dropdown { + width: 100%; + z-index: 999; + display: none; +} +ul li a:hover { + background-color: red; +} +ul li:hover ul.dropdown { + display: block; +} */ +.dropdown { + position: relative; + display: inline-block; +} + +.dropdown-content { + display: none; /* Removido o display: block; */ + position: absolute; + background-color: #f9f9f9; + width: 70px; + height: 20px; + /* box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2); */ + /* padding: 12px 16px; */ + z-index: 1; +} + +.sairImagem { + width: 20px; + margin-right: 10px; +} + +input[type="date"]::-webkit-calendar-picker-indicator { + cursor: pointer; + filter: invert(0.8) brightness(100%) sepia(0%) saturate(10000%) hue-rotate(0deg); +} diff --git a/project/app/static/imagem/finateclogo.png b/project/app/static/imagem/finateclogo.png deleted file mode 100644 index 004347d6..00000000 Binary files a/project/app/static/imagem/finateclogo.png and /dev/null differ diff --git a/project/app/static/imagem/finateclogo.svg b/project/app/static/imagem/finateclogo.svg new file mode 100644 index 00000000..801b0b43 --- /dev/null +++ b/project/app/static/imagem/finateclogo.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/project/app/static/imagem/fundoLogo.svg b/project/app/static/imagem/fundoLogo.svg new file mode 100644 index 00000000..8573006b --- /dev/null +++ b/project/app/static/imagem/fundoLogo.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/project/app/static/imagem/logo.svg b/project/app/static/imagem/logo.svg new file mode 100644 index 00000000..d58c868e --- /dev/null +++ b/project/app/static/imagem/logo.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/project/app/static/imagem/perfil.svg b/project/app/static/imagem/perfil.svg new file mode 100644 index 00000000..202307e3 --- /dev/null +++ b/project/app/static/imagem/perfil.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/project/app/static/imagem/perfilC.svg b/project/app/static/imagem/perfilC.svg new file mode 100644 index 00000000..1d47b4d7 --- /dev/null +++ b/project/app/static/imagem/perfilC.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/project/app/static/imagem/sairImg.svg b/project/app/static/imagem/sairImg.svg new file mode 100644 index 00000000..d17a0924 --- /dev/null +++ b/project/app/static/imagem/sairImg.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/project/app/templates/base.html b/project/app/templates/base.html index 58d9a66e..d9efb18c 100644 --- a/project/app/templates/base.html +++ b/project/app/templates/base.html @@ -5,7 +5,7 @@ AutomaTEC - + @@ -14,10 +14,14 @@ -
- finatec -

Sistema de prestação automático

-
+ {% block conteudo %} {% endblock %} diff --git a/project/app/templates/cadastro.html b/project/app/templates/cadastro.html index 001adbff..1c9ef4b5 100644 --- a/project/app/templates/cadastro.html +++ b/project/app/templates/cadastro.html @@ -1,7 +1,7 @@ {% extends 'base.html' %} {% block conteudo %} {% load static %} - + - - - + +
+ + +
- -

Cadastrar

+

Cadastro

+
{% csrf_token %}
-
- - +
+
+ + +
+
+ + +
-
- - +
+
+ + +
+
+ + +
-
- - +
+
+ + +
+
+ + +
- +
+ +
{% if error_messages %}
    @@ -81,9 +113,8 @@

    Cadastrar

    {% endfor %}
{% endif %} -

Possui uma conta? Logar

+

Possui uma conta? Logar

- {% endblock %} \ No newline at end of file diff --git a/project/app/templates/home.html b/project/app/templates/home.html new file mode 100644 index 00000000..d9b73d42 --- /dev/null +++ b/project/app/templates/home.html @@ -0,0 +1,37 @@ +{% extends 'base.html' %} +{% block conteudo %} +{% load static %} + + + + +
+ + +
+ + +
+
+

Automatec

+

Sistema de prestação de contas automático.
Facilidade no dia a dia da FINATEC.

+ +
+
+ logo +
+
+
+ +{% endblock %} \ No newline at end of file diff --git a/project/app/templates/login.html b/project/app/templates/login.html index 637d2d29..113ccda8 100644 --- a/project/app/templates/login.html +++ b/project/app/templates/login.html @@ -1,6 +1,7 @@ {% extends 'base.html' %} {% block conteudo %} {% load static %} + - + +
+ + +
-

Login

+
{% csrf_token %}
@@ -65,12 +80,14 @@

Login

- +
+ +
{% if error_message %}

{{ error_message }}

{% endif %} -

Não possui uma conta? criar

+

Não possui uma conta? criar

diff --git a/project/app/templates/projeto.html b/project/app/templates/projeto.html index 35d3ea33..0bc96c78 100644 --- a/project/app/templates/projeto.html +++ b/project/app/templates/projeto.html @@ -1,38 +1,147 @@ -{% extends 'base.html' %} -{% block conteudo %} -{% load static %} +{% extends 'base.html' %} {% block conteudo %} {% load static %} -
- {% csrf_token %} - -
+ + +
+ + +
+ +
+ +

Selecione o projeto

+
+ {% csrf_token %} +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+ +
+ +
+
+
-{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/project/app/urls.py b/project/app/urls.py index da413891..d805c123 100644 --- a/project/app/urls.py +++ b/project/app/urls.py @@ -2,9 +2,12 @@ from . import views from django.contrib.auth import views as auth_views +from .views import HomeView + urlpatterns = [ + path('', HomeView.as_view(), name='home'), path("cadastro/", views.cadastro, name="cadastro"), - path('', views.login, name='login' ), + path('login/', views.login, name='login' ), path('projeto/', views.projeto, name='projeto'), path('logout/', views.custom_logout, name='logout'), # path('login_teste/', views.login_teste, name='login_teste'), diff --git a/project/app/views.py b/project/app/views.py index 0483ff1e..04fd14e5 100644 --- a/project/app/views.py +++ b/project/app/views.py @@ -3,10 +3,38 @@ from django.contrib.auth import authenticate from django.contrib.auth import login as login_a from django.contrib.auth.decorators import login_required -from django.http import HttpResponseRedirect +from django.http import HttpResponseRedirect,HttpResponse from django.shortcuts import redirect from django.contrib.auth import logout from django.contrib.auth.password_validation import validate_password +from django.views.generic import TemplateView +from .models import Template +from .oracle_cruds import consultaPorID +from .new_dev import preenche_planilha,extrair,pegar_caminho +from .preenche_fub import preencher_fub_teste +from .preenche_fundep import preenche_fundep +import os +import datetime +import re + +from .capa import inserir_round_retangulo +def convert_datetime_to_string(value): + if isinstance(value, datetime.datetime): + return value.strftime('%d/%m/%Y') + return value +def extract_strings(input_string): + # Use regular expressions to find the text before and after '@@' + matches = re.findall(r'(.*?)@@(.*?)@@', input_string) + + if matches: + return tuple(matches[0]) + else: + + return (input_string, '') + +class HomeView(TemplateView): + template_name = 'home.html' + def cadastro(request): if request.method == "GET": @@ -14,7 +42,10 @@ def cadastro(request): else: usuario = request.POST.get('usuario') senha = request.POST.get('senha') + senha_confirmacao = request.POST.get('senhaConfirm') email = request.POST.get('email') + first_name = request.POST.get('nome1') + last_name = request.POST.get('nome2') try: validate_password(senha, user=User) @@ -27,11 +58,18 @@ def cadastro(request): if user: error_messages = ['Usuário já existe'] return render(request, 'cadastro.html', {'error_messages': error_messages}) + + if senha != senha_confirmacao: + error_messages = ['A senha e a confirmação da senha não coincidem.'] + return render(request, 'cadastro.html', {'error_messages': error_messages}) user = User.objects.create_user(username=usuario, password=senha, email=email) + user.is_active = True + user.first_name = first_name + user.last_name = last_name user.save() - return HttpResponseRedirect('/') + return HttpResponseRedirect('/login/') def login(request): if request.method =="GET": @@ -44,17 +82,252 @@ def login(request): if user: login_a(request, user) - return HttpResponseRedirect ('projeto/') + return HttpResponseRedirect ('/projeto/') else: error_message = 'Usuário ou senha inválido.' return render(request, 'login.html', {'error_message': error_message}) -@login_required(login_url="/") +@login_required(login_url="/login/") def projeto(request): # if request.user.is_authenticated: # return HttpResponse('Projetos') # else: - return render(request, 'projeto.html') + + global tabe + lista_append_db_sql = [] + result = {} + current_key = None + mapeamento = None + coduaigo = request.POST.get('usuario') + template_id = request.POST.get('template') + download = request.POST.get('Baixar') + data1 = request.POST.get('inicio') + data2 = request.POST.get('fim') + print(type(data1)) + print(data2) + try: + db_fin = consultaPorID(coduaigo) + except: + return render(request,'projeto.html',{ + "templates":Template.objects.all(), + }) + + + + # nome = Template.objects.get(pk=template_id) + # nome = Template.objects.get(pk=template_id) + try: + nome = Template.objects.get(pk=template_id) + except: + return render(request,'projeto.html',{ + "templates":Template.objects.all(), + }) + mapeamento = nome.mapeamento + #print(nome.mapeamento) + attribute_names = [ + #"id_mapeamento", + "codigo", + "nome", + "saldo", + "data_assinatura", + "data_vigencia", + "data_encerramento", + "tipo_contrato", + "instituicao_executora", + "processo", + "subprocesso", + "cod_proposta", + "proposta", + "objetivos", + "valor_aprovado", + "nome_tp_controle_saldo", + "grupo_gestores", + "gestor_resp", + "coordenador", + "procedimento_compra", + "tab_frete", + "tab_diarias", + "custo_op", + "nome_financiador", + "departamento", + "situacao", + "banco", + "agencia_bancaria", + "conta_bancaria", + "centro_custo", + "conta_caixa", + "categoria_projeto", + "cod_convenio_conta", + "cod_status", + "ind_sub_projeto", + "tipo_custo_op", + "projeto_mae", + "id_coordenador", + "id_financiador", + "id_instituicao", + "id_departamento", + "nome_instituicao", + "id_instituicao_executora", + "id_tipo" + ] + + # Check for non-empty attributes and print their names + for attribute_name in attribute_names: + attribute_value = getattr(mapeamento, attribute_name) + if attribute_value: + lista_append_db_sql.append(f"{attribute_value}@@{attribute_name}@@") + + print(lista_append_db_sql) + print('\n') + print(mapeamento.id_mapeamento) + print('\n') + print(mapeamento.data_vigencia) + output = [] + result = {} + current_key = None + current_subkey = None + + for line in lista_append_db_sql: + parts = line.strip().split(";") + i = 0 + + while i < len(parts): + if i + 2 < len(parts): + key = parts[i] + subkey = parts[i + 1] + subsubkey = parts[i + 2] + value = extrair(parts) + #print(value) + + if key == current_key: + + result[key].append((subkey,f"{subsubkey}@@{value[0].upper()}@@")) + + + else: + # If the key is different, create a new list + current_key = key + if key in result: + result[key].append((subkey,f"{subsubkey}@@{value[0].upper()}@@")) + else: + result[key]= [(subkey, f"{subsubkey}@@{value[0].upper()}@@")] + i += 3 + + output_dict = {key: value for key, value in result.items()} + + + #print(output_dict) + + # for key, value_list in output_dict.items(): + # for i, (position, template) in enumerate(value_list): + # placeholder = None + # if "'" in template: + # placeholder = template.split("'")[1] + # if placeholder in db_fin: + # value_to_insert = db_fin[placeholder] + # # Convert datetime objects to strings if necessary + # if isinstance(value_to_insert, datetime.datetime): + # value_to_insert = value_to_insert.strftime('%Y-%m-%d') + # if value_to_insert is not None: + # # Replace the template with the actual value + # value_list[i] = (position, template.replace(f"'{placeholder}'", value_to_insert)) + + # Crie um novo dicionário para armazenar os resultados + novo_dicionario = {} + + # Itere sobre o primeiro dicionário + for chave, lista_de_tuplas in output_dict.items(): + nova_lista_de_tuplas = [] + for tupla in lista_de_tuplas: + chave_do_segundo_dicionario = tupla[1] + #print(chave_do_segundo_dicionario) + #print(type(chave_do_segundo_dicionario)) + string_before, string_between = extract_strings(chave_do_segundo_dicionario) + valor_do_segundo_dicionário = db_fin.get(string_between, '') + #print(valor_do_segundo_dicionário) + valor_formatado = convert_datetime_to_string(valor_do_segundo_dicionário) + #print(valor_formatado) + #nova_tupla = (tupla[0],f"{strings[0]} {valor_formatado}") + nova_tupla = (tupla[0],f"{string_before}{valor_formatado}") + nova_lista_de_tuplas.append(nova_tupla) + novo_dicionario[chave] = nova_lista_de_tuplas + + #print(novo_dicionario) + + + dict_final = {} + for key, values in novo_dicionario.items(): + combined_values = {} + for item in values: + if item[0] in combined_values: + combined_values[item[0]] += ' ' + item[1] # Add a space before appending + else: + combined_values[item[0]] = item[1] + + dict_final[key] = [(k, v) for k, v in combined_values.items()] + + #print(dict_final) + tabe = None + if nome.nome_template == "fundep": + tabe = preenche_planilha("planilhas/ModeloFUNDEP.xlsx",dict_final) + if nome.nome_template == "fub": + tabe = preenche_planilha("planilhas/Modelo_Fub.xlsx",dict_final) + if nome.nome_template == "opas": + tabe = preenche_planilha("planilhas/ModeloOPAS.xlsx",dict_final) + if nome.nome_template == "fap": + tabe = preenche_planilha("planilhas/ModeloFAP.xlsx",dict_final) + if nome.nome_template == "finep": + tabe = preenche_planilha("planilhas/ModeloFINEP.xlsx",dict_final) + + + + + + + file_path = None + print(f"download{template_id}") + if template_id == '1': + keys = ['NOME_FAVORECIDO','CNPJ_FAVORECIDO','TIPO_LANCAMENTO','HIS_LANCAMENTO','DATA_EMISSAO','DATA_PAGAMENTO', 'VALOR_PAGO'] + file_path = pegar_caminho('planilhas_preenchidas/planilhas/Modelo_Fub.xlsx') + # data_obj = datetime.strptime(data1, "%Y-%m-%d") + # data1 = data_obj.strftime("%d/%m/%Y") + # data_obj2 = datetime.strptime(data2, "%Y-%m-%d") + # data2 = data_obj2.strftime("%d/%m/%Y") + preencher_fub_teste(coduaigo,convert_datetime_to_string(data1),convert_datetime_to_string(data2),keys,file_path) + inserir_round_retangulo(file_path,data1,data2,db_fin) + elif template_id == '2': + keys = ['NOME_FAVORECIDO','CNPJ_FAVORECIDO','NOME_RUBRICA','DATA_EMISSAO','DATA_PAGAMENTO', 'VALOR_PAGO'] + file_path = pegar_caminho('planilhas_preenchidas/planilhas/ModeloFUNDEP.xlsx') + preenche_fundep(coduaigo,convert_datetime_to_string(data1),convert_datetime_to_string(data2),keys,file_path) + elif template_id == '3': + + file_path = pegar_caminho('planilhas_preenchidas/planilhas/ModeloOPAS.xlsx') + elif template_id == '4': + + file_path = pegar_caminho('planilhas_preenchidas/planilhas/ModeloFAP.xlsx') + elif template_id == '5': + + file_path = pegar_caminho('planilhas_preenchidas/planilhas/ModeloFINEP.xlsx') + else: + # Handle cases where 'download' doesn't match any expected values + return HttpResponse("Invalid download request", status=400) + #print(file_path) + # Check if the file exists + + #print(os.path.exists(file_path)) + if os.path.exists(file_path): + with open(file_path, 'rb') as f: + response = HttpResponse(f.read(), content_type='application/octet-stream') + #print(f'aaaa{os.path.basename(file_path)}') + response['Content-Disposition'] = f'attachment; filename="{os.path.basename(file_path)}"' + return response + else: + print("Invalid aaaaaaaaaaa request") + + return render(request,'projeto.html',{ + "templates":Template.objects.all(), + + }) def custom_logout(request): logout(request) diff --git a/project/backend/__init__.py b/project/backend/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/project/backend/__pycache__/__init__.cpython-38.pyc b/project/backend/__pycache__/__init__.cpython-38.pyc new file mode 100644 index 00000000..4804c0af Binary files /dev/null and b/project/backend/__pycache__/__init__.cpython-38.pyc differ diff --git a/project/backend/__pycache__/admin.cpython-38.pyc b/project/backend/__pycache__/admin.cpython-38.pyc new file mode 100644 index 00000000..176c5f79 Binary files /dev/null and b/project/backend/__pycache__/admin.cpython-38.pyc differ diff --git a/project/backend/__pycache__/apps.cpython-38.pyc b/project/backend/__pycache__/apps.cpython-38.pyc new file mode 100644 index 00000000..76fc14d4 Binary files /dev/null and b/project/backend/__pycache__/apps.cpython-38.pyc differ diff --git a/project/backend/__pycache__/consultas_oracledb.cpython-38.pyc b/project/backend/__pycache__/consultas_oracledb.cpython-38.pyc new file mode 100644 index 00000000..25eb4e34 Binary files /dev/null and b/project/backend/__pycache__/consultas_oracledb.cpython-38.pyc differ diff --git a/project/backend/__pycache__/models.cpython-38.pyc b/project/backend/__pycache__/models.cpython-38.pyc new file mode 100644 index 00000000..3b09b122 Binary files /dev/null and b/project/backend/__pycache__/models.cpython-38.pyc differ diff --git a/project/backend/__pycache__/teste_projects.cpython-38.pyc b/project/backend/__pycache__/teste_projects.cpython-38.pyc new file mode 100644 index 00000000..1508c9f5 Binary files /dev/null and b/project/backend/__pycache__/teste_projects.cpython-38.pyc differ diff --git a/project/backend/__pycache__/urls.cpython-38.pyc b/project/backend/__pycache__/urls.cpython-38.pyc new file mode 100644 index 00000000..3f07f82f Binary files /dev/null and b/project/backend/__pycache__/urls.cpython-38.pyc differ diff --git a/project/backend/__pycache__/views.cpython-38.pyc b/project/backend/__pycache__/views.cpython-38.pyc new file mode 100644 index 00000000..5c469dca Binary files /dev/null and b/project/backend/__pycache__/views.cpython-38.pyc differ diff --git a/project/backend/admin.py b/project/backend/admin.py new file mode 100644 index 00000000..8c38f3f3 --- /dev/null +++ b/project/backend/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/project/backend/apps.py b/project/backend/apps.py new file mode 100644 index 00000000..6a3779f0 --- /dev/null +++ b/project/backend/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class BackendConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'backend' diff --git a/project/backend/consultas_oracledb.py b/project/backend/consultas_oracledb.py new file mode 100644 index 00000000..3a314ba8 --- /dev/null +++ b/project/backend/consultas_oracledb.py @@ -0,0 +1,107 @@ +import oracledb + + +file_path = "/home/ubuntu/Desktop/devfront/devfull/pass.txt" +conStr = '' +with open(file_path, 'r') as file: + conStr = file.readline().strip() + +def getCollumNames(): + + #inicializando o objeto que ira conectar no db + conn = None + #criando o objeto de conexão das + conn = oracledb.connect(conStr) + #criar um objeto cursor necessario para fazer as consultas + cur = conn.cursor() + cur.execute("SELECT * FROM IDEA.STG_PROJETOS_CONVENIAR") + + return cur + +print("\n") + +# cur.close() +# #encerra a conexao +# conn.close() +# print("conexão db completa!") + +def getlimitedRows(numb): + consulta = {} + a=[] + try: + connection = oracledb.connect(conStr) + cursor = connection.cursor() + print("Connected to database") + sqlite_select_query = f"SELECT * FROM IDEA.STG_PROJETOS_CONVENIAR WHERE ROWNUM <={numb}" + + cursor.execute(sqlite_select_query) + records = cursor.fetchall() + collums = getCollumNames() + a=collums.description + + for i in range(0, numb): + # Create a dictionary to store the data for each i + i_data = {} + for j in range(len(a)): + key = a[j][0] + value = records[i][j] + + if key in i_data: + i_data[key].append(value) # If the key already exists, append the new value + else: + i_data[key] = value # If the key doesn't exist, create a list with the value + + # Add the i_data dictionary to the consulta dictionary under the i key + consulta[i] = i_data + + + #print(consulta) + + # print(f"\n \n {consulta['OBJETIVOS']} \n") + #consulta[0]['OBJETIVOS'] = str(consulta[0]['OBJETIVOS']) + + cursor.close() + + except oracledb.Error as error: + print("Failed to read data from table", error) + finally: + if connection: + connection.close() + print("The connection is closed") + + # return records + return consulta + + +# a = int(input("")) +# lul = getlimitedRows(a) +# print("\n") +# print(type(lul)) + +def getallRows(): + + try: + connection = oracledb.connect(conStr) + cursor = connection.cursor() + print("Connected to database") + sqlite_select_query = f"SELECT * FROM IDEA.STG_PROJETOS_CONVENIAR" + cursor.execute(sqlite_select_query) + records = cursor.fetchall() + length = len(records) + print(len(records)) + cursor.execute(sqlite_select_query) + + cursor.close() + + except oracledb.Error as error: + print("Failed to read data from table", error) + finally: + if connection: + connection.close() + print("The connection is closed") + + # return records + return length + + + diff --git a/project/backend/migrations/__init__.py b/project/backend/migrations/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/project/backend/migrations/__pycache__/__init__.cpython-38.pyc b/project/backend/migrations/__pycache__/__init__.cpython-38.pyc new file mode 100644 index 00000000..9cba528b Binary files /dev/null and b/project/backend/migrations/__pycache__/__init__.cpython-38.pyc differ diff --git a/project/backend/models.py b/project/backend/models.py new file mode 100644 index 00000000..71a83623 --- /dev/null +++ b/project/backend/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/project/backend/templates/backend/base.html b/project/backend/templates/backend/base.html new file mode 100644 index 00000000..58d9a66e --- /dev/null +++ b/project/backend/templates/backend/base.html @@ -0,0 +1,26 @@ +{% load static %} + + + + AutomaTEC + + + + + + + + + + + +
+ finatec +

Sistema de prestação automático

+
+ {% block conteudo %} + + {% endblock %} +
Copyright BRISA 2021©. Todos direitos reservados.
+ + \ No newline at end of file diff --git a/project/backend/templates/backend/projetos.html b/project/backend/templates/backend/projetos.html new file mode 100644 index 00000000..f6a28c4c --- /dev/null +++ b/project/backend/templates/backend/projetos.html @@ -0,0 +1,180 @@ +{% extends 'base.html' %} +{% block conteudo %} +{% load static %} + +
+
+ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {% for entry in data %} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {% endfor %} + +
CODIGONOMESALDODATA ASSINATURADATA VIGENCIADATA ENCERRAMENTOTIPO DO CONTRATOINSTITUICAO EXECUTORAPROCESSOSUBPROCESSOCOD_PROPOSTAPROPOSTAVALOR_APROVADONOME_TP_CONTROLE_SALDOGRUPO_GESTORESGESTOR_RESPCOORDENADORPROCEDIMENTO_COMPRATAB_FRETETAB_DIARIASCUSTO_OPNOME_FINANCIADORDEPARTAMENTOSITUACAOBANCOAGENCIA_BANCARIACONTA_BANCARIACENTRO_CUSTOCONTA_CAIXACATEGORIA_PROJETOCOD_CONVENIO_CONTACOD_STATUSIND_SUB_PROJETOTIPO_CUSTO_OPPROJETO_MAEID_COORDENADORID_FINANCIADORID_INSTITUICAOID_DEPARTAMENTONOME_INSTITUICAOID_INSTITUICAO_EXECUTORAID_TIPO
{{ entry.CODIGO }}{{ entry.NOME }}{{ entry.SALDO }}{{ entry.DATA_ASSINATURA }}{{ entry.DATA_VIGENCIA }}{{ entry.DATA_ENCERRAMENTO }}{{ entry.TIPO_CONTRATO }}{{ entry.INSTITUICAO_EXECUTORA }}{{ entry.PROCESSO }}{{ entry.SUBPROCESSO }}{{ entry.COD_PROPOSTA }}{{ entry.PROPOSTA }}{{ entry.VALOR_APROVADO }}{{ entry.NOME_TP_CONTROLE_SALDO }}{{ entry.GRUPO_GESTORES }}{{ entry.GESTOR_RESP }}{{ entry.COORDENADOR }}{{ entry.PROCEDIMENTO_COMPRA }}{{ entry.TAB_FRETE }}{{ entry.TAB_DIARIAS }}{{ entry.CUSTO_OP }}{{ entry.NOME_FINANCIADOR }}{{ entry.DEPARTAMENTO }}{{ entry.SITUACAO }}{{ entry.BANCO }}{{ entry.AGENCIA_BANCARIA }}{{ entry.CONTA_BANCARIA }}{{ entry.CENTRO_CUSTO }}{{ entry.CONTA_CAIXA }}{{ entry.CATEGORIA_PROJETO }}{{ entry.COD_CONVENIO_CONTA }}{{ entry.COD_STATUS }}{{ entry.IND_SUB_PROJETO }}{{ entry.TIPO_CUSTO_OP }}{{ entry.PROJETO_MAE }}{{ entry.ID_COORDENADOR }}{{ entry.ID_FINANCIADOR }}{{ entry.ID_INSTITUICAO }}{{ entry.ID_DEPARTAMENTO }}{{ entry.NOME_INSTITUICAO }}{{ entry.ID_INSTITUICAO_EXECUTORA }}{{ entry.ID_TIPO }}

+ + + +{% endblock %} \ No newline at end of file diff --git a/project/backend/tests.py b/project/backend/tests.py new file mode 100644 index 00000000..7ce503c2 --- /dev/null +++ b/project/backend/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/project/backend/urls.py b/project/backend/urls.py new file mode 100644 index 00000000..64705d83 --- /dev/null +++ b/project/backend/urls.py @@ -0,0 +1,6 @@ +from django.urls import path +from . import views + +urlpatterns = [ + path('', views.project_views, name='pjview'), +] \ No newline at end of file diff --git a/project/backend/views.py b/project/backend/views.py new file mode 100644 index 00000000..bd30d4c8 --- /dev/null +++ b/project/backend/views.py @@ -0,0 +1,86 @@ +from django.shortcuts import render +from .consultas_oracledb import getlimitedRows,getallRows +from django.core.paginator import Paginator,EmptyPage, PageNotAnInteger +# Create your views here. + +def project_views(request): + length = getallRows() + data = getlimitedRows(length) + + relevant_data = [] + for key, inner_dict in data.items(): + relevant_info = { + 'CODIGO': inner_dict.get('CODIGO', ''), + 'NOME': inner_dict.get('NOME', ''), + 'SALDO': inner_dict.get('SALDO', ''), + 'DATA_ASSINATURA': inner_dict.get('DATA_ASSINATURA', ''), + 'DATA_VIGENCIA': inner_dict.get('DATA_VIGENCIA', ''), + 'DATA_ENCERRAMENTO': inner_dict.get('DATA_ENCERRAMENTO', ''), + 'TIPO_CONTRATO': inner_dict.get('TIPO_CONTRATO', ''), + 'INSTITUICAO_EXECUTORA': inner_dict.get('INSTITUICAO_EXECUTORA', ''), + 'PROCESSO': inner_dict.get('PROCESSO', ''), + 'SUBPROCESSO': inner_dict.get('SUBPROCESSO', ''), + 'COD_PROPOSTA': inner_dict.get('COD_PROPOSTA', ''), + 'PROPOSTA': inner_dict.get('PROPOSTA', ''), + #'OBJETIVOS': inner_dict.get('OBJETIVOS', ''), + 'VALOR_APROVADO': inner_dict.get('VALOR_APROVADO', ''), + 'NOME_TP_CONTROLE_SALDO': inner_dict.get('NOME_TP_CONTROLE_SALDO', ''), + 'GRUPO_GESTORES': inner_dict.get('GRUPO_GESTORES', ''), + 'GESTOR_RESP': inner_dict.get('GESTOR_RESP', ''), + 'COORDENADOR': inner_dict.get('COORDENADOR', ''), + 'PROCEDIMENTO_COMPRA': inner_dict.get('PROCEDIMENTO_COMPRA', ''), + 'TAB_FRETE': inner_dict.get('TAB_FRETE', ''), + 'TAB_DIARIAS': inner_dict.get('TAB_DIARIAS', ''), + 'CUSTO_OP': inner_dict.get('CUSTO_OP', ''), + 'NOME_FINANCIADOR': inner_dict.get('NOME_FINANCIADOR', ''), + 'DEPARTAMENTO': inner_dict.get('DEPARTAMENTO', ''), + 'SITUACAO': inner_dict.get('SITUACAO', ''), + 'BANCO': inner_dict.get('BANCO', ''), + 'AGENCIA_BANCARIA': inner_dict.get('AGENCIA_BANCARIA', ''), + 'CONTA_BANCARIA': inner_dict.get('CONTA_BANCARIA', ''), + 'CENTRO_CUSTO': inner_dict.get('CENTRO_CUSTO', ''), + 'CONTA_CAIXA': inner_dict.get('CONTA_CAIXA', ''), + 'CATEGORIA_PROJETO': inner_dict.get('CATEGORIA_PROJETO', ''), + 'COD_CONVENIO_CONTA': inner_dict.get('COD_CONVENIO_CONTA', ''), + 'COD_STATUS': inner_dict.get('COD_STATUS', ''), + 'IND_SUB_PROJETO': inner_dict.get('IND_SUB_PROJETO', ''), + 'TIPO_CUSTO_OP': inner_dict.get('TIPO_CUSTO_OP', ''), + 'PROJETO_MAE': inner_dict.get('PROJETO_MAE', ''), + 'ID_COORDENADOR': inner_dict.get('ID_COORDENADOR', ''), + 'ID_FINANCIADOR': inner_dict.get('ID_FINANCIADOR', ''), + 'ID_INSTITUICAO': inner_dict.get('ID_INSTITUICAO', ''), + 'ID_DEPARTAMENTO': inner_dict.get('ID_DEPARTAMENTO', ''), + 'NOME_INSTITUICAO': inner_dict.get('NOME_INSTITUICAO', ''), + 'ID_INSTITUICAO_EXECUTORA': inner_dict.get('ID_INSTITUICAO_EXECUTORA', ''), + 'ID_TIPO': inner_dict.get('ID_TIPO', ''), + } + relevant_data.append(relevant_info) + # Number of items to display per page + + search_query = request.GET.get('search', '') + if search_query: + search_results = [] + for entry in relevant_data: + for key, value in entry.items(): + if key == 'CODIGO' and str(search_query) == str(value): + search_results.append(entry) + break + elif key != 'CODIGO' and isinstance(value, str) and search_query.lower() in value.lower(): + search_results.append(entry) + break + else: + search_results = relevant_data + + items_per_page = 10 + paginator = Paginator(search_results, items_per_page) + + page = request.GET.get('page') + try: + items = paginator.get_page(page) + except PageNotAnInteger: + items = paginator.get_page(1) + except EmptyPage: + items = paginator.get_page(paginator.num_pages) + + return render(request, "backend/projetos.html", {"search_query": search_query, + "data":items}) diff --git a/project/db.sqlite3 b/project/db.sqlite3 index 7494f163..883e6bb4 100644 Binary files a/project/db.sqlite3 and b/project/db.sqlite3 differ diff --git a/project/project/__pycache__/__init__.cpython-310.pyc b/project/project/__pycache__/__init__.cpython-310.pyc index 89773d19..3ceab1c4 100644 Binary files a/project/project/__pycache__/__init__.cpython-310.pyc and b/project/project/__pycache__/__init__.cpython-310.pyc differ diff --git a/project/project/__pycache__/__init__.cpython-311.pyc b/project/project/__pycache__/__init__.cpython-311.pyc index 73fdbfae..4e6e0280 100644 Binary files a/project/project/__pycache__/__init__.cpython-311.pyc and b/project/project/__pycache__/__init__.cpython-311.pyc differ diff --git a/project/project/__pycache__/__init__.cpython-38.pyc b/project/project/__pycache__/__init__.cpython-38.pyc new file mode 100644 index 00000000..f50d301d Binary files /dev/null and b/project/project/__pycache__/__init__.cpython-38.pyc differ diff --git a/project/project/__pycache__/settings.cpython-310.pyc b/project/project/__pycache__/settings.cpython-310.pyc index b544b004..53bb0887 100644 Binary files a/project/project/__pycache__/settings.cpython-310.pyc and b/project/project/__pycache__/settings.cpython-310.pyc differ diff --git a/project/project/__pycache__/settings.cpython-311.pyc b/project/project/__pycache__/settings.cpython-311.pyc index 8ca67426..59d6431d 100644 Binary files a/project/project/__pycache__/settings.cpython-311.pyc and b/project/project/__pycache__/settings.cpython-311.pyc differ diff --git a/project/project/__pycache__/urls.cpython-310.pyc b/project/project/__pycache__/urls.cpython-310.pyc index 9b9f9900..72eefe69 100644 Binary files a/project/project/__pycache__/urls.cpython-310.pyc and b/project/project/__pycache__/urls.cpython-310.pyc differ diff --git a/project/project/__pycache__/urls.cpython-311.pyc b/project/project/__pycache__/urls.cpython-311.pyc index 80c9abe2..7622de82 100644 Binary files a/project/project/__pycache__/urls.cpython-311.pyc and b/project/project/__pycache__/urls.cpython-311.pyc differ diff --git a/project/project/__pycache__/wsgi.cpython-310.pyc b/project/project/__pycache__/wsgi.cpython-310.pyc index 2b15a062..742a38bc 100644 Binary files a/project/project/__pycache__/wsgi.cpython-310.pyc and b/project/project/__pycache__/wsgi.cpython-310.pyc differ diff --git a/project/project/__pycache__/wsgi.cpython-311.pyc b/project/project/__pycache__/wsgi.cpython-311.pyc index 1366548e..e6149ab5 100644 Binary files a/project/project/__pycache__/wsgi.cpython-311.pyc and b/project/project/__pycache__/wsgi.cpython-311.pyc differ diff --git a/project/project/__pycache__/wsgi.cpython-38.pyc b/project/project/__pycache__/wsgi.cpython-38.pyc new file mode 100644 index 00000000..cd4c6681 Binary files /dev/null and b/project/project/__pycache__/wsgi.cpython-38.pyc differ diff --git a/project/project/populando_banco.py b/project/project/populando_banco.py new file mode 100644 index 00000000..05c75224 --- /dev/null +++ b/project/project/populando_banco.py @@ -0,0 +1,50 @@ +from app.models import Mapeamento + +# fundep +mapa = Mapeamento( + CODIGO = "", + NOME = "'Receita x Despesa';'Título do Projeto: ';A3", + SALDO = "", + DATA_ASSINATURA = "", + DATA_VIGENCIA = "", + DATA_ENCERRAMENTO = "", + TIPO_CONTRATO = "", + INSTITUICAO_EXECUTORA = "", + PROCESSO = "", + SUBPROCESSO = "", + COD_PROPOSTA = "", + PROPOSTA = "", + OBJETIVOS = "", + VALOR_APROVADO = "", + NOME_TP_CONTROLE_SALDO = "", + GRUPO_GESTORES = "", + GESTOR_RESP = "", + COORDENADOR = "", + PROCEDIMENTO_COMPRA = "", + TAB_FRETE = "", + TAB_DIARIAS = "", + CUSTO_OP = "", + NOME_FINANCIADOR = "", + DEPARTAMENTO = "", + SITUACAO = "", + BANCO = "", + AGENCIA_BANCARIA = "", + CONTA_BANCARIA = "", + CENTRO_CUSTO = "", + CONTA_CAIXA = "", + CATEGORIA_PROJETO = "", + COD_CONVENIO_CONTA = "", + COD_STATUS = "", + IND_SUB_PROJETO = "", + TIPO_CUSTO_OP = "", + PROJETO_MAE = "", + ID_COORDENADOR = "", + ID_FINANCIADOR = "", + ID_INSTITUICAO = "", + ID_DEPARTAMENTO = "", + NOME_INSTITUICAO = "", + ID_INSTITUICAO_EXECUTORA = "", + ID_TIPO = "" +) + +mapa.save() \ No newline at end of file diff --git a/project/project/settings.py b/project/project/settings.py index e6d07cc2..72b26e9c 100644 --- a/project/project/settings.py +++ b/project/project/settings.py @@ -27,6 +27,8 @@ 'django.contrib.messages', 'django.contrib.staticfiles', 'app', + 'backend', + ] MIDDLEWARE = [ @@ -62,20 +64,31 @@ # Database # https://docs.djangoproject.com/en/4.2/ref/settings/#databases +file_path = "/home/ubuntu/Desktop/devfront/devfull/postgre.txt" +with open(file_path, 'r') as file: + password_database = file.readline().strip() DATABASES = { 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': BASE_DIR / 'db.sqlite3', - } + 'ENGINE': 'django.db.backends.postgresql', + 'NAME': 'automatec', + 'USER': 'automauser', + 'PASSWORD': password_database, + 'HOST': 'localhost', + 'PORT': '', + }, + # 'default': { + # 'ENGINE': 'django.db.backends.sqlite3', + # 'NAME': BASE_DIR / 'db.sqlite3', + # } } # DATABASES = { -# 'default': { +# 'default': { # 'ENGINE': 'django.db.backends.postgresql', -# 'NAME': 'myproject', -# 'USER': 'myprojectuser', -# 'PASSWORD': 'password', +# 'NAME': 'automatec', +# 'USER': 'automauser', +# 'PASSWORD': '', # 'HOST': 'localhost', # 'PORT': '', # }, diff --git a/project/project/urls.py b/project/project/urls.py index a3a89530..aa668f2d 100644 --- a/project/project/urls.py +++ b/project/project/urls.py @@ -5,4 +5,5 @@ urlpatterns = [ path('', include('app.urls')), path('admin/', admin.site.urls), + path('projetos/',include('backend.urls')), ] diff --git a/project/tabela b/project/tabela new file mode 100644 index 00000000..618551cd Binary files /dev/null and b/project/tabela differ diff --git a/src/codigo-inicial/antigo_dev.py b/src/codigo-inicial/antigo_dev.py index df5d6a34..4f9a3390 100644 --- a/src/codigo-inicial/antigo_dev.py +++ b/src/codigo-inicial/antigo_dev.py @@ -172,7 +172,7 @@ def preenche_planilha(planilha, dicionario): } -modelo_fundep = { +model_fundep = { "Relação e despesas" : [ # campos cadastrais ("C3", "Instituição Gestora"), @@ -194,6 +194,146 @@ def preenche_planilha(planilha, dicionario): ] } +modelo_fundep = { + "Relação e despesas" : [ + ("C3", {INSTITUICAO_EXECUTORA}), + ("F3", {}), #Talvez seja outra + ("I3", {SUBPROCESSO}), + ("C4", {NOME}), + ("C5", {COORDENADOR}), + ("I5", {}), #Datas diferentes do banco + #Não achei novos campos + ] +} + +modelo_fub = { + "Receita x Despesa": [ + ("A3", f"Título do Projeto: {NOME}"), + ("A4", f"Executora: {INSTITUICAO_EXECUTORA}"), + ("A5", "Partícipe: FINATEC - Fundação de Empreendimentos Científicos e Tecnológicos"), #Não achei correspondente da consulta + ("A6", f"Período de Execução Físico-Financeiro: {DATA_ASSINATURA} a {DATA_VIGENCIA}"), + ("A7", f"Período que abrange esta prestação: {x} a {DATA_VIGENCIA}"), #SEM INFORMAÇÃO DA PRIMEIRA DATA + + ("H46", {COORDENADOR}), #Acredito que pode variar o valor + ], + "Exec. Receita e Despesa":[ + #mesmo campos + ], + + "Passagens e Locomoção" : [ + #mesmo campo + ], + + "Pessoa Jurídica":[ + #mesmo campo + ], + + "Obrigaçoes tributárias" : [ + #mesmo campo + ], + + "Pessoa Fisica" : [ + #mesmo campo + ], + + "Serv. Terceiro CLT" : [ + #mesmo campo + ], + + "Conciliação Bancária":[ + #mesmo campo + ], + "Rendimento de Aplicação":[ + #mesmo campo + ] + + +} + +modelo_opas = { + "Relatório Consolidado" : [ + ("C3", {NOME}), + ("C4", {NOME_FINANCIADOR}), + ("C5", {}), #não achei o nome do representante + ("C6", {NOME}), + ("C7", f"{DATA_ASSINATURA} a {DATA_VIGENCIA}"), + ], + + "Relatório Detalhado" : [ + #mesmo anterior + ] +} + +#Modelo inconscistente +modelo_fap = { + "ANEXO I" : [ + ("E7", f"{SUBPROCESSO} \n {PROCESSO}") + + #Questões cadastrais + ("A14",{}), #instituição gestora diferente do banco + ("A20", {NOME}), + ("C22", f"Período da Prestação de Contas: {DATA_ASSINATURA} a {DATA_VIGENCIA}") + + ("D46", {COORDENADOR}), + + ], + "ANEXO II" : [ + ("I3", f"{SUBPROCESSO} \n {PROCESSO}") + ("A5", f"Coordenador: {COORDENADOR}"), + ("A6", f"Concedente: {NOME_FINANCIADOR}"), + ("A7", f"Convenente: {NOME_INSTITUICAO}"), + ("A8", f"Executora: {ID_INSTITUICAO_EXECUTORA}"), + + ], + "ANEXO III" : [ + ("A6", f"Título do Projeto: {NOME}"), + ("A7", f"Instituição Gestora: {NOME_INSTITUICAO}"), + ("A8", f"Instituição Executora: {ID_INSTITUICAO_EXECUTORA}") + + ], + "ANEXO IV" : [ + ("A14", {NOME_INSTITUICAO}), + ("A16", {NOME}), + ("F16", {DATA_VIGENCIA}), + ], + "Conciliação" : [ + ("A10", {NOME_INSTITUICAO}) + ] +} + +modelo_finep = { + "Relatório de Exec Financ A.1" : [ + ("B5", {NOME_INSTITUICAO}), #Diferente da consulta + ("B6", f"de {DATA_ASSINATURA} a {DATA_VIGENCIA}"), #Datas diferentes + ("B7", f"de {DATA_ASSINATURA} a {DATA_VIGENCIA}"), #datas diferentes + + ("F33", {COORDENADOR}) + ], + "DEMOSTR. RECEITA E DESPESA A.2" : [ + ("C5", {NOME_INSTITUICAO}), + ("C6", {DATA_ASSINATURA}), + ("C7", {DATA_VIGENCIA}), + ], + "Elemento de Despesa 39a" : [ + #Semelhante ao anterior + ], + "Elemento de Despesa 39B" : [ + #Semelhante ao anterior + ], + #Varios elementos semelhantes + "Rend. APL" : [ + ("A4", {NOME_INSTITUICAO}), + ("A6", {NOME}), + + #? + ("G6", {DATA_VIGENCIA}), + ("G7", {DATA_ENCERRAMENTO}), + ], + "Conciliação Bancária A.3" : [ + #Titulo igual o da maioria + ] +} + # for nomePlanilha, entradaDados in planilha_local_dados.items(): # planilhaAtual = workbook[nomePlanilha]