Compare commits

..

81 Commits

Author SHA1 Message Date
Jorge Penadés f044809f30 feat: refs #6951 to create back
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-03-15 15:45:47 +01:00
Jorge Penadés 0fd6a6360c Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 6951-ticketCloneAll 2024-03-15 14:18:02 +01:00
Javier Segarra 6e045868c3 Merge pull request '#5858 - zoneCollisions' (!1853) from 5858-zone_Collisions into dev
gitea/salix/pipeline/head This commit looks good Details
Reviewed-on: #1853
Reviewed-by: Javi Gallego <jgallego@verdnatura.es>
2024-03-15 12:36:37 +00:00
Javier Segarra 0f4377ff5d refs #5858 test: fixtures
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-03-15 13:31:51 +01:00
Javier Segarra 950cce22df Merge branch '5858-zone_Collisions' of https://gitea.verdnatura.es/verdnatura/salix into 5858-zone_Collisions
gitea/salix/pipeline/pr-dev There was a failure building this commit Details
2024-03-15 12:23:02 +01:00
Javier Segarra bfdbbc0fdf Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 5858-zone_Collisions 2024-03-15 12:22:57 +01:00
Javier Segarra f18e90d6f3 Merge branch 'dev' into 5858-zone_Collisions
gitea/salix/pipeline/pr-dev There was a failure building this commit Details
2024-03-13 14:45:12 +00:00
Javier Segarra f09283b9c9 refs #5858 perf: html
gitea/salix/pipeline/pr-dev There was a failure building this commit Details
2024-03-13 15:44:16 +01:00
Javier Segarra 4012b1756d refs #5858 add comment 2024-03-13 15:00:12 +01:00
Javier Segarra 172e7566b5 refs #5858 perf: improve insert
gitea/salix/pipeline/pr-dev There was a failure building this commit Details
2024-03-13 11:58:25 +01:00
Javier Segarra 8276765225 refs #5858 perf: destinationFk to pepe
gitea/salix/pipeline/pr-dev There was a failure building this commit Details
2024-03-13 11:54:02 +01:00
Javier Segarra e7f6e61ea1 refs #5858: change notification owner
gitea/salix/pipeline/pr-dev There was a failure building this commit Details
2024-03-12 10:20:43 +01:00
Javier Segarra c1d0ea7e27 refs #5858: breaklines
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-03-12 09:40:42 +01:00
Javier Segarra 63a22a50f4 Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 5858-zone_Collisions 2024-03-12 09:37:41 +01:00
Javier Segarra 18773f34de Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 5858-zone_Collisions
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-03-09 11:27:57 +01:00
Javier Segarra 4994a836c7 refs #5858 feat: alter table util.notification 2024-03-09 11:27:29 +01:00
Javier Segarra 7999a9bf93 Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 5858-zone_Collisions
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-03-06 11:42:09 +01:00
Javier Segarra eb5fdd1940 refs 5858 feat: replace with code 2024-03-06 11:41:48 +01:00
Javier Segarra 2f0c8d96d2 refs 5858 fix: resolve breaklines 2024-03-06 11:41:25 +01:00
Javier Segarra 753525d0ac Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 5858-zone_Collisions
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-03-04 11:57:16 +01:00
Javier Segarra 78c92af02f refs #5858 feat: fix vn file 2024-03-04 11:57:10 +01:00
Javier Segarra 95fa776e41 refs 5858 feat: sql files
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-02-29 12:49:50 +00:00
Javier Segarra 8e976d2e4f refs #5858 feat: remove Schedule system
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-02-29 09:28:27 +01:00
Javier Segarra becd2e6f48 Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 5858-zone_Collisions 2024-02-29 07:49:24 +01:00
Javier Segarra d0c82f694e Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 5858-zone_Collisions
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-02-22 07:08:41 +01:00
Javier Segarra 838effadc0 refs #5858 feat: move change to vnx
gitea/salix/pipeline/pr-dev There was a failure building this commit Details
2024-02-21 15:18:10 +01:00
Javier Segarra cc90b13668 refs #5858 feat: remove unnecesary update
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-02-21 15:05:38 +01:00
Javier Segarra 714345ab04 Merge branch '5858-zone_Collisions' of https://gitea.verdnatura.es/verdnatura/salix into 5858-zone_Collisions
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-02-21 14:29:31 +01:00
Javier Segarra 57a1f2a1f6 refs #5858 test: check vn_schedules 2024-02-21 14:29:20 +01:00
Javier Segarra 7bf89cd448 Merge branch 'dev' into 5858-zone_Collisions
gitea/salix/pipeline/pr-dev There was a failure building this commit Details
2024-02-21 13:27:38 +00:00
Javier Segarra dddd482317 refs #5858 test: check vn_schedules
gitea/salix/pipeline/pr-dev There was a failure building this commit Details
2024-02-21 14:22:19 +01:00
Javier Segarra 88a88640e5 refs #5858 feat: sql comments 2024-02-21 14:22:06 +01:00
Javier Segarra e00133458b Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 5858-zone_Collisions 2024-02-21 13:48:53 +01:00
Javier Segarra be0e835a37 refs #5878 feat: remove vn_event_getCollisions
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-02-20 14:40:38 +01:00
Javier Segarra 791687f271 refs #5878 feat: comments
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-02-20 14:27:22 +01:00
Javier Segarra 811a49275d Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 5858-zone_Collisions 2024-02-20 13:53:18 +01:00
Javier Segarra 37dd3c00c5 updates 2024-02-13 09:11:39 +01:00
Javier Segarra 24984e8aca Revert "refs #5858 feat: comments"
This reverts commit 05d685c86b.
2024-02-13 08:32:04 +01:00
Javier Segarra 242d675d28 Merge branch '5858-zone_Collisions' of https://gitea.verdnatura.es/verdnatura/salix into 5858-zone_Collisions
gitea/salix/pipeline/pr-dev There was a failure building this commit Details
2024-02-12 15:13:27 +01:00
Javier Segarra 955828c63e refs #5858 feat: comments 2024-02-12 15:13:18 +01:00
Javier Segarra 05d685c86b refs #5858 feat: comments
gitea/salix/pipeline/pr-dev There was a failure building this commit Details
2024-02-12 13:17:47 +01:00
Javier Segarra e8c783ca68 refs #5858 feat: comments
gitea/salix/pipeline/pr-dev There was a failure building this commit Details
2024-02-12 13:14:41 +01:00
Javier Segarra 0a398fdd6c refs #5858 feat: comments
gitea/salix/pipeline/pr-dev There was a failure building this commit Details
2024-02-12 11:37:08 +01:00
Javier Segarra 7f1e3c66e2 refs #5858 feat: define event
gitea/salix/pipeline/pr-dev There was a failure building this commit Details
2024-02-12 10:35:12 +01:00
Javier Segarra cff59d197d refs #5858 feat: use active event when trigger 2024-02-12 10:28:07 +01:00
Javier Segarra 337190ef6d refs #5858 feat: use notification system 2024-02-12 10:27:46 +01:00
Javier Segarra e5b7395e5c refs #5858 fix: test Notification getList 2024-02-12 10:27:28 +01:00
Javier Segarra 88dfbd6da0 Merge branch '5858-zone_Collisions' of https://gitea.verdnatura.es/verdnatura/salix into 5858-zone_Collisions
gitea/salix/pipeline/pr-dev There was a failure building this commit Details
2024-02-12 10:15:17 +01:00
Javier Segarra 3cb494c735 refs #5858 fix: restore test to default 2024-02-12 10:14:23 +01:00
Javier Segarra 7abf81f815 refs #5858 fix: restore test to default
gitea/salix/pipeline/pr-dev Build queued... Details
2024-02-12 10:12:58 +01:00
Javier Segarra 4799151565 refs #5858 feat: fixtures.before.sql 2024-02-12 10:12:17 +01:00
Javier Segarra 995a99c661 refs #5858 feat: removeZoneIncludedCheck
gitea/salix/pipeline/pr-dev There was a failure building this commit Details
2024-02-12 08:53:55 +01:00
Javier Segarra a756c3bc3a Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 5858-zone_Collisions
gitea/salix/pipeline/pr-dev There was a failure building this commit Details
2024-02-12 08:51:58 +01:00
Javier Segarra b11b0642f8 Merge branch 'dev' into 5858-zone_Collisions
gitea/salix/pipeline/head There was a failure building this commit Details
gitea/salix/pipeline/pr-dev There was a failure building this commit Details
2024-01-02 11:03:52 +00:00
Javier Segarra 8c3d940987 Merge branch 'dev' into 5858-zone_Collisions
gitea/salix/pipeline/head There was a failure building this commit Details
2023-12-22 10:53:38 +00:00
Javier Segarra 613327491b Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 5858-zone_Collisions
gitea/salix/pipeline/head There was a failure building this commit Details
2023-12-22 09:26:16 +01:00
Javier Segarra 100936d40b Merge branch 'dev' into 5858-zone_Collisions
gitea/salix/pipeline/head There was a failure building this commit Details
2023-12-21 12:05:27 +00:00
Javier Segarra 3e30e77728 Merge branch '5858-zone_Collisions' of https://gitea.verdnatura.es/verdnatura/salix into 5858-zone_Collisions
gitea/salix/pipeline/head This commit looks good Details
2023-12-19 12:57:59 +01:00
Javier Segarra 38a5337f68 refs #5858 test: execute test 2023-12-19 12:57:10 +01:00
Javier Segarra 243319b113 refs #5858 feat zoneIncludedCheck model 2023-12-19 12:55:27 +01:00
Javier Segarra 72e9b69d7e Merge branch 'dev' into 5858-zone_Collisions
gitea/salix/pipeline/head There was a failure building this commit Details
2023-12-19 07:04:41 +00:00
Javier Segarra 2d4fb9d2f8 refs #5858 perf: remove unused methods
gitea/salix/pipeline/head Build queued... Details
2023-12-19 08:04:11 +01:00
Javier Segarra dbc3fc8007 refs #5858 perf: remove bad comments
gitea/salix/pipeline/head There was a failure building this commit Details
2023-12-19 08:02:38 +01:00
Javier Segarra a31b689ae2 refs #5858 perf: update db/changes
gitea/salix/pipeline/head There was a failure building this commit Details
2023-12-19 07:54:49 +01:00
Javier Segarra 5b6112720f refs #5858 feat: new fixture 2023-12-19 07:54:29 +01:00
Javier Segarra cc88fcbd9d refs #5858 feat: update notification template 2023-12-19 07:54:12 +01:00
Javier Segarra 15936ddc55 refs #5858 other: rename files 2023-12-19 07:53:47 +01:00
Javier Segarra e3379b42a1 refs #5858 test: bad test calls
gitea/salix/pipeline/head There was a failure building this commit Details
2023-12-01 14:06:28 +01:00
Javier Segarra db06620d7c Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 5858-zone_Collisions
gitea/salix/pipeline/head There was a failure building this commit Details
2023-12-01 09:39:47 +01:00
Javier Segarra 60fbb1d56e refs #5858 feat: update procedure zoneIncluded_getCollisions 2023-12-01 09:39:21 +01:00
Javier Segarra c40dc134f8 refs #5858 feat: sql files for new version 2023-11-29 12:15:38 +01:00
Javier Segarra 4383ebd7f1 refs #5858 feat: email notification
gitea/salix/pipeline/head There was a failure building this commit Details
2023-11-24 12:30:44 +01:00
Javier Segarra 5d156e81ca refs #5858 perf: move files to current version folder 2023-11-23 15:18:09 +01:00
Javier Segarra a2329e1276 refs #5858 feat: update template notification 2023-11-23 15:17:40 +01:00
Javier Segarra 57b8b69ae9 Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 5858-zone_Collisions 2023-11-23 07:49:42 +01:00
Javier Segarra b453abdb3a refs #5858 feat: new event in vn
gitea/salix/pipeline/head This commit looks good Details
2023-11-22 12:48:43 +01:00
Javier Segarra f4a9e7b74e ref #5858 feat: create table zoneIncludedCheck
gitea/salix/pipeline/head This commit looks good Details
2023-11-22 09:31:09 +01:00
Javier Segarra f00b264daa ref #5858 feat: dispatchers_after[Insert|Update|Delete] 2023-11-22 09:27:08 +01:00
Javier Segarra 1b60cd33d5 ref #5858 feat: notification template 2023-11-22 09:25:35 +01:00
Javier Segarra 50cb7964d9 ref #5858 feat: drp zone_getCollisions procedure 2023-11-22 09:24:45 +01:00
Javier Segarra 1d95c17a0b refs #5858 feat: remove row from bs.nightTask 2023-11-22 09:23:59 +01:00
21 changed files with 201 additions and 69 deletions

