2387 - Fixed error when deleting a zone
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
904db8e2f8
commit
f0818acf32
|
@ -0,0 +1,31 @@
|
|||
DROP TRIGGER IF EXISTS `vn`.`ticket_beforeUpdate`;
|
||||
|
||||
DELIMITER $$
|
||||
USE `vn`$$
|
||||
CREATE DEFINER=`root`@`%` TRIGGER `ticket_beforeUpdate`
|
||||
BEFORE UPDATE ON `ticket`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
IF !(NEW.shipped <=> OLD.shipped) THEN
|
||||
IF YEAR(NEW.shipped) < 2000 THEN
|
||||
SIGNAL SQLSTATE '46000'
|
||||
SET MESSAGE_TEXT = 'Year cannot be lesser than 2000';
|
||||
END IF;
|
||||
|
||||
IF YEAR(NEW.shipped) = 2000 THEN
|
||||
SET NEW.isDeleted = TRUE;
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
IF !(NEW.isDeleted <=> OLD.isDeleted) AND NEW.isDeleted THEN
|
||||
SET NEW.shipped = DATE_FORMAT(NEW.shipped, '2000-%m-%d %T');
|
||||
SET NEW.landed = DATE_FORMAT(NEW.landed, '2000-%m-%d %T');
|
||||
SET NEW.routeFk = NULL;
|
||||
SET NEW.zoneFk = NULL;
|
||||
END IF;
|
||||
|
||||
IF NEW.routeFk AND NEW.isDeleted THEN
|
||||
CALL util.throw ('This ticket is deleted');
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -29,7 +29,8 @@ module.exports = Self => {
|
|||
const options = {transaction: tx};
|
||||
const filter = {
|
||||
where: {
|
||||
zoneFk: id
|
||||
zoneFk: id,
|
||||
shipped: {gte: today}
|
||||
},
|
||||
include: {
|
||||
relation: 'ticketState',
|
||||
|
@ -46,10 +47,10 @@ module.exports = Self => {
|
|||
where: {userFk: userId}
|
||||
}, options);
|
||||
|
||||
ticketList.forEach(ticket => {
|
||||
promises.push(ticket.updateAttributes({zoneFk: null}, options));
|
||||
await models.Ticket.rawSql('UPDATE ticket SET zoneFk = NULL WHERE zoneFk = ?', [id], options);
|
||||
|
||||
if (ticket.ticketState().alertLevel == 0 && ticket.shipped >= today) {
|
||||
ticketList.forEach(ticket => {
|
||||
if (ticket.ticketState().alertLevel == 0) {
|
||||
promises.push(models.TicketTracking.create({
|
||||
ticketFk: ticket.id,
|
||||
stateFk: fixingState.id,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
This zone contains tickets: Esta zona contiene {{ticketsAmount}} tickets. ¿Seguro que quieres eliminar esta zona?
|
||||
This zone contains tickets: Esta zona contiene {{ticketsAmount}} tickets por servir. ¿Seguro que quieres eliminar esta zona?
|
||||
Do you want to clone this zone?: ¿Quieres clonar esta zona?
|
||||
All it's properties will be copied: Todas sus propiedades serán copiadas
|
||||
Zone deleted: Zona eliminada
|
Loading…
Reference in New Issue