From 2eacf7391ea1d03fdf441277b0c73ac37ddf54ce Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 10 Nov 2023 08:46:49 +0100 Subject: [PATCH] refs #6335 fix(db_ticket_canAdvance): not use unnecessary ifnulls --- CHANGELOG.md | 12 ++++++------ .../00-ticket_canAdvance_update.sql | 18 +++++++++--------- .../back/methods/ticket/componentUpdate.js | 8 ++++---- modules/ticket/front/advance/index.js | 4 ++-- 4 files changed, 21 insertions(+), 21 deletions(-) rename db/changes/{234601 => 234801}/00-ticket_canAdvance_update.sql (90%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 09379e91c..08a62f044 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,12 +7,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [2348.01] - 2023-11-30 -### Added -### Changed -### Fixed - -## [2346.01] - 2023-11-16 - ### Added - (Ticket -> Adelantar) Permite mover lineas sin generar negativos - (Ticket -> Adelantar) Permite modificar la fecha de los tickets @@ -22,6 +16,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - (Ticket -> RocketChat) Arreglada detección de cambios +## [2346.01] - 2023-11-16 + +### Added +### Changed +### Fixed + ## [2342.01] - 2023-11-02 diff --git a/db/changes/234601/00-ticket_canAdvance_update.sql b/db/changes/234801/00-ticket_canAdvance_update.sql similarity index 90% rename from db/changes/234601/00-ticket_canAdvance_update.sql rename to db/changes/234801/00-ticket_canAdvance_update.sql index 272a0618a..afe0a4dc6 100644 --- a/db/changes/234601/00-ticket_canAdvance_update.sql +++ b/db/changes/234801/00-ticket_canAdvance_update.sql @@ -13,8 +13,7 @@ BEGIN SELECT inventoried INTO vDateInventory FROM config; - DROP TEMPORARY TABLE IF EXISTS tmp.stock; - CREATE TEMPORARY TABLE tmp.stock + CREATE OR REPLACE TEMPORARY TABLE tmp.stock (itemFk INT PRIMARY KEY, amount INT) ENGINE = MEMORY; @@ -60,22 +59,23 @@ BEGIN dest.totalWithVat, origin.totalWithVat futureTotalWithVat, dest.agency, + dest.agencyModeFk, origin.futureAgency, + origin.agencyModeFk futureAgencyModeFk, dest.lines, dest.liters, origin.futureLines - origin.hasStock AS notMovableLines, (origin.futureLines = origin.hasStock) AS isFullMovable, + dest.zoneFk, origin.futureZoneFk, origin.futureZoneName, origin.classColor futureClassColor, dest.classColor, - IFNULL(dest.clientFk, origin.clientFk) clientFk, + origin.clientFk futureClientFk, + origin.addressFk futureAddressFk, + origin.warehouseFk futureWarehouseFk, + origin.companyFk futureCompanyFk, IFNULL(dest.nickname, origin.nickname) nickname, - IFNULL(dest.addressFk, origin.addressFk) addressFk, - IFNULL(dest.zoneFk, origin.futureZoneFk) zoneFk, - IFNULL(dest.warehouseFk, origin.warehouseFk) warehouseFk, - IFNULL(dest.companyFk, origin.companyFk) companyFk, - IFNULL(dest.agencyModeFk, origin.agencyModeFk) agencyModeFk, dest.landed FROM ( SELECT @@ -145,7 +145,7 @@ BEGIN AND st.order <= 5 GROUP BY t.id ) dest ON dest.addressFk = origin.addressFk - WHERE origin.hasStock != 0; + WHERE origin.hasStock; DROP TEMPORARY TABLE tmp.stock; END$$ diff --git a/modules/ticket/back/methods/ticket/componentUpdate.js b/modules/ticket/back/methods/ticket/componentUpdate.js index d8d1163da..3acd68cfb 100644 --- a/modules/ticket/back/methods/ticket/componentUpdate.js +++ b/modules/ticket/back/methods/ticket/componentUpdate.js @@ -196,7 +196,7 @@ module.exports = Self => { ] }, myOptions); const originalTicket = JSON.parse(JSON.stringify(ticketToChange)); - const ticketChages = { + const ticketChanges = { clientFk: args.clientFk, nickname: args.nickname, agencyModeFk: args.agencyModeFk, @@ -211,13 +211,13 @@ module.exports = Self => { let response; if (args.keepPrice) { - ticketChages.routeFk = null; - response = await ticketToChange.updateAttributes(ticketChages, myOptions); + ticketChanges.routeFk = null; + response = await ticketToChange.updateAttributes(ticketChanges, myOptions); } else { const hasToBeUnrouted = true; response = await Self.rawSql( 'CALL vn.ticket_componentMakeUpdate(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', - [args.id].concat(Object.values(ticketChages), [hasToBeUnrouted, args.option]), + [args.id].concat(Object.values(ticketChanges), [hasToBeUnrouted, args.option]), myOptions ); } diff --git a/modules/ticket/front/advance/index.js b/modules/ticket/front/advance/index.js index 5ab663256..fb539311f 100644 --- a/modules/ticket/front/advance/index.js +++ b/modules/ticket/front/advance/index.js @@ -215,9 +215,9 @@ export default class Controller extends Section { const params = { clientFk: ticket.clientFk, nickname: ticket.nickname, - agencyModeFk: ticket.agencyModeFk, + agencyModeFk: ticket.agencyModeFk ?? ticket.futureAgencyModeFk, addressFk: ticket.addressFk, - zoneFk: ticket.zoneFk, + zoneFk: ticket.zoneFk ?? ticket.futureZoneFk, warehouseFk: ticket.warehouseFk, companyFk: ticket.companyFk, shipped: this.$.model.userParams.dateToAdvance,