Merge branch 'dev' into 5673-claim-development
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
commit
d05106cc83
|
@ -17,6 +17,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
### Added
|
||||
- (Ticket -> Servicios) Se pueden abonar servicios
|
||||
- (Facturas -> Datos básicos) Muestra valores por defecto
|
||||
- (Facturas -> Borrado) Notificación al borrar un asiento ya enlazado en Sage
|
||||
### Changed
|
||||
- (Trabajadores -> Calendario) Icono de check arreglado cuando pulsas un tipo de dia
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@
|
|||
"worker": {
|
||||
"type": "hasOne",
|
||||
"model": "Worker",
|
||||
"foreignKey": "userFk"
|
||||
"foreignKey": "id"
|
||||
},
|
||||
"userConfig": {
|
||||
"type": "hasOne",
|
||||
|
|
|
@ -34,7 +34,7 @@ BEGIN
|
|||
isAllowedToWork
|
||||
FROM(SELECT t.dated,
|
||||
b.id businessFk,
|
||||
w.userFk,
|
||||
w.id,
|
||||
b.departmentFk,
|
||||
IF(j.start = NULL, NULL, GROUP_CONCAT(DISTINCT LEFT(j.start,5) ORDER BY j.start ASC SEPARATOR ' - ')) hourStart ,
|
||||
IF(j.start = NULL, NULL, GROUP_CONCAT(DISTINCT LEFT(j.end,5) ORDER BY j.end ASC SEPARATOR ' - ')) hourEnd,
|
||||
|
@ -48,14 +48,14 @@ BEGIN
|
|||
FROM time t
|
||||
LEFT JOIN business b ON t.dated BETWEEN b.started AND IFNULL(b.ended, vDatedTo)
|
||||
LEFT JOIN worker w ON w.id = b.workerFk
|
||||
JOIN tmp.`user` u ON u.userFK = w.userFK
|
||||
JOIN tmp.`user` u ON u.userFK = w.id
|
||||
LEFT JOIN workCenter wc ON wc.id = b.workcenterFK
|
||||
LEFT JOIN postgresql.calendar_labour_type cl ON cl.calendar_labour_type_id = b.calendarTypeFk
|
||||
LEFT JOIN postgresql.journey j ON j.business_id = b.id AND j.day_id = WEEKDAY(t.dated) + 1
|
||||
LEFT JOIN postgresql.calendar_employee ce ON ce.businessFk = b.id AND ce.date = t.dated
|
||||
LEFT JOIN absenceType at2 ON at2.id = ce.calendar_state_id
|
||||
WHERE t.dated BETWEEN vDatedFrom AND vDatedTo
|
||||
GROUP BY w.userFk, t.dated
|
||||
GROUP BY w.id, t.dated
|
||||
)sub;
|
||||
|
||||
UPDATE tmp.timeBusinessCalculate t
|
||||
|
|
|
@ -46,7 +46,7 @@ BEGIN
|
|||
CONCAT('Cliente ', NEW.id),
|
||||
CONCAT('Recibida la documentación: ', vText)
|
||||
FROM worker w
|
||||
LEFT JOIN account.user u ON w.userFk = u.id AND u.active
|
||||
LEFT JOIN account.user u ON w.id = u.id AND u.active
|
||||
LEFT JOIN account.account ac ON ac.id = u.id
|
||||
WHERE w.id = NEW.salesPersonFk;
|
||||
END IF;
|
||||
|
|
|
@ -3,11 +3,11 @@ INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `pri
|
|||
('Ticket', 'editDiscount', 'WRITE', 'ALLOW', 'ROLE', 'claimManager'),
|
||||
('Ticket', 'editDiscount', 'WRITE', 'ALLOW', 'ROLE', 'salesPerson'),
|
||||
('Ticket', 'isRoleAdvanced', '*', 'ALLOW', 'ROLE', 'salesAssistant'),
|
||||
('Ticket', 'isRoleAdvanced', '*', 'ALLOW', 'ROLE', 'deliveryBoss'),
|
||||
('Ticket', 'isRoleAdvanced', '*', 'ALLOW', 'ROLE', 'deliveryAssistant'),
|
||||
('Ticket', 'isRoleAdvanced', '*', 'ALLOW', 'ROLE', 'buyer'),
|
||||
('Ticket', 'isRoleAdvanced', '*', 'ALLOW', 'ROLE', 'claimManager'),
|
||||
('Ticket', 'deleteTicketWithPartPrepared', 'WRITE', 'ALLOW', 'ROLE', 'salesAssistant'),
|
||||
('Ticket', 'editZone', 'WRITE', 'ALLOW', 'ROLE', 'deliveryBoss'),
|
||||
('Ticket', 'editZone', 'WRITE', 'ALLOW', 'ROLE', 'deliveryAssistant'),
|
||||
('State', 'editableStates', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
('State', 'seeEditableStates', 'READ', 'ALLOW', 'ROLE', 'administrative'),
|
||||
('State', 'seeEditableStates', 'READ', 'ALLOW', 'ROLE', 'production'),
|
|
@ -0,0 +1,4 @@
|
|||
ALTER TABLE `vn`.`worker` DROP KEY `user_id_UNIQUE`;
|
||||
|
||||
ALTER TABLE `vn`.`worker` DROP COLUMN `userFk`;
|
||||
|
|
@ -0,0 +1,86 @@
|
|||
DELIMITER $$
|
||||
$$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`timeBusiness_calculate`(vDatedFrom DATETIME, vDatedTo DATETIME)
|
||||
BEGIN
|
||||
/**
|
||||
* Horas que debe trabajar un empleado según contrato y día.
|
||||
* @param vDatedFrom workerTimeControl
|
||||
* @param vDatedTo workerTimeControl
|
||||
* @table tmp.user(userFk)
|
||||
* @return tmp.timeBusinessCalculate
|
||||
*/
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.timeBusinessCalculate;
|
||||
CREATE TEMPORARY TABLE tmp.timeBusinessCalculate
|
||||
(INDEX (departmentFk))
|
||||
SELECT dated,
|
||||
businessFk,
|
||||
sub.id userFk,
|
||||
departmentFk,
|
||||
hourStart,
|
||||
hourEnd,
|
||||
timeTable,
|
||||
timeWorkSeconds,
|
||||
SEC_TO_TIME(timeWorkSeconds) timeWorkSexagesimal,
|
||||
timeWorkSeconds / 3600 timeWorkDecimal,
|
||||
timeWorkSeconds timeBusinessSeconds,
|
||||
SEC_TO_TIME(timeWorkSeconds) timeBusinessSexagesimal,
|
||||
timeWorkSeconds / 3600 timeBusinessDecimal,
|
||||
name type,
|
||||
permissionRate,
|
||||
hoursWeek,
|
||||
discountRate,
|
||||
isAllowedToWork
|
||||
FROM(SELECT t.dated,
|
||||
b.id businessFk,
|
||||
w.id,
|
||||
b.departmentFk,
|
||||
IF(bs.started = NULL, NULL, GROUP_CONCAT(DISTINCT LEFT(bs.started,5) ORDER BY bs.started ASC SEPARATOR ' - ')) hourStart ,
|
||||
IF(bs.started = NULL, NULL, GROUP_CONCAT(DISTINCT LEFT(bs.ended,5) ORDER BY bs.ended ASC SEPARATOR ' - ')) hourEnd,
|
||||
IF(bs.started = NULL, NULL, GROUP_CONCAT(DISTINCT LEFT(bs.started,5), " - ", LEFT(bs.ended,5) ORDER BY bs.ended ASC SEPARATOR ' - ')) timeTable,
|
||||
IF(bs.started = NULL, 0, IFNULL(SUM(TIME_TO_SEC(bs.ended)) - SUM(TIME_TO_SEC(bs.started)), 0)) timeWorkSeconds,
|
||||
at2.name,
|
||||
at2.permissionRate,
|
||||
at2.discountRate,
|
||||
ct.hoursWeek hoursWeek,
|
||||
at2.isAllowedToWork
|
||||
FROM time t
|
||||
LEFT JOIN business b ON t.dated BETWEEN b.started AND IFNULL(b.ended, vDatedTo)
|
||||
LEFT JOIN worker w ON w.id = b.workerFk
|
||||
JOIN tmp.`user` u ON u.userFK = w.id
|
||||
LEFT JOIN workCenter wc ON wc.id = b.workcenterFK
|
||||
LEFT JOIN calendarType ct ON ct.id = b.calendarTypeFk
|
||||
LEFT JOIN businessSchedule bs ON bs.businessFk = b.id AND bs.weekday = WEEKDAY(t.dated) + 1
|
||||
LEFT JOIN calendar c ON c.businessFk = b.id AND c.dated = t.dated
|
||||
LEFT JOIN absenceType at2 ON at2.id = c.dayOffTypeFk
|
||||
WHERE t.dated BETWEEN vDatedFrom AND vDatedTo
|
||||
GROUP BY w.id, t.dated
|
||||
)sub;
|
||||
|
||||
UPDATE tmp.timeBusinessCalculate t
|
||||
LEFT JOIN businessSchedule bs ON bs.businessFk = t.businessFk
|
||||
SET t.timeWorkSeconds = t.hoursWeek / 5 * 3600,
|
||||
t.timeWorkSexagesimal = SEC_TO_TIME( t.hoursWeek / 5 * 3600),
|
||||
t.timeWorkDecimal = t.hoursWeek / 5,
|
||||
t.timeBusinessSeconds = t.hoursWeek / 5 * 3600,
|
||||
t.timeBusinessSexagesimal = SEC_TO_TIME( t.hoursWeek / 5 * 3600),
|
||||
t.timeBusinessDecimal = t.hoursWeek / 5
|
||||
WHERE DAYOFWEEK(t.dated) IN(2,3,4,5,6) AND bs.id IS NULL ;
|
||||
|
||||
UPDATE tmp.timeBusinessCalculate t
|
||||
SET t.timeWorkSeconds = t.timeWorkSeconds - (t.timeWorkSeconds * permissionRate) ,
|
||||
t.timeWorkSexagesimal = SEC_TO_TIME ((t.timeWorkDecimal - (t.timeWorkDecimal * permissionRate)) * 3600),
|
||||
t.timeWorkDecimal = t.timeWorkDecimal - (t.timeWorkDecimal * permissionRate)
|
||||
WHERE permissionRate <> 0;
|
||||
|
||||
UPDATE tmp.timeBusinessCalculate t
|
||||
JOIN calendarHolidays ch ON ch.dated = t.dated
|
||||
JOIN business b ON b.id = t.businessFk
|
||||
AND b.workcenterFk = ch.workcenterFk
|
||||
SET t.timeWorkSeconds = 0,
|
||||
t.timeWorkSexagesimal = 0,
|
||||
t.timeWorkDecimal = 0,
|
||||
t.permissionrate = 1,
|
||||
t.type = 'Festivo'
|
||||
WHERE t.type IS NULL;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -0,0 +1,57 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `account`.`account_enable`(vSelf INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Enables a worker's account and sets up email configurations.
|
||||
*/
|
||||
UPDATE user
|
||||
SET active = TRUE
|
||||
WHERE id = vSelf;
|
||||
|
||||
INSERT IGNORE INTO account
|
||||
SET id = vSelf;
|
||||
|
||||
INSERT IGNORE INTO mailAliasAccount (mailAlias, account)
|
||||
SELECT id, vSelf
|
||||
FROM mailAlias
|
||||
WHERE alias = 'general';
|
||||
|
||||
INSERT IGNORE INTO mailForward (account, forwardTo)
|
||||
SELECT vSelf, email
|
||||
FROM user
|
||||
WHERE id = vSelf;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
||||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`worker_updateBusiness`(vSelf INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Activates an account and configures its email settings.
|
||||
*
|
||||
* @param vSelf account id.
|
||||
*/
|
||||
DECLARE vOldBusinessFk INT;
|
||||
DECLARE vNewBusinessFk INT;
|
||||
|
||||
SELECT businessFk INTO vOldBusinessFk FROM worker WHERE id = vSelf;
|
||||
|
||||
SELECT id INTO vNewBusinessFk
|
||||
FROM business
|
||||
WHERE workerFk = vSelf
|
||||
AND util.VN_CURDATE() BETWEEN started AND IFNULL(ended, util.VN_CURDATE());
|
||||
|
||||
UPDATE worker
|
||||
SET businessFk = vNewBusinessFk
|
||||
WHERE id = vSelf;
|
||||
|
||||
IF NOT (vOldBusinessFk <=> vNewBusinessFk) THEN
|
||||
IF vNewBusinessFk IS NULL THEN
|
||||
CALL workerDisable(vSelf);
|
||||
END IF;
|
||||
IF vOldBusinessFk IS NULL THEN
|
||||
CALL account.account_enable(vSelf);
|
||||
END IF;
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -0,0 +1,16 @@
|
|||
-- Auto-generated SQL script. Actual values for binary/complex data types may differ - what you see is the default string representation of values.
|
||||
INSERT INTO `account`.`role` (name, description)
|
||||
VALUES ('deliveryAssistant','Jefe auxiliar repartos');
|
||||
|
||||
INSERT INTO `account`.`roleInherit` (role, inheritsFrom)
|
||||
SELECT (SELECT id FROM account.role r1 WHERE r1.name = 'deliveryAssistant'), ri.inheritsFrom
|
||||
FROM account.roleInherit ri
|
||||
JOIN account.role r2 ON r2.id = ri.`role`
|
||||
WHERE r2.name = 'deliveryBoss';
|
||||
|
||||
INSERT INTO `account`.`roleInherit` (role, inheritsFrom)
|
||||
SELECT (SELECT id FROM account.role WHERE name = 'deliveryBoss') role,
|
||||
(SELECT id FROM account.role WHERE name = 'deliveryAssistant') roleInherit;
|
||||
|
||||
|
||||
CALL `account`.`role_syncPrivileges`();
|
|
@ -0,0 +1,20 @@
|
|||
DELIMITER $$
|
||||
$$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`workerCreate`(
|
||||
vFirstname VARCHAR(50),
|
||||
vLastName VARCHAR(50),
|
||||
vCode CHAR(3),
|
||||
vBossFk INT,
|
||||
vUserFk INT,
|
||||
vFi VARCHAR(15) ,
|
||||
vBirth DATE
|
||||
)
|
||||
BEGIN
|
||||
/**
|
||||
* Create new worker
|
||||
*
|
||||
*/
|
||||
INSERT INTO worker(id, code, firstName, lastName, bossFk, fi, birth)
|
||||
VALUES (vUserFk, vCode, vFirstname, vLastName, vBossFk, vFi, vBirth);
|
||||
END$$
|
||||
DELIMITER ;
|
File diff suppressed because one or more lines are too long
|
@ -87,8 +87,8 @@ INSERT INTO `vn`.`educationLevel` (`id`, `name`)
|
|||
(1, 'ESTUDIOS PRIMARIOS COMPLETOS'),
|
||||
(2, 'ENSEÑANZAS DE BACHILLERATO');
|
||||
|
||||
INSERT INTO `vn`.`worker`(`id`,`code`, `firstName`, `lastName`, `userFk`, `bossFk`)
|
||||
SELECT id,UPPER(LPAD(role, 3, '0')), name, name, id, 9
|
||||
INSERT INTO `vn`.`worker`(`id`,`code`, `firstName`, `lastName`, `bossFk`)
|
||||
SELECT id,UPPER(LPAD(role, 3, '0')), name, name, 9
|
||||
FROM `account`.`user`;
|
||||
|
||||
UPDATE `vn`.`worker` SET bossFk = NULL WHERE id = 20;
|
||||
|
@ -188,13 +188,13 @@ INSERT INTO `vn`.`printer` (`id`, `name`, `path`, `isLabeler`, `sectorFk`, `ipAd
|
|||
|
||||
UPDATE `vn`.`sector` SET mainPrinterFk = 1 WHERE id = 1;
|
||||
|
||||
INSERT INTO `vn`.`worker`(`id`, `code`, `firstName`, `lastName`, `userFk`,`bossFk`, `phone`)
|
||||
INSERT INTO `vn`.`worker`(`id`, `code`, `firstName`, `lastName`,`bossFk`, `phone`)
|
||||
VALUES
|
||||
(1106, 'LGN', 'David Charles', 'Haller', 1106, 19, 432978106),
|
||||
(1107, 'ANT', 'Hank' , 'Pym' , 1107, 19, 432978107),
|
||||
(1108, 'DCX', 'Charles' , 'Xavier', 1108, 19, 432978108),
|
||||
(1109, 'HLK', 'Bruce' , 'Banner', 1109, 19, 432978109),
|
||||
(1110, 'JJJ', 'Jessica' , 'Jones' , 1110, 19, 432978110);
|
||||
(1106, 'LGN', 'David Charles', 'Haller', 19, 432978106),
|
||||
(1107, 'ANT', 'Hank' , 'Pym' , 19, 432978107),
|
||||
(1108, 'DCX', 'Charles' , 'Xavier', 19, 432978108),
|
||||
(1109, 'HLK', 'Bruce' , 'Banner', 19, 432978109),
|
||||
(1110, 'JJJ', 'Jessica' , 'Jones' , 19, 432978110);
|
||||
|
||||
INSERT INTO `vn`.`parking` (`id`, `column`, `row`, `sectorFk`, `code`, `pickingOrder`)
|
||||
VALUES
|
||||
|
@ -1013,7 +1013,7 @@ INSERT INTO `vn`.`sale`(`id`, `itemFk`, `ticketFk`, `concept`, `quantity`, `pric
|
|||
(4, 4, 1, 'Melee weapon heavy shield 100cm', 20, 1.69, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
|
||||
(5, 1, 2, 'Ranged weapon longbow 200cm', 1, 110.33, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
|
||||
(6, 1, 3, 'Ranged weapon longbow 200cm', 1, 110.33, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH)),
|
||||
(7, 2, 11, 'Melee weapon combat fist 15cm', 15, 7.44, 0, 0, 0, util.VN_CURDATE()),
|
||||
(7, 2, 11, 'Melee weapon combat fist 15cm', 15, 7.74, 0, 0, 0, util.VN_CURDATE()),
|
||||
(8, 4, 11, 'Melee weapon heavy shield 100cm', 10, 1.79, 0, 0, 0, util.VN_CURDATE()),
|
||||
(9, 1, 16, 'Ranged weapon longbow 200cm', 1, 103.49, 0, 0, 0, util.VN_CURDATE()),
|
||||
(10, 2, 16, 'Melee weapon combat fist 15cm', 10, 7.09, 0, 0, 0, util.VN_CURDATE()),
|
||||
|
@ -2974,5 +2974,3 @@ INSERT INTO vn.XDiario (id, ASIEN, FECHA, SUBCTA, CONTRA, CONCEPTO, EURODEBE, EU
|
|||
(4, 2.0, util.VN_CURDATE(), '4300001104', NULL, 'n/fra T4444444', 8.88, NULL, NULL, NULL, '0', NULL, 0.00, NULL, NULL, NULL, NULL, NULL, '2', NULL, 1, 2, 'I.F.', 'Nombre Importador', 1, 0, 0, util.VN_CURDATE(), 0, 442, 0, 0, 0.00, NULL, NULL, util.VN_CURDATE(), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, 0),
|
||||
(5, 2.0, util.VN_CURDATE(), '2000000000', '4300001104', 'n/fra T4444444 Tony Stark', NULL, 8.07, NULL, NULL, '0', NULL, 0.00, NULL, NULL, NULL, NULL, NULL, '2', NULL, 1, 2, 'I.F.', 'Nombre Importador', 1, 0, 0, util.VN_CURDATE(), 0, 442, 0, 0, 0.00, NULL, NULL, util.VN_CURDATE(), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, 0),
|
||||
(6, 2.0, util.VN_CURDATE(), '4770000010', '4300001104', 'Inmovilizado pendiente : n/fra T4444444 Tony Stark', NULL, 0.81, 8.07, 'T', '4444444', 10.00, NULL, NULL, NULL, NULL, NULL, '', '2', '', 1, 1, '06089160W', 'IRON MAN', 1, 1, 0, util.VN_CURDATE(), 0, 442, 0, 0, 0.00, NULL, NULL, util.VN_CURDATE(), NULL, 1, 1, 1, 1, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, 0);
|
||||
|
||||
|
|
@ -26556,6 +26556,7 @@ CREATE TABLE `deviceLog` (
|
|||
`created` timestamp NOT NULL DEFAULT current_timestamp(),
|
||||
`nameApp` varchar(45) DEFAULT NULL,
|
||||
`versionApp` varchar(45) DEFAULT NULL,
|
||||
`serialNumber` varchar(45) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `deviceLog_FK` (`userFk`),
|
||||
CONSTRAINT `deviceLog_FK` FOREIGN KEY (`userFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE
|
||||
|
|
|
@ -6,13 +6,13 @@ describe('item_getBalance()', () => {
|
|||
let stmts = [];
|
||||
|
||||
let params = {
|
||||
warehouseFk: 1,
|
||||
itemFk: 1
|
||||
itemFk: 1,
|
||||
warehouseFk: 1
|
||||
};
|
||||
|
||||
const conn = await app.models.Item.dataSource.connector;
|
||||
|
||||
stmts.push(new ParameterizedSQL('CALL vn.item_getBalance(?, ?)', [
|
||||
stmts.push(new ParameterizedSQL('CALL vn.item_getBalance(?, ?, NULL)', [
|
||||
params.warehouseFk,
|
||||
params.itemFk
|
||||
]));
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
|
||||
|
||||
describe('logAddWithUser()', () => {
|
||||
it('should log any action taken by the user in a table ending in Log', async() => {
|
||||
let stmts = [];
|
||||
let stmt;
|
||||
|
||||
stmts.push('START TRANSACTION');
|
||||
|
||||
let params = {
|
||||
ticketFk: 1,
|
||||
userId: 9,
|
||||
actionCode: 'update',
|
||||
targetEntity: 'ticket',
|
||||
description: 'we are testing stuff'
|
||||
};
|
||||
|
||||
stmt = new ParameterizedSQL('CALL vn.logAddWithUser(?, ?, ?, ?, ?)', [
|
||||
params.ticketFk,
|
||||
params.userId,
|
||||
params.actionCode,
|
||||
params.targetEntity,
|
||||
params.description
|
||||
]);
|
||||
stmts.push(stmt);
|
||||
|
||||
stmt = new ParameterizedSQL('SELECT * FROM vn.ticketLog WHERE description = ?', [
|
||||
params.description
|
||||
]);
|
||||
let ticketLogIndex = stmts.push(stmt) - 1;
|
||||
|
||||
stmts.push('ROLLBACK');
|
||||
|
||||
let sql = ParameterizedSQL.join(stmts, ';');
|
||||
let result = await app.models.Ticket.rawStmt(sql);
|
||||
|
||||
savedDescription = result[ticketLogIndex][0].description;
|
||||
|
||||
expect(savedDescription).toEqual(params.description);
|
||||
});
|
||||
});
|
|
@ -14,14 +14,6 @@ describe('timeControl_calculateByUser()', () => {
|
|||
let stmts = [];
|
||||
let stmt;
|
||||
|
||||
stmts.push('START TRANSACTION');
|
||||
|
||||
stmts.push(`
|
||||
DROP TEMPORARY TABLE IF EXISTS
|
||||
tmp.timeControlCalculate,
|
||||
tmp.timeBusinessCalculate
|
||||
`);
|
||||
|
||||
let params = {
|
||||
workerID: 1106,
|
||||
start: start,
|
||||
|
@ -37,17 +29,15 @@ describe('timeControl_calculateByUser()', () => {
|
|||
|
||||
let tableIndex = stmts.push('SELECT * FROM tmp.timeControlCalculate') - 1;
|
||||
|
||||
stmts.push('ROLLBACK');
|
||||
|
||||
let sql = ParameterizedSQL.join(stmts, ';');
|
||||
let result = await app.models.Ticket.rawStmt(sql);
|
||||
|
||||
let [timeControlCalculateTable] = result[tableIndex];
|
||||
|
||||
expect(timeControlCalculateTable.timeWorkSeconds).toEqual(29400);
|
||||
expect(timeControlCalculateTable.timeWorkSeconds).toEqual(28200);
|
||||
});
|
||||
|
||||
it(`should return the worked hours between last sunday and monday`, async() => {
|
||||
// #2261
|
||||
xit(`should return the worked hours between last sunday and monday`, async() => {
|
||||
let lastSunday = Date.vnNew();
|
||||
let daysSinceSunday = lastSunday.getDay();
|
||||
if (daysSinceSunday === 0) // this means today is sunday but you need the previous sunday :)
|
||||
|
@ -65,13 +55,7 @@ describe('timeControl_calculateByUser()', () => {
|
|||
|
||||
stmts.push('START TRANSACTION');
|
||||
|
||||
stmts.push(`
|
||||
DROP TEMPORARY TABLE IF EXISTS
|
||||
tmp.timeControlCalculate,
|
||||
tmp.timeBusinessCalculate
|
||||
`);
|
||||
|
||||
const workerID = 1107;
|
||||
const workerID = 1108;
|
||||
|
||||
stmt = new ParameterizedSQL(`
|
||||
INSERT INTO vn.workerTimeControl(userFk, timed, manual, direction)
|
||||
|
|
|
@ -7,7 +7,7 @@ describe('zone zone_getFromGeo()', () => {
|
|||
let stmt;
|
||||
|
||||
stmts.push('START TRANSACTION');
|
||||
let geoFk = 17;
|
||||
let geoFk = 16;
|
||||
|
||||
stmt = new ParameterizedSQL('CALL zone_getFromGeo(?)', [
|
||||
geoFk,
|
||||
|
|
|
@ -8,7 +8,7 @@ describe('Client create path', () => {
|
|||
beforeAll(async() => {
|
||||
browser = await getBrowser();
|
||||
page = browser.page;
|
||||
await page.loginAndModule(' deliveryBoss', 'client');
|
||||
await page.loginAndModule('deliveryAssistant', 'client');
|
||||
});
|
||||
|
||||
afterAll(async() => {
|
||||
|
|
|
@ -45,7 +45,7 @@ describe('Worker create path', () => {
|
|||
|
||||
// should create a new worker and go to worker basic data'
|
||||
await page.pickDate(selectors.workerCreate.birth, new Date(1962, 8, 5));
|
||||
await page.autocompleteSearch(selectors.workerCreate.boss, 'deliveryBoss');
|
||||
await page.autocompleteSearch(selectors.workerCreate.boss, 'deliveryAssistant');
|
||||
await page.waitToClick(selectors.workerCreate.createButton);
|
||||
message = await page.waitForSnackbar();
|
||||
await page.waitForState('worker.card.basicData');
|
||||
|
|
|
@ -75,7 +75,7 @@ describe('Ticket Edit basic data path', () => {
|
|||
const result = await page
|
||||
.waitToGetProperty(selectors.ticketBasicData.stepTwoTotalPriceDif, 'innerText');
|
||||
|
||||
expect(result).toContain('-€232.75');
|
||||
expect(result).toContain('-€228.25');
|
||||
});
|
||||
|
||||
it(`should select a new reason for the changes made then click on finalize`, async() => {
|
||||
|
|
|
@ -8,7 +8,9 @@ describe('Zone basic data path', () => {
|
|||
beforeAll(async() => {
|
||||
browser = await getBrowser();
|
||||
page = browser.page;
|
||||
await page.loginAndModule('deliveryBoss', 'zone'); // turns up the zone module name and route aint the same lol
|
||||
|
||||
await page.loginAndModule('deliveryAssistant',
|
||||
'zone'); // turns up the zone module name and route aint the same lol
|
||||
await page.accessToSearchResult('10');
|
||||
await page.accessToSection('zone.card.basicData');
|
||||
});
|
||||
|
|
|
@ -8,7 +8,7 @@ describe('Zone descriptor path', () => {
|
|||
beforeAll(async() => {
|
||||
browser = await getBrowser();
|
||||
page = browser.page;
|
||||
await page.loginAndModule('deliveryBoss', 'zone');
|
||||
await page.loginAndModule('deliveryAssistant', 'zone');
|
||||
await page.accessToSearchResult('13');
|
||||
});
|
||||
|
||||
|
|
|
@ -316,5 +316,6 @@
|
|||
"The ticket doesn't exist.": "No existe el ticket.",
|
||||
"Social name should be uppercase": "La razón social debe ir en mayúscula",
|
||||
"Street should be uppercase": "La dirección fiscal debe ir en mayúscula",
|
||||
"The response is not a PDF": "La respuesta no es un PDF",
|
||||
"Ticket without Route": "Ticket sin ruta"
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ module.exports = Self => {
|
|||
|
||||
try {
|
||||
const worker = await models.Worker.findOne({
|
||||
where: {userFk: userId}
|
||||
where: {id: userId}
|
||||
}, myOptions);
|
||||
|
||||
const obsevationType = await models.ObservationType.findOne({
|
||||
|
|
|
@ -35,7 +35,7 @@ module.exports = Self => {
|
|||
{
|
||||
relation: 'worker',
|
||||
scope: {
|
||||
fields: ['userFk'],
|
||||
fields: ['id'],
|
||||
include: {
|
||||
relation: 'user',
|
||||
scope: {
|
||||
|
@ -109,7 +109,7 @@ module.exports = Self => {
|
|||
{
|
||||
relation: 'worker',
|
||||
scope: {
|
||||
fields: ['userFk'],
|
||||
fields: ['id'],
|
||||
include: {
|
||||
relation: 'user',
|
||||
scope: {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
|
||||
const buildFilter = require('vn-loopback/util/filter').buildFilter;
|
||||
const { mergeFilters, mergeWhere } = require('vn-loopback/util/filter');
|
||||
const {mergeFilters, mergeWhere} = require('vn-loopback/util/filter');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('logs', {
|
||||
|
@ -12,27 +12,27 @@ module.exports = Self => {
|
|||
arg: 'id',
|
||||
type: 'Number',
|
||||
description: 'The claim id',
|
||||
http: { source: 'path' }
|
||||
http: {source: 'path'}
|
||||
},
|
||||
{
|
||||
arg: 'filter',
|
||||
type: 'object',
|
||||
http: { source: 'query' }
|
||||
http: {source: 'query'}
|
||||
},
|
||||
{
|
||||
arg: 'search',
|
||||
type: 'string',
|
||||
http: { source: 'query' }
|
||||
http: {source: 'query'}
|
||||
},
|
||||
{
|
||||
arg: 'userFk',
|
||||
type: 'number',
|
||||
http: { source: 'query' }
|
||||
http: {source: 'query'}
|
||||
},
|
||||
{
|
||||
arg: 'created',
|
||||
type: 'date',
|
||||
http: { source: 'query' }
|
||||
http: {source: 'query'}
|
||||
},
|
||||
],
|
||||
returns: {
|
||||
|
@ -45,7 +45,7 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.logs = async (ctx, id, filter, options) => {
|
||||
Self.logs = async(ctx, id, filter, options) => {
|
||||
const conn = Self.dataSource.connector;
|
||||
const args = ctx.args;
|
||||
const myOptions = {};
|
||||
|
@ -59,22 +59,22 @@ module.exports = Self => {
|
|||
case 'search':
|
||||
return {
|
||||
or: [
|
||||
{ changedModel: { like: `%${value}%` } },
|
||||
{ oldInstance: { like: `%${value}%` } }
|
||||
{changedModel: {like: `%${value}%`}},
|
||||
{oldInstance: {like: `%${value}%`}}
|
||||
]
|
||||
};
|
||||
case 'userFk':
|
||||
return { 'cl.userFk': value };
|
||||
return {'cl.userFk': value};
|
||||
case 'created':
|
||||
value.setHours(0, 0, 0, 0);
|
||||
to = new Date(value);
|
||||
to.setHours(23, 59, 59, 999);
|
||||
|
||||
return { creationDate: { between: [value, to] } };
|
||||
return {creationDate: {between: [value, to]}};
|
||||
}
|
||||
});
|
||||
where = mergeWhere(where, { ['cl.originFk']: id });
|
||||
filter = mergeFilters(args.filter, { where });
|
||||
where = mergeWhere(where, {['cl.originFk']: id});
|
||||
filter = mergeFilters(args.filter, {where});
|
||||
|
||||
const stmts = [];
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ class Controller extends ModuleCard {
|
|||
{
|
||||
relation: 'worker',
|
||||
scope: {
|
||||
fields: ['userFk'],
|
||||
fields: ['id'],
|
||||
include: {
|
||||
relation: 'user',
|
||||
scope: {
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
<vn-label-value
|
||||
label="Attended by">
|
||||
<span
|
||||
ng-click="workerDescriptor.show($event, $ctrl.claim.worker.userFk)"
|
||||
ng-click="workerDescriptor.show($event, $ctrl.claim.worker.id)"
|
||||
class="link">
|
||||
{{$ctrl.claim.worker.user.name}}
|
||||
</span>
|
||||
|
|
|
@ -80,10 +80,15 @@ module.exports = Self => {
|
|||
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);
|
||||
let stmts = [];
|
||||
stmts.push(new ParameterizedSQL('CALL vn.zone_getPostalCode(?)', [args.zoneFk]));
|
||||
stmts.push(`SELECT name FROM tmp.zoneNodes`);
|
||||
stmts.push(`DROP TEMPORARY TABLE tmp.zoneNodes`);
|
||||
const sql = ParameterizedSQL.join(stmts, ';');
|
||||
const [results] = await conn.executeStmt(sql);
|
||||
|
||||
for (let result of results)
|
||||
postalCode.push(result.name);
|
||||
}
|
||||
|
||||
const where = buildFilter(ctx.args, (param, value) => {
|
||||
|
|
|
@ -60,7 +60,7 @@ module.exports = Self => {
|
|||
at2.id IS NOT NULL as isCompensation
|
||||
FROM vn.receipt r
|
||||
LEFT JOIN vn.worker w ON w.id = r.workerFk
|
||||
LEFT JOIN account.user u ON u.id = w.userFk
|
||||
LEFT JOIN account.user u ON u.id = w.id
|
||||
JOIN vn.company c ON c.id = r.companyFk
|
||||
LEFT JOIN vn.accounting a ON a.id = r.bankFk
|
||||
LEFT JOIN vn.accountingType at2 ON at2.id = a.accountingTypeFk AND at2.code = 'compensation'
|
||||
|
|
|
@ -9,7 +9,7 @@ module.exports = function(Self) {
|
|||
let token = ctx.options.accessToken;
|
||||
let userId = token && token.userId;
|
||||
|
||||
Self.app.models.Worker.findOne({where: {userFk: userId}}, (err, user) => {
|
||||
Self.app.models.Worker.findOne({where: {id: userId}}, (err, user) => {
|
||||
if (err) return next(err);
|
||||
ctx.instance.workerFk = user.id;
|
||||
next();
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
"include": {
|
||||
"relation": "worker",
|
||||
"scope": {
|
||||
"fields": ["userFk"],
|
||||
"fields": ["id"],
|
||||
"include": {
|
||||
"relation": "user",
|
||||
"scope": {
|
||||
|
|
|
@ -68,7 +68,7 @@
|
|||
icon="add_circle"
|
||||
vn-tooltip="New postcode"
|
||||
ng-click="postcode.open()"
|
||||
vn-acl="deliveryBoss"
|
||||
vn-acl="deliveryAssistant"
|
||||
vn-acl-action="remove">
|
||||
</vn-icon-button>
|
||||
</append>
|
||||
|
|
|
@ -81,7 +81,7 @@
|
|||
icon="add_circle"
|
||||
vn-tooltip="New postcode"
|
||||
ng-click="postcode.open()"
|
||||
vn-acl="deliveryBoss"
|
||||
vn-acl="deliveryAssistant"
|
||||
vn-acl-action="remove">
|
||||
</vn-icon-button>
|
||||
</append>
|
||||
|
|
|
@ -73,7 +73,7 @@
|
|||
icon="add_circle"
|
||||
vn-tooltip="New postcode"
|
||||
ng-click="postcode.open()"
|
||||
vn-acl="deliveryBoss"
|
||||
vn-acl="deliveryAssistant"
|
||||
vn-acl-action="remove">
|
||||
</vn-icon-button>
|
||||
</append>
|
||||
|
|
|
@ -9,7 +9,7 @@ export default class Controller extends Section {
|
|||
include: [{
|
||||
relation: 'worker',
|
||||
scope: {
|
||||
fields: ['userFk'],
|
||||
fields: ['id'],
|
||||
include: {
|
||||
relation: 'user',
|
||||
scope: {
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
<vn-td shrink-datetime>{{::credit.created | date:'dd/MM/yyyy HH:mm'}}</vn-td>
|
||||
<vn-td>
|
||||
<span
|
||||
ng-click="workerDescriptor.show($event, credit.worker.userFk)"
|
||||
ng-click="workerDescriptor.show($event, credit.worker.id)"
|
||||
class="link">
|
||||
{{::credit.worker.user.name}}
|
||||
</span>
|
||||
|
|
|
@ -9,7 +9,7 @@ class Controller extends Section {
|
|||
{
|
||||
relation: 'worker',
|
||||
scope: {
|
||||
fields: ['userFk'],
|
||||
fields: ['id'],
|
||||
include: {
|
||||
relation: 'user',
|
||||
scope: {
|
||||
|
|
|
@ -28,7 +28,7 @@ class Controller extends Section {
|
|||
}, {
|
||||
relation: 'worker',
|
||||
scope: {
|
||||
fields: ['userFk'],
|
||||
fields: ['id'],
|
||||
include: {
|
||||
relation: 'user',
|
||||
scope: {
|
||||
|
|
|
@ -94,7 +94,7 @@
|
|||
icon="add_circle"
|
||||
vn-tooltip="New postcode"
|
||||
ng-click="postcode.open()"
|
||||
vn-acl="deliveryBoss"
|
||||
vn-acl="deliveryAssistant"
|
||||
vn-acl-action="remove">
|
||||
</vn-icon-button>
|
||||
</append>
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
icon="add_circle"
|
||||
vn-tooltip="New city"
|
||||
ng-click="city.open($event)"
|
||||
vn-acl="deliveryBoss"
|
||||
vn-acl="deliveryAssistant"
|
||||
vn-acl-action="remove">
|
||||
</vn-icon-button>
|
||||
</append>
|
||||
|
@ -45,7 +45,7 @@
|
|||
icon="add_circle"
|
||||
vn-tooltip="New province"
|
||||
ng-click="province.open($event)"
|
||||
vn-acl="deliveryBoss"
|
||||
vn-acl="deliveryAssistant"
|
||||
vn-acl-action="remove">
|
||||
</vn-icon-button>
|
||||
</append>
|
||||
|
|
|
@ -180,7 +180,7 @@ module.exports = Self => {
|
|||
LEFT JOIN itemType it ON it.id = i.typeFk
|
||||
LEFT JOIN itemCategory ic ON ic.id = it.categoryFk
|
||||
LEFT JOIN worker w ON w.id = it.workerFk
|
||||
LEFT JOIN account.user u ON u.id = w.userFk
|
||||
LEFT JOIN account.user u ON u.id = w.id
|
||||
LEFT JOIN intrastat intr ON intr.id = i.intrastatFk
|
||||
LEFT JOIN producer pr ON pr.id = i.producerFk
|
||||
LEFT JOIN origin ori ON ori.id = i.originFk
|
||||
|
|
|
@ -34,7 +34,7 @@ module.exports = Self => {
|
|||
include: [{
|
||||
relation: 'worker',
|
||||
scope: {
|
||||
fields: ['userFk'],
|
||||
fields: ['id'],
|
||||
include: {
|
||||
relation: 'user',
|
||||
scope: {
|
||||
|
|
|
@ -38,7 +38,7 @@ module.exports = Self => {
|
|||
include: [{
|
||||
relation: 'worker',
|
||||
scope: {
|
||||
fields: ['userFk'],
|
||||
fields: ['id'],
|
||||
include: {
|
||||
relation: 'user',
|
||||
scope: {
|
||||
|
|
|
@ -58,7 +58,7 @@
|
|||
<vn-label-value
|
||||
label="Buyer">
|
||||
<span
|
||||
ng-click="workerDescriptor.show($event, $ctrl.item.itemType.worker.userFk)"
|
||||
ng-click="workerDescriptor.show($event, $ctrl.item.itemType.worker.id)"
|
||||
class="link">
|
||||
{{$ctrl.item.itemType.worker.user.name}}
|
||||
</span>
|
||||
|
|
|
@ -70,7 +70,7 @@
|
|||
</vn-label-value>
|
||||
<vn-label-value label="Buyer">
|
||||
<span
|
||||
ng-click="workerDescriptor.show($event, $ctrl.summary.item.itemType.worker.userFk)"
|
||||
ng-click="workerDescriptor.show($event, $ctrl.summary.item.itemType.worker.id)"
|
||||
class="link">
|
||||
{{$ctrl.summary.item.itemType.worker.user.name}}
|
||||
</span>
|
||||
|
|
|
@ -215,7 +215,7 @@ module.exports = Self => {
|
|||
LEFT JOIN state st ON st.id = ts.stateFk
|
||||
LEFT JOIN client c ON c.id = t.clientFk
|
||||
LEFT JOIN worker wk ON wk.id = c.salesPersonFk
|
||||
LEFT JOIN account.user u ON u.id = wk.userFk
|
||||
LEFT JOIN account.user u ON u.id = wk.id
|
||||
LEFT JOIN zoneEstimatedDelivery zed ON zed.zoneFk = t.zoneFk`);
|
||||
|
||||
if (args.orderFk) {
|
||||
|
|
|
@ -169,7 +169,7 @@ module.exports = Self => {
|
|||
LEFT JOIN agencyMode am ON am.id = o.agency_id
|
||||
LEFT JOIN client c ON c.id = o.customer_id
|
||||
LEFT JOIN worker wk ON wk.id = c.salesPersonFk
|
||||
LEFT JOIN account.user u ON u.id = wk.userFk
|
||||
LEFT JOIN account.user u ON u.id = wk.id
|
||||
LEFT JOIN company co ON co.id = o.company_id
|
||||
LEFT JOIN orderTicket ot ON ot.orderFk = o.id
|
||||
LEFT JOIN ticket t ON t.id = ot.ticketFk
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
const JSZip = require('jszip');
|
||||
const axios = require('axios');
|
||||
const UserError = require('vn-loopback/util/user-error');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('downloadCmrsZip', {
|
||||
description: 'Download a zip file with multiple cmrs pdfs',
|
||||
accessType: 'READ',
|
||||
accepts: [
|
||||
{
|
||||
arg: 'ids',
|
||||
type: 'string',
|
||||
description: 'The cmrs ids',
|
||||
}
|
||||
],
|
||||
returns: [
|
||||
{
|
||||
arg: 'body',
|
||||
type: 'file',
|
||||
root: true
|
||||
}, {
|
||||
arg: 'Content-Type',
|
||||
type: 'string',
|
||||
http: {target: 'header'}
|
||||
}, {
|
||||
arg: 'Content-Disposition',
|
||||
type: 'string',
|
||||
http: {target: 'header'}
|
||||
}
|
||||
],
|
||||
http: {
|
||||
path: '/downloadCmrsZip',
|
||||
verb: 'GET'
|
||||
}
|
||||
});
|
||||
|
||||
Self.downloadCmrsZip = async function(ctx, ids, options) {
|
||||
const models = Self.app.models;
|
||||
const myOptions = {};
|
||||
const token = ctx.req.accessToken;
|
||||
const zip = new JSZip();
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
const zipConfig = await models.ZipConfig.findOne(null, myOptions);
|
||||
let totalSize = 0;
|
||||
ids = ids.split(',');
|
||||
try {
|
||||
for (let id of ids) {
|
||||
if (zipConfig && totalSize > zipConfig.maxSize) throw new UserError('Files are too large');
|
||||
const response = await axios.get(
|
||||
`${ctx.req.headers.referer}api/Routes/${id}/cmr?access_token=${token.id}`, {
|
||||
...myOptions,
|
||||
responseType: 'arraybuffer',
|
||||
});
|
||||
|
||||
if (response.headers['content-type'] !== 'application/pdf')
|
||||
throw new UserError(`The response is not a PDF`);
|
||||
|
||||
zip.file(`${id}.pdf`, response.data, { binary: true });
|
||||
}
|
||||
|
||||
const zipStream = zip.generateNodeStream({ streamFiles: true });
|
||||
|
||||
return [zipStream, 'application/zip', `filename="cmrs.zip"`];
|
||||
} catch (e) {
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
};
|
|
@ -134,7 +134,7 @@ module.exports = Self => {
|
|||
LEFT JOIN agencyMode am ON am.id = r.agencyModeFk
|
||||
LEFT JOIN vehicle v ON v.id = r.vehicleFk
|
||||
LEFT JOIN worker w ON w.id = r.workerFk
|
||||
LEFT JOIN account.user u ON u.id = w.userFk`
|
||||
LEFT JOIN account.user u ON u.id = w.id`
|
||||
);
|
||||
|
||||
stmt.merge(conn.makeSuffix(filter));
|
||||
|
|
|
@ -22,6 +22,11 @@ module.exports = Self => {
|
|||
type: 'integer',
|
||||
description: 'The worker id',
|
||||
},
|
||||
{
|
||||
arg: 'routeFk',
|
||||
type: 'integer',
|
||||
description: 'The route id',
|
||||
},
|
||||
{
|
||||
arg: 'country',
|
||||
type: 'string',
|
||||
|
@ -57,6 +62,7 @@ module.exports = Self => {
|
|||
filter,
|
||||
cmrFk,
|
||||
ticketFk,
|
||||
routeFk,
|
||||
country,
|
||||
clientFk,
|
||||
hasCmrDms,
|
||||
|
@ -66,6 +72,7 @@ module.exports = Self => {
|
|||
const params = {
|
||||
cmrFk,
|
||||
ticketFk,
|
||||
routeFk,
|
||||
country,
|
||||
clientFk,
|
||||
hasCmrDms,
|
||||
|
@ -93,6 +100,7 @@ module.exports = Self => {
|
|||
FROM (
|
||||
SELECT t.cmrFk,
|
||||
t.id ticketFk,
|
||||
t.routeFk,
|
||||
co.country,
|
||||
t.clientFk,
|
||||
IF(sub.id, TRUE, FALSE) hasCmrDms,
|
||||
|
|
|
@ -33,7 +33,7 @@ module.exports = Self => {
|
|||
}, {
|
||||
relation: 'worker',
|
||||
scope: {
|
||||
fields: ['id', 'userFk'],
|
||||
fields: ['id'],
|
||||
include: [
|
||||
{
|
||||
relation: 'user',
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
"worker": {
|
||||
"type": "belongsTo",
|
||||
"model": "Worker",
|
||||
"foreignKey": "userFk"
|
||||
"foreignKey": "id"
|
||||
},
|
||||
"supplier": {
|
||||
"type": "belongsTo",
|
||||
|
|
|
@ -16,6 +16,7 @@ module.exports = Self => {
|
|||
require('../methods/route/downloadZip')(Self);
|
||||
require('../methods/route/cmr')(Self);
|
||||
require('../methods/route/getExternalCmrs')(Self);
|
||||
require('../methods/route/downloadCmrsZip')(Self);
|
||||
|
||||
Self.validate('kmStart', validateDistance, {
|
||||
message: 'Distance must be lesser than 1000'
|
||||
|
|
|
@ -41,7 +41,7 @@ class Controller extends ModuleCard {
|
|||
{
|
||||
relation: 'worker',
|
||||
scope: {
|
||||
fields: ['userFk'],
|
||||
fields: ['id'],
|
||||
include: {
|
||||
relation: 'user',
|
||||
scope: {
|
||||
|
|
|
@ -15,14 +15,14 @@
|
|||
</vn-item>
|
||||
<vn-item
|
||||
ng-click="updateVolumeConfirmation.show()"
|
||||
vn-acl="deliveryBoss"
|
||||
vn-acl="deliveryAssistant"
|
||||
vn-acl-action="remove"
|
||||
translate>
|
||||
Update volume
|
||||
</vn-item>
|
||||
<vn-item
|
||||
ng-click="$ctrl.deleteCurrentRoute()"
|
||||
vn-acl="deliveryBoss"
|
||||
vn-acl="deliveryAssistant"
|
||||
vn-acl-action="remove"
|
||||
translate>
|
||||
Delete route
|
||||
|
|
|
@ -79,7 +79,7 @@ class Controller extends Descriptor {
|
|||
}, {
|
||||
relation: 'worker',
|
||||
scope: {
|
||||
fields: ['userFk'],
|
||||
fields: ['id'],
|
||||
include: {
|
||||
relation: 'user',
|
||||
scope: {
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
icon="format_list_numbered">
|
||||
</vn-button>
|
||||
<vn-button
|
||||
vn-acl="deliveryBoss"
|
||||
vn-acl="deliveryAssistant"
|
||||
vn-acl-action="remove"
|
||||
disabled="!$ctrl.isChecked"
|
||||
icon="sms"
|
||||
|
|
|
@ -35,7 +35,7 @@ module.exports = Self => {
|
|||
{
|
||||
relation: 'worker',
|
||||
scope: {
|
||||
fields: ['id', 'userFk'],
|
||||
fields: ['id'],
|
||||
include: {
|
||||
relation: 'user',
|
||||
scope: {
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
"worker": {
|
||||
"type": "belongsTo",
|
||||
"model": "Worker",
|
||||
"foreignKey": "userFk"
|
||||
"foreignKey": "id"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ class Controller extends ModuleCard {
|
|||
include: [
|
||||
{relation: 'worker',
|
||||
scope: {
|
||||
fields: ['userFk'],
|
||||
fields: ['id'],
|
||||
include: {
|
||||
relation: 'user',
|
||||
scope: {
|
||||
|
|
|
@ -12,7 +12,7 @@ class Controller extends Summary {
|
|||
include: [
|
||||
{relation: 'worker',
|
||||
scope: {
|
||||
fields: ['userFk'],
|
||||
fields: ['id'],
|
||||
include: {
|
||||
relation: 'user',
|
||||
scope: {
|
||||
|
|
|
@ -91,7 +91,7 @@ module.exports = Self => {
|
|||
{
|
||||
relation: 'worker',
|
||||
scope: {
|
||||
fields: ['userFk'],
|
||||
fields: ['id'],
|
||||
include: {
|
||||
relation: 'user',
|
||||
scope: {
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
icon="add_circle"
|
||||
vn-tooltip="New postcode"
|
||||
ng-click="postcode.open()"
|
||||
vn-acl="deliveryBoss"
|
||||
vn-acl="deliveryAssistant"
|
||||
vn-acl-action="remove">
|
||||
</vn-icon-button>
|
||||
</append>
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
icon="add_circle"
|
||||
vn-tooltip="New postcode"
|
||||
ng-click="postcode.open()"
|
||||
vn-acl="deliveryBoss"
|
||||
vn-acl="deliveryAssistant"
|
||||
vn-acl-action="remove">
|
||||
</vn-icon-button>
|
||||
</append>
|
||||
|
|
|
@ -150,7 +150,7 @@
|
|||
icon="add_circle"
|
||||
vn-tooltip="New postcode"
|
||||
ng-click="postcode.open()"
|
||||
vn-acl="deliveryBoss"
|
||||
vn-acl="deliveryAssistant"
|
||||
vn-acl-action="remove">
|
||||
</vn-icon-button>
|
||||
</append>
|
||||
|
|
|
@ -41,7 +41,7 @@ module.exports = Self => {
|
|||
FROM saleTracking st
|
||||
JOIN sale s ON s.id = st.saleFk
|
||||
JOIN worker w ON w.id = st.workerFk
|
||||
JOIN account.user u ON u.id = w.userFk
|
||||
JOIN account.user u ON u.id = w.id
|
||||
JOIN state ste ON ste.id = st.stateFk`);
|
||||
|
||||
stmt.merge(Self.makeSuffix(filter));
|
||||
|
|
|
@ -108,7 +108,7 @@ describe('sale updatePrice()', () => {
|
|||
}}, options);
|
||||
|
||||
expect(updatedSale.price).toBe(price);
|
||||
expect(createdSaleComponent.value).toEqual(-2.04);
|
||||
expect(createdSaleComponent.value).toEqual(-2.34);
|
||||
|
||||
const updatedSalesPersonMana = await models.WorkerMana.findById(18, null, options);
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ module.exports = Self => {
|
|||
|
||||
try {
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
const worker = await Self.app.models.Worker.findOne({where: {userFk: userId}}, myOptions);
|
||||
const worker = await Self.app.models.Worker.findOne({where: {id: userId}}, myOptions);
|
||||
|
||||
const params = {
|
||||
isOk: false,
|
||||
|
|
|
@ -153,9 +153,9 @@ module.exports = Self => {
|
|||
LEFT JOIN item i ON i.id = tr.itemFk
|
||||
LEFT JOIN sale s ON s.id = tr.saleFk
|
||||
LEFT JOIN worker wk ON wk.id = c.salesPersonFk
|
||||
LEFT JOIN account.user u ON u.id = wk.userFk
|
||||
LEFT JOIN account.user u ON u.id = wk.id
|
||||
LEFT JOIN worker wka ON wka.id = tr.attenderFk
|
||||
LEFT JOIN account.user ua ON ua.id = wka.userFk`);
|
||||
LEFT JOIN account.user ua ON ua.id = wka.id`);
|
||||
stmt.merge(conn.makeSuffix(filter));
|
||||
|
||||
return conn.executeStmt(stmt, myOptions);
|
||||
|
|
|
@ -53,7 +53,7 @@ module.exports = Self => {
|
|||
|
||||
if (!params.workerFk) {
|
||||
const worker = await models.Worker.findOne({
|
||||
where: {userFk: userId}
|
||||
where: {id: userId}
|
||||
}, myOptions);
|
||||
|
||||
params.workerFk = worker.id;
|
||||
|
|
|
@ -43,7 +43,7 @@ module.exports = Self => {
|
|||
fields: ['id', 'name', 'alertLevel', 'code']
|
||||
}, myOptions);
|
||||
|
||||
const worker = await models.Worker.findOne({where: {userFk: userId}}, myOptions);
|
||||
const worker = await models.Worker.findOne({where: {id: userId}}, myOptions);
|
||||
|
||||
const promises = [];
|
||||
for (const id of ticketIds) {
|
||||
|
|
|
@ -272,7 +272,7 @@ module.exports = Self => {
|
|||
LEFT JOIN state st ON st.id = ts.stateFk
|
||||
LEFT JOIN client c ON c.id = t.clientFk
|
||||
LEFT JOIN worker wk ON wk.id = c.salesPersonFk
|
||||
LEFT JOIN account.user u ON u.id = wk.userFk
|
||||
LEFT JOIN account.user u ON u.id = wk.id
|
||||
LEFT JOIN route r ON r.id = t.routeFk`);
|
||||
|
||||
if (args.orderFk) {
|
||||
|
|
|
@ -10,7 +10,7 @@ module.exports = function(Self) {
|
|||
Self.observe('before save', async function(ctx) {
|
||||
if (ctx.isNewInstance) {
|
||||
const loopBackContext = LoopBackContext.getCurrentContext();
|
||||
const filter = {where: {userFk: loopBackContext.active.accessToken.userId}};
|
||||
const filter = {where: {id: loopBackContext.active.accessToken.userId}};
|
||||
const models = Self.app.models;
|
||||
const worker = await models.Worker.findOne(filter);
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ class Controller extends Section {
|
|||
{
|
||||
relation: 'worker',
|
||||
scope: {
|
||||
fields: ['userFk'],
|
||||
fields: ['id'],
|
||||
include: {
|
||||
relation: 'user',
|
||||
scope: {
|
||||
|
|
|
@ -9,7 +9,7 @@ class Controller extends Section {
|
|||
{
|
||||
relation: 'worker',
|
||||
scope: {
|
||||
fields: ['userFk'],
|
||||
fields: ['id'],
|
||||
include: {
|
||||
relation: 'user',
|
||||
scope: {
|
||||
|
|
|
@ -50,7 +50,7 @@ describe('Worker absences()', () => {
|
|||
}
|
||||
});
|
||||
|
||||
it('should give the same holidays as worked days since the holidays amount matches the amount of days in a year', async() => {
|
||||
it('Should have an equal number of holidays and workdays, as they both total the days in a year', async() => {
|
||||
const businessId = 1106;
|
||||
const workerId = 1106;
|
||||
|
||||
|
|
|
@ -102,7 +102,7 @@ module.exports = Self => {
|
|||
|
||||
stmt = new ParameterizedSQL('DROP TEMPORARY TABLE IF EXISTS tmp.`user`');
|
||||
stmts.push(stmt);
|
||||
stmt = new ParameterizedSQL('CREATE TEMPORARY TABLE IF NOT EXISTS tmp.`user` SELECT userFk FROM vn.worker w JOIN account.`user` u ON u.id = w.userFk WHERE userFk IS NOT NULL');
|
||||
stmt = new ParameterizedSQL('CREATE TEMPORARY TABLE IF NOT EXISTS tmp.`user` SELECT id as userFk FROM vn.worker w JOIN account.`user` u ON u.id = w.id WHERE id IS NOT NULL');
|
||||
stmts.push(stmt);
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ module.exports = Self => {
|
|||
const query =
|
||||
`SELECT DISTINCT w.id, w.firstName, w.lastName, u.name, u.nickname
|
||||
FROM worker w
|
||||
JOIN account.user u ON u.id = w.userFk
|
||||
JOIN account.user u ON u.id = w.id
|
||||
JOIN account.roleRole i ON i.role = u.role
|
||||
JOIN account.role r ON r.id = i.inheritsFrom`;
|
||||
|
||||
|
|
|
@ -95,8 +95,6 @@ module.exports = Self => {
|
|||
]};
|
||||
case 'id':
|
||||
return {'w.id': value};
|
||||
case 'userFk':
|
||||
return {'w.userFk': value};
|
||||
case 'firstName':
|
||||
return {'w.firstName': {like: `%${value}%`}};
|
||||
case 'lastName':
|
||||
|
@ -123,8 +121,8 @@ module.exports = Self => {
|
|||
FROM worker w
|
||||
LEFT JOIN workerDepartment wd ON wd.workerFk = w.id
|
||||
LEFT JOIN department d ON d.id = wd.departmentFk
|
||||
LEFT JOIN client c ON c.id = w.userFk
|
||||
LEFT JOIN account.user u ON u.id = w.userFk
|
||||
LEFT JOIN client c ON c.id = w.id
|
||||
LEFT JOIN account.user u ON u.id = w.id
|
||||
LEFT JOIN pbx.sip p ON p.user_id = u.id
|
||||
LEFT JOIN account.emailUser mu ON mu.userFk = u.id`
|
||||
);
|
||||
|
|
|
@ -38,7 +38,7 @@ module.exports = Self => {
|
|||
const conn = Self.dataSource.connector;
|
||||
|
||||
const worker = await models.Worker.findById(id);
|
||||
const userId = worker.userFk;
|
||||
const userId = worker.id;
|
||||
|
||||
const stmts = [];
|
||||
|
||||
|
|
|
@ -28,6 +28,9 @@
|
|||
},
|
||||
"deviceProductionFk": {
|
||||
"type": "number"
|
||||
},
|
||||
"serialNumber": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
"worker": {
|
||||
"type": "hasOne",
|
||||
"model": "Worker",
|
||||
"foreignKey": "userFk"
|
||||
"foreignKey": "id"
|
||||
},
|
||||
"warehouse": {
|
||||
"type": "belongsTo",
|
||||
|
|
|
@ -24,9 +24,6 @@
|
|||
"phone": {
|
||||
"type" : "string"
|
||||
},
|
||||
"userFk": {
|
||||
"type" : "number"
|
||||
},
|
||||
"bossFk": {
|
||||
"type" : "number"
|
||||
},
|
||||
|
@ -66,12 +63,12 @@
|
|||
"client": {
|
||||
"type": "belongsTo",
|
||||
"model": "Client",
|
||||
"foreignKey": "userFk"
|
||||
"foreignKey": "id"
|
||||
},
|
||||
"sip": {
|
||||
"type": "belongsTo",
|
||||
"model": "Sip",
|
||||
"foreignKey": "userFk"
|
||||
"foreignKey": "id"
|
||||
},
|
||||
"department": {
|
||||
"type": "belongsTo",
|
||||
|
|
|
@ -72,7 +72,7 @@
|
|||
icon="add_circle"
|
||||
vn-tooltip="New postcode"
|
||||
ng-click="postcode.open()"
|
||||
vn-acl="deliveryBoss"
|
||||
vn-acl="deliveryAssistant"
|
||||
vn-acl-action="remove">
|
||||
</vn-icon-button>
|
||||
</append>
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
<vn-textfield
|
||||
vn-one
|
||||
label="User id"
|
||||
ng-model="filter.userFk">
|
||||
ng-model="filter.id">
|
||||
</vn-textfield>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
|
|
|
@ -58,7 +58,7 @@
|
|||
<vn-one>
|
||||
<h4 translate>User data</h4>
|
||||
<vn-label-value label="User id"
|
||||
value="{{worker.userFk}}">
|
||||
value="{{worker.id}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value label="User"
|
||||
value="{{worker.user.name}}">
|
||||
|
|
|
@ -54,7 +54,7 @@ module.exports = Self => {
|
|||
const ticketList = await models.Ticket.find(filter, myOptions);
|
||||
const fixingState = await models.State.findOne({where: {code: 'FIXING'}}, myOptions);
|
||||
const worker = await models.Worker.findOne({
|
||||
where: {userFk: userId}
|
||||
where: {id: userId}
|
||||
}, myOptions);
|
||||
|
||||
await models.Ticket.rawSql('UPDATE ticket SET zoneFk = NULL WHERE zoneFk = ?', [id], myOptions);
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
<vn-textfield
|
||||
label="Name"
|
||||
ng-model="$ctrl.zone.name"
|
||||
vn-acl="deliveryBoss"
|
||||
vn-acl="deliveryAssistant"
|
||||
rule>
|
||||
</vn-textfield>
|
||||
</vn-horizontal>
|
||||
|
@ -26,7 +26,7 @@
|
|||
show-field="name"
|
||||
value-field="id"
|
||||
label="Agency"
|
||||
vn-acl="deliveryBoss"
|
||||
vn-acl="deliveryAssistant"
|
||||
rule>
|
||||
</vn-autocomplete>
|
||||
<vn-input-number
|
||||
|
@ -34,7 +34,7 @@
|
|||
label="Max m³"
|
||||
ng-model="$ctrl.zone.itemMaxSize"
|
||||
min="0"
|
||||
vn-acl="deliveryBoss"
|
||||
vn-acl="deliveryAssistant"
|
||||
rule>
|
||||
</vn-input-number>
|
||||
<vn-input-number
|
||||
|
@ -42,7 +42,7 @@
|
|||
label="Maximum m³"
|
||||
ng-model="$ctrl.zone.m3Max"
|
||||
min="0"
|
||||
vn-acl="deliveryBoss"
|
||||
vn-acl="deliveryAssistant"
|
||||
rule>
|
||||
</vn-input-number>
|
||||
</vn-horizontal>
|
||||
|
@ -52,13 +52,13 @@
|
|||
ng-model="$ctrl.zone.travelingDays"
|
||||
min="0"
|
||||
step="1"
|
||||
vn-acl="deliveryBoss"
|
||||
vn-acl="deliveryAssistant"
|
||||
rule>
|
||||
</vn-input-number>
|
||||
<vn-input-time
|
||||
label="Closing"
|
||||
ng-model="$ctrl.zone.hour"
|
||||
vn-acl="deliveryBoss"
|
||||
vn-acl="deliveryAssistant"
|
||||
rule>
|
||||
</vn-input-time>
|
||||
</vn-horizontal>
|
||||
|
@ -68,14 +68,14 @@
|
|||
ng-model="$ctrl.zone.price"
|
||||
min="0"
|
||||
step="0.01"
|
||||
vn-acl="deliveryBoss"
|
||||
vn-acl="deliveryAssistant"
|
||||
rule>
|
||||
</vn-input-number>
|
||||
<vn-input-number
|
||||
label="Bonus"
|
||||
ng-model="$ctrl.zone.bonus"
|
||||
step="0.01"
|
||||
vn-acl="deliveryBoss"
|
||||
vn-acl="deliveryAssistant"
|
||||
rule>
|
||||
</vn-input-number>
|
||||
</vn-horizontal>
|
||||
|
@ -86,14 +86,14 @@
|
|||
ng-model="$ctrl.zone.inflation"
|
||||
min="0"
|
||||
step="0.01"
|
||||
vn-acl="deliveryBoss"
|
||||
vn-acl="deliveryAssistant"
|
||||
rule>
|
||||
</vn-input-number>
|
||||
<vn-check
|
||||
vn-one
|
||||
label="Volumetric"
|
||||
ng-model="$ctrl.zone.isVolumetric"
|
||||
vn-acl="deliveryBoss"
|
||||
vn-acl="deliveryAssistant"
|
||||
rule>
|
||||
</vn-check>
|
||||
</vn-horizontal>
|
||||
|
@ -101,7 +101,7 @@
|
|||
<vn-button-bar>
|
||||
<vn-submit
|
||||
disabled="!watcher.dataChanged()"
|
||||
vn-acl="deliveryBoss"
|
||||
vn-acl="deliveryAssistant"
|
||||
label="Save">
|
||||
</vn-submit>
|
||||
<vn-button
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
vn-click-stop="clone.show(zone)"
|
||||
vn-tooltip="Clone"
|
||||
icon="icon-clone"
|
||||
vn-acl="deliveryBoss"
|
||||
vn-acl="deliveryAssistant"
|
||||
vn-acl-action="remove">
|
||||
</vn-icon-button>
|
||||
<vn-icon-button
|
||||
|
@ -62,7 +62,7 @@
|
|||
fixed-bottom-right>
|
||||
<vn-float-button
|
||||
icon="add"
|
||||
vn-acl="deliveryBoss"
|
||||
vn-acl="deliveryAssistant"
|
||||
vn-acl-action="remove">
|
||||
</vn-float-button>
|
||||
</a>
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
root-label="Locations"
|
||||
fetch-func="$ctrl.onFetch($item)"
|
||||
sort-func="$ctrl.onSort($a, $b)">
|
||||
<vn-check acl-role="deliveryBoss"
|
||||
<vn-check acl-role="deliveryAssistant"
|
||||
ng-model="item.selected"
|
||||
on-change="$ctrl.onSelection(value, item)"
|
||||
triple-state="true"
|
||||
|
|
|
@ -7,5 +7,5 @@ SELECT
|
|||
FROM client c
|
||||
JOIN account.user u ON u.id = c.id
|
||||
LEFT JOIN worker w ON w.id = c.salesPersonFk
|
||||
LEFT JOIN account.user wu ON wu.id = w.userFk
|
||||
LEFT JOIN account.user wu ON wu.id = w.id
|
||||
WHERE c.id = ?
|
|
@ -8,5 +8,5 @@ SELECT
|
|||
FROM client c
|
||||
JOIN account.user u ON u.id = c.id
|
||||
LEFT JOIN worker w ON w.id = c.salesPersonFk
|
||||
LEFT JOIN account.user wu ON wu.id = w.userFk
|
||||
LEFT JOIN account.user wu ON wu.id = w.id
|
||||
WHERE c.id = ?
|
|
@ -11,7 +11,7 @@ SELECT
|
|||
FROM route r
|
||||
LEFT JOIN vehicle v ON v.id = r.vehicleFk
|
||||
LEFT JOIN worker w ON w.id = r.workerFk
|
||||
LEFT JOIN account.user u ON u.id = w.userFk
|
||||
LEFT JOIN account.user u ON u.id = w.id
|
||||
LEFT JOIN agencyMode am ON am.id = r.agencyModeFk
|
||||
LEFT JOIN agency a ON a.id = am.agencyFk
|
||||
LEFT JOIN supplierAgencyTerm sa ON sa.agencyFk = a.id
|
||||
|
|
Loading…
Reference in New Issue