Merge branch 'dev' of https: refs #7986//gitea.verdnatura.es/verdnatura/salix into 7986-workerMoto
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
This commit is contained in:
commit
68469e2ba8
|
@ -175,6 +175,9 @@
|
||||||
"PrintConfig": {
|
"PrintConfig": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
|
"QueueMember": {
|
||||||
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
"ViaexpressConfig": {
|
"ViaexpressConfig": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
{
|
||||||
|
"name": "QueueMember",
|
||||||
|
"base": "VnModel",
|
||||||
|
"options": {
|
||||||
|
"mysql": {
|
||||||
|
"table": "pbx.queueMember"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"properties": {
|
||||||
|
"id": {
|
||||||
|
"type": "number",
|
||||||
|
"id": true
|
||||||
|
},
|
||||||
|
"queue": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"extension": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"relations": {
|
||||||
|
"queueRelation": {
|
||||||
|
"type": "belongsTo",
|
||||||
|
"model": "Queue",
|
||||||
|
"foreignKey": "queue",
|
||||||
|
"primaryKey": "name"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"acls": [
|
||||||
|
{
|
||||||
|
"property": "*",
|
||||||
|
"accessType": "READ",
|
||||||
|
"principalType": "ROLE",
|
||||||
|
"principalId": "employee",
|
||||||
|
"permission": "ALLOW"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -3988,3 +3988,25 @@ VALUES
|
||||||
INSERT IGNORE INTO ormConfig
|
INSERT IGNORE INTO ormConfig
|
||||||
SET id =1,
|
SET id =1,
|
||||||
selectLimit = 1000;
|
selectLimit = 1000;
|
||||||
|
|
||||||
|
INSERT INTO pbx.queueMultiConfig
|
||||||
|
SET id = 'ring',
|
||||||
|
strategy = 20,
|
||||||
|
timeout = 2,
|
||||||
|
retry = 0,
|
||||||
|
weight = 0,
|
||||||
|
maxLen = 0,
|
||||||
|
ringInUse = 0;
|
||||||
|
|
||||||
|
INSERT INTO pbx.queue (description, name, config)
|
||||||
|
VALUES ('X-men', '1000', 1),
|
||||||
|
('Avengers', '2000', 1);
|
||||||
|
|
||||||
|
INSERT IGNORE INTO pbx.queueMember
|
||||||
|
SET queue = '1000',
|
||||||
|
extension = '1010';
|
||||||
|
|
||||||
|
UPDATE vn.department SET pbxQueue = '1000' WHERE name = "CAMARA";
|
||||||
|
UPDATE vn.department SET pbxQueue = '2000' WHERE name = "VENTAS";
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ BEGIN
|
||||||
LEFT JOIN observation ob ON ob.ticketFk = t.id
|
LEFT JOIN observation ob ON ob.ticketFk = t.id
|
||||||
WHERE t.id = vParamFk
|
WHERE t.id = vParamFk
|
||||||
AND t.shipped >= vYesterday
|
AND t.shipped >= vYesterday
|
||||||
UNION ALL
|
UNION
|
||||||
SELECT t.id ticketFk,
|
SELECT t.id ticketFk,
|
||||||
IF(NOT(vItemPackingTypeFk <=> 'V'), cc.code, CONCAT(SUBSTRING('ABCDEFGH', tc.wagon, 1), '-', tc.`level`)) `level`,
|
IF(NOT(vItemPackingTypeFk <=> 'V'), cc.code, CONCAT(SUBSTRING('ABCDEFGH', tc.wagon, 1), '-', tc.`level`)) `level`,
|
||||||
am.name agencyName,
|
am.name agencyName,
|
||||||
|
@ -66,7 +66,7 @@ BEGIN
|
||||||
LEFT JOIN vn.worker w ON w.id = c.salesPersonFk
|
LEFT JOIN vn.worker w ON w.id = c.salesPersonFk
|
||||||
LEFT JOIN observation ob ON ob.ticketFk = t.id
|
LEFT JOIN observation ob ON ob.ticketFk = t.id
|
||||||
WHERE tc.collectionFk = vParamFk
|
WHERE tc.collectionFk = vParamFk
|
||||||
UNION ALL
|
UNION
|
||||||
SELECT sg.ticketFk,
|
SELECT sg.ticketFk,
|
||||||
NULL `level`,
|
NULL `level`,
|
||||||
am.name agencyName,
|
am.name agencyName,
|
||||||
|
@ -83,6 +83,7 @@ BEGIN
|
||||||
LEFT JOIN observation ob ON ob.ticketFk = t.id
|
LEFT JOIN observation ob ON ob.ticketFk = t.id
|
||||||
LEFT JOIN vn.client c ON c.id = t.clientFk
|
LEFT JOIN vn.client c ON c.id = t.clientFk
|
||||||
WHERE sc.id = vParamFk
|
WHERE sc.id = vParamFk
|
||||||
AND t.shipped >= vYesterday;
|
AND t.shipped >= vYesterday
|
||||||
|
GROUP BY ticketFk;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelvingSale_deleteAdded`(
|
||||||
|
vSelf INT(11)
|
||||||
|
)
|
||||||
|
proc: BEGIN
|
||||||
|
/**
|
||||||
|
* Borra una reservea devolviendo la cantidad al itemShelving
|
||||||
|
*
|
||||||
|
* @param vSelf Identificador del itemShelvingSale
|
||||||
|
*/
|
||||||
|
DECLARE vSaleFk INT;
|
||||||
|
DECLARE vHasSalesPicked BOOL;
|
||||||
|
|
||||||
|
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
||||||
|
BEGIN
|
||||||
|
ROLLBACK;
|
||||||
|
RESIGNAL;
|
||||||
|
END;
|
||||||
|
|
||||||
|
START TRANSACTION;
|
||||||
|
|
||||||
|
SELECT iss.saleFk INTO vSaleFk
|
||||||
|
FROM itemShelvingSale iss
|
||||||
|
JOIN sale s ON s.id = iss.saleFk
|
||||||
|
WHERE iss.id = vSelf AND s.isAdded
|
||||||
|
FOR UPDATE;
|
||||||
|
|
||||||
|
IF vSaleFk IS NULL THEN
|
||||||
|
CALL util.throw('The sale can not be deleted');
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT COUNT(*) INTO vHasSalesPicked
|
||||||
|
FROM itemShelvingSale
|
||||||
|
WHERE saleFk = vSaleFk AND isPicked;
|
||||||
|
|
||||||
|
IF vHasSalesPicked THEN
|
||||||
|
CALL util.throw('A sale with picked sales cannot be deleted');
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
UPDATE itemShelvingSale iss
|
||||||
|
JOIN itemShelving ish ON ish.id = iss.itemShelvingFk
|
||||||
|
SET ish.available = ish.available + iss.quantity
|
||||||
|
WHERE iss.saleFk = vSaleFk;
|
||||||
|
|
||||||
|
DELETE FROM sale WHERE id = vSaleFk;
|
||||||
|
|
||||||
|
COMMIT;
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -0,0 +1,29 @@
|
||||||
|
DELIMITER $$
|
||||||
|
|
||||||
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`queueMember_updateQueue`(
|
||||||
|
vBusinessFk INT
|
||||||
|
)
|
||||||
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Elimina la entrada de la cola anterior y luego inserta la nueva para un trabajador.
|
||||||
|
*
|
||||||
|
* @param vBusinessFk ID del negocio
|
||||||
|
*/
|
||||||
|
DECLARE vNewQueue VARCHAR(10);
|
||||||
|
DECLARE vExtension VARCHAR(10);
|
||||||
|
DECLARE exit handler FOR SQLEXCEPTION
|
||||||
|
|
||||||
|
SELECT d.pbxQueue, s.extension
|
||||||
|
INTO vNewQueue, vExtension
|
||||||
|
FROM business b
|
||||||
|
JOIN department d ON d.id = b.departmentFk
|
||||||
|
JOIN pbx.sip s ON s.user_id = b.workerFk
|
||||||
|
WHERE b.id = vBusinessFk;
|
||||||
|
|
||||||
|
DELETE FROM pbx.queueMember
|
||||||
|
WHERE extension = vExtension COLLATE utf8_general_ci;
|
||||||
|
|
||||||
|
INSERT IGNORE INTO pbx.queueMember (queue, extension)
|
||||||
|
VALUES (vNewQueue, vExtension);
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -21,6 +21,8 @@ BEGIN
|
||||||
SET businessFk = vNewBusinessFk
|
SET businessFk = vNewBusinessFk
|
||||||
WHERE id = vSelf;
|
WHERE id = vSelf;
|
||||||
|
|
||||||
|
CALL queueMember_updateQueue(vNewBusinessFk);
|
||||||
|
|
||||||
IF vOldBusinessFk IS NULL THEN
|
IF vOldBusinessFk IS NULL THEN
|
||||||
CALL account.account_enable(vSelf);
|
CALL account.account_enable(vSelf);
|
||||||
|
|
||||||
|
|
|
@ -3,10 +3,20 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`business_afterUpdate`
|
||||||
AFTER UPDATE ON `business`
|
AFTER UPDATE ON `business`
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
BEGIN
|
BEGIN
|
||||||
|
DECLARE vIsActive BOOL;
|
||||||
|
DECLARE vExtension VARCHAR(10);
|
||||||
|
|
||||||
CALL worker_updateBusiness(NEW.workerFk);
|
CALL worker_updateBusiness(NEW.workerFk);
|
||||||
|
|
||||||
IF NOT (OLD.workerFk <=> NEW.workerFk) THEN
|
IF NOT (OLD.workerFk <=> NEW.workerFk) THEN
|
||||||
CALL worker_updateBusiness(OLD.workerFk);
|
CALL worker_updateBusiness(OLD.workerFk);
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
|
IF NOT (OLD.departmentFk <=> NEW.departmentFk) THEN
|
||||||
|
SELECT COUNT(*) INTO vIsActive FROM worker WHERE businessFk = NEW.id;
|
||||||
|
IF vIsActive THEN
|
||||||
|
CALL queueMember_updateQueue(NEW.id);
|
||||||
|
END IF;
|
||||||
|
END IF;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -10,7 +10,7 @@ BEGIN
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
IF NEW.shelvingFk <> OLD.shelvingFk THEN
|
IF NEW.shelvingFk <> OLD.shelvingFk THEN
|
||||||
SET NEW.isMoving = FALSE;
|
SET NEW.movingState = NULL;
|
||||||
END IF;
|
END IF;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
/*
|
||||||
|
UPDATE vn.sale
|
||||||
|
SET originalQuantity = quantity
|
||||||
|
WHERE originalQuantity IS NULL
|
||||||
|
*/
|
|
@ -0,0 +1 @@
|
||||||
|
-- ALTER TABLE vn.sale MODIFY COLUMN originalQuantity decimal(10,2) DEFAULT 0.00 NOT NULL COMMENT 'Se utiliza para notificar a través de rocket los cambios de quantity';
|
|
@ -0,0 +1,3 @@
|
||||||
|
-- Place your SQL code here
|
||||||
|
ALTER TABLE vn.itemShelving DROP COLUMN IF EXISTS isMoving;
|
||||||
|
ALTER TABLE vn.itemShelving ADD IF NOT EXISTS movingState ENUM('selected','printed') NULL;
|
|
@ -0,0 +1,3 @@
|
||||||
|
-- Place your SQL code here
|
||||||
|
ALTER TABLE hedera.`order` ADD IF NOT EXISTS rowUpdated DATETIME NULL
|
||||||
|
COMMENT 'Timestamp for last updated record in orderRow table';
|
|
@ -0,0 +1,3 @@
|
||||||
|
-- Place your SQL code here
|
||||||
|
ALTER TABLE vn.itemShelving DROP COLUMN IF EXISTS isMoving;
|
||||||
|
ALTER TABLE vn.itemShelving ADD IF NOT EXISTS movingState ENUM('selected','printed') NULL;
|
|
@ -25,7 +25,12 @@
|
||||||
"type": "belongsTo",
|
"type": "belongsTo",
|
||||||
"model": "VnUser",
|
"model": "VnUser",
|
||||||
"foreignKey": "user_id"
|
"foreignKey": "user_id"
|
||||||
|
},
|
||||||
|
"queueMember": {
|
||||||
|
"type": "belongsTo",
|
||||||
|
"model": "QueueMember",
|
||||||
|
"foreignKey": "extension",
|
||||||
|
"primaryKey": "extension"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.remoteMethod('getWithPackaging', {
|
||||||
|
description: 'Returns the list of suppliers with an entry of type packaging',
|
||||||
|
accessType: 'READ',
|
||||||
|
returns: {
|
||||||
|
type: 'object',
|
||||||
|
root: true
|
||||||
|
},
|
||||||
|
http: {
|
||||||
|
path: `/getWithPackaging`,
|
||||||
|
verb: 'GET'
|
||||||
|
},
|
||||||
|
nolimit: true
|
||||||
|
});
|
||||||
|
Self.getWithPackaging = async options => {
|
||||||
|
const models = Self.app.models;
|
||||||
|
const myOptions = {};
|
||||||
|
const oneYearAgo = new Date();
|
||||||
|
oneYearAgo.setFullYear(oneYearAgo.getFullYear() - 1);
|
||||||
|
|
||||||
|
if (typeof options == 'object')
|
||||||
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
|
const entries = await models.Entry.find({
|
||||||
|
where: {
|
||||||
|
typeFk: 'packaging',
|
||||||
|
created: {gte: oneYearAgo}
|
||||||
|
},
|
||||||
|
include: {
|
||||||
|
relation: 'supplier',
|
||||||
|
scope: {
|
||||||
|
fields: ['id', 'name']
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fields: {supplierFk: true}
|
||||||
|
}, myOptions);
|
||||||
|
|
||||||
|
const result = entries.map(item => ({
|
||||||
|
id: item.supplier().id,
|
||||||
|
name: item.supplier().name
|
||||||
|
}));
|
||||||
|
return Array.from(new Map(result.map(entry => [entry.id, entry])).values());
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
const {models} = require('vn-loopback/server/server');
|
||||||
|
|
||||||
|
describe('Supplier getWithPackaging()', () => {
|
||||||
|
it('should return a list of suppliers with an entry of type packaging', async() => {
|
||||||
|
const typeFk = 'packaging';
|
||||||
|
|
||||||
|
const tx = await models.Supplier.beginTransaction({});
|
||||||
|
const myOptions = {transaction: tx};
|
||||||
|
|
||||||
|
try {
|
||||||
|
const entry = await models.Entry.findOne(
|
||||||
|
{
|
||||||
|
where: {
|
||||||
|
id: 1
|
||||||
|
},
|
||||||
|
myOptions
|
||||||
|
});
|
||||||
|
|
||||||
|
await entry.updateAttributes({
|
||||||
|
typeFk: typeFk,
|
||||||
|
created: new Date()
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = await models.Supplier.getWithPackaging(myOptions);
|
||||||
|
|
||||||
|
expect(result.length).toEqual(1);
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
|
@ -12,6 +12,7 @@ module.exports = Self => {
|
||||||
require('../methods/supplier/campaignMetricsEmail')(Self);
|
require('../methods/supplier/campaignMetricsEmail')(Self);
|
||||||
require('../methods/supplier/newSupplier')(Self);
|
require('../methods/supplier/newSupplier')(Self);
|
||||||
require('../methods/supplier/getItemsPackaging')(Self);
|
require('../methods/supplier/getItemsPackaging')(Self);
|
||||||
|
require('../methods/supplier/getWithPackaging')(Self);
|
||||||
|
|
||||||
Self.validatesPresenceOf('name', {
|
Self.validatesPresenceOf('name', {
|
||||||
message: 'The social name cannot be empty'
|
message: 'The social name cannot be empty'
|
||||||
|
|
|
@ -54,7 +54,7 @@ module.exports = Self => {
|
||||||
JOIN country co ON co.id = p.countryFk
|
JOIN country co ON co.id = p.countryFk
|
||||||
LEFT JOIN account.emailUser eu ON eu.userFk = c.salesPersonFk
|
LEFT JOIN account.emailUser eu ON eu.userFk = c.salesPersonFk
|
||||||
WHERE (al.code = 'PACKED' OR (am.code = 'refund' AND al.code <> 'delivered'))
|
WHERE (al.code = 'PACKED' OR (am.code = 'refund' AND al.code <> 'delivered'))
|
||||||
AND DATE(t.shipped) BETWEEN ? - INTERVAL 2 DAY AND util.dayEnd(?)
|
AND DATE(t.shipped) BETWEEN ? - INTERVAL 7 DAY AND util.dayEnd(?)
|
||||||
AND t.refFk IS NULL
|
AND t.refFk IS NULL
|
||||||
GROUP BY t.id
|
GROUP BY t.id
|
||||||
`, [toDate, toDate]);
|
`, [toDate, toDate]);
|
||||||
|
|
|
@ -12,16 +12,18 @@ module.exports = async function(ctx, Self, tickets, options) {
|
||||||
Object.assign(myOptions, options);
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
let tx;
|
let tx;
|
||||||
if (!myOptions.transaction) {
|
// if (!myOptions.transaction) {
|
||||||
tx = await Self.beginTransaction({});
|
// tx = await Self.beginTransaction({});
|
||||||
myOptions.transaction = tx;
|
// myOptions.transaction = tx;
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (tickets.length == 0) return;
|
if (tickets.length == 0) return;
|
||||||
|
|
||||||
const failedtickets = [];
|
const failedtickets = [];
|
||||||
for (const ticket of tickets) {
|
for (const ticket of tickets) {
|
||||||
try {
|
try {
|
||||||
|
await Self.rawSql(`CALL util.debugAdd('invoicingTicket', ?)`, [ticket.id], {userId});
|
||||||
|
|
||||||
await Self.app.models.InvoiceOut.getSerial(ticket.clientFk, ticket.companyFk, ticket.addressFk, 'quick');
|
await Self.app.models.InvoiceOut.getSerial(ticket.clientFk, ticket.companyFk, ticket.addressFk, 'quick');
|
||||||
await Self.rawSql(
|
await Self.rawSql(
|
||||||
`CALL vn.ticket_closeByTicket(?)`,
|
`CALL vn.ticket_closeByTicket(?)`,
|
||||||
|
@ -149,6 +151,11 @@ module.exports = async function(ctx, Self, tickets, options) {
|
||||||
myOptions);
|
myOptions);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
await Self.rawSql(`
|
||||||
|
INSERT INTO util.debug (variable, value)
|
||||||
|
VALUES ('invoicingTicketError', ?)
|
||||||
|
`, [ticket.id + ' - ' + error]);
|
||||||
|
|
||||||
if (error.responseCode == 450) {
|
if (error.responseCode == 450) {
|
||||||
await invalidEmail(ticket);
|
await invalidEmail(ticket);
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -253,7 +253,18 @@
|
||||||
"relation": "client"
|
"relation": "client"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"relation": "sip"
|
"relation": "sip",
|
||||||
|
"scope": {
|
||||||
|
"include": {
|
||||||
|
"relation": "queueMember",
|
||||||
|
"scope": {
|
||||||
|
"fields": [
|
||||||
|
"queue",
|
||||||
|
"extension"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue