Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
ositoMalvado committed Jul 25, 2024
1 parent 7527181 commit fda9609
Show file tree
Hide file tree
Showing 10 changed files with 303 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ __pycache__/
.Python
build/
develop-eggs/
dist/
# dist/
downloads/
eggs/
.eggs/
Expand Down
20 changes: 20 additions & 0 deletions Funciones.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
def github_to_raw(url):
# Dividir la URL en partes
parts = url.split('/')

# Verificar si es una URL de GitHub
if 'github.com' not in parts:
return "La URL proporcionada no es de GitHub"

# Encontrar el índice de 'github.com' en la URL
github_index = parts.index('github.com')

# Construir la nueva URL
raw_url = 'https://raw.githubusercontent.com'

# Agregar el resto de la ruta, saltando 'github.com' y eliminando 'blob' si está presente
for part in parts[github_index + 1:]:
if part != 'blob':
raw_url += '/' + part

return raw_url
153 changes: 153 additions & 0 deletions Tabs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
import flet as ft
from Widgets import CalculadoraPremio

class TabFederacionFranquicias(ft.Tab):

franquicias = [
{"tipo": "Auto", "porcentaje": "1%", "Monto": "$300.000"},
{"tipo": "Auto", "porcentaje": "2%", "Monto": "$400.000"},
{"tipo": "Auto", "porcentaje": "4%", "Monto": "$500.000"},
{"tipo": "Auto", "porcentaje": "6%", "Monto": "$630.000"},
{"tipo": "Camiones", "porcentaje": "2%", "Monto": "$1.150.000"},
{"tipo": "Acoplados", "porcentaje": "2%", "Monto": "$870.000"},
]


def __init__(self):
super().__init__()
self.text = "Franquicias"
self.mi_data_table = ft.DataTable(
columns=[
ft.DataColumn(ft.Text("Tipo de Vehículo", weight=ft.FontWeight.BOLD), tooltip="Tipo de Vehículo"),
ft.DataColumn(ft.Text("% Suma Asegurada", weight=ft.FontWeight.BOLD), tooltip="% Suma Asegurada"),
ft.DataColumn(ft.Text("Monto mínimo de Franquicia", weight=ft.FontWeight.BOLD), tooltip="Monto mínimo de Franquicia"),
],
rows=[],
)

for i, franquicia in enumerate(self.franquicias):
self.mi_data_table.rows.append(
ft.DataRow(
cells=[
ft.DataCell(ft.Text(franquicia["tipo"], weight=ft.FontWeight.BOLD)),
ft.DataCell(ft.Text(franquicia["porcentaje"])),
ft.DataCell(ft.Text(franquicia["Monto"])),
],
color=ft.colors.BLACK12 if i % 2 == 0 else None
)
)
self.expand = True
self.content = ft.Column(
controls=[
ft.Container(height=5),
ft.Container(
self.mi_data_table,
border_radius=10,
border=ft.border.all(1, ft.colors.BLACK12),
bgcolor=ft.colors.PRIMARY_CONTAINER
)
],
spacing=0,
horizontal_alignment=ft.CrossAxisAlignment.CENTER,
scroll="auto",
expand=True
)

class TabGeneralPatentes(ft.Tab):

patentes = {
"AG450AA": "Enero 2024",
"AG300AA": "Octubre 2023",
"AG000AA": "Mayo 2023",
"AF770AA": "Enero 2023",
"AF600AA": "Octubre 2022",
"AF000AA": "Agosto 2021",
"AE600AA": "Enero 2021",
"AE100AA": "Enero 2020",
"AE000AA": "Octubre 2019",
"AD400AA": "Enero 2019",
"AD000AA": "Julio 2018",
"AC200AA": "Enero 2018",
"AC000AA": "Noviembre 2017",
"AB000AA": "Febrero 2017",
"AA900AA": "Enero 2017",
"AA000AA": "Abril 2016",
"PMA000": "2016",
"ONA000": "2015",
"NMA000": "2014",
"MBA000": "2013",
"KUA000": "2012",
"JNA000": "2011",
"IMA000": "2010",
"HTA000": "2009",
"GVA000": "2008",
"GBA000": "2007",
"FIA000": "2006",
"ETA000": "2005",
"EIA000": "2004",
"EDA000": "2003",
"DXA000": "2002",
"DOA000": "2001",
"DCA000": "2000",
"CMA000": "1999",
"BUA000": "1998",
"BDA000": "1997",
"APA000": "1996",
"AAA000": "1995",
}

