From deeeabd3762195acc2c35d36be9555a512d3285e Mon Sep 17 00:00:00 2001 From: Mauricio Baeza Date: Tue, 23 Jan 2018 16:13:49 -0600 Subject: [PATCH 1/2] Mantener orden de productos al facturar una prefactura --- source/app/models/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/app/models/main.py b/source/app/models/main.py index 305c03c..5fe3bd4 100644 --- a/source/app/models/main.py +++ b/source/app/models/main.py @@ -4097,7 +4097,7 @@ class PreFacturasDetalle(BaseModel): productos = PreFacturasDetalle.select().where( PreFacturasDetalle.factura==id) - for p in productos: + for p in reversed(productos): row = {'id': p.producto.id} row['clave'] = p.producto.clave row['descripcion'] = p.descripcion From 49563020e4559134701e38996e725e7303ea37ce Mon Sep 17 00:00:00 2001 From: Mauricio Baeza Date: Tue, 23 Jan 2018 16:25:01 -0600 Subject: [PATCH 2/2] Fix - Issue #143 --- source/app/controllers/util.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/source/app/controllers/util.py b/source/app/controllers/util.py index 72f3b4d..450fa54 100644 --- a/source/app/controllers/util.py +++ b/source/app/controllers/util.py @@ -741,6 +741,13 @@ class LIBO(object): self._set_cell('{receptor.%s}' % k, v) return + def _copy_row(self, cell): + row = cell.getCellAddress().Row + source = self._sheet.getRows().getByIndex(row) + nc = self._next_cell(cell) + self._sheet.copyRange(nc.getCellAddress(), source.getRangeAddress()) + return + def _conceptos(self, data): first = True for concepto in data: @@ -761,16 +768,15 @@ class LIBO(object): if len(data) > 1: row = cell_1.getCellAddress().Row + 1 self._sheet.getRows().insertByIndex(row, len(data)-1) - source = self._sheet.getRows().getByIndex(row - 1) - nc = self._next_cell(cell_1) - self._sheet.copyRange(nc.getCellAddress(), source.getRangeAddress()) else: + self._copy_row(cell_1) cell_1 = self._set_cell(v=key, cell=cell_1) cell_2 = self._set_cell(v=description, cell=cell_2) cell_3 = self._set_cell(v=unidad, cell=cell_3) cell_4 = self._set_cell(v=cantidad, cell=cell_4, value=True) cell_5 = self._set_cell(v=valor_unitario, cell=cell_5, value=True) cell_6 = self._set_cell(v=importe, cell=cell_6, value=True) + return def _add_totales(self, data):