diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 diff --git a/Pipfile b/Pipfile new file mode 100644 index 00000000..85e734b5 --- /dev/null +++ b/Pipfile @@ -0,0 +1,31 @@ +[[source]] +url = "https://pypi.org/simple" +verify_ssl = true +name = "pypi" + +[packages] +django = "==4.2.4" +asgiref = "==3.7.2" +attrs = "==23.1.0" +cffi = "==1.16.0" +cryptography = "==41.0.5" +et-xmlfile = "==1.1.0" +iniconfig = "==2.0.0" +openpyxl = "==3.0.10" +oracledb = "==1.4.2" +packaging = "==23.2" +pillow = "==10.1.0" +pluggy = "==1.3.0" +psycopg2-binary = "==2.9.9" +py = "==1.11.0" +pycparser = "==2.21" +pytest = "==7.1.2" +sqlparse = "==0.4.4" +tomli = "==2.0.1" +typing-extensions = "==4.8.0" +python-dotenv = "*" + +[dev-packages] + +[requires] +python_version = "3.8" diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/docs/atas/06-29.md b/docs/atas/06-29.md old mode 100644 new mode 100755 diff --git a/docs/atas/07-11.md b/docs/atas/07-11.md old mode 100644 new mode 100755 diff --git a/docs/atas/07-20.md b/docs/atas/07-20.md old mode 100644 new mode 100755 diff --git a/docs/atas/07-27.md b/docs/atas/07-27.md old mode 100644 new mode 100755 diff --git a/docs/atas/08-01.md b/docs/atas/08-01.md old mode 100644 new mode 100755 diff --git a/docs/atas/08-09.md b/docs/atas/08-09.md old mode 100644 new mode 100755 diff --git a/docs/atas/08-10.md b/docs/atas/08-10.md old mode 100644 new mode 100755 diff --git a/docs/atas/08-17.md b/docs/atas/08-17.md old mode 100644 new mode 100755 diff --git a/docs/index.md b/docs/index.md old mode 100644 new mode 100755 diff --git a/docs/planejamento/StoryMapping.md b/docs/planejamento/StoryMapping.md old mode 100644 new mode 100755 diff --git a/docs/planejamento/assets/fluxograma.png b/docs/planejamento/assets/fluxograma.png old mode 100644 new mode 100755 diff --git a/docs/planejamento/assets/incremental.png b/docs/planejamento/assets/incremental.png old mode 100644 new mode 100755 diff --git a/docs/planejamento/assets/logo.png b/docs/planejamento/assets/logo.png old mode 100644 new mode 100755 diff --git a/docs/planejamento/assets/mvp.png b/docs/planejamento/assets/mvp.png old mode 100644 new mode 100755 diff --git a/docs/planejamento/assets/roadmap.png b/docs/planejamento/assets/roadmap.png old mode 100644 new mode 100755 diff --git a/docs/planejamento/backlog/backlog.md b/docs/planejamento/backlog/backlog.md old mode 100644 new mode 100755 diff --git a/docs/planejamento/backlog/backlog1.md b/docs/planejamento/backlog/backlog1.md old mode 100644 new mode 100755 diff --git a/docs/planejamento/contexto.md b/docs/planejamento/contexto.md old mode 100644 new mode 100755 diff --git a/docs/planejamento/escopo.md b/docs/planejamento/escopo.md old mode 100644 new mode 100755 diff --git a/docs/planejamento/fluxograma.md b/docs/planejamento/fluxograma.md old mode 100644 new mode 100755 diff --git a/docs/planejamento/heatmap.md b/docs/planejamento/heatmap.md old mode 100644 new mode 100755 diff --git a/docs/planejamento/metodologia.md b/docs/planejamento/metodologia.md old mode 100644 new mode 100755 diff --git a/docs/planejamento/requisitos/elicitacao.md b/docs/planejamento/requisitos/elicitacao.md old mode 100644 new mode 100755 diff --git a/docs/planejamento/requisitos/priorizacao.md b/docs/planejamento/requisitos/priorizacao.md old mode 100644 new mode 100755 diff --git a/docs/planejamento/roadmap.md b/docs/planejamento/roadmap.md old mode 100644 new mode 100755 diff --git a/docs/planejamento/tecnologias.md b/docs/planejamento/tecnologias.md old mode 100644 new mode 100755 diff --git a/docs/planejamento/teste.md b/docs/planejamento/teste.md old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/PipelinedeDados.md b/docs/treinamento/estudos_individuais/PipelinedeDados.md old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 1.png b/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 1.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 10.png b/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 10.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 11.png b/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 11.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 12.png b/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 12.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 13.png b/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 13.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 14.png b/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 14.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 15.png b/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 15.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 16.png b/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 16.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 17.png b/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 17.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 18.png b/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 18.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 19.png b/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 19.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 2.png b/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 2.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 20.png b/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 20.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 21.png b/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 21.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 22.png b/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 22.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 23.png b/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 23.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 24.png b/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 24.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 25.png b/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 25.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 26.png b/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 26.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 27.png b/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 27.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 28.png b/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 28.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 29.png b/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 29.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 3.png b/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 3.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 30.png b/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 30.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 31.png b/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 31.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 32.png b/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 32.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 33.png b/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 33.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 34.png b/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 34.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 35.png b/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 35.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 36.png b/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 36.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 4.png b/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 4.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 5.png b/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 5.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 6.png b/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 6.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 7.png b/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 7.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 8.png b/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 8.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 9.png b/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled 9.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled.png b/docs/treinamento/estudos_individuais/SQL Specialist 2cc9a31985644e2abf723fddd17f2768/Untitled.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/assets/fundBD/Untitled.png b/docs/treinamento/estudos_individuais/assets/fundBD/Untitled.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/assets/fundBD/Untitled1.png b/docs/treinamento/estudos_individuais/assets/fundBD/Untitled1.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/assets/fundBD/Untitled10.png b/docs/treinamento/estudos_individuais/assets/fundBD/Untitled10.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/assets/fundBD/Untitled11.png b/docs/treinamento/estudos_individuais/assets/fundBD/Untitled11.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/assets/fundBD/Untitled12.png b/docs/treinamento/estudos_individuais/assets/fundBD/Untitled12.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/assets/fundBD/Untitled13.png b/docs/treinamento/estudos_individuais/assets/fundBD/Untitled13.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/assets/fundBD/Untitled14.png b/docs/treinamento/estudos_individuais/assets/fundBD/Untitled14.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/assets/fundBD/Untitled15.png b/docs/treinamento/estudos_individuais/assets/fundBD/Untitled15.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/assets/fundBD/Untitled16.png b/docs/treinamento/estudos_individuais/assets/fundBD/Untitled16.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/assets/fundBD/Untitled17.png b/docs/treinamento/estudos_individuais/assets/fundBD/Untitled17.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/assets/fundBD/Untitled18.png b/docs/treinamento/estudos_individuais/assets/fundBD/Untitled18.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/assets/fundBD/Untitled19.png b/docs/treinamento/estudos_individuais/assets/fundBD/Untitled19.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/assets/fundBD/Untitled2.png b/docs/treinamento/estudos_individuais/assets/fundBD/Untitled2.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/assets/fundBD/Untitled20.png b/docs/treinamento/estudos_individuais/assets/fundBD/Untitled20.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/assets/fundBD/Untitled21.png b/docs/treinamento/estudos_individuais/assets/fundBD/Untitled21.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/assets/fundBD/Untitled22.png b/docs/treinamento/estudos_individuais/assets/fundBD/Untitled22.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/assets/fundBD/Untitled23.png b/docs/treinamento/estudos_individuais/assets/fundBD/Untitled23.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/assets/fundBD/Untitled24.png b/docs/treinamento/estudos_individuais/assets/fundBD/Untitled24.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/assets/fundBD/Untitled25.png b/docs/treinamento/estudos_individuais/assets/fundBD/Untitled25.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/assets/fundBD/Untitled26.png b/docs/treinamento/estudos_individuais/assets/fundBD/Untitled26.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/assets/fundBD/Untitled27.png b/docs/treinamento/estudos_individuais/assets/fundBD/Untitled27.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/assets/fundBD/Untitled28.png b/docs/treinamento/estudos_individuais/assets/fundBD/Untitled28.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/assets/fundBD/Untitled29.png b/docs/treinamento/estudos_individuais/assets/fundBD/Untitled29.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/assets/fundBD/Untitled3.png b/docs/treinamento/estudos_individuais/assets/fundBD/Untitled3.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/assets/fundBD/Untitled30.png b/docs/treinamento/estudos_individuais/assets/fundBD/Untitled30.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/assets/fundBD/Untitled31.png b/docs/treinamento/estudos_individuais/assets/fundBD/Untitled31.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/assets/fundBD/Untitled32.png b/docs/treinamento/estudos_individuais/assets/fundBD/Untitled32.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/assets/fundBD/Untitled33.png b/docs/treinamento/estudos_individuais/assets/fundBD/Untitled33.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/assets/fundBD/Untitled34.png b/docs/treinamento/estudos_individuais/assets/fundBD/Untitled34.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/assets/fundBD/Untitled35.png b/docs/treinamento/estudos_individuais/assets/fundBD/Untitled35.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/assets/fundBD/Untitled36.png b/docs/treinamento/estudos_individuais/assets/fundBD/Untitled36.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/assets/fundBD/Untitled4.png b/docs/treinamento/estudos_individuais/assets/fundBD/Untitled4.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/assets/fundBD/Untitled5.png b/docs/treinamento/estudos_individuais/assets/fundBD/Untitled5.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/assets/fundBD/Untitled6.png b/docs/treinamento/estudos_individuais/assets/fundBD/Untitled6.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/assets/fundBD/Untitled7.png b/docs/treinamento/estudos_individuais/assets/fundBD/Untitled7.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/assets/fundBD/Untitled8.png b/docs/treinamento/estudos_individuais/assets/fundBD/Untitled8.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/assets/fundBD/Untitled9.png b/docs/treinamento/estudos_individuais/assets/fundBD/Untitled9.png old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/fundamentosBD.md b/docs/treinamento/estudos_individuais/fundamentosBD.md old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/linguagem_framework.md b/docs/treinamento/estudos_individuais/linguagem_framework.md old mode 100644 new mode 100755 diff --git a/docs/treinamento/estudos_individuais/metodologias.md b/docs/treinamento/estudos_individuais/metodologias.md old mode 100644 new mode 100755 diff --git a/docs/treinamento/introducao.md b/docs/treinamento/introducao.md old mode 100644 new mode 100755 diff --git a/docs/treinamento/treinamentos/mkdocs.md b/docs/treinamento/treinamentos/mkdocs.md old mode 100644 new mode 100755 diff --git a/docs/treinamento/treinamentos/pipelinesimples.md b/docs/treinamento/treinamentos/pipelinesimples.md old mode 100644 new mode 100755 diff --git a/docs/treinamento/treinamentos/postgresql.md b/docs/treinamento/treinamentos/postgresql.md old mode 100644 new mode 100755 diff --git a/imagemFap/fapdf.png b/imagemFap/fapdf.png new file mode 100644 index 00000000..00fb89de Binary files /dev/null and b/imagemFap/fapdf.png differ diff --git a/imagemFinep/Finep.png b/imagemFinep/Finep.png new file mode 100644 index 00000000..30f2dabc Binary files /dev/null and b/imagemFinep/Finep.png differ diff --git a/project/app/imagensCapa/agencia.png b/imagensCapa/agencia.png old mode 100644 new mode 100755 similarity index 100% rename from project/app/imagensCapa/agencia.png rename to imagensCapa/agencia.png diff --git a/project/app/imagensCapa/agencia_branco.png b/imagensCapa/agencia_branco.png old mode 100644 new mode 100755 similarity index 100% rename from project/app/imagensCapa/agencia_branco.png rename to imagensCapa/agencia_branco.png diff --git a/project/app/imagensCapa/agente.png b/imagensCapa/agente.png old mode 100644 new mode 100755 similarity index 100% rename from project/app/imagensCapa/agente.png rename to imagensCapa/agente.png diff --git a/project/app/imagensCapa/agente_branco.png b/imagensCapa/agente_branco.png old mode 100644 new mode 100755 similarity index 100% rename from project/app/imagensCapa/agente_branco.png rename to imagensCapa/agente_branco.png diff --git a/project/app/imagensCapa/analista.png b/imagensCapa/analista.png old mode 100644 new mode 100755 similarity index 100% rename from project/app/imagensCapa/analista.png rename to imagensCapa/analista.png diff --git a/project/app/imagensCapa/analista_branco.png b/imagensCapa/analista_branco.png old mode 100644 new mode 100755 similarity index 100% rename from project/app/imagensCapa/analista_branco.png rename to imagensCapa/analista_branco.png diff --git a/project/app/imagensCapa/assinaturas_responsaveis.png b/imagensCapa/assinaturas_responsaveis.png old mode 100644 new mode 100755 similarity index 100% rename from project/app/imagensCapa/assinaturas_responsaveis.png rename to imagensCapa/assinaturas_responsaveis.png diff --git a/project/app/imagensCapa/assistente.png b/imagensCapa/assistente.png old mode 100644 new mode 100755 similarity index 100% rename from project/app/imagensCapa/assistente.png rename to imagensCapa/assistente.png diff --git a/project/app/imagensCapa/assistente_branco.png b/imagensCapa/assistente_branco.png old mode 100644 new mode 100755 similarity index 100% rename from project/app/imagensCapa/assistente_branco.png rename to imagensCapa/assistente_branco.png diff --git a/project/app/imagensCapa/banco.png b/imagensCapa/banco.png old mode 100644 new mode 100755 similarity index 100% rename from project/app/imagensCapa/banco.png rename to imagensCapa/banco.png diff --git a/project/app/imagensCapa/banco_branco.png b/imagensCapa/banco_branco.png old mode 100644 new mode 100755 similarity index 100% rename from project/app/imagensCapa/banco_branco.png rename to imagensCapa/banco_branco.png diff --git a/project/app/imagensCapa/centrodecusto.png b/imagensCapa/centrodecusto.png old mode 100644 new mode 100755 similarity index 100% rename from project/app/imagensCapa/centrodecusto.png rename to imagensCapa/centrodecusto.png diff --git a/project/app/imagensCapa/centrodecusto_branco.png b/imagensCapa/centrodecusto_branco.png old mode 100644 new mode 100755 similarity index 100% rename from project/app/imagensCapa/centrodecusto_branco.png rename to imagensCapa/centrodecusto_branco.png diff --git a/project/app/imagensCapa/conta_corrente.png b/imagensCapa/conta_corrente.png old mode 100644 new mode 100755 similarity index 100% rename from project/app/imagensCapa/conta_corrente.png rename to imagensCapa/conta_corrente.png diff --git a/project/app/imagensCapa/conta_corrente_branco.png b/imagensCapa/conta_corrente_branco.png old mode 100644 new mode 100755 similarity index 100% rename from project/app/imagensCapa/conta_corrente_branco.png rename to imagensCapa/conta_corrente_branco.png diff --git a/project/app/imagensCapa/coordenador.png b/imagensCapa/coordenador.png old mode 100644 new mode 100755 similarity index 100% rename from project/app/imagensCapa/coordenador.png rename to imagensCapa/coordenador.png diff --git a/project/app/imagensCapa/coordenador_branco.png b/imagensCapa/coordenador_branco.png old mode 100644 new mode 100755 similarity index 100% rename from project/app/imagensCapa/coordenador_branco.png rename to imagensCapa/coordenador_branco.png diff --git a/project/app/imagensCapa/dadosdoacordo.png b/imagensCapa/dadosdoacordo.png old mode 100644 new mode 100755 similarity index 100% rename from project/app/imagensCapa/dadosdoacordo.png rename to imagensCapa/dadosdoacordo.png diff --git a/project/app/imagensCapa/gerente.png b/imagensCapa/gerente.png old mode 100644 new mode 100755 similarity index 100% rename from project/app/imagensCapa/gerente.png rename to imagensCapa/gerente.png diff --git a/project/app/imagensCapa/gerente_branco.png b/imagensCapa/gerente_branco.png old mode 100644 new mode 100755 similarity index 100% rename from project/app/imagensCapa/gerente_branco.png rename to imagensCapa/gerente_branco.png diff --git a/project/app/imagensCapa/periodo.png b/imagensCapa/periodo.png old mode 100644 new mode 100755 similarity index 100% rename from project/app/imagensCapa/periodo.png rename to imagensCapa/periodo.png diff --git a/project/app/imagensCapa/periodo_branco.png b/imagensCapa/periodo_branco.png old mode 100644 new mode 100755 similarity index 100% rename from project/app/imagensCapa/periodo_branco.png rename to imagensCapa/periodo_branco.png diff --git "a/project/app/imagensCapa/presta\303\247\303\243odecontasparcial.png" b/imagensCapa/prestacaodecontaparcial.png old mode 100644 new mode 100755 similarity index 100% rename from "project/app/imagensCapa/presta\303\247\303\243odecontasparcial.png" rename to imagensCapa/prestacaodecontaparcial.png diff --git a/project/app/imagensCapa/processo.png b/imagensCapa/processo.png old mode 100644 new mode 100755 similarity index 100% rename from project/app/imagensCapa/processo.png rename to imagensCapa/processo.png diff --git a/project/app/imagensCapa/processo_branco.png b/imagensCapa/processo_branco.png old mode 100644 new mode 100755 similarity index 100% rename from project/app/imagensCapa/processo_branco.png rename to imagensCapa/processo_branco.png diff --git a/project/app/imagensCapa/projeto.png b/imagensCapa/projeto.png old mode 100644 new mode 100755 similarity index 100% rename from project/app/imagensCapa/projeto.png rename to imagensCapa/projeto.png diff --git a/project/app/imagensCapa/projeto_branco.png b/imagensCapa/projeto_branco.png old mode 100644 new mode 100755 similarity index 100% rename from project/app/imagensCapa/projeto_branco.png rename to imagensCapa/projeto_branco.png diff --git a/project/app/imagensIBICIT/finatec.png b/imagensIBICIT/finatec.png old mode 100644 new mode 100755 similarity index 100% rename from project/app/imagensIBICIT/finatec.png rename to imagensIBICIT/finatec.png diff --git a/project/app/imagensIBICIT/ibict.png b/imagensIBICIT/ibict.png old mode 100644 new mode 100755 similarity index 100% rename from project/app/imagensIBICIT/ibict.png rename to imagensIBICIT/ibict.png diff --git a/mkdocs.yml b/mkdocs.yml old mode 100644 new mode 100755 diff --git a/project/app/planilhas/IBICT.xlsx b/planilhas/IBICT.xlsx old mode 100644 new mode 100755 similarity index 100% rename from project/app/planilhas/IBICT.xlsx rename to planilhas/IBICT.xlsx diff --git a/planilhas/ModeloFUNDEP.xlsx b/planilhas/ModeloFUNDEP.xlsx new file mode 100644 index 00000000..36aa718b Binary files /dev/null and b/planilhas/ModeloFUNDEP.xlsx differ diff --git a/planilhas/Modelo_Fub.xlsx b/planilhas/Modelo_Fub.xlsx new file mode 100644 index 00000000..918a3c3d Binary files /dev/null and b/planilhas/Modelo_Fub.xlsx differ diff --git a/planilhas/modeloFap.xlsx b/planilhas/modeloFap.xlsx new file mode 100644 index 00000000..194798fb Binary files /dev/null and b/planilhas/modeloFap.xlsx differ diff --git a/planilhas/modeloFinep.xlsx b/planilhas/modeloFinep.xlsx new file mode 100644 index 00000000..345931ae Binary files /dev/null and b/planilhas/modeloFinep.xlsx differ diff --git a/project/app/planilhas_preenchidas/planilhas/test.txt b/planilhas_preenchidas/planilhas/test.txt old mode 100644 new mode 100755 similarity index 100% rename from project/app/planilhas_preenchidas/planilhas/test.txt rename to planilhas_preenchidas/planilhas/test.txt diff --git a/project/Pipfile b/project/Pipfile new file mode 100644 index 00000000..858d5cc4 --- /dev/null +++ b/project/Pipfile @@ -0,0 +1,12 @@ +[[source]] +url = "https://pypi.org/simple" +verify_ssl = true +name = "pypi" + +[packages] +pypdf2 = {extras = ["crypto"], version = "*"} + +[dev-packages] + +[requires] +python_version = "3.8" diff --git a/project/Pipfile.lock b/project/Pipfile.lock new file mode 100644 index 00000000..2e38ce2c --- /dev/null +++ b/project/Pipfile.lock @@ -0,0 +1,77 @@ +{ + "_meta": { + "hash": { + "sha256": "1d496b8910b18d9a7d591f735a3382726d731862baa96c07f133a7f4f68615d4" + }, + "pipfile-spec": 6, + "requires": { + "python_version": "3.8" + }, + "sources": [ + { + "name": "pypi", + "url": "https://pypi.org/simple", + "verify_ssl": true + } + ] + }, + "default": { + "pycryptodome": { + "hashes": [ + "sha256:06d6de87c19f967f03b4cf9b34e538ef46e99a337e9a61a77dbe44b2cbcf0690", + "sha256:09609209ed7de61c2b560cc5c8c4fbf892f8b15b1faf7e4cbffac97db1fffda7", + "sha256:210ba1b647837bfc42dd5a813cdecb5b86193ae11a3f5d972b9a0ae2c7e9e4b4", + "sha256:2a1250b7ea809f752b68e3e6f3fd946b5939a52eaeea18c73bdab53e9ba3c2dd", + "sha256:2ab6ab0cb755154ad14e507d1df72de9897e99fd2d4922851a276ccc14f4f1a5", + "sha256:3427d9e5310af6680678f4cce149f54e0bb4af60101c7f2c16fdf878b39ccccc", + "sha256:3cd3ef3aee1079ae44afaeee13393cf68b1058f70576b11439483e34f93cf818", + "sha256:405002eafad114a2f9a930f5db65feef7b53c4784495dd8758069b89baf68eab", + "sha256:417a276aaa9cb3be91f9014e9d18d10e840a7a9b9a9be64a42f553c5b50b4d1d", + "sha256:4401564ebf37dfde45d096974c7a159b52eeabd9969135f0426907db367a652a", + "sha256:49a4c4dc60b78ec41d2afa392491d788c2e06edf48580fbfb0dd0f828af49d25", + "sha256:5601c934c498cd267640b57569e73793cb9a83506f7c73a8ec57a516f5b0b091", + "sha256:6e0e4a987d38cfc2e71b4a1b591bae4891eeabe5fa0f56154f576e26287bfdea", + "sha256:76658f0d942051d12a9bd08ca1b6b34fd762a8ee4240984f7c06ddfb55eaf15a", + "sha256:76cb39afede7055127e35a444c1c041d2e8d2f1f9c121ecef573757ba4cd2c3c", + "sha256:8d6b98d0d83d21fb757a182d52940d028564efe8147baa9ce0f38d057104ae72", + "sha256:9b3ae153c89a480a0ec402e23db8d8d84a3833b65fa4b15b81b83be9d637aab9", + "sha256:a60fedd2b37b4cb11ccb5d0399efe26db9e0dd149016c1cc6c8161974ceac2d6", + "sha256:ac1c7c0624a862f2e53438a15c9259d1655325fc2ec4392e66dc46cdae24d044", + "sha256:acae12b9ede49f38eb0ef76fdec2df2e94aad85ae46ec85be3648a57f0a7db04", + "sha256:acc2614e2e5346a4a4eab6e199203034924313626f9620b7b4b38e9ad74b7e0c", + "sha256:acf6e43fa75aca2d33e93409f2dafe386fe051818ee79ee8a3e21de9caa2ac9e", + "sha256:baee115a9ba6c5d2709a1e88ffe62b73ecc044852a925dcb67713a288c4ec70f", + "sha256:c18b381553638414b38705f07d1ef0a7cf301bc78a5f9bc17a957eb19446834b", + "sha256:d29daa681517f4bc318cd8a23af87e1f2a7bad2fe361e8aa29c77d652a065de4", + "sha256:d5954acfe9e00bc83ed9f5cb082ed22c592fbbef86dc48b907238be64ead5c33", + "sha256:ec0bb1188c1d13426039af8ffcb4dbe3aad1d7680c35a62d8eaf2a529b5d3d4f", + "sha256:ec1f93feb3bb93380ab0ebf8b859e8e5678c0f010d2d78367cf6bc30bfeb148e", + "sha256:f0e6d631bae3f231d3634f91ae4da7a960f7ff87f2865b2d2b831af1dfb04e9a", + "sha256:f35d6cee81fa145333137009d9c8ba90951d7d77b67c79cbe5f03c7eb74d8fe2", + "sha256:f47888542a0633baff535a04726948e876bf1ed880fddb7c10a736fa99146ab3", + "sha256:fb3b87461fa35afa19c971b0a2b7456a7b1db7b4eba9a8424666104925b78128" + ], + "version": "==3.20.0" + }, + "pypdf2": { + "extras": [ + "crypto" + ], + "hashes": [ + "sha256:a74408f69ba6271f71b9352ef4ed03dc53a31aa404d29b5d31f53bfecfee1440", + "sha256:d16e4205cfee272fbdc0568b68d82be796540b1537508cef59388f839c191928" + ], + "markers": "python_version >= '3.6'", + "version": "==3.0.1" + }, + "typing-extensions": { + "hashes": [ + "sha256:83f085bd5ca59c80295fc2a82ab5dac679cbe02b9f33f7d83af68e241bea51b0", + "sha256:c1f94d72897edaf4ce775bb7558d5b79d8126906a14ea5ed1635921406c0387a" + ], + "markers": "python_version < '3.10'", + "version": "==4.11.0" + } + }, + "develop": {} +} diff --git a/project/app/Pipfile b/project/app/Pipfile new file mode 100644 index 00000000..2b9ce246 --- /dev/null +++ b/project/app/Pipfile @@ -0,0 +1,12 @@ +[[source]] +url = "https://pypi.org/simple" +verify_ssl = true +name = "pypi" + +[packages] +pypdf2 = "*" + +[dev-packages] + +[requires] +python_version = "3.8" diff --git a/project/app/Pipfile.lock b/project/app/Pipfile.lock new file mode 100644 index 00000000..0928f315 --- /dev/null +++ b/project/app/Pipfile.lock @@ -0,0 +1,38 @@ +{ + "_meta": { + "hash": { + "sha256": "3bea0cc4172ed9a3642a128c45c4e411a6fcf65b1b4f113c7f40ec69227f5574" + }, + "pipfile-spec": 6, + "requires": { + "python_version": "3.8" + }, + "sources": [ + { + "name": "pypi", + "url": "https://pypi.org/simple", + "verify_ssl": true + } + ] + }, + "default": { + "pypdf2": { + "hashes": [ + "sha256:a74408f69ba6271f71b9352ef4ed03dc53a31aa404d29b5d31f53bfecfee1440", + "sha256:d16e4205cfee272fbdc0568b68d82be796540b1537508cef59388f839c191928" + ], + "index": "pypi", + "markers": "python_version >= '3.6'", + "version": "==3.0.1" + }, + "typing-extensions": { + "hashes": [ + "sha256:83f085bd5ca59c80295fc2a82ab5dac679cbe02b9f33f7d83af68e241bea51b0", + "sha256:c1f94d72897edaf4ce775bb7558d5b79d8126906a14ea5ed1635921406c0387a" + ], + "markers": "python_version < '3.10'", + "version": "==4.11.0" + } + }, + "develop": {} +} diff --git a/project/app/__init__.py b/project/app/__init__.py old mode 100644 new mode 100755 diff --git a/project/app/admin.py b/project/app/admin.py old mode 100644 new mode 100755 index 8c38f3f3..2de19f67 --- a/project/app/admin.py +++ b/project/app/admin.py @@ -1,3 +1,23 @@ from django.contrib import admin +from django.contrib.auth.admin import UserAdmin as BaseUserAdmin +from django.contrib.auth.models import User -# Register your models here. +from .models import Employee + + +# Define an inline admin descriptor for Employee model +# which acts a bit like a singleton +class EmployeeInline(admin.StackedInline): + model = Employee + can_delete = False + verbose_name_plural = "employee" + + +# Define a new User admin +class UserAdmin(BaseUserAdmin): + inlines = [EmployeeInline] + + +# Re-register UserAdmin +admin.site.unregister(User) +admin.site.register(User, UserAdmin) \ No newline at end of file diff --git a/project/app/apps.py b/project/app/apps.py old mode 100644 new mode 100755 diff --git a/project/app/capa.py b/project/app/capaFub.py old mode 100644 new mode 100755 similarity index 96% rename from project/app/capa.py rename to project/app/capaFub.py index 94a591aa..5f437101 --- a/project/app/capa.py +++ b/project/app/capaFub.py @@ -99,23 +99,18 @@ def inserir_round_retangulo(planilha,data1,data2,dicionariofin): 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') + ("E6",'NomePessoaFinanciador'), + ("E9",'NomeConvenio'), + ("E14",'NomePessoaResponsavel'), + ("E17",'Processo'), + ("E19",'CodConvenio'), + ("K17",'NomeBanco'), + ("K19",'Conta'), + ("K21",'Agencia') + ] } - - - - - # Create an empty dictionary to store the values from the second dictionary result_dict = {} @@ -159,7 +154,7 @@ def inserir_round_retangulo(planilha,data1,data2,dicionariofin): 'gerente_branco.png',#17 'periodo.png',#18 'periodo_branco.png',#19 - 'prestaçãodecontasparcial.png',#20 + 'prestacaodecontaparcial.png',#20 'processo.png',#21 'processo_branco.png',#22 'projeto.png',#23 @@ -173,7 +168,7 @@ def inserir_round_retangulo(planilha,data1,data2,dicionariofin): # List to hold Image objects images = [] - nomePasta = "imagensCapa" + nomePasta = "../../imagensCapa" diretorio = os.path.dirname(__file__) # Loop through the list of image names and create Image objects @@ -185,7 +180,7 @@ def inserir_round_retangulo(planilha,data1,data2,dicionariofin): images.append(img) - + #daqui pra cima testado #estilo imagem worksheet.add_image(images[20], "B2")#prestação @@ -210,6 +205,7 @@ def inserir_round_retangulo(planilha,data1,data2,dicionariofin): 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' @@ -271,6 +267,8 @@ def inserir_round_retangulo(planilha,data1,data2,dicionariofin): worksheet['K21'].font = Font(name="Tahoma", size=10, color="204c80",bold=False) worksheet['K21'].alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + #testado + worksheet.add_image(images[25], "B19")#Centro de custo worksheet.merge_cells('B19:D20') worksheet['B19'] = 'CENTRO DE CUSTO' @@ -292,6 +290,8 @@ def inserir_round_retangulo(planilha,data1,data2,dicionariofin): 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) + #testado + worksheet.add_image(images[7], "B30")#Assistente worksheet.merge_cells('B30:D32') @@ -314,7 +314,7 @@ def inserir_round_retangulo(planilha,data1,data2,dicionariofin): worksheet.add_image(images[16], "B34")#gerengte worksheet.merge_cells('B34:D36') - worksheet['B34'] = 'COORDENADORA DE GESTÃO DE PROJETOS' + worksheet['B34'] = 'GERENTE 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 @@ -329,3 +329,4 @@ def inserir_round_retangulo(planilha,data1,data2,dicionariofin): # Save the workbook workbook.save(planilha) + workbook.close() \ No newline at end of file diff --git a/project/app/capaGeral.py b/project/app/capaGeral.py new file mode 100644 index 00000000..cb3a54da --- /dev/null +++ b/project/app/capaGeral.py @@ -0,0 +1,332 @@ +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_retanguloGeral(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",'NomePessoaFinanciador'), + ("E9",'NomeConvenio'), + ("E14",'NomePessoaResponsavel'), + ("E17",'SubProcesso'), + ("E19",'CodConvenio'), + ("K17",'NomeBanco'), + ("K19",'Conta'), + ("K21",'Agencia') + + ] + } + + # 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 + 'prestacaodecontaparcial.png',#20 + 'processo.png',#21 + 'processo_branco.png',#22 + 'projeto.png',#23 + 'projeto_branco.png',#24, + 'centrodecusto.png',#25, + 'centrodecusto_branco.png' + ] + + + + # List to hold Image objects + images = [] + + nomePasta = "../../imagensCapa" + diretorio = os.path.dirname(__file__) + + # Loop through the list of image names and create Image objects + for i, name in enumerate(image_names): + caminhoImage = os.path.join(diretorio, nomePasta, name) + pil_image = PILImage.open(caminhoImage) + pil_image.save(caminhoImage) + img = Image(caminhoImage) + images.append(img) + + + #daqui pra cima testado + + #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'] = 'CONVÊNIO' + 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) + + #testado + + 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) + #testado + + + 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'] = 'GERENTE 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) + workbook.close() \ No newline at end of file diff --git a/project/app/estiloFINEP.py b/project/app/estiloFINEP.py index 3d60c294..cc2f93a7 100644 --- a/project/app/estiloFINEP.py +++ b/project/app/estiloFINEP.py @@ -1,125 +1,4272 @@ import openpyxl from openpyxl.styles import Font, PatternFill, Alignment,NamedStyle,Border, Side +from openpyxl.utils import get_column_letter +from openpyxl.drawing.image import Image +from PIL import Image as PILImage import os -#pegar o caminho do arquivo -def pegar_caminho(nome_arquivo): +import random - # Obter o caminho absoluto do arquivo Python em execução - caminho_script = os.path.abspath(__file__) +def pegar_caminho(subdiretorio): + # Obtém o caminho do script atual + arq_atual = os.path.abspath(__file__) + + # Obtém o diretório do script + app = os.path.dirname(arq_atual) + + # Obtém o diretório pai do script + project = os.path.dirname(app) + + # Obtém o diretório pai do projeto + pipeline = os.path.dirname(project) + + # Junta o diretório pai do projeto com o subdiretório desejado + caminho_pipeline = os.path.join(pipeline, subdiretorio) + + return caminho_pipeline + +def estiloRelatorioExecFinanceiroA1(tabela,tamanho,stringTamanho): + '''Estilo da Pagina do Relatorio Execução da Receita e Despesa + + Argumentos: + tabela : recebe o arquivo correspondente a tabela Fub extensão xlsx. Esse arquivo ja foi iniciado e passou pela preencher fub mas ainda esta sem o estilo que sera aplicado nessa função. + tamanho : é o tamanho total de linhas que irão ser geradas dinâmicamente. O valor varia dentre o tamanho da quantidade de rubricas diferente que o projeto possui, excluindo Obras e Instalações + Aplicações Financeira e Equipamento e Material Permanente sendo nacional ou importado. + stringTamanho : refere-se aonde esta localizado a string brasília na pagina Receita e despesa para a referencias das formulas. + + + ''' + + if tamanho == 0: + tamanho = 1 + #Carrregar o arquivo da tabela, e inicia a worksheet com o nome da sheet "Relatório de Exec Financ A.1" + caminho = pegar_caminho(tabela) + workbook = openpyxl.load_workbook(caminho) + sheet = workbook['Relatório de Exec Financ A.1'] + + #tamanho recebido para alocar o tamanho das linha que e correspondetente ao que vai ser preenchido da consulta do database mais o tamanho do cabecario que e 16 e cores + size = tamanho + 12 + size2 = size + 1 + + + azul = 'ccffff' + cinza = 'bebebf' + + #remover as gridlines + sheet.sheet_view.showGridLines = False + + + #cabecario RELATÓRIO DE EXECUÇÃO FINANCEIRA + sheet.merge_cells('A1:I1') + sheet['A1'] = f'ANEXO 1' + sheet['A1'].font = Font(name="Arial", size=12, color="000000",bold=True) + sheet['A1'].alignment = Alignment(horizontal="center",vertical="center") + + + sheet.merge_cells('A2:I2') + sheet['A2'] = f'RELATÓRIO DE EXECUÇÃO FINANCEIRA' + sheet['A2'].font = Font(name="Arial", size=12, color="000000",bold=True) + sheet['A2'].alignment = Alignment(horizontal="center",vertical="center") + + + # sheet.merge_cells('B4:F4') + # sheet['A4'] = "" + # sheet['A4'].font = Font(name="Arial", size=12, color="000000") + # sheet['A4'].alignment = Alignment(horizontal="left",vertical="center") + + # sheet.merge_cells('B5:F5') + # sheet['A5'] = "" + # sheet['A5'].font = Font(name="Arial", size=12, color="000000") + # sheet['A5'].alignment = Alignment(horizontal="left",vertical="center") + + # sheet.merge_cells('B6:F6') + # sheet['A6'] = "" + # sheet['A6'].font = Font(name="Arial", size=12, color="000000") + # sheet['A6'].alignment = Alignment(horizontal="left",vertical="center") + + # sheet.merge_cells('B7:F7') + # sheet['A6'] = "" + # sheet['A6'].font = Font(name="Arial", size=12, color="000000") + # sheet['A6'].alignment = Alignment(horizontal="left",vertical="center") + + # sheet.merge_cells('C8:E8') + # sheet['A6'] = "" + # sheet['A6'].font = Font(name="Arial", size=12, color="000000") + # sheet['A6'].alignment = Alignment(horizontal="left",vertical="center") + + # sheet.merge_cells('B9:E9') + # sheet['B9'] = "" + # sheet['B9'].font = Font(name="Arial", size=12, color="000000") + # sheet['B9'].alignment = Alignment(horizontal="left",vertical="center") + + # sheet.merge_cells('F9:I9') + # sheet['F9'] = "" + # sheet['F9'].font = Font(name="Arial", size=12, color="000000") + # sheet['F9'].alignment = Alignment(horizontal="left",vertical="center") + + #CATEGORIA ECONÔMICA / RUBRICAS + sheet.merge_cells('A9:A10') + sheet['A9'] = "CATEGORIA ECONÔMICA / RUBRICAS" + sheet['A9'].font = Font(name="Arial", size=12, color="000000",bold=True) + sheet['A9'].alignment = Alignment(horizontal="left",vertical="center") + sheet['A9'].fill = PatternFill(start_color=azul, end_color=azul,fill_type = "solid") + + + #Concedente,Participe1,Participe 2,total b10 e e10 + values = ["Concedente","Partícipe 1","Partícipe 2",'Total'] + coluna = 2 + for a,b in enumerate(values): + sheet.cell(row=10, column=coluna, value=b) + coluna = coluna + 1 + + #Concedente,Participe1,Participe 2,total f10 e i10 + values = ["Concedente","Partícipe 1","Partícipe 2",'Total'] + coluna = 6 + for a,b in enumerate(values): + sheet.cell(row=10, column=coluna, value=b) + coluna = coluna + 1 + + + sheet.merge_cells('B9:E9') + #Executado No Periodo + sheet['B9'] = 'EXECUTADO NO PERÍODO' + sheet['B9'].font = Font(name="Arial", size=12, color="000000",bold=True) + sheet['B9'].alignment = Alignment(horizontal="center",vertical="center") + sheet['B9'].fill = PatternFill(start_color=azul, end_color=azul,fill_type = "solid") + sheet['B9'].border = Border(top=Side(border_style="double") ,left = Side(border_style="hair") ,right =Side(border_style="hair") ,bottom=Side(border_style="hair") ) + + #EXECUTADO ATÉ O PERÍODO + sheet.merge_cells('F9:I9') + sheet['F9'] = 'EXECUTADO ATÉ O PERÍODO' + sheet['F9'].font = Font(name="Arial", size=12, color="000000",bold=True) + sheet['F9'].alignment = Alignment(horizontal="center",vertical="center") + sheet['F9'].fill = PatternFill(start_color=azul, end_color=azul,fill_type = "solid") + sheet['F9'].border = Border(top=Side(border_style="double") ,left = Side(border_style="hair") ,right =Side(border_style="hair") ,bottom=Side(border_style="hair") ) + + #DESPESA CORRENTES + sheet['A11'] = '3.DESPESAS CORRENTES' + sheet['A11'].font = Font(name="Arial", size=12, color="000000",bold=True) + sheet['A11'].alignment = Alignment(horizontal="center",vertical="center") + sheet['A11'].border = Border(top=Side(border_style="double") ,left = Side(border_style="hair") ,right =Side(border_style="hair") ,bottom=Side(border_style="hair") ) + + #pintar inicio da tabela de azul + for rows in sheet.iter_rows(min_row=9, max_row=10, min_col=1, max_col=9): + for cell in rows: + + cell.fill = PatternFill(start_color=azul, end_color=azul,fill_type = "solid") + + + sheet['E10'] = "Total" + sheet['E10'].font = Font(name="Arial", size=12, color="000000",bold=True) + sheet['E10'].alignment = Alignment(horizontal="left",vertical="center") + sheet['E10'].fill = PatternFill(start_color=azul, end_color=azul,fill_type = "solid") + + sheet['I10'] = "Total" + sheet['I10'].font = Font(name="Arial", size=12, color="000000",bold=True) + sheet['I10'].alignment = Alignment(horizontal="left",vertical="center") + sheet['I10'].fill = PatternFill(start_color=azul, end_color=azul,fill_type = "solid") + + + #4.DESPESAS DE CAPITAL + sheet[f'A{size2}'] = '4.DESPESAS DE CAPITAL' + sheet[f'A{size2}'].font = Font(name="Arial", size=12, color="000000",bold=True) + sheet[f'A{size2}'].alignment = Alignment(horizontal="left",vertical="center") + sheet[f'A{size2}'].border = Border(top=Side(border_style="double") ,left = Side(border_style="hair") + ,right =Side(border_style="hair") ,bottom=Side(border_style="hair") ) + + + + + sheet.column_dimensions['a'].width = 55 + sheet.column_dimensions['b'].width = 20 + sheet.column_dimensions['c'].width = 20 + sheet.column_dimensions['d'].width = 20 + sheet.column_dimensions['e'].width = 20 + sheet.column_dimensions['f'].width = 20 + sheet.column_dimensions['g'].width = 20 + sheet.column_dimensions['h'].width = 20 + sheet.column_dimensions['i'].width = 20 + + + + #51- Obras e Instalações + celulasAzul = f"A{size2+1}" + cell = sheet[celulasAzul] + cell.value = f'51 - Obras e Instalações' + cell.alignment = Alignment(horizontal="left",vertical="center",wrap_text=True) + cell.font = Font(name="Arial", size=12, color="000000",bold=True) + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,bottom=Side(border_style="hair"),right=Side(border_style="hair") ) + #deiarlinha de obras e instalções em negrito + + + #a) Obras + celulasAzul = f"A{size2+2}" + cell = sheet[celulasAzul] + cell.value = f'a) Obras' + cell.alignment = Alignment(horizontal="left",vertical="center",wrap_text=True) + cell.font = Font(name="Arial", size=12, color="000000") + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,bottom=Side(border_style="hair"),right=Side(border_style="hair") ) + + #b) Instalações + celulasAzul = f"A{size2+3}" + cell = sheet[celulasAzul] + cell.value = f'b) Instalações' + cell.alignment = Alignment(horizontal="left",vertical="center",wrap_text=True) + cell.font = Font(name="Arial", size=12, color="000000") + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,bottom=Side(border_style="hair"),right=Side(border_style="hair") ) + + + + #Equipamentos e Material Permantente + celulasAzul = f"A{size2+4}" + cell = sheet[celulasAzul] + cell.value = f'52 - Equipamentos e Material Permanente ' + cell.alignment = Alignment(horizontal="left",vertical="center",wrap_text=True) + cell.font = Font(name="Arial", size=12, color="000000",bold=True) + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,bottom=Side(border_style="hair"),right=Side(border_style="hair") ) + + #a) Nacionais + celulasAzul = f"A{size2+5}" + cell = sheet[celulasAzul] + cell.value = f'a) Nacionais' + cell.alignment = Alignment(horizontal="left",vertical="center",wrap_text=True) + cell.font = Font(name="Arial", size=12, color="000000") + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,bottom=Side(border_style="hair"),right=Side(border_style="hair") ) + + #b) Importados + celulasAzul = f"A{size2+6}" + cell = sheet[celulasAzul] + cell.value = f'b) Importados' + cell.alignment = Alignment(horizontal="left",vertical="center",wrap_text=True) + cell.font = Font(name="Arial", size=12, color="000000") + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,bottom=Side(border_style="hair"),right=Side(border_style="hair") ) + + #Total + celulasAzul = f"A{size2+7}" + cell = sheet[celulasAzul] + cell.value = f'TOTAL' + cell.alignment = Alignment(horizontal="left",vertical="center",wrap_text=True) + cell.font = Font(name="Arial", size=12, color="000000") + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,bottom=Side(border_style="hair"),right=Side(border_style="hair") ) + + #pintar celulas de cinza da celula total + for rows in sheet.iter_rows(min_row=size2+7, max_row=size2+7, min_col=1, max_col=9): + for cell in rows: + cell.font = Font(name="Arial", size=12, color="000000",bold=True) + cell.fill = PatternFill(start_color=cinza, end_color=cinza,fill_type = "solid") + #fazerborda + for rows in sheet.iter_rows(min_row=9, max_row=size2+7, min_col=1, max_col=9): + for cell in rows: + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") + ,right =Side(border_style="hair") ,bottom=Side(border_style="hair") ) + + + #bordasNegrito + for rows in sheet.iter_rows(min_row=1, max_row=size2 + 7, min_col=1, max_col=10): + for cell in rows: + #primeira coluna preta + if cell.column == 1 and cell.row > 8: + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") + ,right =Side(border_style="medium") ,bottom=Side(border_style="hair") ) + + #segunda coluna preta + if cell.column == 6 and cell.row > 8: + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="medium") + ,right =Side(border_style="hair") ,bottom=Side(border_style="hair") ) + #linha preta do top + if cell.row == 8: + cell.border = Border(bottom=Side(border_style="medium") ) + #linha preta da celula 11 + if cell.row == 11 and cell.column > 1: + cell.border = Border(top=Side(border_style="medium") ,left = Side(border_style="hair") + ,right =Side(border_style="hair") ,bottom=Side(border_style="hair") ) + + if cell.row == 11 and cell.column == 1: + cell.border = Border(top=Side(border_style="medium") ,left = Side(border_style="hair") + ,right =Side(border_style="medium") ,bottom=Side(border_style="hair") ) + + if cell.row == 11 and cell.column == 5: + cell.border = Border(top=Side(border_style="medium") ,left = Side(border_style="hair") + ,right =Side(border_style="medium") ,bottom=Side(border_style="hair") ) + #linha preta desepsas de capital + if cell.row == size2 and cell.column > 1: + cell.border = Border(top=Side(border_style="medium") ,left = Side(border_style="hair") + ,right =Side(border_style="hair") ,bottom=Side(border_style="hair") ) + + if cell.row == size2 and cell.column == 1: + cell.border = Border(top=Side(border_style="medium") ,left = Side(border_style="hair") + ,right =Side(border_style="medium") ,bottom=Side(border_style="hair") ) + + if cell.row == size2 and cell.column == 5: + cell.border = Border(top=Side(border_style="medium") ,left = Side(border_style="hair") + ,right =Side(border_style="medium") ,bottom=Side(border_style="hair") ) + #linha double total + + if cell.row == size2+7 and cell.column > 1 : + cell.border = Border(top=Side(border_style="double") ,left = Side(border_style="hair") + ,right =Side(border_style="hair") ,bottom=Side(border_style="medium") ) + if cell.row == size2+7 and cell.column == 1 : + cell.border = Border(top=Side(border_style="double") ,left = Side(border_style="hair") + ,right =Side(border_style="medium") ,bottom=Side(border_style="medium") ) + if cell.row == size2+7 and cell.column == 5 : + cell.border = Border(top=Side(border_style="double") ,left = Side(border_style="hair") + ,right =Side(border_style="medium") ,bottom=Side(border_style="medium") ) + + if cell.column == 10: + cell.border = Border(left = Side(border_style="medium") ) + + # + for rows in sheet.iter_rows(min_row=9, max_row=size2 + 7, min_col=1, max_col=10): + for cell in rows: + if cell.column == 10: + cell.border = Border(left =Side(border_style="medium") ) + + for rows in sheet.iter_rows(min_row=1, max_row=8, min_col=1, max_col=10): + for cell in rows: + if cell.column == 10: + cell.border = Border(left =Side(border_style="thin",color='9e9e9e') ) + + + + #mascaramoneytodatabela + for rows in sheet.iter_rows(min_row=1, max_row=size2+7, min_col=1, max_col=9): + for cell in rows: + cell.number_format = 'R$ #,##0.00' + + + #somadespesas correntes ESTILORELATORIO + for col_index in range(2, 10): + for row in sheet.iter_rows(min_row=11 ,max_row=size2, min_col=col_index, max_col=col_index): + column_letter = get_column_letter(col_index) + cell = sheet[f'{column_letter}{11}'] + cell.value = f"=SUM({column_letter}{12}:{column_letter}{size2-1})" + cell.font = Font(name="Arial", size=10, color="000000",bold = True) + + #soma despesas de capital ESTILORELATORIO + for col_index in range(2, 10): + for row in sheet.iter_rows(min_row=size2 ,max_row=size2+7, min_col=col_index, max_col=col_index): + column_letter = get_column_letter(col_index) + cell = sheet[f'{column_letter}{size2}'] + cell.value = f"=SUM({column_letter}{size2+1}:{column_letter}{size2+6})" + cell.font = Font(name="Arial", size=10, color="000000",bold = True) + + #soma TOTAL ESTILORELATORIO + for col_index in range(2, 10): + for row in sheet.iter_rows(min_row=size2 ,max_row=size2+7, min_col=col_index, max_col=col_index): + column_letter = get_column_letter(col_index) + cell = sheet[f'{column_letter}{size2+7}'] + cell.value = f"=SUM({column_letter}{11},{column_letter}{size2})" + cell.font = Font(name="Arial", size=10, color="000000",bold = True) + + + #formulas total coluna E + + for rows in sheet.iter_rows(min_row=12 ,max_row=size2-1 ,min_col=5, max_col=5): + for cell in rows: + cell.value = f"=SUM(B{cell.row}:D{cell.row})" + cell.font = Font(name="Arial", size=10, color="000000") + + for rows in sheet.iter_rows(min_row=size2+1,max_row=size2+6 ,min_col=5, max_col=5): + for cell in rows: + cell.value = f"=SUM(B{cell.row}:D{cell.row})" + cell.font = Font(name="Arial", size=10, color="000000") + + #formulas total coluna i + + for rows in sheet.iter_rows(min_row=12 ,max_row=size2-1 ,min_col=9, max_col=9): + for cell in rows: + cell.value = f"=SUM(F{cell.row}:H{cell.row})" + cell.font = Font(name="Arial", size=10, color="000000") + + for rows in sheet.iter_rows(min_row=size2+1,max_row=size2+6 ,min_col=9, max_col=9): + for cell in rows: + cell.value = f"=SUM(F{cell.row}:H{cell.row})" + cell.font = Font(name="Arial", size=10, color="000000") + + + + #aumentar o tamanho da celula total + sheet.row_dimensions[size+8].height = 33 + #brasilia + brasilia_row = size2 + 9 + brasilia_formula = f"='DEMOSTR. RECEITA E DESPESA A.2'!A{stringTamanho}" + brasilia_merge_cells = f'A{brasilia_row}:I{brasilia_row}' + sheet.merge_cells(brasilia_merge_cells) + top_left_brasilia_cell_formula = f'A{brasilia_row}' + top_left_brasilia_cell = sheet[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 = size2 + 10 + diretor_cargo_row = size2 + 11 + diretor_cpf_row = size2 + 12 + + diretor_nome_formula = f"='DEMOSTR. RECEITA E DESPESA A.2'!A{stringTamanho+3}" + diretor_cargo_formula = f"='DEMOSTR. RECEITA E DESPESA A.2'!A{stringTamanho+4}" + diretor_cpf_formula = f"='DEMOSTR. RECEITA E DESPESA A.2'!A{stringTamanho+5}" + 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}' + sheet.merge_cells(diretor_merge_cells) + sheet.merge_cells(diretor_cargo_merge_cells) + sheet.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 = sheet[top_left_diretor_cell_formula] + top_left_diretor_cell_cargo_formula = sheet[top_left_diretor_cell_cargo_formula] + top_left_diretor_cell_cpf_formula = sheet[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 = size2 + 10 + coordenadora_cargo_row = size2 + 11 + coordenadora_cpf_row = size2 + 12 + coordenadora_nome_formula = f"='DEMOSTR. RECEITA E DESPESA A.2'!C{stringTamanho+3}" + coordenadora_cargo_formula = f"='DEMOSTR. RECEITA E DESPESA A.2'!C{stringTamanho+4}" + coordenadora_cpf_formula = f"='DEMOSTR. RECEITA E DESPESA A.2'!C{stringTamanho+5}" + coordenadora_merge_cells = f'F{coordenadora_row}:I{coordenadora_row}' + coordenadora_cargo_merge_cells = f'F{coordenadora_cargo_row}:I{coordenadora_cargo_row}' + coordenadora_cpf_merge_cells = f'F{coordenadora_cpf_row}:I{coordenadora_cpf_row}' + sheet.merge_cells(coordenadora_merge_cells) + sheet.merge_cells(coordenadora_cargo_merge_cells) + sheet.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 = sheet[top_left_coordenadora_cell_formula] + top_left_coordenadora_cell_cargo_formula = sheet[top_left_coordenadora_cell_cargo_formula] + top_left_coordenadora_cell_cpf_formula = sheet[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(name="Arial", size=12, color="000000",bold = True) + top_left_coordenadora_cell_cargo_formula.alignment = Alignment(horizontal="center",vertical="center") + top_left_coordenadora_cell_cargo_formula.font = Font(name="Arial", size=12, color="000000") + top_left_coordenadora_cell_cpf_formula.alignment = Alignment(horizontal="center",vertical="center") + top_left_coordenadora_cell_cpf_formula.font= Font(name="Arial", size=12, color="000000") + + #adicionar borda fo nim do arquivo + for row in sheet.iter_rows(min_row=size2 + 8, max_row=coordenadora_cpf_row,min_col=9,max_col=9): + for cell in row: + cell.border = Border(top=Side(border_style="none") ,left = Side(border_style="none") ,right =Side(border_style="thin",color='9e9e9e') ) + + #adicionar borda fo nim do arquivo + for row in sheet.iter_rows(min_row=coordenadora_cpf_row+1, max_row=coordenadora_cpf_row+1,min_col=1,max_col=9): + for cell in row: + if cell.column == 9: + cell.border = Border(top=Side(border_style="none") ,left = Side(border_style="none") ,right =Side(border_style="thin",color='9e9e9e') ,bottom=Side(border_style="thin",color='9e9e9e') ) + else: + cell.border = Border(top=Side(border_style="none") ,left = Side(border_style="none") ,right =Side(border_style="none") ,bottom=Side(border_style="thin",color='9e9e9e') ) + + + + + + + + workbook.save(tabela) + workbook.close() + + #retorna a localizaçãao do despesas de capital + return size2 + +def estiloDEMOSTRRECEITEDESPESAA2(tabela,tamanho): + '''Estilo da Pagina do Relatorio Receita e Despesa. + + Argumentos: + tabela : recebe o arquivo correspondente a tabela Fub extensão xlsx. Esse arquivo ja foi iniciado e passou pela preencher fub mas ainda esta sem o estilo que sera aplicado nessa função. + + tamanho : refere-se ao tamanho do dataframe que recebe + ''' + + + caminho = pegar_caminho(tabela) + #Plan = planilha + # carrega a planilha de acordo com o caminho + workbook = openpyxl.load_workbook(caminho) + sheet = workbook['DEMOSTR. RECEITA E DESPESA A.2'] + size = tamanho + 13 + #tamanaho contando despes decapital, obras e instalaçoes, e euipamentos + size2 = size + 8 + cinza = "d9d9d9" + azul = 'ccffff' + + #remover as gridlines + sheet.sheet_view.showGridLines = False + + + #cabecario relação de pagamentos - outro servicoes de terceiros + sheet.merge_cells('A1:E1') + sheet['A1'] = f'ANEXO 2' + sheet['A1'].font = Font(name="Arial", size=12, color="000000",bold=True) + sheet['A1'].alignment = Alignment(horizontal="center",vertical="center") + + + sheet.merge_cells('A2:E2') + sheet['A2'] = f'DEMONSTRATIVO DE RECEITAS E DESPESAS' + sheet['A2'].font = Font(name="Arial", size=12, color="000000",bold=True) + sheet['A2'].alignment = Alignment(horizontal="center",vertical="center") + + + # sheet.merge_cells('C3:E3') + # sheet['A3'] = "" + # sheet['A3'].font = Font(name="Arial", size=12, color="000000") + # sheet['A3'].alignment = Alignment(horizontal="left",vertical="center",wrap_text=True) + + # sheet.merge_cells('C4:E4') + # sheet['A4'] = "" + # sheet['A4'].font = Font(name="Arial", size=12, color="000000") + # sheet['A4'].alignment = Alignment(horizontal="left",vertical="center") + + # sheet.merge_cells('C5:E5') + # sheet['A5'] = "" + # sheet['A5'].font = Font(name="Arial", size=12, color="000000") + # sheet['A5'].alignment = Alignment(horizontal="left",vertical="center") + + # sheet.merge_cells('C6:E6') + # sheet['A6'] = "" + # sheet['A6'].font = Font(name="Arial", size=12, color="000000") + # sheet['A6'].alignment = Alignment(horizontal="left",vertical="center") + + # sheet.merge_cells('C7:E7') + # sheet['A6'] = "" + # sheet['A6'].font = Font(name="Arial", size=12, color="000000") + # sheet['A6'].alignment = Alignment(horizontal="left",vertical="center") + + # sheet.merge_cells('C8:E8') + # sheet['A6'] = "" + # sheet['A6'].font = Font(name="Arial", size=12, color="000000") + # sheet['A6'].alignment = Alignment(horizontal="left",vertical="center") + + # sheet.merge_cells('C9:E9') + # sheet['A6'] = "" + # sheet['A6'].font = Font(name="Arial", size=12, color="000000") + # sheet['A6'].alignment = Alignment(horizontal="left",vertical="center") + + + # sheet.merge_cells('A10:E10') + # sheet['A10'] = '' + # sheet['A10'].font = Font(name="Arial", size=12, color="000000",bold=True) + # sheet['A10'].alignment = Alignment(horizontal="center",vertical="center") + + + #configurando alturas da tabela demonstrativo.receita despesa + for i in range(1,10): + sheet.row_dimensions[i].height = 20 + if i ==10: + sheet.row_dimensions[i].height = 2 + + + sheet.row_dimensions[1].height = 25 + sheet.row_dimensions[3].height = 35 + sheet.row_dimensions[2].height = 25 + sheet.row_dimensions[11].height = 30 + sheet.row_dimensions[12].height = 30 + sheet.column_dimensions['a'].width = 55 + sheet.column_dimensions['b'].width = 25 + sheet.column_dimensions['c'].width = 30 + sheet.column_dimensions['d'].width = 30 + sheet.column_dimensions['e'].width = 30 + + #mascara real em toda a tabela + for rows in sheet.iter_rows(min_row=13, max_row=size2 +13, min_col=2, max_col=5): + for cell in rows: + cell.number_format = 'R$ #,##0.00' + + + + + #merge das barras azuis da 11 que leva Valor Realizado e Natureza das despesa + barraMerge1 = f"B{11}:D{11}" + sheet.merge_cells(barraMerge1) + #borda Valor realizado + for row in sheet[barraMerge1]: + for cell in row: + cell.border = Border(top=Side(border_style="double"), left=Side(border_style="hair"), bottom=Side(border_style="hair"), right=Side(border_style="double")) + #Valor Realizado + celulasAzul = f"B{11}" + cell = sheet[celulasAzul] + cell.value = f'Valor Realizado' + cell.fill = PatternFill(start_color=azul, end_color=azul, + fill_type = "solid") + cell.alignment = Alignment(horizontal="left",vertical="center",wrap_text=True) + cell.font = Font(name="Arial", size=12, color="000000",bold=True) + cell.border = Border(top=Side(border_style="double") ,left = Side(border_style="hair") ,bottom=Side(border_style="hair"),right=Side(border_style="double") ) + + + #A.Natureza das despesas + sheet['A11'] = 'NATUREZA DAS DESPESAS' + sheet['A11'].font = Font(name="Arial", size=12, color="000000",bold=True) + sheet['A11'].alignment = Alignment(horizontal="left",vertical="center") + sheet['A11'].fill = PatternFill(start_color=azul, end_color=azul,fill_type = "solid") + sheet['A11'].border = Border(top=Side(border_style="double") ,left = Side(border_style="hair") ,right =Side(border_style="hair") ,bottom=Side(border_style="hair") ) + + #despesas correntes + sheet['A13'] = '3.DESPESAS CORRENTES' + sheet['A13'].font = Font(name="Arial", size=12, color="000000",bold=True) + sheet['A13'].alignment = Alignment(horizontal="left",vertical="center") + sheet['A13'].border = Border(top=Side(border_style="double") ,left = Side(border_style="hair") ,right =Side(border_style="hair") ,bottom=Side(border_style="hair") ) + + for row in sheet.iter_rows(min_row=13,max_row=13,min_col=1,max_col=5): + for cell in row : + cell.font = Font(name='Arial',size=12, color="000000",bold=True) + +#Grupo/elemenos de despesas/Ate o periodo Anterior/No periodo deteste balancete total acumaladao, previsão na relação de itens + values = ["Grupos/Elementos de Despesas","Até o período Anterior","No Período deste Balancete",'Total Acumulado',"Previsão na Relação de Itens"] + coluna = 1 + for a,b in enumerate(values): + sheet.cell(row=12, column=coluna, value=b) + coluna = coluna + 1 + + for row in sheet.iter_rows(min_row=12, max_row=12,min_col=1,max_col=5): + for cell in row: + if cell.column == 5 : + cell.fill = PatternFill(start_color=azul, end_color=azul,fill_type = "solid") + cell.font = Font(name='Arial',bold=True,color='000000') + + else: + cell.fill = PatternFill(start_color=azul, end_color=azul,fill_type = "solid") + + + + for row in sheet.iter_rows(min_row=12, max_row=size2,min_col=1,max_col=5): + for cell in row: + if cell.column == 5 and cell.row == 12: + cell.border = Border(top=Side(border_style="double") ,left = Side(border_style="hair") ,right =Side(border_style="double") ,bottom=Side(border_style="hair") ) + elif cell.column == 5: + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,right =Side(border_style="double") ,bottom=Side(border_style="hair") ) + elif cell.row == size2: + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,right =Side(border_style="hair") ,bottom=Side(border_style="double") ) + + else: + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,right =Side(border_style="hair") ,bottom=Side(border_style="hair") ) + + + for row in sheet.iter_rows(min_row=size2, max_row=size2,min_col=5,max_col=5): + for cell in row: + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,right =Side(border_style="double") ,bottom=Side(border_style="double") ) + + + #4.Despesas de Capital + celulasAzul = f"A{size+1}" + cell = sheet[celulasAzul] + cell.value = f'4.DESPESAS DE CAPITAL' + cell.alignment = Alignment(horizontal="left",vertical="center",wrap_text=True) + cell.font = Font(name="Arial", size=12, color="000000",bold=True) + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,bottom=Side(border_style="hair"),right=Side(border_style="hair") ) + #deiarlinha de desoesas de capital em negrito + for rows in sheet.iter_rows(min_row=size+1, max_row=size+1, min_col=1, max_col=6): + for cell in rows: + cell.font = Font(name="Arial", size=12, color="000000",bold=True) + + + + #51- Obras e Instalações + celulasAzul = f"A{size+2}" + cell = sheet[celulasAzul] + cell.value = f'51 - Obras e Instalações' + cell.alignment = Alignment(horizontal="left",vertical="center",wrap_text=True) + cell.font = Font(name="Arial", size=12, color="000000",bold=True) + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,bottom=Side(border_style="hair"),right=Side(border_style="hair") ) + #deiarlinha de obras e instalções em negrito + for rows in sheet.iter_rows(min_row=size+2, max_row=size+2, min_col=1, max_col=6): + for cell in rows: + cell.font = Font(name="Arial", size=12, color="000000",bold=True) + + #a) Obras + celulasAzul = f"A{size+3}" + cell = sheet[celulasAzul] + cell.value = f'a) Obras' + cell.alignment = Alignment(horizontal="left",vertical="center",wrap_text=True) + cell.font = Font(name="Arial", size=12, color="000000") + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,bottom=Side(border_style="hair"),right=Side(border_style="hair") ) + + #b) Instalações + celulasAzul = f"A{size+4}" + cell = sheet[celulasAzul] + cell.value = f'b) Instalações' + cell.alignment = Alignment(horizontal="left",vertical="center",wrap_text=True) + cell.font = Font(name="Arial", size=12, color="000000") + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,bottom=Side(border_style="hair"),right=Side(border_style="hair") ) + + + #Equipamentos e Material Permantente + celulasAzul = f"A{size+5}" + cell = sheet[celulasAzul] + cell.value = f'52 - Equipamentos e Material Permanente ' + cell.alignment = Alignment(horizontal="left",vertical="center",wrap_text=True) + cell.font = Font(name="Arial", size=12, color="000000",bold=True) + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,bottom=Side(border_style="hair"),right=Side(border_style="hair") ) + + + #deiarlinha do equipamento e materialpermaneten em negrito + for rows in sheet.iter_rows(min_row=size+5, max_row=size+5, min_col=1, max_col=6): + for cell in rows: + cell.font = Font(name="Arial", size=12, color="000000",bold=True) + + + + + #a) Nacionais + celulasAzul = f"A{size+6}" + cell = sheet[celulasAzul] + cell.value = f'a) Nacionais' + cell.alignment = Alignment(horizontal="left",vertical="center",wrap_text=True) + cell.font = Font(name="Arial", size=12, color="000000") + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,bottom=Side(border_style="hair"),right=Side(border_style="hair") ) + + #b) Importados + celulasAzul = f"A{size+7}" + cell = sheet[celulasAzul] + cell.value = f'b) Importados' + cell.alignment = Alignment(horizontal="left",vertical="center",wrap_text=True) + cell.font = Font(name="Arial", size=12, color="000000") + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,bottom=Side(border_style="hair"),right=Side(border_style="hair") ) + + + + + #Total das Receitas (B1+B2) + celulasAzul = f"A{size2+2}" + cell = sheet[celulasAzul] + cell.value = f"B. TOTAL DAS RECEITAS (B1+B2)" + cell.fill = PatternFill(start_color=azul, end_color=azul,fill_type = "solid") + cell.alignment = Alignment(horizontal="left",vertical="center",wrap_text=True) + cell.font = Font(name="Arial", size=12, color="000000",bold=True) + cell.border = Border(top=Side(border_style="double") ,left = Side(border_style="hair") ,bottom=Side(border_style="hair"),right=Side(border_style="hair") ) + #deiarlinha de total das reeitas em negrito + for rows in sheet.iter_rows(min_row=size2+2, max_row=size2+2, min_col=1, max_col=6): + for cell in rows: + cell.font = Font(name="Arial", size=12, color="000000",bold=True) + + #Barra azull total das receitas + + for row in sheet.iter_rows(min_row=size2+2, max_row=size2+2,min_col=2,max_col=4): + for cell in row: + if cell.column == 4 : + cell.fill = PatternFill(start_color=azul, end_color=azul,fill_type = "solid") + cell.font = Font(name='Arial',bold=True,color='000000') + cell.border = Border(top=Side(border_style="double") ,left = Side(border_style="hair") ,bottom=Side(border_style="hair"),right=Side(border_style="double") ) + + else: + cell.fill = PatternFill(start_color=azul, end_color=azul,fill_type = "solid") + cell.font = Font(name='Arial',bold=True,color='000000') + cell.border = Border(top=Side(border_style="double") ,left = Side(border_style="hair") ,bottom=Side(border_style="hair"),right=Side(border_style="hair") ) + + #bordas inferiores + for row in sheet.iter_rows(min_row=size2+3, max_row=size2+4,min_col=2,max_col=4): + for cell in row: + if cell.column == 4 and cell.row == size2+3: + + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,bottom=Side(border_style="hair"),right=Side(border_style="double") ) + elif cell.column == 4 and cell.row == size2+4: + + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,bottom=Side(border_style="double"),right=Side(border_style="double") ) + elif cell.column != 4 and cell.row == size2+4: + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,bottom=Side(border_style="double"),right=Side(border_style="hair") ) + + else: + + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,bottom=Side(border_style="hair"),right=Side(border_style="hair") ) + + + + + celulasAzul = f"A{size2+3}" + cell = sheet[celulasAzul] + cell.value = f"B.1 Recursos Recebidos" + cell.alignment = Alignment(horizontal="left",vertical="center",wrap_text=True) + cell.font = Font(name="Arial", size=12, color="000000",bold=True) + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,bottom=Side(border_style="hair"),right=Side(border_style="hair") ) + + celulasAzul = f"A{size2+4}" + cell = sheet[celulasAzul] + cell.value = f"B.2 Rendimento de Aplicações Financeiras" + cell.alignment = Alignment(horizontal="left",vertical="center",wrap_text=True) + cell.font = Font(name="Arial", size=12, color="000000",bold=True) + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,bottom=Side(border_style="double"),right=Side(border_style="hair") ) + + #saldo + celulasAzul = f"A{size2+6}" + cell = sheet[celulasAzul] + cell.value = f"Saldo" + cell.fill = PatternFill(start_color=azul, end_color=azul,fill_type = "solid") + cell.alignment = Alignment(horizontal="left",vertical="center",wrap_text=True) + cell.font = Font(name="Arial", size=12, color="000000",bold=True) + cell.border = Border(top=Side(border_style="double") ,left = Side(border_style="double") ,bottom=Side(border_style="double"),right=Side(border_style="hair") ) + #deiar negrito o saldo + for rows in sheet.iter_rows(min_row=size2+6, max_row=size2+6, min_col=1, max_col=6): + for cell in rows: + cell.font = Font(name="Arial", size=12, color="000000",bold=True) + + + #saldos disponivel para o perido seguinte + celulasAzul = f"A{size2+8}" + cell = sheet[celulasAzul] + cell.value = f"D. Saldo Disponível para o Período Seguinte" + cell.fill = PatternFill(start_color=azul, end_color=azul,fill_type = "solid") + cell.alignment = Alignment(horizontal="left",vertical="center",wrap_text=True) + cell.font = Font(name="Arial", size=12, color="000000",bold=True) + cell.border = Border(top=Side(border_style="double") ,left = Side(border_style="hair") ,bottom=Side(border_style="hair"),right=Side(border_style="hair") ) + + #Negrito no numero da frente + celulasAzul = f"B{size2+8}" + cell = sheet[celulasAzul] + cell.fill = PatternFill(start_color=azul, end_color=azul,fill_type = "solid") + cell.alignment = Alignment(horizontal="left",vertical="center",wrap_text=True) + cell.font = Font(name="Arial", size=12, color="000000",bold=True) + cell.border = Border(top=Side(border_style="double") ,left = Side(border_style="hair") ,bottom=Side(border_style="hair"),right=Side(border_style="double") ) + cell.number_format = 'R$ #,##0.00' + + #d1 borda + celulasAzul = f"B{size2+9}" + cell = sheet[celulasAzul] + cell.alignment = Alignment(horizontal="left",vertical="center",wrap_text=True) + cell.font = Font(name="Arial", size=12, color="000000",bold=True) + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,bottom=Side(border_style="hair"),right=Side(border_style="double") ) + cell.number_format = 'R$ #,##0.00' + + #d2 borda + celulasAzul = f"B{size2+10}" + cell = sheet[celulasAzul] + cell.alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + cell.font = Font(name="Arial", size=12, color="000000",bold=True) + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,bottom=Side(border_style="hair"),right=Side(border_style="double") ) + cell.number_format = 'R$ #,##0.00' + + #d3 borda + celulasAzul = f"B{size2+11}" + cell = sheet[celulasAzul] + cell.alignment = Alignment(horizontal="left",vertical="center",wrap_text=True) + cell.font = Font(name="Arial", size=12, color="000000",bold=True) + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,bottom=Side(border_style="double"),right=Side(border_style="double") ) + cell.number_format = 'R$ #,##0.00' + + #Barra azul saldo + + for row in sheet.iter_rows(min_row=size2+6, max_row=size2+6,min_col=2,max_col=4): + for cell in row: + if cell.column == 3: + cell.fill = PatternFill(start_color=cinza, end_color=cinza,fill_type = "solid") + cell.border = Border(top=Side(border_style="double") ,left = Side(border_style="hair") ,bottom=Side(border_style="double"),right=Side(border_style="hair") ) + + elif cell.column == 4 : + cell.border = Border(top=Side(border_style="double") ,left = Side(border_style="hair") ,bottom=Side(border_style="double"),right=Side(border_style="double") ) + else: + cell.fill = PatternFill(start_color=azul, end_color=azul,fill_type = "solid") + cell.border = Border(top=Side(border_style="double") ,left = Side(border_style="hair") ,bottom=Side(border_style="double"),right=Side(border_style="hair") ) + + + + #saldo em conta corrente e aplicação financeira + celulasAzul = f"A{size2+9}" + cell = sheet[celulasAzul] + cell.value = f"D.1. Saldo em Conta corrente e Aplicação Financeira" + cell.alignment = Alignment(horizontal="left",vertical="center",wrap_text=True) + cell.font = Font(name="Arial", size=12, color="000000",bold=True) + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,bottom=Side(border_style="hair"),right=Side(border_style="hair") ) + #restituições não creditadas + celulasAzul = f"A{size2+10}" + cell = sheet[celulasAzul] + cell.value = f"D.2. Restituições não Creditadas" + cell.alignment = Alignment(horizontal="left",vertical="center",wrap_text=True) + cell.font = Font(name="Arial", size=12, color="000000",bold=True) + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,bottom=Side(border_style="hair"),right=Side(border_style="hair") ) + #cheques emitido e não descontados + celulasAzul = f"A{size2+11}" + cell = sheet[celulasAzul] + cell.value = f"D.3. Cheques Emitidos e não Descontados" + cell.alignment = Alignment(horizontal="left",vertical="center",wrap_text=True) + cell.font = Font(name="Arial", size=12, color="000000",bold=True) + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,bottom=Side(border_style="double"),right=Side(border_style="hair") ) + + #saldos devolvido á Finep + celulasAzul = f"A{size2+13}" + cell = sheet[celulasAzul] + cell.value = f"E. Saldo Devolvido à FINEP" + cell.fill = PatternFill(start_color=azul, end_color=azul, fill_type = "solid") + cell.alignment = Alignment(horizontal="left",vertical="center",wrap_text=True) + cell.font = Font(name="Arial", size=12, color="000000",bold=True) + cell.border = Border(top=Side(border_style="double") ,left = Side(border_style="double") ,bottom=Side(border_style="double"),right=Side(border_style="hair") ) + + + #Negrito no numero da frente + celulasAzul = f"B{size2+13}" + cell = sheet[celulasAzul] + cell.fill = PatternFill(start_color=azul, end_color=azul,fill_type = "solid") + cell.alignment = Alignment(horizontal="left",vertical="center",wrap_text=True) + cell.font = Font(name="Arial", size=12, color="000000",bold=True) + cell.border = Border(top=Side(border_style="double") ,left = Side(border_style="hair") ,bottom=Side(border_style="double"),right=Side(border_style="double") ) + cell.number_format = 'R$ #,##0.00' + + + + + #somatorios + + #somatorio desepsas correntes + + for col_index in range(2, 6): + for row in sheet.iter_rows(min_row=13, max_row=13, min_col=col_index, max_col=col_index): + column_letter = get_column_letter(col_index) + cell = sheet[f'{column_letter}13'] + cell.value = f"=SUM({column_letter}14:{column_letter}{size})" + + #somatorio linha final + for col_index in range(2, 6): + for row in sheet.iter_rows(min_row=size+8, max_row=size+8, min_col=col_index, max_col=col_index): + column_letter = get_column_letter(col_index) + cell = sheet[f'{column_letter}{size+8}'] + cell.value = f"={column_letter}13+{column_letter}{size+1}" + + #Somatorio total das receitas(B1+B2) + for col_index in range(2, 5): + for row in sheet.iter_rows(min_row=size2+2, max_row=size2+2, min_col=col_index, max_col=col_index): + column_letter = get_column_letter(col_index) + cell = sheet[f'{column_letter}{size2+2}'] + cell.value = f"=SUM({column_letter}{size2+3}:{column_letter}{size2+4})" + + #somatorio saldo disponivel para o periodo seguinte + formula = f"=SUM(B{size2+9}:B{size2+11})" + celula = f'B{size2+8}' + sheet[celula] = formula + + + #total acumulado somatorio + #Adicionar Soma na coluna E + for rows in sheet.iter_rows(min_row=14, max_row=size+7, min_col=4, max_col=4): + for cell in rows: + cell.value = f"=SUM(B{cell.row}:C{cell.row})" + + + #FORMULA DESPESAS DE CAPITAL + sheet[f'B{size+1}'] = f"=SUM(B{size+2}:B{size+7})" + sheet[f'B{size+1}'].font = Font(name="Arial", size=12, color="000000",bold=True) + sheet[f'B{size+1}'].alignment = Alignment(horizontal="right",vertical="center") + + #FORMULA DESPESAS DE CAPITAL + sheet[f'C{size+1}'] = f"=SUM(C{size+2}:C{size+7})" + sheet[f'C{size+1}'].font = Font(name="Arial", size=12, color="000000",bold=True) + sheet[f'C{size+1}'].alignment = Alignment(horizontal="right",vertical="center") + + #FORMULA DESPESAS DE CAPITAL + sheet[f'E{size+1}'] = f"=SUM(E{size+2}:E{size+7})" + sheet[f'E{size+1}'].font = Font(name="Arial", size=12, color="000000",bold=True) + sheet[f'E{size+1}'].alignment = Alignment(horizontal="right",vertical="center") + + + + + #brasilia + brasilia_row = size2 + 16 + brasilia_formula = f"Brasília, 28 de agosto de 2022." + brasilia_merge_cells = f"A{brasilia_row}:E{brasilia_row}" + sheet.merge_cells(brasilia_merge_cells) + top_left_brasilia_cell_formula = f'A{brasilia_row}' + top_left_brasilia_cell = sheet[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 = size2 + 19 + diretor_cargo_row = size2 + 20 + diretor_cpf_row = size2 + 21 + diretor_nome_formula = f"Daniel Monteiro Rosa" + diretor_cargo_formula = f"Diretor-Financeiro" + diretor_cpf_formula = f"450.720.272-87" + 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}' + sheet.merge_cells(diretor_merge_cells) + sheet.merge_cells(diretor_cargo_merge_cells) + sheet.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 = sheet[top_left_diretor_cell_formula] + top_left_diretor_cell_cargo_formula = sheet[top_left_diretor_cell_cargo_formula] + top_left_diretor_cell_cpf_formula = sheet[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(name="Arial", size=12,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 = size2 + 19 + coordenadora_cargo_row = size2 + 20 + coordenadora_cpf_row = size2 + 21 + coordenadora_nome_formula = f"teste" + coordenadora_cargo_formula = f"Coordenador(a)" + coordenadora_cpf_formula = f"teste" + coordenadora_merge_cells = f'C{coordenadora_row}:E{coordenadora_row}' + coordenadora_cargo_merge_cells = f'C{coordenadora_cargo_row}:E{coordenadora_cargo_row}' + coordenadora_cpf_merge_cells = f'C{coordenadora_cpf_row}:E{coordenadora_cpf_row}' + sheet.merge_cells(coordenadora_merge_cells) + sheet.merge_cells(coordenadora_cargo_merge_cells) + sheet.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 = sheet[top_left_coordenadora_cell_formula] + top_left_coordenadora_cell_cargo_formula = sheet[top_left_coordenadora_cell_cargo_formula] + top_left_coordenadora_cell_cpf_formula = sheet[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(name="Arial", size=12, color="000000",bold = True) + top_left_coordenadora_cell_cargo_formula.alignment = Alignment(horizontal="center",vertical="center") + top_left_coordenadora_cell_cargo_formula.font = Font(name="Arial", size=12, color="000000") + top_left_coordenadora_cell_cpf_formula.alignment = Alignment(horizontal="center",vertical="center") + top_left_coordenadora_cell_cpf_formula.font= Font(name="Arial", size=12, color="000000") + + #E melhor fazertodas as bordas no fim pra ter certeza que vao ser aplicadas + + + #borda cabeçario + for row in sheet.iter_rows(min_row=1, max_row=11,min_col=5,max_col=5): + for cell in row: + cell.border = Border(top=Side(border_style="none") ,right = Side(border_style="thin",color='9e9e9e') ,left =Side(border_style="none") ,bottom=Side(border_style="none") ) + + #borda fim pagina + for row in sheet.iter_rows(min_row=size2+1, max_row=coordenadora_cpf_row+1,min_col=5,max_col=5): + for cell in row: + cell.border = Border(top=Side(border_style="none") ,right = Side(border_style="thin",color='9e9e9e') ,left =Side(border_style="none") ,bottom=Side(border_style="none") ) + + + + for row in sheet.iter_rows(min_row=coordenadora_cpf_row+1, max_row=coordenadora_cpf_row+1,min_col=1,max_col=5): + for cell in row: + if cell.column == 5: + cell.border = Border(top=Side(border_style="none") ,left = Side(border_style="none") ,right =Side(border_style="thin",color='9e9e9e') ,bottom=Side(border_style="thin",color='9e9e9e') ) + else: + cell.border = Border(top=Side(border_style="none") ,left = Side(border_style="none") ,right =Side(border_style="none") ,bottom=Side(border_style="thin",color='9e9e9e') ) + + + workbook.save(tabela) + workbook.close() + + + #retorna tamanho de brasilia + return size2 + 16 + +def estiloG(tabela,tamanho,nomeVariavel,nomeTabela,stringTamanho,tamanhoestorno): + '''Esse estilo e considerado geral por que todas as tabelas que compõe utilizam das mesma colunas. + + Argumentos: + tabela: recebe o arquivo correspondente a tabela Fub extensão xlsx. Esse arquivo ja foi iniciado e passou pela preencher fub mas ainda esta sem o estilo que sera aplicado nessa função. + tamanho: e o tamanho total de linhas que irao ser geradas dinamicamente correspondente as entradas do respectivo projeto. o valor varia dentre o tamanho das rubricas + + nomeVariavel: variável utilizada para criar o nomes das variaveis dinamicamente para não haver sobreposição de estilos com o mesmo nome. Esses estilos ocorrem nesses codigos: + 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"'.... + nomeTabela: variável utilizada para a criação do nome da tabela.Ela deriva das rubricas que são colocadas no input quando essa função e chamada. + stringTamanho: refere-se aonde esta localizado a string brasilia na pagina Receita e despesa para a referencias das formulas. + + ''' + if tamanho == 0: + tamanho = 1 + + + nomeSheet=nomeVariavel + random_number = random.randint(1, 10000) + nomeVariavel = f'{nomeVariavel}{random_number}' + caminho = pegar_caminho(tabela) + workbook = openpyxl.load_workbook(caminho) + worksheet = workbook[nomeTabela] + size = tamanho + 16 + cinza = "d9d9d9" + cinza_escuro = "bfbfbf" + azul = "336394" + azul_claro = 'ccffff' + + # 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 = 45 + worksheet.column_dimensions['b'].width = 35 + worksheet.column_dimensions['c'].width = 35 + worksheet.column_dimensions['d'].width = 45#descrição + worksheet.column_dimensions['e'].width = 45 #n do recibo ou qeuivalente + worksheet.column_dimensions['f'].width = 35 #data de emissão + worksheet.column_dimensions['g'].width = 35 #data de emissão + worksheet.column_dimensions['h'].width = 35 #data de emissão + worksheet.column_dimensions['i'].width = 35 #data de emissão + worksheet.column_dimensions['j'].width = 35 #data de emissão + + + #cabecario relação de pagamentos - outro servicoes de terceiros + worksheet.merge_cells('A1:I1') + nomeTabela = nomeTabela.upper() + worksheet['A1'] = f'ANEXO 4' + worksheet['A1'].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet['A1'].alignment = Alignment(horizontal="center",vertical="center") + #RELAÇÃO DE PAGAMENTOS + worksheet.merge_cells('A2:I2') + + worksheet['A2'] = f'RELAÇÃO DE PAGAMENTOS' + worksheet['A2'].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet['A2'].alignment = Alignment(horizontal="center",vertical="center") + + #ElementosdeDespesa + + + worksheet['A11'] = f'Elemento de Despesa' + worksheet['A11'].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet['A11'].alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + + + #ElementosdeDespesa + + + worksheet['A14'] = f'DESPESAS REALIZADAS' + worksheet['A14'].font = Font(name="Arial", size=12, color="000000",bold=True,italic=True) + worksheet['A14'].alignment = Alignment(horizontal="center",vertical="center") + + + + #cabecario que recebe de referencia as celulas A da planilha DEMOSTR. RECEITA E DESPESA A.2 + + #Convênio nº: 01.14.0032.00 + worksheet['A4'] = "='DEMOSTR. RECEITA E DESPESA A.2'!A4" + worksheet['A4'].font = Font(name="Arial", size=12, color="000000") + worksheet['A4'].alignment = Alignment(horizontal="left",vertical="center") + #Convenente: + worksheet['A5'] = "='DEMOSTR. RECEITA E DESPESA A.2'!A5" + worksheet['A5'].font = Font(name="Arial", size=12, color="000000") + worksheet['A5'].alignment = Alignment(horizontal="left",vertical="center") + #Período de Execução do Convênio: + worksheet['A6'] = "='DEMOSTR. RECEITA E DESPESA A.2'!A6" + worksheet['A6'].font = Font(name="Arial", size=12, color="000000") + worksheet['A6'].alignment = Alignment(horizontal="left",vertical="center") + #Período Abrangido por este Relatório: + worksheet['A7'] = "='DEMOSTR. RECEITA E DESPESA A.2'!A7" + worksheet['A7'].font = Font(name="Arial", size=12, color="000000") + worksheet['A7'].alignment = Alignment(horizontal="left",vertical="center") + #Fonte de Recursos: + worksheet['A8'] = "='DEMOSTR. RECEITA E DESPESA A.2'!A8" + worksheet['A8'].font = Font(name="Arial", size=12, color="000000") + worksheet['A8'].alignment = Alignment(horizontal="left",vertical="center") + #Partícipe (no caso de contrapartida): + worksheet['A9'] = "='DEMOSTR. RECEITA E DESPESA A.2'!A9" + worksheet['A9'].font = Font(name="Arial", size=12, color="000000") + worksheet['A9'].alignment = Alignment(horizontal="left",vertical="center") + + + + #cabecario que recebe de referencia as celulas C da planilha DEMOSTR. RECEITA E DESPESA A.2 + + # Fundação de Empreendimentos Científicos e Tecnológicos - FINATEC + worksheet['C5'] = "='DEMOSTR. RECEITA E DESPESA A.2'!C5" + worksheet['C5'].font = Font(name="Arial", size=12, color="000000") + worksheet['C5'].alignment = Alignment(horizontal="left",vertical="center") + #de 10/02/2014 a 10/06/2023 + worksheet['C6'] = "='DEMOSTR. RECEITA E DESPESA A.2'!C6" + worksheet['C6'].font = Font(name="Arial", size=12, color="000000") + worksheet['C6'].alignment = Alignment(horizontal="left",vertical="center") + #de 10/02/2014 a 31/07/2022 + worksheet['C7'] = "='DEMOSTR. RECEITA E DESPESA A.2'!C7" + worksheet['C7'].font = Font(name="Arial", size=12, color="000000") + worksheet['C7'].alignment = Alignment(horizontal="left",vertical="center") + #recursos finep recursos contra partid + worksheet['C8'] = "='DEMOSTR. RECEITA E DESPESA A.2'!C8" + worksheet['C8'].font = Font(name="Arial", size=12, color="000000") + worksheet['C8'].alignment = Alignment(horizontal="left",vertical="center") + #xxx + worksheet['C9'] = "='DEMOSTR. RECEITA E DESPESA A.2'!C9" + worksheet['C9'].font = Font(name="Arial", size=12, color="000000") + worksheet['C9'].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="000000",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="double") ,bottom=Side(border_style="hair"), right=Side(border_style="hair"),left=Side(border_style='hair') ) + locals()[input2].height = 20 + + linha_number = 15 + for row in worksheet.iter_rows(min_row=linha_number, max_row=linha_number, min_col=1, max_col=9): + for cell in row: + cell.style = locals()[input2] + if cell.column == 9: + cell.border = Border(top=Side(border_style="double") ,bottom=Side(border_style="thin"), right=Side(border_style="double") ) + cell.fill = openpyxl.styles.PatternFill(start_color=azul_claro, end_color=azul_claro, fill_type='solid') + + + + valores = ["Nº DE ORDEM","CREDOR","CNPJ/CPF",'Equivalência na Relação de Itens Apoiados','Nº DA NOTA FISCAL OU EQUIVALENTE',"DATA DA NOTA FISCAL",'Nº DO CHEQUE OU EQUIVALENTE','DATA DA COMPENSAÇÃO DO CHEQUE','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=15, max_row=size, min_col=1, max_col=9): + 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) + + + value_to_stop = size + start_row = 10 + + #estilo mascara de dinheiro + for row in range(start_row,size+1): + cell = worksheet[f'i{row}'] + cell.style = locals()[input3] + + #estilocinzasimcinzanao + for rows in worksheet.iter_rows(min_row=16, max_row=size, min_col=1, max_col=9): + 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") ) + + + + if cell.column == 9: + 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="double") ,bottom=Side(border_style="hair") ) + if cell.row == size: + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,right =Side(border_style="double") ,bottom=Side(border_style="hair") ) + + #double em cima double total + + #bordinha double + stringAfinarCelula =size+2 + cellborda = f"I{size+1}" + bordacell = worksheet[cellborda] + bordacell.border = Border(right =Side(border_style="double")) + + + #subtotal + worksheet.row_dimensions[size+2].height = 6 + celulas_mergidas_subtotal = f"A{size+2}:H{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="thin") ,right =Side(border_style="thin") ,bottom=Side(border_style="double") ) + + worksheet.row_dimensions[size+2].height = 56.25 + + # FORMULATOTAL + formula = f"=SUM(I16:I{size})" + celula = f'I{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="double") ,bottom=Side(border_style="double") ) + 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="000000",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="double") ,bottom=Side(border_style="hair"),right=Side(border_style='hair'),left=Side(border_style='hair') ) + + + row_number = size + 4 + + for column in range(1, 10): + cell = worksheet.cell(row=row_number, column=column) + cell.style = locals()[input4] + if cell.column == 9: + cell.border = Border(top=Side(border_style="double") ,right =Side(border_style="double") ,bottom=Side(border_style="hair") ) + + + + values = ["Nº DE ORDEM","RESTITUIDOR","CNPJ/CPF" ,'Equivalência na Relação de Itens Apoiados',"CHEQUE OU EQUIVALENTE ESTORNADO","DATA DO CHEQUE",'Nº DO DEPÓSITO','DATA DO DEPÓSITO','VALOR'] + coluna = 1 + for a,b in enumerate(values): + worksheet.cell(row=row_number, column=coluna, value=b) + coluna = coluna + 1 + + + + + #estorno + + for rows in worksheet.iter_rows(min_row=size+5, max_row=size+4+tamanhoestorno, min_col=1, max_col=9): + 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")) + cell.font = Font(name="Arial", size=12, color="000000") + cell.alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + if cell.row == size+4+tamanhoestorno: + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,right =Side(border_style="hair") ,bottom=Side(border_style="hair")) + cell.font = Font(name="Arial", size=12, color="000000") + cell.alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + if cell.column == 9: + cell.number_format = 'R$ #,##0.00' + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,right =Side(border_style="double") ,bottom=Side(border_style="hair")) + cell.font = Font(name="Arial", size=12, color="000000") + cell.alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + if cell.row == size+4+tamanhoestorno: + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,right =Side(border_style="double") ,bottom=Side(border_style="hair")) + cell.font = Font(name="Arial", size=12, color="000000") + cell.alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + + + #bordas,corsimcornao,money + # Set the height of each row to 60 + for row in worksheet.iter_rows(min_row=size+4, max_row=size+4+tamanhoestorno): + worksheet.row_dimensions[row[0].row].height = 60 + + min_row = size + 4 + max_row = size + 4 + tamanhoestorno + + + + #bordinha double + stringAfinarCelula = size + 6 +tamanhoestorno + cellborda = f"I{size + 5 +tamanhoestorno}" + bordacell = worksheet[cellborda] + bordacell.border = Border(right =Side(border_style="double")) + + #subtotal2 + sub_total2_row = size + 6 +tamanhoestorno + subtotal_merge_cells= f'A{sub_total2_row}:H{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="thin") ,left = Side(border_style="thin") ,right =Side(border_style="hair") ,bottom=Side(border_style="hair") ) + + sub_formula_row_celula = f'I{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].value = f'=SUM(I{size+5}:I{sub_total2_row-1})' + 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="double") ,bottom=Side(border_style="thin") ) + + #total1-2 + total12_row = size + 7 + tamanhoestorno + total12_merge_cells = f'A{total12_row}:H{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="thin") ,left = Side(border_style="hair") ,bottom=Side(border_style="double"),right=Side(border_style="thin") ) + + + #total_formula + total_formula_row = size + 7 + tamanhoestorno + total_formulaa = f'=I{size+2} - I{sub_total2_row }' + total_formula_row_celula = f'I{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(bottom=Side(border_style="double"),right=Side(border_style="double") ) + + worksheet.row_dimensions[total_formula_row].height = 30 + worksheet[total_formula_row_celula] = total_formulaa + + + + #brasilia + brasilia_row = size + 8 +tamanhoestorno + brasilia_formula = f"='DEMOSTR. RECEITA E DESPESA A.2'!A{stringTamanho}" + 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 + 9 + tamanhoestorno + diretor_cargo_row = size + 10 + tamanhoestorno + diretor_cpf_row = size + 11 + tamanhoestorno + + diretor_nome_formula = f"='DEMOSTR. RECEITA E DESPESA A.2'!A{stringTamanho+3}" + diretor_cargo_formula = f"='DEMOSTR. RECEITA E DESPESA A.2'!A{stringTamanho+4}" + diretor_cpf_formula = f"='DEMOSTR. RECEITA E DESPESA A.2'!A{stringTamanho+5}" + 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 + 9 + tamanhoestorno + coordenadora_cargo_row = size + 10 + tamanhoestorno + coordenadora_cpf_row = size + 11 + tamanhoestorno + coordenadora_nome_formula = f"='DEMOSTR. RECEITA E DESPESA A.2'!C{stringTamanho+3}" + coordenadora_cargo_formula = f"='DEMOSTR. RECEITA E DESPESA A.2'!C{stringTamanho+4}" + coordenadora_cpf_formula = f"='DEMOSTR. RECEITA E DESPESA A.2'!C{stringTamanho+5}" + coordenadora_merge_cells = f'F{coordenadora_row}:I{coordenadora_row}' + coordenadora_cargo_merge_cells = f'F{coordenadora_cargo_row}:I{coordenadora_cargo_row}' + coordenadora_cpf_merge_cells = f'F{coordenadora_cpf_row}:I{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(name="Arial", size=12, color="000000",bold = True) + top_left_coordenadora_cell_cargo_formula.alignment = Alignment(horizontal="center",vertical="center") + top_left_coordenadora_cell_cargo_formula.font = Font(name="Arial", size=12, color="000000") + top_left_coordenadora_cell_cpf_formula.alignment = Alignment(horizontal="center",vertical="center") + top_left_coordenadora_cell_cpf_formula.font= Font(name="Arial", size=12, color="000000") + + + # 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=9): + # for cell in row: + # cell.border = borda + + for row in worksheet.iter_rows(min_row=linha_number, max_row=linha_number, min_col=9, max_col=9): + for cell in row: + cell.border = Border(top=Side(border_style="double") ,bottom=Side(border_style="hair"), right=Side(border_style="double") ) + cell.fill = openpyxl.styles.PatternFill(start_color=azul_claro, end_color=azul_claro, fill_type='solid') + cell.font = Font(name="Arial", size=12, color="000000",bold=True) + + cinzaborda = '9e9e9e' + + #borda cabeçario + for row in worksheet.iter_rows(min_row=1, max_row=14,min_col=9,max_col=9): + for cell in row: + cell.border = Border(top=Side(border_style="none") ,right = Side(border_style="thin",color='9e9e9e') ,left =Side(border_style="none") ,bottom=Side(border_style="none") ) + + #borda fim pagina + for row in worksheet.iter_rows(min_row=brasilia_row, max_row=coordenadora_cpf_row+1,min_col=9,max_col=9): + for cell in row: + cell.border = Border(top=Side(border_style="none") ,right = Side(border_style="thin",color='9e9e9e') ,left =Side(border_style="none") ,bottom=Side(border_style="none") ) + + + + for row in worksheet.iter_rows(min_row=coordenadora_cpf_row+1, max_row=coordenadora_cpf_row+1,min_col=1,max_col=9): + for cell in row: + if cell.column == 9: + cell.border = Border(top=Side(border_style="none") ,left = Side(border_style="none") ,right =Side(border_style="thin",color='9e9e9e') ,bottom=Side(border_style="thin",color='9e9e9e') ) + else: + cell.border = Border(top=Side(border_style="none") ,left = Side(border_style="none") ,right =Side(border_style="none") ,bottom=Side(border_style="thin",color='9e9e9e') ) + + workbook.save(tabela) + workbook.close() + + return size+5 + +def estiloPagamentoPessoal(tabela,tamanho,stringTamanho,tamanhoestorno): + '''Esse estilo e considerado geral por que todas as tabelas que compõe utilizam das mesma colunas. + + Argumentos: + tabela: recebe o arquivo correspondente a tabela Fub extensão xlsx. Esse arquivo ja foi iniciado e passou pela preencher fub mas ainda esta sem o estilo que sera aplicado nessa função. + tamanho: e o tamanho total de linhas que irao ser geradas dinamicamente correspondente as entradas do respectivo projeto. o valor varia dentre o tamanho das rubricas + + nomeVariavel: variável utilizada para criar o nomes das variaveis dinamicamente para não haver sobreposição de estilos com o mesmo nome. Esses estilos ocorrem nesses codigos: + 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"'.... + nomeTabela: variável utilizada para a criação do nome da tabela.Ela deriva das rubricas que são colocadas no input quando essa função e chamada. + stringTamanho: refere-se aonde esta localizado a string brasilia na pagina Receita e despesa para a referencias das formulas. + + ''' + if tamanho == 0: + tamanho = 1 + + + nomeVariavel = f'PagamentoPessoal' + nomeSheet=nomeVariavel + random_number = random.randint(1, 10000) + nomeVariavel = f'{nomeVariavel}{random_number}' + caminho = pegar_caminho(tabela) + workbook = openpyxl.load_workbook(caminho) + worksheet = workbook['Pagamento de Pessoal'] + size = tamanho + 16 + cinza = "d9d9d9" + cinza_escuro = "bfbfbf" + azul = "336394" + azul_claro = 'ccffff' + + + # 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 = 45 + worksheet.column_dimensions['b'].width = 35 + worksheet.column_dimensions['c'].width = 35 + worksheet.column_dimensions['d'].width = 45#descrição + worksheet.column_dimensions['e'].width = 45 #n do recibo ou qeuivalente + worksheet.column_dimensions['f'].width = 35 #data de emissão + worksheet.column_dimensions['g'].width = 35 #data de emissão + worksheet.column_dimensions['h'].width = 35 #data de emissão + worksheet.column_dimensions['i'].width = 35 #data de emissão + worksheet.column_dimensions['j'].width = 35 #data de emissão + + + #cabecario relação de pagamentos - outro servicoes de terceiros + worksheet.merge_cells('A1:J1') + worksheet['A1'] = f'ANEXO 4' + worksheet['A1'].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet['A1'].alignment = Alignment(horizontal="center",vertical="center") + #RELAÇÃO DE PAGAMENTOS + worksheet.merge_cells('A2:J2') + + worksheet['A2'] = f'RELAÇÃO DE PAGAMENTOS' + worksheet['A2'].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet['A2'].alignment = Alignment(horizontal="center",vertical="center") + + #ElementosdeDespesa + + + worksheet['A11'] = f'Elemento de Despesa' + worksheet['A11'].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet['A11'].alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + + #ElementosdeDespesa + + + worksheet['A14'] = f'DESPESAS REALIZADAS' + worksheet['A14'].font = Font(name="Arial", size=12, color="000000",bold=True,italic=True) + worksheet['A14'].alignment = Alignment(horizontal="center",vertical="center") + + + + #cabecario que recebe de referencia as celulas A da planilha DEMOSTR. RECEITA E DESPESA A.2 + + + worksheet['A4'] = "='DEMOSTR. RECEITA E DESPESA A.2'!A4" + worksheet['A4'].font = Font(name="Arial", size=12, color="000000") + worksheet['A4'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet['A5'] = "='DEMOSTR. RECEITA E DESPESA A.2'!A5" + worksheet['A5'].font = Font(name="Arial", size=12, color="000000") + worksheet['A5'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet['A6'] = "='DEMOSTR. RECEITA E DESPESA A.2'!A6" + worksheet['A6'].font = Font(name="Arial", size=12, color="000000") + worksheet['A6'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet['A7'] = "='DEMOSTR. RECEITA E DESPESA A.2'!A7" + worksheet['A7'].font = Font(name="Arial", size=12, color="000000") + worksheet['A7'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet['A8'] = "='DEMOSTR. RECEITA E DESPESA A.2'!A8" + worksheet['A8'].font = Font(name="Arial", size=12, color="000000") + worksheet['A8'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet['A9'] = "='DEMOSTR. RECEITA E DESPESA A.2'!A9" + worksheet['A9'].font = Font(name="Arial", size=12, color="000000") + worksheet['A9'].alignment = Alignment(horizontal="left",vertical="center") + + + + #cabecario que recebe de referencia as celulas C da planilha DEMOSTR. RECEITA E DESPESA A.2 + + worksheet['C5'] = "='DEMOSTR. RECEITA E DESPESA A.2'!C5" + worksheet['C5'].font = Font(name="Arial", size=12, color="000000") + worksheet['C5'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet['C6'] = "='DEMOSTR. RECEITA E DESPESA A.2'!C6" + worksheet['C6'].font = Font(name="Arial", size=12, color="000000") + worksheet['C6'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet['C7'] = "='DEMOSTR. RECEITA E DESPESA A.2'!C7" + worksheet['C7'].font = Font(name="Arial", size=12, color="000000") + worksheet['C7'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet['C8'] = "='DEMOSTR. RECEITA E DESPESA A.2'!C8" + worksheet['C8'].font = Font(name="Arial", size=12, color="000000") + worksheet['C8'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet['C9'] = "='DEMOSTR. RECEITA E DESPESA A.2'!C9" + worksheet['C9'].font = Font(name="Arial", size=12, color="000000") + worksheet['C9'].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="000000",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="double") ,bottom=Side(border_style="hair"), right=Side(border_style="hair"),left=Side(border_style='hair') ) + locals()[input2].height = 20 + + linha_number = 15 + 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="double") ,bottom=Side(border_style="thin"), right=Side(border_style="double") ) + cell.fill = openpyxl.styles.PatternFill(start_color=azul_claro, end_color=azul_claro, fill_type='solid') + + + + valores = ["Nº DE ORDEM","BENEFICIÁRIO","CNPJ/CPF",'Vencimento / Tipo de Obrigação Patronal / Tipo de Benefício ','Equivalência na Relação de Itens Apoiados','Nº DO COMPROVANTE OU EQUIVALENTE',"DATA DO COMPROVANTE",'Nº DO CHEQUE OU EQUIVALENTE','DATA DA COMPENSAÇÃO DO CHEQUE','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=15, 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) + + + value_to_stop = size + start_row = 10 + + #estilo mascara de dinheiro + for row in range(start_row,size+1): + cell = worksheet[f'j{row}'] + cell.style = locals()[input3] + + #estilocinzasimcinzanao + for rows in worksheet.iter_rows(min_row=16, 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") ) + + + + 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="double") ,bottom=Side(border_style="hair") ) + if cell.row == size: + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,right =Side(border_style="double") ,bottom=Side(border_style="hair") ) + + #double em cima double total + + #bordinha double + stringAfinarCelula =size+2 + cellborda = f"J{size+1}" + bordacell = worksheet[cellborda] + bordacell.border = Border(right =Side(border_style="double")) + + + #subtotal + 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="thin") ,right =Side(border_style="thin") ,bottom=Side(border_style="double") ) + + worksheet.row_dimensions[size+2].height = 56.25 + + # FORMULATOTAL + formula = f"=SUM(J16: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="double") ,bottom=Side(border_style="double") ) + 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="000000",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="double") ,bottom=Side(border_style="hair"),right=Side(border_style='hair'),left=Side(border_style='hair') ) + + + 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="double") ,right =Side(border_style="double") ,bottom=Side(border_style="hair") ) + + + + values = ["Nº DE ORDEM","RESTITUIDOR","CNPJ/CPF",'Vencimento / Tipo de Obrigação Patronal / Tipo de Benefício ','Equivalência na Relação de Itens Apoiados','Nº DO COMPROVANTE OU EQUIVALENTE',"DATA DO COMPROVANTE",'Nº DO CHEQUE OU EQUIVALENTE','DATA DA COMPENSAÇÃO DO CHEQUE','VALOR'] + coluna = 1 + for a,b in enumerate(values): + worksheet.cell(row=row_number, column=coluna, value=b) + coluna = coluna + 1 + + + + + #estorno + + for rows in worksheet.iter_rows(min_row=size+5, max_row=size+4+tamanhoestorno, 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.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")) + if cell.row == size+4+tamanhoestorno: + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,right =Side(border_style="hair") ,bottom=Side(border_style="hair")) + cell.font = Font(name="Arial", size=12, color="000000") + cell.alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + + if cell.column == 10: + cell.number_format = 'R$ #,##0.00' + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,right =Side(border_style="double") ,bottom=Side(border_style="hair")) + cell.font = Font(name="Arial", size=12, color="000000") + cell.alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + if cell.row == size+4+tamanhoestorno: + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,right =Side(border_style="double") ,bottom=Side(border_style="hair")) + cell.font = Font(name="Arial", size=12, color="000000") + cell.alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + + + #bordas,corsimcornao,money + # Set the height of each row to 60 + for row in worksheet.iter_rows(min_row=size+4, max_row=size+4+tamanhoestorno): + worksheet.row_dimensions[row[0].row].height = 60 + + min_row = size + 4 + max_row = size + 4 + tamanhoestorno + + + + #bordinha double + stringAfinarCelula = size + 6 +tamanhoestorno + cellborda = f"J{size + 5 +tamanhoestorno}" + bordacell = worksheet[cellborda] + bordacell.border = Border(right =Side(border_style="double")) + + #subtotal2 + sub_total2_row = size + 6 +tamanhoestorno + 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="thin") ,left = Side(border_style="thin") ,right =Side(border_style="hair") ,bottom=Side(border_style="hair") ) + + 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].value = f'=SUM(J{size+5}:J{sub_total2_row-1})' + 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="double") ,bottom=Side(border_style="thin") ) + + #total1-2 + total12_row = size + 7 + tamanhoestorno + 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="thin") ,left = Side(border_style="hair") ,bottom=Side(border_style="double"),right=Side(border_style="thin") ) + + + #total_formula + total_formula_row = size + 7 + tamanhoestorno + total_formulaa = f'=J{size+2} - J{sub_total2_row }' + 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(bottom=Side(border_style="double"),right=Side(border_style="double") ) + + worksheet.row_dimensions[total_formula_row].height = 30 + worksheet[total_formula_row_celula] = total_formulaa + + + size = size + 1 + #brasilia + brasilia_row = size + 8 +tamanhoestorno + brasilia_formula = f"='DEMOSTR. RECEITA E DESPESA A.2'!A{stringTamanho}" + brasilia_merge_cells = f'A{brasilia_row}:J{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") + top_left_brasilia_cell.font = Font(name="Arial", size=12, color="000000") + #DiretorFinanceiro + diretor_row = size + 9 + tamanhoestorno + diretor_cargo_row = size + 10 + tamanhoestorno + diretor_cpf_row = size + 11 + tamanhoestorno + + diretor_nome_formula = f"='DEMOSTR. RECEITA E DESPESA A.2'!A{stringTamanho+3}" + diretor_cargo_formula = f"='DEMOSTR. RECEITA E DESPESA A.2'!A{stringTamanho+4}" + diretor_cpf_formula = f"='DEMOSTR. RECEITA E DESPESA A.2'!A{stringTamanho+5}" + 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 + 9 + tamanhoestorno + coordenadora_cargo_row = size + 10 + tamanhoestorno + coordenadora_cpf_row = size + 11 + tamanhoestorno + coordenadora_nome_formula = f"='DEMOSTR. RECEITA E DESPESA A.2'!C{stringTamanho+3}" + coordenadora_cargo_formula = f"='DEMOSTR. RECEITA E DESPESA A.2'!C{stringTamanho+4}" + coordenadora_cpf_formula = f"='DEMOSTR. RECEITA E DESPESA A.2'!C{stringTamanho+5}" + 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(name="Arial", size=12, color="000000",bold = True) + top_left_coordenadora_cell_cargo_formula.alignment = Alignment(horizontal="center",vertical="center") + top_left_coordenadora_cell_cargo_formula.font = Font(name="Arial", size=12, color="000000") + top_left_coordenadora_cell_cpf_formula.alignment = Alignment(horizontal="center",vertical="center") + top_left_coordenadora_cell_cpf_formula.font= Font(name="Arial", size=12, color="000000") + + + # 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=9): + # for cell in row: + # cell.border = borda + + for row in worksheet.iter_rows(min_row=linha_number, max_row=linha_number, min_col=10, max_col=10): + for cell in row: + cell.border = Border(top=Side(border_style="double") ,bottom=Side(border_style="hair"), right=Side(border_style="double") ) + cell.fill = openpyxl.styles.PatternFill(start_color=azul_claro, end_color=azul_claro, fill_type='solid') + cell.font = Font(name="Arial", size=12, color="000000",bold=True) + + cinzaborda = '9e9e9e' + + #borda cabeçario + for row in worksheet.iter_rows(min_row=1, max_row=14,min_col=10,max_col=10): + for cell in row: + cell.border = Border(top=Side(border_style="none") ,right = Side(border_style="thin",color='9e9e9e') ,left =Side(border_style="none") ,bottom=Side(border_style="none") ) + + #borda fim pagina + for row in worksheet.iter_rows(min_row=brasilia_row-1, max_row=coordenadora_cpf_row+1,min_col=10,max_col=10): + for cell in row: + cell.border = Border(top=Side(border_style="none") ,right = Side(border_style="thin",color='9e9e9e') ,left =Side(border_style="none") ,bottom=Side(border_style="none") ) + + + + 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="thin",color='9e9e9e') ,bottom=Side(border_style="thin",color='9e9e9e') ) + else: + cell.border = Border(top=Side(border_style="none") ,left = Side(border_style="none") ,right =Side(border_style="none") ,bottom=Side(border_style="thin",color='9e9e9e') ) + + workbook.save(tabela) + workbook.close() + + return size+4 + +def estiloElementoDeDespesa1415Diarias(tabela,tamanho,stringTamanho,tamanhoestorno): + '''Esse estilo e considerado geral por que todas as tabelas que compõe utilizam das mesma colunas. + + Argumentos: + tabela: recebe o arquivo correspondente a tabela Fub extensão xlsx. Esse arquivo ja foi iniciado e passou pela preencher fub mas ainda esta sem o estilo que sera aplicado nessa função. + tamanho: e o tamanho total de linhas que irao ser geradas dinamicamente correspondente as entradas do respectivo projeto. o valor varia dentre o tamanho das rubricas + + nomeVariavel: variável utilizada para criar o nomes das variaveis dinamicamente para não haver sobreposição de estilos com o mesmo nome. Esses estilos ocorrem nesses codigos: + 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"'.... + nomeTabela: variável utilizada para a criação do nome da tabela.Ela deriva das rubricas que são colocadas no input quando essa função e chamada. + stringTamanho: refere-se aonde esta localizado a string brasilia na pagina Receita e despesa para a referencias das formulas. + + ''' + if tamanho == 0: + tamanho = 1 + + + nomeVariavel = f'Diaria' + nomeSheet=nomeVariavel + random_number = random.randint(1, 10000) + nomeVariavel = f'{nomeVariavel}{random_number}' + caminho = pegar_caminho(tabela) + workbook = openpyxl.load_workbook(caminho) + worksheet = workbook['Elemento de Despesa 14.15'] + size = tamanho + 16 + cinza = "d9d9d9" + cinza_escuro = "bfbfbf" + azul = "336394" + azul_claro = 'ccffff' + + + # 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 = 45 + worksheet.column_dimensions['b'].width = 35 + worksheet.column_dimensions['c'].width = 35 + worksheet.column_dimensions['d'].width = 45#descrição + worksheet.column_dimensions['e'].width = 45 #n do recibo ou qeuivalente + worksheet.column_dimensions['f'].width = 35 #data de emissão + worksheet.column_dimensions['g'].width = 35 #data de emissão + worksheet.column_dimensions['h'].width = 35 #data de emissão + worksheet.column_dimensions['i'].width = 35 #data de emissão + worksheet.column_dimensions['j'].width = 35 #data de emissão + worksheet.column_dimensions['k'].width = 35 #data de emissão + worksheet.column_dimensions['l'].width = 35 #data de emissão + + + #cabecario relação de pagamentos - outro servicoes de terceiros + worksheet.merge_cells('A1:L1') + worksheet['A1'] = f'ANEXO 4' + worksheet['A1'].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet['A1'].alignment = Alignment(horizontal="center",vertical="center") + #RELAÇÃO DE PAGAMENTOS + worksheet.merge_cells('A2:L2') + + worksheet['A2'] = f'RELAÇÃO DE PAGAMENTOS' + worksheet['A2'].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet['A2'].alignment = Alignment(horizontal="center",vertical="center") + + #ElementosdeDespesa + + + worksheet['A11'] = f'Elemento de Despesa' + worksheet['A11'].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet['A11'].alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + + #ElementosdeDespesa + + + worksheet['A14'] = f'DESPESAS REALIZADAS' + worksheet['A14'].font = Font(name="Arial", size=12, color="000000",bold=True,italic=True) + worksheet['A14'].alignment = Alignment(horizontal="center",vertical="center") + + + + #cabecario que recebe de referencia as celulas A da planilha DEMOSTR. RECEITA E DESPESA A.2 + + + worksheet['A4'] = "='DEMOSTR. RECEITA E DESPESA A.2'!A4" + worksheet['A4'].font = Font(name="Arial", size=12, color="000000") + worksheet['A4'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet['A5'] = "='DEMOSTR. RECEITA E DESPESA A.2'!A5" + worksheet['A5'].font = Font(name="Arial", size=12, color="000000") + worksheet['A5'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet['A6'] = "='DEMOSTR. RECEITA E DESPESA A.2'!A6" + worksheet['A6'].font = Font(name="Arial", size=12, color="000000") + worksheet['A6'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet['A7'] = "='DEMOSTR. RECEITA E DESPESA A.2'!A7" + worksheet['A7'].font = Font(name="Arial", size=12, color="000000") + worksheet['A7'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet['A8'] = "='DEMOSTR. RECEITA E DESPESA A.2'!A8" + worksheet['A8'].font = Font(name="Arial", size=12, color="000000") + worksheet['A8'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet['A9'] = "='DEMOSTR. RECEITA E DESPESA A.2'!A9" + worksheet['A9'].font = Font(name="Arial", size=12, color="000000") + worksheet['A9'].alignment = Alignment(horizontal="left",vertical="center") + + + + #cabecario que recebe de referencia as celulas C da planilha DEMOSTR. RECEITA E DESPESA A.2 + + worksheet['C5'] = "='DEMOSTR. RECEITA E DESPESA A.2'!C5" + worksheet['C5'].font = Font(name="Arial", size=12, color="000000") + worksheet['C5'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet['C6'] = "='DEMOSTR. RECEITA E DESPESA A.2'!C6" + worksheet['C6'].font = Font(name="Arial", size=12, color="000000") + worksheet['C6'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet['C7'] = "='DEMOSTR. RECEITA E DESPESA A.2'!C7" + worksheet['C7'].font = Font(name="Arial", size=12, color="000000") + worksheet['C7'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet['C8'] = "='DEMOSTR. RECEITA E DESPESA A.2'!C8" + worksheet['C8'].font = Font(name="Arial", size=12, color="000000") + worksheet['C8'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet['C9'] = "='DEMOSTR. RECEITA E DESPESA A.2'!C9" + worksheet['C9'].font = Font(name="Arial", size=12, color="000000") + worksheet['C9'].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="000000",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="double") ,bottom=Side(border_style="hair"), right=Side(border_style="hair"),left=Side(border_style='hair') ) + locals()[input2].height = 20 + + linha_number = 15 + for row in worksheet.iter_rows(min_row=linha_number, max_row=linha_number, min_col=1, max_col=12): + for cell in row: + cell.style = locals()[input2] + if cell.column == 12: + cell.border = Border(top=Side(border_style="double") ,bottom=Side(border_style="thin"), right=Side(border_style="double") ) + cell.fill = openpyxl.styles.PatternFill(start_color=azul_claro, end_color=azul_claro, fill_type='solid') + + + + valores = ["Nº DE ORDEM","BENEFICIÁRIO","CNPJ/CPF",'Destino','Nº DE DIÁRIAS UTILIZADAS','Evento',"Equivalência na Relação de Itens Apoiados",'Nº DO RECIBO OU EQUIVALENTE','DATA DO RECIBO','Nº DO CHEQUE OU EQUIVALENTE','DATA DA COMPENSAÇÃO DO CHEQUE','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=15, max_row=size, min_col=1, max_col=12): + 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) + + + value_to_stop = size + start_row = 10 + + #estilo mascara de dinheiro + for row in range(start_row,size+1): + cell = worksheet[f'L{row}'] + cell.style = locals()[input3] + + #estilocinzasimcinzanao + for rows in worksheet.iter_rows(min_row=16, max_row=size, min_col=1, max_col=12): + 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") ) + + + + if cell.column == 12: + 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="double") ,bottom=Side(border_style="hair") ) + if cell.row == size: + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,right =Side(border_style="double") ,bottom=Side(border_style="hair") ) + + #double em cima double total + + #bordinha double + stringAfinarCelula =size+2 + cellborda = f"L{size+1}" + bordacell = worksheet[cellborda] + bordacell.border = Border(right =Side(border_style="double")) + + + #subtotal + worksheet.row_dimensions[size+2].height = 6 + celulas_mergidas_subtotal = f"A{size+2}:K{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="thin") ,right =Side(border_style="thin") ,bottom=Side(border_style="double") ) + + worksheet.row_dimensions[size+2].height = 56.25 + + # FORMULATOTAL + formula = f"=SUM(L16:L{size})" + celula = f'L{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="double") ,bottom=Side(border_style="double") ) + 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="000000",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="double") ,bottom=Side(border_style="hair"),right=Side(border_style='hair'),left=Side(border_style='hair') ) + + + row_number = size + 4 + + for column in range(1, 13): + cell = worksheet.cell(row=row_number, column=column) + cell.style = locals()[input4] + if cell.column == 12: + cell.border = Border(top=Side(border_style="double") ,right =Side(border_style="double") ,bottom=Side(border_style="hair") ) + + + + values = ["Nº DE ORDEM","RESTITUIDOR","CNPJ/CPF","Destino",'Nº DE DIÁRIAS UTILIZADAS','Evento','Equivalência na Relação de Itens Apoiados',"CHEQUE OU EQUIVALENTE ESTORNADO",'DATA DO CHEQUE','Nº DO DEPÓSITO','DATA DO DEPÓSITO','VALOR'] + coluna = 1 + for a,b in enumerate(values): + worksheet.cell(row=row_number, column=coluna, value=b) + coluna = coluna + 1 + + + + + #estorno + + for rows in worksheet.iter_rows(min_row=size+5, max_row=size+4+tamanhoestorno, min_col=1, max_col=12): + 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.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")) + if cell.row == size+4+tamanhoestorno: + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,right =Side(border_style="hair") ,bottom=Side(border_style="hair")) + cell.font = Font(name="Arial", size=12, color="000000") + cell.alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + if cell.column == 12: + cell.number_format = 'R$ #,##0.00' + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,right =Side(border_style="double") ,bottom=Side(border_style="hair")) + cell.font = Font(name="Arial", size=12, color="000000") + cell.alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + if cell.row == size+4+tamanhoestorno: + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,right =Side(border_style="double") ,bottom=Side(border_style="hair")) + cell.font = Font(name="Arial", size=12, color="000000") + cell.alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + + + #bordas,corsimcornao,money + # Set the height of each row to 60 + for row in worksheet.iter_rows(min_row=size+4, max_row=size+4+tamanhoestorno): + worksheet.row_dimensions[row[0].row].height = 60 + + min_row = size + 4 + max_row = size + 4 + tamanhoestorno + + + + #bordinha double + stringAfinarCelula = size + 6 +tamanhoestorno + cellborda = f"L{size + 5 +tamanhoestorno}" + bordacell = worksheet[cellborda] + bordacell.border = Border(right =Side(border_style="double")) + + #subtotal2 + sub_total2_row = size + 6 +tamanhoestorno + subtotal_merge_cells= f'A{sub_total2_row}:K{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="thin") ,left = Side(border_style="thin") ,right =Side(border_style="hair") ,bottom=Side(border_style="hair") ) + + sub_formula_row_celula = f'L{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].value = f'=SUM(L{size+5}:L{sub_total2_row-1})' + 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="double") ,bottom=Side(border_style="thin") ) + + #total1-2 + total12_row = size + 7 + tamanhoestorno + total12_merge_cells = f'A{total12_row}:K{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="thin") ,left = Side(border_style="hair") ,bottom=Side(border_style="double"),right=Side(border_style="thin") ) + + + #total_formula + total_formula_row = size + 7 + tamanhoestorno + total_formulaa = f'=L{size+2} - L{sub_total2_row }' + total_formula_row_celula = f'L{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(bottom=Side(border_style="double"),right=Side(border_style="double") ) + + worksheet.row_dimensions[total_formula_row].height = 30 + worksheet[total_formula_row_celula] = total_formulaa + + + size = size + 1 + #brasilia + brasilia_row = size + 8 +tamanhoestorno + brasilia_formula = f"='DEMOSTR. RECEITA E DESPESA A.2'!A{stringTamanho}" + brasilia_merge_cells = f'A{brasilia_row}:L{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") + top_left_brasilia_cell.font = Font(name="Arial", size=12, color="000000") + + #DiretorFinanceiro + diretor_row = size + 9 + tamanhoestorno + diretor_cargo_row = size + 10 + tamanhoestorno + diretor_cpf_row = size + 11 + tamanhoestorno + + diretor_nome_formula = f"='DEMOSTR. RECEITA E DESPESA A.2'!A{stringTamanho+3}" + diretor_cargo_formula = f"='DEMOSTR. RECEITA E DESPESA A.2'!A{stringTamanho+4}" + diretor_cpf_formula = f"='DEMOSTR. RECEITA E DESPESA A.2'!A{stringTamanho+5}" + diretor_merge_cells = f'A{diretor_row}:F{diretor_row}' + diretor_cargo_merge_cells = f'A{diretor_cargo_row}:F{diretor_cargo_row}' + diretor_cpf_merge_cells = f'A{diretor_cpf_row}:F{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 + 9 + tamanhoestorno + coordenadora_cargo_row = size + 10 + tamanhoestorno + coordenadora_cpf_row = size + 11 + tamanhoestorno + coordenadora_nome_formula = f"='DEMOSTR. RECEITA E DESPESA A.2'!C{stringTamanho+3}" + coordenadora_cargo_formula = f"='DEMOSTR. RECEITA E DESPESA A.2'!C{stringTamanho+4}" + coordenadora_cpf_formula = f"='DEMOSTR. RECEITA E DESPESA A.2'!C{stringTamanho+5}" + coordenadora_merge_cells = f'G{coordenadora_row}:L{coordenadora_row}' + coordenadora_cargo_merge_cells = f'G{coordenadora_cargo_row}:L{coordenadora_cargo_row}' + coordenadora_cpf_merge_cells = f'G{coordenadora_cpf_row}:L{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'G{coordenadora_row}' + top_left_coordenadora_cell_cargo_formula = f'G{coordenadora_cargo_row}' + top_left_coordenadora_cell_cpf_formula = f'G{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(name="Arial", size=12, color="000000",bold = True) + top_left_coordenadora_cell_cargo_formula.alignment = Alignment(horizontal="center",vertical="center") + top_left_coordenadora_cell_cargo_formula.font = Font(name="Arial", size=12, color="000000") + top_left_coordenadora_cell_cpf_formula.alignment = Alignment(horizontal="center",vertical="center") + top_left_coordenadora_cell_cpf_formula.font= Font(name="Arial", size=12, color="000000") + + + # 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=9): + # for cell in row: + # cell.border = borda + + for row in worksheet.iter_rows(min_row=linha_number, max_row=linha_number, min_col=12, max_col=12): + for cell in row: + cell.border = Border(top=Side(border_style="double") ,bottom=Side(border_style="hair"), right=Side(border_style="double") ) + cell.fill = openpyxl.styles.PatternFill(start_color=azul_claro, end_color=azul_claro, fill_type='solid') + cell.font = Font(name="Arial", size=12, color="000000",bold=True) + + cinzaborda = '9e9e9e' + + #borda cabeçario + for row in worksheet.iter_rows(min_row=1, max_row=14,min_col=12,max_col=12): + for cell in row: + cell.border = Border(top=Side(border_style="none") ,right = Side(border_style="thin",color='9e9e9e') ,left =Side(border_style="none") ,bottom=Side(border_style="none") ) + + #borda fim pagina + for row in worksheet.iter_rows(min_row=brasilia_row-1, max_row=coordenadora_cpf_row+1,min_col=12,max_col=12): + for cell in row: + cell.border = Border(top=Side(border_style="none") ,right = Side(border_style="thin",color='9e9e9e') ,left =Side(border_style="none") ,bottom=Side(border_style="none") ) + + + + for row in worksheet.iter_rows(min_row=coordenadora_cpf_row+1, max_row=coordenadora_cpf_row+1,min_col=1,max_col=12): + for cell in row: + if cell.column == 12: + cell.border = Border(top=Side(border_style="none") ,left = Side(border_style="none") ,right =Side(border_style="thin",color='9e9e9e') ,bottom=Side(border_style="thin",color='9e9e9e') ) + else: + cell.border = Border(top=Side(border_style="none") ,left = Side(border_style="none") ,right =Side(border_style="none") ,bottom=Side(border_style="thin",color='9e9e9e') ) + + workbook.save(tabela) + workbook.close() + + return size+4 + +def estiloElementoDeDespesa33PassagensEDespesa(tabela,tamanho,stringTamanho,tamanhoestorno): + '''Esse estilo e considerado geral por que todas as tabelas que compõe utilizam das mesma colunas. + + Argumentos: + tabela: recebe o arquivo correspondente a tabela Fub extensão xlsx. Esse arquivo ja foi iniciado e passou pela preencher fub mas ainda esta sem o estilo que sera aplicado nessa função. + tamanho: e o tamanho total de linhas que irao ser geradas dinamicamente correspondente as entradas do respectivo projeto. o valor varia dentre o tamanho das rubricas + + nomeVariavel: variável utilizada para criar o nomes das variaveis dinamicamente para não haver sobreposição de estilos com o mesmo nome. Esses estilos ocorrem nesses codigos: + 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"'.... + nomeTabela: variável utilizada para a criação do nome da tabela.Ela deriva das rubricas que são colocadas no input quando essa função e chamada. + stringTamanho: refere-se aonde esta localizado a string brasilia na pagina Receita e despesa para a referencias das formulas. + + ''' + if tamanho == 0: + tamanho = 1 + + nomeVariavel = f'Diaria' + nomeSheet=nomeVariavel + random_number = random.randint(1, 10000) + nomeVariavel = f'{nomeVariavel}{random_number}' + caminho = pegar_caminho(tabela) + workbook = openpyxl.load_workbook(caminho) + worksheet = workbook['Elemento de Despesa 33'] + size = tamanho + 16 + cinza = "d9d9d9" + cinza_escuro = "bfbfbf" + azul = "336394" + azul_claro = 'ccffff' + + + # 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 = 45 + worksheet.column_dimensions['b'].width = 35 + worksheet.column_dimensions['c'].width = 35 + worksheet.column_dimensions['d'].width = 45#descrição + worksheet.column_dimensions['e'].width = 45 #n do recibo ou qeuivalente + worksheet.column_dimensions['f'].width = 35 #data de emissão + worksheet.column_dimensions['g'].width = 35 #data de emissão + worksheet.column_dimensions['h'].width = 35 #data de emissão + worksheet.column_dimensions['i'].width = 35 #data de emissão + worksheet.column_dimensions['j'].width = 35 #data de emissão + worksheet.column_dimensions['k'].width = 35 #data de emissão + worksheet.column_dimensions['l'].width = 35 #data de emissão + + + #cabecario relação de pagamentos - outro servicoes de terceiros + worksheet.merge_cells('A1:L1') + worksheet['A1'] = f'ANEXO 4' + worksheet['A1'].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet['A1'].alignment = Alignment(horizontal="center",vertical="center") + #RELAÇÃO DE PAGAMENTOS + worksheet.merge_cells('A2:L2') + + worksheet['A2'] = f'RELAÇÃO DE PAGAMENTOS' + worksheet['A2'].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet['A2'].alignment = Alignment(horizontal="center",vertical="center") + + #ElementosdeDespesa + + + worksheet['A11'] = f'Elemento de Despesa' + worksheet['A11'].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet['A11'].alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + + #ElementosdeDespesa + + + worksheet['A14'] = f'DESPESAS REALIZADAS' + worksheet['A14'].font = Font(name="Arial", size=12, color="000000",bold=True,italic=True) + worksheet['A14'].alignment = Alignment(horizontal="center",vertical="center") + + + + #cabecario que recebe de referencia as celulas A da planilha DEMOSTR. RECEITA E DESPESA A.2 + + + worksheet['A4'] = "='DEMOSTR. RECEITA E DESPESA A.2'!A4" + worksheet['A4'].font = Font(name="Arial", size=12, color="000000") + worksheet['A4'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet['A5'] = "='DEMOSTR. RECEITA E DESPESA A.2'!A5" + worksheet['A5'].font = Font(name="Arial", size=12, color="000000") + worksheet['A5'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet['A6'] = "='DEMOSTR. RECEITA E DESPESA A.2'!A6" + worksheet['A6'].font = Font(name="Arial", size=12, color="000000") + worksheet['A6'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet['A7'] = "='DEMOSTR. RECEITA E DESPESA A.2'!A7" + worksheet['A7'].font = Font(name="Arial", size=12, color="000000") + worksheet['A7'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet['A8'] = "='DEMOSTR. RECEITA E DESPESA A.2'!A8" + worksheet['A8'].font = Font(name="Arial", size=12, color="000000") + worksheet['A8'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet['A9'] = "='DEMOSTR. RECEITA E DESPESA A.2'!A9" + worksheet['A9'].font = Font(name="Arial", size=12, color="000000") + worksheet['A9'].alignment = Alignment(horizontal="left",vertical="center") + + + + #cabecario que recebe de referencia as celulas C da planilha DEMOSTR. RECEITA E DESPESA A.2 + + worksheet['C5'] = "='DEMOSTR. RECEITA E DESPESA A.2'!C5" + worksheet['C5'].font = Font(name="Arial", size=12, color="000000") + worksheet['C5'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet['C6'] = "='DEMOSTR. RECEITA E DESPESA A.2'!C6" + worksheet['C6'].font = Font(name="Arial", size=12, color="000000") + worksheet['C6'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet['C7'] = "='DEMOSTR. RECEITA E DESPESA A.2'!C7" + worksheet['C7'].font = Font(name="Arial", size=12, color="000000") + worksheet['C7'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet['C8'] = "='DEMOSTR. RECEITA E DESPESA A.2'!C8" + worksheet['C8'].font = Font(name="Arial", size=12, color="000000") + worksheet['C8'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet['C9'] = "='DEMOSTR. RECEITA E DESPESA A.2'!C9" + worksheet['C9'].font = Font(name="Arial", size=12, color="000000") + worksheet['C9'].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="000000",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="double") ,bottom=Side(border_style="hair"), right=Side(border_style="hair"),left=Side(border_style='hair') ) + locals()[input2].height = 20 + + linha_number = 15 + for row in worksheet.iter_rows(min_row=linha_number, max_row=linha_number, min_col=1, max_col=12): + for cell in row: + cell.style = locals()[input2] + if cell.column == 12: + cell.border = Border(top=Side(border_style="double") ,bottom=Side(border_style="thin"), right=Side(border_style="double") ) + cell.fill = openpyxl.styles.PatternFill(start_color=azul_claro, end_color=azul_claro, fill_type='solid') + + + + valores = ["Nº DE ORDEM","CREDOR","CNPJ/CPF",'BENEFICIÁRIO','CPF DO BENEFICIÁRIO','TRECHO',"Equivalência na Relação de Itens Apoiados",'Nº DA NOTA FISCAL OU EQUIVALENTE','DATA DA NOTA FISCAL','Nº DO CHEQUE OU EQUIVALENTE','DATA DA COMPENSAÇÃO DO CHEQUE','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=15, max_row=size, min_col=1, max_col=12): + 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) + + + value_to_stop = size + start_row = 10 + + #estilo mascara de dinheiro + for row in range(start_row,size+1): + cell = worksheet[f'L{row}'] + cell.style = locals()[input3] + + #estilocinzasimcinzanao + for rows in worksheet.iter_rows(min_row=16, max_row=size, min_col=1, max_col=12): + 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") ) + + + + if cell.column == 12: + 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="double") ,bottom=Side(border_style="hair") ) + if cell.row == size: + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,right =Side(border_style="double") ,bottom=Side(border_style="hair") ) + + #double em cima double total + + #bordinha double + stringAfinarCelula =size+2 + cellborda = f"L{size+1}" + bordacell = worksheet[cellborda] + bordacell.border = Border(right =Side(border_style="double")) + + + #subtotal + worksheet.row_dimensions[size+2].height = 6 + celulas_mergidas_subtotal = f"A{size+2}:K{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="thin") ,right =Side(border_style="thin") ,bottom=Side(border_style="double") ) + + worksheet.row_dimensions[size+2].height = 56.25 + + # FORMULATOTAL + formula = f"=SUM(L16:L{size})" + celula = f'L{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="double") ,bottom=Side(border_style="double") ) + 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="000000",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="double") ,bottom=Side(border_style="hair"),right=Side(border_style='hair'),left=Side(border_style='hair') ) + + + row_number = size + 4 + + for column in range(1, 13): + cell = worksheet.cell(row=row_number, column=column) + cell.style = locals()[input4] + if cell.column == 12: + cell.border = Border(top=Side(border_style="double") ,right =Side(border_style="double") ,bottom=Side(border_style="hair") ) + + + # A B C D E F G H I J K L + values = ["Nº DE ORDEM","RESTITUIDOR","CNPJ/CPF","BENEFICIÁRIO",'CPF DO BENEFICIÁRIO','TRECHO',"Equivalência na Relação de Itens Apoiados","CHEQUE OU EQUIVALENTE ESTORNADO",'DATA DO CHEQUE','Nº DO DEPÓSITO','DATA DO DEPÓSITO','VALOR'] + coluna = 1 + for a,b in enumerate(values): + worksheet.cell(row=row_number, column=coluna, value=b) + coluna = coluna + 1 + + + + + #estorno + + for rows in worksheet.iter_rows(min_row=size+5, max_row=size+4+tamanhoestorno, min_col=1, max_col=12): + for cell in rows: + if cell.row % 2: + cell.fill = PatternFill(start_color=cinza, end_color=cinza, + fill_type = "solid") + + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,right =Side(border_style="hair") ,bottom=Side(border_style="hair")) + if cell.row == size+4+tamanhoestorno: + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,right =Side(border_style="hair") ,bottom=Side(border_style="hair")) + + if cell.column == 12: + cell.number_format = 'R$ #,##0.00' + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,right =Side(border_style="double") ,bottom=Side(border_style="hair")) + if cell.row == size+4+tamanhoestorno: + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,right =Side(border_style="double") ,bottom=Side(border_style="hair")) + + + + #bordas,corsimcornao,money + # Set the height of each row to 60 + for row in worksheet.iter_rows(min_row=size+4, max_row=size+4+tamanhoestorno): + worksheet.row_dimensions[row[0].row].height = 60 + + min_row = size + 4 + max_row = size + 4 + tamanhoestorno + + + + #bordinha double + stringAfinarCelula = size + 6 +tamanhoestorno + cellborda = f"L{size + 5 +tamanhoestorno}" + bordacell = worksheet[cellborda] + bordacell.border = Border(right =Side(border_style="double")) + + #subtotal2 + sub_total2_row = size + 6 +tamanhoestorno + subtotal_merge_cells= f'A{sub_total2_row}:K{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="thin") ,left = Side(border_style="thin") ,right =Side(border_style="hair") ,bottom=Side(border_style="hair") ) + + sub_formula_row_celula = f'L{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].value = f'=SUM(L{size+5}:L{sub_total2_row-1})' + + 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="double") ,bottom=Side(border_style="thin") ) + + #total1-2 + total12_row = size + 7 + tamanhoestorno + total12_merge_cells = f'A{total12_row}:K{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="thin") ,left = Side(border_style="hair") ,bottom=Side(border_style="double"),right=Side(border_style="thin") ) + + + #total_formula + total_formula_row = size + 7 + tamanhoestorno + total_formulaa = f'=L{size+2} - L{sub_total2_row }' + total_formula_row_celula = f'L{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(bottom=Side(border_style="double"),right=Side(border_style="double") ) + + worksheet.row_dimensions[total_formula_row].height = 30 + worksheet[total_formula_row_celula] = total_formulaa + + + size = size + 1 + #brasilia + brasilia_row = size + 8 +tamanhoestorno + brasilia_formula = f"='DEMOSTR. RECEITA E DESPESA A.2'!A{stringTamanho}" + brasilia_merge_cells = f'A{brasilia_row}:K{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") + top_left_brasilia_cell.font = Font(name="Arial", size=12, color="000000") + + #DiretorFinanceiro + diretor_row = size + 9 + tamanhoestorno + diretor_cargo_row = size + 10 + tamanhoestorno + diretor_cpf_row = size + 11 + tamanhoestorno + + diretor_nome_formula = f"='DEMOSTR. RECEITA E DESPESA A.2'!A{stringTamanho+3}" + diretor_cargo_formula = f"='DEMOSTR. RECEITA E DESPESA A.2'!A{stringTamanho+4}" + diretor_cpf_formula = f"='DEMOSTR. RECEITA E DESPESA A.2'!A{stringTamanho+5}" + diretor_merge_cells = f'A{diretor_row}:F{diretor_row}' + diretor_cargo_merge_cells = f'A{diretor_cargo_row}:F{diretor_cargo_row}' + diretor_cpf_merge_cells = f'A{diretor_cpf_row}:F{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 + 9 + tamanhoestorno + coordenadora_cargo_row = size + 10 + tamanhoestorno + coordenadora_cpf_row = size + 11 + tamanhoestorno + coordenadora_nome_formula = f"='DEMOSTR. RECEITA E DESPESA A.2'!C{stringTamanho+3}" + coordenadora_cargo_formula = f"='DEMOSTR. RECEITA E DESPESA A.2'!C{stringTamanho+4}" + coordenadora_cpf_formula = f"='DEMOSTR. RECEITA E DESPESA A.2'!C{stringTamanho+5}" + coordenadora_merge_cells = f'G{coordenadora_row}:L{coordenadora_row}' + coordenadora_cargo_merge_cells = f'G{coordenadora_cargo_row}:L{coordenadora_cargo_row}' + coordenadora_cpf_merge_cells = f'G{coordenadora_cpf_row}:L{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'G{coordenadora_row}' + top_left_coordenadora_cell_cargo_formula = f'G{coordenadora_cargo_row}' + top_left_coordenadora_cell_cpf_formula = f'G{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(name="Arial", size=12, color="000000",bold = True) + top_left_coordenadora_cell_cargo_formula.alignment = Alignment(horizontal="center",vertical="center") + top_left_coordenadora_cell_cargo_formula.font = Font(name="Arial", size=12, color="000000") + top_left_coordenadora_cell_cpf_formula.alignment = Alignment(horizontal="center",vertical="center") + top_left_coordenadora_cell_cpf_formula.font= Font(name="Arial", size=12, color="000000") + + + # 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=9): + # for cell in row: + # cell.border = borda + + for row in worksheet.iter_rows(min_row=linha_number, max_row=linha_number, min_col=12, max_col=12): + for cell in row: + cell.border = Border(top=Side(border_style="double") ,bottom=Side(border_style="hair"), right=Side(border_style="double") ) + cell.fill = openpyxl.styles.PatternFill(start_color=azul_claro, end_color=azul_claro, fill_type='solid') + cell.font = Font(name="Arial", size=12, color="000000",bold=True) + + cinzaborda = '9e9e9e' + + #borda cabeçario + for row in worksheet.iter_rows(min_row=1, max_row=14,min_col=12,max_col=12): + for cell in row: + cell.border = Border(top=Side(border_style="none") ,right = Side(border_style="thin",color='9e9e9e') ,left =Side(border_style="none") ,bottom=Side(border_style="none") ) + + #borda fim pagina + for row in worksheet.iter_rows(min_row=brasilia_row -1, max_row=coordenadora_cpf_row+1,min_col=12,max_col=12): + for cell in row: + cell.border = Border(top=Side(border_style="none") ,right = Side(border_style="thin",color='9e9e9e') ,left =Side(border_style="none") ,bottom=Side(border_style="none") ) + + + + for row in worksheet.iter_rows(min_row=coordenadora_cpf_row+1, max_row=coordenadora_cpf_row+1,min_col=1,max_col=12): + for cell in row: + if cell.column == 12: + cell.border = Border(top=Side(border_style="none") ,left = Side(border_style="none") ,right =Side(border_style="thin",color='9e9e9e') ,bottom=Side(border_style="thin",color='9e9e9e') ) + else: + cell.border = Border(top=Side(border_style="none") ,left = Side(border_style="none") ,right =Side(border_style="none") ,bottom=Side(border_style="thin",color='9e9e9e') ) + + workbook.save(tabela) + workbook.close() + + return size+4 + +def estilo_conciliacoes_bancaria(tabela,tamanho,tamanho2,stringTamanho): + """Estilo um pouco diferente pois necessita de dois aspectos dinâmicos que é primeiramente a quantidade de entradas de pagamento de tarifas bancárias e por fim a quantidade de estorno. Sabendo + esses valores é possivel criar a tabela. + + Argumentos: + tabela: recebe o arquivo correspondente a tabela Fub extensão xlsx. Esse arquivo foi iniciado e passou pela preencher fub mas ainda está sem o estilo que será aplicado nessa função. + tamanho:Corresponde ao tamanho das quantidade de transfêrencia bancárias realizada. + tamanho2:Corresponde ao tamanho dos estornos. + stringTamanho: refere-se aonde esta localizado a string brasilia na pagina Receita e despesa para a referências das formulas. + """ + if tamanho == 0: + tamanho = 1 + #pegar o arquivo e carregar ele um worksheet da pagaina Conciliação Bancária + caminho = pegar_caminho(tabela) + workbook = openpyxl.load_workbook(caminho) + worksheet = workbook['Conciliação Bancária A.3'] + + #size e o tamanho da quantidade de arquivos recebido no argumento tamanho mais o tamanho do cabecario que no caso da fub e de 16 + size = tamanho + 18 + cinza = "d9d9d9" + cinza_escuro = "bfbfbf" + + azul_claro = 'ccffff' + + #Borda apenas do lado direito da cedula, uma borda mas larga + borda = Border(right=Side(border_style="medium")) + worksheet.sheet_view.showGridLines = False + # + + + + worksheet.column_dimensions['a'].width =69 + worksheet.column_dimensions['b'].width = 20 + worksheet.column_dimensions['c'].width = 20 + + + #cabecario relação de pagamentos - outro servicoes de terceiros + worksheet.merge_cells('A1:C1') + worksheet['A1'] = f'ANEXO 3' + worksheet['A1'].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet['A1'].alignment = Alignment(horizontal="center",vertical="center") + + worksheet.merge_cells('A2:C2') + worksheet['A2'] = f'CONCILIAÇÃO BANCÁRIA' + worksheet['A2'].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet['A2'].alignment = Alignment(horizontal="center",vertical="center") + + #cabecario que recebe de referencia as celulas A da planilha DEMOSTR. RECEITA E DESPESA A.2 + + + worksheet['A4'] = "='DEMOSTR. RECEITA E DESPESA A.2'!A4" + worksheet['A4'].font = Font(name="Arial", size=12, color="000000") + worksheet['A4'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet['A5'] = "='DEMOSTR. RECEITA E DESPESA A.2'!A5" + worksheet['A5'].font = Font(name="Arial", size=12, color="000000") + worksheet['A5'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet['A6'] = "='DEMOSTR. RECEITA E DESPESA A.2'!A6" + worksheet['A6'].font = Font(name="Arial", size=12, color="000000") + worksheet['A6'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet['A7'] = "='DEMOSTR. RECEITA E DESPESA A.2'!A7" + worksheet['A7'].font = Font(name="Arial", size=12, color="000000") + worksheet['A7'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet['A8'] = "='DEMOSTR. RECEITA E DESPESA A.2'!A8" + worksheet['A8'].font = Font(name="Arial", size=12, color="000000") + worksheet['A8'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet['A9'] = "='DEMOSTR. RECEITA E DESPESA A.2'!A9" + worksheet['A9'].font = Font(name="Arial", size=12, color="000000") + worksheet['A9'].alignment = Alignment(horizontal="left",vertical="center") + + + + #cabecario que recebe de referencia as celulas C da planilha DEMOSTR. RECEITA E DESPESA A.2 + + worksheet['B5'] = "='DEMOSTR. RECEITA E DESPESA A.2'!C5" + worksheet['B5'].font = Font(name="Arial", size=12, color="000000") + worksheet['B5'].alignment = Alignment(horizontal="left",vertical="center",wrap_text=True) + worksheet.merge_cells('B5:C5') + worksheet['B6'] = "='DEMOSTR. RECEITA E DESPESA A.2'!C6" + worksheet['B6'].font = Font(name="Arial", size=12, color="000000") + worksheet['B6'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet['B7'] = "='DEMOSTR. RECEITA E DESPESA A.2'!C7" + worksheet['B7'].font = Font(name="Arial", size=12, color="000000") + worksheet['B7'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet['B8'] = "='DEMOSTR. RECEITA E DESPESA A.2'!C8" + worksheet['B8'].font = Font(name="Arial", size=12, color="000000") + worksheet['B8'].alignment = Alignment(horizontal="left",vertical="center",wrap_text=True) + + worksheet['B9'] = "='DEMOSTR. RECEITA E DESPESA A.2'!C9" + worksheet['B9'].font = Font(name="Arial", size=12, color="000000") + worksheet['B9'].alignment = Alignment(horizontal="left",vertical="center",wrap_text=True) + + + + + worksheet['A11'] = 'A. SALDO CONFORME EXTRATOS BANCÁRIOS NA DATA FINAL DO PERÍODO' + worksheet['A11'].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet['A11'].alignment = Alignment(horizontal="left",vertical="center") + worksheet['A11'].fill = PatternFill(start_color=azul_claro, end_color=azul_claro,fill_type = "solid") + worksheet['A11'].border = Border(top=Side(border_style="medium"),bottom=Side(border_style="hair"),right=Side(border_style='medium')) + worksheet.merge_cells('A11:C11') + + + worksheet['A12'] = 'DISCRIMINAÇÃO' + worksheet['A12'].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet['A12'].alignment = Alignment(horizontal="center",vertical="center") + worksheet['A12'].border = Border(bottom=Side(border_style="hair"),right=Side(border_style='hair')) + worksheet.merge_cells('A12:B12') + + worksheet['C12'] = 'VALOR' + worksheet['C12'].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet['C12'].alignment = Alignment(horizontal="center",vertical="center") + worksheet['C12'].border = Border(bottom=Side(border_style="hair"),right=Side(border_style='hair')) + worksheet['C13'].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet['C13'].alignment = Alignment(horizontal="left",vertical="center") + worksheet['C13'].border = Border(bottom=Side(border_style="hair"),right=Side(border_style='hair')) + worksheet['C14'].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet['C14'].alignment = Alignment(horizontal="left",vertical="center") + worksheet['C14'].border = Border(bottom=Side(border_style="hair"),right=Side(border_style='hair')) + + + worksheet['A13'] = 'a)Saldo de Conta Corrente(R$)' + worksheet['A13'].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet['A13'].alignment = Alignment(horizontal="left",vertical="center") + worksheet['A13'].border = Border(bottom=Side(border_style="hair"),right=Side(border_style='hair')) + worksheet.merge_cells('A13:B13') + + + worksheet['A14'] = 'b)Saldo de Aplicações Financeiras(R$)' + worksheet['A14'].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet['A14'].alignment = Alignment(horizontal="left",vertical="center") + worksheet['A14'].border = Border(bottom=Side(border_style="hair"),right=Side(border_style='hair')) + worksheet.merge_cells('A14:B14') + + + worksheet['A15'] = 'c) TOTAL (a+b)' + worksheet['A15'].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet['A15'].alignment = Alignment(horizontal="left",vertical="center") + worksheet['A15'].border = Border(bottom=Side(border_style="medium"),right=Side(border_style='thin'),left=Side(border_style='thin'),top=Side(border_style="thin")) + worksheet['A15'].fill = PatternFill(start_color=cinza, end_color=cinza,fill_type = "solid") + + worksheet.merge_cells('A15:B15') + + worksheet['C15'].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet['C15'].alignment = Alignment(horizontal="left",vertical="center") + worksheet['C15'].border = Border(bottom=Side(border_style="medium"),right=Side(border_style='medium'),left=Side(border_style='thin'),top=Side(border_style='thin')) + worksheet['C15'].fill = PatternFill(start_color=cinza, end_color=cinza,fill_type = "solid") + + + + + worksheet['A16'].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet['A16'].alignment = Alignment(horizontal="left",vertical="center") + worksheet['A16'].border = Border(bottom=Side(border_style="medium"),right=Side(border_style='medium'),top=Side(border_style='medium')) + worksheet.merge_cells('A16:C16') + + + + worksheet['A17'] = 'B. RESTUIÇÕES NÃO CREDITADAS ATÉ A DATA FINAL DESTA PRESTAÇÃO DE CONTAS' + worksheet['A17'].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet['A17'].alignment = Alignment(horizontal="left",vertical="center") + worksheet['A17'].border = Border(bottom=Side(border_style="medium"),right=Side(border_style='medium'),left=Side(border_style='thin'),top=Side(border_style='medium')) + worksheet['A17'].fill = PatternFill(start_color=azul_claro, end_color=azul_claro,fill_type = "solid") + worksheet.merge_cells('A17:C17') + + + + random_number = random.randint(1, 10000) + + custom_number_format_conciliacoes = [] + # MASCARA R$ + if custom_number_format_conciliacoes!= False: + custom_number_format_conciliacoes = NamedStyle(name=f'custom_number_format_conciliacoes{random_number}') + 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 = 19 + for row in range(start_row,size + tamanho2+ 7): + cell = worksheet[f'C{row}'] + cell.style = custom_number_format_conciliacoes + + for rows in worksheet.iter_rows(min_row=18, max_row=size, min_col=1, max_col=3): + for cell in rows: + if not 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(bottom=Side(border_style="hair"),right=Side(border_style='hair'),top=Side(border_style='hair'),left=Side(border_style='hair')) + + + row_number = 18 + values = ['Descrição',"Data","Valor"] + coluna = 1 + for a,b in enumerate(values): + worksheet.cell(row=row_number, column=coluna, value=b) + + coluna = coluna + 1 + + # FORMULATOTAL + if size > 18: + formula = f"=SUM(C19:C{size-1})" + else: + formula = f"=SUM(C17:C18)" + size = size +1 + celula = f'C{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) + worksheet[celula].border = Border(bottom=Side(border_style="medium"),right=Side(border_style='medium'),top=Side(border_style='medium'),left=Side(border_style='medium')) + + #Total + celula_total_merge = f'A{size}:B{size}' + celula_total = F'A{size}' + worksheet.row_dimensions[size].height = 38 + worksheet.row_dimensions[size-1].height = 3 + worksheet[celula_total] = f'd)TOTAL' + worksheet[celula_total].fill = PatternFill(start_color=cinza, end_color=cinza,fill_type = "solid") + worksheet[celula_total].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet[celula_total].alignment = Alignment(horizontal="center",vertical="center") + worksheet[celula_total].border = Border(bottom=Side(border_style="medium"),right=Side(border_style='medium'),top=Side(border_style='medium'),left=Side(border_style='medium')) + worksheet.merge_cells(celula_total_merge) + #'3. Restituições não creditadas pelo banco até a data final do período' + string_reituicoes_creditadas = f'A{size+2}:C{size+2}' + row_creditadas = f'A{size+2}' + + worksheet[row_creditadas] = 'C. VALORES NÃO DEBITADOS ATÉ A DATA FINAL DESTA PRESTAÇÃO DE CONTAS' + worksheet[row_creditadas].font = Font(name="Arial", size=12, color="000000",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") + worksheet[row_creditadas].border = Border(top=Side(border_style='medium')) + worksheet.merge_cells(string_reituicoes_creditadas) + + #data valor documento descrição + row_number = size+3 + values = ['Descrição',"Data","Valor"] + 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=18, max_row=18, min_col=1, max_col=3): + 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=3): + 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'C{row}'] + cell.style = custom_number_format_conciliacoes + + for rows in worksheet.iter_rows(min_row=size+3, max_row=size+3+tamanho2, min_col=1, max_col=3): + 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(bottom=Side(border_style="hair"),right=Side(border_style='hair'),top=Side(border_style='hair'),left=Side(border_style='hair')) + + + + # FORMULATOTALrestituição + formula = f"=SUM(C{size+4}:C{size+tamanho2+3})" + celula = f'C{size+tamanho2+5}' + 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(bottom=Side(border_style="medium"),right=Side(border_style='medium'),top=Side(border_style='medium'),left=Side(border_style='medium')) + + #Total + celula_total = F'A{size+tamanho2+5}' + string_celula_total= f'A{size+tamanho2+5}:B{size+tamanho2+5}' + worksheet[celula_total].alignment = Alignment(horizontal="center",vertical="center") + worksheet[celula_total] = f'e) TOTAL' + worksheet.row_dimensions[size+tamanho2+5].height = 38 + worksheet.row_dimensions[size+tamanho2+4].height = 3 + worksheet[celula_total].fill = PatternFill(start_color=cinza, end_color=cinza,fill_type = "solid") + worksheet[celula_total].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet[celula_total].border = Border(bottom=Side(border_style="medium"),right=Side(border_style='medium'),top=Side(border_style='medium'),left=Side(border_style='medium')) + worksheet.merge_cells(string_celula_total) + + #Saldo disponível p/ período seguinte (1 +2 - 3) + string_saldo_disponivel = f'A{size+3+tamanho2+3}:B{size+3+tamanho2+3}' + celula_string_saldo = f'A{size+tamanho2+6}' + worksheet.row_dimensions[size+tamanho2+6].height = 30 + worksheet[celula_string_saldo].fill = PatternFill(start_color=azul_claro, end_color=azul_claro,fill_type = "solid") + worksheet[celula_string_saldo].alignment = Alignment(horizontal="left",vertical="center") + worksheet[celula_string_saldo].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet[celula_string_saldo]= f'D. SALDO CONTÁBIL (c+d-e)' + worksheet[celula_string_saldo].border = Border(bottom=Side(border_style="medium"),right=Side(border_style='medium'),top=Side(border_style='medium'),left=Side(border_style='medium')) + worksheet.merge_cells(string_saldo_disponivel) + + #total saldo diposnivel + + celula_string_total = f'C{size+tamanho2+6}' + saldodiposnivelformat_conciliacoes = NamedStyle(name=f'saldodiposnivelformat_conciliacoes{random_number}') + 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, end_color=cinza,fill_type = "solid") + saldodiposnivelformat_conciliacoes.border = Border(bottom=Side(border_style="medium"),right=Side(border_style='medium'),top=Side(border_style='medium'),left=Side(border_style='medium')) + + celular = worksheet[celula_string_total] + celular.style = saldodiposnivelformat_conciliacoes + celular.value = f'=C15+C{size} - C{size+tamanho2+5}'#corrigir + # #saldo anterior + # formula = f"Saldo anterior" + # celula = f'A16' + # worksheet[celula] = formula + # worksheet[celula].font = Font(name="Arial", size=12, color="000000") + + # formula = f"Diversos" + # celula = f'C16' + # worksheet[celula] = formula + # worksheet[celula].font = Font(name="Arial", size=12, color="000000") + + # formula = f"Tarifas Prestações Anteriores" + # celula = f'D16' + # worksheet[celula] = formula + # worksheet[celula].font = Font(name="Arial", size=12, color="000000") + + #brasilia + brasilia_row = size + tamanho2+ 8 + brasilia_formula = f"='DEMOSTR. RECEITA E DESPESA A.2'!A{stringTamanho}" + brasilia_merge_cells = f'A{brasilia_row}:C{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") + top_left_brasilia_cell.font = Font(name="Arial", size=12, color="000000") + + # #DiretorFinanceiro + diretor_row = size + 10 + tamanho2 + diretor_cargo_row = size + 11 + tamanho2 + diretor_cpf_row = size + 12 + tamanho2 + + diretor_nome_formula = f"='DEMOSTR. RECEITA E DESPESA A.2'!A{stringTamanho+3}" + diretor_cargo_formula = f"='DEMOSTR. RECEITA E DESPESA A.2'!A{stringTamanho+4}" + diretor_cpf_formula = f"='DEMOSTR. RECEITA E DESPESA A.2'!A{stringTamanho+5}" + # 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 = diretor_row + coordenadora_cargo_row = diretor_cargo_row + coordenadora_cpf_row = diretor_cpf_row + coordenadora_nome_formula = f"='DEMOSTR. RECEITA E DESPESA A.2'!C{stringTamanho+3}" + coordenadora_cargo_formula = f"='DEMOSTR. RECEITA E DESPESA A.2'!C{stringTamanho+4}" + coordenadora_cpf_formula = f"='DEMOSTR. RECEITA E DESPESA A.2'!C{stringTamanho+5}" + coordenadora_merge_cells = f'B{coordenadora_row}:C{coordenadora_row}' + coordenadora_cargo_merge_cells = f'B{coordenadora_cargo_row}:C{coordenadora_cargo_row}' + coordenadora_cpf_merge_cells = f'B{coordenadora_cpf_row}:C{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'B{coordenadora_row}' + top_left_coordenadora_cell_cargo_formula = f'B{coordenadora_cargo_row}' + top_left_coordenadora_cell_cpf_formula = f'B{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.border = borda + top_left_coordenadora_cell.alignment = Alignment(horizontal="center",vertical="center") + top_left_coordenadora_cell.font= Font(name="Arial", size=12, color="000000",bold = True) + top_left_coordenadora_cell_cargo_formula.alignment = Alignment(horizontal="center",vertical="center") + top_left_coordenadora_cell_cargo_formula.font = Font(name="Arial", size=12, color="000000") + top_left_coordenadora_cell_cpf_formula.alignment = Alignment(horizontal="center",vertical="center") + top_left_coordenadora_cell_cpf_formula.font= Font(name="Arial", size=12, color="000000") + + #borda cabeçario + for row in worksheet.iter_rows(min_row=1, max_row=10,min_col=3,max_col=3): + for cell in row: + cell.border = Border(top=Side(border_style="none") ,right = Side(border_style="thin",color='9e9e9e') ,left =Side(border_style="none") ,bottom=Side(border_style="none") ) + + #borda fim pagina + for row in worksheet.iter_rows(min_row=brasilia_row-1, max_row=coordenadora_cpf_row+1,min_col=3,max_col=3): + for cell in row: + cell.border = Border(top=Side(border_style="none") ,right = Side(border_style="thin",color='9e9e9e') ,left =Side(border_style="none") ,bottom=Side(border_style="none") ) + + #borda pagina + for row in worksheet.iter_rows(min_row=11, max_row=brasilia_row-2,min_col=4,max_col=4): + for cell in row: + cell.border = Border(top=Side(border_style="none") ,right = Side(border_style="none") ,left =Side(border_style="medium") ,bottom=Side(border_style="none") ) + + + # + for row in worksheet.iter_rows(min_row=coordenadora_cpf_row+1, max_row=coordenadora_cpf_row+1,min_col=1,max_col=3): + for cell in row: + if cell.column == 3: + cell.border = Border(top=Side(border_style="none") ,left = Side(border_style="none") ,right =Side(border_style="thin",color='9e9e9e') ,bottom=Side(border_style="thin",color='9e9e9e') ) + else: + cell.border = Border(top=Side(border_style="none") ,left = Side(border_style="none") ,right =Side(border_style="none") ,bottom=Side(border_style="thin",color='9e9e9e') ) + + for rows in worksheet.iter_rows(min_row=size+3, max_row=size+3, min_col=1, max_col=3): + for cell in rows: + cell.font = Font(name="Arial", size=12, color="000000",bold=True) + + worksheet['B5'].alignment = Alignment(horizontal="left",vertical="center",wrap_text=True) + workbook.save(tabela) + workbook.close() + + return size +4 + +def estilo_rendimento_de_aplicacao(tabela,tamanho,stringTamanho): + """Estilo da rendimento de aplicação, tabela com as colunas periodo, saldo anterior,valor aplicado no período,valor resgatado no período,rendimento bruto,imposto,rendimento luiquido,saldo. + + Argumentos: + tabela: recebe o arquivo correspondente a tabela Fub extensão xlsx. Esse arquivo foi iniciado e passou pela preencher fub mas ainda está sem o estilo que será aplicado nessa função. + tamanho:Corresponde ao tamanho das quantidade da tabela de rencimentos. + stringTamanho: refere-se aonde esta localizado a string brasilia na pagina Receita e despesa para a referências das formulas. + """ + if tamanho == 0: + tamanho = 1 + caminho = pegar_caminho(tabela) + workbook = openpyxl.load_workbook(caminho) + worksheet = workbook['Rendimento de Aplicação'] + + random_number = random.randint(1, 10000) + size = tamanho + 14 + worksheet.row_dimensions[2].height = 48 + worksheet.row_dimensions[1].height = 48 + testeRow = 15; + + cinza = "d9d9d9" + cinza_escuro = "bfbfbf" + azul = "336394" + azul_claro = '1c8cbc' + borda = Border(right=Side(border_style="medium")) + worksheet.sheet_view.showGridLines = False + + #imagensfinep + + image_names = [ + 'Finep.png', + + ] + + # Path to the images + path = "/imagemFinep/" + + # List to hold Image objects + images = [] + + nomePasta = "../../imagemFinep" + diretorio = os.path.dirname(__file__) + + # Loop through the list of image names and create Image objects + for i, name in enumerate(image_names): + caminhoImage = os.path.join(diretorio, nomePasta, name) + pil_image = PILImage.open(caminhoImage) + pil_image.save(caminhoImage) + img = Image(caminhoImage) + images.append(img) + + + + worksheet.add_image(images[0], "A1")# FINEP + + + + 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'Demonstrativo dos Ganhos Auferidos com Aplicações ' + worksheet['A1'].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet['A1'].alignment = Alignment(horizontal="center",vertical="center") + + #unidade executora + + worksheet['A3'] = "Unidade Executora:" + worksheet['A3'].font = Font(name="Arial", size=12, color="000000") + worksheet['A3'].alignment = Alignment(horizontal="left",vertical="center") + worksheet['A3'].fill = openpyxl.styles.PatternFill(start_color=cinza_escuro, end_color=cinza_escuro, fill_type='solid') + worksheet['A3'].border = Border(top=Side(border_style="double")) + worksheet.merge_cells('A3:F3') + + worksheet['A4'] = "FINATEC - Fundação de Empreendimentos Científicos e Tecnológicos" + worksheet['A4'].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet['A4'].alignment = Alignment(horizontal="left",vertical="center") + worksheet['A4'].fill = openpyxl.styles.PatternFill(start_color=cinza_escuro, end_color=cinza_escuro, fill_type='solid') + + + + #convenio + worksheet['G3'] = "Convênio Nº: " + worksheet['G3'].font = Font(name="Arial", size=12, color="000000") + worksheet['G3'].alignment = Alignment(horizontal="left",vertical="center") + worksheet['G3'].fill = openpyxl.styles.PatternFill(start_color=cinza_escuro, end_color=cinza_escuro, fill_type='solid') + worksheet['G3'].border = Border(right=Side(border_style="double"),top=Side(border_style="double")) + worksheet.merge_cells('G3:H3') + #convenio + worksheet['G4'] = "='Capa Finatec'!E17" + worksheet['G4'].font = Font(name="Arial", size=12, color="000000") + worksheet['G4'].alignment = Alignment(horizontal="left",vertical="center") + worksheet['G4'].fill = openpyxl.styles.PatternFill(start_color=cinza_escuro, end_color=cinza_escuro, fill_type='solid') + worksheet['G4'].border = Border(right=Side(border_style="double"),top=Side(border_style="double")) + worksheet.merge_cells('G4:H4') + + #projeto + worksheet['A5'] = "Projeto:" + worksheet['A5'].font = Font(name="Arial", size=12, color="000000") + worksheet['A5'].alignment = Alignment(horizontal="left",vertical="center") + worksheet['A5'].fill = openpyxl.styles.PatternFill(start_color=cinza_escuro, end_color=cinza_escuro, fill_type='solid') + worksheet.merge_cells('A5:F5') + + worksheet['A6'] = "='Capa Finatec'!E9" + worksheet['A6'].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet['A6'].alignment = Alignment(horizontal="left",vertical="center",wrap_text=True) + worksheet['A6'].fill = openpyxl.styles.PatternFill(start_color=cinza_escuro, end_color=cinza_escuro, fill_type='solid') + + #Período de Execução do Convênio: + worksheet['G5'] = "Período de Execução do Convênio:" + worksheet['G5'].font = Font(name="Arial", size=12, color="000000") + worksheet['G5'].alignment = Alignment(horizontal="left",vertical="center") + worksheet['G5'].fill = openpyxl.styles.PatternFill(start_color=cinza_escuro, end_color=cinza_escuro, fill_type='solid') + worksheet['G5'].border = Border(right=Side(border_style="double")) + worksheet.merge_cells('G5:H5') + + worksheet['G6'] = "='DEMOSTR. RECEITA E DESPESA A.2'!C6" + worksheet['G6'].font = Font(name="Arial", size=12, color="000000") + worksheet['G6'].alignment = Alignment(horizontal="left",vertical="center") + worksheet['G6'].fill = openpyxl.styles.PatternFill(start_color=cinza_escuro, end_color=cinza_escuro, fill_type='solid') + + #linha 4 + worksheet['A4'].fill = openpyxl.styles.PatternFill(start_color=cinza_escuro, end_color=cinza_escuro, fill_type='solid') + worksheet.merge_cells('A4:F4') + worksheet['G4'].border = Border(right=Side(border_style="double")) + worksheet['G4'].fill = openpyxl.styles.PatternFill(start_color=cinza_escuro, end_color=cinza_escuro, fill_type='solid') + worksheet.merge_cells('G4:H4') + #linha 6 + worksheet['G6'].border = Border(right=Side(border_style="double")) + worksheet['G6'].fill = openpyxl.styles.PatternFill(start_color=cinza_escuro, end_color=cinza_escuro, fill_type='solid') + worksheet.merge_cells('G6:H6') + + #vaireceberinputnopreencher + worksheet['A6'].font = Font(name="Arial", size=12, color="000000") + worksheet['A6'].alignment = Alignment(horizontal="left",vertical="center",wrap_text=True) + worksheet['A6'].fill = openpyxl.styles.PatternFill(start_color=cinza_escuro, end_color=cinza_escuro, fill_type='solid') + worksheet.merge_cells('A6:F7') + + #Período Abrangido por este Relatório: + worksheet['G7'] = "Período Abrangido por este Relatório:" + worksheet['G7'].font = Font(name="Arial", size=12, color="000000") + worksheet['G7'].alignment = Alignment(horizontal="left",vertical="center",wrap_text=True) + worksheet['G7'].fill = openpyxl.styles.PatternFill(start_color=cinza_escuro, end_color=cinza_escuro, fill_type='solid') + worksheet['G7'].border = Border(right=Side(border_style="double")) + worksheet.merge_cells('G7:H7') + + + #barrvazia + worksheet['A8'].font = Font(name="Arial", size=12, color="000000") + worksheet['A8'].alignment = Alignment(horizontal="left",vertical="center") + worksheet['A8'].fill = openpyxl.styles.PatternFill(start_color=cinza_escuro, end_color=cinza_escuro, fill_type='solid') + worksheet['A8'].border = Border(bottom=Side(border_style="double")) + worksheet.merge_cells('A8:F8') + #Período Abrangido por este Relatório: + worksheet['G8'] = "='DEMOSTR. RECEITA E DESPESA A.2'!C7" + worksheet['G8'].font = Font(name="Arial", size=12, color="000000") + worksheet['G8'].alignment = Alignment(horizontal="left",vertical="center") + worksheet['G8'].fill = openpyxl.styles.PatternFill(start_color=cinza_escuro, end_color=cinza_escuro, fill_type='solid') + worksheet['G8'].border = Border(bottom=Side(border_style="double"),right=Side(border_style="double")) + worksheet.merge_cells('G8:H8') + + + worksheet.row_dimensions[9].height = 20 + worksheet.row_dimensions[10].height = 20 + + worksheet.merge_cells('A9:H10') + worksheet['A9'] = f'APLICAÇÃO FINANCEIRA' + worksheet['A9'].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet['A9'].alignment = Alignment(horizontal="center",vertical="center") + + worksheet.row_dimensions[11].height = 20 + worksheet.row_dimensions[12].height = 20 + + + worksheet['A11'] = f'APLICAÇÃO FINANCEIRA - RF REF DI PLUS ÁGIL' + worksheet['A11'].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet['A11'].alignment = Alignment(horizontal="center",vertical="center") + worksheet['A11'].border = Border(bottom=Side(border_style="double"),right=Side(border_style="double"),left=Side(border_style="double"),top=Side(border_style="double")) + worksheet.merge_cells('A11:H12') + + + + worksheet.row_dimensions[13].height = 25 + worksheet.row_dimensions[14].height = 25 + + # #stylecinza + start_row = 11 + for rows in worksheet.iter_rows(min_row=13, max_row=14, min_col=1, max_col=8): + for cell in rows: + if cell.row % 2 == 0: + 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) + cell.fill = PatternFill(start_color=cinza_escuro, end_color=cinza_escuro, + fill_type = "solid") + + #cabcerario abaixo de aplicação financeira + row_number = 13 + 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=13,end_row=14,start_column=i,end_column=i) + + + # #RENDIMENTO LIQUIDO + # # print(size) + for row in worksheet.iter_rows(min_row=testeRow, max_row=size, min_col=7, max_col=7): + for cell in row: + stringSaldo = f"=E{cell.row} - F{cell.row}" + cell.value = stringSaldo + + + + + #BARRAS DE DADOS + start_row = 14 + for rows in worksheet.iter_rows(min_row=testeRow, max_row=size, min_col=1, max_col=8): + for cell in rows: + if cell.row % 2==0: + 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=testeRow, max_row=size-1, min_col=6, max_col=6): + for cell in rows: + cell.font = Font(name="Arial", size=12, color="f90000") + cell.number_format ='#,##0.00' + + #MASCARANEGRITO + for rows in worksheet.iter_rows(min_row=testeRow, 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=6, max_col=6): + # # for cell in rows: + # # cell.font = Font(name="Arial", size=12, color="141fca") + # # cell.number_format ='#,##0.00' + + # # 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) + # # cell.number_format ='#,##0.00' + + + + #barra de totais + formula = f"Saldo anterior" + celula = f'A{testeRow}' + worksheet[celula] = formula + worksheet[celula].font = Font(name="Arial", size=12, color="000000",bold=True) + + + + # FORMULATOTAL + #B + size = size + 1 + formula = f"=SUM(B{testeRow}: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) + worksheet[celula].alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + #C + formula = f"=SUM(C{testeRow}: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) + worksheet[celula].alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + + #D + formula = f"=SUM(D{testeRow}: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) + worksheet[celula].alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + + #E + formula = f"=SUM(E{testeRow}: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) + worksheet[celula].alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + + #F + formula = f"=SUM(F{testeRow}: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) + worksheet[celula].alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + + #G + formula = f"=SUM(G{testeRow}: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) + worksheet[celula].alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + + #H + formula = f"=SUM(H{testeRow}: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) + worksheet[celula].alignment = Alignment(horizontal="center",vertical="center",wrap_text=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) + worksheet[celula].alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + + #borda total + + + + + #brasilia + brasilia_row = size + 2 + brasilia_formula = f"='DEMOSTR. RECEITA E DESPESA A.2'!A{stringTamanho}" + brasilia_merge_cells = f'A{brasilia_row}:H{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") + top_left_brasilia_cell.font = Font(name="Arial", size=12, color="000000") + + # #DiretorFinanceiro + diretor_row = size + 6 + diretor_cargo_row = size + 7 + diretor_cpf_row = size + 8 + diretor_nome_formula = f"='DEMOSTR. RECEITA E DESPESA A.2'!A{stringTamanho+3}" + diretor_cargo_formula = f"='DEMOSTR. RECEITA E DESPESA A.2'!A{stringTamanho+4}" + diretor_cpf_formula = f"='DEMOSTR. RECEITA E DESPESA A.2'!A{stringTamanho+5}" + 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"='DEMOSTR. RECEITA E DESPESA A.2'!C{stringTamanho+3}" + coordenadora_cargo_formula = f"='DEMOSTR. RECEITA E DESPESA A.2'!C{stringTamanho+4}" + coordenadora_cpf_formula = f"='DEMOSTR. RECEITA E DESPESA A.2'!C{stringTamanho+5}" + coordenadora_merge_cells = f'F{coordenadora_row}:H{coordenadora_row}' + coordenadora_cargo_merge_cells = f'F{coordenadora_cargo_row}:H{coordenadora_cargo_row}' + coordenadora_cpf_merge_cells = f'F{coordenadora_cpf_row}:H{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(name="Arial", size=12, color="000000",bold = True) + top_left_coordenadora_cell_cargo_formula.alignment = Alignment(horizontal="center",vertical="center") + top_left_coordenadora_cell_cargo_formula.font = Font(name="Arial", size=12, color="000000") + top_left_coordenadora_cell_cpf_formula.alignment = Alignment(horizontal="center",vertical="center") + top_left_coordenadora_cell_cpf_formula.font= Font(name="Arial", size=12, color="000000") + + for row in worksheet.iter_rows(min_row=15, max_row=brasilia_row-2,min_col=2,max_col=8): + for cell in row: + cell.number_format = 'R$ #,##0.00' + + #borda cabeçario + for row in worksheet.iter_rows(min_row=13, max_row=brasilia_row-2,min_col=8,max_col=8): + for cell in row: + cell.border = Border(top=Side(border_style="none") ,right = Side(border_style="double") ,left =Side(border_style="none") ,bottom=Side(border_style="none") ) + + #borda fim pagina + for row in worksheet.iter_rows(min_row=brasilia_row-1, max_row=coordenadora_cpf_row+1,min_col=8,max_col=8): + for cell in row: + cell.border = Border(top=Side(border_style="none") ,right = Side(border_style="thin",color='9e9e9e') ,left =Side(border_style="none") ,bottom=Side(border_style="none") ) + + + + 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 == 8: + cell.border = Border(top=Side(border_style="none") ,left = Side(border_style="none") ,right =Side(border_style="thin",color='9e9e9e') ,bottom=Side(border_style="thin",color='9e9e9e') ) + else: + cell.border = Border(top=Side(border_style="none") ,left = Side(border_style="none") ,right =Side(border_style="none") ,bottom=Side(border_style="thin",color='9e9e9e') ) + + + #borda da barra total + for row in worksheet.iter_rows(min_row=size, max_row=size,min_col=1,max_col=8): + for cell in row: + cell.border = Border(top=Side(border_style="double") ,right = Side(border_style="none") ,left =Side(border_style="none") ,bottom=Side(border_style="double") ) + if cell.column == 8: + cell.border = Border(top=Side(border_style="double") ,right = Side(border_style="double") ,left =Side(border_style="none") ,bottom=Side(border_style="double") ) + + + workbook.save(tabela) + workbook.close() + +def estiloRelacaoBens(tabela,tamanho,stringTamanho): + """Estilo da tabela de bens, consulta no banco sap + + Argumentos: + tabela: recebe o arquivo correspondente a tabela Fub extensão xlsx. Esse arquivo foi iniciado e passou pela preencher fub mas ainda está sem o estilo que será aplicado nessa função. + tamanho:Corresponde ao tamanho das quantidade de bens. + stringTamanho: refere-se aonde esta localizado a string brasilia na pagina Receita e despesa para a referências das formulas. + """ + if tamanho == 0: + tamanho = 1 + + random_number = random.randint(1, 10000) + nomeTabela = f'relacaodebens' + nomeVariavel = f'material{random_number}' + caminho = pegar_caminho(tabela) + workbook = openpyxl.load_workbook(caminho) + worksheet = workbook['Relação Bens Adquiridos A.5'] + size = tamanho + 13 + cinza = "d9d9d9" + cinza_escuro = "bfbfbf" + azul = "336394" + azul_claro = 'ccffff' + + + worksheet.sheet_view.showGridLines = False + + + + worksheet.column_dimensions['a'].width = 45 + worksheet.column_dimensions['b'].width = 35 + worksheet.column_dimensions['c'].width = 35 + worksheet.column_dimensions['d'].width = 45#descrição + worksheet.column_dimensions['e'].width = 45 #n do recibo ou qeuivalente + worksheet.column_dimensions['f'].width = 35 #data de emissão + worksheet.column_dimensions['g'].width = 35 #data de emissão + worksheet.column_dimensions['h'].width = 35 #data de emissão + worksheet.column_dimensions['i'].width = 35 #data de emissão + worksheet.column_dimensions['j'].width = 35 #data de emissão + worksheet.column_dimensions['k'].width = 35 #data de emissão - # 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) + #cabecario + worksheet.merge_cells('A1:K1') + nomeTabela = nomeTabela.upper() + worksheet['A1'] = f'ANEXO 5' + worksheet['A1'].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet['A1'].alignment = Alignment(horizontal="center",vertical="center") + #RELAÇÃO DE PAGAMENTOS + worksheet.merge_cells('A2:K2') + nomeTabela = nomeTabela.upper() + worksheet['A2'] = f'RELAÇÃO DE BENS ADQUIRIDOS OU PRODUZIDOS' + worksheet['A2'].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet['A2'].alignment = Alignment(horizontal="center",vertical="center") + + #cabecario que recebe de referencia as celulas A da planilha DEMOSTR. RECEITA E DESPESA A.2 + + worksheet['A4'] = "='DEMOSTR. RECEITA E DESPESA A.2'!A4" + worksheet['A4'].font = Font(name="Arial", size=12, color="000000") + worksheet['A4'].alignment = Alignment(horizontal="left",vertical="center") + + + worksheet['A5'] = "='DEMOSTR. RECEITA E DESPESA A.2'!A5" + worksheet['A5'].font = Font(name="Arial", size=12, color="000000") + worksheet['A5'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet['A6'] = "='DEMOSTR. RECEITA E DESPESA A.2'!A6" + worksheet['A6'].font = Font(name="Arial", size=12, color="000000") + worksheet['A6'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet['A7'] = "='DEMOSTR. RECEITA E DESPESA A.2'!A7" + worksheet['A7'].font = Font(name="Arial", size=12, color="000000") + worksheet['A7'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet['A8'] = "='DEMOSTR. RECEITA E DESPESA A.2'!A8" + worksheet['A8'].font = Font(name="Arial", size=12, color="000000") + worksheet['A8'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet['A9'] = "='DEMOSTR. RECEITA E DESPESA A.2'!A9" + worksheet['A9'].font = Font(name="Arial", size=12, color="000000") + worksheet['A9'].alignment = Alignment(horizontal="left",vertical="center") + + + worksheet['C5'] = "='DEMOSTR. RECEITA E DESPESA A.2'!C5" + worksheet['C5'].font = Font(name="Arial", size=12, color="000000") + worksheet['C5'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet['C6'] = "='DEMOSTR. RECEITA E DESPESA A.2'!C6" + worksheet['C6'].font = Font(name="Arial", size=12, color="000000") + worksheet['C6'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet['C7'] = "='DEMOSTR. RECEITA E DESPESA A.2'!C7" + worksheet['C7'].font = Font(name="Arial", size=12, color="000000") + worksheet['C7'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet['C8'] = "='DEMOSTR. RECEITA E DESPESA A.2'!C8" + worksheet['C8'].font = Font(name="Arial", size=12, color="000000") + worksheet['C8'].alignment = Alignment(horizontal="left",vertical="center") + + worksheet['C9'] = "='DEMOSTR. RECEITA E DESPESA A.2'!C9" + worksheet['C9'].font = Font(name="Arial", size=12, color="000000") + worksheet['C9'].alignment = Alignment(horizontal="left",vertical="center") + + #declaração + + worksheet['A11'] = f'Declaramos que os bens abaixo especificados, adquiridos ou produzidos com os recursos do concedente, foram inventariados e encontram-se localizados nas instalações do Convenente ou dos Executores conforme relacionado abaixo. Relacionamos, também, os responsáveis pela guarda dos bens.' + worksheet['A11'].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet['A11'].alignment = Alignment(horizontal="left",vertical="center") + + + input2=f'rowStyle{nomeVariavel}' + + borda = Border( + left=Side(border_style='hair'), + right=Side(border_style='hair'), + top=Side(border_style='double'), + bottom=Side(border_style='hair') +) + 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="000000",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="double") ,bottom=Side(border_style="hair") ) + locals()[input2].height = 20 + linha_number = 13 + for row in worksheet.iter_rows(min_row=linha_number, max_row=linha_number, min_col=1, max_col=11): + for cell in row: + cell.style = locals()[input2] + if cell.column == 11: + cell.border = Border(left=Side(border_style="hair") ,bottom=Side(border_style="hair"), right=Side(border_style="double") ) + + + cell.border = borda + +##CABECARIO + + worksheet["A13"].fill = openpyxl.styles.PatternFill(start_color=azul_claro, end_color=azul_claro, fill_type='solid') + worksheet.merge_cells("A13:A14") + worksheet["A13"] ="Nº DO ITEM" + + + worksheet["B13"].fill = openpyxl.styles.PatternFill(start_color=azul_claro, end_color=azul_claro, fill_type='solid') + worksheet.merge_cells("B13:B14") + worksheet["B13"] = "DESCRIÇÃO DO BEM" + + worksheet["C13"].fill = openpyxl.styles.PatternFill(start_color=azul_claro, end_color=azul_claro, fill_type='solid') + worksheet.merge_cells("C13:C14") + worksheet["C13"] = "NÚMERO PATRIMONIAL DO BEM" + + worksheet["D13"].fill = openpyxl.styles.PatternFill(start_color=azul_claro, end_color=azul_claro, fill_type='solid') + worksheet.merge_cells("D13:E13") + worksheet["D13"] = "DOCUMENTAÇÃO FISCAL" + + worksheet["D14"].fill = openpyxl.styles.PatternFill(start_color=azul_claro, end_color=azul_claro, fill_type='solid') + worksheet["D14"] = "DATA" + worksheet["D14"].border = borda2 + + worksheet["E14"].fill = openpyxl.styles.PatternFill(start_color=azul_claro, end_color=azul_claro, fill_type='solid') + worksheet["E14"] = "Nº " + worksheet["E14"].border = borda2 + + worksheet["F13"].fill = openpyxl.styles.PatternFill(start_color=azul_claro, end_color=azul_claro, fill_type='solid') + worksheet.merge_cells("F13:F14") + worksheet["F13"] = "LOCALIZAÇÃO" + + worksheet["G13"].fill = openpyxl.styles.PatternFill(start_color=azul_claro, end_color=azul_claro, fill_type='solid') + worksheet.merge_cells("G13:G14") + worksheet["G13"] = "Equivalência na Relação de Itens Apoiados" + + worksheet["H13"].fill = openpyxl.styles.PatternFill(start_color=azul_claro, end_color=azul_claro, fill_type='solid') + worksheet.merge_cells("H13:H14") + worksheet["H13"] = "QUANTIDADE" + + worksheet["I13"].fill = openpyxl.styles.PatternFill(start_color=azul_claro, end_color=azul_claro, fill_type='solid') + worksheet.merge_cells("I13:J13") + worksheet["I13"] = "VALOR (R$)" + + worksheet["I14"].fill = openpyxl.styles.PatternFill(start_color=azul_claro, end_color=azul_claro, fill_type='solid') + worksheet["I14"] = "Unitário" + worksheet["I14"].border = borda2 + worksheet["J14"].fill = openpyxl.styles.PatternFill(start_color=azul_claro, end_color=azul_claro, fill_type='solid') + worksheet["J14"] = "Total" + worksheet["J14"].border = borda2 + + worksheet["K13"].fill = openpyxl.styles.PatternFill(start_color=azul_claro, end_color=azul_claro, fill_type='solid') + worksheet["K13"].border = openpyxl.styles.Border(top=Side(border_style="double") ,left = Side(border_style="hair") ,right =Side(border_style="double") ,bottom=Side(border_style="hair") ) + worksheet.merge_cells("K13:K14") + worksheet["K13"] = "RESPONSÁVEL PELA GUARDA DO BEM" + + #Aumentar a altura das celulas + for row in worksheet.iter_rows(min_row=13, max_row=size, min_col=1, max_col=11): + worksheet.row_dimensions[row[0].row].height = 45 + 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(15,size+1): + cell = worksheet[f'I{row}'] + cell.style = locals()[input3] + + for row in range(15,size+1): + cell = worksheet[f'J{row}'] + cell.style = locals()[input3] + + for rows in worksheet.iter_rows(min_row=15, max_row=size+1, min_col=1, max_col=11): + 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") ) + + if cell.row == size+1: + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,right =Side(border_style="hair") ,bottom=Side(border_style="double") ) + cell.font = Font(name="Arial", size=12, color="000000") + cell.alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + + if cell.column == 11: + 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="double") ,bottom=Side(border_style="hair") ) + if cell.row == size+1: + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,right =Side(border_style="double") ,bottom=Side(border_style="double") ) + + for rows in worksheet.iter_rows(min_row=size+1, max_row=size+1, min_col=1, max_col=11): + for cell in rows: + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,right =Side(border_style="hair") ,bottom=Side(border_style="double") ) + if cell.column == 11: + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,right =Side(border_style="double") ,bottom=Side(border_style="double") ) + + #subtotal + stringAfinarCelula =size+2 + worksheet.row_dimensions[size+2].height = 6 + 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=azul_claro, end_color=azul_claro,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") ) + celulas_mergidas_subtotal = f"A{size+2}:I{size+2}" + worksheet.merge_cells(celulas_mergidas_subtotal) + + worksheet.row_dimensions[size+2].height = 56.25 + + # FORMULATOTAL + formula = f"=SUM(J15:J{size+1})" + celula = f'J{size+2}' + worksheet[celula] = formula + worksheet[celula].fill = PatternFill(start_color=azul_claro, end_color=azul_claro,fill_type = "solid") + worksheet[celula].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet[celula].border = Border( 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"='DEMOSTR. RECEITA E DESPESA A.2'!A{stringTamanho}" + brasilia_merge_cells = f'A{brasilia_row}:K{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") + top_left_brasilia_cell.font = Font(name="Arial", size=12, color="000000") + + #DiretorFinanceiro + diretor_row = size + 8 + diretor_cargo_row = size + 9 + diretor_cpf_row = size + 10 + diretor_nome_formula = f"='DEMOSTR. RECEITA E DESPESA A.2'!A{stringTamanho+3}" + diretor_cargo_formula = f"='DEMOSTR. RECEITA E DESPESA A.2'!A{stringTamanho+4}" + diretor_cpf_formula = f"='DEMOSTR. RECEITA E DESPESA A.2'!A{stringTamanho+5}" + diretor_merge_cells = f'A{diretor_row}:F{diretor_row}' + diretor_cargo_merge_cells = f'A{diretor_cargo_row}:F{diretor_cargo_row}' + diretor_cpf_merge_cells = f'A{diretor_cpf_row}:F{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(name="Arial", size=12, color="000000",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"='DEMOSTR. RECEITA E DESPESA A.2'!C{stringTamanho+3}" + coordenadora_cargo_formula = f"='DEMOSTR. RECEITA E DESPESA A.2'!C{stringTamanho+4}" + coordenadora_cpf_formula = f"='DEMOSTR. RECEITA E DESPESA A.2'!C{stringTamanho+5}" + coordenadora_merge_cells = f'G{coordenadora_row}:K{coordenadora_row}' + coordenadora_cargo_merge_cells = f'G{coordenadora_cargo_row}:K{coordenadora_cargo_row}' + coordenadora_cpf_merge_cells = f'G{coordenadora_cpf_row}:K{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'G{coordenadora_row}' + top_left_coordenadora_cell_cargo_formula = f'G{coordenadora_cargo_row}' + top_left_coordenadora_cell_cpf_formula = f'G{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(name="Arial", size=12, color="000000",bold = True) + top_left_coordenadora_cell_cargo_formula.alignment = Alignment(horizontal="center",vertical="center") + top_left_coordenadora_cell_cargo_formula.font = Font(name="Arial", size=12, color="000000") + top_left_coordenadora_cell_cpf_formula.alignment = Alignment(horizontal="center",vertical="center") + top_left_coordenadora_cell_cpf_formula.font= Font(name="Arial", size=12, color="000000") + + + for row in worksheet.iter_rows(min_row=1, max_row=coordenadora_cpf_row-1,min_col=9,max_col=10): + for cell in row: + cell.number_format = 'R$ #,##0.00' + + #borda cabeçario + for row in worksheet.iter_rows(min_row=1, max_row=12,min_col=11,max_col=11): + for cell in row: + cell.border = Border(top=Side(border_style="none") ,right = Side(border_style="thin",color='9e9e9e') ,left =Side(border_style="none") ,bottom=Side(border_style="none") ) + + #borda fim pagina + for row in worksheet.iter_rows(min_row=size+2, max_row=coordenadora_cpf_row+1,min_col=11,max_col=11): + for cell in row: + cell.border = Border(top=Side(border_style="none") ,right = Side(border_style="thin",color='9e9e9e') ,left =Side(border_style="none") ,bottom=Side(border_style="none") ) + + + + for row in worksheet.iter_rows(min_row=coordenadora_cpf_row+1, max_row=coordenadora_cpf_row+1,min_col=1,max_col=11): + for cell in row: + if cell.column == 11: + cell.border = Border(top=Side(border_style="none") ,left = Side(border_style="none") ,right =Side(border_style="thin",color='9e9e9e') ,bottom=Side(border_style="thin",color='9e9e9e') ) + else: + cell.border = Border(top=Side(border_style="none") ,left = Side(border_style="none") ,right =Side(border_style="none") ,bottom=Side(border_style="thin",color='9e9e9e') ) + + + + + + + workbook.save(tabela) + workbook.close() + +def estilo_demonstrativoDeReceita(tabela,tamanho,stringTamanho): + """Estilo da demonstrativo de receita que inclui entradas de receita ISS 2%, ISS 5%. + + Argumentos: + tabela: recebe o arquivo correspondente a tabela Fub extensão xlsx. Esse arquivo foi iniciado e passou pela preencher fub mas ainda está sem o estilo que será aplicado nessa função. + tamanho:Corresponde ao tamanho das quantidade de bens. + stringTamanho: refere-se aonde esta localizado a string brasilia na pagina Receita e despesa para a referências das formulas. + """ + + if tamanho == 0: + tamanho = 1 - return caminho -def estiloGeral(tabela,tamanho,nomeVariavel,nomeTabela): - nomeSheet=nomeVariavel caminho = pegar_caminho(tabela) workbook = openpyxl.load_workbook(caminho) - worksheet = workbook[nomeTabela] + worksheet = workbook['Demonstrativo de Receita'] size = tamanho + 10 cinza = "d9d9d9" cinza_escuro = "bfbfbf" - azul_claro = 'cdfffe' - + azul = "336394" + azul_claro = '1c8cbc' + random_number = random.randint(1, 10000) 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 row in worksheet.iter_rows(min_row=1, max_row=size+11,min_col=5,max_col=5): 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 - + worksheet.column_dimensions['a'].width = 30 + worksheet.column_dimensions['b'].width = 70 + worksheet.column_dimensions['c'].width = 30 + worksheet.column_dimensions['d'].width = 50#descrição + worksheet.column_dimensions['e'].width = 50#descriçã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="000000",bold=True) + worksheet.merge_cells('A1:E2') + 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 E ISS 5% E ISS 2%' + 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'] = "=''Relatório de Exec Financ A.1'!A3" + worksheet.merge_cells('A3:E3') + 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'] = "=''Relatório de Exec Financ A.1'!A4" + worksheet.merge_cells('A4:E4') + 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'] = "=''Relatório de Exec Financ A.1'!A5" + worksheet.merge_cells('A5:E5') + 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'] = "=''Relatório de Exec Financ A.1'!A6" + worksheet.merge_cells('A6:E6') + 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'] = "=''Relatório de Exec Financ A.1'!A7" + worksheet.merge_cells('A7:E7') + 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="000000",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 + row_style_demonstrativo = NamedStyle(name=f'row_style_demonstrativo{random_number}') + 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=10): + for row in worksheet.iter_rows(min_row=linha_number, max_row=linha_number, min_col=1, max_col=5): for cell in row: - cell.style = locals()[input2] - if cell.column == 10: + cell.style = row_style_demonstrativo + if cell.column == 5: cell.border = Border(top=Side(border_style="medium") ,bottom=Side(border_style="thin"), right=Side(border_style="medium") ) - valores = ["Nº DE ORDEM","CREDOR","CNPJ/CPF",'Equivalência na Relação de Itens Apoiados','Nº DA NOTA FISCAL OU EQUIVALENTE',"DATA DA NOTA FISCAL","Nº DO CHEQUE OU EQUIVALENTE",'DATA DA COMPENSAÇÃO DO CHEQUE','VALOR'] + valores = ["NomeFavorecido","Histórico","Documento","Data de Entrada",'Valor'] col = 1 for a,b in enumerate(valores): worksheet.cell(row=linha_number, column=col, value=b) @@ -127,31 +4274,31 @@ def estiloGeral(tabela,tamanho,nomeVariavel,nomeTabela): #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}' - + 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 = 80 + + custom_number_format_demonstrativo = [] # 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) + if custom_number_format_demonstrativo!= False: + custom_number_format_demonstrativo = NamedStyle(name=f'custom_number_format_demonstrativo{random_number}') + 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'J{row}'] - cell.style = locals()[input3] + cell = worksheet[f'E{row}'] + cell.style = custom_number_format_demonstrativo - for rows in worksheet.iter_rows(min_row=10, max_row=size, min_col=1, max_col=10): + for rows in worksheet.iter_rows(min_row=10, max_row=size, min_col=1, max_col=5): for cell in rows: if cell.row % 2: cell.fill = PatternFill(start_color=cinza, end_color=cinza, fill_type = "solid") - if cell.column == 10: + if cell.column == 5: 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") ) @@ -164,7 +4311,7 @@ def estiloGeral(tabela,tamanho,nomeVariavel,nomeTabela): #subtotal stringAfinarCelula =size+2 worksheet.row_dimensions[size+2].height = 6 - celulas_mergidas_subtotal = f"A{size+2}:I{size+2}" + celulas_mergidas_subtotal = f"A{size+2}:D{size+2}" worksheet.merge_cells(celulas_mergidas_subtotal) left_celula_cell = f"A{size+2}" top_left_cell = worksheet[left_celula_cell] @@ -177,8 +4324,8 @@ def estiloGeral(tabela,tamanho,nomeVariavel,nomeTabela): worksheet.row_dimensions[size+2].height = 56.25 # FORMULATOTAL - formula = f"=SUM(J10:J{size})" - celula = f'J{size+2}' + formula = f"=SUM(E10:E{size})" + celula = f'E{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) @@ -187,45 +4334,44 @@ def estiloGeral(tabela,tamanho,nomeVariavel,nomeTabela): #restituições creditadas restituicoes = size + 3 celula_restituicoes=f'A{restituicoes}' - worksheet[celula_restituicoes].value = "RESTITUIÇÕES CREDITADAS" + 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 - - 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="000000",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_style_demonstrativo_append = NamedStyle(name=f'row_style_demonstrativo_append{random_number}') + 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, 11): + for column in range(1, 6): cell = worksheet.cell(row=row_number, column=column) - cell.style = locals()[input4] - if cell.column == 10: + cell.style = row_style_demonstrativo_append + if cell.column == 5: cell.border = Border(top=Side(border_style="medium") ,right =Side(border_style="medium") ,bottom=Side(border_style="medium") ) - values = ["Nº DE ORDEM","RESTITUIDOR","CNPJ/CPF",'Equivalência na Relação de Itens Apoiados',"CHEQUE OU EQUIVALENTE ESTORNADO","DATA DO CHEQUE",'Nº DO DEPÓSITO','DATA DO DEPÓSITO','VALOR'] + values = ["NomeFavorecido","Histórico","Documento","Data de Entrada",'Valor'] coluna = 1 for a,b in enumerate(values): worksheet.cell(row=row_number, column=coluna, value=b) + if coluna == 5: + 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}' + subtotal_merge_cells= f'A{sub_total2_row}:D{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] @@ -235,7 +4381,7 @@ def estiloGeral(tabela,tamanho,nomeVariavel,nomeTabela): 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}' + sub_formula_row_celula = f'E{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' @@ -243,7 +4389,7 @@ def estiloGeral(tabela,tamanho,nomeVariavel,nomeTabela): #total1-2 total12_row = size + 6 - total12_merge_cells = f'A{total12_row}:I{total12_row}' + total12_merge_cells = f'A{total12_row}:D{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] @@ -256,37 +4402,37 @@ def estiloGeral(tabela,tamanho,nomeVariavel,nomeTabela): #total_formula total_formula_row = size + 6 - total_formulaa = f'=J{size}' - total_formula_row_celula = f'J{total_formula_row}' + total_formulaa = f'=E{size}' + total_formula_row_celula = f'E{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}' + brasilia_formula = f"='Receita x Despesa'!A{stringTamanho}:J{stringTamanho}" + brasilia_merge_cells = f'A{brasilia_row}:E{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") + top_left_brasilia_cell.font = Font(name="Arial", size=12, color="000000") #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}' + diretor_nome_formula = f"='Receita x Despesa'!A{stringTamanho+3}" + diretor_cargo_formula = f"='Receita x Despesa'!A{stringTamanho+4}" + diretor_cpf_formula = f"='Receita x Despesa'!A{stringTamanho+5}" + 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) @@ -300,25 +4446,25 @@ def estiloGeral(tabela,tamanho,nomeVariavel,nomeTabela): 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.font = Font(name="Arial", size=12, color="000000",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}' + coordenadora_nome_formula = f"='Receita x Despesa'!H{stringTamanho+3}" + coordenadora_cargo_formula = f"='Receita x Despesa'!H{stringTamanho+4}" + coordenadora_cpf_formula = f"='Receita x Despesa'!H{stringTamanho+5}" + coordenadora_merge_cells = f'C{coordenadora_row}:E{coordenadora_row}' + coordenadora_cargo_merge_cells = f'C{coordenadora_cargo_row}:E{coordenadora_cargo_row}' + coordenadora_cpf_merge_cells = f'C{coordenadora_cpf_row}:E{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_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] @@ -326,23 +4472,25 @@ def estiloGeral(tabela,tamanho,nomeVariavel,nomeTabela): 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.font= Font(name="Arial", size=12, color="000000",bold = True) top_left_coordenadora_cell_cargo_formula.alignment = Alignment(horizontal="center",vertical="center") + top_left_coordenadora_cell_cargo_formula.font = Font(name="Arial", size=12, color="000000") top_left_coordenadora_cell_cpf_formula.alignment = Alignment(horizontal="center",vertical="center") + top_left_coordenadora_cell_cpf_formula.font= Font(name="Arial", size=12, color="000000") + - # 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 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=10): + for row in worksheet.iter_rows(min_row=coordenadora_cpf_row+1, max_row=coordenadora_cpf_row+1,min_col=1,max_col=5): for cell in row: - if cell.column == 10: + if cell.column == 5: 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") ) @@ -352,18 +4500,89 @@ def estiloGeral(tabela,tamanho,nomeVariavel,nomeTabela): +# tabela = pegar_caminho("C:\\Users\\hemanoel.brito\\Desktop\\estilos\\ModeloFINEP.xlsx") +# workbook = openpyxl.load_workbook(tabela) +# sheet = workbook.create_sheet(title="DEMOSTR. RECEITA E DESPESA A.2") +# workbook.save("C:\\Users\\hemanoel.brito\\Desktop\\estilos\\tabelaEstilizada.xlsx") +# workbook.close() + +# tabela = pegar_caminho("C:\\Users\\hemanoel.brito\\Desktop\\estilos\\tabelaEstilizada.xlsx") +# workbook = openpyxl.load_workbook(tabela) +# sheet = workbook.create_sheet(title="Relatório de Exec Financ A.1") +# workbook.save("C:\\Users\\hemanoel.brito\\Desktop\\estilos\\tabelaEstilizada.xlsx") +# workbook.close() + +# tabela = pegar_caminho("C:\\Users\\hemanoel.brito\\Desktop\\estilos\\tabelaEstilizada.xlsx") +# workbook = openpyxl.load_workbook(tabela) +# nomeTabela = "Kek" +# sheet = workbook.create_sheet(title=f"{nomeTabela}") +# workbook.save("C:\\Users\\hemanoel.brito\\Desktop\\estilos\\tabelaEstilizada.xlsx") +# workbook.close() + +# tabela = pegar_caminho("C:\\Users\\hemanoel.brito\\Desktop\\estilos\\tabelaEstilizada.xlsx") +# workbook = openpyxl.load_workbook(tabela) +# nomeTabelaa = "Keka" +# sheet = workbook.create_sheet(title=f"{nomeTabelaa}") +# workbook.save("C:\\Users\\hemanoel.brito\\Desktop\\estilos\\tabelaEstilizada.xlsx") +# workbook.close() + +# tabela = pegar_caminho("C:\\Users\\hemanoel.brito\\Desktop\\estilos\\tabelaEstilizada.xlsx") +# workbook = openpyxl.load_workbook(tabela) +# nomeTabelaaa = "PAgamentoPEssoal" +# sheet = workbook.create_sheet(title=f"{nomeTabelaaa}") +# workbook.save("C:\\Users\\hemanoel.brito\\Desktop\\estilos\\tabelaEstilizada.xlsx") +# workbook.close() + +# tabela = pegar_caminho("C:\\Users\\hemanoel.brito\\Desktop\\estilos\\tabelaEstilizada.xlsx") +# workbook = openpyxl.load_workbook(tabela) +# nomeTabelaaaa = "Elemento1415" +# sheet = workbook.create_sheet(title=f"{nomeTabelaaaa}") +# workbook.save("C:\\Users\\hemanoel.brito\\Desktop\\estilos\\tabelaEstilizada.xlsx") +# workbook.close() + + +# tabela = pegar_caminho("C:\\Users\\hemanoel.brito\\Desktop\\estilos\\tabelaEstilizada.xlsx") +# workbook = openpyxl.load_workbook(tabela) +# nomeTabela33 = "Elemento33" +# sheet = workbook.create_sheet(title=f"{nomeTabela33}") +# workbook.save("C:\\Users\\hemanoel.brito\\Desktop\\estilos\\tabelaEstilizada.xlsx") +# workbook.close() + +# tabela = pegar_caminho("C:\\Users\\hemanoel.brito\\Desktop\\estilos\\tabelaEstilizada.xlsx") +# workbook = openpyxl.load_workbook(tabela) +# BENS = "Relação Bens Adquiridos A.5" +# sheet = workbook.create_sheet(title=f"{BENS}") +# workbook.save("C:\\Users\\hemanoel.brito\\Desktop\\estilos\\tabelaEstilizada.xlsx") +# workbook.close() + +# tabela = pegar_caminho("C:\\Users\\hemanoel.brito\\Desktop\\estilos\\tabelaEstilizada.xlsx") +# workbook = openpyxl.load_workbook(tabela) +# conc = "Conciliação Bancária A.3" +# sheet = workbook.create_sheet(title=f"{conc}") +# workbook.save("C:\\Users\\hemanoel.brito\\Desktop\\estilos\\tabelaEstilizada.xlsx") +# workbook.close() + +# tabela = pegar_caminho("C:\\Users\\hemanoel.brito\\Desktop\\estilos\\tabelaEstilizada.xlsx") +# workbook = openpyxl.load_workbook(tabela) +# rend = "Rendimento de Aplicação" +# sheet = workbook.create_sheet(title=f"{rend}") +# workbook.save("C:\\Users\\hemanoel.brito\\Desktop\\estilos\\tabelaEstilizada.xlsx") +# workbook.close() + +# tamanho = 0 +# nomeVariavel = "Quea" +# tamanhoestorno = 0 +# tamanhoBrasilia = estiloDEMOSTRRECEITEDESPESAA2(tabela,20) -tabela = pegar_caminho('modelFINEP.xlsx') -nomeTabela ="Elemento de Despesa 36a" -tituloStyle = "36a" -workbook = openpyxl.load_workbook(tabela) -sheet2 = workbook.create_sheet(title=nomeTabela) -workbook.save("tabelapreenchida.xlsx") -workbook.close() -maior = 20 -tabela2 = pegar_caminho('tabelapreenchida.xlsx') -print(tabela2) -estiloGeral(tabela2,maior,tituloStyle,nomeTabela) +# stringTamanho = tamanhoBrasilia +# estiloRelatorioExecFinanceiroA1(tabela,20,tamanhoBrasilia) +# estiloG(tabela,tamanho,nomeVariavel,nomeTabela,stringTamanho,tamanhoestorno) +# estiloPagamentoPessoal(tabela,tamanho,nomeTabelaaa,stringTamanho,tamanhoestorno) +# estiloElementoDeDespesa1415Diarias(tabela,tamanho,nomeTabelaaaa,stringTamanho,tamanhoestorno) +# estiloElementoDeDespesa33PassagensEDespesa(tabela,tamanho,nomeTabela33,stringTamanho,tamanhoestorno) +# estiloRelacaoBens(tabela,tamanho,stringTamanho) +# estilo_conciliacoes_bancaria(tabela,tamanho,tamanhoestorno,stringTamanho) +# estilo_rendimento_de_aplicacao(tabela,tamanho,stringTamanho) \ No newline at end of file diff --git a/project/app/estiloFap.py b/project/app/estiloFap.py new file mode 100644 index 00000000..47ab772c --- /dev/null +++ b/project/app/estiloFap.py @@ -0,0 +1,1273 @@ +import openpyxl +from openpyxl.styles import Font, PatternFill, Alignment,NamedStyle,Border, Side +from openpyxl.utils import get_column_letter +from openpyxl.drawing.image import Image +from openpyxl.comments import Comment +from PIL import Image as PILImage +from openpyxl.utils import units +import os +import random +from openpyxl.drawing.geometry import GeomRect + +def pegar_caminho(subdiretorio): + + # Obtém o caminho do script atual + arq_atual = os.path.abspath(__file__) + + # Obtém o diretório do script + app = os.path.dirname(arq_atual) + + # Obtém o diretório pai do script + project = os.path.dirname(app) + + # Obtém o diretório pai do projeto + pipeline = os.path.dirname(project) + + # Junta o diretório pai do projeto com o subdiretório desejado + caminho_pipeline = os.path.join(pipeline, subdiretorio) + + return caminho_pipeline + + +def estiloAnexoDois(tabela,tamanho): + '''Esse estilo e considerado geral por que todas as tabelas que compõe utilizam das mesma colunas. + + Argumentos: + tabela: recebe o arquivo correspondente a tabela Fub extensão xlsx. Esse arquivo ja foi iniciado e passou pela preencher fub mas ainda esta sem o estilo que sera aplicado nessa função. + tamanho: e o tamanho total de linhas que irao ser geradas dinamicamente correspondente as entradas do respectivo projeto. o valor varia dentre o tamanho das rubricas + + nomeVariavel: variável utilizada para criar o nomes das variaveis dinamicamente para não haver sobreposição de estilos com o mesmo nome. Esses estilos ocorrem nesses codigos: + 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"'.... + nomeTabela: variável utilizada para a criação do nome da tabela.Ela deriva das rubricas que são colocadas no input quando essa função e chamada. + stringTamanho: refere-se aonde esta localizado a string brasilia na pagina Receita e despesa para a referencias das formulas. + + ''' + nomeVariavel = f'Anexo2' + + random_number = random.randint(1, 10000) + nomeVariavel = f'{nomeVariavel}{random_number}' + caminho = pegar_caminho(tabela) + workbook = openpyxl.load_workbook(caminho) + worksheet = workbook['ANEXO II'] + size = tamanho + 10 + cinza = "f3f3f2" + cinza_escuro = "bfbfbf" + azul = "336394" + azul_claro = 'ccffff' + + + # 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 = 45 + worksheet.column_dimensions['b'].width = 35 + worksheet.column_dimensions['c'].width = 35 + worksheet.column_dimensions['d'].width = 45#descrição + worksheet.column_dimensions['e'].width = 45 #n do recibo ou qeuivalente + worksheet.column_dimensions['f'].width = 35 #data de emissão + worksheet.column_dimensions['g'].width = 35 #data de emissão + worksheet.column_dimensions['h'].width = 35 #data de emissão + worksheet.column_dimensions['i'].width = 35 #data de emissão + worksheet.column_dimensions['j'].width = 35 #data de emissão + worksheet.column_dimensions['k'].width = 35 #data de emissão + worksheet.column_dimensions['l'].width = 35 #data de emissão + + + #ANEXO II + + + worksheet['A1'] = f'ANEXO 2' + worksheet['A1'].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet['A1'].alignment = Alignment(horizontal="center",vertical="center") + worksheet.merge_cells('A1:L1') + + #Fapdf + worksheet['A2'] = f'FAPDF' + worksheet['A2'].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet['A2'].alignment = Alignment(horizontal="left",vertical="center") + + #FUNDAÇÃO DE APOIO A PESQUISA DO DISTRITO FEDERAL + worksheet['A3'] = f'FUNDAÇÃO DE APOIO A PESQUISA DO DISTRITO FEDERAL' + worksheet['A3'].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet['A3'].alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + + + #RELAÇÃO DE PAGAMENTOS + worksheet['F3'] = f'RELAÇÃO DE PAGAMENTOS' + worksheet['F3'].font = Font(name="Arial", size=12, color="000000",bold=True,italic=True) + worksheet['F3'].alignment = Alignment(horizontal="center",vertical="center") + + + #N TOA/Processo + worksheet['I2'] = f'Nº TOA / Processo' + worksheet['I2'].font = Font(name="Arial", size=12, color="000000",bold=True,italic=True) + worksheet['I2'].alignment = Alignment(horizontal="center",vertical="center") + worksheet['I2'].border = Border(top=Side(border_style="none") ,bottom=Side(border_style="none"), right=Side(border_style="thin"),left=Side(border_style='thin') ) + worksheet.merge_cells('I2:K2') + + worksheet['I3'].border = Border(top=Side(border_style="none") ,bottom=Side(border_style="thin"), right=Side(border_style="thin"),left=Side(border_style='thin') ) + worksheet.merge_cells('I3:K3') + + + #outorgado + + worksheet['A5'] = "Outorgado:" + worksheet['A5'].font = Font(name="Arial", size=12, color="000000") + worksheet['A5'].alignment = Alignment(horizontal="left",vertical="center") + #Título do Projeto: + worksheet['A6'] = "Título do Projeto:" + worksheet['A6'].font = Font(name="Arial", size=12, color="000000") + worksheet['A6'].alignment = Alignment(horizontal="left",vertical="center") + #Instituição Gestora: + worksheet['A7'] = "Instituição Gestora:Fundação de Empreendimentos Científicos e Tecnológicos - FINATEC" + worksheet['A7'].font = Font(name="Arial", size=12, color="000000") + worksheet['A7'].alignment = Alignment(horizontal="left",vertical="center") + #Instituição Executora: + worksheet['A8'] = "Instituição Executora: " + worksheet['A8'].font = Font(name="Arial", size=12, color="000000") + worksheet['A8'].alignment = Alignment(horizontal="left",vertical="center") + + + + + + + + #merges + worksheet.merge_cells('A5:L5') + worksheet.merge_cells('A6:L6') + worksheet.merge_cells('A7:L7') + worksheet.merge_cells('A8:L8') + + + + #variavel + + input2=f'rowStyle{nomeVariavel}' + + + #abecario #Item Rubrica Nº Cheque ou F. de caixa Data Nº Fatura Favorecido Descrição do Bem ou Serviço (nome, marca, tipo, modelo) Qtde. Unitário Custeio Capital + + locals()[input2] = NamedStyle(name=f'{input2}') + locals()[input2].font = Font(name="Arial", size=12, color="000000",bold=True) + locals()[input2].alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + locals()[input2].border = Border(top=Side(border_style="medium") ,bottom=Side(border_style="hair"), right=Side(border_style="hair"),left=Side(border_style='hair') ) + locals()[input2].height = 20 + + linha_number = 10 + + + + + + + valores = ['Item','Rubrica','Nº Cheque ou F. de caixa','Data','Nº Fatura','Favorecido','Descrição do Bem ou Serviço','Qtde','Unitário','Custeio','Capital','Bolsas'] + 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=12): + 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) + + + value_to_stop = size + start_row = 10 + + #estilo mascara de dinheiro lina I + for row in range(start_row,size+1): + cell = worksheet[f'I{row}'] + cell.style = locals()[input3] + + #estilo mascara de dinheiro lina J + for row in range(start_row,size+1): + cell = worksheet[f'J{row}'] + cell.style = locals()[input3] + + #estilocinzasimcinzanao + for rows in worksheet.iter_rows(min_row=11, max_row=size, min_col=1, max_col=12): + 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") ) + if cell.row == size: + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,right =Side(border_style="hair") ,bottom=Side(border_style="hair") ) + + + + + if cell.column == 12: + 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") ) + if cell.row == size: + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,right =Side(border_style="medium") ,bottom=Side(border_style="hair") ) + + + #subtotal + #worksheet.row_dimensions[size+1].height = 6 + celulas_mergidas_subtotal = f"A{size+1}:H{size+1}" + + left_celula_cell = f"A{size+1}" + top_left_cell = worksheet[left_celula_cell] + 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="medium") ,left = Side(border_style="thin") ,right =Side(border_style="thin") ,bottom=Side(border_style="medium") ) + worksheet.merge_cells(celulas_mergidas_subtotal) + worksheet.row_dimensions[size+1].height = 56.25 + + # FORMULASOMATORIOTOTAL + formula = f"=SUM(J11:J{size})" + celula = f'J{size+1}' + worksheet[celula] = formula + worksheet[celula].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet[celula].border = Border(top=Side(border_style="medium") ,left = Side(border_style="thin") ,right =Side(border_style="thin") ,bottom=Side(border_style="medium") ) + worksheet[celula].number_format = 'R$ #,##0.00' + # FORMULASOMATORIOTOTALbolsa + formula = f"=SUM(L11:L{size})" + celula = f'L{size+1}' + worksheet[celula] = formula + worksheet[celula].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet[celula].border = Border(top=Side(border_style="medium") ,left = Side(border_style="thin") ,right =Side(border_style="thin") ,bottom=Side(border_style="medium") ) + worksheet[celula].number_format = 'R$ #,##0.00' + # CEDULATOTAL + celulaTotal = size + 1 + celula_Total=f'I{celulaTotal}' + worksheet[celula_Total].value = "Total" + worksheet[celula_Total].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet[celula_Total].border = Border(top=Side(border_style="medium") ,left = Side(border_style="thin") ,right =Side(border_style="thin") ,bottom=Side(border_style="medium") ) + worksheet.row_dimensions[celulaTotal].height = 30 + + + #capital + formula = f"=SUM(K11:K{size})" + celula = f'K{size+1}' + worksheet[celula] = formula + worksheet[celula].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet[celula].border = Border(top=Side(border_style="medium") ,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 + 3 + brasilia_formula = f"Brasilia" + brasilia_merge_cells = f'A{brasilia_row}:H{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.alignment = Alignment(horizontal="center",vertical="center") + top_left_brasilia_cell.font = Font(name="Arial", size=12, color="000000",bold = True) + top_left_brasilia_cell.value = brasilia_formula + + + + # #DiretorFinanceiro + diretor_row = size + 5 + diretor_cargo_row = size + 6 + diretor_cpf_row = size + 7 + + diretor_nome_formula = f"Daniel Monteiro Rosa" + diretor_cargo_formula = f"Diretor-Financeiro" + diretor_cpf_formula = f"450.720.272-87" + 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(name="Arial", size=12, color="000000",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 + 5 + coordenadora_cargo_row = size + 6 + coordenadora_cpf_row = size + 7 + coordenadora_nome_formula = f"nomeFormula" + coordenadora_cargo_formula = f"cargoformula" + coordenadora_cpf_formula = f"cpformula" + coordenadora_merge_cells = f'E{coordenadora_row}:H{coordenadora_row}' + coordenadora_cargo_merge_cells = f'E{coordenadora_cargo_row}:H{coordenadora_cargo_row}' + coordenadora_cpf_merge_cells = f'E{coordenadora_cpf_row}:H{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(name="Arial", size=12, color="000000",bold = True) + top_left_coordenadora_cell_cargo_formula.alignment = Alignment(horizontal="center",vertical="center") + top_left_coordenadora_cell_cargo_formula.font = Font(name="Arial", size=12, color="000000") + top_left_coordenadora_cell_cpf_formula.alignment = Alignment(horizontal="center",vertical="center") + top_left_coordenadora_cell_cpf_formula.font = Font(name="Arial", size=12, color="000000") + + + + #custeio + # capital + # Bolsa + # total + + + #QUADRADO CINZA + for row in worksheet.iter_rows(min_row=size + 2, max_row=size + 7, min_col=9, max_col=12): + for cell in row: + cell.fill = openpyxl.styles.PatternFill(start_color=cinza, end_color=cinza, fill_type='solid') + cell.font = Font(name="Arial", size=12, color="000000") + cell.number_format = 'R$ #,##0.00' + if cell.column == 9: + cell.border = Border(left=Side(border_style="thin") ) + cell.font = Font(name="Arial", size=12, color="000000",bold=True) + if cell.column == 12: + cell.border = Border(right=Side(border_style="thin") ) + if cell.row == size + 7: + cell.border = Border(bottom=Side(border_style="thin") ) + if cell.row == size + 7 and cell.column == 12: + cell.border = Border(bottom=Side(border_style="thin"), right=Side(border_style="thin") ) + if cell.row == size + 7 and cell.column == 9: + cell.border = Border(bottom=Side(border_style="thin"), left=Side(border_style="thin") ) + + if cell.row == size + 7 and cell.column == 10: + cell.font = Font(name="Arial", size=12, color="000000",bold=True) + + + #TOTAL QUADRADO CINZA + #CUSTEIO + custeio_formula = f"CUSTEIO" + top_left_custeio_cell_formula = f'I{size+3}' + top_left_custeio_cell = worksheet[top_left_custeio_cell_formula] + top_left_custeio_cell.value = custeio_formula + top_left_custeio_cell.alignment = Alignment(horizontal="center",vertical="center") + #CAPITAL + custeio_formula = f"CAPITAL" + top_left_custeio_cell_formula = f'I{size+4}' + top_left_custeio_cell = worksheet[top_left_custeio_cell_formula] + top_left_custeio_cell.value = custeio_formula + top_left_custeio_cell.alignment = Alignment(horizontal="center",vertical="center") + #BOLSA + custeio_formula = f"BOLSA" + top_left_custeio_cell_formula = f'I{size+5}' + top_left_custeio_cell = worksheet[top_left_custeio_cell_formula] + top_left_custeio_cell.value = custeio_formula + top_left_custeio_cell.alignment = Alignment(horizontal="center",vertical="center") + #TOTAL + custeio_formula = f"TOTAL" + top_left_custeio_cell_formula = f'I{size+6}' + top_left_custeio_cell = worksheet[top_left_custeio_cell_formula] + top_left_custeio_cell.value = custeio_formula + top_left_custeio_cell.alignment = Alignment(horizontal="center",vertical="center") + #FORMULA TOTAL + custeio_formula = f"=SUM(J{size+3}:J{size+5})" + top_left_custeio_cell_formula = f'J{size+6}' + top_left_custeio_cell = worksheet[top_left_custeio_cell_formula] + top_left_custeio_cell.value = custeio_formula + top_left_custeio_cell.alignment = Alignment(horizontal="center",vertical="center") + top_left_custeio_cell.font = Font(name="Arial", size=12, color="000000",bold=True) + + + cinzaborda = '9e9e9e' + + for row in worksheet.iter_rows(min_row=linha_number, max_row=linha_number, min_col=1, max_col=12): + for cell in row: + cell.style = locals()[input2] + if cell.column == 12: + cell.border = Border(top=Side(border_style="medium") , right=Side(border_style="medium") ) + + + + #borda cabeçario + for row in worksheet.iter_rows(min_row=1, max_row=9,min_col=12,max_col=12): + for cell in row: + cell.border = Border(top=Side(border_style="none") ,right = Side(border_style="thin",color='9e9e9e') ,left =Side(border_style="none") ,bottom=Side(border_style="none") ) + + # #borda fim pagina + # for row in worksheet.iter_rows(min_row=size + 3, max_row=coordenadora_cpf_row+1,min_col=11,max_col=11): + # for cell in row: + # cell.border = Border(top=Side(border_style="none") ,right = Side(border_style="thin",color='9e9e9e') ,left =Side(border_style="none") ,bottom=Side(border_style="none") ) + + + + for row in worksheet.iter_rows(min_row=coordenadora_cpf_row, max_row=coordenadora_cpf_row,min_col=1,max_col=8): + for cell in row: + if cell.column == 12: + cell.border = Border(top=Side(border_style="none") ,left = Side(border_style="none") ,right =Side(border_style="thin",color='9e9e9e') ,bottom=Side(border_style="thin",color='9e9e9e') ) + else: + cell.border = Border(top=Side(border_style="none") ,left = Side(border_style="none") ,right =Side(border_style="none") ,bottom=Side(border_style="thin",color='9e9e9e') ) + + workbook.save(tabela) + workbook.close() + + return brasilia_row + +def estiloAnexoTres(tabela,tamanho,stringTamanho): + if tamanho == 0: + tamanho = 1 + + nomeVariavel = f'Anexo3' + nomeTabela = f'ANEXO III' + + random_number = random.randint(1, 10000) + nomeVariavel = f'{nomeVariavel}{random_number}' + caminho = pegar_caminho(tabela) + workbook = openpyxl.load_workbook(caminho) + worksheet = workbook['ANEXO III'] + size = tamanho + 10 + cinza = "f3f3f2" + cinza_escuro = "d9d9d9" + + + # 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 = 45 + worksheet.column_dimensions['b'].width = 35 + worksheet.column_dimensions['c'].width = 35 + worksheet.column_dimensions['d'].width = 45#descrição + worksheet.column_dimensions['e'].width = 45 #n do recibo ou qeuivalente + worksheet.column_dimensions['f'].width = 35 #data de emissão + worksheet.column_dimensions['g'].width = 35 #data de emissão + worksheet.column_dimensions['h'].width = 35 #data de emissão + worksheet.column_dimensions['i'].width = 35 #data de emissão + worksheet.column_dimensions['j'].width = 35 #data de emissão + worksheet.column_dimensions['k'].width = 35 #data de emissão + worksheet.column_dimensions['l'].width = 35 #data de emissão + + + #ANEXO II + + nomeTabela = nomeTabela.upper() + worksheet['A1'] = f'ANEXO 3' + worksheet['A1'].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet['A1'].alignment = Alignment(horizontal="center",vertical="center") + worksheet.merge_cells('A1:L1') + + #Fapdf + worksheet['A2'] = f'FAPDF' + worksheet['A2'].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet['A2'].alignment = Alignment(horizontal="left",vertical="center") + + #FUNDAÇÃO DE APOIO A PESQUISA DO DISTRITO FEDERAL + worksheet['A3'] = f'FUNDAÇÃO DE APOIO A PESQUISA DO DISTRITO FEDERAL' + worksheet['A3'].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet['A3'].alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + + + #RELAÇÃO DE PAGAMENTOS + worksheet['F3'] = f'LISTA DE BENS ADQUIRIDOS NO PROJETO' + worksheet['F3'].font = Font(name="Arial", size=12, color="000000",bold=True,italic=True) + worksheet['F3'].alignment = Alignment(horizontal="center",vertical="center") + + + #N TOA/Processo + worksheet['J2'] = f'Nº TOA / Processo' + worksheet['J2'].font = Font(name="Arial", size=12, color="000000",bold=True,italic=True) + worksheet['J2'].alignment = Alignment(horizontal="center",vertical="center") + worksheet['J2'].border = Border(top=Side(border_style="none") ,bottom=Side(border_style="none"), right=Side(border_style="thin"),left=Side(border_style='thin') ) + worksheet.merge_cells('J2:K2') + + worksheet['J3'] = "='ANEXO II'!I3" + worksheet['J3'].font = Font(name="Arial", size=12, color="000000") + worksheet['J3'].alignment = Alignment(horizontal="left",vertical="center") + worksheet['J3'].border = Border(top=Side(border_style="none") ,bottom=Side(border_style="thin"), right=Side(border_style="thin"),left=Side(border_style='thin') ) + worksheet.merge_cells('J3:K3') + + #outorgado + + worksheet['A5'] = "Outorgado:" + worksheet['A5'].font = Font(name="Arial", size=12, color="000000") + worksheet['A5'].alignment = Alignment(horizontal="left",vertical="center") + #Título do Projeto: + worksheet['A6'] = "='ANEXO II'!A6" + worksheet['A6'].font = Font(name="Arial", size=12, color="000000") + worksheet['A6'].alignment = Alignment(horizontal="left",vertical="center") + #Instituição Gestora: + worksheet['A7'] = "='ANEXO II'!A7" + worksheet['A7'].font = Font(name="Arial", size=12, color="000000") + worksheet['A7'].alignment = Alignment(horizontal="left",vertical="center") + #Instituição Executora: + worksheet['A8'] = "='ANEXO II'!A8" + worksheet['A8'].font = Font(name="Arial", size=12, color="000000") + worksheet['A8'].alignment = Alignment(horizontal="left",vertical="center") + + + + + + + + #merges + worksheet.merge_cells('A5:L5') + worksheet.merge_cells('A6:L6') + worksheet.merge_cells('A7:L7') + worksheet.merge_cells('A8:L8') + + + + #variavel + + input2=f'rowStyle{nomeVariavel}' + + + #abecario #Item Rubrica Nº Cheque ou F. de caixa Data Nº Fatura Favorecido Descrição do Bem ou Serviço (nome, marca, tipo, modelo) Qtde. Unitário Custeio Capital + #estilo cabeçario + + + locals()[input2] = NamedStyle(name=f'{input2}') + locals()[input2].font = Font(name="Arial", size=12, color="000000",bold=True) + 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"), right=Side(border_style="thin"),left=Side(border_style='thin') ) + locals()[input2].fill = PatternFill(start_color=cinza_escuro, end_color=cinza_escuro, fill_type = "solid") + locals()[input2].height = 20 + + linha_number = 10 + + + + + + + valores = ['Item','Nº Cheque ou F. de caixa','Data','Nº Fatura','Favorecido','Descrição do Bem ou Serviço','Qtde','Unitário','Capital','Origem / Plaqueta','Localização','Responsável'] + 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=12): + 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) + + + value_to_stop = size + start_row = 10 + + #estilo mascara de dinheiro lina I + for row in range(start_row,size+1): + cell = worksheet[f'H{row}'] + cell.style = locals()[input3] + + #estilo mascara de dinheiro lina J + for row in range(start_row,size+1): + cell = worksheet[f'I{row}'] + cell.style = locals()[input3] + + #estilocinzasimcinzanao + for rows in worksheet.iter_rows(min_row=11, max_row=size, min_col=1, max_col=12): + 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") ) + if cell.row == size: + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,right =Side(border_style="hair") ,bottom=Side(border_style="hair") ) + + + + + if cell.column == 12: + 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") ) + if cell.row == size: + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,right =Side(border_style="medium") ,bottom=Side(border_style="hair") ) + + + #subtotal + #worksheet.row_dimensions[size+1].height = 6 + #subtotal barra + celulas_mergidas_subtotal = f"A{size+1}:G{size+1}" + + left_celula_cell = f"A{size+1}" + top_left_cell = worksheet[left_celula_cell] + 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="medium") ,left = Side(border_style="thin") ,right =Side(border_style="thin") ,bottom=Side(border_style="medium") ) + top_left_cell.value = f'Declaro que as despesas relacionadas acima foram pagas e que os materiais e equipamentos foram recebidos.' + top_left_cell.fill = PatternFill(start_color=cinza_escuro, end_color=cinza_escuro, + fill_type = "solid") + worksheet.merge_cells(celulas_mergidas_subtotal) + worksheet.row_dimensions[size+1].height = 56.25 + #barra 2 + celulas_mergidas_subtotal = f"J{size+1}:L{size+1}" + left_celula_cell = f"J{size+1}" + top_left_cell = worksheet[left_celula_cell] + 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="medium") ,left = Side(border_style="thin") ,right =Side(border_style="medium") ,bottom=Side(border_style="medium") ) + top_left_cell.fill = PatternFill(start_color=cinza_escuro, end_color=cinza_escuro, + fill_type = "solid") + worksheet.merge_cells(celulas_mergidas_subtotal) + + + + + # FORMULASOMATORIOTOTAL + formula = f"=SUM(I11:I{size})" + celula = f'I{size+1}' + worksheet[celula] = formula + worksheet[celula].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet[celula].border = Border(top=Side(border_style="medium") ,left = Side(border_style="thin") ,right =Side(border_style="thin") ,bottom=Side(border_style="medium") ) + worksheet[celula].number_format = 'R$ #,##0.00' + worksheet[celula].fill = PatternFill(start_color=cinza_escuro, end_color=cinza_escuro, + fill_type = "solid") + # CEDULATOTAL + celulaTotal = size + 1 + celula_Total=f'H{celulaTotal}' + worksheet[celula_Total].value = "Total" + worksheet[celula_Total].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet[celula_Total].border = Border(top=Side(border_style="medium") ,left = Side(border_style="thin") ,right =Side(border_style="thin") ,bottom=Side(border_style="medium") ) + worksheet.row_dimensions[celulaTotal].height = 30 + worksheet[celula_Total].fill = PatternFill(start_color=cinza_escuro, end_color=cinza_escuro, + fill_type = "solid") + + + + #brasilia + brasilia_row = size + 3 + brasilia_formula = f"='ANEXO II'!A{stringTamanho}" + brasilia_merge_cells = f'A{brasilia_row}:L{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 + 5 + diretor_cargo_row = size + 6 + diretor_cpf_row = size + 7 + + diretor_nome_formula = f"='ANEXO II'!A{stringTamanho+2}:D{stringTamanho+2}" + diretor_cargo_formula = f"='ANEXO II'!A{stringTamanho+3}:D{stringTamanho+3}" + diretor_cpf_formula = f"='ANEXO II'!A{stringTamanho+4}:D{stringTamanho+4}" + diretor_merge_cells = f'A{diretor_row}:F{diretor_row}' + diretor_cargo_merge_cells = f'A{diretor_cargo_row}:F{diretor_cargo_row}' + diretor_cpf_merge_cells = f'A{diretor_cpf_row}:F{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(name="Arial", size=12, color="000000",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 + 5 + coordenadora_cargo_row = size + 6 + coordenadora_cpf_row = size + 7 + coordenadora_nome_formula = f"='ANEXO II'!E{stringTamanho+2}" + coordenadora_cargo_formula = f"='ANEXO II'!E{stringTamanho+3}" + coordenadora_cpf_formula = f"='ANEXO II'!E{stringTamanho+4}" + coordenadora_merge_cells = f'G{coordenadora_row}:L{coordenadora_row}' + coordenadora_cargo_merge_cells = f'G{coordenadora_cargo_row}:L{coordenadora_cargo_row}' + coordenadora_cpf_merge_cells = f'G{coordenadora_cpf_row}:L{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'G{coordenadora_row}' + top_left_coordenadora_cell_cargo_formula = f'G{coordenadora_cargo_row}' + top_left_coordenadora_cell_cpf_formula = f'G{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(name="Arial", size=12, color="000000",bold = True) + top_left_coordenadora_cell_cargo_formula.alignment = Alignment(horizontal="center",vertical="center") + top_left_coordenadora_cell_cargo_formula.font = Font(name="Arial", size=12, color="000000") + top_left_coordenadora_cell_cpf_formula.alignment = Alignment(horizontal="center",vertical="center") + top_left_coordenadora_cell_cpf_formula.font = Font(name="Arial", size=12, color="000000") + + + + cinzaborda = '9e9e9e' + + for row in worksheet.iter_rows(min_row=linha_number, max_row=linha_number, min_col=1, max_col=12): + for cell in row: + cell.style = locals()[input2] + if cell.column == 12: + cell.border = Border(top=Side(border_style="medium") , right=Side(border_style="medium"),bottom=Side(border_style='thin') ) + + + + #borda cabeçario + for row in worksheet.iter_rows(min_row=1, max_row=9,min_col=12,max_col=12): + for cell in row: + cell.border = Border(top=Side(border_style="none") ,right = Side(border_style="thin",color='9e9e9e') ,left =Side(border_style="none") ,bottom=Side(border_style="none") ) + + # #borda fim pagina + # for row in worksheet.iter_rows(min_row=size + 3, max_row=coordenadora_cpf_row+1,min_col=11,max_col=11): + # for cell in row: + # cell.border = Border(top=Side(border_style="none") ,right = Side(border_style="thin",color='9e9e9e') ,left =Side(border_style="none") ,bottom=Side(border_style="none") ) + + for row in worksheet.iter_rows(min_row=size+2, max_row=coordenadora_cpf_row-1,min_col=12,max_col=12): + for cell in row: + if cell.column == 12: + cell.border = Border(top=Side(border_style="none") ,left = Side(border_style="none") ,right =Side(border_style="thin",color='9e9e9e') ,bottom=Side(border_style="none") ) + else: + cell.border = Border(top=Side(border_style="none") ,left = Side(border_style="none") ,bottom =Side(border_style="none") ,right=Side(border_style="thin",color='9e9e9e') ) + + + for row in worksheet.iter_rows(min_row=coordenadora_cpf_row, max_row=coordenadora_cpf_row,min_col=1,max_col=12): + for cell in row: + if cell.column == 12: + cell.border = Border(top=Side(border_style="none") ,left = Side(border_style="none") ,right =Side(border_style="thin",color='9e9e9e') ,bottom=Side(border_style="thin",color='9e9e9e') ) + else: + cell.border = Border(top=Side(border_style="none") ,left = Side(border_style="none") ,right =Side(border_style="none") ,bottom=Side(border_style="thin",color='9e9e9e') ) + + workbook.save(tabela) + workbook.close() + +def estiloAnexoQuatro(tabela,tamanho,stringTamanho): + + if tamanho == 0: + tamanho = 1 + + + nomeVariavel = f'Anexo4' + random_number = random.randint(1, 10000) + nomeVariavel = f'{nomeVariavel}{random_number}' + caminho = pegar_caminho(tabela) + workbook = openpyxl.load_workbook(caminho) + worksheet = workbook['ANEXO IV'] + size = tamanho + 10 + cinza = "f3f3f2" + cinza_escuro = "d9d9d9" + testeRow = 17; + + + # borda = Border(right=Side(border_style="medium")) + worksheet.sheet_view.showGridLines = False + # + + #imagens + + image_names = [ + 'fapdf.png', + + ] + images = [] + + nomePasta = "../../imagemFap" + diretorio = os.path.dirname(__file__) + + # Loop through the list of image names and create Image objects + for i, name in enumerate(image_names): + caminhoImage = os.path.join(diretorio, nomePasta, name) + pil_image = PILImage.open(caminhoImage) + pil_image.save(caminhoImage) + img = Image(caminhoImage) + images.append(img) + + + worksheet.add_image(images[0], "A1")#fap + + + + + + + # 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.row_dimensions[1].height = 25 + worksheet.row_dimensions[2].height = 25 + worksheet.column_dimensions['a'].width = 45 #Período + worksheet.column_dimensions['b'].width = 35 #Saldo anterior + worksheet.column_dimensions['c'].width = 35 #Valor Aplicado no período + worksheet.column_dimensions['d'].width = 45 #Valor Resgatado no Período + worksheet.column_dimensions['e'].width = 45 #Imposto de Renda / IOF + worksheet.column_dimensions['f'].width = 35 #Rendimento Bruto + worksheet.column_dimensions['g'].width = 35 #Saldo + + + + #ANEXO II + nomeTabela = 'ANEXO IV' + nomeTabela = nomeTabela.upper() + worksheet['A1'] = f'ANEXO IV' + worksheet['A1'].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet['A1'].alignment = Alignment(horizontal="center",vertical="center") + worksheet.merge_cells('A1:G1') + + #Fapdf + worksheet['A4'] = f'FAPDF' + worksheet['A4'].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet['A4'].alignment = Alignment(horizontal="left",vertical="center") + worksheet.merge_cells('A4:G4') + + #FUNDAÇÃO DE APOIO A PESQUISA DO DISTRITO FEDERAL + worksheet['A5'] = f'FUNDAÇÃO DE APOIO A PESQUISA DO DISTRITO FEDERAL' + worksheet['A5'].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet['A5'].alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + worksheet.merge_cells('A5:G5') + + #Demonstrativo dos Ganhos Auferidos com Aplicações Financeiras + worksheet['A7'] = f'Demonstrativo dos Ganhos Auferidos com Aplicações Financeiras' + worksheet['A7'].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet['A7'].alignment = Alignment(horizontal="center",vertical="center") + worksheet.merge_cells('A7:G7') + + + #N TOA/Processo + worksheet['F9'] = f'Nº TOA / Processo' + worksheet['F9'].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet['F9'].alignment = Alignment(horizontal="center",vertical="center") + worksheet.merge_cells('F9:G9') + #N TOA/Processo + worksheet['F10'] = f"='ANEXO II'!I3" + worksheet['F10'].font = Font(name="Arial", size=12, color="000000") + worksheet['F10'].alignment = Alignment(horizontal="center",vertical="center") + worksheet.merge_cells('F10:G10') + + + #outorgado + #Unidade Gestora: + worksheet['A9'] = "Unidade Gestora:" + worksheet['A9'].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet['A9'].alignment = Alignment(horizontal="left",vertical="center",wrap_text=True) + worksheet.merge_cells('A9:E9') + #Unidade Gestora: + worksheet['A10'] = "FINATEC - Fundação de Empreendimentos Científicos e Tecnológicos" + worksheet['A10'].font = Font(name="Arial", size=12, color="000000") + worksheet['A10'].alignment = Alignment(horizontal="left",vertical="center",wrap_text=True) + worksheet.merge_cells('A10:E10') + #Projeto: + worksheet['A11'] = "Projeto" + worksheet['A11'].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet['A11'].alignment = Alignment(horizontal="left",vertical="center",wrap_text=True) + worksheet.merge_cells('A11:E11') + #ProjetorEFERENCIA: + worksheet['A12'] = "='ANEXO II'!A6" + worksheet['A12'].font = Font(name="Arial", size=12, color="000000") + worksheet['A12'].alignment = Alignment(horizontal="left",vertical="center",wrap_text=True) + worksheet.merge_cells('A12:E13') + #Período abrangido: + worksheet['F11'] = "Período abrangido:" + worksheet['F11'].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet['F11'].alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + worksheet.merge_cells('F11:G11') + + #APLICAÇÃO FINANCEIRA - CURTO PRAZO + worksheet['A14'] = "APLICAÇÃO FINANCEIRA - " + worksheet['A14'].font = Font(name="Arial", size=12, color="000000",bold=True) + worksheet['A14'].alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + worksheet.merge_cells('A14:G14') + + + + + worksheet.row_dimensions[15].height = 20 + worksheet.row_dimensions[16].height = 20 + + # + input2=f'rowStyle{nomeVariavel}' + locals()[input2] = NamedStyle(name=f'{input2}') + locals()[input2].font = Font(name="Arial", size=12, color="000000",bold=True) + locals()[input2].alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + locals()[input2].fill = PatternFill(start_color=cinza_escuro, end_color=cinza_escuro, fill_type = "solid") + locals()[input2].border = Border(top=Side(border_style="medium") ) + locals()[input2].height = 20 + + + linha_number = 15 + + + + + # #stylecinza + start_row = 17 + for rows in worksheet.iter_rows(min_row=15, max_row=16, min_col=1, max_col=7): + for cell in rows: + if cell.row % 2 == 0: + 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) + cell.fill = PatternFill(start_color=cinza_escuro, end_color=cinza_escuro, + fill_type = "solid") + + #cabcerario abaixo de aplicação financeira + row_number = 15 + values = ["Período","Saldo Anterior","Valor Aplicado no período",'Valor Resgatado no Período','Imposto de Renda / IOF','Rendimento Bruto','Saldo'] + coluna = 1 + for a,b in enumerate(values): + worksheet.cell(row=row_number, column=coluna, value=b) + coluna = coluna + 1 + + + + + # #RENDIMENTO LIQUIDO + # # # print(size) + # for row in worksheet.iter_rows(min_row=testeRow, max_row=size, min_col=7, max_col=7): + # for cell in row: + # stringSaldo = f"=E{cell.row} - F{cell.row}" + # cell.value = stringSaldo + + + + + #BARRAS DE DADOS + start_row = 14 + for rows in worksheet.iter_rows(min_row=testeRow, max_row=size, min_col=1, max_col=7): + for cell in rows: + if cell.row % 2==0: + 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=testeRow, max_row=size-1, min_col=6, max_col=6): + # for cell in rows: + # cell.font = Font(name="Arial", size=12, color="f90000") + # cell.number_format ='#,##0.00' + + #MASCARANEGRITO + for rows in worksheet.iter_rows(min_row=testeRow, 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=6, max_col=6): + # # for cell in rows: + # # cell.font = Font(name="Arial", size=12, color="141fca") + # # cell.number_format ='#,##0.00' + + # # 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) + # # cell.number_format ='#,##0.00' + + + + #barra de totais + formula = f"Saldo anterior" + celula = f'A{testeRow}' + worksheet[celula] = formula + worksheet[celula].font = Font(name="Arial", size=12, color="000000",bold=True) + + + + + + + # FORMULATOTAL + #B + size = size + 1 + formula = f"=SUM(B{testeRow}: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) + worksheet[celula].alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + + #C + formula = f"=SUM(C{testeRow}: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) + worksheet[celula].alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + + #D + formula = f"=SUM(D{testeRow}: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) + worksheet[celula].alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + #E + formula = f"=SUM(E{testeRow}: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) + worksheet[celula].alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + #F + formula = f"=SUM(F{testeRow}: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) + worksheet[celula].alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + #G + formula = f"=SUM(G{testeRow}: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) + worksheet[celula].alignment = Alignment(horizontal="center",vertical="center",wrap_text=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) + worksheet[celula].alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + #borda total + + + + #brasilia + brasilia_row = size + 3 + brasilia_formula = f"='ANEXO II'!A{stringTamanho}" + brasilia_merge_cells = f'A{brasilia_row}:G{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 + 5 + diretor_cargo_row = size + 6 + diretor_cpf_row = size + 7 + + diretor_nome_formula = f"='ANEXO II'!A{stringTamanho+2}:C{stringTamanho+2}" + diretor_cargo_formula = f"='ANEXO II'!A{stringTamanho+3}:C{stringTamanho+3}" + diretor_cpf_formula = f"='ANEXO II'!A{stringTamanho+4}:C{stringTamanho+4}" + 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(name="Arial", size=12, color="000000",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 + 5 + coordenadora_cargo_row = size + 6 + coordenadora_cpf_row = size + 7 + coordenadora_nome_formula = f"='ANEXO II'!E{stringTamanho+2}" + coordenadora_cargo_formula = f"='ANEXO II'!E{stringTamanho+3}" + coordenadora_cpf_formula = f"='ANEXO II'!E{stringTamanho+4}" + 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(name="Arial", size=12, color="000000",bold = True) + top_left_coordenadora_cell_cargo_formula.alignment = Alignment(horizontal="center",vertical="center") + top_left_coordenadora_cell_cargo_formula.font = Font(name="Arial", size=12, color="000000") + top_left_coordenadora_cell_cpf_formula.alignment = Alignment(horizontal="center",vertical="center") + top_left_coordenadora_cell_cpf_formula.font= Font(name="Arial", size=12, color="000000") + + + + cinzaborda = '9e9e9e' + + #estiloccinza cabeçario + for row in worksheet.iter_rows(min_row=linha_number, max_row=linha_number, min_col=1, max_col=7): + for cell in row: + cell.style = locals()[input2] + if cell.column == 7: + cell.border = Border(top=Side(border_style="medium") , right=Side(border_style="medium"),bottom=Side(border_style='thin') ) + + for i in range(1,7): + worksheet.merge_cells(start_row=15,end_row=16,start_column=i,end_column=i) + + #estilo dinheiro tabela toda + for row in worksheet.iter_rows(min_row=17, max_row=size, min_col=2, max_col=7): + for cell in row: + cell.number_format = 'R$ #,##0.00' + + + + + + #borda cabeçario + for row in worksheet.iter_rows(min_row=1, max_row=14,min_col=7,max_col=7): + for cell in row: + cell.border = Border(top=Side(border_style="none") ,right = Side(border_style="thin",color='9e9e9e') ,left =Side(border_style="none") ,bottom=Side(border_style="none") ) + + #borda fim pagina + for row in worksheet.iter_rows(min_row=15, max_row=size,min_col=1,max_col=7): + for cell in row: + if cell.column == 7 and cell.row == 15 : + cell.border = Border(top=Side(border_style="medium") ,right = Side(border_style="medium") ,left =Side(border_style="none") ,bottom=Side(border_style="none") ) + if cell.column == 7 and cell.row != 15: + cell.border = Border(top=Side(border_style="none") ,right = Side(border_style="medium") ,left =Side(border_style="none") ,bottom=Side(border_style="none") ) + if cell.row == size and cell.column == 7: + cell.border = Border(top=Side(border_style="none") ,bottom = Side(border_style="medium") ,left =Side(border_style="none") ,right=Side(border_style="medium") ) + if cell.row == size and cell.column != 7: + cell.border = Border(top=Side(border_style="none") ,bottom = Side(border_style="medium") ,left =Side(border_style="none") ,right=Side(border_style="none") ) + + + for row in worksheet.iter_rows(min_row=size+1, max_row=coordenadora_cpf_row-1,min_col=7,max_col=7): + for cell in row: + if cell.column == 7: + cell.border = Border(top=Side(border_style="none") ,left = Side(border_style="none") ,right =Side(border_style="thin",color='9e9e9e') ,bottom=Side(border_style="none") ) + else: + cell.border = Border(top=Side(border_style="none") ,left = Side(border_style="none") ,bottom =Side(border_style="none") ,right=Side(border_style="thin",color='9e9e9e') ) + + + for row in worksheet.iter_rows(min_row=coordenadora_cpf_row, max_row=coordenadora_cpf_row,min_col=1,max_col=7): + for cell in row: + if cell.column == 7: + cell.border = Border(top=Side(border_style="none") ,left = Side(border_style="none") ,right =Side(border_style="thin",color='9e9e9e') ,bottom=Side(border_style="thin",color='9e9e9e') ) + else: + cell.border = Border(top=Side(border_style="none") ,left = Side(border_style="none") ,right =Side(border_style="none") ,bottom=Side(border_style="thin",color='9e9e9e') ) + + + + workbook.save(tabela) + workbook.close() + +# tabela = pegar_caminho("C:\\Users\\hemanoel.brito\\Desktop\\estilos\\modeloFap.xlsx") +# # Load the workbook and create a new sheet +# workbook = openpyxl.load_workbook(tabela) +# sheet = workbook.create_sheet(title="ANEXO II") + +# # Save the workbook +# workbook.save("C:\\Users\\hemanoel.brito\\Desktop\\estilos\\tabelafap.xlsx") +# workbook.close() + + + + + + +# tabela = pegar_caminho("C:\\Users\\hemanoel.brito\\Desktop\\estilos\\tabelafap.xlsx") +# tamanho = 20 +# nomeTabela = "ANEXO II" +# stringTamanho = 0 +# tamanhoestorno = 0 +# rowBrasilia = estiloAnexoDois(tabela,tamanho,nomeTabela,stringTamanho,tamanhoestorno) + + + +# tabela = pegar_caminho("C:\\Users\\hemanoel.brito\\Desktop\\estilos\\tabelafap.xlsx") +# # Load the workbook and create a new sheet +# workbook = openpyxl.load_workbook(tabela) +# sheet = workbook.create_sheet(title="ANEXO III") + +# # Save the workbook +# workbook.save("C:\\Users\\hemanoel.brito\\Desktop\\estilos\\tabelafap.xlsx") +# workbook.close() + + + +# tabela = pegar_caminho("C:\\Users\\hemanoel.brito\\Desktop\\estilos\\tabelafap.xlsx") +# tamanho = 20 +# nomeTabela = "ANEXO III" +# stringTamanho = 0 +# tamanhoestorno = 0 +# estiloAnexoTres(tabela,tamanho,nomeTabela,rowBrasilia,tamanhoestorno) + +# # anexo4 +# tabela = pegar_caminho("C:\\Users\\hemanoel.brito\\Desktop\\estilos\\tabelafap.xlsx") +# # Load the workbook and create a new sheet +# workbook = openpyxl.load_workbook(tabela) +# sheet = workbook.create_sheet(title="ANEXO IV") + +# # Save the workbook +# workbook.save("C:\\Users\\hemanoel.brito\\Desktop\\estilos\\tabelafap.xlsx") +# workbook.close() + + + +# tabela = pegar_caminho("C:\\Users\\hemanoel.brito\\Desktop\\estilos\\tabelafap.xlsx") +# tamanho = 20 +# nomeTabela = "ANEXO IV" +# stringTamanho = 0 +# tamanhoestorno = 0 +# estiloAnexoQuatro(tabela,tamanho,nomeTabela,rowBrasilia,tamanhoestorno) + + + + + diff --git a/project/app/estiloIBICT.py b/project/app/estiloIBICT.py old mode 100644 new mode 100755 index 53a4b8f6..e5b84bc1 --- a/project/app/estiloIBICT.py +++ b/project/app/estiloIBICT.py @@ -1,328 +1,1445 @@ import openpyxl from openpyxl.styles import Font, PatternFill, Alignment,NamedStyle,Border, Side -from openpyxl.drawing.image import Image -from PIL import Image as PILImage import os +import random +from PIL import Image as PILImage +from openpyxl.drawing.image import Image #pegar o caminho do arquivo -def pegar_caminho(nome_arquivo): +# def pegar_caminho(nome_arquivo): - # Obter o caminho absoluto do arquivo Python em execução - caminho_script = os.path.abspath(__file__) +# # 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) +# # 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) +# # Combinar o caminho da pasta com o nome do arquivo Excel +# caminho = os.path.join(pasta_script, nome_arquivo) - return caminho +# return caminho + +def pegar_caminho(subdiretorio): + # Obtém o caminho do script atual + arq_atual = os.path.abspath(__file__) + + # Obtém o diretório do script + app = os.path.dirname(arq_atual) + + # Obtém o diretório pai do script + project = os.path.dirname(app) + + # Obtém o diretório pai do projeto + pipeline = os.path.dirname(project) + + # Junta o diretório pai do projeto com o subdiretório desejado + caminho_pipeline = os.path.join(pipeline, subdiretorio) + + return caminho_pipeline +def imagemIbict(tabela,nomeSheet): + '''Estilo da Pagina do Relatorio Execução da Receita e Despesa + + Argumentos: + tabela : recebe o arquivo correspondente a tabela Fub extensão xlsx. Esse arquivo ja foi iniciado e passou pela preencher fub mas ainda esta sem o estilo que sera aplicado nessa função. + nomeSheet = recebe o nome da tabela que tem que preencher com as imagens + -def estiloGeral(tabela,tamanho,nomeVariavel,nomeTabela): - nomeSheet=nomeVariavel + ''' caminho = pegar_caminho(tabela) workbook = openpyxl.load_workbook(caminho) - worksheet = workbook[nomeTabela] - size = tamanho + 16 - cinza = "d9d9d9" - cinza_escuro = "bfbfbf" - azul = "336394" - azul_claro = '1c8cbc' - - borda = Border(right=Side(border_style="dashed")) - 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 + sheet = workbook[nomeSheet] - - #cabecario relação de pagamentos - outro servicoes de terceiros - worksheet.merge_cells('A7:J8') - if nomeSheet == "diarias": - worksheet['A7'] = f'R E L A Ç Ã O D E P A G A M E N T O S -DIÁRIAS E PASSAGENS' - elif nomeSheet == "custoOperacional": - worksheet['A7'] = f'R E L A Ç Ã O D E P A G A M E N T O S - CUSTO OPERACIONAL' - elif nomeSheet == "pessoaJuridica": - worksheet['A7'] = 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 == "bolsaExtensao": - worksheet['A7'] = f'R E L A Ç Ã O D E P A G A M E N T O S - BOLSA DE PESQUISA' - elif nomeSheet == "materialDeConsumo": - worksheet['A7'] = f'R E L A Ç Ã O D E P A G A M E N T O S - MATERIAL DE CONSUMO' - elif nomeSheet == "evento": - worksheet['A7'] = f'R E L A Ç Ã O D E P A G A M E N T O S - EVENTOS' - - - # List of image names image_names = [ - 'finatec.png', - 'ibict.png' + 'ibict.png', + 'finatec.png' + ] - - # # Path to the images - # path = 'C:\\Users\\Softex\\Desktop\\entrega29\\' - - # # 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) - - # List to hold Image objects images = [] - nomePasta = "imagensIBICIT" + nomePasta = "../../imagensIBICIT" diretorio = os.path.dirname(__file__) # Loop through the list of image names and create Image objects for i, name in enumerate(image_names): - caminhoImage = os.path.join(diretorio, nomePasta, name) - pil_image = PILImage.open(caminhoImage) - pil_image.save(caminhoImage) - img = Image(caminhoImage) - images.append(img) + caminhoImage = os.path.join(diretorio, nomePasta, name) + pil_image = PILImage.open(caminhoImage) + pil_image.save(caminhoImage) + img = Image(caminhoImage) + images.append(img) - worksheet.add_image(images[1], "A1")#ibict - worksheet.add_image(images[0], "H1")#finatec - + sheet.add_image(images[0], "A1")#ibict + sheet.add_image(images[0], "D1")#finatec + + # for row in sheet.iter_rows(min_row=1, max_row=size+11,min_col=10,max_col=10): + # for cell in row: + # cell.border = borda + + sheet.row_dimensions[1].height = 25 + sheet.row_dimensions[2].height = 25 + + workbook.save(tabela) + workbook.close() - worksheet['A7'].font = Font(name="Arial", size=12, color="FFFFFF",bold=True) - worksheet['A7'].alignment = Alignment(horizontal="center",vertical="center") - worksheet['A7'].fill = PatternFill(start_color=azul_claro, end_color=azul_claro,fill_type = "solid") +def estiloExecReceitaDespesa(tabela,tamanho,stringTamanho): + '''Estilo da Pagina do Relatorio Execução da Receita e Despesa + + Argumentos: + tabela : recebe o arquivo correspondente a tabela Fub extensão xlsx. Esse arquivo ja foi iniciado e passou pela preencher fub mas ainda esta sem o estilo que sera aplicado nessa função. + tamanho : é o tamanho total de linhas que irão ser geradas dinâmicamente. O valor varia dentre o tamanho da quantidade de rubricas diferente que o projeto possui, excluindo Obras e Instalações + Aplicações Financeira e Equipamento e Material Permanente sendo nacional ou importado. + stringTamanho : refere-se aonde esta localizado a string brasília na pagina Receita e despesa para a referencias das formulas. + + + ''' - worksheet.merge_cells('A9:F9') - worksheet['A9'] = "='Receita x Despesa'!A9:J9" - worksheet['A9'].font = Font(name="Arial", size=12, color="000000") - worksheet['A9'].alignment = Alignment(horizontal="left",vertical="center") + caminho = pegar_caminho(tabela) + workbook = openpyxl.load_workbook(caminho) + sheet = workbook['Exec. Receita e Despesa'] + + size = tamanho + 16; + size2 = size + 1 + cinza = "f1f1f1" + azul_claro = '1c8cbc' + # sheet.row_dimensions[3] = 28 + numRowInicial = 7 + numRowInicialMerge = 8 + variavelA = f'A{numRowInicial}' + + + #cabecario + sheet.merge_cells('A{numRowInicial}:I{numRowInicialMerge}')#7 + sheet['A{numRowInicial}'] = f'E X E C U Ç Ã O D A R E C E I T A E D E S P E S A ' + sheet['A{numRowInicial}'].font = Font(name="Arial", size=12, color="FFFFFF",bold=True) + sheet['A{numRowInicial}'].alignment = Alignment(horizontal="center",vertical="center") + sheet['A{numRowInicial}'].fill = PatternFill(start_color=azul_claro, end_color=azul_claro,fill_type = "solid") + numRowInicial = numRowInicial + 1 + + sheet.merge_cells('A{numRowInicial}:I{numRowInicial}')#8 + sheet['A{numRowInicial}'] = "='Receita x Despesa'!A{numRowInicial}:I{numRowInicial}" + sheet['A{numRowInicial}'].font = Font(name="Arial", size=12, color="000000") + sheet['A{numRowInicial}'].alignment = Alignment(horizontal="left",vertical="center") + numRowInicial = numRowInicial + 1 + - worksheet.merge_cells('A10:F10') - worksheet['A10'] = "='Receita x Despesa'!A10:J10" - worksheet['A10'].font = Font(name="Arial", size=12, color="000000") - worksheet['A10'].alignment = Alignment(horizontal="left",vertical="center") + sheet.merge_cells('A{numRowInicial}:I{numRowInicial}')#9 + sheet['A{numRowInicial}'] = "='Receita x Despesa'!A{numRowInicial}:I{numRowInicial}" + sheet['A{numRowInicial}'].font = Font(name="Arial", size=12, color="000000") + sheet['A{numRowInicial}'].alignment = Alignment(horizontal="left",vertical="center") + numRowInicial = numRowInicial + 1 + - worksheet.merge_cells('A11:F11') - worksheet['A11'] = "='Receita x Despesa'!A11:J11" - worksheet['A11'].font = Font(name="Arial", size=12, color="000000") - worksheet['A11'].alignment = Alignment(horizontal="left",vertical="center") + sheet.merge_cells('A{numRowInicial}:I{numRowInicial}')#10 + sheet['A{numRowInicial}'] = "='Receita x Despesa'!A{numRowInicial}:I{numRowInicial}" + sheet['A{numRowInicial}'].font = Font(name="Arial", size=12, color="000000") + sheet['A{numRowInicial}'].alignment = Alignment(horizontal="left",vertical="center") + numRowInicial = numRowInicial + 1 + - worksheet.merge_cells('A12:F12') - worksheet['A12'] = "='Receita x Despesa'!A12:J12" - worksheet['A12'].font = Font(name="Arial", size=12, color="000000") - worksheet['A12'].alignment = Alignment(horizontal="left",vertical="center") + sheet.merge_cells('A{numRowInicial}:I{numRowInicial}')#11 + sheet['A{numRowInicial}'] = "='Receita x Despesa'!A{numRowInicial}:I{numRowInicial}" + sheet['A{numRowInicial}'].font = Font(name="Arial", size=12, color="000000") + sheet['A{numRowInicial}'].alignment = Alignment(horizontal="left",vertical="center") + numRowInicial = numRowInicial + 1 + - worksheet.merge_cells('A13:F13') - worksheet['A13'] = "='Receita x Despesa'!A13:J13" - worksheet['A13'].font = Font(name="Arial", size=12, color="000000") - worksheet['A13'].alignment = Alignment(horizontal="left",vertical="center") + sheet.merge_cells('A{numRowInicial}:I{numRowInicial}')#12 + sheet['A{numRowInicial}'] = "='Receita x Despesa'!A{numRowInicial}:I{numRowInicial}" + sheet['A{numRowInicial}'].font = Font(name="Arial", size=12, color="000000") + sheet['A{numRowInicial}'].alignment = Alignment(horizontal="left",vertical="center") + numRowInicial = numRowInicial + 1 + - #variavel - - input2=f'rowStyle{nomeVariavel}' + sheet.merge_cells('A{numRowInicial}:I{numRowInicial}')#13 + sheet['A{numRowInicial}'] = 'E X E C U Ç Ã O D A R E C E I T A E D E S P E S A' + sheet['A{numRowInicial}'].font = Font(name="Arial", size=12, color="FFFFFF",bold=True) + sheet['A{numRowInicial}'].alignment = Alignment(horizontal="center",vertical="center") + sheet['A{numRowInicial}'].fill = PatternFill(start_color=azul_claro, end_color=azul_claro,fill_type = "solid") + numRowInicial = numRowInicial + 1 + + #aumentao altura + for i in range(1,10): + sheet.row_dimensions[i].height = 20 + + sheet.row_dimensions[7].height = 25 + sheet.row_dimensions[9].height = 35 + sheet.row_dimensions[8].height = 25 + sheet.row_dimensions[15].height = 30 + + + + #esticando coluna A e pintando ela + numRowInicial = numRowInicial + 1 #ta na 15 + sheet.merge_cells('A{numRowInicial}:A16') + sheet['A{numRowInicial}'].fill = PatternFill(start_color=azul_claro, end_color=azul_claro,fill_type = "solid") + + sheet.column_dimensions['a'].width = 55 + sheet.column_dimensions['b'].width = 20 + sheet.column_dimensions['c'].width = 20 + sheet.column_dimensions['d'].width = 20 + sheet.column_dimensions['e'].width = 20 + sheet.column_dimensions['f'].width = 20 + sheet.column_dimensions['g'].width = 20 + sheet.column_dimensions['h'].width = 20 + sheet.column_dimensions['i'].width = 20 + sheet.column_dimensions['j'].width = 1 + #resto do cabecario + sheet.merge_cells('B12:E13') + sheet['B12'] = 'EXECUTADO NO PERÍODO\n(Valores em R$)' + sheet['B12'].font = Font(name="Arial", size=12, color="FFFFFF",bold=True) + sheet['B12'].alignment = Alignment(horizontal="center",vertical="center") + sheet['B12'].fill = PatternFill(start_color=azul_claro, end_color=azul_claro,fill_type = "solid") + + sheet.merge_cells('F12:I13') + sheet['F12'] = 'ACUMULADO ATÉ O PERÍODO\n(Valores em R$)' + sheet['F12'].font = Font(name="Arial", size=12, color="FFFFFF",bold=True) + sheet['F12'].alignment = Alignment(horizontal="center",vertical="center") + sheet['F12'].fill = PatternFill(start_color=azul_claro, end_color=azul_claro,fill_type = "solid") - #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="thin") ,bottom=Side(border_style="thin") ) - locals()[input2].height = 20 - linha_number = 15 - for row in worksheet.iter_rows(min_row=linha_number, max_row=linha_number, min_col=1, max_col=10): + + + + + + + #%porcentagem Despesas correntes + #IFERROR (C16/B16;0) + #%porcentagem Despesas de Capital + #IFERROR (C16/B16;0) + percentage_style = NamedStyle(name='percentage', number_format='0%') + #diferença e calculo da porcentagem + for row in sheet.iter_rows(min_row=15, max_row=size2+9, min_col=1, max_col=9): for cell in row: - cell.style = locals()[input2] - if cell.column == 10: - cell.border = Border(top=Side(border_style="thin") ,bottom=Side(border_style="thin"), right=Side(border_style="thin") ) + if cell.column == 4: + stringSaldo = f"=B{cell.row} - C{cell.row}" + cell.value = stringSaldo + if cell.column == 8: + stringSaldo = f"=F{cell.row} - G{cell.row}" + cell.value = stringSaldo + + + if cell.column == 5: + stringPorcentagem = f"=IFERROR(C{cell.row}/B{cell.row}, 0)" + cell.value = stringPorcentagem + cell.style = percentage_style + if cell.column == 9: + stringPorcentagem = f"=IFERROR(G{cell.row}/F{cell.row}, 0)" + cell.value = stringPorcentagem + cell.style = percentage_style + + #adicionara mascara do numero + for row in sheet.iter_rows(min_row=15, max_row=size2+9, min_col=1, max_col=9): + for cell in row: + if cell.column != 5 and cell.column != 9: + cell.number_format ='#,##0.00' + + + - 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'] + + + + + #adicionar borda em tudo + borda = Border(right=Side(border_style="medium")) + sheet.sheet_view.showGridLines = False + for row in sheet.iter_rows(min_row=1, max_row=size2+14,min_col=9,max_col=9): + for cell in row: + cell.border = borda + + font = Font(name='Arial', size=12) + #Colocar tudo arial 12 + for row in sheet.iter_rows(min_row=16): + for cell in row: + cell.font = font + #preenche a coluna A e F com cinza + for row in sheet.iter_rows(min_row=16, max_row=size2+9,min_col=1,max_col=9): + for cell in row: + if cell.column == 1 or cell.column == 6 or cell.column == 2: + cell.fill = PatternFill(start_color=cinza, end_color=cinza, + fill_type = "solid") + if cell.column == 6 or cell.column == 2: + cell.fill = PatternFill(start_color=cinza, end_color=cinza, + fill_type = "solid") + cell.font = cell.font = Font(name='Arial', size=12,bold= True) + +###pinta de azul a linha desejada + for row in sheet.iter_rows(min_row=15, max_row=sheet.max_row, min_col=sheet.min_row, max_col= 9): + for cell in row: + if cell.row == 15: + cell.fill = PatternFill(start_color=azul_claro, end_color=azul_claro, + fill_type = "solid") + cell.font = Font(name='Arial', size=12,bold= True) + + if cell.row == size2 or cell.row == size2 +5 or cell.row == size2 + 7 or cell.row== size2+9: + cell.fill = PatternFill(start_color=azul_claro, end_color=azul_claro, + fill_type = "solid") + cell.font = Font(name='Arial', size=12,bold= True) + + + + + #cabecario negrito sem fundo + + valores = ["RUBRICA","PREVISTO","REALIZADO","SALDO",'(%)\nREALIZADO',"PREVISTO","REALIZADO","SALDO","(%)\nREALIZADO"] col = 1 for a,b in enumerate(valores): - worksheet.cell(row=linha_number, column=col, value=b) + sheet.cell(row=14, column=col, value=b) col = col + 1 + #coloca em negrito + font = Font(name='Arial', size=12,bold=True) + #Colocar tudo arial 12 + for row in sheet.iter_rows(min_row=14,max_row=14): + for cell in row: + cell.font = font - #Aumentar a altura das celulas - for row in worksheet.iter_rows(min_row=16, max_row=size, min_col=1, max_col=10): - worksheet.row_dimensions[row[0].row].height = 60 - input3 = f'customNumber{nomeVariavel}' + #depsesas e capital + despesasDeCapitalString = f"I. DESPESAS CORRENTES" + despesasDeCapitalStringCelula = f'A{15}' + sheet[despesasDeCapitalStringCelula] = despesasDeCapitalString + cell=sheet[despesasDeCapitalStringCelula] + cell.font = Font(name="Arial", size=12, color="000000",bold = True) + + + + + #depsesas e capital + despesasDeCapitalString = f"II. DESPESAS DE CAPITAL" + despesasDeCapitalStringCelula = f'A{size2}' + sheet[despesasDeCapitalStringCelula] = despesasDeCapitalString + cell=sheet[despesasDeCapitalStringCelula] + cell.font = Font(name="Arial", size=12, color="000000",bold = True) + - # 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 = 16 -# - 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=16, 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="dashed") ,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="thin") ,right =Side(border_style="thin") ,bottom=Side(border_style="thin") ) - worksheet.row_dimensions[size+2].height = 56.25 + obrasEInstalacoeslString = f"Obras e Instalações" + obrasEInstalacoeslStringCelula = f'A{size2+1}' + sheet[obrasEInstalacoeslStringCelula] = obrasEInstalacoeslString + + + equipamentoseMaterialPermanenteString = f"Equipamentos e Material Permanente" + equipamentoseMaterialPermanenteStringCelula = f'A{size2+2}' + sheet[equipamentoseMaterialPermanenteStringCelula] = equipamentoseMaterialPermanenteString + cell=sheet[equipamentoseMaterialPermanenteStringCelula] + cell.font = Font(name="Arial", size=12, color="000000",bold = True) + cell=sheet[f'B{size2+2}'] + cell.font = Font(name="Arial", size=12, color="000000",bold = True) + + - # 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="dashed") ,bottom=Side(border_style="thin") ) - 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 + nacionalString = f" a) Nacional" + nacionalStringCelula = f'A{size2+3}' + sheet[nacionalStringCelula] = nacionalString + - 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="thin") ,bottom=Side(border_style="thin") ) + importadoString = f" b) Importado" + importadoStringCelula = f'A{size2+4}' + sheet[importadoStringCelula] = importadoString + + + #depsesas e capital + utilRendimentosString = f"III.UTILIZAÇÃO DE RENDIMENTOS" + utilRendimentosStringCelula = f'A{size2+7}' + sheet[utilRendimentosStringCelula] = utilRendimentosString + cell=sheet[utilRendimentosStringCelula] + cell.font = Font(name="Arial", size=12, color="000000",bold = True) + cell=sheet[f'B{size2+1}'] + cell.font = Font(name="Arial", size=12, color="000000",bold = True) + - 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="thin") ,right =Side(border_style="thin") ,bottom=Side(border_style="thin") ) + + apliFinString = f"Aplicação Financeira" + apliFinStringCelula = f'A{size2+8}' + sheet[apliFinStringCelula] = apliFinString + #barra de total nova 22/02 + totalString = f"TOTAL" + totalStringCelula = f'A{size2+5}' + sheet[totalStringCelula] = totalString + cell=sheet[totalStringCelula] + cell.font = Font(name="Arial", size=12, color="000000",bold = True) + cell.fill = PatternFill(start_color='9c9c9c', end_color='9c9c9c',fill_type = "solid") + cell.alignment = Alignment(horizontal="center",vertical="center") - 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 - + + totalString = f"TOTAL" + totalStringCelula = f'A{size2+9}' + sheet[totalStringCelula] = totalString + cell=sheet[totalStringCelula] + cell.font = Font(name="Arial", size=12, color="000000",bold = True) + cell.fill = PatternFill(start_color='9c9c9c', end_color='9c9c9c',fill_type = "solid") + cell.alignment = Alignment(horizontal="center",vertical="center") - merge_formula = f'D{row_number}:E{row_number}' - worksheet.merge_cells(merge_formula) + #barra total nova + + formula = f"=SUM(B{size2}, B15)" + sheet[f'B{size2+5}'] = formula + formula = f"=SUM(C{size2}, C15)" + sheet[f'C{size2+5}'] = formula + + formula = f"=SUM(D{size2}, D15)" + sheet[f'D{size2+5}'] = formula + + formula = f"=SUM(F{size2}, F15)" + sheet[f'F{size2+5}'] = formula + + formula = f"=SUM(G{size2}, G15)" + sheet[f'G{size2+5}'] = formula + + formula = f"=SUM(H{size2},H15)" + sheet[f'H{size2+5}'] = formula + + + #sheet[f'H{size2+5}'] + sheet.row_dimensions[size2 + 6].height = 1 - #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="thin") ,right =Side(border_style="hair") ,bottom=Side(border_style="thin") ) - 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="thin") ,bottom=Side(border_style="thin") ) - #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="thin") ,left = Side(border_style="thin") ,bottom=Side(border_style="thin") ) + #3.UTILIZAÇÂO DE RENDIMENTOS + # formula = f"=SUM(A{size2+8})" + # sheet[f'A{size2+7}'] = formula + formula = f"=SUM(B{size2+8})" + sheet[f'B{size2+7}'] = formula - #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="thin") ,bottom=Side(border_style="thin"),right=Side(border_style="thin") ) + formula = f"=SUM(C{size2+8})" + sheet[f'C{size2+7}'] = formula - worksheet.row_dimensions[total_formula_row].height = 30 - worksheet[total_formula_row_celula] = total_formulaa + formula = f"=SUM(D{size2+8})" + sheet[f'D{size2+7}'] = formula + + formula = f"=SUM(F{size2+8})" + sheet[f'F{size2+7}'] = formula + + formula = f"=SUM(G{size2+8})" + sheet[f'G{size2+7}'] = formula + + formula = f"=SUM(H{size2+8})" + sheet[f'H{size2+7}'] = formula + + ##SOMATORIO NEGATIVO C + Formula = f'=SUMIF(D16:D{size}, "<0")' + sheet[f'C{size2+8}']= Formula + ############## + + ##SOMATORIO NEGATIVO G + Formula = f'=SUMIF(H16:H{size}, "<0")' + sheet[f'G{size2+8}'] = Formula + ############## - #valor + + #totais + #total espesas correntes linha 15 - #brasilia - brasilia_row = size + 7 - brasilia_formula = f"='Receita x Despesa'!A44:J44" - 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") + formula = f"=SUM(B16:B{size})" + sheet['B15'] = formula + formula = f"=SUM(C16:C{size})" + sheet['C15'] = formula + formula = f'=SUMIF(D16:D{size}, ">0")' + sheet['D15'] = formula - #DiretorFinanceiro - diretor_row = size + 8 - diretor_cargo_row = size + 9 - diretor_cpf_row = size + 10 - diretor_nome_formula = f"='Receita x Despesa'!A48" - diretor_cargo_formula = f"='Receita x Despesa'!A49" - diretor_cpf_formula = f"='Receita x Despesa'!A50" - diretor_merge_cells = f'A{diretor_row}:D{diretor_row}' + formula = f"=SUM(F16:F{size})" + sheet['F15'] = formula + formula = f"=SUM(G16:G{size})" + sheet['G15'] = formula + formula = f'=SUMIF(H16:H{size}, ">0")' + sheet['H15'] = formula + + #Total Despesas de Capital + formula = f"=SUM(B{size2+2}:B{size2+4})" + sheet[f'B{size2}'] = formula + + formula = f"=SUM(C{size2+2}:C{size2+4})" + sheet[f'C{size2}'] = formula + + formula = f"=SUM(D{size2+2}:D{size2+4})" + sheet[f'D{size2}'] = formula + + formula = f"=SUM(F{size2+2}:F{size2+4})" + sheet[f'F{size2}'] = formula + + formula = f"=SUM(G{size2+2}:G{size2+4})" + sheet[f'G{size2}'] = formula + + formula = f"=SUM(H{size2+2}:H{size2+4})" + sheet[f'H{size2}'] = formula + + + #Total abaixo de Utilização de rendimentos + + formula = f"=B{size2+8}" + sheet[f'B{size2+9}'] = formula + + formula = f"=C{size2+8}" + sheet[f'C{size2+9}'] = formula + + formula = f"=D{size2+8}" + sheet[f'D{size2+9}'] = formula + + formula = f"=F{size2+8}" + sheet[f'F{size2+9}'] = formula + + formula = f"=G{size2+8}" + sheet[f'G{size2+9}'] = formula + + formula = f"=H{size2+8}" + sheet[f'H{size2+9}'] = formula + + + + #somasaldo h + stringSaldo = f"=SUM(F{size2+8}+G{size2+8})" + + sheet[f"H{size2+8}"] = stringSaldo + + + #brasilia + brasilia_row = size2 + 11 + brasilia_formula = f"='Receita x Despesa'!A{stringTamanho}:I{stringTamanho}" + brasilia_merge_cells = f'A{brasilia_row}:I{brasilia_row}' + sheet.merge_cells(brasilia_merge_cells) + top_left_brasilia_cell_formula = f'A{brasilia_row}' + top_left_brasilia_cell = sheet[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 = size2 + 12 + diretor_cargo_row = size2 + 13 + diretor_cpf_row = size2 + 14 + + diretor_nome_formula = f"Daniel Monteiro Rosa" + diretor_cargo_formula = f"Diretor-Financeiro" + diretor_cpf_formula = f"450.720.272-87" + 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}' + sheet.merge_cells(diretor_merge_cells) + sheet.merge_cells(diretor_cargo_merge_cells) + sheet.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 = sheet[top_left_diretor_cell_formula] + top_left_diretor_cell_cargo_formula = sheet[top_left_diretor_cell_cargo_formula] + top_left_diretor_cell_cpf_formula = sheet[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 = size2 + 12 + coordenadora_cargo_row = size2 + 13 + coordenadora_cpf_row = size2 + 14 + coordenadora_nome_formula = f"='Receita x Despesa'!H{stringTamanho+3}" + coordenadora_cargo_formula = f"='Receita x Despesa'!H{stringTamanho+4}" + coordenadora_cpf_formula = f"='Receita x Despesa'!H{stringTamanho+5}" + coordenadora_merge_cells = f'F{coordenadora_row}:I{coordenadora_row}' + coordenadora_cargo_merge_cells = f'F{coordenadora_cargo_row}:I{coordenadora_cargo_row}' + coordenadora_cpf_merge_cells = f'F{coordenadora_cpf_row}:I{coordenadora_cpf_row}' + sheet.merge_cells(coordenadora_merge_cells) + sheet.merge_cells(coordenadora_cargo_merge_cells) + sheet.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 = sheet[top_left_coordenadora_cell_formula] + top_left_coordenadora_cell_cargo_formula = sheet[top_left_coordenadora_cell_cargo_formula] + top_left_coordenadora_cell_cpf_formula = sheet[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(name="Arial", size=12, color="000000",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")) + # sheet.sheet_view.showGridLines = False + # # + # for row in sheet.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 sheet.iter_rows(min_row=coordenadora_cpf_row+1, max_row=coordenadora_cpf_row+1,min_col=1,max_col=9): + for cell in row: + if cell.column == 9: + 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") ) + + + + #bordinha branca + + for row in sheet.iter_rows(min_row=1,max_row=coordenadora_cpf_row,min_col=1,max_col=10): + for cell in row: + + if cell.row == 15: + cell.border = Border(left=Side(border_style='thin', color='FFFFFF'), # white + right=Side(border_style='thin', color='FFFFFF'), + top=Side(border_style='thin', color='FFFFFF'), + bottom=Side(border_style='thin', color='FFFFFF')) + if cell.column == 9: + cell.border = Border(left=Side(border_style='thin', color='FFFFFF'), # white + right=Side(border_style='medium', color='000000'), + top=Side(border_style='thin', color='FFFFFF'), + bottom=Side(border_style='thin', color='FFFFFF')) + if cell.row == size2: + cell.border = Border(left=Side(border_style='thin', color='FFFFFF'), # white + right=Side(border_style='thin', color='FFFFFF'), + top=Side(border_style='thin', color='FFFFFF'), + bottom=Side(border_style='thin', color='FFFFFF')) + if cell.column == 9: + cell.border = Border(left=Side(border_style='thin', color='FFFFFF'), # white + right=Side(border_style='medium', color='000000'), + top=Side(border_style='thin', color='FFFFFF'), + bottom=Side(border_style='thin', color='FFFFFF')) + + if cell.row == size2+5: + cell.border = Border(left=Side(border_style='thin', color='FFFFFF'), # white + right=Side(border_style='thin', color='FFFFFF'), + top=Side(border_style='thin', color='FFFFFF'), + bottom=Side(border_style='thin', color='FFFFFF')) + if cell.column == 9: + cell.border = Border(left=Side(border_style='thin', color='FFFFFF'), # white + right=Side(border_style='medium', color='000000'), + top=Side(border_style='thin', color='FFFFFF'), + bottom=Side(border_style='thin', color='FFFFFF')) + if cell.row == size2+7: + cell.border = Border(left=Side(border_style='thin', color='FFFFFF'), # white + right=Side(border_style='thin', color='FFFFFF'), + top=Side(border_style='thin', color='FFFFFF'), + bottom=Side(border_style='thin', color='FFFFFF')) + if cell.column == 9: + cell.border = Border(left=Side(border_style='thin', color='FFFFFF'), # white + right=Side(border_style='medium', color='000000'), + top=Side(border_style='thin', color='FFFFFF'), + bottom=Side(border_style='thin', color='FFFFFF')) + if cell.row == size2+9: + cell.border = Border(left=Side(border_style='thin', color='FFFFFF'), # white + right=Side(border_style='thin', color='FFFFFF'), + top=Side(border_style='thin', color='FFFFFF'), + bottom=Side(border_style='thin', color='FFFFFF')) + if cell.column == 9: + cell.border = Border(left=Side(border_style='thin', color='FFFFFF'), # white + right=Side(border_style='medium', color='000000'), + top=Side(border_style='thin', color='FFFFFF'), + bottom=Side(border_style='thin', color='FFFFFF')) + + for row in sheet.iter_rows(min_row=1,max_row=coordenadora_cpf_row,min_col=10,max_col=10): + cell.border = Border(left=Side(border_style='medium', color='000000')) + + workbook.save(tabela) + workbook.close() + + + + + + + return 0 + +def estiloReceitaXDespesa(tabela,stringTamanho): + '''Estilo da Pagina do Relatorio Receita e Despesa. + + Argumentos: + tabela : recebe o arquivo correspondente a tabela Fub extensão xlsx. Esse arquivo ja foi iniciado e passou pela preencher fub mas ainda esta sem o estilo que sera aplicado nessa função. + + stringTamanho : refere-se aonde esta localizado a string Brasilia nessa pagina, ela pega o valor entre o tamanho quantidade de rubricas que o projeto possui salvo algumas exeções + e a entrada de receitas/iss, oque for maior esse ditará tamanho. + ''' + + caminho = pegar_caminho(tabela) + #Plan = planilha + # carrega a planilha de acordo com o caminho + workbook = openpyxl.load_workbook(caminho) + sheet = workbook['Receita x Despesa'] + size = stringTamanho + 16; + size2 = size + 5 + cinza = "d9d9d9" + azul_claro = '1c8cbc' + # sheet.row_dimensions[3] = 28 + + + + #cabecario relação de pagamentos - outro servicoes de terceiros + sheet.merge_cells('A1:J2') + sheet['A1'] = f'D E M O N S T R A T I V O D E R E C E I T A E D E S P E S A' + sheet['A1'].font = Font(name="Arial", size=12, color="FFFFFF",bold=True) + sheet['A1'].alignment = Alignment(horizontal="center",vertical="center") + sheet['A1'].fill = PatternFill(start_color=azul_claro, end_color=azul_claro,fill_type = "solid") + + sheet.merge_cells('A3:J3') + sheet['A3'] = "" + sheet['A3'].font = Font(name="Arial", size=12, color="000000") + sheet['A3'].alignment = Alignment(horizontal="left",vertical="center",wrap_text=True) + + sheet.merge_cells('A4:J4') + sheet['A4'] = "" + sheet['A4'].font = Font(name="Arial", size=12, color="000000") + sheet['A4'].alignment = Alignment(horizontal="left",vertical="center") + + sheet.merge_cells('A5:J5') + sheet['A5'] = "" + sheet['A5'].font = Font(name="Arial", size=12, color="000000") + sheet['A5'].alignment = Alignment(horizontal="left",vertical="center") + + sheet.merge_cells('A6:J6') + sheet['A6'] = "" + sheet['A6'].font = Font(name="Arial", size=12, color="000000") + sheet['A6'].alignment = Alignment(horizontal="left",vertical="center") + + sheet.merge_cells('A7:J7') + sheet['A7'] = "" + sheet['A7'].font = Font(name="Arial", size=12, color="000000") + sheet['A7'].alignment = Alignment(horizontal="left",vertical="center") + + sheet.merge_cells('A9:J9') + sheet['A9'] = 'R E C E I T A E D E S P E S A' + sheet['A9'].font = Font(name="Arial", size=12, color="FFFFFF",bold=True) + sheet['A9'].alignment = Alignment(horizontal="center",vertical="center") + sheet['A9'].fill = PatternFill(start_color=azul_claro, end_color=azul_claro,fill_type = "solid") + + for i in range(1,10): + sheet.row_dimensions[i].height = 20 + + sheet.row_dimensions[1].height = 25 + sheet.row_dimensions[3].height = 35 + sheet.row_dimensions[2].height = 25 + sheet.row_dimensions[9].height = 30 + sheet.column_dimensions['b'].width = 40 + sheet.column_dimensions['c'].width = 30 + sheet.column_dimensions['d'].width = 30 + sheet.column_dimensions['e'].width = 30 + sheet.column_dimensions['f'].width = 30 + sheet.column_dimensions['i'].width = 30 + sheet.column_dimensions['j'].width = 30 + #barra cinza + + barrazinzaMerge = f"A{11}:J{11}" + sheet.merge_cells(barrazinzaMerge) + barrazinzaStringCelula = f"A{11}" + cell = sheet[barrazinzaStringCelula] + cell.fill = PatternFill(start_color=cinza, end_color=cinza, + fill_type = "solid") + cell.alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + + + + + #adicionar borda em tudo + borda = Border(right=Side(border_style="medium")) + sheet.sheet_view.showGridLines = False + for row in sheet.iter_rows(min_row=1, max_row=size2+21,min_col=10,max_col=10): + for cell in row: + cell.border = borda + + + + + + #merge das receitas + for i in range(16,size): + sttring = f"C{i}:D{i}" + sheet.merge_cells(sttring) + + + font = Font(name='Arial', size=12) + #Colocar tudo arial 12 + for row in sheet.iter_rows(min_row=16): + for cell in row: + cell.font = font + + #mascara de dinheiro despesas correntes + for row in sheet.iter_rows(min_row=16,max_row=size,min_col=5,max_col=5): + for cell in row: + cell.number_format = 'R$ #,##0.00' + + #mascara de dinehrio despesas realizadas + for row in sheet.iter_rows(min_row=16,max_row=size,min_col=9,max_col=9): + for cell in row: + cell.number_format = 'R$ #,##0.00' + + + #preenche qualquer linha com cinza + for row in sheet.iter_rows(min_row=16, max_row=sheet.max_row, min_col=sheet.min_row, max_col= sheet.max_column): + for cell in row: + if cell.row == size2+2 or cell.row == size2 +12: + cell.fill = PatternFill(start_color=cinza, end_color=cinza, + fill_type = "solid") + + + + + #Receita + + rendimentoDeAplicacaoFinanceiraMerge = f"A{size2+2}:E{size2+2}" + sheet.merge_cells(rendimentoDeAplicacaoFinanceiraMerge) + rendimentoDeAplicacaoFinanceiraString= f"Rendimento de Aplicação financeira" + rendimentoDeAplicacaoFinanceiraStringCelula = f"A{size2+2}" + sheet[rendimentoDeAplicacaoFinanceiraStringCelula] = rendimentoDeAplicacaoFinanceiraString + cell=sheet[f'A{size2+2}'] + cell.fill = PatternFill(start_color=cinza, end_color=cinza, + fill_type = "solid") + cell.font = Font(name="Arial", size=12, color="000000",bold = True) + + + #Rendimento de aplicação financeira formula + formula = f"=SUM(E{size2+3}:E{size2+6})" + celula = f'F{size2+2}' + sheet[celula] = formula + cell=sheet[f'F{size2+2}'] + cell.fill = PatternFill(start_color=cinza, end_color=cinza, + fill_type = "solid") + cell.font = Font(name="Arial", size=12, color="000000",bold = True) + cell.number_format = 'R$ #,##0.00' + + #soma despesas realizadas + formula = f"=SUM(I{16}:I{size+5})" + celula = f'J13' + sheet[celula] = formula + + #soma saldo conciliado + formula = f'=SUM(I{size2+4}+I{size2+5}+I{size2+6}+I{size2+9})' + celula = f'J{size2+2}' + sheet[celula] = formula + + #valores recebidos no periodo + formula = f"=SUM(E{14}:E{size2+1})" + celula = f'F13' + sheet[celula] = formula + + #SUM total receita + + formula = f'=SUM(F{size2+2}+F13)' + celula = f'F{size2+12}' + sheet[celula] = formula + + #SUM total despesa + formula = f'=SUM(J{size2+2}+J13)' + celula = f'J{size2+12}' + sheet[celula] = formula + + #sum II. DESPESAS DE CAPITAl + formula = f'=SUM(I{size+2}:I{size+5})' + celula = f'I{size+1}' + sheet[celula] = formula + + #Despesas realizadas + #depsesas e capital + despesasDeCapitalString = f"II. DESPESAS DE CAPITAL" + despesasDeCapitalStringCelula = f'H{size+1}' + sheet[despesasDeCapitalStringCelula] = despesasDeCapitalString + cell=sheet[despesasDeCapitalStringCelula] + cell.font = Font(name="Arial", size=12, color="000000",bold = True) + cell=sheet[f'I{size+1}'] + cell.font = Font(name="Arial", size=12, color="000000",bold = True) + cell.number_format = 'R$ #,##0.00' + + + + obrasEInstalacoeslString = f"Obras e Instalações" + obrasEInstalacoeslStringCelula = f'H{size+2}' + sheet[obrasEInstalacoeslStringCelula] = obrasEInstalacoeslString + cell=sheet[f'I{size+2}'] + cell.font = Font(name="Arial", size=12, color="000000") + cell.number_format = 'R$ #,##0.00' + + + equipamentoseMaterialPermanenteString = f"Equipamentos e Material Permanente" + equipamentoseMaterialPermanenteStringCelula = f'H{size+3}' + sheet[equipamentoseMaterialPermanenteStringCelula] = equipamentoseMaterialPermanenteString + cell=sheet[equipamentoseMaterialPermanenteStringCelula] + cell.font = Font(name="Arial", size=12, color="000000",bold = True) + cell=sheet[f'I{size+3}'] + cell.font = Font(name="Arial", size=12, color="000000",bold = True) + cell.number_format = 'R$ #,##0.00' + + + nacionalString = f" a) Nacional" + nacionalStringCelula = f'H{size+4}' + sheet[nacionalStringCelula] = nacionalString + cell=sheet[f'I{size+4}'] + cell.font = Font(name="Arial", size=12, color="000000") + cell.number_format = 'R$ #,##0.00' + + + importadoString = f" b) Importado" + importadoStringCelula = f'H{size+5}' + sheet[importadoStringCelula] = importadoString + cell=sheet[f'I{size+5}'] + cell.font = Font(name="Arial", size=12, color="000000") + cell.number_format = 'R$ #,##0.00' + + #saldo conciliado em: + + saldoConciliadoEmString= f"Saldo Conciliado em: " + saldoConciliadoEmStringCelula = f"H{size2+2}" + sheet[saldoConciliadoEmStringCelula] = saldoConciliadoEmString + cell=sheet[saldoConciliadoEmStringCelula] + cell.font = Font(name="Arial", size=12, color="000000",bold = True) + cell.fill = PatternFill(start_color=cinza, end_color=cinza, + fill_type = "solid") + + ##saldo conciliado formula + cell=sheet[f'J{size2+2}'] + cell.fill = PatternFill(start_color=cinza, end_color=cinza, + fill_type = "solid") + cell.font = Font(name="Arial", size=12, color="000000",bold = True) + cell.number_format = 'R$ #,##0.00' + + #mergecelulasabaixo de Rendimento de Aplicação financeira + for i in range(size2+3,size2+6): + sttring = f"A{i}:D{i}" + sheet.merge_cells(sttring) + + + + contaCorrenteEmString= f"Conta Corrente" + contaCorrenteEmStringCelula = f"H{size2+4}" + sheet[contaCorrenteEmStringCelula] = contaCorrenteEmString + cell=sheet[f'I{size2+4}'] + cell.font = Font(name="Arial", size=12, color="000000") + cell.number_format = 'R$ #,##0.00' + + devolucaoRecursosEmString= f"Devolução de recursos - GRU SIMPLES" + devolucaoRecursosEmStringCelula = f"H{size2+5}" + sheet[devolucaoRecursosEmStringCelula] = devolucaoRecursosEmString + cell=sheet[f'I{size2+5}'] + cell.font = Font(name="Arial", size=12, color="000000") + cell.number_format = 'R$ #,##0.00' + + tarifaBancariaSaldoEmString= f"Tarifa Bancária - Saldo" + tarifaBancariaSaldoEmStringCelula = f"H{size2+6}" + sheet[tarifaBancariaSaldoEmStringCelula] = tarifaBancariaSaldoEmString + cell=sheet[saldoConciliadoEmStringCelula] + cell.font = Font(name="Arial", size=12, color="000000",bold = True) + cell=sheet[f'I{size2+6}'] + cell.value= f"=I{size2+7}-I{size2+8}" + cell.font = Font(name="Arial", size=12, color="000000",bold = True) + cell.number_format = 'R$ #,##0.00' + + tarifaBancariaDespesaEmString= f"Tarifa Bancária - Despesa (-)" + tarifaBancariaDespesaEmStringCelula = f"H{size2+7}" + sheet[tarifaBancariaDespesaEmStringCelula] = tarifaBancariaDespesaEmString + cell=sheet[f'I{size2+7}'] + cell.font = Font(name="Arial", size=12, color="000000") + cell.number_format = 'R$ #,##0.00' + + TarifaBancariaRestituicaoEmString= f"Tarifa Bancária - Restituição (+)" + TarifaBancariaRestituicaoEmStringCelula = f"H{size2+8}" + sheet[TarifaBancariaRestituicaoEmStringCelula] = TarifaBancariaRestituicaoEmString + cell=sheet[f'I{size2+8}'] + cell.number_format = 'R$ #,##0.00' + + aplicacaoFinanceiraEmString= f"Aplicação Financeira" + aplicacaoFinanceiraEmStringCelula = f"H{size2+9}" + sheet[aplicacaoFinanceiraEmStringCelula] = aplicacaoFinanceiraEmString + cell=sheet[aplicacaoFinanceiraEmStringCelula] + cell.font = Font(name="Arial", size=12, color="000000",bold = True) + cell=sheet[f'I{size2+9}'] + cell.font = Font(name="Arial", size=12, color="000000",bold = True) + cell.number_format = 'R$ #,##0.00' + + rendimentoDeaplicacaoEmString= f"Rendimento de aplicação financeira" + rendimentoDeaplicacaoEmStringCelula = f"H{size2+10}" + sheet[rendimentoDeaplicacaoEmStringCelula] = rendimentoDeaplicacaoEmString + + cell=sheet[f'I{size2+10}'] + cell.number_format = 'R$ #,##0.00' + + #Total Receita + + totalMerge = f"A{size2+12}:E{size2+12}" + sheet.merge_cells(totalMerge) + totalString= f"TOTAL" + totalStringCelula = f"A{size2+12}" + sheet[totalStringCelula] = totalString + + cell = sheet[totalStringCelula] + cell.fill = PatternFill(start_color=cinza, end_color=cinza, + fill_type = "solid") + cell.font = Font(name="Arial", size=12, color="000000",bold = True) + cell.alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + + #TotalReceitaFormula + cell=sheet[f'F{size2+12}'] + cell.fill = PatternFill(start_color=cinza, end_color=cinza, + fill_type = "solid") + cell.font = Font(name="Arial", size=12, color="000000",bold = True) + cell.number_format = 'R$ #,##0.00' + #Total Despesa + + totalMerge = f"H{size2+12}:I{size2+12}" + sheet.merge_cells(totalMerge) + totalString= f"TOTAL" + totalStringCelula = f"H{size2+12}" + sheet[totalStringCelula] = totalString + cell = sheet[totalStringCelula] + cell.fill = PatternFill(start_color=cinza, end_color=cinza, + fill_type = "solid") + cell.font = Font(name="Arial", size=12, color="000000",bold=True) + cell.alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + #Total Despesa Formula + cell=sheet[f'J{size2+12}'] + cell.fill = PatternFill(start_color=cinza, end_color=cinza, + fill_type = "solid") + cell.font = Font(name="Arial", size=12, color="000000",bold = True) + cell.number_format = 'R$ #,##0.00' + + + #Barraazul + + barrazulMerge = f"A{size2+14}:J{size2+14}" + sheet.merge_cells(barrazulMerge) + barrazulStringCelula = f"A{size2+14}" + cell = sheet[barrazulStringCelula] + + cell.fill = PatternFill(start_color=azul_claro, end_color=azul_claro, + fill_type = "solid") + cell.alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + + + + #brasilia + brasilia_row = size2 + 16 + brasilia_formula = f"" + brasilia_merge_cells = f'A{brasilia_row}:I{brasilia_row}' + sheet.merge_cells(brasilia_merge_cells) + top_left_brasilia_cell_formula = f'A{brasilia_row}' + top_left_brasilia_cell = sheet[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 = size2 + 19 + diretor_cargo_row = size2 + 20 + diretor_cpf_row = size2 + 21 + diretor_nome_formula = f"Daniel Monteiro Rosa" + diretor_cargo_formula = f"Diretor-Financeiro" + diretor_cpf_formula = f"450.720.272-87" + 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}' + sheet.merge_cells(diretor_merge_cells) + sheet.merge_cells(diretor_cargo_merge_cells) + sheet.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 = sheet[top_left_diretor_cell_formula] + top_left_diretor_cell_cargo_formula = sheet[top_left_diretor_cell_cargo_formula] + top_left_diretor_cell_cpf_formula = sheet[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(name="Arial", size=12,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 = size2 + 19 + coordenadora_cargo_row = size2 + 20 + coordenadora_cpf_row = size2 + 21 + coordenadora_nome_formula = f"teste" + coordenadora_cargo_formula = f"Coordenador(a)" + coordenadora_cpf_formula = f"teste" + coordenadora_merge_cells = f'H{coordenadora_row}:J{coordenadora_row}' + coordenadora_cargo_merge_cells = f'H{coordenadora_cargo_row}:J{coordenadora_cargo_row}' + coordenadora_cpf_merge_cells = f'H{coordenadora_cpf_row}:J{coordenadora_cpf_row}' + sheet.merge_cells(coordenadora_merge_cells) + sheet.merge_cells(coordenadora_cargo_merge_cells) + sheet.merge_cells(coordenadora_cpf_merge_cells) + top_left_coordenadora_cell_formula = f'H{coordenadora_row}' + top_left_coordenadora_cell_cargo_formula = f'H{coordenadora_cargo_row}' + top_left_coordenadora_cell_cpf_formula = f'H{coordenadora_cpf_row}' + top_left_coordenadora_cell = sheet[top_left_coordenadora_cell_formula] + top_left_coordenadora_cell_cargo_formula = sheet[top_left_coordenadora_cell_cargo_formula] + top_left_coordenadora_cell_cpf_formula = sheet[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(name="Arial", size=12, color="000000",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 sheet.iter_rows(min_row=1,max_row=coordenadora_cpf_row,min_col=10,max_col=10): + for cell in row: + cell.border = Border(top=Side(border_style="none") ,left = Side(border_style="none") ,right =Side(border_style="medium") ,bottom=Side(border_style="none") ) + + for row in sheet.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") ) + + # #deixar azul a letra de receita + # cell=sheet['E16'] + # cell.font = Font(name="Arial", size=12,color="0000FF") + # #deixar VERMELHO a letra de receita + # cell=sheet[f'E{17}'] + # cell.font = Font(name="Arial", size=12,color="FF0000") + + # cell=sheet[f'E{18}'] + # cell.font = Font(name="Arial", size=12,color="FF0000") + + workbook.save(tabela) + workbook.close() + + # print(f'printandosize2') + # print(size2) + #retorna tamanho de brasilia e de equipamentos + return size2 + 16,size+3 + +def estiloGeral(tabela,tamanho,nomeVariavel,nomeTabela,stringTamanho,tamanhoestorno): + '''Esse estilo e considerado geral por que todas as tabelas que compõe utilizam das mesma colunas. + + Argumentos: + tabela: recebe o arquivo correspondente a tabela Fub extensão xlsx. Esse arquivo ja foi iniciado e passou pela preencher fub mas ainda esta sem o estilo que sera aplicado nessa função. + tamanho: e o tamanho total de linhas que irao ser geradas dinamicamente correspondente as entradas do respectivo projeto. o valor varia dentre o tamanho das rubricas + + nomeVariavel: variável utilizada para criar o nomes das variaveis dinamicamente para não haver sobreposição de estilos com o mesmo nome. Esses estilos ocorrem nesses codigos: + 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"'.... + nomeTabela: variável utilizada para a criação do nome da tabela.Ela deriva das rubricas que são colocadas no input quando essa função e chamada. + stringTamanho: refere-se aonde esta localizado a string brasilia na pagina Receita e despesa para a referencias das formulas. + tamanhoEstorno = Correspondente ao tamanho do estrono + ''' + + nomeSheet=nomeVariavel + random_number = random.randint(1, 10000) + nomeVariavel = f'{nomeVariavel}{random_number}' + 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+12,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') + nomeTabela = nomeTabela.upper() + worksheet['A1'] = f'R E L A Ç Ã O D E P A G A M E N T O S - {nomeTabela}' + + # 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 == "auxilio": + # 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 E PESQUISADOR' + # 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' + # elif nomeSheet == "isss": + # worksheet['A1'] = f'ISS 5% e ISS 2%' + + + + 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:J3') + 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:J4') + 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:J5') + 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:J6') + 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:J7') + 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 = 75 + 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) + + #mergecells + for x in range(size+4,size+5+tamanhoestorno): + worksheet.merge_cells(start_row=x ,start_column=4, end_row=x, end_column=5) + + + #estorno + + for rows in worksheet.iter_rows(min_row=size+5, max_row=size+4+tamanhoestorno, min_col=1, max_col=10): + for cell in rows: + if cell.row % 2: + cell.font = Font(name="Arial", size=12, color="000000") + cell.fill = PatternFill(start_color=cinza, end_color=cinza, + fill_type = "solid") + if cell.column == 10: + cell.number_format = 'R$ #,##0.00' + cell.font = Font(name="Arial", size=12, color="000000") + + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,right =Side(border_style="hair") ,bottom=Side(border_style="hair")) + cell.font = Font(name="Arial", size=12, color="000000") + + + #bordas,corsimcornao,money + # Set the height of each row to 60 + for row in worksheet.iter_rows(min_row=size+4, max_row=size+4+tamanhoestorno): + worksheet.row_dimensions[row[0].row].height = 75 + + min_row = size + 4 + max_row = size + 4 + tamanhoestorno + + + + #subtotal2 + sub_total2_row = size + 6 +tamanhoestorno + 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].value = f'=SUM(J{size+5}:J{sub_total2_row-1})' + 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 + 7 + tamanhoestorno + 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 + 7 + tamanhoestorno + total_formulaa = f'=J{size+2} - J{sub_total2_row }' + 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 + 8 +tamanhoestorno + brasilia_formula = f"='Receita x Despesa'!A{stringTamanho}:J{stringTamanho}" + 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 + 9 + tamanhoestorno + diretor_cargo_row = size + 10 + tamanhoestorno + diretor_cpf_row = size + 11 + tamanhoestorno + + diretor_nome_formula = f"='Receita x Despesa'!A{stringTamanho+3}" + diretor_cargo_formula = f"='Receita x Despesa'!A{stringTamanho+4}" + diretor_cpf_formula = f"='Receita x Despesa'!A{stringTamanho+5}" + 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) @@ -342,21 +1459,359 @@ def estiloGeral(tabela,tamanho,nomeVariavel,nomeTabela): 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'!G48" - coordenadora_cargo_formula = f"='Receita x Despesa'!G49" - coordenadora_cpf_formula = f"='Receita x Despesa'!G50" - 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}' + coordenadora_row = size + 9 + tamanhoestorno + coordenadora_cargo_row = size + 10 + tamanhoestorno + coordenadora_cpf_row = diretor_cpf_row + coordenadora_nome_formula = f"='Receita x Despesa'!H{stringTamanho+3}" + coordenadora_cargo_formula = f"='Receita x Despesa'!H{stringTamanho+4}" + coordenadora_cpf_formula = f"='Receita x Despesa'!H{stringTamanho+5}" + 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(name="Arial", size=12, color="000000",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=1, max_row=coordenadora_cpf_row+1,min_col=11,max_col=11): + for cell in row: + cell.border = Border(top=Side(border_style="none") ,left = Side(border_style="medium") ,right =Side(border_style="none") ,bottom=Side(border_style="none") ) + + 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() + + return size+4 + +def estilo_conciliacoes_bancaria(tabela,tamanho,tamanho2,stringTamanho): + """Estilo um pouco diferente pois necessita de dois aspectos dinâmicos que é primeiramente a quantidade de entradas de pagamento de tarifas bancárias e por fim a quantidade de estorno. Sabendo + esses valores é possivel criar a tabela. + + Argumentos: + tabela: recebe o arquivo correspondente a tabela Fub extensão xlsx. Esse arquivo foi iniciado e passou pela preencher fub mas ainda está sem o estilo que será aplicado nessa função. + tamanho:Corresponde ao tamanho das quantidade de transfêrencia bancárias realizada. + tamanho2:Corresponde ao tamanho dos estornos. + stringTamanho: refere-se aonde esta localizado a string brasilia na pagina Receita e despesa para a referências das formulas. + """ + + #pegar o arquivo e carregar ele um worksheet da pagaina Conciliação Bancária + caminho = pegar_caminho(tabela) + workbook = openpyxl.load_workbook(caminho) + worksheet = workbook['Conciliação Bancária'] + + #size e o tamanho da quantidade de arquivos recebido no argumento tamanho mais o tamanho do cabecario que no caso da fub e de 16 + size = tamanho + 17 + cinza = "d9d9d9" + cinza_escuro = "bfbfbf" + azul = "336394" + azul_claro = '1c8cbc' + + #Borda apenas do lado direito da cedula, uma borda mas larga + 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+4+tamanho2+1): + sttring = f"D{i}:F{i}" + worksheet.merge_cells(sttring) + + random_number = random.randint(1, 10000) + + custom_number_format_conciliacoes = [] + # MASCARA R$ + if custom_number_format_conciliacoes!= False: + custom_number_format_conciliacoes = NamedStyle(name=f'custom_number_format_conciliacoes{random_number}') + 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) + cell.alignment = Alignment(horizontal="center",vertical="center") + + #saldo anterior restituição + row_restituicao = f'A{size+4}' + worksheet[row_restituicao] = 'Saldo anterior' + worksheet[row_restituicao].font = Font(name="Arial", size=12, color="000000") + worksheet[row_restituicao].alignment = Alignment(horizontal="left",vertical="center") + row_restituicao = f'b{size+4}' + worksheet[row_restituicao].font = Font(name="Arial", size=12, color="000000") + worksheet[row_restituicao].alignment = Alignment(horizontal="left",vertical="center") + row_restituicao = f'c{size+4}' + worksheet[row_restituicao] = 'Diversos' + worksheet[row_restituicao].font = Font(name="Arial", size=12, color="000000") + worksheet[row_restituicao].alignment = Alignment(horizontal="left",vertical="center") + row_restituicao = f'd{size+4}' + worksheet[row_restituicao] = 'Restituição Prestações Anteriores' + worksheet[row_restituicao].font = Font(name="Arial", size=12, color="000000") + worksheet[row_restituicao].alignment = Alignment(horizontal="left",vertical="center") + + + + size = size + 1 + + for row in range(size+3,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+tamanho2, 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+3}:B{size+tamanho2+3})" + celula = f'B{size+tamanho2+5}' + 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+5}' + 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=f'saldodiposnivelformat_conciliacoes{random_number}') + 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-1} -B{size+tamanho2+5}' + #saldo anterior + formula = f"Saldo anterior" + celula = f'A16' + worksheet[celula] = formula + worksheet[celula].font = Font(name="Arial", size=12, color="000000") + + formula = f"Diversos" + celula = f'C16' + worksheet[celula] = formula + worksheet[celula].font = Font(name="Arial", size=12, color="000000") + + formula = f"Tarifas Prestações Anteriores" + celula = f'D16' + worksheet[celula] = formula + worksheet[celula].font = Font(name="Arial", size=12, color="000000") + + #brasilia + brasilia_row = size + tamanho2+ 8 + brasilia_formula = f"='Receita x Despesa'!A{stringTamanho}:J{stringTamanho}" + 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'!A{stringTamanho+3}" + diretor_cargo_formula = f"='Receita x Despesa'!A{stringTamanho+4}" + diretor_cpf_formula = f"='Receita x Despesa'!A{stringTamanho+5}" + 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 = diretor_row + coordenadora_cargo_row = diretor_cargo_row + coordenadora_cpf_row = diretor_cpf_row + coordenadora_nome_formula = f"='Receita x Despesa'!H{stringTamanho+3}" + coordenadora_cargo_formula = f"='Receita x Despesa'!H{stringTamanho+4}" + coordenadora_cpf_formula = f"='Receita x Despesa'!H{stringTamanho+5}" + 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'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_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] @@ -364,325 +1819,547 @@ def estiloGeral(tabela,tamanho,nomeVariavel,nomeTabela): 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.border = borda + top_left_coordenadora_cell.font= Font(name="Arial", size=12, color="000000",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=coordenadora_cpf_row+1,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,stringTamanho): + """Estilo da rendimento de aplicação, tabela com as colunas periodo, saldo anterior,valor aplicado no período,valor resgatado no período,rendimento bruto,imposto,rendimento luiquido,saldo. - # borda = Border(right=Side(border_style="thin")) - # 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 - + Argumentos: + tabela: recebe o arquivo correspondente a tabela Fub extensão xlsx. Esse arquivo foi iniciado e passou pela preencher fub mas ainda está sem o estilo que será aplicado nessa função. + tamanho:Corresponde ao tamanho das quantidade da tabela de rencimentos. + stringTamanho: refere-se aonde esta localizado a string brasilia na pagina Receita e despesa para a referências das formulas. + """ + caminho = pegar_caminho(tabela) + workbook = openpyxl.load_workbook(caminho) + worksheet = workbook['Rendimento de Aplicação'] + + random_number = random.randint(1, 10000) + size = tamanho + 15 + 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) + + + #RENDIMENTO LIQUIDO + # print(size) + for row in worksheet.iter_rows(min_row=14, max_row=size, min_col=7, max_col=7): + for cell in row: + stringSaldo = f"=E{cell.row} - F{cell.row}" + cell.value = stringSaldo + + + + + #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") + cell.number_format ='#,##0.00' + + #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=6, max_col=6): + # for cell in rows: + # cell.font = Font(name="Arial", size=12, color="141fca") + # cell.number_format ='#,##0.00' + + # 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) + # cell.number_format ='#,##0.00' + + #barra de totais + formula = f"Saldo anterior" + celula = f'A14' + worksheet[celula] = formula + worksheet[celula].font = Font(name="Arial", size=12, color="000000",bold=True) + #barra de totais + # FORMULATOTAL + #B + formula = f"=SUM(B15: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) + #C + formula = f"=SUM(C15: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(D15: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(E15: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(F15: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(G15: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(H15: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'!A{stringTamanho}:J{stringTamanho}" + 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'!A{stringTamanho+3}" + diretor_cargo_formula = f"='Receita x Despesa'!A{stringTamanho+4}" + diretor_cpf_formula = f"='Receita x Despesa'!A{stringTamanho+5}" + 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'!H{stringTamanho+3}" + coordenadora_cargo_formula = f"='Receita x Despesa'!H{stringTamanho+4}" + coordenadora_cpf_formula = f"='Receita x Despesa'!H{stringTamanho+5}" + 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(name="Arial", size=12, color="000000",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=10): + + 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 == 10: - cell.border = Border(top=Side(border_style="none") ,left = Side(border_style="none") ,right =Side(border_style="dashed") ,bottom=Side(border_style="dashed") ) + 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="dashed") ) + cell.border = Border(top=Side(border_style="none") ,left = Side(border_style="none") ,right =Side(border_style="none") ,bottom=Side(border_style="medium") ) + - bord = Border(right=Side(border_style="dashed")) - - # - for row in worksheet.iter_rows(min_row=1, max_row=14,min_col=10,max_col=10): - for cell in row: - cell.border = bord - workbook.save(tabela) workbook.close() -def estilo_conciliacoes_bancaria(tabela,tamanho,tamanho2): +def estiloRelacaoBens(tabela,tamanho,nomeVariavel,nomeTabela,stringTamanho): + """Estilo da tabela de bens, consulta no banco sap - + Argumentos: + tabela: recebe o arquivo correspondente a tabela Fub extensão xlsx. Esse arquivo foi iniciado e passou pela preencher fub mas ainda está sem o estilo que será aplicado nessa função. + tamanho:Corresponde ao tamanho das quantidade de bens. + stringTamanho: refere-se aonde esta localizado a string brasilia na pagina Receita e despesa para a referências das formulas. + """ + random_number = random.randint(1, 10000) + + nomeVariavel = f'material{random_number}' caminho = pegar_caminho(tabela) workbook = openpyxl.load_workbook(caminho) - worksheet = workbook['Conciliação Bancária'] - - - size = tamanho + 21 - #worksheet.row_dimensions[27].height = 50 + worksheet = workbook[nomeTabela] + size = tamanho + 13 cinza = "d9d9d9" cinza_escuro = "bfbfbf" azul = "336394" azul_claro = '1c8cbc' - - borda = Border(right=Side(border_style="dashed")) + + borda = Border(right=Side(border_style="medium")) worksheet.sheet_view.showGridLines = False # - - - - # List of image names - image_names = [ - 'finatec.png', - 'ibict.png' - ] - - # # Path to the images - # path = 'C:\\Users\\Softex\\Desktop\\entrega29\\' - - # # 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) - - # Path to the images - path = "/imagensIBICIT/" - - # List to hold Image objects - images = [] - - nomePasta = "imagensIBICIT" - diretorio = os.path.dirname(__file__) - - # Loop through the list of image names and create Image objects - for i, name in enumerate(image_names): - caminhoImage = os.path.join(diretorio, nomePasta, name) - pil_image = PILImage.open(caminhoImage) - pil_image.save(caminhoImage) - img = Image(caminhoImage) - images.append(img) - - - worksheet.add_image(images[1], "A1")#ibict - worksheet.add_image(images[0], "E1")#finatec - + 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['b'].width = 50 worksheet.column_dimensions['c'].width = 35 - worksheet.column_dimensions['d'].width = 35 - worksheet.column_dimensions['e'].width = 35 - worksheet.column_dimensions['f'].width = 25 - worksheet.row_dimensions[14].height = 6 - worksheet.row_dimensions[15].height = 29.25 - worksheet.row_dimensions[16].height = 6 - + worksheet.column_dimensions['d'].width = 35#descrição + worksheet.column_dimensions['e'].width = 40 #n do recibo ou qeuivalente + worksheet.column_dimensions['f'].width = 70 #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('A7:F8') - worksheet['A7'] = f'C O N C I L I A Ç Ã O B A N C Á R I A' - worksheet['A7'].font = Font(name="Arial", size=12, color="FFFFFF",bold=True) - worksheet['A7'].alignment = Alignment(horizontal="center",vertical="center") - worksheet['A7'].fill = PatternFill(start_color=azul_claro, end_color=azul_claro,fill_type = "solid") + 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'!A9:J9" - worksheet['A9'].font = Font(name="Arial", size=12, color="000000",bold=True) + 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") - - worksheet.merge_cells('A10:F10') - worksheet['A10'] = "='Receita x Despesa'!A10:J10" - worksheet['A10'].font = Font(name="Arial", size=12, color="000000",bold=True) - worksheet['A10'].alignment = Alignment(horizontal="left",vertical="center") - worksheet.merge_cells('A11:F11') - worksheet['A11'] = "='Receita x Despesa'!A11:J11" - worksheet['A11'].font = Font(name="Arial", size=12, color="000000",bold=True) - worksheet['A11'].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.merge_cells('A12:F12') - worksheet['A12'] = "='Receita x Despesa'!A12:J12" - worksheet['A12'].font = Font(name="Arial", size=12, color="000000",bold=True) - worksheet['A12'].alignment = Alignment(horizontal="left",vertical="center") + 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.merge_cells('A13:F13') - worksheet['A13'] = "='Receita x Despesa'!A13:J13" - worksheet['A13'].font = Font(name="Arial", size=12, color="000000",bold=True) - worksheet['A13'].alignment = Alignment(horizontal="left",vertical="center") - worksheet.merge_cells('A15:F15') - worksheet['A15'] = "BB RF Simples - CNPJBB RF SIMPLES" - worksheet['A15'].font = Font(name="Arial", size=12, color="FFFFFF",bold=True) - worksheet['A15'].alignment = Alignment(horizontal="center",vertical="center") - worksheet['A15'].fill = PatternFill(start_color=azul_claro, end_color=azul_claro,fill_type = "solid") - - worksheet.merge_cells('A17:F17') - worksheet['A17'] = '1.Saldo conforme extratos bancários na data final do período' - worksheet['A17'].font = Font(name="Arial", size=12, color="FFFFFF",bold=True) - worksheet['A17'].alignment = Alignment(horizontal="left",vertical="center") - worksheet['A17'].fill = PatternFill(start_color=azul_claro, end_color=azul_claro,fill_type = "solid") - - worksheet.merge_cells('A18:E18') - worksheet['A18'] = 'Saldo de Conta Corrente(R$)' - worksheet['A18'].font = Font(name="Arial", size=12, color="000000",bold=True) - worksheet['A18'].alignment = Alignment(horizontal="right",vertical="center") - - worksheet.merge_cells('A19:E19') - worksheet['A19'] = 'Saldo de Aplicações Financeiras(R$)' - worksheet['A19'].font = Font(name="Arial", size=12, color="000000",bold=True) - worksheet['A19'].alignment = Alignment(horizontal="right",vertical="center") - worksheet['A19'].fill = PatternFill(start_color=cinza, end_color=cinza,fill_type = "solid") - - worksheet['F19'].fill = PatternFill(start_color=cinza, end_color=cinza,fill_type = "solid") - - worksheet.merge_cells('A21:F21') - worksheet['A21'] = '2. Restituições não creditadas pelo banco até a data final do período' - worksheet['A21'].font = Font(name="Arial", size=12, color="FFFFFF",bold=True) - worksheet['A21'].alignment = Alignment(horizontal="left",vertical="center") - worksheet['A21'].fill = PatternFill(start_color=azul_claro, end_color=azul_claro,fill_type = "solid") - - for i in range(21,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) + 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" - 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 = 22 - for row in range(start_row,size+2): - cell = worksheet[f'B{row}'] - cell.style = custom_number_format_conciliacoes - - for rows in worksheet.iter_rows(min_row=22, 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) + 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" - row_number = 22 - 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 + worksheet["D12"].fill = openpyxl.styles.PatternFill(start_color=cinza, end_color=cinza, fill_type='solid') + worksheet["D12"] = "DATA" + worksheet["D12"].border = borda2 - # 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) - #rubricado - celulaRubricado = F'C{size}' - stringLozalicaoRubricado = f'C{size}:F{size}' - worksheet.merge_cells(stringLozalicaoRubricado) - worksheet[celulaRubricado].fill = PatternFill(start_color="000000", end_color="FFFFFF",fill_type = "lightUp") + worksheet["E12"].fill = openpyxl.styles.PatternFill(start_color=cinza, end_color=cinza, fill_type='solid') + worksheet["E12"] = "Nº " + worksheet["E12"].border = borda2 - #'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") + 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" - #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 + 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." - for rows in worksheet.iter_rows(min_row=22, max_row=22, min_col=1, max_col=6): - for cell in rows: - cell.font = Font(name="Arial", size=12, color="000000",bold=True) - - + 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 - for row in range(size+4,size+4+tamanho2): - cell = worksheet[f'B{row}'] - cell.style = custom_number_format_conciliacoes + #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(13,size+1): + cell = worksheet[f'H{row}'] + cell.style = locals()[input3] + + for row in range(13,size+1): + cell = worksheet[f'I{row}'] + cell.style = locals()[input3] - for rows in worksheet.iter_rows(min_row=size+3, max_row=size+3+tamanho, min_col=1, max_col=6): + 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") - 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="dashed") ,bottom=Side(border_style="hair") ) + 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 - # FORMULATOTALrestituição - formula = f"=SUM(B{size+4}:B{size+tamanho2+3})" - celula = f'B{size+tamanho2+4}' + # FORMULATOTAL + formula = f"=SUM(I13:I{size})" + celula = f'J{size+2}' worksheet[celula] = formula - worksheet[celula].fill = PatternFill(start_color=cinza_escuro, end_color=cinza_escuro,fill_type = "solid") + 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' - #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) - #rubricado - celulaRubricadoSegundo = F'C{size+tamanho2+4}' - stringLozalicaoRubricadoSegundo = f'C{size+tamanho2+4}:F{size+tamanho2+4}' - worksheet.merge_cells(stringLozalicaoRubricadoSegundo) - worksheet[celulaRubricadoSegundo].fill = PatternFill(start_color="000000", end_color="FFFFFF",fill_type = "lightUp") - #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'!A44:I44" - brasilia_merge_cells = f'A{brasilia_row}:F{brasilia_row}' + + #brasilia + brasilia_row = size + 7 + brasilia_formula = f"='Receita x Despesa'!A{stringTamanho}:J{stringTamanho}" + 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 + 10 + tamanho2 - diretor_cargo_row = size + 11 + tamanho2 - diretor_cpf_row = size + 12 + tamanho2 - diretor_nome_formula = f"='Receita x Despesa'!A48" - diretor_cargo_formula = f"='Receita x Despesa'!A49" - diretor_cpf_formula = f"='Receita x Despesa'!A50" - 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}' + #DiretorFinanceiro + diretor_row = size + 8 + diretor_cargo_row = size + 9 + diretor_cpf_row = size + 10 + diretor_nome_formula = f"='Receita x Despesa'!A{stringTamanho+3}" + diretor_cargo_formula = f"='Receita x Despesa'!A{stringTamanho+4}" + diretor_cpf_formula = f"='Receita x Despesa'!A{stringTamanho+5}" + 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) @@ -696,25 +2373,25 @@ def estilo_conciliacoes_bancaria(tabela,tamanho,tamanho2): 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.font = Font(name="Arial", size=12, color="000000",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'!G48" - coordenadora_cargo_formula = f"='Receita x Despesa'!G49" - coordenadora_cpf_formula = f"='Receita x Despesa'!G50" - 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}' + coordenadora_row = size + 8 + coordenadora_cargo_row = size + 9 + coordenadora_cpf_row = size + 10 + coordenadora_nome_formula = f"='Receita x Despesa'!H{stringTamanho+3}" + coordenadora_cargo_formula = f"='Receita x Despesa'!H{stringTamanho+4}" + coordenadora_cpf_formula = f"='Receita x Despesa'!H{stringTamanho+5}" + 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'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_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] @@ -722,260 +2399,284 @@ def estilo_conciliacoes_bancaria(tabela,tamanho,tamanho2): 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.font= Font(name="Arial", size=12, color="000000",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+tamanho2+12,min_col=6,max_col=6): - for cell in row: - cell.border = borda + + # 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=6): + 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 == 6: - cell.border = Border(top=Side(border_style="none") ,left = Side(border_style="none") ,right =Side(border_style="dashed") ,bottom=Side(border_style="dashed") ) + 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="dashed") ) - - 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) + 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_rendimento_de_aplicacao(tabela,tamanho): +def estilo_demonstrativoDeReceita(tabela,tamanho,stringTamanho): + """Estilo da demonstrativo de receita que inclui entradas de receita ISS 2%, ISS 5%. + + Argumentos: + tabela: recebe o arquivo correspondente a tabela Fub extensão xlsx. Esse arquivo foi iniciado e passou pela preencher fub mas ainda está sem o estilo que será aplicado nessa função. + tamanho:Corresponde ao tamanho das quantidade de bens. + stringTamanho: refere-se aonde esta localizado a string brasilia na pagina Receita e despesa para a referências das formulas. + """ 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 - - # List of image names - image_names = [ - 'finatec.png', - 'ibict.png' - ] - - # # Path to the images - # path = 'C:\\Users\\Softex\\Desktop\\entrega29\\' - - # # 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) - - - # Path to the images - path = "/imagensIBICIT/" - - # List to hold Image objects - images = [] - - nomePasta = "imagensIBICIT" - diretorio = os.path.dirname(__file__) - - # Loop through the list of image names and create Image objects - for i, name in enumerate(image_names): - caminhoImage = os.path.join(diretorio, nomePasta, name) - pil_image = PILImage.open(caminhoImage) - pil_image.save(caminhoImage) - img = Image(caminhoImage) - images.append(img) - - - - - - - - worksheet.add_image(images[1], "A1")#ibict - worksheet.add_image(images[0], "E1")#finatec - + worksheet = workbook['Demonstrativo de Receita'] + size = tamanho + 10 cinza = "d9d9d9" cinza_escuro = "bfbfbf" azul = "336394" - azul_claro = '0198cc' - borda = Border(right=Side(border_style="dashed")) + azul_claro = '1c8cbc' + random_number = random.randint(1, 10000) + 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 row in worksheet.iter_rows(min_row=1, max_row=size+11,min_col=5,max_col=5): 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 - + worksheet.column_dimensions['a'].width = 30 + worksheet.column_dimensions['b'].width = 70 + worksheet.column_dimensions['c'].width = 30 + worksheet.column_dimensions['d'].width = 50#descrição + worksheet.column_dimensions['e'].width = 50#descrição #cabecario relação de pagamentos - outro servicoes de terceiros - worksheet.merge_cells('A7:H8') - worksheet['A7'] = f'Demonstrativo dos Ganhos Auferidos com Aplicações Financeiras' - worksheet['A7'].font = Font(name="Arial", size=12, color="FFFFFF",bold=True) - worksheet['A7'].alignment = Alignment(horizontal="center",vertical="center") - worksheet['A7'].fill = PatternFill(start_color=azul, end_color=azul,fill_type = "solid") - - worksheet.merge_cells('A9:H9') - worksheet['A9'] = "='Receita x Despesa'!A9:J9" - worksheet['A9'].font = Font(name="Arial", size=12, color="000000") - worksheet['A9'].alignment = Alignment(horizontal="left",vertical="center") - - worksheet.merge_cells('A10:H10') - worksheet['A10'] = "='Receita x Despesa'!A10:J10" - worksheet['A10'].font = Font(name="Arial", size=12, color="000000") - worksheet['A10'].alignment = Alignment(horizontal="left",vertical="center") + worksheet.merge_cells('A1:E2') + 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 E ISS 5% E ISS 2%' + 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('A11:H11') - worksheet['A11'] = "='Receita x Despesa'!A11:J11" - worksheet['A11'].font = Font(name="Arial", size=12, color="000000") - worksheet['A11'].alignment = Alignment(horizontal="left",vertical="center") + worksheet.merge_cells('A3:E3') + 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:E4') + 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('A12:H12') - worksheet['A12'] = "='Receita x Despesa'!A12:J12" - worksheet['A12'].font = Font(name="Arial", size=12, color="000000") - worksheet['A12'].alignment = Alignment(horizontal="left",vertical="center") - - worksheet.merge_cells('A13:H13') - worksheet['A13'] = "='Receita x Despesa'!A13:J13" - worksheet['A13'].font = Font(name="Arial", size=12, color="000000") - worksheet['A13'].alignment = Alignment(horizontal="left",vertical="center") + worksheet.merge_cells('A5:E5') + 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('A14:H14') - worksheet['A14'] = 'BB CP Corpor Àgil - CNPJ 11.351.449-0001-10L' - worksheet['A14'].font = Font(name="Arial", size=12, color="FFFFFF",bold=True) - worksheet['A14'].alignment = Alignment(horizontal="center",vertical="center") - worksheet['A14'].fill = PatternFill(start_color=azul, end_color=azul,fill_type = "solid") + worksheet.merge_cells('A6:E6') + 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:E7') + 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=f'row_style_demonstrativo{random_number}') + 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=5): + for cell in row: + cell.style = row_style_demonstrativo + if cell.column == 5: + cell.border = Border(top=Side(border_style="medium") ,bottom=Side(border_style="thin"), right=Side(border_style="medium") ) - #stylecinza - start_row = 18 - for rows in worksheet.iter_rows(min_row=start_row, max_row=13, min_col=1, max_col=8): + valores = ["NomeFavorecido","Histórico","Documento","Data de Entrada",'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 = 80 + + custom_number_format_demonstrativo = [] + # MASCARA R$ + if custom_number_format_demonstrativo!= False: + custom_number_format_demonstrativo = NamedStyle(name=f'custom_number_format_demonstrativo{random_number}') + 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'E{row}'] + cell.style = custom_number_format_demonstrativo + + for rows in worksheet.iter_rows(min_row=10, max_row=size, min_col=1, max_col=5): for cell in rows: if cell.row % 2: - cell.fill = PatternFill(start_color=azul_claro, end_color=azul_claro, + cell.fill = PatternFill(start_color=cinza, end_color=cinza, fill_type = "solid") - cell.font = Font(name="Arial", size=12, color="000000",bold=True) - cell.alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + if cell.column == 5: + 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}:D{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 - row_number = 15 - 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'] + # FORMULATOTAL + formula = f"=SUM(E10:E{size})" + celula = f'E{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=f'row_style_demonstrativo_append{random_number}') + 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, 6): + cell = worksheet.cell(row=row_number, column=column) + cell.style = row_style_demonstrativo_append + if cell.column == 5: + cell.border = Border(top=Side(border_style="medium") ,right =Side(border_style="medium") ,bottom=Side(border_style="medium") ) + + + + values = ["NomeFavorecido","Histórico","Documento","Data de Entrada",'Valor'] coluna = 1 for a,b in enumerate(values): worksheet.cell(row=row_number, column=coluna, value=b) - + if coluna == 5: + coluna = coluna + 1 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) + #subtotal2 + sub_total2_row = size + 5 + subtotal_merge_cells= f'A{sub_total2_row}:D{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'E{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}:D{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'=E{size}' + total_formula_row_celula = f'E{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 - #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}' + brasilia_row = size + 7 + brasilia_formula = f"='Receita x Despesa'!A{stringTamanho}:J{stringTamanho}" + brasilia_merge_cells = f'A{brasilia_row}:E{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}' + #DiretorFinanceiro + diretor_row = size + 8 + diretor_cargo_row = size + 9 + diretor_cpf_row = size + 10 + diretor_nome_formula = f"='Receita x Despesa'!A{stringTamanho+3}" + diretor_cargo_formula = f"='Receita x Despesa'!A{stringTamanho+4}" + diretor_cpf_formula = f"='Receita x Despesa'!A{stringTamanho+5}" + 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) @@ -989,25 +2690,25 @@ def estilo_rendimento_de_aplicacao(tabela,tamanho): 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.font = Font(name="Arial", size=12, color="000000",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'!G45" - coordenadora_cargo_formula = f"='Receita x Despesa'!G46" - coordenadora_cpf_formula = f"='Receita x Despesa'!G47" - 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}' + coordenadora_row = size + 8 + coordenadora_cargo_row = size + 9 + coordenadora_cpf_row = size + 10 + coordenadora_nome_formula = f"='Receita x Despesa'!H{stringTamanho+3}" + coordenadora_cargo_formula = f"='Receita x Despesa'!H{stringTamanho+4}" + coordenadora_cpf_formula = f"='Receita x Despesa'!H{stringTamanho+5}" + coordenadora_merge_cells = f'C{coordenadora_row}:E{coordenadora_row}' + coordenadora_cargo_merge_cells = f'C{coordenadora_cargo_row}:E{coordenadora_cargo_row}' + coordenadora_cpf_merge_cells = f'C{coordenadora_cpf_row}:E{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_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] @@ -1015,41 +2716,26 @@ def estilo_rendimento_de_aplicacao(tabela,tamanho): 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.font= Font(name="Arial", size=12, color="000000",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=8): + for row in worksheet.iter_rows(min_row=coordenadora_cpf_row+1, max_row=coordenadora_cpf_row+1,min_col=1,max_col=5): 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="dashed") ,bottom=Side(border_style="dashed") ) + if cell.column == 5: + 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="dashed") ) - + 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() - - - -tabela = pegar_caminho('IBICT.xlsx') -nomeTabela ="Evento" -tituloStyle = "evento" -workbook = openpyxl.load_workbook(tabela) -sheet2 = workbook.create_sheet(title="Evento") -workbook.save("tabelapreenchida.xlsx") -workbook.close() -tabela = pegar_caminho("tabelapreenchida.xlsx") -workbook = openpyxl.load_workbook(tabela) -sheet2 = workbook.create_sheet(title="Conciliação Bancária") -sheet2 = workbook.create_sheet(title="Rendimento de Aplicação") -workbook.save(tabela) -workbook.close() -maior = 20 -maior2 = 20 -tabela2 = pegar_caminho('tabelapreenchida.xlsx') -print(tabela2) -estiloGeral(tabela2,maior,tituloStyle,nomeTabela) -estilo_conciliacoes_bancaria(tabela2,maior2,maior) -estilo_rendimento_de_aplicacao(tabela2,maior) \ No newline at end of file diff --git a/project/app/estiloOPAS.py b/project/app/estiloOPAS.py old mode 100644 new mode 100755 diff --git a/project/app/estilo_fub.py b/project/app/estilo_fub.py old mode 100644 new mode 100755 index 8762e69f..bdf7c778 --- a/project/app/estilo_fub.py +++ b/project/app/estilo_fub.py @@ -1,31 +1,1072 @@ import openpyxl from openpyxl.styles import Font, PatternFill, Alignment,NamedStyle,Border, Side import os +import random #pegar o caminho do arquivo -def pegar_caminho(nome_arquivo): +# def pegar_caminho(nome_arquivo): - # Obter o caminho absoluto do arquivo Python em execução - caminho_script = os.path.abspath(__file__) +# # 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) +# # 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) +# # Combinar o caminho da pasta com o nome do arquivo Excel +# caminho = os.path.join(pasta_script, nome_arquivo) - return caminho +# 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] = [] +def pegar_caminho(subdiretorio): + # Obtém o caminho do script atual + arq_atual = os.path.abspath(__file__) - # Assign the value to the dynamically created variable name - return variables + # Obtém o diretório do script + app = os.path.dirname(arq_atual) + + # Obtém o diretório pai do script + project = os.path.dirname(app) + + # Obtém o diretório pai do projeto + pipeline = os.path.dirname(project) + + # Junta o diretório pai do projeto com o subdiretório desejado + caminho_pipeline = os.path.join(pipeline, subdiretorio) + + return caminho_pipeline + +def estiloExecReceitaDespesa(tabela,tamanho,stringTamanho): + '''Estilo da Pagina do Relatorio Execução da Receita e Despesa + + Argumentos: + tabela : recebe o arquivo correspondente a tabela Fub extensão xlsx. Esse arquivo ja foi iniciado e passou pela preencher fub mas ainda esta sem o estilo que sera aplicado nessa função. + tamanho : é o tamanho total de linhas que irão ser geradas dinâmicamente. O valor varia dentre o tamanho da quantidade de rubricas diferente que o projeto possui, excluindo Obras e Instalações + Aplicações Financeira e Equipamento e Material Permanente sendo nacional ou importado. + stringTamanho : refere-se aonde esta localizado a string brasília na pagina Receita e despesa para a referencias das formulas. + + + ''' + + caminho = pegar_caminho(tabela) + workbook = openpyxl.load_workbook(caminho) + sheet = workbook['Exec. Receita e Despesa'] + + size = tamanho + 16; + size2 = size + 1 + cinza = "f1f1f1" + azul_claro = '1c8cbc' + # sheet.row_dimensions[3] = 28 + + + + #cabecario + sheet.merge_cells('A1:I2') + sheet['A1'] = f'E X E C U Ç Ã O D A R E C E I T A E D E S P E S A ' + sheet['A1'].font = Font(name="Arial", size=12, color="FFFFFF",bold=True) + sheet['A1'].alignment = Alignment(horizontal="center",vertical="center") + sheet['A1'].fill = PatternFill(start_color=azul_claro, end_color=azul_claro,fill_type = "solid") + + sheet.merge_cells('A3:I3') + sheet['A3'] = "='Receita x Despesa'!A3:I3" + sheet['A3'].font = Font(name="Arial", size=12, color="000000") + sheet['A3'].alignment = Alignment(horizontal="left",vertical="center") + + sheet.merge_cells('A4:I4') + sheet['A4'] = "='Receita x Despesa'!A4:I4" + sheet['A4'].font = Font(name="Arial", size=12, color="000000") + sheet['A4'].alignment = Alignment(horizontal="left",vertical="center") + + sheet.merge_cells('A5:I5') + sheet['A5'] = "='Receita x Despesa'!A5:I5" + sheet['A5'].font = Font(name="Arial", size=12, color="000000") + sheet['A5'].alignment = Alignment(horizontal="left",vertical="center") + + sheet.merge_cells('A6:I6') + sheet['A6'] = "='Receita x Despesa'!A6:I6" + sheet['A6'].font = Font(name="Arial", size=12, color="000000") + sheet['A6'].alignment = Alignment(horizontal="left",vertical="center") + + sheet.merge_cells('A7:I7') + sheet['A7'] = "='Receita x Despesa'!A7:I7" + sheet['A7'].font = Font(name="Arial", size=12, color="000000") + sheet['A7'].alignment = Alignment(horizontal="left",vertical="center") + + sheet.merge_cells('A9:I10') + sheet['A9'] = 'E X E C U Ç Ã O D A R E C E I T A E D E S P E S A' + sheet['A9'].font = Font(name="Arial", size=12, color="FFFFFF",bold=True) + sheet['A9'].alignment = Alignment(horizontal="center",vertical="center") + sheet['A9'].fill = PatternFill(start_color=azul_claro, end_color=azul_claro,fill_type = "solid") + + #aumentao altura + for i in range(1,10): + sheet.row_dimensions[i].height = 20 + + sheet.row_dimensions[1].height = 25 + sheet.row_dimensions[3].height = 35 + sheet.row_dimensions[2].height = 25 + sheet.row_dimensions[9].height = 30 + + + + #esticando coluna A e pintando ela + sheet.merge_cells('A12:A13') + sheet['A12'].fill = PatternFill(start_color=azul_claro, end_color=azul_claro,fill_type = "solid") + + sheet.column_dimensions['a'].width = 55 + sheet.column_dimensions['b'].width = 20 + sheet.column_dimensions['c'].width = 20 + sheet.column_dimensions['d'].width = 20 + sheet.column_dimensions['e'].width = 20 + sheet.column_dimensions['f'].width = 20 + sheet.column_dimensions['g'].width = 20 + sheet.column_dimensions['h'].width = 20 + sheet.column_dimensions['i'].width = 20 + sheet.column_dimensions['j'].width = 1 + #resto do cabecario + sheet.merge_cells('B12:E13') + sheet['B12'] = 'EXECUTADO NO PERÍODO\n(Valores em R$)' + sheet['B12'].font = Font(name="Arial", size=12, color="FFFFFF",bold=True) + sheet['B12'].alignment = Alignment(horizontal="center",vertical="center") + sheet['B12'].fill = PatternFill(start_color=azul_claro, end_color=azul_claro,fill_type = "solid") + + sheet.merge_cells('F12:I13') + sheet['F12'] = 'ACUMULADO ATÉ O PERÍODO\n(Valores em R$)' + sheet['F12'].font = Font(name="Arial", size=12, color="FFFFFF",bold=True) + sheet['F12'].alignment = Alignment(horizontal="center",vertical="center") + sheet['F12'].fill = PatternFill(start_color=azul_claro, end_color=azul_claro,fill_type = "solid") + + + + + + + + #%porcentagem Despesas correntes + #IFERROR (C16/B16;0) + #%porcentagem Despesas de Capital + #IFERROR (C16/B16;0) + percentage_style = NamedStyle(name='percentage', number_format='0%') + #diferença e calculo da porcentagem + for row in sheet.iter_rows(min_row=15, max_row=size2+9, min_col=1, max_col=9): + for cell in row: + if cell.column == 4: + stringSaldo = f"=B{cell.row} - C{cell.row}" + cell.value = stringSaldo + if cell.column == 8: + stringSaldo = f"=F{cell.row} - G{cell.row}" + cell.value = stringSaldo + + + if cell.column == 5: + stringPorcentagem = f"=IFERROR(C{cell.row}/B{cell.row}, 0)" + cell.value = stringPorcentagem + cell.style = percentage_style + if cell.column == 9: + stringPorcentagem = f"=IFERROR(G{cell.row}/F{cell.row}, 0)" + cell.value = stringPorcentagem + cell.style = percentage_style + + #adicionara mascara do numero + for row in sheet.iter_rows(min_row=15, max_row=size2+9, min_col=1, max_col=9): + for cell in row: + if cell.column != 5 and cell.column != 9: + cell.number_format ='#,##0.00' + + + + + + + + + #adicionar borda em tudo + borda = Border(right=Side(border_style="medium")) + sheet.sheet_view.showGridLines = False + for row in sheet.iter_rows(min_row=1, max_row=size2+14,min_col=9,max_col=9): + for cell in row: + cell.border = borda + + font = Font(name='Arial', size=12) + #Colocar tudo arial 12 + for row in sheet.iter_rows(min_row=16): + for cell in row: + cell.font = font + #preenche a coluna A e F com cinza + for row in sheet.iter_rows(min_row=16, max_row=size2+9,min_col=1,max_col=9): + for cell in row: + if cell.column == 1 or cell.column == 6 or cell.column == 2: + cell.fill = PatternFill(start_color=cinza, end_color=cinza, + fill_type = "solid") + if cell.column == 6 or cell.column == 2: + cell.fill = PatternFill(start_color=cinza, end_color=cinza, + fill_type = "solid") + cell.font = cell.font = Font(name='Arial', size=12,bold= True) + +###pinta de azul a linha desejada + for row in sheet.iter_rows(min_row=15, max_row=sheet.max_row, min_col=sheet.min_row, max_col= 9): + for cell in row: + if cell.row == 15: + cell.fill = PatternFill(start_color=azul_claro, end_color=azul_claro, + fill_type = "solid") + cell.font = Font(name='Arial', size=12,bold= True) + + if cell.row == size2 or cell.row == size2 +5 or cell.row == size2 + 7 or cell.row== size2+9: + cell.fill = PatternFill(start_color=azul_claro, end_color=azul_claro, + fill_type = "solid") + cell.font = Font(name='Arial', size=12,bold= True) + + + + + #cabecario negrito sem fundo + + valores = ["RUBRICA","PREVISTO","REALIZADO","SALDO",'(%)\nREALIZADO',"PREVISTO","REALIZADO","SALDO","(%)\nREALIZADO"] + col = 1 + for a,b in enumerate(valores): + sheet.cell(row=14, column=col, value=b) + col = col + 1 + #coloca em negrito + font = Font(name='Arial', size=12,bold=True) + #Colocar tudo arial 12 + for row in sheet.iter_rows(min_row=14,max_row=14): + for cell in row: + cell.font = font + + + #depsesas e capital + despesasDeCapitalString = f"I. DESPESAS CORRENTES" + despesasDeCapitalStringCelula = f'A{15}' + sheet[despesasDeCapitalStringCelula] = despesasDeCapitalString + cell=sheet[despesasDeCapitalStringCelula] + cell.font = Font(name="Arial", size=12, color="000000",bold = True) + + + + + #depsesas e capital + despesasDeCapitalString = f"II. DESPESAS DE CAPITAL" + despesasDeCapitalStringCelula = f'A{size2}' + sheet[despesasDeCapitalStringCelula] = despesasDeCapitalString + cell=sheet[despesasDeCapitalStringCelula] + cell.font = Font(name="Arial", size=12, color="000000",bold = True) + + + + + obrasEInstalacoeslString = f"Obras e Instalações" + obrasEInstalacoeslStringCelula = f'A{size2+1}' + sheet[obrasEInstalacoeslStringCelula] = obrasEInstalacoeslString + + + equipamentoseMaterialPermanenteString = f"Equipamentos e Material Permanente" + equipamentoseMaterialPermanenteStringCelula = f'A{size2+2}' + sheet[equipamentoseMaterialPermanenteStringCelula] = equipamentoseMaterialPermanenteString + cell=sheet[equipamentoseMaterialPermanenteStringCelula] + cell.font = Font(name="Arial", size=12, color="000000",bold = True) + cell=sheet[f'B{size2+2}'] + cell.font = Font(name="Arial", size=12, color="000000",bold = True) + + + + nacionalString = f" a) Nacional" + nacionalStringCelula = f'A{size2+3}' + sheet[nacionalStringCelula] = nacionalString + + + + importadoString = f" b) Importado" + importadoStringCelula = f'A{size2+4}' + sheet[importadoStringCelula] = importadoString + + + + #depsesas e capital + utilRendimentosString = f"III.UTILIZAÇÃO DE RENDIMENTOS" + utilRendimentosStringCelula = f'A{size2+7}' + sheet[utilRendimentosStringCelula] = utilRendimentosString + cell=sheet[utilRendimentosStringCelula] + cell.font = Font(name="Arial", size=12, color="000000",bold = True) + cell=sheet[f'B{size2+1}'] + cell.font = Font(name="Arial", size=12, color="000000",bold = True) + + + + apliFinString = f"Aplicação Financeira" + apliFinStringCelula = f'A{size2+8}' + sheet[apliFinStringCelula] = apliFinString + + + #barra de total nova 22/02 + totalString = f"TOTAL" + totalStringCelula = f'A{size2+5}' + sheet[totalStringCelula] = totalString + cell=sheet[totalStringCelula] + cell.font = Font(name="Arial", size=12, color="000000",bold = True) + cell.fill = PatternFill(start_color='9c9c9c', end_color='9c9c9c',fill_type = "solid") + cell.alignment = Alignment(horizontal="center",vertical="center") + + + totalString = f"TOTAL" + totalStringCelula = f'A{size2+9}' + sheet[totalStringCelula] = totalString + cell=sheet[totalStringCelula] + cell.font = Font(name="Arial", size=12, color="000000",bold = True) + cell.fill = PatternFill(start_color='9c9c9c', end_color='9c9c9c',fill_type = "solid") + cell.alignment = Alignment(horizontal="center",vertical="center") + + #barra total nova + + formula = f"=SUM(B{size2}, B15)" + sheet[f'B{size2+5}'] = formula + + formula = f"=SUM(C{size2}, C15)" + sheet[f'C{size2+5}'] = formula + + formula = f"=SUM(D{size2}, D15)" + sheet[f'D{size2+5}'] = formula + + formula = f"=SUM(F{size2}, F15)" + sheet[f'F{size2+5}'] = formula + + formula = f"=SUM(G{size2}, G15)" + sheet[f'G{size2+5}'] = formula + + formula = f"=SUM(H{size2},H15)" + sheet[f'H{size2+5}'] = formula + + + #sheet[f'H{size2+5}'] + sheet.row_dimensions[size2 + 6].height = 1 + + + + #3.UTILIZAÇÂO DE RENDIMENTOS + # formula = f"=SUM(A{size2+8})" + # sheet[f'A{size2+7}'] = formula + + formula = f"=SUM(B{size2+8})" + sheet[f'B{size2+7}'] = formula + + formula = f"=SUM(C{size2+8})" + sheet[f'C{size2+7}'] = formula + + formula = f"=SUM(D{size2+8})" + sheet[f'D{size2+7}'] = formula + + formula = f"=SUM(F{size2+8})" + sheet[f'F{size2+7}'] = formula + + formula = f"=SUM(G{size2+8})" + sheet[f'G{size2+7}'] = formula + + formula = f"=SUM(H{size2+8})" + sheet[f'H{size2+7}'] = formula + + ##SOMATORIO NEGATIVO C + Formula = f'=SUMIF(D16:D{size}, "<0")' + sheet[f'C{size2+8}']= Formula + ############## + + ##SOMATORIO NEGATIVO G + Formula = f'=SUMIF(H16:H{size}, "<0")' + sheet[f'G{size2+8}'] = Formula + ############## + + + + + #totais + #total espesas correntes linha 15 + + formula = f"=SUM(B16:B{size})" + sheet['B15'] = formula + formula = f"=SUM(C16:C{size})" + sheet['C15'] = formula + formula = f'=SUMIF(D16:D{size}, ">0")' + sheet['D15'] = formula + + formula = f"=SUM(F16:F{size})" + sheet['F15'] = formula + formula = f"=SUM(G16:G{size})" + sheet['G15'] = formula + formula = f'=SUMIF(H16:H{size}, ">0")' + sheet['H15'] = formula + + #Total Despesas de Capital + formula = f"=SUM(B{size2+2}:B{size2+4})" + sheet[f'B{size2}'] = formula + + formula = f"=SUM(C{size2+2}:C{size2+4})" + sheet[f'C{size2}'] = formula + + formula = f"=SUM(D{size2+2}:D{size2+4})" + sheet[f'D{size2}'] = formula + + formula = f"=SUM(F{size2+2}:F{size2+4})" + sheet[f'F{size2}'] = formula + + formula = f"=SUM(G{size2+2}:G{size2+4})" + sheet[f'G{size2}'] = formula + + formula = f"=SUM(H{size2+2}:H{size2+4})" + sheet[f'H{size2}'] = formula + + + #Total abaixo de Utilização de rendimentos + + formula = f"=B{size2+8}" + sheet[f'B{size2+9}'] = formula + + formula = f"=C{size2+8}" + sheet[f'C{size2+9}'] = formula + + formula = f"=D{size2+8}" + sheet[f'D{size2+9}'] = formula + + formula = f"=F{size2+8}" + sheet[f'F{size2+9}'] = formula + + formula = f"=G{size2+8}" + sheet[f'G{size2+9}'] = formula + + formula = f"=H{size2+8}" + sheet[f'H{size2+9}'] = formula + + + + #somasaldo h + stringSaldo = f"=SUM(F{size2+8}+G{size2+8})" + + sheet[f"H{size2+8}"] = stringSaldo + + + #brasilia + brasilia_row = size2 + 11 + brasilia_formula = f"='Receita x Despesa'!A{stringTamanho}:I{stringTamanho}" + brasilia_merge_cells = f'A{brasilia_row}:I{brasilia_row}' + sheet.merge_cells(brasilia_merge_cells) + top_left_brasilia_cell_formula = f'A{brasilia_row}' + top_left_brasilia_cell = sheet[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 = size2 + 12 + diretor_cargo_row = size2 + 13 + diretor_cpf_row = size2 + 14 + + diretor_nome_formula = f"Daniel Monteiro Rosa" + diretor_cargo_formula = f"Diretor-Financeiro" + diretor_cpf_formula = f"450.720.272-87" + 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}' + sheet.merge_cells(diretor_merge_cells) + sheet.merge_cells(diretor_cargo_merge_cells) + sheet.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 = sheet[top_left_diretor_cell_formula] + top_left_diretor_cell_cargo_formula = sheet[top_left_diretor_cell_cargo_formula] + top_left_diretor_cell_cpf_formula = sheet[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 = size2 + 12 + coordenadora_cargo_row = size2 + 13 + coordenadora_cpf_row = size2 + 14 + coordenadora_nome_formula = f"='Receita x Despesa'!H{stringTamanho+3}" + coordenadora_cargo_formula = f"='Receita x Despesa'!H{stringTamanho+4}" + coordenadora_cpf_formula = f"='Receita x Despesa'!H{stringTamanho+5}" + coordenadora_merge_cells = f'F{coordenadora_row}:I{coordenadora_row}' + coordenadora_cargo_merge_cells = f'F{coordenadora_cargo_row}:I{coordenadora_cargo_row}' + coordenadora_cpf_merge_cells = f'F{coordenadora_cpf_row}:I{coordenadora_cpf_row}' + sheet.merge_cells(coordenadora_merge_cells) + sheet.merge_cells(coordenadora_cargo_merge_cells) + sheet.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 = sheet[top_left_coordenadora_cell_formula] + top_left_coordenadora_cell_cargo_formula = sheet[top_left_coordenadora_cell_cargo_formula] + top_left_coordenadora_cell_cpf_formula = sheet[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(name="Arial", size=12, color="000000",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")) + # sheet.sheet_view.showGridLines = False + # # + # for row in sheet.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 sheet.iter_rows(min_row=coordenadora_cpf_row+1, max_row=coordenadora_cpf_row+1,min_col=1,max_col=9): + for cell in row: + if cell.column == 9: + 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") ) + + + + #bordinha branca + + for row in sheet.iter_rows(min_row=1,max_row=coordenadora_cpf_row,min_col=1,max_col=10): + for cell in row: + + if cell.row == 15: + cell.border = Border(left=Side(border_style='thin', color='FFFFFF'), # white + right=Side(border_style='thin', color='FFFFFF'), + top=Side(border_style='thin', color='FFFFFF'), + bottom=Side(border_style='thin', color='FFFFFF')) + if cell.column == 9: + cell.border = Border(left=Side(border_style='thin', color='FFFFFF'), # white + right=Side(border_style='medium', color='000000'), + top=Side(border_style='thin', color='FFFFFF'), + bottom=Side(border_style='thin', color='FFFFFF')) + if cell.row == size2: + cell.border = Border(left=Side(border_style='thin', color='FFFFFF'), # white + right=Side(border_style='thin', color='FFFFFF'), + top=Side(border_style='thin', color='FFFFFF'), + bottom=Side(border_style='thin', color='FFFFFF')) + if cell.column == 9: + cell.border = Border(left=Side(border_style='thin', color='FFFFFF'), # white + right=Side(border_style='medium', color='000000'), + top=Side(border_style='thin', color='FFFFFF'), + bottom=Side(border_style='thin', color='FFFFFF')) + + if cell.row == size2+5: + cell.border = Border(left=Side(border_style='thin', color='FFFFFF'), # white + right=Side(border_style='thin', color='FFFFFF'), + top=Side(border_style='thin', color='FFFFFF'), + bottom=Side(border_style='thin', color='FFFFFF')) + if cell.column == 9: + cell.border = Border(left=Side(border_style='thin', color='FFFFFF'), # white + right=Side(border_style='medium', color='000000'), + top=Side(border_style='thin', color='FFFFFF'), + bottom=Side(border_style='thin', color='FFFFFF')) + if cell.row == size2+7: + cell.border = Border(left=Side(border_style='thin', color='FFFFFF'), # white + right=Side(border_style='thin', color='FFFFFF'), + top=Side(border_style='thin', color='FFFFFF'), + bottom=Side(border_style='thin', color='FFFFFF')) + if cell.column == 9: + cell.border = Border(left=Side(border_style='thin', color='FFFFFF'), # white + right=Side(border_style='medium', color='000000'), + top=Side(border_style='thin', color='FFFFFF'), + bottom=Side(border_style='thin', color='FFFFFF')) + if cell.row == size2+9: + cell.border = Border(left=Side(border_style='thin', color='FFFFFF'), # white + right=Side(border_style='thin', color='FFFFFF'), + top=Side(border_style='thin', color='FFFFFF'), + bottom=Side(border_style='thin', color='FFFFFF')) + if cell.column == 9: + cell.border = Border(left=Side(border_style='thin', color='FFFFFF'), # white + right=Side(border_style='medium', color='000000'), + top=Side(border_style='thin', color='FFFFFF'), + bottom=Side(border_style='thin', color='FFFFFF')) + + for row in sheet.iter_rows(min_row=1,max_row=coordenadora_cpf_row,min_col=10,max_col=10): + cell.border = Border(left=Side(border_style='medium', color='000000')) -def estiloGeral(tabela,tamanho,nomeVariavel,nomeTabela): + workbook.save(tabela) + workbook.close() + + + + + + + return 0 + +def estiloReceitaXDespesa(tabela,stringTamanho): + '''Estilo da Pagina do Relatorio Receita e Despesa. + + Argumentos: + tabela : recebe o arquivo correspondente a tabela Fub extensão xlsx. Esse arquivo ja foi iniciado e passou pela preencher fub mas ainda esta sem o estilo que sera aplicado nessa função. + + stringTamanho : refere-se aonde esta localizado a string Brasilia nessa pagina, ela pega o valor entre o tamanho quantidade de rubricas que o projeto possui salvo algumas exeções + e a entrada de receitas/iss, oque for maior esse ditará tamanho. + ''' + + caminho = pegar_caminho(tabela) + #Plan = planilha + # carrega a planilha de acordo com o caminho + workbook = openpyxl.load_workbook(caminho) + sheet = workbook['Receita x Despesa'] + size = stringTamanho + 16; + size2 = size + 5 + cinza = "d9d9d9" + azul_claro = '1c8cbc' + # sheet.row_dimensions[3] = 28 + + + + #cabecario relação de pagamentos - outro servicoes de terceiros + sheet.merge_cells('A1:J2') + sheet['A1'] = f'D E M O N S T R A T I V O D E R E C E I T A E D E S P E S A' + sheet['A1'].font = Font(name="Arial", size=12, color="FFFFFF",bold=True) + sheet['A1'].alignment = Alignment(horizontal="center",vertical="center") + sheet['A1'].fill = PatternFill(start_color=azul_claro, end_color=azul_claro,fill_type = "solid") + + sheet.merge_cells('A3:J3') + sheet['A3'] = "" + sheet['A3'].font = Font(name="Arial", size=12, color="000000") + sheet['A3'].alignment = Alignment(horizontal="left",vertical="center",wrap_text=True) + + sheet.merge_cells('A4:J4') + sheet['A4'] = "" + sheet['A4'].font = Font(name="Arial", size=12, color="000000") + sheet['A4'].alignment = Alignment(horizontal="left",vertical="center") + + sheet.merge_cells('A5:J5') + sheet['A5'] = "" + sheet['A5'].font = Font(name="Arial", size=12, color="000000") + sheet['A5'].alignment = Alignment(horizontal="left",vertical="center") + + sheet.merge_cells('A6:J6') + sheet['A6'] = "" + sheet['A6'].font = Font(name="Arial", size=12, color="000000") + sheet['A6'].alignment = Alignment(horizontal="left",vertical="center") + + sheet.merge_cells('A7:J7') + sheet['A7'] = "" + sheet['A7'].font = Font(name="Arial", size=12, color="000000") + sheet['A7'].alignment = Alignment(horizontal="left",vertical="center") + + sheet.merge_cells('A9:J9') + sheet['A9'] = 'R E C E I T A E D E S P E S A' + sheet['A9'].font = Font(name="Arial", size=12, color="FFFFFF",bold=True) + sheet['A9'].alignment = Alignment(horizontal="center",vertical="center") + sheet['A9'].fill = PatternFill(start_color=azul_claro, end_color=azul_claro,fill_type = "solid") + + for i in range(1,10): + sheet.row_dimensions[i].height = 20 + + sheet.row_dimensions[1].height = 25 + sheet.row_dimensions[3].height = 35 + sheet.row_dimensions[2].height = 25 + sheet.row_dimensions[9].height = 30 + sheet.column_dimensions['b'].width = 40 + sheet.column_dimensions['c'].width = 30 + sheet.column_dimensions['d'].width = 30 + sheet.column_dimensions['e'].width = 30 + sheet.column_dimensions['f'].width = 30 + sheet.column_dimensions['i'].width = 30 + sheet.column_dimensions['j'].width = 30 + #barra cinza + + barrazinzaMerge = f"A{11}:J{11}" + sheet.merge_cells(barrazinzaMerge) + barrazinzaStringCelula = f"A{11}" + cell = sheet[barrazinzaStringCelula] + cell.fill = PatternFill(start_color=cinza, end_color=cinza, + fill_type = "solid") + cell.alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + + + + + #adicionar borda em tudo + borda = Border(right=Side(border_style="medium")) + sheet.sheet_view.showGridLines = False + for row in sheet.iter_rows(min_row=1, max_row=size2+21,min_col=10,max_col=10): + for cell in row: + cell.border = borda + + + + + + #merge das receitas + for i in range(16,size): + sttring = f"C{i}:D{i}" + sheet.merge_cells(sttring) + + + font = Font(name='Arial', size=12) + #Colocar tudo arial 12 + for row in sheet.iter_rows(min_row=16): + for cell in row: + cell.font = font + + #mascara de dinheiro despesas correntes + for row in sheet.iter_rows(min_row=16,max_row=size,min_col=5,max_col=5): + for cell in row: + cell.number_format = 'R$ #,##0.00' + + #mascara de dinehrio despesas realizadas + for row in sheet.iter_rows(min_row=16,max_row=size,min_col=9,max_col=9): + for cell in row: + cell.number_format = 'R$ #,##0.00' + + + #preenche qualquer linha com cinza + for row in sheet.iter_rows(min_row=16, max_row=sheet.max_row, min_col=sheet.min_row, max_col= sheet.max_column): + for cell in row: + if cell.row == size2+2 or cell.row == size2 +12: + cell.fill = PatternFill(start_color=cinza, end_color=cinza, + fill_type = "solid") + + + + + #Receita + + rendimentoDeAplicacaoFinanceiraMerge = f"A{size2+2}:E{size2+2}" + sheet.merge_cells(rendimentoDeAplicacaoFinanceiraMerge) + rendimentoDeAplicacaoFinanceiraString= f"Rendimento de Aplicação financeira" + rendimentoDeAplicacaoFinanceiraStringCelula = f"A{size2+2}" + sheet[rendimentoDeAplicacaoFinanceiraStringCelula] = rendimentoDeAplicacaoFinanceiraString + cell=sheet[f'A{size2+2}'] + cell.fill = PatternFill(start_color=cinza, end_color=cinza, + fill_type = "solid") + cell.font = Font(name="Arial", size=12, color="000000",bold = True) + + + #Rendimento de aplicação financeira formula + formula = f"=SUM(E{size2+3}:E{size2+6})" + celula = f'F{size2+2}' + sheet[celula] = formula + cell=sheet[f'F{size2+2}'] + cell.fill = PatternFill(start_color=cinza, end_color=cinza, + fill_type = "solid") + cell.font = Font(name="Arial", size=12, color="000000",bold = True) + cell.number_format = 'R$ #,##0.00' + + #soma despesas realizadas + formula = f"=SUM(I{16}:I{size+5})" + celula = f'J13' + sheet[celula] = formula + + #soma saldo conciliado + formula = f'=SUM(I{size2+4}+I{size2+5}+I{size2+6}+I{size2+9})' + celula = f'J{size2+2}' + sheet[celula] = formula + + #valores recebidos no periodo + formula = f"=SUM(E{14}:E{size2+1})" + celula = f'F13' + sheet[celula] = formula + + #SUM total receita + + formula = f'=SUM(F{size2+2}+F13)' + celula = f'F{size2+12}' + sheet[celula] = formula + + #SUM total despesa + formula = f'=SUM(J{size2+2}+J13)' + celula = f'J{size2+12}' + sheet[celula] = formula + + #sum II. DESPESAS DE CAPITAl + formula = f'=SUM(I{size+2}:I{size+5})' + celula = f'I{size+1}' + sheet[celula] = formula + + #Despesas realizadas + #depsesas e capital + despesasDeCapitalString = f"II. DESPESAS DE CAPITAL" + despesasDeCapitalStringCelula = f'H{size+1}' + sheet[despesasDeCapitalStringCelula] = despesasDeCapitalString + cell=sheet[despesasDeCapitalStringCelula] + cell.font = Font(name="Arial", size=12, color="000000",bold = True) + cell=sheet[f'I{size+1}'] + cell.font = Font(name="Arial", size=12, color="000000",bold = True) + cell.number_format = 'R$ #,##0.00' + + + + obrasEInstalacoeslString = f"Obras e Instalações" + obrasEInstalacoeslStringCelula = f'H{size+2}' + sheet[obrasEInstalacoeslStringCelula] = obrasEInstalacoeslString + cell=sheet[f'I{size+2}'] + cell.font = Font(name="Arial", size=12, color="000000") + cell.number_format = 'R$ #,##0.00' + + + equipamentoseMaterialPermanenteString = f"Equipamentos e Material Permanente" + equipamentoseMaterialPermanenteStringCelula = f'H{size+3}' + sheet[equipamentoseMaterialPermanenteStringCelula] = equipamentoseMaterialPermanenteString + cell=sheet[equipamentoseMaterialPermanenteStringCelula] + cell.font = Font(name="Arial", size=12, color="000000",bold = True) + cell=sheet[f'I{size+3}'] + cell.font = Font(name="Arial", size=12, color="000000",bold = True) + cell.number_format = 'R$ #,##0.00' + + + nacionalString = f" a) Nacional" + nacionalStringCelula = f'H{size+4}' + sheet[nacionalStringCelula] = nacionalString + cell=sheet[f'I{size+4}'] + cell.font = Font(name="Arial", size=12, color="000000") + cell.number_format = 'R$ #,##0.00' + + + importadoString = f" b) Importado" + importadoStringCelula = f'H{size+5}' + sheet[importadoStringCelula] = importadoString + cell=sheet[f'I{size+5}'] + cell.font = Font(name="Arial", size=12, color="000000") + cell.number_format = 'R$ #,##0.00' + + #saldo conciliado em: + + saldoConciliadoEmString= f"Saldo Conciliado em: " + saldoConciliadoEmStringCelula = f"H{size2+2}" + sheet[saldoConciliadoEmStringCelula] = saldoConciliadoEmString + cell=sheet[saldoConciliadoEmStringCelula] + cell.font = Font(name="Arial", size=12, color="000000",bold = True) + cell.fill = PatternFill(start_color=cinza, end_color=cinza, + fill_type = "solid") + + ##saldo conciliado formula + cell=sheet[f'J{size2+2}'] + cell.fill = PatternFill(start_color=cinza, end_color=cinza, + fill_type = "solid") + cell.font = Font(name="Arial", size=12, color="000000",bold = True) + cell.number_format = 'R$ #,##0.00' + + #mergecelulasabaixo de Rendimento de Aplicação financeira + for i in range(size2+3,size2+6): + sttring = f"A{i}:D{i}" + sheet.merge_cells(sttring) + + + + contaCorrenteEmString= f"Conta Corrente" + contaCorrenteEmStringCelula = f"H{size2+4}" + sheet[contaCorrenteEmStringCelula] = contaCorrenteEmString + cell=sheet[f'I{size2+4}'] + cell.font = Font(name="Arial", size=12, color="000000") + cell.number_format = 'R$ #,##0.00' + + devolucaoRecursosEmString= f"Devolução de recursos - GRU SIMPLES" + devolucaoRecursosEmStringCelula = f"H{size2+5}" + sheet[devolucaoRecursosEmStringCelula] = devolucaoRecursosEmString + cell=sheet[f'I{size2+5}'] + cell.font = Font(name="Arial", size=12, color="000000") + cell.number_format = 'R$ #,##0.00' + + tarifaBancariaSaldoEmString= f"Tarifa Bancária - Saldo" + tarifaBancariaSaldoEmStringCelula = f"H{size2+6}" + sheet[tarifaBancariaSaldoEmStringCelula] = tarifaBancariaSaldoEmString + cell=sheet[saldoConciliadoEmStringCelula] + cell.font = Font(name="Arial", size=12, color="000000",bold = True) + cell=sheet[f'I{size2+6}'] + cell.value= f"=I{size2+7}-I{size2+8}" + cell.font = Font(name="Arial", size=12, color="000000",bold = True) + cell.number_format = 'R$ #,##0.00' + + tarifaBancariaDespesaEmString= f"Tarifa Bancária - Despesa (-)" + tarifaBancariaDespesaEmStringCelula = f"H{size2+7}" + sheet[tarifaBancariaDespesaEmStringCelula] = tarifaBancariaDespesaEmString + cell=sheet[f'I{size2+7}'] + cell.font = Font(name="Arial", size=12, color="000000") + cell.number_format = 'R$ #,##0.00' + + TarifaBancariaRestituicaoEmString= f"Tarifa Bancária - Restituição (+)" + TarifaBancariaRestituicaoEmStringCelula = f"H{size2+8}" + sheet[TarifaBancariaRestituicaoEmStringCelula] = TarifaBancariaRestituicaoEmString + cell=sheet[f'I{size2+8}'] + cell.number_format = 'R$ #,##0.00' + + aplicacaoFinanceiraEmString= f"Aplicação Financeira" + aplicacaoFinanceiraEmStringCelula = f"H{size2+9}" + sheet[aplicacaoFinanceiraEmStringCelula] = aplicacaoFinanceiraEmString + cell=sheet[aplicacaoFinanceiraEmStringCelula] + cell.font = Font(name="Arial", size=12, color="000000",bold = True) + cell=sheet[f'I{size2+9}'] + cell.font = Font(name="Arial", size=12, color="000000",bold = True) + cell.number_format = 'R$ #,##0.00' + + rendimentoDeaplicacaoEmString= f"Rendimento de aplicação financeira" + rendimentoDeaplicacaoEmStringCelula = f"H{size2+10}" + sheet[rendimentoDeaplicacaoEmStringCelula] = rendimentoDeaplicacaoEmString + + cell=sheet[f'I{size2+10}'] + cell.number_format = 'R$ #,##0.00' + + #Total Receita + + totalMerge = f"A{size2+12}:E{size2+12}" + sheet.merge_cells(totalMerge) + totalString= f"TOTAL" + totalStringCelula = f"A{size2+12}" + sheet[totalStringCelula] = totalString + + cell = sheet[totalStringCelula] + cell.fill = PatternFill(start_color=cinza, end_color=cinza, + fill_type = "solid") + cell.font = Font(name="Arial", size=12, color="000000",bold = True) + cell.alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + + #TotalReceitaFormula + cell=sheet[f'F{size2+12}'] + cell.fill = PatternFill(start_color=cinza, end_color=cinza, + fill_type = "solid") + cell.font = Font(name="Arial", size=12, color="000000",bold = True) + cell.number_format = 'R$ #,##0.00' + #Total Despesa + + totalMerge = f"H{size2+12}:I{size2+12}" + sheet.merge_cells(totalMerge) + totalString= f"TOTAL" + totalStringCelula = f"H{size2+12}" + sheet[totalStringCelula] = totalString + cell = sheet[totalStringCelula] + cell.fill = PatternFill(start_color=cinza, end_color=cinza, + fill_type = "solid") + cell.font = Font(name="Arial", size=12, color="000000",bold=True) + cell.alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + #Total Despesa Formula + cell=sheet[f'J{size2+12}'] + cell.fill = PatternFill(start_color=cinza, end_color=cinza, + fill_type = "solid") + cell.font = Font(name="Arial", size=12, color="000000",bold = True) + cell.number_format = 'R$ #,##0.00' + + + #Barraazul + + barrazulMerge = f"A{size2+14}:J{size2+14}" + sheet.merge_cells(barrazulMerge) + barrazulStringCelula = f"A{size2+14}" + cell = sheet[barrazulStringCelula] + + cell.fill = PatternFill(start_color=azul_claro, end_color=azul_claro, + fill_type = "solid") + cell.alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + + + + #brasilia + brasilia_row = size2 + 16 + brasilia_formula = f"" + brasilia_merge_cells = f'A{brasilia_row}:I{brasilia_row}' + sheet.merge_cells(brasilia_merge_cells) + top_left_brasilia_cell_formula = f'A{brasilia_row}' + top_left_brasilia_cell = sheet[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 = size2 + 19 + diretor_cargo_row = size2 + 20 + diretor_cpf_row = size2 + 21 + diretor_nome_formula = f"Daniel Monteiro Rosa" + diretor_cargo_formula = f"Diretor-Financeiro" + diretor_cpf_formula = f"450.720.272-87" + 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}' + sheet.merge_cells(diretor_merge_cells) + sheet.merge_cells(diretor_cargo_merge_cells) + sheet.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 = sheet[top_left_diretor_cell_formula] + top_left_diretor_cell_cargo_formula = sheet[top_left_diretor_cell_cargo_formula] + top_left_diretor_cell_cpf_formula = sheet[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(name="Arial", size=12,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 = size2 + 19 + coordenadora_cargo_row = size2 + 20 + coordenadora_cpf_row = size2 + 21 + coordenadora_nome_formula = f"teste" + coordenadora_cargo_formula = f"Coordenador(a)" + coordenadora_cpf_formula = f"teste" + coordenadora_merge_cells = f'H{coordenadora_row}:J{coordenadora_row}' + coordenadora_cargo_merge_cells = f'H{coordenadora_cargo_row}:J{coordenadora_cargo_row}' + coordenadora_cpf_merge_cells = f'H{coordenadora_cpf_row}:J{coordenadora_cpf_row}' + sheet.merge_cells(coordenadora_merge_cells) + sheet.merge_cells(coordenadora_cargo_merge_cells) + sheet.merge_cells(coordenadora_cpf_merge_cells) + top_left_coordenadora_cell_formula = f'H{coordenadora_row}' + top_left_coordenadora_cell_cargo_formula = f'H{coordenadora_cargo_row}' + top_left_coordenadora_cell_cpf_formula = f'H{coordenadora_cpf_row}' + top_left_coordenadora_cell = sheet[top_left_coordenadora_cell_formula] + top_left_coordenadora_cell_cargo_formula = sheet[top_left_coordenadora_cell_cargo_formula] + top_left_coordenadora_cell_cpf_formula = sheet[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(name="Arial", size=12, color="000000",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 sheet.iter_rows(min_row=1,max_row=coordenadora_cpf_row,min_col=10,max_col=10): + for cell in row: + cell.border = Border(top=Side(border_style="none") ,left = Side(border_style="none") ,right =Side(border_style="medium") ,bottom=Side(border_style="none") ) + + for row in sheet.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") ) + + # #deixar azul a letra de receita + # cell=sheet['E16'] + # cell.font = Font(name="Arial", size=12,color="0000FF") + # #deixar VERMELHO a letra de receita + # cell=sheet[f'E{17}'] + # cell.font = Font(name="Arial", size=12,color="FF0000") + + # cell=sheet[f'E{18}'] + # cell.font = Font(name="Arial", size=12,color="FF0000") + + workbook.save(tabela) + workbook.close() + + # print(f'printandosize2') + # print(size2) + #retorna tamanho de brasilia e de equipamentos + return size2 + 16,size+3 + +def estiloGeral(tabela,tamanho,nomeVariavel,nomeTabela,stringTamanho,tamanhoestorno): + '''Esse estilo e considerado geral por que todas as tabelas que compõe utilizam das mesma colunas. + + Argumentos: + tabela: recebe o arquivo correspondente a tabela Fub extensão xlsx. Esse arquivo ja foi iniciado e passou pela preencher fub mas ainda esta sem o estilo que sera aplicado nessa função. + tamanho: e o tamanho total de linhas que irao ser geradas dinamicamente correspondente as entradas do respectivo projeto. o valor varia dentre o tamanho das rubricas + + nomeVariavel: variável utilizada para criar o nomes das variaveis dinamicamente para não haver sobreposição de estilos com o mesmo nome. Esses estilos ocorrem nesses codigos: + 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"'.... + nomeTabela: variável utilizada para a criação do nome da tabela.Ela deriva das rubricas que são colocadas no input quando essa função e chamada. + stringTamanho: refere-se aonde esta localizado a string brasilia na pagina Receita e despesa para a referencias das formulas. + tamanhoEstorno = Correspondente ao tamanho do estrono + ''' + nomeSheet=nomeVariavel + random_number = random.randint(1, 10000) + nomeVariavel = f'{nomeVariavel}{random_number}' caminho = pegar_caminho(tabela) workbook = openpyxl.load_workbook(caminho) worksheet = workbook[nomeTabela] @@ -38,7 +1079,7 @@ def estiloGeral(tabela,tamanho,nomeVariavel,nomeTabela): 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 row in worksheet.iter_rows(min_row=1, max_row=size+12,min_col=10,max_col=10): for cell in row: cell.border = borda @@ -57,55 +1098,61 @@ def estiloGeral(tabela,tamanho,nomeVariavel,nomeTabela): #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' + nomeTabela = nomeTabela.upper() + worksheet['A1'] = f'R E L A Ç Ã O D E P A G A M E N T O S - {nomeTabela}' + + # 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' + # elif nomeSheet == "auxilio": + # 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 E PESQUISADOR' + # 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' + # elif nomeSheet == "isss": + # worksheet['A1'] = f'ISS 5% e ISS 2%' + 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.merge_cells('A3:J3') 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.merge_cells('A4:J4') 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.merge_cells('A5:J5') 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.merge_cells('A6:J6') 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.merge_cells('A7:J7') 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") @@ -138,7 +1185,7 @@ def estiloGeral(tabela,tamanho,nomeVariavel,nomeTabela): #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 + worksheet.row_dimensions[row[0].row].height = 75 input3 = f'customNumber{nomeVariavel}' # MASCARA R$ @@ -234,9 +1281,39 @@ def estiloGeral(tabela,tamanho,nomeVariavel,nomeTabela): merge_formula = f'D{row_number}:E{row_number}' worksheet.merge_cells(merge_formula) - + #mergecells + for x in range(size+4,size+5+tamanhoestorno): + worksheet.merge_cells(start_row=x ,start_column=4, end_row=x, end_column=5) + + + #estorno + + for rows in worksheet.iter_rows(min_row=size+5, max_row=size+4+tamanhoestorno, min_col=1, max_col=10): + for cell in rows: + if cell.row % 2: + cell.font = Font(name="Arial", size=12, color="000000") + cell.fill = PatternFill(start_color=cinza, end_color=cinza, + fill_type = "solid") + if cell.column == 10: + cell.number_format = 'R$ #,##0.00' + cell.font = Font(name="Arial", size=12, color="000000") + + cell.border = Border(top=Side(border_style="hair") ,left = Side(border_style="hair") ,right =Side(border_style="hair") ,bottom=Side(border_style="hair")) + cell.font = Font(name="Arial", size=12, color="000000") + + + #bordas,corsimcornao,money + # Set the height of each row to 60 + for row in worksheet.iter_rows(min_row=size+4, max_row=size+4+tamanhoestorno): + worksheet.row_dimensions[row[0].row].height = 75 + + min_row = size + 4 + max_row = size + 4 + tamanhoestorno + + + #subtotal2 - sub_total2_row = size + 5 + sub_total2_row = size + 6 +tamanhoestorno 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}' @@ -249,12 +1326,13 @@ def estiloGeral(tabela,tamanho,nomeVariavel,nomeTabela): 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].value = f'=SUM(J{size+5}:J{sub_total2_row-1})' 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_row = size + 7 + tamanhoestorno 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}' @@ -267,8 +1345,8 @@ def estiloGeral(tabela,tamanho,nomeVariavel,nomeTabela): #total_formula - total_formula_row = size + 6 - total_formulaa = f'=J{size}' + total_formula_row = size + 7 + tamanhoestorno + total_formulaa = f'=J{size+2} - J{sub_total2_row }' 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) @@ -278,10 +1356,11 @@ def estiloGeral(tabela,tamanho,nomeVariavel,nomeTabela): 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_row = size + 8 +tamanhoestorno + brasilia_formula = f"='Receita x Despesa'!A{stringTamanho}:J{stringTamanho}" 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}' @@ -290,12 +1369,13 @@ def estiloGeral(tabela,tamanho,nomeVariavel,nomeTabela): 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_row = size + 9 + tamanhoestorno + diretor_cargo_row = size + 10 + tamanhoestorno + diretor_cpf_row = size + 11 + tamanhoestorno + + diretor_nome_formula = f"='Receita x Despesa'!A{stringTamanho+3}" + diretor_cargo_formula = f"='Receita x Despesa'!A{stringTamanho+4}" + diretor_cpf_formula = f"='Receita x Despesa'!A{stringTamanho+5}" 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}' @@ -316,12 +1396,12 @@ def estiloGeral(tabela,tamanho,nomeVariavel,nomeTabela): 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_row = size + 9 + tamanhoestorno + coordenadora_cargo_row = size + 10 + tamanhoestorno + coordenadora_cpf_row = diretor_cpf_row + coordenadora_nome_formula = f"='Receita x Despesa'!H{stringTamanho+3}" + coordenadora_cargo_formula = f"='Receita x Despesa'!H{stringTamanho+4}" + coordenadora_cpf_formula = f"='Receita x Despesa'!H{stringTamanho+5}" 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}' @@ -338,7 +1418,7 @@ def estiloGeral(tabela,tamanho,nomeVariavel,nomeTabela): 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.font= Font(name="Arial", size=12, color="000000",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") @@ -350,7 +1430,9 @@ def estiloGeral(tabela,tamanho,nomeVariavel,nomeTabela): # for cell in row: # cell.border = borda - + for row in worksheet.iter_rows(min_row=1, max_row=coordenadora_cpf_row+1,min_col=11,max_col=11): + for cell in row: + cell.border = Border(top=Side(border_style="none") ,left = Side(border_style="medium") ,right =Side(border_style="none") ,bottom=Side(border_style="none") ) 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: @@ -362,21 +1444,32 @@ def estiloGeral(tabela,tamanho,nomeVariavel,nomeTabela): workbook.save(tabela) workbook.close() -def estilo_conciliacoes_bancaria(tabela,tamanho,tamanho2): + return size+4 + +def estilo_conciliacoes_bancaria(tabela,tamanho,tamanho2,stringTamanho): + """Estilo um pouco diferente pois necessita de dois aspectos dinâmicos que é primeiramente a quantidade de entradas de pagamento de tarifas bancárias e por fim a quantidade de estorno. Sabendo + esses valores é possivel criar a tabela. - + Argumentos: + tabela: recebe o arquivo correspondente a tabela Fub extensão xlsx. Esse arquivo foi iniciado e passou pela preencher fub mas ainda está sem o estilo que será aplicado nessa função. + tamanho:Corresponde ao tamanho das quantidade de transfêrencia bancárias realizada. + tamanho2:Corresponde ao tamanho dos estornos. + stringTamanho: refere-se aonde esta localizado a string brasilia na pagina Receita e despesa para a referências das formulas. + """ + + #pegar o arquivo e carregar ele um worksheet da pagaina Conciliação Bancária caminho = pegar_caminho(tabela) workbook = openpyxl.load_workbook(caminho) worksheet = workbook['Conciliação Bancária'] - - - size = tamanho + 16 - #worksheet.row_dimensions[27].height = 50 + + #size e o tamanho da quantidade de arquivos recebido no argumento tamanho mais o tamanho do cabecario que no caso da fub e de 16 + size = tamanho + 17 cinza = "d9d9d9" cinza_escuro = "bfbfbf" azul = "336394" azul_claro = '1c8cbc' + #Borda apenas do lado direito da cedula, uma borda mas larga borda = Border(right=Side(border_style="medium")) worksheet.sheet_view.showGridLines = False # @@ -449,14 +1542,16 @@ def estilo_conciliacoes_bancaria(tabela,tamanho,tamanho2): sttring = f"D{i}:F{i}" worksheet.merge_cells(sttring) - for i in range(size+3,size+3+tamanho2): + for i in range(size+3,size+4+tamanho2+1): sttring = f"D{i}:F{i}" worksheet.merge_cells(sttring) + random_number = random.randint(1, 10000) + 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 = NamedStyle(name=f'custom_number_format_conciliacoes{random_number}') 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) @@ -519,14 +1614,34 @@ def estilo_conciliacoes_bancaria(tabela,tamanho,tamanho2): 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.alignment = Alignment(horizontal="center",vertical="center") + + #saldo anterior restituição + row_restituicao = f'A{size+4}' + worksheet[row_restituicao] = 'Saldo anterior' + worksheet[row_restituicao].font = Font(name="Arial", size=12, color="000000") + worksheet[row_restituicao].alignment = Alignment(horizontal="left",vertical="center") + row_restituicao = f'b{size+4}' + worksheet[row_restituicao].font = Font(name="Arial", size=12, color="000000") + worksheet[row_restituicao].alignment = Alignment(horizontal="left",vertical="center") + row_restituicao = f'c{size+4}' + worksheet[row_restituicao] = 'Diversos' + worksheet[row_restituicao].font = Font(name="Arial", size=12, color="000000") + worksheet[row_restituicao].alignment = Alignment(horizontal="left",vertical="center") + row_restituicao = f'd{size+4}' + worksheet[row_restituicao] = 'Restituição Prestações Anteriores' + worksheet[row_restituicao].font = Font(name="Arial", size=12, color="000000") + worksheet[row_restituicao].alignment = Alignment(horizontal="left",vertical="center") + + + + size = size + 1 + + for row in range(size+3,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 rows in worksheet.iter_rows(min_row=size+3, max_row=size+3+tamanho2, min_col=1, max_col=6): for cell in rows: if cell.row % 2: cell.fill = PatternFill(start_color=cinza, end_color=cinza, @@ -538,13 +1653,13 @@ def estilo_conciliacoes_bancaria(tabela,tamanho,tamanho2): # FORMULATOTALrestituição - formula = f"=SUM(B{size+4}:B{size+tamanho2+3})" - celula = f'B{size+tamanho2+4}' + formula = f"=SUM(B{size+3}:B{size+tamanho2+3})" + celula = f'B{size+tamanho2+5}' 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}' + celula_total = F'A{size+tamanho2+5}' 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) @@ -558,18 +1673,33 @@ def estilo_conciliacoes_bancaria(tabela,tamanho,tamanho2): 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 = NamedStyle(name=f'saldodiposnivelformat_conciliacoes{random_number}') 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}' + celular.value = f'=F10+F11+B{size-1} -B{size+tamanho2+5}' + #saldo anterior + formula = f"Saldo anterior" + celula = f'A16' + worksheet[celula] = formula + worksheet[celula].font = Font(name="Arial", size=12, color="000000") + + formula = f"Diversos" + celula = f'C16' + worksheet[celula] = formula + worksheet[celula].font = Font(name="Arial", size=12, color="000000") + + formula = f"Tarifas Prestações Anteriores" + celula = f'D16' + worksheet[celula] = formula + worksheet[celula].font = Font(name="Arial", size=12, color="000000") #brasilia brasilia_row = size + tamanho2+ 8 - brasilia_formula = f"='Receita x Despesa'!A42:F42" + brasilia_formula = f"='Receita x Despesa'!A{stringTamanho}:J{stringTamanho}" 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}' @@ -581,9 +1711,9 @@ def estilo_conciliacoes_bancaria(tabela,tamanho,tamanho2): 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_nome_formula = f"='Receita x Despesa'!A{stringTamanho+3}" + diretor_cargo_formula = f"='Receita x Despesa'!A{stringTamanho+4}" + diretor_cpf_formula = f"='Receita x Despesa'!A{stringTamanho+5}" 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}' @@ -604,12 +1734,12 @@ def estilo_conciliacoes_bancaria(tabela,tamanho,tamanho2): 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_row = diretor_row + coordenadora_cargo_row = diretor_cargo_row + coordenadora_cpf_row = diretor_cpf_row + coordenadora_nome_formula = f"='Receita x Despesa'!H{stringTamanho+3}" + coordenadora_cargo_formula = f"='Receita x Despesa'!H{stringTamanho+4}" + coordenadora_cpf_formula = f"='Receita x Despesa'!H{stringTamanho+5}" 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}' @@ -627,13 +1757,13 @@ def estilo_conciliacoes_bancaria(tabela,tamanho,tamanho2): 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.font= Font(name="Arial", size=12, color="000000",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 row in worksheet.iter_rows(min_row=1, max_row=coordenadora_cpf_row+1,min_col=6,max_col=6): for cell in row: cell.border = borda @@ -647,13 +1777,20 @@ def estilo_conciliacoes_bancaria(tabela,tamanho,tamanho2): workbook.save(tabela) workbook.close() -def estilo_rendimento_de_aplicacao(tabela,tamanho): +def estilo_rendimento_de_aplicacao(tabela,tamanho,stringTamanho): + """Estilo da rendimento de aplicação, tabela com as colunas periodo, saldo anterior,valor aplicado no período,valor resgatado no período,rendimento bruto,imposto,rendimento luiquido,saldo. + + Argumentos: + tabela: recebe o arquivo correspondente a tabela Fub extensão xlsx. Esse arquivo foi iniciado e passou pela preencher fub mas ainda está sem o estilo que será aplicado nessa função. + tamanho:Corresponde ao tamanho das quantidade da tabela de rencimentos. + stringTamanho: refere-se aonde esta localizado a string brasilia na pagina Receita e despesa para a referências das formulas. + """ caminho = pegar_caminho(tabela) workbook = openpyxl.load_workbook(caminho) worksheet = workbook['Rendimento de Aplicação'] - - - size = tamanho + 16 + + random_number = random.randint(1, 10000) + size = tamanho + 15 worksheet.row_dimensions[10].height = 2 worksheet.row_dimensions[9].height = 20 @@ -740,8 +1877,20 @@ def estilo_rendimento_de_aplicacao(tabela,tamanho): coluna = coluna + 1 - for i in range(1,9): - worksheet.merge_cells(start_row=11,end_row=13,start_column=i,end_column=i) + for i in range(1,9): + worksheet.merge_cells(start_row=11,end_row=13,start_column=i,end_column=i) + + + #RENDIMENTO LIQUIDO + # print(size) + for row in worksheet.iter_rows(min_row=14, max_row=size, min_col=7, max_col=7): + for cell in row: + stringSaldo = f"=E{cell.row} - F{cell.row}" + cell.value = stringSaldo + + + + #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): @@ -755,50 +1904,71 @@ def estilo_rendimento_de_aplicacao(tabela,tamanho): 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") + cell.number_format ='#,##0.00' + #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) - + + + # #MASCARA AZUL + # 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="141fca") + # cell.number_format ='#,##0.00' + + # 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) + # cell.number_format ='#,##0.00' + + #barra de totais + formula = f"Saldo anterior" + celula = f'A14' + worksheet[celula] = formula + worksheet[celula].font = Font(name="Arial", size=12, color="000000",bold=True) #barra de totais # FORMULATOTAL + #B + formula = f"=SUM(B15: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) #C - formula = f"=SUM(C14:C{size-1})" + formula = f"=SUM(C15: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})" + formula = f"=SUM(D15: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})" + formula = f"=SUM(E15: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})" + formula = f"=SUM(F15: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})" + formula = f"=SUM(G15: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})" + formula = f"=SUM(H15: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") @@ -812,7 +1982,7 @@ def estilo_rendimento_de_aplicacao(tabela,tamanho): #brasilia brasilia_row = size + 2 - brasilia_formula = f"='Receita x Despesa'!A42:F42" + brasilia_formula = f"='Receita x Despesa'!A{stringTamanho}:J{stringTamanho}" 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}' @@ -824,9 +1994,9 @@ def estilo_rendimento_de_aplicacao(tabela,tamanho): 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_nome_formula = f"='Receita x Despesa'!A{stringTamanho+3}" + diretor_cargo_formula = f"='Receita x Despesa'!A{stringTamanho+4}" + diretor_cpf_formula = f"='Receita x Despesa'!A{stringTamanho+5}" 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}' @@ -850,9 +2020,9 @@ def estilo_rendimento_de_aplicacao(tabela,tamanho): 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_nome_formula = f"='Receita x Despesa'!H{stringTamanho+3}" + coordenadora_cargo_formula = f"='Receita x Despesa'!H{stringTamanho+4}" + coordenadora_cpf_formula = f"='Receita x Despesa'!H{stringTamanho+5}" 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}' @@ -869,7 +2039,7 @@ def estilo_rendimento_de_aplicacao(tabela,tamanho): 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.font= Font(name="Arial", size=12, color="000000",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") @@ -885,17 +2055,26 @@ def estilo_rendimento_de_aplicacao(tabela,tamanho): workbook.save(tabela) workbook.close() -def estiloRelacaoBens(tabela,tamanho,nomeVariavel,nomeTabela): - nomeVariavel = f'material' +def estiloRelacaoBens(tabela,tamanho,nomeVariavel,nomeTabela,stringTamanho): + """Estilo da tabela de bens, consulta no banco sap + + Argumentos: + tabela: recebe o arquivo correspondente a tabela Fub extensão xlsx. Esse arquivo foi iniciado e passou pela preencher fub mas ainda está sem o estilo que será aplicado nessa função. + tamanho:Corresponde ao tamanho das quantidade de bens. + stringTamanho: refere-se aonde esta localizado a string brasilia na pagina Receita e despesa para a referências das formulas. + """ + random_number = random.randint(1, 10000) + + nomeVariavel = f'material{random_number}' caminho = pegar_caminho(tabela) workbook = openpyxl.load_workbook(caminho) worksheet = workbook[nomeTabela] - size = tamanho + 1 + size = tamanho + 13 cinza = "d9d9d9" cinza_escuro = "bfbfbf" azul = "336394" azul_claro = '1c8cbc' - + borda = Border(right=Side(border_style="medium")) worksheet.sheet_view.showGridLines = False # @@ -905,11 +2084,11 @@ def estiloRelacaoBens(tabela,tamanho,nomeVariavel,nomeTabela): worksheet.column_dimensions['a'].width = 25 - worksheet.column_dimensions['b'].width = 25 + worksheet.column_dimensions['b'].width = 50 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['f'].width = 70 #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 @@ -1050,8 +2229,12 @@ def estiloRelacaoBens(tabela,tamanho,nomeVariavel,nomeTabela): value_to_stop = size start_row = 10 # - for row in range(start_row,size+1): - cell = worksheet[f'J{row}'] + for row in range(13,size+1): + cell = worksheet[f'H{row}'] + cell.style = locals()[input3] + + for row in range(13,size+1): + cell = worksheet[f'I{row}'] cell.style = locals()[input3] for rows in worksheet.iter_rows(min_row=13, max_row=size, min_col=1, max_col=10): @@ -1085,7 +2268,7 @@ def estiloRelacaoBens(tabela,tamanho,nomeVariavel,nomeTabela): worksheet.row_dimensions[size+2].height = 56.25 # FORMULATOTAL - formula = f"=SUM(J10:J{size})" + formula = f"=SUM(I13:I{size})" celula = f'J{size+2}' worksheet[celula] = formula worksheet[celula].fill = PatternFill(start_color=cinza, end_color=cinza,fill_type = "solid") @@ -1096,7 +2279,7 @@ def estiloRelacaoBens(tabela,tamanho,nomeVariavel,nomeTabela): #brasilia brasilia_row = size + 7 - brasilia_formula = f"='Receita x Despesa'!A42:J42" + brasilia_formula = f"='Receita x Despesa'!A{stringTamanho}:J{stringTamanho}" 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}' @@ -1108,9 +2291,9 @@ def estiloRelacaoBens(tabela,tamanho,nomeVariavel,nomeTabela): 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_nome_formula = f"='Receita x Despesa'!A{stringTamanho+3}" + diretor_cargo_formula = f"='Receita x Despesa'!A{stringTamanho+4}" + diretor_cpf_formula = f"='Receita x Despesa'!A{stringTamanho+5}" 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}' @@ -1127,16 +2310,16 @@ def estiloRelacaoBens(tabela,tamanho,nomeVariavel,nomeTabela): 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.font = Font(name="Arial", size=12, color="000000",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_nome_formula = f"='Receita x Despesa'!H{stringTamanho+3}" + coordenadora_cargo_formula = f"='Receita x Despesa'!H{stringTamanho+4}" + coordenadora_cpf_formula = f"='Receita x Despesa'!H{stringTamanho+5}" 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}' @@ -1153,7 +2336,7 @@ def estiloRelacaoBens(tabela,tamanho,nomeVariavel,nomeTabela): 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.font= Font(name="Arial", size=12, color="000000",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") @@ -1186,8 +2369,16 @@ def estiloRelacaoBens(tabela,tamanho,nomeVariavel,nomeTabela): workbook.save(tabela) workbook.close() -def estilo_demonstrativoDeReceita(tabela,tamanho): +def estilo_demonstrativoDeReceita(tabela,tamanho,stringTamanho): + """Estilo da demonstrativo de receita que inclui entradas de receita ISS 2%, ISS 5%. + + Argumentos: + tabela: recebe o arquivo correspondente a tabela Fub extensão xlsx. Esse arquivo foi iniciado e passou pela preencher fub mas ainda está sem o estilo que será aplicado nessa função. + tamanho:Corresponde ao tamanho das quantidade de bens. + stringTamanho: refere-se aonde esta localizado a string brasilia na pagina Receita e despesa para a referências das formulas. + """ caminho = pegar_caminho(tabela) + workbook = openpyxl.load_workbook(caminho) worksheet = workbook['Demonstrativo de Receita'] size = tamanho + 10 @@ -1195,68 +2386,69 @@ def estilo_demonstrativoDeReceita(tabela,tamanho): cinza_escuro = "bfbfbf" azul = "336394" azul_claro = '1c8cbc' - + random_number = random.randint(1, 10000) 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 row in worksheet.iter_rows(min_row=1, max_row=size+11,min_col=5,max_col=5): 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 + worksheet.column_dimensions['a'].width = 30 + worksheet.column_dimensions['b'].width = 70 + worksheet.column_dimensions['c'].width = 30 + worksheet.column_dimensions['d'].width = 50#descrição + worksheet.column_dimensions['e'].width = 50#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.merge_cells('A1:E2') + 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 E ISS 5% E ISS 2%' 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.merge_cells('A3:E3') 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.merge_cells('A4:E4') 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.merge_cells('A5:E5') 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.merge_cells('A6:E6') 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.merge_cells('A7:E7') 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 = NamedStyle(name=f'row_style_demonstrativo{random_number}') 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 row in worksheet.iter_rows(min_row=linha_number, max_row=linha_number, min_col=1, max_col=5): for cell in row: cell.style = row_style_demonstrativo - if cell.column == 4: + if cell.column == 5: 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'] + valores = ["NomeFavorecido","Histórico","Documento","Data de Entrada",'Valor'] col = 1 for a,b in enumerate(valores): worksheet.cell(row=linha_number, column=col, value=b) @@ -1265,12 +2457,12 @@ def estilo_demonstrativoDeReceita(tabela,tamanho): #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 + worksheet.row_dimensions[row[0].row].height = 80 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 = NamedStyle(name=f'custom_number_format_demonstrativo{random_number}') 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) @@ -1280,15 +2472,15 @@ def estilo_demonstrativoDeReceita(tabela,tamanho): start_row = 10 # for row in range(start_row,size+1): - cell = worksheet[f'D{row}'] + cell = worksheet[f'E{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 rows in worksheet.iter_rows(min_row=10, max_row=size, min_col=1, max_col=5): for cell in rows: if cell.row % 2: cell.fill = PatternFill(start_color=cinza, end_color=cinza, fill_type = "solid") - if cell.column == 4: + if cell.column == 5: 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") ) @@ -1301,7 +2493,7 @@ def estilo_demonstrativoDeReceita(tabela,tamanho): #subtotal stringAfinarCelula =size+2 worksheet.row_dimensions[size+2].height = 6 - celulas_mergidas_subtotal = f"A{size+2}:C{size+2}" + celulas_mergidas_subtotal = f"A{size+2}:D{size+2}" worksheet.merge_cells(celulas_mergidas_subtotal) left_celula_cell = f"A{size+2}" top_left_cell = worksheet[left_celula_cell] @@ -1314,8 +2506,8 @@ def estilo_demonstrativoDeReceita(tabela,tamanho): worksheet.row_dimensions[size+2].height = 56.25 # FORMULATOTAL - formula = f"=SUM(D10:D{size})" - celula = f'D{size+2}' + formula = f"=SUM(E10:E{size})" + celula = f'E{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) @@ -1329,7 +2521,7 @@ def estilo_demonstrativoDeReceita(tabela,tamanho): worksheet.row_dimensions[restituicoes].height = 30 #estilo colunas restitucoes creditadas - row_style_demonstrativo_append = NamedStyle(name='row_style_demonstrativo_append') + row_style_demonstrativo_append = NamedStyle(name=f'row_style_demonstrativo_append{random_number}') 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) @@ -1339,19 +2531,19 @@ def estilo_demonstrativoDeReceita(tabela,tamanho): row_number = size + 4 - for column in range(1, 5): + for column in range(1, 6): cell = worksheet.cell(row=row_number, column=column) cell.style = row_style_demonstrativo_append - if cell.column == 4: + if cell.column == 5: 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'] + values = ["NomeFavorecido","Histórico","Documento","Data de Entrada",'Valor'] coluna = 1 for a,b in enumerate(values): worksheet.cell(row=row_number, column=coluna, value=b) - if coluna == 4: + if coluna == 5: coluna = coluna + 1 coluna = coluna + 1 @@ -1361,7 +2553,7 @@ def estilo_demonstrativoDeReceita(tabela,tamanho): #subtotal2 sub_total2_row = size + 5 - subtotal_merge_cells= f'A{sub_total2_row}:C{sub_total2_row}' + subtotal_merge_cells= f'A{sub_total2_row}:D{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] @@ -1371,7 +2563,7 @@ def estilo_demonstrativoDeReceita(tabela,tamanho): 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}' + sub_formula_row_celula = f'E{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' @@ -1379,7 +2571,7 @@ def estilo_demonstrativoDeReceita(tabela,tamanho): #total1-2 total12_row = size + 6 - total12_merge_cells = f'A{total12_row}:C{total12_row}' + total12_merge_cells = f'A{total12_row}:D{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] @@ -1392,8 +2584,8 @@ def estilo_demonstrativoDeReceita(tabela,tamanho): #total_formula total_formula_row = size + 6 - total_formulaa = f'=D{size}' - total_formula_row_celula = f'D{total_formula_row}' + total_formulaa = f'=E{size}' + total_formula_row_celula = f'E{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' @@ -1404,8 +2596,8 @@ def estilo_demonstrativoDeReceita(tabela,tamanho): #brasilia brasilia_row = size + 7 - brasilia_formula = f"='Receita x Despesa'!A42:D42" - brasilia_merge_cells = f'A{brasilia_row}:D{brasilia_row}' + brasilia_formula = f"='Receita x Despesa'!A{stringTamanho}:J{stringTamanho}" + brasilia_merge_cells = f'A{brasilia_row}:E{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] @@ -1416,9 +2608,9 @@ def estilo_demonstrativoDeReceita(tabela,tamanho): 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_nome_formula = f"='Receita x Despesa'!A{stringTamanho+3}" + diretor_cargo_formula = f"='Receita x Despesa'!A{stringTamanho+4}" + diretor_cpf_formula = f"='Receita x Despesa'!A{stringTamanho+5}" 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}' @@ -1435,19 +2627,19 @@ def estilo_demonstrativoDeReceita(tabela,tamanho): 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.font = Font(name="Arial", size=12, color="000000",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}' + coordenadora_nome_formula = f"='Receita x Despesa'!H{stringTamanho+3}" + coordenadora_cargo_formula = f"='Receita x Despesa'!H{stringTamanho+4}" + coordenadora_cpf_formula = f"='Receita x Despesa'!H{stringTamanho+5}" + coordenadora_merge_cells = f'C{coordenadora_row}:E{coordenadora_row}' + coordenadora_cargo_merge_cells = f'C{coordenadora_cargo_row}:E{coordenadora_cargo_row}' + coordenadora_cpf_merge_cells = f'C{coordenadora_cpf_row}:E{coordenadora_cpf_row}' worksheet.merge_cells(coordenadora_merge_cells) worksheet.merge_cells(coordenadora_cargo_merge_cells) worksheet.merge_cells(coordenadora_cpf_merge_cells) @@ -1461,7 +2653,7 @@ def estilo_demonstrativoDeReceita(tabela,tamanho): 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.font= Font(name="Arial", size=12, color="000000",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") @@ -1475,2324 +2667,12 @@ def estilo_demonstrativoDeReceita(tabela,tamanho): - 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 row in worksheet.iter_rows(min_row=coordenadora_cpf_row+1, max_row=coordenadora_cpf_row+1,min_col=1,max_col=5): for cell in row: - if cell.column == 4: + if cell.column == 5: 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 old mode 100644 new mode 100755 diff --git a/project/app/migrations/0001_initial.py b/project/app/migrations/0001_initial.py index de25f519..0764d8aa 100644 --- a/project/app/migrations/0001_initial.py +++ b/project/app/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 4.2.5 on 2023-10-27 11:29 +# Generated by Django 4.2.4 on 2024-02-08 14:19 from django.db import migrations, models import django.db.models.deletion @@ -23,6 +23,35 @@ class Migration(migrations.Migration): ('id_projeto', models.CharField(max_length=50)), ], ), + migrations.CreateModel( + name='Lancamento', + 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='Mapeamento', fields=[ @@ -69,36 +98,7 @@ class Migration(migrations.Migration): ('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)), + ('id_tipo', models.CharField(max_length=200)), ], ), migrations.CreateModel( @@ -112,6 +112,16 @@ class Migration(migrations.Migration): ('nome_usuario', models.CharField(max_length=200)), ], ), + migrations.CreateModel( + name='UserActivity', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('user_id', models.CharField(max_length=255)), + ('tag', models.CharField(max_length=50)), + ('activity', models.TextField()), + ('timestamp', models.DateTimeField(auto_now_add=True)), + ], + ), migrations.CreateModel( name='Template', fields=[ diff --git a/project/app/migrations/0002_employee.py b/project/app/migrations/0002_employee.py new file mode 100644 index 00000000..480b7867 --- /dev/null +++ b/project/app/migrations/0002_employee.py @@ -0,0 +1,24 @@ +# Generated by Django 4.2.4 on 2024-02-08 14:22 + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('app', '0001_initial'), + ] + + operations = [ + migrations.CreateModel( + name='Employee', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('cpf', models.CharField(max_length=11)), + ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), + ], + ), + ] 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 deleted file mode 100644 index 7f555884..00000000 --- a/project/app/migrations/0002_rename_agencia_bancaria_mapeamento_agencia_bancaria_and_more.py +++ /dev/null @@ -1,17 +0,0 @@ -# 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 deleted file mode 100644 index 617f6ce0..00000000 --- a/project/app/migrations/0003_alter_mapeamento_id_tipo.py +++ /dev/null @@ -1,18 +0,0 @@ -# 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/models.py b/project/app/models.py old mode 100644 new mode 100755 index 13aceae7..5c882833 --- a/project/app/models.py +++ b/project/app/models.py @@ -1,4 +1,9 @@ from django.db import models +from django.contrib.auth.models import User + +class Employee(models.Model): + user = models.OneToOneField(User, on_delete=models.CASCADE) + cpf = models.CharField(max_length=11) class Mapeamento(models.Model): id_mapeamento = models.IntegerField(primary_key=True) @@ -96,3 +101,12 @@ class Export(models.Model): nome_template = models.CharField(max_length=200) nome_usuario = models.CharField(max_length=200) id_projeto = models.CharField(max_length=50) + +class UserActivity(models.Model): + user_id = models.CharField(max_length=255) + tag = models.CharField(max_length=50) + activity = models.TextField() + timestamp = models.DateTimeField(auto_now_add=True) + + def __str__(self): + return f"{self.user_id} - {self.activity}" \ No newline at end of file diff --git a/project/app/new_dev.py b/project/app/new_dev.py old mode 100644 new mode 100755 index c5f1e2dd..08dd8353 --- a/project/app/new_dev.py +++ b/project/app/new_dev.py @@ -3,25 +3,92 @@ import os -def pegar_caminho(nome_arquivo): +# def pegar_caminho(nome_arquivo): - # Obter o caminho absoluto do arquivo Python em execução - caminho_script = os.path.abspath(__file__) +# # 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) +# # 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) +# # Combinar o caminho da pasta com o nome do arquivo Excel +# caminho = os.path.join(pasta_script, nome_arquivo) - return caminho +# return caminho -def preenche_planilha(planilha, dicionario): +# def pegar_caminho(nome_arquivo, diretorio=''): +# # Obter o caminho absoluto do diretório onde este script está localizado +# pasta_script = os.path.dirname(os.path.abspath(__file__)) - caminho = pegar_caminho(planilha) - Plan = planilha +# # Navegar para o diretório do projeto +# pasta_projeto = os.path.dirname(os.path.dirname(pasta_script)) + +# # Combinar o caminho do diretório fornecido com o nome do arquivo Excel +# caminho = os.path.join(pasta_projeto, diretorio, nome_arquivo) + +# return caminho + +# caminho2 = pegar_caminho("planilhas_preenchidas.txt") +# print(caminho2) + +import os + +def pegar_caminho(subdiretorio): + # Obtém o caminho do script atual + arq_atual = os.path.abspath(__file__) + + # Obtém o diretório do script + app = os.path.dirname(arq_atual) + + # Obtém o diretório pai do script + project = os.path.dirname(app) + + # Obtém o diretório pai do projeto + pipeline = os.path.dirname(project) + + # Junta o diretório pai do projeto com o subdiretório desejado + caminho_pipeline = os.path.join(pipeline, subdiretorio) + + return caminho_pipeline + +# caminho = pegar_caminho("planilhas") +# print(caminho) + + +# def preenche_planilha(planilha, dicionario): + +# caminho = pegar_caminho(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 + +# caminho_planilha = os.path.join(caminho, planilha) +# workbook.save(caminho_planilha) + +# print(f"arquivo salvo como planilhas_preenchidas/{planilha}") +# return caminho_planilha + +def preenche_planilha(planilha, dicionario,codigo,template_id,consultaInicio,consultaFim,stringNomeFinanciador): + + + filename = os.path.basename(planilha) # carrega a planilha de acordo com o caminho - workbook = op.load_workbook(caminho) + workbook = op.load_workbook(planilha) + #print("Nomes das Planilhas no Excel:", workbook.sheetnames) # planilha_preenchida = pegar_caminho('preenchido-' + planilha) for nomePlanilha, entradaDados in dicionario.items(): @@ -38,15 +105,20 @@ def preenche_planilha(planilha, dicionario): # planilhaAtual[intervaloCelula].fill = color <--- teste com cores - workbook.save(f"app/planilhas_preenchidas/{planilha}") + caminho_pasta_planilhas = "../../planilhas_preenchidas/" + + # Obtém o diretório atual do script + diretorio_atual = os.path.dirname(os.path.abspath(__file__)) + + # Combina o diretório atual com o caminho para a pasta "planilhas_preenchidas" e o nome do arquivo + #salvar = os.path.join(diretorio_atual, caminho_pasta_planilhas, f"planilhaPreenchida{filename}") + salvar = os.path.join(diretorio_atual, caminho_pasta_planilhas, f"PC - {stringNomeFinanciador} - {codigo} - {consultaInicio} a {consultaFim}.xlsx") - print(f"arquivo salvo como planilhas_preenchidas/{planilha}") - return f"app/planilhas_preenchidas/{planilha}" -# workbook = op.load_workbook('Modelo_Fub.xlsm') -# number = 3108 + workbook.save(salvar) + workbook.close() + print(f"arquivo salvo como {salvar}") -# value = datetime.datetime.strptime("2014-06-23", "%Y-%m-%d") def extrair(text_list): start_delimiter = "@@" end_delimiter = "@@" @@ -222,4 +294,4 @@ def extrair(text_list): # workbook.save("modified_ModeloFub.xlsx") -#preenche_planilha('planilhas/FUNDEP.xlsx', planilha_local_dados) +#preenche_planilha('planilhas/FUNDEP.xlsx', planilha_local_dados) \ No newline at end of file diff --git a/project/app/oracle_cruds.py b/project/app/oracle_cruds.py deleted file mode 100644 index 51805a97..00000000 --- a/project/app/oracle_cruds.py +++ /dev/null @@ -1,199 +0,0 @@ -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/pegar_caminho.py b/project/app/pegar_caminho.py new file mode 100755 index 00000000..aed2e292 --- /dev/null +++ b/project/app/pegar_caminho.py @@ -0,0 +1,17 @@ +def pegar_caminho(subdiretorio): + # Obtém o caminho do script atual + arq_atual = os.path.abspath(__file__) + + # Obtém o diretório do script + app = os.path.dirname(arq_atual) + + # Obtém o diretório pai do script + project = os.path.dirname(app) + + # Obtém o diretório pai do projeto + pipeline = os.path.dirname(project) + + # Junta o diretório pai do projeto com o subdiretório desejado + caminho_pipeline = os.path.join(pipeline, subdiretorio) + + return caminho_pipeline \ No newline at end of file diff --git a/project/app/planilhas/ModeloFAP.xlsx b/project/app/planilhas/ModeloFAP.xlsx deleted file mode 100644 index 1de9600a..00000000 Binary files a/project/app/planilhas/ModeloFAP.xlsx and /dev/null differ diff --git a/project/app/planilhas/ModeloFUNDEP.xlsx b/project/app/planilhas/ModeloFUNDEP.xlsx deleted file mode 100644 index cb930749..00000000 Binary files a/project/app/planilhas/ModeloFUNDEP.xlsx and /dev/null differ diff --git a/project/app/planilhas/ModeloOPAS.xlsx b/project/app/planilhas/ModeloOPAS.xlsx deleted file mode 100644 index 89b22070..00000000 Binary files a/project/app/planilhas/ModeloOPAS.xlsx and /dev/null differ diff --git a/project/app/planilhas_preenchidas/planilhas/ModeloFUNDEP.xlsx b/project/app/planilhas_preenchidas/planilhas/ModeloFUNDEP.xlsx deleted file mode 100644 index cd310147..00000000 Binary files a/project/app/planilhas_preenchidas/planilhas/ModeloFUNDEP.xlsx and /dev/null differ diff --git a/project/app/planilhas_preenchidas/planilhas/Modelo_Fub.xlsx b/project/app/planilhas_preenchidas/planilhas/Modelo_Fub.xlsx deleted file mode 100644 index 9191dce7..00000000 Binary files a/project/app/planilhas_preenchidas/planilhas/Modelo_Fub.xlsx and /dev/null differ diff --git a/project/app/preencheFap.py b/project/app/preencheFap.py new file mode 100644 index 00000000..b5669c33 --- /dev/null +++ b/project/app/preencheFap.py @@ -0,0 +1,692 @@ +import pyodbc +from datetime import datetime,date +import openpyxl +from openpyxl.styles import Font +import os +from collections import defaultdict +from .estiloFap import * +from .preencheFub import planilhaGeral,consultaID,convert_datetime_to_string,convert_datetime_to_stringdt,formatar_data,formatarDataSemDia,formatar_cpf,check_format,pegar_caminho,pegar_pass +import pandas as pd +from sqlalchemy import create_engine +from sqlalchemy.engine import URL +import numpy as np +import re + +def consultaCabecarioAnexoDois(IDPROJETO,DATA1,DATA2): + """ Informa o titulo do projeto + a instiuição gestora + a instuição executora + NTOA/ e processo + + + + """ + file_path = pegar_pass("passs.txt") + conStr = '' + with open(file_path, 'r') as file: + conStr = file.readline().strip() + + connection_url = URL.create("mssql+pyodbc", query={"odbc_connect": conStr}) + engine = create_engine(connection_url) + parametros = [(IDPROJETO,)] + queryNomeCabecario = f"SELECT [LisConvenio].NomeConvenio ,[LisConvenio].Processo,SubProcesso,ValorAprovado,NomePessoa FROM [Conveniar].[dbo].[LisConvenio] WHERE CodConvenio = ? " + dfCabecarios = pd.read_sql(queryNomeCabecario, engine, params=parametros) + + return dfCabecarios + +def consultaID(IDPROJETO): + + #file_path = "/home/ubuntu/Desktop/devfront/devfull/pass.txt" + file_path = pegar_pass("passs.txt") + conStr = '' + with open(file_path, 'r') as file: + conStr = file.readline().strip() + + conn = None + + conn = pyodbc.connect(conStr) + cursor = conn.cursor() + + + consulta = {} + + + # SQL querys + + sql = f"SELECT [LisConvenio].* , [LisPessoa].[CPFCNPJ] as 'CPFCoordenador' FROM [Conveniar].[dbo].[LisConvenio] INNER JOIN [Conveniar].[dbo].[LisUsuario] ON [LisConvenio].[CodUsuarioResponsavel] = [LisUsuario].[CodUsuario] INNER JOIN [Conveniar].[dbo].[LisPessoa] ON [LisUsuario].[CodPessoa] = [LisPessoa].[CodPessoa] WHERE CodConvenio = ? " + + # Execute the query + cursor.execute(sql, IDPROJETO) + + + records = cursor.fetchall() + + collums = cursor.description + + + for i in range(len(collums)): + consulta[collums[i][0]] = records[0][i] + + cursor.close() + conn.close() + + + + # return records + return consulta + +def consultaAnexoUm(IDPROJETO): + file_path = pegar_pass("passs.txt") + conStr = '' + with open(file_path, 'r') as file: + conStr = file.readline().strip() + + connection_url = URL.create("mssql+pyodbc", query={"odbc_connect": conStr}) + engine = create_engine(connection_url) + parametros = [(IDPROJETO,)] + queryNomeConvenioProcessoSubProcesso = f"SELECT [LisConvenio].NomeConvenio ,[LisConvenio].Processo,SubProcesso,ValorAprovado,NomePessoaResponsavel FROM [Conveniar].[dbo].[LisConvenio] WHERE CodConvenio = ? " + dfConvenioProcessoSubProcessos = pd.read_sql(queryNomeConvenioProcessoSubProcesso, engine, params=parametros) + + + return dfConvenioProcessoSubProcessos + +def consultaAnexoDois(IDPROJETO,DATA1,DATA2): + file_path = pegar_pass("passs.txt") + conStr = '' + with open(file_path, 'r') as file: + conStr = file.readline().strip() + + connection_url = URL.create("mssql+pyodbc", query={"odbc_connect": conStr}) + engine = create_engine(connection_url) + parametros = [(IDPROJETO,DATA1,DATA2)] + queryAnexoDois = f"""SELECT [NomeRubrica] + ,NumChequeDeposito + ,CONVERT(varchar(10), DataPagamento, 103) AS FormattedDate + ,NumDocPago + ,[NomeFavorecido] + ,HisLancamento + ,CASE WHEN NomeTipoCreditoDebito = 'C' THEN -1 * ValorPago ELSE ValorPago END AS ValorPago, + CASE WHEN NomeTipoCreditoDebito = 'C' THEN -1 * ValorPago ELSE ValorPago END AS ValorPago + FROM [Conveniar].[dbo].[LisLancamentoConvenio] + WHERE [LisLancamentoConvenio].CodConvenio = ? AND [LisLancamentoConvenio].CodStatus = 27 + AND [LisLancamentoConvenio].DataPagamento BETWEEN ? AND ? and [LisLancamentoConvenio].CodRubrica not in (2,3,9,67,88,0) order by DataPagamento""" + dfConvenioAnexoDois = pd.read_sql(queryAnexoDois, engine, params=parametros) + + + + return dfConvenioAnexoDois + +def consultaAnexoTres(IDPROJETO,DATA1,DATA2): + file_path = pegar_pass("passss.txt") + conStr = '' + with open(file_path, 'r') as file: + conStr = file.readline().strip() + + connection_url = URL.create("mssql+pyodbc", query={"odbc_connect": conStr}) + engine = create_engine(connection_url) + idprojetoComZero = f"0{IDPROJETO}" + parametros = [(IDPROJETO,idprojetoComZero, DATA1, DATA2)] + + queryConsultaComRubrica = f"""SELECT + CONVERT(varchar, [Data de Aquisição], 103) AS dataAqui, + [Nº Nota][nota], + [Descrição][descri], + [Valor de Aquisição][valorAqui], + [Valor de Aquisição][valorAqui2], + [Patrimônio][patri], + [Localização][localiza], + [Responsável][responsavel] + FROM [SBO_FINATEC].[dbo].[VW_BENS_ADQUIRIDOS] + WHERE ([Cod Projeto] = ? or [Cod Projeto] = ? ) + AND [Status] = 'Imobilizado' + AND [Data de Aquisição] BETWEEN ? AND ? + Order by [Data de Aquisição]""" + dfConsultaBens = pd.read_sql(queryConsultaComRubrica, engine, params=parametros) + + + return dfConsultaBens + return 0 + +def consultaRendimentosIRRFConciliacao(IDPROJETO,DATA1,DATA2): + """consulta fora do comum utilizado para pegar o total de rendimentos para aparecer na pasta conciliação + """ + file_path = pegar_pass("passs.txt") + conStr = '' + with open(file_path, 'r') as file: + conStr = file.readline().strip() + + connection_url = URL.create("mssql+pyodbc", query={"odbc_connect": conStr}) + engine = create_engine(connection_url) + parametros = [(IDPROJETO, DATA1, DATA2)] + + consultaComPeriodo =f"SELECT SUM(ValorPago) AS TotalPago FROM [Conveniar].[dbo].[LisLancamentoConvenio] WHERE CodConvenio = ? AND CodStatus = 27 AND CodRubrica = 0 AND DataPagamento BETWEEN ? AND ?" + + consultaRendimentoAplicacao = f""" + SELECT + NomeTipoLancamento, + SUM(CASE WHEN NomeTipoLancamento = 'IRRF Pessoa Jurídica' THEN ValorPago ELSE 0 END) AS IRRF, + SUM(CASE WHEN NomeTipoLancamento = 'Aplicação Financeira' THEN ValorPago ELSE 0 END) AS Aplicação + FROM + [Conveniar].[dbo].[LisLancamentoConvenio] + WHERE + CodConvenio = ? + AND CodStatus = 27 + AND CodRubrica = 3 + AND DataPagamento BETWEEN ? AND ? + GROUP BY + NomeTipoLancamento; + """ + + + Soma = pd.read_sql(consultaRendimentoAplicacao, engine, params=parametros) + + return Soma + +def consultaDevolucaoRecursosConciliacao(IDPROJETO,DATA1,DATA2): + """Consulta pra informar o total de devolução de recurso dos projetos + """ + file_path = pegar_pass("passs.txt") + conStr = '' + with open(file_path, 'r') as file: + conStr = file.readline().strip() + + connection_url = URL.create("mssql+pyodbc", query={"odbc_connect": conStr}) + engine = create_engine(connection_url) + parametros = [(IDPROJETO, DATA1, DATA2)] + + consultaComPeriodo = f"SELECT SUM(ValorPago) AS TotalPago FROM [Conveniar].[dbo].[LisLancamentoConvenio] WHERE CodConvenio = ? AND CodStatus = 27 AND CodRubrica = 0 AND DataPagamento BETWEEN ? AND ?" + + + Soma = pd.read_sql(consultaComPeriodo, engine, params=parametros) + + return Soma + +def consultaRendimentosAplicacao(IDPROJETO,DATA1,DATA2): + """Imprime as colunas de imposto e rendimento bruto. + + Args: + + IDPROJETO: numero do projeto + + DATA1: Data inicio prestação de contas + + DATA2: Data fim prestação de contas + + + Returns: + + Retorna tres dataframes, um contem o imposto o outro contem o rendimento bruto + """ + + file_path = pegar_pass("passs.txt") + conStr = '' + with open(file_path, 'r') as file: + conStr = file.readline().strip() + + connection_url = URL.create("mssql+pyodbc", query={"odbc_connect": conStr}) + engine = create_engine(connection_url) + parametros = [(IDPROJETO, DATA1, DATA2)] + consultaRendimentoAplicacao = f"SELECT DataPagamento,ValorPago FROM [Conveniar].[dbo].[LisLancamentoConvenio] WHERE CodConvenio = ? AND CodStatus = 27 AND CodRubrica = 3 and NomeTipoLancamento = 'Aplicação Financeira' AND DataPagamento BETWEEN ? AND ? order by DataPagamento" + dfConsultaRendimentoAplicacao = pd.read_sql(consultaRendimentoAplicacao, engine, params=parametros) + + consultaRendimentoEImposto = f"SELECT DataPagamento,ValorPago,NomeTipoLancamento FROM [Conveniar].[dbo].[LisLancamentoConvenio] WHERE CodConvenio = ? AND CodStatus = 27 AND CodRubrica = 3 and (NomeTipoLancamento = 'Aplicação Financeira' or NomeTipoLancamento = 'IRRF Pessoa Jurídica') AND DataPagamento BETWEEN ? AND ? order by DataPagamento" + dfConsultaRendimentoEImposto = pd.read_sql(consultaRendimentoEImposto, engine, params=parametros) + + consultaImposto = f"SELECT DataPagamento,ValorPago FROM [Conveniar].[dbo].[LisLancamentoConvenio] WHERE CodConvenio = ? AND CodStatus = 27 AND CodRubrica = 3 and NomeTipoLancamento = 'IRRF Pessoa Jurídica' AND DataPagamento BETWEEN ? AND ? order by DataPagamento" + dfConsultaImposto = pd.read_sql(consultaImposto, engine, params=parametros) + + + return dfConsultaRendimentoAplicacao,dfConsultaImposto,dfConsultaRendimentoEImposto + +def consultaConciliacao(IDPROJETO,DATA1,DATA2): + """ Informa o nome do convenio,Processo,SubProcesso e Valor Aprovado do projeto + + + + """ + file_path = pegar_pass("passs.txt") + conStr = '' + with open(file_path, 'r') as file: + conStr = file.readline().strip() + + connection_url = URL.create("mssql+pyodbc", query={"odbc_connect": conStr}) + engine = create_engine(connection_url) + parametros = [(IDPROJETO,)] + queryNomeConvenioProcessoSubProcesso = f""" + SELECT [LisConvenio].NomeConvenio , + [LisConvenio].Processo, + SubProcesso, + ValorAprovado,NomePessoaResponsavel + FROM [Conveniar].[dbo].[LisConvenio] WHERE CodConvenio = ? """ + dfConvenioProcessoSubProcessos = pd.read_sql(queryNomeConvenioProcessoSubProcesso, engine, params=parametros) + + return dfConvenioProcessoSubProcessos + + +#preencher + +def anexoUm(tabela,codigo,data1,data2): + dfAnexoUm = consultaAnexoUm(codigo) + dfAnexoRendimento = consultaRendimentosIRRFConciliacao(codigo,data1,data2) + pd.set_option('display.max_colwidth', None) + caminho = pegar_caminho(tabela) + workbook = openpyxl.load_workbook(caminho) + sheet = workbook['ANEXO I'] + # Soma = dfSoma["Aplicação"] + dfSoma["IRRF"] + stringNome = dfAnexoUm['NomeConvenio'] + stringValorAprovado = dfAnexoUm['ValorAprovado'] + stringProcesso = dfAnexoUm['Processo'] + stringSubProcesso = dfAnexoUm['SubProcesso'] + stringCoordenador = dfAnexoUm['NomePessoaResponsavel'] + stringRendApli= dfAnexoRendimento.loc[dfAnexoRendimento['NomeTipoLancamento'] == 'Aplicação Financeira', 'Aplicação'].values[0] + sheet['A20'] = stringNome.to_string(index=False) + sheet['A20'].font = Font(name="Arial", size=12, color="000000",bold=True) + sheet['A20'].alignment = Alignment(horizontal="left",vertical="center",wrap_text=True) + sheet['A22'] = f'Valor Global R$:{stringValorAprovado.to_string(index=False)}' + sheet['A22'].font = Font(name="Arial", size=12, color="000000",bold=True) + sheet['A22'].alignment = Alignment(horizontal="left",vertical="center",wrap_text=True) + sheet['E7'] = f'{stringSubProcesso.to_string(index=False)} / {stringProcesso.to_string(index=False)}' + sheet['E7'].font = Font(name="Arial", size=12, color="000000",bold=True) + sheet['E7'].alignment = Alignment(horizontal="left",vertical="center",wrap_text=True) + sheet['C29'] = stringRendApli + sheet['C29'].font = Font(name="Arial", size=12, color="000000",bold=True) + sheet['C29'].alignment = Alignment(horizontal="right",vertical="center",wrap_text=True) + sheet['D46'] = stringCoordenador.to_string(index=False) + sheet['D46'].font = Font(name="Arial", size=12, color="000000") + sheet['D46'].alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + + + + + 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 + + + #periodo prestação de contas + stringPeriodoAbrangido = f'Período da Prestação de Contas: {output_date_str} a {output_date_str2}' + sheet['C22'] = stringPeriodoAbrangido + sheet['C22'].font = Font(name="Arial", size=12, color="000000",bold=True) + sheet['C22'].alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + + + 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" +} + + stringTamanhoBrasilia = f'A{40}' # retorna lugar de brasilia + hoje = date.today() + data_formatada = f"{hoje.day} de {meses_dict[hoje.month]} de {hoje.year}" + sheet[stringTamanhoBrasilia] = f'Brasilia, {data_formatada}' + sheet[stringTamanhoBrasilia].font = Font(name="Arial", size=12, color="000000",bold=True) + sheet[stringTamanhoBrasilia].alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + + + + + + + + workbook.save(tabela) + workbook.close() + +def anexoDois(tabela,codigo,data1,data2): + consultaAnexoDois(codigo,data1,data2) + df= consultaCabecarioAnexoDois(codigo,data1,data2) + + tabela = pegar_caminho(tabela) + workbook = openpyxl.load_workbook(tabela) + sheet2 = workbook.create_sheet(title="ANEXO II") + workbook.save(tabela) + workbook.close() + + + #carregar a tabela + + tamanho = consultaAnexoDois(codigo,data1,data2) + tamanho = len(tamanho) + + brasiliaRow = estiloAnexoDois(tabela,tamanho) + caminho = pegar_caminho(tabela) + workbook = openpyxl.load_workbook(caminho) + sheet = workbook['ANEXO II'] + 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 + + + + + consulta_coordenador = consultaID(codigo) + stringCoordenador= f'E{brasiliaRow+2}' # retorna lugar do coordanor + stringCoordanadorCargo = f'E{brasiliaRow+3}' + sheet[stringCoordanadorCargo] = f"Coordenador(a)" + stringTamanhoCPF = f'E{brasiliaRow+4}' # retorna lugar do coordanor + sheet[stringCoordenador] = consulta_coordenador['NomePessoaResponsavel'] + sheet[stringTamanhoCPF] = formatar_cpf(consulta_coordenador['CPFCoordenador']) + string_titulo = f"Título do Projeto: {consulta_coordenador['NomeConvenio']}" + string_executora = f"Instituição Executora: {consulta_coordenador['NomePessoa']}" + + #string toa + stringTOA = f"{consulta_coordenador['SubProcesso']} / {consulta_coordenador['Processo']}" + + # Convert 'DataAssinatura' to "dd/mm/YYYY" format + datetime_obj1 = consulta_coordenador['DataAssinatura'] + + if datetime_obj1 is not None: + formatted_date1 = datetime_obj1.strftime("%d/%m/%Y") + + # Convert 'DataVigencia' to "dd/mm/YYYY" format + datetime_obj2 = consulta_coordenador['DataVigencia'] + + if datetime_obj2 is not None: + formatted_date2 = datetime_obj2.strftime("%d/%m/%Y") +# # Convert 'DataAssinatura' to "dd/mm/YYYY" format +# datetime_obj1 = consulta_coordenador['DataAssinatura'] + +# if datetime_obj1 is not None: +# formatted_date1 = datetime_obj1.strftime("%d/%m/%Y") + +# # Convert 'DataVigencia' to "dd/mm/YYYY" format +# datetime_obj2 = consulta_coordenador['DataVigencia'] + +# if datetime_obj2 is not None: +# formatted_date2 = datetime_obj2.strftime("%d/%m/%Y") + +# Create the string representing the period of execution + + sheet['A6'] = string_titulo + sheet['A8'] = string_executora + sheet['I3'] = stringTOA + + #dadosquefaltam = getAnalistaDoProjetoECpfCoordenador(codigo) + #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" +} + + stringTamanhoBrasilia = f'A{brasiliaRow}' # retorna lugar de brasilia + hoje = date.today() + data_formatada = f"{hoje.day} de {meses_dict[hoje.month]} de {hoje.year}" + sheet[stringTamanhoBrasilia] = f'Brasilia, {data_formatada}' + + dfAnexoDois = consultaAnexoDois(codigo,data1,data2) + + dfAnexoDois.insert(6, "col1", 1) + + + + #print(dfAnexoDois) + for row_num, row_data in enumerate(dfAnexoDois.itertuples(), start=11): #inicio linha + for col_num, value in enumerate(row_data, start=1): #inicio coluna + value = convert_datetime_to_stringdt(value) # Assuming you have a function to convert datetime to string + if row_data.NomeRubrica in ['Material Permanente e Equipamento Nacional', 'Material Permanente e Equipamento Importado', 'Equipamentos e Material Permanente', 'Obras e Instalações']: + if col_num == 10: + col_num = 11 # If the condition is met, set col_num to 11 + sheet.cell(row=row_num, column=col_num, value=value) + else : + sheet.cell(row=row_num, column=col_num, value=value) + elif row_data.NomeRubrica in ['Bolsa de Estágio', 'Bolsa de Estímulo a Inovação', 'Bolsa de Estudo', 'Bolsa de Extensão', 'Bolsa de Iniciação Científica', 'Bolsa de Pesquisa', 'Bolsas']: + if col_num == 10: + col_num = 12 # If the condition is met, set col_num to 11 + sheet.cell(row=row_num, column=col_num, value=value) + else: + sheet.cell(row=row_num, column=col_num, value=value) + else : + sheet.cell(row=row_num, column=col_num, value=value) + + + + + + workbook.save(tabela) + workbook.close() + + + return brasiliaRow + +def anexoTres(tabela,codigo,data1,data2,rowBrasilia): + tabela = pegar_caminho(tabela) + workbook = openpyxl.load_workbook(tabela) + sheet2 = workbook.create_sheet(title="ANEXO III") + workbook.save(tabela) + workbook.close() + + dfAnexoTres = consultaAnexoTres(codigo,data1,data2) + tamanho = len(dfAnexoTres) + estiloAnexoTres(tabela,tamanho,rowBrasilia) + caminho = pegar_caminho(tabela) + workbook = openpyxl.load_workbook(caminho) + sheet = workbook['ANEXO III'] + + + + + dfAnexoTres.insert(0, "col1",None) + dfAnexoTres.insert(3, "col2",None) + dfAnexoTres.insert(5, "col3",1) + + + + + + for row_num, row_data in enumerate(dfAnexoTres.itertuples(), start=11): #inicio linha + for col_num, value in enumerate(row_data, start=1): #inicio coluna + value = convert_datetime_to_stringdt(value) + value = re.sub("[^a-zA-ZÀ-ÿ0-9º+-//]", " ", str(value)) + sheet.cell(row=row_num, column=col_num, value=value) + + + + workbook.save(tabela) + workbook.close() + +def anexoQuatro(tabela,codigo,data1,data2,rowBrasilia): + + tabela = pegar_caminho(tabela) + workbook = openpyxl.load_workbook(tabela) + sheet2 = workbook.create_sheet(title="ANEXO IV") + workbook.save(tabela) + workbook.close() + + dfConsultaRendimentoAplicacao,dfConsultaImposto,dfImpostoERendimento = consultaRendimentosAplicacao(codigo,data1,data2) + merged_df = pd.merge(dfConsultaRendimentoAplicacao, dfConsultaImposto, on='DataPagamento') + tamanho = 0 + # tamanhoMaior = lambda tamanho: len(dfConsultaRendimentoAplicacao) if len(dfConsultaRendimentoAplicacao) > len(dfConsultaImposto) else len(dfConsultaImposto) + # tamanhoMaiorParaOEstilo = tamanhoMaior(None) + + tamanhoMaiorParaOEstilo = len(merged_df) + # tem q somra oito algum erro do estilo + tamanhoMaiorParaOEstilo = tamanhoMaiorParaOEstilo + 8 + estiloAnexoQuatro(tabela,tamanhoMaiorParaOEstilo,rowBrasilia) + + workbook = openpyxl.load_workbook(tabela) + sheet = workbook['ANEXO IV'] + + merged_df['data_formatada'] = merged_df['DataPagamento'].apply(formatarDataSemDia) + merged_df['DataPagamento'] = merged_df['data_formatada'] + merged_df = merged_df.drop('data_formatada', axis=1) + + + for row_num, row_data in enumerate(merged_df.itertuples(index=False), start=18):#inicio linha + for col_num, value in enumerate(row_data, start=1):#inicio coluna + + if col_num == 2: + col_num = 6 + if col_num == 3: + col_num = 5 + sheet.cell(row=row_num, column=col_num, value=value) + + + #datas + + 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 + + + + stringPeriodoAbrangido = f'{output_date_str} a {output_date_str2}' + + sheet['F12'] = stringPeriodoAbrangido + sheet['F12'].font = Font(name="Arial", size=12, color="000000",bold=True) + sheet['F12'].alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + + sheet.merge_cells('F12:G12') + + + + + + + + workbook.save(tabela) + workbook.close() + +def Conciliacao(tabela,codigo,data1,data2): + + caminho = pegar_caminho(tabela) + workbook = openpyxl.load_workbook(caminho) + sheet = workbook['Conciliação '] + dfRendimentoConciliacao = consultaRendimentosIRRFConciliacao(codigo,data1,data2) + dfConciliacao = consultaConciliacao(codigo,data1,data2) + dfDevolucao = consultaDevolucaoRecursosConciliacao(codigo,data1,data2) + stringProcesso = dfConciliacao['Processo'] + stringValorAprovado = dfConciliacao['ValorAprovado'] + stringSubProcesso = dfConciliacao['SubProcesso'] + stringCoordenador = dfConciliacao['NomePessoaResponsavel'] + stringDevolucaoTotal = dfDevolucao['TotalPago'] + stringRendApli= dfRendimentoConciliacao.loc[dfRendimentoConciliacao['NomeTipoLancamento'] == 'Aplicação Financeira', 'Aplicação'].values[0] + + + cell_is_null = dfDevolucao.isnull().iloc[0, 0] + + + + + #toa + sheet['D5'] = f'{stringSubProcesso.to_string(index=False)} / {stringProcesso.to_string(index=False)}' + sheet['D5'].font = Font(name="Arial", size=12, color="000000",bold=True) + sheet['D5'].alignment = Alignment(horizontal="left",vertical="center",wrap_text=True) + + + #valorparovado + if not stringValorAprovado.empty: + sheet['B15'] = int(stringValorAprovado.iloc[0]) + + else: + sheet['B15'] = 0 + + sheet['B15'].font = Font(name="Arial", size=12, color="000000",bold=True) + sheet['B15'].alignment = Alignment(horizontal="right",vertical="center",wrap_text=True) + #rendimento + sheet['B21'] = stringRendApli + sheet['B21'].font = Font(name="Arial", size=12, color="000000",bold=True) + sheet['B21'].alignment = Alignment(horizontal="right",vertical="center",wrap_text=True) + sheet['B21'].number_format = 'R$ #,##0.00' + #devolução + if not cell_is_null: + sheet['D19'] = int(stringDevolucaoTotal.iloc[0]) + + else: + sheet['D19'] = 0 + + sheet['D19'].font = Font(name="Arial", size=12, color="000000",bold=True) + sheet['D19'].alignment = Alignment(horizontal="right",vertical="center",wrap_text=True) + sheet['D19'].number_format = 'R$ #,##0.00' + #COORDENADOR + sheet['C48'] = stringCoordenador.to_string(index=False) + sheet['C48'].font = Font(name="Arial", size=12, color="000000") + sheet['C48'].alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + sheet['C48'].number_format = 'R$ #,##0.00' + + + for row in sheet.iter_rows(min_row=12, max_row=24, min_col=1, max_col=4): + for cell in row: + cell.number_format = 'R$ #,##0.00' + + workbook.save(tabela) + workbook.close() + +def preencheFap(codigo,data1,data2,tabela): + '''Preenche a planilha fap + + Argumentos: + codigo = CodConvenio na tabela nova, corresponde ao codigo do projeto + DATA1 = Data Inicial Selecinado pelo Usuario + DATA2 = Data Final Selecionado pelo Usuario + tabela = tabela a ser preenchida extensão xlsx + + + ''' + planilhaGeral(tabela,codigo,data1,data2) + rowBrasilia = anexoDois(tabela,codigo,data1,data2) + anexoUm(tabela,codigo,data1,data2) + anexoTres(tabela,codigo,data1,data2,rowBrasilia) + anexoQuatro(tabela,codigo,data1,data2,rowBrasilia) + Conciliacao(tabela,codigo,data1,data2) + + + + diff --git a/project/app/preencheFub.py b/project/app/preencheFub.py new file mode 100644 index 00000000..48b5c2c5 --- /dev/null +++ b/project/app/preencheFub.py @@ -0,0 +1,1836 @@ +import pyodbc +from datetime import datetime,date +import openpyxl +from openpyxl.styles import Font +import os +from .estilo_fub import * +from collections import defaultdict +import pandas as pd +from sqlalchemy import create_engine +from sqlalchemy.engine import URL +import numpy as np +import re +from openpyxl.worksheet.hyperlink import Hyperlink +from .recibosAutomatizados import acharRecibo + +def split_archive_name(archive_name): + # Using regular expressions to match the pattern + pattern = r'(\w+)_(\d{4}-\d{2}-\d{2})_(\d{4}-\d{2}-\d{2})' + match = re.match(pattern, archive_name) + + if match: + name = match.group(1) + date1 = match.group(2) + date2 = match.group(3) + return name, date1, date2 + else: + return None + +def convert_datetime_to_string(value): + if isinstance(value, datetime): + return value.strftime('%d/%m/%Y') + return value + +def convert_datetime_to_stringdt(dt): + # Check if the value is a pandas Timestamp + if isinstance(dt, pd.Timestamp): + # Convert the Timestamp to a string using strftime + return dt.strftime('%d/%m/%Y') # You can customize the format as needed + else: + # If it's not a Timestamp, return the original value + return dt + +def formatar_data(row): + """ Formata a data com o mes abreviado transformando 01 em jan por exemplo + """ + dia = row.day + mes = row.month + ano = row.year + + # Mapear o número do mês para o nome abreviado + meses = {1: 'jan', 2: 'fev', 3: 'mar', 4: 'abr', 5: 'mai', 6: 'jun', 7: 'jul', 8: 'ago', 9: 'set', 10: 'out', 11: 'nov', 12: 'dez'} + + # Obter o nome abreviado do mês + mes_abreviado = meses.get(mes, mes) + + # Criar a string formatada + data_formatada = f'{dia}-{mes_abreviado}-{ano}' + + return data_formatada + +def formatarDataSemDia(row): + """ Formata a data com o mes abreviado transformando 01 em jan por exemplo + """ + dia = row.day + mes = row.month + ano = row.year + + # Mapear o número do mês para o nome abreviado + meses = {1: 'jan', 2: 'fev', 3: 'mar', 4: 'abr', 5: 'mai', 6: 'jun', 7: 'jul', 8: 'ago', 9: 'set', 10: 'out', 11: 'nov', 12: 'dez'} + + # Obter o nome abreviado do mês + mes_abreviado = meses.get(mes, mes) + + # Criar a string formatada + data_formatada = f'{mes_abreviado}-{ano}' + + return data_formatada + +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(subdiretorio): + # Obtém o caminho do script atual + arq_atual = os.path.abspath(__file__) + + # Obtém o diretório do script + app = os.path.dirname(arq_atual) + + # Obtém o diretório pai do script + project = os.path.dirname(app) + + # Obtém o diretório pai do projeto + pipeline = os.path.dirname(project) + + # Junta o diretório pai do projeto com o subdiretório desejado + caminho_pipeline = os.path.join(pipeline, subdiretorio) + + return caminho_pipeline + +def pegar_pass(chave): + arq_atual = os.path.abspath(__file__) + app = os.path.dirname(arq_atual) + project = os.path.dirname(app) + pipeline = os.path.dirname(project) + desktop = os.path.dirname(pipeline) + caminho_pipeline = os.path.join(desktop, chave) + + return caminho_pipeline + + + # return records + + +#todas as consultas em sql +def consultaNotasFub(filename): + ''' + Merges and displays all items related to a specific NumPedido + ''' + + + file_path = pegar_pass("passs.txt") + conStr = '' + with open(file_path, 'r') as file: + conStr = file.readline().strip() + conn = pyodbc.connect(conStr) + cursor = conn.cursor() + + # queryConsult = f""" + # SELECT [Pedido].[CodPedido], + # [Pedido].[NumPedido], + # [ArquivoBinario].[ArquivoBinario], + # [Arquivo].* + # FROM [Conveniar].[dbo].[Pedido] + # LEFT JOIN [Conveniar].[dbo].[Arquivo] + # ON [Pedido].[CodPedido] = [Arquivo].[CodSolicitacao] + # LEFT JOIN [ConveniarArquivo].[dbo].[ArquivoReferencia] + # ON [Arquivo].[CodArquivoReferencia] = [ArquivoReferencia].CodArquivoReferencia + # LEFT JOIN [ConveniarArquivo].[dbo].[ArquivoBinario] + # ON [ArquivoReferencia].ChaveLocalArmazenamento = [ArquivoBinario].[CodArquivoBinario] + # WHERE NumPedido = '{filename}' + # """ + queryConsult = f""" + SELECT [Pedido].[CodPedido], + [Pedido].[NumPedido], + [ArquivoBinario].[ArquivoBinario], + [Arquivo].[NomeArquivo] + FROM [Conveniar].[dbo].[Pedido] + LEFT JOIN [Conveniar].[dbo].[Arquivo] + ON [Pedido].[CodPedido] = [Arquivo].[CodSolicitacao] + LEFT JOIN [ConveniarArquivo].[dbo].[ArquivoReferencia] + ON [Arquivo].[CodArquivoReferencia] = [ArquivoReferencia].CodArquivoReferencia + LEFT JOIN [ConveniarArquivo].[dbo].[ArquivoBinario] + ON [ArquivoReferencia].ChaveLocalArmazenamento = [ArquivoBinario].[CodArquivoBinario] + WHERE NumPedido = '{filename}' + +UNION ALL + +SELECT [OPCompraAF].[CodOPCompraAF], + [OPCompraAF].[NumOPCompraAF], + [ArquivoBinario].[ArquivoBinario], + [ArquivoOpCompraAF].[NomeArquivoOpCompraAF] + FROM [Conveniar].[dbo].[OPCompraAF] + LEFT JOIN [Conveniar].[dbo].[ArquivoOpCompraAF] + ON [OPCompraAF].[CodOPCompraAF] = [ArquivoOpCompraAF].[CodOPCompraAF] + LEFT JOIN [ConveniarArquivo].[dbo].[ArquivoReferencia] + ON [ArquivoOpCompraAF].[CodArquivoReferencia] = [ArquivoReferencia].CodArquivoReferencia + LEFT JOIN [ConveniarArquivo].[dbo].[ArquivoBinario] + ON [ArquivoReferencia].ChaveLocalArmazenamento = [ArquivoBinario].[CodArquivoBinario] + WHERE [OPCompraAF].[NumOPCompraAF] = '{filename}' + + + """ + + cursor.execute(queryConsult) + if cursor.rowcount == 0: + print("Query returned no results.") + + else: + items = cursor.fetchall() + + return items + + + +def consultaRendimentosTodosAteOPeriodo(IDPROJETO,DATA2): + file_path = pegar_pass("passs.txt") + conStr = '' + with open(file_path, 'r') as file: + conStr = file.readline().strip() + + connection_url = URL.create("mssql+pyodbc", query={"odbc_connect": conStr}) + engine = create_engine(connection_url) + parametros = [(IDPROJETO, DATA2)] + + consultaRendimentoAplicacao = f""" + SELECT + NomeTipoLancamento, + SUM(CASE WHEN NomeTipoLancamento = 'IRRF Pessoa Jurídica' THEN ValorPago ELSE 0 END) AS IRRF, + SUM(CASE WHEN NomeTipoLancamento = 'Aplicação Financeira' THEN ValorPago ELSE 0 END) AS Aplicação + FROM + [Conveniar].[dbo].[LisLancamentoConvenio] + WHERE + CodConvenio = ? + AND CodStatus = 27 + AND CodRubrica = 3 + AND DataPagamento <= ? + GROUP BY + NomeTipoLancamento; + """ + + + Soma = pd.read_sql(consultaRendimentoAplicacao, engine, params=parametros) + + + return Soma + +def consultaRendimentosIRRF(IDPROJETO,DATA1,DATA2): + file_path = pegar_pass("passs.txt") + conStr = '' + with open(file_path, 'r') as file: + conStr = file.readline().strip() + + connection_url = URL.create("mssql+pyodbc", query={"odbc_connect": conStr}) + engine = create_engine(connection_url) + parametros = [(IDPROJETO, DATA1, DATA2)] + + consultaComPeriodo =f"SELECT SUM(ValorPago) AS TotalPago FROM [Conveniar].[dbo].[LisLancamentoConvenio] WHERE CodConvenio = ? AND CodStatus = 27 AND CodRubrica = 0 AND DataPagamento BETWEEN ? AND ?" + + consultaRendimentoAplicacao = f""" + SELECT + NomeTipoLancamento, + SUM(CASE WHEN NomeTipoLancamento = 'IRRF Pessoa Jurídica' THEN ValorPago ELSE 0 END) AS IRRF, + SUM(CASE WHEN NomeTipoLancamento = 'Aplicação Financeira' THEN ValorPago ELSE 0 END) AS Aplicação + FROM + [Conveniar].[dbo].[LisLancamentoConvenio] + WHERE + CodConvenio = ? + AND CodStatus = 27 + AND CodRubrica = 3 + AND DataPagamento BETWEEN ? AND ? + GROUP BY + NomeTipoLancamento; + """ + + + Soma = pd.read_sql(consultaRendimentoAplicacao, engine, params=parametros) + + return Soma + +def consultaDevolucaoRecursos(IDPROJETO,DATA1,DATA2): + file_path = pegar_pass("passs.txt") + conStr = '' + with open(file_path, 'r') as file: + conStr = file.readline().strip() + + connection_url = URL.create("mssql+pyodbc", query={"odbc_connect": conStr}) + engine = create_engine(connection_url) + parametros = [(IDPROJETO, DATA1, DATA2)] + + consultaComPeriodo = f"SELECT SUM(ValorPago) AS TotalPago FROM [Conveniar].[dbo].[LisLancamentoConvenio] WHERE CodConvenio = ? AND CodStatus = 27 AND CodRubrica = 0 AND DataPagamento BETWEEN ? AND ?" + + + Soma = pd.read_sql(consultaComPeriodo, engine, params=parametros) + + return Soma + +def consultaRendimentosAplicacao(IDPROJETO,DATA1,DATA2): + file_path = pegar_pass("passs.txt") + conStr = '' + with open(file_path, 'r') as file: + conStr = file.readline().strip() + + connection_url = URL.create("mssql+pyodbc", query={"odbc_connect": conStr}) + engine = create_engine(connection_url) + parametros = [(IDPROJETO, DATA1, DATA2)] + consultaRendimentoAplicacao = f"SELECT DataPagamento,ValorPago FROM [Conveniar].[dbo].[LisLancamentoConvenio] WHERE CodConvenio = ? AND CodStatus = 27 AND CodRubrica = 3 and NomeTipoLancamento = 'Aplicação Financeira' AND DataPagamento BETWEEN ? AND ? order by DataPagamento" + dfConsultaRendimentoAplicacao = pd.read_sql(consultaRendimentoAplicacao, engine, params=parametros) + + consultaRendimentoEImposto = f"SELECT DataPagamento,ValorPago,NomeTipoLancamento FROM [Conveniar].[dbo].[LisLancamentoConvenio] WHERE CodConvenio = ? AND CodStatus = 27 AND CodRubrica = 3 and (NomeTipoLancamento = 'Aplicação Financeira' or NomeTipoLancamento = 'IRRF Pessoa Jurídica') AND DataPagamento BETWEEN ? AND ? order by DataPagamento" + dfConsultaRendimentoEImposto = pd.read_sql(consultaRendimentoEImposto, engine, params=parametros) + + consultaImposto = f"SELECT DataPagamento,ValorPago FROM [Conveniar].[dbo].[LisLancamentoConvenio] WHERE CodConvenio = ? AND CodStatus = 27 AND CodRubrica = 3 and NomeTipoLancamento = 'IRRF Pessoa Jurídica' AND DataPagamento BETWEEN ? AND ? order by DataPagamento" + dfConsultaImposto = pd.read_sql(consultaImposto, engine, params=parametros) + + + return dfConsultaRendimentoAplicacao,dfConsultaImposto,dfConsultaRendimentoEImposto + +def consultaConciliacaoBancaria(IDPROJETO, DATA1, DATA2): + ''' Função que vai pega os dados da Rubrica 9 Despesas Financeiras e transformalos em dataframe + para poder popular a databela Despesas Financeiras + Argumentos + IDPROJETO = CodConvenio na tabela nova, corresponde ao codigo do projeto + DATA1 = Data Inicial Selecinado pelo Usuario + DATA2 = Data Final Selecionado pelo Usuario + ''' + file_path = pegar_pass("passs.txt") + conStr = '' + with open(file_path, 'r') as file: + conStr = file.readline().strip() + + connection_url = URL.create("mssql+pyodbc", query={"odbc_connect": conStr}) + engine = create_engine(connection_url) + parametros = [(IDPROJETO, DATA1, DATA2)] + parametros2 = [(IDPROJETO, DATA1, DATA2, IDPROJETO, DATA1, DATA2)] + #consultaSemEstorno = f"SELECT DISTINCT DataPagamento,ValorPago,NumChequeDeposito,HisLancamento FROM [Conveniar].[dbo].[LisLancamentoConvenio] WHERE CodConvenio = ? AND CodStatus = 27 AND CodRubrica = 9 AND DataPagamento BETWEEN ? AND ? AND LOWER(HisLancamento) NOT LIKE '%estorno%' order by DataPagamento" + #consultaComEstorno = f"SELECT DISTINCT DataPagamento,ValorPago,NumChequeDeposito,HisLancamento FROM [Conveniar].[dbo].[LisLancamentoConvenio] WHERE CodConvenio = ? AND CodStatus = 27 AND CodRubrica = 9 AND DataPagamento BETWEEN ? AND ? AND LOWER(HisLancamento) LIKE '%estorno%' order by DataPagamento" + + consultaSemEstorno = f""" + SELECT [LisLancamentoConvenio].DataPagamento, + [LisPagamentoDespesaConvenioAdministrativa].Valor , + [LisLancamentoConvenio].NumChequeDeposito,[LisLancamentoConvenio].HisLancamento + FROM [Conveniar].[dbo].[LisLancamentoConvenio] + INNER JOIN [Conveniar].[dbo].[LisDocumentoConvenio] ON [LisLancamentoConvenio].[CodDocFinConvenio] = [LisDocumentoConvenio].[CodDocFinConvenio] + INNER JOIN [Conveniar].[dbo].[DocFinConvPagDespesa] ON [LisDocumentoConvenio].[CodDocFinConvenio] = [DocFinConvPagDespesa].[CodDocFinConvenio] + INNER JOIN [Conveniar].[dbo].[LisPagamentoDespesaConvenio] ON [DocFinConvPagDespesa].[CodPedido] = [LisPagamentoDespesaConvenio].[CodPedido] + INNER JOIN [Conveniar].[dbo].[LisPagamentoDespesaConvenioAdministrativa] ON [LisPagamentoDespesaConvenio].CodDespesaConvenio = [LisPagamentoDespesaConvenioAdministrativa].CodDespesaConvenio + AND [LisPagamentoDespesaConvenio].CodConvenio = [LisPagamentoDespesaConvenioAdministrativa].CodConvenio + WHERE [LisLancamentoConvenio].CodConvenio = ? AND [LisLancamentoConvenio].CodStatus = 27 AND [LisLancamentoConvenio].CodRubrica = 9 AND [LisLancamentoConvenio].DataPagamento BETWEEN ? AND ? + AND LOWER([LisLancamentoConvenio].HisLancamento) NOT LIKE '%estorno%' order by [LisLancamentoConvenio].DataPagamento""" + + consultaComEstorno = f"""SELECT DataPagamento, + ValorPago, + NumChequeDeposito, + HisLancamento + FROM [Conveniar].[dbo].[LisLancamentoConvenio] + WHERE CodConvenio = ? + AND CodStatus = 27 + AND CodRubrica = 9 + AND DataPagamento BETWEEN ? AND ? + AND LOWER(HisLancamento) LIKE '%estorno%' + OR + CodConvenio = ? + AND CodStatus = 27 + AND CodRubrica = 9 + AND NomeTipoCreditoDebito = 'C' + AND DataPagamento BETWEEN ? AND ? + order by DataPagamento""" + + dfSemEstorno = pd.read_sql(consultaSemEstorno, engine, params=parametros) + dfComEstorno = pd.read_sql(consultaComEstorno, engine, params=parametros2) + + + return dfSemEstorno,dfComEstorno + +def consultaConciliaoBancarioSaldoTotal(IDPROJETO,DATA1,DATA2): + file_path = pegar_pass("passs.txt") + conStr = '' + with open(file_path, 'r') as file: + conStr = file.readline().strip() + + connection_url = URL.create("mssql+pyodbc", query={"odbc_connect": conStr}) + engine = create_engine(connection_url) + parametrosconsultaSumTotal = [(IDPROJETO, DATA1)] + parametrosConsultaTotalRestituicao = [(IDPROJETO, DATA1,IDPROJETO, DATA1)] + parametrossumPeriodosemEstorno = [(IDPROJETO, DATA1, DATA2, IDPROJETO, DATA1, DATA2)] + parametrossumPeriodoComEstorno = [(IDPROJETO, DATA1, DATA2, IDPROJETO, DATA1, DATA2)] + + SumTotal= f"""SELECT SUM(ValorPago) AS TotalPago + FROM [Conveniar].[dbo].[LisLancamentoConvenio] + WHERE CodConvenio = ? + AND CodStatus = 27 + AND CodRubrica = 9 + AND DataPagamento <= ? + AND LOWER(HisLancamento) NOT LIKE '%estorno%' + """ + + SumTotalRestituicao = f"""SELECT SUM(ValorPago) AS TotalPago + FROM [Conveniar].[dbo].[LisLancamentoConvenio] + WHERE CodConvenio = ? + AND CodStatus = 27 + AND CodRubrica = 9 + AND DataPagamento <=? + AND LOWER(HisLancamento) LIKE '%estorno%' + OR + CodConvenio = ? + AND CodStatus = 27 + AND CodRubrica = 9 + AND NomeTipoCreditoDebito = 'C' + AND DataPagamento <= ? """ + + + sumPeriodoSemEstorno = f"""SELECT SUM(ValorPago) AS TotalPago + FROM [Conveniar].[dbo].[LisLancamentoConvenio] + WHERE CodConvenio = ? + AND CodStatus = 27 + AND CodRubrica = 9 + AND DataPagamento BETWEEN ? AND ? + AND LOWER(HisLancamento) NOT LIKE '%estorno%' + OR + CodConvenio = ? + AND CodStatus = 27 + AND CodRubrica = 9 + AND NomeTipoCreditoDebito = 'D' + AND DataPagamento BETWEEN ? AND ? """ + + sumPeriodoComEstorno = f"""SELECT SUM(ValorPago) AS TotalPago + FROM [Conveniar].[dbo].[LisLancamentoConvenio] + WHERE CodConvenio = ? + AND CodStatus = 27 + AND CodRubrica = 9 + AND DataPagamento BETWEEN ? AND ? + AND LOWER(HisLancamento) LIKE '%estorno%' + OR + CodConvenio = ? + AND CodStatus = 27 + AND CodRubrica = 9 + AND NomeTipoCreditoDebito = 'C' + AND DataPagamento BETWEEN ? AND ? """ + + + + consultaSaldoTotal= pd.read_sql(SumTotal, engine, params=parametrosconsultaSumTotal) + consultaSumTotalRestituicao= pd.read_sql(SumTotalRestituicao, engine, params=parametrosConsultaTotalRestituicao) + consultasumPeriodoSemEstorno= pd.read_sql(sumPeriodoSemEstorno, engine, params=parametrossumPeriodosemEstorno) + consultasumPeriodoComEstorno= pd.read_sql(sumPeriodoComEstorno, engine, params=parametrossumPeriodoComEstorno) + + return consultaSaldoTotal,consultaSumTotalRestituicao,consultasumPeriodoSemEstorno,consultasumPeriodoComEstorno + +def consultaID(IDPROJETO): + + #file_path = "/home/ubuntu/Desktop/devfront/devfull/pass.txt" + file_path = pegar_pass("passs.txt") + conStr = '' + with open(file_path, 'r') as file: + conStr = file.readline().strip() + + conn = None + + conn = pyodbc.connect(conStr) + cursor = conn.cursor() + + + consulta = {} + + + # SQL querys + + sql = f"SELECT [LisConvenio].* , [LisPessoa].[CPFCNPJ] as 'CPFCoordenador' FROM [Conveniar].[dbo].[LisConvenio] INNER JOIN [Conveniar].[dbo].[LisUsuario] ON [LisConvenio].[CodUsuarioResponsavel] = [LisUsuario].[CodUsuario] INNER JOIN [Conveniar].[dbo].[LisPessoa] ON [LisUsuario].[CodPessoa] = [LisPessoa].[CodPessoa] WHERE CodConvenio = ? " + + # Execute the query + cursor.execute(sql, IDPROJETO) + + + records = cursor.fetchall() + + collums = cursor.description + + + for i in range(len(collums)): + consulta[collums[i][0]] = records[0][i] + + cursor.close() + conn.close() + + + + # return records + return consulta + + + values = [d.get(key) for d in list_of_dicts for key in keys] + + + return values + +def consultaNomeRubricaCodRubrica(IDPROJETO, DATA1, DATA2,): + ''' Função que vai pega os dados da Rubrica 9 Despesas Financeiras e transformalos em dataframe + para poder popular a databela Despesas Financeiras + Argumentos + IDPROJETO = CodConvenio na tabela nova, corresponde ao codigo do projeto + DATA1 = Data Inicial Selecinado pelo Usuario + DATA2 = Data Final Selecionado pelo Usuario + ''' + file_path = pegar_pass("passs.txt") + conStr = '' + with open(file_path, 'r') as file: + conStr = file.readline().strip() + + connection_url = URL.create("mssql+pyodbc", query={"odbc_connect": conStr}) + engine = create_engine(connection_url) + parametros = [(IDPROJETO, DATA1, DATA2)] + queryNomeRubrica = f"SELECT CodRubrica,NomeRubrica FROM [Conveniar].[dbo].[LisLancamentoConvenio] WHERE CodConvenio = ? AND CodStatus = 27 AND DataPagamento BETWEEN ? AND ? GROUP BY NomeRubrica, CodRubrica" + dfNomeRubricaCodRubrica = pd.read_sql(queryNomeRubrica, engine, params=parametros) + + + return dfNomeRubricaCodRubrica + +def consultaProjeto(IDPROJETO, DATA1, DATA2,codigoRubrica): + ''' Consulta dinamica do SQL relacionado a rubrica correspondente,cada pagina tem sua própria consulta correspondente a rubrica + Argumentos + IDPROJETO = CodConvenio na tabela nova, corresponde ao codigo do projeto + DATA1 = Data Inicial Selecinado pelo Usuario + DATA2 = Data Final Selecionado pelo Usuario + codigoRubrica = código da rubrica + ''' + file_path = pegar_pass("passs.txt") + conStr = '' + with open(file_path, 'r') as file: + conStr = file.readline().strip() + + connection_url = URL.create("mssql+pyodbc", query={"odbc_connect": conStr}) + engine = create_engine(connection_url) + parametros = [(IDPROJETO, DATA1, DATA2,codigoRubrica)] + parametrosComRubricaEstorno = [(IDPROJETO, DATA1, DATA2,codigoRubrica,IDPROJETO,DATA1, DATA2,codigoRubrica,)] + parametrosPJ=[(IDPROJETO, DATA1, DATA2)] + parametrosPJestorno=[(IDPROJETO, DATA1, DATA2,IDPROJETO, DATA1, DATA2)] + queryConsultaComRubrica = f"""SELECT NomeFavorecido, + CASE WHEN LEN(FavorecidoCPFCNPJ) > 11 THEN STUFF(STUFF(STUFF(STUFF(FavorecidoCPFCNPJ, 3, 0, '.'), 7, 0, '.'), 11, 0, '/'), 16, 0, '-') + WHEN LEN(FavorecidoCPFCNPJ) = 11 THEN STUFF(STUFF(STUFF(FavorecidoCPFCNPJ, 4, 0, '.'), 8, 0, '.'), 12, 0, '-') ELSE FavorecidoCPFCNPJ END AS FormattedFavorecidoCPFCNPJ, + [LisConvenioItemAprovado].[DescConvenioItemAprovado], + HisLancamento, + NumDocPago, + DataEmissao, + NumChequeDeposito, + DataPagamento, + ValorPago + FROM [Conveniar].[dbo].[LisLancamentoConvenio] + LEFT JOIN [Conveniar].[dbo].[PlanoTrabalhoLancamento] ON [LisLancamentoConvenio].[CodLancamento] = [PlanoTrabalhoLancamento].[CodLancamentoGerado] + LEFT JOIN [Conveniar].[dbo].[LisConvenioItemAprovado] ON [PlanoTrabalhoLancamento].[CodConvenioItemAprovado] = [LisConvenioItemAprovado].[CodConvenioItemAprovado] + WHERE [LisLancamentoConvenio].CodConvenio = ? + AND [LisLancamentoConvenio].CodStatus = 27 + AND [LisLancamentoConvenio].DataPagamento BETWEEN ? AND ? + AND LOWER([LisLancamentoConvenio].HisLancamento) NOT LIKE '%estorno%' + and [LisLancamentoConvenio].CodRubrica = ? order by DataPagamento""" + + queryConsultaComRubricaEstorno = f"""SELECT NomeFavorecido + ,CASE WHEN LEN(FavorecidoCPFCNPJ) > 11 THEN STUFF(STUFF(STUFF(STUFF(FavorecidoCPFCNPJ, 3, 0, '.'), 7, 0, '.'), 11, 0, '/'), 16, 0, '-') + WHEN LEN(FavorecidoCPFCNPJ) = 11 THEN STUFF(STUFF(STUFF(FavorecidoCPFCNPJ, 4, 0, '.'), 8, 0, '.'), 12, 0, '-') ELSE FavorecidoCPFCNPJ END AS FormattedFavorecidoCPFCNPJ, + HisLancamento, + NumChequeDeposito, + DataPagamento, + ValorPago FROM [Conveniar].[dbo].[LisLancamentoConvenio] + LEFT JOIN [Conveniar].[dbo].[PlanoTrabalhoLancamento] ON [LisLancamentoConvenio].[CodLancamento] = [PlanoTrabalhoLancamento].[CodLancamentoGerado] + LEFT JOIN [Conveniar].[dbo].[LisConvenioItemAprovado] ON [PlanoTrabalhoLancamento].[CodConvenioItemAprovado] = [LisConvenioItemAprovado].[CodConvenioItemAprovado] + WHERE + [LisLancamentoConvenio].CodConvenio = ? + AND CodStatus = 27 + AND NomeTipoCreditoDebito = 'C' + AND DataPagamento BETWEEN ? AND ? + and [LisLancamentoConvenio].CodRubrica = ? + OR + CodStatus = 27 + AND [LisLancamentoConvenio].CodConvenio = ? + AND DataPagamento BETWEEN ? AND ? + AND LOWER(HisLancamento) LIKE '%estorno%' + AND [LisLancamentoConvenio].CodRubrica = ? + + order by DataPagamento """ + + queryConsultaPJDOA = f"""SELECT NomeFavorecido, + CASE WHEN LEN(FavorecidoCPFCNPJ) > 11 THEN STUFF(STUFF(STUFF(STUFF(FavorecidoCPFCNPJ, 3, 0, '.'), 7, 0, '.'), 11, 0, '/'), 16, 0, '-') + WHEN LEN(FavorecidoCPFCNPJ) = 11 THEN STUFF(STUFF(STUFF(FavorecidoCPFCNPJ, 4, 0, '.'), 8, 0, '.'), 12, 0, '-') ELSE FavorecidoCPFCNPJ END AS FormattedFavorecidoCPFCNPJ, + [LisConvenioItemAprovado].[DescConvenioItemAprovado], + HisLancamento, + NumDocPago, + DataEmissao, + NumChequeDeposito, + DataPagamento, + ValorPago + FROM [Conveniar].[dbo].[LisLancamentoConvenio] + LEFT JOIN [Conveniar].[dbo].[PlanoTrabalhoLancamento] ON [LisLancamentoConvenio].[CodLancamento] = [PlanoTrabalhoLancamento].[CodLancamentoGerado] + LEFT JOIN [Conveniar].[dbo].[LisConvenioItemAprovado] ON [PlanoTrabalhoLancamento].[CodConvenioItemAprovado] = [LisConvenioItemAprovado].[CodConvenioItemAprovado] + WHERE [LisLancamentoConvenio].CodConvenio = ? + AND CodStatus = 27 + AND DataPagamento BETWEEN ? AND ? + AND LOWER(HisLancamento) NOT LIKE '%estorno%' + AND [LisLancamentoConvenio].CodRubrica IN (57,75,26) + order by DataPagamento """ + + queryConsultaPJDOAEstorno = f""" + SELECT NomeFavorecido, + CASE WHEN LEN(FavorecidoCPFCNPJ) > 11 THEN STUFF(STUFF(STUFF(STUFF(FavorecidoCPFCNPJ, 3, 0, '.'), 7, 0, '.'), 11, 0, '/'), 16, 0, '-') + WHEN LEN(FavorecidoCPFCNPJ) = 11 THEN STUFF(STUFF(STUFF(FavorecidoCPFCNPJ, 4, 0, '.'), 8, 0, '.'), 12, 0, '-') ELSE FavorecidoCPFCNPJ END AS FormattedFavorecidoCPFCNPJ, + HisLancamento, + NumChequeDeposito, + DataPagamento, + ValorPago FROM [Conveniar].[dbo].[LisLancamentoConvenio] + + LEFT JOIN [Conveniar].[dbo].[PlanoTrabalhoLancamento] ON [LisLancamentoConvenio].[CodLancamento] = [PlanoTrabalhoLancamento].[CodLancamentoGerado] + LEFT JOIN [Conveniar].[dbo].[LisConvenioItemAprovado] ON [PlanoTrabalhoLancamento].[CodConvenioItemAprovado] = [LisConvenioItemAprovado].[CodConvenioItemAprovado] + WHERE + [LisLancamentoConvenio].CodConvenio = ? + AND CodStatus = 27 + AND DataPagamento BETWEEN ? AND ? + AND [LisLancamentoConvenio].CodRubrica IN (57,75,26) + AND NomeTipoCreditoDebito = 'C' + OR CodStatus = 27 + AND [LisLancamentoConvenio].CodConvenio = ? + AND DataPagamento BETWEEN ? AND ? + AND LOWER(HisLancamento) LIKE '%estorno%' + AND [LisLancamentoConvenio].CodRubrica IN (57,75,26) + order by DataPagamento + """ + dfconsultaDadosPorRubrica = pd.read_sql(queryConsultaComRubrica, engine, params=parametros) + # queryConsultaComRubricaEstorno = f"SELECT NomeFavorecido,CASE WHEN LEN(FavorecidoCPFCNPJ) > 11 THEN STUFF(STUFF(STUFF(STUFF(FavorecidoCPFCNPJ, 3, 0, '.'), 7, 0, '.'), 11, 0, '/'), 16, 0, '-') WHEN LEN(FavorecidoCPFCNPJ) = 11 THEN STUFF(STUFF(STUFF(FavorecidoCPFCNPJ, 4, 0, '.'), 8, 0, '.'), 12, 0, '-') ELSE FavorecidoCPFCNPJ END AS FormattedFavorecidoCPFCNPJ,HisLancamento,NumChequeDeposito,DataPagamento, ValorPago FROM [Conveniar].[dbo].[LisLancamentoConvenio] WHERE CodConvenio = ? AND CodStatus = 27 AND DataPagamento BETWEEN ? AND ? AND LOWER(HisLancamento) LIKE '%estorno%' and CodRubrica = ? order by DataPagamento " + # queryConsultaPJDOA = f"SELECT NomeFavorecido,CASE WHEN LEN(FavorecidoCPFCNPJ) > 11 THEN STUFF(STUFF(STUFF(STUFF(FavorecidoCPFCNPJ, 3, 0, '.'), 7, 0, '.'), 11, 0, '/'), 16, 0, '-') WHEN LEN(FavorecidoCPFCNPJ) = 11 THEN STUFF(STUFF(STUFF(FavorecidoCPFCNPJ, 4, 0, '.'), 8, 0, '.'), 12, 0, '-') ELSE FavorecidoCPFCNPJ END AS FormattedFavorecidoCPFCNPJ,NomeTipoLancamento,HisLancamento,NumDocPago,DataEmissao,NumChequeDeposito,DataPagamento, ValorPago FROM [Conveniar].[dbo].[LisLancamentoConvenio] WHERE CodConvenio = ? AND CodStatus = 27 AND DataPagamento BETWEEN ? AND ? AND LOWER(HisLancamento) NOT LIKE '%estorno%' AND CodRubrica IN (57,75,26) order by DataPagamento " + # queryConsultaPJDOAEstorno = f"SELECT NomeFavorecido,CASE WHEN LEN(FavorecidoCPFCNPJ) > 11 THEN STUFF(STUFF(STUFF(STUFF(FavorecidoCPFCNPJ, 3, 0, '.'), 7, 0, '.'), 11, 0, '/'), 16, 0, '-') WHEN LEN(FavorecidoCPFCNPJ) = 11 THEN STUFF(STUFF(STUFF(FavorecidoCPFCNPJ, 4, 0, '.'), 8, 0, '.'), 12, 0, '-') ELSE FavorecidoCPFCNPJ END AS FormattedFavorecidoCPFCNPJ,HisLancamento,NumChequeDeposito,DataPagamento, ValorPago FROM [Conveniar].[dbo].[LisLancamentoConvenio] WHERE CodConvenio = ? AND CodStatus = 27 AND DataPagamento BETWEEN ? AND ? AND LOWER(HisLancamento) LIKE '%estorno%' AND CodRubrica IN (57,75,26) order by DataPagamento " + # dfconsultaDadosPorRubrica = pd.read_sql(queryConsultaComRubrica, engine, params=parametros) + dfconsultaDadosPorRubricaComEstorno = pd.read_sql(queryConsultaComRubricaEstorno,engine, params=parametrosComRubricaEstorno) + dfPJDOA = pd.read_sql(queryConsultaPJDOA, engine, params=parametrosPJ) + dfPJDOAESTORNO = pd.read_sql(queryConsultaPJDOAEstorno,engine, params=parametrosPJestorno) + + return dfPJDOA,dfPJDOAESTORNO,dfconsultaDadosPorRubrica,dfconsultaDadosPorRubricaComEstorno + +def consultaEntradaReceitas(IDPROJETO, DATA1, DATA2): + + file_path = pegar_pass("passs.txt") + conStr = '' + with open(file_path, 'r') as file: + conStr = file.readline().strip() + + connection_url = URL.create("mssql+pyodbc", query={"odbc_connect": conStr}) + engine = create_engine(connection_url) + parametros = [(IDPROJETO, DATA1, DATA2,)] + consultaEntradaReceita = f"""SELECT DataPagamento, + NumChequeDeposito + ,NomeFavorecido, + ValorPago, + CodRubrica FROM [Conveniar].[dbo].[LisLancamentoConvenio] WHERE CodConvenio = ? AND (CodRubrica = 2 OR CodRubrica = 67 OR CodRubrica = 88) AND CodStatus = 27 AND DataPagamento BETWEEN ? AND ? + ORDER BY DataPagamento,CodDocFinConvenio,CodRubrica""" + consultaDemonstrativoReceita = f"""SELECT NomeFavorecido, + HisLancamento, + NumChequeDeposito, + DataPagamento, + ValorPago, + CodRubrica FROM [Conveniar].[dbo].[LisLancamentoConvenio] + WHERE CodConvenio = ? AND (CodRubrica = 2 OR CodRubrica = 67 OR CodRubrica = 88) AND CodStatus = 27 AND DataPagamento BETWEEN ? AND ? ORDER BY DataPagamento,NumChequeDeposito""" + consultaSomaTotal2_6788 = f""" + SELECT + SUM(CASE WHEN CodRubrica = 88 THEN ValorPago ELSE 0 END) AS Sum_88, + SUM(CASE WHEN CodRubrica = 67 THEN ValorPago ELSE 0 END) AS Sum_67, + SUM(CASE WHEN CodRubrica = 2 THEN ValorPago ELSE 0 END) AS Sum_2 + FROM + [Conveniar].[dbo].[LisLancamentoConvenio] + WHERE + CodConvenio = ? + AND CodStatus = 27 + AND DataPagamento BETWEEN ? AND ? + """ + dfReceitas = pd.read_sql(consultaEntradaReceita, engine, params=parametros) + dfDemonstrativoReceitas = pd.read_sql(consultaDemonstrativoReceita, engine, params=parametros) + dfSomaTotal = pd.read_sql(consultaSomaTotal2_6788, engine, params=parametros)#88% É ISS2% + #88% É ISS2% + #67 É ISS2% + #2 E ENTRADA DE RECEITA + + + + + return dfReceitas,dfDemonstrativoReceitas,dfSomaTotal + +def consultaReceitaEExecReceita(IDPROJETO, DATA1, DATA2): + ''' Função que vai pega os dados da Rubrica 9 Despesas Financeiras e transformalos em dataframe + para poder popular a databela Despesas Financeiras + Argumentos + IDPROJETO = CodConvenio na tabela nova, corresponde ao codigo do projeto + DATA1 = Data Inicial Selecinado pelo Usuario + DATA2 = Data Final Selecionado pelo Usuario + ''' + file_path = pegar_pass("passs.txt") + conStr = '' + with open(file_path, 'r') as file: + conStr = file.readline().strip() + + connection_url = URL.create("mssql+pyodbc", query={"odbc_connect": conStr}) + engine = create_engine(connection_url) + parametros = [(IDPROJETO, DATA1, DATA2)] + parametros2 = [(IDPROJETO, DATA2)] + parametros3 = IDPROJETO + consultaComPeriodo =f"SELECT NomeRubrica, SUM(ValorPago) AS VALOR_TOTAL_PERIODO FROM [Conveniar].[dbo].[LisLancamentoConvenio] WHERE CodConvenio = ? AND CodStatus = 27 AND DataPagamento BETWEEN ? AND ? GROUP BY NomeRubrica, CodRubrica Order by CodRubrica" + consultaAteAData = f"SELECT NomeRubrica, SUM(ValorPago) AS VALOR_TOTAL_DATA FROM [Conveniar].[dbo].[LisLancamentoConvenio] WHERE CodConvenio = ? AND CodStatus = 27 AND DataPagamento <= ? GROUP BY NomeRubrica, CodRubrica Order by CodRubrica " + consultaPrevisto = f"SELECT NomeRubrica, SUM(VALOR*Quantidade) AS VALOR_TOTAL_PREVISTO FROM [Conveniar].[dbo].[LisConvenioItemAprovado] WHERE CodConvenio = ? GROUP BY NomeRubrica, CodRubrica Order by CodRubrica" + + dfComPeriodo= pd.read_sql(consultaComPeriodo, engine, params=parametros) + dfAteAData = pd.read_sql(consultaAteAData, engine, params=parametros2) + dfPrevisto = pd.read_sql(consultaPrevisto, engine, params=(IDPROJETO,)) + + + return dfComPeriodo,dfAteAData,dfPrevisto + +def consultaBens(IDPROJETO,DATA1,DATA2): + ''' Função que vai pega os dados da Rubrica 9 Despesas Financeiras e transformalos em dataframe + para poder popular a databela Despesas Financeiras + Argumentos + IDPROJETO = CodConvenio na tabela nova, corresponde ao codigo do projeto + DATA1 = Data Inicial Selecinado pelo Usuario + DATA2 = Data Final Selecionado pelo Usuario + ''' + file_path = pegar_pass("passss.txt") + conStr = '' + with open(file_path, 'r') as file: + conStr = file.readline().strip() + + connection_url = URL.create("mssql+pyodbc", query={"odbc_connect": conStr}) + engine = create_engine(connection_url) + idprojetoComZero = f"0{IDPROJETO}" + parametros = [(IDPROJETO,idprojetoComZero, DATA1, DATA2)] + + queryConsultaComRubrica = f"SELECT [Descrição][descri],[Patrimônio][patri],CONVERT(varchar, [Data de Aquisição], 103) AS dataAqui,[Nº Nota][nota],[Localização][localiza],[telefone],[Valor de Aquisição][valorAqui],[Valor de Aquisição][valorAqui2],[Responsável][responsavel] FROM [SBO_FINATEC].[dbo].[VW_BENS_ADQUIRIDOS] WHERE ([Cod Projeto] = ? or [Cod Projeto] = ? ) AND [Status] = 'Imobilizado' AND [Data de Aquisição] BETWEEN ? AND ? Order by [Data de Aquisição]" + dfConsultaBens = pd.read_sql(queryConsultaComRubrica, engine, params=parametros) + + + return dfConsultaBens + +def consultaTabelaGigante(IDPROJETO,DATA1,DATA2): + file_path = pegar_pass("passs.txt") + conStr = '' + with open(file_path, 'r') as file: + conStr = file.readline().strip() + + connection_url = URL.create("mssql+pyodbc", query={"odbc_connect": conStr}) + engine = create_engine(connection_url) + parametros = [(IDPROJETO,DATA1,DATA2)] + queryAnexoDois = f""" + SELECT + NumDocFinConvenio, + NomeTipoPedido, + HisLancamento, + NomeRubrica, + ValorLancamento, + NomeTipoCreditoDebito, + DataCriacao, + DataVencimento, + DataPagamento, + ValorPago, + NumChequeDeposito, + NumDocBancario, + DataEmissao, + NumDocPago, + CodConvenio, + NomeConvenio, + AgenciaBancaria, + ContaBancaria, + NomeFavorecido, + FavorecidoCPFCNPJ, + NomePessoaGestor, + NomeTipoPedido, + NomeStatus, + NumDocFinConvenio, + NumDocFinConvenio + FROM [Conveniar].[dbo].[LisLancamentoConvenio] + WHERE [LisLancamentoConvenio].CodConvenio = ? AND [LisLancamentoConvenio].CodStatus = 27 + AND [LisLancamentoConvenio].DataPagamento BETWEEN ? AND ? and [LisLancamentoConvenio].CodRubrica not in (2,0) + order by DataPagamento""" + dfConvenioAnexoDois = pd.read_sql(queryAnexoDois, engine, params=parametros) + return dfConvenioAnexoDois +#preenche planilha + +def conciliacaoBancaria(codigo,data1,data2,planilha,stringTamanho): + + 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) + + dataframeSemEstorno,dataframeComEstorno = consultaConciliacaoBancaria(codigo,data1,data2) + + #####pergar os dados do db e separar por mes e ano###################3 + + grupos_por_ano_mes = defaultdict(list) + if dataframeSemEstorno.empty and dataframeComEstorno.empty: + print("Data not available or empty.") + maior = 5 + maior2= 5 + tabela = pegar_caminho(planilha) + estilo_conciliacoes_bancaria(tabela,maior,maior2,stringTamanho) + return None # or handle the case accordingly + else: + + tamanho = len(dataframeSemEstorno) + tamanho2 = len(dataframeComEstorno) + + tabela = pegar_caminho(planilha) + estilo_conciliacoes_bancaria(tabela,tamanho,tamanho2,stringTamanho) + + + workb = openpyxl.load_workbook(tabela) + worksheet333 = workb["Conciliação Bancária"] + i = 16 + j=0 + estorno_valor = 0 + + dataframeSemEstorno['data_formatada'] = dataframeSemEstorno['DataPagamento'].apply(formatar_data) + dataframeComEstorno['data_formatada'] = dataframeComEstorno['DataPagamento'].apply(formatar_data) + dataframeSemEstorno['DataPagamento'] = dataframeSemEstorno['data_formatada'] + dataframeComEstorno['DataPagamento'] = dataframeComEstorno['data_formatada'] + + dataframeSemEstorno = dataframeSemEstorno.drop('data_formatada', axis=1) + dataframeComEstorno = dataframeComEstorno.drop('data_formatada', axis=1) + + #for row in worksheet333.iter_rows(min_row=16, max_row=tamanho, min_col=1, max_col=4): + + + for row_num, row_data in enumerate(dataframeSemEstorno.itertuples(index=False), start=17):#inicio linha + for col_num, value in enumerate(row_data, start=1):#inicio coluna + worksheet333.cell(row=row_num, column=col_num, value=value) + + + linha2 = 17+4+tamanho+1 + + + for row_num, row_data in enumerate(dataframeComEstorno.itertuples(index=False), start=linha2):#inicio linha + for col_num, value in enumerate(row_data, start=1):#inicio coluna + worksheet333.cell(row=row_num, column=col_num, value=value) + + #saldo anterior + + consultaSaldoTotal,consultaSumTotalRestituicao,consultasumPeriodoSemEstorno,consultasumPeriodoComEstorno= consultaConciliaoBancarioSaldoTotal(codigo,data1,data2) + + a = consultaSaldoTotal.iloc[0].item() + b = consultaSumTotalRestituicao.iloc[0].item() + + + worksheet333['B16'] = a + worksheet333[f'B{linha2-1}'] = b + + + + workb.save(tabela) + workb.close + +def demonstrativo(codigo,data1,data2,planilha,rowBrasilia,dataframeDemonstrativoReceita,dfReceitas): + tabela = pegar_caminho(planilha) + workbook = openpyxl.load_workbook(tabela) + sheet2 = workbook.create_sheet(title="Demonstrativo de Receita") + workbook.save(tabela) + workbook.close() + tamanho = len(dataframeDemonstrativoReceita) + estilo_demonstrativoDeReceita(tabela,tamanho,rowBrasilia) + + workbook = openpyxl.load_workbook(tabela) + worksheet = workbook['Demonstrativo de Receita'] + + for row_num, row_data in enumerate(dataframeDemonstrativoReceita.itertuples(index = False), start=10):#inicio linha + for col_num, value in enumerate(row_data, start=1):#inicio coluna + if col_num != 6: + worksheet.cell(row=row_num, column=col_num, value=convert_datetime_to_string(value)) + cod_rubrica_value = row_data[5] + if cod_rubrica_value == 67 or cod_rubrica_value == 88: + worksheet.cell(row=row_num, column=5).font = Font(name='Arial', size=12, bold=True, italic=False, color='FF0000') + else: + worksheet.cell(row=row_num, column=5).font = Font(name='Arial', size=12, bold=True, italic=False, color='0000FF') + + + + + + + + workbook.save(tabela) + workbook.close() + +def relacaodeBens(codigo,data1,data2,planilha,rowBrasilia): + 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() + dfBens = consultaBens(codigo,data1,data2) + + tamanho = len(dfBens) + + estiloRelacaoBens(tabela,tamanho,tituloStyle,nomeTabela,rowBrasilia) + + workbook = openpyxl.load_workbook(tabela) + sheet = workbook['Relação de Bens'] + for row_num, row_data in enumerate(dfBens.itertuples(), start=13):#inicio linha + for col_num, value in enumerate(row_data, start=1):#inicio coluna + value = re.sub("[^a-zA-ZÀ-ÿ0-9º+-//]", " ", str(value)) + value = convert_datetime_to_stringdt(value) + if col_num == 7: + value = 1 + sheet.cell(row=row_num, column=col_num, value=value) + + + workbook.save(tabela) + workbook.close() + +def rendimentoDeAplicacao(codigo,data1,data2,planilha,rowBrasilia): + tabela = pegar_caminho(planilha) + workbook = openpyxl.load_workbook(tabela) + sheet2 = workbook.create_sheet(title="Rendimento de Aplicação") + workbook.save(tabela) + workbook.close() + + dfConsultaRendimentoAplicacao,dfConsultaImposto,dfImpostoERendimento = consultaRendimentosAplicacao(codigo,data1,data2) + merged_df = pd.merge(dfConsultaRendimentoAplicacao, dfConsultaImposto, on='DataPagamento') + tamanho = 0 + # tamanhoMaior = lambda tamanho: len(dfConsultaRendimentoAplicacao) if len(dfConsultaRendimentoAplicacao) > len(dfConsultaImposto) else len(dfConsultaImposto) + # tamanhoMaiorParaOEstilo = tamanhoMaior(None) + tamanhoMaiorParaOEstilo = len(merged_df) + estilo_rendimento_de_aplicacao(tabela,tamanhoMaiorParaOEstilo,rowBrasilia) + + workbook = openpyxl.load_workbook(tabela) + sheet = workbook['Rendimento de Aplicação'] + + merged_df['data_formatada'] = merged_df['DataPagamento'].apply(formatarDataSemDia) + merged_df['DataPagamento'] = merged_df['data_formatada'] + merged_df = merged_df.drop('data_formatada', axis=1) + + + + + for row_num, row_data in enumerate(merged_df.itertuples(index=False), start=15):#inicio linha + for col_num, value in enumerate(row_data, start=1):#inicio coluna + if col_num == 2: + col_num = 5 + if col_num == 3: + col_num = 6 + sheet.cell(row=row_num, column=col_num, value=value) + + + workbook.save(tabela) + workbook.close() + return (len(merged_df))+15 + +def rubricaGeral(codigo,data1,data2,planilha,rowBrasilia): + #consulta todas rubricas + tabela = pegar_caminho(planilha) + dfNomeRubricaCodigoRubrica = consultaNomeRubricaCodRubrica(codigo, data1, data2) + + + for index, values in dfNomeRubricaCodigoRubrica.iterrows(): + + dfPJDOA,dfPJDOAESTORNO,dfConsultaProjeto ,dfconsultaDadosPorRubricaComEstorno= consultaProjeto(codigo, data1, data2,values['CodRubrica']) + + #remove as rubricas nao desejadas + # values_to_remove = ["Receitas", "Rendimentos de Aplicações Financeiras", "Despesas Financeiras",'Devolução de Recursos','Outros Serviços de Terceiros - Pessoa Jurídica ','Despesas Operacionais e Administrativas - Finatec'] + # dfConsultaProjeto = dfConsultaProjeto[~dfConsultaProjeto['NomeRubrica'].isin(values_to_remove)] + # dfconsultaDadosPorRubricaComEstorno = dfconsultaDadosPorRubricaComEstorno[~dfconsultaDadosPorRubricaComEstorno['NomeRubrica'].isin(values_to_remove)] + + + if values['NomeRubrica'] == "Obrigações Tributárias e contributivas": + values['NomeRubrica'] = "Obrigações Tributárias" + if values['NomeRubrica'] == "Material Permanente e Equipamento Nacional": + values['NomeRubrica'] = "Equipamento Material Nacional" + if values['NomeRubrica'] == "Serviços de Terceiros Pessoa Física": + values['NomeRubrica'] = "Serviços de Terceiros PF" + if values['NomeRubrica'] == f"Obrigações Tributárias e Contributivas - 20% de OST " : + values['NomeRubrica'] = f"Obrigações Trib. - Encargos 20%" + if values['NomeRubrica'] == f"Obrigações Tributárias e contributivas " : + values['NomeRubrica'] = f"Obrigações Tributárias" + if values['NomeRubrica'] == f"Outros Serviços de Terceiros - Pessoa Física" : + values['NomeRubrica'] = f"Outros Serviços Terceiros - PF" + if values['NomeRubrica'] == f"Outros Serviços de Terceiros - Pessoa Jurídica " : + values['NomeRubrica'] = f"Outros Serviços Terceiros - PJ" + if values['NomeRubrica'] == f"Passagens e Despesas com Locomoção" : + values['NomeRubrica'] = f"Passagens e Desp. Locomoção" + if values['NomeRubrica'] == f"Despesas Operacionais e Administrativas - Finatec" : + values['NomeRubrica'] = f"Despesas Operacionais" + if values['NomeRubrica'] == f"Despesas Operacionais e Administrativas - Finatec" : + values['NomeRubrica'] = f"Despesas Operacionais" + if values['NomeRubrica'] == f"Auxílio Financeiro a Pesquisador" : + values['NomeRubrica'] = f"AuxFinanceiro Pesquisador" + if values['NomeRubrica'] == f"Equipamentos e Material Permanente" : + values['NomeRubrica'] = f"Equip e Mat Permanente" + if values['NomeRubrica'] == f"Material Permanente e Equipamento Importado" : + values['NomeRubrica'] = f"Equipamento Material Importado" + + + + + if values['NomeRubrica'] == "Outros Serviços Terceiros - PJ" or values['NomeRubrica'] == "Serviços de Terceiros Pessoa Jurídica": + values['NomeRubrica'] = "Outros Serviços Terceiros -PJ" + nomeTabela = values['NomeRubrica'] + tituloStyle = values['NomeRubrica'] + workbook = openpyxl.load_workbook(tabela) + sheet2 = workbook.create_sheet(title=f"{values['NomeRubrica']}") + workbook.save(tabela) + workbook.close() + + + tamanho = len(dfPJDOA) + tamanhoRetorno = len(dfPJDOAESTORNO) + + rownovo = estiloGeral(tabela,tamanho,tituloStyle,nomeTabela,rowBrasilia,tamanhoRetorno) + workbook = openpyxl.load_workbook(tabela) + sheet2 = workbook[values['NomeRubrica']] + dfPJDOA.index = dfPJDOA.index + 1 + for row_num, row_data in enumerate(dfPJDOA.itertuples(), start=10):#inicio linha + for col_num, value in enumerate(row_data, start=1):#inicio coluna + value = convert_datetime_to_stringdt(value) + sheet2.cell(row=row_num, column=col_num, value=value) + + dfPJDOAESTORNO.insert(0, "col1", None) + dfPJDOAESTORNO.insert(4, 'Col2', None) + dfPJDOAESTORNO.insert(4, 'Col3', None) + dfPJDOAESTORNO.insert(5, 'Col4', None) + + + rownovo = rownovo + 1 + for row_num, row_data in enumerate(dfPJDOAESTORNO.itertuples(index=False), start=rownovo): #inicio linha + for col_num, value in enumerate(row_data, start=1): #inicio coluna + if col_num == 5: + continue + value = convert_datetime_to_stringdt(value) + sheet2.cell(row=row_num, column=col_num, value=value) + + workbook.save(tabela) + workbook.close() + + + else: + + if values['NomeRubrica'] != "Rendimentos de Aplicações Financeiras" and values['NomeRubrica'] != "Despesas Financeiras" and values['NomeRubrica'] != "Receitas" and values['NomeRubrica'] != "Devolução de Recursos" and values['NomeRubrica'] != "Outros Serviços Terceiros - PJ"and values['NomeRubrica'] != "Despesas Operacionais": + nomeTabela = values['NomeRubrica'] + tituloStyle = values['NomeRubrica'] + workbook = openpyxl.load_workbook(tabela) + sheet2 = workbook.create_sheet(title=f"{values['NomeRubrica']}") + workbook.save(tabela) + workbook.close() + + tamanho = len(dfConsultaProjeto) + tamanhoRetorno = len(dfconsultaDadosPorRubricaComEstorno) + + + + rowEstorno = estiloGeral(tabela,tamanho,tituloStyle,nomeTabela,rowBrasilia,tamanhoRetorno) + workbook = openpyxl.load_workbook(tabela) + sheet2 = workbook[values['NomeRubrica']] + dfConsultaProjeto.index = dfConsultaProjeto.index + 1 + for row_num, row_data in enumerate(dfConsultaProjeto.itertuples(), start=10):#inicio linha + for col_num, value in enumerate(row_data, start=1):#inicio coluna + value = convert_datetime_to_stringdt(value) + sheet2.cell(row=row_num, column=col_num, value=value) + + # dfconsultaDadosPorRubricaComEstorno.index = dfconsultaDadosPorRubricaComEstorno.index + 1 + rowEstorno = rowEstorno + 1 + # + tamanhoDf = len(dfconsultaDadosPorRubricaComEstorno) + dfconsultaDadosPorRubricaComEstorno.insert(0, "col1", None) + dfconsultaDadosPorRubricaComEstorno.insert(4, 'Col2', None) + dfconsultaDadosPorRubricaComEstorno.insert(4, 'Col3', None) + dfconsultaDadosPorRubricaComEstorno.insert(5, 'Col4', None) + + + + + for row_num, row_data in enumerate(dfconsultaDadosPorRubricaComEstorno.itertuples(index=False), start=rowEstorno): #inicio linha + for col_num, value in enumerate(row_data, start=1): #inicio coluna + + if col_num == 5: + continue + value = convert_datetime_to_stringdt(value) + sheet2.cell(row=row_num, column=col_num, value=value) + + workbook.save(tabela) + workbook.close() + + + + #consulta individual + return 0 + +def Receita(planilha,codigo,data1,data2,tamanhoResumo,dataframe): + + #dfReceitas,dfDemonstrativoReceitas,dfIss2,dfIss5 = consultaEntradaReceitas(codigo,data1,data2) + dfReceitas,dfDemonstrativoReceitas,dfSomaTotal = consultaEntradaReceitas(codigo,data1,data2) + + + if len(dfReceitas) > tamanhoResumo and len(dfReceitas) < 15: + tamanhoResumo = len(dfReceitas) + elif len(dataframe) > tamanhoResumo: + tamanhoResumo = len(dataframe) + + + caminho = pegar_caminho(planilha) + #tamanho equipamento ja e valido pois recebeu o tamanho maior e retornou o tamanho equipamentos da string + tamanho,tamanhoequipamentos = estiloReceitaXDespesa(caminho,tamanhoResumo) + + + + #o tamanho na verdade tem que ser do data frame se ele for maior + + #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 = consultaID(codigo) + + stringCoordenador= f'H{tamanho+3}' # retorna lugar do coordanor + stringTamanhoCPF = f'H{tamanho+5}' # retorna lugar do coordanor + sheet[stringCoordenador] = consulta_coordenador['NomePessoaResponsavel'] + sheet[stringTamanhoCPF] = formatar_cpf(consulta_coordenador['CPFCoordenador']) + string_titulo = f"Título do Projeto: {consulta_coordenador['NomeConvenio']}" + string_executora = f"Executora: {consulta_coordenador['NomePessoaFinanciador']}" + string_participe = f"Partícipe: Fundação de Empreendimentos Científicos e Tecnológicos - FINATEC" + # Convert 'DataAssinatura' to "dd/mm/YYYY" format + datetime_obj1 = consulta_coordenador['DataAssinatura'] + formatted_date1 = datetime_obj1.strftime("%d/%m/%Y") + + # Convert 'DataVigencia' to "dd/mm/YYYY" format + datetime_obj2 = consulta_coordenador['DataVigencia'] + formatted_date2 = datetime_obj2.strftime("%d/%m/%Y") + +# Create the string representing the period of execution + string_periodo = f"Período de Execução Físico-Financeiro: {formatted_date1} a {formatted_date2}" + sheet['A3'] = string_titulo + sheet['A4'] = string_executora + sheet['A5'] = string_participe + sheet['A6'] = string_periodo + + #dadosquefaltam = getAnalistaDoProjetoECpfCoordenador(codigo) + + #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" + } + strintT = tamanho + stringTamanho = f'A{tamanho}' # retorna lugar de brasilia + hoje = date.today() + data_formatada = f"{hoje.day} de {meses_dict[hoje.month]} de {hoje.year}" + sheet[stringTamanho] = f'Brasilia, {data_formatada}' + # tamanhoequipamentos = tamanhoequipamentos + 16 + #Obras e Instalações + #previsto + string_exists = dataframe['NomeRubrica'].isin(["Obras e Instalações"]).any() + if string_exists: + + #periodo + stringObras = f'I{tamanhoequipamentos -1}' + sheet[stringObras] = dataframe.loc[dataframe['NomeRubrica'] == 'Obras e Instalações', 'VALOR_TOTAL_PERIODO'].values[0] + + + string_exists = dataframe['NomeRubrica'].isin(["Equipamentos e Material Permanente"]).any() + if string_exists: + #Materiais Equipamentos e Material Permanente + + #periodo + stringObras = f'I{tamanhoequipamentos}' + sheet[stringObras] = dataframe.loc[dataframe['NomeRubrica'] == 'Equipamentos e Material Permanente', 'VALOR_TOTAL_PERIODO'].values[0] + + #Materiais Equipamentos e Material nACIONAL + string_exists = dataframe['NomeRubrica'].isin(["Material Permanente e Equipamento Nacional"]).any() + if string_exists: + + #periodo + stringObras = f'I{tamanhoequipamentos +1}' + sheet[stringObras] = dataframe.loc[dataframe['NomeRubrica'] == 'Material Permanente e Equipamento Nacional', 'VALOR_TOTAL_PERIODO'].values[0] + + + #Materiais Equipamentos e Material iMPORTADO + string_exists = dataframe['NomeRubrica'].isin(["Material Permanente e Equipamento Importado"]).any() + if string_exists: + + #periodo + stringObras = f'I{tamanhoequipamentos + 2}' + sheet[stringObras] = dataframe.loc[dataframe['NomeRubrica'] == 'Material Permanente e Equipamento Importado', 'VALOR_TOTAL_PERIODO'].values[0] + + + #remove as rubricas nao desejadas + values_to_remove = ["Receitas", "Rendimentos de Aplicações Financeiras", "Despesas Financeiras",'Material Permanente e Equipamento Nacional','Material Permanente e Equipamento Importado','Equipamentos e Material Permanente','Devolução de Recursos','Encargos - ISS 5% '] + dataframe = dataframe[~dataframe['NomeRubrica'].isin(values_to_remove)] + + + string_exists = dataframe['NomeRubrica'].isin(["Despesas Operacionais e Administrativas - Finatec"]).any() + if string_exists: + # Extract the value from "Despesas Operacionais e Administrativas - Finatec" + value_to_add = dataframe.loc[dataframe['NomeRubrica'] == 'Despesas Operacionais e Administrativas - Finatec'].iloc[0] + + string_exists = dataframe['NomeRubrica'].isin(["Outros Serviços de Terceiros - Pessoa Jurídica "]).any() + string_exists2 = dataframe['NomeRubrica'].isin(["Serviços de Terceiros Pessoa Jurídica"]).any() + if string_exists or string_exists2: + if string_exists: + # Find the index of "Outros Serviços de Terceiros - Pessoa Jurídica" + index_to_update = dataframe.loc[dataframe['NomeRubrica'] == 'Outros Serviços de Terceiros - Pessoa Jurídica '].index[0] + + + # Add the value to "Outros Serviços de Terceiros - Pessoa Jurídica" + dataframe.loc[dataframe['NomeRubrica'] == 'Outros Serviços de Terceiros - Pessoa Jurídica '] += value_to_add + + # Drop the row for "Despesas Operacionais e Administrativas - Finatec" + dataframe = dataframe[dataframe['NomeRubrica'] != 'Despesas Operacionais e Administrativas - Finatec'] + if string_exists2: + # Find the index of "Outros Serviços de Terceiros - Pessoa Jurídica" + index_to_update = dataframe.loc[dataframe['NomeRubrica'] == 'Serviços de Terceiros Pessoa Jurídica'].index[0] + + # Add the value to "Outros Serviços de Terceiros - Pessoa Jurídica" + dataframe.loc[dataframe['NomeRubrica'] == 'Outros Serviços de Terceiros - Pessoa Jurídica '] += value_to_add + + # Drop the row for "Despesas Operacionais e Administrativas - Finatec" + dataframe = dataframe[dataframe['NomeRubrica'] != 'Despesas Operacionais e Administrativas - Finatec'] + + + + + # else: + # string_exists = dataframe['NomeRubrica'].isin(["Outros Serviços de Terceiros - Pessoa Jurídica "]).any() + # string_exists2 = dataframe['NomeRubrica'].isin(["Serviços de Terceiros Pessoa Jurídica"]).any() + # if string_exists or string_exists2: + # if string_exists: + # # Find the index of "Outros Serviços de Terceiros - Pessoa Jurídica" + # index_to_update = dataframe.loc[dataframe['NomeRubrica'] == 'Outros Serviços de Terceiros - Pessoa Jurídica '].index[0] + + + # if string_exists2: + # # Find the index of "Outros Serviços de Terceiros - Pessoa Jurídica" + # index_to_update = dataframe.loc[dataframe['NomeRubrica'] == 'Serviços de Terceiros Pessoa Jurídica'].index[0] + + + + + #dataframe.loc[['Outros Serviços de Terceiros - Pessoa Jurídica ']] += dataframe.loc[['Despesas Operacionais e Administrativas - Finatec']] + + for row_num, row_data in enumerate(dataframe.itertuples(index = False), start=16):#inicio linha + for col_num, value in enumerate(row_data, start=8):#inicio coluna + sheet.cell(row=row_num, column=col_num, value=convert_datetime_to_string(value)) + + + if len(dfReceitas) < 15: + #vai preencher o lado esquerdo da tabela a parte de receita + for row_num, row_data in enumerate(dfReceitas.itertuples(index = False), start=16):#inicio linha + for col_num, value in enumerate(row_data, start=1):#inicio coluna + + + if col_num != 6: + if col_num == 4: + col_num = 5 + sheet.cell(row=row_num, column=col_num, value=convert_datetime_to_string(value)) + cod_rubrica_value = row_data[4] + if col_num ==5: + kek = row_data[3] + if cod_rubrica_value == 88 or cod_rubrica_value == 67: + kek = -row_data[3] + + sheet.cell(row=row_num, column=col_num, value=convert_datetime_to_string(kek)) + + + if cod_rubrica_value == 88: + if col_num == 3: + + val = f'ISS 2% {value}' + sheet.cell(row=row_num, column=col_num, value=convert_datetime_to_string(val)) + + + + sheet.cell(row=row_num, column=5).font = Font(name='Arial', size=12, bold=True, italic=False, color='FF0000') + + elif cod_rubrica_value == 67: + if col_num == 3: + + vala = f'ISS 5% {value}' + sheet.cell(row=row_num, column=col_num, value=convert_datetime_to_string(vala)) + + sheet.cell(row=row_num, column=5).font = Font(name='Arial', size=12, bold=True, italic=False, color='FF0000') + else: + sheet.cell(row=row_num, column=5).font = Font(name='Arial', size=12, bold=True, italic=False, color='0000FF') + else: + + + number_format = 'R$ #,##0.00' + # Set font and value for row 17 + sheet.cell(row=18, column=5).font = Font(name='Arial', size=12, bold=True, italic=False, color='FF0000') + sheet.cell(row=18, column=5).value = f'ISS 2% R$ {dfSomaTotal["Sum_88"].values[0]}' + sheet.cell(row=18, column=5).alignment = Alignment(horizontal="right",vertical="center") + sheet.cell(row=18, column=5).number_format = number_format + + + # Set font and value for row 16 + sheet.cell(row=17, column=5).font = Font(name='Arial', size=12, bold=True, italic=False, color='FF0000') + sheet.cell(row=17, column=5).value = f'ISS 5% R$ {dfSomaTotal["Sum_67"].values[0]}' + sheet.cell(row=17, column=5).alignment = Alignment(horizontal="right",vertical="center") + sheet.cell(row=17, column=5).number_format = number_format + + # Set font and value for row 15 + sheet.cell(row=16, column=5).font = Font(name='Arial', size=12, bold=True, italic=False, color='0000FF') + sheet.cell(row=16, column=5).value = dfSomaTotal['Sum_2'].values[0] + + + + #rendimentosdeapliacação + dfSoma = consultaRendimentosIRRF(codigo,data1,data2) + dfcComPeriodo = consultaDevolucaoRecursos(codigo,data1,data2) + Soma = dfSoma["Aplicação"] + dfSoma["IRRF"] + + all_null = Soma.isnull().all() + if all_null != True : + if len(Soma) == 1: + result = Soma.iloc[0] + else: + result = Soma.iloc[0] - Soma.iloc[1] + stringRendimento = f'Rendimento de Aplicação' + stringRendimentoValor = f'E{tamanhoequipamentos + 6}' + sheet[stringRendimentoValor] = result + sheet[f'A{tamanhoequipamentos + 6}'] = stringRendimento + + + #tarifasbancarias + + consultaSaldoTotal,consultaSumTotalRestituicao,consultasumPeriodoSemEstorno,consultasumPeriodoComEstorno=consultaConciliaoBancarioSaldoTotal(codigo,data1,data2) + + c = consultaSaldoTotal.iloc[0].item() + + d = consultaSumTotalRestituicao.iloc[0].item() + resultEstorno = consultasumPeriodoSemEstorno.iloc[0].item() + resultSemEstorno = consultasumPeriodoComEstorno.iloc[0].item() + + + #checa soma total ate a data + if c == None: + c = 0 + if d == None: + d = 0 + #checa o total resituição + if resultEstorno == None: + resultEstorno = 0 + if resultSemEstorno == None: + resultSemEstorno = 0 + + + + #TTarifa Bancária - Despesa (-) + stringRendimentoValor = f'I{tamanhoequipamentos + 9}' + sheet[stringRendimentoValor] = resultEstorno + c + + + #Tarifa Bancária - Restituição (+) + stringRendimentoValor = f'I{tamanhoequipamentos + 10}' + sheet[stringRendimentoValor] = resultSemEstorno + d + + + #devoluçãoderecursos + + stringRendimentoValor = f'I{tamanhoequipamentos + 7}' + sheet[stringRendimentoValor] = dfcComPeriodo.iloc[0,0] + + + workbook.save(planilha) + workbook.close() + return strintT,dfReceitas,dfDemonstrativoReceitas + +def ExeReceitaDespesa(planilha,codigo,data1,data2,stringTamanho): + tabela = pegar_caminho(planilha) + workbook = openpyxl.load_workbook(tabela) + sheet2 = workbook.create_sheet(title="Exec. Receita e Despesa") + workbook.save(tabela) + workbook.close() + stringTamanho = 15 #esqueci o pq deve ser =o tamanho na tabela + + #dataframe com os dados + dfComPeriodo,dfAteAData,dfPrevisto = consultaReceitaEExecReceita(codigo,data1,data2) + # Merge with an outer join + merged_df = pd.merge(dfPrevisto, dfComPeriodo, on='NomeRubrica', how='outer') + dfMerged = pd.merge(merged_df,dfAteAData, on = 'NomeRubrica', how = 'outer') + tamanho = len(dfMerged)#tamanho para deixar dinamico para imprimir sa rubricas + #tamanho rubrica dinamicas + string_exists = dfMerged['NomeRubrica'].isin(["Material Permanente e Equipamento Importado"]).any() + if string_exists: + tamanho = tamanho - 1 + string_exists = dfMerged['NomeRubrica'].isin(["Obras e Instalações"]).any() + if string_exists: + tamanho = tamanho - 1 + string_exists = dfMerged['NomeRubrica'].isin(["Equipamentos e Material Permanente"]).any() + if string_exists: + tamanho = tamanho - 1 + string_exists = dfMerged['NomeRubrica'].isin(["Material Permanente e Equipamento Nacional"]).any() + if string_exists: + tamanho = tamanho - 1 + string_exists = dfMerged['NomeRubrica'].isin(["Receitas"]).any() + if string_exists: + tamanho = tamanho - 1 + string_exists = dfMerged['NomeRubrica'].isin(["Rendimentos de Aplicações Financeiras"]).any() + if string_exists: + tamanho = tamanho - 1 + string_exists = dfMerged['NomeRubrica'].isin(["Despesas Financeiras"]).any() + if string_exists: + tamanho = tamanho - 1 + + + stringTamanho = tamanho + 16 + estiloExecReceitaDespesa(tabela,tamanho,stringTamanho) + #preencher + workbook = openpyxl.load_workbook(planilha) + sheet = workbook['Exec. Receita e 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 = consultaID(codigo) + stringCoordenador= f'F{stringTamanho+13}' # retorna lugar do coordanor + stringCoordanadorCargo = f'F{stringTamanho+14}' + sheet[stringCoordanadorCargo] = f"Coordenador(a)" + stringTamanhoCPF = f'F{stringTamanho+15}' # retorna lugar do coordanor + sheet[stringCoordenador] = consulta_coordenador['NomePessoaResponsavel'] + sheet[stringTamanhoCPF] = formatar_cpf(consulta_coordenador['CPFCoordenador']) + string_titulo = f"Título do Projeto: {consulta_coordenador['NomeConvenio']}" + string_executora = f"Executora: {consulta_coordenador['NomePessoaFinanciador']}" + string_participe = f"Partícipe: Fundação de Empreendimentos Científicos e Tecnológicos - FINATEC" + # Convert 'DataAssinatura' to "dd/mm/YYYY" format + datetime_obj1 = consulta_coordenador['DataAssinatura'] + formatted_date1 = datetime_obj1.strftime("%d/%m/%Y") + + # Convert 'DataVigencia' to "dd/mm/YYYY" format + datetime_obj2 = consulta_coordenador['DataVigencia'] + formatted_date2 = datetime_obj2.strftime("%d/%m/%Y") + +# Create the string representing the period of execution + string_periodo = f"Período de Execução Físico-Financeiro: {formatted_date1} a {formatted_date2}" + sheet['A3'] = string_titulo + sheet['A4'] = string_executora + sheet['A5'] = string_participe + sheet['A6'] = string_periodo + + #dadosquefaltam = getAnalistaDoProjetoECpfCoordenador(codigo) + #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" +} + + stringTamanhoBrasilia = f'A{stringTamanho+12}' # retorna lugar de brasilia + hoje = date.today() + data_formatada = f"{hoje.day} de {meses_dict[hoje.month]} de {hoje.year}" + sheet[stringTamanhoBrasilia] = f'Brasilia, {data_formatada}' + + #despesas correntes + imprimirResumoLinha = 16 + + #Obras e Instalações + #previsto + string_exists = dfMerged['NomeRubrica'].isin(["Obras e Instalações"]).any() + if string_exists: + + stringObras = f'B{stringTamanho + 2}' + sheet[stringObras] = dfMerged.loc[dfMerged['NomeRubrica'] == 'Obras e Instalações', 'VALOR_TOTAL_PREVISTO'].values[0] + stringObras = f'F{stringTamanho + 2}' + sheet[stringObras] = dfMerged.loc[dfMerged['NomeRubrica'] == 'Obras e Instalações', 'VALOR_TOTAL_PREVISTO'].values[0] + + #periodo + stringObras = f'C{stringTamanho + 2}' + sheet[stringObras] = dfMerged.loc[dfMerged['NomeRubrica'] == 'Obras e Instalações', 'VALOR_TOTAL_PERIODO'].values[0] + #Ate o momento + stringObras = f'G{stringTamanho + 2}' + sheet[stringObras] = dfMerged.loc[dfMerged['NomeRubrica'] == 'Obras e Instalações', 'VALOR_TOTAL_DATA'].values[0] + + string_exists = dfMerged['NomeRubrica'].isin(["Equipamentos e Material Permanente"]).any() + if string_exists: + #Materiais Equipamentos e Material Permanente + stringObras = f'B{stringTamanho + 3}' + sheet[stringObras] = dfMerged.loc[dfMerged['NomeRubrica'] == 'Equipamentos e Material Permanente', 'VALOR_TOTAL_PREVISTO'].values[0] + stringObras = f'F{stringTamanho + 3}' + sheet[stringObras] = dfMerged.loc[dfMerged['NomeRubrica'] == 'Equipamentos e Material Permanente', 'VALOR_TOTAL_PREVISTO'].values[0] + #periodo + stringObras = f'C{stringTamanho + 3}' + sheet[stringObras] = dfMerged.loc[dfMerged['NomeRubrica'] == 'Equipamentos e Material Permanente', 'VALOR_TOTAL_PERIODO'].values[0] + #Ate o momento + stringObras = f'G{stringTamanho + 3}' + sheet[stringObras] = dfMerged.loc[dfMerged['NomeRubrica'] == 'Equipamentos e Material Permanente', 'VALOR_TOTAL_DATA'].values[0] + + #Materiais Equipamentos e Material nACIONAL + string_exists = dfMerged['NomeRubrica'].isin(["Material Permanente e Equipamento Nacional"]).any() + if string_exists: + stringObras = f'B{stringTamanho + 4}' + sheet[stringObras] = dfMerged.loc[dfMerged['NomeRubrica'] == 'Material Permanente e Equipamento Nacional', 'VALOR_TOTAL_PREVISTO'].values[0] + stringObras = f'F{stringTamanho + 4}' + sheet[stringObras] = dfMerged.loc[dfMerged['NomeRubrica'] == 'Material Permanente e Equipamento Nacional', 'VALOR_TOTAL_PREVISTO'].values[0] + #periodo + stringObras = f'C{stringTamanho + 4}' + sheet[stringObras] = dfMerged.loc[dfMerged['NomeRubrica'] == 'Material Permanente e Equipamento Nacional', 'VALOR_TOTAL_PERIODO'].values[0] + #Ate o momento + stringObras = f'G{stringTamanho + 4}' + sheet[stringObras] = dfMerged.loc[dfMerged['NomeRubrica'] == 'Material Permanente e Equipamento Nacional', 'VALOR_TOTAL_DATA'].values[0] + + #Materiais Equipamentos e Material iMPORTADO + string_exists = dfMerged['NomeRubrica'].isin(["Material Permanente e Equipamento Importado"]).any() + if string_exists: + stringObras = f'B{stringTamanho + 5}' + sheet[stringObras] = dfMerged.loc[dfMerged['NomeRubrica'] == 'Material Permanente e Equipamento Importado', 'VALOR_TOTAL_PREVISTO'].values[0] + stringObras = f'F{stringTamanho + 5}' + sheet[stringObras] = dfMerged.loc[dfMerged['NomeRubrica'] == 'Material Permanente e Equipamento Importado', 'VALOR_TOTAL_PREVISTO'].values[0] + #periodo + stringObras = f'C{stringTamanho + 5}' + sheet[stringObras] = dfMerged.loc[dfMerged['NomeRubrica'] == 'Material Permanente e Equipamento Importado', 'VALOR_TOTAL_PERIODO'].values[0] + #Ate o momento + stringObras = f'G{stringTamanho + 5}' + sheet[stringObras] = dfMerged.loc[dfMerged['NomeRubrica'] == 'Material Permanente e Equipamento Importado', 'VALOR_TOTAL_DATA'].values[0] + + dfSoma = consultaRendimentosIRRF(codigo,data1,data2) + dfRendimentoAteOPeriodo = consultaRendimentosTodosAteOPeriodo(codigo,data2) + + Soma = dfSoma["Aplicação"] + dfSoma["IRRF"] + all_null = Soma.isnull().all() + + if all_null != True : + + if len(Soma) == 1: + result = Soma.iloc[0] + else: + result = Soma.iloc[0] - Soma.iloc[1] + stringObras = f'B{stringTamanho + 9}' + sheet[stringObras] = result + + SomaRendimentoAteoperido = dfRendimentoAteOPeriodo["Aplicação"] + dfRendimentoAteOPeriodo["IRRF"] + resultado = SomaRendimentoAteoperido.iloc[0] - SomaRendimentoAteoperido.iloc[1] + stringObras = f'F{stringTamanho + 9}' + sheet[stringObras] = resultado + + + + + #remover essas linhas da tabela + values_to_remove = ["Receitas", "Rendimentos de Aplicações Financeiras", "Despesas Financeiras",'Material Permanente e Equipamento Nacional','Material Permanente e Equipamento Importado','Devolução de Recursos','Obras e Instalações','Equipamentos e Material Permanente'] + + + + # Use boolean indexing to drop rows based on the values in the first column + dfMerged = dfMerged[~dfMerged['NomeRubrica'].isin(values_to_remove)] + + + + # string_exists = dfMerged['NomeRubrica'].isin(["Despesas Operacionais e Administrativas - Finatec"]).any() + # if string_exists: + # # Extract the row for "Despesas Operacionais e Administrativas - Finatec" + # row_to_add = dfMerged.loc[dfMerged['NomeRubrica'] == 'Despesas Operacionais e Administrativas - Finatec'].iloc[0] + + + # stringDOA_exists = dfMerged['NomeRubrica'].isin(["Despesas Operacionais e Administrativas - Finatec"]).any() + # if stringDOA_exists: + # string_exists = dfMerged['NomeRubrica'].isin(["Outros Serviços de Terceiros - Pessoa Jurídica "]).any() + # string_exists2 = dfMerged['NomeRubrica'].isin(["Serviços de Terceiros Pessoa Jurídica"]).any() + # if string_exists or string_exists2: + # if string_exists: + # # Find the index of "Outros Serviços de Terceiros - Pessoa Jurídica" + # index_to_update = dfMerged.loc[dfMerged['NomeRubrica'] == 'Outros Serviços de Terceiros - Pessoa Jurídica '].index[0] + + # # Update the values in "Outros Serviços de Terceiros - Pessoa Jurídica" row with the values from "Despesas Operacionais e Administrativas - Finatec" + # dfMerged.iloc[index_to_update] += row_to_add + + # # Drop the row for "Despesas Operacionais e Administrativas - Finatec" + # dfMerged = dfMerged[dfMerged['NomeRubrica'] != 'Despesas Operacionais e Administrativas - Finatec'] + # if string_exists2: + # # Find the index of "Outros Serviços de Terceiros - Pessoa Jurídica" + # index_to_update = dfMerged.loc[dfMerged['NomeRubrica'] == "Serviços de Terceiros Pessoa Jurídica"].index[0] + + # # Update the values in "Outros Serviços de Terceiros - Pessoa Jurídica" row with the values from "Despesas Operacionais e Administrativas - Finatec" + # dfMerged.iloc[index_to_update] += row_to_add + + # # Drop the row for "Despesas Operacionais e Administrativas - Finatec" + # dfMerged = dfMerged[dfMerged['NomeRubrica'] != 'Despesas Operacionais e Administrativas - Finatec'] + + string_exists = dfMerged['NomeRubrica'].isin(["Despesas Operacionais e Administrativas - Finatec"]).any() + if string_exists: + # Extract the value from "Despesas Operacionais e Administrativas - Finatec" + value_to_add = dfMerged.loc[dfMerged['NomeRubrica'] == 'Despesas Operacionais e Administrativas - Finatec'].iloc[0] + + string_exists = dfMerged['NomeRubrica'].isin(["Outros Serviços de Terceiros - Pessoa Jurídica "]).any() + string_exists2 = dfMerged['NomeRubrica'].isin(["Serviços de Terceiros Pessoa Jurídica"]).any() + string_exists3 = dfMerged['NomeRubrica'].isin(["Outros Serviços de Terceiros - Pessoa Jurídica"]).any() + + if string_exists or string_exists2 or string_exists3: + if string_exists: + + # Find the index of "Outros Serviços de Terceiros - Pessoa Jurídica" + + #index_to_update = dfMerged.loc[dfMerged['NomeRubrica'] == 'Outros Serviços de Terceiros - Pessoa Jurídica '].index[0] + + # Add the value to "Outros Serviços de Terceiros - Pessoa Jurídica" + + dfMerged.loc[dfMerged['NomeRubrica'] == 'Outros Serviços de Terceiros - Pessoa Jurídica '] += value_to_add + + # Drop the row for "Despesas Operacionais e Administrativas - Finatec" + dfMerged = dfMerged[dfMerged['NomeRubrica'] != 'Despesas Operacionais e Administrativas - Finatec'] + + if string_exists2: + + # Find the index of "Outros Serviços de Terceiros - Pessoa Jurídica" + #index_to_update = dfMerged.loc[dfMerged['NomeRubrica'] == 'Serviços de Terceiros Pessoa Jurídica'].index[0] + + # Add the value to "Outros Serviços de Terceiros - Pessoa Jurídica" + dfMerged.loc[dfMerged['NomeRubrica'] == 'Serviços de Terceiros Pessoa Jurídica'] += value_to_add + + # Drop the row for "Despesas Operacionais e Administrativas - Finatec" + dfMerged = dfMerged[dfMerged['NomeRubrica'] != 'Despesas Operacionais e Administrativas - Finatec'] + if string_exists3: + # Find the index of "Outros Serviços de Terceiros - Pessoa Jurídica" + + index_to_update = dfMerged.loc[dfMerged['NomeRubrica'] == 'Outros Serviços de Terceiros - Pessoa Jurídica'].index[0] + + # Add the value to "Outros Serviços de Terceiros - Pessoa Jurídica" + dfMerged.iloc[index_to_update] += value_to_add + + # Drop the row for "Despesas Operacionais e Administrativas - Finatec" + dfMerged = dfMerged[dfMerged['NomeRubrica'] != 'Despesas Operacionais e Administrativas - Finatec'] + + + + + for row_num, row_data in enumerate(dfMerged.itertuples(index = False), start=16):#inicio linha + for col_num, value in enumerate(row_data, start=1):#inicio coluna + if col_num == 2: + sheet.cell(row=row_num, column=col_num, value=convert_datetime_to_string(value)) + col_num = 6 + sheet.cell(row=row_num, column=col_num, value=convert_datetime_to_string(value)) + col_num=2 + + if col_num == 4: + col_num = 7 + sheet.cell(row=row_num, column=col_num, value=convert_datetime_to_string(value)) + + + + + + + workbook.save(planilha) + workbook.close() + return tamanho,dfComPeriodo + +def planilhaGeral(planilha,codigo,data1,data2): + tabela = pegar_caminho(planilha) + workbook = openpyxl.load_workbook(tabela) + sheet2 = workbook.create_sheet(title="PlanilhaGeral") + workbook.save(tabela) + workbook.close() + + dfconsultaDadosPorRubrica = consultaTabelaGigante(codigo,data1,data2) + + tamanho = len(dfconsultaDadosPorRubrica) + + + + tabela = pegar_caminho(planilha) + workbook = openpyxl.load_workbook(tabela) + sheet2 = workbook['PlanilhaGeral'] + + #print(dfconsultaDadosPorRubrica.columns.values.tolist()) + + + linha = [ + "Nº Pedido", #1 + "Tipo do Pedido",#2 + "Histórico", #3 + "Rubrica", #4 + "Valor", #5 + "Tipo", #6 + "Data Lançamento",#7 + "Data Vencimento", #8 + "Data Pagamento", #9 + "Valor Pago", #10 + "Nº Autenticação Bancária", #11 + "Nº Documento Bancário", #12 + "Data Emissao NF", #13 + "Doc. Pago", #14 + "Cód. Projeto", #15 + "Projeto", #16 + "Agência", #17 + "Conta", #18 + "Empresa / Pessoa / Projeto",#19 + "CPF/CNPJ", #20 + "Gestor", #21 + "Tipo do Lançamento", #22 + "Situação",#23 + "Nota Fiscal",#24 + "Nº Pedido",#24 + ] + + sheet2.append(linha) + #formatar as linhas + cinza = "f1f1f1" + variavel_site = f'http://automatec.finatec.org.br/' + #variavel_site = f'http://127.0.0.1:2778/' + for column in range(ord('A'), ord('Z')+1): + column_letter = chr(column) + sheet2.column_dimensions[column_letter].width = 25 + #estilo + for row in sheet2.iter_rows(min_row=1, max_row=len(dfconsultaDadosPorRubrica)+2, min_col=1, max_col= 25): + for cell in row: + if cell.row == 1: + cell.fill = PatternFill(start_color=cinza, end_color=cinza, + fill_type = "solid") + cell.font = Font(name="Arial", size=12, color="000000",bold = True) + cell.alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + sheet2.row_dimensions[cell.row].height = 60 + else: + cell.font = Font(name="Arial", size=12, color="000000",bold = True) + cell.alignment = Alignment(horizontal="center",vertical="center",wrap_text=True) + sheet2.row_dimensions[cell.row].height = 60 + # #botão imprime tudo + # sheet2['X2'] = f'{variavel_site}download-todos-arquivos/{codigo}_{data1}_{data2}/' + # hyperlink_url = f'{variavel_site}download-todos-arquivos/{codigo}_{data1}_{data2}/' + # sheet2['X2'].font = Font(name="Arial", size=12, color="0000EE",bold=True) + # sheet2['X2'].hyperlink = hyperlink_url + #printar resultados + for row_num, row_data in enumerate(dfconsultaDadosPorRubrica.itertuples(index=False), start=2):#inicio linha + for col_num, value in enumerate(row_data, start=1):#inicio coluna + value = convert_datetime_to_stringdt(value) + if col_num == 24: + vetorConsulta = consultaNotasFub(value) + third_element = vetorConsulta[0][1] # 0 indexes the first tuple, 2 indexes the third element in the tuple + # print(type(consultaNotasFub(value))) + if vetorConsulta[0][2] is not None: + hyperlink_url = f'{variavel_site}notas/{value}/' + #print(third_element) # This will print: None + value = hyperlink_url + sheet2.cell(row=row_num, column=col_num, value=value).font = Font(name="Arial", size=12, color="0000EE",bold=True) + sheet2.cell(row=row_num, column=col_num).hyperlink = hyperlink_url + else: + #print(value) + #value = f'{value}' + # nota = acharRecibo("hemanoel.brito","z>hd]3\p*2o4",value) + # string_with_substring = nota + # substring_to_remove = "data:application/pdf;base64," + # # Remove the substring + # result_string = string_with_substring.replace(substring_to_remove, "") + + #print(result_string) + + #print(nota) + # if row_data + hyperlink_url = f'{variavel_site}recibos/{value}/' + value = hyperlink_url + sheet2.cell(row=row_num, column=col_num, value=value).font = Font(name="Arial", size=12, color="0000EE",bold=True) + sheet2.cell(row=row_num, column=col_num).hyperlink = hyperlink_url + + else: + sheet2.cell(row=row_num, column=col_num, value=value) + # dfconsultaDadosPorRubricaComEstorno.index = dfconsultaDadosPorRubricaComEstorno.index + 1 + + + + + + + workbook.save(tabela) + workbook.close() + + +def preencheFub(codigo,data1,data2,tabela): + '''Preencher fub legado + dadoRubrica = transforma em dicionario a consulta feita por sql e separa por rubricas. + variaveisResumo= preenchimento da tabela Exec, são definidas em tres tipos: + -variavelResumoComPeriodo = consulta no sql com datas1 e data2 + -variavelResumoComPeriodo = consulta no sql ate o periodo da data2 + -variavelResumoComPeriodo = consulta no sql com valor total previsto + execReceitaDespesa = preenche a sheet Exec.Receita e Despesa da planilha, + e retorna 3 argumentos: + -tamanho = o tamanho necessario para fazer o estilo, ele varia de acordo + com a quantidade de rubricas + -dictPraCalcularTamanho = o dicionario utilizado para calcular o tamanho, ele + contem a rubricas utilizadas no projeto para poder preencher a sheet ReceitaxDespesa + -merged_dict = dicionario que contem todas as rubricas inclusive equipamento e + material permanente, utilizado para colocar esses valores na ReceitaxDespesa + + + Argumentos: + codigo = CodConvenio na tabela nova, corresponde ao codigo do projeto + DATA1 = Data Inicial Selecinado pelo Usuario + DATA2 = Data Final Selecionado pelo Usuario + KEYS = Lista responsavel por filtrar no dicionario quais dados irão ser preenchidos nas + planilhas, exemplo cpf,data etc + tabela = tabela a ser preenchida extensão xlsx + + + ''' + planilhaGeral(tabela,codigo,data1,data2) + tamanho,dataframe = ExeReceitaDespesa(tabela,codigo,data1,data2,15) + tamanhoPosicaoBrasilia,dfReceitas,dfDemonstrativoReceitas = Receita(tabela,codigo,data1,data2,tamanho,dataframe) + demonstrativo(codigo,data1,data2,tabela,tamanhoPosicaoBrasilia,dfDemonstrativoReceitas,dfReceitas) + rubricaGeral(codigo,data1,data2,tabela,tamanhoPosicaoBrasilia) + conciliacaoBancaria(codigo,data1,data2,tabela,tamanhoPosicaoBrasilia) + rowRendimento= rendimentoDeAplicacao(codigo,data1,data2,tabela,tamanhoPosicaoBrasilia) + relacaodeBens(codigo,data1,data2,tabela,tamanhoPosicaoBrasilia) + + + diff --git a/project/app/preenche_fundep.py b/project/app/preencheFundep.py old mode 100644 new mode 100755 similarity index 64% rename from project/app/preenche_fundep.py rename to project/app/preencheFundep.py index 302b7a31..02af53c4 --- a/project/app/preenche_fundep.py +++ b/project/app/preencheFundep.py @@ -1,9 +1,9 @@ -import oracledb +import pyodbc from datetime import datetime,date import openpyxl import os from .estilo_fundep import estilo_fundep -from .oracle_cruds import consultaPorID +from .preencheFub import planilhaGeral from openpyxl.styles import Font,Alignment def check_format(time_data, format='%Y-%m-%d'): try: @@ -33,36 +33,78 @@ def convert_datetime_to_string(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######################################### CANCELADO -def pessoa_fisica(codigo,data1,data2,keys,planilha): - tabela = pegar_caminho(planilha) - nomeTabela ="Outros Serviços Terceiros - PF" - tituloStyle = "pessoaFisica" - workbook = openpyxl.load_workbook(tabela) - sheet2 = workbook.create_sheet(title="Outros Serviços Terceiros - PF") - 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['Outros Serviços Terceiros - PF'] - - 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() - - - -def pessoaFisica(codigo,data1,data2,keys,planilha): - - tabela = pegar_caminho(planilha) - nomeTabela ="Outros Serviços Terceiros - PF" - tituloStyle = "pessoaFisica" - workbook = openpyxl.load_workbook(tabela) - sheet2 = workbook.create_sheet(title="Outros Serviços Terceiros - PF") - workbook.save(tabela) - workbook.close() - categorized_data= separarporrubrica(codigo,data1,data2) - - tamanho = [] - - if 87 in categorized_data and 25 in categorized_data: - categorized_data[87].extend(categorized_data[25]) - elif 87 not in categorized_data and 25 in categorized_data: - categorized_data[87] = categorized_data[25] - 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 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(maior) - 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['Outros Serviços Terceiros - PF'] - - 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#########################################CANCELADO -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#########################################CANCELADO -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['Serv. Terceiro CLT'] - - 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) - pessoaFisica(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/preencherFinep.py b/project/app/preencherFinep.py new file mode 100644 index 00000000..c1ae9d43 --- /dev/null +++ b/project/app/preencherFinep.py @@ -0,0 +1,1567 @@ +import pyodbc +from datetime import datetime,date +import openpyxl +from openpyxl.styles import Font +import os +from collections import defaultdict +from .estiloFINEP import * +from .preencheFub import planilhaGeral,consultaNomeRubricaCodRubrica,consultaID,convert_datetime_to_string,convert_datetime_to_stringdt,formatar_data,formatarDataSemDia,formatar_cpf,check_format,pegar_caminho,pegar_pass +import pandas as pd +from sqlalchemy import create_engine +from sqlalchemy.engine import URL +import numpy as np +from openpyxl.cell.cell import ILLEGAL_CHARACTERS_RE +import re + + + +#consulta + +#ok +def consultaRelatorioExecFinanceiraA1(IDPROJETO, DATA1, DATA2): + ''' Consulta que busca os valores executado no periodo, e os valores que foram executados até no periodo + Argumentos + IDPROJETO = CodConvenio na tabela nova, corresponde ao codigo do projeto + DATA1 = Data Inicial Selecinado pelo Usuario + DATA2 = Data Final Selecionado pelo Usuario + ''' + file_path = pegar_pass("passs.txt") + conStr = '' + with open(file_path, 'r') as file: + conStr = file.readline().strip() + + connection_url = URL.create("mssql+pyodbc", query={"odbc_connect": conStr}) + engine = create_engine(connection_url) + parametros = [(IDPROJETO, DATA1, DATA2)] + parametros2 = [(IDPROJETO, DATA2)] + parametros3 = IDPROJETO + consultaComPeriodo =f"SELECT NomeRubrica, SUM(ValorPago) AS VALOR_TOTAL_PERIODO FROM [Conveniar].[dbo].[LisLancamentoConvenio] WHERE CodConvenio = ? AND CodStatus = 27 AND DataPagamento BETWEEN ? AND ? GROUP BY NomeRubrica, CodRubrica Order by CodRubrica" + consultaAteAData = f"SELECT NomeRubrica, SUM(ValorPago) AS VALOR_TOTAL_DATA FROM [Conveniar].[dbo].[LisLancamentoConvenio] WHERE CodConvenio = ? AND CodStatus = 27 AND DataPagamento <= ? GROUP BY NomeRubrica, CodRubrica Order by CodRubrica " + #consultaPrevisto = f"SELECT NomeRubrica, SUM(VALOR*Quantidade) AS VALOR_TOTAL_PREVISTO FROM [Conveniar].[dbo].[LisConvenioItemAprovado] WHERE CodConvenio = ? GROUP BY NomeRubrica, CodRubrica Order by CodRubrica" + + dfComPeriodo= pd.read_sql(consultaComPeriodo, engine, params=parametros) + dfAteAData = pd.read_sql(consultaAteAData, engine, params=parametros2) + #dfPrevisto = pd.read_sql(consultaPrevisto, engine, params=(IDPROJETO,)) + + return dfComPeriodo,dfAteAData +#ok +def consultaDemonstrativoReceitaEDespesaA2(IDPROJETO,DATA1,DATA2): + ''' Função que vai pega os dados da Rubrica 9 Despesas Financeiras e transformalos em dataframe + para poder popular a databela Despesas Financeiras + Argumentos + IDPROJETO = CodConvenio na tabela nova, corresponde ao codigo do projeto + DATA1 = Data Inicial Selecinado pelo Usuario + DATA2 = Data Final Selecionado pelo Usuario + ''' + file_path = pegar_pass("passs.txt") + conStr = '' + with open(file_path, 'r') as file: + conStr = file.readline().strip() + + connection_url = URL.create("mssql+pyodbc", query={"odbc_connect": conStr}) + engine = create_engine(connection_url) + parametros = [(IDPROJETO, DATA1, DATA2)] + parametros2 = [(IDPROJETO, DATA1)] + parametros4 = [(IDPROJETO, DATA2)] + parametros3 = IDPROJETO + consultaComPeriodo =f"SELECT NomeRubrica, SUM(ValorPago) AS VALOR_TOTAL_PERIODO FROM [Conveniar].[dbo].[LisLancamentoConvenio] WHERE CodConvenio = ? AND CodStatus = 27 AND DataPagamento BETWEEN ? AND ? GROUP BY NomeRubrica, CodRubrica Order by CodRubrica" + consultaAteAData = f"SELECT NomeRubrica, SUM(ValorPago) AS VALOR_TOTAL_DATA FROM [Conveniar].[dbo].[LisLancamentoConvenio] WHERE CodConvenio = ? AND CodStatus = 27 AND DataPagamento <= ? GROUP BY NomeRubrica, CodRubrica Order by CodRubrica " + + consultaPrevisto = f"SELECT NomeRubrica, SUM(VALOR*Quantidade) AS VALOR_TOTAL_PREVISTO FROM [Conveniar].[dbo].[LisConvenioItemAprovado] WHERE CodConvenio = ? GROUP BY NomeRubrica, CodRubrica Order by CodRubrica" + consultaRubricaRecursoRecebidos = f"SELECT sum(ValorPago) AS VALOR_TOTAL_DATA FROM [Conveniar].[dbo].[LisLancamentoConvenio] WHERE CodConvenio = ? AND CodStatus = 27 AND DataPagamento <= ? " + consultaRendimentoAplicacao = f""" + SELECT + NomeTipoLancamento, + --SUM(CASE WHEN NomeTipoLancamento = 'IRRF Pessoa Jurídica' THEN ValorPago ELSE 0 END) AS IRRF, + SUM(CASE WHEN NomeTipoLancamento = 'Aplicação Financeira' THEN ValorPago ELSE 0 END) AS Aplicação + FROM + [Conveniar].[dbo].[LisLancamentoConvenio] + WHERE + CodConvenio = ? + AND CodStatus = 27 + AND CodRubrica = 3 + AND DataPagamento BETWEEN ? AND ? + GROUP BY + NomeTipoLancamento; + """ + + + + + Soma = pd.read_sql(consultaRendimentoAplicacao, engine, params=parametros) + dfComPeriodo= pd.read_sql(consultaComPeriodo, engine, params=parametros) + dfAteAData = pd.read_sql(consultaAteAData, engine, params=parametros2) + dfPrevisto = pd.read_sql(consultaPrevisto, engine, params=(IDPROJETO,)) + dfRubricaRecursoRecebidos = pd.read_sql(consultaRubricaRecursoRecebidos, engine, params=parametros4) + + + + return dfComPeriodo,dfAteAData,dfPrevisto,dfRubricaRecursoRecebidos,Soma +#ok +def consultaPagamentoPessoal(IDPROJETO,DATA1,DATA2): + + ''' Consulta dinamica do SQL relacionado a rubrica correspondente,cada pagina tem sua própria consulta correspondente a rubrica + Argumentos + IDPROJETO = CodConvenio na tabela nova, corresponde ao codigo do projeto + DATA1 = Data Inicial Selecinado pelo Usuario + DATA2 = Data Final Selecionado pelo Usuario + codigoRubrica = código da rubrica + ''' + codigoRubrica = 87 + file_path = pegar_pass("passs.txt") + conStr = '' + with open(file_path, 'r') as file: + conStr = file.readline().strip() + + connection_url = URL.create("mssql+pyodbc", query={"odbc_connect": conStr}) + engine = create_engine(connection_url) + parametros = [(IDPROJETO, DATA1, DATA2)] + parametrosComRubricaEstorno = [(IDPROJETO, DATA1, DATA2,IDPROJETO,DATA1, DATA2)] + parametrosPJ=[(IDPROJETO, DATA1, DATA2)] + parametrosPJestorno=[(IDPROJETO, DATA1, DATA2,IDPROJETO, DATA1, DATA2)] + queryConsultaComRubrica = f"""SELECT NomeFavorecido, + CASE WHEN LEN(FavorecidoCPFCNPJ) > 11 THEN STUFF(STUFF(STUFF(STUFF(FavorecidoCPFCNPJ, 3, 0, '.'), 7, 0, '.'), 11, 0, '/'), 16, 0, '-') + WHEN LEN(FavorecidoCPFCNPJ) = 11 THEN STUFF(STUFF(STUFF(FavorecidoCPFCNPJ, 4, 0, '.'), 8, 0, '.'), 12, 0, '-') ELSE FavorecidoCPFCNPJ END AS FormattedFavorecidoCPFCNPJ, + NomeTipoLancamento, + [LisConvenioItemAprovado].[DescConvenioItemAprovado], + NumDocPago, + DataEmissao, + NumChequeDeposito, + DataPagamento, + ValorPago + FROM [Conveniar].[dbo].[LisLancamentoConvenio] + LEFT JOIN [Conveniar].[dbo].[PlanoTrabalhoLancamento] ON [LisLancamentoConvenio].[CodLancamento] = [PlanoTrabalhoLancamento].[CodLancamentoGerado] + LEFT JOIN [Conveniar].[dbo].[LisConvenioItemAprovado] ON [PlanoTrabalhoLancamento].[CodConvenioItemAprovado] = [LisConvenioItemAprovado].[CodConvenioItemAprovado] + WHERE [LisLancamentoConvenio].CodConvenio = ? + AND [LisLancamentoConvenio].CodStatus = 27 + AND [LisLancamentoConvenio].DataPagamento BETWEEN ? AND ? + AND LOWER([LisLancamentoConvenio].HisLancamento) NOT LIKE '%estorno%' + and [LisLancamentoConvenio].CodRubrica = 87 order by DataPagamento""" + + #SEMPRE TEM Q ADICIONAR DUAS COLUNAS DEPOIS + queryConsultaComRubricaEstorno = f"""SELECT NomeFavorecido + ,CASE WHEN LEN(FavorecidoCPFCNPJ) > 11 THEN STUFF(STUFF(STUFF(STUFF(FavorecidoCPFCNPJ, 3, 0, '.'), 7, 0, '.'), 11, 0, '/'), 16, 0, '-') + WHEN LEN(FavorecidoCPFCNPJ) = 11 THEN STUFF(STUFF(STUFF(FavorecidoCPFCNPJ, 4, 0, '.'), 8, 0, '.'), 12, 0, '-') ELSE FavorecidoCPFCNPJ END AS FormattedFavorecidoCPFCNPJ, + NomeTipoLancamento, + HisLancamento, + NumChequeDeposito, + DataPagamento, + ValorPago FROM [Conveniar].[dbo].[LisLancamentoConvenio] + LEFT JOIN [Conveniar].[dbo].[PlanoTrabalhoLancamento] ON [LisLancamentoConvenio].[CodLancamento] = [PlanoTrabalhoLancamento].[CodLancamentoGerado] + LEFT JOIN [Conveniar].[dbo].[LisConvenioItemAprovado] ON [PlanoTrabalhoLancamento].[CodConvenioItemAprovado] = [LisConvenioItemAprovado].[CodConvenioItemAprovado] + WHERE + [LisLancamentoConvenio].CodConvenio = ? + AND CodStatus = 27 + AND NomeTipoCreditoDebito = 'C' + AND DataPagamento BETWEEN ? AND ? + and [LisLancamentoConvenio].CodRubrica = 87 + OR + CodStatus = 27 + AND [LisLancamentoConvenio].CodConvenio = ? + AND DataPagamento BETWEEN ? AND ? + AND LOWER(HisLancamento) LIKE '%estorno%' + AND [LisLancamentoConvenio].CodRubrica = 87 + + order by DataPagamento """ + + + dfconsultaDadosPorRubrica = pd.read_sql(queryConsultaComRubrica, engine, params=parametros) + dfconsultaDadosPorRubricaComEstorno = pd.read_sql(queryConsultaComRubricaEstorno,engine, params=parametrosComRubricaEstorno) + + + + return dfconsultaDadosPorRubrica,dfconsultaDadosPorRubricaComEstorno +#ok +def consultaestiloElementoDeDespesa1415Diarias(IDPROJETO,DATA1,DATA2): + ''' Função que vai pega os dados da Rubrica 9 Despesas Financeiras e transformalos em dataframe + para poder popular a databela Despesas Financeiras + Argumentos + IDPROJETO = CodConvenio na tabela nova, corresponde ao codigo do projeto + DATA1 = Data Inicial Selecinado pelo Usuario + DATA2 = Data Final Selecionado pelo Usuario + ''' + file_path = pegar_pass("passs.txt") + conStr = '' + with open(file_path, 'r') as file: + conStr = file.readline().strip() + + connection_url = URL.create("mssql+pyodbc", query={"odbc_connect": conStr}) + engine = create_engine(connection_url) + + parametros = [(IDPROJETO, DATA1, DATA2)] + parametros2 = [(IDPROJETO, DATA1, DATA2,IDPROJETO, DATA1, DATA2)] + + queryConsultaSemEstorno = f""" + SELECT [LisPessoa].[NomePessoa], + + CASE WHEN LEN([LisPessoa].CPFCNPJ) > 11 THEN STUFF(STUFF(STUFF(STUFF([LisPessoa].CPFCNPJ, 3, 0, '.'), 7, 0, '.'), 11, 0, '/'), 16, 0, '-') + WHEN LEN([LisPessoa].CPFCNPJ) = 11 THEN STUFF(STUFF(STUFF([LisPessoa].CPFCNPJ, 4, 0, '.'), 8, 0, '.'), 12, 0, '-') ELSE [LisPessoa].CPFCNPJ END AS FormattedFavorecidoCPFCNPJ, + (SELECT TOP 1 [NomeCidadeOrigem] + FROM [Conveniar].[dbo].[LisPagamentoDiariaTrecho] + WHERE [LisPagamentoDiariaTrecho].CodPedido = [LisPagamentoDiaria].[CodPedido] + AND [NomeTipoDestino] = 'Saída') + ' - ' + + (SELECT TOP 1 [NomeCidadeDestino] + FROM [Conveniar].[dbo].[LisPagamentoDiariaTrecho] + WHERE [LisPagamentoDiariaTrecho].CodPedido = [LisPagamentoDiaria].[CodPedido] + AND [NomeTipoDestino] = 'Saída') + + + ' -> ' + + (SELECT TOP 1 [NomeCidadeOrigem] + FROM [Conveniar].[dbo].[LisPagamentoDiariaTrecho] + WHERE [LisPagamentoDiariaTrecho].CodPedido = [LisPagamentoDiaria].[CodPedido] + AND [NomeTipoDestino] = 'Chegada') + ' - ' + + (SELECT TOP 1 [NomeCidadeDestino] + FROM [Conveniar].[dbo].[LisPagamentoDiariaTrecho] + WHERE [LisPagamentoDiariaTrecho].CodPedido = [LisPagamentoDiaria].[CodPedido] + AND [NomeTipoDestino] = 'Chegada') AS Destino + + + ,[LisPagamentoDiaria].[QuantDiaria] + ,[LisPagamentoDiaria].[ObsPedido] + ,[LisConvenioItemAprovado].[DescConvenioItemAprovado] + ,[LisLancamentoConvenio]. NumDocPago + ,[LisLancamentoConvenio]. DataEmissao + ,[LisLancamentoConvenio].NumChequeDeposito + ,[LisLancamentoConvenio].DataPagamento + ,[LisLancamentoConvenio].ValorPago + FROM [Conveniar].[dbo].[LisLancamentoConvenio] + INNER JOIN [Conveniar].[dbo].[LisPagamentoDiaria] ON [LisLancamentoConvenio].[NumDocFinConvenio] = [LisPagamentoDiaria].[NumPedido] + INNER JOIN [Conveniar].[dbo].[LisPessoa] ON [LisPagamentoDiaria].[CodPessoaFavorecida] = [LisPessoa].[CodPessoa] + LEFT JOIN [Conveniar].[dbo].[PlanoTrabalhoLancamento] ON [LisLancamentoConvenio].[CodLancamento] = [PlanoTrabalhoLancamento].[CodLancamentoGerado] + LEFT JOIN [Conveniar].[dbo].[LisConvenioItemAprovado] ON [PlanoTrabalhoLancamento].[CodConvenioItemAprovado] = [LisConvenioItemAprovado].[CodConvenioItemAprovado] + + + WHERE LisLancamentoConvenio.CodConvenio = ? + AND LisLancamentoConvenio.CodStatus = 27 + AND LisLancamentoConvenio.DataPagamento BETWEEN ? AND ? + """ + + queryConsultaComEstorno = f""" + SELECT + [LisPessoa].[NomePessoa] + , + + CASE WHEN LEN([LisPessoa].CPFCNPJ) > 11 THEN STUFF(STUFF(STUFF(STUFF([LisPessoa].CPFCNPJ, 3, 0, '.'), 7, 0, '.'), 11, 0, '/'), 16, 0, '-') + WHEN LEN([LisPessoa].CPFCNPJ) = 11 THEN STUFF(STUFF(STUFF([LisPessoa].CPFCNPJ, 4, 0, '.'), 8, 0, '.'), 12, 0, '-') ELSE [LisPessoa].CPFCNPJ END AS FormattedFavorecidoCPFCNPJ, + (SELECT TOP 1 [NomeCidadeOrigem] + FROM [Conveniar].[dbo].[LisPagamentoDiariaTrecho] + WHERE [LisPagamentoDiariaTrecho].CodPedido = [LisPagamentoDiaria].[CodPedido] + AND [NomeTipoDestino] = 'Saída') + ' - ' + + (SELECT TOP 1 [NomeCidadeDestino] + FROM [Conveniar].[dbo].[LisPagamentoDiariaTrecho] + WHERE [LisPagamentoDiariaTrecho].CodPedido = [LisPagamentoDiaria].[CodPedido] + AND [NomeTipoDestino] = 'Saída') + + + ' -> ' + + (SELECT TOP 1 [NomeCidadeOrigem] + FROM [Conveniar].[dbo].[LisPagamentoDiariaTrecho] + WHERE [LisPagamentoDiariaTrecho].CodPedido = [LisPagamentoDiaria].[CodPedido] + AND [NomeTipoDestino] = 'Chegada') + ' - ' + + (SELECT TOP 1 [NomeCidadeDestino] + FROM [Conveniar].[dbo].[LisPagamentoDiariaTrecho] + WHERE [LisPagamentoDiariaTrecho].CodPedido = [LisPagamentoDiaria].[CodPedido] + AND [NomeTipoDestino] = 'Chegada') AS Destino + + + ,[LisPagamentoDiaria].[QuantDiaria] + ,[LisPagamentoDiaria].[ObsPedido] + ,[LisConvenioItemAprovado].[DescConvenioItemAprovado] + ,[LisLancamentoConvenio].NumChequeDeposito + ,[LisLancamentoConvenio]. NumDocPago + ,[LisLancamentoConvenio]. DataEmissao + ,[LisLancamentoConvenio].NumChequeDeposito + ,[LisLancamentoConvenio].DataPagamento + ,[LisLancamentoConvenio].ValorPago + FROM [Conveniar].[dbo].[LisLancamentoConvenio] + INNER JOIN [Conveniar].[dbo].[LisPagamentoDiaria] ON [LisLancamentoConvenio].[NumDocFinConvenio] = [LisPagamentoDiaria].[NumPedido] + INNER JOIN [Conveniar].[dbo].[LisPessoa] ON [LisPagamentoDiaria].[CodPessoaFavorecida] = [LisPessoa].[CodPessoa] + LEFT JOIN [Conveniar].[dbo].[PlanoTrabalhoLancamento] ON [LisLancamentoConvenio].[CodLancamento] = [PlanoTrabalhoLancamento].[CodLancamentoGerado] + LEFT JOIN [Conveniar].[dbo].[LisConvenioItemAprovado] ON [PlanoTrabalhoLancamento].[CodConvenioItemAprovado] = [LisConvenioItemAprovado].[CodConvenioItemAprovado] + + + WHERE [LisLancamentoConvenio].CodConvenio = ? + AND [LisLancamentoConvenio].[CodStatus] = 27 + AND NomeTipoCreditoDebito = 'C' + AND LisLancamentoConvenio.DataPagamento BETWEEN ? AND ? + or + [LisLancamentoConvenio].CodConvenio = ? + AND [LisLancamentoConvenio].[CodStatus] = 27 + AND LOWER(HisLancamento) LIKE '%estorno%' + AND LisLancamentoConvenio.DataPagamento BETWEEN ? AND ? + + + Order by LisLancamentoConvenio.DataPagamento""" + + + dfConsultaDiaria = pd.read_sql(queryConsultaSemEstorno, engine, params=parametros) + dfConsultaDiariaEstorno = pd.read_sql(queryConsultaComEstorno, engine, params=parametros2) + + + return dfConsultaDiaria ,dfConsultaDiariaEstorno +#ok +def consultaGeral30(IDPROJETO,DATA1,DATA2,codigoRubrica): + + ''' Consulta dinamica do SQL relacionado a rubrica correspondente,cada pagina tem sua própria consulta correspondente a rubrica + Argumentos + IDPROJETO = CodConvenio na tabela nova, corresponde ao codigo do projeto + DATA1 = Data Inicial Selecinado pelo Usuario + DATA2 = Data Final Selecionado pelo Usuario + codigoRubrica = código da rubrica + ''' + file_path = pegar_pass("passs.txt") + conStr = '' + with open(file_path, 'r') as file: + conStr = file.readline().strip() + + connection_url = URL.create("mssql+pyodbc", query={"odbc_connect": conStr}) + engine = create_engine(connection_url) + parametros = [(IDPROJETO, DATA1, DATA2,codigoRubrica)] + parametrosComRubricaEstorno = [(IDPROJETO, DATA1, DATA2,codigoRubrica,IDPROJETO,DATA1, DATA2,codigoRubrica,)] + parametrosPJ=[(IDPROJETO, DATA1, DATA2)] + parametrosPJestorno=[(IDPROJETO, DATA1, DATA2,IDPROJETO, DATA1, DATA2)] + + queryConsultaComRubrica = f"""SELECT NomeFavorecido, + CASE WHEN LEN(FavorecidoCPFCNPJ) > 11 THEN STUFF(STUFF(STUFF(STUFF(FavorecidoCPFCNPJ, 3, 0, '.'), 7, 0, '.'), 11, 0, '/'), 16, 0, '-') + WHEN LEN(FavorecidoCPFCNPJ) = 11 THEN STUFF(STUFF(STUFF(FavorecidoCPFCNPJ, 4, 0, '.'), 8, 0, '.'), 12, 0, '-') ELSE FavorecidoCPFCNPJ END AS FormattedFavorecidoCPFCNPJ, + [LisConvenioItemAprovado].[DescConvenioItemAprovado], + + NumDocPago, + DataEmissao, + NumChequeDeposito, + DataPagamento, + ValorPago + FROM [Conveniar].[dbo].[LisLancamentoConvenio] + LEFT JOIN [Conveniar].[dbo].[PlanoTrabalhoLancamento] ON [LisLancamentoConvenio].[CodLancamento] = [PlanoTrabalhoLancamento].[CodLancamentoGerado] + LEFT JOIN [Conveniar].[dbo].[LisConvenioItemAprovado] ON [PlanoTrabalhoLancamento].[CodConvenioItemAprovado] = [LisConvenioItemAprovado].[CodConvenioItemAprovado] + WHERE [LisLancamentoConvenio].CodConvenio = ? + AND [LisLancamentoConvenio].CodStatus = 27 + AND [LisLancamentoConvenio].DataPagamento BETWEEN ? AND ? + AND LOWER([LisLancamentoConvenio].HisLancamento) NOT LIKE '%estorno%' + and [LisLancamentoConvenio].CodRubrica = ? order by DataPagamento""" + + queryConsultaComRubricaEstorno = f"""SELECT NomeFavorecido + ,CASE WHEN LEN(FavorecidoCPFCNPJ) > 11 THEN STUFF(STUFF(STUFF(STUFF(FavorecidoCPFCNPJ, 3, 0, '.'), 7, 0, '.'), 11, 0, '/'), 16, 0, '-') + WHEN LEN(FavorecidoCPFCNPJ) = 11 THEN STUFF(STUFF(STUFF(FavorecidoCPFCNPJ, 4, 0, '.'), 8, 0, '.'), 12, 0, '-') ELSE FavorecidoCPFCNPJ END AS FormattedFavorecidoCPFCNPJ, + HisLancamento, + NumChequeDeposito, + DataPagamento, + ValorPago FROM [Conveniar].[dbo].[LisLancamentoConvenio] + LEFT JOIN [Conveniar].[dbo].[PlanoTrabalhoLancamento] ON [LisLancamentoConvenio].[CodLancamento] = [PlanoTrabalhoLancamento].[CodLancamentoGerado] + LEFT JOIN [Conveniar].[dbo].[LisConvenioItemAprovado] ON [PlanoTrabalhoLancamento].[CodConvenioItemAprovado] = [LisConvenioItemAprovado].[CodConvenioItemAprovado] + WHERE + [LisLancamentoConvenio].CodConvenio = ? + AND CodStatus = 27 + AND NomeTipoCreditoDebito = 'C' + AND DataPagamento BETWEEN ? AND ? + and [LisLancamentoConvenio].CodRubrica = ? + OR + CodStatus = 27 + AND [LisLancamentoConvenio].CodConvenio = ? + AND DataPagamento BETWEEN ? AND ? + AND LOWER(HisLancamento) LIKE '%estorno%' + AND [LisLancamentoConvenio].CodRubrica = ? + + order by DataPagamento """ + + queryConsultaPJDOA = f"""SELECT NomeFavorecido, + CASE WHEN LEN(FavorecidoCPFCNPJ) > 11 THEN STUFF(STUFF(STUFF(STUFF(FavorecidoCPFCNPJ, 3, 0, '.'), 7, 0, '.'), 11, 0, '/'), 16, 0, '-') + WHEN LEN(FavorecidoCPFCNPJ) = 11 THEN STUFF(STUFF(STUFF(FavorecidoCPFCNPJ, 4, 0, '.'), 8, 0, '.'), 12, 0, '-') ELSE FavorecidoCPFCNPJ END AS FormattedFavorecidoCPFCNPJ, + [LisConvenioItemAprovado].[DescConvenioItemAprovado], + + NumDocPago, + DataEmissao, + NumChequeDeposito, + DataPagamento, + ValorPago + FROM [Conveniar].[dbo].[LisLancamentoConvenio] + LEFT JOIN [Conveniar].[dbo].[PlanoTrabalhoLancamento] ON [LisLancamentoConvenio].[CodLancamento] = [PlanoTrabalhoLancamento].[CodLancamentoGerado] + LEFT JOIN [Conveniar].[dbo].[LisConvenioItemAprovado] ON [PlanoTrabalhoLancamento].[CodConvenioItemAprovado] = [LisConvenioItemAprovado].[CodConvenioItemAprovado] + WHERE [LisLancamentoConvenio].CodConvenio = ? + AND [LisLancamentoConvenio].CodStatus = 27 + AND [LisLancamentoConvenio].DataPagamento BETWEEN ? AND ? + AND LOWER([LisLancamentoConvenio].HisLancamento) NOT LIKE '%estorno%' + and [LisLancamentoConvenio].CodRubrica IN (57,75,26) order by DataPagamento""" + + queryConsultaPJDOAEstorno = f"""SELECT NomeFavorecido + ,CASE WHEN LEN(FavorecidoCPFCNPJ) > 11 THEN STUFF(STUFF(STUFF(STUFF(FavorecidoCPFCNPJ, 3, 0, '.'), 7, 0, '.'), 11, 0, '/'), 16, 0, '-') + WHEN LEN(FavorecidoCPFCNPJ) = 11 THEN STUFF(STUFF(STUFF(FavorecidoCPFCNPJ, 4, 0, '.'), 8, 0, '.'), 12, 0, '-') ELSE FavorecidoCPFCNPJ END AS FormattedFavorecidoCPFCNPJ, + HisLancamento, + NumChequeDeposito, + DataPagamento, + ValorPago FROM [Conveniar].[dbo].[LisLancamentoConvenio] + LEFT JOIN [Conveniar].[dbo].[PlanoTrabalhoLancamento] ON [LisLancamentoConvenio].[CodLancamento] = [PlanoTrabalhoLancamento].[CodLancamentoGerado] + LEFT JOIN [Conveniar].[dbo].[LisConvenioItemAprovado] ON [PlanoTrabalhoLancamento].[CodConvenioItemAprovado] = [LisConvenioItemAprovado].[CodConvenioItemAprovado] + WHERE + [LisLancamentoConvenio].CodConvenio = ? + AND CodStatus = 27 + AND NomeTipoCreditoDebito = 'C' + AND DataPagamento BETWEEN ? AND ? + and [LisLancamentoConvenio].CodRubrica IN (57,75,26) + OR + CodStatus = 27 + AND [LisLancamentoConvenio].CodConvenio = ? + AND DataPagamento BETWEEN ? AND ? + AND LOWER(HisLancamento) LIKE '%estorno%' + AND [LisLancamentoConvenio].CodRubrica IN (57,75,26) + + order by DataPagamento """ + + dfconsultaDadosPorRubrica = pd.read_sql(queryConsultaComRubrica, engine, params=parametros) + dfconsultaDadosPorRubricaComEstorno = pd.read_sql(queryConsultaComRubricaEstorno,engine, params=parametrosComRubricaEstorno) + dfPJDOA = pd.read_sql(queryConsultaPJDOA, engine, params=parametrosPJ) + dfPJDOAESTORNO = pd.read_sql(queryConsultaPJDOAEstorno,engine, params=parametrosPJestorno) + + return dfPJDOA,dfPJDOAESTORNO,dfconsultaDadosPorRubrica,dfconsultaDadosPorRubricaComEstorno +#ok +def consultaestiloElementoDeDespesa33PassagemEDespesa(IDPROJETO,DATA1,DATA2): + + ''' Consulta dinamica do SQL relacionado a rubrica correspondente,cada pagina tem sua própria consulta correspondente a rubrica + Argumentos + IDPROJETO = CodConvenio na tabela nova, corresponde ao codigo do projeto + DATA1 = Data Inicial Selecinado pelo Usuario + DATA2 = Data Final Selecionado pelo Usuario + codigoRubrica = código da rubrica + ''' + file_path = pegar_pass("passs.txt") + conStr = '' + with open(file_path, 'r') as file: + conStr = file.readline().strip() + + connection_url = URL.create("mssql+pyodbc", query={"odbc_connect": conStr}) + engine = create_engine(connection_url) + parametros = [(IDPROJETO, DATA1, DATA2)] + parametrosComRubricaEstorno = [(IDPROJETO, DATA1, DATA2,IDPROJETO,DATA1, DATA2,)] + + queryConsultaComRubrica = f"""SELECT NomeFavorecido, + CASE WHEN LEN(FavorecidoCPFCNPJ) > 11 THEN STUFF(STUFF(STUFF(STUFF(FavorecidoCPFCNPJ, 3, 0, '.'), 7, 0, '.'), 11, 0, '/'), 16, 0, '-') + WHEN LEN(FavorecidoCPFCNPJ) = 11 THEN STUFF(STUFF(STUFF(FavorecidoCPFCNPJ, 4, 0, '.'), 8, 0, '.'), 12, 0, '-') ELSE FavorecidoCPFCNPJ END AS FormattedFavorecidoCPFCNPJ, + [LisConvenioItemAprovado].[DescConvenioItemAprovado], + + NumDocPago, + DataEmissao, + NumChequeDeposito, + DataPagamento, + ValorPago + FROM [Conveniar].[dbo].[LisLancamentoConvenio] + LEFT JOIN [Conveniar].[dbo].[PlanoTrabalhoLancamento] ON [LisLancamentoConvenio].[CodLancamento] = [PlanoTrabalhoLancamento].[CodLancamentoGerado] + LEFT JOIN [Conveniar].[dbo].[LisConvenioItemAprovado] ON [PlanoTrabalhoLancamento].[CodConvenioItemAprovado] = [LisConvenioItemAprovado].[CodConvenioItemAprovado] + WHERE [LisLancamentoConvenio].CodConvenio = ? + AND [LisLancamentoConvenio].CodStatus = 27 + AND [LisLancamentoConvenio].DataPagamento BETWEEN ? AND ? + AND LOWER([LisLancamentoConvenio].HisLancamento) NOT LIKE '%estorno%' + and [LisLancamentoConvenio].CodRubrica in (20,78,52) order by [LisLancamentoConvenio].DataPagamento""" + + queryConsultaComRubricaEstorno = f"""SELECT NomeFavorecido + ,CASE WHEN LEN(FavorecidoCPFCNPJ) > 11 THEN STUFF(STUFF(STUFF(STUFF(FavorecidoCPFCNPJ, 3, 0, '.'), 7, 0, '.'), 11, 0, '/'), 16, 0, '-') + WHEN LEN(FavorecidoCPFCNPJ) = 11 THEN STUFF(STUFF(STUFF(FavorecidoCPFCNPJ, 4, 0, '.'), 8, 0, '.'), 12, 0, '-') ELSE FavorecidoCPFCNPJ END AS FormattedFavorecidoCPFCNPJ, + [LisConvenioItemAprovado].[DescConvenioItemAprovado], + NumChequeDeposito, + DataPagamento, + ValorPago + FROM [Conveniar].[dbo].[LisLancamentoConvenio] + LEFT JOIN [Conveniar].[dbo].[PlanoTrabalhoLancamento] ON [LisLancamentoConvenio].[CodLancamento] = [PlanoTrabalhoLancamento].[CodLancamentoGerado] + LEFT JOIN [Conveniar].[dbo].[LisConvenioItemAprovado] ON [PlanoTrabalhoLancamento].[CodConvenioItemAprovado] = [LisConvenioItemAprovado].[CodConvenioItemAprovado] + WHERE + [LisLancamentoConvenio].CodConvenio = ? + AND CodStatus = 27 + AND NomeTipoCreditoDebito = 'C' + AND DataPagamento BETWEEN ? AND ? + and [LisLancamentoConvenio].CodRubrica in (20,78,52) + OR + CodStatus = 27 + AND [LisLancamentoConvenio].CodConvenio = ? + AND DataPagamento BETWEEN ? AND ? + AND LOWER(HisLancamento) LIKE '%estorno%' + AND [LisLancamentoConvenio].CodRubrica in (20,78,52) + + order by [LisLancamentoConvenio].DataPagamento """ + + dfconsultaDadosPorRubrica = pd.read_sql(queryConsultaComRubrica, engine, params=parametros) + dfconsultaDadosPorRubricaComEstorno = pd.read_sql(queryConsultaComRubricaEstorno,engine, params=parametrosComRubricaEstorno) + + + return dfconsultaDadosPorRubrica,dfconsultaDadosPorRubricaComEstorno +#ok +def consultaBens(IDPROJETO,DATA1,DATA2): + ''' Função que vai pega os dados da Rubrica 9 Despesas Financeiras e transformalos em dataframe + para poder popular a databela Despesas Financeiras + Argumentos + IDPROJETO = CodConvenio na tabela nova, corresponde ao codigo do projeto + DATA1 = Data Inicial Selecinado pelo Usuario + DATA2 = Data Final Selecionado pelo Usuario + ''' + file_path = pegar_pass("passss.txt") + conStr = '' + with open(file_path, 'r') as file: + conStr = file.readline().strip() + + connection_url = URL.create("mssql+pyodbc", query={"odbc_connect": conStr}) + engine = create_engine(connection_url) + idprojetoComZero = f"0{IDPROJETO}" + parametros = [(IDPROJETO,idprojetoComZero, DATA1, DATA2)] + + queryConsultaComRubrica = f""" + SELECT [Descrição][descri], + [Patrimônio][patri], + CONVERT(varchar, [Data de Aquisição], 103) AS dataAqui, + [Nº Nota][nota], + [Localização][localiza] + ,[Descrição], + [Valor de Aquisição][valorAqui], + [Valor de Aquisição][valorAqui2], + [Responsável][responsavel] + FROM [SBO_FINATEC].[dbo].[VW_BENS_ADQUIRIDOS] + WHERE ([Cod Projeto] = ? or [Cod Projeto] = ? ) + AND [Status] = 'Imobilizado' + AND [Data de Aquisição] BETWEEN ? AND ? + Order by [Data de Aquisição]""" + dfConsultaBens = pd.read_sql(queryConsultaComRubrica, engine, params=parametros) + + + return dfConsultaBens +#ok +def consultaConciliacaoBancaria(IDPROJETO, DATA1, DATA2): + ''' Função que vai pega os dados da Rubrica 9 Despesas Financeiras e transformalos em dataframe + para poder popular a databela Despesas Financeiras + Argumentos + IDPROJETO = CodConvenio na tabela nova, corresponde ao codigo do projeto + DATA1 = Data Inicial Selecinado pelo Usuario + DATA2 = Data Final Selecionado pelo Usuario + ''' + file_path = pegar_pass("passs.txt") + conStr = '' + with open(file_path, 'r') as file: + conStr = file.readline().strip() + + connection_url = URL.create("mssql+pyodbc", query={"odbc_connect": conStr}) + engine = create_engine(connection_url) + parametros = [(IDPROJETO, DATA1, DATA2)] + parametros2 = [(IDPROJETO, DATA1, DATA2, IDPROJETO, DATA1, DATA2)] + #consultaSemEstorno = f"SELECT DISTINCT DataPagamento,ValorPago,NumChequeDeposito,HisLancamento FROM [Conveniar].[dbo].[LisLancamentoConvenio] WHERE CodConvenio = ? AND CodStatus = 27 AND CodRubrica = 9 AND DataPagamento BETWEEN ? AND ? AND LOWER(HisLancamento) NOT LIKE '%estorno%' order by DataPagamento" + #consultaComEstorno = f"SELECT DISTINCT DataPagamento,ValorPago,NumChequeDeposito,HisLancamento FROM [Conveniar].[dbo].[LisLancamentoConvenio] WHERE CodConvenio = ? AND CodStatus = 27 AND CodRubrica = 9 AND DataPagamento BETWEEN ? AND ? AND LOWER(HisLancamento) LIKE '%estorno%' order by DataPagamento" + + #consultaloucona assim por que precisa ser detalhado cada item na tabela + consultaSemEstorno = f""" + SELECT + [LisLancamentoConvenio].HisLancamento, + CONVERT(varchar, CAST([LisLancamentoConvenio].DataPagamento AS datetime), 103) AS FormattedDate, + [LisPagamentoDespesaConvenioAdministrativa].Valor + FROM [Conveniar].[dbo].[LisLancamentoConvenio] + INNER JOIN [Conveniar].[dbo].[LisDocumentoConvenio] ON [LisLancamentoConvenio].[CodDocFinConvenio] = [LisDocumentoConvenio].[CodDocFinConvenio] + INNER JOIN [Conveniar].[dbo].[DocFinConvPagDespesa] ON [LisDocumentoConvenio].[CodDocFinConvenio] = [DocFinConvPagDespesa].[CodDocFinConvenio] + INNER JOIN [Conveniar].[dbo].[LisPagamentoDespesaConvenio] ON [DocFinConvPagDespesa].[CodPedido] = [LisPagamentoDespesaConvenio].[CodPedido] + INNER JOIN [Conveniar].[dbo].[LisPagamentoDespesaConvenioAdministrativa] ON [LisPagamentoDespesaConvenio].CodDespesaConvenio = [LisPagamentoDespesaConvenioAdministrativa].CodDespesaConvenio + AND [LisPagamentoDespesaConvenio].CodConvenio = [LisPagamentoDespesaConvenioAdministrativa].CodConvenio + WHERE [LisLancamentoConvenio].CodConvenio = ? + AND [LisLancamentoConvenio].CodStatus = 27 + AND [LisLancamentoConvenio].CodRubrica = 9 + AND [LisLancamentoConvenio].DataPagamento BETWEEN ? AND ? + AND LOWER([LisLancamentoConvenio].HisLancamento) NOT LIKE '%estorno%' + order by [LisLancamentoConvenio].DataPagamento""" + + consultaComEstorno = f"""SELECT + HisLancamento , + CONVERT(varchar, CAST(DataPagamento AS datetime), 103) AS FormattedDate, + ValorPago + + FROM [Conveniar].[dbo].[LisLancamentoConvenio] + WHERE CodConvenio = ? + AND CodStatus = 27 + AND CodRubrica = 9 + AND DataPagamento BETWEEN ? AND ? + AND LOWER(HisLancamento) LIKE '%estorno%' + OR + CodConvenio = ? + AND CodStatus = 27 + AND CodRubrica = 9 + AND NomeTipoCreditoDebito = 'C' + AND DataPagamento BETWEEN ? AND ? + order by DataPagamento""" + + dfSemEstorno = pd.read_sql(consultaSemEstorno, engine, params=parametros) + dfComEstorno = pd.read_sql(consultaComEstorno, engine, params=parametros2) + + + return dfSemEstorno,dfComEstorno +#ok +def consultaRendimentosAplicacao(IDPROJETO,DATA1,DATA2): + file_path = pegar_pass("passs.txt") + conStr = '' + with open(file_path, 'r') as file: + conStr = file.readline().strip() + + connection_url = URL.create("mssql+pyodbc", query={"odbc_connect": conStr}) + engine = create_engine(connection_url) + parametros = [(IDPROJETO, DATA1, DATA2)] + consultaRendimentoAplicacao = f"SELECT DataPagamento,ValorPago FROM [Conveniar].[dbo].[LisLancamentoConvenio] WHERE CodConvenio = ? AND CodStatus = 27 AND CodRubrica = 3 and NomeTipoLancamento = 'Aplicação Financeira' AND DataPagamento BETWEEN ? AND ? order by DataPagamento" + dfConsultaRendimentoAplicacao = pd.read_sql(consultaRendimentoAplicacao, engine, params=parametros) + + consultaRendimentoEImposto = f"SELECT DataPagamento,ValorPago,NomeTipoLancamento FROM [Conveniar].[dbo].[LisLancamentoConvenio] WHERE CodConvenio = ? AND CodStatus = 27 AND CodRubrica = 3 and (NomeTipoLancamento = 'Aplicação Financeira' or NomeTipoLancamento = 'IRRF Pessoa Jurídica') AND DataPagamento BETWEEN ? AND ? order by DataPagamento" + dfConsultaRendimentoEImposto = pd.read_sql(consultaRendimentoEImposto, engine, params=parametros) + + consultaImposto = f"SELECT DataPagamento,ValorPago FROM [Conveniar].[dbo].[LisLancamentoConvenio] WHERE CodConvenio = ? AND CodStatus = 27 AND CodRubrica = 3 and NomeTipoLancamento = 'IRRF Pessoa Jurídica' AND DataPagamento BETWEEN ? AND ? order by DataPagamento" + dfConsultaImposto = pd.read_sql(consultaImposto, engine, params=parametros) + + + return dfConsultaRendimentoAplicacao,dfConsultaImposto,dfConsultaRendimentoEImposto + + + + +#preencher +#ok +def demostrativereceitaedepesaA2(codigo,data1,data2,planilha): + #carrega planilha e colocca o estilo e retorna a localização da row brasilia + tabela = pegar_caminho(planilha) + workbook = openpyxl.load_workbook(tabela) + sheet2 = workbook.create_sheet(title="DEMOSTR. RECEITA E DESPESA A.2") + workbook.save(tabela) + workbook.close() + #pega as 3 tabelas da o merge e retira o tamanho com base nas rubricas chaves que ja possuem um lugar no estilo + dfComPeriodo,dfAteAData,dfPrevisto,dfRubricaRecursoRecebidos,Soma=consultaDemonstrativoReceitaEDespesaA2(codigo,data1,data2) + merged_df = pd.merge(dfPrevisto, dfComPeriodo, on='NomeRubrica', how='outer') + dfMerged = pd.merge(merged_df,dfAteAData, on = 'NomeRubrica', how = 'outer') + tamanho = len(dfMerged)#tamanho para deixar dinamico para imprimir sa rubricas + string_exists = dfMerged['NomeRubrica'].isin(["Material Permanente e Equipamento Importado"]).any() + if string_exists: + tamanho = tamanho - 1 + string_exists = dfMerged['NomeRubrica'].isin(["Obras e Instalações"]).any() + if string_exists: + tamanho = tamanho - 1 + string_exists = dfMerged['NomeRubrica'].isin(["Equipamentos e Material Permanente"]).any() + if string_exists: + tamanho = tamanho - 1 + string_exists = dfMerged['NomeRubrica'].isin(["Material Permanente e Equipamento Nacional"]).any() + if string_exists: + tamanho = tamanho - 1 + string_exists = dfMerged['NomeRubrica'].isin(["Receitas"]).any() + if string_exists: + tamanho = tamanho - 1 + string_exists = dfMerged['NomeRubrica'].isin(["Rendimentos de Aplicações Financeiras"]).any() + if string_exists: + tamanho = tamanho - 1 + string_exists = dfMerged['NomeRubrica'].isin(["Despesas Financeiras"]).any() + if string_exists: + tamanho = tamanho - 1 + + + + rowBrasilia = estiloDEMOSTRRECEITEDESPESAA2(planilha,tamanho) + + #carregar planilha para preencher + caminho = pegar_caminho(planilha) + workbook = openpyxl.load_workbook(caminho) + sheet = workbook['DEMOSTR. RECEITA E DESPESA A.2'] + 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"de {output_date_str} a {output_date_str2}" + + consulta_coordenador = consultaID(codigo) + + # o quarenta significa pra achar o lugar do coordenador dinamicamente mais o valor do tamanho da quantidade de rubricas + tamanho_row_coordenador = tamanho + 40 + stringCoordenador= f'C{tamanho_row_coordenador}' # retorna lugar do coordanor + stringTamanhoCPF = f'C{tamanho_row_coordenador+2}' # retorna lugar do coordanor + sheet[stringCoordenador] = consulta_coordenador['NomePessoaResponsavel'] + sheet[stringTamanhoCPF] = formatar_cpf(consulta_coordenador['CPFCoordenador']) + string_convenio = f"Convênio nº: {consulta_coordenador['SubProcesso']}" + string_convenente= f"Fundação de Empreendimentos Científicos e Tecnológicos - FINATEC" + string_convenente_convenente= f"Convenente: " + string_fonte_recursos = f"Fonte de Recursos:" + string_participe = f"Partícipe (no caso de contrapartida):" + string_periodo_relatorio = f"Período Abrangido por este Relatório: " + stringPeriodoExececucao = f'Período de Execução do Convênio:' + # Convert 'DataAssinatura' to "dd/mm/YYYY" format + datetime_obj1 = consulta_coordenador['DataAssinatura'] + formatted_date1 = datetime_obj1.strftime("%d/%m/%Y") + + # Convert 'DataVigencia' to "dd/mm/YYYY" format + datetime_obj2 = consulta_coordenador['DataVigencia'] + formatted_date2 = datetime_obj2.strftime("%d/%m/%Y") + +# Create the string representing the period of execution + + string_periodo_convenio = f"de {formatted_date1} a {formatted_date2}" + sheet['A4'] = string_convenio + sheet['A5'] = string_convenente_convenente + sheet['A6'] = stringPeriodoExececucao + sheet['A7'] = string_periodo_relatorio + sheet['A8'] = string_fonte_recursos + sheet['A9'] = string_participe + + sheet['C5'] = string_convenente + sheet['C6'] = string_periodo_convenio + sheet['C7'] = string_periodo + sheet['C8'] = f'RECURSOS FINEP/RECURSOS CONTRAPARTIDA' + sheet['C9'] = F'XXX' + + + 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" + } + + stringTamanho = f'A{tamanho + 37}' # retorna lugar de brasilia + hoje = date.today() + data_formatada = f"{hoje.day} de {meses_dict[hoje.month]} de {hoje.year}" + sheet[stringTamanho] = f'Brasilia, {data_formatada}' + + + #começar o preenchimento com o dataframe + + + rowDespesasCapital = tamanho + 13 #vai ser o valro menos 1 para n bugar os codigos de tamanho abaixo + + #TOTAL DAS RECEITAS (B1+B2) + #B.1 + #periodo receitas + if dfMerged['NomeRubrica'].isin(["Receitas"]).any(): + stringReceitas = f'C{rowDespesasCapital + 11}' + sheet[stringReceitas] = dfMerged.loc[dfMerged['NomeRubrica'] == 'Receitas', 'VALOR_TOTAL_PERIODO'].values[0] + #Ate o perido anterior receitas + stringReceitas = f'B{rowDespesasCapital + 11}' + sheet[stringReceitas] = dfMerged.loc[dfMerged['NomeRubrica'] == 'Receitas', 'VALOR_TOTAL_PREVISTO'].values[0] + #B.2 + #periodo Rendimentos de Aplicações Financeiras + if dfMerged['NomeRubrica'].isin(["Rendimentos de Aplicações Financeiras"]).any(): + stringRendimentosdeAplicaçõesFinanceiras = f'C{rowDespesasCapital + 12}' + sheet[stringRendimentosdeAplicaçõesFinanceiras] = dfMerged.loc[dfMerged['NomeRubrica'] == 'Rendimentos de Aplicações Financeiras', 'VALOR_TOTAL_PERIODO'].values[0] + #Ate o perido anterior Rendimentos de Aplicações Financeiras + stringRendimentosdeAplicaçõesFinanceiras = f'B{rowDespesasCapital + 12}' + sheet[stringRendimentosdeAplicaçõesFinanceiras] = dfMerged.loc[dfMerged['NomeRubrica'] == 'Rendimentos de Aplicações Financeiras', 'VALOR_TOTAL_PREVISTO'].values[0] + + + #Obras e Instalações + #previsto + string_exists = dfMerged['NomeRubrica'].isin(["Obras e Instalações"]).any() + if string_exists: + + stringObras = f'E{rowDespesasCapital + 2}' + sheet[stringObras] = dfMerged.loc[dfMerged['NomeRubrica'] == 'Obras e Instalações', 'VALOR_TOTAL_PREVISTO'].values[0] + + #periodo + stringObras = f'C{rowDespesasCapital + 2}' + sheet[stringObras] = dfMerged.loc[dfMerged['NomeRubrica'] == 'Obras e Instalações', 'VALOR_TOTAL_PERIODO'].values[0] + #Ate o momento + stringObras = f'B{rowDespesasCapital + 2}' + sheet[stringObras] = dfMerged.loc[dfMerged['NomeRubrica'] == 'Obras e Instalações', 'VALOR_TOTAL_DATA'].values[0] + + string_exists = dfMerged['NomeRubrica'].isin(["Equipamentos e Material Permanente"]).any() + if string_exists: + #Materiais Equipamentos e Material Permanente + stringObras = f'E{rowDespesasCapital + 5}' + + sheet[stringObras] = dfMerged.loc[dfMerged['NomeRubrica'] == 'Equipamentos e Material Permanente', 'VALOR_TOTAL_PREVISTO'].values[0] + + #periodo + stringObras = f'C{rowDespesasCapital + 5}' + sheet[stringObras] = dfMerged.loc[dfMerged['NomeRubrica'] == 'Equipamentos e Material Permanente', 'VALOR_TOTAL_PERIODO'].values[0] + #Ate o momento + stringObras = f'B{rowDespesasCapital + 5}' + sheet[stringObras] = dfMerged.loc[dfMerged['NomeRubrica'] == 'Equipamentos e Material Permanente', 'VALOR_TOTAL_DATA'].values[0] + + #Materiais Equipamentos e Material nACIONAL + string_exists = dfMerged['NomeRubrica'].isin(["Material Permanente e Equipamento Nacional"]).any() + if string_exists: + stringObras = f'E{rowDespesasCapital + 6}' + + sheet[stringObras] = dfMerged.loc[dfMerged['NomeRubrica'] == 'Material Permanente e Equipamento Nacional', 'VALOR_TOTAL_PREVISTO'].values[0] + + #periodo + stringObras = f'C{rowDespesasCapital + 6}' + sheet[stringObras] = dfMerged.loc[dfMerged['NomeRubrica'] == 'Material Permanente e Equipamento Nacional', 'VALOR_TOTAL_PERIODO'].values[0] + #Ate o momento + stringObras = f'B{rowDespesasCapital + 6}' + sheet[stringObras] = dfMerged.loc[dfMerged['NomeRubrica'] == 'Material Permanente e Equipamento Nacional', 'VALOR_TOTAL_DATA'].values[0] + + #Materiais Equipamentos e Material iMPORTADO + string_exists = dfMerged['NomeRubrica'].isin(["Material Permanente e Equipamento Importado"]).any() + if string_exists: + stringObras = f'E{rowDespesasCapital + 7}' + sheet[stringObras] = dfMerged.loc[dfMerged['NomeRubrica'] == 'Material Permanente e Equipamento Importado', 'VALOR_TOTAL_PREVISTO'].values[0] + + #periodo + stringObras = f'C{rowDespesasCapital + 7}' + sheet[stringObras] = dfMerged.loc[dfMerged['NomeRubrica'] == 'Material Permanente e Equipamento Importado', 'VALOR_TOTAL_PERIODO'].values[0] + #Ate o momento + stringObras = f'B{rowDespesasCapital + 7}' + sheet[stringObras] = dfMerged.loc[dfMerged['NomeRubrica'] == 'Material Permanente e Equipamento Importado', 'VALOR_TOTAL_DATA'].values[0] + + + + #remover essas linhas da tabela + values_to_remove = ["Receitas", "Rendimentos de Aplicações Financeiras", "Despesas Financeiras",'Material Permanente e Equipamento Nacional','Material Permanente e Equipamento Importado','Devolução de Recursos','Obras e Instalações','Equipamentos e Material Permanente'] + + # Use boolean indexing to drop rows based on the values in the first column + dfMerged = dfMerged[~dfMerged['NomeRubrica'].isin(values_to_remove)] + + + + string_exists = dfMerged['NomeRubrica'].isin(["Despesas Operacionais e Administrativas - Finatec"]).any() + if string_exists: + # Extract the value from "Despesas Operacionais e Administrativas - Finatec" + value_to_add = dfMerged.loc[dfMerged['NomeRubrica'] == 'Despesas Operacionais e Administrativas - Finatec'].iloc[0] + + string_exists = dfMerged['NomeRubrica'].isin(["Outros Serviços de Terceiros - Pessoa Jurídica "]).any() + string_exists2 = dfMerged['NomeRubrica'].isin(["Serviços de Terceiros Pessoa Jurídica"]).any() + string_exists3 = dfMerged['NomeRubrica'].isin(["Outros Serviços de Terceiros - Pessoa Jurídica"]).any() + + if string_exists or string_exists2 or string_exists3: + if string_exists: + + + dfMerged.loc[dfMerged['NomeRubrica'] == 'Outros Serviços de Terceiros - Pessoa Jurídica '] += value_to_add + + # Drop the row for "Despesas Operacionais e Administrativas - Finatec" + dfMerged = dfMerged[dfMerged['NomeRubrica'] != 'Despesas Operacionais e Administrativas - Finatec'] + + if string_exists2: + + + # Add the value to "Outros Serviços de Terceiros - Pessoa Jurídica" + dfMerged.loc[dfMerged['NomeRubrica'] == 'Serviços de Terceiros Pessoa Jurídica'] += value_to_add + + # Drop the row for "Despesas Operacionais e Administrativas - Finatec" + dfMerged = dfMerged[dfMerged['NomeRubrica'] != 'Despesas Operacionais e Administrativas - Finatec'] + + if string_exists3: + # Find the index of "Outros Serviços de Terceiros - Pessoa Jurídica" + + index_to_update = dfMerged.loc[dfMerged['NomeRubrica'] == 'Outros Serviços de Terceiros - Pessoa Jurídica'].index[0] + + # Add the value to "Outros Serviços de Terceiros - Pessoa Jurídica" + dfMerged.iloc[index_to_update] += value_to_add + + # Drop the row for "Despesas Operacionais e Administrativas - Finatec" + dfMerged = dfMerged[dfMerged['NomeRubrica'] != 'Despesas Operacionais e Administrativas - Finatec'] + + + + + + + + for row_num, row_data in enumerate(dfMerged.itertuples(index = False), start=14):#inicio linha + for col_num, value in enumerate(row_data, start=1):#inicio coluna + + if col_num == 3: + sheet.cell(row=row_num, column=col_num, value=convert_datetime_to_string(value)).alignment=Alignment(horizontal="right",vertical="center",wrap_text=True) + if col_num == 1: + sheet.cell(row=row_num, column=col_num, value=convert_datetime_to_string(value)).alignment=Alignment(horizontal="left",vertical="center",wrap_text=True) + if col_num == 2: + col_num = 5 + sheet.cell(row=row_num, column=col_num, value=convert_datetime_to_string(value)).alignment=Alignment(horizontal="right",vertical="center",wrap_text=True) + #sheet.cell(row=row_num, column=col_num, value=convert_datetime_to_string(value)) + + if col_num == 4: + col_num = 2 + sheet.cell(row=row_num, column=col_num, value=convert_datetime_to_string(value)).alignment=Alignment(horizontal="right",vertical="center",wrap_text=True) + + + + workbook.save(planilha) + workbook.close() + + + + return rowBrasilia +#ok +def relatorioExecFinanceiraA1(codigo,data1,data2,planilha,rowBrasilia): + tabela = pegar_caminho(planilha) + workbook = openpyxl.load_workbook(tabela) + sheet2 = workbook.create_sheet(title="Relatório de Exec Financ A.1") + workbook.save(tabela) + workbook.close() + dfComPeriodo,dfAteAData = consultaRelatorioExecFinanceiraA1(codigo, data1, data2) + + + dfMerged = pd.merge(dfAteAData,dfComPeriodo, on = 'NomeRubrica', how = 'outer') + tamanho = len(dfMerged)#tamanho para deixar dinamico para imprimir sa rubricas + string_exists = dfMerged['NomeRubrica'].isin(["Material Permanente e Equipamento Importado"]).any() + if string_exists: + tamanho = tamanho - 1 + string_exists = dfMerged['NomeRubrica'].isin(["Obras e Instalações"]).any() + if string_exists: + tamanho = tamanho - 1 + string_exists = dfMerged['NomeRubrica'].isin(["Equipamentos e Material Permanente"]).any() + if string_exists: + tamanho = tamanho - 1 + string_exists = dfMerged['NomeRubrica'].isin(["Material Permanente e Equipamento Nacional"]).any() + if string_exists: + tamanho = tamanho - 1 + string_exists = dfMerged['NomeRubrica'].isin(["Receitas"]).any() + if string_exists: + tamanho = tamanho - 1 + string_exists = dfMerged['NomeRubrica'].isin(["Rendimentos de Aplicações Financeiras"]).any() + if string_exists: + tamanho = tamanho - 1 + string_exists = dfMerged['NomeRubrica'].isin(["Despesas Financeiras"]).any() + if string_exists: + tamanho = tamanho - 1 + + + + + rowDespesasCapital = estiloRelatorioExecFinanceiroA1(tabela,tamanho,rowBrasilia) + + + + caminho = pegar_caminho(planilha) + workbook = openpyxl.load_workbook(caminho) + sheet = workbook['Relatório de Exec Financ A.1'] + + + + #Obras e Instalações + #previsto + string_exists = dfMerged['NomeRubrica'].isin(["Obras e Instalações"]).any() + if string_exists: + + + + #periodo + stringObras = f'F{rowDespesasCapital + 1}' + sheet[stringObras] = dfMerged.loc[dfMerged['NomeRubrica'] == 'Obras e Instalações', 'VALOR_TOTAL_PERIODO'].values[0] + #Ate o momento + stringObras = f'B{rowDespesasCapital + 1}' + sheet[stringObras] = dfMerged.loc[dfMerged['NomeRubrica'] == 'Obras e Instalações', 'VALOR_TOTAL_DATA'].values[0] + + string_exists = dfMerged['NomeRubrica'].isin(["Equipamentos e Material Permanente"]).any() + if string_exists: + #Materiais Equipamentos e Material Permanente + + + #periodo + stringObras = f'F{rowDespesasCapital + 4}' + sheet[stringObras] = dfMerged.loc[dfMerged['NomeRubrica'] == 'Equipamentos e Material Permanente', 'VALOR_TOTAL_PERIODO'].values[0] + #Ate o momento + stringObras = f'B{rowDespesasCapital + 4}' + sheet[stringObras] = dfMerged.loc[dfMerged['NomeRubrica'] == 'Equipamentos e Material Permanente', 'VALOR_TOTAL_DATA'].values[0] + + #Materiais Equipamentos e Material nACIONAL + string_exists = dfMerged['NomeRubrica'].isin(["Material Permanente e Equipamento Nacional"]).any() + if string_exists: + + + #periodo + stringObras = f'F{rowDespesasCapital + 5}' + sheet[stringObras] = dfMerged.loc[dfMerged['NomeRubrica'] == 'Material Permanente e Equipamento Nacional', 'VALOR_TOTAL_PERIODO'].values[0] + #Ate o momento + stringObras = f'B{rowDespesasCapital + 5}' + sheet[stringObras] = dfMerged.loc[dfMerged['NomeRubrica'] == 'Material Permanente e Equipamento Nacional', 'VALOR_TOTAL_DATA'].values[0] + + #Materiais Equipamentos e Material iMPORTADO + string_exists = dfMerged['NomeRubrica'].isin(["Material Permanente e Equipamento Importado"]).any() + if string_exists: + + #periodo + stringObras = f'F{rowDespesasCapital + 6}' + sheet[stringObras] = dfMerged.loc[dfMerged['NomeRubrica'] == 'Material Permanente e Equipamento Importado', 'VALOR_TOTAL_PERIODO'].values[0] + #Ate o momento + stringObras = f'B{rowDespesasCapital + 6}' + sheet[stringObras] = dfMerged.loc[dfMerged['NomeRubrica'] == 'Material Permanente e Equipamento Importado', 'VALOR_TOTAL_DATA'].values[0] + + + + #remover essas linhas da tabela + values_to_remove = ["Receitas", "Rendimentos de Aplicações Financeiras", "Despesas Financeiras",'Material Permanente e Equipamento Nacional','Material Permanente e Equipamento Importado','Devolução de Recursos','Obras e Instalações','Equipamentos e Material Permanente'] + + # Use boolean indexing to drop rows based on the values in the first column + dfMerged = dfMerged[~dfMerged['NomeRubrica'].isin(values_to_remove)] + + + + string_exists = dfMerged['NomeRubrica'].isin(["Despesas Operacionais e Administrativas - Finatec"]).any() + if string_exists: + # Extract the value from "Despesas Operacionais e Administrativas - Finatec" + value_to_add = dfMerged.loc[dfMerged['NomeRubrica'] == 'Despesas Operacionais e Administrativas - Finatec'].iloc[0] + + string_exists = dfMerged['NomeRubrica'].isin(["Outros Serviços de Terceiros - Pessoa Jurídica "]).any() + string_exists2 = dfMerged['NomeRubrica'].isin(["Serviços de Terceiros Pessoa Jurídica"]).any() + string_exists3 = dfMerged['NomeRubrica'].isin(["Outros Serviços de Terceiros - Pessoa Jurídica"]).any() + + if string_exists or string_exists2 or string_exists3: + if string_exists: + + + dfMerged.loc[dfMerged['NomeRubrica'] == 'Outros Serviços de Terceiros - Pessoa Jurídica '] += value_to_add + + # Drop the row for "Despesas Operacionais e Administrativas - Finatec" + dfMerged = dfMerged[dfMerged['NomeRubrica'] != 'Despesas Operacionais e Administrativas - Finatec'] + + if string_exists2: + + + # Add the value to "Outros Serviços de Terceiros - Pessoa Jurídica" + dfMerged.loc[dfMerged['NomeRubrica'] == 'Serviços de Terceiros Pessoa Jurídica'] += value_to_add + + # Drop the row for "Despesas Operacionais e Administrativas - Finatec" + dfMerged = dfMerged[dfMerged['NomeRubrica'] != 'Despesas Operacionais e Administrativas - Finatec'] + + if string_exists3: + # Find the index of "Outros Serviços de Terceiros - Pessoa Jurídica" + + index_to_update = dfMerged.loc[dfMerged['NomeRubrica'] == 'Outros Serviços de Terceiros - Pessoa Jurídica'].index[0] + + # Add the value to "Outros Serviços de Terceiros - Pessoa Jurídica" + dfMerged.iloc[index_to_update] += value_to_add + + # Drop the row for "Despesas Operacionais e Administrativas - Finatec" + dfMerged = dfMerged[dfMerged['NomeRubrica'] != 'Despesas Operacionais e Administrativas - Finatec'] + + + + + + for row_num, row_data in enumerate(dfMerged.itertuples(index = False), start=12):#inicio linha + for col_num, value in enumerate(row_data, start=1):#inicio coluna + + + if col_num == 1: + sheet.cell(row=row_num, column=col_num, value=convert_datetime_to_string(value)).alignment=Alignment(horizontal="left",vertical="center",wrap_text=True) + if col_num == 2: + col_num = 6 + sheet.cell(row=row_num, column=col_num, value=convert_datetime_to_string(value)).alignment=Alignment(horizontal="right",vertical="center",wrap_text=True) + #sheet.cell(row=row_num, column=col_num, value=convert_datetime_to_string(value)) + if col_num == 3: + col_num = 2 + sheet.cell(row=row_num, column=col_num, value=convert_datetime_to_string(value)).alignment=Alignment(horizontal="right",vertical="center",wrap_text=True) + + + + + #PREENCHER CABECARIO + 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"de {output_date_str} a {output_date_str2}" + + + consulta_coordenador = consultaID(codigo) + + # o quarenta significa pra achar o lugar do coordenador dinamicamente mais o valor do tamanho da quantidade de rubricas + tamanho_row_coordenador = tamanho + 40 + stringCoordenador= f'C{tamanho_row_coordenador}' # retorna lugar do coordanor + stringTamanhoCPF = f'C{tamanho_row_coordenador+2}' # retorna lugar do coordanor + sheet[stringCoordenador] = consulta_coordenador['NomePessoaResponsavel'] + sheet[stringTamanhoCPF] = formatar_cpf(consulta_coordenador['CPFCoordenador']) + string_convenio = f"Convênio nº: {consulta_coordenador['NomeConvenio']}" + string_convenente= f"Fundação de Empreendimentos Científicos e Tecnológicos - FINATEC" + string_convenente_convenente= f"Convenente: " + string_fonte_recursos = f"Fonte de Recursos:" + string_participe = f"Partícipe (no caso de contrapartida):" + string_periodo_relatorio = f"Período Abrangido por este Relatório: " + stringPeriodoExececucao = f'Período de Execução do Convênio:' + # Convert 'DataAssinatura' to "dd/mm/YYYY" format + datetime_obj1 = consulta_coordenador['DataAssinatura'] + formatted_date1 = datetime_obj1.strftime("%d/%m/%Y") + + # Convert 'DataVigencia' to "dd/mm/YYYY" format + datetime_obj2 = consulta_coordenador['DataVigencia'] + formatted_date2 = datetime_obj2.strftime("%d/%m/%Y") + +# Create the string representing the period of execution + + string_periodo_convenio = f"de {formatted_date1} a {formatted_date2}" + sheet['A4'] = string_convenio + sheet['A5'] = string_convenente_convenente + sheet['A6'] = stringPeriodoExececucao + sheet['A7'] = string_periodo_relatorio + + + sheet['C5'] = string_convenente + sheet['C6'] = string_periodo_convenio + sheet['C7'] = string_periodo + + + + + workbook.save(planilha) + workbook.close() + + + + + return 0 +#ok +def PagamentoDePessoal(codigo,data1,data2,planilha,rowBrasilia): + tabela = pegar_caminho(planilha) + workbook = openpyxl.load_workbook(tabela) + sheet2 = workbook.create_sheet(title="Pagamento de Pessoal") + sheet2['B11'] = f'Pagamento de Pessoal (Vencimentos e Vantagens Fixas, Obrigações Patronais e Benefícios)' + sheet2['B11'].font = Font(name="Arial", size=12, color="000000",bold=True) + workbook.save(tabela) + workbook.close() + + #recebeOsDataFrames + dfconsultaDadosPorRubrica,dfconsultaDadosPorRubricaComEstorno = consultaPagamentoPessoal(codigo,data1,data2) + + tamanho = len(dfconsultaDadosPorRubrica) + tamanhoestorno = len(dfconsultaDadosPorRubricaComEstorno) + + + rowEstorno = estiloPagamentoPessoal(tabela,tamanho,rowBrasilia,tamanhoestorno) + + tabela = pegar_caminho(planilha) + workbook = openpyxl.load_workbook(tabela) + sheet2 = workbook['Pagamento de Pessoal'] + + dfconsultaDadosPorRubrica.index = dfconsultaDadosPorRubrica.index + 1 + for row_num, row_data in enumerate(dfconsultaDadosPorRubrica.itertuples(), start=16):#inicio linha + for col_num, value in enumerate(row_data, start=1):#inicio coluna + value = convert_datetime_to_stringdt(value) + sheet2.cell(row=row_num, column=col_num, value=value) + + # dfconsultaDadosPorRubricaComEstorno.index = dfconsultaDadosPorRubricaComEstorno.index + 1 + + + + + # + dfconsultaDadosPorRubricaComEstorno.insert(0, "col1", None) + dfconsultaDadosPorRubricaComEstorno.insert(5, 'Col2', None) + dfconsultaDadosPorRubricaComEstorno.insert(6, 'Col3', None) + + + for row_num, row_data in enumerate(dfconsultaDadosPorRubricaComEstorno.itertuples(index=False), start=rowEstorno): #inicio linha + for col_num, value in enumerate(row_data, start=1): #inicio coluna + + + value = convert_datetime_to_stringdt(value) + sheet2.cell(row=row_num, column=col_num, value=value) + + workbook.save(tabela) + workbook.close() + + + + return 0 +#ok +def ElementoDeDespesa1415Diarias(codigo,data1,data2,planilha,rowBrasilia): + tabela = pegar_caminho(planilha) + workbook = openpyxl.load_workbook(tabela) + sheet2 = workbook.create_sheet(title="Elemento de Despesa 14.15") + sheet2['B11'] = f'14/15 - Diárias (Pessoal Civil/Militar)' + sheet2['B11'].font = Font(name="Arial", size=12, color="000000",bold=True) + workbook.save(tabela) + workbook.close() + + dfconsultaDadosPorRubrica,dfconsultaDadosPorRubricaComEstorno = consultaestiloElementoDeDespesa1415Diarias(codigo,data1,data2) + + tamanho = len(dfconsultaDadosPorRubrica) + tamanhoestorno = len(dfconsultaDadosPorRubricaComEstorno) + + + rowEstorno = estiloElementoDeDespesa1415Diarias(tabela,tamanho,rowBrasilia,tamanhoestorno) + + + + tabela = pegar_caminho(planilha) + workbook = openpyxl.load_workbook(tabela) + sheet2 = workbook['Elemento de Despesa 14.15'] + + #print(dfconsultaDadosPorRubrica.columns.values.tolist()) + + dfconsultaDadosPorRubrica.index = dfconsultaDadosPorRubrica.index + 1 + for row_num, row_data in enumerate(dfconsultaDadosPorRubrica.itertuples(), start=16):#inicio linha + for col_num, value in enumerate(row_data, start=1):#inicio coluna + value = convert_datetime_to_stringdt(value) + sheet2.cell(row=row_num, column=col_num, value=value) + + # dfconsultaDadosPorRubricaComEstorno.index = dfconsultaDadosPorRubricaComEstorno.index + 1 + + + + + # + dfconsultaDadosPorRubricaComEstorno.insert(0, "col1", None) + dfconsultaDadosPorRubricaComEstorno.insert(5, 'Col2', None) + dfconsultaDadosPorRubricaComEstorno.insert(6, 'Col3', None) + + + for row_num, row_data in enumerate(dfconsultaDadosPorRubricaComEstorno.itertuples(index=False), start=rowEstorno): #inicio linha + for col_num, value in enumerate(row_data, start=1): #inicio coluna + + + value = convert_datetime_to_stringdt(value) + sheet2.cell(row=row_num, column=col_num, value=value) + + workbook.save(tabela) + workbook.close() + + + + + return 0 +#ok +def geral30(codigo,data1,data2,planilha,rowBrasilia): + tabela = pegar_caminho(planilha) + dfNomeRubricaCodigoRubrica = consultaNomeRubricaCodRubrica(codigo, data1, data2) + for index, values in dfNomeRubricaCodigoRubrica.iterrows(): + dfPJDOA,dfPJDOAESTORNO,dfConsultaProjeto ,dfconsultaDadosPorRubricaComEstorno= consultaGeral30(codigo,data1,data2,values['CodRubrica']) + + if values['NomeRubrica'] == "Obrigações Tributárias e contributivas": + values['NomeRubrica'] = "Obrigações Tributárias" + if values['NomeRubrica'] == "Material Permanente e Equipamento Nacional": + values['NomeRubrica'] = "Equipamento Material Nacional" + if values['NomeRubrica'] == "Serviços de Terceiros Pessoa Física": + values['NomeRubrica'] = "Serviços de Terceiros PF" + if values['NomeRubrica'] == f"Obrigações Tributárias e Contributivas - 20% de OST " : + values['NomeRubrica'] = f"Obrigações Trib. - Encargos 20%" + if values['NomeRubrica'] == f"Obrigações Tributárias e contributivas " : + values['NomeRubrica'] = f"Obrigações Tributárias" + if values['NomeRubrica'] == f"Outros Serviços de Terceiros - Pessoa Física" : + values['NomeRubrica'] = f"Outros Serviços Terceiros - PF" + if values['NomeRubrica'] == f"Outros Serviços de Terceiros - Pessoa Jurídica " : + values['NomeRubrica'] = f"Outros Serviços Terceiros - PJ" + if values['NomeRubrica'] == f"Passagens e Despesas com Locomoção" : + values['NomeRubrica'] = f"Passagens e Desp. Locomoção" + if values['NomeRubrica'] == f"Despesas Operacionais e Administrativas - Finatec" : + values['NomeRubrica'] = f"Despesas Operacionais" + if values['NomeRubrica'] == f"Despesas Operacionais e Administrativas - Finatec" : + values['NomeRubrica'] = f"Despesas Operacionais" + if values['NomeRubrica'] == f"Auxílio Financeiro a Pesquisador" : + values['NomeRubrica'] = f"AuxFinanceiro Pesquisador" + if values['NomeRubrica'] == f"Equipamentos e Material Permanente" : + values['NomeRubrica'] = f"Equip e Mat Permanente" + if values['NomeRubrica'] == f"Material Permanente e Equipamento Importado" : + values['NomeRubrica'] = f"Equipamento Material Importado" + + + + + + + + if values['NomeRubrica'] == "Outros Serviços Terceiros - PJ" or values['NomeRubrica'] == "Serviços de Terceiros Pessoa Jurídica": + values['NomeRubrica'] = "Outros Serviços Terceiros -PJ" + nomeTabela = values['NomeRubrica'] + nomeTabelaElemento = f'Elemento de Despesa 39' + tituloStyle = values['NomeRubrica'] + workbook = openpyxl.load_workbook(tabela) + sheet2 = workbook.create_sheet(title=nomeTabelaElemento) + sheet2['B11'] = values['NomeRubrica'] + sheet2['B11'].font = Font(name="Arial", size=12, color="000000",bold=True) + workbook.save(tabela) + workbook.close() + + + tamanho = len(dfPJDOA) + tamanhoRetorno = len(dfPJDOAESTORNO) + + rownovo = estiloG(tabela,tamanho,tituloStyle,nomeTabelaElemento,rowBrasilia,tamanhoRetorno) + workbook = openpyxl.load_workbook(tabela) + sheet2 = workbook[nomeTabelaElemento] + dfPJDOA.index = dfPJDOA.index + 1 + for row_num, row_data in enumerate(dfPJDOA.itertuples(), start=16):#inicio linha + for col_num, value in enumerate(row_data, start=1):#inicio coluna + value = convert_datetime_to_stringdt(value) + sheet2.cell(row=row_num, column=col_num, value=value) + + dfPJDOAESTORNO.insert(0, "col1", None) + dfPJDOAESTORNO.insert(4, 'Col2', None) + dfPJDOAESTORNO.insert(4, 'Col3', None) + + + + rownovo = rownovo + for row_num, row_data in enumerate(dfPJDOAESTORNO.itertuples(index=False), start=rownovo): #inicio linha + for col_num, value in enumerate(row_data, start=1): #inicio coluna + if col_num == 5: + continue + value = convert_datetime_to_stringdt(value) + sheet2.cell(row=row_num, column=col_num, value=value) + + workbook.save(tabela) + workbook.close() + + + else: + excluded_values = ["Rendimentos de Aplicações Financeiras", + "Despesas Financeiras", + "Receitas", + "Devolução de Recursos", + "Outros Serviços Terceiros - PJ", + "Despesas Operacionais", + 'Passagens e Despesas com Locomoção', + "Diárias", + "Diárias - Celetistas", + "Diárias - Colaborador Eventual no País", + "Diárias - Pesquisadores", + "Diárias - Servidores Públicos", + "Diárias Internacional", + "Passagens e Desp. Locomoção", + 'Pagamento de Pessoal', + "Diárias Nacionais"] + + if values['NomeRubrica'] not in excluded_values: + + nomeTabela = values['NomeRubrica'] + tituloStyle = values['NomeRubrica'] + + #switch case + + #pessoa juridica + if values['NomeRubrica'] == f"Outros Serviços Terceiros - PF" : + nomeTabelaElementoGeral = f'Elemento de Despesa 36' + elif values['NomeRubrica'] == f"Obras e Instalações" : + nomeTabelaElementoGeral = f'Elemento de Despesa 51' + elif values['NomeRubrica'] == f"Equipamentos e Material Permanente" : + nomeTabelaElementoGeral = f'Elemento de Despesa 52' + elif values['NomeRubrica'] == f"Material de Consumo " : + nomeTabelaElementoGeral = f'Elemento de Despesa 30' + + else : + nomeTabelaElementoGeral = values['NomeRubrica'] + + workbook = openpyxl.load_workbook(tabela) + sheet2 = workbook.create_sheet(title=nomeTabelaElementoGeral) + sheet2['B11'] = values['NomeRubrica'] + sheet2['B11'].font = Font(name="Arial", size=12, color="000000",bold=True) + workbook.save(tabela) + workbook.close() + + tamanho = len(dfConsultaProjeto) + tamanhoRetorno = len(dfconsultaDadosPorRubricaComEstorno) + + + + rowEstorno = estiloG(tabela,tamanho,tituloStyle,nomeTabelaElementoGeral,rowBrasilia,tamanhoRetorno) + workbook = openpyxl.load_workbook(tabela) + sheet2 = workbook[nomeTabelaElementoGeral] + dfConsultaProjeto.index = dfConsultaProjeto.index + 1 + for row_num, row_data in enumerate(dfConsultaProjeto.itertuples(), start=16):#inicio linha + for col_num, value in enumerate(row_data, start=1):#inicio coluna + value = convert_datetime_to_stringdt(value) + sheet2.cell(row=row_num, column=col_num, value=value) + + # dfconsultaDadosPorRubricaComEstorno.index = dfconsultaDadosPorRubricaComEstorno.index + 1 + rowEstorno = rowEstorno + # + tamanhoDf = len(dfconsultaDadosPorRubricaComEstorno) + dfconsultaDadosPorRubricaComEstorno.insert(0, "col1", None) + dfconsultaDadosPorRubricaComEstorno.insert(4, 'Col2', None) + dfconsultaDadosPorRubricaComEstorno.insert(4, 'Col3', None) + + + + + + for row_num, row_data in enumerate(dfconsultaDadosPorRubricaComEstorno.itertuples(index=False), start=rowEstorno): #inicio linha + for col_num, value in enumerate(row_data, start=1): #inicio coluna + + if col_num == 5: + continue + value = convert_datetime_to_stringdt(value) + sheet2.cell(row=row_num, column=col_num, value=value) + + workbook.save(tabela) + workbook.close() +#ok +def PassagensEDespesa33(codigo,data1,data2,planilha,rowBrasilia): + tabela = pegar_caminho(planilha) + workbook = openpyxl.load_workbook(tabela) + sheet2 = workbook.create_sheet(title="Elemento de Despesa 33") + sheet2['B11'] = f'33 - Passagens e Despesas com Locomoção' + sheet2['B11'].font = Font(name="Arial", size=12, color="000000",bold=True) + workbook.save(tabela) + workbook.close() + dfconsultaDadosPorRubrica,dfconsultaDadosPorRubricaComEstorno = consultaestiloElementoDeDespesa33PassagemEDespesa(codigo,data1,data2) + tamanho = len(dfconsultaDadosPorRubrica) + tamanhoestorno = len(dfconsultaDadosPorRubricaComEstorno) + rowEstorno = estiloElementoDeDespesa33PassagensEDespesa(tabela,tamanho,rowBrasilia,tamanhoestorno) + + + tabela = pegar_caminho(planilha) + workbook = openpyxl.load_workbook(tabela) + sheet2 = workbook['Elemento de Despesa 33'] + + dfconsultaDadosPorRubrica.index = dfconsultaDadosPorRubrica.index + 1 + dfconsultaDadosPorRubrica.insert(2, "col1", None) + dfconsultaDadosPorRubrica.insert(3, 'Col2', None) + dfconsultaDadosPorRubrica.insert(4, 'Col3', None) + for row_num, row_data in enumerate(dfconsultaDadosPorRubrica.itertuples(), start=16):#inicio linha + for col_num, value in enumerate(row_data, start=1):#inicio coluna + value = convert_datetime_to_stringdt(value) + sheet2.cell(row=row_num, column=col_num, value=value) + + # dfconsultaDadosPorRubricaComEstorno.index = dfconsultaDadosPorRubricaComEstorno.index + 1 + + + + + # + dfconsultaDadosPorRubricaComEstorno.insert(0, "col0", None) + dfconsultaDadosPorRubricaComEstorno.insert(3, "col1", None) + dfconsultaDadosPorRubricaComEstorno.insert(4, 'Col2', None) + dfconsultaDadosPorRubricaComEstorno.insert(5, 'Col3', None) + dfconsultaDadosPorRubricaComEstorno.insert(7, 'Col4', None) + dfconsultaDadosPorRubricaComEstorno.insert(8, 'Col5', None) + + + for row_num, row_data in enumerate(dfconsultaDadosPorRubricaComEstorno.itertuples(index=False), start=rowEstorno): #inicio linha + for col_num, value in enumerate(row_data, start=1): #inicio coluna + + + value = convert_datetime_to_stringdt(value) + sheet2.cell(row=row_num, column=col_num, value=value) + + workbook.save(tabela) + workbook.close() + + + + return 0 +#ok +def relacaoBensAdquiridosA5(codigo,data1,data2,planilha,rowBrasilia): + #consult aprojeto 07318 monte de bens imobilizaos, 6995,7311 + tabela = pegar_caminho(planilha) + workbook = openpyxl.load_workbook(tabela) + sheet2 = workbook.create_sheet(title="Relação Bens Adquiridos A.5") + workbook.save(tabela) + workbook.close() + dfConsultaBens = consultaBens(codigo,data1,data2) + estiloRelacaoBens(tabela,len(dfConsultaBens),rowBrasilia) + + + + dfConsultaBens.insert(6, "col1", 1) + + + + + + workbook = openpyxl.load_workbook(tabela) + sheet = workbook['Relação Bens Adquiridos A.5'] + for row_num, row_data in enumerate(dfConsultaBens.itertuples(), start=15):#inicio linha + for col_num, value in enumerate(row_data, start=1):#inicio coluna + value = re.sub("[^a-zA-ZÀ-ÿ0-9º+-//]", " ", str(value)) + value = convert_datetime_to_stringdt(value) + + sheet.cell(row=row_num, column=col_num, value=value) + + + + + + workbook.save(tabela) + workbook.close() + + return 0 +#ok +def rendimentoAplicacao(codigo,data1,data2,planilha,rowBrasilia): + tabela = pegar_caminho(planilha) + workbook = openpyxl.load_workbook(tabela) + sheet2 = workbook.create_sheet(title="Rendimento de Aplicação") + workbook.save(tabela) + workbook.close() + + dfConsultaRendimentoAplicacao,dfConsultaImposto,dfConsultaRendimentoEImposto = consultaRendimentosAplicacao(codigo,data1,data2) + merged_df = pd.merge(dfConsultaRendimentoAplicacao, dfConsultaImposto, on='DataPagamento') + estilo_rendimento_de_aplicacao(tabela,len(merged_df),rowBrasilia) + + workbook = openpyxl.load_workbook(tabela) + sheet = workbook['Rendimento de Aplicação'] + + merged_df['data_formatada'] = merged_df['DataPagamento'].apply(formatarDataSemDia) + merged_df['DataPagamento'] = merged_df['data_formatada'] + merged_df = merged_df.drop('data_formatada', axis=1) + + for row_num, row_data in enumerate(merged_df.itertuples(index=False), start=15):#inicio linha + for col_num, value in enumerate(row_data, start=1):#inicio coluna + if col_num == 2: + col_num = 5 + if col_num == 3: + col_num = 6 + sheet.cell(row=row_num, column=col_num, value=value).number_format = 'R$ #,##0.00' + + + workbook.save(tabela) + workbook.close() + + return 0 +#ok +def conciliacaoBancaria(codigo,data1,data2,planilha,rowBrasilia): + tabela = pegar_caminho(planilha) + workbook = openpyxl.load_workbook(tabela) + sheet2 = workbook.create_sheet(title="Conciliação Bancária A.3") + workbook.save(tabela) + workbook.close() + dfSemEstorno,dfComEstorno = consultaConciliacaoBancaria(codigo,data1,data2) + estorno = estilo_conciliacoes_bancaria(tabela,len(dfSemEstorno)+1,len(dfComEstorno),rowBrasilia) + + workb = openpyxl.load_workbook(tabela) + worksheet333 = workb["Conciliação Bancária A.3"] + + for row_num, row_data in enumerate(dfSemEstorno.itertuples(index=False), start=19):#inicio linha + for col_num, value in enumerate(row_data, start=1):#inicio coluna + worksheet333.cell(row=row_num, column=col_num, value=value) + + for row_num, row_data in enumerate(dfComEstorno.itertuples(index=False), start=estorno):#inicio linha + for col_num, value in enumerate(row_data, start=1):#inicio coluna + worksheet333.cell(row=row_num, column=col_num, value=value) + + workb.save(tabela) + workb.close + return 0 +#ok +def preencheFinep(codigo,data1,data2,tabela): + '''Preenche a planilha finep + + Argumentos: + codigo = CodConvenio na tabela nova, corresponde ao codigo do projeto + DATA1 = Data Inicial Selecinado pelo Usuario + DATA2 = Data Final Selecionado pelo Usuario + tabela = tabela a ser preenchida extensão xlsx + ''' + planilhaGeral(tabela,codigo,data1,data2) + rowBrasilia = demostrativereceitaedepesaA2(codigo,data1,data2,tabela) + relatorioExecFinanceiraA1(codigo,data1,data2,tabela,rowBrasilia) + PagamentoDePessoal(codigo,data1,data2,tabela,rowBrasilia) + ElementoDeDespesa1415Diarias(codigo,data1,data2,tabela,rowBrasilia) + PassagensEDespesa33(codigo,data1,data2,tabela,rowBrasilia) + geral30(codigo,data1,data2,tabela,rowBrasilia) + relacaoBensAdquiridosA5(codigo,data1,data2,tabela,rowBrasilia) + rendimentoAplicacao(codigo,data1,data2,tabela,rowBrasilia) + conciliacaoBancaria(codigo,data1,data2,tabela,rowBrasilia) + + \ No newline at end of file diff --git a/project/app/recibosAutomatizados.py b/project/app/recibosAutomatizados.py new file mode 100644 index 00000000..d2714c48 --- /dev/null +++ b/project/app/recibosAutomatizados.py @@ -0,0 +1,140 @@ +from selenium import webdriver +from selenium.webdriver.chrome.options import Options +from webdriver_manager.chrome import ChromeDriverManager +from selenium.webdriver.chrome.service import Service +from selenium.webdriver.support.ui import Select +from selenium.webdriver.support import expected_conditions as EC +from selenium.webdriver.support.ui import WebDriverWait +from selenium.webdriver.common.by import By +from selenium.common.exceptions import NoSuchElementException +import time +# options = Options() +# options.add_argument('--headless=chrome') +# options.add_argument('--no-sandbox') +# options.add_argument('--disable-dev-shm-usage') +# driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options) + + + +def servico(): + servico = Service(ChromeDriverManager().install()) + + options = Options() + options.add_argument('--headless=new') + options.add_argument('--no-sandbox') + options.add_argument('--disable-dev-shm-usage') + + navegador = webdriver.Chrome(service=servico, options=options) + + return navegador + +def acharRecibo(entrada,sem,pedido): + navegador = servico() + + navegador.get("https://conveniar.finatec.org.br/Fundacao/Login.aspx?ReturnUrl=%2fFundacao%2f") + navegador.find_element('xpath','//*[@id="ctl00_ContentPlaceHolder1_ObjWucLoginCaptcha_lgUsuario_UserName"]').send_keys(f"{entrada}") + navegador.find_element('xpath','//*[@id="ctl00_ContentPlaceHolder1_ObjWucLoginCaptcha_lgUsuario_Password"]').send_keys(f"{sem}") + navegador.find_element('xpath','//*[@id="ctl00_ContentPlaceHolder1_ObjWucLoginCaptcha_lgUsuario_btnLogin"]').click() + navegador.implicitly_wait(30) + select = Select(navegador.find_element('xpath','//*[@id="ctl00_ddlModulos"]')) + select.select_by_value('4') + navegador.implicitly_wait(5) + navegador.get("https://conveniar.finatec.org.br/Fundacao/Forms/Convenio/ControleFinanceiro.aspx") + #pagina controle financeiro + navegador.find_element('xpath','//*[@id="ctl00_ContentPlaceHolder1_FiltroBaixaLancamentoUserControl1_txtValor"]').send_keys(f"{pedido}") + select = Select(navegador.find_element('xpath','//*[@id="ctl00_ContentPlaceHolder1_FiltroBaixaLancamentoUserControl1_ddlStatus"]')) + select.select_by_visible_text('Todos') + navegador.implicitly_wait(5) + #aplicarfiltro + navegador.find_element('xpath','//*[@id="ctl00_ContentPlaceHolder1_FiltroBaixaLancamentoUserControl1_btnFiltrar"]').click() + navegador.implicitly_wait(5) + navegador.find_element('xpath','//*[@id="ctl00_ContentPlaceHolder1_gvPrincipal_ctl02_lbtEditar"]').click() + navegador.implicitly_wait(5) + navegador.find_element('xpath','//*[@id="ctl00_ContentPlaceHolder1_ControleFinanceiroUserControl2_btnAnexos"]/span[2]').click() + navegador.implicitly_wait(5) + #recibo + try: + #button = navegador.find_element('xpath','//*[@id="btnReciboPedido"]/span') + button = WebDriverWait(navegador, 2).until( + EC.visibility_of_element_located((By.XPATH, '//*[@id="btnReciboPedido"]/span')) + ) + except: + # If the button is not found, print a message and continue + print("Button not found.") + return + else: + button.click() + #pdf : + # navegador.find_element('xpath','//*[@id="icon"]/iron-icon').click() + # navegador.get('xpath','//*[@id="main-content"]/a') + #navegador.find_element('xpath','//*[@id="main-content"]/a').click() + + + + #pdf_element = navegador.find_element_by_xpath('//*[@id="main-content"]/a') + pdf_element = WebDriverWait(navegador, 10).until( + EC.visibility_of_element_located((By.XPATH, '//*[@id="iModalResponsive"]')) + ) + # Extract the URL of the PDF file + pdf_url = pdf_element.get_attribute("src") + #print(pdf_url) + + navegador.close() + + return pdf_url + +def acharReciboDevagar(entrada,sem,pedido): + navegador = servico() + + navegador.get("https://conveniar.finatec.org.br/Fundacao/Login.aspx?ReturnUrl=%2fFundacao%2f") + navegador.find_element('xpath','//*[@id="ctl00_ContentPlaceHolder1_ObjWucLoginCaptcha_lgUsuario_UserName"]').send_keys(f"{entrada}") + navegador.find_element('xpath','//*[@id="ctl00_ContentPlaceHolder1_ObjWucLoginCaptcha_lgUsuario_Password"]').send_keys(f"{sem}") + navegador.find_element('xpath','//*[@id="ctl00_ContentPlaceHolder1_ObjWucLoginCaptcha_lgUsuario_btnLogin"]').click() + navegador.implicitly_wait(30) + time.sleep(15) + select = Select(navegador.find_element('xpath','//*[@id="ctl00_ddlModulos"]')) + select.select_by_value('4') + navegador.implicitly_wait(5) + navegador.get("https://conveniar.finatec.org.br/Fundacao/Forms/Convenio/ControleFinanceiro.aspx") + #pagina controle financeiro + navegador.find_element('xpath','//*[@id="ctl00_ContentPlaceHolder1_FiltroBaixaLancamentoUserControl1_txtValor"]').send_keys(f"{pedido}") + select = Select(navegador.find_element('xpath','//*[@id="ctl00_ContentPlaceHolder1_FiltroBaixaLancamentoUserControl1_ddlStatus"]')) + select.select_by_visible_text('Todos') + navegador.implicitly_wait(5) + #aplicarfiltro + navegador.find_element('xpath','//*[@id="ctl00_ContentPlaceHolder1_FiltroBaixaLancamentoUserControl1_btnFiltrar"]').click() + navegador.implicitly_wait(5) + navegador.find_element('xpath','//*[@id="ctl00_ContentPlaceHolder1_gvPrincipal_ctl02_lbtEditar"]').click() + navegador.implicitly_wait(5) + navegador.find_element('xpath','//*[@id="ctl00_ContentPlaceHolder1_ControleFinanceiroUserControl2_btnAnexos"]/span[2]').click() + navegador.implicitly_wait(5) + #recibo + try: + #button = navegador.find_element('xpath','//*[@id="btnReciboPedido"]/span') + button = WebDriverWait(navegador, 2).until( + EC.visibility_of_element_located((By.XPATH, '//*[@id="btnReciboPedido"]/span')) + ) + except: + # If the button is not found, print a message and continue + print("Button not found.") + return + else: + button.click() + #pdf : + # navegador.find_element('xpath','//*[@id="icon"]/iron-icon').click() + # navegador.get('xpath','//*[@id="main-content"]/a') + #navegador.find_element('xpath','//*[@id="main-content"]/a').click() + + + + #pdf_element = navegador.find_element_by_xpath('//*[@id="main-content"]/a') + pdf_element = WebDriverWait(navegador, 10).until( + EC.visibility_of_element_located((By.XPATH, '//*[@id="iModalResponsive"]')) + ) + # Extract the URL of the PDF file + pdf_url = pdf_element.get_attribute("src") + #print(pdf_url) + + navegador.close() + + return pdf_url diff --git a/project/app/static/css/base_style.css b/project/app/static/css/base_style.css new file mode 100644 index 00000000..a1b30ec7 --- /dev/null +++ b/project/app/static/css/base_style.css @@ -0,0 +1,57 @@ +* { + font-family: 'Montserrat', sans-serif; +} + +html, body { + background-image: linear-gradient(#021842 50%, #253e6c); + background-size: contain; /* Added */ + background-repeat: no-repeat; /* Added */ + background-color: #253e6c; + height: 100vh; + margin: 0; + padding: 0; +} + +nav { + background-color: #021842; + padding-block: 25px; + box-shadow: 10px 5px 5px #021233; +} + +.link-primary { + text-decoration: none; + color: aliceblue; + padding-inline: 10px; +} + +.link-primary:hover { + color: rgb(185, 200, 212); +} + +body { + justify-content: space-between; + flex-direction: column; + display: flex; + margin: 0; +} + +footer { + color: aliceblue; + bottom: 0; + height: 2.5rem; +} + +/* tentativa de deixar a tela responsiva + se o content passa da margem da tela + a cor de fundo nao acompanha */ +/* @media (min-height: 100vh) { + html, body { + height: fit-content; + } +} + +@media (max-height: 100vh) { + html, body { + height: 100vh; + } +} */ \ No newline at end of file diff --git a/project/app/static/css/home.css b/project/app/static/css/home.css index befcc660..4a2f58de 100644 --- a/project/app/static/css/home.css +++ b/project/app/static/css/home.css @@ -1,262 +1,19 @@ -* { - font-family: "Montserrat", sans-serif; +:root { + --btn-hover: #F39B00; + --text-color: aliceblue; } -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; +.btn { + padding: 15px 50px 15px 50px; + background-color: var(--text-color); border-radius: 20px; - width: 200px; - height: 60px; - font-weight: 600; - font-size: 20px; - transition: 0.3s; - cursor: pointer; } -.button-submit4:hover { - background: #F39B00; +.btn:hover { + transition: 300ms; + background-color: var(--btn-hover); } +h5 { + color: rgb(212, 212, 212); +} \ No newline at end of file diff --git a/project/app/static/css/lista_projetos.css b/project/app/static/css/lista_projetos.css new file mode 100644 index 00000000..78998952 --- /dev/null +++ b/project/app/static/css/lista_projetos.css @@ -0,0 +1,34 @@ +.pagination { + align-self: center; + color: white; + text-align: center; + display: flex; + justify-content: center; +} + +.pagination a { + color: white; + text-decoration: none; +} + + +.step-links { + display: flex; + justify-content: space-evenly; + width: 170px; + padding: 0; + margin: 0; +} + +.step-links * { + align-self: center; + padding-inline: 10px; + text-align: center; + margin: 0; +} + +#current-page { + border-radius: 20000px; + background-color: #021842; + padding-block: 5px; +} \ No newline at end of file diff --git a/project/app/static/imagem/baixar.png b/project/app/static/imagem/baixar.png old mode 100644 new mode 100755 diff --git a/project/app/static/imagem/finateclogo.svg b/project/app/static/imagem/finateclogo.svg old mode 100644 new mode 100755 diff --git a/project/app/static/imagem/fundoLogo.svg b/project/app/static/imagem/fundoLogo.svg old mode 100644 new mode 100755 diff --git a/project/app/static/imagem/logo.svg b/project/app/static/imagem/logo.svg old mode 100644 new mode 100755 diff --git a/project/app/static/imagem/logo50%.svg b/project/app/static/imagem/logo50%.svg new file mode 100644 index 00000000..ab1a7bff --- /dev/null +++ b/project/app/static/imagem/logo50%.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/project/app/static/imagem/logoFinatec.png b/project/app/static/imagem/logoFinatec.png old mode 100644 new mode 100755 diff --git a/project/app/static/imagem/perfil.svg b/project/app/static/imagem/perfil.svg old mode 100644 new mode 100755 diff --git a/project/app/static/imagem/perfilC.svg b/project/app/static/imagem/perfilC.svg old mode 100644 new mode 100755 diff --git a/project/app/static/imagem/pesquisar.png b/project/app/static/imagem/pesquisar.png old mode 100644 new mode 100755 diff --git a/project/app/static/imagem/sairImg.svg b/project/app/static/imagem/sairImg.svg old mode 100644 new mode 100755 diff --git a/project/app/static/imagem/tick.png b/project/app/static/imagem/tick.png new file mode 100644 index 00000000..2e01f3e7 Binary files /dev/null and b/project/app/static/imagem/tick.png differ diff --git a/project/app/templates/404.html b/project/app/templates/404.html new file mode 100644 index 00000000..bab63f21 --- /dev/null +++ b/project/app/templates/404.html @@ -0,0 +1,23 @@ +{% extends 'base.html' %} +{% block conteudo %} +{% load static %} + +
+
+
+
+
Erro 404 - Página não encontrada
+ +
+ + +
+
+
+
+ +{% endblock %} \ No newline at end of file diff --git a/project/app/templates/base.html b/project/app/templates/base.html old mode 100644 new mode 100755 index d9efb18c..6ac5eeaa --- a/project/app/templates/base.html +++ b/project/app/templates/base.html @@ -5,26 +5,58 @@ AutomaTEC - + + - - + + + - - +
+ {% if request.path != '/' %} + + finatec + + {% else %} + finatec + {% endif %} +
+ + +
+ {% if request.path == '/' %} + Login + Admin + {% elif request.path == '/login/' %} + Home + Admin + {% else %} + Home + Login + Admin + {% endif %} +
+ - --> - {% block conteudo %} - - {% endblock %} -
Copyright BRISA 2021©. Todos direitos reservados.
+ + +
+ {% block conteudo %} + + {% endblock %} +
+ +
+
Copyright BRISA 2021©. Todos direitos reservados.
+
\ No newline at end of file diff --git a/project/app/templates/base_logged.html b/project/app/templates/base_logged.html new file mode 100755 index 00000000..d2a01068 --- /dev/null +++ b/project/app/templates/base_logged.html @@ -0,0 +1,66 @@ +{% load static %} + + + + AutomaTEC + + + + + + + + + + + + + + + + + +
+ {% block conteudo %} + + {% endblock %} +
+ +
+
Copyright BRISA 2021©. Todos direitos reservados.
+
+ + \ No newline at end of file diff --git a/project/app/templates/cadastro.html b/project/app/templates/cadastro.html deleted file mode 100644 index 6b9f33f0..00000000 --- a/project/app/templates/cadastro.html +++ /dev/null @@ -1,120 +0,0 @@ - \ No newline at end of file diff --git a/project/app/templates/cadastro_legado.html b/project/app/templates/cadastro_legado.html deleted file mode 100644 index 3cc2e497..00000000 --- a/project/app/templates/cadastro_legado.html +++ /dev/null @@ -1,99 +0,0 @@ -{% load static %} - - - - AutomaTEC - - - - - - - - - - - - -
- finatec -

Sistema de prestação automático

-
- -
- -

Cadastrar

-
- {% csrf_token %} -
-
- - -
-
- - -
-
- -
- {% if error_messages %} -
    - {% for message in error_messages %} -
  • {{ message }}
  • - {% endfor %} -
- {% endif %} -

Possui uma conta? Logar

-
-
-
Copyright BRISA 2021©. Todos direitos reservados.
- - - \ No newline at end of file diff --git a/project/app/templates/home.html b/project/app/templates/home.html old mode 100644 new mode 100755 index c66d1bd0..25104a57 --- a/project/app/templates/home.html +++ b/project/app/templates/home.html @@ -2,36 +2,22 @@ {% block conteudo %} {% load static %} - - -
- - -
+
+
+
+
Sistema de prestação de contas automático.
Facilidade no dia a dia da FINATEC.
+ +
- -
-
-

Automatec

-

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

- + + +
-
- logo +
+ logo
- +
{% endblock %} \ No newline at end of file diff --git a/project/app/templates/login.html b/project/app/templates/login.html old mode 100644 new mode 100755 index 50032b54..0805e6da --- a/project/app/templates/login.html +++ b/project/app/templates/login.html @@ -1,7 +1,7 @@ {% extends 'base.html' %} {% block conteudo %} {% load static %} - + + -
- - -
- - -
-

Login

- -
- {% csrf_token %} -
-
- - -
-
- - + +
+
+ +
+
+
+
+

Login

+
+ logo +
+ +
+ +
+ +
+
+ {% csrf_token %} + + + +
+
+ +
+ +
+
+ + +
+
+ +
+ +
+
+ + +
+
+ +
+ +
+ + {% if error_message %} +
+

{{ error_message }}

+
+ {% endif %} + + +
-
- -
- - {% if error_message %} -

{{ error_message }}

- {% endif %} -

Não possui uma conta? criar

+
- +
{% endblock %} \ No newline at end of file diff --git a/project/app/templates/login_legado.html b/project/app/templates/login_legado.html deleted file mode 100644 index a157f4a9..00000000 --- a/project/app/templates/login_legado.html +++ /dev/null @@ -1,95 +0,0 @@ -{% load static %} - - - - AutomaTEC - - - - - - - - - - - - -
- finatec -

Sistema de prestação automático

-
- - -
- -

Login

-
- {% csrf_token %} -
-
- - -
-
- - -
-
- -
- {% if error_message %} -

{{ error_message }}

- {% endif %} -

Não possui uma conta? criar

-
-
-
Copyright BRISA 2021©. Todos direitos reservados.
- - \ No newline at end of file diff --git a/project/app/templates/password_reset.html b/project/app/templates/password_reset.html new file mode 100644 index 00000000..2a3b4796 --- /dev/null +++ b/project/app/templates/password_reset.html @@ -0,0 +1,38 @@ +{% extends 'base.html' %} {% block conteudo %} {% load static %} +
+
+
+
+
+
+ Redefinição de senha +
+
+ Esqueceu sua senha? +
+

+ Insira seu email no campo abaixo, e nós te enviaremos um email com instruções para configurar sua nova senha. +

+
+ +
+ +
+ {% csrf_token %} +
+
+
+ + +
+
+ +
+
+
+
+
+
+
+
+{% endblock %} \ No newline at end of file diff --git a/project/app/templates/password_reset_complete.html b/project/app/templates/password_reset_complete.html new file mode 100644 index 00000000..992ed769 --- /dev/null +++ b/project/app/templates/password_reset_complete.html @@ -0,0 +1,24 @@ +{% extends 'base.html' %} {% block conteudo %} {% load static %} +
+
+
+
+
+
+ Redefinição de senha +
+
+ Redefinição de senha completa +
+

+ Sua senha foi redefinida. Você pode prosseguir o acesso com sua nova senha. +

+
+ Acessar +
+
+
+
+
+
+{% endblock %} \ No newline at end of file diff --git a/project/app/templates/password_reset_confirm.html b/project/app/templates/password_reset_confirm.html new file mode 100644 index 00000000..f471b210 --- /dev/null +++ b/project/app/templates/password_reset_confirm.html @@ -0,0 +1,3 @@ +{% extends 'base.html' %} {% block conteudo %} {% load static %} + +{% endblock %} \ No newline at end of file diff --git a/project/app/templates/password_reset_done.html b/project/app/templates/password_reset_done.html new file mode 100644 index 00000000..f3a466f3 --- /dev/null +++ b/project/app/templates/password_reset_done.html @@ -0,0 +1,38 @@ +{% extends 'base.html' %} {% block conteudo %} {% load static %} {% load static custom_filters %} +
+
+
+
+
+
+ Redefinição de senha +
+
+ Link enviado +
+

+ O link de redefinição de senha foi enviado para o seu endereço de email +

+ +
+ +
+ +
+ +
+ +
+
+ +
+
+
+
+{% endblock %} \ No newline at end of file diff --git a/project/app/templates/projeto.html b/project/app/templates/projeto.html old mode 100644 new mode 100755 index 1202171c..dbbffe68 --- a/project/app/templates/projeto.html +++ b/project/app/templates/projeto.html @@ -1,169 +1,196 @@ -{% extends 'base.html' %} {% block conteudo %} {% load static %} - - - -
- - - - -
+ #input-square { + border-radius: 20px; + padding: 10px; + color: white; + background-color: rgba(0, 0, 0, 0); + border: 1px solid white; + } - - -
- -

Selecione o projeto

-
- {% csrf_token %} -
-
- - -
-
- - -
-
- - -
-
- - - - + +
+ +
+
+
+
+
+ logo +

Selecione o projeto

+
+
+ +
+ + + {% csrf_token %} + + + + + {% for codigo in codigos %} + + {% endfor %} + + +
+ +
+
+
+ + +
+
+
+
+ + +
+
+
+ +
+ +
+ +
+ +
+
+ +
+
+ +
+ +
+ + +
+ +
-
- -
- - +
+
-{% endblock %} +{% endblock %} \ No newline at end of file diff --git a/project/app/templates/projeto_legado.html b/project/app/templates/projeto_legado.html deleted file mode 100644 index 26cfb632..00000000 --- a/project/app/templates/projeto_legado.html +++ /dev/null @@ -1,101 +0,0 @@ -{% load static %} - - - - AutomaTEC - - - - - - - - - - -
- finatec -

Sistema de prestação automático

-
- -
- {% csrf_token %} - -
- - - -
- -

Selecione o projeto

-
- {% csrf_token %} -
-
- - -
-
- - -
-
- - -
-
-
-
Copyright BRISA 2021©. Todos direitos reservados.
- - \ No newline at end of file diff --git a/project/app/templates/recibo.html b/project/app/templates/recibo.html new file mode 100644 index 00000000..a0ae941f --- /dev/null +++ b/project/app/templates/recibo.html @@ -0,0 +1,42 @@ + + + + + + Download Falhou + + + +
+

Download Falhou

+

O download não pôde ser concluído porque o recibo não foi encontrado.

+
+ + diff --git a/project/app/templates/report.html b/project/app/templates/report.html new file mode 100644 index 00000000..ec0c486a --- /dev/null +++ b/project/app/templates/report.html @@ -0,0 +1,42 @@ + + + + + + Download Falhou + + + +
+

Download Falhou

+

O download não pôde ser concluído porque a nota não foi encontrada.

+
+ + diff --git a/project/app/templates/user_activity_logs.html b/project/app/templates/user_activity_logs.html new file mode 100644 index 00000000..26ff0533 --- /dev/null +++ b/project/app/templates/user_activity_logs.html @@ -0,0 +1,108 @@ + +{% extends 'base.html' %} {% block conteudo %} {% load static %} + + + + + Activity Logs + + + +
+ + + +
+ +
+
+
+
+
User
+ +
+
+
Date
+
+
+ +
+
+ + +
+
+
+ +
+
+
+ + + + + + + + + + + + + {% for log in logs %} + + + + + + + + {% endfor %} + +
#TimestampUserTagActivity
{{ forloop.counter }} {{ log.timestamp }} {{ log.user_id }} {{ log.tag }} {{ log.activity }}
+ + +
+ + + + +{% endblock %} \ No newline at end of file diff --git a/project/app/templates/user_profile.html b/project/app/templates/user_profile.html new file mode 100644 index 00000000..546309df --- /dev/null +++ b/project/app/templates/user_profile.html @@ -0,0 +1,112 @@ +{% extends 'base_logged.html' %} +{% block conteudo %} +{% load static %} +{% load static custom_filters %} + + + +
+
+
+
+
{{ request.user }}
+
usuário
+ +
+ +
{{ request.user.email }}
+ email + +
+
+ +
+ {{ cpf }} +
+ cpf + +
+ + {% if messages %} +
    + {% for message in messages %} + {{ message }} + {% endfor %} +

+ {% endif %} + +
+
+ +
+
+ +
+
+
+
+
+
+ + + + + + + + + + + +{% endblock %} diff --git a/project/app/templatetags/custom_filters.py b/project/app/templatetags/custom_filters.py new file mode 100644 index 00000000..3e1ae726 --- /dev/null +++ b/project/app/templatetags/custom_filters.py @@ -0,0 +1,17 @@ +from django import template + +register = template.Library() + +@register.filter(name='first_letters') +def first_letters(email): + parts = email.split('@') + username = parts[0] + domain = parts[1] + asteriscos = '' + for i in range(len(username)-5): + asteriscos+='*' + + if len(username) <= 2: + return username + else: + return username[:2] + asteriscos + username[-2:] + '@' + domain diff --git a/project/app/testeBinToPdf.py b/project/app/testeBinToPdf.py new file mode 100644 index 00000000..2af92b78 --- /dev/null +++ b/project/app/testeBinToPdf.py @@ -0,0 +1,63 @@ +import pyodbc +import os + +def pegar_caminho(subdiretorio): + # Obtém o caminho do script atual + arq_atual = os.path.abspath(__file__) + + # Obtém o diretório do script + app = os.path.dirname(arq_atual) + + # Obtém o diretório pai do script + project = os.path.dirname(app) + + # Obtém o diretório pai do projeto + pipeline = os.path.dirname(project) + + # Junta o diretório pai do projeto com o subdiretório desejado + caminho_pipeline = os.path.join(pipeline, subdiretorio) + + return caminho_pipeline + +def pegar_pass(chave): + arq_atual = os.path.abspath(__file__) + app = os.path.dirname(arq_atual) + project = os.path.dirname(app) + pipeline = os.path.dirname(project) + desktop = os.path.dirname(pipeline) + caminho_pipeline = os.path.join(desktop, chave) + + return caminho_pipeline + + + +file_path = pegar_pass("passs.txt") +conStr = '' +with open(file_path, 'r') as file: + conStr = file.readline().strip() + +conn = pyodbc.connect(conStr) +cursor = conn.cursor() + +print(cursor) + +stringconsulta = """SELECT TOP 1000 [Pedido].[CodPedido] + ,[Pedido].[NumPedido] + ,[ArquivoBinario].[ArquivoBinario] + ,[Arquivo].* + ,[ArquivoBinario].* + + FROM [Conveniar].[dbo].[Pedido] + + LEFT JOIN [Conveniar].[dbo].[Arquivo] ON [Pedido].[CodPedido] = [Arquivo].[CodSolicitacao] + LEFT JOIN [ConveniarArquivo].[dbo].[ArquivoReferencia] ON [Arquivo].[CodArquivoReferencia] = [ArquivoReferencia].CodArquivoReferencia + LEFT JOIN [ConveniarArquivo].[dbo].[ArquivoBinario] ON [ArquivoReferencia].ChaveLocalArmazenamento = [ArquivoBinario].[CodArquivoBinario] + + WHERE NumPedido = '233412024'""" +with open("Output.pdf", "wb") as output_file: + cursor.execute(stringconsulta) + ablob = cursor.fetchone() + output_file.write(ablob[2]) + +cursor.close() +conn.close() \ No newline at end of file diff --git a/project/app/testeDelete.py b/project/app/testeDelete.py new file mode 100644 index 00000000..dbeac560 --- /dev/null +++ b/project/app/testeDelete.py @@ -0,0 +1,33 @@ +import os + +def deletar_arquivos_em_pasta(caminho_da_pasta): + # Verificar se o caminho é um diretório + if os.path.isdir(caminho_da_pasta): + # Listar todos os arquivos na pasta + arquivos = os.listdir(caminho_da_pasta) + # Imprimir o nome de cada arquivo + for arquivo in arquivos: + # Verificar se o arquivo é um arquivo XLSX + if arquivo.endswith('.xlsx'): + # Construir o caminho completo do arquivo + caminho_arquivo = os.path.join(caminho_da_pasta, arquivo) + # Tentar excluir o arquivo + try: + os.remove(caminho_arquivo) + print(f"Arquivo {arquivo} excluído com sucesso.") + except OSError as e: + print(f"Erro ao excluir o arquivo {arquivo}: {e}") + + else: + print("O caminho especificado não é um diretório.") + +# # Caminho da pasta de planilhas preenchidas +# caminhoPastaPlanilhasPreenchidas = "../../planilhas_preenchidas/" + + +# # +# diretorio_atual = os.path.dirname(os.path.abspath(__file__)) +# testeCaminho = os.path.join(diretorio_atual, caminhoPastaPlanilhasPreenchidas) + +# # Chamar a função para listar e imprimir os arquivos na pasta +# listar_arquivos_em_pasta(testeCaminho) \ No newline at end of file diff --git a/project/app/tests.py b/project/app/tests.py old mode 100644 new mode 100755 diff --git a/project/app/urls.py b/project/app/urls.py old mode 100644 new mode 100755 index d3b85efd..670415bf --- a/project/app/urls.py +++ b/project/app/urls.py @@ -1,16 +1,24 @@ from django.urls import path from . import views from django.contrib.auth import views as auth_views +from .views import user_activity_logs from .views import HomeView urlpatterns = [ path('', HomeView.as_view(), name='home'), - # path("cadastro/", views.cadastro, name="cadastro"), + path('login/', views.login, name='login' ), path('projeto/', views.projeto, name='projeto'), path('logout/', views.custom_logout, name='logout'), + path('perfil/', views.user_profile, name='user_profile'), + path('notas//', views.consultaNotas, name='notas'), + path('recibos//', views.download_base64_pdf, name='download_base64_pdf'), + #path('download-todos-arquivos//', views.download_todos_arquivos, name='download_todos_arquivos'), + # path('base/', views.base2, name='base'),- + # path('login_teste/', views.login_teste, name='login_teste'), - # path('cadastro_teste/', views.cadastro_teste, name='cadastro_teste'), # path('projeto_teste/', views.projeto_teste, name='projeto_teste'), + + path('user-activity-logs/', user_activity_logs, name='user_activity_logs'), ] \ No newline at end of file diff --git a/project/app/views.py b/project/app/views.py old mode 100644 new mode 100755 index 7b43081e..5daae9c3 --- a/project/app/views.py +++ b/project/app/views.py @@ -1,4 +1,18 @@ +import os +import shutil +import pyodbc +import datetime +import base64 +import io +import re +import tempfile +import json +import os +from PyPDF2 import PdfMerger +import zipfile +from django.conf import settings from django.shortcuts import render +from django.contrib.auth.decorators import user_passes_test from django.contrib.auth.models import User from django.contrib.auth import authenticate from django.contrib.auth import login as login_a @@ -8,69 +22,109 @@ 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 .models import Template, Employee +# 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 .preencherFinep import preencheFinep +from .preencheFundep import preenche_fundep +from .preencheFap import preencheFap +from .preencheFub import consultaID,preencheFub,split_archive_name +#from .preencherFinep import preencheFinep +from .capaFub import inserir_round_retangulo +from .capaGeral import inserir_round_retanguloGeral +from django.contrib.admin.models import LogEntry +from .models import UserActivity +from django.core.paginator import Paginator +from django.contrib import messages +from .testeDelete import deletar_arquivos_em_pasta +# from backend.consultas_oracledb import getlimitedRows,getallRows +from backend.consultaSQLServer import consultaCodConvenio, consultaTudo +import pandas as pd +from django.urls import reverse +from sqlalchemy import create_engine +from sqlalchemy.engine import URL +from .recibosAutomatizados import acharRecibo, acharReciboDevagar +def pegar_caminho(subdiretorio): + # Obtém o caminho do script atual + arq_atual = os.path.abspath(__file__) + + # Obtém o diretório do script + app = os.path.dirname(arq_atual) + + # Obtém o diretório pai do script + project = os.path.dirname(app) + + # Obtém o diretório pai do projeto + pipeline = os.path.dirname(project) + + # Junta o diretório pai do projeto com o subdiretório desejado + caminho_pipeline = os.path.join(pipeline, subdiretorio) + + return caminho_pipeline + +def pegar_pass(chave): + arq_atual = os.path.abspath(__file__) + app = os.path.dirname(arq_atual) + project = os.path.dirname(app) + pipeline = os.path.dirname(project) + desktop = os.path.dirname(pipeline) + caminho_pipeline = os.path.join(desktop, chave) + + return caminho_pipeline + + + +def log_user_activity(user_id, tag, activity): + UserActivity.objects.create(user_id=user_id, tag=tag, activity=activity) -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 convert_datetime_to_string2(value): + # Convert string to datetime object + date_object = datetime.datetime.strptime(value, "%Y-%m-%d") + + # Format the datetime object to the desired format + formatted_date = date_object.strftime("%d.%m.%Y") + + return formatted_date + 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": -# return render(request, 'cadastro.html') -# 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) -# except Exception as e: -# error_messages = e.messages -# return render(request, 'cadastro.html', {'error_messages': error_messages}) - -# user = User.objects.filter(username=usuario).first() - -# if user: -# error_messages = ['Usuário já existe'] -# return render(request, 'cadastro.html', {'error_messages': error_messages}) +@login_required(login_url="/login/") +def user_profile(request): + if request.method == 'POST': + user = User.objects.get(username__exact=request.user) -# 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}) + if request.POST.get('new_password1') == request.POST.get('new_password2') and authenticate(username=request.user, password=request.POST.get('old_password')): + user.set_password(request.POST.get('new_password1')) + user.save() + user_authenticated = authenticate(username=request.user, password=request.POST.get('old_password')) + log_message = f"Alterou a senha" + log_user_activity(request.user, "Sistema", log_message) + messages.success(request, "Senha alterada com sucesso!") + login_a(request, user_authenticated) + else: + messages.error(request, "A senha atual inserida, não corresponde com a senha atual. Tente novamente, ou procure o suporte.") -# 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() + cpf = Employee.objects.get(user=request.user).cpf + maskered_cpf = f"{cpf[0:3]}.{cpf[3:6]}.{cpf[6:9]}-{cpf[9:11]}" + + return render(request,'user_profile.html',{ + "cpf":maskered_cpf, + }) -# return HttpResponseRedirect('/login/') - def login(request): if request.method =="GET": return render(request, 'login.html') @@ -82,298 +136,503 @@ def login(request): if user: login_a(request, user) + log_message = f"Acessou o sistema" + log_user_activity(request.user, "Sistema", log_message) + + # carrega o dataframe para a sessao + df = consultaTudo() + request.session['df'] = df.to_json() + request.session['codigos'] = consultaCodConvenio(df) + return HttpResponseRedirect ('/projeto/') else: error_message = 'Usuário ou senha inválido.' + + log_message = f"Tentativa de acesso" + log_user_activity(usuario, "Sistema", log_message) + return render(request, 'login.html', {'error_message': error_message}) @login_required(login_url="/login/") def projeto(request): - # if request.user.is_authenticated: - # return HttpResponse('Projetos') - # else: - - 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] + if request.method == 'POST': + return projeto_legacy(request) + else: + # projects = [projeto['CODIGO'] for projeto in relevant_data] # Obtendo apenas os códigos dos projetos + return render(request, 'projeto.html', { + "templates": Template.objects.all(), + "codigos": request.session['codigos'] + }) + +def projeto_legacy(request): + lista_append_db_sql = [] + result = {} + current_key = None + mapeamento = None + + codigo = request.POST.get('codigo') # alterar o nome + template_id = request.POST.get('template') + consultaInicio = request.POST.get('inicio') + consultaFim = request.POST.get('fim') + + print(f"----------------------\n{codigo}\n{template_id}\n{consultaInicio}\n{consultaFim}\n{request.POST}\n-----------------------") + + print(type(consultaInicio)) + print(consultaFim) + emptyText = "" + + try: + db_fin = consultaID(codigo) + except: + print("Erro na consulta codigo inexistente ou invalido") + # 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: + print("deu ruim") + # return render(request,'projeto.html',{ + # "templates":Template.objects.all(), + # }) + + dict_final = {} + + caminho_pasta_planilhas = "../../planilhas/" + caminhoPastaPlanilhasPreenchidas = "../../planilhas_preenchidas/" + + # Obtém o diretório atual do script + diretorio_atual = os.path.dirname(os.path.abspath(__file__)) + + #deletar planilhas preendhidas + testeCaminho = os.path.join(diretorio_atual, caminhoPastaPlanilhasPreenchidas) + deletar_arquivos_em_pasta(testeCaminho) + + + #corrigindo datas + consultaInicial = convert_datetime_to_string2(consultaInicio) + consultaFinal = convert_datetime_to_string2(consultaFim) - 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) + print(consultaFinal) + + if nome.nome_template == "fundep": + # Combina o diretório atual com o caminho para a pasta "planilhas_preenchidas" e o nome do arquivo + testeCaminhoFundep = os.path.join(diretorio_atual, caminho_pasta_planilhas, f"ModeloFUNDEP.xlsx") + preenche_planilha(testeCaminhoFundep,dict_final,codigo,template_id,consultaInicial,consultaFinal,stringNomeFinanciador='FUNDEP') + if nome.nome_template == "fub": + testeCaminhoFub = os.path.join(diretorio_atual, caminho_pasta_planilhas, f"Modelo_Fub.xlsx") + preenche_planilha(testeCaminhoFub,dict_final,codigo,template_id,consultaInicial,consultaFinal,stringNomeFinanciador='FUB') + if nome.nome_template == "fap": + testeCaminhoFap = os.path.join(diretorio_atual, caminho_pasta_planilhas, f"modeloFap.xlsx") + preenche_planilha(testeCaminhoFap,dict_final,codigo,template_id,consultaInicial,consultaFinal,stringNomeFinanciador='FAP') - + if nome.nome_template == "finep": + testeCaminhoFap = os.path.join(diretorio_atual, caminho_pasta_planilhas, f"modeloFinep.xlsx") + preenche_planilha(testeCaminhoFap,dict_final,codigo,template_id,consultaInicial,consultaFinal,stringNomeFinanciador='FINEP') + + + file_path = None + print(f"download{template_id}") + if template_id == '1': + + # keys = ['NomeFavorecido','FavorecidoCPFCNPJ','NomeTipoLancamento', + # 'HisLancamento','NumDocPago','DataEmissao','NumChequeDeposito', + # 'DataPagamento', 'ValorPago'] + file_path = os.path.join(diretorio_atual, caminhoPastaPlanilhasPreenchidas, f"PC - FUB - {codigo} - {consultaInicial} a {consultaFinal}.xlsx") + preencheFub(codigo,convert_datetime_to_string(consultaInicio),convert_datetime_to_string(consultaFim),file_path) + inserir_round_retangulo(file_path,consultaInicio,consultaFim,db_fin) + + elif template_id == '2': + keys = ['NomeFavorecido','FavorecidoCPFCNPJ','NomeRubrica','NumDocPago', + 'DataEmissao','NumChequeDeposito','DataPagamento', 'ValorPago'] + file_path = os.path.join(diretorio_atual, caminhoPastaPlanilhasPreenchidas,f"PC - FUNDEP - {codigo} - {consultaInicial} a {consultaFinal}.xlsx") + #file_path = pegar_caminho('/home/ubuntu/Desktop/05_PipelineFinatec/planilhas_preenchidas/planilhaPreenchidaModeloFUNDEP.xlsx') + preenche_fundep(codigo,convert_datetime_to_string(consultaInicio),convert_datetime_to_string(consultaFim),keys,file_path) + + elif template_id == '5': + file_path = os.path.join(diretorio_atual, caminhoPastaPlanilhasPreenchidas, f"PC - FINEP - {codigo} - {consultaInicial} a {consultaFinal}.xlsx") + #file_path = os.path.join(diretorio_atual, caminhoPastaPlanilhasPreenchidas, f"PC - FAP - {codigo} - {consultaInicial} a {consultaFinal}.xlsx") + preencheFinep(codigo,convert_datetime_to_string(consultaInicio),convert_datetime_to_string(consultaFim),file_path) + inserir_round_retanguloGeral(file_path,consultaInicio,consultaFim,db_fin) + elif template_id == '4': + + file_path = os.path.join(diretorio_atual, caminhoPastaPlanilhasPreenchidas, f"PC - FAP - {codigo} - {consultaInicial} a {consultaFinal}.xlsx") + preencheFap(codigo,convert_datetime_to_string(consultaInicio),convert_datetime_to_string(consultaFim),file_path) + inserir_round_retanguloGeral(file_path,consultaInicio,consultaFim,db_fin) - - 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") + else: + # Handle cases where 'download' doesn't match any expected values + return HttpResponse("Invalid download request", status=400) + + # Check if the file exists + if os.path.exists(file_path): + with open(file_path, 'rb') as f: + response = HttpResponse(f.read(), content_type='application/octet-stream') + response['Content-Disposition'] = f'attachment; filename="{os.path.basename(file_path)}"' + + # adicionando log de consulta + consulta_log = f"Projeto: {codigo} | Modelo: {nome.nome_template} | Inicio da Prest.: {consultaInicio} | Fim da Prest.: {consultaFim}" + # LogEntry.objects.log_action(user_id=request.user.id, content_type_id=1, object_repr=consulta_log, action_flag=1, change_message="Consulta de prestação de contas") - return render(request,'projeto.html',{ - "templates":Template.objects.all(), + log_user_activity(request.user, "Consulta",consulta_log) + + return response + else: + print("Invalid aaaaaaaaaaa request") + + # return render(request,'projeto.html',{ + # "templates":Template.objects.all(), + # }) + + #delete the files + + - }) def custom_logout(request): logout(request) return redirect('/') -# def login_teste(request): -# if request.method =="GET": -# return render(request, 'login_teste.html') +from .models import UserActivity + +def is_admin(user): + return user.is_authenticated and user.is_staff + +@user_passes_test(is_admin) +def user_activity_logs(request): + logs_list = UserActivity.objects.all() + + # Filter by user_id + user_id_filter = request.GET.get('user_id') + if user_id_filter: + logs_list = logs_list.filter(user_id=user_id_filter) + + # Filter by date + date_filter = request.GET.get('date') + if date_filter: + logs_list = logs_list.filter(timestamp__date=date_filter) + + logs_list = logs_list.order_by('-timestamp') # Order logs by timestamp in descending order + + paginator = Paginator(logs_list, 50) # Show 50 logs per page + + page = request.GET.get('page') + logs = paginator.get_page(page) + + print(type(logs)) + + return render(request, 'user_activity_logs.html', {'logs': logs}) + + + + + +def consultaNotas(request, filename): + ''' + CARREGA PAGINA DAS NOTAS FISCAIS + ''' + try: + file_path = pegar_pass("passs.txt") + conStr = '' + with open(file_path, 'r') as file: + conStr = file.readline().strip() + conn = pyodbc.connect(conStr) + cursor = conn.cursor() + + # queryConsult = f""" + # SELECT [Pedido].[CodPedido], + # [Pedido].[NumPedido], + # [ArquivoBinario].[ArquivoBinario], + # [Arquivo].* + # FROM [Conveniar].[dbo].[Pedido] + # LEFT JOIN [Conveniar].[dbo].[Arquivo] + # ON [Pedido].[CodPedido] = [Arquivo].[CodSolicitacao] + # LEFT JOIN [ConveniarArquivo].[dbo].[ArquivoReferencia] + # ON [Arquivo].[CodArquivoReferencia] = [ArquivoReferencia].CodArquivoReferencia + # LEFT JOIN [ConveniarArquivo].[dbo].[ArquivoBinario] + # ON [ArquivoReferencia].ChaveLocalArmazenamento = [ArquivoBinario].[CodArquivoBinario] + # WHERE NumPedido = '{filename}' + # """ + queryConsult = f""" + SELECT [Pedido].[CodPedido], + [Pedido].[NumPedido], + [ArquivoBinario].[ArquivoBinario], + [Arquivo].[NomeArquivo] + FROM [Conveniar].[dbo].[Pedido] + LEFT JOIN [Conveniar].[dbo].[Arquivo] + ON [Pedido].[CodPedido] = [Arquivo].[CodSolicitacao] + LEFT JOIN [ConveniarArquivo].[dbo].[ArquivoReferencia] + ON [Arquivo].[CodArquivoReferencia] = [ArquivoReferencia].CodArquivoReferencia + LEFT JOIN [ConveniarArquivo].[dbo].[ArquivoBinario] + ON [ArquivoReferencia].ChaveLocalArmazenamento = [ArquivoBinario].[CodArquivoBinario] + WHERE NumPedido = '{filename}' + +UNION ALL + +SELECT [OPCompraAF].[CodOPCompraAF], + [OPCompraAF].[NumOPCompraAF], + [ArquivoBinario].[ArquivoBinario], + [ArquivoOpCompraAF].[NomeArquivoOpCompraAF] + FROM [Conveniar].[dbo].[OPCompraAF] + LEFT JOIN [Conveniar].[dbo].[ArquivoOpCompraAF] + ON [OPCompraAF].[CodOPCompraAF] = [ArquivoOpCompraAF].[CodOPCompraAF] + LEFT JOIN [ConveniarArquivo].[dbo].[ArquivoReferencia] + ON [ArquivoOpCompraAF].[CodArquivoReferencia] = [ArquivoReferencia].CodArquivoReferencia + LEFT JOIN [ConveniarArquivo].[dbo].[ArquivoBinario] + ON [ArquivoReferencia].ChaveLocalArmazenamento = [ArquivoBinario].[CodArquivoBinario] + WHERE [OPCompraAF].[NumOPCompraAF] = '{filename}' + + + """ + + cursor.execute(queryConsult) + + items = cursor.fetchall() + + #print(f'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{items}') + cwd = os.getcwd() + folder_name = "diretoriopdf" + folder_path = os.path.join(cwd, folder_name) + + if not os.path.exists(folder_path): + os.makedirs(folder_path) + print(f"Folder '{folder_name}' created successfully!") + else: + print(f"Folder '{folder_name}' already exists.") + + # Merge individual PDFs into one + merger = PdfMerger() + count = 0 + + for item in items: + pdf_data = item[2] + #print(f"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{pdf_data}") + if not pdf_data: + return render(request, 'report.html') + filename = item[1] + + # Write PDF data to temporary file + pdf_path = os.path.join(folder_name, f'{filename}{count}.pdf') + print(pdf_path) + with open(pdf_path, 'wb') as pdf_file: + pdf_file.write(pdf_data) + + # Add PDF to merger + merger.append(pdf_path) + count += 1 # Increment count + + + merged_pdf_filename = 'merged.pdf' + merged_pdf_path = os.path.join(folder_path, merged_pdf_filename) + print(merged_pdf_path) + merger.write(merged_pdf_path) + merger.close() + + with open(merged_pdf_path, 'rb') as merged_pdf_file: + response = HttpResponse(merged_pdf_file.read(), content_type='application/pdf') + response['Content-Disposition'] = f'attachment; filename="nota-{filename}.pdf"' + + + if os.path.exists(folder_path): + # Delete the folder and its contents + shutil.rmtree(folder_path) + print(f"The folder '{folder_name}' has been successfully deleted.") + else: + print(f"The folder '{folder_name}' does not exist.") + + return response + except Exception as e: + # Handle any exceptions + #return HttpResponse(f"An error occurred: {str(e)} NOTA NÃO EXISTE") + return render(request, 'report.html') + + +# def download_base64(request,filename): +# if request.method == 'GET': +# return download_base64_pdf(request,filename) # else: -# usuario = request.POST.get('usuario') -# senha = request.POST.get('senha') +# # projects = [projeto['CODIGO'] for projeto in relevant_data] # Obtendo apenas os códigos dos projetos +# return render(request, 'recibo.html') + +def download_base64_pdf(request, filename): + ''' + CARREGA PAGINA DOS RECIBOS + + ''' + try: + + + nota = acharRecibo("selenabot","finatec@300424",filename) + #print(nota) + string_with_substring = nota + substring_to_remove = "data:application/pdf;base64," + # Remove the substring + result_string = string_with_substring.replace(substring_to_remove, "") -# user = authenticate(username=usuario, password=senha) + #print(result_string) -# if user: -# login_a(request, user) -# return HttpResponseRedirect ('http://127.0.0.1:8000/projeto/') + + # Decode the Base64 content + pdf_content = base64.b64decode(result_string) + + # Create an HTTP response with the PDF content + response = HttpResponse(pdf_content, content_type='application/pdf') + response['Content-Disposition'] = f'attachment; filename="recibo-{filename}.pdf"' + return response + + except Exception as e: + # Handle any exceptions + #return HttpResponse(f"An error occurred: {str(e)} NOTA NÃO EXISTE") + return render(request, 'recibo.html') + +# def download_todos_arquivos(request,filename): +# ''' +# CARREGA PAGINA DAS NOTAS FISCAIS +# ''' +# try: +# file_path = pegar_pass("passs.txt") +# conStr = '' +# with open(file_path, 'r') as file: +# conStr = file.readline().strip() +# conn = pyodbc.connect(conStr) +# cursor = conn.cursor() +# name, date1, date2 = split_archive_name(filename) + +# listaPedidos = f""" +# SELECT +# NumDocFinConvenio + +# FROM [Conveniar].[dbo].[LisLancamentoConvenio] +# WHERE [LisLancamentoConvenio].CodConvenio = {name} AND [LisLancamentoConvenio].CodStatus = 27 +# AND [LisLancamentoConvenio].DataPagamento BETWEEN '{date1}' AND '{date2}' and [LisLancamentoConvenio].CodRubrica not in (2,0) +# order by DataPagamento + +# """ +# cursor.execute(listaPedidos) + +# #print(listaPedidos) + +# NumDocFinConvenios = cursor.fetchall() +# merged_pdf_responses = [] +# #print(NumDocFinConvenios) +# cwd = os.getcwd() +# folder_name = "temp_pdfs" +# folder_path = os.path.join(cwd, folder_name) + +# if not os.path.exists(folder_path): +# os.makedirs(folder_path) +# print(f"Folder '{folder_name}' created successfully!") # else: -# error_message = 'Usuário ou senha inválido.' -# return render(request, 'login_teste.html', {'error_message': error_message}) +# print(f"Folder '{folder_name}' already exists.") + +# for Doc in NumDocFinConvenios: +# print(type(Doc)) +# row_str = str(Doc[0]) +# print(row_str) +# queryConsult = f""" +# SELECT [Pedido].[CodPedido], +# [Pedido].[NumPedido], +# [ArquivoBinario].[ArquivoBinario], +# [Arquivo].[NomeArquivo] +# FROM [Conveniar].[dbo].[Pedido] +# LEFT JOIN [Conveniar].[dbo].[Arquivo] +# ON [Pedido].[CodPedido] = [Arquivo].[CodSolicitacao] +# LEFT JOIN [ConveniarArquivo].[dbo].[ArquivoReferencia] +# ON [Arquivo].[CodArquivoReferencia] = [ArquivoReferencia].CodArquivoReferencia +# LEFT JOIN [ConveniarArquivo].[dbo].[ArquivoBinario] +# ON [ArquivoReferencia].ChaveLocalArmazenamento = [ArquivoBinario].[CodArquivoBinario] +# WHERE NumPedido = '{row_str}' + +# UNION ALL + +# SELECT [OPCompraAF].[CodOPCompraAF], +# [OPCompraAF].[NumOPCompraAF], +# [ArquivoBinario].[ArquivoBinario], +# [ArquivoOpCompraAF].[NomeArquivoOpCompraAF] +# FROM [Conveniar].[dbo].[OPCompraAF] +# LEFT JOIN [Conveniar].[dbo].[ArquivoOpCompraAF] +# ON [OPCompraAF].[CodOPCompraAF] = [ArquivoOpCompraAF].[CodOPCompraAF] +# LEFT JOIN [ConveniarArquivo].[dbo].[ArquivoReferencia] +# ON [ArquivoOpCompraAF].[CodArquivoReferencia] = [ArquivoReferencia].CodArquivoReferencia +# LEFT JOIN [ConveniarArquivo].[dbo].[ArquivoBinario] +# ON [ArquivoReferencia].ChaveLocalArmazenamento = [ArquivoBinario].[CodArquivoBinario] +# WHERE [OPCompraAF].[NumOPCompraAF] = '{row_str}' + + +# """ +# #print(queryConsult) +# cursor.execute(queryConsult) +# items = cursor.fetchall() +# #print(items) + + + +# pdf_files = [] +# # Merge individual PDFs into one +# merger = PdfMerger() +# count = 0 +# conta = 0 +# for item in items: +# filename = item[1] +# pdf_data = item[2] +# #print(f"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{pdf_data}") +# if not pdf_data: + +# nota = acharRecibo("selenabot","finatec@300424",filename) +# #print(nota) +# string_with_substring = nota +# substring_to_remove = "data:application/pdf;base64," +# # Remove the substring +# result_string = string_with_substring.replace(substring_to_remove, "") + +# pdf_content = base64.b64decode(result_string) +# pdf_path = os.path.join(folder_name, f'{filename}{conta}.pdf') +# print(pdf_path) +# with open(pdf_path, 'wb') as pdf_file: +# pdf_file.write(pdf_content) + + +# else: +# # Write PDF data to temporary file +# pdf_path = os.path.join(folder_name, f'{filename}{count}.pdf') +# print(pdf_path) +# with open(pdf_path, 'wb') as pdf_file: +# pdf_file.write(pdf_data) + +# # Add PDF to merger + -# def cadastro_teste(request): -# if request.method == "GET": -# return render(request, 'cadastro_teste.html') -# else: -# usuario = request.POST.get('usuario') -# senha = request.POST.get('senha') - -# try: -# validate_password(senha, user=User) -# except Exception as e: -# error_messages = e.messages -# return render(request, 'cadastro_teste.html', {'error_messages': error_messages}) - -# user = User.objects.filter(username=usuario).first() - -# if user: -# error_messages = ['Usuário já existe'] -# return render(request, 'cadastro_teste.html', {'error_messages': error_messages}) - -# user = User.objects.create_user(username=usuario, password=senha) -# user.save() - -# @login_required(login_url="/") -# def projeto_teste(request): -# # if request.user.is_authenticated: -# # return HttpResponse('Projetos') -# # else: -# return render(request, 'projeto_teste.html') \ No newline at end of file +# # Create a temporary file path for the zip file +# zip_file_path = os.path.join(cwd, 'temp_pdfs.zip') + +# # Create a zip file +# with zipfile.ZipFile(zip_file_path, 'w') as zipf: +# for root, dirs, files in os.walk(folder_path): +# for file in files: +# file_path = os.path.join(root, file) +# zipf.write(file_path, os.path.relpath(file_path, folder_path)) + +# # Open the zip file +# with open(zip_file_path, 'rb') as f: +# response = HttpResponse(f.read(), content_type='application/zip') +# response['Content-Disposition'] = f'attachment; filename={name}_{date1}_{date2}.zip' + +# # Clean up: remove the temporary zip file +# os.remove(zip_file_path) +# if os.path.exists(folder_path): +# # Delete the folder and its contents +# shutil.rmtree(folder_path) +# print(f"The folder '{folder_name}' has been successfully deleted.") +# else: +# print(f"The folder '{folder_name}' does not exist.") +# return response + + +# except Exception as e: + # Handle any exceptions + return HttpResponse(f"An error occurred: {str(e)}") \ No newline at end of file diff --git a/project/backend/__init__.py b/project/backend/__init__.py old mode 100644 new mode 100755 diff --git a/project/backend/admin.py b/project/backend/admin.py old mode 100644 new mode 100755 diff --git a/project/backend/apps.py b/project/backend/apps.py old mode 100644 new mode 100755 diff --git a/project/backend/consultaSQLServer.py b/project/backend/consultaSQLServer.py new file mode 100644 index 00000000..881260e9 --- /dev/null +++ b/project/backend/consultaSQLServer.py @@ -0,0 +1,49 @@ +import pyodbc +import os +import pandas as pd +from sqlalchemy import create_engine +from sqlalchemy.engine import URL + + +def pegar_pass(chave): + arq_atual = os.path.abspath(__file__) + app = os.path.dirname(arq_atual) + project = os.path.dirname(app) + pipeline = os.path.dirname(project) + desktop = os.path.dirname(pipeline) + caminho_pipeline = os.path.join(desktop, chave) + + return caminho_pipeline + + + # return records + + +def consultaTudo(): + + file_path = pegar_pass("passs.txt") + conStr = '' + with open(file_path, 'r') as file: + conStr = file.readline().strip() + + connection_url = URL.create("mssql+pyodbc", query={"odbc_connect": conStr}) + engine = create_engine(connection_url) + queryConsultaComRubrica = f"SELECT * FROM [Conveniar].[dbo].[LisConvenio]" + dfconsultaDadosPorRubrica = pd.read_sql(queryConsultaComRubrica, engine) + + return dfconsultaDadosPorRubrica + +def consultaQtd(df, init, end): + final = init + end + slice_df = df.iloc[init:final, :] + + return slice_df + +def consultaCodConvenio(df): + return df['CodConvenio'].tolist() + +def consultaLimitedDict(df, length): + print("") + + + diff --git a/project/backend/consultas_oracledb.py b/project/backend/consultas_oracledb.py old mode 100644 new mode 100755 diff --git a/project/backend/migrations/__init__.py b/project/backend/migrations/__init__.py old mode 100644 new mode 100755 diff --git a/project/backend/models.py b/project/backend/models.py old mode 100644 new mode 100755 diff --git a/project/backend/templates/backend/base.html b/project/backend/templates/backend/base.html old mode 100644 new mode 100755 diff --git a/project/backend/templates/backend/projetos.html b/project/backend/templates/backend/projetos.html old mode 100644 new mode 100755 index 81f5628b..3438cff6 --- a/project/backend/templates/backend/projetos.html +++ b/project/backend/templates/backend/projetos.html @@ -1,195 +1,121 @@ -{% extends 'base.html' %} +{% extends 'base_logged.html' %} {% block conteudo %} {% load static %} - - - + {% elif data.has_previous and data.previous_page_number == 2 %} + 1 + {{ data.previous_page_number }} -
- - -
+ {% elif data.has_previous %} + 1 +

...

+ {{ data.previous_page_number }} -
+ {% endif %} -
-
- - -
-
+ {{ data.number }} - - - - - - - - - - - - - - - - - {% for entry in data %} - - - - - - - - - - - - - {% endfor %} - -
CódigoNomeFinanciadorData
Assinatura
Data
Vigência
CoordenadorValor
Aprovado
GrupoBaixar
{{ entry.CODIGO }}{{ entry.NOME | truncatechars:25 }}{{ entry.NOME_FINANCIADOR | title }}{{ entry.DATA_ASSINATURA | date:"d/m/Y" | center:"15" }}{{ entry.DATA_VIGENCIA | date:"d/m/Y" }}{{ entry.COORDENADOR | title}}R$ {{ entry.VALOR_APROVADO | floatformat:2 }}{{ entry.GRUPO_GESTORES }}btn_download

+ {% if data.has_next and data.next_page_number == data.paginator.num_pages %} + {{ data.paginator.num_pages }} - + {% endif %} + +
-{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/project/backend/tests.py b/project/backend/tests.py old mode 100644 new mode 100755 diff --git a/project/backend/urls.py b/project/backend/urls.py old mode 100644 new mode 100755 diff --git a/project/backend/views.py b/project/backend/views.py old mode 100644 new mode 100755 index e3be2504..dd275ed6 --- a/project/backend/views.py +++ b/project/backend/views.py @@ -1,29 +1,31 @@ from django.shortcuts import render from .consultas_oracledb import getlimitedRows,getallRows from django.core.paginator import Paginator,EmptyPage, PageNotAnInteger +from .consultaSQLServer import consultaLimitedDict +import pandas as pd # Create your views here. def project_views(request): - length = getallRows() - data = getlimitedRows(length) + length = pd.read_json(request.session['df']).shape[0] + data = pd.read_json(request.session['df']) + # data = consultaLimitedDict(pd.read_json(request.session['df']), length) + print(pd.read_json(request.session['df'])) relevant_data = [] - for key, inner_dict in data.items(): + for index, row in data.iterrows(): relevant_info = { - 'CODIGO': inner_dict.get('CODIGO', ''), - 'NOME': inner_dict.get('NOME', ''), - 'NOME_FINANCIADOR': inner_dict.get('NOME_FINANCIADOR', ''), - 'DATA_ASSINATURA': inner_dict.get('DATA_ASSINATURA', ''), - 'DATA_VIGENCIA': inner_dict.get('DATA_VIGENCIA', ''), - 'COORDENADOR': inner_dict.get('COORDENADOR', ''), - 'VALOR_APROVADO': inner_dict.get('VALOR_APROVADO', ''), - 'GRUPO_GESTORES': inner_dict.get('GRUPO_GESTORES', ''), - - - } + 'CODIGO': row['CodConvenio'], + 'NOME': row['NomeConvenio'], + 'NOME_FINANCIADOR': row['NomePessoaFinanciador'], + 'DATA_ASSINATURA': row['DataAssinatura'], + 'DATA_VIGENCIA': row['DataVigencia'], + 'COORDENADOR': row['NomePessoaResponsavel'], + # 'VALOR_APROVADO': row['VALOR_APROVADO'], + 'GRUPO_GESTORES': row['NomeGrupoGestor'], + } relevant_data.append(relevant_info) # Number of items to display per page - + print(relevant_data) search_query = request.GET.get('search', '') if search_query: search_results = [] diff --git a/project/db.sqlite3 b/project/db.sqlite3 old mode 100644 new mode 100755 diff --git a/project/project/__init__.py b/project/project/__init__.py old mode 100644 new mode 100755 diff --git a/project/project/asgi.py b/project/project/asgi.py old mode 100644 new mode 100755 diff --git a/project/project/populando_banco.py b/project/project/populando_banco.py old mode 100644 new mode 100755 diff --git a/project/project/settings.py b/project/project/settings.py old mode 100644 new mode 100755 index a2add47e..7a603f19 --- a/project/project/settings.py +++ b/project/project/settings.py @@ -6,7 +6,6 @@ # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent - # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/ @@ -28,11 +27,17 @@ 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', + 'django_admin_logs', 'app', 'backend', - + 'bootstrap_modal_forms', ] +PGHISTORY_CONFIG = { + 'schema_name': 'automatec', + 'history_table_suffix': '_history', +} + MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', @@ -57,7 +62,13 @@ 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], + + 'libraries':{ + 'first_letters': 'app.templatetags.custom_filters', + + } }, + }, ] @@ -70,20 +81,25 @@ with open(file_path, 'r') as file: password_database = file.readline().strip() -# DATABASES = { -# 'default': { -# 'ENGINE': 'django.db.backends.postgresql', -# 'NAME': 'automatec', -# 'USER': 'automauser', -# 'PASSWORD': password_database, -# 'HOST': '146.235.46.122', -# 'PORT': '5432', -# }, -# # 'default': { -# # 'ENGINE': 'django.db.backends.sqlite3', -# # 'NAME': BASE_DIR / 'db.sqlite3', -# # } -# } +file_path = "/home/ubuntu/Desktop/devfront/devfull/passemail.txt" +with open(file_path, 'r') as file: + password_email = file.readline().strip() + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.postgresql', + 'NAME': 'automatec', + 'USER': 'automauser', + 'PASSWORD': password_database, + 'HOST': '0.0.0.0', + 'PORT': '5432', + }, + # 'default': { + # 'ENGINE': 'django.db.backends.sqlite3', + # 'NAME': BASE_DIR / 'db.sqlite3', + # } +} + # DATABASES = { # 'default': { @@ -141,7 +157,7 @@ LANGUAGE_CODE = 'pt-br' -TIME_ZONE = 'UTC' +TIME_ZONE = 'America/Sao_Paulo' USE_I18N = True @@ -151,12 +167,27 @@ # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/4.2/howto/static-files/ -STATIC_URL = 'assets/' -STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles") -STATICFILES_DIRS = [ - os.path.join(BASE_DIR, "app/static") -] +# STATIC_URL = 'assets/' +# STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles") +# STATICFILES_DIRS = [ +# os.path.join(BASE_DIR, "app/static") +# ] + +STATIC_URL = '/static/' +STATIC_ROOT = '/home/05_PipelineFinatec/sites/public/static' +MEDIA_ROOT = 'home/05_PipelineFinatec/sites/public/static/imagem' + # Default primary key field type # https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' + +# configurando email de recuperacao +EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' +EMAIL_HOST = 'smtp.gmail.com' +EMAIL_PORT = 465 +EMAIL_USE_SSL = True +EMAIL_HOST_USER = "sistemas.finatec@finatec.org.br" +EMAIL_HOST_PASSWORD = password_email + + diff --git a/project/project/urls.py b/project/project/urls.py old mode 100644 new mode 100755 index aa668f2d..22dea843 --- a/project/project/urls.py +++ b/project/project/urls.py @@ -1,9 +1,21 @@ from django.contrib import admin from django.urls import include, path - +from django.contrib.auth import views as auth_views urlpatterns = [ path('', include('app.urls')), path('admin/', admin.site.urls), - path('projetos/',include('backend.urls')), -] + path('projetos/',include('backend.urls')), + + + # path('reset_password/', auth_views.PasswordResetView.as_view(), name="reset_password"), + # path('reset_password_sent/', auth_views.PasswordResetDoneView.as_view(), name="password_reset_done"), + path('reset//', auth_views.PasswordResetConfirmView.as_view(), name="password_reset_confirm"), + # path('reset_password_complete/', auth_views.PasswordResetCompleteView.as_view(), name="password_reset_complete"), + + path('reset_password/', auth_views.PasswordResetView.as_view(template_name="password_reset.html"), name="reset_password"), + path('reset_password_sent/', auth_views.PasswordResetDoneView.as_view(template_name="password_reset_done.html"), name="password_reset_done"), + # path('reset//', auth_views.PasswordResetConfirmView.as_view(template_name="password_reset_confirm.html"), name="password_reset_confirm"), + path('reset_password_complete/', auth_views.PasswordResetCompleteView.as_view(template_name="password_reset_complete.html"), name="password_reset_complete"), + +] \ No newline at end of file diff --git a/project/project/wsgi.py b/project/project/wsgi.py old mode 100644 new mode 100755 diff --git a/project/tabela b/project/tabela deleted file mode 100644 index 618551cd..00000000 Binary files a/project/tabela and /dev/null differ diff --git a/requirements.txt b/requirements.txt old mode 100644 new mode 100755 index 80b35f82..96426f23 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,24 @@ +# Django==4.2.4 +# openpyxl==3.0.10 +# pytest==7.1.2 Django==4.2.4 +asgiref==3.7.2 +attrs==23.1.0 +cffi==1.16.0 +cryptography==41.0.5 +et-xmlfile==1.1.0 +iniconfig==2.0.0 openpyxl==3.0.10 +oracledb==1.4.2 +packaging==23.2 +Pillow==10.1.0 +pluggy==1.3.0 +psycopg2-binary==2.9.9 +py==1.11.0 +pycparser==2.21 pytest==7.1.2 +sqlparse==0.4.4 +tomli==2.0.1 +typing-extensions==4.8.0 +Pillow==10.1.0 +python-dotenv \ No newline at end of file diff --git a/site/404.html b/site/404.html old mode 100644 new mode 100755 diff --git a/site/assets/images/favicon.png b/site/assets/images/favicon.png old mode 100644 new mode 100755 diff --git a/site/assets/javascripts/bundle.51198bba.min.js b/site/assets/javascripts/bundle.51198bba.min.js old mode 100644 new mode 100755 diff --git a/site/assets/javascripts/bundle.51198bba.min.js.map b/site/assets/javascripts/bundle.51198bba.min.js.map old mode 100644 new mode 100755 diff --git a/site/assets/javascripts/lunr/min/lunr.ar.min.js b/site/assets/javascripts/lunr/min/lunr.ar.min.js old mode 100644 new mode 100755 diff --git a/site/assets/javascripts/lunr/min/lunr.da.min.js b/site/assets/javascripts/lunr/min/lunr.da.min.js old mode 100644 new mode 100755 diff --git a/site/assets/javascripts/lunr/min/lunr.de.min.js b/site/assets/javascripts/lunr/min/lunr.de.min.js old mode 100644 new mode 100755 diff --git a/site/assets/javascripts/lunr/min/lunr.du.min.js b/site/assets/javascripts/lunr/min/lunr.du.min.js old mode 100644 new mode 100755 diff --git a/site/assets/javascripts/lunr/min/lunr.es.min.js b/site/assets/javascripts/lunr/min/lunr.es.min.js old mode 100644 new mode 100755 diff --git a/site/assets/javascripts/lunr/min/lunr.fi.min.js b/site/assets/javascripts/lunr/min/lunr.fi.min.js old mode 100644 new mode 100755 diff --git a/site/assets/javascripts/lunr/min/lunr.fr.min.js b/site/assets/javascripts/lunr/min/lunr.fr.min.js old mode 100644 new mode 100755 diff --git a/site/assets/javascripts/lunr/min/lunr.hi.min.js b/site/assets/javascripts/lunr/min/lunr.hi.min.js old mode 100644 new mode 100755 diff --git a/site/assets/javascripts/lunr/min/lunr.hu.min.js b/site/assets/javascripts/lunr/min/lunr.hu.min.js old mode 100644 new mode 100755 diff --git a/site/assets/javascripts/lunr/min/lunr.it.min.js b/site/assets/javascripts/lunr/min/lunr.it.min.js old mode 100644 new mode 100755 diff --git a/site/assets/javascripts/lunr/min/lunr.ja.min.js b/site/assets/javascripts/lunr/min/lunr.ja.min.js old mode 100644 new mode 100755 diff --git a/site/assets/javascripts/lunr/min/lunr.jp.min.js b/site/assets/javascripts/lunr/min/lunr.jp.min.js old mode 100644 new mode 100755 diff --git a/site/assets/javascripts/lunr/min/lunr.ko.min.js b/site/assets/javascripts/lunr/min/lunr.ko.min.js old mode 100644 new mode 100755 diff --git a/site/assets/javascripts/lunr/min/lunr.multi.min.js b/site/assets/javascripts/lunr/min/lunr.multi.min.js old mode 100644 new mode 100755 diff --git a/site/assets/javascripts/lunr/min/lunr.nl.min.js b/site/assets/javascripts/lunr/min/lunr.nl.min.js old mode 100644 new mode 100755 diff --git a/site/assets/javascripts/lunr/min/lunr.no.min.js b/site/assets/javascripts/lunr/min/lunr.no.min.js old mode 100644 new mode 100755 diff --git a/site/assets/javascripts/lunr/min/lunr.pt.min.js b/site/assets/javascripts/lunr/min/lunr.pt.min.js old mode 100644 new mode 100755 diff --git a/site/assets/javascripts/lunr/min/lunr.ro.min.js b/site/assets/javascripts/lunr/min/lunr.ro.min.js old mode 100644 new mode 100755 diff --git a/site/assets/javascripts/lunr/min/lunr.ru.min.js b/site/assets/javascripts/lunr/min/lunr.ru.min.js old mode 100644 new mode 100755 diff --git a/site/assets/javascripts/lunr/min/lunr.stemmer.support.min.js b/site/assets/javascripts/lunr/min/lunr.stemmer.support.min.js old mode 100644 new mode 100755 diff --git a/site/assets/javascripts/lunr/min/lunr.sv.min.js b/site/assets/javascripts/lunr/min/lunr.sv.min.js old mode 100644 new mode 100755 diff --git a/site/assets/javascripts/lunr/min/lunr.ta.min.js b/site/assets/javascripts/lunr/min/lunr.ta.min.js old mode 100644 new mode 100755 diff --git a/site/assets/javascripts/lunr/min/lunr.th.min.js b/site/assets/javascripts/lunr/min/lunr.th.min.js old mode 100644 new mode 100755 diff --git a/site/assets/javascripts/lunr/min/lunr.tr.min.js b/site/assets/javascripts/lunr/min/lunr.tr.min.js old mode 100644 new mode 100755 diff --git a/site/assets/javascripts/lunr/min/lunr.vi.min.js b/site/assets/javascripts/lunr/min/lunr.vi.min.js old mode 100644 new mode 100755 diff --git a/site/assets/javascripts/lunr/min/lunr.zh.min.js b/site/assets/javascripts/lunr/min/lunr.zh.min.js old mode 100644 new mode 100755 diff --git a/site/assets/javascripts/lunr/tinyseg.js b/site/assets/javascripts/lunr/tinyseg.js old mode 100644 new mode 100755 diff --git a/site/assets/javascripts/lunr/wordcut.js b/site/assets/javascripts/lunr/wordcut.js old mode 100644 new mode 100755 diff --git a/site/assets/javascripts/workers/search.208ed371.min.js b/site/assets/javascripts/workers/search.208ed371.min.js old mode 100644 new mode 100755 diff --git a/site/assets/javascripts/workers/search.208ed371.min.js.map b/site/assets/javascripts/workers/search.208ed371.min.js.map old mode 100644 new mode 100755 diff --git a/site/assets/stylesheets/main.ded33207.min.css b/site/assets/stylesheets/main.ded33207.min.css old mode 100644 new mode 100755 diff --git a/site/assets/stylesheets/main.ded33207.min.css.map b/site/assets/stylesheets/main.ded33207.min.css.map old mode 100644 new mode 100755 diff --git a/site/assets/stylesheets/palette.a0c5b2b5.min.css b/site/assets/stylesheets/palette.a0c5b2b5.min.css old mode 100644 new mode 100755 diff --git a/site/assets/stylesheets/palette.a0c5b2b5.min.css.map b/site/assets/stylesheets/palette.a0c5b2b5.min.css.map old mode 100644 new mode 100755 diff --git a/site/index.html b/site/index.html old mode 100644 new mode 100755 diff --git a/site/planejamento/escopo/index.html b/site/planejamento/escopo/index.html old mode 100644 new mode 100755 diff --git a/site/planejamento/heatmap/index.html b/site/planejamento/heatmap/index.html old mode 100644 new mode 100755 diff --git a/site/planejamento/metodologia/index.html b/site/planejamento/metodologia/index.html old mode 100644 new mode 100755 diff --git a/site/planejamento/tecnologias/index.html b/site/planejamento/tecnologias/index.html old mode 100644 new mode 100755 diff --git a/site/search/search_index.json b/site/search/search_index.json old mode 100644 new mode 100755 diff --git a/site/sitemap.xml b/site/sitemap.xml old mode 100644 new mode 100755 diff --git a/site/sitemap.xml.gz b/site/sitemap.xml.gz old mode 100644 new mode 100755 diff --git a/sites/public/imagem/finateclogo.svg b/sites/public/imagem/finateclogo.svg new file mode 100755 index 00000000..801b0b43 --- /dev/null +++ b/sites/public/imagem/finateclogo.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/sites/public/imagem/fundoLogo.svg b/sites/public/imagem/fundoLogo.svg new file mode 100755 index 00000000..8573006b --- /dev/null +++ b/sites/public/imagem/fundoLogo.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/sites/public/imagem/logo.svg b/sites/public/imagem/logo.svg new file mode 100755 index 00000000..d58c868e --- /dev/null +++ b/sites/public/imagem/logo.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/sites/public/imagem/logoFinatec.png b/sites/public/imagem/logoFinatec.png new file mode 100755 index 00000000..9a488715 Binary files /dev/null and b/sites/public/imagem/logoFinatec.png differ diff --git a/sites/public/imagem/perfil.svg b/sites/public/imagem/perfil.svg new file mode 100755 index 00000000..202307e3 --- /dev/null +++ b/sites/public/imagem/perfil.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/sites/public/imagem/perfilC.svg b/sites/public/imagem/perfilC.svg new file mode 100755 index 00000000..1d47b4d7 --- /dev/null +++ b/sites/public/imagem/perfilC.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/sites/public/imagem/sairImg.svg b/sites/public/imagem/sairImg.svg new file mode 100755 index 00000000..d17a0924 --- /dev/null +++ b/sites/public/imagem/sairImg.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/sites/public/static/admin/css/autocomplete.css b/sites/public/static/admin/css/autocomplete.css new file mode 100755 index 00000000..69c94e73 --- /dev/null +++ b/sites/public/static/admin/css/autocomplete.css @@ -0,0 +1,275 @@ +select.admin-autocomplete { + width: 20em; +} + +.select2-container--admin-autocomplete.select2-container { + min-height: 30px; +} + +.select2-container--admin-autocomplete .select2-selection--single, +.select2-container--admin-autocomplete .select2-selection--multiple { + min-height: 30px; + padding: 0; +} + +.select2-container--admin-autocomplete.select2-container--focus .select2-selection, +.select2-container--admin-autocomplete.select2-container--open .select2-selection { + border-color: var(--body-quiet-color); + min-height: 30px; +} + +.select2-container--admin-autocomplete.select2-container--focus .select2-selection.select2-selection--single, +.select2-container--admin-autocomplete.select2-container--open .select2-selection.select2-selection--single { + padding: 0; +} + +.select2-container--admin-autocomplete.select2-container--focus .select2-selection.select2-selection--multiple, +.select2-container--admin-autocomplete.select2-container--open .select2-selection.select2-selection--multiple { + padding: 0; +} + +.select2-container--admin-autocomplete .select2-selection--single { + background-color: var(--body-bg); + border: 1px solid var(--border-color); + border-radius: 4px; +} + +.select2-container--admin-autocomplete .select2-selection--single .select2-selection__rendered { + color: var(--body-fg); + line-height: 30px; +} + +.select2-container--admin-autocomplete .select2-selection--single .select2-selection__clear { + cursor: pointer; + float: right; + font-weight: bold; +} + +.select2-container--admin-autocomplete .select2-selection--single .select2-selection__placeholder { + color: var(--body-quiet-color); +} + +.select2-container--admin-autocomplete .select2-selection--single .select2-selection__arrow { + height: 26px; + position: absolute; + top: 1px; + right: 1px; + width: 20px; +} + +.select2-container--admin-autocomplete .select2-selection--single .select2-selection__arrow b { + border-color: #888 transparent transparent transparent; + border-style: solid; + border-width: 5px 4px 0 4px; + height: 0; + left: 50%; + margin-left: -4px; + margin-top: -2px; + position: absolute; + top: 50%; + width: 0; +} + +.select2-container--admin-autocomplete[dir="rtl"] .select2-selection--single .select2-selection__clear { + float: left; +} + +.select2-container--admin-autocomplete[dir="rtl"] .select2-selection--single .select2-selection__arrow { + left: 1px; + right: auto; +} + +.select2-container--admin-autocomplete.select2-container--disabled .select2-selection--single { + background-color: var(--darkened-bg); + cursor: default; +} + +.select2-container--admin-autocomplete.select2-container--disabled .select2-selection--single .select2-selection__clear { + display: none; +} + +.select2-container--admin-autocomplete.select2-container--open .select2-selection--single .select2-selection__arrow b { + border-color: transparent transparent #888 transparent; + border-width: 0 4px 5px 4px; +} + +.select2-container--admin-autocomplete .select2-selection--multiple { + background-color: var(--body-bg); + border: 1px solid var(--border-color); + border-radius: 4px; + cursor: text; +} + +.select2-container--admin-autocomplete .select2-selection--multiple .select2-selection__rendered { + box-sizing: border-box; + list-style: none; + margin: 0; + padding: 0 10px 5px 5px; + width: 100%; + display: flex; + flex-wrap: wrap; +} + +.select2-container--admin-autocomplete .select2-selection--multiple .select2-selection__rendered li { + list-style: none; +} + +.select2-container--admin-autocomplete .select2-selection--multiple .select2-selection__placeholder { + color: var(--body-quiet-color); + margin-top: 5px; + float: left; +} + +.select2-container--admin-autocomplete .select2-selection--multiple .select2-selection__clear { + cursor: pointer; + float: right; + font-weight: bold; + margin: 5px; + position: absolute; + right: 0; +} + +.select2-container--admin-autocomplete .select2-selection--multiple .select2-selection__choice { + background-color: var(--darkened-bg); + border: 1px solid var(--border-color); + border-radius: 4px; + cursor: default; + float: left; + margin-right: 5px; + margin-top: 5px; + padding: 0 5px; +} + +.select2-container--admin-autocomplete .select2-selection--multiple .select2-selection__choice__remove { + color: var(--body-quiet-color); + cursor: pointer; + display: inline-block; + font-weight: bold; + margin-right: 2px; +} + +.select2-container--admin-autocomplete .select2-selection--multiple .select2-selection__choice__remove:hover { + color: var(--body-fg); +} + +.select2-container--admin-autocomplete[dir="rtl"] .select2-selection--multiple .select2-selection__choice, .select2-container--admin-autocomplete[dir="rtl"] .select2-selection--multiple .select2-selection__placeholder, .select2-container--admin-autocomplete[dir="rtl"] .select2-selection--multiple .select2-search--inline { + float: right; +} + +.select2-container--admin-autocomplete[dir="rtl"] .select2-selection--multiple .select2-selection__choice { + margin-left: 5px; + margin-right: auto; +} + +.select2-container--admin-autocomplete[dir="rtl"] .select2-selection--multiple .select2-selection__choice__remove { + margin-left: 2px; + margin-right: auto; +} + +.select2-container--admin-autocomplete.select2-container--focus .select2-selection--multiple { + border: solid var(--body-quiet-color) 1px; + outline: 0; +} + +.select2-container--admin-autocomplete.select2-container--disabled .select2-selection--multiple { + background-color: var(--darkened-bg); + cursor: default; +} + +.select2-container--admin-autocomplete.select2-container--disabled .select2-selection__choice__remove { + display: none; +} + +.select2-container--admin-autocomplete.select2-container--open.select2-container--above .select2-selection--single, .select2-container--admin-autocomplete.select2-container--open.select2-container--above .select2-selection--multiple { + border-top-left-radius: 0; + border-top-right-radius: 0; +} + +.select2-container--admin-autocomplete.select2-container--open.select2-container--below .select2-selection--single, .select2-container--admin-autocomplete.select2-container--open.select2-container--below .select2-selection--multiple { + border-bottom-left-radius: 0; + border-bottom-right-radius: 0; +} + +.select2-container--admin-autocomplete .select2-search--dropdown { + background: var(--darkened-bg); +} + +.select2-container--admin-autocomplete .select2-search--dropdown .select2-search__field { + background: var(--body-bg); + color: var(--body-fg); + border: 1px solid var(--border-color); + border-radius: 4px; +} + +.select2-container--admin-autocomplete .select2-search--inline .select2-search__field { + background: transparent; + color: var(--body-fg); + border: none; + outline: 0; + box-shadow: none; + -webkit-appearance: textfield; +} + +.select2-container--admin-autocomplete .select2-results > .select2-results__options { + max-height: 200px; + overflow-y: auto; + color: var(--body-fg); + background: var(--body-bg); +} + +.select2-container--admin-autocomplete .select2-results__option[role=group] { + padding: 0; +} + +.select2-container--admin-autocomplete .select2-results__option[aria-disabled=true] { + color: var(--body-quiet-color); +} + +.select2-container--admin-autocomplete .select2-results__option[aria-selected=true] { + background-color: var(--selected-bg); + color: var(--body-fg); +} + +.select2-container--admin-autocomplete .select2-results__option .select2-results__option { + padding-left: 1em; +} + +.select2-container--admin-autocomplete .select2-results__option .select2-results__option .select2-results__group { + padding-left: 0; +} + +.select2-container--admin-autocomplete .select2-results__option .select2-results__option .select2-results__option { + margin-left: -1em; + padding-left: 2em; +} + +.select2-container--admin-autocomplete .select2-results__option .select2-results__option .select2-results__option .select2-results__option { + margin-left: -2em; + padding-left: 3em; +} + +.select2-container--admin-autocomplete .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option { + margin-left: -3em; + padding-left: 4em; +} + +.select2-container--admin-autocomplete .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option { + margin-left: -4em; + padding-left: 5em; +} + +.select2-container--admin-autocomplete .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option { + margin-left: -5em; + padding-left: 6em; +} + +.select2-container--admin-autocomplete .select2-results__option--highlighted[aria-selected] { + background-color: var(--primary); + color: var(--primary-fg); +} + +.select2-container--admin-autocomplete .select2-results__group { + cursor: default; + display: block; + padding: 6px; +} diff --git a/sites/public/static/admin/css/base.css b/sites/public/static/admin/css/base.css new file mode 100755 index 00000000..72f4ae16 --- /dev/null +++ b/sites/public/static/admin/css/base.css @@ -0,0 +1,1138 @@ +/* + DJANGO Admin styles +*/ + +/* VARIABLE DEFINITIONS */ +html[data-theme="light"], +:root { + --primary: #79aec8; + --secondary: #417690; + --accent: #f5dd5d; + --primary-fg: #fff; + + --body-fg: #333; + --body-bg: #fff; + --body-quiet-color: #666; + --body-loud-color: #000; + + --header-color: #ffc; + --header-branding-color: var(--accent); + --header-bg: var(--secondary); + --header-link-color: var(--primary-fg); + + --breadcrumbs-fg: #c4dce8; + --breadcrumbs-link-fg: var(--body-bg); + --breadcrumbs-bg: var(--primary); + + --link-fg: #417893; + --link-hover-color: #036; + --link-selected-fg: #5b80b2; + + --hairline-color: #e8e8e8; + --border-color: #ccc; + + --error-fg: #ba2121; + + --message-success-bg: #dfd; + --message-warning-bg: #ffc; + --message-error-bg: #ffefef; + + --darkened-bg: #f8f8f8; /* A bit darker than --body-bg */ + --selected-bg: #e4e4e4; /* E.g. selected table cells */ + --selected-row: #ffc; + + --button-fg: #fff; + --button-bg: var(--primary); + --button-hover-bg: #609ab6; + --default-button-bg: var(--secondary); + --default-button-hover-bg: #205067; + --close-button-bg: #747474; + --close-button-hover-bg: #333; + --delete-button-bg: #ba2121; + --delete-button-hover-bg: #a41515; + + --object-tools-fg: var(--button-fg); + --object-tools-bg: var(--close-button-bg); + --object-tools-hover-bg: var(--close-button-hover-bg); + + --font-family-primary: + -apple-system, + BlinkMacSystemFont, + "Segoe UI", + system-ui, + Roboto, + "Helvetica Neue", + Arial, + sans-serif, + "Apple Color Emoji", + "Segoe UI Emoji", + "Segoe UI Symbol", + "Noto Color Emoji"; + --font-family-monospace: + ui-monospace, + Menlo, + Monaco, + "Cascadia Mono", + "Segoe UI Mono", + "Roboto Mono", + "Oxygen Mono", + "Ubuntu Monospace", + "Source Code Pro", + "Fira Mono", + "Droid Sans Mono", + "Courier New", + monospace, + "Apple Color Emoji", + "Segoe UI Emoji", + "Segoe UI Symbol", + "Noto Color Emoji"; +} + +html, body { + height: 100%; +} + +body { + margin: 0; + padding: 0; + font-size: 0.875rem; + font-family: var(--font-family-primary); + color: var(--body-fg); + background: var(--body-bg); +} + +/* LINKS */ + +a:link, a:visited { + color: var(--link-fg); + text-decoration: none; + transition: color 0.15s, background 0.15s; +} + +a:focus, a:hover { + color: var(--link-hover-color); +} + +a:focus { + text-decoration: underline; +} + +a img { + border: none; +} + +a.section:link, a.section:visited { + color: var(--header-link-color); + text-decoration: none; +} + +a.section:focus, a.section:hover { + text-decoration: underline; +} + +/* GLOBAL DEFAULTS */ + +p, ol, ul, dl { + margin: .2em 0 .8em 0; +} + +p { + padding: 0; + line-height: 140%; +} + +h1,h2,h3,h4,h5 { + font-weight: bold; +} + +h1 { + margin: 0 0 20px; + font-weight: 300; + font-size: 1.25rem; + color: var(--body-quiet-color); +} + +h2 { + font-size: 1rem; + margin: 1em 0 .5em 0; +} + +h2.subhead { + font-weight: normal; + margin-top: 0; +} + +h3 { + font-size: 0.875rem; + margin: .8em 0 .3em 0; + color: var(--body-quiet-color); + font-weight: bold; +} + +h4 { + font-size: 0.75rem; + margin: 1em 0 .8em 0; + padding-bottom: 3px; +} + +h5 { + font-size: 0.625rem; + margin: 1.5em 0 .5em 0; + color: var(--body-quiet-color); + text-transform: uppercase; + letter-spacing: 1px; +} + +ul > li { + list-style-type: square; + padding: 1px 0; +} + +li ul { + margin-bottom: 0; +} + +li, dt, dd { + font-size: 0.8125rem; + line-height: 1.25rem; +} + +dt { + font-weight: bold; + margin-top: 4px; +} + +dd { + margin-left: 0; +} + +form { + margin: 0; + padding: 0; +} + +fieldset { + margin: 0; + min-width: 0; + padding: 0; + border: none; + border-top: 1px solid var(--hairline-color); +} + +blockquote { + font-size: 0.6875rem; + color: #777; + margin-left: 2px; + padding-left: 10px; + border-left: 5px solid #ddd; +} + +code, pre { + font-family: var(--font-family-monospace); + color: var(--body-quiet-color); + font-size: 0.75rem; + overflow-x: auto; +} + +pre.literal-block { + margin: 10px; + background: var(--darkened-bg); + padding: 6px 8px; +} + +code strong { + color: #930; +} + +hr { + clear: both; + color: var(--hairline-color); + background-color: var(--hairline-color); + height: 1px; + border: none; + margin: 0; + padding: 0; + line-height: 1px; +} + +/* TEXT STYLES & MODIFIERS */ + +.small { + font-size: 0.6875rem; +} + +.mini { + font-size: 0.625rem; +} + +.help, p.help, form p.help, div.help, form div.help, div.help li { + font-size: 0.6875rem; + color: var(--body-quiet-color); +} + +div.help ul { + margin-bottom: 0; +} + +.help-tooltip { + cursor: help; +} + +p img, h1 img, h2 img, h3 img, h4 img, td img { + vertical-align: middle; +} + +.quiet, a.quiet:link, a.quiet:visited { + color: var(--body-quiet-color); + font-weight: normal; +} + +.clear { + clear: both; +} + +.nowrap { + white-space: nowrap; +} + +.hidden { + display: none !important; +} + +/* TABLES */ + +table { + border-collapse: collapse; + border-color: var(--border-color); +} + +td, th { + font-size: 0.8125rem; + line-height: 1rem; + border-bottom: 1px solid var(--hairline-color); + vertical-align: top; + padding: 8px; +} + +th { + font-weight: 600; + text-align: left; +} + +thead th, +tfoot td { + color: var(--body-quiet-color); + padding: 5px 10px; + font-size: 0.6875rem; + background: var(--body-bg); + border: none; + border-top: 1px solid var(--hairline-color); + border-bottom: 1px solid var(--hairline-color); +} + +tfoot td { + border-bottom: none; + border-top: 1px solid var(--hairline-color); +} + +thead th.required { + color: var(--body-loud-color); +} + +tr.alt { + background: var(--darkened-bg); +} + +tr:nth-child(odd), .row-form-errors { + background: var(--body-bg); +} + +tr:nth-child(even), +tr:nth-child(even) .errorlist, +tr:nth-child(odd) + .row-form-errors, +tr:nth-child(odd) + .row-form-errors .errorlist { + background: var(--darkened-bg); +} + +/* SORTABLE TABLES */ + +thead th { + padding: 5px 10px; + line-height: normal; + text-transform: uppercase; + background: var(--darkened-bg); +} + +thead th a:link, thead th a:visited { + color: var(--body-quiet-color); +} + +thead th.sorted { + background: var(--selected-bg); +} + +thead th.sorted .text { + padding-right: 42px; +} + +table thead th .text span { + padding: 8px 10px; + display: block; +} + +table thead th .text a { + display: block; + cursor: pointer; + padding: 8px 10px; +} + +table thead th .text a:focus, table thead th .text a:hover { + background: var(--selected-bg); +} + +thead th.sorted a.sortremove { + visibility: hidden; +} + +table thead th.sorted:hover a.sortremove { + visibility: visible; +} + +table thead th.sorted .sortoptions { + display: block; + padding: 9px 5px 0 5px; + float: right; + text-align: right; +} + +table thead th.sorted .sortpriority { + font-size: .8em; + min-width: 12px; + text-align: center; + vertical-align: 3px; + margin-left: 2px; + margin-right: 2px; +} + +table thead th.sorted .sortoptions a { + position: relative; + width: 14px; + height: 14px; + display: inline-block; + background: url(../img/sorting-icons.svg) 0 0 no-repeat; + background-size: 14px auto; +} + +table thead th.sorted .sortoptions a.sortremove { + background-position: 0 0; +} + +table thead th.sorted .sortoptions a.sortremove:after { + content: '\\'; + position: absolute; + top: -6px; + left: 3px; + font-weight: 200; + font-size: 1.125rem; + color: var(--body-quiet-color); +} + +table thead th.sorted .sortoptions a.sortremove:focus:after, +table thead th.sorted .sortoptions a.sortremove:hover:after { + color: var(--link-fg); +} + +table thead th.sorted .sortoptions a.sortremove:focus, +table thead th.sorted .sortoptions a.sortremove:hover { + background-position: 0 -14px; +} + +table thead th.sorted .sortoptions a.ascending { + background-position: 0 -28px; +} + +table thead th.sorted .sortoptions a.ascending:focus, +table thead th.sorted .sortoptions a.ascending:hover { + background-position: 0 -42px; +} + +table thead th.sorted .sortoptions a.descending { + top: 1px; + background-position: 0 -56px; +} + +table thead th.sorted .sortoptions a.descending:focus, +table thead th.sorted .sortoptions a.descending:hover { + background-position: 0 -70px; +} + +/* FORM DEFAULTS */ + +input, textarea, select, .form-row p, form .button { + margin: 2px 0; + padding: 2px 3px; + vertical-align: middle; + font-family: var(--font-family-primary); + font-weight: normal; + font-size: 0.8125rem; +} +.form-row div.help { + padding: 2px 3px; +} + +textarea { + vertical-align: top; +} + +input[type=text], input[type=password], input[type=email], input[type=url], +input[type=number], input[type=tel], textarea, select, .vTextField { + border: 1px solid var(--border-color); + border-radius: 4px; + padding: 5px 6px; + margin-top: 0; + color: var(--body-fg); + background-color: var(--body-bg); +} + +input[type=text]:focus, input[type=password]:focus, input[type=email]:focus, +input[type=url]:focus, input[type=number]:focus, input[type=tel]:focus, +textarea:focus, select:focus, .vTextField:focus { + border-color: var(--body-quiet-color); +} + +select { + height: 1.875rem; +} + +select[multiple] { + /* Allow HTML size attribute to override the height in the rule above. */ + height: auto; + min-height: 150px; +} + +/* FORM BUTTONS */ + +.button, input[type=submit], input[type=button], .submit-row input, a.button { + background: var(--button-bg); + padding: 10px 15px; + border: none; + border-radius: 4px; + color: var(--button-fg); + cursor: pointer; + transition: background 0.15s; +} + +a.button { + padding: 4px 5px; +} + +.button:active, input[type=submit]:active, input[type=button]:active, +.button:focus, input[type=submit]:focus, input[type=button]:focus, +.button:hover, input[type=submit]:hover, input[type=button]:hover { + background: var(--button-hover-bg); +} + +.button[disabled], input[type=submit][disabled], input[type=button][disabled] { + opacity: 0.4; +} + +.button.default, input[type=submit].default, .submit-row input.default { + border: none; + font-weight: 400; + background: var(--default-button-bg); +} + +.button.default:active, input[type=submit].default:active, +.button.default:focus, input[type=submit].default:focus, +.button.default:hover, input[type=submit].default:hover { + background: var(--default-button-hover-bg); +} + +.button[disabled].default, +input[type=submit][disabled].default, +input[type=button][disabled].default { + opacity: 0.4; +} + + +/* MODULES */ + +.module { + border: none; + margin-bottom: 30px; + background: var(--body-bg); +} + +.module p, .module ul, .module h3, .module h4, .module dl, .module pre { + padding-left: 10px; + padding-right: 10px; +} + +.module blockquote { + margin-left: 12px; +} + +.module ul, .module ol { + margin-left: 1.5em; +} + +.module h3 { + margin-top: .6em; +} + +.module h2, .module caption, .inline-group h2 { + margin: 0; + padding: 8px; + font-weight: 400; + font-size: 0.8125rem; + text-align: left; + background: var(--primary); + color: var(--header-link-color); +} + +.module caption, +.inline-group h2 { + font-size: 0.75rem; + letter-spacing: 0.5px; + text-transform: uppercase; +} + +.module table { + border-collapse: collapse; +} + +/* MESSAGES & ERRORS */ + +ul.messagelist { + padding: 0; + margin: 0; +} + +ul.messagelist li { + display: block; + font-weight: 400; + font-size: 0.8125rem; + padding: 10px 10px 10px 65px; + margin: 0 0 10px 0; + background: var(--message-success-bg) url(../img/icon-yes.svg) 40px 12px no-repeat; + background-size: 16px auto; + color: var(--body-fg); + word-break: break-word; +} + +ul.messagelist li.warning { + background: var(--message-warning-bg) url(../img/icon-alert.svg) 40px 14px no-repeat; + background-size: 14px auto; +} + +ul.messagelist li.error { + background: var(--message-error-bg) url(../img/icon-no.svg) 40px 12px no-repeat; + background-size: 16px auto; +} + +.errornote { + font-size: 0.875rem; + font-weight: 700; + display: block; + padding: 10px 12px; + margin: 0 0 10px 0; + color: var(--error-fg); + border: 1px solid var(--error-fg); + border-radius: 4px; + background-color: var(--body-bg); + background-position: 5px 12px; + overflow-wrap: break-word; +} + +ul.errorlist { + margin: 0 0 4px; + padding: 0; + color: var(--error-fg); + background: var(--body-bg); +} + +ul.errorlist li { + font-size: 0.8125rem; + display: block; + margin-bottom: 4px; + overflow-wrap: break-word; +} + +ul.errorlist li:first-child { + margin-top: 0; +} + +ul.errorlist li a { + color: inherit; + text-decoration: underline; +} + +td ul.errorlist { + margin: 0; + padding: 0; +} + +td ul.errorlist li { + margin: 0; +} + +.form-row.errors { + margin: 0; + border: none; + border-bottom: 1px solid var(--hairline-color); + background: none; +} + +.form-row.errors ul.errorlist li { + padding-left: 0; +} + +.errors input, .errors select, .errors textarea, +td ul.errorlist + input, td ul.errorlist + select, td ul.errorlist + textarea { + border: 1px solid var(--error-fg); +} + +.description { + font-size: 0.75rem; + padding: 5px 0 0 12px; +} + +/* BREADCRUMBS */ + +div.breadcrumbs { + background: var(--breadcrumbs-bg); + padding: 10px 40px; + border: none; + color: var(--breadcrumbs-fg); + text-align: left; +} + +div.breadcrumbs a { + color: var(--breadcrumbs-link-fg); +} + +div.breadcrumbs a:focus, div.breadcrumbs a:hover { + color: var(--breadcrumbs-fg); +} + +/* ACTION ICONS */ + +.viewlink, .inlineviewlink { + padding-left: 16px; + background: url(../img/icon-viewlink.svg) 0 1px no-repeat; +} + +.addlink { + padding-left: 16px; + background: url(../img/icon-addlink.svg) 0 1px no-repeat; +} + +.changelink, .inlinechangelink { + padding-left: 16px; + background: url(../img/icon-changelink.svg) 0 1px no-repeat; +} + +.deletelink { + padding-left: 16px; + background: url(../img/icon-deletelink.svg) 0 1px no-repeat; +} + +a.deletelink:link, a.deletelink:visited { + color: #CC3434; /* XXX Probably unused? */ +} + +a.deletelink:focus, a.deletelink:hover { + color: #993333; /* XXX Probably unused? */ + text-decoration: none; +} + +/* OBJECT TOOLS */ + +.object-tools { + font-size: 0.625rem; + font-weight: bold; + padding-left: 0; + float: right; + position: relative; + margin-top: -48px; +} + +.object-tools li { + display: block; + float: left; + margin-left: 5px; + height: 1rem; +} + +.object-tools a { + border-radius: 15px; +} + +.object-tools a:link, .object-tools a:visited { + display: block; + float: left; + padding: 3px 12px; + background: var(--object-tools-bg); + color: var(--object-tools-fg); + font-weight: 400; + font-size: 0.6875rem; + text-transform: uppercase; + letter-spacing: 0.5px; +} + +.object-tools a:focus, .object-tools a:hover { + background-color: var(--object-tools-hover-bg); +} + +.object-tools a:focus{ + text-decoration: none; +} + +.object-tools a.viewsitelink, .object-tools a.addlink { + background-repeat: no-repeat; + background-position: right 7px center; + padding-right: 26px; +} + +.object-tools a.viewsitelink { + background-image: url(../img/tooltag-arrowright.svg); +} + +.object-tools a.addlink { + background-image: url(../img/tooltag-add.svg); +} + +/* OBJECT HISTORY */ + +#change-history table { + width: 100%; +} + +#change-history table tbody th { + width: 16em; +} + +#change-history .paginator { + color: var(--body-quiet-color); + border-bottom: 1px solid var(--hairline-color); + background: var(--body-bg); + overflow: hidden; +} + +/* PAGE STRUCTURE */ + +#container { + position: relative; + width: 100%; + min-width: 980px; + padding: 0; + display: flex; + flex-direction: column; + height: 100%; +} + +#container > div { + flex-shrink: 0; +} + +#container > .main { + display: flex; + flex: 1 0 auto; +} + +.main > .content { + flex: 1 0; + max-width: 100%; +} + +.skip-to-content-link { + position: absolute; + top: -999px; + margin: 5px; + padding: 5px; + background: var(--body-bg); + z-index: 1; +} + +.skip-to-content-link:focus { + left: 0px; + top: 0px; +} + +#content { + padding: 20px 40px; +} + +.dashboard #content { + width: 600px; +} + +#content-main { + float: left; + width: 100%; +} + +#content-related { + float: right; + width: 260px; + position: relative; + margin-right: -300px; +} + +#footer { + clear: both; + padding: 10px; +} + +/* COLUMN TYPES */ + +.colMS { + margin-right: 300px; +} + +.colSM { + margin-left: 300px; +} + +.colSM #content-related { + float: left; + margin-right: 0; + margin-left: -300px; +} + +.colSM #content-main { + float: right; +} + +.popup .colM { + width: auto; +} + +/* HEADER */ + +#header { + width: auto; + height: auto; + display: flex; + justify-content: space-between; + align-items: center; + padding: 10px 40px; + background: var(--header-bg); + color: var(--header-color); + overflow: hidden; +} + +#header a:link, #header a:visited, #logout-form button { + color: var(--header-link-color); +} + +#header a:focus , #header a:hover { + text-decoration: underline; +} + +#branding { + display: flex; +} + +#branding h1 { + padding: 0; + margin: 0; + margin-inline-end: 20px; + font-weight: 300; + font-size: 1.5rem; + color: var(--header-branding-color); +} + +#branding h1 a:link, #branding h1 a:visited { + color: var(--accent); +} + +#branding h2 { + padding: 0 10px; + font-size: 0.875rem; + margin: -8px 0 8px 0; + font-weight: normal; + color: var(--header-color); +} + +#branding a:hover { + text-decoration: none; +} + +#logout-form { + display: inline; +} + +#logout-form button { + background: none; + border: 0; + cursor: pointer; + font-family: var(--font-family-primary); +} + +#user-tools { + float: right; + margin: 0 0 0 20px; + text-align: right; +} + +#user-tools, #logout-form button{ + padding: 0; + font-weight: 300; + font-size: 0.6875rem; + letter-spacing: 0.5px; + text-transform: uppercase; +} + +#user-tools a, #logout-form button { + border-bottom: 1px solid rgba(255, 255, 255, 0.25); +} + +#user-tools a:focus, #user-tools a:hover, +#logout-form button:active, #logout-form button:hover { + text-decoration: none; + border-bottom: 0; +} + +#logout-form button:active, #logout-form button:hover { + margin-bottom: 1px; +} + +/* SIDEBAR */ + +#content-related { + background: var(--darkened-bg); +} + +#content-related .module { + background: none; +} + +#content-related h3 { + color: var(--body-quiet-color); + padding: 0 16px; + margin: 0 0 16px; +} + +#content-related h4 { + font-size: 0.8125rem; +} + +#content-related p { + padding-left: 16px; + padding-right: 16px; +} + +#content-related .actionlist { + padding: 0; + margin: 16px; +} + +#content-related .actionlist li { + line-height: 1.2; + margin-bottom: 10px; + padding-left: 18px; +} + +#content-related .module h2 { + background: none; + padding: 16px; + margin-bottom: 16px; + border-bottom: 1px solid var(--hairline-color); + font-size: 1.125rem; + color: var(--body-fg); +} + +.delete-confirmation form input[type="submit"] { + background: var(--delete-button-bg); + border-radius: 4px; + padding: 10px 15px; + color: var(--button-fg); +} + +.delete-confirmation form input[type="submit"]:active, +.delete-confirmation form input[type="submit"]:focus, +.delete-confirmation form input[type="submit"]:hover { + background: var(--delete-button-hover-bg); +} + +.delete-confirmation form .cancel-link { + display: inline-block; + vertical-align: middle; + height: 0.9375rem; + line-height: 0.9375rem; + border-radius: 4px; + padding: 10px 15px; + color: var(--button-fg); + background: var(--close-button-bg); + margin: 0 0 0 10px; +} + +.delete-confirmation form .cancel-link:active, +.delete-confirmation form .cancel-link:focus, +.delete-confirmation form .cancel-link:hover { + background: var(--close-button-hover-bg); +} + +/* POPUP */ +.popup #content { + padding: 20px; +} + +.popup #container { + min-width: 0; +} + +.popup #header { + padding: 10px 20px; +} + +/* PAGINATOR */ + +.paginator { + font-size: 0.8125rem; + padding-top: 10px; + padding-bottom: 10px; + line-height: 22px; + margin: 0; + border-top: 1px solid var(--hairline-color); + width: 100%; +} + +.paginator a:link, .paginator a:visited { + padding: 2px 6px; + background: var(--button-bg); + text-decoration: none; + color: var(--button-fg); +} + +.paginator a.showall { + border: none; + background: none; + color: var(--link-fg); +} + +.paginator a.showall:focus, .paginator a.showall:hover { + background: none; + color: var(--link-hover-color); +} + +.paginator .end { + margin-right: 6px; +} + +.paginator .this-page { + padding: 2px 6px; + font-weight: bold; + font-size: 0.8125rem; + vertical-align: top; +} + +.paginator a:focus, .paginator a:hover { + color: white; + background: var(--link-hover-color); +} + +.base-svgs { + display: none; +} diff --git a/sites/public/static/admin/css/changelists.css b/sites/public/static/admin/css/changelists.css new file mode 100755 index 00000000..a7545131 --- /dev/null +++ b/sites/public/static/admin/css/changelists.css @@ -0,0 +1,328 @@ +/* CHANGELISTS */ + +#changelist { + display: flex; + align-items: flex-start; + justify-content: space-between; +} + +#changelist .changelist-form-container { + flex: 1 1 auto; + min-width: 0; +} + +#changelist table { + width: 100%; +} + +.change-list .hiddenfields { display:none; } + +.change-list .filtered table { + border-right: none; +} + +.change-list .filtered { + min-height: 400px; +} + +.change-list .filtered .results, .change-list .filtered .paginator, +.filtered #toolbar, .filtered div.xfull { + width: auto; +} + +.change-list .filtered table tbody th { + padding-right: 1em; +} + +#changelist-form .results { + overflow-x: auto; + width: 100%; +} + +#changelist .toplinks { + border-bottom: 1px solid var(--hairline-color); +} + +#changelist .paginator { + color: var(--body-quiet-color); + border-bottom: 1px solid var(--hairline-color); + background: var(--body-bg); + overflow: hidden; +} + +/* CHANGELIST TABLES */ + +#changelist table thead th { + padding: 0; + white-space: nowrap; + vertical-align: middle; +} + +#changelist table thead th.action-checkbox-column { + width: 1.5em; + text-align: center; +} + +#changelist table tbody td.action-checkbox { + text-align: center; +} + +#changelist table tfoot { + color: var(--body-quiet-color); +} + +/* TOOLBAR */ + +#toolbar { + padding: 8px 10px; + margin-bottom: 15px; + border-top: 1px solid var(--hairline-color); + border-bottom: 1px solid var(--hairline-color); + background: var(--darkened-bg); + color: var(--body-quiet-color); +} + +#toolbar form input { + border-radius: 4px; + font-size: 0.875rem; + padding: 5px; + color: var(--body-fg); +} + +#toolbar #searchbar { + height: 1.1875rem; + border: 1px solid var(--border-color); + padding: 2px 5px; + margin: 0; + vertical-align: top; + font-size: 0.8125rem; + max-width: 100%; +} + +#toolbar #searchbar:focus { + border-color: var(--body-quiet-color); +} + +#toolbar form input[type="submit"] { + border: 1px solid var(--border-color); + font-size: 0.8125rem; + padding: 4px 8px; + margin: 0; + vertical-align: middle; + background: var(--body-bg); + box-shadow: 0 -15px 20px -10px rgba(0, 0, 0, 0.15) inset; + cursor: pointer; + color: var(--body-fg); +} + +#toolbar form input[type="submit"]:focus, +#toolbar form input[type="submit"]:hover { + border-color: var(--body-quiet-color); +} + +#changelist-search img { + vertical-align: middle; + margin-right: 4px; +} + +#changelist-search .help { + word-break: break-word; +} + +/* FILTER COLUMN */ + +#changelist-filter { + flex: 0 0 240px; + order: 1; + background: var(--darkened-bg); + border-left: none; + margin: 0 0 0 30px; +} + +#changelist-filter h2 { + font-size: 0.875rem; + text-transform: uppercase; + letter-spacing: 0.5px; + padding: 5px 15px; + margin-bottom: 12px; + border-bottom: none; +} + +#changelist-filter h3, +#changelist-filter details summary { + font-weight: 400; + padding: 0 15px; + margin-bottom: 10px; +} + +#changelist-filter details summary > * { + display: inline; +} + +#changelist-filter details > summary { + list-style-type: none; +} + +#changelist-filter details > summary::-webkit-details-marker { + display: none; +} + +#changelist-filter details > summary::before { + content: '→'; + font-weight: bold; + color: var(--link-hover-color); +} + +#changelist-filter details[open] > summary::before { + content: '↓'; +} + +#changelist-filter ul { + margin: 5px 0; + padding: 0 15px 15px; + border-bottom: 1px solid var(--hairline-color); +} + +#changelist-filter ul:last-child { + border-bottom: none; +} + +#changelist-filter li { + list-style-type: none; + margin-left: 0; + padding-left: 0; +} + +#changelist-filter a { + display: block; + color: var(--body-quiet-color); + word-break: break-word; +} + +#changelist-filter li.selected { + border-left: 5px solid var(--hairline-color); + padding-left: 10px; + margin-left: -15px; +} + +#changelist-filter li.selected a { + color: var(--link-selected-fg); +} + +#changelist-filter a:focus, #changelist-filter a:hover, +#changelist-filter li.selected a:focus, +#changelist-filter li.selected a:hover { + color: var(--link-hover-color); +} + +#changelist-filter #changelist-filter-clear a { + font-size: 0.8125rem; + padding-bottom: 10px; + border-bottom: 1px solid var(--hairline-color); +} + +/* DATE DRILLDOWN */ + +.change-list .toplinks { + display: flex; + padding-bottom: 5px; + flex-wrap: wrap; + gap: 3px 17px; + font-weight: bold; +} + +.change-list .toplinks a { + font-size: 0.8125rem; +} + +.change-list .toplinks .date-back { + color: var(--body-quiet-color); +} + +.change-list .toplinks .date-back:focus, +.change-list .toplinks .date-back:hover { + color: var(--link-hover-color); +} + +/* ACTIONS */ + +.filtered .actions { + border-right: none; +} + +#changelist table input { + margin: 0; + vertical-align: baseline; +} + +/* Once the :has() pseudo-class is supported by all browsers, the tr.selected + selector and the JS adding the class can be removed. */ +#changelist tbody tr.selected { + background-color: var(--selected-row); +} + +#changelist tbody tr:has(.action-select:checked) { + background-color: var(--selected-row); +} + +#changelist .actions { + padding: 10px; + background: var(--body-bg); + border-top: none; + border-bottom: none; + line-height: 1.5rem; + color: var(--body-quiet-color); + width: 100%; +} + +#changelist .actions span.all, +#changelist .actions span.action-counter, +#changelist .actions span.clear, +#changelist .actions span.question { + font-size: 0.8125rem; + margin: 0 0.5em; +} + +#changelist .actions:last-child { + border-bottom: none; +} + +#changelist .actions select { + vertical-align: top; + height: 1.5rem; + color: var(--body-fg); + border: 1px solid var(--border-color); + border-radius: 4px; + font-size: 0.875rem; + padding: 0 0 0 4px; + margin: 0; + margin-left: 10px; +} + +#changelist .actions select:focus { + border-color: var(--body-quiet-color); +} + +#changelist .actions label { + display: inline-block; + vertical-align: middle; + font-size: 0.8125rem; +} + +#changelist .actions .button { + font-size: 0.8125rem; + border: 1px solid var(--border-color); + border-radius: 4px; + background: var(--body-bg); + box-shadow: 0 -15px 20px -10px rgba(0, 0, 0, 0.15) inset; + cursor: pointer; + height: 1.5rem; + line-height: 1; + padding: 4px 8px; + margin: 0; + color: var(--body-fg); +} + +#changelist .actions .button:focus, #changelist .actions .button:hover { + border-color: var(--body-quiet-color); +} diff --git a/sites/public/static/admin/css/dark_mode.css b/sites/public/static/admin/css/dark_mode.css new file mode 100755 index 00000000..6d08233a --- /dev/null +++ b/sites/public/static/admin/css/dark_mode.css @@ -0,0 +1,137 @@ +@media (prefers-color-scheme: dark) { + :root { + --primary: #264b5d; + --primary-fg: #f7f7f7; + + --body-fg: #eeeeee; + --body-bg: #121212; + --body-quiet-color: #e0e0e0; + --body-loud-color: #ffffff; + + --breadcrumbs-link-fg: #e0e0e0; + --breadcrumbs-bg: var(--primary); + + --link-fg: #81d4fa; + --link-hover-color: #4ac1f7; + --link-selected-fg: #6f94c6; + + --hairline-color: #272727; + --border-color: #353535; + + --error-fg: #e35f5f; + --message-success-bg: #006b1b; + --message-warning-bg: #583305; + --message-error-bg: #570808; + + --darkened-bg: #212121; + --selected-bg: #1b1b1b; + --selected-row: #00363a; + + --close-button-bg: #333333; + --close-button-hover-bg: #666666; + } + } + + +html[data-theme="dark"] { + --primary: #264b5d; + --primary-fg: #f7f7f7; + + --body-fg: #eeeeee; + --body-bg: #121212; + --body-quiet-color: #e0e0e0; + --body-loud-color: #ffffff; + + --breadcrumbs-link-fg: #e0e0e0; + --breadcrumbs-bg: var(--primary); + + --link-fg: #81d4fa; + --link-hover-color: #4ac1f7; + --link-selected-fg: #6f94c6; + + --hairline-color: #272727; + --border-color: #353535; + + --error-fg: #e35f5f; + --message-success-bg: #006b1b; + --message-warning-bg: #583305; + --message-error-bg: #570808; + + --darkened-bg: #212121; + --selected-bg: #1b1b1b; + --selected-row: #00363a; + + --close-button-bg: #333333; + --close-button-hover-bg: #666666; +} + +/* THEME SWITCH */ +.theme-toggle { + cursor: pointer; + border: none; + padding: 0; + background: transparent; + vertical-align: middle; + margin-inline-start: 5px; + margin-top: -1px; +} + +.theme-toggle svg { + vertical-align: middle; + height: 1rem; + width: 1rem; + display: none; +} + +/* +Fully hide screen reader text so we only show the one matching the current +theme. +*/ +.theme-toggle .visually-hidden { + display: none; +} + +html[data-theme="auto"] .theme-toggle .theme-label-when-auto { + display: block; +} + +html[data-theme="dark"] .theme-toggle .theme-label-when-dark { + display: block; +} + +html[data-theme="light"] .theme-toggle .theme-label-when-light { + display: block; +} + +/* ICONS */ +.theme-toggle svg.theme-icon-when-auto, +.theme-toggle svg.theme-icon-when-dark, +.theme-toggle svg.theme-icon-when-light { + fill: var(--header-link-color); + color: var(--header-bg); +} + +html[data-theme="auto"] .theme-toggle svg.theme-icon-when-auto { + display: block; +} + +html[data-theme="dark"] .theme-toggle svg.theme-icon-when-dark { + display: block; +} + +html[data-theme="light"] .theme-toggle svg.theme-icon-when-light { + display: block; +} + +.visually-hidden { + position: absolute; + width: 1px; + height: 1px; + padding: 0; + overflow: hidden; + clip: rect(0,0,0,0); + white-space: nowrap; + border: 0; + color: var(--body-fg); + background-color: var(--body-bg); +} diff --git a/sites/public/static/admin/css/dashboard.css b/sites/public/static/admin/css/dashboard.css new file mode 100755 index 00000000..242b81a4 --- /dev/null +++ b/sites/public/static/admin/css/dashboard.css @@ -0,0 +1,29 @@ +/* DASHBOARD */ +.dashboard td, .dashboard th { + word-break: break-word; +} + +.dashboard .module table th { + width: 100%; +} + +.dashboard .module table td { + white-space: nowrap; +} + +.dashboard .module table td a { + display: block; + padding-right: .6em; +} + +/* RECENT ACTIONS MODULE */ + +.module ul.actionlist { + margin-left: 0; +} + +ul.actionlist li { + list-style-type: none; + overflow: hidden; + text-overflow: ellipsis; +} diff --git a/sites/public/static/admin/css/forms.css b/sites/public/static/admin/css/forms.css new file mode 100755 index 00000000..e45abe1c --- /dev/null +++ b/sites/public/static/admin/css/forms.css @@ -0,0 +1,530 @@ +@import url('widgets.css'); + +/* FORM ROWS */ + +.form-row { + overflow: hidden; + padding: 10px; + font-size: 0.8125rem; + border-bottom: 1px solid var(--hairline-color); +} + +.form-row img, .form-row input { + vertical-align: middle; +} + +.form-row label input[type="checkbox"] { + margin-top: 0; + vertical-align: 0; +} + +form .form-row p { + padding-left: 0; +} + +.flex-container { + display: flex; + flex-wrap: wrap; +} + +.form-multiline > div { + padding-bottom: 10px; +} + +/* FORM LABELS */ + +label { + font-weight: normal; + color: var(--body-quiet-color); + font-size: 0.8125rem; +} + +.required label, label.required { + font-weight: bold; + color: var(--body-fg); +} + +/* RADIO BUTTONS */ + +form div.radiolist div { + padding-right: 7px; +} + +form div.radiolist.inline div { + display: inline-block; +} + +form div.radiolist label { + width: auto; +} + +form div.radiolist input[type="radio"] { + margin: -2px 4px 0 0; + padding: 0; +} + +form ul.inline { + margin-left: 0; + padding: 0; +} + +form ul.inline li { + float: left; + padding-right: 7px; +} + +/* ALIGNED FIELDSETS */ + +.aligned label { + display: block; + padding: 4px 10px 0 0; + width: 160px; + word-wrap: break-word; + line-height: 1; +} + +.aligned label:not(.vCheckboxLabel):after { + content: ''; + display: inline-block; + vertical-align: middle; + height: 1.625rem; +} + +.aligned label + p, .aligned .checkbox-row + div.help, .aligned label + div.readonly { + padding: 6px 0; + margin-top: 0; + margin-bottom: 0; + margin-left: 0; + overflow-wrap: break-word; +} + +.aligned ul label { + display: inline; + float: none; + width: auto; +} + +.aligned .form-row input { + margin-bottom: 0; +} + +.colMS .aligned .vLargeTextField, .colMS .aligned .vXMLLargeTextField { + width: 350px; +} + +form .aligned ul { + margin-left: 160px; + padding-left: 10px; +} + +form .aligned div.radiolist { + display: inline-block; + margin: 0; + padding: 0; +} + +form .aligned p.help, +form .aligned div.help { + margin-top: 0; + margin-left: 160px; + padding-left: 10px; +} + +form .aligned p.date div.help.timezonewarning, +form .aligned p.datetime div.help.timezonewarning, +form .aligned p.time div.help.timezonewarning { + margin-left: 0; + padding-left: 0; + font-weight: normal; +} + +form .aligned p.help:last-child, +form .aligned div.help:last-child { + margin-bottom: 0; + padding-bottom: 0; +} + +form .aligned input + p.help, +form .aligned textarea + p.help, +form .aligned select + p.help, +form .aligned input + div.help, +form .aligned textarea + div.help, +form .aligned select + div.help { + margin-left: 160px; + padding-left: 10px; +} + +form .aligned ul li { + list-style: none; +} + +form .aligned table p { + margin-left: 0; + padding-left: 0; +} + +.aligned .vCheckboxLabel { + float: none; + width: auto; + display: inline-block; + vertical-align: -3px; + padding: 0 0 5px 5px; +} + +.aligned .vCheckboxLabel + p.help, +.aligned .vCheckboxLabel + div.help { + margin-top: -4px; +} + +.colM .aligned .vLargeTextField, .colM .aligned .vXMLLargeTextField { + width: 610px; +} + +fieldset .fieldBox { + margin-right: 20px; +} + +/* WIDE FIELDSETS */ + +.wide label { + width: 200px; +} + +form .wide p, +form .wide ul.errorlist, +form .wide input + p.help, +form .wide input + div.help { + margin-left: 200px; +} + +form .wide p.help, +form .wide div.help { + padding-left: 50px; +} + +form div.help ul { + padding-left: 0; + margin-left: 0; +} + +.colM fieldset.wide .vLargeTextField, .colM fieldset.wide .vXMLLargeTextField { + width: 450px; +} + +/* COLLAPSED FIELDSETS */ + +fieldset.collapsed * { + display: none; +} + +fieldset.collapsed h2, fieldset.collapsed { + display: block; +} + +fieldset.collapsed { + border: 1px solid var(--hairline-color); + border-radius: 4px; + overflow: hidden; +} + +fieldset.collapsed h2 { + background: var(--darkened-bg); + color: var(--body-quiet-color); +} + +fieldset .collapse-toggle { + color: var(--header-link-color); +} + +fieldset.collapsed .collapse-toggle { + background: transparent; + display: inline; + color: var(--link-fg); +} + +/* MONOSPACE TEXTAREAS */ + +fieldset.monospace textarea { + font-family: var(--font-family-monospace); +} + +/* SUBMIT ROW */ + +.submit-row { + padding: 12px 14px 12px; + margin: 0 0 20px; + background: var(--darkened-bg); + border: 1px solid var(--hairline-color); + border-radius: 4px; + overflow: hidden; + display: flex; + gap: 10px; + flex-wrap: wrap; +} + +body.popup .submit-row { + overflow: auto; +} + +.submit-row input { + height: 2.1875rem; + line-height: 0.9375rem; +} + +.submit-row input, .submit-row a { + margin: 0; +} + +.submit-row input.default { + text-transform: uppercase; +} + +.submit-row a.deletelink { + margin-left: auto; +} + +.submit-row a.deletelink { + display: block; + background: var(--delete-button-bg); + border-radius: 4px; + padding: 0.625rem 0.9375rem; + height: 0.9375rem; + line-height: 0.9375rem; + color: var(--button-fg); +} + +.submit-row a.closelink { + display: inline-block; + background: var(--close-button-bg); + border-radius: 4px; + padding: 10px 15px; + height: 0.9375rem; + line-height: 0.9375rem; + color: var(--button-fg); +} + +.submit-row a.deletelink:focus, +.submit-row a.deletelink:hover, +.submit-row a.deletelink:active { + background: var(--delete-button-hover-bg); + text-decoration: none; +} + +.submit-row a.closelink:focus, +.submit-row a.closelink:hover, +.submit-row a.closelink:active { + background: var(--close-button-hover-bg); + text-decoration: none; +} + +/* CUSTOM FORM FIELDS */ + +.vSelectMultipleField { + vertical-align: top; +} + +.vCheckboxField { + border: none; +} + +.vDateField, .vTimeField { + margin-right: 2px; + margin-bottom: 4px; +} + +.vDateField { + min-width: 6.85em; +} + +.vTimeField { + min-width: 4.7em; +} + +.vURLField { + width: 30em; +} + +.vLargeTextField, .vXMLLargeTextField { + width: 48em; +} + +.flatpages-flatpage #id_content { + height: 40.2em; +} + +.module table .vPositiveSmallIntegerField { + width: 2.2em; +} + +.vIntegerField { + width: 5em; +} + +.vBigIntegerField { + width: 10em; +} + +.vForeignKeyRawIdAdminField { + width: 5em; +} + +.vTextField, .vUUIDField { + width: 20em; +} + +/* INLINES */ + +.inline-group { + padding: 0; + margin: 0 0 30px; +} + +.inline-group thead th { + padding: 8px 10px; +} + +.inline-group .aligned label { + width: 160px; +} + +.inline-related { + position: relative; +} + +.inline-related h3 { + margin: 0; + color: var(--body-quiet-color); + padding: 5px; + font-size: 0.8125rem; + background: var(--darkened-bg); + border-top: 1px solid var(--hairline-color); + border-bottom: 1px solid var(--hairline-color); +} + +.inline-related h3 span.delete { + float: right; +} + +.inline-related h3 span.delete label { + margin-left: 2px; + font-size: 0.6875rem; +} + +.inline-related fieldset { + margin: 0; + background: var(--body-bg); + border: none; + width: 100%; +} + +.inline-related fieldset.module h3 { + margin: 0; + padding: 2px 5px 3px 5px; + font-size: 0.6875rem; + text-align: left; + font-weight: bold; + background: #bcd; + color: var(--body-bg); +} + +.inline-group .tabular fieldset.module { + border: none; +} + +.inline-related.tabular fieldset.module table { + width: 100%; + overflow-x: scroll; +} + +.last-related fieldset { + border: none; +} + +.inline-group .tabular tr.has_original td { + padding-top: 2em; +} + +.inline-group .tabular tr td.original { + padding: 2px 0 0 0; + width: 0; + _position: relative; +} + +.inline-group .tabular th.original { + width: 0px; + padding: 0; +} + +.inline-group .tabular td.original p { + position: absolute; + left: 0; + height: 1.1em; + padding: 2px 9px; + overflow: hidden; + font-size: 0.5625rem; + font-weight: bold; + color: var(--body-quiet-color); + _width: 700px; +} + +.inline-group ul.tools { + padding: 0; + margin: 0; + list-style: none; +} + +.inline-group ul.tools li { + display: inline; + padding: 0 5px; +} + +.inline-group div.add-row, +.inline-group .tabular tr.add-row td { + color: var(--body-quiet-color); + background: var(--darkened-bg); + padding: 8px 10px; + border-bottom: 1px solid var(--hairline-color); +} + +.inline-group .tabular tr.add-row td { + padding: 8px 10px; + border-bottom: 1px solid var(--hairline-color); +} + +.inline-group ul.tools a.add, +.inline-group div.add-row a, +.inline-group .tabular tr.add-row td a { + background: url(../img/icon-addlink.svg) 0 1px no-repeat; + padding-left: 16px; + font-size: 0.75rem; +} + +.empty-form { + display: none; +} + +/* RELATED FIELD ADD ONE / LOOKUP */ + +.related-lookup { + margin-left: 5px; + display: inline-block; + vertical-align: middle; + background-repeat: no-repeat; + background-size: 14px; +} + +.related-lookup { + width: 1rem; + height: 1rem; + background-image: url(../img/search.svg); +} + +form .related-widget-wrapper ul { + display: inline-block; + margin-left: 0; + padding-left: 0; +} + +.clearable-file-input input { + margin-top: 0; +} diff --git a/sites/public/static/admin/css/login.css b/sites/public/static/admin/css/login.css new file mode 100755 index 00000000..389772f5 --- /dev/null +++ b/sites/public/static/admin/css/login.css @@ -0,0 +1,61 @@ +/* LOGIN FORM */ + +.login { + background: var(--darkened-bg); + height: auto; +} + +.login #header { + height: auto; + padding: 15px 16px; + justify-content: center; +} + +.login #header h1 { + font-size: 1.125rem; + margin: 0; +} + +.login #header h1 a { + color: var(--header-link-color); +} + +.login #content { + padding: 20px 20px 0; +} + +.login #container { + background: var(--body-bg); + border: 1px solid var(--hairline-color); + border-radius: 4px; + overflow: hidden; + width: 28em; + min-width: 300px; + margin: 100px auto; + height: auto; +} + +.login .form-row { + padding: 4px 0; +} + +.login .form-row label { + display: block; + line-height: 2em; +} + +.login .form-row #id_username, .login .form-row #id_password { + padding: 8px; + width: 100%; + box-sizing: border-box; +} + +.login .submit-row { + padding: 1em 0 0 0; + margin: 0; + text-align: center; +} + +.login .password-reset-link { + text-align: center; +} diff --git a/sites/public/static/admin/css/nav_sidebar.css b/sites/public/static/admin/css/nav_sidebar.css new file mode 100755 index 00000000..f76e6ce4 --- /dev/null +++ b/sites/public/static/admin/css/nav_sidebar.css @@ -0,0 +1,144 @@ +.sticky { + position: sticky; + top: 0; + max-height: 100vh; +} + +.toggle-nav-sidebar { + z-index: 20; + left: 0; + display: flex; + align-items: center; + justify-content: center; + flex: 0 0 23px; + width: 23px; + border: 0; + border-right: 1px solid var(--hairline-color); + background-color: var(--body-bg); + cursor: pointer; + font-size: 1.25rem; + color: var(--link-fg); + padding: 0; +} + +[dir="rtl"] .toggle-nav-sidebar { + border-left: 1px solid var(--hairline-color); + border-right: 0; +} + +.toggle-nav-sidebar:hover, +.toggle-nav-sidebar:focus { + background-color: var(--darkened-bg); +} + +#nav-sidebar { + z-index: 15; + flex: 0 0 275px; + left: -276px; + margin-left: -276px; + border-top: 1px solid transparent; + border-right: 1px solid var(--hairline-color); + background-color: var(--body-bg); + overflow: auto; +} + +[dir="rtl"] #nav-sidebar { + border-left: 1px solid var(--hairline-color); + border-right: 0; + left: 0; + margin-left: 0; + right: -276px; + margin-right: -276px; +} + +.toggle-nav-sidebar::before { + content: '\00BB'; +} + +.main.shifted .toggle-nav-sidebar::before { + content: '\00AB'; +} + +.main > #nav-sidebar { + visibility: hidden; +} + +.main.shifted > #nav-sidebar { + margin-left: 0; + visibility: visible; +} + +[dir="rtl"] .main.shifted > #nav-sidebar { + margin-right: 0; +} + +#nav-sidebar .module th { + width: 100%; + overflow-wrap: anywhere; +} + +#nav-sidebar .module th, +#nav-sidebar .module caption { + padding-left: 16px; +} + +#nav-sidebar .module td { + white-space: nowrap; +} + +[dir="rtl"] #nav-sidebar .module th, +[dir="rtl"] #nav-sidebar .module caption { + padding-left: 8px; + padding-right: 16px; +} + +#nav-sidebar .current-app .section:link, +#nav-sidebar .current-app .section:visited { + color: var(--header-color); + font-weight: bold; +} + +#nav-sidebar .current-model { + background: var(--selected-row); +} + +.main > #nav-sidebar + .content { + max-width: calc(100% - 23px); +} + +.main.shifted > #nav-sidebar + .content { + max-width: calc(100% - 299px); +} + +@media (max-width: 767px) { + #nav-sidebar, #toggle-nav-sidebar { + display: none; + } + + .main > #nav-sidebar + .content, + .main.shifted > #nav-sidebar + .content { + max-width: 100%; + } +} + +#nav-filter { + width: 100%; + box-sizing: border-box; + padding: 2px 5px; + margin: 5px 0; + border: 1px solid var(--border-color); + background-color: var(--darkened-bg); + color: var(--body-fg); +} + +#nav-filter:focus { + border-color: var(--body-quiet-color); +} + +#nav-filter.no-results { + background: var(--message-error-bg); +} + +#nav-sidebar table { + width: 100%; +} diff --git a/sites/public/static/admin/css/responsive.css b/sites/public/static/admin/css/responsive.css new file mode 100755 index 00000000..9ce4f67b --- /dev/null +++ b/sites/public/static/admin/css/responsive.css @@ -0,0 +1,998 @@ +/* Tablets */ + +input[type="submit"], button { + -webkit-appearance: none; + appearance: none; +} + +@media (max-width: 1024px) { + /* Basic */ + + html { + -webkit-text-size-adjust: 100%; + } + + td, th { + padding: 10px; + font-size: 0.875rem; + } + + .small { + font-size: 0.75rem; + } + + /* Layout */ + + #container { + min-width: 0; + } + + #content { + padding: 15px 20px 20px; + } + + div.breadcrumbs { + padding: 10px 30px; + } + + /* Header */ + + #header { + flex-direction: column; + padding: 15px 30px; + justify-content: flex-start; + } + + #branding h1 { + margin: 0 0 8px; + line-height: 1.2; + } + + #user-tools { + margin: 0; + font-weight: 400; + line-height: 1.85; + text-align: left; + } + + #user-tools a { + display: inline-block; + line-height: 1.4; + } + + /* Dashboard */ + + .dashboard #content { + width: auto; + } + + #content-related { + margin-right: -290px; + } + + .colSM #content-related { + margin-left: -290px; + } + + .colMS { + margin-right: 290px; + } + + .colSM { + margin-left: 290px; + } + + .dashboard .module table td a { + padding-right: 0; + } + + td .changelink, td .addlink { + font-size: 0.8125rem; + } + + /* Changelist */ + + #toolbar { + border: none; + padding: 15px; + } + + #changelist-search > div { + display: flex; + flex-wrap: nowrap; + max-width: 480px; + } + + #changelist-search label { + line-height: 1.375rem; + } + + #toolbar form #searchbar { + flex: 1 0 auto; + width: 0; + height: 1.375rem; + margin: 0 10px 0 6px; + } + + #toolbar form input[type=submit] { + flex: 0 1 auto; + } + + #changelist-search .quiet { + width: 0; + flex: 1 0 auto; + margin: 5px 0 0 25px; + } + + #changelist .actions { + display: flex; + flex-wrap: wrap; + padding: 15px 0; + } + + #changelist .actions label { + display: flex; + } + + #changelist .actions select { + background: var(--body-bg); + } + + #changelist .actions .button { + min-width: 48px; + margin: 0 10px; + } + + #changelist .actions span.all, + #changelist .actions span.clear, + #changelist .actions span.question, + #changelist .actions span.action-counter { + font-size: 0.6875rem; + margin: 0 10px 0 0; + } + + #changelist-filter { + flex-basis: 200px; + } + + .change-list .filtered .results, + .change-list .filtered .paginator, + .filtered #toolbar, + .filtered .actions, + + #changelist .paginator { + border-top-color: var(--hairline-color); /* XXX Is this used at all? */ + } + + #changelist .results + .paginator { + border-top: none; + } + + /* Forms */ + + label { + font-size: 0.875rem; + } + + .form-row input[type=text], + .form-row input[type=password], + .form-row input[type=email], + .form-row input[type=url], + .form-row input[type=tel], + .form-row input[type=number], + .form-row textarea, + .form-row select, + .form-row .vTextField { + box-sizing: border-box; + margin: 0; + padding: 6px 8px; + min-height: 2.25rem; + font-size: 0.875rem; + } + + .form-row select { + height: 2.25rem; + } + + .form-row select[multiple] { + height: auto; + min-height: 0; + } + + fieldset .fieldBox + .fieldBox { + margin-top: 10px; + padding-top: 10px; + border-top: 1px solid var(--hairline-color); + } + + textarea { + max-width: 100%; + max-height: 120px; + } + + .aligned label { + padding-top: 6px; + } + + .aligned .related-lookup, + .aligned .datetimeshortcuts, + .aligned .related-lookup + strong { + align-self: center; + margin-left: 15px; + } + + form .aligned div.radiolist { + margin-left: 2px; + } + + .submit-row { + padding: 8px; + } + + .submit-row a.deletelink { + padding: 10px 7px; + } + + .button, input[type=submit], input[type=button], .submit-row input, a.button { + padding: 7px; + } + + /* Related widget */ + + .related-widget-wrapper { + float: none; + } + + .related-widget-wrapper-link + .selector { + max-width: calc(100% - 30px); + margin-right: 15px; + } + + select + .related-widget-wrapper-link, + .related-widget-wrapper-link + .related-widget-wrapper-link { + margin-left: 10px; + } + + /* Selector */ + + .selector { + display: flex; + width: 100%; + } + + .selector .selector-filter { + display: flex; + align-items: center; + } + + .selector .selector-filter label { + margin: 0 8px 0 0; + } + + .selector .selector-filter input { + width: auto; + min-height: 0; + flex: 1 1; + } + + .selector-available, .selector-chosen { + width: auto; + flex: 1 1; + display: flex; + flex-direction: column; + } + + .selector select { + width: 100%; + flex: 1 0 auto; + margin-bottom: 5px; + } + + .selector ul.selector-chooser { + width: 26px; + height: 52px; + padding: 2px 0; + margin: auto 15px; + border-radius: 20px; + transform: translateY(-10px); + } + + .selector-add, .selector-remove { + width: 20px; + height: 20px; + background-size: 20px auto; + } + + .selector-add { + background-position: 0 -120px; + } + + .selector-remove { + background-position: 0 -80px; + } + + a.selector-chooseall, a.selector-clearall { + align-self: center; + } + + .stacked { + flex-direction: column; + max-width: 480px; + } + + .stacked > * { + flex: 0 1 auto; + } + + .stacked select { + margin-bottom: 0; + } + + .stacked .selector-available, .stacked .selector-chosen { + width: auto; + } + + .stacked ul.selector-chooser { + width: 52px; + height: 26px; + padding: 0 2px; + margin: 15px auto; + transform: none; + } + + .stacked .selector-chooser li { + padding: 3px; + } + + .stacked .selector-add, .stacked .selector-remove { + background-size: 20px auto; + } + + .stacked .selector-add { + background-position: 0 -40px; + } + + .stacked .active.selector-add { + background-position: 0 -40px; + } + + .active.selector-add:focus, .active.selector-add:hover { + background-position: 0 -140px; + } + + .stacked .active.selector-add:focus, .stacked .active.selector-add:hover { + background-position: 0 -60px; + } + + .stacked .selector-remove { + background-position: 0 0; + } + + .stacked .active.selector-remove { + background-position: 0 0; + } + + .active.selector-remove:focus, .active.selector-remove:hover { + background-position: 0 -100px; + } + + .stacked .active.selector-remove:focus, .stacked .active.selector-remove:hover { + background-position: 0 -20px; + } + + .help-tooltip, .selector .help-icon { + display: none; + } + + .datetime input { + width: 50%; + max-width: 120px; + } + + .datetime span { + font-size: 0.8125rem; + } + + .datetime .timezonewarning { + display: block; + font-size: 0.6875rem; + color: var(--body-quiet-color); + } + + .datetimeshortcuts { + color: var(--border-color); /* XXX Redundant, .datetime span also sets #ccc */ + } + + .form-row .datetime input.vDateField, .form-row .datetime input.vTimeField { + width: 75%; + } + + .inline-group { + overflow: auto; + } + + /* Messages */ + + ul.messagelist li { + padding-left: 55px; + background-position: 30px 12px; + } + + ul.messagelist li.error { + background-position: 30px 12px; + } + + ul.messagelist li.warning { + background-position: 30px 14px; + } + + /* Login */ + + .login #header { + padding: 15px 20px; + } + + .login #branding h1 { + margin: 0; + } + + /* GIS */ + + div.olMap { + max-width: calc(100vw - 30px); + max-height: 300px; + } + + .olMap + .clear_features { + display: block; + margin-top: 10px; + } + + /* Docs */ + + .module table.xfull { + width: 100%; + } + + pre.literal-block { + overflow: auto; + } +} + +/* Mobile */ + +@media (max-width: 767px) { + /* Layout */ + + #header, #content, #footer { + padding: 15px; + } + + #footer:empty { + padding: 0; + } + + div.breadcrumbs { + padding: 10px 15px; + } + + /* Dashboard */ + + .colMS, .colSM { + margin: 0; + } + + #content-related, .colSM #content-related { + width: 100%; + margin: 0; + } + + #content-related .module { + margin-bottom: 0; + } + + #content-related .module h2 { + padding: 10px 15px; + font-size: 1rem; + } + + /* Changelist */ + + #changelist { + align-items: stretch; + flex-direction: column; + } + + #toolbar { + padding: 10px; + } + + #changelist-filter { + margin-left: 0; + } + + #changelist .actions label { + flex: 1 1; + } + + #changelist .actions select { + flex: 1 0; + width: 100%; + } + + #changelist .actions span { + flex: 1 0 100%; + } + + #changelist-filter { + position: static; + width: auto; + margin-top: 30px; + } + + .object-tools { + float: none; + margin: 0 0 15px; + padding: 0; + overflow: hidden; + } + + .object-tools li { + height: auto; + margin-left: 0; + } + + .object-tools li + li { + margin-left: 15px; + } + + /* Forms */ + + .form-row { + padding: 15px 0; + } + + .aligned .form-row, + .aligned .form-row > div { + max-width: 100vw; + } + + .aligned .form-row > div { + width: calc(100vw - 30px); + } + + .flex-container { + flex-flow: column; + } + + textarea { + max-width: none; + } + + .vURLField { + width: auto; + } + + fieldset .fieldBox + .fieldBox { + margin-top: 15px; + padding-top: 15px; + } + + fieldset.collapsed .form-row { + display: none; + } + + .aligned label { + width: 100%; + padding: 0 0 10px; + } + + .aligned label:after { + max-height: 0; + } + + .aligned .form-row input, + .aligned .form-row select, + .aligned .form-row textarea { + flex: 1 1 auto; + max-width: 100%; + } + + .aligned .checkbox-row { + align-items: center; + } + + .aligned .checkbox-row input { + flex: 0 1 auto; + margin: 0; + } + + .aligned .vCheckboxLabel { + flex: 1 0; + padding: 1px 0 0 5px; + } + + .aligned label + p, + .aligned label + div.help, + .aligned label + div.readonly { + padding: 0; + margin-left: 0; + } + + .aligned p.file-upload { + font-size: 0.8125rem; + } + + span.clearable-file-input { + margin-left: 15px; + } + + span.clearable-file-input label { + font-size: 0.8125rem; + padding-bottom: 0; + } + + .aligned .timezonewarning { + flex: 1 0 100%; + margin-top: 5px; + } + + form .aligned .form-row div.help { + width: 100%; + margin: 5px 0 0; + padding: 0; + } + + form .aligned ul, + form .aligned ul.errorlist { + margin-left: 0; + padding-left: 0; + } + + form .aligned div.radiolist { + margin-top: 5px; + margin-right: 15px; + margin-bottom: -3px; + } + + form .aligned div.radiolist:not(.inline) div + div { + margin-top: 5px; + } + + /* Related widget */ + + .related-widget-wrapper { + width: 100%; + display: flex; + align-items: flex-start; + } + + .related-widget-wrapper .selector { + order: 1; + } + + .related-widget-wrapper > a { + order: 2; + } + + .related-widget-wrapper .radiolist ~ a { + align-self: flex-end; + } + + .related-widget-wrapper > select ~ a { + align-self: center; + } + + select + .related-widget-wrapper-link, + .related-widget-wrapper-link + .related-widget-wrapper-link { + margin-left: 15px; + } + + /* Selector */ + + .selector { + flex-direction: column; + } + + .selector > * { + float: none; + } + + .selector-available, .selector-chosen { + margin-bottom: 0; + flex: 1 1 auto; + } + + .selector select { + max-height: 96px; + } + + .selector ul.selector-chooser { + display: block; + float: none; + width: 52px; + height: 26px; + padding: 0 2px; + margin: 15px auto 20px; + transform: none; + } + + .selector ul.selector-chooser li { + float: left; + } + + .selector-remove { + background-position: 0 0; + } + + .active.selector-remove:focus, .active.selector-remove:hover { + background-position: 0 -20px; + } + + .selector-add { + background-position: 0 -40px; + } + + .active.selector-add:focus, .active.selector-add:hover { + background-position: 0 -60px; + } + + /* Inlines */ + + .inline-group[data-inline-type="stacked"] .inline-related { + border: 1px solid var(--hairline-color); + border-radius: 4px; + margin-top: 15px; + overflow: auto; + } + + .inline-group[data-inline-type="stacked"] .inline-related > * { + box-sizing: border-box; + } + + .inline-group[data-inline-type="stacked"] .inline-related .module { + padding: 0 10px; + } + + .inline-group[data-inline-type="stacked"] .inline-related .module .form-row { + border-top: 1px solid var(--hairline-color); + border-bottom: none; + } + + .inline-group[data-inline-type="stacked"] .inline-related .module .form-row:first-child { + border-top: none; + } + + .inline-group[data-inline-type="stacked"] .inline-related h3 { + padding: 10px; + border-top-width: 0; + border-bottom-width: 2px; + display: flex; + flex-wrap: wrap; + align-items: center; + } + + .inline-group[data-inline-type="stacked"] .inline-related h3 .inline_label { + margin-right: auto; + } + + .inline-group[data-inline-type="stacked"] .inline-related h3 span.delete { + float: none; + flex: 1 1 100%; + margin-top: 5px; + } + + .inline-group[data-inline-type="stacked"] .aligned .form-row > div:not([class]) { + width: 100%; + } + + .inline-group[data-inline-type="stacked"] .aligned label { + width: 100%; + } + + .inline-group[data-inline-type="stacked"] div.add-row { + margin-top: 15px; + border: 1px solid var(--hairline-color); + border-radius: 4px; + } + + .inline-group div.add-row, + .inline-group .tabular tr.add-row td { + padding: 0; + } + + .inline-group div.add-row a, + .inline-group .tabular tr.add-row td a { + display: block; + padding: 8px 10px 8px 26px; + background-position: 8px 9px; + } + + /* Submit row */ + + .submit-row { + padding: 10px; + margin: 0 0 15px; + flex-direction: column; + gap: 8px; + } + + .submit-row input, .submit-row input.default, .submit-row a { + text-align: center; + } + + .submit-row a.closelink { + padding: 10px 0; + text-align: center; + } + + .submit-row a.deletelink { + margin: 0; + } + + /* Messages */ + + ul.messagelist li { + padding-left: 40px; + background-position: 15px 12px; + } + + ul.messagelist li.error { + background-position: 15px 12px; + } + + ul.messagelist li.warning { + background-position: 15px 14px; + } + + /* Paginator */ + + .paginator .this-page, .paginator a:link, .paginator a:visited { + padding: 4px 10px; + } + + /* Login */ + + body.login { + padding: 0 15px; + } + + .login #container { + width: auto; + max-width: 480px; + margin: 50px auto; + } + + .login #header, + .login #content { + padding: 15px; + } + + .login #content-main { + float: none; + } + + .login .form-row { + padding: 0; + } + + .login .form-row + .form-row { + margin-top: 15px; + } + + .login .form-row label { + margin: 0 0 5px; + line-height: 1.2; + } + + .login .submit-row { + padding: 15px 0 0; + } + + .login br { + display: none; + } + + .login .submit-row input { + margin: 0; + text-transform: uppercase; + } + + .errornote { + margin: 0 0 20px; + padding: 8px 12px; + font-size: 0.8125rem; + } + + /* Calendar and clock */ + + .calendarbox, .clockbox { + position: fixed !important; + top: 50% !important; + left: 50% !important; + transform: translate(-50%, -50%); + margin: 0; + border: none; + overflow: visible; + } + + .calendarbox:before, .clockbox:before { + content: ''; + position: fixed; + top: 50%; + left: 50%; + width: 100vw; + height: 100vh; + background: rgba(0, 0, 0, 0.75); + transform: translate(-50%, -50%); + } + + .calendarbox > *, .clockbox > * { + position: relative; + z-index: 1; + } + + .calendarbox > div:first-child { + z-index: 2; + } + + .calendarbox .calendar, .clockbox h2 { + border-radius: 4px 4px 0 0; + overflow: hidden; + } + + .calendarbox .calendar-cancel, .clockbox .calendar-cancel { + border-radius: 0 0 4px 4px; + overflow: hidden; + } + + .calendar-shortcuts { + padding: 10px 0; + font-size: 0.75rem; + line-height: 0.75rem; + } + + .calendar-shortcuts a { + margin: 0 4px; + } + + .timelist a { + background: var(--body-bg); + padding: 4px; + } + + .calendar-cancel { + padding: 8px 10px; + } + + .clockbox h2 { + padding: 8px 15px; + } + + .calendar caption { + padding: 10px; + } + + .calendarbox .calendarnav-previous, .calendarbox .calendarnav-next { + z-index: 1; + top: 10px; + } + + /* History */ + + table#change-history tbody th, table#change-history tbody td { + font-size: 0.8125rem; + word-break: break-word; + } + + table#change-history tbody th { + width: auto; + } + + /* Docs */ + + table.model tbody th, table.model tbody td { + font-size: 0.8125rem; + word-break: break-word; + } +} diff --git a/sites/public/static/admin/css/responsive_rtl.css b/sites/public/static/admin/css/responsive_rtl.css new file mode 100755 index 00000000..639e20b2 --- /dev/null +++ b/sites/public/static/admin/css/responsive_rtl.css @@ -0,0 +1,81 @@ +/* TABLETS */ + +@media (max-width: 1024px) { + [dir="rtl"] .colMS { + margin-right: 0; + } + + [dir="rtl"] #user-tools { + text-align: right; + } + + [dir="rtl"] #changelist .actions label { + padding-left: 10px; + padding-right: 0; + } + + [dir="rtl"] #changelist .actions select { + margin-left: 0; + margin-right: 15px; + } + + [dir="rtl"] .change-list .filtered .results, + [dir="rtl"] .change-list .filtered .paginator, + [dir="rtl"] .filtered #toolbar, + [dir="rtl"] .filtered div.xfull, + [dir="rtl"] .filtered .actions, + [dir="rtl"] #changelist-filter { + margin-left: 0; + } + + [dir="rtl"] .inline-group ul.tools a.add, + [dir="rtl"] .inline-group div.add-row a, + [dir="rtl"] .inline-group .tabular tr.add-row td a { + padding: 8px 26px 8px 10px; + background-position: calc(100% - 8px) 9px; + } + + [dir="rtl"] .related-widget-wrapper-link + .selector { + margin-right: 0; + margin-left: 15px; + } + + [dir="rtl"] .selector .selector-filter label { + margin-right: 0; + margin-left: 8px; + } + + [dir="rtl"] .object-tools li { + float: right; + } + + [dir="rtl"] .object-tools li + li { + margin-left: 0; + margin-right: 15px; + } + + [dir="rtl"] .dashboard .module table td a { + padding-left: 0; + padding-right: 16px; + } +} + +/* MOBILE */ + +@media (max-width: 767px) { + [dir="rtl"] .aligned .related-lookup, + [dir="rtl"] .aligned .datetimeshortcuts { + margin-left: 0; + margin-right: 15px; + } + + [dir="rtl"] .aligned ul, + [dir="rtl"] form .aligned ul.errorlist { + margin-right: 0; + } + + [dir="rtl"] #changelist-filter { + margin-left: 0; + margin-right: 0; + } +} diff --git a/sites/public/static/admin/css/rtl.css b/sites/public/static/admin/css/rtl.css new file mode 100755 index 00000000..53a6dd6c --- /dev/null +++ b/sites/public/static/admin/css/rtl.css @@ -0,0 +1,288 @@ +/* GLOBAL */ + +th { + text-align: right; +} + +.module h2, .module caption { + text-align: right; +} + +.module ul, .module ol { + margin-left: 0; + margin-right: 1.5em; +} + +.viewlink, .addlink, .changelink { + padding-left: 0; + padding-right: 16px; + background-position: 100% 1px; +} + +.deletelink { + padding-left: 0; + padding-right: 16px; + background-position: 100% 1px; +} + +.object-tools { + float: left; +} + +thead th:first-child, +tfoot td:first-child { + border-left: none; +} + +/* LAYOUT */ + +#user-tools { + right: auto; + left: 0; + text-align: left; +} + +div.breadcrumbs { + text-align: right; +} + +#content-main { + float: right; +} + +#content-related { + float: left; + margin-left: -300px; + margin-right: auto; +} + +.colMS { + margin-left: 300px; + margin-right: 0; +} + +/* SORTABLE TABLES */ + +table thead th.sorted .sortoptions { + float: left; +} + +thead th.sorted .text { + padding-right: 0; + padding-left: 42px; +} + +/* dashboard styles */ + +.dashboard .module table td a { + padding-left: .6em; + padding-right: 16px; +} + +/* changelists styles */ + +.change-list .filtered table { + border-left: none; + border-right: 0px none; +} + +#changelist-filter { + border-left: none; + border-right: none; + margin-left: 0; + margin-right: 30px; +} + +#changelist-filter li.selected { + border-left: none; + padding-left: 10px; + margin-left: 0; + border-right: 5px solid var(--hairline-color); + padding-right: 10px; + margin-right: -15px; +} + +#changelist table tbody td:first-child, #changelist table tbody th:first-child { + border-right: none; + border-left: none; +} + +/* FORMS */ + +.aligned label { + padding: 0 0 3px 1em; +} + +.submit-row a.deletelink { + margin-left: 0; + margin-right: auto; +} + +.vDateField, .vTimeField { + margin-left: 2px; +} + +.aligned .form-row input { + margin-left: 5px; +} + +form .aligned ul { + margin-right: 163px; + padding-right: 10px; + margin-left: 0; + padding-left: 0; +} + +form ul.inline li { + float: right; + padding-right: 0; + padding-left: 7px; +} + +form .aligned p.help, +form .aligned div.help { + margin-right: 160px; + padding-right: 10px; +} + +form div.help ul, +form .aligned .checkbox-row + .help, +form .aligned p.date div.help.timezonewarning, +form .aligned p.datetime div.help.timezonewarning, +form .aligned p.time div.help.timezonewarning { + margin-right: 0; + padding-right: 0; +} + +form .wide p.help, form .wide div.help { + padding-left: 0; + padding-right: 50px; +} + +form .wide p, +form .wide ul.errorlist, +form .wide input + p.help, +form .wide input + div.help { + margin-right: 200px; + margin-left: 0px; +} + +.submit-row { + text-align: right; +} + +fieldset .fieldBox { + margin-left: 20px; + margin-right: 0; +} + +.errorlist li { + background-position: 100% 12px; + padding: 0; +} + +.errornote { + background-position: 100% 12px; + padding: 10px 12px; +} + +/* WIDGETS */ + +.calendarnav-previous { + top: 0; + left: auto; + right: 10px; + background: url(../img/calendar-icons.svg) 0 -30px no-repeat; +} + +.calendarbox .calendarnav-previous:focus, +.calendarbox .calendarnav-previous:hover { + background-position: 0 -45px; +} + +.calendarnav-next { + top: 0; + right: auto; + left: 10px; + background: url(../img/calendar-icons.svg) 0 0 no-repeat; +} + +.calendarbox .calendarnav-next:focus, +.calendarbox .calendarnav-next:hover { + background-position: 0 -15px; +} + +.calendar caption, .calendarbox h2 { + text-align: center; +} + +.selector { + float: right; +} + +.selector .selector-filter { + text-align: right; +} + +.selector-add { + background: url(../img/selector-icons.svg) 0 -64px no-repeat; +} + +.active.selector-add:focus, .active.selector-add:hover { + background-position: 0 -80px; +} + +.selector-remove { + background: url(../img/selector-icons.svg) 0 -96px no-repeat; +} + +.active.selector-remove:focus, .active.selector-remove:hover { + background-position: 0 -112px; +} + +a.selector-chooseall { + background: url(../img/selector-icons.svg) right -128px no-repeat; +} + +a.active.selector-chooseall:focus, a.active.selector-chooseall:hover { + background-position: 100% -144px; +} + +a.selector-clearall { + background: url(../img/selector-icons.svg) 0 -160px no-repeat; +} + +a.active.selector-clearall:focus, a.active.selector-clearall:hover { + background-position: 0 -176px; +} + +.inline-deletelink { + float: left; +} + +form .form-row p.datetime { + overflow: hidden; +} + +.related-widget-wrapper { + float: right; +} + +/* MISC */ + +.inline-related h2, .inline-group h2 { + text-align: right +} + +.inline-related h3 span.delete { + padding-right: 20px; + padding-left: inherit; + left: 10px; + right: inherit; + float:left; +} + +.inline-related h3 span.delete label { + margin-left: inherit; + margin-right: 2px; +} diff --git a/sites/public/static/admin/css/vendor/select2/LICENSE-SELECT2.md b/sites/public/static/admin/css/vendor/select2/LICENSE-SELECT2.md new file mode 100755 index 00000000..8cb8a2b1 --- /dev/null +++ b/sites/public/static/admin/css/vendor/select2/LICENSE-SELECT2.md @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2012-2017 Kevin Brown, Igor Vaynberg, and Select2 contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/sites/public/static/admin/css/vendor/select2/select2.css b/sites/public/static/admin/css/vendor/select2/select2.css new file mode 100755 index 00000000..750b3207 --- /dev/null +++ b/sites/public/static/admin/css/vendor/select2/select2.css @@ -0,0 +1,481 @@ +.select2-container { + box-sizing: border-box; + display: inline-block; + margin: 0; + position: relative; + vertical-align: middle; } + .select2-container .select2-selection--single { + box-sizing: border-box; + cursor: pointer; + display: block; + height: 28px; + user-select: none; + -webkit-user-select: none; } + .select2-container .select2-selection--single .select2-selection__rendered { + display: block; + padding-left: 8px; + padding-right: 20px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; } + .select2-container .select2-selection--single .select2-selection__clear { + position: relative; } + .select2-container[dir="rtl"] .select2-selection--single .select2-selection__rendered { + padding-right: 8px; + padding-left: 20px; } + .select2-container .select2-selection--multiple { + box-sizing: border-box; + cursor: pointer; + display: block; + min-height: 32px; + user-select: none; + -webkit-user-select: none; } + .select2-container .select2-selection--multiple .select2-selection__rendered { + display: inline-block; + overflow: hidden; + padding-left: 8px; + text-overflow: ellipsis; + white-space: nowrap; } + .select2-container .select2-search--inline { + float: left; } + .select2-container .select2-search--inline .select2-search__field { + box-sizing: border-box; + border: none; + font-size: 100%; + margin-top: 5px; + padding: 0; } + .select2-container .select2-search--inline .select2-search__field::-webkit-search-cancel-button { + -webkit-appearance: none; } + +.select2-dropdown { + background-color: white; + border: 1px solid #aaa; + border-radius: 4px; + box-sizing: border-box; + display: block; + position: absolute; + left: -100000px; + width: 100%; + z-index: 1051; } + +.select2-results { + display: block; } + +.select2-results__options { + list-style: none; + margin: 0; + padding: 0; } + +.select2-results__option { + padding: 6px; + user-select: none; + -webkit-user-select: none; } + .select2-results__option[aria-selected] { + cursor: pointer; } + +.select2-container--open .select2-dropdown { + left: 0; } + +.select2-container--open .select2-dropdown--above { + border-bottom: none; + border-bottom-left-radius: 0; + border-bottom-right-radius: 0; } + +.select2-container--open .select2-dropdown--below { + border-top: none; + border-top-left-radius: 0; + border-top-right-radius: 0; } + +.select2-search--dropdown { + display: block; + padding: 4px; } + .select2-search--dropdown .select2-search__field { + padding: 4px; + width: 100%; + box-sizing: border-box; } + .select2-search--dropdown .select2-search__field::-webkit-search-cancel-button { + -webkit-appearance: none; } + .select2-search--dropdown.select2-search--hide { + display: none; } + +.select2-close-mask { + border: 0; + margin: 0; + padding: 0; + display: block; + position: fixed; + left: 0; + top: 0; + min-height: 100%; + min-width: 100%; + height: auto; + width: auto; + opacity: 0; + z-index: 99; + background-color: #fff; + filter: alpha(opacity=0); } + +.select2-hidden-accessible { + border: 0 !important; + clip: rect(0 0 0 0) !important; + -webkit-clip-path: inset(50%) !important; + clip-path: inset(50%) !important; + height: 1px !important; + overflow: hidden !important; + padding: 0 !important; + position: absolute !important; + width: 1px !important; + white-space: nowrap !important; } + +.select2-container--default .select2-selection--single { + background-color: #fff; + border: 1px solid #aaa; + border-radius: 4px; } + .select2-container--default .select2-selection--single .select2-selection__rendered { + color: #444; + line-height: 28px; } + .select2-container--default .select2-selection--single .select2-selection__clear { + cursor: pointer; + float: right; + font-weight: bold; } + .select2-container--default .select2-selection--single .select2-selection__placeholder { + color: #999; } + .select2-container--default .select2-selection--single .select2-selection__arrow { + height: 26px; + position: absolute; + top: 1px; + right: 1px; + width: 20px; } + .select2-container--default .select2-selection--single .select2-selection__arrow b { + border-color: #888 transparent transparent transparent; + border-style: solid; + border-width: 5px 4px 0 4px; + height: 0; + left: 50%; + margin-left: -4px; + margin-top: -2px; + position: absolute; + top: 50%; + width: 0; } + +.select2-container--default[dir="rtl"] .select2-selection--single .select2-selection__clear { + float: left; } + +.select2-container--default[dir="rtl"] .select2-selection--single .select2-selection__arrow { + left: 1px; + right: auto; } + +.select2-container--default.select2-container--disabled .select2-selection--single { + background-color: #eee; + cursor: default; } + .select2-container--default.select2-container--disabled .select2-selection--single .select2-selection__clear { + display: none; } + +.select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b { + border-color: transparent transparent #888 transparent; + border-width: 0 4px 5px 4px; } + +.select2-container--default .select2-selection--multiple { + background-color: white; + border: 1px solid #aaa; + border-radius: 4px; + cursor: text; } + .select2-container--default .select2-selection--multiple .select2-selection__rendered { + box-sizing: border-box; + list-style: none; + margin: 0; + padding: 0 5px; + width: 100%; } + .select2-container--default .select2-selection--multiple .select2-selection__rendered li { + list-style: none; } + .select2-container--default .select2-selection--multiple .select2-selection__clear { + cursor: pointer; + float: right; + font-weight: bold; + margin-top: 5px; + margin-right: 10px; + padding: 1px; } + .select2-container--default .select2-selection--multiple .select2-selection__choice { + background-color: #e4e4e4; + border: 1px solid #aaa; + border-radius: 4px; + cursor: default; + float: left; + margin-right: 5px; + margin-top: 5px; + padding: 0 5px; } + .select2-container--default .select2-selection--multiple .select2-selection__choice__remove { + color: #999; + cursor: pointer; + display: inline-block; + font-weight: bold; + margin-right: 2px; } + .select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover { + color: #333; } + +.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice, .select2-container--default[dir="rtl"] .select2-selection--multiple .select2-search--inline { + float: right; } + +.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice { + margin-left: 5px; + margin-right: auto; } + +.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice__remove { + margin-left: 2px; + margin-right: auto; } + +.select2-container--default.select2-container--focus .select2-selection--multiple { + border: solid black 1px; + outline: 0; } + +.select2-container--default.select2-container--disabled .select2-selection--multiple { + background-color: #eee; + cursor: default; } + +.select2-container--default.select2-container--disabled .select2-selection__choice__remove { + display: none; } + +.select2-container--default.select2-container--open.select2-container--above .select2-selection--single, .select2-container--default.select2-container--open.select2-container--above .select2-selection--multiple { + border-top-left-radius: 0; + border-top-right-radius: 0; } + +.select2-container--default.select2-container--open.select2-container--below .select2-selection--single, .select2-container--default.select2-container--open.select2-container--below .select2-selection--multiple { + border-bottom-left-radius: 0; + border-bottom-right-radius: 0; } + +.select2-container--default .select2-search--dropdown .select2-search__field { + border: 1px solid #aaa; } + +.select2-container--default .select2-search--inline .select2-search__field { + background: transparent; + border: none; + outline: 0; + box-shadow: none; + -webkit-appearance: textfield; } + +.select2-container--default .select2-results > .select2-results__options { + max-height: 200px; + overflow-y: auto; } + +.select2-container--default .select2-results__option[role=group] { + padding: 0; } + +.select2-container--default .select2-results__option[aria-disabled=true] { + color: #999; } + +.select2-container--default .select2-results__option[aria-selected=true] { + background-color: #ddd; } + +.select2-container--default .select2-results__option .select2-results__option { + padding-left: 1em; } + .select2-container--default .select2-results__option .select2-results__option .select2-results__group { + padding-left: 0; } + .select2-container--default .select2-results__option .select2-results__option .select2-results__option { + margin-left: -1em; + padding-left: 2em; } + .select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option { + margin-left: -2em; + padding-left: 3em; } + .select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option { + margin-left: -3em; + padding-left: 4em; } + .select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option { + margin-left: -4em; + padding-left: 5em; } + .select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option { + margin-left: -5em; + padding-left: 6em; } + +.select2-container--default .select2-results__option--highlighted[aria-selected] { + background-color: #5897fb; + color: white; } + +.select2-container--default .select2-results__group { + cursor: default; + display: block; + padding: 6px; } + +.select2-container--classic .select2-selection--single { + background-color: #f7f7f7; + border: 1px solid #aaa; + border-radius: 4px; + outline: 0; + background-image: -webkit-linear-gradient(top, white 50%, #eeeeee 100%); + background-image: -o-linear-gradient(top, white 50%, #eeeeee 100%); + background-image: linear-gradient(to bottom, white 50%, #eeeeee 100%); + background-repeat: repeat-x; + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF', endColorstr='#FFEEEEEE', GradientType=0); } + .select2-container--classic .select2-selection--single:focus { + border: 1px solid #5897fb; } + .select2-container--classic .select2-selection--single .select2-selection__rendered { + color: #444; + line-height: 28px; } + .select2-container--classic .select2-selection--single .select2-selection__clear { + cursor: pointer; + float: right; + font-weight: bold; + margin-right: 10px; } + .select2-container--classic .select2-selection--single .select2-selection__placeholder { + color: #999; } + .select2-container--classic .select2-selection--single .select2-selection__arrow { + background-color: #ddd; + border: none; + border-left: 1px solid #aaa; + border-top-right-radius: 4px; + border-bottom-right-radius: 4px; + height: 26px; + position: absolute; + top: 1px; + right: 1px; + width: 20px; + background-image: -webkit-linear-gradient(top, #eeeeee 50%, #cccccc 100%); + background-image: -o-linear-gradient(top, #eeeeee 50%, #cccccc 100%); + background-image: linear-gradient(to bottom, #eeeeee 50%, #cccccc 100%); + background-repeat: repeat-x; + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFEEEEEE', endColorstr='#FFCCCCCC', GradientType=0); } + .select2-container--classic .select2-selection--single .select2-selection__arrow b { + border-color: #888 transparent transparent transparent; + border-style: solid; + border-width: 5px 4px 0 4px; + height: 0; + left: 50%; + margin-left: -4px; + margin-top: -2px; + position: absolute; + top: 50%; + width: 0; } + +.select2-container--classic[dir="rtl"] .select2-selection--single .select2-selection__clear { + float: left; } + +.select2-container--classic[dir="rtl"] .select2-selection--single .select2-selection__arrow { + border: none; + border-right: 1px solid #aaa; + border-radius: 0; + border-top-left-radius: 4px; + border-bottom-left-radius: 4px; + left: 1px; + right: auto; } + +.select2-container--classic.select2-container--open .select2-selection--single { + border: 1px solid #5897fb; } + .select2-container--classic.select2-container--open .select2-selection--single .select2-selection__arrow { + background: transparent; + border: none; } + .select2-container--classic.select2-container--open .select2-selection--single .select2-selection__arrow b { + border-color: transparent transparent #888 transparent; + border-width: 0 4px 5px 4px; } + +.select2-container--classic.select2-container--open.select2-container--above .select2-selection--single { + border-top: none; + border-top-left-radius: 0; + border-top-right-radius: 0; + background-image: -webkit-linear-gradient(top, white 0%, #eeeeee 50%); + background-image: -o-linear-gradient(top, white 0%, #eeeeee 50%); + background-image: linear-gradient(to bottom, white 0%, #eeeeee 50%); + background-repeat: repeat-x; + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF', endColorstr='#FFEEEEEE', GradientType=0); } + +.select2-container--classic.select2-container--open.select2-container--below .select2-selection--single { + border-bottom: none; + border-bottom-left-radius: 0; + border-bottom-right-radius: 0; + background-image: -webkit-linear-gradient(top, #eeeeee 50%, white 100%); + background-image: -o-linear-gradient(top, #eeeeee 50%, white 100%); + background-image: linear-gradient(to bottom, #eeeeee 50%, white 100%); + background-repeat: repeat-x; + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFEEEEEE', endColorstr='#FFFFFFFF', GradientType=0); } + +.select2-container--classic .select2-selection--multiple { + background-color: white; + border: 1px solid #aaa; + border-radius: 4px; + cursor: text; + outline: 0; } + .select2-container--classic .select2-selection--multiple:focus { + border: 1px solid #5897fb; } + .select2-container--classic .select2-selection--multiple .select2-selection__rendered { + list-style: none; + margin: 0; + padding: 0 5px; } + .select2-container--classic .select2-selection--multiple .select2-selection__clear { + display: none; } + .select2-container--classic .select2-selection--multiple .select2-selection__choice { + background-color: #e4e4e4; + border: 1px solid #aaa; + border-radius: 4px; + cursor: default; + float: left; + margin-right: 5px; + margin-top: 5px; + padding: 0 5px; } + .select2-container--classic .select2-selection--multiple .select2-selection__choice__remove { + color: #888; + cursor: pointer; + display: inline-block; + font-weight: bold; + margin-right: 2px; } + .select2-container--classic .select2-selection--multiple .select2-selection__choice__remove:hover { + color: #555; } + +.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice { + float: right; + margin-left: 5px; + margin-right: auto; } + +.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice__remove { + margin-left: 2px; + margin-right: auto; } + +.select2-container--classic.select2-container--open .select2-selection--multiple { + border: 1px solid #5897fb; } + +.select2-container--classic.select2-container--open.select2-container--above .select2-selection--multiple { + border-top: none; + border-top-left-radius: 0; + border-top-right-radius: 0; } + +.select2-container--classic.select2-container--open.select2-container--below .select2-selection--multiple { + border-bottom: none; + border-bottom-left-radius: 0; + border-bottom-right-radius: 0; } + +.select2-container--classic .select2-search--dropdown .select2-search__field { + border: 1px solid #aaa; + outline: 0; } + +.select2-container--classic .select2-search--inline .select2-search__field { + outline: 0; + box-shadow: none; } + +.select2-container--classic .select2-dropdown { + background-color: white; + border: 1px solid transparent; } + +.select2-container--classic .select2-dropdown--above { + border-bottom: none; } + +.select2-container--classic .select2-dropdown--below { + border-top: none; } + +.select2-container--classic .select2-results > .select2-results__options { + max-height: 200px; + overflow-y: auto; } + +.select2-container--classic .select2-results__option[role=group] { + padding: 0; } + +.select2-container--classic .select2-results__option[aria-disabled=true] { + color: grey; } + +.select2-container--classic .select2-results__option--highlighted[aria-selected] { + background-color: #3875d7; + color: white; } + +.select2-container--classic .select2-results__group { + cursor: default; + display: block; + padding: 6px; } + +.select2-container--classic.select2-container--open .select2-dropdown { + border-color: #5897fb; } diff --git a/sites/public/static/admin/css/vendor/select2/select2.min.css b/sites/public/static/admin/css/vendor/select2/select2.min.css new file mode 100755 index 00000000..7c18ad59 --- /dev/null +++ b/sites/public/static/admin/css/vendor/select2/select2.min.css @@ -0,0 +1 @@ +.select2-container{box-sizing:border-box;display:inline-block;margin:0;position:relative;vertical-align:middle}.select2-container .select2-selection--single{box-sizing:border-box;cursor:pointer;display:block;height:28px;user-select:none;-webkit-user-select:none}.select2-container .select2-selection--single .select2-selection__rendered{display:block;padding-left:8px;padding-right:20px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.select2-container .select2-selection--single .select2-selection__clear{position:relative}.select2-container[dir="rtl"] .select2-selection--single .select2-selection__rendered{padding-right:8px;padding-left:20px}.select2-container .select2-selection--multiple{box-sizing:border-box;cursor:pointer;display:block;min-height:32px;user-select:none;-webkit-user-select:none}.select2-container .select2-selection--multiple .select2-selection__rendered{display:inline-block;overflow:hidden;padding-left:8px;text-overflow:ellipsis;white-space:nowrap}.select2-container .select2-search--inline{float:left}.select2-container .select2-search--inline .select2-search__field{box-sizing:border-box;border:none;font-size:100%;margin-top:5px;padding:0}.select2-container .select2-search--inline .select2-search__field::-webkit-search-cancel-button{-webkit-appearance:none}.select2-dropdown{background-color:white;border:1px solid #aaa;border-radius:4px;box-sizing:border-box;display:block;position:absolute;left:-100000px;width:100%;z-index:1051}.select2-results{display:block}.select2-results__options{list-style:none;margin:0;padding:0}.select2-results__option{padding:6px;user-select:none;-webkit-user-select:none}.select2-results__option[aria-selected]{cursor:pointer}.select2-container--open .select2-dropdown{left:0}.select2-container--open .select2-dropdown--above{border-bottom:none;border-bottom-left-radius:0;border-bottom-right-radius:0}.select2-container--open .select2-dropdown--below{border-top:none;border-top-left-radius:0;border-top-right-radius:0}.select2-search--dropdown{display:block;padding:4px}.select2-search--dropdown .select2-search__field{padding:4px;width:100%;box-sizing:border-box}.select2-search--dropdown .select2-search__field::-webkit-search-cancel-button{-webkit-appearance:none}.select2-search--dropdown.select2-search--hide{display:none}.select2-close-mask{border:0;margin:0;padding:0;display:block;position:fixed;left:0;top:0;min-height:100%;min-width:100%;height:auto;width:auto;opacity:0;z-index:99;background-color:#fff;filter:alpha(opacity=0)}.select2-hidden-accessible{border:0 !important;clip:rect(0 0 0 0) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}.select2-container--default .select2-selection--single{background-color:#fff;border:1px solid #aaa;border-radius:4px}.select2-container--default .select2-selection--single .select2-selection__rendered{color:#444;line-height:28px}.select2-container--default .select2-selection--single .select2-selection__clear{cursor:pointer;float:right;font-weight:bold}.select2-container--default .select2-selection--single .select2-selection__placeholder{color:#999}.select2-container--default .select2-selection--single .select2-selection__arrow{height:26px;position:absolute;top:1px;right:1px;width:20px}.select2-container--default .select2-selection--single .select2-selection__arrow b{border-color:#888 transparent transparent transparent;border-style:solid;border-width:5px 4px 0 4px;height:0;left:50%;margin-left:-4px;margin-top:-2px;position:absolute;top:50%;width:0}.select2-container--default[dir="rtl"] .select2-selection--single .select2-selection__clear{float:left}.select2-container--default[dir="rtl"] .select2-selection--single .select2-selection__arrow{left:1px;right:auto}.select2-container--default.select2-container--disabled .select2-selection--single{background-color:#eee;cursor:default}.select2-container--default.select2-container--disabled .select2-selection--single .select2-selection__clear{display:none}.select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b{border-color:transparent transparent #888 transparent;border-width:0 4px 5px 4px}.select2-container--default .select2-selection--multiple{background-color:white;border:1px solid #aaa;border-radius:4px;cursor:text}.select2-container--default .select2-selection--multiple .select2-selection__rendered{box-sizing:border-box;list-style:none;margin:0;padding:0 5px;width:100%}.select2-container--default .select2-selection--multiple .select2-selection__rendered li{list-style:none}.select2-container--default .select2-selection--multiple .select2-selection__clear{cursor:pointer;float:right;font-weight:bold;margin-top:5px;margin-right:10px;padding:1px}.select2-container--default .select2-selection--multiple .select2-selection__choice{background-color:#e4e4e4;border:1px solid #aaa;border-radius:4px;cursor:default;float:left;margin-right:5px;margin-top:5px;padding:0 5px}.select2-container--default .select2-selection--multiple .select2-selection__choice__remove{color:#999;cursor:pointer;display:inline-block;font-weight:bold;margin-right:2px}.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover{color:#333}.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice,.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-search--inline{float:right}.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice{margin-left:5px;margin-right:auto}.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice__remove{margin-left:2px;margin-right:auto}.select2-container--default.select2-container--focus .select2-selection--multiple{border:solid black 1px;outline:0}.select2-container--default.select2-container--disabled .select2-selection--multiple{background-color:#eee;cursor:default}.select2-container--default.select2-container--disabled .select2-selection__choice__remove{display:none}.select2-container--default.select2-container--open.select2-container--above .select2-selection--single,.select2-container--default.select2-container--open.select2-container--above .select2-selection--multiple{border-top-left-radius:0;border-top-right-radius:0}.select2-container--default.select2-container--open.select2-container--below .select2-selection--single,.select2-container--default.select2-container--open.select2-container--below .select2-selection--multiple{border-bottom-left-radius:0;border-bottom-right-radius:0}.select2-container--default .select2-search--dropdown .select2-search__field{border:1px solid #aaa}.select2-container--default .select2-search--inline .select2-search__field{background:transparent;border:none;outline:0;box-shadow:none;-webkit-appearance:textfield}.select2-container--default .select2-results>.select2-results__options{max-height:200px;overflow-y:auto}.select2-container--default .select2-results__option[role=group]{padding:0}.select2-container--default .select2-results__option[aria-disabled=true]{color:#999}.select2-container--default .select2-results__option[aria-selected=true]{background-color:#ddd}.select2-container--default .select2-results__option .select2-results__option{padding-left:1em}.select2-container--default .select2-results__option .select2-results__option .select2-results__group{padding-left:0}.select2-container--default .select2-results__option .select2-results__option .select2-results__option{margin-left:-1em;padding-left:2em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-2em;padding-left:3em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-3em;padding-left:4em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-4em;padding-left:5em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-5em;padding-left:6em}.select2-container--default .select2-results__option--highlighted[aria-selected]{background-color:#5897fb;color:white}.select2-container--default .select2-results__group{cursor:default;display:block;padding:6px}.select2-container--classic .select2-selection--single{background-color:#f7f7f7;border:1px solid #aaa;border-radius:4px;outline:0;background-image:-webkit-linear-gradient(top, #fff 50%, #eee 100%);background-image:-o-linear-gradient(top, #fff 50%, #eee 100%);background-image:linear-gradient(to bottom, #fff 50%, #eee 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF', endColorstr='#FFEEEEEE', GradientType=0)}.select2-container--classic .select2-selection--single:focus{border:1px solid #5897fb}.select2-container--classic .select2-selection--single .select2-selection__rendered{color:#444;line-height:28px}.select2-container--classic .select2-selection--single .select2-selection__clear{cursor:pointer;float:right;font-weight:bold;margin-right:10px}.select2-container--classic .select2-selection--single .select2-selection__placeholder{color:#999}.select2-container--classic .select2-selection--single .select2-selection__arrow{background-color:#ddd;border:none;border-left:1px solid #aaa;border-top-right-radius:4px;border-bottom-right-radius:4px;height:26px;position:absolute;top:1px;right:1px;width:20px;background-image:-webkit-linear-gradient(top, #eee 50%, #ccc 100%);background-image:-o-linear-gradient(top, #eee 50%, #ccc 100%);background-image:linear-gradient(to bottom, #eee 50%, #ccc 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFEEEEEE', endColorstr='#FFCCCCCC', GradientType=0)}.select2-container--classic .select2-selection--single .select2-selection__arrow b{border-color:#888 transparent transparent transparent;border-style:solid;border-width:5px 4px 0 4px;height:0;left:50%;margin-left:-4px;margin-top:-2px;position:absolute;top:50%;width:0}.select2-container--classic[dir="rtl"] .select2-selection--single .select2-selection__clear{float:left}.select2-container--classic[dir="rtl"] .select2-selection--single .select2-selection__arrow{border:none;border-right:1px solid #aaa;border-radius:0;border-top-left-radius:4px;border-bottom-left-radius:4px;left:1px;right:auto}.select2-container--classic.select2-container--open .select2-selection--single{border:1px solid #5897fb}.select2-container--classic.select2-container--open .select2-selection--single .select2-selection__arrow{background:transparent;border:none}.select2-container--classic.select2-container--open .select2-selection--single .select2-selection__arrow b{border-color:transparent transparent #888 transparent;border-width:0 4px 5px 4px}.select2-container--classic.select2-container--open.select2-container--above .select2-selection--single{border-top:none;border-top-left-radius:0;border-top-right-radius:0;background-image:-webkit-linear-gradient(top, #fff 0%, #eee 50%);background-image:-o-linear-gradient(top, #fff 0%, #eee 50%);background-image:linear-gradient(to bottom, #fff 0%, #eee 50%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF', endColorstr='#FFEEEEEE', GradientType=0)}.select2-container--classic.select2-container--open.select2-container--below .select2-selection--single{border-bottom:none;border-bottom-left-radius:0;border-bottom-right-radius:0;background-image:-webkit-linear-gradient(top, #eee 50%, #fff 100%);background-image:-o-linear-gradient(top, #eee 50%, #fff 100%);background-image:linear-gradient(to bottom, #eee 50%, #fff 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFEEEEEE', endColorstr='#FFFFFFFF', GradientType=0)}.select2-container--classic .select2-selection--multiple{background-color:white;border:1px solid #aaa;border-radius:4px;cursor:text;outline:0}.select2-container--classic .select2-selection--multiple:focus{border:1px solid #5897fb}.select2-container--classic .select2-selection--multiple .select2-selection__rendered{list-style:none;margin:0;padding:0 5px}.select2-container--classic .select2-selection--multiple .select2-selection__clear{display:none}.select2-container--classic .select2-selection--multiple .select2-selection__choice{background-color:#e4e4e4;border:1px solid #aaa;border-radius:4px;cursor:default;float:left;margin-right:5px;margin-top:5px;padding:0 5px}.select2-container--classic .select2-selection--multiple .select2-selection__choice__remove{color:#888;cursor:pointer;display:inline-block;font-weight:bold;margin-right:2px}.select2-container--classic .select2-selection--multiple .select2-selection__choice__remove:hover{color:#555}.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice{float:right;margin-left:5px;margin-right:auto}.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice__remove{margin-left:2px;margin-right:auto}.select2-container--classic.select2-container--open .select2-selection--multiple{border:1px solid #5897fb}.select2-container--classic.select2-container--open.select2-container--above .select2-selection--multiple{border-top:none;border-top-left-radius:0;border-top-right-radius:0}.select2-container--classic.select2-container--open.select2-container--below .select2-selection--multiple{border-bottom:none;border-bottom-left-radius:0;border-bottom-right-radius:0}.select2-container--classic .select2-search--dropdown .select2-search__field{border:1px solid #aaa;outline:0}.select2-container--classic .select2-search--inline .select2-search__field{outline:0;box-shadow:none}.select2-container--classic .select2-dropdown{background-color:#fff;border:1px solid transparent}.select2-container--classic .select2-dropdown--above{border-bottom:none}.select2-container--classic .select2-dropdown--below{border-top:none}.select2-container--classic .select2-results>.select2-results__options{max-height:200px;overflow-y:auto}.select2-container--classic .select2-results__option[role=group]{padding:0}.select2-container--classic .select2-results__option[aria-disabled=true]{color:grey}.select2-container--classic .select2-results__option--highlighted[aria-selected]{background-color:#3875d7;color:#fff}.select2-container--classic .select2-results__group{cursor:default;display:block;padding:6px}.select2-container--classic.select2-container--open .select2-dropdown{border-color:#5897fb} diff --git a/sites/public/static/admin/css/widgets.css b/sites/public/static/admin/css/widgets.css new file mode 100755 index 00000000..5f7adcb2 --- /dev/null +++ b/sites/public/static/admin/css/widgets.css @@ -0,0 +1,603 @@ +/* SELECTOR (FILTER INTERFACE) */ + +.selector { + width: 800px; + float: left; + display: flex; +} + +.selector select { + width: 380px; + height: 17.2em; + flex: 1 0 auto; +} + +.selector-available, .selector-chosen { + width: 380px; + text-align: center; + margin-bottom: 5px; + display: flex; + flex-direction: column; +} + +.selector-available h2, .selector-chosen h2 { + border: 1px solid var(--border-color); + border-radius: 4px 4px 0 0; +} + +.selector-chosen .list-footer-display { + border: 1px solid var(--border-color); + border-top: none; + border-radius: 0 0 4px 4px; + margin: 0 0 10px; + padding: 8px; + text-align: center; + background: var(--primary); + color: var(--header-link-color); + cursor: pointer; +} +.selector-chosen .list-footer-display__clear { + color: var(--breadcrumbs-fg); +} + +.selector-chosen h2 { + background: var(--primary); + color: var(--header-link-color); +} + +.selector .selector-available h2 { + background: var(--darkened-bg); + color: var(--body-quiet-color); +} + +.selector .selector-filter { + border: 1px solid var(--border-color); + border-width: 0 1px; + padding: 8px; + color: var(--body-quiet-color); + font-size: 0.625rem; + margin: 0; + text-align: left; +} + +.selector .selector-filter label, +.inline-group .aligned .selector .selector-filter label { + float: left; + margin: 7px 0 0; + width: 18px; + height: 18px; + padding: 0; + overflow: hidden; + line-height: 1; +} + +.selector .selector-available input, +.selector .selector-chosen input { + width: 320px; + margin-left: 8px; +} + +.selector ul.selector-chooser { + align-self: center; + width: 22px; + background-color: var(--selected-bg); + border-radius: 10px; + margin: 0 5px; + padding: 0; + transform: translateY(-17px); +} + +.selector-chooser li { + margin: 0; + padding: 3px; + list-style-type: none; +} + +.selector select { + padding: 0 10px; + margin: 0 0 10px; + border-radius: 0 0 4px 4px; +} +.selector .selector-chosen--with-filtered select { + margin: 0; + border-radius: 0; + height: 14em; +} + +.selector .selector-chosen:not(.selector-chosen--with-filtered) .list-footer-display { + display: none; +} + +.selector-add, .selector-remove { + width: 16px; + height: 16px; + display: block; + text-indent: -3000px; + overflow: hidden; + cursor: default; + opacity: 0.55; +} + +.active.selector-add, .active.selector-remove { + opacity: 1; +} + +.active.selector-add:hover, .active.selector-remove:hover { + cursor: pointer; +} + +.selector-add { + background: url(../img/selector-icons.svg) 0 -96px no-repeat; +} + +.active.selector-add:focus, .active.selector-add:hover { + background-position: 0 -112px; +} + +.selector-remove { + background: url(../img/selector-icons.svg) 0 -64px no-repeat; +} + +.active.selector-remove:focus, .active.selector-remove:hover { + background-position: 0 -80px; +} + +a.selector-chooseall, a.selector-clearall { + display: inline-block; + height: 16px; + text-align: left; + margin: 1px auto 3px; + overflow: hidden; + font-weight: bold; + line-height: 16px; + color: var(--body-quiet-color); + text-decoration: none; + opacity: 0.55; +} + +a.active.selector-chooseall:focus, a.active.selector-clearall:focus, +a.active.selector-chooseall:hover, a.active.selector-clearall:hover { + color: var(--link-fg); +} + +a.active.selector-chooseall, a.active.selector-clearall { + opacity: 1; +} + +a.active.selector-chooseall:hover, a.active.selector-clearall:hover { + cursor: pointer; +} + +a.selector-chooseall { + padding: 0 18px 0 0; + background: url(../img/selector-icons.svg) right -160px no-repeat; + cursor: default; +} + +a.active.selector-chooseall:focus, a.active.selector-chooseall:hover { + background-position: 100% -176px; +} + +a.selector-clearall { + padding: 0 0 0 18px; + background: url(../img/selector-icons.svg) 0 -128px no-repeat; + cursor: default; +} + +a.active.selector-clearall:focus, a.active.selector-clearall:hover { + background-position: 0 -144px; +} + +/* STACKED SELECTORS */ + +.stacked { + float: left; + width: 490px; + display: block; +} + +.stacked select { + width: 480px; + height: 10.1em; +} + +.stacked .selector-available, .stacked .selector-chosen { + width: 480px; +} + +.stacked .selector-available { + margin-bottom: 0; +} + +.stacked .selector-available input { + width: 422px; +} + +.stacked ul.selector-chooser { + height: 22px; + width: 50px; + margin: 0 0 10px 40%; + background-color: #eee; + border-radius: 10px; + transform: none; +} + +.stacked .selector-chooser li { + float: left; + padding: 3px 3px 3px 5px; +} + +.stacked .selector-chooseall, .stacked .selector-clearall { + display: none; +} + +.stacked .selector-add { + background: url(../img/selector-icons.svg) 0 -32px no-repeat; + cursor: default; +} + +.stacked .active.selector-add { + background-position: 0 -32px; + cursor: pointer; +} + +.stacked .active.selector-add:focus, .stacked .active.selector-add:hover { + background-position: 0 -48px; + cursor: pointer; +} + +.stacked .selector-remove { + background: url(../img/selector-icons.svg) 0 0 no-repeat; + cursor: default; +} + +.stacked .active.selector-remove { + background-position: 0 0px; + cursor: pointer; +} + +.stacked .active.selector-remove:focus, .stacked .active.selector-remove:hover { + background-position: 0 -16px; + cursor: pointer; +} + +.selector .help-icon { + background: url(../img/icon-unknown.svg) 0 0 no-repeat; + display: inline-block; + vertical-align: middle; + margin: -2px 0 0 2px; + width: 13px; + height: 13px; +} + +.selector .selector-chosen .help-icon { + background: url(../img/icon-unknown-alt.svg) 0 0 no-repeat; +} + +.selector .search-label-icon { + background: url(../img/search.svg) 0 0 no-repeat; + display: inline-block; + height: 1.125rem; + width: 1.125rem; +} + +/* DATE AND TIME */ + +p.datetime { + line-height: 20px; + margin: 0; + padding: 0; + color: var(--body-quiet-color); + font-weight: bold; +} + +.datetime span { + white-space: nowrap; + font-weight: normal; + font-size: 0.6875rem; + color: var(--body-quiet-color); +} + +.datetime input, .form-row .datetime input.vDateField, .form-row .datetime input.vTimeField { + margin-left: 5px; + margin-bottom: 4px; +} + +table p.datetime { + font-size: 0.6875rem; + margin-left: 0; + padding-left: 0; +} + +.datetimeshortcuts .clock-icon, .datetimeshortcuts .date-icon { + position: relative; + display: inline-block; + vertical-align: middle; + height: 16px; + width: 16px; + overflow: hidden; +} + +.datetimeshortcuts .clock-icon { + background: url(../img/icon-clock.svg) 0 0 no-repeat; +} + +.datetimeshortcuts a:focus .clock-icon, +.datetimeshortcuts a:hover .clock-icon { + background-position: 0 -16px; +} + +.datetimeshortcuts .date-icon { + background: url(../img/icon-calendar.svg) 0 0 no-repeat; + top: -1px; +} + +.datetimeshortcuts a:focus .date-icon, +.datetimeshortcuts a:hover .date-icon { + background-position: 0 -16px; +} + +.timezonewarning { + font-size: 0.6875rem; + color: var(--body-quiet-color); +} + +/* URL */ + +p.url { + line-height: 20px; + margin: 0; + padding: 0; + color: var(--body-quiet-color); + font-size: 0.6875rem; + font-weight: bold; +} + +.url a { + font-weight: normal; +} + +/* FILE UPLOADS */ + +p.file-upload { + line-height: 20px; + margin: 0; + padding: 0; + color: var(--body-quiet-color); + font-size: 0.6875rem; + font-weight: bold; +} + +.file-upload a { + font-weight: normal; +} + +.file-upload .deletelink { + margin-left: 5px; +} + +span.clearable-file-input label { + color: var(--body-fg); + font-size: 0.6875rem; + display: inline; + float: none; +} + +/* CALENDARS & CLOCKS */ + +.calendarbox, .clockbox { + margin: 5px auto; + font-size: 0.75rem; + width: 19em; + text-align: center; + background: var(--body-bg); + color: var(--body-fg); + border: 1px solid var(--hairline-color); + border-radius: 4px; + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15); + overflow: hidden; + position: relative; +} + +.clockbox { + width: auto; +} + +.calendar { + margin: 0; + padding: 0; +} + +.calendar table { + margin: 0; + padding: 0; + border-collapse: collapse; + background: white; + width: 100%; +} + +.calendar caption, .calendarbox h2 { + margin: 0; + text-align: center; + border-top: none; + font-weight: 700; + font-size: 0.75rem; + color: #333; + background: var(--accent); +} + +.calendar th { + padding: 8px 5px; + background: var(--darkened-bg); + border-bottom: 1px solid var(--border-color); + font-weight: 400; + font-size: 0.75rem; + text-align: center; + color: var(--body-quiet-color); +} + +.calendar td { + font-weight: 400; + font-size: 0.75rem; + text-align: center; + padding: 0; + border-top: 1px solid var(--hairline-color); + border-bottom: none; +} + +.calendar td.selected a { + background: var(--primary); + color: var(--button-fg); +} + +.calendar td.nonday { + background: var(--darkened-bg); +} + +.calendar td.today a { + font-weight: 700; +} + +.calendar td a, .timelist a { + display: block; + font-weight: 400; + padding: 6px; + text-decoration: none; + color: var(--body-quiet-color); +} + +.calendar td a:focus, .timelist a:focus, +.calendar td a:hover, .timelist a:hover { + background: var(--primary); + color: white; +} + +.calendar td a:active, .timelist a:active { + background: var(--header-bg); + color: white; +} + +.calendarnav { + font-size: 0.625rem; + text-align: center; + color: #ccc; + margin: 0; + padding: 1px 3px; +} + +.calendarnav a:link, #calendarnav a:visited, +#calendarnav a:focus, #calendarnav a:hover { + color: var(--body-quiet-color); +} + +.calendar-shortcuts { + background: var(--body-bg); + color: var(--body-quiet-color); + font-size: 0.6875rem; + line-height: 0.6875rem; + border-top: 1px solid var(--hairline-color); + padding: 8px 0; +} + +.calendarbox .calendarnav-previous, .calendarbox .calendarnav-next { + display: block; + position: absolute; + top: 8px; + width: 15px; + height: 15px; + text-indent: -9999px; + padding: 0; +} + +.calendarnav-previous { + left: 10px; + background: url(../img/calendar-icons.svg) 0 0 no-repeat; +} + +.calendarbox .calendarnav-previous:focus, +.calendarbox .calendarnav-previous:hover { + background-position: 0 -15px; +} + +.calendarnav-next { + right: 10px; + background: url(../img/calendar-icons.svg) 0 -30px no-repeat; +} + +.calendarbox .calendarnav-next:focus, +.calendarbox .calendarnav-next:hover { + background-position: 0 -45px; +} + +.calendar-cancel { + margin: 0; + padding: 4px 0; + font-size: 0.75rem; + background: #eee; + border-top: 1px solid var(--border-color); + color: var(--body-fg); +} + +.calendar-cancel:focus, .calendar-cancel:hover { + background: #ddd; +} + +.calendar-cancel a { + color: black; + display: block; +} + +ul.timelist, .timelist li { + list-style-type: none; + margin: 0; + padding: 0; +} + +.timelist a { + padding: 2px; +} + +/* EDIT INLINE */ + +.inline-deletelink { + float: right; + text-indent: -9999px; + background: url(../img/inline-delete.svg) 0 0 no-repeat; + width: 16px; + height: 16px; + border: 0px none; +} + +.inline-deletelink:focus, .inline-deletelink:hover { + cursor: pointer; +} + +/* RELATED WIDGET WRAPPER */ +.related-widget-wrapper { + float: left; /* display properly in form rows with multiple fields */ + overflow: hidden; /* clear floated contents */ +} + +.related-widget-wrapper-link { + opacity: 0.3; +} + +.related-widget-wrapper-link:link { + opacity: .8; +} + +.related-widget-wrapper-link:link:focus, +.related-widget-wrapper-link:link:hover { + opacity: 1; +} + +select + .related-widget-wrapper-link, +.related-widget-wrapper-link + .related-widget-wrapper-link { + margin-left: 7px; +} + +/* GIS MAPS */ +.dj_map { + width: 600px; + height: 400px; +} diff --git a/sites/public/static/admin/img/LICENSE b/sites/public/static/admin/img/LICENSE new file mode 100755 index 00000000..a4faaa1d --- /dev/null +++ b/sites/public/static/admin/img/LICENSE @@ -0,0 +1,20 @@ +The MIT License (MIT) + +Copyright (c) 2014 Code Charm Ltd + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/sites/public/static/admin/img/README.txt b/sites/public/static/admin/img/README.txt new file mode 100755 index 00000000..4eb2e492 --- /dev/null +++ b/sites/public/static/admin/img/README.txt @@ -0,0 +1,7 @@ +All icons are taken from Font Awesome (http://fontawesome.io/) project. +The Font Awesome font is licensed under the SIL OFL 1.1: +- https://scripts.sil.org/OFL + +SVG icons source: https://github.com/encharm/Font-Awesome-SVG-PNG +Font-Awesome-SVG-PNG is licensed under the MIT license (see file license +in current folder). diff --git a/sites/public/static/admin/img/calendar-icons.svg b/sites/public/static/admin/img/calendar-icons.svg new file mode 100755 index 00000000..dbf21c39 --- /dev/null +++ b/sites/public/static/admin/img/calendar-icons.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/sites/public/static/admin/img/gis/move_vertex_off.svg b/sites/public/static/admin/img/gis/move_vertex_off.svg new file mode 100755 index 00000000..228854f3 --- /dev/null +++ b/sites/public/static/admin/img/gis/move_vertex_off.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/sites/public/static/admin/img/gis/move_vertex_on.svg b/sites/public/static/admin/img/gis/move_vertex_on.svg new file mode 100755 index 00000000..96b87fdd --- /dev/null +++ b/sites/public/static/admin/img/gis/move_vertex_on.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/sites/public/static/admin/img/icon-addlink.svg b/sites/public/static/admin/img/icon-addlink.svg new file mode 100755 index 00000000..e004fb16 --- /dev/null +++ b/sites/public/static/admin/img/icon-addlink.svg @@ -0,0 +1,3 @@ + + + diff --git a/sites/public/static/admin/img/icon-alert.svg b/sites/public/static/admin/img/icon-alert.svg new file mode 100755 index 00000000..e51ea83f --- /dev/null +++ b/sites/public/static/admin/img/icon-alert.svg @@ -0,0 +1,3 @@ + + + diff --git a/sites/public/static/admin/img/icon-calendar.svg b/sites/public/static/admin/img/icon-calendar.svg new file mode 100755 index 00000000..97910a99 --- /dev/null +++ b/sites/public/static/admin/img/icon-calendar.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/sites/public/static/admin/img/icon-changelink.svg b/sites/public/static/admin/img/icon-changelink.svg new file mode 100755 index 00000000..bbb137aa --- /dev/null +++ b/sites/public/static/admin/img/icon-changelink.svg @@ -0,0 +1,3 @@ + + + diff --git a/sites/public/static/admin/img/icon-clock.svg b/sites/public/static/admin/img/icon-clock.svg new file mode 100755 index 00000000..bf9985d3 --- /dev/null +++ b/sites/public/static/admin/img/icon-clock.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/sites/public/static/admin/img/icon-deletelink.svg b/sites/public/static/admin/img/icon-deletelink.svg new file mode 100755 index 00000000..4059b155 --- /dev/null +++ b/sites/public/static/admin/img/icon-deletelink.svg @@ -0,0 +1,3 @@ + + + diff --git a/sites/public/static/admin/img/icon-no.svg b/sites/public/static/admin/img/icon-no.svg new file mode 100755 index 00000000..2e0d3832 --- /dev/null +++ b/sites/public/static/admin/img/icon-no.svg @@ -0,0 +1,3 @@ + + + diff --git a/sites/public/static/admin/img/icon-unknown-alt.svg b/sites/public/static/admin/img/icon-unknown-alt.svg new file mode 100755 index 00000000..1c6b99fc --- /dev/null +++ b/sites/public/static/admin/img/icon-unknown-alt.svg @@ -0,0 +1,3 @@ + + + diff --git a/sites/public/static/admin/img/icon-unknown.svg b/sites/public/static/admin/img/icon-unknown.svg new file mode 100755 index 00000000..50b4f972 --- /dev/null +++ b/sites/public/static/admin/img/icon-unknown.svg @@ -0,0 +1,3 @@ + + + diff --git a/sites/public/static/admin/img/icon-viewlink.svg b/sites/public/static/admin/img/icon-viewlink.svg new file mode 100755 index 00000000..a1ca1d3f --- /dev/null +++ b/sites/public/static/admin/img/icon-viewlink.svg @@ -0,0 +1,3 @@ + + + diff --git a/sites/public/static/admin/img/icon-yes.svg b/sites/public/static/admin/img/icon-yes.svg new file mode 100755 index 00000000..5883d877 --- /dev/null +++ b/sites/public/static/admin/img/icon-yes.svg @@ -0,0 +1,3 @@ + + + diff --git a/sites/public/static/admin/img/inline-delete.svg b/sites/public/static/admin/img/inline-delete.svg new file mode 100755 index 00000000..17d1ad67 --- /dev/null +++ b/sites/public/static/admin/img/inline-delete.svg @@ -0,0 +1,3 @@ + + + diff --git a/sites/public/static/admin/img/search.svg b/sites/public/static/admin/img/search.svg new file mode 100755 index 00000000..c8c69b2a --- /dev/null +++ b/sites/public/static/admin/img/search.svg @@ -0,0 +1,3 @@ + + + diff --git a/sites/public/static/admin/img/selector-icons.svg b/sites/public/static/admin/img/selector-icons.svg new file mode 100755 index 00000000..926b8e21 --- /dev/null +++ b/sites/public/static/admin/img/selector-icons.svg @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sites/public/static/admin/img/sorting-icons.svg b/sites/public/static/admin/img/sorting-icons.svg new file mode 100755 index 00000000..7c31ec91 --- /dev/null +++ b/sites/public/static/admin/img/sorting-icons.svg @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/sites/public/static/admin/img/tooltag-add.svg b/sites/public/static/admin/img/tooltag-add.svg new file mode 100755 index 00000000..1ca64ae5 --- /dev/null +++ b/sites/public/static/admin/img/tooltag-add.svg @@ -0,0 +1,3 @@ + + + diff --git a/sites/public/static/admin/img/tooltag-arrowright.svg b/sites/public/static/admin/img/tooltag-arrowright.svg new file mode 100755 index 00000000..b664d619 --- /dev/null +++ b/sites/public/static/admin/img/tooltag-arrowright.svg @@ -0,0 +1,3 @@ + + + diff --git a/sites/public/static/admin/js/SelectBox.js b/sites/public/static/admin/js/SelectBox.js new file mode 100755 index 00000000..3db4ec7f --- /dev/null +++ b/sites/public/static/admin/js/SelectBox.js @@ -0,0 +1,116 @@ +'use strict'; +{ + const SelectBox = { + cache: {}, + init: function(id) { + const box = document.getElementById(id); + SelectBox.cache[id] = []; + const cache = SelectBox.cache[id]; + for (const node of box.options) { + cache.push({value: node.value, text: node.text, displayed: 1}); + } + }, + redisplay: function(id) { + // Repopulate HTML select box from cache + const box = document.getElementById(id); + const scroll_value_from_top = box.scrollTop; + box.innerHTML = ''; + for (const node of SelectBox.cache[id]) { + if (node.displayed) { + const new_option = new Option(node.text, node.value, false, false); + // Shows a tooltip when hovering over the option + new_option.title = node.text; + box.appendChild(new_option); + } + } + box.scrollTop = scroll_value_from_top; + }, + filter: function(id, text) { + // Redisplay the HTML select box, displaying only the choices containing ALL + // the words in text. (It's an AND search.) + const tokens = text.toLowerCase().split(/\s+/); + for (const node of SelectBox.cache[id]) { + node.displayed = 1; + const node_text = node.text.toLowerCase(); + for (const token of tokens) { + if (!node_text.includes(token)) { + node.displayed = 0; + break; // Once the first token isn't found we're done + } + } + } + SelectBox.redisplay(id); + }, + get_hidden_node_count(id) { + const cache = SelectBox.cache[id] || []; + return cache.filter(node => node.displayed === 0).length; + }, + delete_from_cache: function(id, value) { + let delete_index = null; + const cache = SelectBox.cache[id]; + for (const [i, node] of cache.entries()) { + if (node.value === value) { + delete_index = i; + break; + } + } + cache.splice(delete_index, 1); + }, + add_to_cache: function(id, option) { + SelectBox.cache[id].push({value: option.value, text: option.text, displayed: 1}); + }, + cache_contains: function(id, value) { + // Check if an item is contained in the cache + for (const node of SelectBox.cache[id]) { + if (node.value === value) { + return true; + } + } + return false; + }, + move: function(from, to) { + const from_box = document.getElementById(from); + for (const option of from_box.options) { + const option_value = option.value; + if (option.selected && SelectBox.cache_contains(from, option_value)) { + SelectBox.add_to_cache(to, {value: option_value, text: option.text, displayed: 1}); + SelectBox.delete_from_cache(from, option_value); + } + } + SelectBox.redisplay(from); + SelectBox.redisplay(to); + }, + move_all: function(from, to) { + const from_box = document.getElementById(from); + for (const option of from_box.options) { + const option_value = option.value; + if (SelectBox.cache_contains(from, option_value)) { + SelectBox.add_to_cache(to, {value: option_value, text: option.text, displayed: 1}); + SelectBox.delete_from_cache(from, option_value); + } + } + SelectBox.redisplay(from); + SelectBox.redisplay(to); + }, + sort: function(id) { + SelectBox.cache[id].sort(function(a, b) { + a = a.text.toLowerCase(); + b = b.text.toLowerCase(); + if (a > b) { + return 1; + } + if (a < b) { + return -1; + } + return 0; + } ); + }, + select_all: function(id) { + const box = document.getElementById(id); + for (const option of box.options) { + option.selected = true; + } + } + }; + window.SelectBox = SelectBox; +} diff --git a/sites/public/static/admin/js/SelectFilter2.js b/sites/public/static/admin/js/SelectFilter2.js new file mode 100755 index 00000000..9a4e0a3a --- /dev/null +++ b/sites/public/static/admin/js/SelectFilter2.js @@ -0,0 +1,283 @@ +/*global SelectBox, gettext, interpolate, quickElement, SelectFilter*/ +/* +SelectFilter2 - Turns a multiple-select box into a filter interface. + +Requires core.js and SelectBox.js. +*/ +'use strict'; +{ + window.SelectFilter = { + init: function(field_id, field_name, is_stacked) { + if (field_id.match(/__prefix__/)) { + // Don't initialize on empty forms. + return; + } + const from_box = document.getElementById(field_id); + from_box.id += '_from'; // change its ID + from_box.className = 'filtered'; + + for (const p of from_box.parentNode.getElementsByTagName('p')) { + if (p.classList.contains("info")) { + // Remove

, because it just gets in the way. + from_box.parentNode.removeChild(p); + } else if (p.classList.contains("help")) { + // Move help text up to the top so it isn't below the select + // boxes or wrapped off on the side to the right of the add + // button: + from_box.parentNode.insertBefore(p, from_box.parentNode.firstChild); + } + } + + //

or
+ const selector_div = quickElement('div', from_box.parentNode); + selector_div.className = is_stacked ? 'selector stacked' : 'selector'; + + //
+ const selector_available = quickElement('div', selector_div); + selector_available.className = 'selector-available'; + const title_available = quickElement('h2', selector_available, interpolate(gettext('Available %s') + ' ', [field_name])); + quickElement( + 'span', title_available, '', + 'class', 'help help-tooltip help-icon', + 'title', interpolate( + gettext( + 'This is the list of available %s. You may choose some by ' + + 'selecting them in the box below and then clicking the ' + + '"Choose" arrow between the two boxes.' + ), + [field_name] + ) + ); + + const filter_p = quickElement('p', selector_available, '', 'id', field_id + '_filter'); + filter_p.className = 'selector-filter'; + + const search_filter_label = quickElement('label', filter_p, '', 'for', field_id + '_input'); + + quickElement( + 'span', search_filter_label, '', + 'class', 'help-tooltip search-label-icon', + 'title', interpolate(gettext("Type into this box to filter down the list of available %s."), [field_name]) + ); + + filter_p.appendChild(document.createTextNode(' ')); + + const filter_input = quickElement('input', filter_p, '', 'type', 'text', 'placeholder', gettext("Filter")); + filter_input.id = field_id + '_input'; + + selector_available.appendChild(from_box); + const choose_all = quickElement('a', selector_available, gettext('Choose all'), 'title', interpolate(gettext('Click to choose all %s at once.'), [field_name]), 'href', '#', 'id', field_id + '_add_all_link'); + choose_all.className = 'selector-chooseall'; + + //
    + const selector_chooser = quickElement('ul', selector_div); + selector_chooser.className = 'selector-chooser'; + const add_link = quickElement('a', quickElement('li', selector_chooser), gettext('Choose'), 'title', gettext('Choose'), 'href', '#', 'id', field_id + '_add_link'); + add_link.className = 'selector-add'; + const remove_link = quickElement('a', quickElement('li', selector_chooser), gettext('Remove'), 'title', gettext('Remove'), 'href', '#', 'id', field_id + '_remove_link'); + remove_link.className = 'selector-remove'; + + //
    + const selector_chosen = quickElement('div', selector_div, '', 'id', field_id + '_selector_chosen'); + selector_chosen.className = 'selector-chosen'; + const title_chosen = quickElement('h2', selector_chosen, interpolate(gettext('Chosen %s') + ' ', [field_name])); + quickElement( + 'span', title_chosen, '', + 'class', 'help help-tooltip help-icon', + 'title', interpolate( + gettext( + 'This is the list of chosen %s. You may remove some by ' + + 'selecting them in the box below and then clicking the ' + + '"Remove" arrow between the two boxes.' + ), + [field_name] + ) + ); + + const filter_selected_p = quickElement('p', selector_chosen, '', 'id', field_id + '_filter_selected'); + filter_selected_p.className = 'selector-filter'; + + const search_filter_selected_label = quickElement('label', filter_selected_p, '', 'for', field_id + '_selected_input'); + + quickElement( + 'span', search_filter_selected_label, '', + 'class', 'help-tooltip search-label-icon', + 'title', interpolate(gettext("Type into this box to filter down the list of selected %s."), [field_name]) + ); + + filter_selected_p.appendChild(document.createTextNode(' ')); + + const filter_selected_input = quickElement('input', filter_selected_p, '', 'type', 'text', 'placeholder', gettext("Filter")); + filter_selected_input.id = field_id + '_selected_input'; + + const to_box = quickElement('select', selector_chosen, '', 'id', field_id + '_to', 'multiple', '', 'size', from_box.size, 'name', from_box.name); + to_box.className = 'filtered'; + + const warning_footer = quickElement('div', selector_chosen, '', 'class', 'list-footer-display'); + quickElement('span', warning_footer, '', 'id', field_id + '_list-footer-display-text'); + quickElement('span', warning_footer, ' (click to clear)', 'class', 'list-footer-display__clear'); + + const clear_all = quickElement('a', selector_chosen, gettext('Remove all'), 'title', interpolate(gettext('Click to remove all chosen %s at once.'), [field_name]), 'href', '#', 'id', field_id + '_remove_all_link'); + clear_all.className = 'selector-clearall'; + + from_box.name = from_box.name + '_old'; + + // Set up the JavaScript event handlers for the select box filter interface + const move_selection = function(e, elem, move_func, from, to) { + if (elem.classList.contains('active')) { + move_func(from, to); + SelectFilter.refresh_icons(field_id); + SelectFilter.refresh_filtered_selects(field_id); + SelectFilter.refresh_filtered_warning(field_id); + } + e.preventDefault(); + }; + choose_all.addEventListener('click', function(e) { + move_selection(e, this, SelectBox.move_all, field_id + '_from', field_id + '_to'); + }); + add_link.addEventListener('click', function(e) { + move_selection(e, this, SelectBox.move, field_id + '_from', field_id + '_to'); + }); + remove_link.addEventListener('click', function(e) { + move_selection(e, this, SelectBox.move, field_id + '_to', field_id + '_from'); + }); + clear_all.addEventListener('click', function(e) { + move_selection(e, this, SelectBox.move_all, field_id + '_to', field_id + '_from'); + }); + warning_footer.addEventListener('click', function(e) { + filter_selected_input.value = ''; + SelectBox.filter(field_id + '_to', ''); + SelectFilter.refresh_filtered_warning(field_id); + SelectFilter.refresh_icons(field_id); + }); + filter_input.addEventListener('keypress', function(e) { + SelectFilter.filter_key_press(e, field_id, '_from', '_to'); + }); + filter_input.addEventListener('keyup', function(e) { + SelectFilter.filter_key_up(e, field_id, '_from'); + }); + filter_input.addEventListener('keydown', function(e) { + SelectFilter.filter_key_down(e, field_id, '_from', '_to'); + }); + filter_selected_input.addEventListener('keypress', function(e) { + SelectFilter.filter_key_press(e, field_id, '_to', '_from'); + }); + filter_selected_input.addEventListener('keyup', function(e) { + SelectFilter.filter_key_up(e, field_id, '_to', '_selected_input'); + }); + filter_selected_input.addEventListener('keydown', function(e) { + SelectFilter.filter_key_down(e, field_id, '_to', '_from'); + }); + selector_div.addEventListener('change', function(e) { + if (e.target.tagName === 'SELECT') { + SelectFilter.refresh_icons(field_id); + } + }); + selector_div.addEventListener('dblclick', function(e) { + if (e.target.tagName === 'OPTION') { + if (e.target.closest('select').id === field_id + '_to') { + SelectBox.move(field_id + '_to', field_id + '_from'); + } else { + SelectBox.move(field_id + '_from', field_id + '_to'); + } + SelectFilter.refresh_icons(field_id); + } + }); + from_box.closest('form').addEventListener('submit', function() { + SelectBox.filter(field_id + '_to', ''); + SelectBox.select_all(field_id + '_to'); + }); + SelectBox.init(field_id + '_from'); + SelectBox.init(field_id + '_to'); + // Move selected from_box options to to_box + SelectBox.move(field_id + '_from', field_id + '_to'); + + // Initial icon refresh + SelectFilter.refresh_icons(field_id); + }, + any_selected: function(field) { + // Temporarily add the required attribute and check validity. + field.required = true; + const any_selected = field.checkValidity(); + field.required = false; + return any_selected; + }, + refresh_filtered_warning: function(field_id) { + const count = SelectBox.get_hidden_node_count(field_id + '_to'); + const selector = document.getElementById(field_id + '_selector_chosen'); + const warning = document.getElementById(field_id + '_list-footer-display-text'); + selector.className = selector.className.replace('selector-chosen--with-filtered', ''); + warning.textContent = interpolate(ngettext( + '%s selected option not visible', + '%s selected options not visible', + count + ), [count]); + if(count > 0) { + selector.className += ' selector-chosen--with-filtered'; + } + }, + refresh_filtered_selects: function(field_id) { + SelectBox.filter(field_id + '_from', document.getElementById(field_id + "_input").value); + SelectBox.filter(field_id + '_to', document.getElementById(field_id + "_selected_input").value); + }, + refresh_icons: function(field_id) { + const from = document.getElementById(field_id + '_from'); + const to = document.getElementById(field_id + '_to'); + // Active if at least one item is selected + document.getElementById(field_id + '_add_link').classList.toggle('active', SelectFilter.any_selected(from)); + document.getElementById(field_id + '_remove_link').classList.toggle('active', SelectFilter.any_selected(to)); + // Active if the corresponding box isn't empty + document.getElementById(field_id + '_add_all_link').classList.toggle('active', from.querySelector('option')); + document.getElementById(field_id + '_remove_all_link').classList.toggle('active', to.querySelector('option')); + SelectFilter.refresh_filtered_warning(field_id); + }, + filter_key_press: function(event, field_id, source, target) { + const source_box = document.getElementById(field_id + source); + // don't submit form if user pressed Enter + if ((event.which && event.which === 13) || (event.keyCode && event.keyCode === 13)) { + source_box.selectedIndex = 0; + SelectBox.move(field_id + source, field_id + target); + source_box.selectedIndex = 0; + event.preventDefault(); + } + }, + filter_key_up: function(event, field_id, source, filter_input) { + const input = filter_input || '_input'; + const source_box = document.getElementById(field_id + source); + const temp = source_box.selectedIndex; + SelectBox.filter(field_id + source, document.getElementById(field_id + input).value); + source_box.selectedIndex = temp; + SelectFilter.refresh_filtered_warning(field_id); + SelectFilter.refresh_icons(field_id); + }, + filter_key_down: function(event, field_id, source, target) { + const source_box = document.getElementById(field_id + source); + // right key (39) or left key (37) + const direction = source === '_from' ? 39 : 37; + // right arrow -- move across + if ((event.which && event.which === direction) || (event.keyCode && event.keyCode === direction)) { + const old_index = source_box.selectedIndex; + SelectBox.move(field_id + source, field_id + target); + SelectFilter.refresh_filtered_selects(field_id); + SelectFilter.refresh_filtered_warning(field_id); + source_box.selectedIndex = (old_index === source_box.length) ? source_box.length - 1 : old_index; + return; + } + // down arrow -- wrap around + if ((event.which && event.which === 40) || (event.keyCode && event.keyCode === 40)) { + source_box.selectedIndex = (source_box.length === source_box.selectedIndex + 1) ? 0 : source_box.selectedIndex + 1; + } + // up arrow -- wrap around + if ((event.which && event.which === 38) || (event.keyCode && event.keyCode === 38)) { + source_box.selectedIndex = (source_box.selectedIndex === 0) ? source_box.length - 1 : source_box.selectedIndex - 1; + } + } + }; + + window.addEventListener('load', function(e) { + document.querySelectorAll('select.selectfilter, select.selectfilterstacked').forEach(function(el) { + const data = el.dataset; + SelectFilter.init(el.id, data.fieldName, parseInt(data.isStacked, 10)); + }); + }); +} diff --git a/sites/public/static/admin/js/actions.js b/sites/public/static/admin/js/actions.js new file mode 100755 index 00000000..20a5c143 --- /dev/null +++ b/sites/public/static/admin/js/actions.js @@ -0,0 +1,201 @@ +/*global gettext, interpolate, ngettext*/ +'use strict'; +{ + function show(selector) { + document.querySelectorAll(selector).forEach(function(el) { + el.classList.remove('hidden'); + }); + } + + function hide(selector) { + document.querySelectorAll(selector).forEach(function(el) { + el.classList.add('hidden'); + }); + } + + function showQuestion(options) { + hide(options.acrossClears); + show(options.acrossQuestions); + hide(options.allContainer); + } + + function showClear(options) { + show(options.acrossClears); + hide(options.acrossQuestions); + document.querySelector(options.actionContainer).classList.remove(options.selectedClass); + show(options.allContainer); + hide(options.counterContainer); + } + + function reset(options) { + hide(options.acrossClears); + hide(options.acrossQuestions); + hide(options.allContainer); + show(options.counterContainer); + } + + function clearAcross(options) { + reset(options); + const acrossInputs = document.querySelectorAll(options.acrossInput); + acrossInputs.forEach(function(acrossInput) { + acrossInput.value = 0; + }); + document.querySelector(options.actionContainer).classList.remove(options.selectedClass); + } + + function checker(actionCheckboxes, options, checked) { + if (checked) { + showQuestion(options); + } else { + reset(options); + } + actionCheckboxes.forEach(function(el) { + el.checked = checked; + el.closest('tr').classList.toggle(options.selectedClass, checked); + }); + } + + function updateCounter(actionCheckboxes, options) { + const sel = Array.from(actionCheckboxes).filter(function(el) { + return el.checked; + }).length; + const counter = document.querySelector(options.counterContainer); + // data-actions-icnt is defined in the generated HTML + // and contains the total amount of objects in the queryset + const actions_icnt = Number(counter.dataset.actionsIcnt); + counter.textContent = interpolate( + ngettext('%(sel)s of %(cnt)s selected', '%(sel)s of %(cnt)s selected', sel), { + sel: sel, + cnt: actions_icnt + }, true); + const allToggle = document.getElementById(options.allToggleId); + allToggle.checked = sel === actionCheckboxes.length; + if (allToggle.checked) { + showQuestion(options); + } else { + clearAcross(options); + } + } + + const defaults = { + actionContainer: "div.actions", + counterContainer: "span.action-counter", + allContainer: "div.actions span.all", + acrossInput: "div.actions input.select-across", + acrossQuestions: "div.actions span.question", + acrossClears: "div.actions span.clear", + allToggleId: "action-toggle", + selectedClass: "selected" + }; + + window.Actions = function(actionCheckboxes, options) { + options = Object.assign({}, defaults, options); + let list_editable_changed = false; + let lastChecked = null; + let shiftPressed = false; + + document.addEventListener('keydown', (event) => { + shiftPressed = event.shiftKey; + }); + + document.addEventListener('keyup', (event) => { + shiftPressed = event.shiftKey; + }); + + document.getElementById(options.allToggleId).addEventListener('click', function(event) { + checker(actionCheckboxes, options, this.checked); + updateCounter(actionCheckboxes, options); + }); + + document.querySelectorAll(options.acrossQuestions + " a").forEach(function(el) { + el.addEventListener('click', function(event) { + event.preventDefault(); + const acrossInputs = document.querySelectorAll(options.acrossInput); + acrossInputs.forEach(function(acrossInput) { + acrossInput.value = 1; + }); + showClear(options); + }); + }); + + document.querySelectorAll(options.acrossClears + " a").forEach(function(el) { + el.addEventListener('click', function(event) { + event.preventDefault(); + document.getElementById(options.allToggleId).checked = false; + clearAcross(options); + checker(actionCheckboxes, options, false); + updateCounter(actionCheckboxes, options); + }); + }); + + function affectedCheckboxes(target, withModifier) { + const multiSelect = (lastChecked && withModifier && lastChecked !== target); + if (!multiSelect) { + return [target]; + } + const checkboxes = Array.from(actionCheckboxes); + const targetIndex = checkboxes.findIndex(el => el === target); + const lastCheckedIndex = checkboxes.findIndex(el => el === lastChecked); + const startIndex = Math.min(targetIndex, lastCheckedIndex); + const endIndex = Math.max(targetIndex, lastCheckedIndex); + const filtered = checkboxes.filter((el, index) => (startIndex <= index) && (index <= endIndex)); + return filtered; + }; + + Array.from(document.getElementById('result_list').tBodies).forEach(function(el) { + el.addEventListener('change', function(event) { + const target = event.target; + if (target.classList.contains('action-select')) { + const checkboxes = affectedCheckboxes(target, shiftPressed); + checker(checkboxes, options, target.checked); + updateCounter(actionCheckboxes, options); + lastChecked = target; + } else { + list_editable_changed = true; + } + }); + }); + + document.querySelector('#changelist-form button[name=index]').addEventListener('click', function(event) { + if (list_editable_changed) { + const confirmed = confirm(gettext("You have unsaved changes on individual editable fields. If you run an action, your unsaved changes will be lost.")); + if (!confirmed) { + event.preventDefault(); + } + } + }); + + const el = document.querySelector('#changelist-form input[name=_save]'); + // The button does not exist if no fields are editable. + if (el) { + el.addEventListener('click', function(event) { + if (document.querySelector('[name=action]').value) { + const text = list_editable_changed + ? gettext("You have selected an action, but you haven’t saved your changes to individual fields yet. Please click OK to save. You’ll need to re-run the action.") + : gettext("You have selected an action, and you haven’t made any changes on individual fields. You’re probably looking for the Go button rather than the Save button."); + if (!confirm(text)) { + event.preventDefault(); + } + } + }); + } + }; + + // Call function fn when the DOM is loaded and ready. If it is already + // loaded, call the function now. + // http://youmightnotneedjquery.com/#ready + function ready(fn) { + if (document.readyState !== 'loading') { + fn(); + } else { + document.addEventListener('DOMContentLoaded', fn); + } + } + + ready(function() { + const actionsEls = document.querySelectorAll('tr input.action-select'); + if (actionsEls.length > 0) { + Actions(actionsEls); + } + }); +} diff --git a/sites/public/static/admin/js/admin/DateTimeShortcuts.js b/sites/public/static/admin/js/admin/DateTimeShortcuts.js new file mode 100755 index 00000000..aa1cae9e --- /dev/null +++ b/sites/public/static/admin/js/admin/DateTimeShortcuts.js @@ -0,0 +1,408 @@ +/*global Calendar, findPosX, findPosY, get_format, gettext, gettext_noop, interpolate, ngettext, quickElement*/ +// Inserts shortcut buttons after all of the following: +// +// +'use strict'; +{ + const DateTimeShortcuts = { + calendars: [], + calendarInputs: [], + clockInputs: [], + clockHours: { + default_: [ + [gettext_noop('Now'), -1], + [gettext_noop('Midnight'), 0], + [gettext_noop('6 a.m.'), 6], + [gettext_noop('Noon'), 12], + [gettext_noop('6 p.m.'), 18] + ] + }, + dismissClockFunc: [], + dismissCalendarFunc: [], + calendarDivName1: 'calendarbox', // name of calendar
    that gets toggled + calendarDivName2: 'calendarin', // name of
    that contains calendar + calendarLinkName: 'calendarlink', // name of the link that is used to toggle + clockDivName: 'clockbox', // name of clock
    that gets toggled + clockLinkName: 'clocklink', // name of the link that is used to toggle + shortCutsClass: 'datetimeshortcuts', // class of the clock and cal shortcuts + timezoneWarningClass: 'timezonewarning', // class of the warning for timezone mismatch + timezoneOffset: 0, + init: function() { + const serverOffset = document.body.dataset.adminUtcOffset; + if (serverOffset) { + const localOffset = new Date().getTimezoneOffset() * -60; + DateTimeShortcuts.timezoneOffset = localOffset - serverOffset; + } + + for (const inp of document.getElementsByTagName('input')) { + if (inp.type === 'text' && inp.classList.contains('vTimeField')) { + DateTimeShortcuts.addClock(inp); + DateTimeShortcuts.addTimezoneWarning(inp); + } + else if (inp.type === 'text' && inp.classList.contains('vDateField')) { + DateTimeShortcuts.addCalendar(inp); + DateTimeShortcuts.addTimezoneWarning(inp); + } + } + }, + // Return the current time while accounting for the server timezone. + now: function() { + const serverOffset = document.body.dataset.adminUtcOffset; + if (serverOffset) { + const localNow = new Date(); + const localOffset = localNow.getTimezoneOffset() * -60; + localNow.setTime(localNow.getTime() + 1000 * (serverOffset - localOffset)); + return localNow; + } else { + return new Date(); + } + }, + // Add a warning when the time zone in the browser and backend do not match. + addTimezoneWarning: function(inp) { + const warningClass = DateTimeShortcuts.timezoneWarningClass; + let timezoneOffset = DateTimeShortcuts.timezoneOffset / 3600; + + // Only warn if there is a time zone mismatch. + if (!timezoneOffset) { + return; + } + + // Check if warning is already there. + if (inp.parentNode.querySelectorAll('.' + warningClass).length) { + return; + } + + let message; + if (timezoneOffset > 0) { + message = ngettext( + 'Note: You are %s hour ahead of server time.', + 'Note: You are %s hours ahead of server time.', + timezoneOffset + ); + } + else { + timezoneOffset *= -1; + message = ngettext( + 'Note: You are %s hour behind server time.', + 'Note: You are %s hours behind server time.', + timezoneOffset + ); + } + message = interpolate(message, [timezoneOffset]); + + const warning = document.createElement('div'); + warning.classList.add('help', warningClass); + warning.textContent = message; + inp.parentNode.appendChild(warning); + }, + // Add clock widget to a given field + addClock: function(inp) { + const num = DateTimeShortcuts.clockInputs.length; + DateTimeShortcuts.clockInputs[num] = inp; + DateTimeShortcuts.dismissClockFunc[num] = function() { DateTimeShortcuts.dismissClock(num); return true; }; + + // Shortcut links (clock icon and "Now" link) + const shortcuts_span = document.createElement('span'); + shortcuts_span.className = DateTimeShortcuts.shortCutsClass; + inp.parentNode.insertBefore(shortcuts_span, inp.nextSibling); + const now_link = document.createElement('a'); + now_link.href = "#"; + now_link.textContent = gettext('Now'); + now_link.addEventListener('click', function(e) { + e.preventDefault(); + DateTimeShortcuts.handleClockQuicklink(num, -1); + }); + const clock_link = document.createElement('a'); + clock_link.href = '#'; + clock_link.id = DateTimeShortcuts.clockLinkName + num; + clock_link.addEventListener('click', function(e) { + e.preventDefault(); + // avoid triggering the document click handler to dismiss the clock + e.stopPropagation(); + DateTimeShortcuts.openClock(num); + }); + + quickElement( + 'span', clock_link, '', + 'class', 'clock-icon', + 'title', gettext('Choose a Time') + ); + shortcuts_span.appendChild(document.createTextNode('\u00A0')); + shortcuts_span.appendChild(now_link); + shortcuts_span.appendChild(document.createTextNode('\u00A0|\u00A0')); + shortcuts_span.appendChild(clock_link); + + // Create clock link div + // + // Markup looks like: + //
    + //

    Choose a time

    + // + //

    Cancel

    + //
    + + const clock_box = document.createElement('div'); + clock_box.style.display = 'none'; + clock_box.style.position = 'absolute'; + clock_box.className = 'clockbox module'; + clock_box.id = DateTimeShortcuts.clockDivName + num; + document.body.appendChild(clock_box); + clock_box.addEventListener('click', function(e) { e.stopPropagation(); }); + + quickElement('h2', clock_box, gettext('Choose a time')); + const time_list = quickElement('ul', clock_box); + time_list.className = 'timelist'; + // The list of choices can be overridden in JavaScript like this: + // DateTimeShortcuts.clockHours.name = [['3 a.m.', 3]]; + // where name is the name attribute of the . + const name = typeof DateTimeShortcuts.clockHours[inp.name] === 'undefined' ? 'default_' : inp.name; + DateTimeShortcuts.clockHours[name].forEach(function(element) { + const time_link = quickElement('a', quickElement('li', time_list), gettext(element[0]), 'href', '#'); + time_link.addEventListener('click', function(e) { + e.preventDefault(); + DateTimeShortcuts.handleClockQuicklink(num, element[1]); + }); + }); + + const cancel_p = quickElement('p', clock_box); + cancel_p.className = 'calendar-cancel'; + const cancel_link = quickElement('a', cancel_p, gettext('Cancel'), 'href', '#'); + cancel_link.addEventListener('click', function(e) { + e.preventDefault(); + DateTimeShortcuts.dismissClock(num); + }); + + document.addEventListener('keyup', function(event) { + if (event.which === 27) { + // ESC key closes popup + DateTimeShortcuts.dismissClock(num); + event.preventDefault(); + } + }); + }, + openClock: function(num) { + const clock_box = document.getElementById(DateTimeShortcuts.clockDivName + num); + const clock_link = document.getElementById(DateTimeShortcuts.clockLinkName + num); + + // Recalculate the clockbox position + // is it left-to-right or right-to-left layout ? + if (window.getComputedStyle(document.body).direction !== 'rtl') { + clock_box.style.left = findPosX(clock_link) + 17 + 'px'; + } + else { + // since style's width is in em, it'd be tough to calculate + // px value of it. let's use an estimated px for now + clock_box.style.left = findPosX(clock_link) - 110 + 'px'; + } + clock_box.style.top = Math.max(0, findPosY(clock_link) - 30) + 'px'; + + // Show the clock box + clock_box.style.display = 'block'; + document.addEventListener('click', DateTimeShortcuts.dismissClockFunc[num]); + }, + dismissClock: function(num) { + document.getElementById(DateTimeShortcuts.clockDivName + num).style.display = 'none'; + document.removeEventListener('click', DateTimeShortcuts.dismissClockFunc[num]); + }, + handleClockQuicklink: function(num, val) { + let d; + if (val === -1) { + d = DateTimeShortcuts.now(); + } + else { + d = new Date(1970, 1, 1, val, 0, 0, 0); + } + DateTimeShortcuts.clockInputs[num].value = d.strftime(get_format('TIME_INPUT_FORMATS')[0]); + DateTimeShortcuts.clockInputs[num].focus(); + DateTimeShortcuts.dismissClock(num); + }, + // Add calendar widget to a given field. + addCalendar: function(inp) { + const num = DateTimeShortcuts.calendars.length; + + DateTimeShortcuts.calendarInputs[num] = inp; + DateTimeShortcuts.dismissCalendarFunc[num] = function() { DateTimeShortcuts.dismissCalendar(num); return true; }; + + // Shortcut links (calendar icon and "Today" link) + const shortcuts_span = document.createElement('span'); + shortcuts_span.className = DateTimeShortcuts.shortCutsClass; + inp.parentNode.insertBefore(shortcuts_span, inp.nextSibling); + const today_link = document.createElement('a'); + today_link.href = '#'; + today_link.appendChild(document.createTextNode(gettext('Today'))); + today_link.addEventListener('click', function(e) { + e.preventDefault(); + DateTimeShortcuts.handleCalendarQuickLink(num, 0); + }); + const cal_link = document.createElement('a'); + cal_link.href = '#'; + cal_link.id = DateTimeShortcuts.calendarLinkName + num; + cal_link.addEventListener('click', function(e) { + e.preventDefault(); + // avoid triggering the document click handler to dismiss the calendar + e.stopPropagation(); + DateTimeShortcuts.openCalendar(num); + }); + quickElement( + 'span', cal_link, '', + 'class', 'date-icon', + 'title', gettext('Choose a Date') + ); + shortcuts_span.appendChild(document.createTextNode('\u00A0')); + shortcuts_span.appendChild(today_link); + shortcuts_span.appendChild(document.createTextNode('\u00A0|\u00A0')); + shortcuts_span.appendChild(cal_link); + + // Create calendarbox div. + // + // Markup looks like: + // + //
    + //

    + // + // February 2003 + //

    + //
    + // + //
    + //
    + // Yesterday | Today | Tomorrow + //
    + //

    Cancel

    + //
    + const cal_box = document.createElement('div'); + cal_box.style.display = 'none'; + cal_box.style.position = 'absolute'; + cal_box.className = 'calendarbox module'; + cal_box.id = DateTimeShortcuts.calendarDivName1 + num; + document.body.appendChild(cal_box); + cal_box.addEventListener('click', function(e) { e.stopPropagation(); }); + + // next-prev links + const cal_nav = quickElement('div', cal_box); + const cal_nav_prev = quickElement('a', cal_nav, '<', 'href', '#'); + cal_nav_prev.className = 'calendarnav-previous'; + cal_nav_prev.addEventListener('click', function(e) { + e.preventDefault(); + DateTimeShortcuts.drawPrev(num); + }); + + const cal_nav_next = quickElement('a', cal_nav, '>', 'href', '#'); + cal_nav_next.className = 'calendarnav-next'; + cal_nav_next.addEventListener('click', function(e) { + e.preventDefault(); + DateTimeShortcuts.drawNext(num); + }); + + // main box + const cal_main = quickElement('div', cal_box, '', 'id', DateTimeShortcuts.calendarDivName2 + num); + cal_main.className = 'calendar'; + DateTimeShortcuts.calendars[num] = new Calendar(DateTimeShortcuts.calendarDivName2 + num, DateTimeShortcuts.handleCalendarCallback(num)); + DateTimeShortcuts.calendars[num].drawCurrent(); + + // calendar shortcuts + const shortcuts = quickElement('div', cal_box); + shortcuts.className = 'calendar-shortcuts'; + let day_link = quickElement('a', shortcuts, gettext('Yesterday'), 'href', '#'); + day_link.addEventListener('click', function(e) { + e.preventDefault(); + DateTimeShortcuts.handleCalendarQuickLink(num, -1); + }); + shortcuts.appendChild(document.createTextNode('\u00A0|\u00A0')); + day_link = quickElement('a', shortcuts, gettext('Today'), 'href', '#'); + day_link.addEventListener('click', function(e) { + e.preventDefault(); + DateTimeShortcuts.handleCalendarQuickLink(num, 0); + }); + shortcuts.appendChild(document.createTextNode('\u00A0|\u00A0')); + day_link = quickElement('a', shortcuts, gettext('Tomorrow'), 'href', '#'); + day_link.addEventListener('click', function(e) { + e.preventDefault(); + DateTimeShortcuts.handleCalendarQuickLink(num, +1); + }); + + // cancel bar + const cancel_p = quickElement('p', cal_box); + cancel_p.className = 'calendar-cancel'; + const cancel_link = quickElement('a', cancel_p, gettext('Cancel'), 'href', '#'); + cancel_link.addEventListener('click', function(e) { + e.preventDefault(); + DateTimeShortcuts.dismissCalendar(num); + }); + document.addEventListener('keyup', function(event) { + if (event.which === 27) { + // ESC key closes popup + DateTimeShortcuts.dismissCalendar(num); + event.preventDefault(); + } + }); + }, + openCalendar: function(num) { + const cal_box = document.getElementById(DateTimeShortcuts.calendarDivName1 + num); + const cal_link = document.getElementById(DateTimeShortcuts.calendarLinkName + num); + const inp = DateTimeShortcuts.calendarInputs[num]; + + // Determine if the current value in the input has a valid date. + // If so, draw the calendar with that date's year and month. + if (inp.value) { + const format = get_format('DATE_INPUT_FORMATS')[0]; + const selected = inp.value.strptime(format); + const year = selected.getUTCFullYear(); + const month = selected.getUTCMonth() + 1; + const re = /\d{4}/; + if (re.test(year.toString()) && month >= 1 && month <= 12) { + DateTimeShortcuts.calendars[num].drawDate(month, year, selected); + } + } + + // Recalculate the clockbox position + // is it left-to-right or right-to-left layout ? + if (window.getComputedStyle(document.body).direction !== 'rtl') { + cal_box.style.left = findPosX(cal_link) + 17 + 'px'; + } + else { + // since style's width is in em, it'd be tough to calculate + // px value of it. let's use an estimated px for now + cal_box.style.left = findPosX(cal_link) - 180 + 'px'; + } + cal_box.style.top = Math.max(0, findPosY(cal_link) - 75) + 'px'; + + cal_box.style.display = 'block'; + document.addEventListener('click', DateTimeShortcuts.dismissCalendarFunc[num]); + }, + dismissCalendar: function(num) { + document.getElementById(DateTimeShortcuts.calendarDivName1 + num).style.display = 'none'; + document.removeEventListener('click', DateTimeShortcuts.dismissCalendarFunc[num]); + }, + drawPrev: function(num) { + DateTimeShortcuts.calendars[num].drawPreviousMonth(); + }, + drawNext: function(num) { + DateTimeShortcuts.calendars[num].drawNextMonth(); + }, + handleCalendarCallback: function(num) { + const format = get_format('DATE_INPUT_FORMATS')[0]; + return function(y, m, d) { + DateTimeShortcuts.calendarInputs[num].value = new Date(y, m - 1, d).strftime(format); + DateTimeShortcuts.calendarInputs[num].focus(); + document.getElementById(DateTimeShortcuts.calendarDivName1 + num).style.display = 'none'; + }; + }, + handleCalendarQuickLink: function(num, offset) { + const d = DateTimeShortcuts.now(); + d.setDate(d.getDate() + offset); + DateTimeShortcuts.calendarInputs[num].value = d.strftime(get_format('DATE_INPUT_FORMATS')[0]); + DateTimeShortcuts.calendarInputs[num].focus(); + DateTimeShortcuts.dismissCalendar(num); + } + }; + + window.addEventListener('load', DateTimeShortcuts.init); + window.DateTimeShortcuts = DateTimeShortcuts; +} diff --git a/sites/public/static/admin/js/admin/RelatedObjectLookups.js b/sites/public/static/admin/js/admin/RelatedObjectLookups.js new file mode 100755 index 00000000..afb6b66c --- /dev/null +++ b/sites/public/static/admin/js/admin/RelatedObjectLookups.js @@ -0,0 +1,238 @@ +/*global SelectBox, interpolate*/ +// Handles related-objects functionality: lookup link for raw_id_fields +// and Add Another links. +'use strict'; +{ + const $ = django.jQuery; + let popupIndex = 0; + const relatedWindows = []; + + function dismissChildPopups() { + relatedWindows.forEach(function(win) { + if(!win.closed) { + win.dismissChildPopups(); + win.close(); + } + }); + } + + function setPopupIndex() { + if(document.getElementsByName("_popup").length > 0) { + const index = window.name.lastIndexOf("__") + 2; + popupIndex = parseInt(window.name.substring(index)); + } else { + popupIndex = 0; + } + } + + function addPopupIndex(name) { + return name + "__" + (popupIndex + 1); + } + + function removePopupIndex(name) { + return name.replace(new RegExp("__" + (popupIndex + 1) + "$"), ''); + } + + function showAdminPopup(triggeringLink, name_regexp, add_popup) { + const name = addPopupIndex(triggeringLink.id.replace(name_regexp, '')); + const href = new URL(triggeringLink.href); + if (add_popup) { + href.searchParams.set('_popup', 1); + } + const win = window.open(href, name, 'height=500,width=800,resizable=yes,scrollbars=yes'); + relatedWindows.push(win); + win.focus(); + return false; + } + + function showRelatedObjectLookupPopup(triggeringLink) { + return showAdminPopup(triggeringLink, /^lookup_/, true); + } + + function dismissRelatedLookupPopup(win, chosenId) { + const name = removePopupIndex(win.name); + const elem = document.getElementById(name); + if (elem.classList.contains('vManyToManyRawIdAdminField') && elem.value) { + elem.value += ',' + chosenId; + } else { + document.getElementById(name).value = chosenId; + } + const index = relatedWindows.indexOf(win); + if (index > -1) { + relatedWindows.splice(index, 1); + } + win.close(); + } + + function showRelatedObjectPopup(triggeringLink) { + return showAdminPopup(triggeringLink, /^(change|add|delete)_/, false); + } + + function updateRelatedObjectLinks(triggeringLink) { + const $this = $(triggeringLink); + const siblings = $this.nextAll('.view-related, .change-related, .delete-related'); + if (!siblings.length) { + return; + } + const value = $this.val(); + if (value) { + siblings.each(function() { + const elm = $(this); + elm.attr('href', elm.attr('data-href-template').replace('__fk__', value)); + }); + } else { + siblings.removeAttr('href'); + } + } + + function updateRelatedSelectsOptions(currentSelect, win, objId, newRepr, newId) { + // After create/edit a model from the options next to the current + // select (+ or :pencil:) update ForeignKey PK of the rest of selects + // in the page. + + const path = win.location.pathname; + // Extract the model from the popup url '...//add/' or + // '...///change/' depending the action (add or change). + const modelName = path.split('/')[path.split('/').length - (objId ? 4 : 3)]; + // Exclude autocomplete selects. + const selectsRelated = document.querySelectorAll(`[data-model-ref="${modelName}"] select:not(.admin-autocomplete)`); + + selectsRelated.forEach(function(select) { + if (currentSelect === select) { + return; + } + + let option = select.querySelector(`option[value="${objId}"]`); + + if (!option) { + option = new Option(newRepr, newId); + select.options.add(option); + return; + } + + option.textContent = newRepr; + option.value = newId; + }); + } + + function dismissAddRelatedObjectPopup(win, newId, newRepr) { + const name = removePopupIndex(win.name); + const elem = document.getElementById(name); + if (elem) { + const elemName = elem.nodeName.toUpperCase(); + if (elemName === 'SELECT') { + elem.options[elem.options.length] = new Option(newRepr, newId, true, true); + updateRelatedSelectsOptions(elem, win, null, newRepr, newId); + } else if (elemName === 'INPUT') { + if (elem.classList.contains('vManyToManyRawIdAdminField') && elem.value) { + elem.value += ',' + newId; + } else { + elem.value = newId; + } + } + // Trigger a change event to update related links if required. + $(elem).trigger('change'); + } else { + const toId = name + "_to"; + const o = new Option(newRepr, newId); + SelectBox.add_to_cache(toId, o); + SelectBox.redisplay(toId); + } + const index = relatedWindows.indexOf(win); + if (index > -1) { + relatedWindows.splice(index, 1); + } + win.close(); + } + + function dismissChangeRelatedObjectPopup(win, objId, newRepr, newId) { + const id = removePopupIndex(win.name.replace(/^edit_/, '')); + const selectsSelector = interpolate('#%s, #%s_from, #%s_to', [id, id, id]); + const selects = $(selectsSelector); + selects.find('option').each(function() { + if (this.value === objId) { + this.textContent = newRepr; + this.value = newId; + } + }).trigger('change'); + updateRelatedSelectsOptions(selects[0], win, objId, newRepr, newId); + selects.next().find('.select2-selection__rendered').each(function() { + // The element can have a clear button as a child. + // Use the lastChild to modify only the displayed value. + this.lastChild.textContent = newRepr; + this.title = newRepr; + }); + const index = relatedWindows.indexOf(win); + if (index > -1) { + relatedWindows.splice(index, 1); + } + win.close(); + } + + function dismissDeleteRelatedObjectPopup(win, objId) { + const id = removePopupIndex(win.name.replace(/^delete_/, '')); + const selectsSelector = interpolate('#%s, #%s_from, #%s_to', [id, id, id]); + const selects = $(selectsSelector); + selects.find('option').each(function() { + if (this.value === objId) { + $(this).remove(); + } + }).trigger('change'); + const index = relatedWindows.indexOf(win); + if (index > -1) { + relatedWindows.splice(index, 1); + } + win.close(); + } + + window.showRelatedObjectLookupPopup = showRelatedObjectLookupPopup; + window.dismissRelatedLookupPopup = dismissRelatedLookupPopup; + window.showRelatedObjectPopup = showRelatedObjectPopup; + window.updateRelatedObjectLinks = updateRelatedObjectLinks; + window.dismissAddRelatedObjectPopup = dismissAddRelatedObjectPopup; + window.dismissChangeRelatedObjectPopup = dismissChangeRelatedObjectPopup; + window.dismissDeleteRelatedObjectPopup = dismissDeleteRelatedObjectPopup; + window.dismissChildPopups = dismissChildPopups; + + // Kept for backward compatibility + window.showAddAnotherPopup = showRelatedObjectPopup; + window.dismissAddAnotherPopup = dismissAddRelatedObjectPopup; + + window.addEventListener('unload', function(evt) { + window.dismissChildPopups(); + }); + + $(document).ready(function() { + setPopupIndex(); + $("a[data-popup-opener]").on('click', function(event) { + event.preventDefault(); + opener.dismissRelatedLookupPopup(window, $(this).data("popup-opener")); + }); + $('body').on('click', '.related-widget-wrapper-link[data-popup="yes"]', function(e) { + e.preventDefault(); + if (this.href) { + const event = $.Event('django:show-related', {href: this.href}); + $(this).trigger(event); + if (!event.isDefaultPrevented()) { + showRelatedObjectPopup(this); + } + } + }); + $('body').on('change', '.related-widget-wrapper select', function(e) { + const event = $.Event('django:update-related'); + $(this).trigger(event); + if (!event.isDefaultPrevented()) { + updateRelatedObjectLinks(this); + } + }); + $('.related-widget-wrapper select').trigger('change'); + $('body').on('click', '.related-lookup', function(e) { + e.preventDefault(); + const event = $.Event('django:lookup-related'); + $(this).trigger(event); + if (!event.isDefaultPrevented()) { + showRelatedObjectLookupPopup(this); + } + }); + }); +} diff --git a/sites/public/static/admin/js/autocomplete.js b/sites/public/static/admin/js/autocomplete.js new file mode 100755 index 00000000..d3daeab8 --- /dev/null +++ b/sites/public/static/admin/js/autocomplete.js @@ -0,0 +1,33 @@ +'use strict'; +{ + const $ = django.jQuery; + + $.fn.djangoAdminSelect2 = function() { + $.each(this, function(i, element) { + $(element).select2({ + ajax: { + data: (params) => { + return { + term: params.term, + page: params.page, + app_label: element.dataset.appLabel, + model_name: element.dataset.modelName, + field_name: element.dataset.fieldName + }; + } + } + }); + }); + return this; + }; + + $(function() { + // Initialize all autocomplete widgets except the one in the template + // form used when a new formset is added. + $('.admin-autocomplete').not('[name*=__prefix__]').djangoAdminSelect2(); + }); + + document.addEventListener('formset:added', (event) => { + $(event.target).find('.admin-autocomplete').djangoAdminSelect2(); + }); +} diff --git a/sites/public/static/admin/js/calendar.js b/sites/public/static/admin/js/calendar.js new file mode 100755 index 00000000..a62d10a7 --- /dev/null +++ b/sites/public/static/admin/js/calendar.js @@ -0,0 +1,221 @@ +/*global gettext, pgettext, get_format, quickElement, removeChildren*/ +/* +calendar.js - Calendar functions by Adrian Holovaty +depends on core.js for utility functions like removeChildren or quickElement +*/ +'use strict'; +{ + // CalendarNamespace -- Provides a collection of HTML calendar-related helper functions + const CalendarNamespace = { + monthsOfYear: [ + gettext('January'), + gettext('February'), + gettext('March'), + gettext('April'), + gettext('May'), + gettext('June'), + gettext('July'), + gettext('August'), + gettext('September'), + gettext('October'), + gettext('November'), + gettext('December') + ], + monthsOfYearAbbrev: [ + pgettext('abbrev. month January', 'Jan'), + pgettext('abbrev. month February', 'Feb'), + pgettext('abbrev. month March', 'Mar'), + pgettext('abbrev. month April', 'Apr'), + pgettext('abbrev. month May', 'May'), + pgettext('abbrev. month June', 'Jun'), + pgettext('abbrev. month July', 'Jul'), + pgettext('abbrev. month August', 'Aug'), + pgettext('abbrev. month September', 'Sep'), + pgettext('abbrev. month October', 'Oct'), + pgettext('abbrev. month November', 'Nov'), + pgettext('abbrev. month December', 'Dec') + ], + daysOfWeek: [ + pgettext('one letter Sunday', 'S'), + pgettext('one letter Monday', 'M'), + pgettext('one letter Tuesday', 'T'), + pgettext('one letter Wednesday', 'W'), + pgettext('one letter Thursday', 'T'), + pgettext('one letter Friday', 'F'), + pgettext('one letter Saturday', 'S') + ], + firstDayOfWeek: parseInt(get_format('FIRST_DAY_OF_WEEK')), + isLeapYear: function(year) { + return (((year % 4) === 0) && ((year % 100) !== 0 ) || ((year % 400) === 0)); + }, + getDaysInMonth: function(month, year) { + let days; + if (month === 1 || month === 3 || month === 5 || month === 7 || month === 8 || month === 10 || month === 12) { + days = 31; + } + else if (month === 4 || month === 6 || month === 9 || month === 11) { + days = 30; + } + else if (month === 2 && CalendarNamespace.isLeapYear(year)) { + days = 29; + } + else { + days = 28; + } + return days; + }, + draw: function(month, year, div_id, callback, selected) { // month = 1-12, year = 1-9999 + const today = new Date(); + const todayDay = today.getDate(); + const todayMonth = today.getMonth() + 1; + const todayYear = today.getFullYear(); + let todayClass = ''; + + // Use UTC functions here because the date field does not contain time + // and using the UTC function variants prevent the local time offset + // from altering the date, specifically the day field. For example: + // + // ``` + // var x = new Date('2013-10-02'); + // var day = x.getDate(); + // ``` + // + // The day variable above will be 1 instead of 2 in, say, US Pacific time + // zone. + let isSelectedMonth = false; + if (typeof selected !== 'undefined') { + isSelectedMonth = (selected.getUTCFullYear() === year && (selected.getUTCMonth() + 1) === month); + } + + month = parseInt(month); + year = parseInt(year); + const calDiv = document.getElementById(div_id); + removeChildren(calDiv); + const calTable = document.createElement('table'); + quickElement('caption', calTable, CalendarNamespace.monthsOfYear[month - 1] + ' ' + year); + const tableBody = quickElement('tbody', calTable); + + // Draw days-of-week header + let tableRow = quickElement('tr', tableBody); + for (let i = 0; i < 7; i++) { + quickElement('th', tableRow, CalendarNamespace.daysOfWeek[(i + CalendarNamespace.firstDayOfWeek) % 7]); + } + + const startingPos = new Date(year, month - 1, 1 - CalendarNamespace.firstDayOfWeek).getDay(); + const days = CalendarNamespace.getDaysInMonth(month, year); + + let nonDayCell; + + // Draw blanks before first of month + tableRow = quickElement('tr', tableBody); + for (let i = 0; i < startingPos; i++) { + nonDayCell = quickElement('td', tableRow, ' '); + nonDayCell.className = "nonday"; + } + + function calendarMonth(y, m) { + function onClick(e) { + e.preventDefault(); + callback(y, m, this.textContent); + } + return onClick; + } + + // Draw days of month + let currentDay = 1; + for (let i = startingPos; currentDay <= days; i++) { + if (i % 7 === 0 && currentDay !== 1) { + tableRow = quickElement('tr', tableBody); + } + if ((currentDay === todayDay) && (month === todayMonth) && (year === todayYear)) { + todayClass = 'today'; + } else { + todayClass = ''; + } + + // use UTC function; see above for explanation. + if (isSelectedMonth && currentDay === selected.getUTCDate()) { + if (todayClass !== '') { + todayClass += " "; + } + todayClass += "selected"; + } + + const cell = quickElement('td', tableRow, '', 'class', todayClass); + const link = quickElement('a', cell, currentDay, 'href', '#'); + link.addEventListener('click', calendarMonth(year, month)); + currentDay++; + } + + // Draw blanks after end of month (optional, but makes for valid code) + while (tableRow.childNodes.length < 7) { + nonDayCell = quickElement('td', tableRow, ' '); + nonDayCell.className = "nonday"; + } + + calDiv.appendChild(calTable); + } + }; + + // Calendar -- A calendar instance + function Calendar(div_id, callback, selected) { + // div_id (string) is the ID of the element in which the calendar will + // be displayed + // callback (string) is the name of a JavaScript function that will be + // called with the parameters (year, month, day) when a day in the + // calendar is clicked + this.div_id = div_id; + this.callback = callback; + this.today = new Date(); + this.currentMonth = this.today.getMonth() + 1; + this.currentYear = this.today.getFullYear(); + if (typeof selected !== 'undefined') { + this.selected = selected; + } + } + Calendar.prototype = { + drawCurrent: function() { + CalendarNamespace.draw(this.currentMonth, this.currentYear, this.div_id, this.callback, this.selected); + }, + drawDate: function(month, year, selected) { + this.currentMonth = month; + this.currentYear = year; + + if(selected) { + this.selected = selected; + } + + this.drawCurrent(); + }, + drawPreviousMonth: function() { + if (this.currentMonth === 1) { + this.currentMonth = 12; + this.currentYear--; + } + else { + this.currentMonth--; + } + this.drawCurrent(); + }, + drawNextMonth: function() { + if (this.currentMonth === 12) { + this.currentMonth = 1; + this.currentYear++; + } + else { + this.currentMonth++; + } + this.drawCurrent(); + }, + drawPreviousYear: function() { + this.currentYear--; + this.drawCurrent(); + }, + drawNextYear: function() { + this.currentYear++; + this.drawCurrent(); + } + }; + window.Calendar = Calendar; + window.CalendarNamespace = CalendarNamespace; +} diff --git a/sites/public/static/admin/js/cancel.js b/sites/public/static/admin/js/cancel.js new file mode 100755 index 00000000..3069c6f2 --- /dev/null +++ b/sites/public/static/admin/js/cancel.js @@ -0,0 +1,29 @@ +'use strict'; +{ + // Call function fn when the DOM is loaded and ready. If it is already + // loaded, call the function now. + // http://youmightnotneedjquery.com/#ready + function ready(fn) { + if (document.readyState !== 'loading') { + fn(); + } else { + document.addEventListener('DOMContentLoaded', fn); + } + } + + ready(function() { + function handleClick(event) { + event.preventDefault(); + const params = new URLSearchParams(window.location.search); + if (params.has('_popup')) { + window.close(); // Close the popup. + } else { + window.history.back(); // Otherwise, go back. + } + } + + document.querySelectorAll('.cancel-link').forEach(function(el) { + el.addEventListener('click', handleClick); + }); + }); +} diff --git a/sites/public/static/admin/js/change_form.js b/sites/public/static/admin/js/change_form.js new file mode 100755 index 00000000..96a4c62e --- /dev/null +++ b/sites/public/static/admin/js/change_form.js @@ -0,0 +1,16 @@ +'use strict'; +{ + const inputTags = ['BUTTON', 'INPUT', 'SELECT', 'TEXTAREA']; + const modelName = document.getElementById('django-admin-form-add-constants').dataset.modelName; + if (modelName) { + const form = document.getElementById(modelName + '_form'); + for (const element of form.elements) { + // HTMLElement.offsetParent returns null when the element is not + // rendered. + if (inputTags.includes(element.tagName) && !element.disabled && element.offsetParent) { + element.focus(); + break; + } + } + } +} diff --git a/sites/public/static/admin/js/collapse.js b/sites/public/static/admin/js/collapse.js new file mode 100755 index 00000000..c6c7b0f6 --- /dev/null +++ b/sites/public/static/admin/js/collapse.js @@ -0,0 +1,43 @@ +/*global gettext*/ +'use strict'; +{ + window.addEventListener('load', function() { + // Add anchor tag for Show/Hide link + const fieldsets = document.querySelectorAll('fieldset.collapse'); + for (const [i, elem] of fieldsets.entries()) { + // Don't hide if fields in this fieldset have errors + if (elem.querySelectorAll('div.errors, ul.errorlist').length === 0) { + elem.classList.add('collapsed'); + const h2 = elem.querySelector('h2'); + const link = document.createElement('a'); + link.id = 'fieldsetcollapser' + i; + link.className = 'collapse-toggle'; + link.href = '#'; + link.textContent = gettext('Show'); + h2.appendChild(document.createTextNode(' (')); + h2.appendChild(link); + h2.appendChild(document.createTextNode(')')); + } + } + // Add toggle to hide/show anchor tag + const toggleFunc = function(ev) { + if (ev.target.matches('.collapse-toggle')) { + ev.preventDefault(); + ev.stopPropagation(); + const fieldset = ev.target.closest('fieldset'); + if (fieldset.classList.contains('collapsed')) { + // Show + ev.target.textContent = gettext('Hide'); + fieldset.classList.remove('collapsed'); + } else { + // Hide + ev.target.textContent = gettext('Show'); + fieldset.classList.add('collapsed'); + } + } + }; + document.querySelectorAll('fieldset.module').forEach(function(el) { + el.addEventListener('click', toggleFunc); + }); + }); +} diff --git a/sites/public/static/admin/js/core.js b/sites/public/static/admin/js/core.js new file mode 100755 index 00000000..0344a13f --- /dev/null +++ b/sites/public/static/admin/js/core.js @@ -0,0 +1,170 @@ +// Core JavaScript helper functions +'use strict'; + +// quickElement(tagType, parentReference [, textInChildNode, attribute, attributeValue ...]); +function quickElement() { + const obj = document.createElement(arguments[0]); + if (arguments[2]) { + const textNode = document.createTextNode(arguments[2]); + obj.appendChild(textNode); + } + const len = arguments.length; + for (let i = 3; i < len; i += 2) { + obj.setAttribute(arguments[i], arguments[i + 1]); + } + arguments[1].appendChild(obj); + return obj; +} + +// "a" is reference to an object +function removeChildren(a) { + while (a.hasChildNodes()) { + a.removeChild(a.lastChild); + } +} + +// ---------------------------------------------------------------------------- +// Find-position functions by PPK +// See https://www.quirksmode.org/js/findpos.html +// ---------------------------------------------------------------------------- +function findPosX(obj) { + let curleft = 0; + if (obj.offsetParent) { + while (obj.offsetParent) { + curleft += obj.offsetLeft - obj.scrollLeft; + obj = obj.offsetParent; + } + } else if (obj.x) { + curleft += obj.x; + } + return curleft; +} + +function findPosY(obj) { + let curtop = 0; + if (obj.offsetParent) { + while (obj.offsetParent) { + curtop += obj.offsetTop - obj.scrollTop; + obj = obj.offsetParent; + } + } else if (obj.y) { + curtop += obj.y; + } + return curtop; +} + +//----------------------------------------------------------------------------- +// Date object extensions +// ---------------------------------------------------------------------------- +{ + Date.prototype.getTwelveHours = function() { + return this.getHours() % 12 || 12; + }; + + Date.prototype.getTwoDigitMonth = function() { + return (this.getMonth() < 9) ? '0' + (this.getMonth() + 1) : (this.getMonth() + 1); + }; + + Date.prototype.getTwoDigitDate = function() { + return (this.getDate() < 10) ? '0' + this.getDate() : this.getDate(); + }; + + Date.prototype.getTwoDigitTwelveHour = function() { + return (this.getTwelveHours() < 10) ? '0' + this.getTwelveHours() : this.getTwelveHours(); + }; + + Date.prototype.getTwoDigitHour = function() { + return (this.getHours() < 10) ? '0' + this.getHours() : this.getHours(); + }; + + Date.prototype.getTwoDigitMinute = function() { + return (this.getMinutes() < 10) ? '0' + this.getMinutes() : this.getMinutes(); + }; + + Date.prototype.getTwoDigitSecond = function() { + return (this.getSeconds() < 10) ? '0' + this.getSeconds() : this.getSeconds(); + }; + + Date.prototype.getAbbrevMonthName = function() { + return typeof window.CalendarNamespace === "undefined" + ? this.getTwoDigitMonth() + : window.CalendarNamespace.monthsOfYearAbbrev[this.getMonth()]; + }; + + Date.prototype.getFullMonthName = function() { + return typeof window.CalendarNamespace === "undefined" + ? this.getTwoDigitMonth() + : window.CalendarNamespace.monthsOfYear[this.getMonth()]; + }; + + Date.prototype.strftime = function(format) { + const fields = { + b: this.getAbbrevMonthName(), + B: this.getFullMonthName(), + c: this.toString(), + d: this.getTwoDigitDate(), + H: this.getTwoDigitHour(), + I: this.getTwoDigitTwelveHour(), + m: this.getTwoDigitMonth(), + M: this.getTwoDigitMinute(), + p: (this.getHours() >= 12) ? 'PM' : 'AM', + S: this.getTwoDigitSecond(), + w: '0' + this.getDay(), + x: this.toLocaleDateString(), + X: this.toLocaleTimeString(), + y: ('' + this.getFullYear()).substr(2, 4), + Y: '' + this.getFullYear(), + '%': '%' + }; + let result = '', i = 0; + while (i < format.length) { + if (format.charAt(i) === '%') { + result += fields[format.charAt(i + 1)]; + ++i; + } + else { + result += format.charAt(i); + } + ++i; + } + return result; + }; + + // ---------------------------------------------------------------------------- + // String object extensions + // ---------------------------------------------------------------------------- + String.prototype.strptime = function(format) { + const split_format = format.split(/[.\-/]/); + const date = this.split(/[.\-/]/); + let i = 0; + let day, month, year; + while (i < split_format.length) { + switch (split_format[i]) { + case "%d": + day = date[i]; + break; + case "%m": + month = date[i] - 1; + break; + case "%Y": + year = date[i]; + break; + case "%y": + // A %y value in the range of [00, 68] is in the current + // century, while [69, 99] is in the previous century, + // according to the Open Group Specification. + if (parseInt(date[i], 10) >= 69) { + year = date[i]; + } else { + year = (new Date(Date.UTC(date[i], 0))).getUTCFullYear() + 100; + } + break; + } + ++i; + } + // Create Date object from UTC since the parsed value is supposed to be + // in UTC, not local time. Also, the calendar uses UTC functions for + // date extraction. + return new Date(Date.UTC(year, month, day)); + }; +} diff --git a/sites/public/static/admin/js/filters.js b/sites/public/static/admin/js/filters.js new file mode 100755 index 00000000..f5536ebc --- /dev/null +++ b/sites/public/static/admin/js/filters.js @@ -0,0 +1,30 @@ +/** + * Persist changelist filters state (collapsed/expanded). + */ +'use strict'; +{ + // Init filters. + let filters = JSON.parse(sessionStorage.getItem('django.admin.filtersState')); + + if (!filters) { + filters = {}; + } + + Object.entries(filters).forEach(([key, value]) => { + const detailElement = document.querySelector(`[data-filter-title='${CSS.escape(key)}']`); + + // Check if the filter is present, it could be from other view. + if (detailElement) { + value ? detailElement.setAttribute('open', '') : detailElement.removeAttribute('open'); + } + }); + + // Save filter state when clicks. + const details = document.querySelectorAll('details'); + details.forEach(detail => { + detail.addEventListener('toggle', event => { + filters[`${event.target.dataset.filterTitle}`] = detail.open; + sessionStorage.setItem('django.admin.filtersState', JSON.stringify(filters)); + }); + }); +} diff --git a/sites/public/static/admin/js/inlines.js b/sites/public/static/admin/js/inlines.js new file mode 100755 index 00000000..e9a1dfe1 --- /dev/null +++ b/sites/public/static/admin/js/inlines.js @@ -0,0 +1,359 @@ +/*global DateTimeShortcuts, SelectFilter*/ +/** + * Django admin inlines + * + * Based on jQuery Formset 1.1 + * @author Stanislaus Madueke (stan DOT madueke AT gmail DOT com) + * @requires jQuery 1.2.6 or later + * + * Copyright (c) 2009, Stanislaus Madueke + * All rights reserved. + * + * Spiced up with Code from Zain Memon's GSoC project 2009 + * and modified for Django by Jannis Leidel, Travis Swicegood and Julien Phalip. + * + * Licensed under the New BSD License + * See: https://opensource.org/licenses/bsd-license.php + */ +'use strict'; +{ + const $ = django.jQuery; + $.fn.formset = function(opts) { + const options = $.extend({}, $.fn.formset.defaults, opts); + const $this = $(this); + const $parent = $this.parent(); + const updateElementIndex = function(el, prefix, ndx) { + const id_regex = new RegExp("(" + prefix + "-(\\d+|__prefix__))"); + const replacement = prefix + "-" + ndx; + if ($(el).prop("for")) { + $(el).prop("for", $(el).prop("for").replace(id_regex, replacement)); + } + if (el.id) { + el.id = el.id.replace(id_regex, replacement); + } + if (el.name) { + el.name = el.name.replace(id_regex, replacement); + } + }; + const totalForms = $("#id_" + options.prefix + "-TOTAL_FORMS").prop("autocomplete", "off"); + let nextIndex = parseInt(totalForms.val(), 10); + const maxForms = $("#id_" + options.prefix + "-MAX_NUM_FORMS").prop("autocomplete", "off"); + const minForms = $("#id_" + options.prefix + "-MIN_NUM_FORMS").prop("autocomplete", "off"); + let addButton; + + /** + * The "Add another MyModel" button below the inline forms. + */ + const addInlineAddButton = function() { + if (addButton === null) { + if ($this.prop("tagName") === "TR") { + // If forms are laid out as table rows, insert the + // "add" button in a new table row: + const numCols = $this.eq(-1).children().length; + $parent.append('' + options.addText + ""); + addButton = $parent.find("tr:last a"); + } else { + // Otherwise, insert it immediately after the last form: + $this.filter(":last").after('"); + addButton = $this.filter(":last").next().find("a"); + } + } + addButton.on('click', addInlineClickHandler); + }; + + const addInlineClickHandler = function(e) { + e.preventDefault(); + const template = $("#" + options.prefix + "-empty"); + const row = template.clone(true); + row.removeClass(options.emptyCssClass) + .addClass(options.formCssClass) + .attr("id", options.prefix + "-" + nextIndex); + addInlineDeleteButton(row); + row.find("*").each(function() { + updateElementIndex(this, options.prefix, totalForms.val()); + }); + // Insert the new form when it has been fully edited. + row.insertBefore($(template)); + // Update number of total forms. + $(totalForms).val(parseInt(totalForms.val(), 10) + 1); + nextIndex += 1; + // Hide the add button if there's a limit and it's been reached. + if ((maxForms.val() !== '') && (maxForms.val() - totalForms.val()) <= 0) { + addButton.parent().hide(); + } + // Show the remove buttons if there are more than min_num. + toggleDeleteButtonVisibility(row.closest('.inline-group')); + + // Pass the new form to the post-add callback, if provided. + if (options.added) { + options.added(row); + } + row.get(0).dispatchEvent(new CustomEvent("formset:added", { + bubbles: true, + detail: { + formsetName: options.prefix + } + })); + }; + + /** + * The "X" button that is part of every unsaved inline. + * (When saved, it is replaced with a "Delete" checkbox.) + */ + const addInlineDeleteButton = function(row) { + if (row.is("tr")) { + // If the forms are laid out in table rows, insert + // the remove button into the last table cell: + row.children(":last").append('"); + } else if (row.is("ul") || row.is("ol")) { + // If they're laid out as an ordered/unordered list, + // insert an
  • after the last list item: + row.append('
  • ' + options.deleteText + "
  • "); + } else { + // Otherwise, just insert the remove button as the + // last child element of the form's container: + row.children(":first").append('' + options.deleteText + ""); + } + // Add delete handler for each row. + row.find("a." + options.deleteCssClass).on('click', inlineDeleteHandler.bind(this)); + }; + + const inlineDeleteHandler = function(e1) { + e1.preventDefault(); + const deleteButton = $(e1.target); + const row = deleteButton.closest('.' + options.formCssClass); + const inlineGroup = row.closest('.inline-group'); + // Remove the parent form containing this button, + // and also remove the relevant row with non-field errors: + const prevRow = row.prev(); + if (prevRow.length && prevRow.hasClass('row-form-errors')) { + prevRow.remove(); + } + row.remove(); + nextIndex -= 1; + // Pass the deleted form to the post-delete callback, if provided. + if (options.removed) { + options.removed(row); + } + document.dispatchEvent(new CustomEvent("formset:removed", { + detail: { + formsetName: options.prefix + } + })); + // Update the TOTAL_FORMS form count. + const forms = $("." + options.formCssClass); + $("#id_" + options.prefix + "-TOTAL_FORMS").val(forms.length); + // Show add button again once below maximum number. + if ((maxForms.val() === '') || (maxForms.val() - forms.length) > 0) { + addButton.parent().show(); + } + // Hide the remove buttons if at min_num. + toggleDeleteButtonVisibility(inlineGroup); + // Also, update names and ids for all remaining form controls so + // they remain in sequence: + let i, formCount; + const updateElementCallback = function() { + updateElementIndex(this, options.prefix, i); + }; + for (i = 0, formCount = forms.length; i < formCount; i++) { + updateElementIndex($(forms).get(i), options.prefix, i); + $(forms.get(i)).find("*").each(updateElementCallback); + } + }; + + const toggleDeleteButtonVisibility = function(inlineGroup) { + if ((minForms.val() !== '') && (minForms.val() - totalForms.val()) >= 0) { + inlineGroup.find('.inline-deletelink').hide(); + } else { + inlineGroup.find('.inline-deletelink').show(); + } + }; + + $this.each(function(i) { + $(this).not("." + options.emptyCssClass).addClass(options.formCssClass); + }); + + // Create the delete buttons for all unsaved inlines: + $this.filter('.' + options.formCssClass + ':not(.has_original):not(.' + options.emptyCssClass + ')').each(function() { + addInlineDeleteButton($(this)); + }); + toggleDeleteButtonVisibility($this); + + // Create the add button, initially hidden. + addButton = options.addButton; + addInlineAddButton(); + + // Show the add button if allowed to add more items. + // Note that max_num = None translates to a blank string. + const showAddButton = maxForms.val() === '' || (maxForms.val() - totalForms.val()) > 0; + if ($this.length && showAddButton) { + addButton.parent().show(); + } else { + addButton.parent().hide(); + } + + return this; + }; + + /* Setup plugin defaults */ + $.fn.formset.defaults = { + prefix: "form", // The form prefix for your django formset + addText: "add another", // Text for the add link + deleteText: "remove", // Text for the delete link + addCssClass: "add-row", // CSS class applied to the add link + deleteCssClass: "delete-row", // CSS class applied to the delete link + emptyCssClass: "empty-row", // CSS class applied to the empty row + formCssClass: "dynamic-form", // CSS class applied to each form in a formset + added: null, // Function called each time a new form is added + removed: null, // Function called each time a form is deleted + addButton: null // Existing add button to use + }; + + + // Tabular inlines --------------------------------------------------------- + $.fn.tabularFormset = function(selector, options) { + const $rows = $(this); + + const reinitDateTimeShortCuts = function() { + // Reinitialize the calendar and clock widgets by force + if (typeof DateTimeShortcuts !== "undefined") { + $(".datetimeshortcuts").remove(); + DateTimeShortcuts.init(); + } + }; + + const updateSelectFilter = function() { + // If any SelectFilter widgets are a part of the new form, + // instantiate a new SelectFilter instance for it. + if (typeof SelectFilter !== 'undefined') { + $('.selectfilter').each(function(index, value) { + SelectFilter.init(value.id, this.dataset.fieldName, false); + }); + $('.selectfilterstacked').each(function(index, value) { + SelectFilter.init(value.id, this.dataset.fieldName, true); + }); + } + }; + + const initPrepopulatedFields = function(row) { + row.find('.prepopulated_field').each(function() { + const field = $(this), + input = field.find('input, select, textarea'), + dependency_list = input.data('dependency_list') || [], + dependencies = []; + $.each(dependency_list, function(i, field_name) { + dependencies.push('#' + row.find('.field-' + field_name).find('input, select, textarea').attr('id')); + }); + if (dependencies.length) { + input.prepopulate(dependencies, input.attr('maxlength')); + } + }); + }; + + $rows.formset({ + prefix: options.prefix, + addText: options.addText, + formCssClass: "dynamic-" + options.prefix, + deleteCssClass: "inline-deletelink", + deleteText: options.deleteText, + emptyCssClass: "empty-form", + added: function(row) { + initPrepopulatedFields(row); + reinitDateTimeShortCuts(); + updateSelectFilter(); + }, + addButton: options.addButton + }); + + return $rows; + }; + + // Stacked inlines --------------------------------------------------------- + $.fn.stackedFormset = function(selector, options) { + const $rows = $(this); + const updateInlineLabel = function(row) { + $(selector).find(".inline_label").each(function(i) { + const count = i + 1; + $(this).html($(this).html().replace(/(#\d+)/g, "#" + count)); + }); + }; + + const reinitDateTimeShortCuts = function() { + // Reinitialize the calendar and clock widgets by force, yuck. + if (typeof DateTimeShortcuts !== "undefined") { + $(".datetimeshortcuts").remove(); + DateTimeShortcuts.init(); + } + }; + + const updateSelectFilter = function() { + // If any SelectFilter widgets were added, instantiate a new instance. + if (typeof SelectFilter !== "undefined") { + $(".selectfilter").each(function(index, value) { + SelectFilter.init(value.id, this.dataset.fieldName, false); + }); + $(".selectfilterstacked").each(function(index, value) { + SelectFilter.init(value.id, this.dataset.fieldName, true); + }); + } + }; + + const initPrepopulatedFields = function(row) { + row.find('.prepopulated_field').each(function() { + const field = $(this), + input = field.find('input, select, textarea'), + dependency_list = input.data('dependency_list') || [], + dependencies = []; + $.each(dependency_list, function(i, field_name) { + // Dependency in a fieldset. + let field_element = row.find('.form-row .field-' + field_name); + // Dependency without a fieldset. + if (!field_element.length) { + field_element = row.find('.form-row.field-' + field_name); + } + dependencies.push('#' + field_element.find('input, select, textarea').attr('id')); + }); + if (dependencies.length) { + input.prepopulate(dependencies, input.attr('maxlength')); + } + }); + }; + + $rows.formset({ + prefix: options.prefix, + addText: options.addText, + formCssClass: "dynamic-" + options.prefix, + deleteCssClass: "inline-deletelink", + deleteText: options.deleteText, + emptyCssClass: "empty-form", + removed: updateInlineLabel, + added: function(row) { + initPrepopulatedFields(row); + reinitDateTimeShortCuts(); + updateSelectFilter(); + updateInlineLabel(row); + }, + addButton: options.addButton + }); + + return $rows; + }; + + $(document).ready(function() { + $(".js-inline-admin-formset").each(function() { + const data = $(this).data(), + inlineOptions = data.inlineFormset; + let selector; + switch(data.inlineType) { + case "stacked": + selector = inlineOptions.name + "-group .inline-related"; + $(selector).stackedFormset(selector, inlineOptions.options); + break; + case "tabular": + selector = inlineOptions.name + "-group .tabular.inline-related tbody:first > tr.form-row"; + $(selector).tabularFormset(selector, inlineOptions.options); + break; + } + }); + }); +} diff --git a/sites/public/static/admin/js/jquery.init.js b/sites/public/static/admin/js/jquery.init.js new file mode 100755 index 00000000..f40b27f4 --- /dev/null +++ b/sites/public/static/admin/js/jquery.init.js @@ -0,0 +1,8 @@ +/*global jQuery:false*/ +'use strict'; +/* Puts the included jQuery into our own namespace using noConflict and passing + * it 'true'. This ensures that the included jQuery doesn't pollute the global + * namespace (i.e. this preserves pre-existing values for both window.$ and + * window.jQuery). + */ +window.django = {jQuery: jQuery.noConflict(true)}; diff --git a/sites/public/static/admin/js/nav_sidebar.js b/sites/public/static/admin/js/nav_sidebar.js new file mode 100755 index 00000000..7e735db1 --- /dev/null +++ b/sites/public/static/admin/js/nav_sidebar.js @@ -0,0 +1,79 @@ +'use strict'; +{ + const toggleNavSidebar = document.getElementById('toggle-nav-sidebar'); + if (toggleNavSidebar !== null) { + const navSidebar = document.getElementById('nav-sidebar'); + const main = document.getElementById('main'); + let navSidebarIsOpen = localStorage.getItem('django.admin.navSidebarIsOpen'); + if (navSidebarIsOpen === null) { + navSidebarIsOpen = 'true'; + } + main.classList.toggle('shifted', navSidebarIsOpen === 'true'); + navSidebar.setAttribute('aria-expanded', navSidebarIsOpen); + + toggleNavSidebar.addEventListener('click', function() { + if (navSidebarIsOpen === 'true') { + navSidebarIsOpen = 'false'; + } else { + navSidebarIsOpen = 'true'; + } + localStorage.setItem('django.admin.navSidebarIsOpen', navSidebarIsOpen); + main.classList.toggle('shifted'); + navSidebar.setAttribute('aria-expanded', navSidebarIsOpen); + }); + } + + function initSidebarQuickFilter() { + const options = []; + const navSidebar = document.getElementById('nav-sidebar'); + if (!navSidebar) { + return; + } + navSidebar.querySelectorAll('th[scope=row] a').forEach((container) => { + options.push({title: container.innerHTML, node: container}); + }); + + function checkValue(event) { + let filterValue = event.target.value; + if (filterValue) { + filterValue = filterValue.toLowerCase(); + } + if (event.key === 'Escape') { + filterValue = ''; + event.target.value = ''; // clear input + } + let matches = false; + for (const o of options) { + let displayValue = ''; + if (filterValue) { + if (o.title.toLowerCase().indexOf(filterValue) === -1) { + displayValue = 'none'; + } else { + matches = true; + } + } + // show/hide parent + o.node.parentNode.parentNode.style.display = displayValue; + } + if (!filterValue || matches) { + event.target.classList.remove('no-results'); + } else { + event.target.classList.add('no-results'); + } + sessionStorage.setItem('django.admin.navSidebarFilterValue', filterValue); + } + + const nav = document.getElementById('nav-filter'); + nav.addEventListener('change', checkValue, false); + nav.addEventListener('input', checkValue, false); + nav.addEventListener('keyup', checkValue, false); + + const storedValue = sessionStorage.getItem('django.admin.navSidebarFilterValue'); + if (storedValue) { + nav.value = storedValue; + checkValue({target: nav, key: ''}); + } + } + window.initSidebarQuickFilter = initSidebarQuickFilter; + initSidebarQuickFilter(); +} diff --git a/sites/public/static/admin/js/popup_response.js b/sites/public/static/admin/js/popup_response.js new file mode 100755 index 00000000..2b1d3dd3 --- /dev/null +++ b/sites/public/static/admin/js/popup_response.js @@ -0,0 +1,16 @@ +/*global opener */ +'use strict'; +{ + const initData = JSON.parse(document.getElementById('django-admin-popup-response-constants').dataset.popupResponse); + switch(initData.action) { + case 'change': + opener.dismissChangeRelatedObjectPopup(window, initData.value, initData.obj, initData.new_value); + break; + case 'delete': + opener.dismissDeleteRelatedObjectPopup(window, initData.value); + break; + default: + opener.dismissAddRelatedObjectPopup(window, initData.value, initData.obj); + break; + } +} diff --git a/sites/public/static/admin/js/prepopulate.js b/sites/public/static/admin/js/prepopulate.js new file mode 100755 index 00000000..89e95ab4 --- /dev/null +++ b/sites/public/static/admin/js/prepopulate.js @@ -0,0 +1,43 @@ +/*global URLify*/ +'use strict'; +{ + const $ = django.jQuery; + $.fn.prepopulate = function(dependencies, maxLength, allowUnicode) { + /* + Depends on urlify.js + Populates a selected field with the values of the dependent fields, + URLifies and shortens the string. + dependencies - array of dependent fields ids + maxLength - maximum length of the URLify'd string + allowUnicode - Unicode support of the URLify'd string + */ + return this.each(function() { + const prepopulatedField = $(this); + + const populate = function() { + // Bail if the field's value has been changed by the user + if (prepopulatedField.data('_changed')) { + return; + } + + const values = []; + $.each(dependencies, function(i, field) { + field = $(field); + if (field.val().length > 0) { + values.push(field.val()); + } + }); + prepopulatedField.val(URLify(values.join(' '), maxLength, allowUnicode)); + }; + + prepopulatedField.data('_changed', false); + prepopulatedField.on('change', function() { + prepopulatedField.data('_changed', true); + }); + + if (!prepopulatedField.val()) { + $(dependencies.join(',')).on('keyup change focus', populate); + } + }); + }; +} diff --git a/sites/public/static/admin/js/prepopulate_init.js b/sites/public/static/admin/js/prepopulate_init.js new file mode 100755 index 00000000..a58841f0 --- /dev/null +++ b/sites/public/static/admin/js/prepopulate_init.js @@ -0,0 +1,15 @@ +'use strict'; +{ + const $ = django.jQuery; + const fields = $('#django-admin-prepopulated-fields-constants').data('prepopulatedFields'); + $.each(fields, function(index, field) { + $( + '.empty-form .form-row .field-' + field.name + + ', .empty-form.form-row .field-' + field.name + + ', .empty-form .form-row.field-' + field.name + ).addClass('prepopulated_field'); + $(field.id).data('dependency_list', field.dependency_list).prepopulate( + field.dependency_ids, field.maxLength, field.allowUnicode + ); + }); +} diff --git a/sites/public/static/admin/js/theme.js b/sites/public/static/admin/js/theme.js new file mode 100755 index 00000000..794cd15f --- /dev/null +++ b/sites/public/static/admin/js/theme.js @@ -0,0 +1,56 @@ +'use strict'; +{ + window.addEventListener('load', function(e) { + + function setTheme(mode) { + if (mode !== "light" && mode !== "dark" && mode !== "auto") { + console.error(`Got invalid theme mode: ${mode}. Resetting to auto.`); + mode = "auto"; + } + document.documentElement.dataset.theme = mode; + localStorage.setItem("theme", mode); + } + + function cycleTheme() { + const currentTheme = localStorage.getItem("theme") || "auto"; + const prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches; + + if (prefersDark) { + // Auto (dark) -> Light -> Dark + if (currentTheme === "auto") { + setTheme("light"); + } else if (currentTheme === "light") { + setTheme("dark"); + } else { + setTheme("auto"); + } + } else { + // Auto (light) -> Dark -> Light + if (currentTheme === "auto") { + setTheme("dark"); + } else if (currentTheme === "dark") { + setTheme("light"); + } else { + setTheme("auto"); + } + } + } + + function initTheme() { + // set theme defined in localStorage if there is one, or fallback to auto mode + const currentTheme = localStorage.getItem("theme"); + currentTheme ? setTheme(currentTheme) : setTheme("auto"); + } + + function setupTheme() { + // Attach event handlers for toggling themes + const buttons = document.getElementsByClassName("theme-toggle"); + Array.from(buttons).forEach((btn) => { + btn.addEventListener("click", cycleTheme); + }); + initTheme(); + } + + setupTheme(); + }); +} diff --git a/sites/public/static/admin/js/urlify.js b/sites/public/static/admin/js/urlify.js new file mode 100755 index 00000000..9fc04094 --- /dev/null +++ b/sites/public/static/admin/js/urlify.js @@ -0,0 +1,169 @@ +/*global XRegExp*/ +'use strict'; +{ + const LATIN_MAP = { + 'À': 'A', 'Á': 'A', 'Â': 'A', 'Ã': 'A', 'Ä': 'A', 'Å': 'A', 'Æ': 'AE', + 'Ç': 'C', 'È': 'E', 'É': 'E', 'Ê': 'E', 'Ë': 'E', 'Ì': 'I', 'Í': 'I', + 'Î': 'I', 'Ï': 'I', 'Ð': 'D', 'Ñ': 'N', 'Ò': 'O', 'Ó': 'O', 'Ô': 'O', + 'Õ': 'O', 'Ö': 'O', 'Ő': 'O', 'Ø': 'O', 'Ù': 'U', 'Ú': 'U', 'Û': 'U', + 'Ü': 'U', 'Ű': 'U', 'Ý': 'Y', 'Þ': 'TH', 'Ÿ': 'Y', 'ß': 'ss', 'à': 'a', + 'á': 'a', 'â': 'a', 'ã': 'a', 'ä': 'a', 'å': 'a', 'æ': 'ae', 'ç': 'c', + 'è': 'e', 'é': 'e', 'ê': 'e', 'ë': 'e', 'ì': 'i', 'í': 'i', 'î': 'i', + 'ï': 'i', 'ð': 'd', 'ñ': 'n', 'ò': 'o', 'ó': 'o', 'ô': 'o', 'õ': 'o', + 'ö': 'o', 'ő': 'o', 'ø': 'o', 'ù': 'u', 'ú': 'u', 'û': 'u', 'ü': 'u', + 'ű': 'u', 'ý': 'y', 'þ': 'th', 'ÿ': 'y' + }; + const LATIN_SYMBOLS_MAP = { + '©': '(c)' + }; + const GREEK_MAP = { + 'α': 'a', 'β': 'b', 'γ': 'g', 'δ': 'd', 'ε': 'e', 'ζ': 'z', 'η': 'h', + 'θ': '8', 'ι': 'i', 'κ': 'k', 'λ': 'l', 'μ': 'm', 'ν': 'n', 'ξ': '3', + 'ο': 'o', 'π': 'p', 'ρ': 'r', 'σ': 's', 'τ': 't', 'υ': 'y', 'φ': 'f', + 'χ': 'x', 'ψ': 'ps', 'ω': 'w', 'ά': 'a', 'έ': 'e', 'ί': 'i', 'ό': 'o', + 'ύ': 'y', 'ή': 'h', 'ώ': 'w', 'ς': 's', 'ϊ': 'i', 'ΰ': 'y', 'ϋ': 'y', + 'ΐ': 'i', 'Α': 'A', 'Β': 'B', 'Γ': 'G', 'Δ': 'D', 'Ε': 'E', 'Ζ': 'Z', + 'Η': 'H', 'Θ': '8', 'Ι': 'I', 'Κ': 'K', 'Λ': 'L', 'Μ': 'M', 'Ν': 'N', + 'Ξ': '3', 'Ο': 'O', 'Π': 'P', 'Ρ': 'R', 'Σ': 'S', 'Τ': 'T', 'Υ': 'Y', + 'Φ': 'F', 'Χ': 'X', 'Ψ': 'PS', 'Ω': 'W', 'Ά': 'A', 'Έ': 'E', 'Ί': 'I', + 'Ό': 'O', 'Ύ': 'Y', 'Ή': 'H', 'Ώ': 'W', 'Ϊ': 'I', 'Ϋ': 'Y' + }; + const TURKISH_MAP = { + 'ş': 's', 'Ş': 'S', 'ı': 'i', 'İ': 'I', 'ç': 'c', 'Ç': 'C', 'ü': 'u', + 'Ü': 'U', 'ö': 'o', 'Ö': 'O', 'ğ': 'g', 'Ğ': 'G' + }; + const ROMANIAN_MAP = { + 'ă': 'a', 'î': 'i', 'ș': 's', 'ț': 't', 'â': 'a', + 'Ă': 'A', 'Î': 'I', 'Ș': 'S', 'Ț': 'T', 'Â': 'A' + }; + const RUSSIAN_MAP = { + 'а': 'a', 'б': 'b', 'в': 'v', 'г': 'g', 'д': 'd', 'е': 'e', 'ё': 'yo', + 'ж': 'zh', 'з': 'z', 'и': 'i', 'й': 'j', 'к': 'k', 'л': 'l', 'м': 'm', + 'н': 'n', 'о': 'o', 'п': 'p', 'р': 'r', 'с': 's', 'т': 't', 'у': 'u', + 'ф': 'f', 'х': 'h', 'ц': 'c', 'ч': 'ch', 'ш': 'sh', 'щ': 'sh', 'ъ': '', + 'ы': 'y', 'ь': '', 'э': 'e', 'ю': 'yu', 'я': 'ya', + 'А': 'A', 'Б': 'B', 'В': 'V', 'Г': 'G', 'Д': 'D', 'Е': 'E', 'Ё': 'Yo', + 'Ж': 'Zh', 'З': 'Z', 'И': 'I', 'Й': 'J', 'К': 'K', 'Л': 'L', 'М': 'M', + 'Н': 'N', 'О': 'O', 'П': 'P', 'Р': 'R', 'С': 'S', 'Т': 'T', 'У': 'U', + 'Ф': 'F', 'Х': 'H', 'Ц': 'C', 'Ч': 'Ch', 'Ш': 'Sh', 'Щ': 'Sh', 'Ъ': '', + 'Ы': 'Y', 'Ь': '', 'Э': 'E', 'Ю': 'Yu', 'Я': 'Ya' + }; + const UKRAINIAN_MAP = { + 'Є': 'Ye', 'І': 'I', 'Ї': 'Yi', 'Ґ': 'G', 'є': 'ye', 'і': 'i', + 'ї': 'yi', 'ґ': 'g' + }; + const CZECH_MAP = { + 'č': 'c', 'ď': 'd', 'ě': 'e', 'ň': 'n', 'ř': 'r', 'š': 's', 'ť': 't', + 'ů': 'u', 'ž': 'z', 'Č': 'C', 'Ď': 'D', 'Ě': 'E', 'Ň': 'N', 'Ř': 'R', + 'Š': 'S', 'Ť': 'T', 'Ů': 'U', 'Ž': 'Z' + }; + const SLOVAK_MAP = { + 'á': 'a', 'ä': 'a', 'č': 'c', 'ď': 'd', 'é': 'e', 'í': 'i', 'ľ': 'l', + 'ĺ': 'l', 'ň': 'n', 'ó': 'o', 'ô': 'o', 'ŕ': 'r', 'š': 's', 'ť': 't', + 'ú': 'u', 'ý': 'y', 'ž': 'z', + 'Á': 'a', 'Ä': 'A', 'Č': 'C', 'Ď': 'D', 'É': 'E', 'Í': 'I', 'Ľ': 'L', + 'Ĺ': 'L', 'Ň': 'N', 'Ó': 'O', 'Ô': 'O', 'Ŕ': 'R', 'Š': 'S', 'Ť': 'T', + 'Ú': 'U', 'Ý': 'Y', 'Ž': 'Z' + }; + const POLISH_MAP = { + 'ą': 'a', 'ć': 'c', 'ę': 'e', 'ł': 'l', 'ń': 'n', 'ó': 'o', 'ś': 's', + 'ź': 'z', 'ż': 'z', + 'Ą': 'A', 'Ć': 'C', 'Ę': 'E', 'Ł': 'L', 'Ń': 'N', 'Ó': 'O', 'Ś': 'S', + 'Ź': 'Z', 'Ż': 'Z' + }; + const LATVIAN_MAP = { + 'ā': 'a', 'č': 'c', 'ē': 'e', 'ģ': 'g', 'ī': 'i', 'ķ': 'k', 'ļ': 'l', + 'ņ': 'n', 'š': 's', 'ū': 'u', 'ž': 'z', + 'Ā': 'A', 'Č': 'C', 'Ē': 'E', 'Ģ': 'G', 'Ī': 'I', 'Ķ': 'K', 'Ļ': 'L', + 'Ņ': 'N', 'Š': 'S', 'Ū': 'U', 'Ž': 'Z' + }; + const ARABIC_MAP = { + 'أ': 'a', 'ب': 'b', 'ت': 't', 'ث': 'th', 'ج': 'g', 'ح': 'h', 'خ': 'kh', 'د': 'd', + 'ذ': 'th', 'ر': 'r', 'ز': 'z', 'س': 's', 'ش': 'sh', 'ص': 's', 'ض': 'd', 'ط': 't', + 'ظ': 'th', 'ع': 'aa', 'غ': 'gh', 'ف': 'f', 'ق': 'k', 'ك': 'k', 'ل': 'l', 'م': 'm', + 'ن': 'n', 'ه': 'h', 'و': 'o', 'ي': 'y' + }; + const LITHUANIAN_MAP = { + 'ą': 'a', 'č': 'c', 'ę': 'e', 'ė': 'e', 'į': 'i', 'š': 's', 'ų': 'u', + 'ū': 'u', 'ž': 'z', + 'Ą': 'A', 'Č': 'C', 'Ę': 'E', 'Ė': 'E', 'Į': 'I', 'Š': 'S', 'Ų': 'U', + 'Ū': 'U', 'Ž': 'Z' + }; + const SERBIAN_MAP = { + 'ђ': 'dj', 'ј': 'j', 'љ': 'lj', 'њ': 'nj', 'ћ': 'c', 'џ': 'dz', + 'đ': 'dj', 'Ђ': 'Dj', 'Ј': 'j', 'Љ': 'Lj', 'Њ': 'Nj', 'Ћ': 'C', + 'Џ': 'Dz', 'Đ': 'Dj' + }; + const AZERBAIJANI_MAP = { + 'ç': 'c', 'ə': 'e', 'ğ': 'g', 'ı': 'i', 'ö': 'o', 'ş': 's', 'ü': 'u', + 'Ç': 'C', 'Ə': 'E', 'Ğ': 'G', 'İ': 'I', 'Ö': 'O', 'Ş': 'S', 'Ü': 'U' + }; + const GEORGIAN_MAP = { + 'ა': 'a', 'ბ': 'b', 'გ': 'g', 'დ': 'd', 'ე': 'e', 'ვ': 'v', 'ზ': 'z', + 'თ': 't', 'ი': 'i', 'კ': 'k', 'ლ': 'l', 'მ': 'm', 'ნ': 'n', 'ო': 'o', + 'პ': 'p', 'ჟ': 'j', 'რ': 'r', 'ს': 's', 'ტ': 't', 'უ': 'u', 'ფ': 'f', + 'ქ': 'q', 'ღ': 'g', 'ყ': 'y', 'შ': 'sh', 'ჩ': 'ch', 'ც': 'c', 'ძ': 'dz', + 'წ': 'w', 'ჭ': 'ch', 'ხ': 'x', 'ჯ': 'j', 'ჰ': 'h' + }; + + const ALL_DOWNCODE_MAPS = [ + LATIN_MAP, + LATIN_SYMBOLS_MAP, + GREEK_MAP, + TURKISH_MAP, + ROMANIAN_MAP, + RUSSIAN_MAP, + UKRAINIAN_MAP, + CZECH_MAP, + SLOVAK_MAP, + POLISH_MAP, + LATVIAN_MAP, + ARABIC_MAP, + LITHUANIAN_MAP, + SERBIAN_MAP, + AZERBAIJANI_MAP, + GEORGIAN_MAP + ]; + + const Downcoder = { + 'Initialize': function() { + if (Downcoder.map) { // already made + return; + } + Downcoder.map = {}; + for (const lookup of ALL_DOWNCODE_MAPS) { + Object.assign(Downcoder.map, lookup); + } + Downcoder.regex = new RegExp(Object.keys(Downcoder.map).join('|'), 'g'); + } + }; + + function downcode(slug) { + Downcoder.Initialize(); + return slug.replace(Downcoder.regex, function(m) { + return Downcoder.map[m]; + }); + } + + + function URLify(s, num_chars, allowUnicode) { + // changes, e.g., "Petty theft" to "petty-theft" + if (!allowUnicode) { + s = downcode(s); + } + s = s.toLowerCase(); // convert to lowercase + // if downcode doesn't hit, the char will be stripped here + if (allowUnicode) { + // Keep Unicode letters including both lowercase and uppercase + // characters, whitespace, and dash; remove other characters. + s = XRegExp.replace(s, XRegExp('[^-_\\p{L}\\p{N}\\s]', 'g'), ''); + } else { + s = s.replace(/[^-\w\s]/g, ''); // remove unneeded chars + } + s = s.replace(/^\s+|\s+$/g, ''); // trim leading/trailing spaces + s = s.replace(/[-\s]+/g, '-'); // convert spaces to hyphens + s = s.substring(0, num_chars); // trim to first num_chars chars + return s.replace(/-+$/g, ''); // trim any trailing hyphens + } + window.URLify = URLify; +} diff --git a/sites/public/static/admin/js/vendor/jquery/LICENSE.txt b/sites/public/static/admin/js/vendor/jquery/LICENSE.txt new file mode 100755 index 00000000..f642c3f7 --- /dev/null +++ b/sites/public/static/admin/js/vendor/jquery/LICENSE.txt @@ -0,0 +1,20 @@ +Copyright OpenJS Foundation and other contributors, https://openjsf.org/ + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/sites/public/static/admin/js/vendor/jquery/jquery.js b/sites/public/static/admin/js/vendor/jquery/jquery.js new file mode 100755 index 00000000..7f35c11b --- /dev/null +++ b/sites/public/static/admin/js/vendor/jquery/jquery.js @@ -0,0 +1,10965 @@ +/*! + * jQuery JavaScript Library v3.6.4 + * https://jquery.com/ + * + * Includes Sizzle.js + * https://sizzlejs.com/ + * + * Copyright OpenJS Foundation and other contributors + * Released under the MIT license + * https://jquery.org/license + * + * Date: 2023-03-08T15:28Z + */ +( function( global, factory ) { + + "use strict"; + + if ( typeof module === "object" && typeof module.exports === "object" ) { + + // For CommonJS and CommonJS-like environments where a proper `window` + // is present, execute the factory and get jQuery. + // For environments that do not have a `window` with a `document` + // (such as Node.js), expose a factory as module.exports. + // This accentuates the need for the creation of a real `window`. + // e.g. var jQuery = require("jquery")(window); + // See ticket trac-14549 for more info. + module.exports = global.document ? + factory( global, true ) : + function( w ) { + if ( !w.document ) { + throw new Error( "jQuery requires a window with a document" ); + } + return factory( w ); + }; + } else { + factory( global ); + } + +// Pass this if window is not defined yet +} )( typeof window !== "undefined" ? window : this, function( window, noGlobal ) { + +// Edge <= 12 - 13+, Firefox <=18 - 45+, IE 10 - 11, Safari 5.1 - 9+, iOS 6 - 9.1 +// throw exceptions when non-strict code (e.g., ASP.NET 4.5) accesses strict mode +// arguments.callee.caller (trac-13335). But as of jQuery 3.0 (2016), strict mode should be common +// enough that all such attempts are guarded in a try block. +"use strict"; + +var arr = []; + +var getProto = Object.getPrototypeOf; + +var slice = arr.slice; + +var flat = arr.flat ? function( array ) { + return arr.flat.call( array ); +} : function( array ) { + return arr.concat.apply( [], array ); +}; + + +var push = arr.push; + +var indexOf = arr.indexOf; + +var class2type = {}; + +var toString = class2type.toString; + +var hasOwn = class2type.hasOwnProperty; + +var fnToString = hasOwn.toString; + +var ObjectFunctionString = fnToString.call( Object ); + +var support = {}; + +var isFunction = function isFunction( obj ) { + + // Support: Chrome <=57, Firefox <=52 + // In some browsers, typeof returns "function" for HTML elements + // (i.e., `typeof document.createElement( "object" ) === "function"`). + // We don't want to classify *any* DOM node as a function. + // Support: QtWeb <=3.8.5, WebKit <=534.34, wkhtmltopdf tool <=0.12.5 + // Plus for old WebKit, typeof returns "function" for HTML collections + // (e.g., `typeof document.getElementsByTagName("div") === "function"`). (gh-4756) + return typeof obj === "function" && typeof obj.nodeType !== "number" && + typeof obj.item !== "function"; + }; + + +var isWindow = function isWindow( obj ) { + return obj != null && obj === obj.window; + }; + + +var document = window.document; + + + + var preservedScriptAttributes = { + type: true, + src: true, + nonce: true, + noModule: true + }; + + function DOMEval( code, node, doc ) { + doc = doc || document; + + var i, val, + script = doc.createElement( "script" ); + + script.text = code; + if ( node ) { + for ( i in preservedScriptAttributes ) { + + // Support: Firefox 64+, Edge 18+ + // Some browsers don't support the "nonce" property on scripts. + // On the other hand, just using `getAttribute` is not enough as + // the `nonce` attribute is reset to an empty string whenever it + // becomes browsing-context connected. + // See https://github.com/whatwg/html/issues/2369 + // See https://html.spec.whatwg.org/#nonce-attributes + // The `node.getAttribute` check was added for the sake of + // `jQuery.globalEval` so that it can fake a nonce-containing node + // via an object. + val = node[ i ] || node.getAttribute && node.getAttribute( i ); + if ( val ) { + script.setAttribute( i, val ); + } + } + } + doc.head.appendChild( script ).parentNode.removeChild( script ); + } + + +function toType( obj ) { + if ( obj == null ) { + return obj + ""; + } + + // Support: Android <=2.3 only (functionish RegExp) + return typeof obj === "object" || typeof obj === "function" ? + class2type[ toString.call( obj ) ] || "object" : + typeof obj; +} +/* global Symbol */ +// Defining this global in .eslintrc.json would create a danger of using the global +// unguarded in another place, it seems safer to define global only for this module + + + +var + version = "3.6.4", + + // Define a local copy of jQuery + jQuery = function( selector, context ) { + + // The jQuery object is actually just the init constructor 'enhanced' + // Need init if jQuery is called (just allow error to be thrown if not included) + return new jQuery.fn.init( selector, context ); + }; + +jQuery.fn = jQuery.prototype = { + + // The current version of jQuery being used + jquery: version, + + constructor: jQuery, + + // The default length of a jQuery object is 0 + length: 0, + + toArray: function() { + return slice.call( this ); + }, + + // Get the Nth element in the matched element set OR + // Get the whole matched element set as a clean array + get: function( num ) { + + // Return all the elements in a clean array + if ( num == null ) { + return slice.call( this ); + } + + // Return just the one element from the set + return num < 0 ? this[ num + this.length ] : this[ num ]; + }, + + // Take an array of elements and push it onto the stack + // (returning the new matched element set) + pushStack: function( elems ) { + + // Build a new jQuery matched element set + var ret = jQuery.merge( this.constructor(), elems ); + + // Add the old object onto the stack (as a reference) + ret.prevObject = this; + + // Return the newly-formed element set + return ret; + }, + + // Execute a callback for every element in the matched set. + each: function( callback ) { + return jQuery.each( this, callback ); + }, + + map: function( callback ) { + return this.pushStack( jQuery.map( this, function( elem, i ) { + return callback.call( elem, i, elem ); + } ) ); + }, + + slice: function() { + return this.pushStack( slice.apply( this, arguments ) ); + }, + + first: function() { + return this.eq( 0 ); + }, + + last: function() { + return this.eq( -1 ); + }, + + even: function() { + return this.pushStack( jQuery.grep( this, function( _elem, i ) { + return ( i + 1 ) % 2; + } ) ); + }, + + odd: function() { + return this.pushStack( jQuery.grep( this, function( _elem, i ) { + return i % 2; + } ) ); + }, + + eq: function( i ) { + var len = this.length, + j = +i + ( i < 0 ? len : 0 ); + return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] ); + }, + + end: function() { + return this.prevObject || this.constructor(); + }, + + // For internal use only. + // Behaves like an Array's method, not like a jQuery method. + push: push, + sort: arr.sort, + splice: arr.splice +}; + +jQuery.extend = jQuery.fn.extend = function() { + var options, name, src, copy, copyIsArray, clone, + target = arguments[ 0 ] || {}, + i = 1, + length = arguments.length, + deep = false; + + // Handle a deep copy situation + if ( typeof target === "boolean" ) { + deep = target; + + // Skip the boolean and the target + target = arguments[ i ] || {}; + i++; + } + + // Handle case when target is a string or something (possible in deep copy) + if ( typeof target !== "object" && !isFunction( target ) ) { + target = {}; + } + + // Extend jQuery itself if only one argument is passed + if ( i === length ) { + target = this; + i--; + } + + for ( ; i < length; i++ ) { + + // Only deal with non-null/undefined values + if ( ( options = arguments[ i ] ) != null ) { + + // Extend the base object + for ( name in options ) { + copy = options[ name ]; + + // Prevent Object.prototype pollution + // Prevent never-ending loop + if ( name === "__proto__" || target === copy ) { + continue; + } + + // Recurse if we're merging plain objects or arrays + if ( deep && copy && ( jQuery.isPlainObject( copy ) || + ( copyIsArray = Array.isArray( copy ) ) ) ) { + src = target[ name ]; + + // Ensure proper type for the source value + if ( copyIsArray && !Array.isArray( src ) ) { + clone = []; + } else if ( !copyIsArray && !jQuery.isPlainObject( src ) ) { + clone = {}; + } else { + clone = src; + } + copyIsArray = false; + + // Never move original objects, clone them + target[ name ] = jQuery.extend( deep, clone, copy ); + + // Don't bring in undefined values + } else if ( copy !== undefined ) { + target[ name ] = copy; + } + } + } + } + + // Return the modified object + return target; +}; + +jQuery.extend( { + + // Unique for each copy of jQuery on the page + expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ), + + // Assume jQuery is ready without the ready module + isReady: true, + + error: function( msg ) { + throw new Error( msg ); + }, + + noop: function() {}, + + isPlainObject: function( obj ) { + var proto, Ctor; + + // Detect obvious negatives + // Use toString instead of jQuery.type to catch host objects + if ( !obj || toString.call( obj ) !== "[object Object]" ) { + return false; + } + + proto = getProto( obj ); + + // Objects with no prototype (e.g., `Object.create( null )`) are plain + if ( !proto ) { + return true; + } + + // Objects with prototype are plain iff they were constructed by a global Object function + Ctor = hasOwn.call( proto, "constructor" ) && proto.constructor; + return typeof Ctor === "function" && fnToString.call( Ctor ) === ObjectFunctionString; + }, + + isEmptyObject: function( obj ) { + var name; + + for ( name in obj ) { + return false; + } + return true; + }, + + // Evaluates a script in a provided context; falls back to the global one + // if not specified. + globalEval: function( code, options, doc ) { + DOMEval( code, { nonce: options && options.nonce }, doc ); + }, + + each: function( obj, callback ) { + var length, i = 0; + + if ( isArrayLike( obj ) ) { + length = obj.length; + for ( ; i < length; i++ ) { + if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) { + break; + } + } + } else { + for ( i in obj ) { + if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) { + break; + } + } + } + + return obj; + }, + + // results is for internal usage only + makeArray: function( arr, results ) { + var ret = results || []; + + if ( arr != null ) { + if ( isArrayLike( Object( arr ) ) ) { + jQuery.merge( ret, + typeof arr === "string" ? + [ arr ] : arr + ); + } else { + push.call( ret, arr ); + } + } + + return ret; + }, + + inArray: function( elem, arr, i ) { + return arr == null ? -1 : indexOf.call( arr, elem, i ); + }, + + // Support: Android <=4.0 only, PhantomJS 1 only + // push.apply(_, arraylike) throws on ancient WebKit + merge: function( first, second ) { + var len = +second.length, + j = 0, + i = first.length; + + for ( ; j < len; j++ ) { + first[ i++ ] = second[ j ]; + } + + first.length = i; + + return first; + }, + + grep: function( elems, callback, invert ) { + var callbackInverse, + matches = [], + i = 0, + length = elems.length, + callbackExpect = !invert; + + // Go through the array, only saving the items + // that pass the validator function + for ( ; i < length; i++ ) { + callbackInverse = !callback( elems[ i ], i ); + if ( callbackInverse !== callbackExpect ) { + matches.push( elems[ i ] ); + } + } + + return matches; + }, + + // arg is for internal usage only + map: function( elems, callback, arg ) { + var length, value, + i = 0, + ret = []; + + // Go through the array, translating each of the items to their new values + if ( isArrayLike( elems ) ) { + length = elems.length; + for ( ; i < length; i++ ) { + value = callback( elems[ i ], i, arg ); + + if ( value != null ) { + ret.push( value ); + } + } + + // Go through every key on the object, + } else { + for ( i in elems ) { + value = callback( elems[ i ], i, arg ); + + if ( value != null ) { + ret.push( value ); + } + } + } + + // Flatten any nested arrays + return flat( ret ); + }, + + // A global GUID counter for objects + guid: 1, + + // jQuery.support is not used in Core but other projects attach their + // properties to it so it needs to exist. + support: support +} ); + +if ( typeof Symbol === "function" ) { + jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ]; +} + +// Populate the class2type map +jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ), + function( _i, name ) { + class2type[ "[object " + name + "]" ] = name.toLowerCase(); + } ); + +function isArrayLike( obj ) { + + // Support: real iOS 8.2 only (not reproducible in simulator) + // `in` check used to prevent JIT error (gh-2145) + // hasOwn isn't used here due to false negatives + // regarding Nodelist length in IE + var length = !!obj && "length" in obj && obj.length, + type = toType( obj ); + + if ( isFunction( obj ) || isWindow( obj ) ) { + return false; + } + + return type === "array" || length === 0 || + typeof length === "number" && length > 0 && ( length - 1 ) in obj; +} +var Sizzle = +/*! + * Sizzle CSS Selector Engine v2.3.10 + * https://sizzlejs.com/ + * + * Copyright JS Foundation and other contributors + * Released under the MIT license + * https://js.foundation/ + * + * Date: 2023-02-14 + */ +( function( window ) { +var i, + support, + Expr, + getText, + isXML, + tokenize, + compile, + select, + outermostContext, + sortInput, + hasDuplicate, + + // Local document vars + setDocument, + document, + docElem, + documentIsHTML, + rbuggyQSA, + rbuggyMatches, + matches, + contains, + + // Instance-specific data + expando = "sizzle" + 1 * new Date(), + preferredDoc = window.document, + dirruns = 0, + done = 0, + classCache = createCache(), + tokenCache = createCache(), + compilerCache = createCache(), + nonnativeSelectorCache = createCache(), + sortOrder = function( a, b ) { + if ( a === b ) { + hasDuplicate = true; + } + return 0; + }, + + // Instance methods + hasOwn = ( {} ).hasOwnProperty, + arr = [], + pop = arr.pop, + pushNative = arr.push, + push = arr.push, + slice = arr.slice, + + // Use a stripped-down indexOf as it's faster than native + // https://jsperf.com/thor-indexof-vs-for/5 + indexOf = function( list, elem ) { + var i = 0, + len = list.length; + for ( ; i < len; i++ ) { + if ( list[ i ] === elem ) { + return i; + } + } + return -1; + }, + + booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|" + + "ismap|loop|multiple|open|readonly|required|scoped", + + // Regular expressions + + // http://www.w3.org/TR/css3-selectors/#whitespace + whitespace = "[\\x20\\t\\r\\n\\f]", + + // https://www.w3.org/TR/css-syntax-3/#ident-token-diagram + identifier = "(?:\\\\[\\da-fA-F]{1,6}" + whitespace + + "?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+", + + // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors + attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace + + + // Operator (capture 2) + "*([*^$|!~]?=)" + whitespace + + + // "Attribute values must be CSS identifiers [capture 5] + // or strings [capture 3 or capture 4]" + "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + + whitespace + "*\\]", + + pseudos = ":(" + identifier + ")(?:\\((" + + + // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments: + // 1. quoted (capture 3; capture 4 or capture 5) + "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" + + + // 2. simple (capture 6) + "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" + + + // 3. anything else (capture 2) + ".*" + + ")\\)|)", + + // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter + rwhitespace = new RegExp( whitespace + "+", "g" ), + rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + + whitespace + "+$", "g" ), + + rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ), + rleadingCombinator = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + + "*" ), + rdescend = new RegExp( whitespace + "|>" ), + + rpseudo = new RegExp( pseudos ), + ridentifier = new RegExp( "^" + identifier + "$" ), + + matchExpr = { + "ID": new RegExp( "^#(" + identifier + ")" ), + "CLASS": new RegExp( "^\\.(" + identifier + ")" ), + "TAG": new RegExp( "^(" + identifier + "|[*])" ), + "ATTR": new RegExp( "^" + attributes ), + "PSEUDO": new RegExp( "^" + pseudos ), + "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + + whitespace + "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + + whitespace + "*(\\d+)|))" + whitespace + "*\\)|)", "i" ), + "bool": new RegExp( "^(?:" + booleans + ")$", "i" ), + + // For use in libraries implementing .is() + // We use this for POS matching in `select` + "needsContext": new RegExp( "^" + whitespace + + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + whitespace + + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" ) + }, + + rhtml = /HTML$/i, + rinputs = /^(?:input|select|textarea|button)$/i, + rheader = /^h\d$/i, + + rnative = /^[^{]+\{\s*\[native \w/, + + // Easily-parseable/retrievable ID or TAG or CLASS selectors + rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/, + + rsibling = /[+~]/, + + // CSS escapes + // http://www.w3.org/TR/CSS21/syndata.html#escaped-characters + runescape = new RegExp( "\\\\[\\da-fA-F]{1,6}" + whitespace + "?|\\\\([^\\r\\n\\f])", "g" ), + funescape = function( escape, nonHex ) { + var high = "0x" + escape.slice( 1 ) - 0x10000; + + return nonHex ? + + // Strip the backslash prefix from a non-hex escape sequence + nonHex : + + // Replace a hexadecimal escape sequence with the encoded Unicode code point + // Support: IE <=11+ + // For values outside the Basic Multilingual Plane (BMP), manually construct a + // surrogate pair + high < 0 ? + String.fromCharCode( high + 0x10000 ) : + String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 ); + }, + + // CSS string/identifier serialization + // https://drafts.csswg.org/cssom/#common-serializing-idioms + rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g, + fcssescape = function( ch, asCodePoint ) { + if ( asCodePoint ) { + + // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER + if ( ch === "\0" ) { + return "\uFFFD"; + } + + // Control characters and (dependent upon position) numbers get escaped as code points + return ch.slice( 0, -1 ) + "\\" + + ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " "; + } + + // Other potentially-special ASCII characters get backslash-escaped + return "\\" + ch; + }, + + // Used for iframes + // See setDocument() + // Removing the function wrapper causes a "Permission Denied" + // error in IE + unloadHandler = function() { + setDocument(); + }, + + inDisabledFieldset = addCombinator( + function( elem ) { + return elem.disabled === true && elem.nodeName.toLowerCase() === "fieldset"; + }, + { dir: "parentNode", next: "legend" } + ); + +// Optimize for push.apply( _, NodeList ) +try { + push.apply( + ( arr = slice.call( preferredDoc.childNodes ) ), + preferredDoc.childNodes + ); + + // Support: Android<4.0 + // Detect silently failing push.apply + // eslint-disable-next-line no-unused-expressions + arr[ preferredDoc.childNodes.length ].nodeType; +} catch ( e ) { + push = { apply: arr.length ? + + // Leverage slice if possible + function( target, els ) { + pushNative.apply( target, slice.call( els ) ); + } : + + // Support: IE<9 + // Otherwise append directly + function( target, els ) { + var j = target.length, + i = 0; + + // Can't trust NodeList.length + while ( ( target[ j++ ] = els[ i++ ] ) ) {} + target.length = j - 1; + } + }; +} + +function Sizzle( selector, context, results, seed ) { + var m, i, elem, nid, match, groups, newSelector, + newContext = context && context.ownerDocument, + + // nodeType defaults to 9, since context defaults to document + nodeType = context ? context.nodeType : 9; + + results = results || []; + + // Return early from calls with invalid selector or context + if ( typeof selector !== "string" || !selector || + nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) { + + return results; + } + + // Try to shortcut find operations (as opposed to filters) in HTML documents + if ( !seed ) { + setDocument( context ); + context = context || document; + + if ( documentIsHTML ) { + + // If the selector is sufficiently simple, try using a "get*By*" DOM method + // (excepting DocumentFragment context, where the methods don't exist) + if ( nodeType !== 11 && ( match = rquickExpr.exec( selector ) ) ) { + + // ID selector + if ( ( m = match[ 1 ] ) ) { + + // Document context + if ( nodeType === 9 ) { + if ( ( elem = context.getElementById( m ) ) ) { + + // Support: IE, Opera, Webkit + // TODO: identify versions + // getElementById can match elements by name instead of ID + if ( elem.id === m ) { + results.push( elem ); + return results; + } + } else { + return results; + } + + // Element context + } else { + + // Support: IE, Opera, Webkit + // TODO: identify versions + // getElementById can match elements by name instead of ID + if ( newContext && ( elem = newContext.getElementById( m ) ) && + contains( context, elem ) && + elem.id === m ) { + + results.push( elem ); + return results; + } + } + + // Type selector + } else if ( match[ 2 ] ) { + push.apply( results, context.getElementsByTagName( selector ) ); + return results; + + // Class selector + } else if ( ( m = match[ 3 ] ) && support.getElementsByClassName && + context.getElementsByClassName ) { + + push.apply( results, context.getElementsByClassName( m ) ); + return results; + } + } + + // Take advantage of querySelectorAll + if ( support.qsa && + !nonnativeSelectorCache[ selector + " " ] && + ( !rbuggyQSA || !rbuggyQSA.test( selector ) ) && + + // Support: IE 8 only + // Exclude object elements + ( nodeType !== 1 || context.nodeName.toLowerCase() !== "object" ) ) { + + newSelector = selector; + newContext = context; + + // qSA considers elements outside a scoping root when evaluating child or + // descendant combinators, which is not what we want. + // In such cases, we work around the behavior by prefixing every selector in the + // list with an ID selector referencing the scope context. + // The technique has to be used as well when a leading combinator is used + // as such selectors are not recognized by querySelectorAll. + // Thanks to Andrew Dupont for this technique. + if ( nodeType === 1 && + ( rdescend.test( selector ) || rleadingCombinator.test( selector ) ) ) { + + // Expand context for sibling selectors + newContext = rsibling.test( selector ) && testContext( context.parentNode ) || + context; + + // We can use :scope instead of the ID hack if the browser + // supports it & if we're not changing the context. + if ( newContext !== context || !support.scope ) { + + // Capture the context ID, setting it first if necessary + if ( ( nid = context.getAttribute( "id" ) ) ) { + nid = nid.replace( rcssescape, fcssescape ); + } else { + context.setAttribute( "id", ( nid = expando ) ); + } + } + + // Prefix every selector in the list + groups = tokenize( selector ); + i = groups.length; + while ( i-- ) { + groups[ i ] = ( nid ? "#" + nid : ":scope" ) + " " + + toSelector( groups[ i ] ); + } + newSelector = groups.join( "," ); + } + + try { + push.apply( results, + newContext.querySelectorAll( newSelector ) + ); + return results; + } catch ( qsaError ) { + nonnativeSelectorCache( selector, true ); + } finally { + if ( nid === expando ) { + context.removeAttribute( "id" ); + } + } + } + } + } + + // All others + return select( selector.replace( rtrim, "$1" ), context, results, seed ); +} + +/** + * Create key-value caches of limited size + * @returns {function(string, object)} Returns the Object data after storing it on itself with + * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength) + * deleting the oldest entry + */ +function createCache() { + var keys = []; + + function cache( key, value ) { + + // Use (key + " ") to avoid collision with native prototype properties (see Issue #157) + if ( keys.push( key + " " ) > Expr.cacheLength ) { + + // Only keep the most recent entries + delete cache[ keys.shift() ]; + } + return ( cache[ key + " " ] = value ); + } + return cache; +} + +/** + * Mark a function for special use by Sizzle + * @param {Function} fn The function to mark + */ +function markFunction( fn ) { + fn[ expando ] = true; + return fn; +} + +/** + * Support testing using an element + * @param {Function} fn Passed the created element and returns a boolean result + */ +function assert( fn ) { + var el = document.createElement( "fieldset" ); + + try { + return !!fn( el ); + } catch ( e ) { + return false; + } finally { + + // Remove from its parent by default + if ( el.parentNode ) { + el.parentNode.removeChild( el ); + } + + // release memory in IE + el = null; + } +} + +/** + * Adds the same handler for all of the specified attrs + * @param {String} attrs Pipe-separated list of attributes + * @param {Function} handler The method that will be applied + */ +function addHandle( attrs, handler ) { + var arr = attrs.split( "|" ), + i = arr.length; + + while ( i-- ) { + Expr.attrHandle[ arr[ i ] ] = handler; + } +} + +/** + * Checks document order of two siblings + * @param {Element} a + * @param {Element} b + * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b + */ +function siblingCheck( a, b ) { + var cur = b && a, + diff = cur && a.nodeType === 1 && b.nodeType === 1 && + a.sourceIndex - b.sourceIndex; + + // Use IE sourceIndex if available on both nodes + if ( diff ) { + return diff; + } + + // Check if b follows a + if ( cur ) { + while ( ( cur = cur.nextSibling ) ) { + if ( cur === b ) { + return -1; + } + } + } + + return a ? 1 : -1; +} + +/** + * Returns a function to use in pseudos for input types + * @param {String} type + */ +function createInputPseudo( type ) { + return function( elem ) { + var name = elem.nodeName.toLowerCase(); + return name === "input" && elem.type === type; + }; +} + +/** + * Returns a function to use in pseudos for buttons + * @param {String} type + */ +function createButtonPseudo( type ) { + return function( elem ) { + var name = elem.nodeName.toLowerCase(); + return ( name === "input" || name === "button" ) && elem.type === type; + }; +} + +/** + * Returns a function to use in pseudos for :enabled/:disabled + * @param {Boolean} disabled true for :disabled; false for :enabled + */ +function createDisabledPseudo( disabled ) { + + // Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable + return function( elem ) { + + // Only certain elements can match :enabled or :disabled + // https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled + // https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled + if ( "form" in elem ) { + + // Check for inherited disabledness on relevant non-disabled elements: + // * listed form-associated elements in a disabled fieldset + // https://html.spec.whatwg.org/multipage/forms.html#category-listed + // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled + // * option elements in a disabled optgroup + // https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled + // All such elements have a "form" property. + if ( elem.parentNode && elem.disabled === false ) { + + // Option elements defer to a parent optgroup if present + if ( "label" in elem ) { + if ( "label" in elem.parentNode ) { + return elem.parentNode.disabled === disabled; + } else { + return elem.disabled === disabled; + } + } + + // Support: IE 6 - 11 + // Use the isDisabled shortcut property to check for disabled fieldset ancestors + return elem.isDisabled === disabled || + + // Where there is no isDisabled, check manually + /* jshint -W018 */ + elem.isDisabled !== !disabled && + inDisabledFieldset( elem ) === disabled; + } + + return elem.disabled === disabled; + + // Try to winnow out elements that can't be disabled before trusting the disabled property. + // Some victims get caught in our net (label, legend, menu, track), but it shouldn't + // even exist on them, let alone have a boolean value. + } else if ( "label" in elem ) { + return elem.disabled === disabled; + } + + // Remaining elements are neither :enabled nor :disabled + return false; + }; +} + +/** + * Returns a function to use in pseudos for positionals + * @param {Function} fn + */ +function createPositionalPseudo( fn ) { + return markFunction( function( argument ) { + argument = +argument; + return markFunction( function( seed, matches ) { + var j, + matchIndexes = fn( [], seed.length, argument ), + i = matchIndexes.length; + + // Match elements found at the specified indexes + while ( i-- ) { + if ( seed[ ( j = matchIndexes[ i ] ) ] ) { + seed[ j ] = !( matches[ j ] = seed[ j ] ); + } + } + } ); + } ); +} + +/** + * Checks a node for validity as a Sizzle context + * @param {Element|Object=} context + * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value + */ +function testContext( context ) { + return context && typeof context.getElementsByTagName !== "undefined" && context; +} + +// Expose support vars for convenience +support = Sizzle.support = {}; + +/** + * Detects XML nodes + * @param {Element|Object} elem An element or a document + * @returns {Boolean} True iff elem is a non-HTML XML node + */ +isXML = Sizzle.isXML = function( elem ) { + var namespace = elem && elem.namespaceURI, + docElem = elem && ( elem.ownerDocument || elem ).documentElement; + + // Support: IE <=8 + // Assume HTML when documentElement doesn't yet exist, such as inside loading iframes + // https://bugs.jquery.com/ticket/4833 + return !rhtml.test( namespace || docElem && docElem.nodeName || "HTML" ); +}; + +/** + * Sets document-related variables once based on the current document + * @param {Element|Object} [doc] An element or document object to use to set the document + * @returns {Object} Returns the current document + */ +setDocument = Sizzle.setDocument = function( node ) { + var hasCompare, subWindow, + doc = node ? node.ownerDocument || node : preferredDoc; + + // Return early if doc is invalid or already selected + // Support: IE 11+, Edge 17 - 18+ + // IE/Edge sometimes throw a "Permission denied" error when strict-comparing + // two documents; shallow comparisons work. + // eslint-disable-next-line eqeqeq + if ( doc == document || doc.nodeType !== 9 || !doc.documentElement ) { + return document; + } + + // Update global variables + document = doc; + docElem = document.documentElement; + documentIsHTML = !isXML( document ); + + // Support: IE 9 - 11+, Edge 12 - 18+ + // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936) + // Support: IE 11+, Edge 17 - 18+ + // IE/Edge sometimes throw a "Permission denied" error when strict-comparing + // two documents; shallow comparisons work. + // eslint-disable-next-line eqeqeq + if ( preferredDoc != document && + ( subWindow = document.defaultView ) && subWindow.top !== subWindow ) { + + // Support: IE 11, Edge + if ( subWindow.addEventListener ) { + subWindow.addEventListener( "unload", unloadHandler, false ); + + // Support: IE 9 - 10 only + } else if ( subWindow.attachEvent ) { + subWindow.attachEvent( "onunload", unloadHandler ); + } + } + + // Support: IE 8 - 11+, Edge 12 - 18+, Chrome <=16 - 25 only, Firefox <=3.6 - 31 only, + // Safari 4 - 5 only, Opera <=11.6 - 12.x only + // IE/Edge & older browsers don't support the :scope pseudo-class. + // Support: Safari 6.0 only + // Safari 6.0 supports :scope but it's an alias of :root there. + support.scope = assert( function( el ) { + docElem.appendChild( el ).appendChild( document.createElement( "div" ) ); + return typeof el.querySelectorAll !== "undefined" && + !el.querySelectorAll( ":scope fieldset div" ).length; + } ); + + // Support: Chrome 105 - 110+, Safari 15.4 - 16.3+ + // Make sure the the `:has()` argument is parsed unforgivingly. + // We include `*` in the test to detect buggy implementations that are + // _selectively_ forgiving (specifically when the list includes at least + // one valid selector). + // Note that we treat complete lack of support for `:has()` as if it were + // spec-compliant support, which is fine because use of `:has()` in such + // environments will fail in the qSA path and fall back to jQuery traversal + // anyway. + support.cssHas = assert( function() { + try { + document.querySelector( ":has(*,:jqfake)" ); + return false; + } catch ( e ) { + return true; + } + } ); + + /* Attributes + ---------------------------------------------------------------------- */ + + // Support: IE<8 + // Verify that getAttribute really returns attributes and not properties + // (excepting IE8 booleans) + support.attributes = assert( function( el ) { + el.className = "i"; + return !el.getAttribute( "className" ); + } ); + + /* getElement(s)By* + ---------------------------------------------------------------------- */ + + // Check if getElementsByTagName("*") returns only elements + support.getElementsByTagName = assert( function( el ) { + el.appendChild( document.createComment( "" ) ); + return !el.getElementsByTagName( "*" ).length; + } ); + + // Support: IE<9 + support.getElementsByClassName = rnative.test( document.getElementsByClassName ); + + // Support: IE<10 + // Check if getElementById returns elements by name + // The broken getElementById methods don't pick up programmatically-set names, + // so use a roundabout getElementsByName test + support.getById = assert( function( el ) { + docElem.appendChild( el ).id = expando; + return !document.getElementsByName || !document.getElementsByName( expando ).length; + } ); + + // ID filter and find + if ( support.getById ) { + Expr.filter[ "ID" ] = function( id ) { + var attrId = id.replace( runescape, funescape ); + return function( elem ) { + return elem.getAttribute( "id" ) === attrId; + }; + }; + Expr.find[ "ID" ] = function( id, context ) { + if ( typeof context.getElementById !== "undefined" && documentIsHTML ) { + var elem = context.getElementById( id ); + return elem ? [ elem ] : []; + } + }; + } else { + Expr.filter[ "ID" ] = function( id ) { + var attrId = id.replace( runescape, funescape ); + return function( elem ) { + var node = typeof elem.getAttributeNode !== "undefined" && + elem.getAttributeNode( "id" ); + return node && node.value === attrId; + }; + }; + + // Support: IE 6 - 7 only + // getElementById is not reliable as a find shortcut + Expr.find[ "ID" ] = function( id, context ) { + if ( typeof context.getElementById !== "undefined" && documentIsHTML ) { + var node, i, elems, + elem = context.getElementById( id ); + + if ( elem ) { + + // Verify the id attribute + node = elem.getAttributeNode( "id" ); + if ( node && node.value === id ) { + return [ elem ]; + } + + // Fall back on getElementsByName + elems = context.getElementsByName( id ); + i = 0; + while ( ( elem = elems[ i++ ] ) ) { + node = elem.getAttributeNode( "id" ); + if ( node && node.value === id ) { + return [ elem ]; + } + } + } + + return []; + } + }; + } + + // Tag + Expr.find[ "TAG" ] = support.getElementsByTagName ? + function( tag, context ) { + if ( typeof context.getElementsByTagName !== "undefined" ) { + return context.getElementsByTagName( tag ); + + // DocumentFragment nodes don't have gEBTN + } else if ( support.qsa ) { + return context.querySelectorAll( tag ); + } + } : + + function( tag, context ) { + var elem, + tmp = [], + i = 0, + + // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too + results = context.getElementsByTagName( tag ); + + // Filter out possible comments + if ( tag === "*" ) { + while ( ( elem = results[ i++ ] ) ) { + if ( elem.nodeType === 1 ) { + tmp.push( elem ); + } + } + + return tmp; + } + return results; + }; + + // Class + Expr.find[ "CLASS" ] = support.getElementsByClassName && function( className, context ) { + if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) { + return context.getElementsByClassName( className ); + } + }; + + /* QSA/matchesSelector + ---------------------------------------------------------------------- */ + + // QSA and matchesSelector support + + // matchesSelector(:active) reports false when true (IE9/Opera 11.5) + rbuggyMatches = []; + + // qSa(:focus) reports false when true (Chrome 21) + // We allow this because of a bug in IE8/9 that throws an error + // whenever `document.activeElement` is accessed on an iframe + // So, we allow :focus to pass through QSA all the time to avoid the IE error + // See https://bugs.jquery.com/ticket/13378 + rbuggyQSA = []; + + if ( ( support.qsa = rnative.test( document.querySelectorAll ) ) ) { + + // Build QSA regex + // Regex strategy adopted from Diego Perini + assert( function( el ) { + + var input; + + // Select is set to empty string on purpose + // This is to test IE's treatment of not explicitly + // setting a boolean content attribute, + // since its presence should be enough + // https://bugs.jquery.com/ticket/12359 + docElem.appendChild( el ).innerHTML = "" + + ""; + + // Support: IE8, Opera 11-12.16 + // Nothing should be selected when empty strings follow ^= or $= or *= + // The test attribute must be unknown in Opera but "safe" for WinRT + // https://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section + if ( el.querySelectorAll( "[msallowcapture^='']" ).length ) { + rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" ); + } + + // Support: IE8 + // Boolean attributes and "value" are not treated correctly + if ( !el.querySelectorAll( "[selected]" ).length ) { + rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" ); + } + + // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+ + if ( !el.querySelectorAll( "[id~=" + expando + "-]" ).length ) { + rbuggyQSA.push( "~=" ); + } + + // Support: IE 11+, Edge 15 - 18+ + // IE 11/Edge don't find elements on a `[name='']` query in some cases. + // Adding a temporary attribute to the document before the selection works + // around the issue. + // Interestingly, IE 10 & older don't seem to have the issue. + input = document.createElement( "input" ); + input.setAttribute( "name", "" ); + el.appendChild( input ); + if ( !el.querySelectorAll( "[name='']" ).length ) { + rbuggyQSA.push( "\\[" + whitespace + "*name" + whitespace + "*=" + + whitespace + "*(?:''|\"\")" ); + } + + // Webkit/Opera - :checked should return selected option elements + // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked + // IE8 throws error here and will not see later tests + if ( !el.querySelectorAll( ":checked" ).length ) { + rbuggyQSA.push( ":checked" ); + } + + // Support: Safari 8+, iOS 8+ + // https://bugs.webkit.org/show_bug.cgi?id=136851 + // In-page `selector#id sibling-combinator selector` fails + if ( !el.querySelectorAll( "a#" + expando + "+*" ).length ) { + rbuggyQSA.push( ".#.+[+~]" ); + } + + // Support: Firefox <=3.6 - 5 only + // Old Firefox doesn't throw on a badly-escaped identifier. + el.querySelectorAll( "\\\f" ); + rbuggyQSA.push( "[\\r\\n\\f]" ); + } ); + + assert( function( el ) { + el.innerHTML = "" + + ""; + + // Support: Windows 8 Native Apps + // The type and name attributes are restricted during .innerHTML assignment + var input = document.createElement( "input" ); + input.setAttribute( "type", "hidden" ); + el.appendChild( input ).setAttribute( "name", "D" ); + + // Support: IE8 + // Enforce case-sensitivity of name attribute + if ( el.querySelectorAll( "[name=d]" ).length ) { + rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" ); + } + + // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled) + // IE8 throws error here and will not see later tests + if ( el.querySelectorAll( ":enabled" ).length !== 2 ) { + rbuggyQSA.push( ":enabled", ":disabled" ); + } + + // Support: IE9-11+ + // IE's :disabled selector does not pick up the children of disabled fieldsets + docElem.appendChild( el ).disabled = true; + if ( el.querySelectorAll( ":disabled" ).length !== 2 ) { + rbuggyQSA.push( ":enabled", ":disabled" ); + } + + // Support: Opera 10 - 11 only + // Opera 10-11 does not throw on post-comma invalid pseudos + el.querySelectorAll( "*,:x" ); + rbuggyQSA.push( ",.*:" ); + } ); + } + + if ( ( support.matchesSelector = rnative.test( ( matches = docElem.matches || + docElem.webkitMatchesSelector || + docElem.mozMatchesSelector || + docElem.oMatchesSelector || + docElem.msMatchesSelector ) ) ) ) { + + assert( function( el ) { + + // Check to see if it's possible to do matchesSelector + // on a disconnected node (IE 9) + support.disconnectedMatch = matches.call( el, "*" ); + + // This should fail with an exception + // Gecko does not error, returns false instead + matches.call( el, "[s!='']:x" ); + rbuggyMatches.push( "!=", pseudos ); + } ); + } + + if ( !support.cssHas ) { + + // Support: Chrome 105 - 110+, Safari 15.4 - 16.3+ + // Our regular `try-catch` mechanism fails to detect natively-unsupported + // pseudo-classes inside `:has()` (such as `:has(:contains("Foo"))`) + // in browsers that parse the `:has()` argument as a forgiving selector list. + // https://drafts.csswg.org/selectors/#relational now requires the argument + // to be parsed unforgivingly, but browsers have not yet fully adjusted. + rbuggyQSA.push( ":has" ); + } + + rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join( "|" ) ); + rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join( "|" ) ); + + /* Contains + ---------------------------------------------------------------------- */ + hasCompare = rnative.test( docElem.compareDocumentPosition ); + + // Element contains another + // Purposefully self-exclusive + // As in, an element does not contain itself + contains = hasCompare || rnative.test( docElem.contains ) ? + function( a, b ) { + + // Support: IE <9 only + // IE doesn't have `contains` on `document` so we need to check for + // `documentElement` presence. + // We need to fall back to `a` when `documentElement` is missing + // as `ownerDocument` of elements within `