View File

@ -7,7 +7,7 @@ describe('NotificationSubscription getList()', () => {
const notifications = await models.Notification.find({});
const totalAvailable = notifications.length - active.length;
expect(active.length).toEqual(2);
expect(active.length).toEqual(3);
expect(available.length).toEqual(totalAvailable);
});
});

View File

@ -70,7 +70,7 @@ UPDATE vn.supplier
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
('Agencia', '1', '1', '1'),
('Otra agencia ', '1', '0', '0');

View File

@ -2809,7 +2809,8 @@ INSERT INTO `util`.`notification` (`id`, `name`, `description`)
(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'),
(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`)
VALUES
@ -2819,7 +2820,8 @@ INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`)
(3, 9),
(4, 1),
(5, 9),
(6, 9);
(6, 9),
(7, 9);
INSERT INTO `util`.`notificationQueue` (`id`, `notificationFk`, `params`, `authorFk`, `status`, `created`)
VALUES
@ -2836,8 +2838,8 @@ INSERT INTO `util`.`notificationSubscription` (`notificationFk`, `userFk`)
(2, 1109),
(1, 9),
(1, 3),
(6, 9);
(6, 9),
(7, 9);
INSERT INTO `vn`.`routeConfig` (`id`, `defaultWorkCenterFk`)
VALUES

View File

@ -15,7 +15,7 @@ BEGIN
SET vNewShipped = IFNULL(vNewShipped, util.VN_CURDATE());
CALL ticket_Clone(vTicketFk, vNewTicketFk, vWithWarehouse);
CALL ticket_Clone(vTicketFk, vNewTicketFk);
UPDATE ticket
SET landed = TIMESTAMPADD(DAY, DATEDIFF(vNewShipped, shipped), landed),

View File

@ -1,8 +1,9 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zone_getCollisions`()
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
*
*/
@ -10,17 +11,18 @@ BEGIN
DECLARE vZoneFk INT;
DECLARE vIsDone INT DEFAULT FALSE;
DECLARE vTableCollisions TEXT;
DECLARE json_data JSON;
DECLARE cur1 CURSOR FOR SELECT zoneFk from tmp.zoneOption;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vIsDone = TRUE;
DROP TEMPORARY TABLE IF EXISTS tmp.zone;
CREATE TEMPORARY TABLE tmp.zone
SELECT z.id
SELECT z.id
FROM zone z
JOIN agencyMode am ON am.id = z.agencyModeFk
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);
@ -35,7 +37,7 @@ BEGIN
PRIMARY KEY zoneFkk (zoneFk, geoFk),
INDEX(geoFk))
ENGINE = MyISAM;
OPEN cur1;
cur1Loop: LOOP
SET vIsDone = FALSE;
@ -43,82 +45,63 @@ BEGIN
IF vIsDone THEN
LEAVE cur1Loop;
END IF;
CALL zone_getLeaves(vZoneFk, NULL, NULL, TRUE);
myLoop: LOOP
myLoop: LOOP
SET vGeoFk = NULL;
SELECT geoFk INTO vGeoFk
SELECT geoFk INTO vGeoFk
FROM tmp.zoneNodes zn
WHERE NOT isChecked
LIMIT 1;
IF vGeoFk IS NULL THEN
LEAVE myLoop;
END IF;
CALL zone_getLeaves(vZoneFk, vGeoFk, NULL, TRUE);
UPDATE tmp.zoneNodes
SET isChecked = TRUE
SET isChecked = TRUE
WHERE geoFk = vGeoFk;
END LOOP;
END LOOP;
CLOSE cur1;
DELETE FROM tmp.zoneNodes
DELETE FROM tmp.zoneNodes
WHERE sons > 0;
DROP TEMPORARY TABLE IF EXISTS geoCollision;
CREATE TEMPORARY TABLE geoCollision
SELECT z.agencyModeFk, zn.geoFk, zw.warehouseFk
FROM tmp.zoneNodes zn
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
HAVING count(*) > 1;
SELECT '<table cellspacing="10">
<tr>
<th>C.Postal</th>
<th>Número de zona</th>
<th>Precio</th>
<th>Zona</th>
<th>Almacén</th>
<th>Salix</th>
</tr>' INTO vTableCollisions;
INSERT INTO mail (receiver,replyTo,subject,body)
SELECT 'pepe@verdnatura.es' receiver,
'noreply@verdnatura.es' replyTo,
CONCAT('Colisiones en zonas ', util.VN_CURDATE()) subject,
CONCAT(vTableCollisions,
GROUP_CONCAT(sub.td SEPARATOR ''),
'</table>') body
FROM(SELECT
CONCAT('<tr>
<td>', zn.name, '</td>
<td>', zoneFk,'</td>
<td>', z.price,'</td>
<td>', z.name,'</td>
<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,
-- Recojo los datos de la zona que ha dado conflicto
SELECT JSON_ARRAYAGG(
JSON_OBJECT(
'zoneFk', zoneFk,
'zn', JSON_OBJECT('name', zn.name),
'z', JSON_OBJECT('name', z.name,'price', z.price),
'w', JSON_OBJECT('name', w.name)
)
) 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
INTO json_data;
-- Creo un registro de la notificacion 'zone-included' para reportar via email
SELECT util.notification_send(
'zone-included',
JSON_OBJECT('zoneCollisions',json_data),
account.myUser_getId()
);
DROP TEMPORARY TABLE
geoCollision,
tmp.zone,
tmp.zoneNodes;
END$$

View File

@ -8,5 +8,6 @@ BEGIN
`changedModel` = 'zoneIncluded',
`changedModelId` = OLD.zoneFk,
`userFk` = account.myUser_getId();
END$$
DELIMITER ;

View File

@ -4,5 +4,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneIncluded_beforeIn
FOR EACH ROW
BEGIN
SET NEW.editorFk = account.myUser_getId();
END$$
DELIMITER ;

View File

@ -4,5 +4,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneIncluded_beforeUp
FOR EACH ROW
BEGIN
SET NEW.editorFk = account.myUser_getId();
END$$
DELIMITER ;

View File

@ -0,0 +1 @@
ALTER TABLE util.notification MODIFY COLUMN id int(11) auto_increment NOT NULL;

View File

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

View File

@ -0,0 +1,2 @@
INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId)
VALUES('Ticket', 'clone', 'WRITE', 'ALLOW', 'ROLE', 'administrative');

View File

@ -0,0 +1,54 @@
module.exports = Self => {
Self.remoteMethodCtx('clone', {
description: 'clone a ticket and return the new ticket id',
accessType: 'WRITE',
accepts: [{
arg: 'id',
type: 'number',
required: true,
description: 'The ticket id',
http: {source: 'path'}
}, {
arg: 'shipped',
type: 'date',
}, {
arg: 'withWarehouse',
type: 'boolean',
}
],
returns: {
type: 'number',
root: true
},
http: {
path: `/:id/clone`,
verb: 'POST'
}
});
Self.clone = async(ctx, id, shipped, withWarehouse, options) => {
const myOptions = {userId: ctx.req.accessToken.userId};
let tx;
if (typeof options == 'object')
Object.assign(myOptions, options);
if (!myOptions.transaction) {
tx = await Self.beginTransaction({});
myOptions.transaction = tx;
}
try {
const [, [{clonedTicketId}]] = await Self.rawSql(`
CALL vn.ticket_CloneAll(?, ?, ?, @clonedTicketId);
SELECT @clonedTicketId clonedTicketId;`,
[id, shipped, withWarehouse], myOptions);
if (tx) await tx.commit();
return clonedTicketId;
} catch (e) {
if (tx) await tx.rollback();
throw e;
}
};
};

View File

@ -46,4 +46,6 @@ module.exports = function(Self) {
require('../methods/ticket/invoiceTicketsAndPdf')(Self);
require('../methods/ticket/docuwareDownload')(Self);
require('../methods/ticket/myLastModified')(Self);
require('../methods/ticket/addSaleByCode')(Self);
require('../methods/ticket/clone')(Self);
};

View File

@ -1,5 +1,4 @@
module.exports = Self => {
require('./ticket-methods')(Self);
require('../methods/ticket/state')(Self);
require('../methods/ticket/addSaleByCode')(Self);
};

View File

@ -1,6 +1,5 @@
const models = require('vn-loopback/server/server').models;
const LoopBackContext = require('loopback-context');
describe('zone toggleIsIncluded()', () => {
beforeAll(async() => {
const activeCtx = {
@ -58,7 +57,7 @@ describe('zone toggleIsIncluded()', () => {
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});

View File

@ -3,10 +3,10 @@
"dataSource": "vn"
},
"AgencyMode": {
"dataSource": "vn"
"dataSource": "vn"
},
"DeliveryMethod": {
"dataSource": "vn"
"dataSource": "vn"
},
"Zone": {
"dataSource": "vn"

View File

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

View File

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

View File

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

View File

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