Conditions | 1 |
Total Lines | 97 |
Code Lines | 71 |
Lines | 97 |
Ratio | 100 % |
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 | import os |
||
166 | def test_nomina(): |
||
167 | xml_file = "invoice_nomina" |
||
168 | |||
169 | signer = get_signer('xiqb891116qe4') |
||
170 | emisor = cfdi33.Issuer(signer=signer, tax_system="606") |
||
171 | |||
172 | invoice = cfdi33.Comprobante.nomina( |
||
173 | emisor=emisor, |
||
174 | receptor=cfdi33.Receptor( |
||
175 | rfc='KIJ0906199R1', |
||
176 | nombre='KIJ, S.A DE C.V.', |
||
177 | uso_cfdi='G03', |
||
178 | ), |
||
179 | lugar_expedicion="56820", |
||
180 | complemento_nomina=nomina12.Nomina( |
||
181 | emisor={ |
||
182 | 'RegistroPatronal': 'Z1234567890' |
||
183 | }, |
||
184 | receptor={ |
||
185 | 'Curp': 'XIQB891116MCHZRL72', |
||
186 | 'NumSeguridadSocial': '987654321', |
||
187 | 'FechaInicioRelLaboral': date(2020, 1, 1), |
||
188 | 'Antigüedad': 'P96W', |
||
189 | 'TipoContrato': '01', |
||
190 | 'Sindicalizado': 'No', |
||
191 | 'TipoJornada': '01', |
||
192 | 'TipoRegimen': '02', |
||
193 | 'NumEmpleado': '12345678', |
||
194 | 'Departamento': 'Departamento del Trabajo', |
||
195 | 'Puesto': 'Trabajador', |
||
196 | 'RiesgoPuesto': '2', |
||
197 | 'PeriodicidadPago': '04', |
||
198 | 'CuentaBancaria': '0001000200030004', |
||
199 | 'SalarioDiarioIntegrado': Decimal('100.01'), |
||
200 | 'ClaveEntFed': 'MOR' |
||
201 | }, |
||
202 | percepciones={ |
||
203 | 'Percepcion': [ |
||
204 | { |
||
205 | 'TipoPercepcion': '001', |
||
206 | 'Clave': '001', |
||
207 | 'Concepto': 'SUELDO', |
||
208 | 'ImporteGravado': Decimal('1200'), |
||
209 | 'ImporteExento': Decimal('400') |
||
210 | } |
||
211 | ] |
||
212 | }, |
||
213 | deducciones={ |
||
214 | 'Deduccion': [ |
||
215 | { |
||
216 | 'TipoDeduccion': '002', |
||
217 | 'Clave': '300', |
||
218 | 'Concepto': 'ISR A CARGO', |
||
219 | 'Importe': Decimal('1234.73') |
||
220 | }, |
||
221 | { |
||
222 | 'TipoDeduccion': '004', |
||
223 | 'Clave': '204', |
||
224 | 'Concepto': 'FONDO DE AHORRO EMPLEADOS', |
||
225 | 'Importe': Decimal('521.10') |
||
226 | }, |
||
227 | ] |
||
228 | }, |
||
229 | otros_pagos=[ |
||
230 | { |
||
231 | 'TipoOtroPago': '999', |
||
232 | 'Clave': '046', |
||
233 | 'Concepto': 'REEMBOLSO DE GASTOS', |
||
234 | 'Importe': Decimal('456') |
||
235 | }, |
||
236 | { |
||
237 | 'SubsidioAlEmpleo': Decimal('0'), |
||
238 | 'TipoOtroPago': '002', |
||
239 | 'Clave': '002', |
||
240 | 'Concepto': 'SUBSIDIO EMPLEO', |
||
241 | 'Importe': Decimal('0') |
||
242 | } |
||
243 | ], |
||
244 | incapacidades=[ |
||
245 | { |
||
246 | "DiasIncapacidad": 2, |
||
247 | 'TipoIncapacidad': '02', |
||
248 | 'ImporteMonetario': Decimal(1000), |
||
249 | } |
||
250 | ], |
||
251 | tipo_nomina='O', |
||
252 | fecha_pago=date(2020, 1, 30), |
||
253 | fecha_final_pago=date(2020, 1, 31), |
||
254 | fecha_inicial_pago=date(2020, 1, 16), |
||
255 | num_dias_pagados=Decimal('16.000') |
||
256 | ), |
||
257 | serie="A", |
||
258 | folio="123456", |
||
259 | fecha=datetime.fromisoformat("2020-09-29T22:40:38") |
||
260 | ) |
||
261 | |||
262 | verify_invoice(invoice, f"{xml_file}") |
||
263 |