Factura global
This commit is contained in:
parent
a6276a33fb
commit
a13c7c0a1d
|
@ -151,6 +151,7 @@ class CFDI(object):
|
|||
return ''
|
||||
|
||||
self._comprobante(datos['comprobante'])
|
||||
self._informacion_global(datos['global'])
|
||||
self._relacionados(datos['relacionados'])
|
||||
self._emisor(datos['emisor'])
|
||||
self._receptor(datos['receptor'])
|
||||
|
@ -288,6 +289,14 @@ class CFDI(object):
|
|||
self._cfdi = ET.Element('{}:Comprobante'.format(self._pre), attributes)
|
||||
return
|
||||
|
||||
def _informacion_global(self, datos):
|
||||
if not datos:
|
||||
return
|
||||
|
||||
node_name = '{}:InformacionGlobal'.format(self._pre)
|
||||
node = ET.SubElement(self._cfdi, node_name, datos)
|
||||
return
|
||||
|
||||
def _relacionados(self, datos):
|
||||
if not datos or not datos['tipo'] or not datos['cfdis']:
|
||||
return
|
||||
|
@ -586,7 +595,7 @@ class CFDI(object):
|
|||
node = ET.SubElement(node_pago, f'{pre}:DoctoRelacionado', row)
|
||||
node_tax = ET.SubElement(node, f'{pre}:ImpuestosDR')
|
||||
if taxes['retenciones']:
|
||||
node = ET.SubElement(node_tax, f'{pre}:RetencionsDR')
|
||||
node = ET.SubElement(node_tax, f'{pre}:RetencionesDR')
|
||||
for tax in taxes['retenciones']:
|
||||
ET.SubElement(node, f'{pre}:RetencionDR', tax)
|
||||
if taxes['traslados']:
|
||||
|
|
|
@ -637,6 +637,12 @@ class LIBO(object):
|
|||
self._set_cell('{cfdi.%s}' % k, v)
|
||||
return
|
||||
|
||||
def _informacion_global(self, data):
|
||||
for k, v in data.items():
|
||||
print(k, v)
|
||||
self._set_cell('{cfdi.%s}' % k, v)
|
||||
return
|
||||
|
||||
def _emisor(self, data):
|
||||
for k, v in data.items():
|
||||
self._set_cell('{emisor.%s}' % k, v)
|
||||
|
@ -1222,6 +1228,7 @@ class LIBO(object):
|
|||
pakings = data.pop('pakings', [])
|
||||
|
||||
self._comprobante(data['comprobante'])
|
||||
self._informacion_global(data['informacion_global'])
|
||||
self._emisor(data['emisor'])
|
||||
self._receptor(data['receptor'])
|
||||
self._conceptos(data['conceptos'], pakings)
|
||||
|
|
|
@ -357,6 +357,16 @@ class CfdiToDict(object):
|
|||
'YUC': 'Yucatán',
|
||||
'ZAC': 'Zacatecas',
|
||||
}
|
||||
PERIODICIDAD = {
|
||||
'01': '[01] Diario',
|
||||
'02': '[02] Semanal',
|
||||
'03': '[03] Quincenal',
|
||||
'04': '[04] Mensual',
|
||||
'05': '[05] Bimestral',
|
||||
}
|
||||
MESES = {
|
||||
'12': '[12] Diciembre',
|
||||
}
|
||||
|
||||
def __init__(self, xml):
|
||||
self.version = ''
|
||||
|
@ -374,11 +384,28 @@ class CfdiToDict(object):
|
|||
self.version = self._root.attrib['Version']
|
||||
ns = f'cfdi{self.version}'
|
||||
self.NS['cfdi'] = self.NS_VERSION[ns]
|
||||
|
||||
self._informacion_global()
|
||||
self._receptor()
|
||||
self._complementos()
|
||||
return
|
||||
|
||||
def _informacion_global(self):
|
||||
self._values['informacion_global'] = {}
|
||||
|
||||
path = '//cfdi:InformacionGlobal'
|
||||
data = self._root.xpath(path, namespaces=self.NS)
|
||||
if not data:
|
||||
return
|
||||
|
||||
data = data[0]
|
||||
attr = CaseInsensitiveDict(data.attrib)
|
||||
|
||||
value = f"Periodicidad Factura Global: {self.PERIODICIDAD[attr['Periodicidad']]} "
|
||||
value += f"del mes {self.MESES[attr['Meses']]} "
|
||||
value += f"del año {attr['Año']}"
|
||||
self._values['informacion_global'] = {'informacion_global': value}
|
||||
return
|
||||
|
||||
def _receptor(self):
|
||||
path = '//cfdi:Receptor'
|
||||
receptor = self._root.xpath(path, namespaces=self.NS)[0]
|
||||
|
|
|
@ -5632,9 +5632,8 @@ class Facturas(BaseModel):
|
|||
tax_decimals = Configuracion.get_bool('chk_config_tax_decimals')
|
||||
decimales_precios = Configuracion.get_bool('chk_config_decimales_precios')
|
||||
invoice_by_ticket = Configuracion.get_bool('chk_config_invoice_by_ticket')
|
||||
# ~ is_global = (invoice.cliente.rfc == RFCS['PUBLIC']) and invoice_by_ticket
|
||||
|
||||
is_global = bool(invoice.periodicidad)
|
||||
|
||||
data_global = {}
|
||||
if is_global:
|
||||
now = utils.now()
|
||||
|
@ -5707,6 +5706,7 @@ class Facturas(BaseModel):
|
|||
'Nombre': emisor.nombre,
|
||||
'RegimenFiscal': invoice.regimen_fiscal,
|
||||
}
|
||||
|
||||
receptor = {
|
||||
'Rfc': invoice.cliente.rfc,
|
||||
'Nombre': invoice.cliente.nombre,
|
||||
|
@ -5714,6 +5714,7 @@ class Facturas(BaseModel):
|
|||
'DomicilioFiscalReceptor': invoice.cliente.codigo_postal,
|
||||
'RegimenFiscalReceptor': invoice.receptor_regimen
|
||||
}
|
||||
|
||||
if invoice.cliente.tipo_persona == 4:
|
||||
if invoice.cliente.pais:
|
||||
receptor['ResidenciaFiscal'] = invoice.cliente.pais
|
||||
|
@ -5735,11 +5736,14 @@ class Facturas(BaseModel):
|
|||
'NoIdentificacion': key,
|
||||
'Cantidad': FORMAT.format(row.cantidad),
|
||||
'ClaveUnidad': row.unidad,
|
||||
'Unidad': SATUnidades.get(SATUnidades.key==row.unidad).name[:20],
|
||||
# ~ 'Unidad': SATUnidades.get(SATUnidades.key==row.unidad).name[:20],
|
||||
'Descripcion': row.descripcion,
|
||||
'ValorUnitario': frm_vu.format(row.valor_unitario),
|
||||
'Importe': FORMAT.format(row.importe),
|
||||
}
|
||||
if not is_global:
|
||||
concepto['Unidad'] = SATUnidades.get(SATUnidades.key==row.unidad).name[:20],
|
||||
|
||||
if row.descuento:
|
||||
concepto['Descuento'] = FORMAT.format(row.descuento)
|
||||
|
||||
|
@ -5826,7 +5830,7 @@ class Facturas(BaseModel):
|
|||
concepto['impuestos'] = taxes
|
||||
|
||||
# cfdi4
|
||||
if row.producto.objeto_impuesto:
|
||||
if not is_global:
|
||||
concepto['ObjetoImp'] = row.producto.objeto_impuesto
|
||||
else:
|
||||
if taxes:
|
||||
|
|
|
@ -611,7 +611,9 @@ function cmd_cancelar_ticket_click(){
|
|||
|
||||
function chk_is_invoice_day_change(new_value, old_value){
|
||||
var value = Boolean(new_value)
|
||||
|
||||
show('fs_ticket_search_client', !value)
|
||||
enable('lst_periodicidad', value)
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -115,6 +115,7 @@ var opt_tax_object = [
|
|||
{id: '01', value: '[01] No objeto de impuesto.'},
|
||||
{id: '02', value: '[02] Sí objeto de impuesto.'},
|
||||
{id: '03', value: '[03] Sí objeto del impuesto y no obligado al desglose.'},
|
||||
{id: '04', value: '[04] Sí objeto del impuesto y no causa impuesto.'},
|
||||
]
|
||||
|
||||
|
||||
|
|
|
@ -246,7 +246,7 @@ var toolbar_ticket_invoice = {view: 'toolbar', elements: [{},
|
|||
{view: 'checkbox', id: 'chk_is_invoice_day', labelWidth: 0, width: 150,
|
||||
labelRight: 'Es factura del día'},
|
||||
{view: 'richselect', id: 'lst_periodicidad', labelWidth: 90, width: 250,
|
||||
label: 'Periodicidad:', options: opt_periodicidad, value: '01'},
|
||||
label: 'Periodicidad:', options: opt_periodicidad, value: '01', disabled: true},
|
||||
{},
|
||||
{view: 'button', id: 'cmd_close_ticket_invoice', label: 'Cerrar',
|
||||
type: 'danger', autowidth: true, align: 'center'}
|
||||
|
|
Loading…
Reference in New Issue