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