Cancel cfdi of nomina with xml signed

This commit is contained in:
Mauricio Baeza 2020-12-31 21:11:22 -06:00
parent 90eec635ce
commit 9423aeef6c
1 changed files with 8 additions and 13 deletions

View File

@ -6529,13 +6529,11 @@ class CfdiPagos(BaseModel):
auth = Configuracion.get_({'fields': 'pac_auth'})
certificado = Certificado.get(Certificado.es_fiel==False)
result = utils.cancel_xml_sign(last, auth, certificado)
# ~ data, result = util.cancel_xml(auth, last.uuid, cert)
if result['ok']:
last.estatus = 'Cancelada'
last.error = ''
last.cancelada = True
last.fecha_cancelacion = result['Fecha']
# ~ msg = 'Factura cancelada correctamente'
else:
last.error = result['msg']
last.save()
@ -8029,29 +8027,26 @@ class CfdiNomina(BaseModel):
def _cancel(self, values, user):
id = int(values['id'])
msg = 'Recibo cancelado correctamente'
auth = Emisor.get_auth()
certificado = Certificado.select()[0]
obj = CfdiNomina.get(CfdiNomina.id==id)
if obj.uuid is None:
msg = 'Solo se pueden cancelar recibos timbrados'
return {'ok': False, 'msg': msg}
data, result = util.cancel_xml(auth, obj.uuid, certificado)
auth = Configuracion.get_({'fields': 'pac_auth'})
certificado = Certificado.get(Certificado.es_fiel==False)
result = utils.cancel_xml_sign(obj, auth, certificado)
if data['ok']:
data['msg'] = 'Recibo cancelado correctamente'
data['row']['estatus'] = 'Cancelado'
obj.estatus = data['row']['estatus']
if result['ok']:
obj.estatus = 'Cancelado'
obj.error = ''
obj.cancelada = True
obj.fecha_cancelacion = result['Fecha']
obj.acuse = result['Acuse'] or ''
else:
obj.error = data['msg']
obj.error = result['msg']
obj.save()
return data
return result
def _send_mail(self, values, user):
id = int(values['id'])