Merge branch 'dev' into 4497-services-intrastat
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
commit
b73fe06043
|
@ -1,12 +1,13 @@
|
|||
const jsdom = require('jsdom');
|
||||
const mysql = require('mysql');
|
||||
const FormData = require('form-data');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('closeTicket', {
|
||||
description: 'Close tickets without response from the user',
|
||||
accessType: 'READ',
|
||||
returns: {
|
||||
type: 'Object',
|
||||
type: 'object',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
|
@ -54,9 +55,9 @@ module.exports = Self => {
|
|||
});
|
||||
});
|
||||
|
||||
await requestToken();
|
||||
await getRequestToken();
|
||||
|
||||
async function requestToken() {
|
||||
async function getRequestToken() {
|
||||
const response = await fetch(ostUri);
|
||||
|
||||
const result = response.headers.get('set-cookie');
|
||||
|
@ -93,24 +94,45 @@ module.exports = Self => {
|
|||
await close(token, secondCookie);
|
||||
}
|
||||
|
||||
async function getLockCode(token, secondCookie, ticketId) {
|
||||
const ostUri = `${config.host}/ajax.php/lock/ticket/${ticketId}`;
|
||||
const params = {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'X-CSRFToken': token,
|
||||
'Cookie': secondCookie
|
||||
}
|
||||
};
|
||||
const response = await fetch(ostUri, params);
|
||||
const body = await response.text();
|
||||
const json = JSON.parse(body);
|
||||
|
||||
return json.code;
|
||||
}
|
||||
|
||||
async function close(token, secondCookie) {
|
||||
for (const ticketId of ticketsId) {
|
||||
const ostUri = `${config.host}/ajax.php/tickets/${ticketId}/status`;
|
||||
const data = {
|
||||
status_id: config.newStatusId,
|
||||
comments: config.comment,
|
||||
undefined: config.action
|
||||
};
|
||||
const lockCode = await getLockCode(token, secondCookie, ticketId);
|
||||
let form = new FormData();
|
||||
form.append('__CSRFToken__', token);
|
||||
form.append('id', ticketId);
|
||||
form.append('a', config.responseType);
|
||||
form.append('lockCode', lockCode);
|
||||
form.append('from_email_id', config.fromEmailId);
|
||||
form.append('reply-to', config.replyTo);
|
||||
form.append('cannedResp', 0);
|
||||
form.append('response', config.comment);
|
||||
form.append('signature', 'none');
|
||||
form.append('reply_status_id', config.newStatusId);
|
||||
|
||||
const ostUri = `${config.host}/tickets.php?id=${ticketId}`;
|
||||
const params = {
|
||||
method: 'POST',
|
||||
body: new URLSearchParams(data),
|
||||
body: form,
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
'X-CSRFToken': token,
|
||||
'Cookie': secondCookie
|
||||
}
|
||||
};
|
||||
|
||||
return fetch(ostUri, params);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,9 +27,6 @@
|
|||
"newStatusId": {
|
||||
"type": "number"
|
||||
},
|
||||
"action": {
|
||||
"type": "string"
|
||||
},
|
||||
"day": {
|
||||
"type": "number"
|
||||
},
|
||||
|
@ -47,6 +44,15 @@
|
|||
},
|
||||
"portDb": {
|
||||
"type": "number"
|
||||
},
|
||||
"responseType": {
|
||||
"type": "string"
|
||||
},
|
||||
"fromEmailId": {
|
||||
"type": "number"
|
||||
},
|
||||
"replyTo": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
ALTER TABLE `vn`.`itemType` CHANGE `transaction` transaction__ tinyint(4) DEFAULT 0 NOT NULL;
|
||||
ALTER TABLE `vn`.`itemType` CHANGE location location__ varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL NULL;
|
||||
ALTER TABLE `vn`.`itemType` CHANGE hasComponents hasComponents__ tinyint(1) DEFAULT 1 NOT NULL;
|
||||
ALTER TABLE `vn`.`itemType` CHANGE warehouseFk warehouseFk__ smallint(6) unsigned DEFAULT 60 NOT NULL;
|
||||
ALTER TABLE `vn`.`itemType` CHANGE compression compression__ decimal(5,2) DEFAULT 1.00 NULL;
|
|
@ -13,8 +13,4 @@ CREATE TABLE `vn`.`osTicketConfig` (
|
|||
`passwordDb` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
|
||||
`portDb` int(11) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
|
||||
|
||||
INSERT INTO `vn`.`osTicketConfig`(`id`, `host`, `user`, `password`, `oldStatus`, `newStatusId`, `action`, `day`, `comment`, `hostDb`, `userDb`, `passwordDb`, `portDb`)
|
||||
VALUES
|
||||
(0, 'https://cau.verdnatura.es/scp', NULL, NULL, 'open', 3, 'Cerrar', 60, 'Este CAU se ha cerrado automáticamente', NULL, NULL, NULL, NULL);
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
|
|
@ -0,0 +1,2 @@
|
|||
INSERT INTO `salix`.`ACL` (model,property,accessType,permission,principalId)
|
||||
VALUES ('WorkerDisableExcluded','*','*','ALLOW','hr');
|
|
@ -0,0 +1,3 @@
|
|||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
('Business', '*', '*', 'ALLOW', 'ROLE', 'hr');
|
|
@ -0,0 +1,3 @@
|
|||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
('Sale', 'usesMana', '*', 'ALLOW', 'ROLE', 'employee');
|
|
@ -0,0 +1,8 @@
|
|||
ALTER TABLE `vn`.`osTicketConfig` DROP COLUMN `action`;
|
||||
ALTER TABLE `vn`.`osTicketConfig` ADD responseType varchar(100) NULL;
|
||||
ALTER TABLE `vn`.`osTicketConfig` ADD fromEmailId INT NULL;
|
||||
ALTER TABLE `vn`.`osTicketConfig` ADD replyTo varchar(100) NULL;
|
||||
|
||||
UPDATE `vn`.`osTicketConfig`
|
||||
SET responseType='reply', fromEmailId=5, replyTo='all'
|
||||
WHERE id=0;
|
|
@ -0,0 +1 @@
|
|||
ALTER TABLE `vn`.`claimConfig` DROP COLUMN `pickupContact`;
|
|
@ -0,0 +1,4 @@
|
|||
INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId)
|
||||
VALUES
|
||||
('ItemShelving', '*', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
('ItemShelving', '*', 'WRITE', 'ALLOW', 'ROLE', 'production');
|
|
@ -0,0 +1,4 @@
|
|||
INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId)
|
||||
VALUES
|
||||
('ItemShelvingPlacementSupplyStock', '*', 'READ', 'ALLOW', 'ROLE', 'employee');
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
DROP PROCEDURE IF EXISTS `vn`.`zone_getPostalCode`;
|
||||
|
||||
DELIMITER $$
|
||||
$$
|
||||
CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zone_getPostalCode`(vSelf INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Devuelve los códigos postales incluidos en una zona
|
||||
*/
|
||||
DECLARE vGeoFk INT DEFAULT NULL;
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.zoneNodes;
|
||||
CREATE TEMPORARY TABLE tmp.zoneNodes (
|
||||
geoFk INT,
|
||||
name VARCHAR(100),
|
||||
parentFk INT,
|
||||
sons INT,
|
||||
isChecked BOOL DEFAULT 0,
|
||||
zoneFk INT,
|
||||
PRIMARY KEY zoneNodesPk (zoneFk, geoFk),
|
||||
INDEX(geoFk))
|
||||
ENGINE = MEMORY;
|
||||
|
||||
CALL zone_getLeaves2(vSelf, NULL , NULL);
|
||||
|
||||
UPDATE tmp.zoneNodes zn
|
||||
SET isChecked = 0
|
||||
WHERE parentFk IS NULL;
|
||||
|
||||
myLoop: LOOP
|
||||
SET vGeoFk = NULL;
|
||||
SELECT geoFk INTO vGeoFk
|
||||
FROM tmp.zoneNodes zn
|
||||
WHERE NOT isChecked
|
||||
LIMIT 1;
|
||||
|
||||
CALL zone_getLeaves2(vSelf, vGeoFk, NULL);
|
||||
UPDATE tmp.zoneNodes
|
||||
SET isChecked = TRUE
|
||||
WHERE geoFk = vGeoFk;
|
||||
|
||||
IF vGeoFk IS NULL THEN
|
||||
LEAVE myLoop;
|
||||
END IF;
|
||||
END LOOP;
|
||||
|
||||
DELETE FROM tmp.zoneNodes
|
||||
WHERE sons > 0;
|
||||
|
||||
SELECT zn.geoFk, zn.name
|
||||
FROM tmp.zoneNodes zn
|
||||
JOIN zone z ON z.id = zn.zoneFk;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -353,48 +353,48 @@ INSERT INTO `vn`.`clientConfig`(`riskTolerance`, `maxCreditRows`)
|
|||
|
||||
INSERT INTO `vn`.`address`(`id`, `nickname`, `street`, `city`, `postalCode`, `provinceFk`, `phone`, `mobile`, `isActive`, `clientFk`, `agencyModeFk`, `longitude`, `latitude`, `isEqualizated`, `isDefaultAddress`)
|
||||
VALUES
|
||||
(1, 'Bruce Wayne', '1007 Mountain Drive, Gotham', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1101, 2, NULL, NULL, 0, 1),
|
||||
(2, 'Petter Parker', '20 Ingram Street', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1102, 2, NULL, NULL, 0, 1),
|
||||
(3, 'Clark Kent', '344 Clinton Street', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1103, 2, NULL, NULL, 0, 1),
|
||||
(4, 'Tony Stark', '10880 Malibu Point', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1104, 2, NULL, NULL, 0, 1),
|
||||
(5, 'Max Eisenhardt', 'Unknown Whereabouts', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1105, 2, NULL, NULL, 0, 1),
|
||||
(6, 'DavidCharlesHaller', 'Evil hideout', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1106, 2, NULL, NULL, 0, 1),
|
||||
(7, 'Hank Pym', 'Anthill', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1107, 2, NULL, NULL, 0, 1),
|
||||
(8, 'Charles Xavier', '3800 Victory Pkwy, Cincinnati, OH 45207, USA', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1108, 2, NULL, NULL, 0, 1),
|
||||
(9, 'Bruce Banner', 'Somewhere in New York', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 1),
|
||||
(10, 'Jessica Jones', 'NYCC 2015 Poster', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1110, 2, NULL, NULL, 0, 1),
|
||||
(11, 'Missing', 'The space', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1111, 10, NULL, NULL, 0, 1),
|
||||
(12, 'Trash', 'New York city', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1112, 10, NULL, NULL, 0, 1),
|
||||
(101, 'Somewhere in Thailand', 'address 01', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
|
||||
(102, 'Somewhere in Poland', 'address 02', 'Gotham', 46460, 1, 3333333333, 444444444, 1, 1109, 2, NULL, NULL, 0, 0),
|
||||
(103, 'Somewhere in Japan', 'address 03', 'Gotham', 46460, 1, 3333333333, 444444444, 1, 1109, 2, NULL, NULL, 0, 0),
|
||||
(104, 'Somewhere in Spain', 'address 04', 'Gotham', 46460, 1, 3333333333, 444444444, 1, 1109, 2, NULL, NULL, 0, 0),
|
||||
(105, 'Somewhere in Potugal', 'address 05', 'Gotham', 46460, 1, 5555555555, 666666666, 1, 1109, 2, NULL, NULL, 0, 0),
|
||||
(106, 'Somewhere in UK', 'address 06', 'Gotham', 46460, 1, 5555555555, 666666666, 1, 1109, 2, NULL, NULL, 0, 0),
|
||||
(107, 'Somewhere in Valencia', 'address 07', 'Gotham', 46460, 1, 5555555555, 666666666, 1, 1109, 2, NULL, NULL, 0, 0),
|
||||
(108, 'Somewhere in Gotham', 'address 08', 'Gotham', 46460, 1, 5555555555, 666666666, 1, 1109, 2, NULL, NULL, 0, 0),
|
||||
(109, 'Somewhere in London', 'address 09', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
|
||||
(110, 'Somewhere in Algemesi', 'address 10', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
|
||||
(111, 'Somewhere in Carlet', 'address 11', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
|
||||
(112, 'Somewhere in Campanar', 'address 12', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
|
||||
(113, 'Somewhere in Malilla', 'address 13', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
|
||||
(114, 'Somewhere in France', 'address 14', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
|
||||
(115, 'Somewhere in Birmingham', 'address 15', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
|
||||
(116, 'Somewhere in Scotland', 'address 16', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
|
||||
(117, 'Somewhere in nowhere', 'address 17', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
|
||||
(118, 'Somewhere over the rainbow', 'address 18', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
|
||||
(119, 'Somewhere in Alberic', 'address 19', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
|
||||
(120, 'Somewhere in Montortal', 'address 20', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
|
||||
(121, 'the bat cave', 'address 21', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1101, 2, NULL, NULL, 0, 0),
|
||||
(122, 'NY roofs', 'address 22', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1102, 2, NULL, NULL, 0, 0),
|
||||
(123, 'The phone box', 'address 23', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1103, 2, NULL, NULL, 0, 0),
|
||||
(124, 'Stark tower Gotham', 'address 24', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1104, 2, NULL, NULL, 0, 0),
|
||||
(125, 'The plastic cell', 'address 25', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1105, 2, NULL, NULL, 0, 0),
|
||||
(126, 'Many places', 'address 26', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1106, 2, NULL, NULL, 0, 0),
|
||||
(127, 'Your pocket', 'address 27', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1107, 2, NULL, NULL, 0, 0),
|
||||
(128, 'Cerebro', 'address 28', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1108, 2, NULL, NULL, 0, 0),
|
||||
(129, 'Luke Cages Bar', 'address 29', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1110, 2, NULL, NULL, 0, 0),
|
||||
(130, 'Non valid address', 'address 30', 'Gotham', 46460, 1, 1111111111, 222222222, 0, 1101, 2, NULL, NULL, 0, 0);
|
||||
(1, 'Bruce Wayne', '1007 Mountain Drive, Gotham', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1101, 2, NULL, NULL, 0, 1),
|
||||
(2, 'Petter Parker', '20 Ingram Street', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1102, 2, NULL, NULL, 0, 1),
|
||||
(3, 'Clark Kent', '344 Clinton Street', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1103, 2, NULL, NULL, 0, 1),
|
||||
(4, 'Tony Stark', '10880 Malibu Point', 'Gotham', 46460, 1, 1111111111, 222222222, 1 , 1104, 2, NULL, NULL, 0, 1),
|
||||
(5, 'Max Eisenhardt', 'Unknown Whereabouts', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1105, 2, NULL, NULL, 0, 1),
|
||||
(6, 'DavidCharlesHaller', 'Evil hideout', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1106, 2, NULL, NULL, 0, 1),
|
||||
(7, 'Hank Pym', 'Anthill', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1107, 2, NULL, NULL, 0, 1),
|
||||
(8, 'Charles Xavier', '3800 Victory Pkwy, Cincinnati, OH 45207, USA', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1108, 2, NULL, NULL, 0, 1),
|
||||
(9, 'Bruce Banner', 'Somewhere in New York', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 1),
|
||||
(10, 'Jessica Jones', 'NYCC 2015 Poster', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1110, 2, NULL, NULL, 0, 1),
|
||||
(11, 'Missing', 'The space', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1111, 10, NULL, NULL, 0, 1),
|
||||
(12, 'Trash', 'New York city', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1112, 10, NULL, NULL, 0, 1),
|
||||
(101, 'Somewhere in Thailand', 'address 01', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
|
||||
(102, 'Somewhere in Poland', 'address 02', 'Gotham', 46460, 1, 3333333333, 444444444, 1, 1109, 2, NULL, NULL, 0, 0),
|
||||
(103, 'Somewhere in Japan', 'address 03', 'Gotham', 46460, 1, 3333333333, 444444444, 1, 1109, 2, NULL, NULL, 0, 0),
|
||||
(104, 'Somewhere in Spain', 'address 04', 'Gotham', 46460, 1, 3333333333, 444444444, 1, 1109, 2, NULL, NULL, 0, 0),
|
||||
(105, 'Somewhere in Potugal', 'address 05', 'Gotham', 46460, 1, 5555555555, 666666666, 1, 1109, 2, NULL, NULL, 0, 0),
|
||||
(106, 'Somewhere in UK', 'address 06', 'Gotham', 46460, 1, 5555555555, 666666666, 1, 1109, 2, NULL, NULL, 0, 0),
|
||||
(107, 'Somewhere in Valencia', 'address 07', 'Gotham', 46460, 1, 5555555555, 666666666, 1, 1109, 2, NULL, NULL, 0, 0),
|
||||
(108, 'Somewhere in Gotham', 'address 08', 'Gotham', 46460, 1, 5555555555, 666666666, 1, 1109, 2, NULL, NULL, 0, 0),
|
||||
(109, 'Somewhere in London', 'address 09', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
|
||||
(110, 'Somewhere in Algemesi', 'address 10', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
|
||||
(111, 'Somewhere in Carlet', 'address 11', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
|
||||
(112, 'Somewhere in Campanar', 'address 12', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
|
||||
(113, 'Somewhere in Malilla', 'address 13', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
|
||||
(114, 'Somewhere in France', 'address 14', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
|
||||
(115, 'Somewhere in Birmingham', 'address 15', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
|
||||
(116, 'Somewhere in Scotland', 'address 16', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
|
||||
(117, 'Somewhere in nowhere', 'address 17', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
|
||||
(118, 'Somewhere over the rainbow', 'address 18', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
|
||||
(119, 'Somewhere in Alberic', 'address 19', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
|
||||
(120, 'Somewhere in Montortal', 'address 20', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0),
|
||||
(121, 'the bat cave', 'address 21', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1101, 2, NULL, NULL, 0, 0),
|
||||
(122, 'NY roofs', 'address 22', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1102, 2, NULL, NULL, 0, 0),
|
||||
(123, 'The phone box', 'address 23', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1103, 2, NULL, NULL, 0, 0),
|
||||
(124, 'Stark tower Gotham', 'address 24', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1104, 2, NULL, NULL, 0, 0),
|
||||
(125, 'The plastic cell', 'address 25', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1105, 2, NULL, NULL, 0, 0),
|
||||
(126, 'Many places', 'address 26', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1106, 2, NULL, NULL, 0, 0),
|
||||
(127, 'Your pocket', 'address 27', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1107, 2, NULL, NULL, 0, 0),
|
||||
(128, 'Cerebro', 'address 28', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1108, 2, NULL, NULL, 0, 0),
|
||||
(129, 'Luke Cages Bar', 'address 29', 'Gotham', 'EC170150', 1, 1111111111, 222222222, 1, 1110, 2, NULL, NULL, 0, 0),
|
||||
(130, 'Non valid address', 'address 30', 'Gotham', 46460, 1, 1111111111, 222222222, 0, 1101, 2, NULL, NULL, 0, 0);
|
||||
|
||||
INSERT INTO `vn`.`address`( `nickname`, `street`, `city`, `postalCode`, `provinceFk`, `isActive`, `clientFk`, `agencyModeFk`, `isDefaultAddress`)
|
||||
SELECT name, CONCAT(name, 'Street'), 'GOTHAM', 46460, 1, 1, id, 2, 1
|
||||
|
@ -1778,10 +1778,10 @@ INSERT INTO `vn`.`claimEnd`(`id`, `saleFk`, `claimFk`, `workerFk`, `claimDestina
|
|||
(1, 31, 4, 21, 2),
|
||||
(2, 32, 3, 21, 3);
|
||||
|
||||
INSERT INTO `vn`.`claimConfig`(`id`, `pickupContact`, `maxResponsibility`)
|
||||
INSERT INTO `vn`.`claimConfig`(`id`, `maxResponsibility`)
|
||||
VALUES
|
||||
(1, 'Contact description', 50),
|
||||
(2, 'Contact description', 30);
|
||||
(1, 50),
|
||||
(2, 30);
|
||||
|
||||
INSERT INTO `vn`.`claimRatio`(`clientFk`, `yearSale`, `claimAmount`, `claimingRate`, `priceIncreasing`, `packingRate`)
|
||||
VALUES
|
||||
|
@ -1791,7 +1791,7 @@ INSERT INTO `vn`.`claimRatio`(`clientFk`, `yearSale`, `claimAmount`, `claimingRa
|
|||
(1104, 2500, 150.00, 0.02, 0.10, 1.00);
|
||||
|
||||
INSERT INTO vn.claimRma (`id`, `code`, `created`, `workerFk`)
|
||||
VALUES
|
||||
VALUES
|
||||
(1, '02676A049183', DEFAULT, 1106),
|
||||
(2, '02676A049183', DEFAULT, 1106),
|
||||
(3, '02676A049183', DEFAULT, 1107),
|
||||
|
@ -2047,6 +2047,7 @@ INSERT INTO `vn`.`zoneIncluded` (`zoneFk`, `geoFk`, `isIncluded`)
|
|||
(8, 4, 0),
|
||||
(8, 5, 0),
|
||||
(8, 1, 1),
|
||||
(9, 7, 1),
|
||||
(10, 14, 1);
|
||||
|
||||
INSERT INTO `vn`.`zoneEvent`(`zoneFk`, `type`, `dated`)
|
||||
|
@ -2710,3 +2711,7 @@ INSERT INTO `vn`.`ticketCollection` (`ticketFk`, `collectionFk`, `created`, `lev
|
|||
UPDATE `account`.`user`
|
||||
SET `hasGrant` = 1
|
||||
WHERE `id` = 66;
|
||||
|
||||
INSERT INTO `vn`.`osTicketConfig` (`id`, `host`, `user`, `password`, `oldStatus`, `newStatusId`, `day`, `comment`, `hostDb`, `userDb`, `passwordDb`, `portDb`, `responseType`, `fromEmailId`, `replyTo`)
|
||||
VALUES
|
||||
(0, 'http://localhost:56596/scp', 'ostadmin', 'Admin1', 'open', 3, 60, 'Este CAU se ha cerrado automáticamente. Si el problema persiste responda a este mensaje.', 'localhost', 'osticket', 'osticket', 40003, 'reply', 1, 'all');
|
|
@ -1,37 +0,0 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
|
||||
|
||||
// #1885
|
||||
xdescribe('order_confirmWithUser()', () => {
|
||||
it('should confirm an order', async() => {
|
||||
let stmts = [];
|
||||
let stmt;
|
||||
|
||||
stmts.push('START TRANSACTION');
|
||||
|
||||
let params = {
|
||||
orderFk: 10,
|
||||
userId: 9
|
||||
};
|
||||
// problema: la funcion order_confirmWithUser tiene una transacción, por tanto esta nunca hace rollback
|
||||
stmt = new ParameterizedSQL('CALL hedera.order_confirmWithUser(?, ?)', [
|
||||
params.orderFk,
|
||||
params.userId
|
||||
]);
|
||||
stmts.push(stmt);
|
||||
|
||||
stmt = new ParameterizedSQL('SELECT confirmed FROM hedera.order WHERE id = ?', [
|
||||
params.orderFk
|
||||
]);
|
||||
let orderIndex = stmts.push(stmt) - 1;
|
||||
|
||||
stmts.push('ROLLBACK');
|
||||
|
||||
let sql = ParameterizedSQL.join(stmts, ';');
|
||||
let result = await app.models.Ticket.rawStmt(sql);
|
||||
|
||||
savedDescription = result[orderIndex][0].confirmed;
|
||||
|
||||
expect(savedDescription).toBeTruthy();
|
||||
});
|
||||
});
|
|
@ -596,7 +596,14 @@ export default {
|
|||
submitNotesButton: 'button[type=submit]'
|
||||
},
|
||||
ticketExpedition: {
|
||||
thirdExpeditionRemoveButton: 'vn-ticket-expedition vn-table div > vn-tbody > vn-tr:nth-child(3) > vn-td:nth-child(1) > vn-icon-button[icon="delete"]',
|
||||
firstSaleCheckbox: 'vn-ticket-expedition vn-tr:nth-child(1) vn-check[ng-model="expedition.checked"]',
|
||||
thirdSaleCheckbox: 'vn-ticket-expedition vn-tr:nth-child(3) vn-check[ng-model="expedition.checked"]',
|
||||
deleteExpeditionButton: 'vn-ticket-expedition vn-tool-bar > vn-button[icon="delete"]',
|
||||
moveExpeditionButton: 'vn-ticket-expedition vn-tool-bar > vn-button[icon="keyboard_arrow_down"]',
|
||||
moreMenuWithoutRoute: 'vn-item[name="withoutRoute"]',
|
||||
moreMenuWithRoute: 'vn-item[name="withRoute"]',
|
||||
newRouteId: '.vn-dialog.shown vn-textfield[ng-model="$ctrl.newRoute"]',
|
||||
saveButton: '.vn-dialog.shown [response="accept"]',
|
||||
expeditionRow: 'vn-ticket-expedition vn-table vn-tbody > vn-tr'
|
||||
},
|
||||
ticketPackages: {
|
||||
|
|
|
@ -18,7 +18,8 @@ describe('Ticket expeditions and log path', () => {
|
|||
});
|
||||
|
||||
it(`should delete a former expedition and confirm the remaining expedition are the expected ones`, async() => {
|
||||
await page.waitToClick(selectors.ticketExpedition.thirdExpeditionRemoveButton);
|
||||
await page.waitToClick(selectors.ticketExpedition.thirdSaleCheckbox);
|
||||
await page.waitToClick(selectors.ticketExpedition.deleteExpeditionButton);
|
||||
await page.waitToClick(selectors.globalItems.acceptButton);
|
||||
await page.reloadSection('ticket.card.expedition');
|
||||
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
import selectors from '../../helpers/selectors.js';
|
||||
import getBrowser from '../../helpers/puppeteer';
|
||||
|
||||
describe('Ticket expeditions', () => {
|
||||
let browser;
|
||||
let page;
|
||||
|
||||
beforeAll(async() => {
|
||||
browser = await getBrowser();
|
||||
page = browser.page;
|
||||
await page.loginAndModule('production', 'ticket');
|
||||
await page.accessToSearchResult('1');
|
||||
await page.accessToSection('ticket.card.expedition');
|
||||
});
|
||||
|
||||
afterAll(async() => {
|
||||
await browser.close();
|
||||
});
|
||||
|
||||
it(`should move one expedition to new ticket withoute route`, async() => {
|
||||
await page.waitToClick(selectors.ticketExpedition.thirdSaleCheckbox);
|
||||
await page.waitToClick(selectors.ticketExpedition.moveExpeditionButton);
|
||||
await page.waitToClick(selectors.ticketExpedition.moreMenuWithoutRoute);
|
||||
await page.waitToClick(selectors.ticketExpedition.saveButton);
|
||||
await page.waitForState('ticket.card.summary');
|
||||
await page.accessToSection('ticket.card.expedition');
|
||||
|
||||
await page.waitForSelector(selectors.ticketExpedition.expeditionRow, {});
|
||||
const result = await page
|
||||
.countElement(selectors.ticketExpedition.expeditionRow);
|
||||
|
||||
expect(result).toEqual(1);
|
||||
});
|
||||
|
||||
it(`should move one expedition to new ticket with route`, async() => {
|
||||
await page.waitToClick(selectors.ticketExpedition.firstSaleCheckbox);
|
||||
await page.waitToClick(selectors.ticketExpedition.moveExpeditionButton);
|
||||
await page.waitToClick(selectors.ticketExpedition.moreMenuWithRoute);
|
||||
await page.write(selectors.ticketExpedition.newRouteId, '1');
|
||||
await page.waitToClick(selectors.ticketExpedition.saveButton);
|
||||
await page.waitForState('ticket.card.summary');
|
||||
await page.accessToSection('ticket.card.expedition');
|
||||
|
||||
await page.waitForSelector(selectors.ticketExpedition.expeditionRow, {});
|
||||
const result = await page
|
||||
.countElement(selectors.ticketExpedition.expeditionRow);
|
||||
|
||||
expect(result).toEqual(1);
|
||||
});
|
||||
});
|
|
@ -51,6 +51,7 @@ Entries: Entradas
|
|||
Users: Usuarios
|
||||
Suppliers: Proveedores
|
||||
Monitors: Monitores
|
||||
Shelvings: Carros
|
||||
|
||||
# Common
|
||||
|
||||
|
|
|
@ -134,6 +134,7 @@
|
|||
"Password does not meet requirements": "Password does not meet requirements",
|
||||
"You don't have privileges to change the zone": "You don't have privileges to change the zone or for these parameters there are more than one shipping options, talk to agencies",
|
||||
"Not enough privileges to edit a client": "Not enough privileges to edit a client",
|
||||
"Claim pickup order sent": "Claim pickup order sent [({{claimId}})]({{{claimUrl}}}) to client *{{clientName}}*",
|
||||
"You don't have grant privilege": "You don't have grant privilege",
|
||||
"You don't own the role and you can't assign it to another user": "You don't own the role and you can't assign it to another user"
|
||||
}
|
||||
|
|
|
@ -236,6 +236,8 @@
|
|||
"Modifiable user details only by an administrator": "Detalles de usuario modificables solo por un administrador",
|
||||
"Modifiable password only via recovery or by an administrator": "Contraseña modificable solo a través de la recuperación o por un administrador",
|
||||
"Not enough privileges to edit a client": "No tienes suficientes privilegios para editar un cliente",
|
||||
"This route does not exists": "Esta ruta no existe",
|
||||
"Claim pickup order sent": "Reclamación Orden de recogida enviada [({{claimId}})]({{{claimUrl}}}) al cliente *{{clientName}}*",
|
||||
"You don't have grant privilege": "No tienes privilegios para dar privilegios",
|
||||
"You don't own the role and you can't assign it to another user": "No eres el propietario del rol y no puedes asignarlo a otro usuario"
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ module.exports = Self => {
|
|||
arg: 'id',
|
||||
type: 'number',
|
||||
required: true,
|
||||
description: 'The client id',
|
||||
description: 'The claim id',
|
||||
http: {source: 'path'}
|
||||
},
|
||||
{
|
||||
|
@ -42,6 +42,11 @@ module.exports = Self => {
|
|||
});
|
||||
|
||||
Self.claimPickupEmail = async ctx => {
|
||||
const models = Self.app.models;
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
const $t = ctx.req.__; // $translate
|
||||
const origin = ctx.req.headers.origin;
|
||||
|
||||
const args = Object.assign({}, ctx.args);
|
||||
const params = {
|
||||
recipient: args.recipient,
|
||||
|
@ -52,6 +57,34 @@ module.exports = Self => {
|
|||
for (const param in args)
|
||||
params[param] = args[param];
|
||||
|
||||
const claim = await models.Claim.findById(args.id, {
|
||||
fields: ['id', 'clientFk'],
|
||||
include: {
|
||||
relation: 'client',
|
||||
scope: {
|
||||
fields: ['name', 'salesPersonFk']
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const message = $t('Claim pickup order sent', {
|
||||
claimId: args.id,
|
||||
clientName: claim.client().name,
|
||||
claimUrl: `${origin}/#!/claim/${args.id}/summary`,
|
||||
});
|
||||
|
||||
const salesPersonId = claim.client().salesPersonFk;
|
||||
if (salesPersonId)
|
||||
await models.Chat.sendCheckingPresence(ctx, salesPersonId, message);
|
||||
|
||||
await models.ClaimLog.create({
|
||||
originFk: args.id,
|
||||
userFk: userId,
|
||||
action: 'insert',
|
||||
description: 'Claim-pickup-order sent',
|
||||
changedModel: 'Mail'
|
||||
});
|
||||
|
||||
const email = new Email('claim-pickup-order', params);
|
||||
|
||||
return email.send();
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
readonly="true">
|
||||
</vn-textfield>
|
||||
<vn-textfield
|
||||
label="Created"
|
||||
label="Created"
|
||||
field="::$ctrl.claim.created | date:'yyyy-MM-dd HH:mm'"
|
||||
readonly="true">
|
||||
</vn-textfield>
|
||||
|
@ -56,7 +56,7 @@
|
|||
label="Pick up"
|
||||
ng-model="$ctrl.claim.hasToPickUp"
|
||||
vn-acl="claimManager"
|
||||
info="When checked will notify to the salesPerson">
|
||||
title="{{'When checked will notify to the salesPerson' | translate}}">
|
||||
</vn-check>
|
||||
</vn-horizontal>
|
||||
</vn-card>
|
||||
|
|
|
@ -5,5 +5,5 @@ Responsability: Responsabilidad
|
|||
Company: Empresa
|
||||
Sales/Client: Comercial/Cliente
|
||||
Pick up: Recoger
|
||||
When checked will notify a pickup to the salesPerson: Cuando se marque enviará una notificación de recogida al comercial
|
||||
Packages received: Bultos recibidos
|
||||
When checked will notify to the salesPerson: Cuando se marque enviará una notificación de recogida al comercial
|
||||
Packages received: Bultos recibidos
|
||||
|
|
|
@ -25,16 +25,23 @@
|
|||
</vn-button-menu>
|
||||
</h5>
|
||||
<vn-horizontal>
|
||||
<vn-one>
|
||||
<vn-label-value
|
||||
label="Created"
|
||||
value="{{$ctrl.summary.claim.created | date: 'dd/MM/yyyy'}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value
|
||||
label="State"
|
||||
value="{{$ctrl.summary.claim.claimState.description}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value
|
||||
<vn-auto>
|
||||
<h4>
|
||||
<a
|
||||
ui-sref="claim.card.basicData({id:$ctrl.claim.id})"
|
||||
target="_self">
|
||||
<span translate vn-tooltip="Go to">Basic data</span>
|
||||
</a>
|
||||
</h4>
|
||||
<vn-label-value
|
||||
label="Created"
|
||||
value="{{$ctrl.summary.claim.created | date: 'dd/MM/yyyy'}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value
|
||||
label="State"
|
||||
value="{{$ctrl.summary.claim.claimState.description}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value
|
||||
label="Salesperson"
|
||||
value="{{$ctrl.summary.claim.client.salesPersonUser.name}}">
|
||||
</vn-label-value>
|
||||
|
@ -42,16 +49,23 @@
|
|||
label="Attended by"
|
||||
value="{{$ctrl.summary.claim.worker.user.nickname}}">
|
||||
</vn-label-value>
|
||||
</vn-one>
|
||||
<vn-check
|
||||
class="vn-mr-md"
|
||||
label="Pick up"
|
||||
ng-model="$ctrl.summary.claim.hasToPickUp"
|
||||
title="{{'When checked will notify to the salesPerson' | translate}}"
|
||||
disabled="true">
|
||||
</vn-check>
|
||||
</vn-auto>
|
||||
<vn-auto>
|
||||
<h4 ng-show="$ctrl.isSalesPerson && $ctrl.summary.observations.length">
|
||||
<a
|
||||
<a
|
||||
ui-sref="claim.card.note.index({id:$ctrl.claim.id})"
|
||||
target="_self">
|
||||
<span translate vn-tooltip="Go to">Observations</span>
|
||||
</a>
|
||||
</h4>
|
||||
<h4
|
||||
<h4
|
||||
ng-show="!$ctrl.isSalesPerson && $ctrl.summary.observations.length"
|
||||
translate>
|
||||
Observations
|
||||
|
@ -70,13 +84,13 @@
|
|||
</vn-auto>
|
||||
<vn-auto>
|
||||
<h4 ng-show="$ctrl.isSalesPerson">
|
||||
<a
|
||||
<a
|
||||
ui-sref="claim.card.detail({id:$ctrl.claim.id})"
|
||||
target="_self">
|
||||
<span translate vn-tooltip="Go to">Detail</span>
|
||||
</a>
|
||||
</h4>
|
||||
<h4
|
||||
<h4
|
||||
ng-show="!$ctrl.isSalesPerson"
|
||||
translate>
|
||||
Detail
|
||||
|
@ -98,7 +112,7 @@
|
|||
<vn-tbody>
|
||||
<vn-tr ng-repeat="saleClaimed in $ctrl.summary.salesClaimed">
|
||||
<vn-td number>
|
||||
<span
|
||||
<span
|
||||
ng-click="itemDescriptor.show($event, saleClaimed.sale.itemFk, saleClaimed.sale.id)"
|
||||
class="link">
|
||||
{{::saleClaimed.sale.itemFk | zeroFill:6}}
|
||||
|
@ -111,7 +125,7 @@
|
|||
<vn-td number>{{::saleClaimed.sale.price | currency: 'EUR':2}}</vn-td>
|
||||
<vn-td number>{{::saleClaimed.sale.discount}} %</vn-td>
|
||||
<vn-td number>
|
||||
{{saleClaimed.sale.quantity * saleClaimed.sale.price *
|
||||
{{saleClaimed.sale.quantity * saleClaimed.sale.price *
|
||||
((100 - saleClaimed.sale.discount) / 100) | currency: 'EUR':2}}
|
||||
</vn-td>
|
||||
</vn-tr>
|
||||
|
@ -123,7 +137,7 @@
|
|||
<h4 translate>Photos</h4>
|
||||
<vn-horizontal class="photo-list">
|
||||
<section class="photo" ng-repeat="photo in photos">
|
||||
<section class="image" on-error-src
|
||||
<section class="image" on-error-src
|
||||
ng-style="{'background': 'url(' + $ctrl.getImagePath(photo.dmsFk) + ')'}"
|
||||
zoom-image="{{$ctrl.getImagePath(photo.dmsFk)}}"
|
||||
ng-if="photo.dms.contentType != 'video/mp4'">
|
||||
|
@ -137,13 +151,13 @@
|
|||
</vn-auto>
|
||||
<vn-auto>
|
||||
<h4 ng-show="$ctrl.isClaimManager">
|
||||
<a
|
||||
<a
|
||||
ui-sref="claim.card.development({id:$ctrl.claim.id})"
|
||||
target="_self">
|
||||
<span translate vn-tooltip="Go to">Development</span>
|
||||
</a>
|
||||
</h4>
|
||||
<h4
|
||||
<h4
|
||||
translate
|
||||
ng-show="!$ctrl.isClaimManager">
|
||||
Development
|
||||
|
@ -165,8 +179,8 @@
|
|||
<vn-td>{{::development.claimResult.description}}</vn-td>
|
||||
<vn-td>{{::development.claimResponsible.description}}</vn-td>
|
||||
<vn-td expand>
|
||||
<span
|
||||
class="link"
|
||||
<span
|
||||
class="link"
|
||||
ng-click="workerDescriptor.show($event, development.workerFk)">
|
||||
{{::development.worker.user.nickname}}
|
||||
</span>
|
||||
|
@ -179,21 +193,21 @@
|
|||
</vn-auto>
|
||||
<vn-auto>
|
||||
<h4 ng-show="$ctrl.isClaimManager">
|
||||
<a
|
||||
<a
|
||||
ui-sref="claim.card.action({id:$ctrl.claim.id})"
|
||||
target="_self">
|
||||
<span translate vn-tooltip="Go to">Action</span>
|
||||
</a>
|
||||
</h4>
|
||||
<h4
|
||||
translate
|
||||
translate
|
||||
ng-show="!$ctrl.isClaimManager">
|
||||
Action
|
||||
</h4>
|
||||
<vn-horizontal>
|
||||
<vn-one>
|
||||
<vn-range
|
||||
vn-one
|
||||
vn-one
|
||||
disabled="true"
|
||||
label="Responsability"
|
||||
min-label="Company"
|
||||
|
@ -224,14 +238,14 @@
|
|||
<vn-tbody>
|
||||
<vn-tr ng-repeat="action in $ctrl.summary.actions">
|
||||
<vn-td number>
|
||||
<span
|
||||
<span
|
||||
ng-click="itemDescriptor.show($event, action.sale.itemFk, action.sale.id)"
|
||||
class="link">
|
||||
{{::action.sale.itemFk | zeroFill:6}}
|
||||
</span>
|
||||
</vn-td>
|
||||
<vn-td number>
|
||||
<span
|
||||
<span
|
||||
ng-click="ticketDescriptor.show($event, action.sale.ticket.id)"
|
||||
class="link">
|
||||
{{::action.sale.ticket.id}}
|
||||
|
@ -258,9 +272,9 @@
|
|||
vn-id="item-descriptor"
|
||||
warehouse-fk="$ctrl.vnConfig.warehouseFk">
|
||||
</vn-item-descriptor-popover>
|
||||
<vn-worker-descriptor-popover
|
||||
<vn-worker-descriptor-popover
|
||||
vn-id="worker-descriptor">
|
||||
</vn-worker-descriptor-popover>
|
||||
<vn-ticket-descriptor-popover
|
||||
<vn-ticket-descriptor-popover
|
||||
vn-id="ticket-descriptor">
|
||||
</vn-ticket-descriptor-popover>
|
||||
</vn-ticket-descriptor-popover>
|
||||
|
|
|
@ -0,0 +1,147 @@
|
|||
|
||||
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
|
||||
const buildFilter = require('vn-loopback/util/filter').buildFilter;
|
||||
const mergeFilters = require('vn-loopback/util/filter').mergeFilters;
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('filter', {
|
||||
description: 'Find all clients matched by the filter',
|
||||
accessType: 'READ',
|
||||
accepts: [
|
||||
{
|
||||
arg: 'filter',
|
||||
type: 'object',
|
||||
},
|
||||
{
|
||||
arg: 'search',
|
||||
type: 'string',
|
||||
description: `If it's and integer searchs by id, otherwise it searchs by name`,
|
||||
},
|
||||
{
|
||||
arg: 'name',
|
||||
type: 'string',
|
||||
description: 'The client name',
|
||||
},
|
||||
{
|
||||
arg: 'salesPersonFk',
|
||||
type: 'number',
|
||||
},
|
||||
{
|
||||
arg: 'fi',
|
||||
type: 'string',
|
||||
description: 'The client fiscal id',
|
||||
},
|
||||
{
|
||||
arg: 'socialName',
|
||||
type: 'string',
|
||||
},
|
||||
{
|
||||
arg: 'city',
|
||||
type: 'string',
|
||||
},
|
||||
{
|
||||
arg: 'postcode',
|
||||
type: 'string',
|
||||
},
|
||||
{
|
||||
arg: 'provinceFk',
|
||||
type: 'number',
|
||||
},
|
||||
{
|
||||
arg: 'email',
|
||||
type: 'string',
|
||||
},
|
||||
{
|
||||
arg: 'phone',
|
||||
type: 'string',
|
||||
},
|
||||
{
|
||||
arg: 'zoneFk',
|
||||
type: 'number',
|
||||
},
|
||||
],
|
||||
returns: {
|
||||
type: ['object'],
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/filter`,
|
||||
verb: 'GET'
|
||||
}
|
||||
});
|
||||
|
||||
Self.filter = async(ctx, filter, options) => {
|
||||
const conn = Self.dataSource.connector;
|
||||
const myOptions = {};
|
||||
const postalCode = [];
|
||||
const args = ctx.args;
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
if (args.zoneFk) {
|
||||
query = `CALL vn.zone_getPostalCode(?)`;
|
||||
const [geos] = await Self.rawSql(query, [args.zoneFk]);
|
||||
for (let geo of geos)
|
||||
postalCode.push(geo.name);
|
||||
}
|
||||
|
||||
const where = buildFilter(ctx.args, (param, value) => {
|
||||
switch (param) {
|
||||
case 'search':
|
||||
return /^\d+$/.test(value)
|
||||
? {'c.id': {inq: value}}
|
||||
: {'c.name': {like: `%${value}%`}};
|
||||
case 'name':
|
||||
case 'salesPersonFk':
|
||||
case 'fi':
|
||||
case 'socialName':
|
||||
case 'city':
|
||||
case 'postcode':
|
||||
case 'provinceFk':
|
||||
case 'email':
|
||||
case 'phone':
|
||||
param = `c.${param}`;
|
||||
return {[param]: value};
|
||||
case 'zoneFk':
|
||||
param = 'a.postalCode';
|
||||
return {[param]: {inq: postalCode}};
|
||||
}
|
||||
});
|
||||
|
||||
filter = mergeFilters(filter, {where});
|
||||
|
||||
const stmts = [];
|
||||
const stmt = new ParameterizedSQL(
|
||||
`SELECT
|
||||
DISTINCT c.id,
|
||||
c.name,
|
||||
c.fi,
|
||||
c.socialName,
|
||||
c.phone,
|
||||
c.city,
|
||||
c.postcode,
|
||||
c.email,
|
||||
c.isActive,
|
||||
c.isFreezed,
|
||||
p.id AS provinceFk,
|
||||
p.name AS province,
|
||||
u.id AS salesPersonFk,
|
||||
u.name AS salesPerson
|
||||
FROM client c
|
||||
LEFT JOIN account.user u ON u.id = c.salesPersonFk
|
||||
LEFT JOIN province p ON p.id = c.provinceFk
|
||||
JOIN vn.address a ON a.clientFk = c.id
|
||||
`
|
||||
);
|
||||
|
||||
stmt.merge(conn.makeWhere(filter.where));
|
||||
stmt.merge(conn.makePagination(filter));
|
||||
|
||||
const clientsIndex = stmts.push(stmt) - 1;
|
||||
const sql = ParameterizedSQL.join(stmts, ';');
|
||||
const result = await conn.executeStmt(sql, myOptions);
|
||||
|
||||
return clientsIndex === 0 ? result : result[clientsIndex];
|
||||
};
|
||||
};
|
|
@ -0,0 +1,199 @@
|
|||
const {models} = require('vn-loopback/server/server');
|
||||
|
||||
describe('client filter()', () => {
|
||||
it('should return the clients matching the filter with a limit of 20 rows', async() => {
|
||||
const tx = await models.Client.beginTransaction({});
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const ctx = {req: {accessToken: {userId: 1}}, args: {}};
|
||||
const filter = {limit: '8'};
|
||||
const result = await models.Client.filter(ctx, filter, options);
|
||||
|
||||
expect(result.length).toEqual(8);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
|
||||
it('should return the client "Bruce Wayne" matching the search argument with his name', async() => {
|
||||
const tx = await models.Client.beginTransaction({});
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const ctx = {req: {accessToken: {userId: 1}}, args: {search: 'Bruce Wayne'}};
|
||||
const filter = {};
|
||||
const result = await models.Client.filter(ctx, filter, options);
|
||||
|
||||
const firstResult = result[0];
|
||||
|
||||
expect(result.length).toEqual(1);
|
||||
expect(firstResult.name).toEqual('Bruce Wayne');
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
|
||||
it('should return the client "Bruce Wayne" matching the search argument with his id', async() => {
|
||||
const tx = await models.Client.beginTransaction({});
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const ctx = {req: {accessToken: {userId: 1}}, args: {search: '1101'}};
|
||||
const filter = {};
|
||||
const result = await models.Client.filter(ctx, filter, options);
|
||||
|
||||
const firstResult = result[0];
|
||||
|
||||
expect(result.length).toEqual(1);
|
||||
expect(firstResult.name).toEqual('Bruce Wayne');
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
|
||||
it('should return the client "Bruce Wayne" matching the name argument', async() => {
|
||||
const tx = await models.Client.beginTransaction({});
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const ctx = {req: {accessToken: {userId: 1}}, args: {name: 'Bruce Wayne'}};
|
||||
const filter = {};
|
||||
const result = await models.Client.filter(ctx, filter, options);
|
||||
|
||||
const firstResult = result[0];
|
||||
|
||||
expect(result.length).toEqual(1);
|
||||
expect(firstResult.name).toEqual('Bruce Wayne');
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
|
||||
it('should return the clients matching the "salesPersonFk" argument', async() => {
|
||||
const tx = await models.Client.beginTransaction({});
|
||||
const salesPersonId = 18;
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const ctx = {req: {accessToken: {userId: 1}}, args: {salesPersonFk: salesPersonId}};
|
||||
const filter = {};
|
||||
const result = await models.Client.filter(ctx, filter, options);
|
||||
|
||||
const randomIndex = Math.floor(Math.random() * result.length);
|
||||
const randomResultClient = result[randomIndex];
|
||||
|
||||
expect(result.length).toBeGreaterThanOrEqual(5);
|
||||
expect(randomResultClient.salesPersonFk).toEqual(salesPersonId);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
|
||||
it('should return the clients matching the "fi" argument', async() => {
|
||||
const tx = await models.Client.beginTransaction({});
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const ctx = {req: {accessToken: {userId: 1}}, args: {fi: '251628698'}};
|
||||
const filter = {};
|
||||
const result = await models.Client.filter(ctx, filter, options);
|
||||
|
||||
const firstClient = result[0];
|
||||
|
||||
expect(result.length).toEqual(1);
|
||||
expect(firstClient.name).toEqual('Max Eisenhardt');
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
|
||||
it('should return the clients matching the "city" argument', async() => {
|
||||
const tx = await models.Client.beginTransaction({});
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const ctx = {req: {accessToken: {userId: 1}}, args: {city: 'Gotham'}};
|
||||
const filter = {};
|
||||
const result = await models.Client.filter(ctx, filter, options);
|
||||
|
||||
const randomIndex = Math.floor(Math.random() * result.length);
|
||||
const randomResultClient = result[randomIndex];
|
||||
|
||||
expect(result.length).toBeGreaterThanOrEqual(20);
|
||||
expect(randomResultClient.city.toLowerCase()).toEqual('gotham');
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
|
||||
it('should return the clients matching the "postcode" argument', async() => {
|
||||
const tx = await models.Client.beginTransaction({});
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const ctx = {req: {accessToken: {userId: 1}}, args: {postcode: '46460'}};
|
||||
const filter = {};
|
||||
const result = await models.Client.filter(ctx, filter, options);
|
||||
|
||||
const randomIndex = Math.floor(Math.random() * result.length);
|
||||
const randomResultClient = result[randomIndex];
|
||||
|
||||
expect(result.length).toBeGreaterThanOrEqual(20);
|
||||
expect(randomResultClient.postcode).toEqual('46460');
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
|
||||
it('should return the clients matching the "zoneFk" argument', async() => {
|
||||
const tx = await models.Client.beginTransaction({});
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const ctx = {req: {accessToken: {userId: 1}}, args: {zoneFk: 9}};
|
||||
const filter = {};
|
||||
const result = await models.Client.filter(ctx, filter, options);
|
||||
|
||||
expect(result.length).toBe(1);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
});
|
|
@ -8,6 +8,9 @@
|
|||
"BankEntity": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"Business": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"BusinessType": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
"name": "Business",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "business"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "number",
|
||||
"id": true
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"worker": {
|
||||
"type": "belongsTo",
|
||||
"model": "Worker",
|
||||
"foreignKey": "workerFk"
|
||||
},
|
||||
"department": {
|
||||
"type": "belongsTo",
|
||||
"model": "Department",
|
||||
"foreignKey": "departmentFk"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -47,4 +47,5 @@ module.exports = Self => {
|
|||
require('../methods/client/incotermsAuthorizationHtml')(Self);
|
||||
require('../methods/client/incotermsAuthorizationEmail')(Self);
|
||||
require('../methods/client/consumptionSendQueued')(Self);
|
||||
require('../methods/client/filter')(Self);
|
||||
};
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<vn-crud-model
|
||||
vn-id="model"
|
||||
url="Clients"
|
||||
url="Clients/filter"
|
||||
order="id DESC"
|
||||
limit="8"
|
||||
data="clients">
|
||||
|
@ -10,8 +10,7 @@
|
|||
vn-focus
|
||||
panel="vn-client-search-panel"
|
||||
info="Search client by id or name"
|
||||
model="model"
|
||||
expr-builder="$ctrl.exprBuilder(param, value)">
|
||||
model="model">
|
||||
</vn-searchbar>
|
||||
</vn-portal>
|
||||
<vn-portal slot="menu">
|
||||
|
|
|
@ -2,32 +2,6 @@ import ngModule from '../module';
|
|||
import ModuleMain from 'salix/components/module-main';
|
||||
|
||||
export default class Client extends ModuleMain {
|
||||
exprBuilder(param, value) {
|
||||
switch (param) {
|
||||
case 'search':
|
||||
return /^\d+$/.test(value)
|
||||
? {id: value}
|
||||
: {or: [{name: {like: `%${value}%`}}, {socialName: {like: `%${value}%`}}]};
|
||||
case 'phone':
|
||||
return {
|
||||
or: [
|
||||
{phone: value},
|
||||
{mobile: value}
|
||||
]
|
||||
};
|
||||
case 'name':
|
||||
case 'socialName':
|
||||
case 'city':
|
||||
case 'email':
|
||||
return {[param]: {like: `%${value}%`}};
|
||||
case 'id':
|
||||
case 'fi':
|
||||
case 'postcode':
|
||||
case 'provinceFk':
|
||||
case 'salesPersonFk':
|
||||
return {[param]: value};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ngModule.vnComponent('vnClient', {
|
||||
|
|
|
@ -58,6 +58,13 @@
|
|||
value-field="id"
|
||||
label="Province">
|
||||
</vn-autocomplete>
|
||||
<vn-autocomplete
|
||||
ng-model="filter.zoneFk"
|
||||
url="Zones"
|
||||
show-field="name"
|
||||
value-field="id"
|
||||
label="Zone">
|
||||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-textfield
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethod('deleteItemShelvings', {
|
||||
description: 'Deletes the selected item shelvings',
|
||||
accessType: 'WRITE',
|
||||
accepts: [{
|
||||
arg: 'itemShelvingIds',
|
||||
type: ['number'],
|
||||
required: true,
|
||||
description: 'The itemShelving ids to delete'
|
||||
}],
|
||||
returns: {
|
||||
type: ['object'],
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/deleteItemShelvings`,
|
||||
verb: 'POST'
|
||||
}
|
||||
});
|
||||
|
||||
Self.deleteItemShelvings = async(itemShelvingIds, options) => {
|
||||
const models = Self.app.models;
|
||||
const myOptions = {};
|
||||
let tx;
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
if (!myOptions.transaction) {
|
||||
tx = await Self.beginTransaction({});
|
||||
myOptions.transaction = tx;
|
||||
}
|
||||
|
||||
try {
|
||||
const promises = [];
|
||||
for (let itemShelvingId of itemShelvingIds) {
|
||||
const itemShelvingToDelete = models.ItemShelving.destroyById(itemShelvingId, myOptions);
|
||||
promises.push(itemShelvingToDelete);
|
||||
}
|
||||
|
||||
const deletedItemShelvings = await Promise.all(promises);
|
||||
|
||||
if (tx) await tx.commit();
|
||||
|
||||
return deletedItemShelvings;
|
||||
} catch (e) {
|
||||
if (tx) await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
};
|
|
@ -0,0 +1,21 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('ItemShelving deleteItemShelvings()', () => {
|
||||
it('should return the deleted itemShelvings', async() => {
|
||||
const tx = await models.Order.beginTransaction({});
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const itemShelvingIds = [1, 2];
|
||||
const result = await models.ItemShelving.deleteItemShelvings(itemShelvingIds, options);
|
||||
|
||||
expect(result.length).toEqual(2);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
});
|
|
@ -53,6 +53,9 @@
|
|||
"ItemShelvingSale": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"ItemShelvingPlacementSupplyStock": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"ItemImageQueue": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
{
|
||||
"name": "ItemShelvingPlacementSupplyStock",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "itemShelvingPlacementSupplyStock"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"itemShelvingFk": {
|
||||
"type": "number",
|
||||
"id": true
|
||||
},
|
||||
"created": {
|
||||
"type": "date"
|
||||
},
|
||||
"itemFk": {
|
||||
"type": "number"
|
||||
},
|
||||
"longName": {
|
||||
"type": "string"
|
||||
},
|
||||
"parking": {
|
||||
"type": "string"
|
||||
},
|
||||
"shelving": {
|
||||
"type": "string"
|
||||
},
|
||||
"packing": {
|
||||
"type": "number"
|
||||
},
|
||||
"stock": {
|
||||
"type": "number"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = Self => {
|
||||
require('../methods/item-shelving/deleteItemShelvings')(Self);
|
||||
};
|
|
@ -24,3 +24,5 @@ import './waste/detail';
|
|||
import './fixed-price';
|
||||
import './fixed-price-search-panel';
|
||||
import './item-type';
|
||||
import './item-shelving';
|
||||
|
||||
|
|
|
@ -0,0 +1,118 @@
|
|||
<vn-crud-model
|
||||
vn-id="model"
|
||||
url="ItemShelvingPlacementSupplyStocks"
|
||||
link="{itemFk: $ctrl.$params.id}"
|
||||
data="$ctrl.itemShelvingPlacementSupplyStocks"
|
||||
auto-load="true">
|
||||
</vn-crud-model>
|
||||
<vn-card>
|
||||
<smart-table
|
||||
model="model"
|
||||
options="$ctrl.smartTableOptions"
|
||||
expr-builder="$ctrl.exprBuilder(param, value)">
|
||||
<slot-actions>
|
||||
<div>
|
||||
<div class="totalBox" style="text-align: center;">
|
||||
<h6 translate>Total</h6>
|
||||
<vn-label-value
|
||||
label="Total labels"
|
||||
value="{{$ctrl.labelTotal.toFixed(2)}}">
|
||||
</vn-label-value>
|
||||
</div>
|
||||
</div>
|
||||
<div class="vn-pa-md">
|
||||
<vn-button
|
||||
disabled="!$ctrl.checked.length"
|
||||
ng-click="removeConfirm.show()"
|
||||
icon="delete"
|
||||
vn-tooltip="Remove selected lines"
|
||||
vn-acl="replenisherBos">
|
||||
</vn-button>
|
||||
</div>
|
||||
</slot-actions>
|
||||
<slot-table>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th shrink>
|
||||
<vn-multi-check
|
||||
model="model">
|
||||
</vn-multi-check>
|
||||
</th>
|
||||
<th field="created">
|
||||
<span translate>Created</span>
|
||||
</th>
|
||||
<th shrink field="itemFk">
|
||||
<span translate>Item</span>
|
||||
</th>
|
||||
<th
|
||||
field="longName">
|
||||
<span translate>Concept</span>
|
||||
</th>
|
||||
<th
|
||||
field="parking">
|
||||
<span translate>Parking</span>
|
||||
</th>
|
||||
<th field="shelving">
|
||||
<span translate>Shelving</span>
|
||||
</th>
|
||||
<th
|
||||
field="label">
|
||||
<span translate>Etiqueta</span>
|
||||
</th>
|
||||
<th
|
||||
field="packing"
|
||||
shrink>
|
||||
<span translate>Packing</span>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr
|
||||
ng-repeat="itemShelvingPlacementSupplyStock in $ctrl.itemShelvingPlacementSupplyStocks"
|
||||
vn-repeat-last on-last="$ctrl.calculateTotals()">
|
||||
<td shrink>
|
||||
<vn-check
|
||||
ng-model="itemShelvingPlacementSupplyStock.checked"
|
||||
vn-click-stop>
|
||||
</vn-check>
|
||||
</td>
|
||||
<td shrink-date>{{::itemShelvingPlacementSupplyStock.created | date: 'dd/MM/yyyy'}}</td>
|
||||
<td>
|
||||
{{::itemShelvingPlacementSupplyStock.itemFk}}
|
||||
</td>
|
||||
<td expand title="{{::itemShelvingPlacementSupplyStock.longName}}">
|
||||
<span
|
||||
vn-click-stop="itemDescriptor.show($event, itemShelvingPlacementSupplyStock.itemFk)"
|
||||
class="link">
|
||||
{{itemShelvingPlacementSupplyStock.longName}}
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
{{::itemShelvingPlacementSupplyStock.parking}}
|
||||
</td>
|
||||
<td>
|
||||
{{::itemShelvingPlacementSupplyStock.shelving}}
|
||||
</td>
|
||||
<td>
|
||||
{{(itemShelvingPlacementSupplyStock.stock / itemShelvingPlacementSupplyStock.packing).toFixed(2)}}
|
||||
</td>
|
||||
<td>
|
||||
{{::itemShelvingPlacementSupplyStock.packing}}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</slot-table>
|
||||
</smart-table>
|
||||
</vn-card>
|
||||
<vn-item-descriptor-popover
|
||||
vn-id="item-descriptor">
|
||||
</vn-item-descriptor-popover>
|
||||
|
||||
<vn-confirm
|
||||
vn-id="removeConfirm"
|
||||
message="Selected lines will be deleted"
|
||||
question="Are you sure you want to continue?"
|
||||
on-accept="$ctrl.onRemove()">
|
||||
</vn-confirm>
|
|
@ -0,0 +1,89 @@
|
|||
import ngModule from '../module';
|
||||
import Section from 'salix/components/section';
|
||||
|
||||
export default class Controller extends Section {
|
||||
constructor($element, $) {
|
||||
super($element, $);
|
||||
|
||||
this.smartTableOptions = {
|
||||
activeButtons: {
|
||||
search: true
|
||||
},
|
||||
columns: [
|
||||
{
|
||||
field: 'parking',
|
||||
autocomplete: {
|
||||
url: 'Parkings',
|
||||
showField: 'code',
|
||||
valueField: 'code'
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'shelving',
|
||||
autocomplete: {
|
||||
url: 'Shelvings',
|
||||
showField: 'code',
|
||||
valueField: 'code'
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'created',
|
||||
searchable: false
|
||||
},
|
||||
{
|
||||
field: 'itemFk',
|
||||
searchable: false
|
||||
},
|
||||
{
|
||||
field: 'longName',
|
||||
searchable: false
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
get checked() {
|
||||
const itemShelvings = this.$.model.data || [];
|
||||
const checkedLines = [];
|
||||
for (let itemShelving of itemShelvings) {
|
||||
if (itemShelving.checked)
|
||||
checkedLines.push(itemShelving.itemShelvingFk);
|
||||
}
|
||||
|
||||
return checkedLines;
|
||||
}
|
||||
|
||||
calculateTotals() {
|
||||
this.labelTotal = 0;
|
||||
const itemShelvings = this.$.model.data || [];
|
||||
itemShelvings.forEach(itemShelving => {
|
||||
const label = itemShelving.stock / itemShelving.packing;
|
||||
this.labelTotal += label;
|
||||
});
|
||||
}
|
||||
|
||||
onRemove() {
|
||||
const params = {itemShelvingIds: this.checked};
|
||||
const query = `ItemShelvings/deleteItemShelvings`;
|
||||
this.$http.post(query, params)
|
||||
.then(() => {
|
||||
this.vnApp.showSuccess(this.$t('ItemShelvings removed'));
|
||||
this.$.model.refresh();
|
||||
});
|
||||
}
|
||||
|
||||
exprBuilder(param, value) {
|
||||
switch (param) {
|
||||
case 'parking':
|
||||
case 'shelving':
|
||||
case 'label':
|
||||
case 'packing':
|
||||
return {[param]: value};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ngModule.vnComponent('vnItemShelving', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller
|
||||
});
|
|
@ -0,0 +1,81 @@
|
|||
import './index';
|
||||
import crudModel from 'core/mocks/crud-model';
|
||||
|
||||
describe('item shelving', () => {
|
||||
describe('Component vnItemShelving', () => {
|
||||
let controller;
|
||||
let $httpBackend;
|
||||
|
||||
beforeEach(ngModule('item'));
|
||||
|
||||
beforeEach(inject(($componentController, _$httpBackend_) => {
|
||||
$httpBackend = _$httpBackend_;
|
||||
const $element = angular.element('<vn-item-shelving></vn-item-shelving>');
|
||||
controller = $componentController('vnItemShelving', {$element});
|
||||
controller.$.model = crudModel;
|
||||
controller.$.model.data = [
|
||||
{itemShelvingFk: 1, packing: 10, stock: 1},
|
||||
{itemShelvingFk: 2, packing: 12, stock: 5},
|
||||
{itemShelvingFk: 4, packing: 20, stock: 10}
|
||||
];
|
||||
const modelData = controller.$.model.data;
|
||||
modelData[0].checked = true;
|
||||
modelData[1].checked = true;
|
||||
}));
|
||||
|
||||
describe('checked() getter', () => {
|
||||
it('should return a the selected rows', () => {
|
||||
const result = controller.checked;
|
||||
|
||||
expect(result).toEqual(expect.arrayContaining([1, 2]));
|
||||
});
|
||||
});
|
||||
|
||||
describe('calculateTotals()', () => {
|
||||
it('should calculate the total of labels', () => {
|
||||
controller.calculateTotals();
|
||||
|
||||
expect(controller.labelTotal).toEqual(1.0166666666666666);
|
||||
});
|
||||
});
|
||||
|
||||
describe('onRemove()', () => {
|
||||
it('shoud remove the selected lines', () => {
|
||||
jest.spyOn(controller.$.model, 'refresh');
|
||||
const expectedParams = {itemShelvingIds: [1, 2]};
|
||||
|
||||
$httpBackend.expectPOST('ItemShelvings/deleteItemShelvings', expectedParams).respond(200);
|
||||
controller.onRemove();
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(controller.$.model.refresh).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('exprBuilder()', () => {
|
||||
it('should search by parking', () => {
|
||||
const expr = controller.exprBuilder('parking', '700-01');
|
||||
|
||||
expect(expr).toEqual({'parking': '700-01'});
|
||||
});
|
||||
|
||||
it('should search by shelving', () => {
|
||||
const expr = controller.exprBuilder('shelving', 'AAA');
|
||||
|
||||
expect(expr).toEqual({'shelving': 'AAA'});
|
||||
});
|
||||
|
||||
it('should search by label', () => {
|
||||
const expr = controller.exprBuilder('label', 0.17);
|
||||
|
||||
expect(expr).toEqual({'label': 0.17});
|
||||
});
|
||||
|
||||
it('should search by packing', () => {
|
||||
const expr = controller.exprBuilder('packing', 10);
|
||||
|
||||
expect(expr).toEqual({'packing': 10});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
|
@ -0,0 +1,5 @@
|
|||
Shelving: Matrícula
|
||||
Remove selected lines: Eliminar líneas seleccionadas
|
||||
Selected lines will be deleted: Las líneas seleccionadas serán eliminadas
|
||||
ItemShelvings removed: Carros eliminados
|
||||
Total labels: Total etiquetas
|
|
@ -54,6 +54,7 @@ Basic data: Datos básicos
|
|||
Tax: IVA
|
||||
History: Historial
|
||||
Botanical: Botánico
|
||||
Shelvings: Carros
|
||||
Barcodes: Códigos de barras
|
||||
Diary: Histórico
|
||||
Item diary: Registro de compra-venta
|
||||
|
|
|
@ -15,11 +15,12 @@
|
|||
"card": [
|
||||
{"state": "item.card.basicData", "icon": "settings"},
|
||||
{"state": "item.card.tags", "icon": "icon-tags"},
|
||||
{"state": "item.card.last-entries", "icon": "icon-regentry"},
|
||||
{"state": "item.card.tax", "icon": "icon-tax"},
|
||||
{"state": "item.card.botanical", "icon": "local_florist"},
|
||||
{"state": "item.card.botanical", "icon": "local_florist"},
|
||||
{"state": "item.card.shelving", "icon": "icon-inventory"},
|
||||
{"state": "item.card.itemBarcode", "icon": "icon-barcode"},
|
||||
{"state": "item.card.diary", "icon": "icon-transaction"},
|
||||
{"state": "item.card.last-entries", "icon": "icon-regentry"},
|
||||
{"state": "item.card.log", "icon": "history"}
|
||||
],
|
||||
"itemType": [
|
||||
|
@ -92,6 +93,16 @@
|
|||
},
|
||||
"acl": ["buyer"]
|
||||
},
|
||||
{
|
||||
"url" : "/shelving",
|
||||
"state": "item.card.shelving",
|
||||
"component": "vn-item-shelving",
|
||||
"description": "Shelvings",
|
||||
"params": {
|
||||
"item": "$ctrl.item"
|
||||
},
|
||||
"acl": ["employee"]
|
||||
},
|
||||
{
|
||||
"url" : "/barcode",
|
||||
"state": "item.card.itemBarcode",
|
||||
|
|
|
@ -13,9 +13,6 @@
|
|||
{"state": "shelving.card.log", "icon": "history"}
|
||||
]
|
||||
},
|
||||
"keybindings": [
|
||||
{"key": "s", "state": "shelving.index"}
|
||||
],
|
||||
"routes": [
|
||||
{
|
||||
"url": "/shelving",
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethod('deleteExpeditions', {
|
||||
description: 'Delete the selected expeditions',
|
||||
accessType: 'WRITE',
|
||||
accepts: [{
|
||||
arg: 'expeditionIds',
|
||||
type: ['number'],
|
||||
required: true,
|
||||
description: 'The expeditions ids to delete'
|
||||
}],
|
||||
returns: {
|
||||
type: ['object'],
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/deleteExpeditions`,
|
||||
verb: 'POST'
|
||||
}
|
||||
});
|
||||
|
||||
Self.deleteExpeditions = async(expeditionIds, options) => {
|
||||
const models = Self.app.models;
|
||||
const myOptions = {};
|
||||
let tx;
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
if (!myOptions.transaction) {
|
||||
tx = await Self.beginTransaction({});
|
||||
myOptions.transaction = tx;
|
||||
}
|
||||
|
||||
try {
|
||||
const promises = [];
|
||||
for (let expeditionId of expeditionIds) {
|
||||
const deletedExpedition = models.Expedition.destroyById(expeditionId, myOptions);
|
||||
promises.push(deletedExpedition);
|
||||
}
|
||||
|
||||
const deletedExpeditions = await Promise.all(promises);
|
||||
|
||||
if (tx) await tx.commit();
|
||||
|
||||
return deletedExpeditions;
|
||||
} catch (e) {
|
||||
if (tx) await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
};
|
|
@ -0,0 +1,93 @@
|
|||
const UserError = require('vn-loopback/util/user-error');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('moveExpeditions', {
|
||||
description: 'Move the selected expeditions to another ticket',
|
||||
accessType: 'WRITE',
|
||||
accepts: [{
|
||||
arg: 'clientId',
|
||||
type: 'number',
|
||||
description: `The client id`,
|
||||
required: true
|
||||
},
|
||||
{
|
||||
arg: 'landed',
|
||||
type: 'date',
|
||||
description: `The landing date`
|
||||
},
|
||||
{
|
||||
arg: 'warehouseId',
|
||||
type: 'number',
|
||||
description: `The warehouse id`,
|
||||
required: true
|
||||
},
|
||||
{
|
||||
arg: 'addressId',
|
||||
type: 'number',
|
||||
description: `The address id`,
|
||||
required: true
|
||||
},
|
||||
{
|
||||
arg: 'agencyModeId',
|
||||
type: 'any',
|
||||
description: `The agencyMode id`
|
||||
},
|
||||
{
|
||||
arg: 'routeId',
|
||||
type: 'any',
|
||||
description: `The route id`
|
||||
},
|
||||
{
|
||||
arg: 'expeditionIds',
|
||||
type: ['number'],
|
||||
required: true,
|
||||
description: 'The expeditions ids to move'
|
||||
}],
|
||||
returns: {
|
||||
type: 'object',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/moveExpeditions`,
|
||||
verb: 'POST'
|
||||
}
|
||||
});
|
||||
|
||||
Self.moveExpeditions = async(ctx, options) => {
|
||||
const models = Self.app.models;
|
||||
const args = ctx.args;
|
||||
const myOptions = {};
|
||||
let tx;
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
if (!myOptions.transaction) {
|
||||
tx = await Self.beginTransaction({});
|
||||
myOptions.transaction = tx;
|
||||
}
|
||||
|
||||
try {
|
||||
if (args.routeId) {
|
||||
const route = await models.Route.findById(args.routeId, null, myOptions);
|
||||
if (!route) throw new UserError('This route does not exists');
|
||||
}
|
||||
const ticket = await models.Ticket.new(ctx, myOptions);
|
||||
const promises = [];
|
||||
for (let expeditionsId of args.expeditionIds) {
|
||||
const expeditionToUpdate = await models.Expedition.findById(expeditionsId, null, myOptions);
|
||||
const expeditionUpdated = expeditionToUpdate.updateAttribute('ticketFk', ticket.id, myOptions);
|
||||
promises.push(expeditionUpdated);
|
||||
}
|
||||
|
||||
await Promise.all(promises);
|
||||
|
||||
if (tx) await tx.commit();
|
||||
|
||||
return ticket;
|
||||
} catch (e) {
|
||||
if (tx) await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
};
|
|
@ -0,0 +1,22 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('ticket deleteExpeditions()', () => {
|
||||
it('should delete the selected expeditions', async() => {
|
||||
const tx = await models.Expedition.beginTransaction({});
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const expeditionIds = [12, 13];
|
||||
const result = await models.Expedition.deleteExpeditions(expeditionIds, options);
|
||||
|
||||
expect(result.length).toEqual(2);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('ticket moveExpeditions()', () => {
|
||||
it('should move the selected expeditions to new ticket', async() => {
|
||||
const tx = await models.Expedition.beginTransaction({});
|
||||
const ctx = {
|
||||
req: {accessToken: {userId: 9}},
|
||||
args: {},
|
||||
params: {}
|
||||
};
|
||||
const myCtx = Object.assign({}, ctx);
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
myCtx.args = {
|
||||
clientId: 1101,
|
||||
landed: new Date(),
|
||||
warehouseId: 1,
|
||||
addressId: 121,
|
||||
agencyModeId: 1,
|
||||
routeId: null,
|
||||
expeditionIds: [1, 2]
|
||||
|
||||
};
|
||||
|
||||
const ticket = await models.Expedition.moveExpeditions(myCtx, options);
|
||||
|
||||
const newestTicketIdInFixtures = 27;
|
||||
|
||||
expect(ticket.id).toBeGreaterThan(newestTicketIdInFixtures);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
@ -79,10 +79,18 @@ describe('sale updatePrice()', () => {
|
|||
const price = 5.4;
|
||||
const originalSalesPersonMana = await models.WorkerMana.findById(18, null, options);
|
||||
const manaComponent = await models.Component.findOne({where: {code: 'mana'}}, options);
|
||||
const teamOne = 96;
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
|
||||
const business = await models.Business.findOne({where: {workerFk: userId}}, options);
|
||||
await business.updateAttribute('departmentFk', teamOne, options);
|
||||
|
||||
await models.Sale.updatePrice(ctx, saleId, price, options);
|
||||
const updatedSale = await models.Sale.findById(saleId, null, options);
|
||||
createdSaleComponent = await models.SaleComponent.findOne({where: {saleFk: saleId, componentFk: manaComponent.id}}, options);
|
||||
const createdSaleComponent = await models.SaleComponent.findOne({
|
||||
where: {
|
||||
saleFk: saleId, componentFk: manaComponent.id
|
||||
}}, options);
|
||||
|
||||
expect(updatedSale.price).toBe(price);
|
||||
expect(createdSaleComponent.value).toEqual(-2.04);
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('sale usesMana()', () => {
|
||||
const ctx = {
|
||||
req: {
|
||||
accessToken: {userId: 18}
|
||||
}
|
||||
};
|
||||
|
||||
it('should return that the worker uses mana', async() => {
|
||||
const tx = await models.Sale.beginTransaction({});
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
const teamOne = 96;
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
|
||||
const business = await models.Business.findOne({where: {workerFk: userId}}, options);
|
||||
await business.updateAttribute('departmentFk', teamOne, options);
|
||||
|
||||
const usesMana = await models.Sale.usesMana(ctx, options);
|
||||
|
||||
expect(usesMana).toBe(true);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
|
||||
it('should return that the worker not uses mana', async() => {
|
||||
const tx = await models.Sale.beginTransaction({});
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const usesMana = await models.Sale.usesMana(ctx, options);
|
||||
|
||||
expect(usesMana).toBe(false);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
});
|
|
@ -77,7 +77,8 @@ module.exports = Self => {
|
|||
|
||||
const oldPrice = sale.price;
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
const usesMana = await models.WorkerMana.findOne({where: {workerFk: userId}, fields: 'amount'}, myOptions);
|
||||
|
||||
const usesMana = await models.Sale.usesMana(ctx, myOptions);
|
||||
const componentCode = usesMana ? 'mana' : 'buyerDiscount';
|
||||
const discount = await models.Component.findOne({where: {code: componentCode}}, myOptions);
|
||||
const componentId = discount.id;
|
||||
|
@ -88,7 +89,6 @@ module.exports = Self => {
|
|||
saleFk: id
|
||||
};
|
||||
const saleComponent = await models.SaleComponent.findOne({where}, myOptions);
|
||||
|
||||
if (saleComponent) {
|
||||
await models.SaleComponent.updateAll(where, {
|
||||
value: saleComponent.value + componentValue
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('usesMana', {
|
||||
description: 'Returns if the worker uses mana',
|
||||
accessType: 'READ',
|
||||
accepts: [],
|
||||
returns: {
|
||||
type: 'boolean',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/usesMana`,
|
||||
verb: 'GET'
|
||||
}
|
||||
});
|
||||
|
||||
Self.usesMana = async(ctx, options) => {
|
||||
const models = Self.app.models;
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
const myOptions = {};
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
const salesDepartment = await models.Department.findOne({where: {code: 'VT'}, fields: 'id'}, myOptions);
|
||||
const departments = await models.Department.getLeaves(salesDepartment.id, null, myOptions);
|
||||
const workerDepartment = await models.WorkerDepartment.findById(userId, null, myOptions);
|
||||
const usesMana = departments.find(department => department.id == workerDepartment.departmentFk);
|
||||
|
||||
return usesMana ? true : false;
|
||||
};
|
||||
};
|
|
@ -18,9 +18,12 @@ describe('ticket componentUpdate()', () => {
|
|||
beforeAll(async() => {
|
||||
const deliveryComponenet = await models.Component.findOne({where: {code: 'delivery'}});
|
||||
deliveryComponentId = deliveryComponenet.id;
|
||||
componentOfSaleSeven = `SELECT value FROM vn.saleComponent WHERE saleFk = 7 AND componentFk = ${deliveryComponentId}`;
|
||||
componentOfSaleEight = `SELECT value FROM vn.saleComponent WHERE saleFk = 8 AND componentFk = ${deliveryComponentId}`;
|
||||
|
||||
componentOfSaleSeven = `SELECT value
|
||||
FROM vn.saleComponent
|
||||
WHERE saleFk = 7 AND componentFk = ${deliveryComponentId}`;
|
||||
componentOfSaleEight = `SELECT value
|
||||
FROM vn.saleComponent
|
||||
WHERE saleFk = 8 AND componentFk = ${deliveryComponentId}`;
|
||||
[componentValue] = await models.SaleComponent.rawSql(componentOfSaleSeven);
|
||||
firstvalueBeforeChange = componentValue.value;
|
||||
|
||||
|
|
|
@ -110,6 +110,11 @@ describe('sale updateDiscount()', () => {
|
|||
const componentId = manaDiscount.id;
|
||||
const manaCode = 'mana';
|
||||
|
||||
const teamOne = 96;
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
const business = await models.Business.findOne({where: {workerFk: userId}}, options);
|
||||
await business.updateAttribute('departmentFk', teamOne, options);
|
||||
|
||||
await models.Ticket.updateDiscount(ctx, ticketId, sales, newDiscount, manaCode, options);
|
||||
|
||||
const updatedSale = await models.Sale.findById(originalSaleId, null, options);
|
||||
|
@ -150,6 +155,11 @@ describe('sale updateDiscount()', () => {
|
|||
const componentId = manaDiscount.id;
|
||||
const manaCode = 'manaClaim';
|
||||
|
||||
const teamOne = 96;
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
const business = await models.Business.findOne({where: {workerFk: userId}}, options);
|
||||
await business.updateAttribute('departmentFk', teamOne, options);
|
||||
|
||||
await models.Ticket.updateDiscount(ctx, ticketId, sales, newDiscount, manaCode, options);
|
||||
|
||||
const updatedSale = await models.Sale.findById(originalSaleId, null, options);
|
||||
|
|
|
@ -98,12 +98,7 @@ module.exports = Self => {
|
|||
if (isLocked || (!hasAllowedRoles && alertLevel > 0))
|
||||
throw new UserError(`The sales of this ticket can't be modified`);
|
||||
|
||||
const usesMana = await models.WorkerMana.findOne({
|
||||
where: {
|
||||
workerFk: userId
|
||||
},
|
||||
fields: 'amount'}, myOptions);
|
||||
|
||||
const usesMana = await models.Sale.usesMana(ctx, myOptions);
|
||||
const componentCode = usesMana ? manaCode : 'buyerDiscount';
|
||||
const discountComponent = await models.Component.findOne({
|
||||
where: {code: componentCode}}, myOptions);
|
||||
|
@ -115,14 +110,38 @@ module.exports = Self => {
|
|||
for (let sale of sales) {
|
||||
const oldDiscount = sale.discount;
|
||||
const value = ((-sale.price * newDiscount) / 100);
|
||||
const newComponent = models.SaleComponent.upsert({
|
||||
saleFk: sale.id,
|
||||
value: value,
|
||||
componentFk: componentId}, myOptions);
|
||||
|
||||
const manaComponent = await models.Component.findOne({
|
||||
where: {code: 'mana'}
|
||||
}, myOptions);
|
||||
|
||||
const manaClaimComponent = await models.Component.findOne({
|
||||
where: {code: 'manaClaim'}
|
||||
}, myOptions);
|
||||
|
||||
const [oldComponent] = await models.SaleComponent.find({
|
||||
where: {
|
||||
and: [
|
||||
{saleFk: sale.id},
|
||||
{componentFk: {inq: [manaComponent.id, manaClaimComponent.id]}}
|
||||
]
|
||||
}
|
||||
}, myOptions);
|
||||
|
||||
let deletedComponent;
|
||||
if (oldComponent) {
|
||||
const filter = {
|
||||
saleFk: sale.id,
|
||||
componentFk: oldComponent.componentFk
|
||||
};
|
||||
deletedComponent = await models.SaleComponent.destroyAll(filter, myOptions);
|
||||
}
|
||||
|
||||
const newComponent = await createSaleComponent(sale.id, value, componentId, myOptions);
|
||||
|
||||
const updatedSale = sale.updateAttribute('discount', newDiscount, myOptions);
|
||||
|
||||
promises.push(newComponent, updatedSale);
|
||||
promises.push(newComponent, updatedSale, deletedComponent);
|
||||
|
||||
const change = `${oldDiscount}% ➔ *${newDiscount}%*`;
|
||||
changesMade += `\r\n-${sale.itemFk}: ${sale.concept} (${sale.quantity}) ${change}`;
|
||||
|
@ -165,4 +184,14 @@ module.exports = Self => {
|
|||
throw e;
|
||||
}
|
||||
};
|
||||
|
||||
async function createSaleComponent(saleId, value, componentId, myOptions) {
|
||||
const models = Self.app.models;
|
||||
|
||||
return models.SaleComponent.create({
|
||||
saleFk: saleId,
|
||||
value: value,
|
||||
componentFk: componentId
|
||||
}, myOptions);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
module.exports = function(Self) {
|
||||
require('../methods/expedition/filter')(Self);
|
||||
require('../methods/expedition/deleteExpeditions')(Self);
|
||||
require('../methods/expedition/moveExpeditions')(Self);
|
||||
};
|
||||
|
|
|
@ -8,6 +8,7 @@ module.exports = Self => {
|
|||
require('../methods/sale/recalculatePrice')(Self);
|
||||
require('../methods/sale/refund')(Self);
|
||||
require('../methods/sale/canEdit')(Self);
|
||||
require('../methods/sale/usesMana')(Self);
|
||||
|
||||
Self.validatesPresenceOf('concept', {
|
||||
message: `Concept cannot be blank`
|
||||
|
|
|
@ -8,54 +8,77 @@
|
|||
auto-load="true">
|
||||
</vn-crud-model>
|
||||
<vn-data-viewer model="model">
|
||||
<vn-card class="vn-w-xl">
|
||||
<vn-table model="model">
|
||||
<vn-thead>
|
||||
<vn-tr>
|
||||
<vn-th></vn-th>
|
||||
<vn-th field="itemFk" number>Expedition</vn-th>
|
||||
<vn-th field="itemFk" number>Item</vn-th>
|
||||
<vn-th field="packageItemName">Name</vn-th>
|
||||
<vn-th field="freightItemName">Package type</vn-th>
|
||||
<vn-th field="counter" number>Counter</vn-th>
|
||||
<vn-th field="externalId" number>externalId</vn-th>
|
||||
<vn-th field="created" expand>Created</vn-th>
|
||||
<vn-th field="state" expand>State</vn-th>
|
||||
<vn-th></vn-th>
|
||||
</vn-tr>
|
||||
</vn-thead>
|
||||
<vn-tbody>
|
||||
<vn-tr ng-repeat="expedition in expeditions">
|
||||
<vn-td class="vn-px-md" style="width:30px; color:#FFA410;">
|
||||
<vn-icon-button icon="delete"
|
||||
ng-click="deleteExpedition.show(expedition.id)"
|
||||
vn-tooltip="Delete expedition">
|
||||
</vn-icon-button>
|
||||
</vn-td>
|
||||
<vn-td number expand>{{expedition.id | zeroFill:6}}</vn-td>
|
||||
<vn-td number>
|
||||
<span
|
||||
ng-class="{link: expedition.packagingItemFk}"
|
||||
ng-click="itemDescriptor.show($event, expedition.packagingItemFk)">
|
||||
{{expedition.packagingFk}}
|
||||
</span>
|
||||
</vn-td>
|
||||
<vn-td>{{::expedition.packageItemName}}</vn-td>
|
||||
<vn-td>{{::expedition.freightItemName}}</vn-td>
|
||||
<vn-td number>{{::expedition.counter}}</vn-td>
|
||||
<vn-td expand>{{::expedition.externalId}}</vn-td>
|
||||
<vn-td shrink-datetime>{{::expedition.created | date:'dd/MM/yyyy HH:mm'}}</vn-td>
|
||||
<vn-td>{{::expedition.state}}</vn-td>
|
||||
<vn-td>
|
||||
<vn-icon-button
|
||||
vn-click-stop="$ctrl.showLog(expedition)"
|
||||
vn-tooltip="Status log"
|
||||
icon="history">
|
||||
</vn-icon-button>
|
||||
</vn-td>
|
||||
</vn-tr>
|
||||
</vn-tbody>
|
||||
</vn-table>
|
||||
<vn-card class="vn-pa-lg">
|
||||
<vn-horizontal class="header">
|
||||
<vn-tool-bar class="vn-mb-md">
|
||||
<vn-button icon="keyboard_arrow_down"
|
||||
label="Move"
|
||||
ng-click="moreOptions.show($event)"
|
||||
disabled="!$ctrl.totalChecked">
|
||||
</vn-button>
|
||||
<vn-button
|
||||
disabled="!$ctrl.checked.length"
|
||||
ng-click="removeConfirm.show()"
|
||||
icon="delete"
|
||||
vn-tooltip="Delete expedition">
|
||||
</vn-button>
|
||||
</vn-tool-bar>
|
||||
<vn-one class="taxes" ng-if="$ctrl.sales.length > 0">
|
||||
<p><vn-label translate>Subtotal</vn-label> {{$ctrl.ticket.totalWithoutVat | currency: 'EUR':2}}</p>
|
||||
<p><vn-label translate>VAT</vn-label> {{$ctrl.ticket.totalWithVat - $ctrl.ticket.totalWithoutVat | currency: 'EUR':2}}</p>
|
||||
<p><vn-label><strong>Total</strong></vn-label> <strong>{{$ctrl.ticket.totalWithVat | currency: 'EUR':2}}</strong></p>
|
||||
</vn-one>
|
||||
</vn-horizontal>
|
||||
<vn-table model="model">
|
||||
<vn-thead>
|
||||
<vn-tr>
|
||||
<vn-th shrink>
|
||||
<vn-multi-check
|
||||
model="model">
|
||||
</vn-multi-check>
|
||||
</vn-th>
|
||||
<vn-th field="itemFk" number>Expedition</vn-th>
|
||||
<vn-th field="itemFk" number>Item</vn-th>
|
||||
<vn-th field="packageItemName">Name</vn-th>
|
||||
<vn-th field="freightItemName">Package type</vn-th>
|
||||
<vn-th field="counter" number>Counter</vn-th>
|
||||
<vn-th field="externalId" number>externalId</vn-th>
|
||||
<vn-th field="created" expand>Created</vn-th>
|
||||
<vn-th field="state" expand>State</vn-th>
|
||||
<vn-th></vn-th>
|
||||
</vn-tr>
|
||||
</vn-thead>
|
||||
<vn-tbody>
|
||||
<vn-tr ng-repeat="expedition in expeditions">
|
||||
<vn-td shrink>
|
||||
<vn-check tabindex="-1"
|
||||
ng-model="expedition.checked">
|
||||
</vn-check>
|
||||
</vn-td>
|
||||
<vn-td number expand>{{expedition.id | zeroFill:6}}</vn-td>
|
||||
<vn-td number>
|
||||
<span
|
||||
ng-class="{link: expedition.packagingItemFk}"
|
||||
ng-click="itemDescriptor.show($event, expedition.packagingItemFk)">
|
||||
{{expedition.packagingFk}}
|
||||
</span>
|
||||
</vn-td>
|
||||
<vn-td>{{::expedition.packageItemName}}</vn-td>
|
||||
<vn-td>{{::expedition.freightItemName}}</vn-td>
|
||||
<vn-td number>{{::expedition.counter}}</vn-td>
|
||||
<vn-td expand>{{::expedition.externalId}}</vn-td>
|
||||
<vn-td shrink-datetime>{{::expedition.created | date:'dd/MM/yyyy HH:mm'}}</vn-td>
|
||||
<vn-td>{{::expedition.state}}</vn-td>
|
||||
<vn-td>
|
||||
<vn-icon-button
|
||||
vn-click-stop="$ctrl.showLog(expedition)"
|
||||
vn-tooltip="Status log"
|
||||
icon="history">
|
||||
</vn-icon-button>
|
||||
</vn-td>
|
||||
</vn-tr>
|
||||
</vn-tbody>
|
||||
</vn-table>
|
||||
</vn-card>
|
||||
</vn-data-viewer>
|
||||
<vn-item-descriptor-popover
|
||||
|
@ -66,25 +89,25 @@
|
|||
<vn-worker-descriptor-popover
|
||||
vn-id="worker-descriptor">
|
||||
</vn-worker-descriptor-popover>
|
||||
<vn-confirm
|
||||
vn-id="delete-expedition"
|
||||
on-accept="$ctrl.onDialogAccept($data)"
|
||||
<vn-confirm
|
||||
vn-id="removeConfirm"
|
||||
message="Are you sure you want to delete this expedition?"
|
||||
question="Delete expedition"
|
||||
message="Are you sure you want to delete this expedition?">
|
||||
on-accept="$ctrl.onRemove()">
|
||||
</vn-confirm>
|
||||
|
||||
<vn-popup vn-id="statusLog">
|
||||
<vn-crud-model
|
||||
vn-id="model"
|
||||
vn-id="modelExpeditionStates"
|
||||
url="ExpeditionStates/filter"
|
||||
link="{expeditionFk: $ctrl.expedition.id}"
|
||||
data="expeditionStates"
|
||||
order="created DESC"
|
||||
auto-load="true">
|
||||
</vn-crud-model>
|
||||
<vn-data-viewer model="model">
|
||||
<vn-data-viewer model="modelExpeditionStates">
|
||||
<vn-card class="vn-w-md">
|
||||
<vn-table model="model">
|
||||
<vn-table model="modelExpeditionStates">
|
||||
<vn-thead>
|
||||
<vn-tr>
|
||||
<vn-th field="state">State</vn-th>
|
||||
|
@ -111,4 +134,37 @@
|
|||
<vn-worker-descriptor-popover
|
||||
vn-id="workerDescriptor">
|
||||
</vn-worker-descriptor-popover>
|
||||
</vn-popup>
|
||||
</vn-popup>
|
||||
|
||||
<vn-menu vn-id="moreOptions">
|
||||
<vn-item translate
|
||||
name="withoutRoute"
|
||||
ng-click="selectLanded.show('withoutRoute')">
|
||||
New ticket without route
|
||||
</vn-item>
|
||||
<vn-item translate
|
||||
name="withRoute"
|
||||
ng-click="selectLanded.show('withRoute')">
|
||||
New ticket with route
|
||||
</vn-item>
|
||||
</vn-menu>
|
||||
|
||||
<vn-dialog
|
||||
vn-id="selectLanded"
|
||||
on-accept="$ctrl.createTicket($ctrl.landed, $ctrl.newRoute)">
|
||||
<tpl-body>
|
||||
<vn-date-picker
|
||||
label="Landed"
|
||||
ng-model="$ctrl.landed">
|
||||
</vn-date-picker>
|
||||
<vn-textfield
|
||||
ng-show="selectLanded.data == 'withRoute'"
|
||||
label="Route id"
|
||||
ng-model="$ctrl.newRoute">
|
||||
</vn-textfield>
|
||||
</tpl-body>
|
||||
<tpl-buttons>
|
||||
<input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/>
|
||||
<button response="accept" translate>Accept</button>
|
||||
</tpl-buttons>
|
||||
</vn-dialog>
|
|
@ -2,6 +2,27 @@ import ngModule from '../module';
|
|||
import Section from 'salix/components/section';
|
||||
|
||||
class Controller extends Section {
|
||||
constructor($element, $scope) {
|
||||
super($element, $scope);
|
||||
this.landed = new Date();
|
||||
this.newRoute = null;
|
||||
}
|
||||
|
||||
get checked() {
|
||||
const rows = this.$.model.data || [];
|
||||
const checkedRows = [];
|
||||
for (let row of rows) {
|
||||
if (row.checked)
|
||||
checkedRows.push(row.id);
|
||||
}
|
||||
|
||||
return checkedRows;
|
||||
}
|
||||
|
||||
get totalChecked() {
|
||||
return this.checked.length;
|
||||
}
|
||||
|
||||
onDialogAccept(id) {
|
||||
return this.$http.delete(`Expeditions/${id}`)
|
||||
.then(() => this.$.model.refresh());
|
||||
|
@ -11,6 +32,33 @@ class Controller extends Section {
|
|||
this.expedition = expedition;
|
||||
this.$.statusLog.show();
|
||||
}
|
||||
|
||||
onRemove() {
|
||||
const params = {expeditionIds: this.checked};
|
||||
const query = `Expeditions/deleteExpeditions`;
|
||||
this.$http.post(query, params)
|
||||
.then(() => {
|
||||
this.vnApp.showSuccess(this.$t('Expedition removed'));
|
||||
this.$.model.refresh();
|
||||
});
|
||||
}
|
||||
|
||||
createTicket(landed, routeFk) {
|
||||
const params = {
|
||||
clientId: this.ticket.clientFk,
|
||||
landed: landed,
|
||||
warehouseId: this.ticket.warehouseFk,
|
||||
addressId: this.ticket.addressFk,
|
||||
agencyModeId: this.ticket.agencyModeFk,
|
||||
routeId: routeFk,
|
||||
expeditionIds: this.checked
|
||||
};
|
||||
const query = `Expeditions/moveExpeditions`;
|
||||
this.$http.post(query, params).then(res => {
|
||||
this.vnApp.showSuccess(this.$t('Data saved!'));
|
||||
this.$state.go('ticket.card.summary', {id: res.data.id});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
ngModule.vnComponent('vnTicketExpedition', {
|
||||
|
|
|
@ -17,6 +17,14 @@ describe('Ticket', () => {
|
|||
refresh: () => {}
|
||||
};
|
||||
controller = $componentController('vnTicketExpedition', {$element: null, $scope});
|
||||
controller.$.model.data = [
|
||||
{id: 1},
|
||||
{id: 2},
|
||||
{id: 3}
|
||||
];
|
||||
const modelData = controller.$.model.data;
|
||||
modelData[0].checked = true;
|
||||
modelData[1].checked = true;
|
||||
}));
|
||||
|
||||
describe('onDialogAccept()', () => {
|
||||
|
@ -50,5 +58,51 @@ describe('Ticket', () => {
|
|||
expect(controller.$.statusLog.show).toHaveBeenCalledWith();
|
||||
});
|
||||
});
|
||||
|
||||
describe('onRemove()', () => {
|
||||
it('should make a query and then call to the model refresh() method', () => {
|
||||
jest.spyOn($scope.model, 'refresh');
|
||||
|
||||
const expectedParams = {expeditionIds: [1, 2]};
|
||||
$httpBackend.expect('POST', 'Expeditions/deleteExpeditions', expectedParams).respond(200);
|
||||
controller.onRemove();
|
||||
$httpBackend.flush();
|
||||
|
||||
expect($scope.model.refresh).toHaveBeenCalledWith();
|
||||
});
|
||||
});
|
||||
|
||||
describe('createTicket()', () => {
|
||||
it('should make a query and then call to the $state go() method', () => {
|
||||
jest.spyOn(controller.$state, 'go').mockReturnThis();
|
||||
|
||||
const ticket = {
|
||||
clientFk: 1101,
|
||||
landed: new Date(),
|
||||
addressFk: 121,
|
||||
agencyModeFk: 1,
|
||||
warehouseFk: 1
|
||||
};
|
||||
const routeId = null;
|
||||
controller.ticket = ticket;
|
||||
|
||||
const ticketToTransfer = {id: 28};
|
||||
|
||||
const expectedParams = {
|
||||
clientId: 1101,
|
||||
landed: new Date(),
|
||||
warehouseId: 1,
|
||||
addressId: 121,
|
||||
agencyModeId: 1,
|
||||
routeId: null,
|
||||
expeditionIds: [1, 2]
|
||||
};
|
||||
$httpBackend.expect('POST', 'Expeditions/moveExpeditions', expectedParams).respond(ticketToTransfer);
|
||||
controller.createTicket(ticket.landed, routeId);
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(controller.$state.go).toHaveBeenCalledWith('ticket.card.summary', {id: ticketToTransfer.id});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1 +1,6 @@
|
|||
Status log: Hitorial de estados
|
||||
Status log: Hitorial de estados
|
||||
Expedition removed: Expedición eliminada
|
||||
Move: Mover
|
||||
New ticket without route: Nuevo ticket sin ruta
|
||||
New ticket with route: Nuevo ticket con ruta
|
||||
Route id: Id ruta
|
|
@ -244,7 +244,7 @@
|
|||
</vn-spinner>
|
||||
<div ng-if="$ctrl.edit.mana != null">
|
||||
<section class="header vn-pa-md">
|
||||
<h5>MANÁ: {{::$ctrl.edit.mana | currency: 'EUR': 0}}</h5>
|
||||
<h5>Mana: {{::$ctrl.edit.mana | currency: 'EUR': 0}}</h5>
|
||||
</section>
|
||||
<div class="vn-pa-md">
|
||||
<vn-input-number
|
||||
|
@ -264,50 +264,6 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</vn-popover>
|
||||
|
||||
<!-- Discount popover -->
|
||||
<vn-popover
|
||||
vn-id="editDiscount"
|
||||
on-open="$ctrl.getMana()">
|
||||
<div class="edit-popover">
|
||||
<vn-spinner class="vn-pa-xs"
|
||||
ng-if="$ctrl.edit.mana == null"
|
||||
enable="true">
|
||||
</vn-spinner>
|
||||
<div ng-if="$ctrl.edit.mana != null">
|
||||
<section class="header vn-pa-md">
|
||||
<h5>Mana: {{::$ctrl.edit.mana | currency: 'EUR':0}}</h5>
|
||||
</section>
|
||||
<div class="vn-pa-md">
|
||||
<vn-input-number
|
||||
vn-focus
|
||||
label="Discount"
|
||||
ng-model="$ctrl.edit.discount"
|
||||
clear-disabled="true"
|
||||
suffix="%">
|
||||
</vn-input-number>
|
||||
<vn-vertical ng-if="$ctrl.currentWorkerMana != 0">
|
||||
<vn-radio
|
||||
label="Promotion mana"
|
||||
val="mana"
|
||||
ng-model="$ctrl.manaCode">
|
||||
</vn-radio>
|
||||
<vn-radio
|
||||
label="Claim mana"
|
||||
val="manaClaim"
|
||||
ng-model="$ctrl.manaCode">
|
||||
</vn-radio>
|
||||
</vn-vertical>
|
||||
<div class="simulator">
|
||||
<p class="simulatorTitle" translate>New price</p>
|
||||
<p>
|
||||
<strong>{{$ctrl.getNewPrice() | currency: 'EUR': 2}}</strong>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<vn-horizontal >
|
||||
<vn-button
|
||||
label="Cancel"
|
||||
|
@ -321,31 +277,59 @@
|
|||
</div>
|
||||
</vn-popover>
|
||||
|
||||
<!-- Multiple discount dialog -->
|
||||
<vn-dialog vn-id="editDiscountDialog"
|
||||
on-open="$ctrl.getMana()"
|
||||
message="Edit discount">
|
||||
<tpl-body>
|
||||
<!-- Discount popover -->
|
||||
<vn-popover
|
||||
vn-id="editDiscount"
|
||||
on-open="$ctrl.getMana()">
|
||||
<div class="edit-popover">
|
||||
<vn-spinner class="vn-pa-xs"
|
||||
ng-if="$ctrl.edit.mana == null"
|
||||
enable="true">
|
||||
</vn-spinner>
|
||||
<div ng-if="$ctrl.edit.mana != null">
|
||||
<section class="header vn-pa-md">
|
||||
<h5>Mana: {{::$ctrl.edit.mana | currency: 'EUR': 0}}</h5>
|
||||
</section>
|
||||
<div class="vn-pa-md">
|
||||
<vn-input-number vn-focus
|
||||
<vn-input-number
|
||||
vn-focus
|
||||
label="Discount"
|
||||
ng-model="$ctrl.edit.discount"
|
||||
on-change="$ctrl.changeMultipleDiscount()"
|
||||
clear-disabled="true"
|
||||
suffix="%">
|
||||
</vn-input-number>
|
||||
<vn-vertical ng-if="$ctrl.usesMana && $ctrl.currentWorkerMana != 0">
|
||||
<vn-radio
|
||||
label="Promotion mana"
|
||||
val="mana"
|
||||
ng-model="$ctrl.manaCode">
|
||||
</vn-radio>
|
||||
<vn-radio
|
||||
label="Claim mana"
|
||||
val="manaClaim"
|
||||
ng-model="$ctrl.manaCode">
|
||||
</vn-radio>
|
||||
</vn-vertical>
|
||||
<div class="simulator" ng-show="$ctrl.edit.sale">
|
||||
<p class="simulatorTitle" translate>New price</p>
|
||||
<p>
|
||||
<strong>{{$ctrl.getNewPrice() | currency: 'EUR': 2}}</strong>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<section class="header vn-pa-md">
|
||||
<span>Mana: <strong>{{::$ctrl.edit.mana | currency: 'EUR': 0}}</strong></span>
|
||||
</section>
|
||||
</div>
|
||||
</tpl-body>
|
||||
</vn-dialog>
|
||||
<vn-horizontal >
|
||||
<vn-button
|
||||
label="Cancel"
|
||||
ng-click="$ctrl.cancel()">
|
||||
</vn-button>
|
||||
<vn-button
|
||||
label="Save"
|
||||
ng-click="$ctrl.save()">
|
||||
</vn-button>
|
||||
</vn-horizontal>
|
||||
</div>
|
||||
</vn-popover>
|
||||
|
||||
<!-- Transfer Popover -->
|
||||
<vn-popover vn-id="transfer">
|
||||
|
@ -490,7 +474,7 @@
|
|||
</vn-item>
|
||||
<vn-item translate
|
||||
name="discount"
|
||||
ng-click="$ctrl.showEditDiscountDialog($event)">
|
||||
ng-click="$ctrl.showEditDiscountPopover($event, sale)">
|
||||
Update discount
|
||||
</vn-item>
|
||||
<vn-item translate
|
||||
|
|
|
@ -75,6 +75,7 @@ class Controller extends Section {
|
|||
this.$.editPricePopover.relocate();
|
||||
});
|
||||
});
|
||||
this.getUsesMana();
|
||||
this.getCurrentWorkerMana();
|
||||
}
|
||||
|
||||
|
@ -85,6 +86,13 @@ class Controller extends Section {
|
|||
});
|
||||
}
|
||||
|
||||
getUsesMana() {
|
||||
this.$http.get(`Sales/usesMana`)
|
||||
.then(res => {
|
||||
this.useMana = res.data;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns checked instances
|
||||
*
|
||||
|
@ -243,26 +251,21 @@ class Controller extends Section {
|
|||
|
||||
showEditDiscountPopover(event, sale) {
|
||||
if (this.isLocked) return;
|
||||
|
||||
this.edit = {
|
||||
discount: sale.discount,
|
||||
sale: sale
|
||||
};
|
||||
if (sale) {
|
||||
this.edit = {
|
||||
discount: sale.discount,
|
||||
sale: sale
|
||||
};
|
||||
} else {
|
||||
this.edit = {
|
||||
discount: null,
|
||||
sales: this.selectedValidSales()
|
||||
};
|
||||
}
|
||||
|
||||
this.$.editDiscount.show(event);
|
||||
}
|
||||
|
||||
showEditDiscountDialog(event) {
|
||||
if (this.isLocked) return;
|
||||
|
||||
this.edit = {
|
||||
discount: null,
|
||||
sales: this.selectedValidSales()
|
||||
};
|
||||
|
||||
this.$.editDiscountDialog.show(event);
|
||||
}
|
||||
|
||||
changeDiscount() {
|
||||
const sale = this.edit.sale;
|
||||
const newDiscount = this.edit.discount;
|
||||
|
@ -278,11 +281,10 @@ class Controller extends Section {
|
|||
const hasChanges = sales.some(sale => {
|
||||
return sale.discount != newDiscount;
|
||||
});
|
||||
|
||||
if (newDiscount != null && hasChanges)
|
||||
this.updateDiscount(sales);
|
||||
|
||||
this.$.editDiscountDialog.hide();
|
||||
this.$.editDiscount.hide();
|
||||
}
|
||||
|
||||
updateDiscount(sales) {
|
||||
|
@ -303,7 +305,7 @@ class Controller extends Section {
|
|||
}
|
||||
|
||||
getNewPrice() {
|
||||
if (this.edit) {
|
||||
if (this.edit.sale) {
|
||||
const sale = this.edit.sale;
|
||||
let newDiscount = sale.discount;
|
||||
let newPrice = this.edit.price || sale.price;
|
||||
|
@ -505,7 +507,8 @@ class Controller extends Section {
|
|||
}
|
||||
|
||||
save() {
|
||||
this.changeDiscount();
|
||||
if (this.edit.sale) this.changeDiscount();
|
||||
if (this.edit.sales) this.changeMultipleDiscount();
|
||||
}
|
||||
|
||||
cancel() {
|
||||
|
|
|
@ -115,6 +115,7 @@ describe('Ticket', () => {
|
|||
const expectedAmount = 250;
|
||||
|
||||
$httpBackend.expect('GET', 'Tickets/1/getSalesPersonMana').respond(200, expectedAmount);
|
||||
$httpBackend.expect('GET', 'Sales/usesMana').respond(200);
|
||||
$httpBackend.expect('GET', 'WorkerManas/getCurrentWorkerMana').respond(200, expectedAmount);
|
||||
controller.getMana();
|
||||
$httpBackend.flush();
|
||||
|
@ -393,7 +394,7 @@ describe('Ticket', () => {
|
|||
secondSelectedSale.checked = true;
|
||||
|
||||
const expectedSales = [firstSelectedSale, secondSelectedSale];
|
||||
controller.$.editDiscountDialog = {hide: jest.fn()};
|
||||
controller.$.editDiscount = {hide: jest.fn()};
|
||||
controller.edit = {
|
||||
discount: 10,
|
||||
sales: expectedSales
|
||||
|
@ -402,7 +403,7 @@ describe('Ticket', () => {
|
|||
controller.changeMultipleDiscount();
|
||||
|
||||
expect(controller.updateDiscount).toHaveBeenCalledWith(expectedSales);
|
||||
expect(controller.$.editDiscountDialog.hide).toHaveBeenCalledWith();
|
||||
expect(controller.$.editDiscount.hide).toHaveBeenCalledWith();
|
||||
});
|
||||
|
||||
it('should not call to the updateDiscount() method and then to the editDiscountDialog hide() method', () => {
|
||||
|
@ -417,7 +418,7 @@ describe('Ticket', () => {
|
|||
secondSelectedSale.discount = 10;
|
||||
|
||||
const expectedSales = [firstSelectedSale, secondSelectedSale];
|
||||
controller.$.editDiscountDialog = {hide: jest.fn()};
|
||||
controller.$.editDiscount = {hide: jest.fn()};
|
||||
controller.edit = {
|
||||
discount: 10,
|
||||
sales: expectedSales
|
||||
|
@ -426,7 +427,7 @@ describe('Ticket', () => {
|
|||
controller.changeMultipleDiscount();
|
||||
|
||||
expect(controller.updateDiscount).not.toHaveBeenCalledWith(expectedSales);
|
||||
expect(controller.$.editDiscountDialog.hide).toHaveBeenCalledWith();
|
||||
expect(controller.$.editDiscount.hide).toHaveBeenCalledWith();
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -64,6 +64,9 @@
|
|||
},
|
||||
"WorkerTimeControlMail": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"WorkerDisableExcluded": {
|
||||
"dataSource": "vn"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
{
|
||||
"name": "WorkerDisableExcluded",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "workerDisableExcluded"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"workerFk": {
|
||||
"id": true,
|
||||
"type": "number"
|
||||
},
|
||||
"dated": {
|
||||
"type": "date"
|
||||
}
|
||||
},
|
||||
"acls": [
|
||||
{
|
||||
"accessType": "READ",
|
||||
"principalType": "ROLE",
|
||||
"principalId": "$everyone",
|
||||
"permission": "ALLOW"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -14,6 +14,20 @@
|
|||
</vn-float-button>
|
||||
</div>
|
||||
</slot-before>
|
||||
<slot-menu>
|
||||
<vn-item
|
||||
ng-click="$ctrl.handleExcluded()"
|
||||
translate
|
||||
ng-if="!$ctrl.excluded">
|
||||
Click to exclude the user from getting disabled
|
||||
</vn-item>
|
||||
<vn-item
|
||||
ng-click="$ctrl.handleExcluded()"
|
||||
translate
|
||||
ng-if="$ctrl.excluded">
|
||||
Click to allow the user to be disabled
|
||||
</vn-item>
|
||||
</slot-menu>
|
||||
<slot-body>
|
||||
<div class="attributes">
|
||||
<vn-label-value
|
||||
|
@ -37,6 +51,13 @@
|
|||
value="{{$ctrl.worker.sip.extension}}">
|
||||
</vn-label-value>
|
||||
</div>
|
||||
<div class="icons">
|
||||
<vn-icon
|
||||
vn-tooltip="This user can't be disabled"
|
||||
icon="person"
|
||||
ng-if="$ctrl.worker.excluded">
|
||||
</vn-icon>
|
||||
</div>
|
||||
<div class="quicklinks">
|
||||
<div ng-transclude="btnOne">
|
||||
<vn-quick-link
|
||||
|
|
|
@ -13,6 +13,33 @@ class Controller extends Descriptor {
|
|||
|
||||
set worker(value) {
|
||||
this.entity = value;
|
||||
|
||||
if (value)
|
||||
this.getIsExcluded();
|
||||
}
|
||||
|
||||
get excluded() {
|
||||
return this.entity.excluded;
|
||||
}
|
||||
|
||||
set excluded(value) {
|
||||
this.entity.excluded = value;
|
||||
}
|
||||
|
||||
getIsExcluded() {
|
||||
this.$http.get(`workerDisableExcludeds/${this.entity.id}/exists`).then(data => {
|
||||
this.excluded = data.data.exists;
|
||||
});
|
||||
}
|
||||
|
||||
handleExcluded() {
|
||||
if (this.excluded) {
|
||||
this.$http.delete(`workerDisableExcludeds/${this.entity.id}`);
|
||||
this.excluded = false;
|
||||
} else {
|
||||
this.$http.post(`workerDisableExcludeds`, {workerFk: this.entity.id, dated: new Date});
|
||||
this.excluded = true;
|
||||
}
|
||||
}
|
||||
|
||||
loadData() {
|
||||
|
|
|
@ -20,4 +20,7 @@ View worker: Ver trabajador
|
|||
Worker id: Id trabajador
|
||||
Workers: Trabajadores
|
||||
worker: trabajador
|
||||
Go to the worker: Ir al trabajador
|
||||
Go to the worker: Ir al trabajador
|
||||
Click to exclude the user from getting disabled: Marcar para no deshabilitar
|
||||
Click to allow the user to be disabled: Marcar para deshabilitar
|
||||
This user can't be disabled: Fijado para no deshabilitar
|
|
@ -16,6 +16,7 @@
|
|||
"bcrypt": "^5.0.1",
|
||||
"bmp-js": "^0.1.0",
|
||||
"compression": "^1.7.3",
|
||||
"form-data": "^4.0.0",
|
||||
"fs-extra": "^5.0.0",
|
||||
"ftps": "^1.2.0",
|
||||
"got": "^10.7.0",
|
||||
|
|
|
@ -21,7 +21,7 @@ module.exports = {
|
|||
},
|
||||
props: {
|
||||
id: {
|
||||
type: [Number, String],
|
||||
type: Number,
|
||||
required: true
|
||||
},
|
||||
from: {
|
||||
|
|
|
@ -23,9 +23,10 @@
|
|||
<!-- Block -->
|
||||
<div class="grid-row">
|
||||
<div class="grid-block vn-pa-ml">
|
||||
<h1>{{ $t('title') }}</h1>
|
||||
<p>{{$t('description.dear')}},</p>
|
||||
<p>{{$t('description.instructions')}}</p>
|
||||
<h1>{{ $t('title', [id]) }}</h1>
|
||||
<p>{{ $t('description.dear') }},</p>
|
||||
<p v-html="instructions"></p>
|
||||
<p>{{ $t('description.conclusion') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Footer block -->
|
||||
|
@ -43,4 +44,4 @@
|
|||
</tbody>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
|
|
@ -8,9 +8,22 @@ module.exports = {
|
|||
'email-header': emailHeader.build(),
|
||||
'email-footer': emailFooter.build()
|
||||
},
|
||||
async serverPrefetch() {
|
||||
this.ticket = await this.fetchTicket(this.id);
|
||||
|
||||
if (!this.ticket)
|
||||
throw new Error('Something went wrong');
|
||||
|
||||
this.instructions = this.$t('description.instructions', [this.id, this.ticket.id]);
|
||||
},
|
||||
methods: {
|
||||
fetchTicket(id) {
|
||||
return this.findOneFromDef('ticket', [id]);
|
||||
}
|
||||
},
|
||||
props: {
|
||||
id: {
|
||||
type: [Number, String],
|
||||
type: Number,
|
||||
required: true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
subject: Orden de recogida
|
||||
title: Orden de recogida
|
||||
subject: Reclamación Verdnatura
|
||||
title: Reclamación Verdnatura {0}
|
||||
description:
|
||||
dear: Estimado cliente
|
||||
instructions: Aqui tienes tu orden de recogida.
|
||||
dear: Estimado cliente
|
||||
instructions: 'Le informamos que se ha aceptado su solicitud de reclamación <strong>nº {0}</strong> correspondiente al pedido <strong>{1}</strong>.
|
||||
Para tramitar la recogida, rellene el <a href="https://form.jotform.com/verdnatura/recogida-verdnatura"
|
||||
title="Formulario Recogida" target="_blank" style="color: #8dba25">SIGUIENTE FORMULARIO</a> en un <strong>plazo máximo de 24h.</strong>
|
||||
<br/><br/>Cuando recibamos el género en nuestras instalaciones emitiremos el abono correspondiente.
|
||||
Debe imprimir el archivo adjunto e incluirlo en la caja. En el caso de no poder imprimirlo, <strong>identifique la caja con el número de reclamación CLARAMENTE LEGIBLE.</strong>'
|
||||
conclusion: Un saludo
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
SELECT
|
||||
c.ticketFk as id
|
||||
FROM claim c
|
||||
WHERE c.id = ?
|
|
@ -23,7 +23,7 @@ module.exports = {
|
|||
},
|
||||
props: {
|
||||
id: {
|
||||
type: [Number, String],
|
||||
type: Number,
|
||||
required: true
|
||||
},
|
||||
from: {
|
||||
|
|
|
@ -18,7 +18,7 @@ module.exports = {
|
|||
},
|
||||
props: {
|
||||
id: {
|
||||
type: [Number, String],
|
||||
type: Number,
|
||||
required: true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ module.exports = {
|
|||
},
|
||||
props: {
|
||||
id: {
|
||||
type: [Number, String],
|
||||
type: Number,
|
||||
required: true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ module.exports = {
|
|||
},
|
||||
props: {
|
||||
id: {
|
||||
type: [Number, String],
|
||||
type: Number,
|
||||
required: true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ module.exports = {
|
|||
},
|
||||
props: {
|
||||
id: {
|
||||
type: [Number, String],
|
||||
type: Number,
|
||||
required: true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,12 +23,12 @@ module.exports = {
|
|||
},
|
||||
props: {
|
||||
id: {
|
||||
type: [Number, String],
|
||||
type: Number,
|
||||
required: true,
|
||||
description: 'The client id'
|
||||
},
|
||||
companyId: {
|
||||
type: [Number, String],
|
||||
type: Number,
|
||||
required: true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ module.exports = {
|
|||
},
|
||||
props: {
|
||||
reference: {
|
||||
type: [Number, String],
|
||||
type: Number,
|
||||
required: true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,11 +34,11 @@ module.exports = {
|
|||
},
|
||||
props: {
|
||||
id: {
|
||||
type: [Number, String],
|
||||
type: Number,
|
||||
required: true
|
||||
},
|
||||
companyId: {
|
||||
type: [Number, String],
|
||||
type: Number,
|
||||
required: true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,11 +34,11 @@ module.exports = {
|
|||
},
|
||||
props: {
|
||||
id: {
|
||||
type: [Number, String],
|
||||
type: Number,
|
||||
required: true
|
||||
},
|
||||
companyId: {
|
||||
type: [Number, String],
|
||||
type: Number,
|
||||
required: true
|
||||
},
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ module.exports = {
|
|||
},
|
||||
props: {
|
||||
id: {
|
||||
type: [Number, String],
|
||||
type: Number,
|
||||
required: true,
|
||||
description: 'The client id'
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ module.exports = {
|
|||
},
|
||||
props: {
|
||||
id: {
|
||||
type: [Number, String],
|
||||
type: Number,
|
||||
required: true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,11 +16,11 @@ module.exports = {
|
|||
},
|
||||
props: {
|
||||
id: {
|
||||
type: [Number, String],
|
||||
type: Number,
|
||||
required: true
|
||||
},
|
||||
companyId: {
|
||||
type: [Number, String],
|
||||
type: Number,
|
||||
required: true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ module.exports = {
|
|||
},
|
||||
props: {
|
||||
id: {
|
||||
type: [Number, String],
|
||||
type: Number,
|
||||
required: true
|
||||
},
|
||||
from: {
|
||||
|
|
|
@ -25,7 +25,7 @@ module.exports = {
|
|||
},
|
||||
props: {
|
||||
id: {
|
||||
type: [Number, String],
|
||||
type: Number,
|
||||
required: true,
|
||||
description: 'The client id'
|
||||
},
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<table class="column-oriented vn-mt-ml">
|
||||
<thead>
|
||||
<tr>
|
||||
|
@ -71,16 +71,13 @@
|
|||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
<div class="panel sign">
|
||||
<div class="header">{{$t('clientSignature')}}</div>
|
||||
<div class="body centered">
|
||||
<h3>{{client.name}}</h3>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p v-html="$t('sections.agency.description')"></p>
|
||||
<p>{{claimConfig.pickupContact}}</p>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Footer block -->
|
||||
|
@ -94,4 +91,4 @@
|
|||
</tbody>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
|
|
@ -7,7 +7,6 @@ module.exports = {
|
|||
async serverPrefetch() {
|
||||
this.client = await this.fetchClient(this.id);
|
||||
this.sales = await this.fetchSales(this.id);
|
||||
this.claimConfig = await this.fetchClaimConfig();
|
||||
|
||||
if (!this.client)
|
||||
throw new Error('Something went wrong');
|
||||
|
@ -25,10 +24,7 @@ module.exports = {
|
|||
},
|
||||
fetchSales(id) {
|
||||
return this.rawSqlFromDef('sales', [id]);
|
||||
},
|
||||
fetchClaimConfig() {
|
||||
return this.findOneFromDef('claimConfig');
|
||||
},
|
||||
}
|
||||
},
|
||||
components: {
|
||||
'report-header': reportHeader.build(),
|
||||
|
@ -36,7 +32,7 @@ module.exports = {
|
|||
},
|
||||
props: {
|
||||
id: {
|
||||
type: [Number, String],
|
||||
type: Number,
|
||||
required: true,
|
||||
description: 'The claim id'
|
||||
}
|
||||
|
|
|
@ -11,7 +11,3 @@ concept: Concepto
|
|||
clientSignature: Firma del cliente
|
||||
claim: Reclamación {0}
|
||||
phone: Teléfono
|
||||
sections:
|
||||
agency:
|
||||
description: 'Para agilizar su recogida, por favor, póngase en contacto con la oficina
|
||||
de Logista Parcel.'
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
SELECT pickupContact
|
||||
FROM claimConfig;
|
|
@ -69,7 +69,7 @@ module.exports = {
|
|||
},
|
||||
props: {
|
||||
id: {
|
||||
type: [Number, String],
|
||||
type: Number,
|
||||
required: true,
|
||||
description: 'The client id'
|
||||
},
|
||||
|
|
|
@ -127,7 +127,7 @@ module.exports = {
|
|||
},
|
||||
props: {
|
||||
id: {
|
||||
type: [Number, String],
|
||||
type: Number,
|
||||
required: true,
|
||||
description: 'The ticket id'
|
||||
},
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue