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