Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -701,6 +701,40 @@ def process_iptu_data(
|
|
701 |
return ("Processamento concluído.", df_resumo_iptu, result_agg, total_novo_str, total_atual_trib_str, total_atual_calc_str,
|
702 |
gr.Textbox(value=filename_text, visible=bool(filename_text)), download_button_result)
|
703 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
704 |
|
705 |
# --- Gradio Interface ---
|
706 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
@@ -744,48 +778,50 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
744 |
pg_defaults_lim = [25000, 60000, 100000, 140000, 200000, 300000, 600000]
|
745 |
pg_defaults_aliq = [0.0, 0.004, 0.0047, 0.0055, 0.0062, 0.007, 0.0077, 0.0085]
|
746 |
|
747 |
-
|
|
|
748 |
pg_inputs = create_8_band_inputs("PG", pg_defaults_lim, pg_defaults_aliq)
|
749 |
all_rate_inputs.extend(pg_inputs)
|
750 |
|
751 |
-
with gr.Accordion("Predial Residencial (PR)", open=False):
|
752 |
pr_inputs = create_8_band_inputs("PR", pg_defaults_lim, pg_defaults_aliq)
|
753 |
all_rate_inputs.extend(pr_inputs)
|
754 |
|
755 |
-
with gr.Accordion("Predial Não Residencial (PNR)", open=False):
|
756 |
pnr_inputs = create_8_band_inputs("PNR", pg_defaults_lim, pg_defaults_aliq)
|
757 |
all_rate_inputs.extend(pnr_inputs)
|
758 |
|
759 |
-
with gr.Accordion("Estacionamentos Geral (EG)", open=False):
|
760 |
eg_inputs = create_8_band_inputs("EG", pg_defaults_lim, pg_defaults_aliq)
|
761 |
all_rate_inputs.extend(eg_inputs)
|
762 |
|
763 |
-
with gr.Accordion("Estacionamentos Residenciais (ER)", open=False):
|
764 |
er_inputs = create_8_band_inputs("ER", pg_defaults_lim, pg_defaults_aliq)
|
765 |
all_rate_inputs.extend(er_inputs)
|
766 |
|
767 |
-
with gr.Accordion("Estacionamentos Não Residenciais (ENR)", open=False):
|
768 |
enr_inputs = create_8_band_inputs("ENR", pg_defaults_lim, pg_defaults_aliq)
|
769 |
all_rate_inputs.extend(enr_inputs)
|
770 |
|
771 |
t_df_defaults_lim = 15000
|
772 |
-
with gr.Accordion("Terrenos 1a DF (T1DF)", open=False):
|
773 |
t1df_inputs = create_2_band_inputs("T1DF", t_df_defaults_lim, [0.0, 0.03])
|
774 |
all_rate_inputs.extend(t1df_inputs)
|
775 |
|
776 |
-
with gr.Accordion("Terrenos 2a DF (T2DF)", open=False):
|
777 |
t2df_inputs = create_2_band_inputs("T2DF", t_df_defaults_lim, [0.0, 0.02])
|
778 |
all_rate_inputs.extend(t2df_inputs)
|
779 |
|
780 |
-
with gr.Accordion("Terrenos 3a DF (T3DF)", open=False):
|
781 |
t3df_inputs = create_2_band_inputs("T3DF", t_df_defaults_lim, [0.0, 0.01])
|
782 |
all_rate_inputs.extend(t3df_inputs)
|
783 |
|
784 |
-
|
|
|
785 |
tae_alq1_input = gr.Number(label="TAE Alíquota 1 (ex: 0.009)", value=0.009)
|
786 |
all_rate_inputs.append(tae_alq1_input)
|
787 |
|
788 |
-
with gr.Accordion("Terrenos Alíquota Fixa (TAF)", open=False):
|
789 |
taf_alq1_input = gr.Number(label="TAF Alíquota 1 (ex: 0.0095)", value=0.0095)
|
790 |
all_rate_inputs.append(taf_alq1_input)
|
791 |
|
@@ -808,6 +844,19 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
808 |
filename_display = gr.Textbox(label="Arquivo gerado", interactive=False, visible=False)
|
809 |
download_btn = gr.DownloadButton(label="Download", visible=False)
|
810 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
811 |
click_inputs = [
|
812 |
valor_venal_dropdown, ufm_input,
|
813 |
diferencia_estacionamentos_check, diferencia_predios_check
|
@@ -1027,6 +1076,11 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
1027 |
- **📋 Resumo Agregado**: Totais por categoria principal
|
1028 |
- **💰 Totais Gerais**: Sumário dos valores calculados
|
1029 |
- **⚙️ Parâmetros Utilizados**: Configurações completas (reimportáveis)
|
|
|
|
|
|
|
|
|
|
|
1030 |
""")
|
1031 |
|
1032 |
if __name__ == "__main__":
|
|
|
701 |
return ("Processamento concluído.", df_resumo_iptu, result_agg, total_novo_str, total_atual_trib_str, total_atual_calc_str,
|
702 |
gr.Textbox(value=filename_text, visible=bool(filename_text)), download_button_result)
|
703 |
|
704 |
+
# Functions to handle field visibility
|
705 |
+
def update_parking_visibility(diferencia_estacionamentos):
|
706 |
+
"""Update visibility of parking fields based on differentiation checkbox"""
|
707 |
+
if diferencia_estacionamentos:
|
708 |
+
# Hide EG, show ER and ENR
|
709 |
+
return [
|
710 |
+
gr.Accordion(visible=False), # EG
|
711 |
+
gr.Accordion(visible=True), # ER
|
712 |
+
gr.Accordion(visible=True) # ENR
|
713 |
+
]
|
714 |
+
else:
|
715 |
+
# Show EG, hide ER and ENR
|
716 |
+
return [
|
717 |
+
gr.Accordion(visible=True), # EG
|
718 |
+
gr.Accordion(visible=False), # ER
|
719 |
+
gr.Accordion(visible=False) # ENR
|
720 |
+
]
|
721 |
+
|
722 |
+
def update_building_visibility(diferencia_predios):
|
723 |
+
"""Update visibility of building fields based on differentiation checkbox"""
|
724 |
+
if diferencia_predios:
|
725 |
+
# Hide PG, show PR and PNR
|
726 |
+
return [
|
727 |
+
gr.Accordion(visible=False), # PG
|
728 |
+
gr.Accordion(visible=True), # PR
|
729 |
+
gr.Accordion(visible=True) # PNR
|
730 |
+
]
|
731 |
+
else:
|
732 |
+
# Show PG, hide PR and PNR
|
733 |
+
return [
|
734 |
+
gr.Accordion(visible=True), # PG
|
735 |
+
gr.Accordion(visible=False), # PR
|
736 |
+
gr.Accordion(visible=False) # PNR
|
737 |
+
]
|
738 |
|
739 |
# --- Gradio Interface ---
|
740 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
|
778 |
pg_defaults_lim = [25000, 60000, 100000, 140000, 200000, 300000, 600000]
|
779 |
pg_defaults_aliq = [0.0, 0.004, 0.0047, 0.0055, 0.0062, 0.007, 0.0077, 0.0085]
|
780 |
|
781 |
+
# Create accordions with visibility control
|
782 |
+
with gr.Accordion("Predial Geral (PG)", open=False, visible=True) as pg_accordion:
|
783 |
pg_inputs = create_8_band_inputs("PG", pg_defaults_lim, pg_defaults_aliq)
|
784 |
all_rate_inputs.extend(pg_inputs)
|
785 |
|
786 |
+
with gr.Accordion("Predial Residencial (PR)", open=False, visible=False) as pr_accordion:
|
787 |
pr_inputs = create_8_band_inputs("PR", pg_defaults_lim, pg_defaults_aliq)
|
788 |
all_rate_inputs.extend(pr_inputs)
|
789 |
|
790 |
+
with gr.Accordion("Predial Não Residencial (PNR)", open=False, visible=False) as pnr_accordion:
|
791 |
pnr_inputs = create_8_band_inputs("PNR", pg_defaults_lim, pg_defaults_aliq)
|
792 |
all_rate_inputs.extend(pnr_inputs)
|
793 |
|
794 |
+
with gr.Accordion("Estacionamentos Geral (EG)", open=False, visible=True) as eg_accordion:
|
795 |
eg_inputs = create_8_band_inputs("EG", pg_defaults_lim, pg_defaults_aliq)
|
796 |
all_rate_inputs.extend(eg_inputs)
|
797 |
|
798 |
+
with gr.Accordion("Estacionamentos Residenciais (ER)", open=False, visible=False) as er_accordion:
|
799 |
er_inputs = create_8_band_inputs("ER", pg_defaults_lim, pg_defaults_aliq)
|
800 |
all_rate_inputs.extend(er_inputs)
|
801 |
|
802 |
+
with gr.Accordion("Estacionamentos Não Residenciais (ENR)", open=False, visible=False) as enr_accordion:
|
803 |
enr_inputs = create_8_band_inputs("ENR", pg_defaults_lim, pg_defaults_aliq)
|
804 |
all_rate_inputs.extend(enr_inputs)
|
805 |
|
806 |
t_df_defaults_lim = 15000
|
807 |
+
with gr.Accordion("Terrenos 1a DF (T1DF)", open=False) as t1df_accordion:
|
808 |
t1df_inputs = create_2_band_inputs("T1DF", t_df_defaults_lim, [0.0, 0.03])
|
809 |
all_rate_inputs.extend(t1df_inputs)
|
810 |
|
811 |
+
with gr.Accordion("Terrenos 2a DF (T2DF)", open=False) as t2df_accordion:
|
812 |
t2df_inputs = create_2_band_inputs("T2DF", t_df_defaults_lim, [0.0, 0.02])
|
813 |
all_rate_inputs.extend(t2df_inputs)
|
814 |
|
815 |
+
with gr.Accordion("Terrenos 3a DF (T3DF)", open=False) as t3df_accordion:
|
816 |
t3df_inputs = create_2_band_inputs("T3DF", t_df_defaults_lim, [0.0, 0.01])
|
817 |
all_rate_inputs.extend(t3df_inputs)
|
818 |
|
819 |
+
# TAE and TAF are always hidden as requested
|
820 |
+
with gr.Accordion("Terrenos Alíquota Especial (TAE)", open=False, visible=False) as tae_accordion:
|
821 |
tae_alq1_input = gr.Number(label="TAE Alíquota 1 (ex: 0.009)", value=0.009)
|
822 |
all_rate_inputs.append(tae_alq1_input)
|
823 |
|
824 |
+
with gr.Accordion("Terrenos Alíquota Fixa (TAF)", open=False, visible=False) as taf_accordion:
|
825 |
taf_alq1_input = gr.Number(label="TAF Alíquota 1 (ex: 0.0095)", value=0.0095)
|
826 |
all_rate_inputs.append(taf_alq1_input)
|
827 |
|
|
|
844 |
filename_display = gr.Textbox(label="Arquivo gerado", interactive=False, visible=False)
|
845 |
download_btn = gr.DownloadButton(label="Download", visible=False)
|
846 |
|
847 |
+
# Set up visibility change handlers
|
848 |
+
diferencia_estacionamentos_check.change(
|
849 |
+
fn=update_parking_visibility,
|
850 |
+
inputs=[diferencia_estacionamentos_check],
|
851 |
+
outputs=[eg_accordion, er_accordion, enr_accordion]
|
852 |
+
)
|
853 |
+
|
854 |
+
diferencia_predios_check.change(
|
855 |
+
fn=update_building_visibility,
|
856 |
+
inputs=[diferencia_predios_check],
|
857 |
+
outputs=[pg_accordion, pr_accordion, pnr_accordion]
|
858 |
+
)
|
859 |
+
|
860 |
click_inputs = [
|
861 |
valor_venal_dropdown, ufm_input,
|
862 |
diferencia_estacionamentos_check, diferencia_predios_check
|
|
|
1076 |
- **📋 Resumo Agregado**: Totais por categoria principal
|
1077 |
- **💰 Totais Gerais**: Sumário dos valores calculados
|
1078 |
- **⚙️ Parâmetros Utilizados**: Configurações completas (reimportáveis)
|
1079 |
+
|
1080 |
+
### 🎛️ Controles de Visibilidade:
|
1081 |
+
- **Estacionamentos**: Marque "Diferenciar por Uso" para mostrar campos ER/ENR em vez de EG
|
1082 |
+
- **Prédios**: Marque "Diferenciar por Uso" para mostrar campos PR/PNR em vez de PG
|
1083 |
+
- **TAE/TAF**: Campos sempre ocultos (configurados internamente)
|
1084 |
""")
|
1085 |
|
1086 |
if __name__ == "__main__":
|