Merge branch 'dev' into 7272_bug_redirectToLogin
gitea/salix/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
Javier Segarra 2024-05-02 07:41:25 +00:00
commit bc4c671587
19 changed files with 96 additions and 55 deletions

View File

@ -0,0 +1,13 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`connection_kill`(
vConnectionId BIGINT
)
BEGIN
/**
* Kill a connection
*
* @param vConnectionId
*/
KILL vConnectionId;
END$$
DELIMITER ;

View File

@ -30,10 +30,9 @@ BEGIN
-- Si hay colecciones sin terminar, sale del proceso -- Si hay colecciones sin terminar, sale del proceso
CALL collection_get(vUserFk); CALL collection_get(vUserFk);
SELECT (pc.maxNotReadyCollections - COUNT(*)) <= 0 SELECT (pc.maxNotReadyCollections - COUNT(*)) <= 0 INTO vHasTooMuchCollections
INTO vHasTooMuchCollections FROM productionConfig pc
FROM tCollection LEFT JOIN tCollection ON TRUE;
JOIN productionConfig pc;
DROP TEMPORARY TABLE tCollection; DROP TEMPORARY TABLE tCollection;
@ -47,7 +46,7 @@ BEGIN
WHERE workerFk = vUserFk; WHERE workerFk = vUserFk;
SET vLockName = CONCAT_WS('/', SET vLockName = CONCAT_WS('/',
'collection_assign', vLockName,
vWarehouseFk, vWarehouseFk,
vItemPackingTypeFk vItemPackingTypeFk
); );

View File

@ -63,7 +63,8 @@ BEGIN
o.numberOfWagons, o.numberOfWagons,
o.trainFk, o.trainFk,
o.linesLimit, o.linesLimit,
o.volumeLimit o.volumeLimit,
pc.collection_new_lockname
INTO vMaxTickets, INTO vMaxTickets,
vHasUniqueCollectionTime, vHasUniqueCollectionTime,
vWorkerCode, vWorkerCode,
@ -73,14 +74,15 @@ BEGIN
vWagons, vWagons,
vTrainFk, vTrainFk,
vLinesLimit, vLinesLimit,
vVolumeLimit vVolumeLimit,
vLockName
FROM productionConfig pc FROM productionConfig pc
JOIN worker w ON w.id = vUserFk JOIN worker w ON w.id = vUserFk
JOIN state st ON st.`code` = 'ON_PREPARATION' JOIN state st ON st.`code` = 'ON_PREPARATION'
JOIN operator o ON o.workerFk = vUserFk; JOIN operator o ON o.workerFk = vUserFk;
SET vLockName = CONCAT_WS('/', SET vLockName = CONCAT_WS('/',
'collection_new', vLockName,
vWarehouseFk, vWarehouseFk,
vItemPackingTypeFk vItemPackingTypeFk
); );

View File

@ -79,6 +79,10 @@ BEGIN
ORDER BY (vQuantity % `grouping`) ASC ORDER BY (vQuantity % `grouping`) ASC
LIMIT 1; LIMIT 1;
IF vNewPrice IS NULL THEN
CALL util.throw('price retrieval failed');
END IF;
IF vNewPrice > vOldPrice THEN IF vNewPrice > vOldPrice THEN
SET vFinalPrice = vOldPrice; SET vFinalPrice = vOldPrice;
SET vOption = 'substitution'; SET vOption = 'substitution';
@ -90,7 +94,8 @@ BEGIN
START TRANSACTION; START TRANSACTION;
UPDATE sale UPDATE sale
SET quantity = quantity - vQuantity SET originalQuantity = quantity - vQuantity,
quantity = quantity - vQuantity
WHERE id = vSaleFk; WHERE id = vSaleFk;
INSERT INTO vn.sale(ticketFk, INSERT INTO vn.sale(ticketFk,
@ -100,7 +105,8 @@ BEGIN
price) price)
SELECT vTicketFk, SELECT vTicketFk,
vNewItemFk, vNewItemFk,
CEIL(vQuantity / vRoundQuantity) * vRoundQuantity, CONCAT('+ ', i.name), CEIL(vQuantity / vRoundQuantity) * vRoundQuantity,
CONCAT('+ ', i.name),
vFinalPrice vFinalPrice
FROM vn.item i FROM vn.item i
WHERE id = vNewItemFk; WHERE id = vNewItemFk;

View File

