diff --git a/source/app/controllers/cfdi_xml.py b/source/app/controllers/cfdi_xml.py index c605617..f02e587 100644 --- a/source/app/controllers/cfdi_xml.py +++ b/source/app/controllers/cfdi_xml.py @@ -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']: diff --git a/source/app/controllers/util.py b/source/app/controllers/util.py index 27d8803..a26d6e4 100644 --- a/source/app/controllers/util.py +++ b/source/app/controllers/util.py @@ -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) diff --git a/source/app/controllers/utils.py b/source/app/controllers/utils.py index 38c196a..21eb2fe 100644 --- a/source/app/controllers/utils.py +++ b/source/app/controllers/utils.py @@ -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] diff --git a/source/app/models/main.py b/source/app/models/main.py index 496a847..ce08700 100644 --- a/source/app/models/main.py +++ b/source/app/models/main.py @@ -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: diff --git a/source/static/js/controller/tickets.js b/source/static/js/controller/tickets.js index 98e31e8..31f937d 100644 --- a/source/static/js/controller/tickets.js +++ b/source/static/js/controller/tickets.js @@ -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) } diff --git a/source/static/js/ui/products.js b/source/static/js/ui/products.js index b15ab8d..df4ab56 100644 --- a/source/static/js/ui/products.js +++ b/source/static/js/ui/products.js @@ -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.'}, ] diff --git a/source/static/js/ui/tickets.js b/source/static/js/ui/tickets.js index bfb96e2..bdd148e 100644 --- a/source/static/js/ui/tickets.js +++ b/source/static/js/ui/tickets.js @@ -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'}