Merge branch 'dev' into 3126-changePackageFkTopackagingFk
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Pablo Natek 2023-10-05 07:57:46 +00:00
commit 020de5d754
137 changed files with 1439 additions and 542 deletions

View File

@ -5,18 +5,27 @@ 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/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [2342.01] - 2023-10-19
### Added
### Changed
### Fixed
## [2340.01] - 2023-10-05
### Added
### Changed
- (Usuarios -> Foto) Se muestra la foto del trabajador
### Changed
### Fixed
- (Usuarios -> Historial) Abre el descriptor del usuario correctamente
## [2338.01] - 2023-09-21
### Added
- (Ticket -> Servicios) Se pueden abonar servicios
- (Facturas -> Datos básicos) Muestra valores por defecto
- (Facturas -> Borrado) Notificación al borrar un asiento ya enlazado en Sage
### Changed
- (Trabajadores -> Calendario) Icono de check arreglado cuando pulsas un tipo de dia

View File

@ -0,0 +1,146 @@
module.exports = Self => {
Self.remoteMethodCtx('getTickets', {
description: 'Make a new collection of tickets',
accessType: 'WRITE',
accepts: [{
arg: 'id',
type: 'number',
description: 'The collection id',
required: true,
http: {source: 'path'}
}, {
arg: 'print',
type: 'boolean',
description: 'True if you want to print'
}],
returns: {
type: ['object'],
root: true
},
http: {
path: `/:id/getTickets`,
verb: 'POST'
}
});
Self.getTickets = async(ctx, id, print, options) => {
const userId = ctx.req.accessToken.userId;
const origin = ctx.req.headers.origin;
const $t = ctx.req.__;
const myOptions = {};
if (typeof options == 'object')
Object.assign(myOptions, options);
myOptions.userId = userId;
const promises = [];
const [tickets] = await Self.rawSql(`CALL vn.collection_getTickets(?)`, [id], myOptions);
const sales = await Self.rawSql(`
SELECT s.ticketFk,
sgd.saleGroupFk,
s.id saleFk,
s.itemFk,
i.longName,
i.size,
ic.color,
o.code origin,
ish.packing,
ish.grouping,
s.isAdded,
s.originalQuantity,
s.quantity saleQuantity,
iss.quantity reservedQuantity,
SUM(iss.quantity) OVER (PARTITION BY s.id ORDER BY ish.id) accumulatedQuantity,
ROW_NUMBER () OVER (PARTITION BY s.id ORDER BY pickingOrder) currentItemShelving,
COUNT(*) OVER (PARTITION BY s.id ORDER BY s.id) totalItemShelving,
sh.code,
IFNULL(p2.code, p.code) parkingCode,
IFNULL(p2.pickingOrder, p.pickingOrder) pickingOrder,
iss.id itemShelvingSaleFk,
iss.isPicked
FROM ticketCollection tc
LEFT JOIN collection c ON c.id = tc.collectionFk
JOIN ticket t ON t.id = tc.ticketFk
JOIN sale s ON s.ticketFk = t.id
LEFT JOIN saleGroupDetail sgd ON sgd.saleFk = s.id
LEFT JOIN saleGroup sg ON sg.id = sgd.saleGroupFk
LEFT JOIN parking p2 ON p2.id = sg.parkingFk
JOIN item i ON i.id = s.itemFk
LEFT JOIN itemShelvingSale iss ON iss.saleFk = s.id
LEFT JOIN itemShelving ish ON ish.id = iss.itemShelvingFk
LEFT JOIN shelving sh ON sh.code = ish.shelvingFk
LEFT JOIN parking p ON p.id = sh.parkingFk
LEFT JOIN itemColor ic ON ic.itemFk = s.itemFk
LEFT JOIN origin o ON o.id = i.originFk
WHERE tc.collectionFk = ?
GROUP BY ish.id, p.code, p2.code
ORDER BY pickingOrder;`, [id], myOptions);
if (print)
await Self.rawSql(`CALL vn.collection_printSticker(?, ?)`, [id, null], myOptions);
const collection = {collectionFk: id, tickets: []};
if (tickets && tickets.length) {
for (const ticket of tickets) {
const ticketId = ticket.ticketFk;
// SEND ROCKET
if (ticket.observaciones != '') {
for (observation of ticket.observaciones.split(' ')) {
if (['#', '@'].includes(observation.charAt(0))) {
promises.push(Self.app.models.Chat.send(ctx, observation,
$t('The ticket is in preparation', {
ticketId: ticketId,
ticketUrl: `${origin}/#!/ticket/${ticketId}/summary`,
salesPersonId: ticket.salesPersonFk
})));
}
}
}
// SET COLLECTION
if (sales && sales.length) {
// GET BARCODES
const barcodes = await Self.rawSql(`
SELECT s.id saleFk, b.code, c.id
FROM vn.sale s
LEFT JOIN vn.itemBarcode b ON b.itemFk = s.itemFk
LEFT JOIN vn.buy c ON c.itemFk = s.itemFk
LEFT JOIN vn.entry e ON e.id = c.entryFk
LEFT JOIN vn.travel tr ON tr.id = e.travelFk
WHERE s.ticketFk = ?
AND tr.landed >= util.VN_CURDATE() - INTERVAL 1 YEAR`,
[ticketId], myOptions);
// BINDINGS
ticket.sales = [];
for (const sale of sales) {
if (sale.ticketFk === ticketId) {
sale.Barcodes = [];
if (barcodes && barcodes.length) {
for (const barcode of barcodes) {
if (barcode.saleFk === sale.saleFk) {
for (const prop in barcode) {
if (['id', 'code'].includes(prop) && barcode[prop])
sale.Barcodes.push(barcode[prop].toString(), '0' + barcode[prop]);
}
}
}
}
ticket.sales.push(sale);
}
}
}
collection.tickets.push(ticket);
}
}
await Promise.all(promises);
return collection;
};
};

View File

