Conditions | 1 |
Total Lines | 85 |
Code Lines | 67 |
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 |
||
18 | def make_layout(has_fiel): |
||
19 | # LAYOUT |
||
20 | button_column = [ |
||
21 | sg.Button("Preparar Facturas", key="prepare_facturas", border_width=0), |
||
22 | sg.Text("Año-Mes:", pad=TEXT_PADDING), |
||
23 | sg.Input(date.today().strftime('%Y-%m'), size=(8, 1), key="periodo", change_submits=True), |
||
24 | sg.Text("De La:", pad=TEXT_PADDING), |
||
25 | sg.Input("1", key="inicio", size=(4, 1), change_submits=True), |
||
26 | sg.Text("Hasta:", pad=TEXT_PADDING), |
||
27 | sg.Input("", key="final", size=(4, 1), change_submits=True), |
||
28 | sg.Text(" ", pad=TEXT_PADDING), |
||
29 | sg.Button("Exportar Excel", key="exportar_facturas", border_width=0), |
||
30 | sg.Button("Ver Excel", key="ver_excel", border_width=0), |
||
31 | ] |
||
32 | |||
33 | c_second = [ |
||
34 | sg.Column( |
||
35 | [ |
||
36 | [ |
||
37 | sg.Button("Buscar:", key="buscar_factura", border_width=0, pad=TEXT_PADDING), |
||
38 | sg.Input("", size=(40, 1), key="factura_pagar", change_submits=True), |
||
39 | sg.Button("Descarga", key="descarga", border_width=0, disabled=True), |
||
40 | ], |
||
41 | [ |
||
42 | sg.Button("Status SAT", key="status_sat", border_width=0, disabled=True), |
||
43 | sg.Button("PUE Pagada", key="pago_pue", border_width=0, disabled=True), |
||
44 | sg.Button("PPD Ignorar", key="ignorar_ppd", border_width=0, disabled=True), |
||
45 | sg.Button("Email Notificada", key="email_notificada", border_width=0, disabled=True), |
||
46 | sg.Button("Ver PDF", key="ver_factura", border_width=0, disabled=True), |
||
47 | ] |
||
48 | ], |
||
49 | pad=0 |
||
50 | ), |
||
51 | sg.VSeparator(), |
||
52 | sg.Column( |
||
53 | [ |
||
54 | [ |
||
55 | sg.CalendarButton("FechaPago:", format='%Y-%m-%d', title="FechaPago", no_titlebar=False, target="fecha_pago", pad=TEXT_PADDING, border_width=0, |
||
56 | key="fecha_pago_select", disabled=True), |
||
57 | sg.Input("", size=(12, 1), key="fecha_pago", change_submits=True, disabled=True), |
||
58 | sg.Text("FormaPago:", pad=TEXT_PADDING), |
||
59 | 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), disabled=True), |
||
|
|||
60 | ], |
||
61 | [ |
||
62 | sg.Button("Preparar Comprobante Pago", key="prepare_pago", border_width=0, disabled=True), |
||
63 | ] |
||
64 | ], |
||
65 | pad=0 |
||
66 | ) |
||
67 | ] |
||
68 | |||
69 | button_column_third = [ |
||
70 | sg.Button("Preparar Correos", key="prepare_correos", border_width=0), |
||
71 | sg.Button("Facturas Pendientes", key="facturas_pendientes", border_width=0), |
||
72 | sg.Checkbox("Ver Detallado", default=False, key="detallado"), |
||
73 | sg.VSeparator(), |
||
74 | sg.Button("Ajuste Anual", key="preparar_ajuste_anual", border_width=0), |
||
75 | sg.Text("Año-Mes:", pad=TEXT_PADDING), |
||
76 | sg.Input((date.today() + relativedelta(months=1)).strftime('%Y-%m'), size=(8, 1), key="anio_mes_ajuste"), |
||
77 | sg.Text("Ajuste:", pad=TEXT_PADDING), |
||
78 | sg.Input("", size=(6, 1), key="ajuste_porcentaje"), |
||
79 | sg.Text("%", pad=RTEXT_PADDING), |
||
80 | sg.VSeparator(), |
||
81 | sg.Text("Recuperar:", pad=TEXT_PADDING), |
||
82 | sg.Button("Emitidas", key="recuperar_emitidas", border_width=0, disabled=not has_fiel), |
||
83 | sg.Button("Recibidas", key="recuperar_recibidas", border_width=0, disabled=not has_fiel), |
||
84 | sg.Text("Dias:", pad=TEXT_PADDING), |
||
85 | sg.Input("40", size=(4, 1), key="recuperar_dias", disabled=not has_fiel), |
||
86 | ] |
||
87 | |||
88 | button_column_low = [ |
||
89 | sg.Button("Validar Clientes", key="validate_clientes", border_width=0), |
||
90 | sg.Button("Crear Facturas", disabled=True, key="crear_facturas", border_width=0), |
||
91 | sg.Button("Enviar Correos", disabled=True, key="enviar_correos", border_width=0), |
||
92 | ] |
||
93 | |||
94 | # ----- Full layout ----- |
||
95 | return [ |
||
96 | button_column, |
||
97 | [sg.HSeparator()], |
||
98 | c_second, |
||
99 | [sg.HSeparator()], |
||
100 | button_column_third, |
||
101 | [sg.Output(expand_x=True, expand_y=True, key="console")], |
||
102 | button_column_low |
||
103 | ] |
||
154 |