@ -1,19 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticketRequest_Add`(vDescription VARCHAR(255), vQuantity INT, vPrice DOUBLE, vTicketFk INT, vBuyerCode VARCHAR(3))
BEGIN
INSERT INTO vn.ticketRequest(description,
quantity,
price,
ticketFk,
buyerCode,
requesterFk)
VALUES(vDescription,
vQuantity,
vPrice,
vTicketFk,
vBuyerCode,
vn.getUser());
END$$
DELIMITER ;

View File

@ -63,7 +63,7 @@ BEGIN
INSERT INTO ticketPackaging (ticketFk, packagingFk, quantity) INSERT INTO ticketPackaging (ticketFk, packagingFk, quantity)
(SELECT vCurTicketFk, p.id, COUNT(*) (SELECT vCurTicketFk, p.id, COUNT(*)
FROM expedition e FROM expedition e
JOIN packaging p ON p.itemFk = e.freightItemFk JOIN packaging p ON p.id = e.packagingFk
WHERE e.ticketFk = vCurTicketFk AND p.isPackageReturnable WHERE e.ticketFk = vCurTicketFk AND p.isPackageReturnable
AND vWithPackage AND vWithPackage
GROUP BY p.itemFk); GROUP BY p.itemFk);

View File

@ -4,7 +4,5 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticketPackaging_befor
FOR EACH ROW FOR EACH ROW
BEGIN BEGIN
SET NEW.editorFk = account.myUser_getId(); SET NEW.editorFk = account.myUser_getId();
SET NEW.workerFk = account.myUser_getId();
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -14,7 +14,7 @@ BEGIN
END IF; END IF;
IF NEW.attenderFk IS NULL THEN IF NEW.attenderFk IS NULL THEN
SET NEW.attenderFk = (SELECT w.id FROM worker w WHERE w.code = NEW.buyerCode); SET NEW.attenderFk = (SELECT defaultAttenderFk FROM ticketConfig LIMIT 1);
END IF; END IF;
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -12,9 +12,5 @@ BEGIN
IF NEW.salesPersonCode <> OLD.salesPersonCode THEN IF NEW.salesPersonCode <> OLD.salesPersonCode THEN
SET NEW.requesterFk = (SELECT w.id FROM worker w WHERE w.code = NEW.salesPersonCode); SET NEW.requesterFk = (SELECT w.id FROM worker w WHERE w.code = NEW.salesPersonCode);
END IF; END IF;
IF NEW.buyerCode <> OLD.buyerCode THEN
SET NEW.attenderFk = (SELECT w.id FROM worker w WHERE w.code = NEW.buyerCode);
END IF;
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -0,0 +1,7 @@
-- Place your SQL code here
ALTER TABLE `vn`.`ticketRequest`
CHANGE IF EXISTS `buyerCode` `buyerCode__` varchar(3) NOT NULL COMMENT '@deprecated 2024-04-23 refs #6731 field not used';
ALTER TABLE `vn`.`ticketConfig` ADD COLUMN IF NOT EXISTS `defaultAttenderFk` int unsigned;
ALTER TABLE vn.ticketConfig ADD CONSTRAINT ticketConfig_worker_FK FOREIGN KEY (defaultAttenderFk) REFERENCES vn.worker(id);

View File

@ -0,0 +1,5 @@
-- Place your SQL code here
ALTER TABLE vn.productionConfig ADD collectionNewLockname varchar(100)
DEFAULT 'collection_new' NOT NULL COMMENT 'Lockname value for proc vn.collection_new';
ALTER TABLE vn.productionConfig ADD collectionAssignLockname varchar(100)
DEFAULT 'collection_assign' NULL COMMENT 'Lockname value for proc vn.collection_new';

View File

@ -0,0 +1,3 @@
-- Place your SQL code here
ALTER TABLE vn.productionConfig ADD collection_new_lockname varchar(100) DEFAULT 'collection_new' NOT NULL COMMENT 'Lockname value for proc vn.collection_new';
ALTER TABLE vn.productionConfig ADD collection_assign_lockname varchar(100) DEFAULT 'collection_assign' NULL COMMENT 'Lockname value for proc vn.collection_new';

View File

@ -0,0 +1,13 @@
ALTER TABLE vn.productionConfig
DROP COLUMN IF EXISTS collectionNewLockname,
DROP COLUMN IF EXISTS collectionAssignLockname;
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`connection_kill`()
BEGIN
END$$
DELIMITER ;
GRANT EXECUTE ON PROCEDURE util.connection_kill TO 'developer';

View File

@ -223,7 +223,7 @@
"printerNotExists": "The printer does not exist", "printerNotExists": "The printer does not exist",
"There are not picking tickets": "There are not picking tickets", "There are not picking tickets": "There are not picking tickets",
"ticketCommercial": "The ticket {{ ticket }} for the salesperson {{ salesMan }} is in preparation. (automatically generated message)", "ticketCommercial": "The ticket {{ ticket }} for the salesperson {{ salesMan }} is in preparation. (automatically generated message)",
"This password can only be changed by the user themselves": "This password can only be changed by the user themselves", "This password can only be changed by the user themselves": "This password can only be changed by the user themselves",
"They're not your subordinate": "They're not your subordinate", "They're not your subordinate": "They're not your subordinate",
"InvoiceIn is already booked": "InvoiceIn is already booked" "InvoiceIn is already booked": "InvoiceIn is already booked"
} }

View File

@ -49,8 +49,7 @@ module.exports = Self => {
JOIN vn.agencyMode am ON am.id = r.agencyModeFk JOIN vn.agencyMode am ON am.id = r.agencyModeFk
JOIN vn.agency ag ON ag.id = am.agencyFk JOIN vn.agency ag ON ag.id = am.agencyFk
LEFT JOIN vn.userConfig uc ON uc.userFk = account.myUser_getId() LEFT JOIN vn.userConfig uc ON uc.userFk = account.myUser_getId()
WHERE (r.created = util.VN_CURDATE() OR r.created = util.yesterday()) WHERE t.routeFk = ?
AND t.routeFk = ?
GROUP BY t.addressFk, e.itemPackingTypeFk GROUP BY t.addressFk, e.itemPackingTypeFk
) sub ) sub
GROUP BY addressFk GROUP BY addressFk

View File

@ -92,9 +92,7 @@ describe('ticket-request confirm()', () => {
const request = await models.TicketRequest.findById(requestId, null, options); const request = await models.TicketRequest.findById(requestId, null, options);
expect(request.saleFk).toBeNull(); expect(request.saleFk).toBeNull();
await request.updateAttributes({saleFk: 2});
await request.updateAttributes({saleFk: 2}, options);
ctx.args = { ctx.args = {
itemFk: itemId, itemFk: itemId,
id: requestId, id: requestId,
@ -102,7 +100,6 @@ describe('ticket-request confirm()', () => {
}; };
await models.TicketRequest.confirm(ctx, options); await models.TicketRequest.confirm(ctx, options);
await tx.rollback(); await tx.rollback();
} catch (e) { } catch (e) {
await tx.rollback(); await tx.rollback();

View File

@ -30,7 +30,7 @@ module.exports = Self => {
}); });
Self.addSaleByCode = async(ctx, barcode, quantity, ticketFk, warehouseFk, options) => { Self.addSaleByCode = async(ctx, barcode, quantity, ticketFk, warehouseFk, options) => {
const myOptions = {}; const myOptions = {userId: ctx.req.accessToken.userId};
let tx; let tx;
if (typeof options == 'object') if (typeof options == 'object')

View File

@ -23,6 +23,16 @@
}, },
"daysForWarningClaim": { "daysForWarningClaim": {
"type": "number" "type": "number"
},
"defaultAttenderFk": {
"type": "number"
}
},
"relations": {
"attender": {
"type": "belongsTo",
"model": "Worker",
"foreignKey": "defaultAttenderFk"
} }
} }
} }

View File

@ -8,21 +8,21 @@ module.exports = function(Self) {
require('../methods/ticket-request/getItemTypeWorker')(Self); require('../methods/ticket-request/getItemTypeWorker')(Self);
Self.observe('before save', async function(ctx) { Self.observe('before save', async function(ctx) {
if (ctx.isNewInstance) { const loopBackContext = LoopBackContext.getCurrentContext();
const loopBackContext = LoopBackContext.getCurrentContext(); const filter = {where: {id: loopBackContext.active.accessToken.userId}};
const filter = {where: {id: loopBackContext.active.accessToken.userId}}; const models = Self.app.models;
const models = Self.app.models; const worker = await models.Worker.findOne(filter);
const worker = await models.Worker.findOne(filter); const instance = ctx.instance;
const attenderFk = instance?.attenderFk;
const instance = ctx.instance; if (ctx.isNewInstance) {
instance.requesterFk = worker.id; instance.requesterFk = worker.id;
const httpCtx = {req: loopBackContext.active}; const httpCtx = {req: loopBackContext.active};
const httpRequest = httpCtx.req.http .req; const httpRequest = httpCtx.req.http .req;
const $t = httpRequest.__; const $t = httpRequest.__;
const attenderId = instance.attenderFk; if (attenderFk) {
if (attenderId) {
const ticket = await models.Ticket.findById(instance.ticketFk); const ticket = await models.Ticket.findById(instance.ticketFk);
let messageText = 'New ticket request has been created'; let messageText = 'New ticket request has been created';
if (instance.price) if (instance.price)
@ -35,8 +35,20 @@ module.exports = function(Self) {
quantity: instance.quantity, quantity: instance.quantity,
price: instance.price price: instance.price
}); });
await models.Chat.sendCheckingPresence(httpCtx, attenderId, message); await models.Chat.sendCheckingPresence(httpCtx, attenderFk, message);
} else {
const {defaultAttenderFk} = await models.TicketConfig.findOne();
Object.assign(instance, {attenderFk: defaultAttenderFk});
} }
} }
}); });
Self.observe('after save', async function(ctx) {
const models = Self.app.models;
const instance = ctx.instance;
if (instance?.attenderFk === null && !ctx.isNewInstance) {
const {defaultAttenderFk} = await models.TicketConfig.findOne();
await models.TicketRequest.updateAll({id: instance.id}, {attenderFk: defaultAttenderFk});
}
});
}; };