Conditions | 1 |
Total Lines | 80 |
Code Lines | 61 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | from datetime import date, timedelta |
||
17 | def make_layout(): |
||
18 | # LAYOUT |
||
19 | button_column = [ |
||
20 | sg.Button("Preparar Facturas", key="prepare_facturas"), |
||
21 | sg.Text("Año-Mes:", pad=TEXT_PADDING), |
||
22 | sg.Input(date.today().strftime('%Y-%m'), size=(8, 1), key="periodo", change_submits=True), |
||
23 | sg.Text("De La:", pad=TEXT_PADDING), |
||
24 | sg.Input("1", key="inicio", size=(4, 1), change_submits=True), |
||
25 | sg.Text("Hasta:", pad=TEXT_PADDING), |
||
26 | sg.Input("", key="final", size=(4, 1), change_submits=True), |
||
27 | ] |
||
28 | |||
29 | c_second = [ |
||
30 | sg.Column( |
||
31 | [ |
||
32 | [ |
||
33 | sg.Text("Factura:", pad=TEXT_PADDING), |
||
34 | sg.Input("", size=(30, 1), key="factura_pagar", change_submits=True), |
||
35 | ], |
||
36 | [ |
||
37 | sg.Button("Status", key="status_sat"), |
||
38 | sg.Button("Descarga", key="descarga"), |
||
39 | sg.Button("Pago PUE", key="pago_pue"), |
||
40 | ] |
||
41 | ], |
||
42 | pad=0 |
||
43 | ), |
||
44 | sg.VSeparator(), |
||
45 | sg.Column( |
||
46 | [ |
||
47 | [ |
||
48 | sg.CalendarButton("FechaPago:", format='%Y-%m-%d', title="FechaPago", no_titlebar=False, target="fecha_pago", pad=TEXT_PADDING), |
||
49 | sg.Input("", size=(12, 1), key="fecha_pago", change_submits=True), |
||
50 | sg.Text("FormaPago:", pad=TEXT_PADDING), |
||
51 | sg.Combo([Code(k, v) for k, v in FORMA_PAGO.items()], default_value=Code("03", FORMA_PAGO["03"]), key="forma_pago", change_submits=True, size=(34, 1)) |
||
52 | ], |
||
53 | [ |
||
54 | sg.Button("Comprobante Pago", key="prepare_pago"), |
||
55 | ] |
||
56 | ], |
||
57 | pad=0 |
||
58 | ) |
||
59 | ] |
||
60 | |||
61 | button_column_third = [ |
||
62 | sg.Button("Preparar Correos", key="prepare_correos"), |
||
63 | sg.Button("Facturas Pendientes", key="facturas_pendientes"), |
||
64 | sg.Checkbox("Ver Detallado", default=False, key="detallado"), |
||
65 | sg.VSeparator(), |
||
66 | sg.Button("Ajuste Anual", key="preparar_ajuste_anual"), |
||
67 | sg.Text("Año-Mes:", pad=TEXT_PADDING), |
||
68 | sg.Input((date.today() + timedelta(days=31)).strftime('%Y-%m'), size=(8, 1), key="anio_mes_ajuste"), |
||
69 | sg.Text("Ajuste:", pad=TEXT_PADDING), |
||
70 | sg.Input("", size=(6, 1), key="ajuste_porcentaje"), |
||
71 | sg.Text("%", pad=RTEXT_PADDING), |
||
72 | sg.VSeparator(), |
||
73 | sg.Text("Recuperar:", pad=TEXT_PADDING), |
||
74 | sg.Button("Emitidas", key="recuperar_emitidas"), |
||
75 | sg.Button("Recibidas", key="recuperar_recibidas"), |
||
76 | sg.Text("Dias:", pad=TEXT_PADDING), |
||
77 | sg.Input("40", size=(4, 1), key="recuperar_dias"), |
||
78 | ] |
||
79 | |||
80 | button_column_low = [ |
||
81 | sg.Button("Validar Clientes", key="validate_clientes"), |
||
82 | sg.Button("Crear Facturas", disabled=True, key="crear_facturas"), |
||
83 | sg.Button("Enviar Correos", disabled=True, key="enviar_correos"), |
||
84 | sg.Button("Confirmar Pago", disabled=True, key="confirm_pago_button"), |
||
85 | |||
86 | ] |
||
87 | |||
88 | # ----- Full layout ----- |
||
89 | return [ |
||
90 | button_column, |
||
91 | [sg.HSeparator()], |
||
92 | c_second, |
||
93 | [sg.HSeparator()], |
||
94 | button_column_third, |
||
95 | [sg.Output(expand_x=True, expand_y=True, key="console")], |
||
96 | button_column_low |
||
97 | ] |
||
174 |