Merge branch 'dev' into 5673-claim-development
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Alex Moreno 2023-09-25 10:10:21 +00:00
commit d05106cc83
94 changed files with 5636 additions and 5424 deletions

View File

@ -17,6 +17,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added ### Added
- (Ticket -> Servicios) Se pueden abonar servicios - (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 ### Changed
- (Trabajadores -> Calendario) Icono de check arreglado cuando pulsas un tipo de dia - (Trabajadores -> Calendario) Icono de check arreglado cuando pulsas un tipo de dia

View File

@ -84,7 +84,7 @@
"worker": { "worker": {
"type": "hasOne", "type": "hasOne",
"model": "Worker", "model": "Worker",
"foreignKey": "userFk" "foreignKey": "id"
}, },
"userConfig": { "userConfig": {
"type": "hasOne", "type": "hasOne",

View File

@ -34,7 +34,7 @@ BEGIN
isAllowedToWork isAllowedToWork
FROM(SELECT t.dated, FROM(SELECT t.dated,
b.id businessFk, b.id businessFk,
w.userFk, w.id,
b.departmentFk, 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.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, 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 FROM time t
LEFT JOIN business b ON t.dated BETWEEN b.started AND IFNULL(b.ended, vDatedTo) LEFT JOIN business b ON t.dated BETWEEN b.started AND IFNULL(b.ended, vDatedTo)
LEFT JOIN worker w ON w.id = b.workerFk 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 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.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.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 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 LEFT JOIN absenceType at2 ON at2.id = ce.calendar_state_id
WHERE t.dated BETWEEN vDatedFrom AND vDatedTo WHERE t.dated BETWEEN vDatedFrom AND vDatedTo
GROUP BY w.userFk, t.dated GROUP BY w.id, t.dated
)sub; )sub;
UPDATE tmp.timeBusinessCalculate t UPDATE tmp.timeBusinessCalculate t

View File

@ -46,7 +46,7 @@ BEGIN
CONCAT('Cliente ', NEW.id), CONCAT('Cliente ', NEW.id),
CONCAT('Recibida la documentación: ', vText) CONCAT('Recibida la documentación: ', vText)
FROM worker w 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 LEFT JOIN account.account ac ON ac.id = u.id
WHERE w.id = NEW.salesPersonFk; WHERE w.id = NEW.salesPersonFk;
END IF; END IF;

View File

@ -3,11 +3,11 @@ INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `pri
('Ticket', 'editDiscount', 'WRITE', 'ALLOW', 'ROLE', 'claimManager'), ('Ticket', 'editDiscount', 'WRITE', 'ALLOW', 'ROLE', 'claimManager'),
('Ticket', 'editDiscount', 'WRITE', 'ALLOW', 'ROLE', 'salesPerson'), ('Ticket', 'editDiscount', 'WRITE', 'ALLOW', 'ROLE', 'salesPerson'),
('Ticket', 'isRoleAdvanced', '*', 'ALLOW', 'ROLE', 'salesAssistant'), ('Ticket', 'isRoleAdvanced', '*', 'ALLOW', 'ROLE', 'salesAssistant'),
('Ticket', 'isRoleAdvanced', '*', 'ALLOW', 'ROLE', 'deliveryBoss'), ('Ticket', 'isRoleAdvanced', '*', 'ALLOW', 'ROLE', 'deliveryAssistant'),
('Ticket', 'isRoleAdvanced', '*', 'ALLOW', 'ROLE', 'buyer'), ('Ticket', 'isRoleAdvanced', '*', 'ALLOW', 'ROLE', 'buyer'),
('Ticket', 'isRoleAdvanced', '*', 'ALLOW', 'ROLE', 'claimManager'), ('Ticket', 'isRoleAdvanced', '*', 'ALLOW', 'ROLE', 'claimManager'),
('Ticket', 'deleteTicketWithPartPrepared', 'WRITE', 'ALLOW', 'ROLE', 'salesAssistant'), ('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', 'editableStates', 'READ', 'ALLOW', 'ROLE', 'employee'),
('State', 'seeEditableStates', 'READ', 'ALLOW', 'ROLE', 'administrative'), ('State', 'seeEditableStates', 'READ', 'ALLOW', 'ROLE', 'administrative'),
('State', 'seeEditableStates', 'READ', 'ALLOW', 'ROLE', 'production'), ('State', 'seeEditableStates', 'READ', 'ALLOW', 'ROLE', 'production'),

View File

@ -0,0 +1,4 @@
ALTER TABLE `vn`.`worker` DROP KEY `user_id_UNIQUE`;
ALTER TABLE `vn`.`worker` DROP COLUMN `userFk`;

View File

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

View File

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

View File

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

View File

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

View File

@ -87,8 +87,8 @@ INSERT INTO `vn`.`educationLevel` (`id`, `name`)
(1, 'ESTUDIOS PRIMARIOS COMPLETOS'), (1, 'ESTUDIOS PRIMARIOS COMPLETOS'),
(2, 'ENSEÑANZAS DE BACHILLERATO'); (2, 'ENSEÑANZAS DE BACHILLERATO');
INSERT INTO `vn`.`worker`(`id`,`code`, `firstName`, `lastName`, `userFk`, `bossFk`) INSERT INTO `vn`.`worker`(`id`,`code`, `firstName`, `lastName`, `bossFk`)
SELECT id,UPPER(LPAD(role, 3, '0')), name, name, id, 9 SELECT id,UPPER(LPAD(role, 3, '0')), name, name, 9
FROM `account`.`user`; FROM `account`.`user`;
UPDATE `vn`.`worker` SET bossFk = NULL WHERE id = 20; 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; 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 VALUES
(1106, 'LGN', 'David Charles', 'Haller', 1106, 19, 432978106), (1106, 'LGN', 'David Charles', 'Haller', 19, 432978106),
(1107, 'ANT', 'Hank' , 'Pym' , 1107, 19, 432978107), (1107, 'ANT', 'Hank' , 'Pym' , 19, 432978107),
(1108, 'DCX', 'Charles' , 'Xavier', 1108, 19, 432978108), (1108, 'DCX', 'Charles' , 'Xavier', 19, 432978108),
(1109, 'HLK', 'Bruce' , 'Banner', 1109, 19, 432978109), (1109, 'HLK', 'Bruce' , 'Banner', 19, 432978109),
(1110, 'JJJ', 'Jessica' , 'Jones' , 1110, 19, 432978110); (1110, 'JJJ', 'Jessica' , 'Jones' , 19, 432978110);
INSERT INTO `vn`.`parking` (`id`, `column`, `row`, `sectorFk`, `code`, `pickingOrder`) INSERT INTO `vn`.`parking` (`id`, `column`, `row`, `sectorFk`, `code`, `pickingOrder`)
VALUES 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)), (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)), (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)), (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()), (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()), (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()), (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), (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), (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); (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);

View File

@ -26556,6 +26556,7 @@ CREATE TABLE `deviceLog` (
`created` timestamp NOT NULL DEFAULT current_timestamp(), `created` timestamp NOT NULL DEFAULT current_timestamp(),
`nameApp` varchar(45) DEFAULT NULL, `nameApp` varchar(45) DEFAULT NULL,
`versionApp` varchar(45) DEFAULT NULL, `versionApp` varchar(45) DEFAULT NULL,
`serialNumber` varchar(45) DEFAULT NULL,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
KEY `deviceLog_FK` (`userFk`), KEY `deviceLog_FK` (`userFk`),
CONSTRAINT `deviceLog_FK` FOREIGN KEY (`userFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE CONSTRAINT `deviceLog_FK` FOREIGN KEY (`userFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE

View File

@ -6,13 +6,13 @@ describe('item_getBalance()', () => {
let stmts = []; let stmts = [];
let params = { let params = {
warehouseFk: 1, itemFk: 1,
itemFk: 1 warehouseFk: 1
}; };
const conn = await app.models.Item.dataSource.connector; 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.warehouseFk,
params.itemFk params.itemFk
])); ]));

View File

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

View File

@ -14,14 +14,6 @@ describe('timeControl_calculateByUser()', () => {
let stmts = []; let stmts = [];
let stmt; let stmt;
stmts.push('START TRANSACTION');
stmts.push(`
DROP TEMPORARY TABLE IF EXISTS
tmp.timeControlCalculate,
tmp.timeBusinessCalculate
`);
let params = { let params = {
workerID: 1106, workerID: 1106,
start: start, start: start,
@ -37,17 +29,15 @@ describe('timeControl_calculateByUser()', () => {
let tableIndex = stmts.push('SELECT * FROM tmp.timeControlCalculate') - 1; let tableIndex = stmts.push('SELECT * FROM tmp.timeControlCalculate') - 1;
stmts.push('ROLLBACK');
let sql = ParameterizedSQL.join(stmts, ';'); let sql = ParameterizedSQL.join(stmts, ';');
let result = await app.models.Ticket.rawStmt(sql); let result = await app.models.Ticket.rawStmt(sql);
let [timeControlCalculateTable] = result[tableIndex]; let [timeControlCalculateTable] = result[tableIndex];
expect(timeControlCalculateTable.timeWorkSeconds).toEqual(29400); expect(timeControlCalculateTable.timeWorkSeconds).toEqual(28200);
}); });
// #2261
it(`should return the worked hours between last sunday and monday`, async() => { xit(`should return the worked hours between last sunday and monday`, async() => {
let lastSunday = Date.vnNew(); let lastSunday = Date.vnNew();
let daysSinceSunday = lastSunday.getDay(); let daysSinceSunday = lastSunday.getDay();
if (daysSinceSunday === 0) // this means today is sunday but you need the previous sunday :) 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('START TRANSACTION');
stmts.push(` const workerID = 1108;
DROP TEMPORARY TABLE IF EXISTS
tmp.timeControlCalculate,
tmp.timeBusinessCalculate
`);
const workerID = 1107;
stmt = new ParameterizedSQL(` stmt = new ParameterizedSQL(`
INSERT INTO vn.workerTimeControl(userFk, timed, manual, direction) INSERT INTO vn.workerTimeControl(userFk, timed, manual, direction)

View File

@ -7,7 +7,7 @@ describe('zone zone_getFromGeo()', () => {
let stmt; let stmt;
stmts.push('START TRANSACTION'); stmts.push('START TRANSACTION');
let geoFk = 17; let geoFk = 16;
stmt = new ParameterizedSQL('CALL zone_getFromGeo(?)', [ stmt = new ParameterizedSQL('CALL zone_getFromGeo(?)', [
geoFk, geoFk,

View File

@ -8,7 +8,7 @@ describe('Client create path', () => {
beforeAll(async() => { beforeAll(async() => {
browser = await getBrowser(); browser = await getBrowser();
page = browser.page; page = browser.page;
await page.loginAndModule(' deliveryBoss', 'client'); await page.loginAndModule('deliveryAssistant', 'client');
}); });
afterAll(async() => { afterAll(async() => {

View File

@ -45,7 +45,7 @@ describe('Worker create path', () => {
// should create a new worker and go to worker basic data' // should create a new worker and go to worker basic data'
await page.pickDate(selectors.workerCreate.birth, new Date(1962, 8, 5)); 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); await page.waitToClick(selectors.workerCreate.createButton);
message = await page.waitForSnackbar(); message = await page.waitForSnackbar();
await page.waitForState('worker.card.basicData'); await page.waitForState('worker.card.basicData');

View File

@ -75,7 +75,7 @@ describe('Ticket Edit basic data path', () => {
const result = await page const result = await page
.waitToGetProperty(selectors.ticketBasicData.stepTwoTotalPriceDif, 'innerText'); .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() => { it(`should select a new reason for the changes made then click on finalize`, async() => {

View File

@ -8,7 +8,9 @@ describe('Zone basic data path', () => {
beforeAll(async() => { beforeAll(async() => {
browser = await getBrowser(); browser = await getBrowser();
page = browser.page; 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.accessToSearchResult('10');
await page.accessToSection('zone.card.basicData'); await page.accessToSection('zone.card.basicData');
}); });

View File

@ -8,7 +8,7 @@ describe('Zone descriptor path', () => {
beforeAll(async() => { beforeAll(async() => {
browser = await getBrowser(); browser = await getBrowser();
page = browser.page; page = browser.page;
await page.loginAndModule('deliveryBoss', 'zone'); await page.loginAndModule('deliveryAssistant', 'zone');
await page.accessToSearchResult('13'); await page.accessToSearchResult('13');
}); });

View File

@ -316,5 +316,6 @@
"The ticket doesn't exist.": "No existe el ticket.", "The ticket doesn't exist.": "No existe el ticket.",
"Social name should be uppercase": "La razón social debe ir en mayúscula", "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", "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" "Ticket without Route": "Ticket sin ruta"
} }

View File

@ -75,7 +75,7 @@ module.exports = Self => {
try { try {
const worker = await models.Worker.findOne({ const worker = await models.Worker.findOne({
where: {userFk: userId} where: {id: userId}
}, myOptions); }, myOptions);
const obsevationType = await models.ObservationType.findOne({ const obsevationType = await models.ObservationType.findOne({

View File

@ -35,7 +35,7 @@ module.exports = Self => {
{ {
relation: 'worker', relation: 'worker',
scope: { scope: {
fields: ['userFk'], fields: ['id'],
include: { include: {
relation: 'user', relation: 'user',
scope: { scope: {
@ -109,7 +109,7 @@ module.exports = Self => {
{ {
relation: 'worker', relation: 'worker',
scope: { scope: {
fields: ['userFk'], fields: ['id'],
include: { include: {
relation: 'user', relation: 'user',
scope: { scope: {

View File

@ -1,7 +1,7 @@
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
const buildFilter = require('vn-loopback/util/filter').buildFilter; 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 => { module.exports = Self => {
Self.remoteMethodCtx('logs', { Self.remoteMethodCtx('logs', {
@ -12,27 +12,27 @@ module.exports = Self => {
arg: 'id', arg: 'id',
type: 'Number', type: 'Number',
description: 'The claim id', description: 'The claim id',
http: { source: 'path' } http: {source: 'path'}
}, },
{ {
arg: 'filter', arg: 'filter',
type: 'object', type: 'object',
http: { source: 'query' } http: {source: 'query'}
}, },
{ {
arg: 'search', arg: 'search',
type: 'string', type: 'string',
http: { source: 'query' } http: {source: 'query'}
}, },
{ {
arg: 'userFk', arg: 'userFk',
type: 'number', type: 'number',
http: { source: 'query' } http: {source: 'query'}
}, },
{ {
arg: 'created', arg: 'created',
type: 'date', type: 'date',
http: { source: 'query' } http: {source: 'query'}
}, },
], ],
returns: { 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 conn = Self.dataSource.connector;
const args = ctx.args; const args = ctx.args;
const myOptions = {}; const myOptions = {};
@ -59,22 +59,22 @@ module.exports = Self => {
case 'search': case 'search':
return { return {
or: [ or: [
{ changedModel: { like: `%${value}%` } }, {changedModel: {like: `%${value}%`}},
{ oldInstance: { like: `%${value}%` } } {oldInstance: {like: `%${value}%`}}
] ]
}; };
case 'userFk': case 'userFk':
return { 'cl.userFk': value }; return {'cl.userFk': value};
case 'created': case 'created':
value.setHours(0, 0, 0, 0); value.setHours(0, 0, 0, 0);
to = new Date(value); to = new Date(value);
to.setHours(23, 59, 59, 999); to.setHours(23, 59, 59, 999);
return { creationDate: { between: [value, to] } }; return {creationDate: {between: [value, to]}};
} }
}); });
where = mergeWhere(where, { ['cl.originFk']: id }); where = mergeWhere(where, {['cl.originFk']: id});
filter = mergeFilters(args.filter, { where }); filter = mergeFilters(args.filter, {where});
const stmts = []; const stmts = [];

View File

@ -8,7 +8,7 @@ class Controller extends ModuleCard {
{ {
relation: 'worker', relation: 'worker',
scope: { scope: {
fields: ['userFk'], fields: ['id'],
include: { include: {
relation: 'user', relation: 'user',
scope: { scope: {

View File

@ -45,7 +45,7 @@
<vn-label-value <vn-label-value
label="Attended by"> label="Attended by">
<span <span
ng-click="workerDescriptor.show($event, $ctrl.claim.worker.userFk)" ng-click="workerDescriptor.show($event, $ctrl.claim.worker.id)"
class="link"> class="link">
{{$ctrl.claim.worker.user.name}} {{$ctrl.claim.worker.user.name}}
</span> </span>

View File

@ -80,10 +80,15 @@ module.exports = Self => {
Object.assign(myOptions, options); Object.assign(myOptions, options);
if (args.zoneFk) { if (args.zoneFk) {
query = `CALL vn.zone_getPostalCode(?)`; let stmts = [];
const [geos] = await Self.rawSql(query, [args.zoneFk]); stmts.push(new ParameterizedSQL('CALL vn.zone_getPostalCode(?)', [args.zoneFk]));
for (let geo of geos) stmts.push(`SELECT name FROM tmp.zoneNodes`);
postalCode.push(geo.name); 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) => { const where = buildFilter(ctx.args, (param, value) => {

View File

@ -60,7 +60,7 @@ module.exports = Self => {
at2.id IS NOT NULL as isCompensation at2.id IS NOT NULL as isCompensation
FROM vn.receipt r FROM vn.receipt r
LEFT JOIN vn.worker w ON w.id = r.workerFk 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 JOIN vn.company c ON c.id = r.companyFk
LEFT JOIN vn.accounting a ON a.id = r.bankFk LEFT JOIN vn.accounting a ON a.id = r.bankFk
LEFT JOIN vn.accountingType at2 ON at2.id = a.accountingTypeFk AND at2.code = 'compensation' LEFT JOIN vn.accountingType at2 ON at2.id = a.accountingTypeFk AND at2.code = 'compensation'

View File

@ -9,7 +9,7 @@ module.exports = function(Self) {
let token = ctx.options.accessToken; let token = ctx.options.accessToken;
let userId = token && token.userId; 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); if (err) return next(err);
ctx.instance.workerFk = user.id; ctx.instance.workerFk = user.id;
next(); next();

View File

@ -41,7 +41,7 @@
"include": { "include": {
"relation": "worker", "relation": "worker",
"scope": { "scope": {
"fields": ["userFk"], "fields": ["id"],
"include": { "include": {
"relation": "user", "relation": "user",
"scope": { "scope": {

View File

@ -68,7 +68,7 @@
icon="add_circle" icon="add_circle"
vn-tooltip="New postcode" vn-tooltip="New postcode"
ng-click="postcode.open()" ng-click="postcode.open()"
vn-acl="deliveryBoss" vn-acl="deliveryAssistant"
vn-acl-action="remove"> vn-acl-action="remove">
</vn-icon-button> </vn-icon-button>
</append> </append>

View File

@ -81,7 +81,7 @@
icon="add_circle" icon="add_circle"
vn-tooltip="New postcode" vn-tooltip="New postcode"
ng-click="postcode.open()" ng-click="postcode.open()"
vn-acl="deliveryBoss" vn-acl="deliveryAssistant"
vn-acl-action="remove"> vn-acl-action="remove">
</vn-icon-button> </vn-icon-button>
</append> </append>

View File

@ -73,7 +73,7 @@
icon="add_circle" icon="add_circle"
vn-tooltip="New postcode" vn-tooltip="New postcode"
ng-click="postcode.open()" ng-click="postcode.open()"
vn-acl="deliveryBoss" vn-acl="deliveryAssistant"
vn-acl-action="remove"> vn-acl-action="remove">
</vn-icon-button> </vn-icon-button>
</append> </append>

View File

@ -9,7 +9,7 @@ export default class Controller extends Section {
include: [{ include: [{
relation: 'worker', relation: 'worker',
scope: { scope: {
fields: ['userFk'], fields: ['id'],
include: { include: {
relation: 'user', relation: 'user',
scope: { scope: {

View File

@ -25,7 +25,7 @@
<vn-td shrink-datetime>{{::credit.created | date:'dd/MM/yyyy HH:mm'}}</vn-td> <vn-td shrink-datetime>{{::credit.created | date:'dd/MM/yyyy HH:mm'}}</vn-td>
<vn-td> <vn-td>
<span <span
ng-click="workerDescriptor.show($event, credit.worker.userFk)" ng-click="workerDescriptor.show($event, credit.worker.id)"
class="link"> class="link">
{{::credit.worker.user.name}} {{::credit.worker.user.name}}
</span> </span>

View File

@ -9,7 +9,7 @@ class Controller extends Section {
{ {
relation: 'worker', relation: 'worker',
scope: { scope: {
fields: ['userFk'], fields: ['id'],
include: { include: {
relation: 'user', relation: 'user',
scope: { scope: {

View File

@ -28,7 +28,7 @@ class Controller extends Section {
}, { }, {
relation: 'worker', relation: 'worker',
scope: { scope: {
fields: ['userFk'], fields: ['id'],
include: { include: {
relation: 'user', relation: 'user',
scope: { scope: {

View File

@ -94,7 +94,7 @@
icon="add_circle" icon="add_circle"
vn-tooltip="New postcode" vn-tooltip="New postcode"
ng-click="postcode.open()" ng-click="postcode.open()"
vn-acl="deliveryBoss" vn-acl="deliveryAssistant"
vn-acl-action="remove"> vn-acl-action="remove">
</vn-icon-button> </vn-icon-button>
</append> </append>

View File

@ -27,7 +27,7 @@
icon="add_circle" icon="add_circle"
vn-tooltip="New city" vn-tooltip="New city"
ng-click="city.open($event)" ng-click="city.open($event)"
vn-acl="deliveryBoss" vn-acl="deliveryAssistant"
vn-acl-action="remove"> vn-acl-action="remove">
</vn-icon-button> </vn-icon-button>
</append> </append>
@ -45,7 +45,7 @@
icon="add_circle" icon="add_circle"
vn-tooltip="New province" vn-tooltip="New province"
ng-click="province.open($event)" ng-click="province.open($event)"
vn-acl="deliveryBoss" vn-acl="deliveryAssistant"
vn-acl-action="remove"> vn-acl-action="remove">
</vn-icon-button> </vn-icon-button>
</append> </append>

View File

@ -180,7 +180,7 @@ module.exports = Self => {
LEFT JOIN itemType it ON it.id = i.typeFk LEFT JOIN itemType it ON it.id = i.typeFk
LEFT JOIN itemCategory ic ON ic.id = it.categoryFk LEFT JOIN itemCategory ic ON ic.id = it.categoryFk
LEFT JOIN worker w ON w.id = it.workerFk 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 intrastat intr ON intr.id = i.intrastatFk
LEFT JOIN producer pr ON pr.id = i.producerFk LEFT JOIN producer pr ON pr.id = i.producerFk
LEFT JOIN origin ori ON ori.id = i.originFk LEFT JOIN origin ori ON ori.id = i.originFk

View File

@ -34,7 +34,7 @@ module.exports = Self => {
include: [{ include: [{
relation: 'worker', relation: 'worker',
scope: { scope: {
fields: ['userFk'], fields: ['id'],
include: { include: {
relation: 'user', relation: 'user',
scope: { scope: {

View File

@ -38,7 +38,7 @@ module.exports = Self => {
include: [{ include: [{
relation: 'worker', relation: 'worker',
scope: { scope: {
fields: ['userFk'], fields: ['id'],
include: { include: {
relation: 'user', relation: 'user',
scope: { scope: {

View File

@ -58,7 +58,7 @@
<vn-label-value <vn-label-value
label="Buyer"> label="Buyer">
<span <span
ng-click="workerDescriptor.show($event, $ctrl.item.itemType.worker.userFk)" ng-click="workerDescriptor.show($event, $ctrl.item.itemType.worker.id)"
class="link"> class="link">
{{$ctrl.item.itemType.worker.user.name}} {{$ctrl.item.itemType.worker.user.name}}
</span> </span>

View File

@ -70,7 +70,7 @@
</vn-label-value> </vn-label-value>
<vn-label-value label="Buyer"> <vn-label-value label="Buyer">
<span <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"> class="link">
{{$ctrl.summary.item.itemType.worker.user.name}} {{$ctrl.summary.item.itemType.worker.user.name}}
</span> </span>

View File

@ -215,7 +215,7 @@ module.exports = Self => {
LEFT JOIN state st ON st.id = ts.stateFk LEFT JOIN state st ON st.id = ts.stateFk
LEFT JOIN client c ON c.id = t.clientFk LEFT JOIN client c ON c.id = t.clientFk
LEFT JOIN worker wk ON wk.id = c.salesPersonFk 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`); LEFT JOIN zoneEstimatedDelivery zed ON zed.zoneFk = t.zoneFk`);
if (args.orderFk) { if (args.orderFk) {

View File

@ -169,7 +169,7 @@ module.exports = Self => {
LEFT JOIN agencyMode am ON am.id = o.agency_id LEFT JOIN agencyMode am ON am.id = o.agency_id
LEFT JOIN client c ON c.id = o.customer_id LEFT JOIN client c ON c.id = o.customer_id
LEFT JOIN worker wk ON wk.id = c.salesPersonFk 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 company co ON co.id = o.company_id
LEFT JOIN orderTicket ot ON ot.orderFk = o.id LEFT JOIN orderTicket ot ON ot.orderFk = o.id
LEFT JOIN ticket t ON t.id = ot.ticketFk LEFT JOIN ticket t ON t.id = ot.ticketFk

View File

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

View File

@ -134,7 +134,7 @@ module.exports = Self => {
LEFT JOIN agencyMode am ON am.id = r.agencyModeFk LEFT JOIN agencyMode am ON am.id = r.agencyModeFk
LEFT JOIN vehicle v ON v.id = r.vehicleFk LEFT JOIN vehicle v ON v.id = r.vehicleFk
LEFT JOIN worker w ON w.id = r.workerFk 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)); stmt.merge(conn.makeSuffix(filter));

View File

@ -22,6 +22,11 @@ module.exports = Self => {
type: 'integer', type: 'integer',
description: 'The worker id', description: 'The worker id',
}, },
{
arg: 'routeFk',
type: 'integer',
description: 'The route id',
},
{ {
arg: 'country', arg: 'country',
type: 'string', type: 'string',
@ -57,6 +62,7 @@ module.exports = Self => {
filter, filter,
cmrFk, cmrFk,
ticketFk, ticketFk,
routeFk,
country, country,
clientFk, clientFk,
hasCmrDms, hasCmrDms,
@ -66,6 +72,7 @@ module.exports = Self => {
const params = { const params = {
cmrFk, cmrFk,
ticketFk, ticketFk,
routeFk,
country, country,
clientFk, clientFk,
hasCmrDms, hasCmrDms,
@ -93,6 +100,7 @@ module.exports = Self => {
FROM ( FROM (
SELECT t.cmrFk, SELECT t.cmrFk,
t.id ticketFk, t.id ticketFk,
t.routeFk,
co.country, co.country,
t.clientFk, t.clientFk,
IF(sub.id, TRUE, FALSE) hasCmrDms, IF(sub.id, TRUE, FALSE) hasCmrDms,

View File

@ -33,7 +33,7 @@ module.exports = Self => {
}, { }, {
relation: 'worker', relation: 'worker',
scope: { scope: {
fields: ['id', 'userFk'], fields: ['id'],
include: [ include: [
{ {
relation: 'user', relation: 'user',

View File

@ -47,7 +47,7 @@
"worker": { "worker": {
"type": "belongsTo", "type": "belongsTo",
"model": "Worker", "model": "Worker",
"foreignKey": "userFk" "foreignKey": "id"
}, },
"supplier": { "supplier": {
"type": "belongsTo", "type": "belongsTo",

View File

@ -16,6 +16,7 @@ module.exports = Self => {
require('../methods/route/downloadZip')(Self); require('../methods/route/downloadZip')(Self);
require('../methods/route/cmr')(Self); require('../methods/route/cmr')(Self);
require('../methods/route/getExternalCmrs')(Self); require('../methods/route/getExternalCmrs')(Self);
require('../methods/route/downloadCmrsZip')(Self);
Self.validate('kmStart', validateDistance, { Self.validate('kmStart', validateDistance, {
message: 'Distance must be lesser than 1000' message: 'Distance must be lesser than 1000'

View File

@ -41,7 +41,7 @@ class Controller extends ModuleCard {
{ {
relation: 'worker', relation: 'worker',
scope: { scope: {
fields: ['userFk'], fields: ['id'],
include: { include: {
relation: 'user', relation: 'user',
scope: { scope: {

View File

@ -15,14 +15,14 @@
</vn-item> </vn-item>
<vn-item <vn-item
ng-click="updateVolumeConfirmation.show()" ng-click="updateVolumeConfirmation.show()"
vn-acl="deliveryBoss" vn-acl="deliveryAssistant"
vn-acl-action="remove" vn-acl-action="remove"
translate> translate>
Update volume Update volume
</vn-item> </vn-item>
<vn-item <vn-item
ng-click="$ctrl.deleteCurrentRoute()" ng-click="$ctrl.deleteCurrentRoute()"
vn-acl="deliveryBoss" vn-acl="deliveryAssistant"
vn-acl-action="remove" vn-acl-action="remove"
translate> translate>
Delete route Delete route

View File

@ -79,7 +79,7 @@ class Controller extends Descriptor {
}, { }, {
relation: 'worker', relation: 'worker',
scope: { scope: {
fields: ['userFk'], fields: ['id'],
include: { include: {
relation: 'user', relation: 'user',
scope: { scope: {

View File

@ -37,7 +37,7 @@
icon="format_list_numbered"> icon="format_list_numbered">
</vn-button> </vn-button>
<vn-button <vn-button
vn-acl="deliveryBoss" vn-acl="deliveryAssistant"
vn-acl-action="remove" vn-acl-action="remove"
disabled="!$ctrl.isChecked" disabled="!$ctrl.isChecked"
icon="sms" icon="sms"

View File

@ -35,7 +35,7 @@ module.exports = Self => {
{ {
relation: 'worker', relation: 'worker',
scope: { scope: {
fields: ['id', 'userFk'], fields: ['id'],
include: { include: {
relation: 'user', relation: 'user',
scope: { scope: {

View File

@ -41,7 +41,7 @@
"worker": { "worker": {
"type": "belongsTo", "type": "belongsTo",
"model": "Worker", "model": "Worker",
"foreignKey": "userFk" "foreignKey": "id"
} }
} }
} }

View File

@ -7,7 +7,7 @@ class Controller extends ModuleCard {
include: [ include: [
{relation: 'worker', {relation: 'worker',
scope: { scope: {
fields: ['userFk'], fields: ['id'],
include: { include: {
relation: 'user', relation: 'user',
scope: { scope: {

View File

@ -12,7 +12,7 @@ class Controller extends Summary {
include: [ include: [
{relation: 'worker', {relation: 'worker',
scope: { scope: {
fields: ['userFk'], fields: ['id'],
include: { include: {
relation: 'user', relation: 'user',
scope: { scope: {

View File

@ -91,7 +91,7 @@ module.exports = Self => {
{ {
relation: 'worker', relation: 'worker',
scope: { scope: {
fields: ['userFk'], fields: ['id'],
include: { include: {
relation: 'user', relation: 'user',
scope: { scope: {

View File

@ -50,7 +50,7 @@
icon="add_circle" icon="add_circle"
vn-tooltip="New postcode" vn-tooltip="New postcode"
ng-click="postcode.open()" ng-click="postcode.open()"
vn-acl="deliveryBoss" vn-acl="deliveryAssistant"
vn-acl-action="remove"> vn-acl-action="remove">
</vn-icon-button> </vn-icon-button>
</append> </append>

View File

@ -48,7 +48,7 @@
icon="add_circle" icon="add_circle"
vn-tooltip="New postcode" vn-tooltip="New postcode"
ng-click="postcode.open()" ng-click="postcode.open()"
vn-acl="deliveryBoss" vn-acl="deliveryAssistant"
vn-acl-action="remove"> vn-acl-action="remove">
</vn-icon-button> </vn-icon-button>
</append> </append>

View File

@ -150,7 +150,7 @@
icon="add_circle" icon="add_circle"
vn-tooltip="New postcode" vn-tooltip="New postcode"
ng-click="postcode.open()" ng-click="postcode.open()"
vn-acl="deliveryBoss" vn-acl="deliveryAssistant"
vn-acl-action="remove"> vn-acl-action="remove">
</vn-icon-button> </vn-icon-button>
</append> </append>

View File

@ -41,7 +41,7 @@ module.exports = Self => {
FROM saleTracking st FROM saleTracking st
JOIN sale s ON s.id = st.saleFk JOIN sale s ON s.id = st.saleFk
JOIN worker w ON w.id = st.workerFk 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`); JOIN state ste ON ste.id = st.stateFk`);
stmt.merge(Self.makeSuffix(filter)); stmt.merge(Self.makeSuffix(filter));

View File

@ -108,7 +108,7 @@ describe('sale updatePrice()', () => {
}}, options); }}, options);
expect(updatedSale.price).toBe(price); 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); const updatedSalesPersonMana = await models.WorkerMana.findById(18, null, options);

View File

@ -39,7 +39,7 @@ module.exports = Self => {
try { try {
const userId = ctx.req.accessToken.userId; 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 = { const params = {
isOk: false, isOk: false,

View File

@ -153,9 +153,9 @@ module.exports = Self => {
LEFT JOIN item i ON i.id = tr.itemFk LEFT JOIN item i ON i.id = tr.itemFk
LEFT JOIN sale s ON s.id = tr.saleFk LEFT JOIN sale s ON s.id = tr.saleFk
LEFT JOIN worker wk ON wk.id = c.salesPersonFk 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 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)); stmt.merge(conn.makeSuffix(filter));
return conn.executeStmt(stmt, myOptions); return conn.executeStmt(stmt, myOptions);

View File

@ -53,7 +53,7 @@ module.exports = Self => {
if (!params.workerFk) { if (!params.workerFk) {
const worker = await models.Worker.findOne({ const worker = await models.Worker.findOne({
where: {userFk: userId} where: {id: userId}
}, myOptions); }, myOptions);
params.workerFk = worker.id; params.workerFk = worker.id;

View File

@ -43,7 +43,7 @@ module.exports = Self => {
fields: ['id', 'name', 'alertLevel', 'code'] fields: ['id', 'name', 'alertLevel', 'code']
}, myOptions); }, myOptions);
const worker = await models.Worker.findOne({where: {userFk: userId}}, myOptions); const worker = await models.Worker.findOne({where: {id: userId}}, myOptions);
const promises = []; const promises = [];
for (const id of ticketIds) { for (const id of ticketIds) {

View File

@ -272,7 +272,7 @@ module.exports = Self => {
LEFT JOIN state st ON st.id = ts.stateFk LEFT JOIN state st ON st.id = ts.stateFk
LEFT JOIN client c ON c.id = t.clientFk LEFT JOIN client c ON c.id = t.clientFk
LEFT JOIN worker wk ON wk.id = c.salesPersonFk 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`); LEFT JOIN route r ON r.id = t.routeFk`);
if (args.orderFk) { if (args.orderFk) {

View File

@ -10,7 +10,7 @@ module.exports = function(Self) {
Self.observe('before save', async function(ctx) { Self.observe('before save', async function(ctx) {
if (ctx.isNewInstance) { if (ctx.isNewInstance) {
const loopBackContext = LoopBackContext.getCurrentContext(); 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 models = Self.app.models;
const worker = await models.Worker.findOne(filter); const worker = await models.Worker.findOne(filter);

View File

@ -29,7 +29,7 @@ class Controller extends Section {
{ {
relation: 'worker', relation: 'worker',
scope: { scope: {
fields: ['userFk'], fields: ['id'],
include: { include: {
relation: 'user', relation: 'user',
scope: { scope: {

View File

@ -9,7 +9,7 @@ class Controller extends Section {
{ {
relation: 'worker', relation: 'worker',
scope: { scope: {
fields: ['userFk'], fields: ['id'],
include: { include: {
relation: 'user', relation: 'user',
scope: { scope: {

View File

@ -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 businessId = 1106;
const workerId = 1106; const workerId = 1106;

View File

@ -102,7 +102,7 @@ module.exports = Self => {
stmt = new ParameterizedSQL('DROP TEMPORARY TABLE IF EXISTS tmp.`user`'); stmt = new ParameterizedSQL('DROP TEMPORARY TABLE IF EXISTS tmp.`user`');
stmts.push(stmt); 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); stmts.push(stmt);
} }

View File

@ -23,7 +23,7 @@ module.exports = Self => {
const query = const query =
`SELECT DISTINCT w.id, w.firstName, w.lastName, u.name, u.nickname `SELECT DISTINCT w.id, w.firstName, w.lastName, u.name, u.nickname
FROM worker w 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.roleRole i ON i.role = u.role
JOIN account.role r ON r.id = i.inheritsFrom`; JOIN account.role r ON r.id = i.inheritsFrom`;

View File

@ -95,8 +95,6 @@ module.exports = Self => {
]}; ]};
case 'id': case 'id':
return {'w.id': value}; return {'w.id': value};
case 'userFk':
return {'w.userFk': value};
case 'firstName': case 'firstName':
return {'w.firstName': {like: `%${value}%`}}; return {'w.firstName': {like: `%${value}%`}};
case 'lastName': case 'lastName':
@ -123,8 +121,8 @@ module.exports = Self => {
FROM worker w FROM worker w
LEFT JOIN workerDepartment wd ON wd.workerFk = w.id LEFT JOIN workerDepartment wd ON wd.workerFk = w.id
LEFT JOIN department d ON d.id = wd.departmentFk LEFT JOIN department d ON d.id = wd.departmentFk
LEFT JOIN client c ON c.id = w.userFk LEFT JOIN client c ON c.id = w.id
LEFT JOIN account.user u ON u.id = w.userFk LEFT JOIN account.user u ON u.id = w.id
LEFT JOIN pbx.sip p ON p.user_id = u.id LEFT JOIN pbx.sip p ON p.user_id = u.id
LEFT JOIN account.emailUser mu ON mu.userFk = u.id` LEFT JOIN account.emailUser mu ON mu.userFk = u.id`
); );

View File

@ -38,7 +38,7 @@ module.exports = Self => {
const conn = Self.dataSource.connector; const conn = Self.dataSource.connector;
const worker = await models.Worker.findById(id); const worker = await models.Worker.findById(id);
const userId = worker.userFk; const userId = worker.id;
const stmts = []; const stmts = [];

View File

@ -28,6 +28,9 @@
}, },
"deviceProductionFk": { "deviceProductionFk": {
"type": "number" "type": "number"
},
"serialNumber": {
"type": "string"
} }
}, },
"relations": { "relations": {

View File

@ -36,7 +36,7 @@
"worker": { "worker": {
"type": "hasOne", "type": "hasOne",
"model": "Worker", "model": "Worker",
"foreignKey": "userFk" "foreignKey": "id"
}, },
"warehouse": { "warehouse": {
"type": "belongsTo", "type": "belongsTo",

View File

@ -24,9 +24,6 @@
"phone": { "phone": {
"type" : "string" "type" : "string"
}, },
"userFk": {
"type" : "number"
},
"bossFk": { "bossFk": {
"type" : "number" "type" : "number"
}, },
@ -66,12 +63,12 @@
"client": { "client": {
"type": "belongsTo", "type": "belongsTo",
"model": "Client", "model": "Client",
"foreignKey": "userFk" "foreignKey": "id"
}, },
"sip": { "sip": {
"type": "belongsTo", "type": "belongsTo",
"model": "Sip", "model": "Sip",
"foreignKey": "userFk" "foreignKey": "id"
}, },
"department": { "department": {
"type": "belongsTo", "type": "belongsTo",

View File

@ -72,7 +72,7 @@
icon="add_circle" icon="add_circle"
vn-tooltip="New postcode" vn-tooltip="New postcode"
ng-click="postcode.open()" ng-click="postcode.open()"
vn-acl="deliveryBoss" vn-acl="deliveryAssistant"
vn-acl-action="remove"> vn-acl-action="remove">
</vn-icon-button> </vn-icon-button>
</append> </append>

View File

@ -18,7 +18,7 @@
<vn-textfield <vn-textfield
vn-one vn-one
label="User id" label="User id"
ng-model="filter.userFk"> ng-model="filter.id">
</vn-textfield> </vn-textfield>
</vn-horizontal> </vn-horizontal>
<vn-horizontal> <vn-horizontal>

View File

@ -58,7 +58,7 @@
<vn-one> <vn-one>
<h4 translate>User data</h4> <h4 translate>User data</h4>
<vn-label-value label="User id" <vn-label-value label="User id"
value="{{worker.userFk}}"> value="{{worker.id}}">
</vn-label-value> </vn-label-value>
<vn-label-value label="User" <vn-label-value label="User"
value="{{worker.user.name}}"> value="{{worker.user.name}}">

View File

@ -54,7 +54,7 @@ module.exports = Self => {
const ticketList = await models.Ticket.find(filter, myOptions); const ticketList = await models.Ticket.find(filter, myOptions);
const fixingState = await models.State.findOne({where: {code: 'FIXING'}}, myOptions); const fixingState = await models.State.findOne({where: {code: 'FIXING'}}, myOptions);
const worker = await models.Worker.findOne({ const worker = await models.Worker.findOne({
where: {userFk: userId} where: {id: userId}
}, myOptions); }, myOptions);
await models.Ticket.rawSql('UPDATE ticket SET zoneFk = NULL WHERE zoneFk = ?', [id], myOptions); await models.Ticket.rawSql('UPDATE ticket SET zoneFk = NULL WHERE zoneFk = ?', [id], myOptions);

View File

@ -14,7 +14,7 @@
<vn-textfield <vn-textfield
label="Name" label="Name"
ng-model="$ctrl.zone.name" ng-model="$ctrl.zone.name"
vn-acl="deliveryBoss" vn-acl="deliveryAssistant"
rule> rule>
</vn-textfield> </vn-textfield>
</vn-horizontal> </vn-horizontal>
@ -26,7 +26,7 @@
show-field="name" show-field="name"
value-field="id" value-field="id"
label="Agency" label="Agency"
vn-acl="deliveryBoss" vn-acl="deliveryAssistant"
rule> rule>
</vn-autocomplete> </vn-autocomplete>
<vn-input-number <vn-input-number
@ -34,7 +34,7 @@
label="Max m³" label="Max m³"
ng-model="$ctrl.zone.itemMaxSize" ng-model="$ctrl.zone.itemMaxSize"
min="0" min="0"
vn-acl="deliveryBoss" vn-acl="deliveryAssistant"
rule> rule>
</vn-input-number> </vn-input-number>
<vn-input-number <vn-input-number
@ -42,7 +42,7 @@
label="Maximum m³" label="Maximum m³"
ng-model="$ctrl.zone.m3Max" ng-model="$ctrl.zone.m3Max"
min="0" min="0"
vn-acl="deliveryBoss" vn-acl="deliveryAssistant"
rule> rule>
</vn-input-number> </vn-input-number>
</vn-horizontal> </vn-horizontal>
@ -52,13 +52,13 @@
ng-model="$ctrl.zone.travelingDays" ng-model="$ctrl.zone.travelingDays"
min="0" min="0"
step="1" step="1"
vn-acl="deliveryBoss" vn-acl="deliveryAssistant"
rule> rule>
</vn-input-number> </vn-input-number>
<vn-input-time <vn-input-time
label="Closing" label="Closing"
ng-model="$ctrl.zone.hour" ng-model="$ctrl.zone.hour"
vn-acl="deliveryBoss" vn-acl="deliveryAssistant"
rule> rule>
</vn-input-time> </vn-input-time>
</vn-horizontal> </vn-horizontal>
@ -68,14 +68,14 @@
ng-model="$ctrl.zone.price" ng-model="$ctrl.zone.price"
min="0" min="0"
step="0.01" step="0.01"
vn-acl="deliveryBoss" vn-acl="deliveryAssistant"
rule> rule>
</vn-input-number> </vn-input-number>
<vn-input-number <vn-input-number
label="Bonus" label="Bonus"
ng-model="$ctrl.zone.bonus" ng-model="$ctrl.zone.bonus"
step="0.01" step="0.01"
vn-acl="deliveryBoss" vn-acl="deliveryAssistant"
rule> rule>
</vn-input-number> </vn-input-number>
</vn-horizontal> </vn-horizontal>
@ -86,14 +86,14 @@
ng-model="$ctrl.zone.inflation" ng-model="$ctrl.zone.inflation"
min="0" min="0"
step="0.01" step="0.01"
vn-acl="deliveryBoss" vn-acl="deliveryAssistant"
rule> rule>
</vn-input-number> </vn-input-number>
<vn-check <vn-check
vn-one vn-one
label="Volumetric" label="Volumetric"
ng-model="$ctrl.zone.isVolumetric" ng-model="$ctrl.zone.isVolumetric"
vn-acl="deliveryBoss" vn-acl="deliveryAssistant"
rule> rule>
</vn-check> </vn-check>
</vn-horizontal> </vn-horizontal>
@ -101,7 +101,7 @@
<vn-button-bar> <vn-button-bar>
<vn-submit <vn-submit
disabled="!watcher.dataChanged()" disabled="!watcher.dataChanged()"
vn-acl="deliveryBoss" vn-acl="deliveryAssistant"
label="Save"> label="Save">
</vn-submit> </vn-submit>
<vn-button <vn-button

View File

@ -32,7 +32,7 @@
vn-click-stop="clone.show(zone)" vn-click-stop="clone.show(zone)"
vn-tooltip="Clone" vn-tooltip="Clone"
icon="icon-clone" icon="icon-clone"
vn-acl="deliveryBoss" vn-acl="deliveryAssistant"
vn-acl-action="remove"> vn-acl-action="remove">
</vn-icon-button> </vn-icon-button>
<vn-icon-button <vn-icon-button
@ -62,7 +62,7 @@
fixed-bottom-right> fixed-bottom-right>
<vn-float-button <vn-float-button
icon="add" icon="add"
vn-acl="deliveryBoss" vn-acl="deliveryAssistant"
vn-acl-action="remove"> vn-acl-action="remove">
</vn-float-button> </vn-float-button>
</a> </a>

View File

@ -16,7 +16,7 @@
root-label="Locations" root-label="Locations"
fetch-func="$ctrl.onFetch($item)" fetch-func="$ctrl.onFetch($item)"
sort-func="$ctrl.onSort($a, $b)"> sort-func="$ctrl.onSort($a, $b)">
<vn-check acl-role="deliveryBoss" <vn-check acl-role="deliveryAssistant"
ng-model="item.selected" ng-model="item.selected"
on-change="$ctrl.onSelection(value, item)" on-change="$ctrl.onSelection(value, item)"
triple-state="true" triple-state="true"

View File

@ -7,5 +7,5 @@ SELECT
FROM client c FROM client c
JOIN account.user u ON u.id = c.id JOIN account.user u ON u.id = c.id
LEFT JOIN worker w ON w.id = c.salesPersonFk 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 = ? WHERE c.id = ?

View File

@ -8,5 +8,5 @@ SELECT
FROM client c FROM client c
JOIN account.user u ON u.id = c.id JOIN account.user u ON u.id = c.id
LEFT JOIN worker w ON w.id = c.salesPersonFk 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 = ? WHERE c.id = ?

View File

@ -11,7 +11,7 @@ SELECT
FROM route r FROM route r
LEFT JOIN vehicle v ON v.id = r.vehicleFk LEFT JOIN vehicle v ON v.id = r.vehicleFk
LEFT JOIN worker w ON w.id = r.workerFk 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 agencyMode am ON am.id = r.agencyModeFk
LEFT JOIN agency a ON a.id = am.agencyFk LEFT JOIN agency a ON a.id = am.agencyFk
LEFT JOIN supplierAgencyTerm sa ON sa.agencyFk = a.id LEFT JOIN supplierAgencyTerm sa ON sa.agencyFk = a.id