From 32815bad510a4b0767076dc18080c9021abca2e6 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 4 Sep 2024 09:24:07 +0200 Subject: [PATCH 1/5] revert(salix): rollback limit query --- loopback/common/models/vn-model.js | 30 +++++++++++++++--------------- loopback/server/boot/orm.js | 12 ++++++------ 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/loopback/common/models/vn-model.js b/loopback/common/models/vn-model.js index 6fcb6f0e3..a11bed11d 100644 --- a/loopback/common/models/vn-model.js +++ b/loopback/common/models/vn-model.js @@ -27,25 +27,25 @@ module.exports = function(Self) { }; }); - // this.beforeRemote('**', async ctx => { - // if (!this.hasFilter(ctx)) return; + this.beforeRemote('**', async ctx => { + if (!this.hasFilter(ctx)) return; - // const defaultLimit = this.app.orm.selectLimit; - // const filter = ctx.args.filter || {limit: defaultLimit}; + const defaultLimit = this.app.orm.selectLimit; + const filter = ctx.args.filter || {limit: defaultLimit}; - // if (filter.limit > defaultLimit) { - // filter.limit = defaultLimit; - // ctx.args.filter = filter; - // } - // }); + if (filter.limit > defaultLimit) { + filter.limit = defaultLimit; + ctx.args.filter = filter; + } + }); - // this.afterRemote('**', async ctx => { - // if (!this.hasFilter(ctx)) return; + this.afterRemote('**', async ctx => { + if (!this.hasFilter(ctx)) return; - // const {result} = ctx; - // const length = Array.isArray(result) ? result.length : result ? 1 : 0; - // if (length >= this.app.orm.selectLimit) throw new UserError('Too many records'); - // }); + const {result} = ctx; + const length = Array.isArray(result) ? result.length : result ? 1 : 0; + if (length >= this.app.orm.selectLimit) throw new UserError('Too many records'); + }); // Register field ACL validation /* diff --git a/loopback/server/boot/orm.js b/loopback/server/boot/orm.js index ccd9d4eca..8bbd969e1 100644 --- a/loopback/server/boot/orm.js +++ b/loopback/server/boot/orm.js @@ -1,6 +1,6 @@ -// module.exports = async function(app) { -// if (!app.orm) { -// const ormConfig = await app.models.OrmConfig.findOne(); -// app.orm = ormConfig; -// } -// }; +module.exports = async function(app) { + if (!app.orm) { + const ormConfig = await app.models.OrmConfig.findOne(); + app.orm = ormConfig; + } +}; From 8311795fd8dd9dac88b718df423129b589b9ed09 Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 4 Sep 2024 12:16:42 +0200 Subject: [PATCH 2/5] refactor: refs #7524 dynamic fetch --- modules/ticket/front/sale-tracking/index.html | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/modules/ticket/front/sale-tracking/index.html b/modules/ticket/front/sale-tracking/index.html index f05cf15fb..3bf35ae39 100644 --- a/modules/ticket/front/sale-tracking/index.html +++ b/modules/ticket/front/sale-tracking/index.html @@ -6,16 +6,6 @@ order="concept ASC, quantity DESC" auto-load="true"> - - - - @@ -208,7 +198,7 @@ Date: Wed, 4 Sep 2024 13:36:57 +0200 Subject: [PATCH 3/5] fix: hotfix --- print/templates/reports/sepa-core/sql/supplier.sql | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/print/templates/reports/sepa-core/sql/supplier.sql b/print/templates/reports/sepa-core/sql/supplier.sql index da543147a..e7bede26d 100644 --- a/print/templates/reports/sepa-core/sql/supplier.sql +++ b/print/templates/reports/sepa-core/sql/supplier.sql @@ -7,8 +7,8 @@ SELECT m.code mandateCode, sp.name province, ad.value accountDetailValue FROM client c - JOIN mandate m ON m.clientFk = c.id - JOIN mandateType mt ON mt.id = m.mandateTypeFk + JOIN mandate m ON m.clientFk = c.id + JOIN mandateType mt ON mt.id = m.mandateTypeFk JOIN supplier s ON s.id = m.companyFk LEFT JOIN country sc ON sc.id = s.countryFk LEFT JOIN province sp ON sp.id = s.provinceFk @@ -18,7 +18,7 @@ SELECT m.code mandateCode, WHERE m.companyFk = ? AND m.finished IS NULL AND c.id = ? - AND mt.name = 'CORE' + AND mt.code = 'CORE' AND adt.description = 'Referencia Remesas' GROUP BY m.id, ad.value - ORDER BY m.created DESC \ No newline at end of file + ORDER BY m.created DESC From e574f0060a78aa0c4d9ea2f27707262883bae73d Mon Sep 17 00:00:00 2001 From: Pako Date: Wed, 4 Sep 2024 13:37:13 +0200 Subject: [PATCH 4/5] hotfix --- .../vn/procedures/sale_getProblems.sql | 65 +++++++++---------- .../11205-grayCymbidium/00-firstScript.sql | 2 + 2 files changed, 31 insertions(+), 36 deletions(-) create mode 100644 db/versions/11205-grayCymbidium/00-firstScript.sql diff --git a/db/routines/vn/procedures/sale_getProblems.sql b/db/routines/vn/procedures/sale_getProblems.sql index 8df28dbc0..7c5204e0d 100644 --- a/db/routines/vn/procedures/sale_getProblems.sql +++ b/db/routines/vn/procedures/sale_getProblems.sql @@ -23,43 +23,36 @@ BEGIN DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - DELETE tt.* - FROM tmp.sale_getProblems tt - JOIN ticketObservation tto ON tto.ticketFk = tt.ticketFk - JOIN observationType ot ON ot.id = tto.observationTypeFk - WHERE ot.code = 'administrative' - AND tto.description = 'Miriam'; + CREATE OR REPLACE TEMPORARY TABLE tmp.sale_problems ( + ticketFk INT(11), + saleFk INT(11), + isFreezed INTEGER(1) DEFAULT 0, + risk DECIMAL(10,1) DEFAULT 0, + hasRisk TINYINT(1) DEFAULT 0, + hasHighRisk TINYINT(1) DEFAULT 0, + hasTicketRequest INTEGER(1) DEFAULT 0, + itemShortage VARCHAR(255), + isTaxDataChecked INTEGER(1) DEFAULT 1, + itemDelay VARCHAR(255), + itemLost VARCHAR(255), + hasComponentLack INTEGER(1), + hasRounding VARCHAR(255), + isTooLittle BOOL DEFAULT FALSE, + isVip BOOL DEFAULT FALSE, + PRIMARY KEY (ticketFk, saleFk) + ) ENGINE = MEMORY; - CREATE OR REPLACE TEMPORARY TABLE tmp.sale_problems ( - ticketFk INT(11), - saleFk INT(11), - isFreezed INTEGER(1) DEFAULT 0, - risk DECIMAL(10,1) DEFAULT 0, - hasRisk TINYINT(1) DEFAULT 0, - hasHighRisk TINYINT(1) DEFAULT 0, - hasTicketRequest INTEGER(1) DEFAULT 0, - itemShortage VARCHAR(255), - isTaxDataChecked INTEGER(1) DEFAULT 1, - itemDelay VARCHAR(255), - itemLost VARCHAR(255), - hasComponentLack INTEGER(1), - hasRounding VARCHAR(255), - isTooLittle BOOL DEFAULT FALSE, - isVip BOOL DEFAULT FALSE, - PRIMARY KEY (ticketFk, saleFk) - ) ENGINE = MEMORY; - - INSERT INTO tmp.sale_problems(ticketFk, - saleFk, - isFreezed, - risk, - hasRisk, - hasHighRisk, - hasTicketRequest, - isTaxDataChecked, - hasComponentLack, - hasRounding, - isTooLittle) + INSERT INTO tmp.sale_problems(ticketFk, + saleFk, + isFreezed, + risk, + hasRisk, + hasHighRisk, + hasTicketRequest, + isTaxDataChecked, + hasComponentLack, + hasRounding, + isTooLittle) SELECT sgp.ticketFk, s.id, IF(FIND_IN_SET('isFreezed', t.problem), TRUE, FALSE) isFreezed, diff --git a/db/versions/11205-grayCymbidium/00-firstScript.sql b/db/versions/11205-grayCymbidium/00-firstScript.sql new file mode 100644 index 000000000..ba3ab60e1 --- /dev/null +++ b/db/versions/11205-grayCymbidium/00-firstScript.sql @@ -0,0 +1,2 @@ +-- Place your SQL code here +ALTER TABLE dipole.expedition_PrintOut MODIFY COLUMN isPrinted int(11) DEFAULT 0 NOT NULL COMMENT '0.- Not Printed ; 1.- Printed; 2.- Selected ; 3.- Error ; 4.- Waiting to be printed'; From 212e8d1a037c397f9491f54b6fde309713334024 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 4 Sep 2024 14:09:31 +0200 Subject: [PATCH 5/5] fix: refs #7346 invoiceSerial --- db/routines/vn/functions/invoiceSerial.sql | 37 +++++++++----- modules/ticket/back/methods/ticket/closure.js | 49 +++++++------------ 2 files changed, 41 insertions(+), 45 deletions(-) diff --git a/db/routines/vn/functions/invoiceSerial.sql b/db/routines/vn/functions/invoiceSerial.sql index 9df887cf5..10ab7a797 100644 --- a/db/routines/vn/functions/invoiceSerial.sql +++ b/db/routines/vn/functions/invoiceSerial.sql @@ -1,18 +1,23 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`invoiceSerial`(vClientFk INT, vCompanyFk INT, vType CHAR(15)) +CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`invoiceSerial`( + vClientFk INT, + vCompanyFk INT, + vType CHAR(15) +) RETURNS char(2) CHARSET utf8mb3 COLLATE utf8mb3_general_ci DETERMINISTIC BEGIN - /** - * Obtiene la serie de una factura - * dependiendo del area del cliente. - * - * @param vClientFk Id del cliente - * @param vCompanyFk Id de la empresa - * @param vType Tipo de factura ['global','multiple','quick'] - * @return vSerie de la factura - */ +/** +* Obtiene la serie de una factura +* dependiendo del area del cliente. +* +* @param vClientFk Id del cliente +* @param vCompanyFk Id de la empresa +* @param vType Tipo de factura (vn.invoiceOutSerial.type[ENUM]) +* @return vSerie de la factura +*/ DECLARE vTaxArea VARCHAR(25) COLLATE utf8mb3_general_ci; + DECLARE vTransactionCode INT(2); DECLARE vSerie CHAR(2); IF (SELECT hasInvoiceSimplified FROM client WHERE id = vClientFk) THEN @@ -23,9 +28,15 @@ BEGIN FROM client WHERE id = vClientFk; - SELECT code INTO vSerie - FROM invoiceOutSerial - WHERE `type` = vType AND taxAreaFk = vTaxArea; + SELECT CodigoTransaccion INTO vTransactionCode + FROM taxArea + WHERE code = vTaxArea; + + SELECT ios.code INTO vSerie + FROM invoiceOutSerial ios + JOIN taxArea ta ON ta.code = ios.taxAreaFk + WHERE ios.`type` = vType + AND ta.CodigoTransaccion = vTransactionCode; RETURN vSerie; END$$ diff --git a/modules/ticket/back/methods/ticket/closure.js b/modules/ticket/back/methods/ticket/closure.js index fba39f18f..c39d51c02 100644 --- a/modules/ticket/back/methods/ticket/closure.js +++ b/modules/ticket/back/methods/ticket/closure.js @@ -13,23 +13,20 @@ module.exports = async function(ctx, Self, tickets, reqArgs = {}) { const failedtickets = []; for (const ticket of tickets) { try { - await Self.app.models.InvoiceOut.getSerial(ticket.clientFk, ticket.companyFk, ticket.addressFk, 'M'); + await Self.app.models.InvoiceOut.getSerial(ticket.clientFk, ticket.companyFk, ticket.addressFk, 'multiple'); await Self.rawSql( `CALL vn.ticket_closeByTicket(?)`, [ticket.id], {userId} ); - const [invoiceOut] = await Self.rawSql( - ` + const [invoiceOut] = await Self.rawSql(` SELECT io.id, io.ref, io.serial, cny.code companyCode, io.issued FROM ticket t JOIN invoiceOut io ON io.ref = t.refFk JOIN company cny ON cny.id = io.companyFk WHERE t.id = ? - `, - [ticket.id], - ); + `, [ticket.id]); const mailOptions = { overrideAttachments: true, @@ -104,17 +101,14 @@ module.exports = async function(ctx, Self, tickets, reqArgs = {}) { } // Incoterms authorization - const [{firstOrder}] = await Self.rawSql( - ` - SELECT COUNT(*) as firstOrder - FROM ticket t - JOIN client c ON c.id = t.clientFk - WHERE t.clientFk = ? - AND NOT t.isDeleted - AND c.isVies - `, - [ticket.clientFk], - ); + const [{firstOrder}] = await Self.rawSql(` + SELECT COUNT(*) as firstOrder + FROM ticket t + JOIN client c ON c.id = t.clientFk + WHERE t.clientFk = ? + AND NOT t.isDeleted + AND c.isVies + `, [ticket.clientFk]); if (firstOrder == 1) { const args = { @@ -129,26 +123,17 @@ module.exports = async function(ctx, Self, tickets, reqArgs = {}) { const email = new Email('incoterms-authorization', args); await email.send(); - const [sample] = await Self.rawSql( - `SELECT id + const [sample] = await Self.rawSql(` + SELECT id FROM sample - WHERE code = 'incoterms-authorization' - `, - ); + WHERE code = 'incoterms-authorization' + `); - await Self.rawSql( - ` + await Self.rawSql(` INSERT INTO clientSample (clientFk, typeFk, companyFk) VALUES(?, ?, ?) - `, - [ticket.clientFk, sample.id, ticket.companyFk], - {userId}, - ); + `, [ticket.clientFk, sample.id, ticket.companyFk], {userId}); } } catch (error) { - await Self.rawSql(` - INSERT INTO util.debug (variable, value) - VALUES ('invoicingTicketError', ?) - `, [ticket.id + ' - ' + error]); // Domain not found if (error.responseCode == 450) { await invalidEmail(ticket);