diff --git a/back/models/image.js b/back/models/image.js index 340b2e5a6..113bc7084 100644 --- a/back/models/image.js +++ b/back/models/image.js @@ -90,7 +90,9 @@ module.exports = Self => { ); } - await fs.unlink(srcFilePath); + if (fs.existsSync(srcFilePath)) + await fs.unlink(srcFilePath); + await tx.commit(); return newImage; } catch (e) { diff --git a/modules/item/back/methods/item-image-queue/downloadImages.js b/modules/item/back/methods/item-image-queue/downloadImages.js index c49cb0702..420b357a5 100644 --- a/modules/item/back/methods/item-image-queue/downloadImages.js +++ b/modules/item/back/methods/item-image-queue/downloadImages.js @@ -19,7 +19,6 @@ module.exports = Self => { Self.downloadImages = async() => { const models = Self.app.models; - let image; try { const tempPath = path.join('/tmp/salix-image'); @@ -27,7 +26,7 @@ module.exports = Self => { await fs.mkdir(tempPath, {recursive: true}); const timer = setInterval(async() => { - image = await Self.findOne({where: {error: null}}); + const image = await Self.findOne({where: {error: null}}); // Exit loop if (!image) return clearInterval(timer); @@ -62,9 +61,9 @@ module.exports = Self => { await errorHandler(image.itemFk, error, filePath); } }); - }, 1500); + }, 1000); } catch (error) { - await errorHandler(image.itemFk, error); + throw new Error('Try-catch error: ', error); } async function errorHandler(rowId, error, filePath) { @@ -76,10 +75,10 @@ module.exports = Self => { await row.updateAttribute('error', error); - if (filePath) + if (filePath && fs.existsSync(filePath)) await fs.unlink(filePath); - } catch (error) { - throw error; + } catch (err) { + throw new Error(`ErrorHandler error: ${err}`); } } }; diff --git a/modules/order/back/methods/order/filter.js b/modules/order/back/methods/order/filter.js index bfa64c4dd..66b4244d0 100644 --- a/modules/order/back/methods/order/filter.js +++ b/modules/order/back/methods/order/filter.js @@ -136,14 +136,10 @@ module.exports = Self => { let stmts = []; let stmt; - stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.filter'); - stmt = new ParameterizedSQL( - `CREATE TEMPORARY TABLE tmp.filter - (INDEX (id)) - ENGINE = MEMORY - SELECT + `SELECT o.id, + o.total, o.date_send landed, o.date_make created, o.customer_id clientFk, @@ -178,36 +174,13 @@ module.exports = Self => { } stmt.merge(conn.makeWhere(filter.where)); - stmt.merge({ - sql: `GROUP BY o.id` - }); + stmt.merge(`GROUP BY o.id`); stmt.merge(conn.makePagination(filter)); stmts.push(stmt); - stmts.push(` - CREATE TEMPORARY TABLE tmp.order - (INDEX (orderFk)) - ENGINE = MEMORY - SELECT id AS orderFk - FROM tmp.filter`); + const sql = ParameterizedSQL.join(stmts, ';'); + const result = await conn.executeStmt(sql); - stmts.push('CALL hedera.order_getTotal()'); - - stmt = new ParameterizedSQL( - `SELECT f.*, ot.* - FROM tmp.filter f - LEFT JOIN tmp.orderTotal ot ON ot.orderFk = f.id`); - const orderIndex = stmts.push(stmt) - 1; - - stmts.push(` - DROP TEMPORARY TABLE - tmp.order, - tmp.orderTotal, - tmp.filter`); - - let sql = ParameterizedSQL.join(stmts, ';'); - let result = await conn.executeStmt(sql); - - return result[orderIndex]; + return result; }; }; diff --git a/modules/order/back/models/order.json b/modules/order/back/models/order.json index ab10ad194..38755c2a5 100644 --- a/modules/order/back/models/order.json +++ b/modules/order/back/models/order.json @@ -79,6 +79,9 @@ "mysql": { "columnName": "confirm_date" } + }, + "total": { + "type": "Number" } }, "relations": { diff --git a/modules/order/front/locale/es.yml b/modules/order/front/locale/es.yml index fbc384f21..c35898378 100644 --- a/modules/order/front/locale/es.yml +++ b/modules/order/front/locale/es.yml @@ -23,4 +23,5 @@ Created from: Creado desde Search order by id: Buscar el pedido por identificador order: pedido Confirm lines: Confirmar las lineas -Confirm: Confirmar \ No newline at end of file +Confirm: Confirmar +Real hour: Hora real \ No newline at end of file diff --git a/modules/order/front/search-panel/locale/es.yml b/modules/order/front/search-panel/locale/es.yml index 949f9b202..9546c7f74 100644 --- a/modules/order/front/search-panel/locale/es.yml +++ b/modules/order/front/search-panel/locale/es.yml @@ -7,4 +7,5 @@ Agency: Agencia Application: Aplicación SalesPerson: Comercial Order confirmed: Pedido confirmado -Show empty: Mostrar vacías \ No newline at end of file +Show empty: Mostrar vacías +Search orders by id: Buscar pedido por id \ No newline at end of file