From d622975a89b5a6fa9cb79701cf05e62e4ea3987f Mon Sep 17 00:00:00 2001 From: Mauricio Baeza Date: Tue, 6 Feb 2018 12:07:35 -0600 Subject: [PATCH] =?UTF-8?q?Plantilla=20N=C3=B3mina=20#173?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/app/controllers/util.py | 20 +++++++++++++++++--- source/app/models/main.py | 10 +++++++++- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/source/app/controllers/util.py b/source/app/controllers/util.py index db49197..cd510af 100644 --- a/source/app/controllers/util.py +++ b/source/app/controllers/util.py @@ -737,7 +737,7 @@ class LIBO(object): def _comprobante(self, data): for k, v in data.items(): - if k in ('total', 'descuento', 'subtotal'): + if k.lower() in ('total', 'descuento', 'subtotal', 'totalgravado', 'totalexento'): self._set_cell('{cfdi.%s}' % k, v, value=True) else: self._set_cell('{cfdi.%s}' % k, v) @@ -750,7 +750,10 @@ class LIBO(object): def _receptor(self, data): for k, v in data.items(): - self._set_cell('{receptor.%s}' % k, v) + if k.lower() in ('salariobasecotapor', 'salariodiariointegrado'): + self._set_cell('{receptor.%s}' % k, v, value=True) + else: + self._set_cell('{receptor.%s}' % k, v) return def _copy_row(self, cell): @@ -788,6 +791,7 @@ class LIBO(object): col4 = [] col5 = [] col6 = [] + col7 = [] count = len(data)-1 for concepto in data: key = concepto.get('noidentificacion', '') @@ -796,6 +800,7 @@ class LIBO(object): cantidad = concepto['cantidad'] valor_unitario = concepto['valorunitario'] importe = concepto['importe'] + descuento = concepto.get('descuento', 0.0) if first: first = False cell_1 = self._set_cell('{noidentificacion}', key) @@ -804,6 +809,7 @@ class LIBO(object): cell_4 = self._set_cell('{cantidad}', cantidad, value=True) cell_5 = self._set_cell('{valorunitario}', valor_unitario, value=True) cell_6 = self._set_cell('{importe}', importe, value=True) + cell_7 = self._set_cell('{descuento}', descuento, value=True) if len(data) > 1: row = cell_1.getCellAddress().Row + 1 self._sheet.getRows().insertByIndex(row, count) @@ -816,6 +822,7 @@ class LIBO(object): col4.append((float(cantidad),)) col5.append((float(valor_unitario),)) col6.append((float(importe),)) + col7.append((float(descuento),)) if not count: return @@ -955,7 +962,11 @@ class LIBO(object): otrospagos = data.pop('otrospagos', []) for k, v in data.items(): - self._set_cell('{nomina.%s}' % k, v) + if k.lower() in ('totalpercepciones', 'totaldeducciones', + 'totalotrospagos', 'subsidiocausado'): + self._set_cell('{nomina.%s}' % k, v, value=True) + else: + self._set_cell('{nomina.%s}' % k, v) count = len(percepciones) if len(deducciones) > count: @@ -1389,6 +1400,8 @@ def _comprobante(doc, options): is_nomina = options.get('is_nomina', False) if is_nomina: + data['formadepago'] = options['formadepago'] + data['periodicidaddepago'] = options['periodicidaddepago'] return data if data['version'] == '3.3': @@ -1402,6 +1415,7 @@ def _comprobante(doc, options): 'C.P. de Expedición: {}'.format(data['lugarexpedicion']) data['metododepago'] = options['metododepago'] data['formadepago'] = options['formadepago'] + if 'condicionesdepago' in data: data['condicionesdepago'] = \ 'Condiciones de pago: {}'.format(data['condicionesdepago']) diff --git a/source/app/models/main.py b/source/app/models/main.py index a70e66e..dda0428 100644 --- a/source/app/models/main.py +++ b/source/app/models/main.py @@ -6420,7 +6420,15 @@ class CfdiNomina(BaseModel): if invoice.version == '3.2': return values - values['regimenfiscal'] = invoice.regimen_fiscal + obj = SATRegimenes.get(SATRegimenes.key==invoice.regimen_fiscal) + values['regimenfiscal'] = str(obj) + + obj = SATFormaPago.get(SATFormaPago.key==invoice.forma_pago) + values['formadepago'] = '{} ({})'.format(obj.name, obj.key) + + obj = SATPeriodicidadPago.get(SATPeriodicidadPago.id==invoice.empleado.periodicidad_pago) + values['periodicidaddepago'] = '{} ({})'.format(obj.name, obj.key) + values['usocfdi'] = invoice.uso_cfdi values['receptor'] = {} values['fechadof'] = None