7167-testToMaster_2414 #2244
|
@ -2,21 +2,23 @@ DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`workerTimeControl_clockIn`(
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`workerTimeControl_clockIn`(
|
||||||
vWorkerFk INT,
|
vWorkerFk INT,
|
||||||
vTimed DATETIME,
|
vTimed DATETIME,
|
||||||
vDirection VARCHAR(10)
|
vDirection VARCHAR(10),
|
||||||
|
vDevice VARCHAR(255)
|
||||||
)
|
)
|
||||||
BEGIN
|
BEGIN
|
||||||
/**
|
/**
|
||||||
* Verifica si el empleado puede fichar
|
* Verifica si el empleado puede fichar
|
||||||
* @param vWorkerFk Identificador del trabajador
|
* @param vWorkerFk Identificador del trabajador
|
||||||
* @param vTimed valor de la fichada, IF vTimed IS NULL vTimed = NOW
|
* @param vTimed Balor de la fichada, IF vTimed IS NULL vTimed = NOW
|
||||||
* @param vDirection solo se pueden pasa los valores del campo
|
* @param vDirection Solo se pueden pasa los valores del campo
|
||||||
* workerTimeControl.direction ENUM('in', 'out', 'middle')
|
* workerTimeControl.direction ENUM('in', 'out', 'middle')
|
||||||
* @return Si todo es correcto, retorna el número de id la tabla workerTimeControl.
|
* @param vDevice Dispositivo en el que se ha fichado
|
||||||
* Si hay algún problema, devuelve el mesaje que se debe mostrar al usuario
|
* @return Si todo es correcto, retorna el número de id la tabla workerTimeControl.
|
||||||
* Solo retorna el primer problema, en caso de no ocurrir ningún error se añadirá
|
* Si hay algún problema, devuelve el mesaje que se debe mostrar al usuario
|
||||||
* fichada a la tabla vn.workerTimeControl
|
* Solo retorna el primer problema, en caso de no ocurrir ningún error se añadirá
|
||||||
*/
|
* fichada a la tabla vn.workerTimeControl
|
||||||
|
*/
|
||||||
|
|
||||||
DECLARE vLastIn DATETIME;
|
DECLARE vLastIn DATETIME;
|
||||||
DECLARE vLastOut DATETIME;
|
DECLARE vLastOut DATETIME;
|
||||||
DECLARE vNextIn DATETIME;
|
DECLARE vNextIn DATETIME;
|
||||||
|
@ -269,16 +271,16 @@ BEGIN
|
||||||
GROUP BY breakCounter
|
GROUP BY breakCounter
|
||||||
HAVING hasError
|
HAVING hasError
|
||||||
LIMIT 1;
|
LIMIT 1;
|
||||||
|
|
||||||
IF vIsError THEN
|
IF vIsError THEN
|
||||||
SET vErrorCode = 'BREAK_WEEK';
|
SET vErrorCode = 'BREAK_WEEK';
|
||||||
CALL util.throw(vErrorCode);
|
CALL util.throw(vErrorCode);
|
||||||
END IF;
|
END IF;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
-- SE PERMITE FICHAR
|
-- Se permite fichar
|
||||||
INSERT INTO workerTimeControl(userFk, timed, direction, `manual`)
|
INSERT INTO workerTimeControl(userFk, timed, direction, device, `manual`)
|
||||||
VALUES(vWorkerFk, vTimed, vDirection, vIsManual);
|
VALUES(vWorkerFk, vTimed, vDirection, vDevice, vIsManual);
|
||||||
|
|
||||||
SELECT LAST_INSERT_ID() id;
|
SELECT LAST_INSERT_ID() id;
|
||||||
|
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
|
||||||
SQL SECURITY DEFINER
|
|
||||||
VIEW `vn2008`.`tr2`
|
|
||||||
AS SELECT `vn`.`travel`.`id` AS `id`,
|
|
||||||
`vn`.`travel`.`shipped` AS `shipped`,
|
|
||||||
`vn`.`travel`.`shipmentHour` AS `shipmentHour`,
|
|
||||||
`vn`.`travel`.`landed` AS `landed`,
|
|
||||||
`vn`.`travel`.`landingHour` AS `landingHour`,
|
|
||||||
`vn`.`travel`.`warehouseInFk` AS `warehouseInFk`,
|
|
||||||
`vn`.`travel`.`warehouseOutFk` AS `warehouseOutFk`,
|
|
||||||
`vn`.`travel`.`agencyModeFk` AS `agencyFk`,
|
|
||||||
`vn`.`travel`.`ref` AS `ref`,
|
|
||||||
`vn`.`travel`.`isDelivered` AS `isDelivered`,
|
|
||||||
`vn`.`travel`.`isReceived` AS `isReceived`,
|
|
||||||
`vn`.`travel`.`m3` AS `m3`,
|
|
||||||
`vn`.`travel`.`kg` AS `kg`,
|
|
||||||
`vn`.`travel`.`cargoSupplierFk` AS `cargoSupplierFk`,
|
|
||||||
`vn`.`travel`.`totalEntries` AS `totalEntries`
|
|
||||||
FROM `vn`.`travel`
|
|
|
@ -1,11 +0,0 @@
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
|
||||||
SQL SECURITY DEFINER
|
|
||||||
VIEW `vn2008`.`travel_thermograph`
|
|
||||||
AS SELECT `tt`.`thermographFk` AS `thermograph_id`,
|
|
||||||
`tt`.`created` AS `odbc_date`,
|
|
||||||
`tt`.`warehouseFk` AS `warehouse_id`,
|
|
||||||
`tt`.`travelFk` AS `travel_id`,
|
|
||||||
`tt`.`temperatureFk` AS `temperature`,
|
|
||||||
`tt`.`result` AS `result`,
|
|
||||||
`tt`.`dmsFk` AS `gestdoc_id`
|
|
||||||
FROM `vn`.`travelThermograph` `tt`
|
|
|
@ -1,5 +0,0 @@
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
|
||||||
SQL SECURITY DEFINER
|
|
||||||
VIEW `vn2008`.`v_account`
|
|
||||||
AS SELECT `a`.`id` AS `user_id`
|
|
||||||
FROM `account`.`account` `a`
|
|
|
@ -1,15 +0,0 @@
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
|
||||||
SQL SECURITY DEFINER
|
|
||||||
VIEW `vn2008`.`v_analisis_ventas`
|
|
||||||
AS SELECT `bi`.`analisis_ventas`.`Familia` AS `Familia`,
|
|
||||||
`bi`.`analisis_ventas`.`Reino` AS `Reino`,
|
|
||||||
`bi`.`analisis_ventas`.`Comercial` AS `Comercial`,
|
|
||||||
`bi`.`analisis_ventas`.`Comprador` AS `Comprador`,
|
|
||||||
`bi`.`analisis_ventas`.`Provincia` AS `Provincia`,
|
|
||||||
`bi`.`analisis_ventas`.`almacen` AS `almacen`,
|
|
||||||
`bi`.`analisis_ventas`.`Año` AS `Año`,
|
|
||||||
`bi`.`analisis_ventas`.`Mes` AS `Mes`,
|
|
||||||
`bi`.`analisis_ventas`.`Semana` AS `Semana`,
|
|
||||||
`bi`.`analisis_ventas`.`Vista` AS `Vista`,
|
|
||||||
`bi`.`analisis_ventas`.`Importe` AS `Importe`
|
|
||||||
FROM `bi`.`analisis_ventas`
|
|
|
@ -1,21 +0,0 @@
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
|
||||||
SQL SECURITY DEFINER
|
|
||||||
VIEW `vn2008`.`v_barcodes`
|
|
||||||
AS SELECT `Articles`.`Id_Article` AS `code`,
|
|
||||||
`Articles`.`Id_Article` AS `Id_Article`
|
|
||||||
FROM `vn2008`.`Articles`
|
|
||||||
UNION ALL
|
|
||||||
SELECT `barcodes`.`code` AS `code`,
|
|
||||||
`barcodes`.`Id_Article` AS `Id_Article`
|
|
||||||
FROM `vn2008`.`barcodes`
|
|
||||||
UNION ALL
|
|
||||||
SELECT `c`.`Id_Compra` AS `Id_Compra`,
|
|
||||||
`c`.`Id_Article` AS `Id_Article`
|
|
||||||
FROM (
|
|
||||||
(
|
|
||||||
`vn2008`.`Compres` `c`
|
|
||||||
JOIN `vn2008`.`Entradas` `e` ON(`c`.`Id_Entrada` = `e`.`Id_Entrada`)
|
|
||||||
)
|
|
||||||
JOIN `vn2008`.`travel` `tr` ON(`tr`.`id` = `e`.`travel_id`)
|
|
||||||
)
|
|
||||||
WHERE `tr`.`landing` >= `util`.`VN_CURDATE`() + INTERVAL -15 DAY
|
|
|
@ -1,8 +0,0 @@
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
|
||||||
SQL SECURITY DEFINER
|
|
||||||
VIEW `vn2008`.`v_departure_limit`
|
|
||||||
AS SELECT `cache`.`departure_limit`.`warehouse_id` AS `warehouse_id`,
|
|
||||||
`cache`.`departure_limit`.`fecha` AS `fecha`,
|
|
||||||
`cache`.`departure_limit`.`hora` AS `hora`,
|
|
||||||
`cache`.`departure_limit`.`minSpeed` AS `minSpeed`
|
|
||||||
FROM `cache`.`departure_limit`
|
|
|
@ -1,41 +0,0 @@
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
|
||||||
SQL SECURITY DEFINER
|
|
||||||
VIEW `vn2008`.`v_descuadre_bionic`
|
|
||||||
AS SELECT `t`.`Id_Ticket` AS `Id_Ticket`,
|
|
||||||
`t`.`Alias` AS `Alias`,
|
|
||||||
`m`.`Concepte` AS `Concepte`,
|
|
||||||
sum(`mc`.`Valor`) AS `suma_componente`,
|
|
||||||
`m`.`Preu` AS `Preu`,
|
|
||||||
`m`.`Descuento` AS `Descuento`,
|
|
||||||
`m`.`Preu` * (100 - `m`.`Descuento`) / 100 - sum(`mc`.`Valor`) AS `diferencia`,
|
|
||||||
`t`.`Fecha` AS `Fecha`,
|
|
||||||
`m`.`Preu` > 0
|
|
||||||
AND `tp`.`reino_id` <> 6
|
|
||||||
AND `a`.`tipo_id` NOT IN (7, 115) AS `benvenut`
|
|
||||||
FROM (
|
|
||||||
(
|
|
||||||
(
|
|
||||||
(
|
|
||||||
(
|
|
||||||
(
|
|
||||||
`vn2008`.`Movimientos` `m`
|
|
||||||
JOIN `vn2008`.`Tickets` `t` ON(`m`.`Id_Ticket` = `t`.`Id_Ticket`)
|
|
||||||
)
|
|
||||||
JOIN `vn2008`.`Clientes` `c` ON(`t`.`Id_Cliente` = `c`.`id_cliente`)
|
|
||||||
)
|
|
||||||
JOIN `vn2008`.`warehouse` `w` ON(`w`.`id` = `t`.`warehouse_id`)
|
|
||||||
)
|
|
||||||
JOIN `vn2008`.`Articles` `a` ON(`m`.`Id_Article` = `a`.`Id_Article`)
|
|
||||||
)
|
|
||||||
JOIN `vn2008`.`Tipos` `tp` ON(`a`.`tipo_id` = `tp`.`tipo_id`)
|
|
||||||
)
|
|
||||||
LEFT JOIN `vn2008`.`Movimientos_componentes` `mc` ON(`m`.`Id_Movimiento` = `mc`.`Id_Movimiento`)
|
|
||||||
)
|
|
||||||
WHERE `t`.`Fecha` >= '2015-09-01'
|
|
||||||
AND `t`.`empresa_id` IN (442, 791, 567)
|
|
||||||
AND `w`.`reserve` <> 0
|
|
||||||
AND `c`.`real` <> 0
|
|
||||||
AND `tp`.`reino_id` <> 6
|
|
||||||
GROUP BY `m`.`Id_Movimiento`
|
|
||||||
HAVING abs(`diferencia`) > 0.01
|
|
||||||
OR `diferencia` IS NULL
|
|
|
@ -1,11 +0,0 @@
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
|
||||||
SQL SECURITY DEFINER
|
|
||||||
VIEW `vn2008`.`v_inter`
|
|
||||||
AS SELECT `tt`.`id` AS `inter_id`,
|
|
||||||
`tt`.`stateFk` AS `state_id`,
|
|
||||||
`tt`.`notes` AS `nota`,
|
|
||||||
`tt`.`created` AS `odbc_date`,
|
|
||||||
`tt`.`ticketFk` AS `Id_Ticket`,
|
|
||||||
`tt`.`userFk` AS `Id_Trabajador`,
|
|
||||||
`tt`.`supervisorFk` AS `Id_supervisor`
|
|
||||||
FROM `vn`.`ticketTracking` `tt`
|
|
|
@ -1,23 +0,0 @@
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
|
||||||
SQL SECURITY DEFINER
|
|
||||||
VIEW `vn2008`.`v_miriam`
|
|
||||||
AS SELECT `M`.`Id_Article` AS `Id_Article`,
|
|
||||||
`M`.`Concepte` AS `Concepte`,
|
|
||||||
`M`.`Cantidad` AS `Cantidad`,
|
|
||||||
`M`.`Preu` AS `Preu`,
|
|
||||||
`M`.`Descuento` AS `Descuento`,
|
|
||||||
`T`.`Fecha` AS `Fecha`,
|
|
||||||
`T`.`Id_Cliente` AS `Id_Cliente`,
|
|
||||||
`M`.`Cantidad` * `M`.`Preu` * (100 - `M`.`Descuento`) / 100 AS `Importe`
|
|
||||||
FROM (
|
|
||||||
(
|
|
||||||
(
|
|
||||||
`vn2008`.`Tickets` `T`
|
|
||||||
JOIN `vn2008`.`Movimientos` `M` ON(`T`.`Id_Ticket` = `M`.`Id_Ticket`)
|
|
||||||
)
|
|
||||||
JOIN `vn2008`.`Articles` `A` ON(`M`.`Id_Article` = `A`.`Id_Article`)
|
|
||||||
)
|
|
||||||
JOIN `vn2008`.`Tipos` `TP` ON(`A`.`tipo_id` = `TP`.`tipo_id`)
|
|
||||||
)
|
|
||||||
WHERE `T`.`Fecha` >= '2011-01-01'
|
|
||||||
AND `A`.`tipo_id` = 7
|
|
|
@ -1,35 +0,0 @@
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
|
||||||
SQL SECURITY DEFINER
|
|
||||||
VIEW `vn2008`.`v_price_fixed`
|
|
||||||
AS SELECT `pf`.`warehouse_id` AS `warehouse_id`,
|
|
||||||
`pf`.`item_id` AS `item_id`,
|
|
||||||
`pf`.`rate_0` AS `rate_0`,
|
|
||||||
`pf`.`rate_1` AS `rate_1`,
|
|
||||||
`pf`.`rate_2` AS `rate_2`,
|
|
||||||
`pf`.`rate_3` AS `rate_3`,
|
|
||||||
`pf`.`date_start` AS `date_start`,
|
|
||||||
`pf`.`date_end` AS `date_end`,
|
|
||||||
`pf`.`bonus` AS `bonus`,
|
|
||||||
`pf`.`grouping` AS `grouping`,
|
|
||||||
`pf`.`Packing` AS `Packing`,
|
|
||||||
`pf`.`caja` AS `caja`
|
|
||||||
FROM `vn2008`.`price_fixed` `pf`
|
|
||||||
WHERE `pf`.`warehouse_id` < 1000
|
|
||||||
UNION ALL
|
|
||||||
SELECT `wg`.`warehouse_id` AS `warehouse_id`,
|
|
||||||
`pf`.`item_id` AS `item_id`,
|
|
||||||
`pf`.`rate_0` AS `rate_0`,
|
|
||||||
`pf`.`rate_1` AS `rate_1`,
|
|
||||||
`pf`.`rate_2` AS `rate_2`,
|
|
||||||
`pf`.`rate_3` AS `rate_3`,
|
|
||||||
`pf`.`date_start` AS `date_start`,
|
|
||||||
`pf`.`date_end` AS `date_end`,
|
|
||||||
`pf`.`bonus` AS `bonus`,
|
|
||||||
`pf`.`grouping` AS `grouping`,
|
|
||||||
`pf`.`Packing` AS `Packing`,
|
|
||||||
`pf`.`caja` AS `caja`
|
|
||||||
FROM (
|
|
||||||
`vn2008`.`price_fixed` `pf`
|
|
||||||
JOIN `vn2008`.`warehouse_group` `wg`
|
|
||||||
)
|
|
||||||
WHERE `wg`.`warehouse_alias_id` + 1000 = `pf`.`warehouse_id`
|
|
|
@ -0,0 +1 @@
|
||||||
|
ALTER TABLE vn.workerTimeControl ADD device varchar(255) DEFAULT NULL NULL COMMENT 'Dispositivo en el que se ha fichado' AFTER `order`;
|
|
@ -0,0 +1 @@
|
||||||
|
ALTER TABLE vn.workerTimeControl CHANGE direction direction enum('in','out','middle') CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT 'middle' NULL AFTER timed;
|
|
@ -333,7 +333,7 @@
|
||||||
"It was not able to remove the next expeditions:": "No se pudo eliminar las siguientes expediciones: {{expeditions}}",
|
"It was not able to remove the next expeditions:": "No se pudo eliminar las siguientes expediciones: {{expeditions}}",
|
||||||
"This claim has been updated": "La reclamación con Id: {{claimId}}, ha sido actualizada",
|
"This claim has been updated": "La reclamación con Id: {{claimId}}, ha sido actualizada",
|
||||||
"This user does not have an assigned tablet": "Este usuario no tiene tablet asignada",
|
"This user does not have an assigned tablet": "Este usuario no tiene tablet asignada",
|
||||||
"Incorrect pin": "Pin incorrecto.",
|
"Incorrect pin": "Pin incorrecto",
|
||||||
"You already have the mailAlias": "Ya tienes este alias de correo",
|
"You already have the mailAlias": "Ya tienes este alias de correo",
|
||||||
"The alias cant be modified": "Este alias de correo no puede ser modificado",
|
"The alias cant be modified": "Este alias de correo no puede ser modificado",
|
||||||
"No tickets to invoice": "No hay tickets para facturar",
|
"No tickets to invoice": "No hay tickets para facturar",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import './index';
|
import './index';
|
||||||
|
|
||||||
fdescribe('component vnRoleCard', () => {
|
describe('component vnRoleCard', () => {
|
||||||
let controller;
|
let controller;
|
||||||
let $httpBackend;
|
let $httpBackend;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import './index';
|
import './index';
|
||||||
|
|
||||||
fdescribe('component vnRoleDescriptor', () => {
|
describe('component vnRoleDescriptor', () => {
|
||||||
let controller;
|
let controller;
|
||||||
let $httpBackend;
|
let $httpBackend;
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,6 @@ module.exports = Self => {
|
||||||
if (!isSubordinate || (isHimself && !isTeamBoss))
|
if (!isSubordinate || (isHimself && !isTeamBoss))
|
||||||
throw new UserError(`You don't have enough privileges`);
|
throw new UserError(`You don't have enough privileges`);
|
||||||
|
|
||||||
return Self.clockIn(workerId, args.timed, args.direction, myOptions);
|
return Self.clockIn(workerId, args.timed, args.direction, null, myOptions);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -18,7 +18,10 @@ module.exports = Self => {
|
||||||
arg: 'direction',
|
arg: 'direction',
|
||||||
type: 'string'
|
type: 'string'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
arg: 'device',
|
||||||
|
type: 'string'
|
||||||
|
},
|
||||||
],
|
],
|
||||||
http: {
|
http: {
|
||||||
path: `/clockIn`,
|
path: `/clockIn`,
|
||||||
|
@ -30,13 +33,19 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.clockIn = async(workerFk, timed, direction, options) => {
|
Self.clockIn = async(workerFk, timed, direction, device, options) => {
|
||||||
const myOptions = {};
|
const myOptions = {};
|
||||||
if (typeof options == 'object')
|
if (typeof options == 'object')
|
||||||
Object.assign(myOptions, options);
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
const query = 'CALL vn.workerTimeControl_clockIn(?, ?, ?)';
|
const query = 'CALL vn.workerTimeControl_clockIn(?, ?, ?, ?)';
|
||||||
const [[response]] = await Self.rawSql(query, [workerFk, timed, direction], myOptions);
|
const [[response]] = await Self.rawSql(query, [
|
||||||
|
workerFk,
|
||||||
|
timed,
|
||||||
|
direction,
|
||||||
|
(device || null)],
|
||||||
|
myOptions);
|
||||||
|
|
||||||
if (response && response.error)
|
if (response && response.error)
|
||||||
throw new UserError(response.error);
|
throw new UserError(response.error);
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
const UserError = require('vn-loopback/util/user-error');
|
const UserError = require('vn-loopback/util/user-error');
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('login', {
|
Self.remoteMethod('login', {
|
||||||
description: 'Consult the user\'s information and the buttons that must be activated after logging in',
|
description: 'Consult the user\'s information and the buttons that must be activated after logging in',
|
||||||
accessType: 'READ',
|
accessType: 'READ',
|
||||||
accepts: [
|
accepts: [
|
||||||
|
@ -21,15 +21,14 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.login = async(ctx, pin, options) => {
|
Self.login = async(pin, options) => {
|
||||||
const myOptions = {};
|
const myOptions = {};
|
||||||
const $t = ctx.req.__;
|
|
||||||
if (typeof options == 'object')
|
if (typeof options == 'object')
|
||||||
Object.assign(myOptions, options);
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
const query = `CALL vn.workerTimeControl_login(?)`;
|
const query = `CALL vn.workerTimeControl_login(?)`;
|
||||||
const [[user]] = await Self.rawSql(query, [pin], myOptions);
|
const [[user]] = await Self.rawSql(query, [pin], myOptions);
|
||||||
if (!user) throw new UserError($t('Incorrect pin'));
|
if (!user) throw new UserError('Incorrect pin');
|
||||||
return user;
|
return user;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -30,7 +30,7 @@ describe('workerTimeControl clockIn()', () => {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
await models.WorkerTimeControl.clockIn(workerId, inTime, 'in', options);
|
await models.WorkerTimeControl.clockIn(workerId, inTime, 'in', 'test', options);
|
||||||
const isClockIn = await models.WorkerTimeControl.findOne({
|
const isClockIn = await models.WorkerTimeControl.findOne({
|
||||||
where: {
|
where: {
|
||||||
userFk: workerId
|
userFk: workerId
|
||||||
|
|
|
@ -3,29 +3,15 @@ const LoopBackContext = require('loopback-context');
|
||||||
const UserError = require('vn-loopback/util/user-error');
|
const UserError = require('vn-loopback/util/user-error');
|
||||||
|
|
||||||
describe('workerTimeControl login()', () => {
|
describe('workerTimeControl login()', () => {
|
||||||
let ctx;
|
|
||||||
beforeAll(async() => {
|
|
||||||
ctx = {
|
|
||||||
accessToken: {userId: 9},
|
|
||||||
req: {
|
|
||||||
headers: {origin: 'http://localhost'},
|
|
||||||
__: key => key
|
|
||||||
}
|
|
||||||
};
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
|
||||||
active: ctx
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should correctly login', async() => {
|
it('should correctly login', async() => {
|
||||||
const response = await models.WorkerTimeControl.login(ctx, 9);
|
const response = await models.WorkerTimeControl.login(9);
|
||||||
|
|
||||||
expect(response.name).toBe('developer');
|
expect(response.name).toBe('developer');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw UserError if pin is not provided', async() => {
|
it('should throw UserError if pin is not provided', async() => {
|
||||||
try {
|
try {
|
||||||
await models.WorkerTimeControl.login(ctx);
|
await models.WorkerTimeControl.login();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
expect(error).toBeInstanceOf(UserError);
|
expect(error).toBeInstanceOf(UserError);
|
||||||
expect(error.message).toBe('Incorrect pin');
|
expect(error.message).toBe('Incorrect pin');
|
||||||
|
|
|
@ -14,13 +14,16 @@
|
||||||
"timed": {
|
"timed": {
|
||||||
"type": "date"
|
"type": "date"
|
||||||
},
|
},
|
||||||
|
"direction": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"manual": {
|
"manual": {
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
},
|
},
|
||||||
"order": {
|
"order": {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
},
|
},
|
||||||
"direction": {
|
"device": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"isSendMail": {
|
"isSendMail": {
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
"node-ssh": "^11.0.0",
|
"node-ssh": "^11.0.0",
|
||||||
"object-diff": "0.0.4",
|
"object-diff": "0.0.4",
|
||||||
"object.pick": "^1.3.0",
|
"object.pick": "^1.3.0",
|
||||||
"puppeteer": "^20.3.0",
|
"puppeteer": "^21.10.0",
|
||||||
"read-chunk": "^3.2.0",
|
"read-chunk": "^3.2.0",
|
||||||
"require-yaml": "0.0.1",
|
"require-yaml": "0.0.1",
|
||||||
"smbhash": "0.0.1",
|
"smbhash": "0.0.1",
|
||||||
|
|
Loading…
Reference in New Issue