7167-testToMaster_2414 #2244
|
@ -7,7 +7,7 @@ describe('NotificationSubscription getList()', () => {
|
||||||
const notifications = await models.Notification.find({});
|
const notifications = await models.Notification.find({});
|
||||||
const totalAvailable = notifications.length - active.length;
|
const totalAvailable = notifications.length - active.length;
|
||||||
|
|
||||||
expect(active.length).toEqual(2);
|
expect(active.length).toEqual(3);
|
||||||
expect(available.length).toEqual(totalAvailable);
|
expect(available.length).toEqual(totalAvailable);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -70,7 +70,7 @@ UPDATE vn.supplier
|
||||||
|
|
||||||
UPDATE `vn`.`claimRatio` SET `claimAmount` = '10' WHERE (`clientFk` = '1101');
|
UPDATE `vn`.`claimRatio` SET `claimAmount` = '10' WHERE (`clientFk` = '1101');
|
||||||
|
|
||||||
INSERT INTO `vn`.`agency` (`name`, `warehouseFk`, `isOwn`, `isAnyVolumeAllowed`)
|
INSERT INTO `vn`.`agency` (`name`, `warehouseFk`, `isOwn`, `isAnyVolumeAllowed`)
|
||||||
VALUES
|
VALUES
|
||||||
('Agencia', '1', '1', '1'),
|
('Agencia', '1', '1', '1'),
|
||||||
('Otra agencia ', '1', '0', '0');
|
('Otra agencia ', '1', '0', '0');
|
||||||
|
|
|
@ -2809,7 +2809,8 @@ INSERT INTO `util`.`notification` (`id`, `name`, `description`)
|
||||||
(3, 'not-main-printer-configured', 'A printer distinct than main has been configured'),
|
(3, 'not-main-printer-configured', 'A printer distinct than main has been configured'),
|
||||||
(4, 'supplier-pay-method-update', 'A supplier pay method has been updated'),
|
(4, 'supplier-pay-method-update', 'A supplier pay method has been updated'),
|
||||||
(5, 'modified-entry', 'An entry has been modified'),
|
(5, 'modified-entry', 'An entry has been modified'),
|
||||||
(6, 'book-entry-deleted', 'accounting entries deleted');
|
(6, 'book-entry-deleted', 'accounting entries deleted'),
|
||||||
|
(7, 'zone-included','An email to notify zoneCollisions');
|
||||||
|
|
||||||
INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`)
|
INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`)
|
||||||
VALUES
|
VALUES
|
||||||
|
@ -2819,7 +2820,8 @@ INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`)
|
||||||
(3, 9),
|
(3, 9),
|
||||||
(4, 1),
|
(4, 1),
|
||||||
(5, 9),
|
(5, 9),
|
||||||
(6, 9);
|
(6, 9),
|
||||||
|
(7, 9);
|
||||||
|
|
||||||
INSERT INTO `util`.`notificationQueue` (`id`, `notificationFk`, `params`, `authorFk`, `status`, `created`)
|
INSERT INTO `util`.`notificationQueue` (`id`, `notificationFk`, `params`, `authorFk`, `status`, `created`)
|
||||||
VALUES
|
VALUES
|
||||||
|
@ -2836,8 +2838,8 @@ INSERT INTO `util`.`notificationSubscription` (`notificationFk`, `userFk`)
|
||||||
(2, 1109),
|
(2, 1109),
|
||||||
(1, 9),
|
(1, 9),
|
||||||
(1, 3),
|
(1, 3),
|
||||||
(6, 9);
|
(6, 9),
|
||||||
|
(7, 9);
|
||||||
|
|
||||||
INSERT INTO `vn`.`routeConfig` (`id`, `defaultWorkCenterFk`)
|
INSERT INTO `vn`.`routeConfig` (`id`, `defaultWorkCenterFk`)
|
||||||
VALUES
|
VALUES
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
|
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zone_getCollisions`()
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zone_getCollisions`()
|
||||||
BEGIN
|
BEGIN
|
||||||
/**
|
/**
|
||||||
* Calcula si para un mismo codigo postal y dia
|
* Calcula si para un mismo codigo postal y dia
|
||||||
* hay mas de una zona configurada y manda correo
|
* hay mas de una zona configurada y manda correo
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -10,17 +11,18 @@ BEGIN
|
||||||
DECLARE vZoneFk INT;
|
DECLARE vZoneFk INT;
|
||||||
DECLARE vIsDone INT DEFAULT FALSE;
|
DECLARE vIsDone INT DEFAULT FALSE;
|
||||||
DECLARE vTableCollisions TEXT;
|
DECLARE vTableCollisions TEXT;
|
||||||
|
DECLARE json_data JSON;
|
||||||
DECLARE cur1 CURSOR FOR SELECT zoneFk from tmp.zoneOption;
|
DECLARE cur1 CURSOR FOR SELECT zoneFk from tmp.zoneOption;
|
||||||
|
|
||||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vIsDone = TRUE;
|
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vIsDone = TRUE;
|
||||||
|
|
||||||
DROP TEMPORARY TABLE IF EXISTS tmp.zone;
|
DROP TEMPORARY TABLE IF EXISTS tmp.zone;
|
||||||
CREATE TEMPORARY TABLE tmp.zone
|
CREATE TEMPORARY TABLE tmp.zone
|
||||||
SELECT z.id
|
SELECT z.id
|
||||||
FROM zone z
|
FROM zone z
|
||||||
JOIN agencyMode am ON am.id = z.agencyModeFk
|
JOIN agencyMode am ON am.id = z.agencyModeFk
|
||||||
JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk
|
JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk
|
||||||
WHERE dm.code IN ('AGENCY','DELIVERY');
|
WHERE dm.code IN ('AGENCY','DELIVERY');
|
||||||
|
|
||||||
CALL zone_getOptionsForShipment(util.VN_CURDATE(),FALSE);
|
CALL zone_getOptionsForShipment(util.VN_CURDATE(),FALSE);
|
||||||
|
|
||||||
|
@ -35,7 +37,7 @@ BEGIN
|
||||||
PRIMARY KEY zoneFkk (zoneFk, geoFk),
|
PRIMARY KEY zoneFkk (zoneFk, geoFk),
|
||||||
INDEX(geoFk))
|
INDEX(geoFk))
|
||||||
ENGINE = MyISAM;
|
ENGINE = MyISAM;
|
||||||
|
|
||||||
OPEN cur1;
|
OPEN cur1;
|
||||||
cur1Loop: LOOP
|
cur1Loop: LOOP
|
||||||
SET vIsDone = FALSE;
|
SET vIsDone = FALSE;
|
||||||
|
@ -43,82 +45,63 @@ BEGIN
|
||||||
IF vIsDone THEN
|
IF vIsDone THEN
|
||||||
LEAVE cur1Loop;
|
LEAVE cur1Loop;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
CALL zone_getLeaves(vZoneFk, NULL, NULL, TRUE);
|
CALL zone_getLeaves(vZoneFk, NULL, NULL, TRUE);
|
||||||
|
|
||||||
myLoop: LOOP
|
myLoop: LOOP
|
||||||
SET vGeoFk = NULL;
|
SET vGeoFk = NULL;
|
||||||
SELECT geoFk INTO vGeoFk
|
SELECT geoFk INTO vGeoFk
|
||||||
FROM tmp.zoneNodes zn
|
FROM tmp.zoneNodes zn
|
||||||
WHERE NOT isChecked
|
WHERE NOT isChecked
|
||||||
LIMIT 1;
|
LIMIT 1;
|
||||||
|
|
||||||
IF vGeoFk IS NULL THEN
|
IF vGeoFk IS NULL THEN
|
||||||
LEAVE myLoop;
|
LEAVE myLoop;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
CALL zone_getLeaves(vZoneFk, vGeoFk, NULL, TRUE);
|
CALL zone_getLeaves(vZoneFk, vGeoFk, NULL, TRUE);
|
||||||
UPDATE tmp.zoneNodes
|
UPDATE tmp.zoneNodes
|
||||||
SET isChecked = TRUE
|
SET isChecked = TRUE
|
||||||
WHERE geoFk = vGeoFk;
|
WHERE geoFk = vGeoFk;
|
||||||
END LOOP;
|
END LOOP;
|
||||||
|
|
||||||
END LOOP;
|
END LOOP;
|
||||||
CLOSE cur1;
|
CLOSE cur1;
|
||||||
DELETE FROM tmp.zoneNodes
|
DELETE FROM tmp.zoneNodes
|
||||||
WHERE sons > 0;
|
WHERE sons > 0;
|
||||||
|
|
||||||
DROP TEMPORARY TABLE IF EXISTS geoCollision;
|
DROP TEMPORARY TABLE IF EXISTS geoCollision;
|
||||||
CREATE TEMPORARY TABLE geoCollision
|
CREATE TEMPORARY TABLE geoCollision
|
||||||
SELECT z.agencyModeFk, zn.geoFk, zw.warehouseFk
|
SELECT z.agencyModeFk, zn.geoFk, zw.warehouseFk
|
||||||
FROM tmp.zoneNodes zn
|
FROM tmp.zoneNodes zn
|
||||||
JOIN zone z ON z.id = zn.zoneFk
|
JOIN zone z ON z.id = zn.zoneFk
|
||||||
JOIN zoneWarehouse zw ON z.id = zw.zoneFk
|
JOIN zoneWarehouse zw ON z.id = zw.zoneFk
|
||||||
GROUP BY z.agencyModeFk, zn.geoFk, zw.warehouseFk
|
GROUP BY z.agencyModeFk, zn.geoFk, zw.warehouseFk
|
||||||
HAVING count(*) > 1;
|
HAVING count(*) > 1;
|
||||||
|
|
||||||
SELECT '<table cellspacing="10">
|
-- Recojo los datos de la zona que ha dado conflicto
|
||||||
<tr>
|
SELECT JSON_ARRAYAGG(
|
||||||
<th>C.Postal</th>
|
JSON_OBJECT(
|
||||||
<th>Número de zona</th>
|
'zoneFk', zoneFk,
|
||||||
<th>Precio</th>
|
'zn', JSON_OBJECT('name', zn.name),
|
||||||
<th>Zona</th>
|
'z', JSON_OBJECT('name', z.name,'price', z.price),
|
||||||
<th>Almacén</th>
|
'w', JSON_OBJECT('name', w.name)
|
||||||
<th>Salix</th>
|
)
|
||||||
</tr>' INTO vTableCollisions;
|
) FROM tmp.zoneNodes zn
|
||||||
|
JOIN zone z ON z.id = zn.zoneFk
|
||||||
INSERT INTO mail (receiver,replyTo,subject,body)
|
JOIN geoCollision gc ON gc.agencyModeFk = z.agencyModeFk AND zn.geoFk = gc.geoFk
|
||||||
SELECT 'pepe@verdnatura.es' receiver,
|
JOIN warehouse w ON w.id = gc.warehouseFk
|
||||||
'noreply@verdnatura.es' replyTo,
|
INTO json_data;
|
||||||
CONCAT('Colisiones en zonas ', util.VN_CURDATE()) subject,
|
|
||||||
CONCAT(vTableCollisions,
|
-- Creo un registro de la notificacion 'zone-included' para reportar via email
|
||||||
GROUP_CONCAT(sub.td SEPARATOR ''),
|
SELECT util.notification_send(
|
||||||
'</table>') body
|
'zone-included',
|
||||||
FROM(SELECT
|
JSON_OBJECT('zoneCollisions',json_data),
|
||||||
CONCAT('<tr>
|
account.myUser_getId()
|
||||||
<td>', zn.name, '</td>
|
);
|
||||||
<td>', zoneFk,'</td>
|
|
||||||
<td>', z.price,'</td>
|
DROP TEMPORARY TABLE
|
||||||
<td>', z.name,'</td>
|
geoCollision,
|
||||||
<td>', w.name, '</td>
|
|
||||||
<td>', CONCAT('<a href="https://salix.verdnatura.es/#!/zone/',
|
|
||||||
zoneFk,
|
|
||||||
'/location?q=%7B%22search%22:%22',
|
|
||||||
zn.name,
|
|
||||||
'%22%7D">'
|
|
||||||
'https://salix.verdnatura.es/#!/zone/',
|
|
||||||
zoneFk,
|
|
||||||
'/location?q=%7B%22search%22:%22',
|
|
||||||
zn.name,
|
|
||||||
'%22%7D</a>'),'</td>
|
|
||||||
</tr>') td
|
|
||||||
FROM tmp.zoneNodes zn
|
|
||||||
JOIN zone z ON z.id = zn.zoneFk
|
|
||||||
JOIN geoCollision gc ON gc.agencyModeFk = z.agencyModeFk AND zn.geoFk = gc.geoFk
|
|
||||||
JOIN warehouse w ON w.id = gc.warehouseFk) sub;
|
|
||||||
|
|
||||||
DROP TEMPORARY TABLE
|
|
||||||
geoCollision,
|
|
||||||
tmp.zone,
|
tmp.zone,
|
||||||
tmp.zoneNodes;
|
tmp.zoneNodes;
|
||||||
END$$
|
END$$
|
||||||
|
|
|
@ -8,5 +8,6 @@ BEGIN
|
||||||
`changedModel` = 'zoneIncluded',
|
`changedModel` = 'zoneIncluded',
|
||||||
`changedModelId` = OLD.zoneFk,
|
`changedModelId` = OLD.zoneFk,
|
||||||
`userFk` = account.myUser_getId();
|
`userFk` = account.myUser_getId();
|
||||||
|
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -4,5 +4,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneIncluded_beforeIn
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
BEGIN
|
BEGIN
|
||||||
SET NEW.editorFk = account.myUser_getId();
|
SET NEW.editorFk = account.myUser_getId();
|
||||||
|
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -4,5 +4,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneIncluded_beforeUp
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
BEGIN
|
BEGIN
|
||||||
SET NEW.editorFk = account.myUser_getId();
|
SET NEW.editorFk = account.myUser_getId();
|
||||||
|
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
ALTER TABLE util.notification MODIFY COLUMN id int(11) auto_increment NOT NULL;
|
|
@ -0,0 +1,15 @@
|
||||||
|
INSERT IGNORE INTO util.notification ( `name`,`description`)
|
||||||
|
VALUES
|
||||||
|
( 'zone-included','An email to notify zoneCollisions');
|
||||||
|
|
||||||
|
-- Change value if destionation user should be different
|
||||||
|
SET @DESTINATION_USER = "pepe";
|
||||||
|
|
||||||
|
SET @MaxId = LAST_INSERT_ID();
|
||||||
|
|
||||||
|
INSERT IGNORE INTO util.notificationSubscription (notificationFk,userFk)
|
||||||
|
VALUES(
|
||||||
|
@MaxId, (SELECT id from `account`.`user` where name = @DESTINATION_USER));
|
||||||
|
|
||||||
|
INSERT IGNORE INTO util.notificationAcl (notificationFk,roleFk)
|
||||||
|
SELECT @MaxId, (SELECT role from `account`.`user` where name = @DESTINATION_USER) FROM util.notification WHERE name= "zone-included";
|
|
@ -1,6 +1,5 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
const LoopBackContext = require('loopback-context');
|
const LoopBackContext = require('loopback-context');
|
||||||
|
|
||||||
describe('zone toggleIsIncluded()', () => {
|
describe('zone toggleIsIncluded()', () => {
|
||||||
beforeAll(async() => {
|
beforeAll(async() => {
|
||||||
const activeCtx = {
|
const activeCtx = {
|
||||||
|
@ -58,7 +57,7 @@ describe('zone toggleIsIncluded()', () => {
|
||||||
|
|
||||||
await models.Zone.toggleIsIncluded(1, 20, false, options);
|
await models.Zone.toggleIsIncluded(1, 20, false, options);
|
||||||
|
|
||||||
let result = await models.Zone.toggleIsIncluded(1, 20, undefined, options);
|
const result = await models.Zone.toggleIsIncluded(1, 20, undefined, options);
|
||||||
|
|
||||||
expect(result).toEqual({count: 1});
|
expect(result).toEqual({count: 1});
|
||||||
|
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
"AgencyMode": {
|
"AgencyMode": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
"DeliveryMethod": {
|
"DeliveryMethod": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
"Zone": {
|
"Zone": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
const Stylesheet = require(`vn-print/core/stylesheet`);
|
||||||
|
|
||||||
|
const path = require('path');
|
||||||
|
const vnPrintPath = path.resolve('print');
|
||||||
|
|
||||||
|
module.exports = new Stylesheet([
|
||||||
|
`${vnPrintPath}/common/css/spacing.css`,
|
||||||
|
`${vnPrintPath}/common/css/misc.css`,
|
||||||
|
`${vnPrintPath}/common/css/layout.css`,
|
||||||
|
`${vnPrintPath}/common/css/email.css`])
|
||||||
|
.mergeStyles();
|
|
@ -0,0 +1,7 @@
|
||||||
|
subject: Colisiones en zonas
|
||||||
|
title: "La zona {0} y localización {1} ha sido registrada en más de un sitio"
|
||||||
|
postalCode: C. Postal
|
||||||
|
zoneFk: Número de zona
|
||||||
|
price: Precio
|
||||||
|
zone: Zona
|
||||||
|
warehouse: Almacén
|
|
@ -0,0 +1,42 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html v-bind:lang="$i18n.locale">
|
||||||
|
<head>
|
||||||
|
<meta name="viewport" content="width=device-width" />
|
||||||
|
<meta name="format-detection" content="telephone=no" />
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<table class="grid column-oriented">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>{{ $t('postalCode') }}</th>
|
||||||
|
<th>{{ $t('zoneFk') }}</th>
|
||||||
|
<th>{{ $t('price') }}</th>
|
||||||
|
<th>{{ $t('zone') }}</th>
|
||||||
|
<th>{{ $t('warehouse') }}</th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr v-for="zone in zoneCollisions">
|
||||||
|
<td>{{ zone.zn.name }}</td>
|
||||||
|
<td>{{ zone.zoneFk }}</td>
|
||||||
|
<td>{{ zone.z.price }}</td>
|
||||||
|
<td>{{ zone.z.name }}</td>
|
||||||
|
<td>{{ zone.w.name }}</td>
|
||||||
|
<td>
|
||||||
|
<a v-bind:href="'https://salix.verdnatura.es/#!/zone/'+
|
||||||
|
zone.zoneFk+
|
||||||
|
'/location?q=%7B%22search%22:%22'+
|
||||||
|
zone.zn.name+
|
||||||
|
'%22%7D'">
|
||||||
|
https://salix.verdnatura.es/#!/zone/
|
||||||
|
{{zone.zoneFk}}
|
||||||
|
/location?q=%7B%22search%22:%22
|
||||||
|
{{zone.zn.name}}
|
||||||
|
%22%7D</a></td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,12 @@
|
||||||
|
const Component = require(`vn-print/core/component`);
|
||||||
|
const emailHeader = new Component('email-header');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: 'zone-included',
|
||||||
|
components: {
|
||||||
|
'email-header': emailHeader.build(),
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
zoneCollisions: {type: Array, required: true}
|
||||||
|
}
|
||||||
|
};
|
Loading…
Reference in New Issue