@ -0,0 +1,39 @@
const models = require('vn-loopback/server/server').models;
describe('collection getTickets()', () => {
let ctx;
beforeAll(async() => {
ctx = {
req: {
accessToken: {userId: 9},
headers: {origin: 'http://localhost'}
}
};
});
it('should get tickets, sales and barcodes from collection', async() => {
const tx = await models.Collection.beginTransaction({});
try {
const options = {transaction: tx};
const collectionId = 1;
const collectionTickets = await models.Collection.getTickets(ctx, collectionId, null, options);
expect(collectionTickets.collectionFk).toEqual(collectionId);
expect(collectionTickets.tickets.length).toEqual(3);
expect(collectionTickets.tickets[0].ticketFk).toEqual(1);
expect(collectionTickets.tickets[1].ticketFk).toEqual(2);
expect(collectionTickets.tickets[2].ticketFk).toEqual(23);
expect(collectionTickets.tickets[0].sales[0].ticketFk).toEqual(1);
expect(collectionTickets.tickets[0].sales[1].ticketFk).toEqual(1);
expect(collectionTickets.tickets[0].sales[2].ticketFk).toEqual(1);
expect(collectionTickets.tickets[0].sales[0].Barcodes.length).toBeTruthy();
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});

View File

@ -4,4 +4,5 @@ module.exports = Self => {
require('../methods/collection/getSectors')(Self);
require('../methods/collection/setSaleQuantity')(Self);
require('../methods/collection/previousLabel')(Self);
require('../methods/collection/getTickets')(Self);
};

View File

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

View File

@ -34,7 +34,7 @@ BEGIN
isAllowedToWork
FROM(SELECT t.dated,
b.id businessFk,
w.userFk,
w.id,
b.departmentFk,
IF(j.start = NULL, NULL, GROUP_CONCAT(DISTINCT LEFT(j.start,5) ORDER BY j.start ASC SEPARATOR ' - ')) hourStart ,
IF(j.start = NULL, NULL, GROUP_CONCAT(DISTINCT LEFT(j.end,5) ORDER BY j.end ASC SEPARATOR ' - ')) hourEnd,
@ -48,14 +48,14 @@ BEGIN
FROM time t
LEFT JOIN business b ON t.dated BETWEEN b.started AND IFNULL(b.ended, vDatedTo)
LEFT JOIN worker w ON w.id = b.workerFk
JOIN tmp.`user` u ON u.userFK = w.userFK
JOIN tmp.`user` u ON u.userFK = w.id
LEFT JOIN workCenter wc ON wc.id = b.workcenterFK
LEFT JOIN postgresql.calendar_labour_type cl ON cl.calendar_labour_type_id = b.calendarTypeFk
LEFT JOIN postgresql.journey j ON j.business_id = b.id AND j.day_id = WEEKDAY(t.dated) + 1
LEFT JOIN postgresql.calendar_employee ce ON ce.businessFk = b.id AND ce.date = t.dated
LEFT JOIN absenceType at2 ON at2.id = ce.calendar_state_id
WHERE t.dated BETWEEN vDatedFrom AND vDatedTo
GROUP BY w.userFk, t.dated
GROUP BY w.id, t.dated
)sub;
UPDATE tmp.timeBusinessCalculate t

View File

@ -46,7 +46,7 @@ BEGIN
CONCAT('Cliente ', NEW.id),
CONCAT('Recibida la documentación: ', vText)
FROM worker w
LEFT JOIN account.user u ON w.userFk = u.id AND u.active
LEFT JOIN account.user u ON w.id = u.id AND u.active
LEFT JOIN account.account ac ON ac.id = u.id
WHERE w.id = NEW.salesPersonFk;
END IF;

View File

@ -1,6 +1,6 @@
ALTER TABLE `vn`.`deviceLog` ADD serialNumber varchar(45) DEFAULT NULL NULL;
-- ALTER TABLE `vn`.`deviceLog` ADD serialNumber varchar(45) DEFAULT NULL NULL;
INSERT INTO `salix`.`ACL` ( model, property, accessType, permission, principalType, principalId)
VALUES( 'DeviceLog', 'create', 'WRITE', 'ALLOW', 'ROLE', 'employee');
-- INSERT INTO `salix`.`ACL` ( model, property, accessType, permission, principalType, principalId)
-- VALUES( 'DeviceLog', 'create', 'WRITE', 'ALLOW', 'ROLE', 'employee');

View File

@ -0,0 +1,3 @@
INSERT INTO `salix`.`ACL`(model, property, accessType, permission, principalType, principalId)
VALUES
('Collection', 'getTickets', 'WRITE', 'ALLOW', 'ROLE', 'employee');

View File

@ -0,0 +1,42 @@
-- No encuentro este back
DELETE FROM `salix`.`ACL` WHERE property = 'activeWorkersWithRole';
DELETE FROM `salix`.`ACL` WHERE model = 'Client' AND property = '*';
INSERT INTO `salix`.`ACL` (model,property,accessType,permission,principalType,principalId)
VALUES ('Client','findOne','READ','ALLOW','ROLE','employee');
INSERT INTO `salix`.`ACL` (model,property,accessType,permission,principalType,principalId)
VALUES ('Client','findById','READ','ALLOW','ROLE','employee');
INSERT INTO `salix`.`ACL` (model,property,accessType,permission,principalType,principalId)
VALUES ('Client','find','READ','ALLOW','ROLE','employee');
INSERT INTO `salix`.`ACL` (model,property,accessType,permission,principalType,principalId)
VALUES ('Client','exists','READ','ALLOW','ROLE','employee');
INSERT INTO `salix`.`ACL` (model,property,accessType,permission,principalType,principalId)
VALUES ('Client','__get__addresses','READ','ALLOW','ROLE','employee');
DELETE FROM `salix`.`ACL` WHERE model = 'Client' AND property = '*' AND accessType IN (
'campaignMetricsEmail',
'campaignMetricsPdf',
'clientDebtStatementEmail',
'clientDebtStatementHtml',
'clientDebtStatementPdf',
'clientWelcomeEmail',
'clientWelcomeHtml',
'consumptionSendQueued',
'creditRequestEmail',
'creditRequestHtml',
'creditRequestPdf',
'getClientOrSupplierReference',
'incotermsAuthorizationEmail',
'incotermsAuthorizationHtml',
'incotermsAuthorizationPdf',
'letterDebtorNdEmail',
'letterDebtorNdHtml',
'letterDebtorPdf',
'letterDebtorStEmail',
'letterDebtorStHtml',
'printerSetupEmail',
'printerSetupHtml',
'sepaCoreEmail',
'setPassword',
'updateUser',
'uploadFile');

View File

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

View File

@ -0,0 +1,11 @@
INSERT INTO `salix`.`ACL` ( model, property, accessType, permission, principalType, principalId)
VALUES
('ExpeditionMistakeType', '*', 'READ', 'ALLOW', 'ROLE', 'employee'),
('WorkerMistakeType', '*', 'READ', 'ALLOW', 'ROLE', 'employee'),
('ExpeditionMistake','*','WRITE','ALLOW','ROLE','employee'),
('WorkerMistake', '*', 'WRITE', 'ALLOW', 'ROLE', 'coolerBoss'),
('MistakesTypes', '*', 'WRITE', 'ALLOW', 'ROLE', 'coolerBoss'),
('MistakeType','*','READ','ALLOW','ROLE','employee'),
('MachineWorker', '*', 'READ', 'ALLOW', 'ROLE', 'coolerAssist'),
('Printer','*','READ','ALLOW','ROLE','employee'),
('SaleMistake', '*', 'WRITE', 'ALLOW', 'ROLE', 'production');

View File

@ -0,0 +1,86 @@
DELIMITER $$
$$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`timeBusiness_calculate`(vDatedFrom DATETIME, vDatedTo DATETIME)
BEGIN
/**
* Horas que debe trabajar un empleado según contrato y día.
* @param vDatedFrom workerTimeControl
* @param vDatedTo workerTimeControl
* @table tmp.user(userFk)
* @return tmp.timeBusinessCalculate
*/
DROP TEMPORARY TABLE IF EXISTS tmp.timeBusinessCalculate;
CREATE TEMPORARY TABLE tmp.timeBusinessCalculate
(INDEX (departmentFk))
SELECT dated,
businessFk,
sub.id userFk,
departmentFk,
hourStart,
hourEnd,
timeTable,
timeWorkSeconds,
SEC_TO_TIME(timeWorkSeconds) timeWorkSexagesimal,
timeWorkSeconds / 3600 timeWorkDecimal,
timeWorkSeconds timeBusinessSeconds,
SEC_TO_TIME(timeWorkSeconds) timeBusinessSexagesimal,
timeWorkSeconds / 3600 timeBusinessDecimal,
name type,
permissionRate,
hoursWeek,
discountRate,
isAllowedToWork
FROM(SELECT t.dated,
b.id businessFk,
w.id,
b.departmentFk,
IF(bs.started = NULL, NULL, GROUP_CONCAT(DISTINCT LEFT(bs.started,5) ORDER BY bs.started ASC SEPARATOR ' - ')) hourStart ,
IF(bs.started = NULL, NULL, GROUP_CONCAT(DISTINCT LEFT(bs.ended,5) ORDER BY bs.ended ASC SEPARATOR ' - ')) hourEnd,
IF(bs.started = NULL, NULL, GROUP_CONCAT(DISTINCT LEFT(bs.started,5), " - ", LEFT(bs.ended,5) ORDER BY bs.ended ASC SEPARATOR ' - ')) timeTable,
IF(bs.started = NULL, 0, IFNULL(SUM(TIME_TO_SEC(bs.ended)) - SUM(TIME_TO_SEC(bs.started)), 0)) timeWorkSeconds,
at2.name,
at2.permissionRate,
at2.discountRate,
ct.hoursWeek hoursWeek,
at2.isAllowedToWork
FROM time t
LEFT JOIN business b ON t.dated BETWEEN b.started AND IFNULL(b.ended, vDatedTo)
LEFT JOIN worker w ON w.id = b.workerFk
JOIN tmp.`user` u ON u.userFK = w.id
LEFT JOIN workCenter wc ON wc.id = b.workcenterFK
LEFT JOIN calendarType ct ON ct.id = b.calendarTypeFk
LEFT JOIN businessSchedule bs ON bs.businessFk = b.id AND bs.weekday = WEEKDAY(t.dated) + 1
LEFT JOIN calendar c ON c.businessFk = b.id AND c.dated = t.dated
LEFT JOIN absenceType at2 ON at2.id = c.dayOffTypeFk
WHERE t.dated BETWEEN vDatedFrom AND vDatedTo
GROUP BY w.id, t.dated
)sub;
UPDATE tmp.timeBusinessCalculate t
LEFT JOIN businessSchedule bs ON bs.businessFk = t.businessFk
SET t.timeWorkSeconds = t.hoursWeek / 5 * 3600,
t.timeWorkSexagesimal = SEC_TO_TIME( t.hoursWeek / 5 * 3600),
t.timeWorkDecimal = t.hoursWeek / 5,
t.timeBusinessSeconds = t.hoursWeek / 5 * 3600,
t.timeBusinessSexagesimal = SEC_TO_TIME( t.hoursWeek / 5 * 3600),
t.timeBusinessDecimal = t.hoursWeek / 5
WHERE DAYOFWEEK(t.dated) IN(2,3,4,5,6) AND bs.id IS NULL ;
UPDATE tmp.timeBusinessCalculate t
SET t.timeWorkSeconds = t.timeWorkSeconds - (t.timeWorkSeconds * permissionRate) ,
t.timeWorkSexagesimal = SEC_TO_TIME ((t.timeWorkDecimal - (t.timeWorkDecimal * permissionRate)) * 3600),
t.timeWorkDecimal = t.timeWorkDecimal - (t.timeWorkDecimal * permissionRate)
WHERE permissionRate <> 0;
UPDATE tmp.timeBusinessCalculate t
JOIN calendarHolidays ch ON ch.dated = t.dated
JOIN business b ON b.id = t.businessFk
AND b.workcenterFk = ch.workcenterFk
SET t.timeWorkSeconds = 0,
t.timeWorkSexagesimal = 0,
t.timeWorkDecimal = 0,
t.permissionrate = 1,
t.type = 'Festivo'
WHERE t.type IS NULL;
END$$
DELIMITER ;

View File

@ -0,0 +1,57 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `account`.`account_enable`(vSelf INT)
BEGIN
/**
* Enables a worker's account and sets up email configurations.
*/
UPDATE user
SET active = TRUE
WHERE id = vSelf;
INSERT IGNORE INTO account
SET id = vSelf;
INSERT IGNORE INTO mailAliasAccount (mailAlias, account)
SELECT id, vSelf
FROM mailAlias
WHERE alias = 'general';
INSERT IGNORE INTO mailForward (account, forwardTo)
SELECT vSelf, email
FROM user
WHERE id = vSelf;
END$$
DELIMITER ;
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`worker_updateBusiness`(vSelf INT)
BEGIN
/**
* Activates an account and configures its email settings.
*
* @param vSelf account id.
*/
DECLARE vOldBusinessFk INT;
DECLARE vNewBusinessFk INT;
SELECT businessFk INTO vOldBusinessFk FROM worker WHERE id = vSelf;
SELECT id INTO vNewBusinessFk
FROM business
WHERE workerFk = vSelf
AND util.VN_CURDATE() BETWEEN started AND IFNULL(ended, util.VN_CURDATE());
UPDATE worker
SET businessFk = vNewBusinessFk
WHERE id = vSelf;
IF NOT (vOldBusinessFk <=> vNewBusinessFk) THEN
IF vNewBusinessFk IS NULL THEN
CALL workerDisable(vSelf);
END IF;
IF vOldBusinessFk IS NULL THEN
CALL account.account_enable(vSelf);
END IF;
END IF;
END$$
DELIMITER ;

View File

@ -0,0 +1,10 @@
DELETE FROM `salix`.`ACL` WHERE model = 'Account' AND property = '*' AND principalId = 'employee';
INSERT INTO `salix`.`ACL` (model,property,accessType,permission,principalType,principalId)
VALUES ('Account','findOne','READ','ALLOW','ROLE','employee');
INSERT INTO `salix`.`ACL` (model,property,accessType,permission,principalType,principalId)
VALUES ('Account','findById','READ','ALLOW','ROLE','employee');
INSERT INTO `salix`.`ACL` (model,property,accessType,permission,principalType,principalId)
VALUES ('Account','find','READ','ALLOW','ROLE','employee');
INSERT INTO `salix`.`ACL` (model,property,accessType,permission,principalType,principalId)
VALUES ('Account','exists','READ','ALLOW','ROLE','employee');

View File

@ -1,16 +1,21 @@
-- Auto-generated SQL script. Actual values for binary/complex data types may differ - what you see is the default string representation of values.
INSERT INTO `account`.`role` (name,description)
INSERT INTO `account`.`role` (name, description)
VALUES ('deliveryAssistant','Jefe auxiliar repartos');
INSERT INTO `account`.`roleInherit` (role, inheritsFrom)
SELECT (SELECT id FROM account.role r1 WHERE r1.name = 'deliveryAssistant'), ri.inheritsFrom
FROM account.roleInherit ri
JOIN account.role r2 ON r2.id = ri.`role`
WHERE r2.name = 'deliveryBoss';
FROM account.roleInherit ri
JOIN account.role r2 ON r2.id = ri.`role`
WHERE r2.name = 'deliveryBoss';
DELETE `account`.`roleInherit` FROM `account`.`roleInherit`
JOIN `account`.`role` r ON `account`.`roleInherit`.role = r.id
WHERE r.name = 'deliveryBoss';
INSERT INTO `account`.`roleInherit` (role, inheritsFrom)
SELECT (SELECT id FROM account.role WHERE name = 'deliveryBoss') role,
(SELECT id FROM account.role WHERE name = 'deliveryAssistant') roleInherit;
CALL `account`.`role_syncPrivileges`();
UPDATE `salix`.`ACL`
SET principalId='deliveryAssistant'
WHERE principalId='deliveryBoss';

View File

@ -0,0 +1,20 @@
DELIMITER $$
$$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`workerCreate`(
vFirstname VARCHAR(50),
vLastName VARCHAR(50),
vCode CHAR(3),
vBossFk INT,
vUserFk INT,
vFi VARCHAR(15) ,
vBirth DATE
)
BEGIN
/**
* Create new worker
*
*/
INSERT INTO worker(id, code, firstName, lastName, bossFk, fi, birth)
VALUES (vUserFk, vCode, vFirstname, vLastName, vBossFk, vFi, vBirth);
END$$
DELIMITER ;

View File

@ -0,0 +1,2 @@
-- Locally it fails because it is executed before the fixtures and the roleConfig table is empty
CALL `account`.`role_syncPrivileges`();

View File

@ -0,0 +1,291 @@
ALTER TABLE `vn`.`itemShelvingSale` DROP COLUMN IF EXISTS isPicked;
ALTER TABLE`vn`.`itemShelvingSale`
ADD isPicked TINYINT(1) DEFAULT FALSE NOT NULL;
ALTER TABLE `vn`.`productionConfig` DROP COLUMN IF EXISTS orderMode;
ALTER TABLE `vn`.`productionConfig`
ADD orderMode ENUM('Location', 'Age') NOT NULL DEFAULT 'Location';
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_reserveByCollection`(
vCollectionFk INT(11)
)
BEGIN
/**
* Reserva cantidades con ubicaciones para el contenido de una colección
*
* @param vCollectionFk Identificador de collection
*/
CREATE OR REPLACE TEMPORARY TABLE tmp.sale
(INDEX(saleFk))
ENGINE = MEMORY
SELECT s.id saleFk, NULL userFk
FROM ticketCollection tc
JOIN sale s ON s.ticketFk = tc.ticketFk
LEFT JOIN (
SELECT DISTINCT saleFk
FROM saleTracking st
JOIN state s ON s.id = st.stateFk
WHERE st.isChecked
AND s.semaphore = 1)st ON st.saleFk = s.id
WHERE tc.collectionFk = vCollectionFk
AND st.saleFk IS NULL
AND NOT s.isPicked;
CALL itemShelvingSale_reserve();
END$$
DELIMITER ;
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_setQuantity`(
vItemShelvingSaleFk INT(10),
vQuantity DECIMAL(10,0),
vIsItemShelvingSaleEmpty BOOLEAN
)
BEGIN
/**
* Gestiona la reserva de un itemShelvingFk, actualizando isPicked y quantity
* en vn.itemShelvingSale y vn.sale.isPicked en caso necesario.
* Si la reserva de la ubicación es fallida, se regulariza la situación
*
* @param vItemShelvingSaleFk Id itemShelvingSaleFK
* @param vQuantity Cantidad real que se ha cogido de la ubicación
* @param vIsItemShelvingSaleEmpty determina si ka ubicación itemShelvingSale se ha
* quedado vacio tras el movimiento
*/
DECLARE vSaleFk INT;
DECLARE vCursorSaleFk INT;
DECLARE vItemShelvingFk INT;
DECLARE vReservedQuantity INT;
DECLARE vRemainingQuantity INT;
DECLARE vItemFk INT;
DECLARE vUserFk INT;
DECLARE vDone BOOLEAN DEFAULT FALSE;
DECLARE vSales CURSOR FOR
SELECT iss.saleFk, iss.userFk
FROM itemShelvingSale iss
JOIN sale s ON s.id = iss.saleFk
WHERE iss.id = vItemShelvingSaleFk
AND s.itemFk = vItemFk
AND NOT iss.isPicked;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
IF (SELECT isPicked FROM itemShelvingSale WHERE id = vItemShelvingSaleFk) THEN
CALL util.throw('Booking completed');
END IF;
SELECT s.itemFk, iss.saleFk, iss.itemShelvingFk
INTO vItemFk, vSaleFk, vItemShelvingFk
FROM itemShelvingSale iss
JOIN sale s ON s.id = iss.saleFk
WHERE iss.id = vItemShelvingSaleFk
AND NOT iss.isPicked;
UPDATE itemShelvingSale
SET isPicked = TRUE,
quantity = vQuantity
WHERE id = vItemShelvingSaleFk;
UPDATE itemShelving
SET visible = IF(vIsItemShelvingSaleEmpty, 0, GREATEST(0,visible - vQuantity))
WHERE id = vItemShelvingFk;
IF vIsItemShelvingSaleEmpty THEN
OPEN vSales;
l: LOOP
SET vDone = FALSE;
FETCH vSales INTO vCursorSaleFk, vUserFk;
IF vDone THEN
LEAVE l;
END IF;
CREATE OR REPLACE TEMPORARY TABLE tmp.sale
(INDEX(saleFk, userFk))
ENGINE = MEMORY
SELECT vCursorSaleFk, vUserFk;
CALL itemShelvingSale_reserveWhitUser();
DROP TEMPORARY TABLE tmp.sale;
END LOOP;
CLOSE vSales;
DELETE iss
FROM itemShelvingSale iss
JOIN sale s ON s.id = iss.saleFk
WHERE iss.id = vItemShelvingSaleFk
AND s.itemFk = vItemFk
AND NOT iss.isPicked;
END IF;
SELECT SUM(quantity) INTO vRemainingQuantity
FROM itemShelvingSale
WHERE saleFk = vSaleFk
AND NOT isPicked;
IF vRemainingQuantity THEN
CALL itemShelvingSale_reserveBySale (vSaleFk, vRemainingQuantity, NULL);
SELECT SUM(quantity) INTO vRemainingQuantity
FROM itemShelvingSale
WHERE saleFk = vSaleFk
AND NOT isPicked;
IF NOT vRemainingQuantity <=> 0 THEN
SELECT SUM(iss.quantity)
INTO vReservedQuantity
FROM itemShelvingSale iss
WHERE iss.saleFk = vSaleFk;
CALL saleTracking_new(
vSaleFk,
TRUE,
vReservedQuantity,
`account`.`myUser_getId`(),
NULL,
'PREPARED',
TRUE);
UPDATE sale s
SET s.quantity = vReservedQuantity
WHERE s.id = vSaleFk ;
END IF;
END IF;
END$$
DELIMITER ;
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_reserve`()
BEGIN
/**
* Reserva cantidades con ubicaciones para un conjunto de sales del mismo wareHouse
*
* @table tmp.sale(saleFk, userFk)
*/
DECLARE vCalcFk INT;
DECLARE vWarehouseFk INT;
DECLARE vCurrentYear INT DEFAULT YEAR(util.VN_NOW());
DECLARE vLastPickingOrder INT;
SELECT t.warehouseFk, MAX(p.pickingOrder)
INTO vWarehouseFk, vLastPickingOrder
FROM ticket t
JOIN sale s ON s.ticketFk = t.id
JOIN tmp.sale ts ON ts.saleFk = s.id
LEFT JOIN itemShelvingSale iss ON iss.saleFk = ts.saleFk
LEFT JOIN itemShelving ish ON ish.id = iss.itemShelvingFk
LEFT JOIN shelving sh ON sh.code = ish.shelvingFk
LEFT JOIN parking p ON p.id = sh.parkingFk
WHERE t.warehouseFk IS NOT NULL;
IF vWarehouseFk IS NULL THEN
CALL util.throw('Warehouse not set');
END IF;
CALL cache.visible_refresh(vCalcFk, FALSE, vWarehouseFk);
SET @outstanding = 0;
SET @oldsaleFk = 0;
CREATE OR REPLACE TEMPORARY TABLE tSalePlacementQuantity
(INDEX(saleFk))
ENGINE = MEMORY
SELECT saleFk, userFk, quantityToReserve, itemShelvingFk
FROM( SELECT saleFk,
sub.userFk,
itemShelvingFk ,
IF(saleFk <> @oldsaleFk, @outstanding := quantity, @outstanding),
@qtr := LEAST(@outstanding, available) quantityToReserve,
@outStanding := @outStanding - @qtr,
@oldsaleFk := saleFk
FROM(
SELECT ts.saleFk,
ts.userFk,
s.quantity,
ish.id itemShelvingFk,
ish.visible - IFNULL(ishr.reservedQuantity, 0) available
FROM tmp.sale ts
JOIN sale s ON s.id = ts.saleFk
JOIN itemShelving ish ON ish.itemFk = s.itemFk
LEFT JOIN (
SELECT itemShelvingFk, SUM(quantity) reservedQuantity
FROM itemShelvingSale
WHERE NOT isPicked
GROUP BY itemShelvingFk) ishr ON ishr.itemShelvingFk = ish.id
JOIN shelving sh ON sh.code = ish.shelvingFk
JOIN parking p ON p.id = sh.parkingFk
JOIN sector sc ON sc.id = p.sectorFk
JOIN warehouse w ON w.id = sc.warehouseFk
JOIN productionConfig pc
WHERE w.id = vWarehouseFk
AND NOT sc.isHideForPickers
ORDER BY
s.id,
p.pickingOrder >= vLastPickingOrder,
sh.priority DESC,
ish.visible >= s.quantity DESC,
s.quantity MOD ish.grouping = 0 DESC,
ish.grouping DESC,
IF(pc.orderMode = 'Location', p.pickingOrder, ish.created)
)sub
)sub2
WHERE quantityToReserve > 0;
INSERT INTO itemShelvingSale(
itemShelvingFk,
saleFk,
quantity,
userFk)
SELECT itemShelvingFk,
saleFk,
quantityToReserve,
IFNULL(userFk, getUser())
FROM tSalePlacementQuantity spl;
DROP TEMPORARY TABLE tmp.sale;
END$$
DELIMITER ;
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_reserveBySale`(
vSelf INT ,
vQuantity INT,
vUserFk INT
)
BEGIN
/**
* Reserva cantida y ubicación para una saleFk
*
* @param vSelf Identificador de la venta
* @param vQuantity Cantidad a reservar
* @param vUserFk Id de usuario que realiza la reserva
*/
CREATE OR REPLACE TEMPORARY TABLE tmp.sale
ENGINE = MEMORY
SELECT vSelf saleFk, vUserFk userFk;
CALL itemShelvingSale_reserve();
END$$
DELIMITER ;
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemShelvingSale_AFTER_INSERT`
AFTER INSERT ON `itemShelvingSale`
FOR EACH ROW
BEGIN
UPDATE vn.sale
SET isPicked = TRUE
WHERE id = NEW.saleFk;
END$$
DELIMITER ;

View File

File diff suppressed because one or more lines are too long

View File

@ -87,8 +87,8 @@ INSERT INTO `vn`.`educationLevel` (`id`, `name`)
(1, 'ESTUDIOS PRIMARIOS COMPLETOS'),
(2, 'ENSEÑANZAS DE BACHILLERATO');
INSERT INTO `vn`.`worker`(`id`,`code`, `firstName`, `lastName`, `userFk`, `bossFk`)
SELECT id,UPPER(LPAD(role, 3, '0')), name, name, id, 9
INSERT INTO `vn`.`worker`(`id`,`code`, `firstName`, `lastName`, `bossFk`)
SELECT id,UPPER(LPAD(role, 3, '0')), name, name, 9
FROM `account`.`user`;
UPDATE `vn`.`worker` SET bossFk = NULL WHERE id = 20;
@ -188,13 +188,13 @@ INSERT INTO `vn`.`printer` (`id`, `name`, `path`, `isLabeler`, `sectorFk`, `ipAd
UPDATE `vn`.`sector` SET mainPrinterFk = 1 WHERE id = 1;
INSERT INTO `vn`.`worker`(`id`, `code`, `firstName`, `lastName`, `userFk`,`bossFk`, `phone`)
INSERT INTO `vn`.`worker`(`id`, `code`, `firstName`, `lastName`,`bossFk`, `phone`)
VALUES
(1106, 'LGN', 'David Charles', 'Haller', 1106, 19, 432978106),
(1107, 'ANT', 'Hank' , 'Pym' , 1107, 19, 432978107),
(1108, 'DCX', 'Charles' , 'Xavier', 1108, 19, 432978108),
(1109, 'HLK', 'Bruce' , 'Banner', 1109, 19, 432978109),
(1110, 'JJJ', 'Jessica' , 'Jones' , 1110, 19, 432978110);
(1106, 'LGN', 'David Charles', 'Haller', 19, 432978106),
(1107, 'ANT', 'Hank' , 'Pym' , 19, 432978107),
(1108, 'DCX', 'Charles' , 'Xavier', 19, 432978108),
(1109, 'HLK', 'Bruce' , 'Banner', 19, 432978109),
(1110, 'JJJ', 'Jessica' , 'Jones' , 19, 432978110);
INSERT INTO `vn`.`parking` (`id`, `column`, `row`, `sectorFk`, `code`, `pickingOrder`)
VALUES
@ -1409,10 +1409,8 @@ INSERT INTO `cache`.`cache_calc`(`id`, `cache_id`, `cacheName`, `params`, `last_
INSERT INTO `vn`.`ticketWeekly`(`ticketFk`, `weekDay`)
VALUES
(1, 0),
(2, 1),
(3, 2),
(4, 4),
(5, 6),
(15, 6);
@ -2974,3 +2972,7 @@ INSERT INTO vn.XDiario (id, ASIEN, FECHA, SUBCTA, CONTRA, CONCEPTO, EURODEBE, EU
(4, 2.0, util.VN_CURDATE(), '4300001104', NULL, 'n/fra T4444444', 8.88, NULL, NULL, NULL, '0', NULL, 0.00, NULL, NULL, NULL, NULL, NULL, '2', NULL, 1, 2, 'I.F.', 'Nombre Importador', 1, 0, 0, util.VN_CURDATE(), 0, 442, 0, 0, 0.00, NULL, NULL, util.VN_CURDATE(), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, 0),
(5, 2.0, util.VN_CURDATE(), '2000000000', '4300001104', 'n/fra T4444444 Tony Stark', NULL, 8.07, NULL, NULL, '0', NULL, 0.00, NULL, NULL, NULL, NULL, NULL, '2', NULL, 1, 2, 'I.F.', 'Nombre Importador', 1, 0, 0, util.VN_CURDATE(), 0, 442, 0, 0, 0.00, NULL, NULL, util.VN_CURDATE(), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, 0),
(6, 2.0, util.VN_CURDATE(), '4770000010', '4300001104', 'Inmovilizado pendiente : n/fra T4444444 Tony Stark', NULL, 0.81, 8.07, 'T', '4444444', 10.00, NULL, NULL, NULL, NULL, NULL, '', '2', '', 1, 1, '06089160W', 'IRON MAN', 1, 1, 0, util.VN_CURDATE(), 0, 442, 0, 0, 0.00, NULL, NULL, util.VN_CURDATE(), NULL, 1, 1, 1, 1, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, 0);
INSERT INTO `vn`.`mistakeType` (`id`, `description`)
VALUES
(1, 'Incorrect quantity');

View File

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

View File

@ -520,8 +520,7 @@ export default {
searchResultDate: 'vn-ticket-summary [label=Landed] span',
topbarSearch: 'vn-searchbar',
moreMenu: 'vn-ticket-index vn-icon-button[icon=more_vert]',
fourthWeeklyTicket: 'vn-ticket-weekly-index vn-card smart-table slot-table tr:nth-child(5)',
fiveWeeklyTicket: 'vn-ticket-weekly-index vn-card smart-table slot-table tr:nth-child(6)',
thirdWeeklyTicket: 'vn-ticket-weekly-index vn-card smart-table slot-table tr:nth-child(4)',
weeklyTicket: 'vn-ticket-weekly-index vn-card smart-table slot-table table tbody tr',
firstWeeklyTicketDeleteIcon: 'vn-ticket-weekly-index vn-card smart-table slot-table tr:nth-child(2) vn-icon-button[icon="delete"]',
firstWeeklyTicketAgency: 'vn-ticket-weekly-index vn-card smart-table slot-table tr:nth-child(2) [ng-model="weekly.agencyModeFk"]',

View File

@ -19,7 +19,7 @@ describe('Ticket descriptor path', () => {
it('should count the amount of tickets in the turns section', async() => {
const result = await page.countElement(selectors.ticketsIndex.weeklyTicket);
expect(result).toEqual(7);
expect(result).toEqual(5);
});
it('should go back to the ticket index then search and access a ticket summary', async() => {
@ -45,7 +45,7 @@ describe('Ticket descriptor path', () => {
it('should confirm the ticket 11 was added to thursday', async() => {
await page.accessToSection('ticket.weekly.index');
const result = await page.waitToGetProperty(selectors.ticketsIndex.fourthWeeklyTicket, 'value');
const result = await page.waitToGetProperty(selectors.ticketsIndex.thirdWeeklyTicket, 'value');
expect(result).toEqual('Thursday');
});
@ -80,7 +80,9 @@ describe('Ticket descriptor path', () => {
it('should confirm the ticket 11 was added on saturday', async() => {
await page.accessToSection('ticket.weekly.index');
const result = await page.waitToGetProperty(selectors.ticketsIndex.fiveWeeklyTicket, 'value');
await page.waitForTimeout(5000);
const result = await page.waitToGetProperty(selectors.ticketsIndex.thirdWeeklyTicket, 'value');
expect(result).toEqual('Saturday');
});
@ -104,7 +106,7 @@ describe('Ticket descriptor path', () => {
await page.doSearch();
const nResults = await page.countElement(selectors.ticketsIndex.searchWeeklyResult);
expect(nResults).toEqual(7);
expect(nResults).toEqual(5);
});
it('should update the agency then remove it afterwards', async() => {

View File

@ -1,5 +1,5 @@
import selectors from '../../helpers/selectors.js';
import getBrowser from '../../helpers/puppeteer';
import getBrowser from '../../helpers/puppeteer.js';
// #1528 e2e claim/detail
xdescribe('Claim detail', () => {

View File

@ -1,97 +0,0 @@
import selectors from '../../helpers/selectors.js';
import getBrowser from '../../helpers/puppeteer';
describe('Claim development', () => {
let browser;
let page;
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('claimManager', 'claim');
await page.accessToSearchResult('1');
await page.accessToSection('claim.card.development');
});
afterAll(async() => {
await browser.close();
});
it('should delete a development and create a new one', async() => {
await page.waitToClick(selectors.claimDevelopment.firstDeleteDevelopmentButton);
await page.waitToClick(selectors.claimDevelopment.addDevelopmentButton);
await page.autocompleteSearch(selectors.claimDevelopment.secondClaimReason, 'Baja calidad');
await page.autocompleteSearch(selectors.claimDevelopment.secondClaimResult, 'Deshidratacion');
await page.autocompleteSearch(selectors.claimDevelopment.secondClaimResponsible, 'Calidad general');
await page.autocompleteSearch(selectors.claimDevelopment.secondClaimWorker, 'deliveryNick');
await page.autocompleteSearch(selectors.claimDevelopment.secondClaimRedelivery, 'Reparto');
await page.waitToClick(selectors.claimDevelopment.saveDevelopmentButton);
const message = await page.waitForSnackbar();
expect(message.text).toContain('Data saved!');
});
it(`should redirect to the next section of claims as the role is claimManager`, async() => {
await page.waitForState('claim.card.action');
});
it('should edit a development', async() => {
await page.reloadSection('claim.card.development');
await page.autocompleteSearch(selectors.claimDevelopment.firstClaimReason, 'Calor');
await page.autocompleteSearch(selectors.claimDevelopment.firstClaimResult, 'Cocido');
await page.autocompleteSearch(selectors.claimDevelopment.firstClaimResponsible, 'Calidad general');
await page.autocompleteSearch(selectors.claimDevelopment.firstClaimWorker, 'adminAssistantNick');
await page.autocompleteSearch(selectors.claimDevelopment.firstClaimRedelivery, 'Cliente');
await page.waitToClick(selectors.claimDevelopment.saveDevelopmentButton);
const message = await page.waitForSnackbar();
expect(message.text).toContain('Data saved!');
});
it('should confirm the first development is the expected one', async() => {
await page.reloadSection('claim.card.development');
const reason = await page
.waitToGetProperty(selectors.claimDevelopment.firstClaimReason, 'value');
const result = await page
.waitToGetProperty(selectors.claimDevelopment.firstClaimResult, 'value');
const responsible = await page
.waitToGetProperty(selectors.claimDevelopment.firstClaimResponsible, 'value');
const worker = await page
.waitToGetProperty(selectors.claimDevelopment.firstClaimWorker, 'value');
const redelivery = await page
.waitToGetProperty(selectors.claimDevelopment.firstClaimRedelivery, 'value');
expect(reason).toEqual('Calor');
expect(result).toEqual('Baboso/Cocido');
expect(responsible).toEqual('Calidad general');
expect(worker).toEqual('adminAssistantNick');
expect(redelivery).toEqual('Cliente');
});
it('should confirm the second development is the expected one', async() => {
const reason = await page
.waitToGetProperty(selectors.claimDevelopment.secondClaimReason, 'value');
const result = await page
.waitToGetProperty(selectors.claimDevelopment.secondClaimResult, 'value');
const responsible = await page
.waitToGetProperty(selectors.claimDevelopment.secondClaimResponsible, 'value');
const worker = await page
.waitToGetProperty(selectors.claimDevelopment.secondClaimWorker, 'value');
const redelivery = await page
.waitToGetProperty(selectors.claimDevelopment.secondClaimRedelivery, 'value');
expect(reason).toEqual('Baja calidad');
expect(result).toEqual('Deshidratacion');
expect(responsible).toEqual('Calidad general');
expect(worker).toEqual('deliveryNick');
expect(redelivery).toEqual('Reparto');
});
});

View File

@ -1,5 +1,5 @@
import selectors from '../../helpers/selectors.js';
import getBrowser from '../../helpers/puppeteer';
import getBrowser from '../../helpers/puppeteer.js';
describe('Claim action path', () => {
let browser;

View File

@ -1,6 +1,6 @@
import selectors from '../../helpers/selectors.js';
import getBrowser from '../../helpers/puppeteer';
import getBrowser from '../../helpers/puppeteer.js';
describe('Claim summary path', () => {
let browser;

View File

@ -1,5 +1,5 @@
import selectors from '../../helpers/selectors.js';
import getBrowser from '../../helpers/puppeteer';
import getBrowser from '../../helpers/puppeteer.js';
describe('Claim descriptor path', () => {
let browser;

View File

@ -18,6 +18,7 @@ import './section';
import './summary';
import './topbar/topbar';
import './user-popover';
import './user-photo';
import './upload-photo';
import './bank-entity';
import './log';

View File

@ -28,7 +28,7 @@
<vn-avatar
ng-class="::{system: !userLog.user}"
val="{{::userLog.user ? userLog.user.nickname : $ctrl.$t('System')}}"
ng-click="$ctrl.showWorkerDescriptor($event, userLog)">
ng-click="$ctrl.showDescriptor($event, userLog)">
<img
ng-if="::userLog.user.image"
ng-src="/api/Images/user/160x160/{{::userLog.userFk}}/download?access_token={{::$ctrl.vnToken.token}}">
@ -260,3 +260,6 @@
<vn-worker-descriptor-popover
vn-id="worker-descriptor">
</vn-worker-descriptor-popover>
<vn-account-descriptor-popover
vn-id="account-descriptor">
</vn-account-descriptor-popover>

View File

@ -362,9 +362,11 @@ export default class Controller extends Section {
}
}
showWorkerDescriptor(event, userLog) {
if (userLog.user?.worker)
this.$.workerDescriptor.show(event.target, userLog.userFk);
showDescriptor(event, userLog) {
if (userLog.user?.worker && this.$state.current.name.split('.')[0] != 'account')
return this.$.workerDescriptor.show(event.target, userLog.userFk);
this.$.accountDescriptor.show(event.target, userLog.userFk);
}
}

View File

@ -0,0 +1,15 @@
<div class="photo" text-center>
<img vn-id="photo"
ng-src="{{$root.imagePath('user', '520x520', $ctrl.userId)}}"
zoom-image="{{$root.imagePath('user', '1600x1600', $ctrl.userId)}}"
on-error-src/>
<vn-float-button ng-click="uploadPhoto.show('user', $ctrl.userId)"
icon="edit"
vn-visible-by="userPhotos">
</vn-float-button>
</div>
<!-- Upload photo dialog -->
<vn-upload-photo
vn-id="uploadPhoto"
on-response="$ctrl.onUploadResponse()">
</vn-upload-photo>

View File

@ -0,0 +1,31 @@
import ngModule from '../../module';
export default class Controller {
constructor($element, $, $rootScope) {
Object.assign(this, {
$element,
$,
$rootScope,
});
}
onUploadResponse() {
const timestamp = Date.vnNew().getTime();
const src = this.$rootScope.imagePath('user', '520x520', this.userId);
const zoomSrc = this.$rootScope.imagePath('user', '1600x1600', this.userId);
const newSrc = `${src}&t=${timestamp}`;
const newZoomSrc = `${zoomSrc}&t=${timestamp}`;
this.$.photo.setAttribute('src', newSrc);
this.$.photo.setAttribute('zoom-image', newZoomSrc);
}
}
Controller.$inject = ['$element', '$scope', '$rootScope'];
ngModule.vnComponent('vnUserPhoto', {
template: require('./index.html'),
controller: Controller,
bindings: {
userId: '@?',
}
});

View File

@ -0,0 +1,6 @@
My account: Mi cuenta
Local warehouse: Almacén local
Local bank: Banco local
Local company: Empresa local
User warehouse: Almacén del usuario
User company: Empresa del usuario

View File

@ -187,5 +187,7 @@
"This ticket is not editable.": "This ticket is not editable.",
"The ticket doesn't exist.": "The ticket doesn't exist.",
"The sales do not exists": "The sales do not exists",
"Ticket without Route": "Ticket without route"
"Ticket without Route": "Ticket without route",
"Booking completed": "Booking complete",
"The ticket is in preparation": "The ticket [{{ticketId}}]({{{ticketUrl}}}) of the sales person {{salesPersonId}} is in preparation"
}

View File

@ -314,8 +314,10 @@
"This ticket is locked.": "Este ticket está bloqueado.",
"This ticket is not editable.": "Este ticket no es editable.",
"The ticket doesn't exist.": "No existe el ticket.",
"Social name should be uppercase": "La razón social debe ir en mayúscula",
"Social name should be uppercase": "La razón social debe ir en mayúscula",
"Street should be uppercase": "La dirección fiscal debe ir en mayúscula",
"The response is not a PDF": "La respuesta no es un PDF",
"Ticket without Route": "Ticket sin ruta"
"Ticket without Route": "Ticket sin ruta",
"Booking completed": "Reserva completada",
"The ticket is in preparation": "El ticket [{{ticketId}}]({{{ticketUrl}}}) del comercial {{salesPersonId}} está en preparación"
}

View File

@ -0,0 +1,4 @@
<slot-descriptor>
<vn-user-descriptor>
</vn-user-descriptor>
</slot-descriptor>

View File

@ -0,0 +1,9 @@
import ngModule from '../module';
import DescriptorPopover from 'salix/components/descriptor-popover';
class Controller extends DescriptorPopover {}
ngModule.vnComponent('vnAccountDescriptorPopover', {
slotTemplate: require('./index.html'),
controller: Controller
});

View File

@ -2,6 +2,9 @@
module="account"
description="$ctrl.user.nickname"
summary="$ctrl.$.summary">
<slot-before>
<vn-user-photo user-id="{{$ctrl.id}}"/>
</slot-before>
<slot-menu>
<vn-item
ng-click="deleteUser.show()"

View File

@ -24,6 +24,28 @@ class Controller extends Descriptor {
.then(res => this.hasAccount = res.data.exists);
}
loadData() {
const filter = {
where: {id: this.$params.id},
include: {
relation: 'role',
scope: {
fields: ['id', 'name']
}
}
};
return Promise.all([
this.$http.get(`VnUsers/preview`, {filter})
.then(res => {
const [user] = res.data;
this.user = user;
}),
this.$http.get(`Accounts/${this.$params.id}/exists`)
.then(res => this.hasAccount = res.data.exists)
]);
}
onDelete() {
return this.$http.delete(`VnUsers/${this.id}`)
.then(() => this.$state.go('account.index'))

View File

@ -9,6 +9,7 @@ import './acl';
import './summary';
import './card';
import './descriptor';
import './descriptor-popover';
import './search-panel';
import './create';
import './basic-data';

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,116 +1,2 @@
<vn-crud-model
vn-id="model"
url="ClaimDevelopments"
fields="['id', 'claimFk', 'claimReasonFk', 'claimResultFk', 'claimResponsibleFk', 'workerFk', 'claimRedeliveryFk']"
link="{claimFk: $ctrl.$params.id}"
filter="$ctrl.filter"
data="claimDevelopments"
auto-load="true">
</vn-crud-model>
<vn-crud-model
url="ClaimReasons"
data="claimReasons"
order="description"
auto-load="true">
</vn-crud-model>
<vn-crud-model
url="ClaimResults"
data="claimResults"
order="description"
auto-load="true">
</vn-crud-model>
<vn-crud-model
url="ClaimResponsibles"
data="claimResponsibles"
order="description"
auto-load="true">
</vn-crud-model>
<vn-crud-model
url="ClaimRedeliveries"
data="claimRedeliveries"
order="description"
auto-load="true">
</vn-crud-model>
<vn-watcher
vn-id="watcher"
data="claimDevelopments"
form="form">
</vn-watcher>
<vn-vertical class="vn-w-lg">
<vn-card class="vn-pa-lg">
<vn-vertical>
<form name="form">
<vn-horizontal ng-repeat="claimDevelopment in claimDevelopments">
<vn-autocomplete
vn-focus
label="Reason"
ng-model="claimDevelopment.claimReasonFk"
data="claimReasons"
fields="['id', 'description']"
show-field="description"
rule>
</vn-autocomplete>
<vn-autocomplete
label="Result"
ng-model="claimDevelopment.claimResultFk"
data="claimResults"
fields="['id', 'description']"
show-field="description"
rule>
</vn-autocomplete>
<vn-autocomplete
label="Responsible"
ng-model="claimDevelopment.claimResponsibleFk"
data="claimResponsibles"
fields="['id', 'description']"
show-field="description"
rule>
</vn-autocomplete>
<vn-worker-autocomplete
ng-model="claimDevelopment.workerFk"
show-field="nickname"
rule>
</vn-worker-autocomplete>
<vn-autocomplete
label="Redelivery"
ng-model="claimDevelopment.claimRedeliveryFk"
data="claimRedeliveries"
fields="['id', 'description']"
show-field="description"
rule>
</vn-autocomplete>
<vn-icon-button
vn-none
class="vn-my-md"
vn-tooltip="Remove sale"
icon="delete"
ng-click="model.remove($index)"
tabindex="-1">
</vn-icon-button>
</vn-horizontal>
</form>
<vn-one class="vn-pt-md">
<vn-icon-button
vn-bind="+"
vn-tooltip="Add sale"
icon="add_circle"
ng-click="model.insert()">
</vn-icon-button>
</vn-one>
</vn-vertical>
</vn-card>
<vn-button-bar>
<vn-submit
disabled="!watcher.dataChanged()"
ng-click="$ctrl.onSubmit()"
label="Save">
</vn-submit>
<!-- # #2680 Undo changes button bugs -->
<!-- <vn-button
class="cancel"
label="Undo changes"
disabled="!watcher.dataChanged()"
ng-click="watcher.loadOriginalData()">
</vn-button> -->
</vn-button-bar>
</vn-vertical>
<vn-card>
</vn-card>

View File

@ -1,17 +1,14 @@
import ngModule from '../module';
import Section from 'salix/components/section';
import './style.scss';
class Controller extends Section {
onSubmit() {
this.$.watcher.check();
this.$.model.save().then(() => {
this.$.watcher.notifySaved();
this.$.watcher.updateOriginalData();
constructor($element, $) {
super($element, $);
}
if (this.aclService.hasAny(['claimManager']))
this.$state.go('claim.card.action');
});
async $onInit() {
this.$state.go('claim.card.summary', {id: this.$params.id});
window.location.href = await this.vnApp.getUrl(`claim/${this.$params.id}/development`);
}
}

View File

@ -1,31 +0,0 @@
import './index.js';
import watcher from 'core/mocks/watcher';
import crudModel from 'core/mocks/crud-model';
describe('Claim', () => {
describe('Component vnClaimDevelopment', () => {
let controller;
let $scope;
beforeEach(ngModule('claim'));
beforeEach(inject(($componentController, $rootScope) => {
$scope = $rootScope.$new();
$scope.watcher = watcher;
$scope.model = crudModel;
const $element = angular.element('<vn-claim-development></vn-claim-development>');
controller = $componentController('vnClaimDevelopment', {$element, $scope});
}));
describe('onSubmit()', () => {
it(`should redirect to 'claim.card.action' state`, () => {
jest.spyOn(controller.aclService, 'hasAny').mockReturnValue(true);
jest.spyOn(controller.$state, 'go');
controller.onSubmit();
expect(controller.$state.go).toHaveBeenCalledWith('claim.card.action');
});
});
});
});

View File

@ -1,8 +0,0 @@
Destination: Destino
Development: Trazabilidad
Reason: Motivo
Result: Consecuencia
Responsible: Responsable
Worker: Trabajador
Redelivery: Devolución
Add line: Añadir Linea

View File

@ -1,5 +1,5 @@
module.exports = Self => {
Self.remoteMethodCtx('clientCreditEmail', {
Self.remoteMethodCtx('creditRequestEmail', {
description: 'Sends the credit request email with an attached PDF',
accessType: 'WRITE',
accepts: [
@ -40,5 +40,5 @@ module.exports = Self => {
},
});
Self.clientCreditEmail = ctx => Self.sendTemplate(ctx, 'credit-request');
Self.creditRequestEmail = ctx => Self.sendTemplate(ctx, 'credit-request');
};

View File

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

View File

@ -9,7 +9,7 @@ module.exports = function(Self) {
let token = ctx.options.accessToken;
let userId = token && token.userId;
Self.app.models.Worker.findOne({where: {userFk: userId}}, (err, user) => {
Self.app.models.Worker.findOne({where: {id: userId}}, (err, user) => {
if (err) return next(err);
ctx.instance.workerFk = user.id;
next();

View File

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

View File

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

View File

@ -24,8 +24,8 @@
<vn-tr ng-repeat="credit in credits track by credit.id">
<vn-td shrink-datetime>{{::credit.created | date:'dd/MM/yyyy HH:mm'}}</vn-td>
<vn-td>
<span
ng-click="workerDescriptor.show($event, credit.worker.userFk)"
<span
ng-click="workerDescriptor.show($event, credit.worker.id)"
class="link">
{{::credit.worker.user.name}}
</span>
@ -41,10 +41,10 @@
ui-sref="client.card.credit.create"
vn-acl="teamBoss"
vn-acl-action="remove"
vn-tooltip="New credit"
vn-tooltip="New credit"
vn-bind="+"
fixed-bottom-right>
</vn-float-button>
<vn-worker-descriptor-popover
<vn-worker-descriptor-popover
vn-id="workerDescriptor">
</vn-worker-descriptor-popover>
</vn-worker-descriptor-popover>

View File

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

View File

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

View File

@ -18,6 +18,13 @@
"isLabeler": {
"type": "boolean"
}
},
"relations": {
"sector": {
"type": "belongsTo",
"model": "Sector",
"foreignKey": "sectorFk"
}
},
"acls": [{
"accessType": "READ",

View File

@ -0,0 +1,28 @@
module.exports = Self => {
Self.remoteMethodCtx('itemShelvingSaleByCollection', {
description: 'Insert sales of the collection in itemShelvingSale',
accessType: 'WRITE',
accepts: [
{
arg: 'id',
type: 'number',
description: 'The collection id',
required: true,
http: {source: 'path'}
}
],
http: {
path: `/:id/itemShelvingSaleByCollection`,
verb: 'POST'
}
});
Self.itemShelvingSaleByCollection = async(ctx, id, options) => {
const myOptions = {userId: ctx.req.accessToken.userId};
if (typeof options == 'object')
Object.assign(myOptions, options);
await Self.rawSql(`CALL vn.itemShelvingSale_addByCollection(?)`, [id], myOptions);
};
};

View File

@ -0,0 +1,41 @@
module.exports = Self => {
Self.remoteMethodCtx('itemShelvingSaleSetQuantity', {
description: 'Set quanitity of a sale in itemShelvingSale',
accessType: 'WRITE',
accepts: [
{
arg: 'id',
type: 'number',
required: true,
description: 'The sale id',
},
{
arg: 'quantity',
type: 'number',
required: true,
description: 'The quantity to set',
},
{
arg: 'isItemShelvingSaleEmpty',
type: 'boolean',
required: true,
description: 'True if the shelvingFk is empty ',
}
],
http: {
path: `/itemShelvingSaleSetQuantity`,
verb: 'POST'
}
});
Self.itemShelvingSaleSetQuantity = async(ctx, id, quantity, isItemShelvingSaleEmpty, options) => {
const myOptions = {userId: ctx.req.accessToken.userId};
if (typeof options == 'object')
Object.assign(myOptions, options);
await Self.rawSql(`CALL vn.itemShelvingSale_setQuantity(?, ?, ? )`,
[id, quantity, isItemShelvingSaleEmpty],
myOptions);
};
};

View File

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

View File

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

View File

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

View File

@ -32,6 +32,6 @@ module.exports = Self => {
Self.setVisibleDiscard = async(ctx, itemFk, warehouseFk, quantity, addressFk) => {
const query = `CALL vn.item_setVisibleDiscard(?, ?, ?, ?)`;
await Self.rawSql(query, [itemFk, warehouseFk, quantity, addressFk]);
await Self.rawSql(query, [itemFk, warehouseFk, quantity, addressFk], {userId: ctx.req.accessToken.userId});
};
};

View File

@ -26,11 +26,17 @@
"shelving": {
"type": "string"
},
"subName": {
"type": "string"
},
"packing": {
"type": "number"
},
"stock": {
"type": "number"
},
"size": {
"type": "number"
}
}
}

View File

@ -1,3 +1,5 @@
module.exports = Self => {
require('../methods/item-shelving-sale/filter')(Self);
require('../methods/item-shelving-sale/itemShelvingSaleByCollection')(Self);
require('../methods/item-shelving-sale/itemShelvingSaleSetQuantity')(Self);
};

View File

@ -20,10 +20,16 @@
},
"created": {
"type": "date"
},
"grouping": {
"type": "number"
},
"isChecked": {
"type": "boolean"
},
"packing": {
"type": "number"
},
"visible": {
"type": "number"
},

View File

@ -1,6 +1,6 @@
<vn-crud-model
auto-load="true"
url="Warehouses"
auto-load="true"
url="Warehouses"
data="warehouses">
</vn-crud-model>
<vn-descriptor-content
@ -58,7 +58,7 @@
<vn-label-value
label="Buyer">
<span
ng-click="workerDescriptor.show($event, $ctrl.item.itemType.worker.userFk)"
ng-click="workerDescriptor.show($event, $ctrl.item.itemType.worker.id)"
class="link">
{{$ctrl.item.itemType.worker.user.name}}
</span>

View File

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

View File

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

View File

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

View File

@ -111,7 +111,7 @@ module.exports = Self => {
let stmt;
stmt = new ParameterizedSQL(
`SELECT
`SELECT
r.id,
r.workerFk,
r.created,
@ -134,7 +134,7 @@ module.exports = Self => {
LEFT JOIN agencyMode am ON am.id = r.agencyModeFk
LEFT JOIN vehicle v ON v.id = r.vehicleFk
LEFT JOIN worker w ON w.id = r.workerFk
LEFT JOIN account.user u ON u.id = w.userFk`
LEFT JOIN account.user u ON u.id = w.id`
);
stmt.merge(conn.makeSuffix(filter));

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -10,5 +10,8 @@
},
"Sector": {
"dataSource": "vn"
},
"Train": {
"dataSource": "vn"
}
}

View File

@ -9,12 +9,11 @@
"properties": {
"id": {
"type": "number",
"id": true,
"description": "Identifier"
"description": "Identifier",
"id": true
},
"code": {
"type": "string",
"required": true
"type": "string"
},
"parkingFk": {
"type": "number"
@ -41,7 +40,7 @@
"worker": {
"type": "belongsTo",
"model": "Worker",
"foreignKey": "userFk"
"foreignKey": "id"
}
}
}

View File

@ -0,0 +1,19 @@
{
"name": "Train",
"options": {
"mysql": {
"table": "train"
}
},
"properties": {
"id": {
"type": "number",
"id": true
},
"name": {
"type": "string",
"required": true
}
}
}

View File

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

View File

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

View File

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

View File

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

View File

@ -39,7 +39,7 @@ module.exports = Self => {
try {
const userId = ctx.req.accessToken.userId;
const worker = await Self.app.models.Worker.findOne({where: {userFk: userId}}, myOptions);
const worker = await Self.app.models.Worker.findOne({where: {id: userId}}, myOptions);
const params = {
isOk: false,

View File

@ -153,9 +153,9 @@ module.exports = Self => {
LEFT JOIN item i ON i.id = tr.itemFk
LEFT JOIN sale s ON s.id = tr.saleFk
LEFT JOIN worker wk ON wk.id = c.salesPersonFk
LEFT JOIN account.user u ON u.id = wk.userFk
LEFT JOIN account.user u ON u.id = wk.id
LEFT JOIN worker wka ON wka.id = tr.attenderFk
LEFT JOIN account.user ua ON ua.id = wka.userFk`);
LEFT JOIN account.user ua ON ua.id = wka.id`);
stmt.merge(conn.makeSuffix(filter));
return conn.executeStmt(stmt, myOptions);

View File

@ -14,7 +14,7 @@ describe('ticket-request filter()', () => {
const result = await models.TicketRequest.filter(ctx, options);
expect(result.length).toEqual(3);
expect(result.length).toEqual(5);
await tx.rollback();
} catch (e) {
@ -93,7 +93,7 @@ describe('ticket-request filter()', () => {
const result = await models.TicketRequest.filter(ctx, options);
const requestId = result[0].id;
expect(requestId).toEqual(3);
expect(requestId).toEqual(1);
await tx.rollback();
} catch (e) {
@ -113,7 +113,7 @@ describe('ticket-request filter()', () => {
const result = await models.TicketRequest.filter(ctx, options);
const requestId = result[0].id;
expect(requestId).toEqual(3);
expect(requestId).toEqual(1);
await tx.rollback();
} catch (e) {
@ -153,7 +153,7 @@ describe('ticket-request filter()', () => {
const result = await models.TicketRequest.filter(ctx, {order: 'id'}, options);
const requestId = result[0].id;
expect(requestId).toEqual(3);
expect(requestId).toEqual(1);
await tx.rollback();
} catch (e) {
@ -173,7 +173,7 @@ describe('ticket-request filter()', () => {
const result = await models.TicketRequest.filter(ctx, options);
const requestId = result[0].id;
expect(requestId).toEqual(3);
expect(requestId).toEqual(1);
await tx.rollback();
} catch (e) {

View File

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

View File

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

View File

@ -16,8 +16,8 @@ describe('ticket-weekly filter()', () => {
const firstRow = result[0];
expect(firstRow.ticketFk).toEqual(1);
expect(result.length).toEqual(6);
expect(firstRow.ticketFk).toEqual(2);
expect(result.length).toEqual(4);
await tx.rollback();
} catch (e) {
@ -52,12 +52,12 @@ describe('ticket-weekly filter()', () => {
try {
const options = {transaction: tx};
const ctx = {req: {accessToken: {userId: authUserId}}, args: {search: 'bruce'}};
const ctx = {req: {accessToken: {userId: authUserId}}, args: {search: 'max'}};
const result = await models.TicketWeekly.filter(ctx, null, options);
const firstRow = result[0];
expect(firstRow.clientName).toEqual('Bruce Wayne');
expect(firstRow.clientName).toEqual('Max Eisenhardt');
await tx.rollback();
} catch (e) {
@ -72,13 +72,13 @@ describe('ticket-weekly filter()', () => {
try {
const options = {transaction: tx};
const ctx = {req: {accessToken: {userId: authUserId}}, args: {search: 1101}};
const ctx = {req: {accessToken: {userId: authUserId}}, args: {search: 1105}};
const result = await models.TicketWeekly.filter(ctx, null, options);
const firstRow = result[0];
expect(firstRow.clientFk).toEqual(1101);
expect(firstRow.clientName).toEqual('Bruce Wayne');
expect(firstRow.clientFk).toEqual(1105);
expect(firstRow.clientName).toEqual('Max Eisenhardt');
await tx.rollback();
} catch (e) {

View File

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

View File

@ -40,7 +40,7 @@ module.exports = Self => {
if (!isEditable && !isRoleAdvanced)
throw new ForbiddenError(`This ticket is not editable.`);
if (isLocked)
if (isLocked && !isWeekly)
throw new ForbiddenError(`This ticket is locked.`);
if (isWeekly && !canEditWeeklyTicket)

Some files were not shown because too many files have changed in this diff Show More