Stamp nomina
This commit is contained in:
parent
a54ad8d760
commit
8a8f05384b
|
@ -2051,7 +2051,8 @@ def get_data_from_xml(invoice, values):
|
|||
if data['pagos']:
|
||||
data['pays'] = _cfdipays(doc, data, version)
|
||||
data['pakings'] = values.get('pakings', [])
|
||||
data['version'] = values['version']
|
||||
# ~ data['version'] = values['version']
|
||||
data['version'] = version
|
||||
return data
|
||||
|
||||
|
||||
|
|
|
@ -224,6 +224,8 @@ def import_invoice():
|
|||
def get_doc(type_doc, id, rfc):
|
||||
types = {
|
||||
'xml': 'application/xml',
|
||||
'xmlpago': 'application/xml',
|
||||
'nomxml': 'application/xml',
|
||||
'ods': 'application/octet-stream',
|
||||
'zip': 'application/octet-stream',
|
||||
'nomlog': 'application/txt',
|
||||
|
@ -386,8 +388,8 @@ class Configuracion(BaseModel):
|
|||
.select(Configuracion.valor)
|
||||
.where(Configuracion.clave == key)
|
||||
)
|
||||
if data:
|
||||
return util.get_bool(data[0].valor)
|
||||
if data and data[0].valor == '1':
|
||||
return True
|
||||
return False
|
||||
|
||||
def _get_partners(self):
|
||||
|
@ -3847,9 +3849,6 @@ class Facturas(BaseModel):
|
|||
msg = 'Factura cancelada correctamente'
|
||||
return {'ok': True, 'msg': msg, 'row': {'estatus': obj.estatus}}
|
||||
|
||||
# ~ if CANCEL_SIGNATURE:
|
||||
# ~ return cls._cancel_signature(cls, id)
|
||||
# ~ return cls._cancel_xml(cls, id)
|
||||
return cls._cancel_xml_sign(obj)
|
||||
|
||||
@classmethod
|
||||
|
@ -6669,9 +6668,9 @@ class CfdiPagos(BaseModel):
|
|||
|
||||
return related
|
||||
|
||||
def _generate_xml(self, invoice, auth):
|
||||
def _generate_xml(self, invoice):
|
||||
emisor = Emisor.select()[0]
|
||||
cert = Certificado.get_cert()
|
||||
certificado = Certificado.get(Certificado.es_fiel==False)
|
||||
used_data_bank = Configuracion.get_bool('chk_cfg_pays_data_bank')
|
||||
|
||||
cfdi = {}
|
||||
|
@ -6679,8 +6678,8 @@ class CfdiPagos(BaseModel):
|
|||
cfdi['Serie'] = invoice.serie
|
||||
cfdi['Folio'] = str(invoice.folio)
|
||||
cfdi['Fecha'] = invoice.fecha.isoformat()[:19]
|
||||
cfdi['NoCertificado'] = cert.serie
|
||||
cfdi['Certificado'] = cert.cer_txt
|
||||
cfdi['NoCertificado'] = certificado.serie
|
||||
# ~ cfdi['Certificado'] = cert.cer_txt
|
||||
cfdi['SubTotal'] = '0'
|
||||
cfdi['Moneda'] = DEFAULT_CFDIPAY['CURRENCY']
|
||||
cfdi['Total'] = '0'
|
||||
|
@ -6760,27 +6759,27 @@ class CfdiPagos(BaseModel):
|
|||
'edu': False,
|
||||
'complementos': complementos,
|
||||
}
|
||||
return util.make_xml(data, cert, auth)
|
||||
return utils.make_xml(data, certificado)
|
||||
|
||||
def _stamp(self, values):
|
||||
id_mov = int(values['id_mov'])
|
||||
send_email = Configuracion.get_bool('correo_directo')
|
||||
auth = Configuracion.get_({'fields': 'pac_auth'})
|
||||
|
||||
send_email = util.get_bool(Configuracion.get_('correo_directo'))
|
||||
auth = Emisor.get_auth()
|
||||
filters = (
|
||||
(CfdiPagos.movimiento==id_mov) &
|
||||
(CfdiPagos.uuid.is_null(True))
|
||||
)
|
||||
obj = CfdiPagos.get(filters)
|
||||
obj.xml = self._generate_xml(self, obj, auth)
|
||||
obj.xml = self._generate_xml(self, obj)
|
||||
obj.estatus = 'Generada'
|
||||
obj.save()
|
||||
msg = 'Factura timbrada correctamente'
|
||||
result = util.timbra_xml(obj.xml, auth)
|
||||
result = utils.xml_stamp(obj.xml, auth)
|
||||
if result['ok']:
|
||||
obj.xml = result['xml']
|
||||
obj.uuid = result['uuid']
|
||||
obj.fecha_timbrado = result['fecha']
|
||||
obj.fecha_timbrado = result['date']
|
||||
obj.estatus = 'Timbrada'
|
||||
obj.error = ''
|
||||
row = {'uuid': obj.uuid, 'estatus': 'Timbrada'}
|
||||
|
@ -6833,7 +6832,6 @@ class CfdiPagos(BaseModel):
|
|||
(obj.xml, name, target),
|
||||
)
|
||||
cls._sync_files(cls, files)
|
||||
|
||||
return obj.xml, name
|
||||
|
||||
def _get_not_in_xml(self, invoice, emisor):
|
||||
|
@ -8586,10 +8584,11 @@ class CfdiNomina(BaseModel):
|
|||
|
||||
return
|
||||
|
||||
def _make_xml(self, cfdi, auth):
|
||||
def _make_xml(self, cfdi):
|
||||
emisor = Emisor.select()[0]
|
||||
empleado = cfdi.empleado
|
||||
certificado = Certificado.select()[0]
|
||||
# ~ certificado = Certificado.select()[0]
|
||||
certificado = Certificado.get(Certificado.es_fiel==False)
|
||||
totals = CfdiNominaTotales.select().where(CfdiNominaTotales.cfdi==cfdi)[0]
|
||||
|
||||
comprobante = {}
|
||||
|
@ -8692,8 +8691,8 @@ class CfdiNomina(BaseModel):
|
|||
ant = 'P{}D'.format(days)
|
||||
nomina_receptor['Antigüedad'] = ant
|
||||
|
||||
if empleado.puesto:
|
||||
if empleado.puesto.departamento:
|
||||
if empleado.puesto.nombre:
|
||||
if empleado.puesto.departamento.nombre:
|
||||
nomina_receptor['Departamento'] = empleado.puesto.departamento.nombre
|
||||
nomina_receptor['Puesto'] = empleado.puesto.nombre
|
||||
|
||||
|
@ -8833,21 +8832,24 @@ class CfdiNomina(BaseModel):
|
|||
'impuestos': {},
|
||||
'donativo': {},
|
||||
}
|
||||
return util.make_xml(data, certificado, auth)
|
||||
# ~ return util.make_xml(data, certificado, auth)
|
||||
return utils.make_xml(data, certificado)
|
||||
|
||||
def _stamp_id(self, id):
|
||||
auth = Emisor.get_auth()
|
||||
# ~ auth = Emisor.get_auth()
|
||||
auth = Configuracion.get_({'fields': 'pac_auth'})
|
||||
obj = CfdiNomina.get(CfdiNomina.id==id)
|
||||
obj.xml = self._make_xml(self, obj, auth)
|
||||
obj.xml = self._make_xml(self, obj)
|
||||
obj.estatus = 'Generado'
|
||||
obj.save()
|
||||
|
||||
result = util.timbra_xml(obj.xml, auth)
|
||||
# ~ result = util.timbra_xml(obj.xml, auth)
|
||||
result = utils.xml_stamp(obj.xml, auth)
|
||||
# ~ print (result)
|
||||
if result['ok']:
|
||||
obj.xml = result['xml']
|
||||
obj.uuid = result['uuid']
|
||||
obj.fecha_timbrado = result['fecha']
|
||||
obj.fecha_timbrado = result['date']
|
||||
obj.estatus = 'Timbrado'
|
||||
obj.error = ''
|
||||
obj.save()
|
||||
|
@ -8858,7 +8860,6 @@ class CfdiNomina(BaseModel):
|
|||
obj.error = msg
|
||||
obj.save()
|
||||
|
||||
|
||||
return result['ok'], obj.error
|
||||
|
||||
def _stamp(self):
|
||||
|
|
Loading…
Reference in New Issue