def __init__(self):
super().__init__()
self.text = "Año de auto por patente"
self.mi_data_table = ft.DataTable(
columns=[
ft.DataColumn(ft.Text("Patente", weight=ft.FontWeight.BOLD), tooltip="Patente"),
ft.DataColumn(ft.Text("Año", weight=ft.FontWeight.BOLD), tooltip="Año"),
],
rows=[],
)
for i, patente in enumerate(self.patentes):
self.mi_data_table.rows.append(
ft.DataRow(
cells=[
ft.DataCell(ft.Text(patente, weight=ft.FontWeight.BOLD)),
ft.DataCell(ft.Text(self.patentes[patente])),
],
color=ft.colors.BLACK12 if i % 2 == 0 else None
)
)

self.expand = True
self.content = ft.Column(
controls=[
ft.Container(height=5),
ft.Container(
self.mi_data_table,
border_radius=10,
border=ft.border.all(1, ft.colors.BLACK12),
bgcolor=ft.colors.PRIMARY_CONTAINER
)
],
spacing=0,
horizontal_alignment=ft.CrossAxisAlignment.CENTER,
scroll="auto",
expand=True
)

class TabRioUruguayPremio(ft.Tab):

def __init__(self):
super().__init__()
self.text = "Premio"

self.expand = True
self.content = ft.Column(
controls=[
ft.Container(height=5),
CalculadoraPremio()
],
spacing=0,
horizontal_alignment=ft.CrossAxisAlignment.CENTER,
scroll="auto",
expand=True
)
63 changes: 63 additions & 0 deletions Widgets.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import flet as ft
import math
class CalculadoraPremio(ft.Container):


def update_premio(self, e):
# Aplicar el descuento del 15%
# Actualizar el valor en la interfaz
if final_value and self.text_field_premio.value:
discounted_value = float(self.text_field_premio.value) * 0.85

# Redondear al múltiplo de 300 más cercano, siempre hacia arriba
rounded_value = math.ceil(discounted_value / 300) * 300

# Asegurarse de que el valor redondeado no sea menor que el valor descontado
final_value = max(rounded_value, math.ceil(discounted_value))

self.valor_final.value = str(int(final_value))
else:
self.valor_final.value = "0"
self.valor_final.update()

def __init__(self):
super().__init__()

self.valor_final = ft.Text("0")

self.text_field_premio = ft.TextField(
label="Premio",
prefix_icon=ft.icons.ATTACH_MONEY_ROUNDED,
hint_text="Ingresa el premio",
on_change=self.update_premio
)
self.boton_copiar = ft.ElevatedButton(
content=ft.Row(
[
ft.Icon(ft.icons.ATTACH_MONEY_ROUNDED),
self.valor_final,
],
alignment=ft.MainAxisAlignment.SPACE_BETWEEN,
),
tooltip="Copiar premio con descuento",
)
self.content = ft.Column(
controls=[
ft.Text("Calculadora de Premio"),
self.text_field_premio,
self.boton_copiar
]
)
self.border_radius=10
self.border=ft.border.all(1, ft.colors.BLACK12)
self.bgcolor=ft.colors.PRIMARY_CONTAINER
self.width=500
self.padding=10


def main(page: ft.Page):
page.add(CalculadoraPremio())


if __name__ == "__main__":
ft.app(target=main)
Binary file added assets/favicon.ico
Binary file not shown.
Binary file added assets/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/marzo24.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added favicon.ico
Binary file not shown.
Binary file added favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
69 changes: 66 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,71 @@
import flet as ft

from Tabs import *
from Funciones import *
import random

def main(page: ft.Page):
page.add(ft.SafeArea(ft.Text("Te amo ana")))

page.horizontal_alignment = ft.CrossAxisAlignment.CENTER
page.padding = 0

page.fonts = {
"Sans": github_to_raw("https://github.com/chrisbull/font-collection/raw/master/GoogleSans/GoogleSans-Regular.ttf")
}

page.theme = ft.Theme(
font_family="Sans"
)

def change_color():
random_color = "#%02x%02x%02x" % (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255))
page.theme = ft.Theme(
color_scheme_seed=random_color
)
page.update()
change_color()

page.add(
ft.Tabs(
[
ft.Tab(
text="Federación Patronal",
content=ft.Tabs(
[
TabFederacionFranquicias()
],
tab_alignment=ft.TabAlignment.CENTER,
expand=True,
scrollable=True
)
),
ft.Tab(
text="Río Uruguay",
content=ft.Tabs(
[
TabRioUruguayPremio()
],
tab_alignment=ft.TabAlignment.CENTER,
expand=True,
scrollable=True
)
),
ft.Tab(
text="General",
content=ft.Tabs(
[
TabGeneralPatentes()
],
tab_alignment=ft.TabAlignment.CENTER,
expand=True,
scrollable=True
)
)
],
tab_alignment=ft.TabAlignment.CENTER,
expand=True
)
)



ft.app(main, view=ft.WEB_BROWSER)
ft.app(main, assets_dir="assets", view=ft.AppView.WEB_BROWSER)

0 comments on commit fda9609

Please sign in to comment.