| Conditions | 7 |
| Total Lines | 254 |
| Code Lines | 205 |
| 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 |
||
| 122 | def make_layout(has_fiel, local_db): |
||
| 123 | # LAYOUT |
||
| 124 | button_column = [ |
||
| 125 | sg.Text("Periodo:", pad=TEXT_PADDING), |
||
| 126 | sg.Input(date.today().strftime('%Y-%m'), size=(11, 1), key="periodo"), |
||
| 127 | sg.Button(image_data=FOLDER_ICON, key="ver_carpeta", border_width=0, button_color=BUTTON_COLOR), |
||
| 128 | sg.Button(image_data=EXCEL_ICON, key="ver_excel", border_width=0, button_color=BUTTON_COLOR), |
||
| 129 | sg.Button(image_data=HTML_ICON, key="ver_html", border_width=0, button_color=BUTTON_COLOR), |
||
| 130 | |||
| 131 | sg.Push(), |
||
| 132 | sg.Text("Factura:", pad=TEXT_PADDING), |
||
| 133 | sg.Text("", key="serie_folio", pad=TEXT_PADDING), |
||
| 134 | sg.Button("".center(22), disabled=True, key="crear_facturas", border_width=0, button_color=sg.theme_background_color()), |
||
| 135 | sg.Button(image_data=PREVIEW_ICON, key="ver_preview", border_width=0, button_color=BUTTON_COLOR, disabled=True), |
||
| 136 | ] |
||
| 137 | |||
| 138 | # ----- Full layout ----- |
||
| 139 | return [ |
||
| 140 | button_column, |
||
| 141 | [ |
||
| 142 | sg.TabGroup( |
||
| 143 | [[ |
||
| 144 | sg.Tab( |
||
| 145 | 'Consola'.center(13), |
||
| 146 | [ |
||
| 147 | [ |
||
| 148 | sg.Push(), |
||
| 149 | sg.Button(image_data=ABOUT_ICON, key="about", border_width=0, button_color=BUTTON_COLOR), |
||
| 150 | ], |
||
| 151 | [sg.Multiline( |
||
| 152 | expand_x=True, |
||
| 153 | expand_y=True, |
||
| 154 | key="console", |
||
| 155 | write_only=True, |
||
| 156 | autoscroll=True, |
||
| 157 | reroute_stdout=True |
||
| 158 | )] |
||
| 159 | ], |
||
| 160 | key='console_tab', |
||
| 161 | ), |
||
| 162 | sg.Tab( |
||
| 163 | 'Clientes'.center(13), |
||
| 164 | [ |
||
| 165 | [ |
||
| 166 | sg.Push(), |
||
| 167 | sg.Button(image_data=EDIT_ICON, key="editar_clientes", border_width=0, button_color=BUTTON_COLOR), |
||
| 168 | ], |
||
| 169 | [ |
||
| 170 | MyTable( |
||
| 171 | key="clientes_table", |
||
| 172 | headings=[ |
||
| 173 | "#", |
||
| 174 | "Razon Social", |
||
| 175 | "Rfc", |
||
| 176 | "Reg", |
||
| 177 | "CP" |
||
| 178 | ], |
||
| 179 | row_fn=lambda i, r: [ |
||
| 180 | i, |
||
| 181 | r["RazonSocial"], |
||
| 182 | r["Rfc"], |
||
| 183 | r["RegimenFiscal"].code, |
||
| 184 | r["CodigoPostal"] |
||
| 185 | ] |
||
| 186 | ) |
||
| 187 | ]], |
||
| 188 | key='clientes_tab', |
||
| 189 | ), |
||
| 190 | sg.Tab( |
||
| 191 | 'Facturas'.center(13), |
||
| 192 | [ |
||
| 193 | [ |
||
| 194 | sg.Text("", pad=TEXT_PADDING, key="preparar_facturas_text"), |
||
| 195 | sg.Push(), |
||
| 196 | sg.Button(image_data=EDIT_ICON, key="editar_facturas", border_width=0, button_color=BUTTON_COLOR), |
||
| 197 | ], |
||
| 198 | [ |
||
| 199 | MyTable( |
||
| 200 | key="facturas_table", |
||
| 201 | headings=[ |
||
| 202 | '#', |
||
| 203 | 'EReg', |
||
| 204 | 'Receptor Razon Social', |
||
| 205 | 'Recep. Rfc', |
||
| 206 | "Tipo", |
||
| 207 | "Subtotal", |
||
| 208 | "Total" |
||
| 209 | ], |
||
| 210 | row_fn=lambda i, r: [ |
||
| 211 | i, |
||
| 212 | r['Emisor']['RegimenFiscal'].code, |
||
| 213 | r['Receptor']['Nombre'], |
||
| 214 | r['Receptor']['Rfc'], |
||
| 215 | mf_pago_fmt(r), |
||
| 216 | r['SubTotal'], |
||
| 217 | r['Total'] |
||
| 218 | ] |
||
| 219 | ) |
||
| 220 | ]], |
||
| 221 | key='facturas_tab', |
||
| 222 | ), |
||
| 223 | sg.Tab( |
||
| 224 | 'Emitidas'.center(13), |
||
| 225 | [ |
||
| 226 | [ |
||
| 227 | sg.Button("Emitidas", key="facturas_emitidas", border_width=0), |
||
| 228 | sg.Button("Pendientes", key="facturas_pendientes", border_width=0), |
||
| 229 | sg.Button(image_data=SEARCH_ICON, key="buscar_facturas", border_width=0, button_color=BUTTON_COLOR), |
||
| 230 | sg.Input("", size=(40, 1), key="emitidas_search"), |
||
| 231 | ], |
||
| 232 | [ |
||
| 233 | sg.Column([[ |
||
| 234 | sg.Button("".ljust(10), key="status_sat", border_width=0, button_color=sg.theme_background_color()), |
||
| 235 | sg.Button("".ljust(10), key="email_notificada", border_width=0, button_color=sg.theme_background_color()), |
||
| 236 | sg.Button("".ljust(10), key="pendiente_pago", border_width=0, button_color=sg.theme_background_color()), |
||
| 237 | ]]), |
||
| 238 | sg.VSeparator(), |
||
| 239 | sg.Column([[ |
||
| 240 | sg.CalendarButton("FechaPago:", format=FECHA_PAGO_FMT, title="FechaPago", no_titlebar=False, target="fecha_pago", pad=TEXT_PADDING, |
||
| 241 | border_width=0), |
||
| 242 | sg.Input(datetime.now().strftime(FECHA_PAGO_FMT), size=(12, 1), key="fecha_pago"), |
||
| 243 | sg.Text("FormaPago:", pad=TEXT_PADDING, border_width=0), |
||
| 244 | sg.Combo([Code(k, v) for k, v in FORMA_PAGO.items()], |
||
| 245 | default_value=Code("03", FORMA_PAGO["03"]), key="forma_pago", size=(35, 1)), |
||
| 246 | sg.Text("ImpPagado:", pad=TEXT_PADDING, border_width=0), |
||
| 247 | sg.Input("", size=(12, 1), key="importe_pago"), |
||
| 248 | ]], visible=False, key="ppd_action_items"), |
||
| 249 | ], |
||
| 250 | [ |
||
| 251 | MyTable( |
||
| 252 | key="emitidas_table", |
||
| 253 | headings=[ |
||
| 254 | '#', |
||
| 255 | 'Receptor Razon Social', |
||
| 256 | 'Recep. Rfc', |
||
| 257 | 'Factura', |
||
| 258 | "Fecha", |
||
| 259 | "Total", |
||
| 260 | "Pendiente", |
||
| 261 | "Pagada", |
||
| 262 | "Tipo", |
||
| 263 | "Folio" |
||
| 264 | ], |
||
| 265 | row_fn=lambda i, r: [ |
||
| 266 | i, |
||
| 267 | r['Receptor'].get('Nombre', ''), |
||
| 268 | r['Receptor']['Rfc'], |
||
| 269 | r.name, |
||
| 270 | r["Fecha"].strftime(FECHA_PAGO_FMT), |
||
| 271 | r["Total"], |
||
| 272 | r.saldo_pendiente if r.saldo_pendiente else "", |
||
| 273 | local_db.liquidated_state(r), |
||
| 274 | mf_pago_fmt(r), |
||
| 275 | r.uuid |
||
| 276 | ] |
||
| 277 | ) |
||
| 278 | ]], |
||
| 279 | key='emitidas_tab', |
||
| 280 | ), |
||
| 281 | sg.Tab( |
||
| 282 | 'Correos'.center(13), |
||
| 283 | [ |
||
| 284 | [ |
||
| 285 | sg.Text("", pad=TEXT_PADDING), |
||
| 286 | ], |
||
| 287 | [ |
||
| 288 | MyTable( |
||
| 289 | key="correos_table", |
||
| 290 | headings=[ |
||
| 291 | '#', |
||
| 292 | 'Receptor Razon Social', |
||
| 293 | 'Recep. Rfc', |
||
| 294 | 'Facturas', |
||
| 295 | 'Pendientes Emitidas Meses Anteriores' |
||
| 296 | ], |
||
| 297 | row_fn=lambda i, r: [ |
||
| 298 | i, |
||
| 299 | r[0]["RazonSocial"][0:36], |
||
| 300 | r[0]["Rfc"], |
||
| 301 | ",".join(n.name for n in r[1]), |
||
| 302 | ",".join(n.name for n in r[2]) |
||
| 303 | ] |
||
| 304 | ) |
||
| 305 | ]], |
||
| 306 | key='correos_tab', |
||
| 307 | ), |
||
| 308 | sg.Tab( |
||
| 309 | 'Ajustes'.center(13), |
||
| 310 | [ |
||
| 311 | [ |
||
| 312 | sg.Text("", pad=TEXT_PADDING, key="preparar_ajustes_text"), |
||
| 313 | ], |
||
| 314 | [ |
||
| 315 | MyTable( |
||
| 316 | key="ajustes_table", |
||
| 317 | headings=[ |
||
| 318 | "#", |
||
| 319 | "Receptor Razon Social", |
||
| 320 | "Recep. Rfc", |
||
| 321 | "Actual", |
||
| 322 | "Nuevo", |
||
| 323 | "Ajuste %", |
||
| 324 | "Periodo", |
||
| 325 | "Meses", |
||
| 326 | "Ajuste Efectivo" |
||
| 327 | ], |
||
| 328 | row_fn=lambda i, r: [ |
||
| 329 | i, |
||
| 330 | r["receptor"]["RazonSocial"], |
||
| 331 | r["receptor"]["Rfc"], |
||
| 332 | r["valor_unitario"], |
||
| 333 | r["valor_unitario_nuevo"], |
||
| 334 | r["ajuste_porcentaje"], |
||
| 335 | r["periodo"], |
||
| 336 | r["meses"], |
||
| 337 | r["efectivo_periodo_desc"] |
||
| 338 | ] |
||
| 339 | ) |
||
| 340 | ]], |
||
| 341 | key='ajustes_tab' |
||
| 342 | ), |
||
| 343 | sg.Tab( |
||
| 344 | 'Recuperar'.center(13), |
||
| 345 | [ |
||
| 346 | [ |
||
| 347 | sg.Button("SAT Status", key="sat_status_todas", border_width=0), |
||
| 348 | sg.Text("Recuperar:", pad=TEXT_PADDING), |
||
| 349 | sg.Button("Emitidas ", key="recuperar_emitidas", border_width=0), |
||
| 350 | sg.Button("Recibidas", key="recuperar_recibidas", border_width=0), |
||
| 351 | sg.Text("Dias:", pad=TEXT_PADDING), |
||
| 352 | sg.Input("40", size=(4, 1), key="recuperar_dias"), |
||
| 353 | ] |
||
| 354 | ], |
||
| 355 | key='recuperar_tab', |
||
| 356 | visible=has_fiel |
||
| 357 | ), |
||
| 358 | sg.Tab( |
||
| 359 | 'Configuracion'.center(13), |
||
| 360 | [ |
||
| 361 | [ |
||
| 362 | sg.Text("Folio de Proxima Factura:", pad=TEXT_PADDING), |
||
| 363 | sg.Input("", key="folio", size=(8, 1), enable_events=True), |
||
| 364 | ], |
||
| 365 | [ |
||
| 366 | sg.Button(image_data=CONFIG_ICON, key="ver_config", border_width=0, button_color=BUTTON_COLOR), |
||
| 367 | ] |
||
| 368 | ], |
||
| 369 | key='configuracion_tab', |
||
| 370 | ), |
||
| 371 | ]], |
||
| 372 | expand_x=True, |
||
| 373 | expand_y=True, |
||
| 374 | enable_events=True, |
||
| 375 | key="main_tab_group", |
||
| 376 | ) |
||
| 423 |