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