Merge branch 'dev' into 7272_bug_redirectToLogin
This commit is contained in:
commit
f0f38c199c
|
@ -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 ;
|
|
@ -30,10 +30,9 @@ BEGIN
|
|||
-- Si hay colecciones sin terminar, sale del proceso
|
||||
CALL collection_get(vUserFk);
|
||||
|
||||
SELECT (pc.maxNotReadyCollections - COUNT(*)) <= 0
|
||||
INTO vHasTooMuchCollections
|
||||
FROM tCollection
|
||||
JOIN productionConfig pc;
|
||||
SELECT (pc.maxNotReadyCollections - COUNT(*)) <= 0 INTO vHasTooMuchCollections
|
||||
FROM productionConfig pc
|
||||
LEFT JOIN tCollection ON TRUE;
|
||||
|
||||
DROP TEMPORARY TABLE tCollection;
|
||||
|
||||
|
@ -47,7 +46,7 @@ BEGIN
|
|||
WHERE workerFk = vUserFk;
|
||||
|
||||
SET vLockName = CONCAT_WS('/',
|
||||
'collection_assign',
|
||||
vLockName,
|
||||
vWarehouseFk,
|
||||
vItemPackingTypeFk
|
||||
);
|
||||
|
|
|
@ -63,7 +63,8 @@ BEGIN
|
|||
o.numberOfWagons,
|
||||
o.trainFk,
|
||||
o.linesLimit,
|
||||
o.volumeLimit
|
||||
o.volumeLimit,
|
||||
pc.collection_new_lockname
|
||||
INTO vMaxTickets,
|
||||
vHasUniqueCollectionTime,
|
||||
vWorkerCode,
|
||||
|
@ -73,14 +74,15 @@ BEGIN
|
|||
vWagons,
|
||||
vTrainFk,
|
||||
vLinesLimit,
|
||||
vVolumeLimit
|
||||
vVolumeLimit,
|
||||
vLockName
|
||||
FROM productionConfig pc
|
||||
JOIN worker w ON w.id = vUserFk
|
||||
JOIN state st ON st.`code` = 'ON_PREPARATION'
|
||||
JOIN operator o ON o.workerFk = vUserFk;
|
||||
|
||||
SET vLockName = CONCAT_WS('/',
|
||||
'collection_new',
|
||||
vLockName,
|
||||
vWarehouseFk,
|
||||
vItemPackingTypeFk
|
||||
);
|
||||
|
|
|
@ -79,6 +79,10 @@ BEGIN
|
|||
ORDER BY (vQuantity % `grouping`) ASC
|
||||
LIMIT 1;
|
||||
|
||||
IF vNewPrice IS NULL THEN
|
||||
CALL util.throw('price retrieval failed');
|
||||
END IF;
|
||||
|
||||
IF vNewPrice > vOldPrice THEN
|
||||
SET vFinalPrice = vOldPrice;
|
||||
SET vOption = 'substitution';
|
||||
|
@ -90,7 +94,8 @@ BEGIN
|
|||
START TRANSACTION;
|
||||
|
||||
UPDATE sale
|
||||
SET quantity = quantity - vQuantity
|
||||
SET originalQuantity = quantity - vQuantity,
|
||||
quantity = quantity - vQuantity
|
||||
WHERE id = vSaleFk;
|
||||
|
||||
INSERT INTO vn.sale(ticketFk,
|
||||
|
@ -100,7 +105,8 @@ BEGIN
|
|||
price)
|
||||
SELECT vTicketFk,
|
||||
vNewItemFk,
|
||||
CEIL(vQuantity / vRoundQuantity) * vRoundQuantity, CONCAT('+ ', i.name),
|
||||
CEIL(vQuantity / vRoundQuantity) * vRoundQuantity,
|
||||
CONCAT('+ ', i.name),
|
||||
vFinalPrice
|
||||
FROM vn.item i
|
||||
WHERE id = vNewItemFk;
|
||||
|
|
|
@ -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 ;
|
|
@ -63,7 +63,7 @@ BEGIN
|
|||
INSERT INTO ticketPackaging (ticketFk, packagingFk, quantity)
|
||||
(SELECT vCurTicketFk, p.id, COUNT(*)
|
||||
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
|
||||
AND vWithPackage
|
||||
GROUP BY p.itemFk);
|
||||
|
|
|
@ -4,7 +4,5 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticketPackaging_befor
|
|||
FOR EACH ROW
|
||||
BEGIN
|
||||
SET NEW.editorFk = account.myUser_getId();
|
||||
SET NEW.workerFk = account.myUser_getId();
|
||||
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -14,7 +14,7 @@ BEGIN
|
|||
END IF;
|
||||
|
||||
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$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -12,9 +12,5 @@ BEGIN
|
|||
IF NEW.salesPersonCode <> OLD.salesPersonCode THEN
|
||||
SET NEW.requesterFk = (SELECT w.id FROM worker w WHERE w.code = NEW.salesPersonCode);
|
||||
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$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -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);
|
|
@ -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';
|
|
@ -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';
|
|
@ -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';
|
|
@ -223,7 +223,7 @@
|
|||
"printerNotExists": "The printer does not exist",
|
||||
"There are not picking tickets": "There are not picking tickets",
|
||||
"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",
|
||||
"They're not your subordinate": "They're not your subordinate",
|
||||
"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",
|
||||
"InvoiceIn is already booked": "InvoiceIn is already booked"
|
||||
}
|
|
@ -49,8 +49,7 @@ module.exports = Self => {
|
|||
JOIN vn.agencyMode am ON am.id = r.agencyModeFk
|
||||
JOIN vn.agency ag ON ag.id = am.agencyFk
|
||||
LEFT JOIN vn.userConfig uc ON uc.userFk = account.myUser_getId()
|
||||
WHERE (r.created = util.VN_CURDATE() OR r.created = util.yesterday())
|
||||
AND t.routeFk = ?
|
||||
WHERE t.routeFk = ?
|
||||
GROUP BY t.addressFk, e.itemPackingTypeFk
|
||||
) sub
|
||||
GROUP BY addressFk
|
||||
|
|
|
@ -92,9 +92,7 @@ describe('ticket-request confirm()', () => {
|
|||
const request = await models.TicketRequest.findById(requestId, null, options);
|
||||
|
||||
expect(request.saleFk).toBeNull();
|
||||
|
||||
await request.updateAttributes({saleFk: 2}, options);
|
||||
|
||||
await request.updateAttributes({saleFk: 2});
|
||||
ctx.args = {
|
||||
itemFk: itemId,
|
||||
id: requestId,
|
||||
|
@ -102,7 +100,6 @@ describe('ticket-request confirm()', () => {
|
|||
};
|
||||
|
||||
await models.TicketRequest.confirm(ctx, options);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
|
|
|
@ -30,7 +30,7 @@ module.exports = Self => {
|
|||
});
|
||||
|
||||
Self.addSaleByCode = async(ctx, barcode, quantity, ticketFk, warehouseFk, options) => {
|
||||
const myOptions = {};
|
||||
const myOptions = {userId: ctx.req.accessToken.userId};
|
||||
let tx;
|
||||
|
||||
if (typeof options == 'object')
|
||||
|
|
|
@ -23,6 +23,16 @@
|
|||
},
|
||||
"daysForWarningClaim": {
|
||||
"type": "number"
|
||||
},
|
||||
"defaultAttenderFk": {
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"attender": {
|
||||
"type": "belongsTo",
|
||||
"model": "Worker",
|
||||
"foreignKey": "defaultAttenderFk"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,21 +8,21 @@ module.exports = function(Self) {
|
|||
require('../methods/ticket-request/getItemTypeWorker')(Self);
|
||||
|
||||
Self.observe('before save', async function(ctx) {
|
||||
if (ctx.isNewInstance) {
|
||||
const loopBackContext = LoopBackContext.getCurrentContext();
|
||||
const filter = {where: {id: loopBackContext.active.accessToken.userId}};
|
||||
const models = Self.app.models;
|
||||
const worker = await models.Worker.findOne(filter);
|
||||
const loopBackContext = LoopBackContext.getCurrentContext();
|
||||
const filter = {where: {id: loopBackContext.active.accessToken.userId}};
|
||||
const models = Self.app.models;
|
||||
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;
|
||||
|
||||
const httpCtx = {req: loopBackContext.active};
|
||||
const httpRequest = httpCtx.req.http .req;
|
||||
const $t = httpRequest.__;
|
||||
|
||||
const attenderId = instance.attenderFk;
|
||||
if (attenderId) {
|
||||
if (attenderFk) {
|
||||
const ticket = await models.Ticket.findById(instance.ticketFk);
|
||||
let messageText = 'New ticket request has been created';
|
||||
if (instance.price)
|
||||
|
@ -35,8 +35,20 @@ module.exports = function(Self) {
|
|||
quantity: instance.quantity,
|
||||
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});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue