Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 5097-item.summary_available
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
commit
508bce73bc
53
CHANGELOG.md
53
CHANGELOG.md
|
@ -5,20 +5,55 @@ All notable changes to this project will be documented in this file.
|
||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
## [2302.01] - 2023-01-12
|
## [2306.01] - 2023-02-23
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
- [General](Inicio) Permite recuperar la contraseña
|
-
|
||||||
- [Ticket](Opciones) Subir albarán a Docuware
|
|
||||||
- [Ticket](Opciones) Enviar correo con PDF de Docuware
|
|
||||||
- [Artículo](Datos Básicos) Añadido campo Unidades/Caja
|
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- [Reclamaciones](Descriptor) Cambiado el campo Agencia por Zona
|
-
|
||||||
- [Tickets](Líneas preparadas) Actualizada sección para que sea más visual
|
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- [General] Al utilizar el traductor de Google se descuadraban los iconos
|
-
|
||||||
|
|
||||||
|
## [2304.01] - 2023-02-09
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- (Rutas) Al descargar varias facturas se comprime en un zip
|
||||||
|
- (Trabajadores -> Nuevo trabajador) Nueva sección
|
||||||
|
- (Tickets -> Adelantar tickets) Añadidos campos "líneas" y "litros" al ticket origen
|
||||||
|
- (Tickets -> Adelantar tickets) Nuevo icono muestra cuando las agencias de los tickets origen/destino son distintas
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- (Entradas -> Compras) Cambiados los campos "Precio Grouping/Packing" por "PVP" y "Precio" por "Coste"
|
||||||
|
- (Artículos -> Últimas entradas) Cambiados los campos "P.P.U." y "P.P.P." por "PVP"
|
||||||
|
- (Rutas -> Sumario/Tickets) Actualizados campos de los tickets
|
||||||
|
- (Proveedores -> Crear/Editar) Permite añadir Proveedores con la misma razón social pero con países distintos
|
||||||
|
- (Tickets -> Adelantar tickets) Cambiados selectores de estado por checks "Pendiente origen/destino"
|
||||||
|
- (Tickets -> Adelantar tickets) Cambiado stock de destino a origen.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- (Artículos -> Etiquetas) Permite intercambiar la relevancia entre dos etiquetas.
|
||||||
|
- (Cliente -> Datos Fiscales) No se permite seleccionar 'Notificar vía e-mail' a los clientes sin e-mail
|
||||||
|
- (Tickets -> Datos básicos) Permite guardar la hora de envío
|
||||||
|
- (Tickets -> Añadir pago) Eliminado "null" en las referencias
|
||||||
|
- (Tickets -> Adelantar tickets) Permite ordenar por importe
|
||||||
|
- (Tickets -> Adelantar tickets) El filtrado por encajado muestra también los tickets sin tipo de encajado
|
||||||
|
|
||||||
|
## [2302.01] - 2023-01-26
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- (General -> Inicio) Permite recuperar la contraseña
|
||||||
|
- (Tickets -> Opciones) Subir albarán a Docuware
|
||||||
|
- (Tickets -> Opciones) Enviar correo con PDF de Docuware
|
||||||
|
- (Artículos -> Datos Básicos) Añadido campo Unidades/Caja
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- (Reclamaciones -> Descriptor) Cambiado el campo Agencia por Zona
|
||||||
|
- (Tickets -> Líneas preparadas) Actualizada sección para que sea más visual
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- (General) Al utilizar el traductor de Google se descuadraban los iconos
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
- [Tickets](Control clientes) Eliminada sección
|
- (Tickets -> Control clientes) Eliminada sección
|
||||||
|
|
|
@ -36,19 +36,26 @@ module.exports = Self => {
|
||||||
JOIN osticket.ost_ticket_status ots ON ots.id = ot.status_id
|
JOIN osticket.ost_ticket_status ots ON ots.id = ot.status_id
|
||||||
JOIN osticket.ost_thread ot2 ON ot2.object_id = ot.ticket_id AND ot2.object_type = 'T'
|
JOIN osticket.ost_thread ot2 ON ot2.object_id = ot.ticket_id AND ot2.object_type = 'T'
|
||||||
JOIN (
|
JOIN (
|
||||||
SELECT ote.thread_id, MAX(ote.created) created, MAX(ote.updated) updated
|
SELECT sub2.thread_id, sub2.type, sub2.updated, sub2.created
|
||||||
|
FROM (
|
||||||
|
SELECT ote.thread_id, ote.created, ote.updated, ote.type
|
||||||
FROM osticket.ost_thread_entry ote
|
FROM osticket.ost_thread_entry ote
|
||||||
WHERE ote.staff_id AND ote.type = 'R'
|
WHERE ote.staff_id
|
||||||
GROUP BY ote.thread_id
|
ORDER BY ote.id DESC
|
||||||
|
LIMIT 10000000000000000000) sub2
|
||||||
|
GROUP BY sub2.thread_id
|
||||||
) sub ON sub.thread_id = ot2.id
|
) sub ON sub.thread_id = ot2.id
|
||||||
WHERE ot.isanswered
|
WHERE ot.isanswered
|
||||||
AND ots.state = ?
|
AND ots.id IN (?)
|
||||||
AND IF(sub.updated > sub.created, sub.updated, sub.created) < DATE_SUB(CURDATE(), INTERVAL ? DAY)`;
|
AND sub.type = 'R'
|
||||||
|
AND IF(sub.updated > sub.created, sub.updated, sub.created) < DATE_SUB(CURDATE(), INTERVAL ? DAY);`;
|
||||||
|
|
||||||
const ticketsId = [];
|
const ticketsId = [];
|
||||||
|
const statusIdToClose = config.oldStatus.split(',');
|
||||||
|
|
||||||
con.connect(err => {
|
con.connect(err => {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
con.query(sql, [config.oldStatus, config.day],
|
con.query(sql, [statusIdToClose, config.day],
|
||||||
(err, results) => {
|
(err, results) => {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
for (const result of results)
|
for (const result of results)
|
||||||
|
|
|
@ -6,6 +6,16 @@
|
||||||
"table": "util.notificationAcl"
|
"table": "util.notificationAcl"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"properties":{
|
||||||
|
"notificationFk": {
|
||||||
|
"id": true,
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"roleFk":{
|
||||||
|
"id": true,
|
||||||
|
"type": "number"
|
||||||
|
}
|
||||||
|
},
|
||||||
"relations": {
|
"relations": {
|
||||||
"notification": {
|
"notification": {
|
||||||
"type": "belongsTo",
|
"type": "belongsTo",
|
||||||
|
|
|
@ -0,0 +1,62 @@
|
||||||
|
const UserError = require('vn-loopback/util/user-error');
|
||||||
|
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.observe('before save', async function(ctx) {
|
||||||
|
const models = Self.app.models;
|
||||||
|
const userId = ctx.options.accessToken.userId;
|
||||||
|
const user = await ctx.instance.userFk;
|
||||||
|
const modifiedUser = await getUserToModify(null, user, models);
|
||||||
|
|
||||||
|
if (userId != modifiedUser.id && userId != modifiedUser.bossFk)
|
||||||
|
throw new UserError('You dont have permission to modify this user');
|
||||||
|
});
|
||||||
|
|
||||||
|
Self.remoteMethod('deleteNotification', {
|
||||||
|
description: 'Deletes a notification subscription',
|
||||||
|
accepts: [
|
||||||
|
{
|
||||||
|
arg: 'ctx',
|
||||||
|
type: 'object',
|
||||||
|
http: {source: 'context'}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'notificationId',
|
||||||
|
type: 'number',
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
],
|
||||||
|
returns: {
|
||||||
|
type: 'object',
|
||||||
|
root: true
|
||||||
|
},
|
||||||
|
http: {
|
||||||
|
verb: 'POST',
|
||||||
|
path: '/deleteNotification'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Self.deleteNotification = async function(ctx, notificationId) {
|
||||||
|
const models = Self.app.models;
|
||||||
|
const user = ctx.req.accessToken.userId;
|
||||||
|
const modifiedUser = await getUserToModify(notificationId, null, models);
|
||||||
|
|
||||||
|
if (user != modifiedUser.id && user != modifiedUser.bossFk)
|
||||||
|
throw new UserError('You dont have permission to modify this user');
|
||||||
|
|
||||||
|
await models.NotificationSubscription.destroyById(notificationId);
|
||||||
|
};
|
||||||
|
|
||||||
|
async function getUserToModify(notificationId, userFk, models) {
|
||||||
|
let userToModify = userFk;
|
||||||
|
if (notificationId) {
|
||||||
|
const subscription = await models.NotificationSubscription.findById(notificationId);
|
||||||
|
userToModify = subscription.userFk;
|
||||||
|
}
|
||||||
|
return await models.Worker.findOne({
|
||||||
|
fields: ['id', 'bossFk'],
|
||||||
|
where: {
|
||||||
|
id: userToModify
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
|
@ -7,15 +7,18 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"properties": {
|
"properties": {
|
||||||
"notificationFk": {
|
"id": {
|
||||||
"type": "number",
|
"type": "number",
|
||||||
"id": true,
|
"id": true,
|
||||||
"description": "Identifier"
|
"description": "Primary key"
|
||||||
|
},
|
||||||
|
"notificationFk": {
|
||||||
|
"type": "number",
|
||||||
|
"description": "Foreign key to Notification"
|
||||||
},
|
},
|
||||||
"userFk": {
|
"userFk": {
|
||||||
"type": "number",
|
"type": "number",
|
||||||
"id": true,
|
"description": "Foreign key to Account"
|
||||||
"description": "Identifier"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"relations": {
|
"relations": {
|
||||||
|
|
|
@ -0,0 +1,74 @@
|
||||||
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
|
describe('loopback model NotificationSubscription', () => {
|
||||||
|
it('Should fail to delete a notification if the user is not editing itself or a subordinate', async() => {
|
||||||
|
const tx = await models.NotificationSubscription.beginTransaction({});
|
||||||
|
|
||||||
|
try {
|
||||||
|
const options = {transaction: tx};
|
||||||
|
const user = 9;
|
||||||
|
const notificationSubscriptionId = 2;
|
||||||
|
const ctx = {req: {accessToken: {userId: user}}};
|
||||||
|
const notification = await models.NotificationSubscription.findById(notificationSubscriptionId);
|
||||||
|
|
||||||
|
let error;
|
||||||
|
|
||||||
|
try {
|
||||||
|
await models.NotificationSubscription.deleteNotification(ctx, notification.id, options);
|
||||||
|
} catch (e) {
|
||||||
|
error = e;
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(error.message).toContain('You dont have permission to modify this user');
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Should delete a notification if the user is editing itself', async() => {
|
||||||
|
const tx = await models.NotificationSubscription.beginTransaction({});
|
||||||
|
|
||||||
|
try {
|
||||||
|
const options = {transaction: tx};
|
||||||
|
const user = 9;
|
||||||
|
const notificationSubscriptionId = 4;
|
||||||
|
const ctx = {req: {accessToken: {userId: user}}};
|
||||||
|
const notification = await models.NotificationSubscription.findById(notificationSubscriptionId);
|
||||||
|
|
||||||
|
await models.NotificationSubscription.deleteNotification(ctx, notification.id, options);
|
||||||
|
|
||||||
|
const deletedNotification = await models.NotificationSubscription.findById(notificationSubscriptionId);
|
||||||
|
|
||||||
|
expect(deletedNotification).toBeNull();
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Should delete a notification if the user is editing a subordinate', async() => {
|
||||||
|
const tx = await models.NotificationSubscription.beginTransaction({});
|
||||||
|
|
||||||
|
try {
|
||||||
|
const options = {transaction: tx};
|
||||||
|
const user = 9;
|
||||||
|
const notificationSubscriptionId = 5;
|
||||||
|
const ctx = {req: {accessToken: {userId: user}}};
|
||||||
|
const notification = await models.NotificationSubscription.findById(notificationSubscriptionId);
|
||||||
|
|
||||||
|
await models.NotificationSubscription.deleteNotification(ctx, notification.id, options);
|
||||||
|
|
||||||
|
const deletedNotification = await models.NotificationSubscription.findById(notificationSubscriptionId);
|
||||||
|
|
||||||
|
expect(deletedNotification).toBeNull();
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
UPDATE `vn`.`osTicketConfig`
|
||||||
|
SET oldStatus='1,6'
|
||||||
|
WHERE id=0;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
ALTER TABLE `vn`.`supplier` ADD UNIQUE (name, countryFk);
|
|
@ -0,0 +1,9 @@
|
||||||
|
ALTER TABLE `vn`.`itemConfig` ADD defaultTag INT DEFAULT 56 NOT NULL;
|
||||||
|
ALTER TABLE `vn`.`itemConfig` ADD CONSTRAINT itemConfig_FK FOREIGN KEY (defaultTag) REFERENCES vn.tag(id);
|
||||||
|
ALTER TABLE `vn`.`itemConfig` ADD validPriorities varchar(50) DEFAULT '[1,2,3]' NOT NULL;
|
||||||
|
ALTER TABLE `vn`.`itemConfig` ADD defaultPriority INT DEFAULT 2 NOT NULL;
|
||||||
|
ALTER TABLE `vn`.`item` MODIFY COLUMN relevancy tinyint(1) DEFAULT 0 NOT NULL COMMENT 'La web ordena de forma descendiente por este campo para mostrar los artículos';
|
||||||
|
|
||||||
|
INSERT INTO `salix`.`ACL`
|
||||||
|
(model, property, accessType, permission, principalType, principalId)
|
||||||
|
VALUES('ItemConfig', '*', 'READ', 'ALLOW', 'ROLE', 'buyer');
|
|
@ -0,0 +1,6 @@
|
||||||
|
ALTER TABLE `vn`.`workerTimeControlConfig` ADD teleworkingStart INT NULL COMMENT 'Hora comienzo jornada de los teletrabajdores expresada en segundos';
|
||||||
|
ALTER TABLE `vn`.`workerTimeControlConfig` ADD teleworkingStartBreakTime INT NULL COMMENT 'Hora comienzo descanso de los teletrabjadores expresada en segundos';
|
||||||
|
|
||||||
|
UPDATE `vn`.`workerTimeControlConfig`
|
||||||
|
SET `teleworkingStart`=28800, `teleworkingStartBreakTime`=32400
|
||||||
|
WHERE `id`=1;
|
|
@ -0,0 +1,3 @@
|
||||||
|
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||||
|
VALUES
|
||||||
|
('Tag', 'onSubmit', 'WRITE', 'ALLOW', 'ROLE', 'employee');
|
|
@ -0,0 +1,4 @@
|
||||||
|
INSERT INTO `salix`.`ACL` (model,property,accessType,principalId)
|
||||||
|
VALUES
|
||||||
|
('NotificationSubscription','*','*','employee'),
|
||||||
|
('NotificationAcl','*','READ','employee');
|
|
@ -0,0 +1,24 @@
|
||||||
|
UPDATE `salix`.`ACL`
|
||||||
|
SET accessType='READ'
|
||||||
|
WHERE model='Worker'
|
||||||
|
AND property='*'
|
||||||
|
AND accessType='*'
|
||||||
|
AND permission='ALLOW'
|
||||||
|
AND principalType='ROLE'
|
||||||
|
AND principalId='employee';
|
||||||
|
|
||||||
|
|
||||||
|
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||||
|
VALUES
|
||||||
|
('Worker', 'updateAttributes', 'WRITE', 'ALLOW', 'ROLE', 'hr'),
|
||||||
|
('Worker', 'createAbsence', '*', 'ALLOW', 'ROLE', 'employee'),
|
||||||
|
('Worker', 'updateAbsence', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
|
||||||
|
('Worker', 'deleteAbsence', '*', 'ALLOW', 'ROLE', 'employee'),
|
||||||
|
('Worker', 'new', 'WRITE', 'ALLOW', 'ROLE', 'hr'),
|
||||||
|
('Role', '*', 'READ', 'ALLOW', 'ROLE', 'hr');
|
||||||
|
|
||||||
|
ALTER TABLE `vn`.`workerConfig` ADD roleFk int(10) unsigned NOT NULL COMMENT 'Rol por defecto al dar de alta un trabajador nuevo';
|
||||||
|
UPDATE `vn`.`workerConfig`
|
||||||
|
SET roleFk = 1
|
||||||
|
WHERE id = 1;
|
||||||
|
|
|
@ -0,0 +1,110 @@
|
||||||
|
DROP PROCEDURE IF EXISTS vn.ticket_canAdvance;
|
||||||
|
|
||||||
|
DELIMITER $$
|
||||||
|
$$
|
||||||
|
CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_canAdvance`(vDateFuture DATE, vDateToAdvance DATE, vWarehouseFk INT)
|
||||||
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Devuelve los tickets y la cantidad de lineas de venta que se pueden adelantar.
|
||||||
|
*
|
||||||
|
* @param vDateFuture Fecha de los tickets que se quieren adelantar.
|
||||||
|
* @param vDateToAdvance Fecha a cuando se quiere adelantar.
|
||||||
|
* @param vWarehouseFk Almacén
|
||||||
|
*/
|
||||||
|
|
||||||
|
DECLARE vDateInventory DATE;
|
||||||
|
|
||||||
|
SELECT inventoried INTO vDateInventory FROM vn.config;
|
||||||
|
|
||||||
|
DROP TEMPORARY TABLE IF EXISTS tmp.stock;
|
||||||
|
CREATE TEMPORARY TABLE tmp.stock
|
||||||
|
(itemFk INT PRIMARY KEY,
|
||||||
|
amount INT)
|
||||||
|
ENGINE = MEMORY;
|
||||||
|
|
||||||
|
INSERT INTO tmp.stock(itemFk, amount)
|
||||||
|
SELECT itemFk, SUM(quantity) amount FROM
|
||||||
|
(
|
||||||
|
SELECT itemFk, quantity
|
||||||
|
FROM vn.itemTicketOut
|
||||||
|
WHERE shipped >= vDateInventory
|
||||||
|
AND shipped < vDateFuture
|
||||||
|
AND warehouseFk = vWarehouseFk
|
||||||
|
UNION ALL
|
||||||
|
SELECT itemFk, quantity
|
||||||
|
FROM vn.itemEntryIn
|
||||||
|
WHERE landed >= vDateInventory
|
||||||
|
AND landed < vDateFuture
|
||||||
|
AND isVirtualStock = FALSE
|
||||||
|
AND warehouseInFk = vWarehouseFk
|
||||||
|
UNION ALL
|
||||||
|
SELECT itemFk, quantity
|
||||||
|
FROM vn.itemEntryOut
|
||||||
|
WHERE shipped >= vDateInventory
|
||||||
|
AND shipped < vDateFuture
|
||||||
|
AND warehouseOutFk = vWarehouseFk
|
||||||
|
) t
|
||||||
|
GROUP BY itemFk HAVING amount != 0;
|
||||||
|
|
||||||
|
DROP TEMPORARY TABLE IF EXISTS tmp.filter;
|
||||||
|
CREATE TEMPORARY TABLE tmp.filter
|
||||||
|
(INDEX (id))
|
||||||
|
SELECT s.ticketFk futureId,
|
||||||
|
t2.ticketFk id,
|
||||||
|
count(DISTINCT s.id) saleCount,
|
||||||
|
t2.state,
|
||||||
|
t2.isNotValidated,
|
||||||
|
st.name futureState,
|
||||||
|
st.isNotValidated futureIsNotValidated,
|
||||||
|
GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) futureIpt,
|
||||||
|
t2.ipt,
|
||||||
|
t.workerFk,
|
||||||
|
CAST(SUM(litros) AS DECIMAL(10,0)) futureLiters,
|
||||||
|
CAST(COUNT(*) AS DECIMAL(10,0)) `futureLines`,
|
||||||
|
t2.shipped,
|
||||||
|
t.shipped futureShipped,
|
||||||
|
t2.totalWithVat,
|
||||||
|
t.totalWithVat futureTotalWithVat,
|
||||||
|
t2.agency,
|
||||||
|
am.name futureAgency,
|
||||||
|
t2.lines,
|
||||||
|
t2.liters,
|
||||||
|
SUM((s.quantity <= IFNULL(st.amount,0))) hasStock
|
||||||
|
FROM vn.ticket t
|
||||||
|
JOIN vn.ticketState ts ON ts.ticketFk = t.id
|
||||||
|
JOIN vn.state st ON st.id = ts.stateFk
|
||||||
|
JOIN vn.saleVolume sv ON t.id = sv.ticketFk
|
||||||
|
JOIN (SELECT
|
||||||
|
t2.id ticketFk,
|
||||||
|
t2.addressFk,
|
||||||
|
st.isNotValidated,
|
||||||
|
st.name state,
|
||||||
|
GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) ipt,
|
||||||
|
t2.shipped,
|
||||||
|
t2.totalWithVat,
|
||||||
|
am.name agency,
|
||||||
|
CAST(SUM(litros) AS DECIMAL(10,0)) liters,
|
||||||
|
CAST(COUNT(*) AS DECIMAL(10,0)) `lines`
|
||||||
|
FROM vn.ticket t2
|
||||||
|
JOIN vn.saleVolume sv ON t2.id = sv.ticketFk
|
||||||
|
JOIN vn.sale s ON s.ticketFk = t2.id
|
||||||
|
JOIN vn.item i ON i.id = s.itemFk
|
||||||
|
JOIN vn.ticketState ts ON ts.ticketFk = t2.id
|
||||||
|
JOIN vn.state st ON st.id = ts.stateFk
|
||||||
|
JOIN vn.agencyMode am ON t2.agencyModeFk = am.id
|
||||||
|
LEFT JOIN vn.itemPackingType ipt ON ipt.code = i.itemPackingTypeFk
|
||||||
|
WHERE t2.shipped BETWEEN vDateToAdvance AND util.dayend(vDateToAdvance)
|
||||||
|
AND t2.warehouseFk = vWarehouseFk
|
||||||
|
GROUP BY t2.id) t2 ON t2.addressFk = t.addressFk
|
||||||
|
JOIN vn.sale s ON s.ticketFk = t.id
|
||||||
|
JOIN vn.item i ON i.id = s.itemFk
|
||||||
|
JOIN vn.agencyMode am ON t.agencyModeFk = am.id
|
||||||
|
LEFT JOIN vn.itemPackingType ipt ON ipt.code = i.itemPackingTypeFk
|
||||||
|
LEFT JOIN tmp.stock st ON st.itemFk = s.itemFk
|
||||||
|
WHERE t.shipped BETWEEN vDateFuture AND util.dayend(vDateFuture)
|
||||||
|
AND t.warehouseFk = vWarehouseFk
|
||||||
|
GROUP BY t.id;
|
||||||
|
|
||||||
|
DROP TEMPORARY TABLE tmp.stock;
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -0,0 +1,4 @@
|
||||||
|
ALTER TABLE
|
||||||
|
`util`.`notificationSubscription`
|
||||||
|
ADD
|
||||||
|
CONSTRAINT `notificationSubscription_UN` UNIQUE KEY (`notificationFk`, `userFk`);
|
|
@ -0,0 +1,6 @@
|
||||||
|
UPDATE `vn`.`client`
|
||||||
|
SET isToBeMailed = FALSE
|
||||||
|
WHERE
|
||||||
|
mailAddress is NULL
|
||||||
|
AND email is NULL
|
||||||
|
AND isToBeMailed = TRUE;
|
|
@ -0,0 +1,7 @@
|
||||||
|
ALTER TABLE `util`.`notificationSubscription`
|
||||||
|
ADD `id` int(11) auto_increment NULL,
|
||||||
|
DROP PRIMARY KEY,
|
||||||
|
ADD CONSTRAINT PRIMARY KEY (`id`);
|
||||||
|
|
||||||
|
ALTER TABLE `util`.`notificationSubscription`
|
||||||
|
ADD KEY `notificationSubscription_ibfk_1` (`notificationFk`);
|
|
@ -1954,10 +1954,6 @@ INSERT INTO `vn`.`workerBusinessType` (`id`, `name`, `isFullTime`, `isPermanent`
|
||||||
(100, 'INDEFINIDO A TIEMPO COMPLETO', 1, 1, 1),
|
(100, 'INDEFINIDO A TIEMPO COMPLETO', 1, 1, 1),
|
||||||
(109, 'CONVERSION DE TEMPORAL EN INDEFINIDO T.COMPLETO', 1, 1, 1);
|
(109, 'CONVERSION DE TEMPORAL EN INDEFINIDO T.COMPLETO', 1, 1, 1);
|
||||||
|
|
||||||
INSERT INTO `vn`.`businessCategory` (`id`, `description`, `rate`)
|
|
||||||
VALUES
|
|
||||||
(1, 'basic employee', 1);
|
|
||||||
|
|
||||||
UPDATE `vn`.`business` b
|
UPDATE `vn`.`business` b
|
||||||
SET `rate` = 7,
|
SET `rate` = 7,
|
||||||
`workerBusinessCategoryFk` = 1,
|
`workerBusinessCategoryFk` = 1,
|
||||||
|
@ -2629,7 +2625,7 @@ INSERT INTO `vn`.`machineWorker` (`workerFk`, `machineFk`, `inTimed`, `outTimed`
|
||||||
|
|
||||||
INSERT INTO `vn`.`zoneExclusion` (`id`, `zoneFk`, `dated`, `created`, `userFk`)
|
INSERT INTO `vn`.`zoneExclusion` (`id`, `zoneFk`, `dated`, `created`, `userFk`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, 1, DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=7, 7, 14) - DAYOFWEEK(util.VN_CURDATE())) DAY), util.VN_CURDATE(), 100),
|
(1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL (IF(DAYOFWEEK(util.VN_CURDATE())<=7, 7, 14) - DAYOFWEEK(util.VN_CURDATE())) DAY), util.VN_CURDATE(), 100),
|
||||||
(2, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL (IF(DAYOFWEEK(util.VN_CURDATE())<=8, 8, 15) - DAYOFWEEK(util.VN_CURDATE())) DAY), util.VN_CURDATE(), 100);
|
(2, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL (IF(DAYOFWEEK(util.VN_CURDATE())<=8, 8, 15) - DAYOFWEEK(util.VN_CURDATE())) DAY), util.VN_CURDATE(), 100);
|
||||||
|
|
||||||
INSERT INTO `vn`.`zoneExclusionGeo` (`zoneExclusionFk`, `geoFk`)
|
INSERT INTO `vn`.`zoneExclusionGeo` (`zoneExclusionFk`, `geoFk`)
|
||||||
|
@ -2667,9 +2663,9 @@ INSERT INTO `vn`.`sectorCollectionSaleGroup` (`sectorCollectionFk`, `saleGroupFk
|
||||||
VALUES
|
VALUES
|
||||||
(1, 1);
|
(1, 1);
|
||||||
|
|
||||||
INSERT INTO `vn`.`workerTimeControlConfig` (`id`, `dayBreak`, `dayBreakDriver`, `shortWeekBreak`, `longWeekBreak`, `weekScope`, `mailPass`, `mailHost`, `mailSuccessFolder`, `mailErrorFolder`, `mailUser`, `minHoursToBreak`, `breakHours`, `hoursCompleteWeek`, `startNightlyHours`, `endNightlyHours`, `maxTimePerDay`, `breakTime`, `timeToBreakTime`, `dayMaxTime`, `shortWeekDays`, `longWeekDays`)
|
INSERT INTO `vn`.`workerTimeControlConfig` (`id`, `dayBreak`, `dayBreakDriver`, `shortWeekBreak`, `longWeekBreak`, `weekScope`, `mailPass`, `mailHost`, `mailSuccessFolder`, `mailErrorFolder`, `mailUser`, `minHoursToBreak`, `breakHours`, `hoursCompleteWeek`, `startNightlyHours`, `endNightlyHours`, `maxTimePerDay`, `breakTime`, `timeToBreakTime`, `dayMaxTime`, `shortWeekDays`, `longWeekDays`, `teleworkingStart`, `teleworkingStartBreakTime`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, 43200, 32400, 129600, 259200, 604800, '', '', 'Leidos.exito', 'Leidos.error', 'timeControl', 5.33, 0.33, 40, '22:00:00', '06:00:00', 57600, 1200, 18000, 57600, 6, 13);
|
(1, 43200, 32400, 129600, 259200, 604800, '', '', 'Leidos.exito', 'Leidos.error', 'timeControl', 5.33, 0.33, 40, '22:00:00', '06:00:00', 57600, 1200, 18000, 57600, 6, 13, 28800, 32400);
|
||||||
|
|
||||||
INSERT INTO `vn`.`host` (`id`, `code`, `description`, `warehouseFk`, `bankFk`)
|
INSERT INTO `vn`.`host` (`id`, `code`, `description`, `warehouseFk`, `bankFk`)
|
||||||
VALUES
|
VALUES
|
||||||
|
@ -2705,7 +2701,10 @@ INSERT INTO `util`.`notificationSubscription` (`notificationFk`, `userFk`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, 1109),
|
(1, 1109),
|
||||||
(1, 1110),
|
(1, 1110),
|
||||||
(3, 1109);
|
(3, 1109),
|
||||||
|
(1,9),
|
||||||
|
(1,3);
|
||||||
|
|
||||||
|
|
||||||
INSERT INTO `vn`.`routeConfig` (`id`, `defaultWorkCenterFk`)
|
INSERT INTO `vn`.`routeConfig` (`id`, `defaultWorkCenterFk`)
|
||||||
VALUES
|
VALUES
|
||||||
|
@ -2719,6 +2718,10 @@ INSERT INTO `vn`.`collection` (`id`, `created`, `workerFk`, `stateFk`, `itemPack
|
||||||
VALUES
|
VALUES
|
||||||
(3, util.VN_NOW(), 1107, 5, NULL, 0, 0, 1, NULL, NULL);
|
(3, util.VN_NOW(), 1107, 5, NULL, 0, 0, 1, NULL, NULL);
|
||||||
|
|
||||||
|
INSERT INTO `vn`.`itemConfig` (`id`, `isItemTagTriggerDisabled`, `monthToDeactivate`, `wasteRecipients`, `validPriorities`, `defaultPriority`, `defaultTag`)
|
||||||
|
VALUES
|
||||||
|
(0, 0, 24, '', '[1,2,3]', 2, 56);
|
||||||
|
|
||||||
INSERT INTO `vn`.`ticketCollection` (`ticketFk`, `collectionFk`, `created`, `level`, `wagon`, `smartTagFk`, `usedShelves`, `itemCount`, `liters`)
|
INSERT INTO `vn`.`ticketCollection` (`ticketFk`, `collectionFk`, `created`, `level`, `wagon`, `smartTagFk`, `usedShelves`, `itemCount`, `liters`)
|
||||||
VALUES
|
VALUES
|
||||||
(9, 3, util.VN_NOW(), NULL, 0, NULL, NULL, NULL, NULL);
|
(9, 3, util.VN_NOW(), NULL, 0, NULL, NULL, NULL, NULL);
|
||||||
|
@ -2741,16 +2744,20 @@ INSERT INTO `vn`.`ticketLog` (`originFk`, userFk, `action`, changedModel, oldIns
|
||||||
|
|
||||||
INSERT INTO `vn`.`osTicketConfig` (`id`, `host`, `user`, `password`, `oldStatus`, `newStatusId`, `day`, `comment`, `hostDb`, `userDb`, `passwordDb`, `portDb`, `responseType`, `fromEmailId`, `replyTo`)
|
INSERT INTO `vn`.`osTicketConfig` (`id`, `host`, `user`, `password`, `oldStatus`, `newStatusId`, `day`, `comment`, `hostDb`, `userDb`, `passwordDb`, `portDb`, `responseType`, `fromEmailId`, `replyTo`)
|
||||||
VALUES
|
VALUES
|
||||||
(0, 'http://localhost:56596/scp', 'ostadmin', 'Admin1', 'open', 3, 60, 'Este CAU se ha cerrado automáticamente. Si el problema persiste responda a este mensaje.', 'localhost', 'osticket', 'osticket', 40003, 'reply', 1, 'all');
|
(0, 'http://localhost:56596/scp', 'ostadmin', 'Admin1', '1,6', 3, 60, 'Este CAU se ha cerrado automáticamente. Si el problema persiste responda a este mensaje.', 'localhost', 'osticket', 'osticket', 40003, 'reply', 1, 'all');
|
||||||
|
|
||||||
INSERT INTO `vn`.`mdbApp` (`app`, `baselineBranchFk`, `userFk`, `locked`)
|
INSERT INTO `vn`.`mdbApp` (`app`, `baselineBranchFk`, `userFk`, `locked`)
|
||||||
VALUES
|
VALUES
|
||||||
('foo', 'master', NULL, NULL),
|
('foo', 'master', NULL, NULL),
|
||||||
('bar', 'test', 9, util.VN_NOW());
|
('bar', 'test', 9, util.VN_NOW());
|
||||||
INSERT INTO `vn`.`ticketLog` (`id`, `originFk`, `userFk`, `action`, `changedModel`, `oldInstance`, `newInstance`, `changedModelId`)
|
|
||||||
VALUES
|
|
||||||
(1, 1, 9, 'insert', 'Ticket', '{}', '{"clientFk":1, "nickname": "Bat cave"}', 1);
|
|
||||||
|
|
||||||
|
INSERT INTO `vn`.`profileType` (`id`, `name`)
|
||||||
|
VALUES
|
||||||
|
(1, 'working');
|
||||||
|
|
||||||
|
INSERT INTO `vn`.`newWorkerConfig` (`id`, `street`, `provinceFk`, `companyFk`, `profileTypeFk`, `roleFk`)
|
||||||
|
VALUES
|
||||||
|
(1, 'S/ ', 1, 442, 1, 1);
|
||||||
|
|
||||||
INSERT INTO `salix`.`url` (`appName`, `environment`, `url`)
|
INSERT INTO `salix`.`url` (`appName`, `environment`, `url`)
|
||||||
VALUES
|
VALUES
|
||||||
|
@ -2761,3 +2768,7 @@ INSERT INTO `vn`.`payDemDetail` (`id`, `detail`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, 1);
|
(1, 1);
|
||||||
|
|
||||||
|
INSERT INTO `vn`.`workerConfig` (`id`, `businessUpdated`, `roleFk`)
|
||||||
|
VALUES
|
||||||
|
(1, NULL, 1);
|
||||||
|
|
||||||
|
|
|
@ -80203,4 +80203,3 @@ USE `vncontrol`;
|
||||||
-- Dump completed on 2022-11-21 7:57:28
|
-- Dump completed on 2022-11-21 7:57:28
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,7 @@ export default {
|
||||||
deleteAccount: '.vn-menu [name="deleteUser"]',
|
deleteAccount: '.vn-menu [name="deleteUser"]',
|
||||||
setPassword: '.vn-menu [name="setPassword"]',
|
setPassword: '.vn-menu [name="setPassword"]',
|
||||||
activateAccount: '.vn-menu [name="enableAccount"]',
|
activateAccount: '.vn-menu [name="enableAccount"]',
|
||||||
|
disableAccount: '.vn-menu [name="disableAccount"]',
|
||||||
activateUser: '.vn-menu [name="activateUser"]',
|
activateUser: '.vn-menu [name="activateUser"]',
|
||||||
deactivateUser: '.vn-menu [name="deactivateUser"]',
|
deactivateUser: '.vn-menu [name="deactivateUser"]',
|
||||||
newPassword: 'vn-textfield[ng-model="$ctrl.newPassword"]',
|
newPassword: 'vn-textfield[ng-model="$ctrl.newPassword"]',
|
||||||
|
@ -428,6 +429,7 @@ export default {
|
||||||
},
|
},
|
||||||
itemCreateView: {
|
itemCreateView: {
|
||||||
temporalName: 'vn-item-create vn-textfield[ng-model="$ctrl.item.provisionalName"]',
|
temporalName: 'vn-item-create vn-textfield[ng-model="$ctrl.item.provisionalName"]',
|
||||||
|
priority: 'vn-autocomplete[ng-model="$ctrl.item.priority"]',
|
||||||
type: 'vn-autocomplete[ng-model="$ctrl.item.typeFk"]',
|
type: 'vn-autocomplete[ng-model="$ctrl.item.typeFk"]',
|
||||||
intrastat: 'vn-autocomplete[ng-model="$ctrl.item.intrastatFk"]',
|
intrastat: 'vn-autocomplete[ng-model="$ctrl.item.intrastatFk"]',
|
||||||
origin: 'vn-autocomplete[ng-model="$ctrl.item.originFk"]',
|
origin: 'vn-autocomplete[ng-model="$ctrl.item.originFk"]',
|
||||||
|
@ -521,7 +523,7 @@ export default {
|
||||||
},
|
},
|
||||||
itemLog: {
|
itemLog: {
|
||||||
anyLineCreated: 'vn-item-log > vn-log vn-tbody > vn-tr',
|
anyLineCreated: 'vn-item-log > vn-log vn-tbody > vn-tr',
|
||||||
fifthLineCreatedProperty: 'vn-item-log > vn-log vn-tbody > vn-tr:nth-child(5) table tr:nth-child(3) td.after',
|
fifthLineCreatedProperty: 'vn-item-log > vn-log vn-tbody > vn-tr:nth-child(5) table tr:nth-child(2) td.after',
|
||||||
},
|
},
|
||||||
ticketSummary: {
|
ticketSummary: {
|
||||||
header: 'vn-ticket-summary > vn-card > h5',
|
header: 'vn-ticket-summary > vn-card > h5',
|
||||||
|
@ -560,15 +562,15 @@ export default {
|
||||||
payoutBank: '.vn-dialog vn-autocomplete[ng-model="$ctrl.bankFk"]',
|
payoutBank: '.vn-dialog vn-autocomplete[ng-model="$ctrl.bankFk"]',
|
||||||
payoutDescription: 'vn-textfield[ng-model="$ctrl.receipt.description"]',
|
payoutDescription: 'vn-textfield[ng-model="$ctrl.receipt.description"]',
|
||||||
submitPayout: '.vn-dialog button[response="accept"]',
|
submitPayout: '.vn-dialog button[response="accept"]',
|
||||||
searchWeeklyResult: 'vn-ticket-weekly-index vn-table vn-tbody > vn-tr',
|
searchWeeklyResult: 'vn-ticket-weekly-index vn-card smart-table slot-table table tbody tr',
|
||||||
searchResultDate: 'vn-ticket-summary [label=Landed] span',
|
searchResultDate: 'vn-ticket-summary [label=Landed] span',
|
||||||
topbarSearch: 'vn-searchbar',
|
topbarSearch: 'vn-searchbar',
|
||||||
moreMenu: 'vn-ticket-index vn-icon-button[icon=more_vert]',
|
moreMenu: 'vn-ticket-index vn-icon-button[icon=more_vert]',
|
||||||
fourthWeeklyTicket: 'vn-ticket-weekly-index vn-table vn-tbody vn-tr:nth-child(4)',
|
fourthWeeklyTicket: 'vn-ticket-weekly-index vn-card smart-table slot-table tr:nth-child(4)',
|
||||||
fiveWeeklyTicket: 'vn-ticket-weekly-index vn-table vn-tbody vn-tr:nth-child(5)',
|
fiveWeeklyTicket: 'vn-ticket-weekly-index vn-card smart-table slot-table tr:nth-child(5)',
|
||||||
weeklyTicket: 'vn-ticket-weekly-index vn-table > div > vn-tbody > vn-tr',
|
weeklyTicket: 'vn-ticket-weekly-index vn-card smart-table slot-table table tbody tr',
|
||||||
firstWeeklyTicketDeleteIcon: 'vn-ticket-weekly-index vn-tr:nth-child(1) vn-icon-button[icon="delete"]',
|
firstWeeklyTicketDeleteIcon: 'vn-ticket-weekly-index vn-card smart-table slot-table tr:nth-child(1) vn-icon-button[icon="delete"]',
|
||||||
firstWeeklyTicketAgency: 'vn-ticket-weekly-index vn-tr:nth-child(1) [ng-model="weekly.agencyModeFk"]',
|
firstWeeklyTicketAgency: 'vn-ticket-weekly-index vn-card smart-table slot-table tr:nth-child(1) [ng-model="weekly.agencyModeFk"]',
|
||||||
acceptDeleteTurn: '.vn-confirm.shown button[response="accept"]'
|
acceptDeleteTurn: '.vn-confirm.shown button[response="accept"]'
|
||||||
},
|
},
|
||||||
createTicketView: {
|
createTicketView: {
|
||||||
|
@ -776,8 +778,8 @@ export default {
|
||||||
ipt: 'vn-autocomplete[label="Destination IPT"]',
|
ipt: 'vn-autocomplete[label="Destination IPT"]',
|
||||||
tableIpt: 'vn-autocomplete[name="ipt"]',
|
tableIpt: 'vn-autocomplete[name="ipt"]',
|
||||||
tableFutureIpt: 'vn-autocomplete[name="futureIpt"]',
|
tableFutureIpt: 'vn-autocomplete[name="futureIpt"]',
|
||||||
futureState: 'vn-autocomplete[label="Origin Grouped State"]',
|
futureState: 'vn-check[label="Pending Origin"]',
|
||||||
state: 'vn-autocomplete[label="Destination Grouped State"]',
|
state: 'vn-check[label="Pending Destination"]',
|
||||||
warehouseFk: 'vn-autocomplete[label="Warehouse"]',
|
warehouseFk: 'vn-autocomplete[label="Warehouse"]',
|
||||||
tableButtonSearch: 'vn-button[vn-tooltip="Search"]',
|
tableButtonSearch: 'vn-button[vn-tooltip="Search"]',
|
||||||
moveButton: 'vn-button[vn-tooltip="Advance tickets"]',
|
moveButton: 'vn-button[vn-tooltip="Advance tickets"]',
|
||||||
|
@ -942,9 +944,9 @@ export default {
|
||||||
routeSummary: {
|
routeSummary: {
|
||||||
header: 'vn-route-summary > vn-card > h5',
|
header: 'vn-route-summary > vn-card > h5',
|
||||||
cost: 'vn-route-summary vn-label-value[label="Cost"]',
|
cost: 'vn-route-summary vn-label-value[label="Cost"]',
|
||||||
firstTicketID: 'vn-route-summary vn-tbody > vn-tr:nth-child(1) > vn-td:nth-child(2) > span',
|
firstTicketID: 'vn-route-summary vn-tbody > vn-tr:nth-child(1) > vn-td:nth-child(10) > span',
|
||||||
firstTicketDescriptor: '.vn-popover.shown vn-ticket-descriptor',
|
firstTicketDescriptor: '.vn-popover.shown vn-ticket-descriptor',
|
||||||
firstAlias: 'vn-route-summary vn-tbody > vn-tr:nth-child(1) > vn-td:nth-child(3) > span',
|
firstAlias: 'vn-route-summary vn-tbody > vn-tr:nth-child(1) > vn-td:nth-child(5) > span',
|
||||||
firstClientDescriptor: '.vn-popover.shown vn-client-descriptor',
|
firstClientDescriptor: '.vn-popover.shown vn-client-descriptor',
|
||||||
goToRouteSummaryButton: 'vn-route-summary > vn-card > h5 > a',
|
goToRouteSummaryButton: 'vn-route-summary > vn-card > h5 > a',
|
||||||
|
|
||||||
|
@ -968,6 +970,7 @@ export default {
|
||||||
confirmButton: '.vn-confirm.shown button[response="accept"]'
|
confirmButton: '.vn-confirm.shown button[response="accept"]'
|
||||||
},
|
},
|
||||||
workerSummary: {
|
workerSummary: {
|
||||||
|
summaryIcon: 'vn-worker-descriptor a[title="Go to module summary"]',
|
||||||
header: 'vn-worker-summary h5',
|
header: 'vn-worker-summary h5',
|
||||||
id: 'vn-worker-summary vn-one:nth-child(1) > vn-label-value:nth-child(3) > section > span',
|
id: 'vn-worker-summary vn-one:nth-child(1) > vn-label-value:nth-child(3) > section > span',
|
||||||
email: 'vn-worker-summary vn-one:nth-child(1) > vn-label-value:nth-child(4) > section > span',
|
email: 'vn-worker-summary vn-one:nth-child(1) > vn-label-value:nth-child(4) > section > span',
|
||||||
|
@ -1020,6 +1023,25 @@ export default {
|
||||||
furlough: 'vn-worker-calendar > vn-side-menu [name="absenceTypes"] > vn-chip:nth-child(4)',
|
furlough: 'vn-worker-calendar > vn-side-menu [name="absenceTypes"] > vn-chip:nth-child(4)',
|
||||||
halfFurlough: 'vn-worker-calendar > vn-side-menu [name="absenceTypes"] > vn-chip:nth-child(5)',
|
halfFurlough: 'vn-worker-calendar > vn-side-menu [name="absenceTypes"] > vn-chip:nth-child(5)',
|
||||||
},
|
},
|
||||||
|
workerCreate: {
|
||||||
|
newWorkerButton: 'vn-worker-index a[ui-sref="worker.create"]',
|
||||||
|
firstname: 'vn-worker-create vn-textfield[ng-model="$ctrl.worker.firstName"]',
|
||||||
|
lastname: 'vn-worker-create vn-textfield[ng-model="$ctrl.worker.lastNames"]',
|
||||||
|
birth: 'vn-worker-create vn-date-picker[ng-model="$ctrl.worker.birth"]',
|
||||||
|
fi: 'vn-worker-create vn-textfield[ng-model="$ctrl.worker.fi"]',
|
||||||
|
code: 'vn-worker-create vn-textfield[ng-model="$ctrl.worker.code"]',
|
||||||
|
phone: 'vn-worker-create vn-textfield[ng-model="$ctrl.worker.phone"]',
|
||||||
|
city: 'vn-worker-create vn-textfield[ng-model="$ctrl.worker.city"]',
|
||||||
|
postcode: 'vn-worker-create vn-datalist[ng-model="$ctrl.worker.postcode"]',
|
||||||
|
street: 'vn-worker-create vn-textfield[ng-model="$ctrl.worker.street"]',
|
||||||
|
user: 'vn-worker-create vn-textfield[ng-model="$ctrl.worker.name"]',
|
||||||
|
email: 'vn-worker-create vn-textfield[ng-model="$ctrl.worker.email"]',
|
||||||
|
boss: 'vn-worker-create vn-autocomplete[ng-model="$ctrl.worker.bossFk"]',
|
||||||
|
role: 'vn-worker-create vn-autocomplete[ng-model="$ctrl.worker.roleFk"]',
|
||||||
|
iban: 'vn-worker-create vn-textfield[ng-model="$ctrl.worker.iban"]',
|
||||||
|
switft: 'vn-worker-create vn-autocomplete[ng-model="$ctrl.worker.bankEntityFk"]',
|
||||||
|
createButton: 'vn-worker-create vn-submit[label="Create"]',
|
||||||
|
},
|
||||||
invoiceOutIndex: {
|
invoiceOutIndex: {
|
||||||
topbarSearch: 'vn-searchbar',
|
topbarSearch: 'vn-searchbar',
|
||||||
searchResult: 'vn-invoice-out-index vn-card > vn-table > div > vn-tbody > a.vn-tr',
|
searchResult: 'vn-invoice-out-index vn-card > vn-table > div > vn-tbody > a.vn-tr',
|
||||||
|
|
|
@ -23,6 +23,7 @@ describe('Worker time control path', () => {
|
||||||
|
|
||||||
it('should go to the next month, go to current month and go 1 month in the past', async() => {
|
it('should go to the next month, go to current month and go 1 month in the past', async() => {
|
||||||
let date = new Date();
|
let date = new Date();
|
||||||
|
date.setDate(1);
|
||||||
date.setMonth(date.getMonth() + 1);
|
date.setMonth(date.getMonth() + 1);
|
||||||
let month = date.toLocaleString('default', {month: 'long'});
|
let month = date.toLocaleString('default', {month: 'long'});
|
||||||
|
|
||||||
|
@ -32,6 +33,7 @@ describe('Worker time control path', () => {
|
||||||
expect(result).toContain(month);
|
expect(result).toContain(month);
|
||||||
|
|
||||||
date = new Date();
|
date = new Date();
|
||||||
|
date.setDate(1);
|
||||||
month = date.toLocaleString('default', {month: 'long'});
|
month = date.toLocaleString('default', {month: 'long'});
|
||||||
|
|
||||||
await page.click(selectors.workerTimeControl.previousMonthButton);
|
await page.click(selectors.workerTimeControl.previousMonthButton);
|
||||||
|
@ -40,6 +42,7 @@ describe('Worker time control path', () => {
|
||||||
expect(result).toContain(month);
|
expect(result).toContain(month);
|
||||||
|
|
||||||
date = new Date();
|
date = new Date();
|
||||||
|
date.setDate(1);
|
||||||
date.setMonth(date.getMonth() - 1);
|
date.setMonth(date.getMonth() - 1);
|
||||||
const timestamp = Math.round(date.getTime() / 1000);
|
const timestamp = Math.round(date.getTime() / 1000);
|
||||||
month = date.toLocaleString('default', {month: 'long'});
|
month = date.toLocaleString('default', {month: 'long'});
|
||||||
|
|
|
@ -0,0 +1,74 @@
|
||||||
|
import selectors from '../../helpers/selectors.js';
|
||||||
|
import getBrowser from '../../helpers/puppeteer';
|
||||||
|
|
||||||
|
describe('Worker create path', () => {
|
||||||
|
let browser;
|
||||||
|
let page;
|
||||||
|
let newWorker;
|
||||||
|
beforeAll(async() => {
|
||||||
|
browser = await getBrowser();
|
||||||
|
page = browser.page;
|
||||||
|
await page.loginAndModule('hr', 'worker');
|
||||||
|
await page.waitToClick(selectors.workerCreate.newWorkerButton);
|
||||||
|
await page.waitForState('worker.create');
|
||||||
|
});
|
||||||
|
|
||||||
|
afterAll(async() => {
|
||||||
|
await browser.close();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should insert default data', async() => {
|
||||||
|
await page.write(selectors.workerCreate.firstname, 'Victor');
|
||||||
|
await page.write(selectors.workerCreate.lastname, 'Von Doom');
|
||||||
|
await page.write(selectors.workerCreate.fi, '78457139E');
|
||||||
|
await page.write(selectors.workerCreate.phone, '12356789');
|
||||||
|
await page.write(selectors.workerCreate.postcode, '46680');
|
||||||
|
await page.write(selectors.workerCreate.street, 'S/ Doomstadt');
|
||||||
|
await page.write(selectors.workerCreate.email, 'doctorDoom@marvel.com');
|
||||||
|
await page.write(selectors.workerCreate.iban, 'ES9121000418450200051332');
|
||||||
|
await page.autocompleteSearch(selectors.workerCreate.switft, 'BBKKESMMMMM');
|
||||||
|
|
||||||
|
// should check for autocompleted worker code and worker user name
|
||||||
|
const workerCode = await page
|
||||||
|
.waitToGetProperty(selectors.workerCreate.code, 'value');
|
||||||
|
|
||||||
|
newWorker = await page
|
||||||
|
.waitToGetProperty(selectors.workerCreate.user, 'value');
|
||||||
|
|
||||||
|
expect(workerCode).toEqual('VVD');
|
||||||
|
expect(newWorker).toContain('victorvd');
|
||||||
|
|
||||||
|
// should fail if necessary data is void
|
||||||
|
await page.waitToClick(selectors.workerCreate.createButton);
|
||||||
|
let message = await page.waitForSnackbar();
|
||||||
|
|
||||||
|
expect(message.text).toContain('is a required argument');
|
||||||
|
|
||||||
|
// 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.waitToClick(selectors.workerCreate.createButton);
|
||||||
|
message = await page.waitForSnackbar();
|
||||||
|
await page.waitForState('worker.card.basicData');
|
||||||
|
|
||||||
|
expect(message.text).toContain('Data saved!');
|
||||||
|
|
||||||
|
// 'rollback'
|
||||||
|
await page.loginAndModule('sysadmin', 'account');
|
||||||
|
await page.accessToSearchResult(newWorker);
|
||||||
|
|
||||||
|
await page.waitToClick(selectors.accountDescriptor.menuButton);
|
||||||
|
await page.waitToClick(selectors.accountDescriptor.deactivateUser);
|
||||||
|
await page.waitToClick(selectors.accountDescriptor.acceptButton);
|
||||||
|
message = await page.waitForSnackbar();
|
||||||
|
|
||||||
|
expect(message.text).toContain('User deactivated!');
|
||||||
|
|
||||||
|
await page.waitToClick(selectors.accountDescriptor.menuButton);
|
||||||
|
await page.waitToClick(selectors.accountDescriptor.disableAccount);
|
||||||
|
await page.waitToClick(selectors.accountDescriptor.acceptButton);
|
||||||
|
message = await page.waitForSnackbar();
|
||||||
|
|
||||||
|
expect(message.text).toContain('Account disabled!');
|
||||||
|
});
|
||||||
|
});
|
|
@ -36,11 +36,20 @@ describe('Item Create', () => {
|
||||||
await page.waitForState('item.create');
|
await page.waitForState('item.create');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should create the Infinity Gauntlet item', async() => {
|
it('should throw an error when insert an invalid priority', async() => {
|
||||||
await page.write(selectors.itemCreateView.temporalName, 'Infinity Gauntlet');
|
await page.write(selectors.itemCreateView.temporalName, 'Infinity Gauntlet');
|
||||||
await page.autocompleteSearch(selectors.itemCreateView.type, 'Crisantemo');
|
await page.autocompleteSearch(selectors.itemCreateView.type, 'Crisantemo');
|
||||||
await page.autocompleteSearch(selectors.itemCreateView.intrastat, 'Coral y materiales similares');
|
await page.autocompleteSearch(selectors.itemCreateView.intrastat, 'Coral y materiales similares');
|
||||||
await page.autocompleteSearch(selectors.itemCreateView.origin, 'Holand');
|
await page.autocompleteSearch(selectors.itemCreateView.origin, 'Holand');
|
||||||
|
await page.clearInput(selectors.itemCreateView.priority);
|
||||||
|
await page.waitToClick(selectors.itemCreateView.createButton);
|
||||||
|
const message = await page.waitForSnackbar();
|
||||||
|
|
||||||
|
expect(message.text).toContain('Valid priorities');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create the Infinity Gauntlet item', async() => {
|
||||||
|
await page.autocompleteSearch(selectors.itemCreateView.priority, '2');
|
||||||
await page.waitToClick(selectors.itemCreateView.createButton);
|
await page.waitToClick(selectors.itemCreateView.createButton);
|
||||||
const message = await page.waitForSnackbar();
|
const message = await page.waitForSnackbar();
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ describe('Ticket Advance path', () => {
|
||||||
await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton);
|
await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton);
|
||||||
await page.autocompleteSearch(selectors.ticketAdvance.ipt, 'Horizontal');
|
await page.autocompleteSearch(selectors.ticketAdvance.ipt, 'Horizontal');
|
||||||
await page.waitToClick(selectors.ticketAdvance.submit);
|
await page.waitToClick(selectors.ticketAdvance.submit);
|
||||||
await page.waitForNumberOfElements(selectors.ticketAdvance.table, 0);
|
await page.waitForNumberOfElements(selectors.ticketAdvance.table, 1);
|
||||||
|
|
||||||
await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton);
|
await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton);
|
||||||
await page.clearInput(selectors.ticketAdvance.ipt);
|
await page.clearInput(selectors.ticketAdvance.ipt);
|
||||||
|
@ -62,7 +62,7 @@ describe('Ticket Advance path', () => {
|
||||||
await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton);
|
await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton);
|
||||||
await page.autocompleteSearch(selectors.ticketAdvance.futureIpt, 'Horizontal');
|
await page.autocompleteSearch(selectors.ticketAdvance.futureIpt, 'Horizontal');
|
||||||
await page.waitToClick(selectors.ticketAdvance.submit);
|
await page.waitToClick(selectors.ticketAdvance.submit);
|
||||||
await page.waitForNumberOfElements(selectors.ticketAdvance.table, 0);
|
await page.waitForNumberOfElements(selectors.ticketAdvance.table, 1);
|
||||||
|
|
||||||
await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton);
|
await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton);
|
||||||
await page.clearInput(selectors.ticketAdvance.futureIpt);
|
await page.clearInput(selectors.ticketAdvance.futureIpt);
|
||||||
|
@ -70,26 +70,36 @@ describe('Ticket Advance path', () => {
|
||||||
await page.waitForNumberOfElements(selectors.ticketAdvance.table, 1);
|
await page.waitForNumberOfElements(selectors.ticketAdvance.table, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should search with the origin grouped state', async() => {
|
it('should search with the origin pending state', async() => {
|
||||||
await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton);
|
await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton);
|
||||||
await page.autocompleteSearch(selectors.ticketAdvance.futureState, 'Free');
|
await page.waitToClick(selectors.ticketAdvance.futureState);
|
||||||
await page.waitToClick(selectors.ticketAdvance.submit);
|
await page.waitToClick(selectors.ticketAdvance.submit);
|
||||||
await page.waitForNumberOfElements(selectors.ticketAdvance.table, 1);
|
await page.waitForNumberOfElements(selectors.ticketAdvance.table, 1);
|
||||||
|
|
||||||
await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton);
|
await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton);
|
||||||
await page.clearInput(selectors.ticketAdvance.futureState);
|
await page.waitToClick(selectors.ticketAdvance.futureState);
|
||||||
|
await page.waitToClick(selectors.ticketAdvance.submit);
|
||||||
|
await page.waitForNumberOfElements(selectors.ticketAdvance.table, 0);
|
||||||
|
|
||||||
|
await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton);
|
||||||
|
await page.waitToClick(selectors.ticketAdvance.futureState);
|
||||||
await page.waitToClick(selectors.ticketAdvance.submit);
|
await page.waitToClick(selectors.ticketAdvance.submit);
|
||||||
await page.waitForNumberOfElements(selectors.ticketAdvance.table, 1);
|
await page.waitForNumberOfElements(selectors.ticketAdvance.table, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should search with the destination grouped state', async() => {
|
it('should search with the destination grouped state', async() => {
|
||||||
await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton);
|
await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton);
|
||||||
await page.autocompleteSearch(selectors.ticketAdvance.state, 'Free');
|
await page.waitToClick(selectors.ticketAdvance.state);
|
||||||
await page.waitToClick(selectors.ticketAdvance.submit);
|
await page.waitToClick(selectors.ticketAdvance.submit);
|
||||||
await page.waitForNumberOfElements(selectors.ticketAdvance.table, 0);
|
await page.waitForNumberOfElements(selectors.ticketAdvance.table, 0);
|
||||||
|
|
||||||
await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton);
|
await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton);
|
||||||
await page.clearInput(selectors.ticketAdvance.state);
|
await page.waitToClick(selectors.ticketAdvance.state);
|
||||||
|
await page.waitToClick(selectors.ticketAdvance.submit);
|
||||||
|
await page.waitForNumberOfElements(selectors.ticketAdvance.table, 1);
|
||||||
|
|
||||||
|
await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton);
|
||||||
|
await page.waitToClick(selectors.ticketAdvance.state);
|
||||||
await page.waitToClick(selectors.ticketAdvance.submit);
|
await page.waitToClick(selectors.ticketAdvance.submit);
|
||||||
await page.waitForNumberOfElements(selectors.ticketAdvance.table, 1);
|
await page.waitForNumberOfElements(selectors.ticketAdvance.table, 1);
|
||||||
});
|
});
|
||||||
|
@ -116,42 +126,7 @@ describe('Ticket Advance path', () => {
|
||||||
await page.waitForNumberOfElements(selectors.ticketAdvance.table, 1);
|
await page.waitForNumberOfElements(selectors.ticketAdvance.table, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should search in smart-table with stock', async() => {
|
it('should check the one ticket and move to the present', async() => {
|
||||||
await page.waitToClick(selectors.ticketAdvance.tableButtonSearch);
|
|
||||||
await page.write(selectors.ticketAdvance.tableStock, '5');
|
|
||||||
await page.waitForNumberOfElements(selectors.ticketAdvance.table, 2);
|
|
||||||
|
|
||||||
await page.waitToClick(selectors.ticketAdvance.tableButtonSearch);
|
|
||||||
await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton);
|
|
||||||
await page.waitToClick(selectors.ticketAdvance.submit);
|
|
||||||
await page.waitForNumberOfElements(selectors.ticketAdvance.table, 1);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should search in smart-table with especified Lines', async() => {
|
|
||||||
await page.waitToClick(selectors.ticketAdvance.tableButtonSearch);
|
|
||||||
await page.write(selectors.ticketAdvance.tableLines, '0');
|
|
||||||
await page.keyboard.press('Enter');
|
|
||||||
await page.waitForNumberOfElements(selectors.ticketAdvance.table, 1);
|
|
||||||
|
|
||||||
await page.waitToClick(selectors.ticketAdvance.tableButtonSearch);
|
|
||||||
await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton);
|
|
||||||
await page.waitToClick(selectors.ticketAdvance.submit);
|
|
||||||
await page.waitForNumberOfElements(selectors.ticketAdvance.table, 1);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should search in smart-table with especified Liters', async() => {
|
|
||||||
await page.waitToClick(selectors.ticketAdvance.tableButtonSearch);
|
|
||||||
await page.write(selectors.ticketAdvance.tableLiters, '0');
|
|
||||||
await page.keyboard.press('Enter');
|
|
||||||
await page.waitForNumberOfElements(selectors.ticketAdvance.table, 1);
|
|
||||||
|
|
||||||
await page.waitToClick(selectors.ticketAdvance.tableButtonSearch);
|
|
||||||
await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton);
|
|
||||||
await page.waitToClick(selectors.ticketAdvance.submit);
|
|
||||||
await page.waitForNumberOfElements(selectors.ticketAdvance.table, 1);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should check the three last tickets and move to the future', async() => {
|
|
||||||
await page.waitToClick(selectors.ticketAdvance.multiCheck);
|
await page.waitToClick(selectors.ticketAdvance.multiCheck);
|
||||||
await page.waitToClick(selectors.ticketAdvance.moveButton);
|
await page.waitToClick(selectors.ticketAdvance.moveButton);
|
||||||
await page.waitToClick(selectors.ticketAdvance.acceptButton);
|
await page.waitToClick(selectors.ticketAdvance.acceptButton);
|
||||||
|
|
|
@ -87,6 +87,7 @@ ngModule.vnComponent('vnButtonMenu', {
|
||||||
selectFields: '<?',
|
selectFields: '<?',
|
||||||
initialData: '<?',
|
initialData: '<?',
|
||||||
showFilter: '<?',
|
showFilter: '<?',
|
||||||
|
fields: '<?',
|
||||||
field: '=?',
|
field: '=?',
|
||||||
url: '@?',
|
url: '@?',
|
||||||
data: '<?',
|
data: '<?',
|
||||||
|
|
|
@ -147,28 +147,17 @@ export default class CrudModel extends ModelProxy {
|
||||||
this.moreRows = null;
|
this.moreRows = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
getChanges() {
|
||||||
* Saves current changes on the server.
|
if (!this.isChanged) return null;
|
||||||
*
|
|
||||||
* @return {Promise} The save request promise
|
|
||||||
*/
|
|
||||||
save() {
|
|
||||||
if (!this.isChanged)
|
|
||||||
return this.$q.resolve();
|
|
||||||
|
|
||||||
let deletes = [];
|
const deletes = [];
|
||||||
let updates = [];
|
const updates = [];
|
||||||
let creates = [];
|
const creates = [];
|
||||||
let orgDeletes = [];
|
|
||||||
let orgUpdates = [];
|
|
||||||
let orgCreates = [];
|
|
||||||
|
|
||||||
let pk = this.primaryKey;
|
const pk = this.primaryKey;
|
||||||
|
|
||||||
for (let row of this.removed) {
|
for (let row of this.removed)
|
||||||
deletes.push(row.$orgRow[pk]);
|
deletes.push(row.$orgRow[pk]);
|
||||||
orgDeletes.push(row);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (let row of this.data) {
|
for (let row of this.data) {
|
||||||
if (row.$isNew) {
|
if (row.$isNew) {
|
||||||
|
@ -178,7 +167,6 @@ export default class CrudModel extends ModelProxy {
|
||||||
data[prop] = row[prop];
|
data[prop] = row[prop];
|
||||||
}
|
}
|
||||||
creates.push(row);
|
creates.push(row);
|
||||||
orgCreates.push(row);
|
|
||||||
} else if (row.$oldData) {
|
} else if (row.$oldData) {
|
||||||
let data = {};
|
let data = {};
|
||||||
for (let prop in row.$oldData)
|
for (let prop in row.$oldData)
|
||||||
|
@ -187,28 +175,38 @@ export default class CrudModel extends ModelProxy {
|
||||||
data,
|
data,
|
||||||
where: {[pk]: row.$orgRow[pk]}
|
where: {[pk]: row.$orgRow[pk]}
|
||||||
});
|
});
|
||||||
orgUpdates.push(row);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let changes = {deletes, updates, creates};
|
const changes = {deletes, updates, creates};
|
||||||
|
|
||||||
for (let prop in changes) {
|
for (let prop in changes) {
|
||||||
if (changes[prop].length === 0)
|
if (changes[prop].length === 0)
|
||||||
changes[prop] = undefined;
|
changes[prop] = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!changes)
|
return changes;
|
||||||
return this.$q.resolve();
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Saves current changes on the server.
|
||||||
|
*
|
||||||
|
* @return {Promise} The save request promise
|
||||||
|
*/
|
||||||
|
save() {
|
||||||
|
const pk = this.primaryKey;
|
||||||
|
const changes = this.getChanges();
|
||||||
|
if (!changes) return this.$q.resolve();
|
||||||
|
|
||||||
|
const creates = changes.creates || [];
|
||||||
let url = this.saveUrl ? this.saveUrl : `${this._url}/crud`;
|
let url = this.saveUrl ? this.saveUrl : `${this._url}/crud`;
|
||||||
return this.$http.post(url, changes)
|
return this.$http.post(url, changes)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
const created = res.data;
|
const created = res.data;
|
||||||
|
|
||||||
// Apply new data to created instances
|
// Apply new data to created instances
|
||||||
for (let i = 0; i < orgCreates.length; i++) {
|
for (let i = 0; i < creates.length; i++) {
|
||||||
const row = orgCreates[i];
|
const row = creates[i];
|
||||||
row[pk] = created[i][pk];
|
row[pk] = created[i][pk];
|
||||||
|
|
||||||
for (let prop in row) {
|
for (let prop in row) {
|
||||||
|
|
|
@ -478,8 +478,8 @@ export default class SmartTable extends Component {
|
||||||
|
|
||||||
const params = {q: JSON.stringify(stateFilter)};
|
const params = {q: JSON.stringify(stateFilter)};
|
||||||
|
|
||||||
this.$state.go(this.$state.current.name, params, {location: 'replace'});
|
this.$state.go(this.$state.current.name, params, {location: 'replace'})
|
||||||
this.refresh();
|
.then(() => this.refresh());
|
||||||
}
|
}
|
||||||
|
|
||||||
applySort() {
|
applySort() {
|
||||||
|
@ -499,8 +499,8 @@ export default class SmartTable extends Component {
|
||||||
stateFilter.tableOrder = order;
|
stateFilter.tableOrder = order;
|
||||||
|
|
||||||
const params = {q: JSON.stringify(stateFilter)};
|
const params = {q: JSON.stringify(stateFilter)};
|
||||||
this.$state.go(this.$state.current.name, params, {location: 'replace'});
|
this.$state.go(this.$state.current.name, params, {location: 'replace'})
|
||||||
this.refresh();
|
.then(() => this.refresh());
|
||||||
}
|
}
|
||||||
|
|
||||||
filterSanitizer(field) {
|
filterSanitizer(field) {
|
||||||
|
@ -589,7 +589,7 @@ export default class SmartTable extends Component {
|
||||||
refresh() {
|
refresh() {
|
||||||
this.isRefreshing = true;
|
this.isRefreshing = true;
|
||||||
this.model.refresh()
|
this.model.refresh()
|
||||||
.then(() => this.isRefreshing = false);
|
.finally(() => this.isRefreshing = false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -160,7 +160,7 @@ describe('Component smartTable', () => {
|
||||||
describe('applySort()', () => {
|
describe('applySort()', () => {
|
||||||
it('should call the $state go and model refresh without making changes on the model order', () => {
|
it('should call the $state go and model refresh without making changes on the model order', () => {
|
||||||
controller.$state = {
|
controller.$state = {
|
||||||
go: jest.fn(),
|
go: jest.fn().mockReturnValue(new Promise(resolve => resolve())),
|
||||||
current: {
|
current: {
|
||||||
name: 'section'
|
name: 'section'
|
||||||
}
|
}
|
||||||
|
@ -171,13 +171,12 @@ describe('Component smartTable', () => {
|
||||||
|
|
||||||
expect(controller.model.order).toBeUndefined();
|
expect(controller.model.order).toBeUndefined();
|
||||||
expect(controller.$state.go).toHaveBeenCalled();
|
expect(controller.$state.go).toHaveBeenCalled();
|
||||||
expect(controller.refresh).toHaveBeenCalled();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should call the $state go and model refresh after setting model order according to the controller sortCriteria', () => {
|
it('should call the $state go and model refresh after setting model order according to the controller sortCriteria', () => {
|
||||||
const orderBy = {field: 'myField', sortType: 'ASC'};
|
const orderBy = {field: 'myField', sortType: 'ASC'};
|
||||||
controller.$state = {
|
controller.$state = {
|
||||||
go: jest.fn(),
|
go: jest.fn().mockReturnValue(new Promise(resolve => resolve())),
|
||||||
current: {
|
current: {
|
||||||
name: 'section'
|
name: 'section'
|
||||||
}
|
}
|
||||||
|
@ -190,7 +189,6 @@ describe('Component smartTable', () => {
|
||||||
|
|
||||||
expect(controller.model.order).toEqual(`${orderBy.field} ${orderBy.sortType}`);
|
expect(controller.model.order).toEqual(`${orderBy.field} ${orderBy.sortType}`);
|
||||||
expect(controller.$state.go).toHaveBeenCalled();
|
expect(controller.$state.go).toHaveBeenCalled();
|
||||||
expect(controller.refresh).toHaveBeenCalled();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -293,12 +291,10 @@ describe('Component smartTable', () => {
|
||||||
controller.$inputsScope = {
|
controller.$inputsScope = {
|
||||||
searchProps: {}
|
searchProps: {}
|
||||||
};
|
};
|
||||||
jest.spyOn(controller, 'refresh');
|
|
||||||
|
|
||||||
controller.defaultFilter();
|
controller.defaultFilter();
|
||||||
|
|
||||||
expect(controller.model.addFilter).toHaveBeenCalled();
|
expect(controller.model.addFilter).toHaveBeenCalled();
|
||||||
expect(controller.refresh).toHaveBeenCalled();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,7 @@ vn-log {
|
||||||
& > td.after,
|
& > td.after,
|
||||||
& > th.after {
|
& > th.after {
|
||||||
width: 40%;
|
width: 40%;
|
||||||
|
white-space: pre-line;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
Reset password: Restrablecer contraseña
|
Reset password: Restrablecer contraseña
|
||||||
New password: Nueva contraseña
|
New password: Nueva contraseña
|
||||||
Repeat password: Repetir contraseñaç
|
Repeat password: Repetir contraseña
|
||||||
Password changed!: ¡Contraseña cambiada!
|
Password changed!: ¡Contraseña cambiada!
|
||||||
Password requirements: >
|
Password requirements: >
|
||||||
La contraseña debe tener al menos {{ length }} caracteres de longitud,
|
La contraseña debe tener al menos {{ length }} caracteres de longitud,
|
||||||
|
|
|
@ -142,10 +142,13 @@
|
||||||
"You don't own the role and you can't assign it to another user": "You don't own the role and you can't assign it to another user",
|
"You don't own the role and you can't assign it to another user": "You don't own the role and you can't assign it to another user",
|
||||||
"Email verify": "Email verify",
|
"Email verify": "Email verify",
|
||||||
"Ticket merged": "Ticket [{{originId}}]({{{originFullPath}}}) ({{{originDated}}}) merged with [{{destinationId}}]({{{destinationFullPath}}}) ({{{destinationDated}}})",
|
"Ticket merged": "Ticket [{{originId}}]({{{originFullPath}}}) ({{{originDated}}}) merged with [{{destinationId}}]({{{destinationFullPath}}}) ({{{destinationDated}}})",
|
||||||
"Sale(s) blocked, please contact production": "Sale(s) blocked, please contact production",
|
|
||||||
"App locked": "App locked by user {{userId}}",
|
"App locked": "App locked by user {{userId}}",
|
||||||
"The sales of the receiver ticket can't be modified": "The sales of the receiver ticket can't be modified",
|
"The sales of the receiver ticket can't be modified": "The sales of the receiver ticket can't be modified",
|
||||||
"Receipt's bank was not found": "Receipt's bank was not found",
|
"Receipt's bank was not found": "Receipt's bank was not found",
|
||||||
"This receipt was not compensated": "This receipt was not compensated",
|
"This receipt was not compensated": "This receipt was not compensated",
|
||||||
"Client's email was not found": "Client's email was not found"
|
"Client's email was not found": "Client's email was not found",
|
||||||
|
"It is not possible to modify tracked sales": "It is not possible to modify tracked sales",
|
||||||
|
"It is not possible to modify sales that their articles are from Floramondo": "It is not possible to modify sales that their articles are from Floramondo",
|
||||||
|
"It is not possible to modify cloned sales": "It is not possible to modify cloned sales",
|
||||||
|
"Valid priorities: 1,2,3": "Valid priorities: 1,2,3"
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,7 +84,6 @@
|
||||||
"The current ticket can't be modified": "El ticket actual no puede ser modificado",
|
"The current ticket can't be modified": "El ticket actual no puede ser modificado",
|
||||||
"The current claim can't be modified": "La reclamación actual no puede ser modificada",
|
"The current claim can't be modified": "La reclamación actual no puede ser modificada",
|
||||||
"The sales of this ticket can't be modified": "Las lineas de este ticket no pueden ser modificadas",
|
"The sales of this ticket can't be modified": "Las lineas de este ticket no pueden ser modificadas",
|
||||||
"Sale(s) blocked, contact production": "Linea(s) bloqueada(s), contacte con produccion",
|
|
||||||
"Please select at least one sale": "Por favor selecciona al menos una linea",
|
"Please select at least one sale": "Por favor selecciona al menos una linea",
|
||||||
"All sales must belong to the same ticket": "Todas las lineas deben pertenecer al mismo ticket",
|
"All sales must belong to the same ticket": "Todas las lineas deben pertenecer al mismo ticket",
|
||||||
"NO_ZONE_FOR_THIS_PARAMETERS": "Para este día no hay ninguna zona configurada",
|
"NO_ZONE_FOR_THIS_PARAMETERS": "Para este día no hay ninguna zona configurada",
|
||||||
|
@ -252,9 +251,18 @@
|
||||||
"Receipt's bank was not found": "No se encontró el banco del recibo",
|
"Receipt's bank was not found": "No se encontró el banco del recibo",
|
||||||
"This receipt was not compensated": "Este recibo no ha sido compensado",
|
"This receipt was not compensated": "Este recibo no ha sido compensado",
|
||||||
"Client's email was not found": "No se encontró el email del cliente",
|
"Client's email was not found": "No se encontró el email del cliente",
|
||||||
|
"This worker code already exists": "Este codigo de trabajador ya existe",
|
||||||
|
"This personal mail already exists": "Este correo personal ya existe",
|
||||||
|
"This worker already exists": "Este trabajador ya existe",
|
||||||
"App name does not exist": "El nombre de aplicación no es válido",
|
"App name does not exist": "El nombre de aplicación no es válido",
|
||||||
"Try again": "Vuelve a intentarlo",
|
"Try again": "Vuelve a intentarlo",
|
||||||
"Aplicación bloqueada por el usuario 9": "Aplicación bloqueada por el usuario 9",
|
"Aplicación bloqueada por el usuario 9": "Aplicación bloqueada por el usuario 9",
|
||||||
"Failed to upload file": "Error al subir archivo",
|
"Failed to upload file": "Error al subir archivo",
|
||||||
"The DOCUWARE PDF document does not exists": "The DOCUWARE PDF document does not exists"
|
"The DOCUWARE PDF document does not exists": "El documento PDF Docuware no existe",
|
||||||
|
"It is not possible to modify tracked sales": "No es posible modificar líneas de pedido que se hayan empezado a preparar",
|
||||||
|
"It is not possible to modify sales that their articles are from Floramondo": "No es posible modificar líneas de pedido cuyos artículos sean de Floramondo",
|
||||||
|
"It is not possible to modify cloned sales": "No es posible modificar líneas de pedido clonadas",
|
||||||
|
"A supplier with the same name already exists. Change the country.": "Un proveedor con el mismo nombre ya existe. Cambie el país.",
|
||||||
|
"There is no assigned email for this client": "No hay correo asignado para este cliente"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
module.exports = class NotFoundError extends Error {
|
||||||
|
constructor(message = 'Not found', code = 'NOT_FOUND', ...translateArgs) {
|
||||||
|
super(message);
|
||||||
|
this.name = 'NotFoundError';
|
||||||
|
this.statusCode = 404;
|
||||||
|
this.code = code;
|
||||||
|
this.translateArgs = translateArgs;
|
||||||
|
}
|
||||||
|
};
|
|
@ -19,10 +19,26 @@ class Controller extends ModuleCard {
|
||||||
}, {
|
}, {
|
||||||
relation: 'ticket',
|
relation: 'ticket',
|
||||||
scope: {
|
scope: {
|
||||||
fields: ['zoneFk'],
|
fields: ['zoneFk', 'addressFk'],
|
||||||
include: {
|
include: [
|
||||||
relation: 'zone'
|
{
|
||||||
|
relation: 'zone',
|
||||||
|
scope: {
|
||||||
|
fields: ['name']
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
relation: 'address',
|
||||||
|
scope: {
|
||||||
|
fields: ['provinceFk'],
|
||||||
|
include: {
|
||||||
|
relation: 'province',
|
||||||
|
scope: {
|
||||||
|
fields: ['name']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}]
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
relation: 'claimState',
|
relation: 'claimState',
|
||||||
|
|
|
@ -55,9 +55,13 @@
|
||||||
<span
|
<span
|
||||||
ng-click="zoneDescriptor.show($event, $ctrl.claim.ticket.zoneFk)"
|
ng-click="zoneDescriptor.show($event, $ctrl.claim.ticket.zoneFk)"
|
||||||
class="link">
|
class="link">
|
||||||
{{$ctrl.claim.ticket.zoneFk}}
|
{{$ctrl.claim.ticket.zone.name}}
|
||||||
</span>
|
</span>
|
||||||
</vn-label-value>
|
</vn-label-value>
|
||||||
|
<vn-label-value
|
||||||
|
label="Province"
|
||||||
|
value="{{$ctrl.claim.ticket.address.province.name}}">
|
||||||
|
</vn-label-value>
|
||||||
<vn-label-value
|
<vn-label-value
|
||||||
label="Ticket">
|
label="Ticket">
|
||||||
<span
|
<span
|
||||||
|
|
|
@ -141,6 +141,16 @@ module.exports = Self => {
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Self.validateAsync('isToBeMailed', isToBeMailed, {
|
||||||
|
message: 'There is no assigned email for this client'
|
||||||
|
});
|
||||||
|
|
||||||
|
function isToBeMailed(err, done) {
|
||||||
|
if (this.isToBeMailed == true && !this.email)
|
||||||
|
err();
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
|
||||||
Self.validateAsync('defaultAddressFk', isActive,
|
Self.validateAsync('defaultAddressFk', isActive,
|
||||||
{message: 'Unable to default a disabled consignee'}
|
{message: 'Unable to default a disabled consignee'}
|
||||||
);
|
);
|
||||||
|
|
|
@ -59,13 +59,11 @@ class Controller extends Dialog {
|
||||||
|
|
||||||
if (value) {
|
if (value) {
|
||||||
const accountingType = value.accountingType;
|
const accountingType = value.accountingType;
|
||||||
if (this.originalDescription) {
|
if (accountingType.receiptDescription != null) {
|
||||||
this.receipt.description =
|
this.receipt.description = accountingType.receiptDescription;
|
||||||
`${accountingType && accountingType.receiptDescription}, ${this.originalDescription}`;
|
if (this.originalDescription) this.receipt.description += `, ${this.originalDescription}`;
|
||||||
} else {
|
} else if (this.originalDescription)
|
||||||
this.receipt.description =
|
this.receipt.description = this.originalDescription;
|
||||||
`${accountingType && accountingType.receiptDescription}`;
|
|
||||||
}
|
|
||||||
this.maxAmount = accountingType && accountingType.maxAmount;
|
this.maxAmount = accountingType && accountingType.maxAmount;
|
||||||
|
|
||||||
this.receipt.payed = new Date();
|
this.receipt.payed = new Date();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
Edit buy(s): Editar compra(s)
|
Edit buy(s): Editar compra(s)
|
||||||
Buying value: Precio
|
Buying value: Coste
|
||||||
Freight value: Porte
|
Freight value: Porte
|
||||||
Commission value: Comisión
|
Commission value: Comisión
|
||||||
Package value: Embalaje
|
Package value: Embalaje
|
||||||
|
|
|
@ -114,8 +114,7 @@
|
||||||
<th translate center field="grouping">Grouping</th>
|
<th translate center field="grouping">Grouping</th>
|
||||||
<th translate center field="buyingValue">Buying value</th>
|
<th translate center field="buyingValue">Buying value</th>
|
||||||
<th translate center field="price3">Import</th>
|
<th translate center field="price3">Import</th>
|
||||||
<th translate center expand field="price2">Grouping price</th>
|
<th translate center expand field="price">PVP</th>
|
||||||
<th translate center expand field="price3">Packing price</th>
|
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody ng-repeat="line in buys">
|
<tbody ng-repeat="line in buys">
|
||||||
|
@ -136,8 +135,7 @@
|
||||||
</vn-td>
|
</vn-td>
|
||||||
<td center title="{{::line.buyingValue | currency: 'EUR':2}}">{{::line.buyingValue | currency: 'EUR':2}}</td>
|
<td center title="{{::line.buyingValue | currency: 'EUR':2}}">{{::line.buyingValue | currency: 'EUR':2}}</td>
|
||||||
<td center title="{{::line.quantity * line.buyingValue | currency: 'EUR':2}}">{{::line.quantity * line.buyingValue | currency: 'EUR':2}}</td>
|
<td center title="{{::line.quantity * line.buyingValue | currency: 'EUR':2}}">{{::line.quantity * line.buyingValue | currency: 'EUR':2}}</td>
|
||||||
<td center title="{{::line.price2 | currency: 'EUR':2}}">{{::line.price2 | currency: 'EUR':2}}</td>
|
<td center title="Grouping / Packing">{{::line.price2 | currency: 'EUR':2 | dashIfEmpty}} / {{::line.price3 | currency: 'EUR':2 | dashIfEmpty}}</td>
|
||||||
<td center title="{{::line.price3 | currency: 'EUR':2}}">{{::line.price3 | currency: 'EUR':2}}</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="dark-row">
|
<tr class="dark-row">
|
||||||
<td shrink>
|
<td shrink>
|
||||||
|
|
|
@ -36,13 +36,13 @@
|
||||||
ng-if="$ctrl.isAgricultural()"
|
ng-if="$ctrl.isAgricultural()"
|
||||||
ng-click="$ctrl.showPdfInvoice()"
|
ng-click="$ctrl.showPdfInvoice()"
|
||||||
translate>
|
translate>
|
||||||
Show agricultural invoice as PDF
|
Show agricultural receipt as PDF
|
||||||
</vn-item>
|
</vn-item>
|
||||||
<vn-item
|
<vn-item
|
||||||
ng-if="$ctrl.isAgricultural()"
|
ng-if="$ctrl.isAgricultural()"
|
||||||
ng-click="sendPdfConfirmation.show({email: $ctrl.entity.supplierContact[0].email})"
|
ng-click="sendPdfConfirmation.show({email: $ctrl.entity.supplierContact[0].email})"
|
||||||
translate>
|
translate>
|
||||||
Send agricultural invoice as PDF
|
Send agricultural receipt as PDF
|
||||||
</vn-item>
|
</vn-item>
|
||||||
</slot-menu>
|
</slot-menu>
|
||||||
<slot-body>
|
<slot-body>
|
||||||
|
|
|
@ -19,6 +19,6 @@ To book: Contabilizar
|
||||||
Total amount: Total importe
|
Total amount: Total importe
|
||||||
Total net: Total neto
|
Total net: Total neto
|
||||||
Total stems: Total tallos
|
Total stems: Total tallos
|
||||||
Show agricultural invoice as PDF: Ver factura agrícola como PDF
|
Show agricultural receipt as PDF: Ver recibo agrícola como PDF
|
||||||
Send agricultural invoice as PDF: Enviar factura agrícola como PDF
|
Send agricultural receipt as PDF: Enviar recibo agrícola como PDF
|
||||||
New InvoiceIn: Nueva Factura
|
New InvoiceIn: Nueva Factura
|
|
@ -37,7 +37,8 @@ module.exports = Self => {
|
||||||
'typeFk',
|
'typeFk',
|
||||||
'intrastatFk',
|
'intrastatFk',
|
||||||
'originFk',
|
'originFk',
|
||||||
'relevancy'
|
'priority',
|
||||||
|
'tag'
|
||||||
];
|
];
|
||||||
|
|
||||||
for (const key in params) {
|
for (const key in params) {
|
||||||
|
@ -46,10 +47,14 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
const itemConfig = await models.ItemConfig.findOne({fields: ['validPriorities']}, myOptions);
|
||||||
|
if (!itemConfig.validPriorities.includes(params.priority))
|
||||||
|
throw new UserError(`Valid priorities: ${[...itemConfig.validPriorities]}`);
|
||||||
|
|
||||||
const provisionalName = params.provisionalName;
|
const provisionalName = params.provisionalName;
|
||||||
delete params.provisionalName;
|
delete params.provisionalName;
|
||||||
|
|
||||||
const itemType = await models.ItemType.findById(params.typeFk, myOptions);
|
const itemType = await models.ItemType.findById(params.typeFk, {fields: ['isLaid']}, myOptions);
|
||||||
|
|
||||||
params.isLaid = itemType.isLaid;
|
params.isLaid = itemType.isLaid;
|
||||||
|
|
||||||
|
@ -63,12 +68,13 @@ module.exports = Self => {
|
||||||
|
|
||||||
await Self.rawSql(query, null, myOptions);
|
await Self.rawSql(query, null, myOptions);
|
||||||
|
|
||||||
let nameTag = await models.Tag.findOne({where: {name: 'Nombre temporal'}});
|
const nameTag = await models.Tag.findById(params.tag, {fields: ['id']}, myOptions);
|
||||||
|
|
||||||
let newTags = [];
|
let newTags = [];
|
||||||
|
|
||||||
newTags.push({itemFk: item.id, tagFk: nameTag.id, value: provisionalName, priority: '2'});
|
newTags.push({itemFk: item.id, tagFk: nameTag.id, value: provisionalName, priority: item.priority});
|
||||||
typeTags.forEach(typeTag => {
|
typeTags.forEach(typeTag => {
|
||||||
|
if (nameTag.id != typeTag.tagFk)
|
||||||
newTags.push({itemFk: item.id, tagFk: typeTag.tagFk, value: '', priority: typeTag.priority});
|
newTags.push({itemFk: item.id, tagFk: typeTag.tagFk, value: '', priority: typeTag.priority});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,8 @@ describe('item new()', () => {
|
||||||
originFk: 1,
|
originFk: 1,
|
||||||
provisionalName: 'planta',
|
provisionalName: 'planta',
|
||||||
typeFk: 2,
|
typeFk: 2,
|
||||||
relevancy: 0
|
priority: 2,
|
||||||
|
tag: 1
|
||||||
};
|
};
|
||||||
|
|
||||||
let item = await models.Item.new(itemParams, options);
|
let item = await models.Item.new(itemParams, options);
|
||||||
|
@ -20,7 +21,7 @@ describe('item new()', () => {
|
||||||
|
|
||||||
item.isLaid = itemType.isLaid;
|
item.isLaid = itemType.isLaid;
|
||||||
|
|
||||||
const temporalNameTag = await models.Tag.findOne({where: {name: 'Nombre temporal'}}, options);
|
const temporalNameTag = await models.Tag.findById(itemParams.tag, {fields: ['id']}, options);
|
||||||
|
|
||||||
const temporalName = await models.ItemTag.findOne({
|
const temporalName = await models.ItemTag.findOne({
|
||||||
where: {
|
where: {
|
||||||
|
@ -31,7 +32,7 @@ describe('item new()', () => {
|
||||||
|
|
||||||
item = await models.Item.findById(item.id, null, options);
|
item = await models.Item.findById(item.id, null, options);
|
||||||
|
|
||||||
itemType = await models.ItemType.findById(item.typeFk, options);
|
itemType = await models.ItemType.findById(item.typeFk, {fields: ['isLaid']}, options);
|
||||||
|
|
||||||
item.isLaid = itemType.isLaid;
|
item.isLaid = itemType.isLaid;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,81 @@
|
||||||
|
|
||||||
|
module.exports = function(Self) {
|
||||||
|
Self.remoteMethodCtx('onSubmit', {
|
||||||
|
description: 'Save model changes',
|
||||||
|
accessType: 'WRITE',
|
||||||
|
accepts: [
|
||||||
|
{
|
||||||
|
arg: 'creates',
|
||||||
|
type: ['object'],
|
||||||
|
description: 'The itemTags records to create'
|
||||||
|
}, {
|
||||||
|
arg: 'deletes',
|
||||||
|
type: ['number'],
|
||||||
|
description: 'The itemTags ids to delete'
|
||||||
|
}, {
|
||||||
|
arg: 'updates',
|
||||||
|
type: ['object'],
|
||||||
|
description: 'The itemTags records to update'
|
||||||
|
}, {
|
||||||
|
arg: 'maxPriority',
|
||||||
|
type: 'number',
|
||||||
|
description: 'The maxPriority value'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
returns: {
|
||||||
|
root: true,
|
||||||
|
type: 'object'
|
||||||
|
},
|
||||||
|
http: {
|
||||||
|
verb: 'PATCH',
|
||||||
|
path: '/onSubmit'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Self.onSubmit = async(ctx, options) => {
|
||||||
|
const models = Self.app.models;
|
||||||
|
const args = ctx.args;
|
||||||
|
let tx;
|
||||||
|
const myOptions = {};
|
||||||
|
|
||||||
|
if (typeof options == 'object')
|
||||||
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
|
if (!myOptions.transaction) {
|
||||||
|
tx = await Self.beginTransaction({});
|
||||||
|
myOptions.transaction = tx;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (args.deletes) {
|
||||||
|
for (const itemTagId of args.deletes)
|
||||||
|
await models.ItemTag.destroyById(itemTagId, myOptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.updates) {
|
||||||
|
for (const row of args.updates) {
|
||||||
|
if (row.data.priority) {
|
||||||
|
const itemTag = await models.ItemTag.findById(row.where.id, null, myOptions);
|
||||||
|
await itemTag.updateAttributes({
|
||||||
|
priority: row.data.priority + args.maxPriority
|
||||||
|
}, myOptions);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (const row of args.updates) {
|
||||||
|
const itemTag = await models.ItemTag.findById(row.where.id, null, myOptions);
|
||||||
|
await itemTag.updateAttributes(row.data, myOptions);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.creates) {
|
||||||
|
for (const itemTag of args.creates)
|
||||||
|
await models.ItemTag.create(itemTag, myOptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tx) await tx.commit();
|
||||||
|
} catch (e) {
|
||||||
|
if (tx) await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
|
@ -0,0 +1,96 @@
|
||||||
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
|
describe('tag onSubmit()', () => {
|
||||||
|
it('should delete a tag', async() => {
|
||||||
|
const tx = await models.Item.beginTransaction({});
|
||||||
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
try {
|
||||||
|
const deletes = [40];
|
||||||
|
const ctx = {
|
||||||
|
args: {
|
||||||
|
deletes: deletes
|
||||||
|
}
|
||||||
|
};
|
||||||
|
await models.Tag.onSubmit(ctx, options);
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should update a tag', async() => {
|
||||||
|
const tx = await models.Item.beginTransaction({});
|
||||||
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
try {
|
||||||
|
const updates = [{data: {value: 'Container Test'}, where: {id: 36}}];
|
||||||
|
const ctx = {
|
||||||
|
args: {
|
||||||
|
updates: updates
|
||||||
|
}
|
||||||
|
};
|
||||||
|
await models.Tag.onSubmit(ctx, options);
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create a tag', async() => {
|
||||||
|
const tx = await models.Item.beginTransaction({});
|
||||||
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
try {
|
||||||
|
const creates = [{
|
||||||
|
'itemFk': '6',
|
||||||
|
'priority': 8,
|
||||||
|
'$orgIndex': null,
|
||||||
|
'$oldData': null,
|
||||||
|
'$isNew': true,
|
||||||
|
'tagFk': 3,
|
||||||
|
'value': 'madera'
|
||||||
|
}];
|
||||||
|
const ctx = {
|
||||||
|
args: {
|
||||||
|
creates: creates
|
||||||
|
}
|
||||||
|
};
|
||||||
|
await models.Tag.onSubmit(ctx, options);
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should swap priority for two tags', async() => {
|
||||||
|
const tx = await models.Item.beginTransaction({});
|
||||||
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
try {
|
||||||
|
const updates = [
|
||||||
|
{data: {priority: 2}, where: {id: 36}},
|
||||||
|
{data: {priority: 1}, where: {id: 37}}
|
||||||
|
];
|
||||||
|
const ctx = {
|
||||||
|
args: {
|
||||||
|
updates: updates,
|
||||||
|
maxPriority: 7,
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
await models.Tag.onSubmit(ctx, options);
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
|
@ -16,6 +16,22 @@
|
||||||
"wasteRecipients": {
|
"wasteRecipients": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "Buyers waste report recipients"
|
"description": "Buyers waste report recipients"
|
||||||
|
},
|
||||||
|
"validPriorities": {
|
||||||
|
"type": "array"
|
||||||
|
},
|
||||||
|
"defaultPriority": {
|
||||||
|
"type": "int"
|
||||||
|
},
|
||||||
|
"defaultTag": {
|
||||||
|
"type": "int"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"relations": {
|
||||||
|
"tag": {
|
||||||
|
"type": "belongsTo",
|
||||||
|
"model": "Tag",
|
||||||
|
"foreignKey": "defaultTag"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,3 +1,4 @@
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
require('../methods/tag/filterValue')(Self);
|
require('../methods/tag/filterValue')(Self);
|
||||||
|
require('../methods/tag/onSubmit')(Self);
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,10 +16,24 @@
|
||||||
<vn-card class="vn-pa-lg">
|
<vn-card class="vn-pa-lg">
|
||||||
<vn-horizontal>
|
<vn-horizontal>
|
||||||
<vn-textfield
|
<vn-textfield
|
||||||
label="Temporal name"
|
label="Name"
|
||||||
ng-model="$ctrl.item.provisionalName"
|
ng-model="$ctrl.item.provisionalName"
|
||||||
vn-focus>
|
vn-focus>
|
||||||
</vn-textfield>
|
</vn-textfield>
|
||||||
|
<vn-autocomplete
|
||||||
|
ng-model="$ctrl.item.tag"
|
||||||
|
url="Tags"
|
||||||
|
show-field="name"
|
||||||
|
value-field="id"
|
||||||
|
label="Tag">
|
||||||
|
</vn-autocomplete>
|
||||||
|
<vn-autocomplete
|
||||||
|
data="$ctrl.validPriorities"
|
||||||
|
label="Priority"
|
||||||
|
ng-model="$ctrl.item.priority"
|
||||||
|
show-field="priority"
|
||||||
|
value-field="priority">
|
||||||
|
</vn-autocomplete>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
<vn-horizontal>
|
<vn-horizontal>
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
|
|
|
@ -4,10 +4,26 @@ import Section from 'salix/components/section';
|
||||||
class Controller extends Section {
|
class Controller extends Section {
|
||||||
constructor($element, $) {
|
constructor($element, $) {
|
||||||
super($element, $);
|
super($element, $);
|
||||||
|
this.fetchDefaultPriorityTag();
|
||||||
|
}
|
||||||
|
|
||||||
|
fetchDefaultPriorityTag() {
|
||||||
|
this.validPriorities = [];
|
||||||
|
const filter = {fields: ['defaultPriority', 'defaultTag', 'validPriorities'], limit: 1};
|
||||||
|
this.$http.get(`ItemConfigs`, {filter})
|
||||||
|
.then(res => {
|
||||||
|
if (res.data) {
|
||||||
|
const dataRow = res.data[0];
|
||||||
|
dataRow.validPriorities.forEach(priority => {
|
||||||
|
this.validPriorities.push({priority});
|
||||||
|
});
|
||||||
this.item = {
|
this.item = {
|
||||||
relevancy: 0
|
priority: dataRow.defaultPriority,
|
||||||
|
tag: dataRow.defaultTag
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
onSubmit() {
|
onSubmit() {
|
||||||
this.$.watcher.submit().then(
|
this.$.watcher.submit().then(
|
||||||
|
|
|
@ -35,8 +35,7 @@
|
||||||
<vn-th field="warehouseFk">Warehouse</vn-th>
|
<vn-th field="warehouseFk">Warehouse</vn-th>
|
||||||
<vn-th field="landed">Landed</vn-th>
|
<vn-th field="landed">Landed</vn-th>
|
||||||
<vn-th number>Entry</vn-th>
|
<vn-th number>Entry</vn-th>
|
||||||
<vn-th number vn-tooltip="Price Per Unit">P.P.U</vn-th>
|
<vn-th vn-tooltip="Grouping / Packing">PVP</vn-th>
|
||||||
<vn-th number vn-tooltip="Price Per Package">P.P.P</vn-th>
|
|
||||||
<vn-th number class="expendable">Label</vn-th>
|
<vn-th number class="expendable">Label</vn-th>
|
||||||
<vn-th number>Packing</vn-th>
|
<vn-th number>Packing</vn-th>
|
||||||
<vn-th number>Grouping</vn-th>
|
<vn-th number>Grouping</vn-th>
|
||||||
|
@ -65,8 +64,9 @@
|
||||||
{{::entry.entryFk | dashIfEmpty}}
|
{{::entry.entryFk | dashIfEmpty}}
|
||||||
</span>
|
</span>
|
||||||
</vn-td>
|
</vn-td>
|
||||||
<vn-td number>{{::entry.price2 | dashIfEmpty}}</vn-td>
|
<vn-td title="{{::entry.price2 | currency: 'EUR':2 | dashIfEmpty}} / {{::entry.price3 | currency: 'EUR':2 | dashIfEmpty}}">
|
||||||
<vn-td number>{{::entry.price3 | dashIfEmpty}}</vn-td>
|
{{::entry.price2 | currency: 'EUR':2 | dashIfEmpty}} / {{::entry.price3 | currency: 'EUR':2 | dashIfEmpty}}
|
||||||
|
</vn-td>
|
||||||
<vn-td number class="expendable">{{entry.stickers | dashIfEmpty}}</vn-td>
|
<vn-td number class="expendable">{{entry.stickers | dashIfEmpty}}</vn-td>
|
||||||
<vn-td number>
|
<vn-td number>
|
||||||
<vn-chip translate-attr="{title: 'Packing'}" ng-class="{'message': entry.groupingMode == 2}">
|
<vn-chip translate-attr="{title: 'Packing'}" ng-class="{'message': entry.groupingMode == 2}">
|
||||||
|
@ -84,11 +84,11 @@
|
||||||
class="expendable">
|
class="expendable">
|
||||||
<span
|
<span
|
||||||
vn-tooltip="
|
vn-tooltip="
|
||||||
{{::$ctrl.$t('Cost')}}: {{::entry.buyingValue| dashIfEmpty}}<br>
|
{{::$ctrl.$t('Cost')}}: {{::entry.buyingValue | currency: 'EUR':2 | dashIfEmpty}}<br>
|
||||||
{{::$ctrl.$t('Package')}}: {{::entry.packageValue| dashIfEmpty}}<br>
|
{{::$ctrl.$t('Package')}}: {{::entry.packageValue | currency: 'EUR':2 | dashIfEmpty}}<br>
|
||||||
{{::$ctrl.$t('Freight')}}: {{::entry.freightValue| dashIfEmpty}}<br>
|
{{::$ctrl.$t('Freight')}}: {{::entry.freightValue | currency: 'EUR':2 | dashIfEmpty}}<br>
|
||||||
{{::$ctrl.$t('Comission')}}: {{::entry.comissionValue| dashIfEmpty}}">
|
{{::$ctrl.$t('Comission')}}: {{::entry.comissionValue | currency: 'EUR':2 | dashIfEmpty}}">
|
||||||
{{::entry.cost | dashIfEmpty}}
|
{{::entry.cost | currency: 'EUR':2 | dashIfEmpty}}
|
||||||
</span>
|
</span>
|
||||||
</vn-td>
|
</vn-td>
|
||||||
<vn-td number>{{::entry.weight | dashIfEmpty}}</vn-td>
|
<vn-td number>{{::entry.weight | dashIfEmpty}}</vn-td>
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
data="tags"
|
data="tags"
|
||||||
auto-load="true">
|
auto-load="true">
|
||||||
</vn-crud-model>
|
</vn-crud-model>
|
||||||
<form name="form" ng-submit="$ctrl.onSubmit()" class="vn-w-md">
|
<form name="form" class="vn-w-md">
|
||||||
<vn-card class="vn-pa-lg">
|
<vn-card class="vn-pa-lg">
|
||||||
<vn-horizontal ng-repeat="itemTag in $ctrl.itemTags">
|
<vn-horizontal ng-repeat="itemTag in $ctrl.itemTags">
|
||||||
<vn-autocomplete vn-two vn-id="tag" vn-focus
|
<vn-autocomplete vn-two vn-id="tag" vn-focus
|
||||||
|
@ -74,6 +74,7 @@
|
||||||
</vn-card>
|
</vn-card>
|
||||||
<vn-button-bar>
|
<vn-button-bar>
|
||||||
<vn-submit
|
<vn-submit
|
||||||
|
ng-click="$ctrl.onSubmit()"
|
||||||
disabled="!watcher.dataChanged()"
|
disabled="!watcher.dataChanged()"
|
||||||
label="Save">
|
label="Save">
|
||||||
</vn-submit>
|
</vn-submit>
|
||||||
|
|
|
@ -29,11 +29,17 @@ class Controller extends Section {
|
||||||
}
|
}
|
||||||
|
|
||||||
onSubmit() {
|
onSubmit() {
|
||||||
this.$.watcher.check();
|
const changes = this.$.model.getChanges();
|
||||||
this.$.model.save().then(() => {
|
const data = {
|
||||||
|
creates: changes.creates,
|
||||||
|
deletes: changes.deletes,
|
||||||
|
updates: changes.updates,
|
||||||
|
maxPriority: this.getHighestPriority()
|
||||||
|
};
|
||||||
|
this.$http.patch(`Tags/onSubmit`, data).then(() => {
|
||||||
|
this.$.model.refresh();
|
||||||
this.$.watcher.notifySaved();
|
this.$.watcher.notifySaved();
|
||||||
this.$.watcher.updateOriginalData();
|
this.$.watcher.updateOriginalData();
|
||||||
this.card.reload();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,7 +157,7 @@ class Controller extends Section {
|
||||||
* Apply order to model
|
* Apply order to model
|
||||||
*/
|
*/
|
||||||
applyOrder() {
|
applyOrder() {
|
||||||
if (this.typeId || this.tagGroups.length > 0)
|
if (this.typeId || this.tagGroups.length > 0 || this.itemName)
|
||||||
this.$.model.addFilter(null, {orderBy: this.getOrderBy()});
|
this.$.model.addFilter(null, {orderBy: this.getOrderBy()});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,62 @@
|
||||||
|
const JSZip = require('jszip');
|
||||||
|
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.remoteMethodCtx('downloadZip', {
|
||||||
|
description: 'Download a zip file with multiple routes pdfs',
|
||||||
|
accessType: 'READ',
|
||||||
|
accepts: [
|
||||||
|
{
|
||||||
|
arg: 'id',
|
||||||
|
type: 'string',
|
||||||
|
description: 'The routes 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: '/downloadZip',
|
||||||
|
verb: 'GET'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Self.downloadZip = async function(ctx, id, options) {
|
||||||
|
const models = Self.app.models;
|
||||||
|
const myOptions = {};
|
||||||
|
const zip = new JSZip();
|
||||||
|
|
||||||
|
if (typeof options == 'object')
|
||||||
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
|
const ids = id.split(',');
|
||||||
|
for (let id of ids) {
|
||||||
|
ctx.args.id = id;
|
||||||
|
const routePdf = await models.Route.driverRoutePdf(ctx, id);
|
||||||
|
const fileName = extractFileName(routePdf[2]);
|
||||||
|
const body = routePdf[0];
|
||||||
|
|
||||||
|
zip.file(fileName, body);
|
||||||
|
}
|
||||||
|
|
||||||
|
const stream = zip.generateNodeStream({streamFiles: true});
|
||||||
|
|
||||||
|
return [stream, 'application/zip', `filename="download.zip"`];
|
||||||
|
};
|
||||||
|
|
||||||
|
function extractFileName(str) {
|
||||||
|
const matches = str.match(/"(.*?)"/);
|
||||||
|
return matches ? matches[1] : str;
|
||||||
|
}
|
||||||
|
};
|
|
@ -50,9 +50,12 @@ module.exports = Self => {
|
||||||
am.name AS agencyModeName,
|
am.name AS agencyModeName,
|
||||||
u.nickname AS userNickname,
|
u.nickname AS userNickname,
|
||||||
vn.ticketTotalVolume(t.id) AS volume,
|
vn.ticketTotalVolume(t.id) AS volume,
|
||||||
tob.description
|
tob.description,
|
||||||
|
GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk) ipt
|
||||||
FROM vn.route r
|
FROM vn.route r
|
||||||
JOIN ticket t ON t.routeFk = r.id
|
JOIN ticket t ON t.routeFk = r.id
|
||||||
|
JOIN vn.sale s ON s.ticketFk = t.id
|
||||||
|
JOIN vn.item i ON i.id = s.itemFk
|
||||||
LEFT JOIN ticketState ts ON ts.ticketFk = t.id
|
LEFT JOIN ticketState ts ON ts.ticketFk = t.id
|
||||||
LEFT JOIN state st ON st.id = ts.stateFk
|
LEFT JOIN state st ON st.id = ts.stateFk
|
||||||
LEFT JOIN warehouse wh ON wh.id = t.warehouseFk
|
LEFT JOIN warehouse wh ON wh.id = t.warehouseFk
|
||||||
|
@ -70,7 +73,9 @@ module.exports = Self => {
|
||||||
const where = filter.where;
|
const where = filter.where;
|
||||||
where['r.id'] = filter.id;
|
where['r.id'] = filter.id;
|
||||||
|
|
||||||
stmt.merge(conn.makeSuffix(filter));
|
stmt.merge(conn.makeWhere(filter.where));
|
||||||
|
stmt.merge(conn.makeGroupBy('t.id'));
|
||||||
|
stmt.merge(conn.makeOrderBy(filter.order));
|
||||||
|
|
||||||
const tickets = await conn.executeStmt(stmt, myOptions);
|
const tickets = await conn.executeStmt(stmt, myOptions);
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ module.exports = Self => {
|
||||||
require('../methods/route/driverRoutePdf')(Self);
|
require('../methods/route/driverRoutePdf')(Self);
|
||||||
require('../methods/route/driverRouteEmail')(Self);
|
require('../methods/route/driverRouteEmail')(Self);
|
||||||
require('../methods/route/sendSms')(Self);
|
require('../methods/route/sendSms')(Self);
|
||||||
|
require('../methods/route/downloadZip')(Self);
|
||||||
|
|
||||||
Self.validate('kmStart', validateDistance, {
|
Self.validate('kmStart', validateDistance, {
|
||||||
message: 'Distance must be lesser than 1000'
|
message: 'Distance must be lesser than 1000'
|
||||||
|
|
|
@ -34,12 +34,22 @@ export default class Controller extends Section {
|
||||||
}
|
}
|
||||||
|
|
||||||
showRouteReport() {
|
showRouteReport() {
|
||||||
const routes = [];
|
const routesIds = [];
|
||||||
for (let route of this.checked)
|
for (let route of this.checked)
|
||||||
routes.push(route.id);
|
routesIds.push(route.id);
|
||||||
const routesId = routes.join(',');
|
const stringRoutesIds = routesIds.join(',');
|
||||||
|
|
||||||
this.vnReport.show(`Routes/${routesId}/driver-route-pdf`);
|
if (this.checked.length <= 1) {
|
||||||
|
const url = `api/Routes/${stringRoutesIds}/driver-route-pdf?access_token=${this.vnToken.token}`;
|
||||||
|
window.open(url, '_blank');
|
||||||
|
} else {
|
||||||
|
const serializedParams = this.$httpParamSerializer({
|
||||||
|
access_token: this.vnToken.token,
|
||||||
|
id: stringRoutesIds
|
||||||
|
});
|
||||||
|
const url = `api/Routes/downloadZip?${serializedParams}`;
|
||||||
|
window.open(url, '_blank');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
openClonationDialog() {
|
openClonationDialog() {
|
||||||
|
|
|
@ -44,17 +44,15 @@ describe('Component vnRouteIndex', () => {
|
||||||
|
|
||||||
describe('showRouteReport()', () => {
|
describe('showRouteReport()', () => {
|
||||||
it('should call to the vnReport show method', () => {
|
it('should call to the vnReport show method', () => {
|
||||||
controller.vnReport.show = jest.fn();
|
jest.spyOn(window, 'open').mockReturnThis();
|
||||||
|
|
||||||
const data = controller.$.model.data;
|
const data = controller.$.model.data;
|
||||||
data[0].checked = true;
|
data[0].checked = true;
|
||||||
data[2].checked = true;
|
data[2].checked = true;
|
||||||
|
|
||||||
const routeIds = '1,3';
|
|
||||||
|
|
||||||
controller.showRouteReport();
|
controller.showRouteReport();
|
||||||
|
|
||||||
expect(controller.vnReport.show).toHaveBeenCalledWith(`Routes/${routeIds}/driver-route-pdf`);
|
expect(window.open).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -77,19 +77,35 @@
|
||||||
<vn-thead>
|
<vn-thead>
|
||||||
<vn-tr>
|
<vn-tr>
|
||||||
<vn-th shrink>Order</vn-th>
|
<vn-th shrink>Order</vn-th>
|
||||||
<vn-th number>Ticket id</vn-th>
|
<vn-th>Street</vn-th>
|
||||||
<vn-th>Alias</vn-th>
|
<vn-th>City</vn-th>
|
||||||
|
<vn-th shrink>PC</vn-th>
|
||||||
|
<vn-th>Client</vn-th>
|
||||||
|
<vn-th>Warehouse</vn-th>
|
||||||
<vn-th number shrink>Packages</vn-th>
|
<vn-th number shrink>Packages</vn-th>
|
||||||
<vn-th shrink>m³</vn-th>
|
<vn-th shrink>m³</vn-th>
|
||||||
<vn-th>Warehouse</vn-th>
|
<vn-th shrink>Packaging</vn-th>
|
||||||
<vn-th shrink>PC</vn-th>
|
<vn-th number>Ticket</vn-th>
|
||||||
<vn-th>Street</vn-th>
|
|
||||||
<vn-th shrink></vn-th>
|
<vn-th shrink></vn-th>
|
||||||
</vn-tr>
|
</vn-tr>
|
||||||
</vn-thead>
|
</vn-thead>
|
||||||
<vn-tbody>
|
<vn-tbody>
|
||||||
<vn-tr ng-repeat="ticket in $ctrl.summary.tickets">
|
<vn-tr ng-repeat="ticket in $ctrl.summary.tickets">
|
||||||
<vn-td shrink>{{ticket.priority | dashIfEmpty}}</vn-td>
|
<vn-td shrink>{{ticket.priority | dashIfEmpty}}</vn-td>
|
||||||
|
<vn-td expand title="{{ticket.address.street}}">{{ticket.street}}</vn-td>
|
||||||
|
<vn-td expand>{{ticket.city}}</vn-td>
|
||||||
|
<vn-td shrink>{{ticket.postalCode}}</vn-td>
|
||||||
|
<vn-td>
|
||||||
|
<span
|
||||||
|
ng-click="clientDescriptor.show($event, ticket.clientFk)"
|
||||||
|
class="link">
|
||||||
|
{{ticket.nickname}}
|
||||||
|
</span>
|
||||||
|
</vn-td>
|
||||||
|
<vn-td>{{ticket.warehouseName}}</vn-td>
|
||||||
|
<vn-td number shrink>{{ticket.packages}}</vn-td>
|
||||||
|
<vn-td shrink>{{ticket.volume}}</vn-td>
|
||||||
|
<vn-td shrink>{{ticket.ipt}}</vn-td>
|
||||||
<vn-td number>
|
<vn-td number>
|
||||||
<span
|
<span
|
||||||
ng-click="ticketDescriptor.show($event, ticket.id)"
|
ng-click="ticketDescriptor.show($event, ticket.id)"
|
||||||
|
@ -98,24 +114,12 @@
|
||||||
</span>
|
</span>
|
||||||
</vn-td>
|
</vn-td>
|
||||||
<vn-td>
|
<vn-td>
|
||||||
<span
|
<vn-icon-button
|
||||||
ng-click="clientDescriptor.show($event, ticket.clientFk)"
|
ng-if="::ticket.description"
|
||||||
class="link">
|
vn-tooltip="{{::ticket.description}}"
|
||||||
{{ticket.nickname}}
|
icon="icon-notes"
|
||||||
</span>
|
tabindex="-1">
|
||||||
</vn-td>
|
</vn-icon-button>
|
||||||
<vn-td number shrink>{{ticket.packages}}</vn-td>
|
|
||||||
<vn-td shrink>{{ticket.volume}}</vn-td>
|
|
||||||
<vn-td>{{ticket.warehouseName}}</vn-td>
|
|
||||||
<vn-td shrink>{{ticket.postalCode}}</vn-td>
|
|
||||||
<vn-td expand title="{{ticket.address.street}}">{{ticket.street}}</vn-td>
|
|
||||||
<vn-td shrink>
|
|
||||||
<vn-icon
|
|
||||||
ng-if="ticket.notes.length"
|
|
||||||
vn-tooltip="{{ticket.notes[0].description}}"
|
|
||||||
icon="insert_drive_file"
|
|
||||||
class="bright">
|
|
||||||
</vn-icon>
|
|
||||||
</vn-td>
|
</vn-td>
|
||||||
</vn-tr>
|
</vn-tr>
|
||||||
</vn-tbody>
|
</vn-tbody>
|
||||||
|
|
|
@ -59,8 +59,10 @@
|
||||||
<vn-th field="city">City</vn-th>
|
<vn-th field="city">City</vn-th>
|
||||||
<vn-th field="postalCode" translate-attr="{title: 'Postcode'}" shrink>PC</vn-th>
|
<vn-th field="postalCode" translate-attr="{title: 'Postcode'}" shrink>PC</vn-th>
|
||||||
<vn-th field="clientFk" expand>Client</vn-th>
|
<vn-th field="clientFk" expand>Client</vn-th>
|
||||||
|
<vn-th field="warehouse" expand>Warehouse</vn-th>
|
||||||
<vn-th field="packages" shrink>Packages</vn-th>
|
<vn-th field="packages" shrink>Packages</vn-th>
|
||||||
<vn-th field="volume" shrink>m³</vn-th>
|
<vn-th field="volume" shrink>m³</vn-th>
|
||||||
|
<vn-th field="packaging" shrink>Packaging</vn-th>
|
||||||
<vn-th field="id" number>Ticket</vn-th>
|
<vn-th field="id" number>Ticket</vn-th>
|
||||||
<vn-th shrink></vn-th>
|
<vn-th shrink></vn-th>
|
||||||
<vn-th shrink></vn-th>
|
<vn-th shrink></vn-th>
|
||||||
|
@ -100,8 +102,10 @@
|
||||||
{{::ticket.nickname}}
|
{{::ticket.nickname}}
|
||||||
</span>
|
</span>
|
||||||
</vn-td>
|
</vn-td>
|
||||||
|
<vn-td>{{ticket.warehouseName}}</vn-td>
|
||||||
<vn-td shrink>{{::ticket.packages}}</vn-td>
|
<vn-td shrink>{{::ticket.packages}}</vn-td>
|
||||||
<vn-td shrink>{{::ticket.volume | number:2}}</vn-td>
|
<vn-td shrink>{{::ticket.volume | number:2}}</vn-td>
|
||||||
|
<vn-td shrink>{{::ticket.ipt}}</vn-td>
|
||||||
<vn-td number>
|
<vn-td number>
|
||||||
<span
|
<span
|
||||||
ng-click="ticketDescriptor.show($event, ticket.id)"
|
ng-click="ticketDescriptor.show($event, ticket.id)"
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"module": "shelving",
|
"module": "shelving",
|
||||||
"name": "Shelvings",
|
"name": "Shelvings",
|
||||||
"icon" : "contact_support",
|
"icon" : "icon-inventory",
|
||||||
"dependencies": ["worker"],
|
"dependencies": ["worker"],
|
||||||
"validations" : true,
|
"validations" : true,
|
||||||
"menus": {
|
"menus": {
|
||||||
"main": [
|
"main": [
|
||||||
{"state": "shelving.index", "icon": "contact_support"}
|
{"state": "shelving.index", "icon": "icon-inventory"}
|
||||||
],
|
],
|
||||||
"card": [
|
"card": [
|
||||||
{"state": "shelving.card.basicData", "icon": "settings"},
|
{"state": "shelving.card.basicData", "icon": "settings"},
|
||||||
|
|
|
@ -16,10 +16,6 @@ module.exports = Self => {
|
||||||
message: 'The social name cannot be empty'
|
message: 'The social name cannot be empty'
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.validatesUniquenessOf('name', {
|
|
||||||
message: 'The supplier name must be unique'
|
|
||||||
});
|
|
||||||
|
|
||||||
if (this.city) {
|
if (this.city) {
|
||||||
Self.validatesPresenceOf('city', {
|
Self.validatesPresenceOf('city', {
|
||||||
message: 'City cannot be empty'
|
message: 'City cannot be empty'
|
||||||
|
@ -117,6 +113,27 @@ module.exports = Self => {
|
||||||
throw new UserError('You can not modify is pay method checked');
|
throw new UserError('You can not modify is pay method checked');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Self.validateAsync('name', 'countryFk', hasSupplierSameName, {
|
||||||
|
message: 'A supplier with the same name already exists. Change the country.'
|
||||||
|
});
|
||||||
|
|
||||||
|
async function hasSupplierSameName(err, done) {
|
||||||
|
if (!this.name || !this.countryFk) done();
|
||||||
|
const supplier = await Self.app.models.Supplier.findOne(
|
||||||
|
{
|
||||||
|
where: {
|
||||||
|
name: this.name,
|
||||||
|
countryFk: this.countryFk
|
||||||
|
},
|
||||||
|
fields: ['id']
|
||||||
|
});
|
||||||
|
|
||||||
|
if (supplier && supplier.id != this.id)
|
||||||
|
err();
|
||||||
|
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
|
||||||
Self.observe('before save', async function(ctx) {
|
Self.observe('before save', async function(ctx) {
|
||||||
const changes = ctx.data || ctx.instance;
|
const changes = ctx.data || ctx.instance;
|
||||||
const orgData = ctx.currentInstance;
|
const orgData = ctx.currentInstance;
|
||||||
|
|
|
@ -24,36 +24,42 @@
|
||||||
</vn-textfield>
|
</vn-textfield>
|
||||||
<vn-input-number
|
<vn-input-number
|
||||||
type="number"
|
type="number"
|
||||||
|
step="0.01"
|
||||||
label="Minimum M3"
|
label="Minimum M3"
|
||||||
ng-model="supplierAgencyTerm.minimumM3"
|
ng-model="supplierAgencyTerm.minimumM3"
|
||||||
rule>
|
rule>
|
||||||
</vn-input-number>
|
</vn-input-number>
|
||||||
<vn-input-number
|
<vn-input-number
|
||||||
type="number"
|
type="number"
|
||||||
|
step="0.01"
|
||||||
label="Package Price"
|
label="Package Price"
|
||||||
ng-model="supplierAgencyTerm.packagePrice"
|
ng-model="supplierAgencyTerm.packagePrice"
|
||||||
rule>
|
rule>
|
||||||
</vn-input-number>
|
</vn-input-number>
|
||||||
<vn-input-number
|
<vn-input-number
|
||||||
type="number"
|
type="number"
|
||||||
|
step="0.01"
|
||||||
label="Km Price"
|
label="Km Price"
|
||||||
ng-model="supplierAgencyTerm.kmPrice"
|
ng-model="supplierAgencyTerm.kmPrice"
|
||||||
rule>
|
rule>
|
||||||
</vn-input-number>
|
</vn-input-number>
|
||||||
<vn-input-number
|
<vn-input-number
|
||||||
type="number"
|
type="number"
|
||||||
|
step="0.01"
|
||||||
label="M3 Price"
|
label="M3 Price"
|
||||||
ng-model="supplierAgencyTerm.m3Price"
|
ng-model="supplierAgencyTerm.m3Price"
|
||||||
rule>
|
rule>
|
||||||
</vn-input-number>
|
</vn-input-number>
|
||||||
<vn-input-number
|
<vn-input-number
|
||||||
type="number"
|
type="number"
|
||||||
|
step="0.01"
|
||||||
label="Route Price"
|
label="Route Price"
|
||||||
ng-model="supplierAgencyTerm.routePrice"
|
ng-model="supplierAgencyTerm.routePrice"
|
||||||
rule>
|
rule>
|
||||||
</vn-input-number>
|
</vn-input-number>
|
||||||
<vn-input-number
|
<vn-input-number
|
||||||
type="number"
|
type="number"
|
||||||
|
step="0.01"
|
||||||
label="Minimum Km"
|
label="Minimum Km"
|
||||||
ng-model="supplierAgencyTerm.minimumKm"
|
ng-model="supplierAgencyTerm.minimumKm"
|
||||||
rule>
|
rule>
|
||||||
|
|
|
@ -36,7 +36,7 @@ module.exports = Self => {
|
||||||
st.originalQuantity,
|
st.originalQuantity,
|
||||||
st.created,
|
st.created,
|
||||||
st.workerFk,
|
st.workerFk,
|
||||||
u.nickname userNickname,
|
u.name,
|
||||||
ste.name AS state
|
ste.name AS state
|
||||||
FROM saleTracking st
|
FROM saleTracking st
|
||||||
JOIN sale s ON s.id = st.saleFk
|
JOIN sale s ON s.id = st.saleFk
|
||||||
|
@ -48,24 +48,6 @@ module.exports = Self => {
|
||||||
|
|
||||||
const trackings = await Self.rawStmt(stmt, myOptions);
|
const trackings = await Self.rawStmt(stmt, myOptions);
|
||||||
|
|
||||||
const salesFilter = {
|
|
||||||
include: [
|
|
||||||
{
|
|
||||||
relation: 'item'
|
|
||||||
}
|
|
||||||
],
|
|
||||||
where: {ticketFk: filter.where.ticketFk}
|
|
||||||
};
|
|
||||||
|
|
||||||
const sales = await Self.app.models.Sale.find(salesFilter, myOptions);
|
|
||||||
|
|
||||||
for (const tracking of trackings) {
|
|
||||||
for (const sale of sales) {
|
|
||||||
if (tracking.itemFk == sale.itemFk)
|
|
||||||
tracking.item = sale.item();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return trackings;
|
return trackings;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -56,6 +56,13 @@ module.exports = Self => {
|
||||||
const shouldEditCloned = canEditCloned || !hasSaleCloned;
|
const shouldEditCloned = canEditCloned || !hasSaleCloned;
|
||||||
const shouldEditFloramondo = canEditFloramondo || !hasSaleFloramondo;
|
const shouldEditFloramondo = canEditFloramondo || !hasSaleFloramondo;
|
||||||
|
|
||||||
return shouldEditTracked && shouldEditCloned && shouldEditFloramondo;
|
if (!shouldEditTracked)
|
||||||
|
throw new UserError('It is not possible to modify tracked sales');
|
||||||
|
if (!shouldEditCloned)
|
||||||
|
throw new UserError('It is not possible to modify cloned sales');
|
||||||
|
if (!shouldEditFloramondo)
|
||||||
|
throw new UserError('It is not possible to modify sales that their articles are from Floramondo');
|
||||||
|
|
||||||
|
return true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -43,9 +43,7 @@ module.exports = Self => {
|
||||||
try {
|
try {
|
||||||
const saleIds = sales.map(sale => sale.id);
|
const saleIds = sales.map(sale => sale.id);
|
||||||
|
|
||||||
const canEditSales = await models.Sale.canEdit(ctx, saleIds, myOptions);
|
await models.Sale.canEdit(ctx, saleIds, myOptions);
|
||||||
if (!canEditSales)
|
|
||||||
throw new UserError(`Sale(s) blocked, please contact production`);
|
|
||||||
|
|
||||||
const ticket = await models.Ticket.findById(ticketId, {
|
const ticket = await models.Ticket.findById(ticketId, {
|
||||||
include: {
|
include: {
|
||||||
|
|
|
@ -37,9 +37,7 @@ module.exports = Self => {
|
||||||
try {
|
try {
|
||||||
const salesIds = sales.map(sale => sale.id);
|
const salesIds = sales.map(sale => sale.id);
|
||||||
|
|
||||||
const canEditSale = await models.Sale.canEdit(ctx, salesIds, myOptions);
|
await models.Sale.canEdit(ctx, salesIds, myOptions);
|
||||||
if (!canEditSale)
|
|
||||||
throw new UserError(`Sale(s) blocked, please contact production`);
|
|
||||||
|
|
||||||
const query = `
|
const query = `
|
||||||
DROP TEMPORARY TABLE IF EXISTS tmp.recalculateSales;
|
DROP TEMPORARY TABLE IF EXISTS tmp.recalculateSales;
|
||||||
|
|
|
@ -51,9 +51,7 @@ module.exports = Self => {
|
||||||
try {
|
try {
|
||||||
const salesIds = sales.map(sale => sale.id);
|
const salesIds = sales.map(sale => sale.id);
|
||||||
|
|
||||||
const canEditSale = await models.Sale.canEdit(ctx, salesIds, myOptions);
|
await models.Sale.canEdit(ctx, salesIds, myOptions);
|
||||||
if (!canEditSale)
|
|
||||||
throw new UserError(`Sale(s) blocked, please contact production`);
|
|
||||||
|
|
||||||
let changesMade = '';
|
let changesMade = '';
|
||||||
const promises = [];
|
const promises = [];
|
||||||
|
|
|
@ -50,7 +50,7 @@ describe('sale canEdit()', () => {
|
||||||
|
|
||||||
it('should return false if any of the sales has a saleTracking record', async() => {
|
it('should return false if any of the sales has a saleTracking record', async() => {
|
||||||
const tx = await models.Sale.beginTransaction({});
|
const tx = await models.Sale.beginTransaction({});
|
||||||
|
let error;
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
@ -59,15 +59,15 @@ describe('sale canEdit()', () => {
|
||||||
|
|
||||||
const sales = [31];
|
const sales = [31];
|
||||||
|
|
||||||
const result = await models.Sale.canEdit(ctx, sales, options);
|
await models.Sale.canEdit(ctx, sales, options);
|
||||||
|
|
||||||
expect(result).toEqual(false);
|
|
||||||
|
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
throw e;
|
error = e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
expect(error).toEqual(
|
||||||
|
new Error('It is not possible to modify tracked sales'));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -75,22 +75,22 @@ describe('sale canEdit()', () => {
|
||||||
const saleCloned = [29];
|
const saleCloned = [29];
|
||||||
it('should return false if any of the sales is cloned', async() => {
|
it('should return false if any of the sales is cloned', async() => {
|
||||||
const tx = await models.Sale.beginTransaction({});
|
const tx = await models.Sale.beginTransaction({});
|
||||||
|
let error;
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
const buyerId = 35;
|
const buyerId = 35;
|
||||||
const ctx = {req: {accessToken: {userId: buyerId}}};
|
const ctx = {req: {accessToken: {userId: buyerId}}};
|
||||||
|
|
||||||
const result = await models.Sale.canEdit(ctx, saleCloned, options);
|
await models.Sale.canEdit(ctx, saleCloned, options);
|
||||||
|
|
||||||
expect(result).toEqual(false);
|
|
||||||
|
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
throw e;
|
error = e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
expect(error).toEqual(
|
||||||
|
new Error('It is not possible to modify cloned sales'));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return true if any of the sales is cloned and has the correct role', async() => {
|
it('should return true if any of the sales is cloned and has the correct role', async() => {
|
||||||
|
@ -130,7 +130,7 @@ describe('sale canEdit()', () => {
|
||||||
it('should return false if any of the sales isFloramondo', async() => {
|
it('should return false if any of the sales isFloramondo', async() => {
|
||||||
const tx = await models.Sale.beginTransaction({});
|
const tx = await models.Sale.beginTransaction({});
|
||||||
const sales = [26];
|
const sales = [26];
|
||||||
|
let error;
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
@ -140,15 +140,15 @@ describe('sale canEdit()', () => {
|
||||||
const saleToEdit = await models.Sale.findById(sales[0], null, options);
|
const saleToEdit = await models.Sale.findById(sales[0], null, options);
|
||||||
await saleToEdit.updateAttribute('itemFk', 9, options);
|
await saleToEdit.updateAttribute('itemFk', 9, options);
|
||||||
|
|
||||||
const result = await models.Sale.canEdit(ctx, sales, options);
|
await models.Sale.canEdit(ctx, sales, options);
|
||||||
|
|
||||||
expect(result).toEqual(false);
|
|
||||||
|
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
throw e;
|
error = e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
expect(error).toEqual(
|
||||||
|
new Error('It is not possible to modify sales that their articles are from Floramondo'));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return true if any of the sales is of isFloramondo and has the correct role', async() => {
|
it('should return true if any of the sales is of isFloramondo and has the correct role', async() => {
|
||||||
|
|
|
@ -40,10 +40,7 @@ module.exports = Self => {
|
||||||
try {
|
try {
|
||||||
const currentLine = await models.Sale.findById(id, null, myOptions);
|
const currentLine = await models.Sale.findById(id, null, myOptions);
|
||||||
|
|
||||||
const canEditSale = await models.Sale.canEdit(ctx, [id], myOptions);
|
await models.Sale.canEdit(ctx, [id], myOptions);
|
||||||
|
|
||||||
if (!canEditSale)
|
|
||||||
throw new UserError(`Sale(s) blocked, please contact production`);
|
|
||||||
|
|
||||||
const line = await currentLine.updateAttributes({concept: newConcept}, myOptions);
|
const line = await currentLine.updateAttributes({concept: newConcept}, myOptions);
|
||||||
|
|
||||||
|
|
|
@ -66,9 +66,7 @@ module.exports = Self => {
|
||||||
|
|
||||||
const sale = await models.Sale.findById(id, filter, myOptions);
|
const sale = await models.Sale.findById(id, filter, myOptions);
|
||||||
|
|
||||||
const canEditSale = await models.Sale.canEdit(ctx, [id], myOptions);
|
await models.Sale.canEdit(ctx, [id], myOptions);
|
||||||
if (!canEditSale)
|
|
||||||
throw new UserError(`Sale(s) blocked, please contact production`);
|
|
||||||
|
|
||||||
const oldPrice = sale.price;
|
const oldPrice = sale.price;
|
||||||
const userId = ctx.req.accessToken.userId;
|
const userId = ctx.req.accessToken.userId;
|
||||||
|
|
|
@ -41,9 +41,7 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const canEditSale = await models.Sale.canEdit(ctx, [id], myOptions);
|
await models.Sale.canEdit(ctx, [id], myOptions);
|
||||||
if (!canEditSale)
|
|
||||||
throw new UserError(`Sale(s) blocked, please contact production`);
|
|
||||||
|
|
||||||
const filter = {
|
const filter = {
|
||||||
include: {
|
include: {
|
||||||
|
|
|
@ -24,7 +24,7 @@ module.exports = Self => {
|
||||||
if (typeof options == 'object')
|
if (typeof options == 'object')
|
||||||
Object.assign(myOptions, options);
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
let statesList = await models.State.find({where: filter.where}, myOptions);
|
let statesList = await models.State.find(filter, myOptions);
|
||||||
const isProduction = await models.Account.hasRole(userId, 'production', myOptions);
|
const isProduction = await models.Account.hasRole(userId, 'production', myOptions);
|
||||||
const isSalesPerson = await models.Account.hasRole(userId, 'salesPerson', myOptions);
|
const isSalesPerson = await models.Account.hasRole(userId, 'salesPerson', myOptions);
|
||||||
const isAdministrative = await models.Account.hasRole(userId, 'administrative', myOptions);
|
const isAdministrative = await models.Account.hasRole(userId, 'administrative', myOptions);
|
||||||
|
|
|
@ -50,14 +50,14 @@ module.exports = Self => {
|
||||||
required: false
|
required: false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
arg: 'state',
|
arg: 'isNotValidated',
|
||||||
type: 'string',
|
type: 'boolean',
|
||||||
description: 'Origin state',
|
description: 'Origin state',
|
||||||
required: false
|
required: false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
arg: 'futureState',
|
arg: 'futureIsNotValidated',
|
||||||
type: 'string',
|
type: 'boolean',
|
||||||
description: 'Destination state',
|
description: 'Destination state',
|
||||||
required: false
|
required: false
|
||||||
},
|
},
|
||||||
|
@ -92,13 +92,23 @@ module.exports = Self => {
|
||||||
case 'futureId':
|
case 'futureId':
|
||||||
return {'f.futureId': value};
|
return {'f.futureId': value};
|
||||||
case 'ipt':
|
case 'ipt':
|
||||||
return {'f.ipt': value};
|
return {or:
|
||||||
|
[
|
||||||
|
{'f.ipt': {like: `%${value}%`}},
|
||||||
|
{'f.ipt': null}
|
||||||
|
]
|
||||||
|
};
|
||||||
case 'futureIpt':
|
case 'futureIpt':
|
||||||
return {'f.futureIpt': value};
|
return {or:
|
||||||
case 'state':
|
[
|
||||||
return {'f.stateCode': {like: `%${value}%`}};
|
{'f.futureIpt': {like: `%${value}%`}},
|
||||||
case 'futureState':
|
{'f.futureIpt': null}
|
||||||
return {'f.futureStateCode': {like: `%${value}%`}};
|
]
|
||||||
|
};
|
||||||
|
case 'isNotValidated':
|
||||||
|
return {'f.isNotValidated': value};
|
||||||
|
case 'futureIsNotValidated':
|
||||||
|
return {'f.futureIsNotValidated': value};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ describe('TicketFuture getTicketsAdvance()', () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return the tickets matching the origin grouped state', async() => {
|
it('should return the tickets matching the origin pending state', async() => {
|
||||||
const tx = await models.Ticket.beginTransaction({});
|
const tx = await models.Ticket.beginTransaction({});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -39,7 +39,7 @@ describe('TicketFuture getTicketsAdvance()', () => {
|
||||||
dateFuture: tomorrow,
|
dateFuture: tomorrow,
|
||||||
dateToAdvance: today,
|
dateToAdvance: today,
|
||||||
warehouseFk: 1,
|
warehouseFk: 1,
|
||||||
state: 'OK'
|
futureIsNotValidated: true
|
||||||
};
|
};
|
||||||
|
|
||||||
const ctx = {req: {accessToken: {userId: 9}}, args};
|
const ctx = {req: {accessToken: {userId: 9}}, args};
|
||||||
|
@ -54,7 +54,7 @@ describe('TicketFuture getTicketsAdvance()', () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return the tickets matching the destination grouped state', async() => {
|
it('should return the tickets matching the destination pending state', async() => {
|
||||||
const tx = await models.Ticket.beginTransaction({});
|
const tx = await models.Ticket.beginTransaction({});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -64,13 +64,13 @@ describe('TicketFuture getTicketsAdvance()', () => {
|
||||||
dateFuture: tomorrow,
|
dateFuture: tomorrow,
|
||||||
dateToAdvance: today,
|
dateToAdvance: today,
|
||||||
warehouseFk: 1,
|
warehouseFk: 1,
|
||||||
futureState: 'FREE'
|
isNotValidated: true
|
||||||
};
|
};
|
||||||
|
|
||||||
const ctx = {req: {accessToken: {userId: 9}}, args};
|
const ctx = {req: {accessToken: {userId: 9}}, args};
|
||||||
const result = await models.Ticket.getTicketsAdvance(ctx, options);
|
const result = await models.Ticket.getTicketsAdvance(ctx, options);
|
||||||
|
|
||||||
expect(result.length).toBeGreaterThan(0);
|
expect(result.length).toEqual(0);
|
||||||
|
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -89,7 +89,7 @@ describe('TicketFuture getTicketsAdvance()', () => {
|
||||||
dateFuture: tomorrow,
|
dateFuture: tomorrow,
|
||||||
dateToAdvance: today,
|
dateToAdvance: today,
|
||||||
warehouseFk: 1,
|
warehouseFk: 1,
|
||||||
ipt: 'Vertical'
|
ipt: 'V'
|
||||||
};
|
};
|
||||||
|
|
||||||
const ctx = {req: {accessToken: {userId: 9}}, args};
|
const ctx = {req: {accessToken: {userId: 9}}, args};
|
||||||
|
@ -114,7 +114,7 @@ describe('TicketFuture getTicketsAdvance()', () => {
|
||||||
dateFuture: tomorrow,
|
dateFuture: tomorrow,
|
||||||
dateToAdvance: today,
|
dateToAdvance: today,
|
||||||
warehouseFk: 1,
|
warehouseFk: 1,
|
||||||
tfIpt: 'Vertical'
|
tfIpt: 'V'
|
||||||
};
|
};
|
||||||
|
|
||||||
const ctx = {req: {accessToken: {userId: 9}}, args};
|
const ctx = {req: {accessToken: {userId: 9}}, args};
|
||||||
|
|
|
@ -39,26 +39,18 @@
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
<vn-horizontal class="vn-px-lg">
|
<vn-horizontal class="vn-px-lg">
|
||||||
<vn-autocomplete vn-one
|
<vn-check
|
||||||
data="$ctrl.groupedStates"
|
vn-one
|
||||||
label="Origin Grouped State"
|
label="Pending Origin"
|
||||||
value-field="code"
|
ng-model="filter.futureIsNotValidated"
|
||||||
show-field="name"
|
triple-state="true">
|
||||||
ng-model="filter.futureState">
|
</vn-check>
|
||||||
<tpl-item>
|
<vn-check
|
||||||
{{name}}
|
vn-one
|
||||||
</tpl-item>
|
label="Pending Destination"
|
||||||
</vn-autocomplete>
|
ng-model="filter.isNotValidated"
|
||||||
<vn-autocomplete vn-one
|
triple-state="true">
|
||||||
data="$ctrl.groupedStates"
|
</vn-check>
|
||||||
label="Destination Grouped State"
|
|
||||||
value-field="code"
|
|
||||||
show-field="name"
|
|
||||||
ng-model="filter.state">
|
|
||||||
<tpl-item>
|
|
||||||
{{name}}
|
|
||||||
</tpl-item>
|
|
||||||
</vn-autocomplete>
|
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
<vn-horizontal class="vn-px-lg">
|
<vn-horizontal class="vn-px-lg">
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
|
|
|
@ -5,24 +5,9 @@ class Controller extends SearchPanel {
|
||||||
constructor($, $element) {
|
constructor($, $element) {
|
||||||
super($, $element);
|
super($, $element);
|
||||||
this.filter = this.$.filter;
|
this.filter = this.$.filter;
|
||||||
this.getGroupedStates();
|
|
||||||
this.getItemPackingTypes();
|
this.getItemPackingTypes();
|
||||||
}
|
}
|
||||||
|
|
||||||
getGroupedStates() {
|
|
||||||
let groupedStates = [];
|
|
||||||
this.$http.get('AlertLevels').then(res => {
|
|
||||||
for (let state of res.data) {
|
|
||||||
groupedStates.push({
|
|
||||||
id: state.id,
|
|
||||||
code: state.code,
|
|
||||||
name: this.$t(state.code)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
this.groupedStates = groupedStates;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
getItemPackingTypes() {
|
getItemPackingTypes() {
|
||||||
let itemPackingTypes = [];
|
let itemPackingTypes = [];
|
||||||
const filter = {
|
const filter = {
|
||||||
|
|
|
@ -1 +1,3 @@
|
||||||
Advance tickets: Adelantar tickets
|
Advance tickets: Adelantar tickets
|
||||||
|
Pending Origin: Pendiente origen
|
||||||
|
Pending Destination: Pendiente destino
|
||||||
|
|
|
@ -32,8 +32,8 @@
|
||||||
<thead>
|
<thead>
|
||||||
<tr second-header>
|
<tr second-header>
|
||||||
<td></td>
|
<td></td>
|
||||||
<th colspan="5" translate>Origin</th>
|
<th colspan="9" translate>Origin</th>
|
||||||
<th colspan="8" translate>Destination</th>
|
<th colspan="7" translate>Destination</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th shrink>
|
<th shrink>
|
||||||
|
@ -43,19 +43,30 @@
|
||||||
check-field="checked">
|
check-field="checked">
|
||||||
</vn-multi-check>
|
</vn-multi-check>
|
||||||
</th>
|
</th>
|
||||||
|
<th shrink>
|
||||||
|
</th>
|
||||||
<th field="futureId">
|
<th field="futureId">
|
||||||
<span translate>ID</span>
|
<span translate>ID</span>
|
||||||
</th>
|
</th>
|
||||||
<th field="futureShipped">
|
<th field="futureShipped">
|
||||||
<span translate>Date</span>
|
<span translate>Date</span>
|
||||||
</th>
|
</th>
|
||||||
<th field="futureIpt" title="Item Packing Type">
|
<th field="futureIpt" title="{{'Item Packing Type' | translate}}">
|
||||||
<span>IPT</span>
|
<span>IPT</span>
|
||||||
</th>
|
</th>
|
||||||
<th field="futureState">
|
<th field="futureState">
|
||||||
<span translate>State</span>
|
<span translate>State</span>
|
||||||
</th>
|
</th>
|
||||||
<th field="totalWithVat">
|
<th field="futureLiters">
|
||||||
|
<span translate>Liters</span>
|
||||||
|
</th>
|
||||||
|
<th field="hasStock">
|
||||||
|
<span>Stock</span>
|
||||||
|
</th>
|
||||||
|
<th field="futureLines">
|
||||||
|
<span translate>Lines</span>
|
||||||
|
</th>
|
||||||
|
<th field="futureTotalWithVat">
|
||||||
<span translate>Import</span>
|
<span translate>Import</span>
|
||||||
</th>
|
</th>
|
||||||
<th separator field="id">
|
<th separator field="id">
|
||||||
|
@ -64,7 +75,7 @@
|
||||||
<th field="shipped">
|
<th field="shipped">
|
||||||
<span translate>Date</span>
|
<span translate>Date</span>
|
||||||
</th>
|
</th>
|
||||||
<th field="ipt" title="Item Packing Type">
|
<th field="ipt" title="{{'Item Packing Type' | translate}}">
|
||||||
<span>IPT</span>
|
<span>IPT</span>
|
||||||
</th>
|
</th>
|
||||||
<th field="state">
|
<th field="state">
|
||||||
|
@ -73,13 +84,10 @@
|
||||||
<th field="liters">
|
<th field="liters">
|
||||||
<span translate>Liters</span>
|
<span translate>Liters</span>
|
||||||
</th>
|
</th>
|
||||||
<th field="hasStock">
|
|
||||||
<span>Stock</span>
|
|
||||||
</th>
|
|
||||||
<th field="lines">
|
<th field="lines">
|
||||||
<span translate>Lines</span>
|
<span translate>Lines</span>
|
||||||
</th>
|
</th>
|
||||||
<th field="futureTotalWithVat">
|
<th field="totalWithVat">
|
||||||
<span translate>Import</span>
|
<span translate>Import</span>
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -92,6 +100,13 @@
|
||||||
vn-click-stop>
|
vn-click-stop>
|
||||||
</vn-check>
|
</vn-check>
|
||||||
</td>
|
</td>
|
||||||
|
<td>
|
||||||
|
<vn-icon
|
||||||
|
ng-show="ticket.futureAgency !== ticket.agency"
|
||||||
|
icon="icon-agency-term"
|
||||||
|
vn-tooltip="{{$ctrl.agencies(ticket.futureAgency, ticket.agency)}}">
|
||||||
|
</vn-icon>
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<span
|
<span
|
||||||
ng-click="ticketDescriptor.show($event, ticket.futureId)"
|
ng-click="ticketDescriptor.show($event, ticket.futureId)"
|
||||||
|
@ -111,6 +126,9 @@
|
||||||
{{::ticket.futureState | dashIfEmpty}}
|
{{::ticket.futureState | dashIfEmpty}}
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
|
<td>{{::ticket.futureLiters | dashIfEmpty}}</td>
|
||||||
|
<td>{{::ticket.hasStock | dashIfEmpty}}</td>
|
||||||
|
<td>{{::ticket.futureLines | dashIfEmpty}}</td>
|
||||||
<td>
|
<td>
|
||||||
<span class="chip {{$ctrl.totalPriceColor(ticket.futureTotalWithVat)}}">
|
<span class="chip {{$ctrl.totalPriceColor(ticket.futureTotalWithVat)}}">
|
||||||
{{::(ticket.futureTotalWithVat ? ticket.futureTotalWithVat : 0) | currency: 'EUR': 2}}
|
{{::(ticket.futureTotalWithVat ? ticket.futureTotalWithVat : 0) | currency: 'EUR': 2}}
|
||||||
|
@ -136,7 +154,6 @@
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
<td>{{::ticket.liters | dashIfEmpty}}</td>
|
<td>{{::ticket.liters | dashIfEmpty}}</td>
|
||||||
<td>{{::ticket.hasStock | dashIfEmpty}}</td>
|
|
||||||
<td>{{::ticket.lines | dashIfEmpty}}</td>
|
<td>{{::ticket.lines | dashIfEmpty}}</td>
|
||||||
<td>
|
<td>
|
||||||
<span class="chip {{$ctrl.totalPriceColor(ticket.totalWithVat)}}">
|
<span class="chip {{$ctrl.totalPriceColor(ticket.totalWithVat)}}">
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import ngModule from '../module';
|
import ngModule from '../module';
|
||||||
import Section from 'salix/components/section';
|
import Section from 'salix/components/section';
|
||||||
|
import './style.scss';
|
||||||
|
|
||||||
export default class Controller extends Section {
|
export default class Controller extends Section {
|
||||||
constructor($element, $) {
|
constructor($element, $) {
|
||||||
|
@ -128,6 +129,11 @@ export default class Controller extends Section {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
agencies(futureAgency, agency) {
|
||||||
|
return this.$t(`Origin agency`, {agency: futureAgency}) +
|
||||||
|
'<br/>' + this.$t(`Destination agency`, {agency: agency});
|
||||||
|
}
|
||||||
|
|
||||||
moveTicketsAdvance() {
|
moveTicketsAdvance() {
|
||||||
let ticketsToMove = [];
|
let ticketsToMove = [];
|
||||||
this.checked.forEach(ticket => {
|
this.checked.forEach(ticket => {
|
||||||
|
@ -157,6 +163,10 @@ export default class Controller extends Section {
|
||||||
return {'liters': value};
|
return {'liters': value};
|
||||||
case 'lines':
|
case 'lines':
|
||||||
return {'lines': value};
|
return {'lines': value};
|
||||||
|
case 'futureLiters':
|
||||||
|
return {'futureLiters': value};
|
||||||
|
case 'futureLines':
|
||||||
|
return {'futureLines': value};
|
||||||
case 'ipt':
|
case 'ipt':
|
||||||
return {'ipt': value};
|
return {'ipt': value};
|
||||||
case 'futureIpt':
|
case 'futureIpt':
|
||||||
|
|
|
@ -4,3 +4,6 @@ Advance confirmation: ¿Desea adelantar {{checked}} tickets?
|
||||||
Success: Tickets movidos correctamente
|
Success: Tickets movidos correctamente
|
||||||
Lines: Líneas
|
Lines: Líneas
|
||||||
Liters: Litros
|
Liters: Litros
|
||||||
|
Item Packing Type: Encajado
|
||||||
|
Origin agency: "Agencia origen: {{agency}}"
|
||||||
|
Destination agency: "Agencia destino: {{agency}}"
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
@import "variables";
|
||||||
|
|
||||||
|
vn-ticket-advance{
|
||||||
|
vn-icon {
|
||||||
|
color: #f7931e
|
||||||
|
}
|
||||||
|
}
|
|
@ -75,8 +75,10 @@ class Controller extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
set shipped(value) {
|
set shipped(value) {
|
||||||
|
if (new Date(this.ticket.shipped).toDateString() != value.toDateString())
|
||||||
|
value.setHours(0, 0, 0, 0);
|
||||||
|
|
||||||
this.ticket.shipped = value;
|
this.ticket.shipped = value;
|
||||||
this.ticket.shipped.setHours(0, 0, 0, 0);
|
|
||||||
this.getLanded({
|
this.getLanded({
|
||||||
shipped: value,
|
shipped: value,
|
||||||
addressFk: this.ticket.addressFk,
|
addressFk: this.ticket.addressFk,
|
||||||
|
|
|
@ -31,9 +31,9 @@
|
||||||
</vn-td>
|
</vn-td>
|
||||||
<vn-td number>
|
<vn-td number>
|
||||||
<span
|
<span
|
||||||
ng-click="$ctrl.showItemDescriptor($event, sale)"
|
ng-click="itemDescriptor.show($event, sale.item.id)"
|
||||||
class="link">
|
class="link">
|
||||||
{{::sale.itemFk | zeroFill:6}}
|
{{::sale.item.id}}
|
||||||
</span>
|
</span>
|
||||||
</vn-td>
|
</vn-td>
|
||||||
<vn-td vn-fetched-tags>
|
<vn-td vn-fetched-tags>
|
||||||
|
@ -96,27 +96,23 @@
|
||||||
</vn-tr>
|
</vn-tr>
|
||||||
</vn-thead>
|
</vn-thead>
|
||||||
<vn-tbody>
|
<vn-tbody>
|
||||||
<vn-tr ng-repeat="sale in saleTrackings">
|
<vn-tr ng-repeat="saleTracking in saleTrackings">
|
||||||
<vn-td number>{{::sale.quantity}}</vn-td>
|
<vn-td number>{{::saleTracking.quantity}}</vn-td>
|
||||||
<vn-td number>{{::sale.originalQuantity}}</vn-td>
|
<vn-td number>{{::saleTracking.originalQuantity}}</vn-td>
|
||||||
<vn-td expand>
|
<vn-td expand>
|
||||||
<span
|
<span
|
||||||
class="link"
|
class="link"
|
||||||
ng-click="workerDescriptor.show($event, sale.workerFk)">
|
ng-click="workerDescriptor.show($event, saleTracking.workerFk)">
|
||||||
{{::sale.userNickname | dashIfEmpty}}
|
{{::saleTracking.name | dashIfEmpty}}
|
||||||
</span>
|
</span>
|
||||||
</vn-td>
|
</vn-td>
|
||||||
<vn-td shrink>{{::sale.state}}</vn-td>
|
<vn-td shrink>{{::saleTracking.state}}</vn-td>
|
||||||
<vn-td expand>{{::sale.created | date: 'dd/MM/yyyy HH:mm'}}</vn-td>
|
<vn-td expand>{{::saleTracking.created | date: 'dd/MM/yyyy HH:mm'}}</vn-td>
|
||||||
</vn-tr>
|
</vn-tr>
|
||||||
</vn-tbody>
|
</vn-tbody>
|
||||||
</vn-table>
|
</vn-table>
|
||||||
</vn-card>
|
</vn-card>
|
||||||
</vn-data-viewer>
|
</vn-data-viewer>
|
||||||
<vn-item-descriptor-popover
|
|
||||||
vn-id="item-descriptor"
|
|
||||||
warehouse-fk="$ctrl.ticket.warehouseFk">
|
|
||||||
</vn-item-descriptor-popover>
|
|
||||||
<vn-worker-descriptor-popover
|
<vn-worker-descriptor-popover
|
||||||
vn-id="worker-descriptor">
|
vn-id="worker-descriptor">
|
||||||
</vn-worker-descriptor-popover>
|
</vn-worker-descriptor-popover>
|
||||||
|
|
|
@ -45,14 +45,14 @@ class Controller extends Section {
|
||||||
btnThree: {
|
btnThree: {
|
||||||
icon: 'icon-transaction',
|
icon: 'icon-transaction',
|
||||||
state: `item.card.diary({
|
state: `item.card.diary({
|
||||||
id: ${sale.itemFk},
|
id: ${sale.item.id},
|
||||||
warehouseFk: ${this.ticket.warehouseFk},
|
warehouseFk: ${this.ticket.warehouseFk},
|
||||||
lineFk: ${sale.id}
|
lineFk: ${sale.id}
|
||||||
})`,
|
})`,
|
||||||
tooltip: 'Item diary'
|
tooltip: 'Item diary'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
this.$.itemDescriptor.show(event.target, sale.itemFk);
|
this.$.itemDescriptor.show(event.target, sale.item.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
chipHasSaleGroupDetail(hasSaleGroupDetail) {
|
chipHasSaleGroupDetail(hasSaleGroupDetail) {
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
disabled="!$ctrl.isEditable"
|
disabled="!$ctrl.isEditable"
|
||||||
label="State"
|
label="State"
|
||||||
value-field="code"
|
value-field="code"
|
||||||
|
fields="['id', 'name', 'alertLevel', 'code']"
|
||||||
url="States/editableStates"
|
url="States/editableStates"
|
||||||
on-change="$ctrl.changeState(value)">
|
on-change="$ctrl.changeState(value)">
|
||||||
</vn-button-menu>
|
</vn-button-menu>
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
class="message"
|
class="message"
|
||||||
label="Change state"
|
label="Change state"
|
||||||
value-field="code"
|
value-field="code"
|
||||||
|
fields="['id', 'name', 'alertLevel', 'code']"
|
||||||
url="States/editableStates"
|
url="States/editableStates"
|
||||||
on-change="$ctrl.changeState(value)">
|
on-change="$ctrl.changeState(value)">
|
||||||
</vn-button-menu>
|
</vn-button-menu>
|
||||||
|
|
|
@ -17,43 +17,65 @@
|
||||||
model="model">
|
model="model">
|
||||||
</vn-searchbar>
|
</vn-searchbar>
|
||||||
</vn-portal>
|
</vn-portal>
|
||||||
<vn-data-viewer
|
|
||||||
model="model"
|
|
||||||
class="vn-w-xl">
|
|
||||||
<vn-card>
|
<vn-card>
|
||||||
<vn-table model="model">
|
<smart-table
|
||||||
<vn-thead>
|
model="model"
|
||||||
<vn-tr>
|
options="$ctrl.smartTableOptions"
|
||||||
<vn-th field="ticketFk" number>Ticket ID</vn-th>
|
view-config-id="ticketsMonitor"
|
||||||
<vn-th field="clientName">Client</vn-th>
|
expr-builder="$ctrl.exprBuilder(param, value)"
|
||||||
<vn-th>Shipment</vn-th>
|
>
|
||||||
<vn-th>Agency</vn-th>
|
<slot-actions>
|
||||||
<vn-th>Warehouse</vn-th>
|
<vn-check
|
||||||
<vn-th>Salesperson</vn-th>
|
label="Auto-refresh"
|
||||||
<vn-th shrink></vn-th>
|
vn-tooltip="Toggle auto-refresh every 2 minutes"
|
||||||
</vn-tr>
|
on-change="$ctrl.autoRefresh(value)">
|
||||||
</vn-thead>
|
</vn-check>
|
||||||
<vn-tbody>
|
</slot-actions>
|
||||||
<vn-tr
|
<slot-table>
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th field="ticketFk">
|
||||||
|
<span translate>Ticket ID</span>
|
||||||
|
</th>
|
||||||
|
<th field="clientName">
|
||||||
|
<span translate>Client</span>
|
||||||
|
</th>
|
||||||
|
<th field="weekDay">
|
||||||
|
<span translate>Shipment</span>
|
||||||
|
</th>
|
||||||
|
<th field="agencyModeFk">
|
||||||
|
<span translate>Agency</span>
|
||||||
|
</th>
|
||||||
|
<th field="warehouseFk">
|
||||||
|
<span translate>Warehouse</span>
|
||||||
|
</th>
|
||||||
|
<th field="nickName">
|
||||||
|
<span translate>Salesperson</span>
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr
|
||||||
ng-repeat="weekly in weeklies"
|
ng-repeat="weekly in weeklies"
|
||||||
ui-sref="ticket.card.summary({id: {{::weekly.ticketFk}}})"
|
ui-sref="ticket.card.summary({id: {{::weekly.ticketFk}}})"
|
||||||
class="clickable">
|
class="clickable">
|
||||||
<vn-td number>
|
<td number>
|
||||||
<span
|
<span
|
||||||
vn-click-stop="ticketDescriptor.show($event, weekly.ticketFk)"
|
vn-click-stop="ticketDescriptor.show($event, weekly.ticketFk)"
|
||||||
class="link">
|
class="link">
|
||||||
{{weekly.ticketFk}}
|
{{weekly.ticketFk}}
|
||||||
</span>
|
</span>
|
||||||
</vn-td>
|
</td>
|
||||||
<vn-td>
|
<td>
|
||||||
<span
|
<span
|
||||||
vn-click-stop="clientDescriptor.show($event, weekly.clientFk)"
|
vn-click-stop="clientDescriptor.show($event, weekly.clientFk)"
|
||||||
title ="{{::weekly.clientName}}"
|
title ="{{::weekly.clientName}}"
|
||||||
class="link">
|
class="link">
|
||||||
{{::weekly.clientName}}
|
{{::weekly.clientName}}
|
||||||
</span>
|
</span>
|
||||||
</vn-td>
|
</td>
|
||||||
<vn-td vn-click-stop>
|
<td vn-click-stop>
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
vn-id="weekday"
|
vn-id="weekday"
|
||||||
ng-model="weekly.weekDay"
|
ng-model="weekly.weekDay"
|
||||||
|
@ -65,8 +87,8 @@
|
||||||
order="id"
|
order="id"
|
||||||
class="dense">
|
class="dense">
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
</vn-td>
|
</td>
|
||||||
<vn-td vn-click-stop>
|
<td vn-click-stop>
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
vn-id="agencyMode"
|
vn-id="agencyMode"
|
||||||
ng-model="weekly.agencyModeFk"
|
ng-model="weekly.agencyModeFk"
|
||||||
|
@ -77,27 +99,28 @@
|
||||||
order="name"
|
order="name"
|
||||||
class="dense">
|
class="dense">
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
</vn-td>
|
</td>
|
||||||
<vn-td>{{::weekly.warehouseName}}</vn-td>
|
<td vn-click-stop>{{weekly.warehouseName}}</td>
|
||||||
<vn-td>
|
<td>
|
||||||
<span
|
<span
|
||||||
vn-click-stop="workerDescriptor.show($event, weekly.workerFk)"
|
vn-click-stop="workerDescriptor.show($event, weekly.workerFk)"
|
||||||
class="link" >
|
class="link" >
|
||||||
{{::weekly.userName}}
|
{{::weekly.userName}}
|
||||||
</span>
|
</span>
|
||||||
</vn-td>
|
</td>
|
||||||
<vn-td shrink>
|
<td shrink>
|
||||||
<vn-icon-button
|
<vn-icon-button
|
||||||
icon="delete"
|
icon="delete"
|
||||||
vn-click-stop="deleteWeekly.show(weekly.ticketFk)"
|
vn-click-stop="deleteWeekly.show(weekly.ticketFk)"
|
||||||
vn-tooltip="Delete">
|
vn-tooltip="Delete">
|
||||||
</vn-icon-button>
|
</vn-icon-button>
|
||||||
</vn-td>
|
</td>
|
||||||
</vn-tr>
|
</tr>
|
||||||
</vn-tbody>
|
</tbody>
|
||||||
</vn-table>
|
</table>
|
||||||
|
</slot-table>
|
||||||
|
</smart-table>
|
||||||
</vn-card>
|
</vn-card>
|
||||||
</vn-data-viewer>
|
|
||||||
<vn-client-descriptor-popover
|
<vn-client-descriptor-popover
|
||||||
vn-id="clientDescriptor">
|
vn-id="clientDescriptor">
|
||||||
</vn-client-descriptor-popover>
|
</vn-client-descriptor-popover>
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
|
||||||
import ngModule from '../module';
|
import ngModule from '../module';
|
||||||
import Section from 'salix/components/section';
|
import Section from 'salix/components/section';
|
||||||
|
|
||||||
|
@ -15,6 +16,44 @@ export default class Controller extends Section {
|
||||||
{id: 5, name: 'Saturday'},
|
{id: 5, name: 'Saturday'},
|
||||||
{id: 6, name: 'Sunday'}
|
{id: 6, name: 'Sunday'}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
this.smartTableOptions = {
|
||||||
|
activeButtons: {
|
||||||
|
search: true,
|
||||||
|
shownColumns: true,
|
||||||
|
},
|
||||||
|
columns: [
|
||||||
|
{
|
||||||
|
field: 'ticketFk',
|
||||||
|
searchable: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'clientName',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'weekDay',
|
||||||
|
searchable: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'agencyModeFk',
|
||||||
|
searchable: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'warehouseFk',
|
||||||
|
searchable: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'nickname',
|
||||||
|
},
|
||||||
|
]
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
exprBuilder(param, value) {
|
||||||
|
switch (param) {
|
||||||
|
case 'clientName': return {'c.name': value};
|
||||||
|
case 'nickName': return {'u.name': value};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onUpdate(ticketFk, field, value) {
|
onUpdate(ticketFk, field, value) {
|
||||||
|
|
|
@ -32,22 +32,15 @@ module.exports = Self => {
|
||||||
const models = Self.app.models;
|
const models = Self.app.models;
|
||||||
const conn = Self.dataSource.connector;
|
const conn = Self.dataSource.connector;
|
||||||
const args = ctx.args;
|
const args = ctx.args;
|
||||||
const $t = ctx.req.__; // $translate
|
|
||||||
let tx;
|
let tx;
|
||||||
const myOptions = {};
|
const myOptions = {};
|
||||||
|
|
||||||
if (typeof options == 'object')
|
if (typeof options == 'object')
|
||||||
Object.assign(myOptions, options);
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
if (!myOptions.transaction) {
|
|
||||||
tx = await Self.beginTransaction({});
|
|
||||||
myOptions.transaction = tx;
|
|
||||||
}
|
|
||||||
|
|
||||||
const stmts = [];
|
const stmts = [];
|
||||||
let stmt;
|
let stmt;
|
||||||
|
|
||||||
try {
|
|
||||||
if (!args.week || !args.year) {
|
if (!args.week || !args.year) {
|
||||||
const from = new Date();
|
const from = new Date();
|
||||||
const to = new Date();
|
const to = new Date();
|
||||||
|
@ -156,6 +149,9 @@ module.exports = Self => {
|
||||||
`, [args.workerId]);
|
`, [args.workerId]);
|
||||||
const index = stmts.push(stmt) - 1;
|
const index = stmts.push(stmt) - 1;
|
||||||
|
|
||||||
|
stmts.push('DROP TEMPORARY TABLE tmp.timeControlCalculate');
|
||||||
|
stmts.push('DROP TEMPORARY TABLE tmp.timeBusinessCalculate');
|
||||||
|
|
||||||
const sql = ParameterizedSQL.join(stmts, ';');
|
const sql = ParameterizedSQL.join(stmts, ';');
|
||||||
const days = await conn.executeStmt(sql, myOptions);
|
const days = await conn.executeStmt(sql, myOptions);
|
||||||
|
|
||||||
|
@ -165,14 +161,19 @@ module.exports = Self => {
|
||||||
const workerTimeControlConfig = await models.WorkerTimeControlConfig.findOne(null, myOptions);
|
const workerTimeControlConfig = await models.WorkerTimeControlConfig.findOne(null, myOptions);
|
||||||
|
|
||||||
for (let day of days[index]) {
|
for (let day of days[index]) {
|
||||||
|
if (!myOptions.transaction) {
|
||||||
|
tx = await Self.beginTransaction({});
|
||||||
|
myOptions.transaction = tx;
|
||||||
|
}
|
||||||
|
try {
|
||||||
workerFk = day.workerFk;
|
workerFk = day.workerFk;
|
||||||
if (day.timeWorkDecimal > 0 && day.timeWorkedDecimal == null
|
if (day.timeWorkDecimal > 0 && day.timeWorkedDecimal == null
|
||||||
&& (day.permissionRate ? day.permissionRate : true)) {
|
&& (day.permissionRate == null ? true : day.permissionRate)) {
|
||||||
if (day.timeTable == null) {
|
if (day.timeTable == null) {
|
||||||
const timed = new Date(day.dated);
|
const timed = new Date(day.dated);
|
||||||
await models.WorkerTimeControl.create({
|
await models.WorkerTimeControl.create({
|
||||||
userFk: day.workerFk,
|
userFk: day.workerFk,
|
||||||
timed: timed.setHours(8),
|
timed: timed.setHours(workerTimeControlConfig.teleworkingStart / 3600),
|
||||||
manual: true,
|
manual: true,
|
||||||
direction: 'in',
|
direction: 'in',
|
||||||
isSendMail: true
|
isSendMail: true
|
||||||
|
@ -181,7 +182,7 @@ module.exports = Self => {
|
||||||
if (day.timeWorkDecimal >= workerTimeControlConfig.timeToBreakTime / 3600) {
|
if (day.timeWorkDecimal >= workerTimeControlConfig.timeToBreakTime / 3600) {
|
||||||
await models.WorkerTimeControl.create({
|
await models.WorkerTimeControl.create({
|
||||||
userFk: day.workerFk,
|
userFk: day.workerFk,
|
||||||
timed: timed.setHours(9),
|
timed: timed.setHours(workerTimeControlConfig.teleworkingStartBreakTime / 3600),
|
||||||
manual: true,
|
manual: true,
|
||||||
direction: 'middle',
|
direction: 'middle',
|
||||||
isSendMail: true
|
isSendMail: true
|
||||||
|
@ -189,7 +190,10 @@ module.exports = Self => {
|
||||||
|
|
||||||
await models.WorkerTimeControl.create({
|
await models.WorkerTimeControl.create({
|
||||||
userFk: day.workerFk,
|
userFk: day.workerFk,
|
||||||
timed: timed.setHours(9, 20),
|
timed: timed.setHours(
|
||||||
|
workerTimeControlConfig.teleworkingStartBreakTime / 3600,
|
||||||
|
workerTimeControlConfig.breakTime / 60
|
||||||
|
),
|
||||||
manual: true,
|
manual: true,
|
||||||
direction: 'middle',
|
direction: 'middle',
|
||||||
isSendMail: true
|
isSendMail: true
|
||||||
|
@ -199,7 +203,11 @@ module.exports = Self => {
|
||||||
const [hoursWork, minutesWork, secondsWork] = getTime(day.timeWorkSexagesimal);
|
const [hoursWork, minutesWork, secondsWork] = getTime(day.timeWorkSexagesimal);
|
||||||
await models.WorkerTimeControl.create({
|
await models.WorkerTimeControl.create({
|
||||||
userFk: day.workerFk,
|
userFk: day.workerFk,
|
||||||
timed: timed.setHours(8 + hoursWork, minutesWork, secondsWork),
|
timed: timed.setHours(
|
||||||
|
workerTimeControlConfig.teleworkingStart / 3600 + hoursWork,
|
||||||
|
minutesWork,
|
||||||
|
secondsWork
|
||||||
|
),
|
||||||
manual: true,
|
manual: true,
|
||||||
direction: 'out',
|
direction: 'out',
|
||||||
isSendMail: true
|
isSendMail: true
|
||||||
|
@ -307,7 +315,7 @@ module.exports = Self => {
|
||||||
}, myOptions);
|
}, myOptions);
|
||||||
|
|
||||||
if (firstWorkerTimeControl)
|
if (firstWorkerTimeControl)
|
||||||
firstWorkerTimeControl.updateAttribute('direction', 'in', myOptions);
|
await firstWorkerTimeControl.updateAttribute('direction', 'in', myOptions);
|
||||||
|
|
||||||
const lastWorkerTimeControl = await models.WorkerTimeControl.findOne({
|
const lastWorkerTimeControl = await models.WorkerTimeControl.findOne({
|
||||||
where: {
|
where: {
|
||||||
|
@ -318,7 +326,7 @@ module.exports = Self => {
|
||||||
}, myOptions);
|
}, myOptions);
|
||||||
|
|
||||||
if (lastWorkerTimeControl)
|
if (lastWorkerTimeControl)
|
||||||
lastWorkerTimeControl.updateAttribute('direction', 'out', myOptions);
|
await lastWorkerTimeControl.updateAttribute('direction', 'out', myOptions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -339,15 +347,18 @@ module.exports = Self => {
|
||||||
previousWorkerFk = day.workerFk;
|
previousWorkerFk = day.workerFk;
|
||||||
previousReceiver = day.receiver;
|
previousReceiver = day.receiver;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tx) {
|
||||||
|
await tx.commit();
|
||||||
|
delete myOptions.transaction;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tx) await tx.commit();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (tx) await tx.rollback();
|
if (tx) await tx.rollback();
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
function getStartDateOfWeekNumber(week, year) {
|
function getStartDateOfWeekNumber(week, year) {
|
||||||
|
|
|
@ -10,7 +10,6 @@ describe('workerTimeControl sendMail()', () => {
|
||||||
const ctx = {req: activeCtx, args: {}};
|
const ctx = {req: activeCtx, args: {}};
|
||||||
|
|
||||||
it('should fill time control of a worker without records in Journey and with rest', async() => {
|
it('should fill time control of a worker without records in Journey and with rest', async() => {
|
||||||
pending('https://redmine.verdnatura.es/issues/4903');
|
|
||||||
const tx = await models.WorkerTimeControl.beginTransaction({});
|
const tx = await models.WorkerTimeControl.beginTransaction({});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -35,7 +34,6 @@ describe('workerTimeControl sendMail()', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fill time control of a worker without records in Journey and without rest', async() => {
|
it('should fill time control of a worker without records in Journey and without rest', async() => {
|
||||||
pending('https://redmine.verdnatura.es/issues/4903');
|
|
||||||
const workdayOf20Hours = 3;
|
const workdayOf20Hours = 3;
|
||||||
const tx = await models.WorkerTimeControl.beginTransaction({});
|
const tx = await models.WorkerTimeControl.beginTransaction({});
|
||||||
|
|
||||||
|
@ -63,7 +61,6 @@ describe('workerTimeControl sendMail()', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fill time control of a worker with records in Journey and with rest', async() => {
|
it('should fill time control of a worker with records in Journey and with rest', async() => {
|
||||||
pending('https://redmine.verdnatura.es/issues/4903');
|
|
||||||
const tx = await models.WorkerTimeControl.beginTransaction({});
|
const tx = await models.WorkerTimeControl.beginTransaction({});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -95,7 +92,6 @@ describe('workerTimeControl sendMail()', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fill time control of a worker with records in Journey and without rest', async() => {
|
it('should fill time control of a worker with records in Journey and without rest', async() => {
|
||||||
pending('https://redmine.verdnatura.es/issues/4903');
|
|
||||||
const tx = await models.WorkerTimeControl.beginTransaction({});
|
const tx = await models.WorkerTimeControl.beginTransaction({});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -2,7 +2,7 @@ const {Email} = require('vn-print');
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('weeklyHourRecordEmail', {
|
Self.remoteMethodCtx('weeklyHourRecordEmail', {
|
||||||
description: 'Sends the buyer waste email',
|
description: 'Sends the weekly hour record',
|
||||||
accessType: 'WRITE',
|
accessType: 'WRITE',
|
||||||
accepts: [
|
accepts: [
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,256 @@
|
||||||
|
/* eslint max-len: ["error", { "code": 130 }]*/
|
||||||
|
const UserError = require('vn-loopback/util/user-error');
|
||||||
|
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.remoteMethodCtx('new', {
|
||||||
|
description: 'Creates a new worker and returns the id',
|
||||||
|
accessType: 'WRITE',
|
||||||
|
accepts: [
|
||||||
|
{
|
||||||
|
arg: 'fi',
|
||||||
|
type: 'string',
|
||||||
|
description: `The worker fi`,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'name',
|
||||||
|
type: 'string',
|
||||||
|
description: `The user name`,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'firstName',
|
||||||
|
type: 'string',
|
||||||
|
description: `The worker firstname`,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'lastNames',
|
||||||
|
type: 'string',
|
||||||
|
description: `The worker lastnames`,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'email',
|
||||||
|
type: 'string',
|
||||||
|
description: `The worker email`,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'street',
|
||||||
|
type: 'string',
|
||||||
|
description: `The worker address`,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'city',
|
||||||
|
type: 'string',
|
||||||
|
description: `The worker city`,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'provinceFk',
|
||||||
|
type: 'number',
|
||||||
|
description: `The worker province`,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'iban',
|
||||||
|
type: 'string',
|
||||||
|
description: `The worker iban`,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'bankEntityFk',
|
||||||
|
type: 'number',
|
||||||
|
description: `The worker bank entity`,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'companyFk',
|
||||||
|
type: 'number',
|
||||||
|
description: `The worker company`,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'postcode',
|
||||||
|
type: 'string',
|
||||||
|
description: `The worker postcode`,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'phone',
|
||||||
|
type: 'string',
|
||||||
|
description: `The worker phone`,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'code',
|
||||||
|
type: 'string',
|
||||||
|
description: `The worker code`,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'bossFk',
|
||||||
|
type: 'number',
|
||||||
|
description: `The worker boss`,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'birth',
|
||||||
|
type: 'date',
|
||||||
|
description: `The worker birth`,
|
||||||
|
required: true,
|
||||||
|
}
|
||||||
|
],
|
||||||
|
returns: {
|
||||||
|
type: 'number',
|
||||||
|
root: true,
|
||||||
|
},
|
||||||
|
http: {
|
||||||
|
path: `/new`,
|
||||||
|
verb: 'POST',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
Self.new = async(ctx, options) => {
|
||||||
|
const models = Self.app.models;
|
||||||
|
const myOptions = {};
|
||||||
|
const args = ctx.args;
|
||||||
|
|
||||||
|
let tx;
|
||||||
|
|
||||||
|
if (typeof options == 'object') Object.assign(myOptions, options);
|
||||||
|
|
||||||
|
if (!myOptions.transaction) {
|
||||||
|
tx = await Self.beginTransaction({});
|
||||||
|
myOptions.transaction = tx;
|
||||||
|
}
|
||||||
|
|
||||||
|
let client;
|
||||||
|
|
||||||
|
try {
|
||||||
|
client = await models.Client.findOne(
|
||||||
|
{
|
||||||
|
where: {fi: args.fi},
|
||||||
|
},
|
||||||
|
myOptions
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!client) {
|
||||||
|
const nickname = args.firstName.concat(' ', args.lastNames);
|
||||||
|
const workerConfig = await models.WorkerConfig.findOne({fields: ['roleFk']});
|
||||||
|
const [randomPassword] = await models.Worker.rawSql(
|
||||||
|
'SELECT account.passwordGenerate() as password;'
|
||||||
|
);
|
||||||
|
|
||||||
|
const user = await models.Account.create(
|
||||||
|
{
|
||||||
|
name: args.name,
|
||||||
|
nickname,
|
||||||
|
password: randomPassword.password,
|
||||||
|
email: args.email,
|
||||||
|
roleFk: workerConfig.roleFk,
|
||||||
|
},
|
||||||
|
myOptions
|
||||||
|
);
|
||||||
|
|
||||||
|
await models.UserAccount.create(
|
||||||
|
{
|
||||||
|
id: user.id,
|
||||||
|
},
|
||||||
|
myOptions
|
||||||
|
);
|
||||||
|
|
||||||
|
await models.Worker.rawSql(
|
||||||
|
'CALL vn.clientCreate(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
|
||||||
|
[
|
||||||
|
args.firstName,
|
||||||
|
args.lastNames,
|
||||||
|
args.fi,
|
||||||
|
args.street,
|
||||||
|
args.postalCode,
|
||||||
|
args.city,
|
||||||
|
args.provinceFk,
|
||||||
|
args.companyFk,
|
||||||
|
args.phone,
|
||||||
|
args.email,
|
||||||
|
user.id,
|
||||||
|
],
|
||||||
|
myOptions
|
||||||
|
);
|
||||||
|
|
||||||
|
const address = await models.Address.create(
|
||||||
|
{
|
||||||
|
clientFk: user.id,
|
||||||
|
street: args.street,
|
||||||
|
city: args.city,
|
||||||
|
provinceFk: args.provinceFk,
|
||||||
|
postalCode: args.postalCode,
|
||||||
|
mobile: args.phone,
|
||||||
|
nickname: nickname,
|
||||||
|
isDefaultAddress: true,
|
||||||
|
},
|
||||||
|
myOptions
|
||||||
|
);
|
||||||
|
|
||||||
|
client = await models.Client.findById(
|
||||||
|
user.id,
|
||||||
|
{fields: ['id', 'name', 'socialName', 'street', 'city', 'iban', 'bankEntityFk', 'defaultAddressFk']},
|
||||||
|
myOptions
|
||||||
|
);
|
||||||
|
|
||||||
|
await client.updateAttributes(
|
||||||
|
{
|
||||||
|
iban: args.iban,
|
||||||
|
bankEntityFk: args.bankEntityFk,
|
||||||
|
defaultAddressFk: address.id,
|
||||||
|
},
|
||||||
|
myOptions
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const user = await models.Account.findById(client.id, null, myOptions);
|
||||||
|
await user.updateAttribute('email', args.email, myOptions);
|
||||||
|
|
||||||
|
await models.Worker.rawSql(
|
||||||
|
'CALL vn.workerCreate(?, ?, ?, ?, ?, ?, ?)',
|
||||||
|
[
|
||||||
|
args.firstName,
|
||||||
|
args.lastNames,
|
||||||
|
args.code,
|
||||||
|
args.bossFk,
|
||||||
|
client.id,
|
||||||
|
args.fi,
|
||||||
|
args.birth,
|
||||||
|
],
|
||||||
|
myOptions
|
||||||
|
);
|
||||||
|
|
||||||
|
if (tx) await tx.commit();
|
||||||
|
} catch (error) {
|
||||||
|
if (tx) await tx.rollback();
|
||||||
|
const code = error.code;
|
||||||
|
const message = error.sqlMessage;
|
||||||
|
|
||||||
|
if (code === 'ER_DUP_ENTRY' && message.includes(`for key 'mail'`))
|
||||||
|
throw new UserError(`This personal mail already exists`);
|
||||||
|
|
||||||
|
if (code === 'ER_DUP_ENTRY' && message.includes(`CodigoTrabajador_UNIQUE`))
|
||||||
|
throw new UserError(`This worker code already exists`);
|
||||||
|
|
||||||
|
if (code === 'ER_DUP_ENTRY' && message.includes(`PRIMARY`))
|
||||||
|
throw new UserError(`This worker already exists`);
|
||||||
|
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
|
||||||
|
await models.user.resetPassword({
|
||||||
|
email: args.email,
|
||||||
|
emailTemplate: 'worker-welcome',
|
||||||
|
id: client.id
|
||||||
|
});
|
||||||
|
|
||||||
|
return {id: client.id};
|
||||||
|
};
|
||||||
|
};
|
|
@ -0,0 +1,139 @@
|
||||||
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
const LoopBackContext = require('loopback-context');
|
||||||
|
|
||||||
|
describe('Worker new', () => {
|
||||||
|
beforeAll(async() => {
|
||||||
|
const activeCtx = {
|
||||||
|
accessToken: {userId: 9},
|
||||||
|
http: {
|
||||||
|
req: {
|
||||||
|
headers: {origin: 'http://localhost'}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||||
|
active: activeCtx
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
const employeeId = 1;
|
||||||
|
const defaultWorker = {
|
||||||
|
fi: '78457139E',
|
||||||
|
name: 'defaultWorker',
|
||||||
|
firstName: 'default',
|
||||||
|
lastNames: 'worker',
|
||||||
|
email: 'defaultWorker@mydomain.com',
|
||||||
|
street: 'S/ defaultWorkerStreet',
|
||||||
|
city: 'defaultWorkerCity',
|
||||||
|
provinceFk: 1,
|
||||||
|
iban: 'ES8304879798578129532677',
|
||||||
|
bankEntityFk: 128,
|
||||||
|
companyFk: 442,
|
||||||
|
postcode: '46680',
|
||||||
|
phone: '123456789',
|
||||||
|
code: 'DWW',
|
||||||
|
bossFk: 9,
|
||||||
|
birth: '2022-12-11T23:00:00.000Z'
|
||||||
|
};
|
||||||
|
|
||||||
|
it('should return error if personal mail already exists', async() => {
|
||||||
|
const user = await models.Account.findById(employeeId, {fields: ['email']});
|
||||||
|
|
||||||
|
const tx = await models.Worker.beginTransaction({});
|
||||||
|
|
||||||
|
let error;
|
||||||
|
try {
|
||||||
|
const options = {transaction: tx};
|
||||||
|
const ctx = {
|
||||||
|
args: Object.assign({}, defaultWorker, {email: user.email})
|
||||||
|
};
|
||||||
|
|
||||||
|
await models.Worker.new(ctx, options);
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
error = e;
|
||||||
|
await tx.rollback();
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(error.message).toEqual('This personal mail already exists');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return error if worker code already exists', async() => {
|
||||||
|
const worker = await models.Worker.findById(employeeId, {fields: ['code']});
|
||||||
|
|
||||||
|
const tx = await models.Worker.beginTransaction({});
|
||||||
|
|
||||||
|
let error;
|
||||||
|
try {
|
||||||
|
const options = {transaction: tx};
|
||||||
|
const ctx = {
|
||||||
|
args: Object.assign({}, defaultWorker, {code: worker.code})
|
||||||
|
};
|
||||||
|
|
||||||
|
await models.Worker.new(ctx, options);
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
error = e;
|
||||||
|
await tx.rollback();
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(error.message).toEqual('This worker code already exists');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return error if worker already exists', async() => {
|
||||||
|
const worker = await models.Client.findById(employeeId, {fields: ['fi']});
|
||||||
|
|
||||||
|
const tx = await models.Worker.beginTransaction({});
|
||||||
|
|
||||||
|
let error;
|
||||||
|
try {
|
||||||
|
const options = {transaction: tx};
|
||||||
|
const ctx = {
|
||||||
|
args: Object.assign({}, defaultWorker, {fi: worker.fi})
|
||||||
|
};
|
||||||
|
await models.Worker.new(ctx, options);
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
error = e;
|
||||||
|
await tx.rollback();
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(error.message).toEqual('This worker already exists');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create a new worker', async() => {
|
||||||
|
const newWorker = await models.Worker.new({args: defaultWorker});
|
||||||
|
|
||||||
|
await models.Worker.destroyById(newWorker.id);
|
||||||
|
await models.Address.destroyAll({clientFk: newWorker.id});
|
||||||
|
await models.Mandate.destroyAll({clientFk: newWorker.id});
|
||||||
|
await models.Client.destroyById(newWorker.id);
|
||||||
|
await models.Account.destroyById(newWorker.id);
|
||||||
|
|
||||||
|
expect(newWorker.id).toBeDefined();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create a new worker in client', async() => {
|
||||||
|
const bruceWayneId = 1101;
|
||||||
|
const client = await models.Client.findById(bruceWayneId, {fields: ['fi', 'email']});
|
||||||
|
|
||||||
|
const newWorkerData = {
|
||||||
|
args: Object.assign(
|
||||||
|
{},
|
||||||
|
defaultWorker,
|
||||||
|
{
|
||||||
|
fi: client.fi,
|
||||||
|
email: client.email
|
||||||
|
})
|
||||||
|
};
|
||||||
|
const newWorker = await models.Worker.new(newWorkerData);
|
||||||
|
|
||||||
|
await models.Worker.destroyById(newWorker.id);
|
||||||
|
|
||||||
|
expect(newWorker.id).toEqual(bruceWayneId);
|
||||||
|
});
|
||||||
|
});
|
|
@ -17,12 +17,18 @@
|
||||||
"Department": {
|
"Department": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
|
"Device": {
|
||||||
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
"EducationLevel": {
|
"EducationLevel": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
"Journey": {
|
"Journey": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
|
"ProfileType":{
|
||||||
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
"Time": {
|
"Time": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
|
@ -32,39 +38,42 @@
|
||||||
"WorkCenterHoliday": {
|
"WorkCenterHoliday": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
"WorkerDms": {
|
"Worker": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
"Worker": {
|
"WorkerConfig": {
|
||||||
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
|
"WorkerDepartment": {
|
||||||
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
|
"WorkerDisableExcluded": {
|
||||||
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
|
"WorkerDms": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
"WorkerLabour": {
|
"WorkerLabour": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
|
"WorkerLog": {
|
||||||
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
"WorkerMana": {
|
"WorkerMana": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
|
"WorkerMedia": {
|
||||||
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
"WorkerTeam": {
|
"WorkerTeam": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
"WorkerTeamCollegues": {
|
"WorkerTeamCollegues": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
"WorkerMedia": {
|
|
||||||
"dataSource": "vn"
|
|
||||||
},
|
|
||||||
"WorkerDepartment": {
|
|
||||||
"dataSource": "vn"
|
|
||||||
},
|
|
||||||
"WorkerTimeControl": {
|
"WorkerTimeControl": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
"Device": {
|
|
||||||
"dataSource": "vn"
|
|
||||||
},
|
|
||||||
"WorkerLog": {
|
|
||||||
"dataSource": "vn"
|
|
||||||
},
|
|
||||||
"WorkerTimeControlConfig": {
|
"WorkerTimeControlConfig": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
|
@ -73,9 +82,6 @@
|
||||||
},
|
},
|
||||||
"WorkerTimeControlMail": {
|
"WorkerTimeControlMail": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
|
||||||
"WorkerDisableExcluded": {
|
|
||||||
"dataSource": "vn"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
{
|
||||||
|
"name": "ProfileType",
|
||||||
|
"base": "VnModel",
|
||||||
|
"options": {
|
||||||
|
"mysql": {
|
||||||
|
"table": "profileType"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"properties": {
|
||||||
|
"id": {
|
||||||
|
"type": "number",
|
||||||
|
"id": true,
|
||||||
|
"description": "Identifier"
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
{
|
||||||
|
"name": "WorkerConfig",
|
||||||
|
"base": "VnModel",
|
||||||
|
"options": {
|
||||||
|
"mysql": {
|
||||||
|
"table": "workerConfig"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"properties": {
|
||||||
|
"id": {
|
||||||
|
"type": "number",
|
||||||
|
"id": true,
|
||||||
|
"description": "Identifier"
|
||||||
|
},
|
||||||
|
"roleFk": {
|
||||||
|
"type": "number"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"acls": [
|
||||||
|
{
|
||||||
|
"accessType": "READ",
|
||||||
|
"principalType": "ROLE",
|
||||||
|
"principalId": "$everyone",
|
||||||
|
"permission": "ALLOW"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -11,8 +11,17 @@
|
||||||
"id": true,
|
"id": true,
|
||||||
"type": "number"
|
"type": "number"
|
||||||
},
|
},
|
||||||
|
"breakTime": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
"timeToBreakTime": {
|
"timeToBreakTime": {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
|
},
|
||||||
|
"teleworkingStart": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"teleworkingStartBreakTime": {
|
||||||
|
"type": "number"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -13,4 +13,5 @@ module.exports = Self => {
|
||||||
require('../methods/worker/contracts')(Self);
|
require('../methods/worker/contracts')(Self);
|
||||||
require('../methods/worker/holidays')(Self);
|
require('../methods/worker/holidays')(Self);
|
||||||
require('../methods/worker/activeContract')(Self);
|
require('../methods/worker/activeContract')(Self);
|
||||||
|
require('../methods/worker/new')(Self);
|
||||||
};
|
};
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue