Added warehouse & isDeleted on ticket basic data #322

This commit is contained in:
Joan Sanchez 2018-05-25 11:40:04 +02:00
parent 2aee807915
commit 7a5d8bdd03
8 changed files with 117 additions and 3 deletions

View File

@ -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}`);
}

View File

@ -47,5 +47,18 @@
initial-data="$ctrl.ticket.companyFk">
</vn-autocomplete>
</vn-horizontal>
<vn-horizontal>
<vn-autocomplete vn-one
url="/api/Warehouses"
label="Warehouse"
show-field="name"
value-field="id"
field="$ctrl.ticket.warehouseFk"
initial-data="$ctrl.ticket.warehouseFk">
</vn-autocomplete>
<vn-one>
<vn-check label="Deleted" field="$ctrl.ticket.isDeleted"></vn-check>
</vn-one>
</vn-horizontal>
</vn-card>
</form>

View File

@ -1 +1,2 @@
There's no available agency for this landing date: No hay ninguna agencia disponible para la fecha de envío seleccionada
There's no available agency for this landing date: No hay ninguna agencia disponible para la fecha de envío seleccionada
Deleted: Eliminado

View File

@ -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
};

View File

@ -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 ;

View File

@ -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 ;

View File

@ -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;

View File

@ -33,6 +33,9 @@
},
"created": {
"type": "date"
},
"isDeleted": {
"type": "boolean"
}
},
"relations": {