diff --git a/client/core/src/lib/date.js b/client/core/src/lib/date.js index ad3d1d308..1fd9847ca 100644 --- a/client/core/src/lib/date.js +++ b/client/core/src/lib/date.js @@ -5,6 +5,8 @@ * @return {String} Formatted date string */ export function toJsonDate(date) { + date = new Date(date); + let day = date.getDate(); let month = date.getMonth() + 1; let year = date.getFullYear(); @@ -15,5 +17,5 @@ export function toJsonDate(date) { if (month < 10) month = `0${month}` - return `${year}-${month}-${day}`; + return new Date(`${year}-${month}-${day}`); } \ No newline at end of file diff --git a/client/ticket/src/data/step-one/index.html b/client/ticket/src/data/step-one/index.html index 0df72dec2..19bf410c6 100644 --- a/client/ticket/src/data/step-one/index.html +++ b/client/ticket/src/data/step-one/index.html @@ -47,5 +47,18 @@ initial-data="$ctrl.ticket.companyFk"> + + + + + + + diff --git a/client/ticket/src/data/step-one/locale/es.yml b/client/ticket/src/data/step-one/locale/es.yml index fadbc2f54..a8d7d93ce 100644 --- a/client/ticket/src/data/step-one/locale/es.yml +++ b/client/ticket/src/data/step-one/locale/es.yml @@ -1 +1,2 @@ -There's no available agency for this landing date: No hay ninguna agencia disponible para la fecha de envío seleccionada \ No newline at end of file +There's no available agency for this landing date: No hay ninguna agencia disponible para la fecha de envío seleccionada +Deleted: Eliminado \ No newline at end of file diff --git a/client/ticket/src/data/step-three/index.js b/client/ticket/src/data/step-three/index.js index f5b738996..f98aaa5bf 100644 --- a/client/ticket/src/data/step-three/index.js +++ b/client/ticket/src/data/step-three/index.js @@ -34,6 +34,7 @@ class Controller { warehouseFk: this.ticket.warehouseFk, shipped: this.ticket.shipped, landed: this.ticket.landed, + isDeleted: this.ticket.isDeleted, option: this.ticket.option }; diff --git a/services/db/install/changes/1.0.6/01-ticketComponentUpdate.sql b/services/db/install/changes/1.0.6/01-ticketComponentUpdate.sql new file mode 100644 index 000000000..6af8d40e5 --- /dev/null +++ b/services/db/install/changes/1.0.6/01-ticketComponentUpdate.sql @@ -0,0 +1,52 @@ +USE `vn`; +DROP procedure IF EXISTS `ticketComponentUpdate`; + +DELIMITER $$ +USE `vn`$$ +CREATE DEFINER=`root`@`%` PROCEDURE `ticketComponentUpdate`( + vTicketFk INT, + vAgencyModeFk INT, + vAddressFk INT, + vWarehouseFk INT, + vShipped DATETIME, + vLanded DATE, + vIsDeleted BOOLEAN, + vOption INT) +BEGIN + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + RESIGNAL; + END; + + START TRANSACTION; + + UPDATE ticket t + SET + t.agencyModeFk = vAgencyModeFk, + t.addressFk = vAddressFk, + t.warehouseFk = vWarehouseFk, + t.landed = vLanded, + t.shipped = vShipped, + t.isDeleted = vIsDeleted + WHERE + t.id = vTicketFk; + + IF vOption <> 8 THEN + DROP TEMPORARY TABLE IF EXISTS tmp.sale; + CREATE TEMPORARY TABLE tmp.sale + (PRIMARY KEY (saleFk)) + ENGINE = MEMORY + SELECT id AS saleFk, vWarehouseFk warehouseFk + FROM sale s WHERE s.ticketFk = vTicketFk; + + CALL ticketComponentUpdateSale (vOption); + + DROP TEMPORARY TABLE tmp.sale; + END IF; + + COMMIT; +END$$ + +DELIMITER ; + diff --git a/services/db/install/changes/1.0.6/02-ticketComponentMakeUpdate.sql b/services/db/install/changes/1.0.6/02-ticketComponentMakeUpdate.sql new file mode 100644 index 000000000..a59902e97 --- /dev/null +++ b/services/db/install/changes/1.0.6/02-ticketComponentMakeUpdate.sql @@ -0,0 +1,41 @@ +USE `vn`; +DROP procedure IF EXISTS `ticketComponentMakeUpdate`; + +DELIMITER $$ +USE `vn`$$ +CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketComponentMakeUpdate`( + vTicketFk INT, + vAgencyModeFk INT, + vAddressFk INT, + vWarehouseFk INT, + vShipped DATETIME, + vLanded DATE, + vIsDeleted BOOLEAN, + vOption INT) +BEGIN +/** + * Devuelve las diferencias de precio + * de los movimientos de un ticket. + * + * @param vTicketFk Id del ticket + */ + + CALL vn.ticketComponentPreview (vLanded, vAddressFk, vAgencyModeFk, vTicketFk); + CALL vn.ticketComponentUpdate ( + vTicketFk, + vAgencyModeFk, + vAddressFk, + vWarehouseFk, + vShipped, + vLanded, + vIsDeleted, + vOption + ); + + DROP TEMPORARY TABLE + tmp.ticketComponent, + tmp.ticketComponentPrice; +END$$ + +DELIMITER ; + diff --git a/services/loopback/common/methods/ticket/componentUpdate.js b/services/loopback/common/methods/ticket/componentUpdate.js index faa89dda7..284b5baf3 100644 --- a/services/loopback/common/methods/ticket/componentUpdate.js +++ b/services/loopback/common/methods/ticket/componentUpdate.js @@ -26,7 +26,7 @@ module.exports = Self => { }); Self.componentUpdate = async (ticketFk, data) => { - let query = 'CALL vn.ticketComponentMakeUpdate(?, ?, ?, ?, ?, ?, ?)'; + let query = 'CALL vn.ticketComponentMakeUpdate(?, ?, ?, ?, ?, ?, ?, ?)'; let res = await Self.rawSql(query, [ ticketFk, data.agencyModeFk, @@ -34,6 +34,7 @@ module.exports = Self => { data.warehouseFk, data.shipped, data.landed, + data.isDeleted, data.option ]); return res; diff --git a/services/loopback/common/models/ticket.json b/services/loopback/common/models/ticket.json index c914c8738..1ca2d1855 100644 --- a/services/loopback/common/models/ticket.json +++ b/services/loopback/common/models/ticket.json @@ -33,6 +33,9 @@ }, "created": { "type": "date" + }, + "isDeleted": { + "type": "boolean" } }, "relations": {