Stamp CE in version 2.0
This commit is contained in:
parent
d2e92098da
commit
510ebdd1e5
|
@ -169,7 +169,9 @@ class CFDI(object):
|
||||||
if 'nomina' in datos:
|
if 'nomina' in datos:
|
||||||
self._nomina(datos['nomina'])
|
self._nomina(datos['nomina'])
|
||||||
|
|
||||||
return self._to_pretty_xml(ET.tostring(self._cfdi, encoding='utf-8'))
|
xml = self._to_pretty_xml(ET.tostring(self._cfdi, encoding='utf-8'))
|
||||||
|
|
||||||
|
return xml
|
||||||
|
|
||||||
def add_sello(self, sello, cert_txt):
|
def add_sello(self, sello, cert_txt):
|
||||||
self._cfdi.attrib['Sello'] = sello
|
self._cfdi.attrib['Sello'] = sello
|
||||||
|
@ -518,6 +520,47 @@ class CFDI(object):
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def _complemento_comercio_exterior(self, datos):
|
||||||
|
prefix = SAT['comercioe']['prefix']
|
||||||
|
|
||||||
|
emisor = datos.pop('emisor')
|
||||||
|
propietarios = datos.pop('propietarios', {})
|
||||||
|
receptor = datos.pop('receptor')
|
||||||
|
destinatario = datos.pop('destinatario', {})
|
||||||
|
mercancias = datos.pop('mercancias')
|
||||||
|
|
||||||
|
attr = {'Version': SAT['comercioe']['version']}
|
||||||
|
attr.update(datos)
|
||||||
|
ce = ET.SubElement(
|
||||||
|
self._complemento, f'{prefix}:ComercioExterior', attr)
|
||||||
|
|
||||||
|
attributes = {}
|
||||||
|
if 'Curp' in emisor:
|
||||||
|
attributes = {'Curp': emisor.pop('Curp')}
|
||||||
|
node = ET.SubElement(ce, '{}:Emisor'.format(prefix), attributes)
|
||||||
|
ET.SubElement(node, '{}:Domicilio'.format(prefix), emisor)
|
||||||
|
|
||||||
|
attributes = {}
|
||||||
|
if 'NumRegIdTrib' in receptor:
|
||||||
|
attributes = {'NumRegIdTrib': receptor.pop('NumRegIdTrib')}
|
||||||
|
node = ET.SubElement(ce, '{}:Receptor'.format(prefix), attributes)
|
||||||
|
ET.SubElement(node, '{}:Domicilio'.format(prefix), receptor)
|
||||||
|
|
||||||
|
node = ET.SubElement(ce, '{}:Mercancias'.format(prefix))
|
||||||
|
fields = ('Marca', 'Modelo', 'SubModelo', 'NumeroSerie')
|
||||||
|
for row in mercancias:
|
||||||
|
detalle = {}
|
||||||
|
for f in fields:
|
||||||
|
if f in row and row[f]:
|
||||||
|
detalle[f] = row[f]
|
||||||
|
row.pop(f)
|
||||||
|
concepto = ET.SubElement(node, '{}:Mercancia'.format(prefix), row)
|
||||||
|
if detalle:
|
||||||
|
ET.SubElement(
|
||||||
|
concepto, '{}:DescripcionesEspecificas'.format(prefix), detalle)
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
def _complementos(self, datos):
|
def _complementos(self, datos):
|
||||||
if not datos:
|
if not datos:
|
||||||
return
|
return
|
||||||
|
@ -642,52 +685,7 @@ class CFDI(object):
|
||||||
ET.SubElement(node_leyend, '{}:Leyenda'.format(pre), leyend)
|
ET.SubElement(node_leyend, '{}:Leyenda'.format(pre), leyend)
|
||||||
|
|
||||||
if self._comercio_exterior:
|
if self._comercio_exterior:
|
||||||
prefix = SAT['comercioe']['prefix']
|
|
||||||
datos = datos.pop('comercioe')
|
datos = datos.pop('comercioe')
|
||||||
|
self._complemento_comercio_exterior(datos)
|
||||||
|
|
||||||
emisor = datos.pop('emisor')
|
|
||||||
propietarios = datos.pop('propietarios', {})
|
|
||||||
receptor = datos.pop('receptor')
|
|
||||||
destinatario = datos.pop('destinatario', {})
|
|
||||||
mercancias = datos.pop('mercancias')
|
|
||||||
|
|
||||||
attr = {'Version': SAT['comercioe']['version']}
|
|
||||||
attr.update(datos)
|
|
||||||
ce = ET.SubElement(
|
|
||||||
self._complemento, f'{prefix}:ComercioExterior', attr)
|
|
||||||
|
|
||||||
attributes = {}
|
|
||||||
if 'Curp' in emisor:
|
|
||||||
attributes = {'Curp': emisor.pop('Curp')}
|
|
||||||
node = ET.SubElement(ce, '{}:Emisor'.format(prefix), attributes)
|
|
||||||
ET.SubElement(node, '{}:Domicilio'.format(prefix), emisor)
|
|
||||||
|
|
||||||
# ~ if propietario:
|
|
||||||
# ~ ET.SubElement(ce, '{}:Propietario'.format(prefix), propietario)
|
|
||||||
|
|
||||||
attributes = {}
|
|
||||||
if 'NumRegIdTrib' in receptor:
|
|
||||||
attributes = {'NumRegIdTrib': receptor.pop('NumRegIdTrib')}
|
|
||||||
node = ET.SubElement(ce, '{}:Receptor'.format(prefix), attributes)
|
|
||||||
ET.SubElement(node, '{}:Domicilio'.format(prefix), receptor)
|
|
||||||
|
|
||||||
# ~ attributes = {}
|
|
||||||
# ~ if 'NumRegIdTrib' in destinatario:
|
|
||||||
# ~ attributes = {'NumRegIdTrib': destinatario.pop('NumRegIdTrib')}
|
|
||||||
# ~ if 'Nombre' in destinatario:
|
|
||||||
# ~ attributes.update({'Nombre': destinatario.pop('Nombre')})
|
|
||||||
# ~ node = ET.SubElement(ce, '{}:Destinatario'.format(prefix), attributes)
|
|
||||||
# ~ ET.SubElement(node, '{}:Domicilio'.format(prefix), destinatario)
|
|
||||||
|
|
||||||
node = ET.SubElement(ce, '{}:Mercancias'.format(prefix))
|
|
||||||
fields = ('Marca', 'Modelo', 'SubModelo', 'NumeroSerie')
|
|
||||||
for row in mercancias:
|
|
||||||
detalle = {}
|
|
||||||
for f in fields:
|
|
||||||
if f in row:
|
|
||||||
detalle[f] = row.pop(f)
|
|
||||||
concepto = ET.SubElement(node, '{}:Mercancia'.format(prefix), row)
|
|
||||||
if detalle:
|
|
||||||
ET.SubElement(
|
|
||||||
concepto, '{}:DescripcionesEspecificas'.format(prefix), detalle)
|
|
||||||
return
|
return
|
||||||
|
|
|
@ -1576,11 +1576,12 @@ class LIBO(object):
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def _current_region_to_tuple(self, cursor):
|
def _current_region_to_tuple(self, cursor):
|
||||||
|
data = []
|
||||||
cursor.collapseToCurrentRegion()
|
cursor.collapseToCurrentRegion()
|
||||||
rows = cursor.getDataArray()[1:]
|
rows = cursor.getDataArray()[1:]
|
||||||
|
|
||||||
if len(rows) == 2:
|
if len(rows) == 1:
|
||||||
return []
|
return data
|
||||||
|
|
||||||
keys = rows[0]
|
keys = rows[0]
|
||||||
data = [dict(zip(keys, values)) for values in rows[1:]]
|
data = [dict(zip(keys, values)) for values in rows[1:]]
|
||||||
|
|
|
@ -5623,8 +5623,6 @@ class Facturas(BaseModel):
|
||||||
if not valores:
|
if not valores:
|
||||||
return
|
return
|
||||||
|
|
||||||
# ~ values = utils.loads(valores)
|
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
'factura': invoice,
|
'factura': invoice,
|
||||||
'nombre': 'comercioe',
|
'nombre': 'comercioe',
|
||||||
|
|
|
@ -247,6 +247,7 @@ function default_config(){
|
||||||
$$('tv_invoice').getTabbar().hideOption('Comercio Exterior')
|
$$('tv_invoice').getTabbar().hideOption('Comercio Exterior')
|
||||||
}else{
|
}else{
|
||||||
$$('tv_invoice').getTabbar().showOption('Comercio Exterior')
|
$$('tv_invoice').getTabbar().showOption('Comercio Exterior')
|
||||||
|
_set_default_comercio_exterior()
|
||||||
}
|
}
|
||||||
cfg_invoice['leyendasfiscales'] = values.cfdi_leyendasfiscales
|
cfg_invoice['leyendasfiscales'] = values.cfdi_leyendasfiscales
|
||||||
cfg_invoice['edu'] = values.cfdi_edu
|
cfg_invoice['edu'] = values.cfdi_edu
|
||||||
|
@ -2961,7 +2962,48 @@ function up_invoice_json_on_after_file_add(obj){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function _set_default_comercio_exterior(){
|
||||||
|
const controls = {
|
||||||
|
lst_ce_exportacion: '02',
|
||||||
|
lst_ce_motivo_traslado: '',
|
||||||
|
lst_ce_clave_pedimento: 'A1',
|
||||||
|
lst_ce_certificado_origen: '0',
|
||||||
|
txt_ce_numero_certificado: '',
|
||||||
|
txt_ce_numero_exportador: '',
|
||||||
|
lst_ce_incoterm: 'CFR',
|
||||||
|
txt_ce_observaciones: '',
|
||||||
|
txt_ce_tipo_cambio_usd: '',
|
||||||
|
txt_ce_total_usd: '',
|
||||||
|
};
|
||||||
|
|
||||||
|
Object.keys(controls).forEach(key => {
|
||||||
|
$$(key).setValue(controls[key])
|
||||||
|
});
|
||||||
|
|
||||||
|
var grid = $$('grid_ce_emisor')
|
||||||
|
grid.clearAll()
|
||||||
|
grid.add({id: 0})
|
||||||
|
|
||||||
|
var grid = $$('grid_ce_receptor')
|
||||||
|
grid.clearAll()
|
||||||
|
grid.add({id: 0})
|
||||||
|
|
||||||
|
var grid = $$('grid_ce_destinatario')
|
||||||
|
grid.clearAll()
|
||||||
|
grid.add({id: 0})
|
||||||
|
|
||||||
|
var grid = $$('grid_ce_propietarios')
|
||||||
|
grid.clearAll()
|
||||||
|
|
||||||
|
var grid = $$('grid_ce_mercancias')
|
||||||
|
grid.clearAll()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function _set_from_json_comercioe(data, json){
|
function _set_from_json_comercioe(data, json){
|
||||||
|
|
||||||
|
_set_default_comercio_exterior()
|
||||||
|
|
||||||
try{
|
try{
|
||||||
if(json){
|
if(json){
|
||||||
values = JSON.parse(data)
|
values = JSON.parse(data)
|
||||||
|
|
Loading…
Reference in New Issue