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

View File

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

View File

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

View File

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

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', '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'),

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'),
(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);

File diff suppressed because it is too large Load Diff

View File

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

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

View File

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

View File

@ -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() => {

View File

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

View File

@ -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() => {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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 = {};
@ -56,25 +56,25 @@ module.exports = Self => {
let where = buildFilter(args, (param, value) => {
switch (param) {
case 'search':
return {
or: [
{ changedModel: { like: `%${value}%` } },
{ oldInstance: { like: `%${value}%` } }
]
};
case 'userFk':
return { 'cl.userFk': value };
case 'created':
value.setHours(0, 0, 0, 0);
to = new Date(value);
to.setHours(23, 59, 59, 999);
case 'search':
return {
or: [
{changedModel: {like: `%${value}%`}},
{oldInstance: {like: `%${value}%`}}
]
};
case 'userFk':
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 = [];

View File

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

View File

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

View File

@ -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) => {

View File

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

View File

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

View File

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

View File

@ -31,7 +31,7 @@
<vn-check
vn-one
label="Default" ng-model="$ctrl.address.isDefaultAddress">
</vn-check>
</vn-check>
</vn-horizontal>
<vn-horizontal>
<vn-textfield
@ -60,7 +60,7 @@
show-field="code"
rule>
<tpl-item>
{{code}} - {{town.name}} ({{town.province.name}},
{{code}} - {{town.name}} ({{town.province.name}},
{{town.province.country.country}})
</tpl-item>
<append>
@ -68,12 +68,12 @@
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>
</vn-datalist>
<vn-datalist vn-id="town" vn-one
<vn-datalist vn-id="town" vn-one
label="City"
ng-model="$ctrl.address.city"
selection="$ctrl.town"
@ -158,7 +158,7 @@
</vn-geo-postcode>
<!-- Create custom agent dialog -->
<vn-dialog class="edit"
<vn-dialog class="edit"
vn-id="customAgent"
on-accept="$ctrl.onCustomAgentAccept()"
message="New customs agent">
@ -190,4 +190,4 @@
<input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/>
<button response="accept" translate>Create</button>
</tpl-buttons>
</vn-dialog>
</vn-dialog>

View File

@ -73,20 +73,20 @@
show-field="code"
rule>
<tpl-item>
{{code}} - {{town.name}} ({{town.province.name}},
{{code}} - {{town.name}} ({{town.province.name}},
{{town.province.country.country}})
</tpl-item>
<append>
<vn-icon-button
<vn-icon-button
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>
</vn-datalist>
<vn-datalist vn-id="town" vn-one
<vn-datalist vn-id="town" vn-one
label="City"
ng-model="$ctrl.address.city"
selection="$ctrl.town"
@ -178,14 +178,14 @@
icon="delete"
ng-click="$ctrl.removeObservation($index)"
tabindex="-1">
</vn-icon-button>
</vn-icon-button>
</vn-none>
</vn-horizontal>
<vn-icon-button
vn-bind="+"
vn-tooltip="Add note"
icon="add_circle"
ng-if="types.length > observations.length"
ng-if="types.length > observations.length"
ng-click="model.insert()">
</vn-icon-button>
</div>
@ -197,12 +197,12 @@
</form>
<!-- New postcode dialog -->
<vn-geo-postcode vn-id="postcode"
<vn-geo-postcode vn-id="postcode"
on-response="$ctrl.onResponse($response)">
</vn-geo-postcode>
<!-- Create custom agent dialog -->
<vn-dialog class="edit"
<vn-dialog class="edit"
vn-id="customAgent"
on-accept="$ctrl.onCustomAgentAccept()"
message="New customs agent">
@ -234,4 +234,4 @@
<input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/>
<button response="accept" translate>Create</button>
</tpl-buttons>
</vn-dialog>
</vn-dialog>

View File

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

View File

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

View File

@ -24,8 +24,8 @@
<vn-tr ng-repeat="credit in credits track by credit.id">
<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)"
<span
ng-click="workerDescriptor.show($event, credit.worker.id)"
class="link">
{{::credit.worker.user.name}}
</span>
@ -41,10 +41,10 @@
ui-sref="client.card.credit.create"
vn-acl="teamBoss"
vn-acl-action="remove"
vn-tooltip="New credit"
vn-tooltip="New credit"
vn-bind="+"
fixed-bottom-right>
</vn-float-button>
<vn-worker-descriptor-popover
<vn-worker-descriptor-popover
vn-id="workerDescriptor">
</vn-worker-descriptor-popover>
</vn-worker-descriptor-popover>

View File

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

View File

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

View File

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

View File

@ -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>
@ -73,4 +73,4 @@
<vn-geo-city
vn-id="city"
on-response="$ctrl.onCityResponse($response)">
</vn-geo-city>
</vn-geo-city>

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
<vn-crud-model
auto-load="true"
url="Warehouses"
auto-load="true"
url="Warehouses"
data="warehouses">
</vn-crud-model>
<vn-descriptor-content
@ -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>

View File

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

View File

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

View File

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

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

@ -111,7 +111,7 @@ module.exports = Self => {
let stmt;
stmt = new ParameterizedSQL(
`SELECT
`SELECT
r.id,
r.workerFk,
r.created,
@ -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));

View File

@ -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,
@ -89,37 +96,38 @@ module.exports = Self => {
let stmts = [];
const stmt = new ParameterizedSQL(`
SELECT *
FROM (
SELECT t.cmrFk,
t.id ticketFk,
co.country,
t.clientFk,
IF(sub.id, TRUE, FALSE) hasCmrDms,
DATE(t.shipped) shipped
FROM ticket t
JOIN ticketState ts ON ts.ticketFk = t.id
JOIN state s ON s.id = ts.stateFk
JOIN alertLevel al ON al.id = s.alertLevel
JOIN client c ON c.id = t.clientFk
JOIN address a ON a.id = t.addressFk
JOIN province p ON p.id = a.provinceFk
JOIN country co ON co.id = p.countryFk
JOIN agencyMode am ON am.id = t.agencyModeFk
JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk
JOIN warehouse w ON w.id = t.warehouseFk
LEFT JOIN (
SELECT td.ticketFk, d.id
FROM ticketDms td
JOIN dms d ON d.id = td.dmsFk
JOIN dmsType dt ON dt.id = d.dmsTypeFk
WHERE dt.name = 'cmr'
) sub ON sub.ticketFk = t.id
WHERE co.code <> 'ES'
AND am.name <> 'ABONO'
AND w.code = 'ALG'
AND dm.code = 'DELIVERY'
AND t.cmrFk
SELECT *
FROM (
SELECT t.cmrFk,
t.id ticketFk,
t.routeFk,
co.country,
t.clientFk,
IF(sub.id, TRUE, FALSE) hasCmrDms,
DATE(t.shipped) shipped
FROM ticket t
JOIN ticketState ts ON ts.ticketFk = t.id
JOIN state s ON s.id = ts.stateFk
JOIN alertLevel al ON al.id = s.alertLevel
JOIN client c ON c.id = t.clientFk
JOIN address a ON a.id = t.addressFk
JOIN province p ON p.id = a.provinceFk
JOIN country co ON co.id = p.countryFk
JOIN agencyMode am ON am.id = t.agencyModeFk
JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk
JOIN warehouse w ON w.id = t.warehouseFk
LEFT JOIN (
SELECT td.ticketFk, d.id
FROM ticketDms td
JOIN dms d ON d.id = td.dmsFk
JOIN dmsType dt ON dt.id = d.dmsTypeFk
WHERE dt.name = 'cmr'
) sub ON sub.ticketFk = t.id
WHERE co.code <> 'ES'
AND am.name <> 'ABONO'
AND w.code = 'ALG'
AND dm.code = 'DELIVERY'
AND t.cmrFk
) sub
`);

View File

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

View File

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

View File

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

View File

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

View File

@ -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
@ -31,23 +31,23 @@
<slot-body>
<div class="attributes">
<vn-label-value
label="Date"
label="Date"
value="{{$ctrl.route.created | date: 'dd/MM/yyyy'}}">
</vn-label-value>
<vn-label-value
label="Agency"
label="Agency"
value="{{$ctrl.route.agencyMode.name}}">
</vn-label-value>
<vn-label-value
label="Zone"
label="Zone"
value="{{$ctrl.route.zone.name}}">
</vn-label-value>
<vn-label-value
label="Volume"
label="Volume"
value="{{$ctrl.route.m3 | dashIfEmpty}} / {{$ctrl.route.vehicle.m3 | dashIfEmpty}} m³">
</vn-label-value>
<vn-label-value
label="Description"
label="Description"
value="{{$ctrl.route.description}}">
</vn-label-value>
</div>
@ -72,4 +72,4 @@
</vn-confirm>
<vn-popup vn-id="summary">
<vn-route-summary route="$ctrl.route"></vn-route-summary>
</vn-popup>
</vn-popup>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -42,7 +42,7 @@
show-field="code"
rule>
<tpl-item>
{{code}} - {{town.name}} ({{town.province.name}},
{{code}} - {{town.name}} ({{town.province.name}},
{{town.province.country.country}})
</tpl-item>
<append>
@ -50,12 +50,12 @@
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>
</vn-datalist>
<vn-datalist vn-id="town" vn-one
<vn-datalist vn-id="town" vn-one
label="City"
ng-model="$ctrl.address.city"
selection="$ctrl.town"
@ -106,4 +106,4 @@
<!-- New postcode dialog -->
<vn-geo-postcode vn-id="postcode"
on-response="$ctrl.onResponse($response)">
</vn-geo-postcode>
</vn-geo-postcode>

View File

@ -40,20 +40,20 @@
show-field="code"
rule>
<tpl-item>
{{code}} - {{town.name}} ({{town.province.name}},
{{code}} - {{town.name}} ({{town.province.name}},
{{town.province.country.country}})
</tpl-item>
<append>
<vn-icon-button
<vn-icon-button
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>
</vn-datalist>
<vn-datalist vn-id="town" vn-one
<vn-datalist vn-id="town" vn-one
label="City"
ng-model="$ctrl.address.city"
selection="$ctrl.town"
@ -99,6 +99,6 @@
</form>
<!-- New postcode dialog -->
<vn-geo-postcode vn-id="postcode"
<vn-geo-postcode vn-id="postcode"
on-response="$ctrl.onResponse($response)">
</vn-geo-postcode>
</vn-geo-postcode>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -9,7 +9,7 @@ class Controller extends Section {
{
relation: 'worker',
scope: {
fields: ['userFk'],
fields: ['id'],
include: {
relation: 'user',
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 workerId = 1106;

View File

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

View File

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

View File

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

View File

@ -38,12 +38,12 @@ 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 = [];
stmts.push(`
DROP TEMPORARY TABLE IF EXISTS
DROP TEMPORARY TABLE IF EXISTS
tmp.timeControlCalculate,
tmp.timeBusinessCalculate
`);
@ -54,7 +54,7 @@ module.exports = Self => {
const resultIndex = stmts.push(new ParameterizedSQL(`
SELECT tcc.dated, tbc.timeWorkSeconds expectedHours, tcc.timeWorkSeconds workedHours
FROM tmp.timeControlCalculate tcc
FROM tmp.timeControlCalculate tcc
LEFT JOIN tmp.timeBusinessCalculate tbc ON tcc.dated = tbc.dated
WHERE tcc.dated BETWEEN DATE(?) AND DATE(?)
`, [started, ended])) - 1;

View File

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

View File

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

View File

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

View File

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

View File

@ -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>
@ -64,4 +64,4 @@
<vn-submit label="Search"></vn-submit>
</vn-horizontal>
</form>
</div>
</div>

View File

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

View File

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

View File

@ -12,9 +12,9 @@
<vn-card class="vn-pa-lg">
<vn-horizontal>
<vn-textfield
label="Name"
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,16 +68,16 @@
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-input-number>
</vn-horizontal>
<vn-horizontal>
<vn-input-number
@ -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

View File

@ -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
@ -50,7 +50,7 @@
<vn-popup vn-id="summary">
<vn-zone-summary zone="$ctrl.selectedZone"></vn-zone-summary>
</vn-popup>
<vn-confirm
<vn-confirm
vn-id="clone"
on-accept="$ctrl.onCloneAccept($data)"
question="Do you want to clone this zone?"
@ -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>

View File

@ -16,12 +16,12 @@
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)"
on-change="$ctrl.onSelection(value, item)"
triple-state="true"
ng-click="$event.preventDefault()"
label="{{::item.name}}">
label="{{::item.name}}">
</vn-check>
</vn-treeview>
</vn-card>

View File

@ -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
WHERE c.id = ?
LEFT JOIN account.user wu ON wu.id = w.id
WHERE c.id = ?

View File

@ -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
WHERE c.id = ?
LEFT JOIN account.user wu ON wu.id = w.id
WHERE c.id = ?

View File

@ -1,4 +1,4 @@
SELECT
SELECT
r.id,
r.m3,
r.created,
@ -11,9 +11,9 @@ 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
LEFT JOIN supplier s ON s.id = sa.supplierFk
WHERE r.id IN(?)
WHERE r.id IN(?)