Conditions | 1 |
Total Lines | 200 |
Code Lines | 160 |
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, datetime |
||
101 | def make_layout(has_fiel): |
||
102 | # LAYOUT |
||
103 | button_column = [ |
||
104 | sg.Button(image_data=CONFIG_ICON, key="ver_config", border_width=0, button_color=BUTTON_COLOR), |
||
105 | sg.Text("Periodo:", pad=TEXT_PADDING), |
||
106 | sg.Input(date.today().strftime('%Y-%m'), size=(11, 1), key="periodo"), |
||
107 | sg.Button(image_data=FOLDER_ICON, key="ver_carpeta", border_width=0, button_color=BUTTON_COLOR), |
||
108 | sg.Button(image_data=EXCEL_ICON, key="ver_excel", border_width=0, button_color=BUTTON_COLOR), |
||
109 | sg.Button(image_data=HTML_ICON, key="ver_html", border_width=0, button_color=BUTTON_COLOR), |
||
110 | |||
111 | sg.Push(), |
||
112 | sg.Text("Factura:", pad=TEXT_PADDING), |
||
113 | sg.Text("", key="serie", pad=TEXT_PADDING, text_color="black"), |
||
114 | sg.Input("", key="folio", size=(8, 1), enable_events=True), |
||
115 | sg.Button("".center(22), disabled=True, key="crear_facturas", border_width=0, button_color=sg.theme_background_color()), |
||
116 | ] |
||
117 | |||
118 | # ----- Full layout ----- |
||
119 | return [ |
||
120 | button_column, |
||
121 | [ |
||
122 | sg.TabGroup( |
||
123 | [[ |
||
124 | sg.Tab( |
||
125 | 'Consola'.center(13), |
||
126 | [ |
||
127 | [ |
||
128 | sg.Push(), |
||
129 | sg.Button(image_data=ABOUT_ICON, key="about", border_width=0, button_color=BUTTON_COLOR), |
||
130 | ], |
||
131 | [sg.Multiline( |
||
132 | expand_x=True, |
||
133 | expand_y=True, |
||
134 | key="console", |
||
135 | write_only=True, |
||
136 | autoscroll=True, |
||
137 | reroute_stdout=True |
||
138 | )] |
||
139 | ], |
||
140 | key='console_tab', |
||
141 | ), |
||
142 | sg.Tab( |
||
143 | 'Clientes'.center(13), |
||
144 | [ |
||
145 | [ |
||
146 | sg.Button("Refrescar", key="refresh_clientes", border_width=0), |
||
147 | sg.Push(), |
||
148 | sg.Button(image_data=EDIT_ICON, key="editar_clientes", border_width=0, button_color=BUTTON_COLOR), |
||
149 | ], |
||
150 | [ |
||
151 | MyTable( |
||
152 | headings=[ |
||
153 | "#", |
||
154 | "Razon Social", |
||
155 | "Rfc", |
||
156 | "Reg", |
||
157 | "CP", |
||
158 | "Facturas", |
||
159 | ], |
||
160 | key="clientes_table" |
||
161 | ) |
||
162 | ]], |
||
163 | key='clients_tab', |
||
164 | ), |
||
165 | sg.Tab( |
||
166 | 'Facturas'.center(13), |
||
167 | [ |
||
168 | [ |
||
169 | sg.Button("Refrescar", key="refresh_facturas", border_width=0, ), |
||
170 | sg.Text("", pad=TEXT_PADDING, key="preparar_facturas_text"), |
||
171 | sg.Push(), |
||
172 | sg.Button(image_data=EDIT_ICON, key="editar_facturas", border_width=0, button_color=BUTTON_COLOR), |
||
173 | ], |
||
174 | [ |
||
175 | MyTable( |
||
176 | key="facturas_table", |
||
177 | headings=[ |
||
178 | '#', |
||
179 | 'EReg', |
||
180 | 'Receptor Razon Social', |
||
181 | 'Recep. Rfc', |
||
182 | "Tipo", |
||
183 | "Subtotal", |
||
184 | "Total" |
||
185 | ], |
||
186 | ) |
||
187 | ]], |
||
188 | key='facturas_tab', |
||
189 | ), |
||
190 | sg.Tab( |
||
191 | 'Emitidas'.center(13), |
||
192 | [ |
||
193 | [ |
||
194 | sg.Button("Pendientes", key="facturas_pendientes", border_width=0), |
||
195 | sg.Button("Todas", key="facturas_emitidas", border_width=0), |
||
196 | sg.Button(image_data=SEARCH_ICON, key="emitidas_search_enter", border_width=0, button_color=BUTTON_COLOR), |
||
197 | sg.Input("", size=(20, 1), key="emitidas_search", border_width=0), |
||
198 | sg.Text("", pad=TEXT_PADDING, key="emitidas_text"), |
||
199 | ], |
||
200 | [ |
||
201 | sg.Column([[ |
||
202 | sg.Button("".ljust(10), key="status_sat", border_width=0, button_color=sg.theme_background_color()), |
||
203 | sg.Button("".ljust(10), key="email_notificada", border_width=0, button_color=sg.theme_background_color()), |
||
204 | sg.Button("".ljust(10), key="pendiente_pago", border_width=0, button_color=sg.theme_background_color()), |
||
205 | ]]), |
||
206 | sg.VSeparator(), |
||
207 | sg.Column([[ |
||
208 | sg.CalendarButton("FechaPago:", format='%Y-%m-%d', title="FechaPago", no_titlebar=False, target="fecha_pago", pad=TEXT_PADDING, |
||
209 | border_width=0, |
||
210 | key="fecha_pago_select"), |
||
211 | sg.Input(datetime.now().strftime('%Y-%m-%d'), size=(12, 1), key="fecha_pago", border_width=0), |
||
212 | sg.Combo([Code(k, v) for k, v in FORMA_PAGO.items()], default_value=Code("03", FORMA_PAGO["03"]), key="forma_pago", size=(28, 1)), |
||
|
|||
213 | sg.Text("ImpPagado:", pad=TEXT_PADDING, key="imp_pagado_text", border_width=0), |
||
214 | sg.Input("", size=(12, 1), key="importe_pago", border_width=0), |
||
215 | sg.Button("Comprobante Pago", key="prepare_pago", border_width=0), |
||
216 | sg.Button(image_data=PREVIEW_ICON, key="ver_html_pago", border_width=0, button_color=BUTTON_COLOR), |
||
217 | ]], visible=False, key="ppd_action_items"), |
||
218 | ], |
||
219 | [ |
||
220 | MyTable( |
||
221 | key="emitidas_table", |
||
222 | headings=[ |
||
223 | '#', |
||
224 | 'Receptor Razon Social', |
||
225 | 'Recep. Rfc', |
||
226 | 'Factura', |
||
227 | "Fecha", |
||
228 | "Total", |
||
229 | "Pagada", |
||
230 | "Tipo", |
||
231 | ], |
||
232 | ) |
||
233 | ]], |
||
234 | key='emitidas_tab', |
||
235 | ), |
||
236 | sg.Tab( |
||
237 | 'Correos'.center(13), |
||
238 | [ |
||
239 | [ |
||
240 | sg.Button("Refrescar", key="refresh_correos", border_width=0, ), |
||
241 | ], |
||
242 | [ |
||
243 | MyTable( |
||
244 | key="correos_table", |
||
245 | headings=[ |
||
246 | '#', |
||
247 | 'Receptor Razon Social', |
||
248 | 'Recep. Rfc', |
||
249 | 'Facturas', |
||
250 | 'Pendientes Emitidas Meses Anteriores' |
||
251 | ] |
||
252 | ) |
||
253 | ]], |
||
254 | key='correos_tab', |
||
255 | ), |
||
256 | sg.Tab( |
||
257 | 'Ajustes'.center(13), |
||
258 | [ |
||
259 | [ |
||
260 | sg.Button("Refrescar", key="refresh_ajustes", border_width=0, ), |
||
261 | sg.Text("", pad=TEXT_PADDING, key="preparar_ajustes_text"), |
||
262 | ], |
||
263 | [ |
||
264 | MyTable( |
||
265 | key="ajustes_table", |
||
266 | headings=[ |
||
267 | "#", |
||
268 | "Receptor Razon Social", |
||
269 | "Recep. Rfc", |
||
270 | "Actual", |
||
271 | "Nuevo", |
||
272 | "Ajuste %", |
||
273 | "Periodo", |
||
274 | "Meses", |
||
275 | "Ajuste Efectivo" |
||
276 | ], |
||
277 | ) |
||
278 | ]], |
||
279 | key='ajustes_tab' |
||
280 | ), |
||
281 | sg.Tab( |
||
282 | 'Recuperar'.center(13), |
||
283 | [ |
||
284 | [ |
||
285 | sg.Button("SAT Status", key="sat_status_todas", border_width=0), |
||
286 | sg.Text("Recuperar:", pad=TEXT_PADDING), |
||
287 | sg.Button("Emitidas ", key="recuperar_emitidas", border_width=0), |
||
288 | sg.Button("Recibidas", key="recuperar_recibidas", border_width=0), |
||
289 | sg.Text("Dias:", pad=TEXT_PADDING), |
||
290 | sg.Input("40", size=(4, 1), key="recuperar_dias"), |
||
291 | ] |
||
292 | ], |
||
293 | key='recuperar_tab', |
||
294 | visible=has_fiel |
||
295 | ), |
||
296 | ]], |
||
297 | expand_x=True, |
||
298 | expand_y=True, |
||
299 | enable_events=True, |
||
300 | key="main_tab_group", |
||
301 | ) |
||
334 |