forked from elmau/empresa-libre
commit
1f043746dd
|
@ -1,3 +1,8 @@
|
||||||
|
v 1.6.1 [09-abr-2018]
|
||||||
|
---------------------
|
||||||
|
- Fix: Nómina con separación
|
||||||
|
|
||||||
|
|
||||||
v 1.6.0 [18-feb-2018]
|
v 1.6.0 [18-feb-2018]
|
||||||
---------------------
|
---------------------
|
||||||
- Facturacion a extranjeros
|
- Facturacion a extranjeros
|
||||||
|
|
|
@ -1008,7 +1008,12 @@ class LIBO(object):
|
||||||
count -= 1
|
count -= 1
|
||||||
|
|
||||||
first = True
|
first = True
|
||||||
|
separacion = {}
|
||||||
for r in percepciones:
|
for r in percepciones:
|
||||||
|
if 'TotalPagado' in r:
|
||||||
|
separacion = r
|
||||||
|
continue
|
||||||
|
|
||||||
tipo = r.get('TipoPercepcion')
|
tipo = r.get('TipoPercepcion')
|
||||||
concepto = r.get('Concepto')
|
concepto = r.get('Concepto')
|
||||||
gravado = r.get('ImporteGravado')
|
gravado = r.get('ImporteGravado')
|
||||||
|
@ -1264,6 +1269,15 @@ class LIBO(object):
|
||||||
data = tuple([r[2:] for r in rows[:count+2]])
|
data = tuple([r[2:] for r in rows[:count+2]])
|
||||||
return data, ''
|
return data, ''
|
||||||
|
|
||||||
|
def _get_separacion(self, doc, count):
|
||||||
|
rows, msg = self._get_data(doc, 'Separacion')
|
||||||
|
if len(rows) == 2:
|
||||||
|
msg = 'Sin Separacion'
|
||||||
|
return {}, msg
|
||||||
|
|
||||||
|
data = tuple([r[1:] for r in rows[:count+2]])
|
||||||
|
return data, ''
|
||||||
|
|
||||||
def _get_horas_extras(self, doc, count):
|
def _get_horas_extras(self, doc, count):
|
||||||
rows, msg = self._get_data(doc, 'HorasExtras')
|
rows, msg = self._get_data(doc, 'HorasExtras')
|
||||||
if len(rows) == 2:
|
if len(rows) == 2:
|
||||||
|
@ -1318,6 +1332,11 @@ class LIBO(object):
|
||||||
doc.close(True)
|
doc.close(True)
|
||||||
return {}, msg
|
return {}, msg
|
||||||
|
|
||||||
|
separacion, msg = self._get_separacion(doc, len(nomina))
|
||||||
|
if msg:
|
||||||
|
doc.close(True)
|
||||||
|
return {}, msg
|
||||||
|
|
||||||
horas_extras, msg = self._get_horas_extras(doc, len(nomina))
|
horas_extras, msg = self._get_horas_extras(doc, len(nomina))
|
||||||
if msg:
|
if msg:
|
||||||
doc.close(True)
|
doc.close(True)
|
||||||
|
@ -1333,6 +1352,7 @@ class LIBO(object):
|
||||||
data['percepciones'] = percepciones
|
data['percepciones'] = percepciones
|
||||||
data['deducciones'] = deducciones
|
data['deducciones'] = deducciones
|
||||||
data['otros_pagos'] = otros_pagos
|
data['otros_pagos'] = otros_pagos
|
||||||
|
data['separacion'] = separacion
|
||||||
data['horas_extras'] = horas_extras
|
data['horas_extras'] = horas_extras
|
||||||
data['incapacidades'] = incapacidades
|
data['incapacidades'] = incapacidades
|
||||||
|
|
||||||
|
|
|
@ -6146,6 +6146,7 @@ class CfdiNomina(BaseModel):
|
||||||
total_jubilacion += gravado + exento
|
total_jubilacion += gravado + exento
|
||||||
elif key in ('022', '023', '025'):
|
elif key in ('022', '023', '025'):
|
||||||
total_separacion += gravado + exento
|
total_separacion += gravado + exento
|
||||||
|
|
||||||
new = {
|
new = {
|
||||||
'tipo_percepcion': tp,
|
'tipo_percepcion': tp,
|
||||||
'importe_gravado': gravado,
|
'importe_gravado': gravado,
|
||||||
|
@ -6153,15 +6154,15 @@ class CfdiNomina(BaseModel):
|
||||||
}
|
}
|
||||||
data.append(new)
|
data.append(new)
|
||||||
|
|
||||||
total_sueldos = round(total_gravado + total_exento, DECIMALES)
|
total_percepciones = round(total_gravado + total_exento, DECIMALES)
|
||||||
|
total_sueldos = round(total_percepciones - total_jubilacion - total_separacion, DECIMALES)
|
||||||
totals = {
|
totals = {
|
||||||
'total_gravado': total_gravado,
|
'total_gravado': total_gravado,
|
||||||
'total_exento': total_exento,
|
'total_exento': total_exento,
|
||||||
'total_jubilacion': total_jubilacion,
|
'total_jubilacion': total_jubilacion,
|
||||||
'total_separacion': total_separacion,
|
'total_separacion': total_separacion,
|
||||||
'total_sueldos': total_sueldos,
|
'total_sueldos': total_sueldos,
|
||||||
'total_percepciones': round(
|
'total_percepciones': total_percepciones
|
||||||
total_sueldos + total_jubilacion + total_separacion, DECIMALES)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return data, totals, ''
|
return data, totals, ''
|
||||||
|
@ -6239,6 +6240,31 @@ class CfdiNomina(BaseModel):
|
||||||
|
|
||||||
return data, totals, ''
|
return data, totals, ''
|
||||||
|
|
||||||
|
def _validate_separacion(self, row):
|
||||||
|
if not row[0]:
|
||||||
|
return {}, ''
|
||||||
|
|
||||||
|
if not row[2] or isinstance(row[2], str):
|
||||||
|
msg = 'El campo Ultimo Sueldo debe ser un importe'
|
||||||
|
return {}, msg
|
||||||
|
|
||||||
|
if isinstance(row[3], str):
|
||||||
|
msg = 'El campo Ingreso Acumulable debe ser un importe'
|
||||||
|
return {}, msg
|
||||||
|
|
||||||
|
if isinstance(row[4], str):
|
||||||
|
msg = 'El campo Ingreso No Acumulable debe ser un importe'
|
||||||
|
return {}, msg
|
||||||
|
|
||||||
|
new = {
|
||||||
|
'total_pagado': round(row[0], DECIMALES),
|
||||||
|
'years_servicio': int(row[1]),
|
||||||
|
'ultimo_sueldo': round(row[2], DECIMALES),
|
||||||
|
'ingreso_acumulable': round(row[3], DECIMALES),
|
||||||
|
'ingreso_no_acumulable': round(row[4], DECIMALES),
|
||||||
|
}
|
||||||
|
return new, ''
|
||||||
|
|
||||||
def _validate_horas_extras(self, row):
|
def _validate_horas_extras(self, row):
|
||||||
data = []
|
data = []
|
||||||
for i, key in enumerate(row[::4]):
|
for i, key in enumerate(row[::4]):
|
||||||
|
@ -6327,6 +6353,7 @@ class CfdiNomina(BaseModel):
|
||||||
deducciones = data['deducciones'][2:]
|
deducciones = data['deducciones'][2:]
|
||||||
ho = data['otros_pagos'][:1]
|
ho = data['otros_pagos'][:1]
|
||||||
otros_pagos = data['otros_pagos'][2:]
|
otros_pagos = data['otros_pagos'][2:]
|
||||||
|
separacion = data['separacion'][2:]
|
||||||
horas_extras = data['horas_extras'][2:]
|
horas_extras = data['horas_extras'][2:]
|
||||||
incapacidades = data['incapacidades'][2:]
|
incapacidades = data['incapacidades'][2:]
|
||||||
|
|
||||||
|
@ -6361,6 +6388,11 @@ class CfdiNomina(BaseModel):
|
||||||
util.log_file('nomina', msg)
|
util.log_file('nomina', msg)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
new_separacion, msg = self._validate_separacion(self, separacion[i])
|
||||||
|
if msg:
|
||||||
|
util.log_file('nomina', msg)
|
||||||
|
continue
|
||||||
|
|
||||||
new_horas_extras, msg = self._validate_horas_extras(self, horas_extras[i])
|
new_horas_extras, msg = self._validate_horas_extras(self, horas_extras[i])
|
||||||
if msg:
|
if msg:
|
||||||
util.log_file('nomina', msg)
|
util.log_file('nomina', msg)
|
||||||
|
@ -6413,6 +6445,10 @@ class CfdiNomina(BaseModel):
|
||||||
row['cfdi'] = obj
|
row['cfdi'] = obj
|
||||||
CfdiNominaRelacionados.create(**row)
|
CfdiNominaRelacionados.create(**row)
|
||||||
|
|
||||||
|
if new_separacion:
|
||||||
|
new_separacion['cfdi'] = obj
|
||||||
|
CfdiNominaSeparacion.create(**new_separacion)
|
||||||
|
|
||||||
concepto = {
|
concepto = {
|
||||||
'cfdi': obj,
|
'cfdi': obj,
|
||||||
'valor_unitario': totals['subtotal'],
|
'valor_unitario': totals['subtotal'],
|
||||||
|
@ -6618,6 +6654,18 @@ class CfdiNomina(BaseModel):
|
||||||
details.append(p)
|
details.append(p)
|
||||||
percepciones['details'] = details
|
percepciones['details'] = details
|
||||||
|
|
||||||
|
rows = CfdiNominaSeparacion.select().where(CfdiNominaSeparacion.cfdi==cfdi)
|
||||||
|
for row in rows:
|
||||||
|
separacion = {
|
||||||
|
'TotalPagado': FORMAT.format(row.total_pagado),
|
||||||
|
'NumAñosServicio': str(row.years_servicio),
|
||||||
|
'UltimoSueldoMensOrd': FORMAT.format(row.ultimo_sueldo),
|
||||||
|
'IngresoAcumulable': FORMAT.format(row.ingreso_acumulable),
|
||||||
|
'IngresoNoAcumulable': FORMAT.format(row.ingreso_no_acumulable),
|
||||||
|
}
|
||||||
|
percepciones['separacion'] = separacion
|
||||||
|
break
|
||||||
|
|
||||||
rows = CfdiNominaHorasExtra.select().where(CfdiNominaHorasExtra.cfdi==cfdi)
|
rows = CfdiNominaHorasExtra.select().where(CfdiNominaHorasExtra.cfdi==cfdi)
|
||||||
details = []
|
details = []
|
||||||
for row in rows:
|
for row in rows:
|
||||||
|
@ -6812,6 +6860,8 @@ class CfdiNomina(BaseModel):
|
||||||
q.execute()
|
q.execute()
|
||||||
q = CfdiNominaOtroPago.delete().where(CfdiNominaOtroPago.cfdi==obj)
|
q = CfdiNominaOtroPago.delete().where(CfdiNominaOtroPago.cfdi==obj)
|
||||||
q.execute()
|
q.execute()
|
||||||
|
q = CfdiNominaSeparacion.delete().where(CfdiNominaSeparacion.cfdi==obj)
|
||||||
|
q.execute()
|
||||||
q = CfdiNominaHorasExtra.delete().where(CfdiNominaHorasExtra.cfdi==obj)
|
q = CfdiNominaHorasExtra.delete().where(CfdiNominaHorasExtra.cfdi==obj)
|
||||||
q.execute()
|
q.execute()
|
||||||
q = CfdiNominaIncapacidad.delete().where(CfdiNominaIncapacidad.cfdi==obj)
|
q = CfdiNominaIncapacidad.delete().where(CfdiNominaIncapacidad.cfdi==obj)
|
||||||
|
@ -8131,8 +8181,8 @@ def _exportar_documentos():
|
||||||
_, name = Facturas.get_xml(row['id'])
|
_, name = Facturas.get_xml(row['id'])
|
||||||
msg = '\tXML extraido...'
|
msg = '\tXML extraido...'
|
||||||
log.info(msg)
|
log.info(msg)
|
||||||
# ~ name = name[:-3] + 'pdf'
|
name = name[:-3] + 'pdf'
|
||||||
# ~ path = '/home/mau/facturas/{}/{}/{}/{}'.format(rfc, year, month, name)
|
# ~ path = '/home/mau/facturas/CURG62080951A/{}/{}/{}'.format(year, month.zfill(2), name)
|
||||||
# ~ if util.exists(path):
|
# ~ if util.exists(path):
|
||||||
# ~ continue
|
# ~ continue
|
||||||
Facturas.get_pdf(row['id'], rfc, True)
|
Facturas.get_pdf(row['id'], rfc, True)
|
||||||
|
|
Loading…
Reference in New Issue