7658-devToTest_2428 #2663
|
@ -28,7 +28,7 @@ Pull from repository.
|
|||
|
||||
Run this commands on project root directory to install Node dependencies.
|
||||
```
|
||||
$ npm install
|
||||
$ pnpm install
|
||||
$ gulp install
|
||||
```
|
||||
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
const UserError = require('vn-loopback/util/user-error');
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('assignCollection', {
|
||||
description: 'Assign a collection',
|
||||
accessType: 'WRITE',
|
||||
http: {
|
||||
path: `/assignCollection`,
|
||||
verb: 'POST'
|
||||
},
|
||||
returns: {
|
||||
type: ['object'],
|
||||
root: true
|
||||
},
|
||||
});
|
||||
|
||||
Self.assignCollection = async(ctx, options) => {
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
const myOptions = {userId};
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
const [info, info2, [{'@vCollectionFk': collectionFk}]] = await Self.rawSql(
|
||||
'CALL vn.collection_getAssigned(?, @vCollectionFk);SELECT @vCollectionFk', [userId], myOptions);
|
||||
if (!collectionFk) throw new UserError('There are not picking tickets');
|
||||
await Self.rawSql('CALL vn.collection_printSticker(?, NULL)', [collectionFk], myOptions);
|
||||
|
||||
return collectionFk;
|
||||
};
|
||||
};
|
|
@ -1,6 +1,6 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('getSales', {
|
||||
description: 'Get sales from ticket or collection',
|
||||
description: 'Get sales from ticket, collection or sectorCollection',
|
||||
accessType: 'READ',
|
||||
accepts: [
|
||||
{
|
||||
|
|
|
@ -37,6 +37,7 @@ module.exports = Self => {
|
|||
|
||||
const promises = [];
|
||||
const [tickets] = await Self.rawSql(`CALL vn.collection_getTickets(?)`, [id], myOptions);
|
||||
|
||||
const sales = await Self.rawSql(`
|
||||
SELECT s.ticketFk,
|
||||
sgd.saleGroupFk,
|
||||
|
@ -68,7 +69,7 @@ module.exports = Self => {
|
|||
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
|
||||
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
|
||||
|
@ -76,17 +77,56 @@ module.exports = Self => {
|
|||
LEFT JOIN origin o ON o.id = i.originFk
|
||||
WHERE tc.collectionFk = ?
|
||||
GROUP BY s.id, ish.id, p.code, p2.code
|
||||
ORDER BY pickingOrder;`, [id], myOptions);
|
||||
|
||||
UNION ALL
|
||||
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,
|
||||
iss.quantity,
|
||||
SUM(iss.quantity) OVER (PARTITION BY s.id ORDER BY ish.id),
|
||||
ROW_NUMBER () OVER (PARTITION BY s.id ORDER BY p.pickingOrder),
|
||||
COUNT(*) OVER (PARTITION BY s.id ORDER BY s.id) ,
|
||||
sh.code,
|
||||
IFNULL(p2.code, p.code),
|
||||
IFNULL(p2.pickingOrder, p.pickingOrder),
|
||||
iss.id itemShelvingSaleFk,
|
||||
iss.isPicked
|
||||
FROM sectorCollection sc
|
||||
JOIN sectorCollectionSaleGroup ss ON ss.sectorCollectionFk = sc.id
|
||||
JOIN saleGroup sg ON sg.id = ss.saleGroupFk
|
||||
JOIN ticket t ON t.id = sg.ticketFk
|
||||
JOIN sale s ON s.ticketFk = t.id
|
||||
LEFT JOIN saleGroupDetail sgd ON sgd.saleFk = s.id
|
||||
LEFT JOIN parking p2 ON p2.id = sg.parkingFk
|
||||
JOIN item i ON i.id = s.itemFk
|
||||
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 sc.id = ?
|
||||
AND sgd.saleGroupFk
|
||||
GROUP BY s.id, ish.id, p.code, p2.code`, [id, 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;
|
||||
if (ticket.observaciones != '') {
|
||||
for (observation of ticket.observaciones.split(' ')) {
|
||||
if (ticket.observation) {
|
||||
for (observation of ticket.observation?.split(' ')) {
|
||||
if (['#', '@'].includes(observation.charAt(0))) {
|
||||
promises.push(Self.app.models.Chat.send(ctx, observation,
|
||||
$t('The ticket is in preparation', {
|
||||
|
@ -100,11 +140,11 @@ module.exports = Self => {
|
|||
if (sales && sales.length) {
|
||||
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
|
||||
FROM sale s
|
||||
LEFT JOIN itemBarcode b ON b.itemFk = s.itemFk
|
||||
LEFT JOIN buy c ON c.itemFk = s.itemFk
|
||||
LEFT JOIN entry e ON e.id = c.entryFk
|
||||
LEFT JOIN travel tr ON tr.id = e.travelFk
|
||||
WHERE s.ticketFk = ?
|
||||
AND tr.landed >= util.VN_CURDATE() - INTERVAL 1 YEAR`,
|
||||
[ticketId], myOptions);
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('ticket assignCollection()', () => {
|
||||
let ctx;
|
||||
let options;
|
||||
let tx;
|
||||
beforeEach(async() => {
|
||||
ctx = {
|
||||
req: {
|
||||
accessToken: {userId: 1106},
|
||||
headers: {origin: 'http://localhost'},
|
||||
__: value => value
|
||||
},
|
||||
args: {}
|
||||
};
|
||||
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: ctx.req
|
||||
});
|
||||
|
||||
options = {transaction: tx};
|
||||
tx = await models.Sale.beginTransaction({});
|
||||
options.transaction = tx;
|
||||
});
|
||||
|
||||
afterEach(async() => {
|
||||
await tx.rollback();
|
||||
});
|
||||
|
||||
it('should throw an error when there is not picking tickets', async() => {
|
||||
try {
|
||||
await models.Collection.assignCollection(ctx, options);
|
||||
} catch (e) {
|
||||
expect(e.message).toEqual('There are not picking tickets');
|
||||
}
|
||||
});
|
||||
});
|
|
@ -26,8 +26,8 @@ describe('collection getTickets()', () => {
|
|||
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[1].sales.length).toEqual(0);
|
||||
expect(collectionTickets.tickets[2].sales.length).toEqual(0);
|
||||
expect(collectionTickets.tickets[0].sales[0].Barcodes.length).toBeTruthy();
|
||||
|
||||
await tx.rollback();
|
||||
|
|
|
@ -22,7 +22,7 @@ module.exports = Self => {
|
|||
const url = await Self.app.models.Url.findOne({
|
||||
where: {
|
||||
appName,
|
||||
environment: process.env.NODE_ENV || 'development'
|
||||
environment: process.env.NODE_ENV || 'dev'
|
||||
}
|
||||
});
|
||||
return url?.url;
|
||||
|
|
|
@ -16,36 +16,51 @@ module.exports = Self => {
|
|||
accessScopes: ['DEFAULT', 'read:multimedia']});
|
||||
|
||||
Self.renewToken = async function(ctx) {
|
||||
const {accessToken: token} = ctx.req;
|
||||
|
||||
const {courtesyTime} = await models.AccessTokenConfig.findOne({
|
||||
fields: ['courtesyTime']
|
||||
});
|
||||
const isNotExceeded = await Self.validateToken(ctx);
|
||||
if (isNotExceeded)
|
||||
return token;
|
||||
|
||||
// Schedule to remove current token
|
||||
setTimeout(async() => {
|
||||
try {
|
||||
const exists = await models.AccessToken.findById(token.id);
|
||||
exists && await Self.logout(token.id);
|
||||
} catch (err) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(err);
|
||||
}
|
||||
}, courtesyTime * 1000);
|
||||
|
||||
// Get scopes
|
||||
|
||||
let createTokenOptions = {};
|
||||
const {scopes} = token;
|
||||
if (scopes)
|
||||
createTokenOptions = {scopes: [scopes[0]]};
|
||||
// Create new accessToken
|
||||
const user = await Self.findById(token.userId);
|
||||
const accessToken = await user.accessTokens.create(createTokenOptions);
|
||||
let token; let isNotExceeded;
|
||||
try {
|
||||
token = ctx.req.accessToken;
|
||||
|
||||
return {id: accessToken.id, ttl: accessToken.ttl};
|
||||
const {courtesyTime} = await models.AccessTokenConfig.findOne({
|
||||
fields: ['courtesyTime']
|
||||
});
|
||||
isNotExceeded = await Self.validateToken(ctx);
|
||||
if (isNotExceeded)
|
||||
return token;
|
||||
|
||||
// Schedule to remove current token
|
||||
setTimeout(async() => {
|
||||
let exists;
|
||||
try {
|
||||
exists = await models.AccessToken.findById(token.id);
|
||||
exists && await Self.logout(token.id);
|
||||
} catch (error) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(error);
|
||||
const body = {error: error.message, now: Date.now(), userId: token?.userId ?? null, exists};
|
||||
await handleError(body);
|
||||
throw new Error(error);
|
||||
}
|
||||
}, courtesyTime * 1000);
|
||||
|
||||
// Get scopes
|
||||
const {scopes} = token;
|
||||
if (scopes)
|
||||
createTokenOptions = {scopes: [scopes[0]]};
|
||||
// Create new accessToken
|
||||
const user = await Self.findById(token.userId);
|
||||
const accessToken = await user.accessTokens.create(createTokenOptions);
|
||||
|
||||
return {id: accessToken.id, ttl: accessToken.ttl};
|
||||
} catch (error) {
|
||||
const body = {error: error.message, now: Date.now(), userId: token?.userId ?? null, createTokenOptions, isNotExceeded};
|
||||
await handleError(body);
|
||||
throw new Error(error);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
async function handleError(body, tag = 'renewToken') {
|
||||
body = JSON.stringify(body);
|
||||
await models.Application.rawSql('CALL util.debugAdd(?,?);', [tag, body]);
|
||||
}
|
||||
|
|
|
@ -61,4 +61,21 @@ describe('Renew Token', () => {
|
|||
expect(error).toBeUndefined();
|
||||
expect(response.id).toEqual(ctx.req.accessToken.id);
|
||||
});
|
||||
|
||||
it('throw error', async() => {
|
||||
let error;
|
||||
|
||||
try {
|
||||
await models.VnUser.renewToken({req: {token: null}});
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
|
||||
expect(error).toBeDefined();
|
||||
const query = 'SELECT * FROM util.debug';
|
||||
|
||||
const debugLog = await models.Application.rawSql(query, null);
|
||||
|
||||
expect(debugLog.length).toEqual(1);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -64,6 +64,9 @@
|
|||
"EmailUser": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"Expedition_PrintOut": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"Image": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
|
@ -190,4 +193,4 @@
|
|||
"RouteConfig": {
|
||||
"dataSource": "vn"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,6 +3,7 @@ module.exports = Self => {
|
|||
require('../methods/collection/setSaleQuantity')(Self);
|
||||
require('../methods/collection/previousLabel')(Self);
|
||||
require('../methods/collection/getTickets')(Self);
|
||||
require('../methods/collection/assignCollection')(Self);
|
||||
require('../methods/collection/assign')(Self);
|
||||
require('../methods/collection/getSales')(Self);
|
||||
};
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"name": "Expedition_PrintOut",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "dipole.expedition_PrintOut"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"expeditionFk": {
|
||||
"type": "number",
|
||||
"id": true,
|
||||
"description": "id expeditionFk"
|
||||
},
|
||||
"itemFk": {
|
||||
"type": "number"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,17 +3,23 @@
|
|||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "productionConfig"
|
||||
"table": "productionConfig"
|
||||
}
|
||||
},
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "number",
|
||||
"required": true,
|
||||
"id": true
|
||||
},
|
||||
"sectorFromCode": {
|
||||
"type": "string"
|
||||
},
|
||||
"sectorToCode": {
|
||||
"type": "string"
|
||||
},
|
||||
"backupPrinterNotificationDelay": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,7 +3,7 @@ USE `util`;
|
|||
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
|
||||
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
|
||||
|
||||
INSERT INTO `version` VALUES ('vn-database','11090','7adf4a373d19ce126adbc7b1077f69a74559c09a','2024-06-11 08:32:36','11094');
|
||||
INSERT INTO `version` VALUES ('vn-database','11114','cf0f80142fed798c3307565a69158d7dba9276c4','2024-06-25 09:25:54','11115');
|
||||
|
||||
INSERT INTO `versionLog` VALUES ('vn-database','10107','00-firstScript.sql','jenkins@10.0.2.69','2022-04-23 10:53:53',NULL,NULL);
|
||||
INSERT INTO `versionLog` VALUES ('vn-database','10112','00-firstScript.sql','jenkins@10.0.2.69','2022-05-09 09:14:53',NULL,NULL);
|
||||
|
@ -834,19 +834,34 @@ INSERT INTO `versionLog` VALUES ('vn-database','11058','00-firstScript.sql','jen
|
|||
INSERT INTO `versionLog` VALUES ('vn-database','11059','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-06-11 08:32:34',NULL,NULL);
|
||||
INSERT INTO `versionLog` VALUES ('vn-database','11060','00-createRoleReviewer.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-06-11 08:32:34',NULL,NULL);
|
||||
INSERT INTO `versionLog` VALUES ('vn-database','11061','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:48',NULL,NULL);
|
||||
INSERT INTO `versionLog` VALUES ('vn-database','11063','00-roadmapAddress.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-06-25 08:38:13',NULL,NULL);
|
||||
INSERT INTO `versionLog` VALUES ('vn-database','11063','01-roadmapStop.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-06-25 08:38:13',NULL,NULL);
|
||||
INSERT INTO `versionLog` VALUES ('vn-database','11063','02-roadmapStopGrants.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-06-25 08:38:13',NULL,NULL);
|
||||
INSERT INTO `versionLog` VALUES ('vn-database','11064','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-06-25 08:38:13',NULL,NULL);
|
||||
INSERT INTO `versionLog` VALUES ('vn-database','11065','00-modifyInvoiceInPrivileges.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-06-11 08:32:34',NULL,NULL);
|
||||
INSERT INTO `versionLog` VALUES ('vn-database','11065','01-modifyInvoiceInAcls.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-06-11 08:32:34',NULL,NULL);
|
||||
INSERT INTO `versionLog` VALUES ('vn-database','11068','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-06-11 08:32:34',NULL,NULL);
|
||||
INSERT INTO `versionLog` VALUES ('vn-database','11069','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-06-11 08:32:34',NULL,NULL);
|
||||
INSERT INTO `versionLog` VALUES ('vn-database','11070','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-06-25 08:38:13',NULL,NULL);
|
||||
INSERT INTO `versionLog` VALUES ('vn-database','11071','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:48',NULL,NULL);
|
||||
INSERT INTO `versionLog` VALUES ('vn-database','11074','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-06-11 08:32:35',NULL,NULL);
|
||||
INSERT INTO `versionLog` VALUES ('vn-database','11075','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-28 12:54:13',NULL,NULL);
|
||||
INSERT INTO `versionLog` VALUES ('vn-database','11078','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-06-11 08:32:35',NULL,NULL);
|
||||
INSERT INTO `versionLog` VALUES ('vn-database','11079','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-31 08:22:10',NULL,NULL);
|
||||
INSERT INTO `versionLog` VALUES ('vn-database','11080','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-31 12:01:58',NULL,NULL);
|
||||
INSERT INTO `versionLog` VALUES ('vn-database','11082','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-06-25 08:38:13',NULL,NULL);
|
||||
INSERT INTO `versionLog` VALUES ('vn-database','11083','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-06-03 10:46:36',NULL,NULL);
|
||||
INSERT INTO `versionLog` VALUES ('vn-database','11084','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-06-25 08:38:13',NULL,NULL);
|
||||
INSERT INTO `versionLog` VALUES ('vn-database','11087','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-06-25 08:38:13',NULL,NULL);
|
||||
INSERT INTO `versionLog` VALUES ('vn-database','11089','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-06-25 08:39:16',NULL,NULL);
|
||||
INSERT INTO `versionLog` VALUES ('vn-database','11090','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-06-11 08:32:35',NULL,NULL);
|
||||
INSERT INTO `versionLog` VALUES ('vn-database','11092','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-06-07 08:21:23',NULL,NULL);
|
||||
INSERT INTO `versionLog` VALUES ('vn-database','11093','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-06-25 08:39:16',NULL,NULL);
|
||||
INSERT INTO `versionLog` VALUES ('vn-database','11096','00-addBuyerAcl.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-06-11 12:48:51',NULL,NULL);
|
||||
INSERT INTO `versionLog` VALUES ('vn-database','11105','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-06-20 15:36:07',NULL,NULL);
|
||||
INSERT INTO `versionLog` VALUES ('vn-database','11106','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-06-25 08:39:49',NULL,NULL);
|
||||
INSERT INTO `versionLog` VALUES ('vn-database','11109','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-06-18 19:09:56',NULL,NULL);
|
||||
INSERT INTO `versionLog` VALUES ('vn-database','11114','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-06-25 08:39:49',NULL,NULL);
|
||||
|
||||
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
|
||||
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
|
||||
|
@ -930,7 +945,7 @@ INSERT INTO `role` VALUES (109,'salesTeamBoss','Jefe de equipo de comerciales',1
|
|||
INSERT INTO `role` VALUES (110,'palletizer','Paletizadores',1,'2022-12-02 13:56:22','2022-12-02 13:56:30',NULL);
|
||||
INSERT INTO `role` VALUES (111,'entryEditor','Entry editor',1,'2023-01-13 12:21:55','2023-01-13 12:21:55',NULL);
|
||||
INSERT INTO `role` VALUES (112,'maintenance','Personal de mantenimiento',1,'2023-01-19 07:23:35','2023-01-19 07:23:35',NULL);
|
||||
INSERT INTO `role` VALUES (114,'maintenanceBos','Jefe de mantenimiento',1,'2023-01-19 07:31:16','2023-05-17 13:07:21',NULL);
|
||||
INSERT INTO `role` VALUES (114,'maintenanceBoss','Jefe de mantenimiento',1,'2023-01-19 07:31:16','2024-06-14 08:56:41',19295);
|
||||
INSERT INTO `role` VALUES (115,'itManagement','TI management',1,'2023-03-29 09:27:55','2023-03-29 09:28:04',NULL);
|
||||
INSERT INTO `role` VALUES (119,'palletizerBoss','Jefe de paletizadores',1,'2023-06-07 13:51:54','2023-06-07 13:51:54',NULL);
|
||||
INSERT INTO `role` VALUES (120,'developerBoss','Jefe de proyecto de desarrollo',1,'2023-06-19 09:07:21','2023-06-19 09:07:21',21709);
|
||||
|
@ -1212,6 +1227,7 @@ INSERT INTO `roleInherit` VALUES (367,30,73,NULL);
|
|||
INSERT INTO `roleInherit` VALUES (368,130,49,10578);
|
||||
INSERT INTO `roleInherit` VALUES (369,50,130,10578);
|
||||
INSERT INTO `roleInherit` VALUES (370,72,130,10578);
|
||||
INSERT INTO `roleInherit` VALUES (371,36,35,NULL);
|
||||
|
||||
INSERT INTO `userPassword` VALUES (1,7,1,0,2,1);
|
||||
|
||||
|
@ -1535,7 +1551,7 @@ INSERT INTO `ACL` VALUES (383,'Sector','*','READ','ALLOW','ROLE','employee');
|
|||
INSERT INTO `ACL` VALUES (384,'Sector','*','WRITE','ALLOW','ROLE','employee');
|
||||
INSERT INTO `ACL` VALUES (385,'Route','driverRoutePdf','READ','ALLOW','ROLE','employee');
|
||||
INSERT INTO `ACL` VALUES (386,'Route','driverRouteEmail','WRITE','ALLOW','ROLE','employee');
|
||||
INSERT INTO `ACL` VALUES (387,'Ticket','deliveryNotePdf','READ','ALLOW','ROLE','customer');
|
||||
INSERT INTO `ACL` VALUES (387,'Ticket','deliveryNotePdf','READ','ALLOW','ROLE','$owner');
|
||||
INSERT INTO `ACL` VALUES (388,'Supplier','newSupplier','WRITE','ALLOW','ROLE','administrative');
|
||||
INSERT INTO `ACL` VALUES (389,'ClaimRma','*','READ','ALLOW','ROLE','claimManager');
|
||||
INSERT INTO `ACL` VALUES (390,'ClaimRma','*','WRITE','ALLOW','ROLE','claimManager');
|
||||
|
@ -1791,10 +1807,6 @@ INSERT INTO `ACL` VALUES (686,'MailForward','*','*','ALLOW','ROLE','hr');
|
|||
INSERT INTO `ACL` VALUES (687,'ClientSms','find','READ','ALLOW','ROLE','employee');
|
||||
INSERT INTO `ACL` VALUES (688,'ClientSms','create','WRITE','ALLOW','ROLE','employee');
|
||||
INSERT INTO `ACL` VALUES (689,'Vehicle','sorted','WRITE','ALLOW','ROLE','employee');
|
||||
INSERT INTO `ACL` VALUES (690,'Roadmap','*','*','ALLOW','ROLE','palletizerBoss');
|
||||
INSERT INTO `ACL` VALUES (691,'Roadmap','*','*','ALLOW','ROLE','productionBoss');
|
||||
INSERT INTO `ACL` VALUES (692,'RoadmapStop','*','*','ALLOW','ROLE','production');
|
||||
INSERT INTO `ACL` VALUES (693,'RoadmapStop','*','*','ALLOW','ROLE','productionBoss');
|
||||
INSERT INTO `ACL` VALUES (695,'ViaexpressConfig','internationalExpedition','WRITE','ALLOW','ROLE','employee');
|
||||
INSERT INTO `ACL` VALUES (696,'ViaexpressConfig','renderer','READ','ALLOW','ROLE','employee');
|
||||
INSERT INTO `ACL` VALUES (697,'Ticket','transferClient','WRITE','ALLOW','ROLE','administrative');
|
||||
|
@ -1863,7 +1875,7 @@ INSERT INTO `ACL` VALUES (761,'Route','downloadZip','READ','ALLOW','ROLE','emplo
|
|||
INSERT INTO `ACL` VALUES (762,'Route','filter','READ','ALLOW','ROLE','employee');
|
||||
INSERT INTO `ACL` VALUES (763,'Route','getByWorker','READ','ALLOW','ROLE','employee');
|
||||
INSERT INTO `ACL` VALUES (764,'Route','getDeliveryPoint','READ','ALLOW','ROLE','employee');
|
||||
INSERT INTO `ACL` VALUES (765,'Route','getExternalCmrs','READ','ALLOW','ROLE','employee');
|
||||
INSERT INTO `ACL` VALUES (765,'Route','cmrs','READ','ALLOW','ROLE','employee');
|
||||
INSERT INTO `ACL` VALUES (766,'Route','getSuggestedTickets','READ','ALLOW','ROLE','employee');
|
||||
INSERT INTO `ACL` VALUES (767,'Route','getTickets','READ','ALLOW','ROLE','employee');
|
||||
INSERT INTO `ACL` VALUES (768,'Route','guessPriority','WRITE','ALLOW','ROLE','employee');
|
||||
|
@ -1939,8 +1951,6 @@ INSERT INTO `ACL` VALUES (840,'Locker','*','*','ALLOW','ROLE','hr');
|
|||
INSERT INTO `ACL` VALUES (841,'Locker','*','*','ALLOW','ROLE','productionBoss');
|
||||
INSERT INTO `ACL` VALUES (842,'Worker','__get__locker','READ','ALLOW','ROLE','hr');
|
||||
INSERT INTO `ACL` VALUES (843,'Worker','__get__locker','READ','ALLOW','ROLE','productionBoss');
|
||||
INSERT INTO `ACL` VALUES (844,'RoadmapStop','*','*','ALLOW','ROLE','production');
|
||||
INSERT INTO `ACL` VALUES (845,'RoadmapStop','*','*','ALLOW','ROLE','productionBoss');
|
||||
INSERT INTO `ACL` VALUES (846,'Ticket','refund','WRITE','ALLOW','ROLE','logistic');
|
||||
INSERT INTO `ACL` VALUES (847,'RouteConfig','*','READ','ALLOW','ROLE','employee');
|
||||
INSERT INTO `ACL` VALUES (848,'InvoiceIn','updateInvoiceIn','WRITE','ALLOW','ROLE','administrative');
|
||||
|
@ -1960,6 +1970,19 @@ INSERT INTO `ACL` VALUES (861,'InvoiceIn','toBook','WRITE','ALLOW','ROLE','buyer
|
|||
INSERT INTO `ACL` VALUES (862,'InvoiceIn','deleteById','WRITE','ALLOW','ROLE','buyer');
|
||||
INSERT INTO `ACL` VALUES (863,'InvoiceIn','create','WRITE','ALLOW','ROLE','administrative');
|
||||
INSERT INTO `ACL` VALUES (864,'InvoiceIn','create','WRITE','ALLOW','ROLE','buyer');
|
||||
INSERT INTO `ACL` VALUES (865,'Ticket','deliveryNotePdf','READ','ALLOW','ROLE','employee');
|
||||
INSERT INTO `ACL` VALUES (866,'InvoiceOut','download','READ','ALLOW','ROLE','$owner');
|
||||
INSERT INTO `ACL` VALUES (867,'InvoiceIn','*','READ','ALLOW','ROLE','maintenanceBoss');
|
||||
INSERT INTO `ACL` VALUES (868,'InvoiceIn','*','READ','ALLOW','ROLE','maintenanceBos');
|
||||
INSERT INTO `ACL` VALUES (869,'Ticket','editZone','WRITE','ALLOW','ROLE','buyer');
|
||||
INSERT INTO `ACL` VALUES (870,'Entry','find','READ','ALLOW','ROLE','production');
|
||||
INSERT INTO `ACL` VALUES (871,'RoadmapAddress','*','WRITE','ALLOW','ROLE','palletizerBoss');
|
||||
INSERT INTO `ACL` VALUES (872,'RoadmapAddress','*','READ','ALLOW','ROLE','production');
|
||||
INSERT INTO `ACL` VALUES (873,'Roadmap','*','WRITE','ALLOW','ROLE','palletizerBoss');
|
||||
INSERT INTO `ACL` VALUES (874,'Roadmap','*','READ','ALLOW','ROLE','production');
|
||||
INSERT INTO `ACL` VALUES (875,'RoadmapStop','*','WRITE','ALLOW','ROLE','palletizerBoss');
|
||||
INSERT INTO `ACL` VALUES (876,'RoadmapStop','*','READ','ALLOW','ROLE','production');
|
||||
INSERT INTO `ACL` VALUES (877,'TravelKgPercentage','*','READ','ALLOW','ROLE','employee');
|
||||
|
||||
INSERT INTO `fieldAcl` VALUES (1,'Client','name','update','employee');
|
||||
INSERT INTO `fieldAcl` VALUES (2,'Client','contact','update','employee');
|
||||
|
@ -2280,7 +2303,7 @@ INSERT INTO `continent` VALUES (3,'África','AF');
|
|||
INSERT INTO `continent` VALUES (4,'Europa','EU');
|
||||
INSERT INTO `continent` VALUES (5,'Oceanía','OC');
|
||||
|
||||
INSERT INTO `department` VALUES (1,'VN','VERDNATURA',1,110,763,0,0,0,0,25,NULL,'/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (1,'VN','VERDNATURA',1,110,763,0,0,0,0,26,NULL,'/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (22,'shopping','COMPRAS',2,3,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (23,'CMA','CAMARA',13,14,NULL,72,1,1,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,1,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (31,'it','INFORMATICA',4,5,NULL,72,0,0,1,0,1,'/1/','informatica-cau',1,NULL,1,0,0,0,NULL,NULL,NULL,NULL);
|
||||
|
@ -2291,49 +2314,49 @@ INSERT INTO `department` VALUES (37,'PROD','PRODUCCION',12,35,NULL,72,1,1,1,11,1
|
|||
INSERT INTO `department` VALUES (38,'picking','SACADO',15,16,NULL,72,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (39,'packing','ENCAJADO',17,18,NULL,72,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (41,'administration','ADMINISTRACION',36,37,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (43,'VT','VENTAS',38,71,NULL,0,0,0,1,16,1,'/1/',NULL,1,'',1,0,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (44,'management','GERENCIA',72,73,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (45,'logistic','LOGISTICA',74,75,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (46,'delivery','REPARTO',76,77,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (48,'storage','ALMACENAJE',78,79,NULL,0,1,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (49,NULL,'PROPIEDAD',80,81,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (52,NULL,'CARGA AEREA',82,83,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (43,'VT','VENTAS',38,69,NULL,0,0,0,1,15,1,'/1/',NULL,1,'',1,0,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (44,'management','GERENCIA',70,71,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (45,'logistic','LOGISTICA',72,73,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (46,'delivery','REPARTO',74,75,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (48,'storage','ALMACENAJE',76,77,NULL,0,1,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (49,NULL,'PROPIEDAD',78,79,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (52,NULL,'CARGA AEREA',80,81,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (53,'marketing','MARKETING Y COMUNICACIÓN',39,40,NULL,72,0,0,2,0,43,'/1/43/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (54,NULL,'ORNAMENTALES',84,85,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (54,NULL,'ORNAMENTALES',82,83,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (55,NULL,'TALLER NATURAL',19,20,14548,72,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,0,1118,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (56,NULL,'TALLER ARTIFICIAL',21,22,8470,72,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,0,1927,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (58,'CMP','CAMPOS',86,89,NULL,72,0,0,1,1,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (59,'maintenance','MANTENIMIENTO',90,91,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (58,'CMP','CAMPOS',84,87,NULL,72,0,0,1,1,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (59,'maintenance','MANTENIMIENTO',88,89,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (60,'claims','RECLAMACIONES',41,42,NULL,72,0,0,2,0,43,'/1/43/',NULL,1,NULL,1,1,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (61,NULL,'VNH',92,95,NULL,73,0,0,1,1,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (66,NULL,'VERDNAMADRID',96,97,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (61,NULL,'VNH',90,93,NULL,73,0,0,1,1,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (66,NULL,'VERDNAMADRID',94,95,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (68,NULL,'COMPLEMENTOS',23,24,NULL,72,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (69,NULL,'VERDNABARNA',98,99,NULL,74,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (69,NULL,'VERDNABARNA',96,97,NULL,74,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (80,'spainTeam5','EQUIPO ESPAÑA 5',43,44,4250,0,0,0,2,0,43,'/1/43/','es5_equipo',1,'es5@verdnatura.es',0,0,0,0,NULL,NULL,'5300',NULL);
|
||||
INSERT INTO `department` VALUES (86,NULL,'LIMPIEZA',100,101,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (89,NULL,'COORDINACION',102,103,NULL,0,1,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (90,NULL,'TRAILER',93,94,NULL,0,0,0,2,0,61,'/1/61/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (86,NULL,'LIMPIEZA',98,99,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (89,NULL,'COORDINACION',100,101,NULL,0,1,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (90,NULL,'TRAILER',91,92,NULL,0,0,0,2,0,61,'/1/61/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (91,'artificial','ARTIFICIAL',25,26,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (92,NULL,'EQUIPO SILVERIO',45,46,1203,0,0,0,2,0,43,'/1/43/','sdc_equipo',0,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (94,'spainTeam2','EQUIPO ESPAÑA 2',47,48,3797,0,0,0,2,0,43,'/1/43/','es2_equipo',0,'es2@verdnatura.es',0,0,0,0,NULL,NULL,'5100',NULL);
|
||||
INSERT INTO `department` VALUES (95,'spainTeam1','EQUIPO ESPAÑA 1',49,50,24065,0,0,0,2,0,43,'/1/43/','es1_equipo',0,'es1@verdnatura.es',0,0,0,0,NULL,NULL,'5000',NULL);
|
||||
INSERT INTO `department` VALUES (94,'spainTeam2','EQUIPO ESPAÑA 2',47,48,3797,0,0,0,2,0,43,'/1/43/','es2_equipo',1,'es2@verdnatura.es',0,0,0,0,NULL,NULL,'5100',NULL);
|
||||
INSERT INTO `department` VALUES (95,'spainTeam1','EQUIPO ESPAÑA 1',49,50,24065,0,0,0,2,0,43,'/1/43/','es1_equipo',1,'es1@verdnatura.es',0,0,0,0,NULL,NULL,'5000',NULL);
|
||||
INSERT INTO `department` VALUES (96,NULL,'EQUIPO C LOPEZ',51,52,4661,0,0,0,2,0,43,'/1/43/','cla_equipo',0,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (115,NULL,'EQUIPO CLAUDI',53,54,3810,0,0,0,2,0,43,'/1/43/','csr_equipo',0,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (123,NULL,'EQUIPO ELENA BASCUÑANA',55,56,7102,0,0,0,2,0,43,'/1/43/','ebt_equipo',0,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (124,NULL,'CONTROL INTERNO',57,58,NULL,72,0,0,2,0,43,'/1/43/',NULL,0,NULL,1,0,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (125,'spainTeam3','EQUIPO ESPAÑA 3',59,60,1118,0,0,0,2,0,43,'/1/43/','es3_equipo',0,'es3@verdnatura.es',0,0,0,0,NULL,NULL,'5200',NULL);
|
||||
INSERT INTO `department` VALUES (124,NULL,'CONTROL INTERNO',102,103,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,1,0,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (125,'spainTeam3','EQUIPO ESPAÑA 3',57,58,1118,0,0,0,2,0,43,'/1/43/','es3_equipo',1,'es3@verdnatura.es',0,0,0,0,NULL,NULL,'5200',NULL);
|
||||
INSERT INTO `department` VALUES (126,NULL,'PRESERVADO',27,28,NULL,0,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (128,NULL,'PALETIZADO',29,30,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (130,NULL,'REVISION',31,32,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (131,'greenhouse','INVERNADERO',87,88,NULL,0,0,0,2,0,58,'/1/58/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (132,NULL,'EQUIPO DC',61,62,1731,0,0,0,2,0,43,'/1/43/','dc_equipo',1,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (133,'franceTeam','EQUIPO FRANCIA',63,64,1731,72,0,0,2,0,43,'/1/43/','fr_equipo',1,'gestionfrancia@verdnatura.es',0,0,0,0,NULL,NULL,'3300',NULL);
|
||||
INSERT INTO `department` VALUES (134,'portugalTeam','EQUIPO PORTUGAL',65,66,6264,0,0,0,2,0,43,'/1/43/','pt_equipo',1,'portugal@verdnatura.es',0,0,0,0,NULL,NULL,'3500',NULL);
|
||||
INSERT INTO `department` VALUES (131,'greenhouse','INVERNADERO',85,86,NULL,0,0,0,2,0,58,'/1/58/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (132,NULL,'EQUIPO DC',59,60,1731,0,0,0,2,0,43,'/1/43/','dc_equipo',1,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (133,'franceTeam','EQUIPO FRANCIA',61,62,1731,72,0,0,2,0,43,'/1/43/','fr_equipo',1,'gestionfrancia@verdnatura.es',0,0,0,0,NULL,NULL,'3300',NULL);
|
||||
INSERT INTO `department` VALUES (134,'portugalTeam','EQUIPO PORTUGAL',63,64,6264,0,0,0,2,0,43,'/1/43/','pt_equipo',1,'portugal@verdnatura.es',0,0,0,0,NULL,NULL,'3500',NULL);
|
||||
INSERT INTO `department` VALUES (135,'routers','ENRUTADORES',104,105,NULL,0,0,0,1,0,1,'/1/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (136,'heavyVehicles','VEHICULOS PESADOS',106,107,NULL,0,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (137,'sorter','SORTER',108,109,NULL,0,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (139,'spainTeam4','EQUIPO ESPAÑA 4',67,68,3803,0,0,0,2,0,43,'/1/43/','es4_equipo',1,'es4@verdnatura.es',0,0,0,0,NULL,NULL,'5400',NULL);
|
||||
INSERT INTO `department` VALUES (140,'hollandTeam','EQUIPO HOLANDA',69,70,NULL,0,0,0,2,0,43,'/1/43/','nl_equipo',1,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (139,'spainTeam4','EQUIPO ESPAÑA 4',65,66,3803,0,0,0,2,0,43,'/1/43/','es4_equipo',1,'es4@verdnatura.es',0,0,0,0,NULL,NULL,'5400',NULL);
|
||||
INSERT INTO `department` VALUES (140,'hollandTeam','EQUIPO HOLANDA',67,68,NULL,0,0,0,2,0,43,'/1/43/','nl_equipo',1,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO `department` VALUES (141,NULL,'PREVIA',33,34,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,NULL);
|
||||
|
||||
INSERT INTO `docuware` VALUES (1,'deliveryNote','Albaranes cliente','find','find','N__ALBAR_N',NULL);
|
||||
|
|
|
@ -647,7 +647,7 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','pgcMaster','
|
|||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','itemBarcode','alexm@%','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','host','alexm@%','0000-00-00 00:00:00','Select,Update','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','ticket','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','invoiceIn','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Delete','Update');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','invoiceIn','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hrBoss','invoiceIn','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','Update');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','invoiceIn','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert','Update');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','claimManager','inventoryFailure','alexm@%','0000-00-00 00:00:00','Select','');
|
||||
|
@ -982,7 +982,7 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','invoiceCorre
|
|||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','ink','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','zone','alexm@%','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','XDiario','alexm@%','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','XDiario','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','XDiario','jgallego@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesAssistant','workerTimeControlMail','alexm@%','0000-00-00 00:00:00','Select,Update','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','workerTimeControl','alexm@%','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','bi','financial','Greuge_Evolution','alexm@%','0000-00-00 00:00:00','Select','');
|
||||
|
@ -1048,7 +1048,7 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','grafana','userSession','j
|
|||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','receipt','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','buy','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','calendarHolidays','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','parking','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','parking','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','role','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','errorLogApp','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','continent','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||
|
@ -1300,7 +1300,7 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerBoss','itemShelving','g
|
|||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','negativeOrigin','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','deliveryBoss','Vehiculos_consumo','carlosap@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','entryOrder','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Delete','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','maintenanceBos','project','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','maintenanceBoss','machineDms','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','ink','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','supplierDms','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','supplierDms','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert','');
|
||||
|
@ -1350,7 +1350,7 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','warehouse
|
|||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','component','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','config','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','','Select');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','componentType','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','maintenanceBos','machineDms','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','priceFixed','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','production','itemShelvingSale','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logisticAssist','tagAbbreviation','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','production','ticketTracking','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert','');
|
||||
|
@ -1361,7 +1361,7 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','sale_freight
|
|||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','accounting','jgallego@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','accounting','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','workerActivity','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','maintenanceBos','machineDetail','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','ticketRequest','guillermo@10.5.1.3','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryBoss','vehicleState','jgallego@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','srt','grafana','expeditionState','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','specialPrice','jgallego@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
|
||||
|
@ -1384,6 +1384,7 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','professionalCategor
|
|||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','production','ticketObservation','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','deliveryNoteState','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','deliveryNote','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','comparative','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','invoiceOutExpense','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','delivery','carlosap@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','entry','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Update','');
|
||||
|
@ -1398,23 +1399,29 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','grafana','visit','root@lo
|
|||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','workerActivity','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','bankPolicy','alexm@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Delete','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','bankPolicyDetail','alexm@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Delete','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','bankPolicyReview','alexm@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Delete','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','bankPolicyReview','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','roadmapStop','guillermo@10.5.1.3','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','production','roadmapStop','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','agencyWorkCenter','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','roadmapStop','guillermo@10.5.1.3','0000-00-00 00:00:00','Insert,Update,Delete','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenanceBos','antenna','guillermo@10.5.1.3','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenanceBos','bufferPool','guillermo@10.5.1.3','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenanceBos','enteringLog','guillermo@10.5.1.3','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenanceBos','expeditionLoading','guillermo@10.5.1.3','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenanceBos','failureLog','guillermo@10.5.1.3','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenanceBos','movingLog','guillermo@10.5.1.3','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenanceBos','sorterLog','guillermo@10.5.1.3','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','entryEditor','Entradas','guillermo@10.5.1.3','0000-00-00 00:00:00','Insert','Update');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','clientInforma','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','solunionCAP','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','clientUnpaid','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','pay_dem','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','adminOfficer','invoiceOut','guillermo@10.5.1.3','0000-00-00 00:00:00','Update,Delete','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financialBoss','invoiceOut','guillermo@10.5.1.3','0000-00-00 00:00:00','Update,Delete','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financialBoss','accountDetail','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Update','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','adminOfficer','accountDetail','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Update','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','maintenanceBoss','project','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','maintenanceBoss','machineDetail','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenanceBoss','antenna','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenanceBoss','bufferPool','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenanceBoss','enteringLog','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenanceBoss','expeditionLoading','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenanceBoss','failureLog','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenanceBoss','movingLog','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||
INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenanceBoss','sorterLog','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||
/*!40000 ALTER TABLE `tables_priv` ENABLE KEYS */;
|
||||
|
||||
/*!40000 ALTER TABLE `columns_priv` DISABLE KEYS */;
|
||||
|
@ -1474,28 +1481,6 @@ INSERT IGNORE INTO `columns_priv` VALUES ('','pbx','grafana','sip','user_id','0
|
|||
INSERT IGNORE INTO `columns_priv` VALUES ('','pbx','grafana','sip','extension','0000-00-00 00:00:00','Select');
|
||||
INSERT IGNORE INTO `columns_priv` VALUES ('','account','grafana','user','name','0000-00-00 00:00:00','Select');
|
||||
INSERT IGNORE INTO `columns_priv` VALUES ('','account','grafana','user','active','0000-00-00 00:00:00','Select');
|
||||
INSERT IGNORE INTO `columns_priv` VALUES ('','vn','administrative','invoiceIn','editorFk','0000-00-00 00:00:00','Update');
|
||||
INSERT IGNORE INTO `columns_priv` VALUES ('','vn','administrative','invoiceIn','expenseFkDeductible','0000-00-00 00:00:00','Update');
|
||||
INSERT IGNORE INTO `columns_priv` VALUES ('','vn','administrative','invoiceIn','withholdingSageFk','0000-00-00 00:00:00','Update');
|
||||
INSERT IGNORE INTO `columns_priv` VALUES ('','vn','administrative','invoiceIn','isVatDeductible','0000-00-00 00:00:00','Update');
|
||||
INSERT IGNORE INTO `columns_priv` VALUES ('','vn','administrative','invoiceIn','bookEntried','0000-00-00 00:00:00','Update');
|
||||
INSERT IGNORE INTO `columns_priv` VALUES ('','vn','administrative','invoiceIn','siiTrascendencyInvoiceInFk','0000-00-00 00:00:00','Update');
|
||||
INSERT IGNORE INTO `columns_priv` VALUES ('','vn','administrative','invoiceIn','cplusTaxBreakFk','0000-00-00 00:00:00','Update');
|
||||
INSERT IGNORE INTO `columns_priv` VALUES ('','vn','administrative','invoiceIn','cplusSubjectOpFk','0000-00-00 00:00:00','Update');
|
||||
INSERT IGNORE INTO `columns_priv` VALUES ('','vn','administrative','invoiceIn','cplusRectificationTypeFk','0000-00-00 00:00:00','Update');
|
||||
INSERT IGNORE INTO `columns_priv` VALUES ('','vn','administrative','invoiceIn','siiTypeInvoiceInFk','0000-00-00 00:00:00','Update');
|
||||
INSERT IGNORE INTO `columns_priv` VALUES ('','vn','administrative','invoiceIn','operated','0000-00-00 00:00:00','Update');
|
||||
INSERT IGNORE INTO `columns_priv` VALUES ('','vn','administrative','invoiceIn','booked','0000-00-00 00:00:00','Update');
|
||||
INSERT IGNORE INTO `columns_priv` VALUES ('','vn','administrative','invoiceIn','docFk','0000-00-00 00:00:00','Update');
|
||||
INSERT IGNORE INTO `columns_priv` VALUES ('','vn','administrative','invoiceIn','companyFk','0000-00-00 00:00:00','Update');
|
||||
INSERT IGNORE INTO `columns_priv` VALUES ('','vn','administrative','invoiceIn','created','0000-00-00 00:00:00','Update');
|
||||
INSERT IGNORE INTO `columns_priv` VALUES ('','vn','administrative','invoiceIn','currencyFk','0000-00-00 00:00:00','Update');
|
||||
INSERT IGNORE INTO `columns_priv` VALUES ('','vn','administrative','invoiceIn','supplierRef','0000-00-00 00:00:00','Update');
|
||||
INSERT IGNORE INTO `columns_priv` VALUES ('','vn','administrative','invoiceIn','issued','0000-00-00 00:00:00','Update');
|
||||
INSERT IGNORE INTO `columns_priv` VALUES ('','vn','administrative','invoiceIn','supplierFk','0000-00-00 00:00:00','Update');
|
||||
INSERT IGNORE INTO `columns_priv` VALUES ('','vn','administrative','invoiceIn','serial','0000-00-00 00:00:00','Update');
|
||||
INSERT IGNORE INTO `columns_priv` VALUES ('','vn','administrative','invoiceIn','serialNumber','0000-00-00 00:00:00','Update');
|
||||
INSERT IGNORE INTO `columns_priv` VALUES ('','vn','administrative','invoiceIn','id','0000-00-00 00:00:00','Update');
|
||||
INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','routesMonitor','routeFk','0000-00-00 00:00:00','Update');
|
||||
INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','routesMonitor','name','0000-00-00 00:00:00','Update');
|
||||
INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','routesMonitor','beachFk','0000-00-00 00:00:00','Update');
|
||||
|
@ -1904,7 +1889,6 @@ INSERT IGNORE INTO `procs_priv` VALUES ('','vn','salesAssistant','invoiceoutboo
|
|||
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','ticket_gettax','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00');
|
||||
INSERT IGNORE INTO `procs_priv` VALUES ('','util','productionAssi','midnight','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00');
|
||||
INSERT IGNORE INTO `procs_priv` VALUES ('','dipole','employee','expedition_add','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00');
|
||||
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','ticketstateupdate','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00');
|
||||
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','coolerBoss','itempacking','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00');
|
||||
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','salesPerson','ticket_clone','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00');
|
||||
INSERT IGNORE INTO `procs_priv` VALUES ('','cache','employee','available_refresh','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00');
|
||||
|
@ -2151,6 +2135,7 @@ INSERT IGNORE INTO `procs_priv` VALUES ('','vn','artificialBoss','confection_co
|
|||
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','financial','remittance_calc','PROCEDURE','alexm@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
|
||||
INSERT IGNORE INTO `procs_priv` VALUES ('','util','developer','connection_kill','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
|
||||
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','financial','client_getRisk','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
|
||||
INSERT IGNORE INTO `procs_priv` VALUES ('','account','developer','user_hasRole','FUNCTION','root@localhost','Execute','0000-00-00 00:00:00');
|
||||
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','financialBoss','balance_create','PROCEDURE','jenkins@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
|
||||
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','hrBoss','balance_create','PROCEDURE','jenkins@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
|
||||
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','claimManager','buy_recalcPricesByEntry','PROCEDURE','jenkins@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
|
||||
|
@ -2215,7 +2200,7 @@ INSERT IGNORE INTO `global_priv` VALUES ('','logisticAssist','{\"access\":0,\"v
|
|||
INSERT IGNORE INTO `global_priv` VALUES ('','logisticBoss','{\"access\":0,\"version_id\":100707,\"is_role\":true}');
|
||||
INSERT IGNORE INTO `global_priv` VALUES ('','maintenance','{\"access\":0,\"version_id\":101106,\"is_role\":true}');
|
||||
INSERT IGNORE INTO `global_priv` VALUES ('','maintenanceBos','{\"access\":0,\"version_id\":101106,\"is_role\":true}');
|
||||
INSERT IGNORE INTO `global_priv` VALUES ('','maintenanceBoss','{\"access\":0,\"version_id\":100707,\"is_role\":true}');
|
||||
INSERT IGNORE INTO `global_priv` VALUES ('','maintenanceBoss','{\"access\":0,\"version_id\":101106,\"is_role\":true}');
|
||||
INSERT IGNORE INTO `global_priv` VALUES ('','manager','{\"access\":0,\"version_id\":100707,\"is_role\":true}');
|
||||
INSERT IGNORE INTO `global_priv` VALUES ('','marketing','{\"access\": 0, \"is_role\": true,\"version_id\":101106}');
|
||||
INSERT IGNORE INTO `global_priv` VALUES ('','marketingBoss','{\"access\":0,\"version_id\":101106,\"is_role\":true}');
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -2140,24 +2140,22 @@ BEGIN
|
|||
END IF;
|
||||
|
||||
IF !(OLD.started <=> NEW.started AND OLD.ended <=> NEW.ended) THEN
|
||||
|
||||
SELECT COUNT(*) > 0 INTO isOverlapping
|
||||
FROM business b
|
||||
WHERE (util.hasDateOverlapped(
|
||||
NEW.started,
|
||||
IFNULL(NEW.ended, b.started),
|
||||
b.started,
|
||||
IFNULL(b.ended, NEW.started))
|
||||
OR (NEW.ended <=> NULL AND b.ended <=> NULL))
|
||||
AND b.id <> OLD.id
|
||||
AND workerFk = OLD.workerFk;
|
||||
SELECT util.hasDateOverlapped(
|
||||
started,
|
||||
ended,
|
||||
NEW.started,
|
||||
IFNULL(NEW.ended, b.started)
|
||||
) isOverlapped INTO isOverlapping
|
||||
FROM vn.business b
|
||||
WHERE workerFk = NEW.workerFK
|
||||
AND b.id <> NEW.id
|
||||
ORDER BY isOverlapped DESC
|
||||
LIMIT 1;
|
||||
|
||||
IF isOverlapping THEN
|
||||
CALL util.throw ('IS_OVERLAPPING');
|
||||
END IF;
|
||||
|
||||
END IF;
|
||||
|
||||
END */;;
|
||||
DELIMITER ;
|
||||
/*!50003 SET sql_mode = @saved_sql_mode */ ;
|
||||
|
@ -2366,7 +2364,15 @@ trig:BEGIN
|
|||
LEAVE trig;
|
||||
END IF;
|
||||
|
||||
CALL entry_isEditable(OLD.entryFk);
|
||||
IF NOT (NEW.entryFk <=> OLD.entryFk) OR
|
||||
NOT (NEW.quantity <=> OLD.quantity) OR
|
||||
NOT (NEW.buyingValue <=> OLD.buyingValue) OR
|
||||
NOT (NEW.packing <=> OLD.packing)
|
||||
THEN
|
||||
|
||||
CALL entry_isEditable(OLD.entryFk);
|
||||
END IF;
|
||||
|
||||
SET NEW.editorFk = account.myUser_getId();
|
||||
|
||||
SELECT defaultEntry INTO vDefaultEntry
|
||||
|
@ -3010,6 +3016,52 @@ DELIMITER ;
|
|||
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
|
||||
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
|
||||
DELIMITER ;;
|
||||
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimRatio_afterInsert`
|
||||
AFTER INSERT ON `claimRatio`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
INSERT INTO clientRate(clientFk, `value`)
|
||||
VALUES(NEW.clientFk, NEW.priceIncreasing)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
`value` = VALUES(`value`);
|
||||
END */;;
|
||||
DELIMITER ;
|
||||
/*!50003 SET sql_mode = @saved_sql_mode */ ;
|
||||
/*!50003 SET character_set_client = @saved_cs_client */ ;
|
||||
/*!50003 SET character_set_results = @saved_cs_results */ ;
|
||||
/*!50003 SET collation_connection = @saved_col_connection */ ;
|
||||
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
|
||||
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
|
||||
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
|
||||
/*!50003 SET character_set_client = utf8mb4 */ ;
|
||||
/*!50003 SET character_set_results = utf8mb4 */ ;
|
||||
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
|
||||
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
|
||||
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
|
||||
DELIMITER ;;
|
||||
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimRatio_afterUpdate`
|
||||
AFTER UPDATE ON `claimRatio`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
INSERT INTO clientRate(clientFk, `value`)
|
||||
VALUES(NEW.clientFk, NEW.priceIncreasing)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
`value` = VALUES(`value`);
|
||||
END */;;
|
||||
DELIMITER ;
|
||||
/*!50003 SET sql_mode = @saved_sql_mode */ ;
|
||||
/*!50003 SET character_set_client = @saved_cs_client */ ;
|
||||
/*!50003 SET character_set_results = @saved_cs_results */ ;
|
||||
/*!50003 SET collation_connection = @saved_col_connection */ ;
|
||||
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
|
||||
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
|
||||
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
|
||||
/*!50003 SET character_set_client = utf8mb4 */ ;
|
||||
/*!50003 SET character_set_results = utf8mb4 */ ;
|
||||
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
|
||||
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
|
||||
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
|
||||
DELIMITER ;;
|
||||
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimState_beforeInsert`
|
||||
BEFORE INSERT ON `claimState`
|
||||
FOR EACH ROW
|
||||
|
@ -3198,11 +3250,11 @@ BEGIN
|
|||
END IF;
|
||||
END IF;
|
||||
|
||||
IF !(NEW.salesPersonFk <=> OLD.salesPersonFk) THEN
|
||||
IF NOT (NEW.salesPersonFk <=> OLD.salesPersonFk) THEN
|
||||
SET NEW.lastSalesPersonFk = IFNULL(NEW.salesPersonFk, OLD.salesPersonFk);
|
||||
END IF;
|
||||
|
||||
IF !(NEW.businessTypeFk <=> OLD.businessTypeFk) AND (NEW.businessTypeFk = 'individual' OR OLD.businessTypeFk = 'individual') THEN
|
||||
IF NOT (NEW.businessTypeFk <=> OLD.businessTypeFk) AND (NEW.businessTypeFk = 'individual' OR OLD.businessTypeFk = 'individual') THEN
|
||||
SET NEW.isTaxDataChecked = 0;
|
||||
END IF;
|
||||
END */;;
|
||||
|
@ -3224,13 +3276,36 @@ DELIMITER ;;
|
|||
AFTER UPDATE ON `client`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
IF !(NEW.defaultAddressFk <=> OLD.defaultAddressFk) THEN
|
||||
IF NOT (NEW.defaultAddressFk <=> OLD.defaultAddressFk) THEN
|
||||
UPDATE `address` SET isDefaultAddress = FALSE
|
||||
WHERE clientFk = NEW.id;
|
||||
|
||||
UPDATE `address` SET isDefaultAddress = TRUE
|
||||
WHERE id = NEW.defaultAddressFk;
|
||||
END IF;
|
||||
|
||||
IF NEW.id <> OLD.id
|
||||
OR NOT (NEW.provinceFk <=> OLD.provinceFk)
|
||||
OR NOT (NEW.socialName <=> OLD.socialName)
|
||||
OR NOT (NEW.street <=> OLD.street)
|
||||
OR NOT (NEW.accountingAccount <=> OLD.accountingAccount)
|
||||
OR NOT (NEW.isVies <=> OLD.isVies)
|
||||
OR NOT (NEW.fi <=> OLD.fi)
|
||||
OR NOT (NEW.postcode <=> OLD.postcode)
|
||||
OR NOT (NEW.city <=> OLD.city)
|
||||
OR NOT (NEW.countryFk <=> OLD.countryFk)
|
||||
OR NOT (NEW.taxTypeSageFk <=> OLD.taxTypeSageFk)
|
||||
OR NOT (NEW.transactionTypeSageFk <=> OLD.transactionTypeSageFk)
|
||||
OR NOT (NEW.email <=> OLD.email)
|
||||
OR NOT (NEW.iban <=> OLD.iban)
|
||||
OR NOT (NEW.phone <=> OLD.phone)
|
||||
OR NOT (NEW.mobile <=> OLD.mobile) THEN
|
||||
|
||||
UPDATE sage.clientSupplier
|
||||
SET isSync = FALSE
|
||||
WHERE idClientSupplier IN (NEW.id, OLD.id)
|
||||
AND `type` = 'C';
|
||||
END IF;
|
||||
END */;;
|
||||
DELIMITER ;
|
||||
/*!50003 SET sql_mode = @saved_sql_mode */ ;
|
||||
|
@ -4203,31 +4278,6 @@ DELIMITER ;
|
|||
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
|
||||
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
|
||||
DELIMITER ;;
|
||||
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`deviceProductionConfig_afterUpdate`
|
||||
AFTER UPDATE ON `deviceProductionConfig`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
IF NEW.isAllUsersAllowed = 1 OR NEW.isAllUsersAllowed = -1 THEN
|
||||
SET @username := (SELECT account.myUser_getName());
|
||||
INSERT INTO vn.mail (receiver, subject, body)
|
||||
VALUES ('cau@verdnatura.es', 'Se ha activado la autenticación sin restricciones en la app',
|
||||
CONCAT('El usuario ', @username,' ha habilitado la opción para que todos los usuarios puedan acceder a la app sin restricciones'));
|
||||
END IF;
|
||||
END */;;
|
||||
DELIMITER ;
|
||||
/*!50003 SET sql_mode = @saved_sql_mode */ ;
|
||||
/*!50003 SET character_set_client = @saved_cs_client */ ;
|
||||
/*!50003 SET character_set_results = @saved_cs_results */ ;
|
||||
/*!50003 SET collation_connection = @saved_col_connection */ ;
|
||||
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
|
||||
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
|
||||
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
|
||||
/*!50003 SET character_set_client = utf8mb4 */ ;
|
||||
/*!50003 SET character_set_results = utf8mb4 */ ;
|
||||
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
|
||||
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
|
||||
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
|
||||
DELIMITER ;;
|
||||
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`deviceProductionModels_beforeInsert`
|
||||
BEFORE INSERT ON `deviceProductionModels`
|
||||
FOR EACH ROW
|
||||
|
@ -4617,10 +4667,21 @@ BEGIN
|
|||
DECLARE vPrintedCount INT;
|
||||
DECLARE vHasDistinctWarehouses BOOL;
|
||||
DECLARE vTotalBuy INT;
|
||||
|
||||
IF NEW.isBooked = OLD.isBooked THEN
|
||||
|
||||
IF NEW.isBooked = OLD.isBooked AND (
|
||||
NOT (NEW.supplierFk <=> OLD.supplierFk) OR
|
||||
NOT (NEW.dated <=> OLD.dated) OR
|
||||
NOT (NEW.invoiceNumber <=> OLD.invoiceNumber) OR
|
||||
NOT (NEW.travelFk <=> OLD.travelFk) OR
|
||||
NOT (NEW.companyFk <=> OLD.companyFk) OR
|
||||
NOT (NEW.invoiceInFk <=> OLD.invoiceInFk) OR
|
||||
NOT (NEW.invoiceAmount <=> OLD.invoiceAmount) OR
|
||||
NOT (NEW.typeFk <=> OLD.typeFk)
|
||||
) THEN
|
||||
|
||||
CALL entry_isEditable(OLD.id);
|
||||
ELSE
|
||||
|
||||
IF NEW.isBooked THEN
|
||||
SELECT COUNT(*) INTO vTotalBuy
|
||||
FROM buy
|
||||
|
@ -4894,25 +4955,25 @@ DELIMITER ;;
|
|||
BEFORE INSERT ON `expedition`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
DECLARE intcounter INT;
|
||||
DECLARE vShipFk INT;
|
||||
DECLARE vMaxCounter INT;
|
||||
|
||||
SET NEW.editorFk = account.myUser_getId();
|
||||
|
||||
IF NEW.freightItemFk IS NOT NULL THEN
|
||||
IF NEW.freightItemFk IS NOT NULL THEN
|
||||
|
||||
UPDATE ticket SET packages = IFNULL(packages, 0) + 1 WHERE id = NEW.ticketFk;
|
||||
|
||||
SELECT IFNULL(MAX(counter),0) +1 INTO intcounter
|
||||
FROM expedition e
|
||||
INNER JOIN ticket t1 ON e.ticketFk = t1.id
|
||||
SELECT IFNULL(MAX(counter),0) + 1 INTO vMaxCounter
|
||||
FROM expedition e
|
||||
JOIN alertLevel al ON al.code = 'DELIVERED'
|
||||
JOIN ticket t1 ON e.ticketFk = t1.id
|
||||
LEFT JOIN ticketState ts ON ts.ticketFk = t1.id
|
||||
INNER JOIN ticket t2 ON t2.addressFk = t1.addressFk AND DATE(t2.shipped) = DATE(t1.shipped)
|
||||
JOIN ticket t2 ON t2.addressFk = t1.addressFk AND DATE(t2.shipped) = DATE(t1.shipped)
|
||||
AND t1.warehouseFk = t2.warehouseFk
|
||||
WHERE t2.id = NEW.ticketFk AND ts.alertLevel < 3 AND t1.companyFk = t2.companyFk
|
||||
WHERE t2.id = NEW.ticketFk AND ts.alertLevel < al.id AND t1.companyFk = t2.companyFk
|
||||
AND t1.agencyModeFk = t2.agencyModeFk;
|
||||
|
||||
SET NEW.`counter` = intcounter;
|
||||
SET NEW.`counter` = vMaxCounter;
|
||||
END IF;
|
||||
END */;;
|
||||
DELIMITER ;
|
||||
|
@ -8525,6 +8586,44 @@ DELIMITER ;
|
|||
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
|
||||
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
|
||||
DELIMITER ;;
|
||||
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`supplier_afterUpdate`
|
||||
BEFORE UPDATE ON `supplier`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
IF NEW.id <> OLD.id
|
||||
OR NOT (NEW.name <=> OLD.name)
|
||||
OR NOT (NEW.street <=> OLD.street)
|
||||
OR NOT (NEW.account <=> OLD.account)
|
||||
OR NOT (NEW.nif <=> OLD.nif)
|
||||
OR NOT (NEW.isVies <=> OLD.isVies)
|
||||
OR NOT (NEW.provinceFk <=> OLD.provinceFk)
|
||||
OR NOT (NEW.countryFk <=> OLD.countryFk)
|
||||
OR NOT (NEW.postCode <=> OLD.postCode)
|
||||
OR NOT (NEW.city <=> OLD.city)
|
||||
OR NOT (NEW.taxTypeSageFk <=> OLD.taxTypeSageFk)
|
||||
OR NOT (NEW.transactionTypeSageFk <=> OLD.transactionTypeSageFk)
|
||||
OR NOT (NEW.withholdingSageFk <=> OLD.withholdingSageFk) THEN
|
||||
|
||||
UPDATE sage.clientSupplier
|
||||
SET isSync = FALSE
|
||||
WHERE idClientSupplier IN (NEW.id, OLD.id)
|
||||
AND `type` = 'P';
|
||||
END IF;
|
||||
END */;;
|
||||
DELIMITER ;
|
||||
/*!50003 SET sql_mode = @saved_sql_mode */ ;
|
||||
/*!50003 SET character_set_client = @saved_cs_client */ ;
|
||||
/*!50003 SET character_set_results = @saved_cs_results */ ;
|
||||
/*!50003 SET collation_connection = @saved_col_connection */ ;
|
||||
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
|
||||
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
|
||||
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
|
||||
/*!50003 SET character_set_client = utf8mb4 */ ;
|
||||
/*!50003 SET character_set_results = utf8mb4 */ ;
|
||||
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
|
||||
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
|
||||
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
|
||||
DELIMITER ;;
|
||||
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`supplier_afterDelete`
|
||||
AFTER DELETE ON `supplier`
|
||||
FOR EACH ROW
|
||||
|
@ -10825,4 +10924,4 @@ USE `vn2008`;
|
|||
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
|
||||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
||||
|
||||
-- Dump completed on 2024-06-11 6:35:55
|
||||
-- Dump completed on 2024-06-25 7:27:06
|
||||
|
|
|
@ -839,9 +839,9 @@ INSERT INTO `vn`.`config`(`id`, `mdbServer`, `fakeEmail`, `defaultersMaxAmount`,
|
|||
INSERT INTO `vn`.`greugeType`(`id`, `name`, `code`)
|
||||
VALUES
|
||||
(1, 'Diff', 'diff'),
|
||||
(2, 'Recover', 'recover'),
|
||||
(2, 'Recovery', 'recovery'),
|
||||
(3, 'Mana', 'mana'),
|
||||
(4, 'Reclaim', 'reclaim'),
|
||||
(4, 'Claim', 'claim'),
|
||||
(5, 'Heritage', 'heritage'),
|
||||
(6, 'Miscellaneous', 'miscellaneous'),
|
||||
(7, 'Freight Pickup', 'freightPickUp');
|
||||
|
@ -1885,9 +1885,9 @@ INSERT INTO `vn`.`claimEnd`(`id`, `saleFk`, `claimFk`, `workerFk`, `claimDestina
|
|||
(1, 31, 4, 21, 2),
|
||||
(2, 32, 3, 21, 3);
|
||||
|
||||
INSERT INTO `vn`.`claimConfig`(`id`, `maxResponsibility`)
|
||||
INSERT INTO `vn`.`claimConfig`(`id`, `maxResponsibility`, `monthsToRefund`, `minShipped`)
|
||||
VALUES
|
||||
(1, 50);
|
||||
(1, 5, 4, '2016-10-01');
|
||||
|
||||
INSERT INTO `vn`.`claimRatio`(`clientFk`, `yearSale`, `claimAmount`, `claimingRate`, `priceIncreasing`, `packingRate`)
|
||||
VALUES
|
||||
|
@ -3845,6 +3845,13 @@ INSERT INTO `vn`.`ledgerCompany` SET
|
|||
INSERT INTO `vn`.`ledgerConfig` SET
|
||||
maxTolerance = 0.01;
|
||||
|
||||
|
||||
INSERT INTO vn.trainingCourse (workerFk,trainingCourseTypeFk,centerFk,started,ended,hasDiscount,hasDiploma)
|
||||
VALUES
|
||||
(9,2,1,'2018-06-20 00:00:00.000','2020-06-24 00:00:00.000',0,1),
|
||||
(9,1,2,'2018-06-20 00:00:00.000','2020-06-24 00:00:00.000',1,0),
|
||||
(9,2,2,'2018-06-20 00:00:00.000','2020-06-24 00:00:00.000',1,1);
|
||||
|
||||
INSERT INTO vn.sectorCollection
|
||||
SET id = 2,
|
||||
userFk = 18,
|
||||
|
@ -3882,3 +3889,11 @@ INSERT INTO `vn`.`calendarHolidays` (calendarHolidaysTypeFk, dated, calendarHoli
|
|||
(1, '2001-05-17', 1, 5),
|
||||
(1, '2001-05-18', 1, 5);
|
||||
|
||||
|
||||
INSERT INTO dipole.printer (id, description)
|
||||
VALUES(1, '');
|
||||
|
||||
INSERT INTO dipole.expedition_PrintOut (expeditionFk, ticketFk, addressFk, street, postalCode, city, shopName, isPrinted, created, printerFk, routeFk, parkingCode,
|
||||
truckName, clientFk, phone, province, agency, m3, workerCode, itemFk, quantity, longName, shelvingFk, comments)
|
||||
VALUES(1, 1, 0, ' ', ' ', ' ', ' ', 0, '2001-01-01 00:00:00', 1, 0, ' ', ' ', 0, NULL, '', NULL, 0.000, NULL, 10, NULL, NULL, 'NCC', NULL);
|
||||
|
||||
|
|
|
@ -1,167 +0,0 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bi`.`claim_ratio_routine`()
|
||||
BEGIN
|
||||
DECLARE vMonthToRefund INT DEFAULT 4;
|
||||
|
||||
/*
|
||||
* PAK 2015-11-20
|
||||
* Se trata de añadir a la tabla Greuges todos los
|
||||
* cargos que luego vamos a utilizar para calcular el recobro
|
||||
*/
|
||||
|
||||
-- Reclamaciones demasiado sensibles
|
||||
|
||||
INSERT INTO vn.greuge(shipped, clientFk, description,
|
||||
amount, greugeTypeFk, ticketFk)
|
||||
SELECT c.ticketCreated
|
||||
, c.clientFk
|
||||
, concat('Claim ', c.id,' : ', s.concept)
|
||||
,round( -1 * ((c.responsibility -1)/4) * s.quantity *
|
||||
s.price * (100 - s.discount) / 100, 2)
|
||||
, 4
|
||||
, s.ticketFk
|
||||
FROM vn.sale s
|
||||
JOIN vn.claimEnd ce ON ce.saleFk = s.id
|
||||
JOIN vn.claim c ON c.id = ce.claimFk
|
||||
WHERE ce.claimDestinationFk NOT IN (1,5)
|
||||
AND NOT ce.isGreuge
|
||||
AND c.claimStateFk = 3;
|
||||
|
||||
-- Reclamaciones que pasan a Maná
|
||||
|
||||
INSERT INTO vn.greuge(shipped, clientFk, description,
|
||||
amount, greugeTypeFk, ticketFk)
|
||||
SELECT c.ticketCreated
|
||||
, c.clientFk
|
||||
, concat('Claim_mana ',c.id,' : ', s.concept)
|
||||
,round( ((c.responsibility -1)/4) * s.quantity * s.price * (100 - s.discount) / 100, 2)
|
||||
,3
|
||||
,s.ticketFk
|
||||
FROM vn.sale s
|
||||
JOIN vn.claimEnd ce ON ce.saleFk = s.id
|
||||
JOIN vn.claim c ON c.id = ce.claimFk
|
||||
WHERE ce.claimDestinationFk NOT IN (1,5)
|
||||
AND NOT ce.isGreuge
|
||||
AND c.claimStateFk = 3
|
||||
AND c.isChargedToMana;
|
||||
|
||||
-- Marcamos para no repetir
|
||||
UPDATE vn.claimEnd ce
|
||||
JOIN vn.claim c ON c.id = ce.claimFk
|
||||
SET ce.isGreuge = TRUE
|
||||
WHERE ce.claimDestinationFk NOT IN (1,5)
|
||||
AND NOT ce.isGreuge
|
||||
AND c.claimStateFk = 3;
|
||||
|
||||
-- Recobros
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.ticket_list;
|
||||
CREATE TEMPORARY TABLE tmp.ticket_list
|
||||
(PRIMARY KEY (Id_Ticket))
|
||||
SELECT DISTINCT t.id Id_Ticket
|
||||
FROM vn.saleComponent sc
|
||||
JOIN vn.sale s ON sc.saleFk = s.id
|
||||
JOIN vn.ticket t ON t.id = s.ticketFk
|
||||
JOIN vn.ticketLastState ts ON ts.ticketFk = t.id
|
||||
JOIN vn.ticketTracking tt ON tt.id = ts.ticketTrackingFk
|
||||
JOIN vn.state st ON st.id = tt.stateFk
|
||||
JOIN vn.alertLevel al ON al.code = 'DELIVERED'
|
||||
WHERE sc.componentFk = 17
|
||||
AND sc.isGreuge = 0
|
||||
AND t.shipped >= '2016-10-01'
|
||||
AND t.shipped < util.VN_CURDATE()
|
||||
AND st.alertLevel >= al.id;
|
||||
|
||||
DELETE g.*
|
||||
FROM vn.greuge g
|
||||
JOIN tmp.ticket_list t ON g.ticketFk = t.Id_Ticket
|
||||
WHERE g.greugeTypeFk = 2;
|
||||
|
||||
INSERT INTO vn.greuge(clientFk, description, amount,shipped,
|
||||
greugeTypeFk, ticketFk)
|
||||
SELECT t.clientFk
|
||||
,concat('recobro ', s.ticketFk), - round(SUM(sc.value*s.quantity),2)
|
||||
AS dif,
|
||||
date(t.shipped)
|
||||
, 2
|
||||
,tt.Id_Ticket
|
||||
FROM vn.sale s
|
||||
JOIN vn.ticket t ON t.id = s.ticketFk
|
||||
JOIN tmp.ticket_list tt ON tt.Id_Ticket = t.id
|
||||
JOIN vn.saleComponent sc
|
||||
ON sc.saleFk = s.id AND sc.componentFk = 17
|
||||
GROUP BY t.id
|
||||
HAVING ABS(dif) > 1;
|
||||
|
||||
UPDATE vn.saleComponent sc
|
||||
JOIN vn.sale s ON s.id = sc.saleFk
|
||||
JOIN tmp.ticket_list tt ON tt.Id_Ticket = s.ticketFk
|
||||
SET sc.isGreuge = 1
|
||||
WHERE sc.componentFk = 17;
|
||||
|
||||
/*
|
||||
* Recalculamos la ratio de las reclamaciones, que luego
|
||||
* se va a utilizar en el recobro
|
||||
*/
|
||||
|
||||
REPLACE bi.claims_ratio(Id_Cliente, Consumo, Reclamaciones, Ratio, recobro)
|
||||
SELECT id, 0,0,0,0
|
||||
FROM vn.client;
|
||||
|
||||
REPLACE bi.claims_ratio(Id_Cliente, Consumo, Reclamaciones, Ratio, recobro)
|
||||
SELECT fm.Id_Cliente, 12 * fm.Consumo, Reclamaciones,
|
||||
round(Reclamaciones / (12*fm.Consumo),4), 0
|
||||
FROM bi.facturacion_media_anual fm
|
||||
LEFT JOIN(
|
||||
SELECT c.clientFk, round(sum(-1 * ((c.responsibility -1)/4) *
|
||||
s.quantity * s.price * (100 - s.discount) / 100))
|
||||
AS Reclamaciones
|
||||
FROM vn.sale s
|
||||
JOIN vn.claimEnd ce ON ce.saleFk = s.id
|
||||
JOIN vn.claim c ON c.id = ce.claimFk
|
||||
WHERE ce.claimDestinationFk NOT IN (1,5)
|
||||
AND c.claimStateFk = 3
|
||||
AND c.ticketCreated >= TIMESTAMPADD(YEAR, -1, util.VN_CURDATE())
|
||||
GROUP BY c.clientFk
|
||||
) claims ON claims.clientFk = fm.Id_Cliente;
|
||||
|
||||
|
||||
-- Calculamos el porcentaje del recobro para añadirlo al precio de venta
|
||||
UPDATE bi.claims_ratio cr
|
||||
JOIN (
|
||||
SELECT clientFk Id_Cliente, IFNULL(SUM(amount), 0) AS Greuge
|
||||
FROM vn.greuge
|
||||
WHERE shipped <= util.VN_CURDATE()
|
||||
GROUP BY clientFk
|
||||
) g ON g.Id_Cliente = cr.Id_Cliente
|
||||
SET recobro = GREATEST(0,round(IFNULL(Greuge, 0) /
|
||||
(IFNULL(Consumo, 0) * vMonthToRefund / 12 ) ,3));
|
||||
|
||||
-- Protección neonatos
|
||||
UPDATE bi.claims_ratio cr
|
||||
JOIN vn.firstTicketShipped fts ON fts.clientFk = cr.Id_Cliente
|
||||
SET recobro = 0, Ratio = 0
|
||||
WHERE fts.shipped > TIMESTAMPADD(MONTH,-1,util.VN_CURDATE());
|
||||
|
||||
-- CLIENTE 7983, JULIAN SUAU
|
||||
UPDATE bi.claims_ratio SET recobro = LEAST(0.05, recobro) WHERE Id_Cliente = 7983;
|
||||
|
||||
-- CLIENTE 4358
|
||||
UPDATE bi.claims_ratio SET recobro = GREATEST(0.05, recobro) WHERE Id_Cliente = 4358;
|
||||
|
||||
-- CLIENTE 5523, VERDECORA
|
||||
UPDATE bi.claims_ratio SET recobro = GREATEST(0.12, recobro) WHERE Id_Cliente = 5523;
|
||||
|
||||
-- CLIENTE 15979, SERVEIS VETERINARIS
|
||||
UPDATE bi.claims_ratio SET recobro = GREATEST(0.05, recobro) WHERE Id_Cliente = 15979;
|
||||
|
||||
-- CLIENTE 5189 i 8942, son de CSR i son el mateix client
|
||||
UPDATE bi.claims_ratio cr
|
||||
JOIN (SELECT sum(Consumo * recobro)/sum(Consumo) as recobro
|
||||
FROM bi.claims_ratio
|
||||
WHERE Id_Cliente IN ( 5189,8942)
|
||||
) sub
|
||||
SET cr.recobro = sub.recobro
|
||||
WHERE Id_Cliente IN ( 5189,8942);
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,22 +0,0 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE
|
||||
DEFINER=`root`@`localhost`
|
||||
EVENT `floranet`.`clean`
|
||||
ON SCHEDULE EVERY 1 DAY
|
||||
STARTS '2024-01-01 23:00:00.000'
|
||||
ON COMPLETION PRESERVE
|
||||
ENABLE
|
||||
DO
|
||||
BEGIN
|
||||
DELETE
|
||||
FROM `order`
|
||||
WHERE created < CURDATE()
|
||||
AND isPaid = FALSE;
|
||||
|
||||
DELETE c.*
|
||||
FROM catalogue c
|
||||
LEFT JOIN `order` o ON o.catalogueFk = c.id
|
||||
WHERE c.created < CURDATE()
|
||||
AND o.id IS NULL;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -21,7 +21,8 @@ BEGIN
|
|||
DECLARE vTransactionExportTaxFreeFk INT;
|
||||
DECLARE vSerialDua VARCHAR(1) DEFAULT 'D';
|
||||
DECLARE vInvoiceTypeInformativeCode VARCHAR(1);
|
||||
DECLARE vCountryCanariasCode, vCountryCeutaMelillaCode VARCHAR(2) ;
|
||||
DECLARE vCountryCanariasCode, vCountryCeutaMelillaCode VARCHAR(2);
|
||||
DECLARE vCompanyCode INT;
|
||||
|
||||
SELECT SiglaNacion INTO vCountryCanariasCode
|
||||
FROM Naciones
|
||||
|
@ -31,9 +32,6 @@ BEGIN
|
|||
FROM Naciones
|
||||
WHERE Nacion ='CEUTA Y MELILLA';
|
||||
|
||||
SELECT pendingServiceTransactionTypeFk INTO vDuaTransactionFk
|
||||
FROM config;
|
||||
|
||||
SELECT id INTO vTaxImportFk
|
||||
FROM taxType
|
||||
WHERE code = 'import21';
|
||||
|
@ -46,10 +44,14 @@ BEGIN
|
|||
FROM taxType
|
||||
WHERE code = 'import4';
|
||||
|
||||
SELECT definitiveExportTransactionTypeFk INTO vTransactionExportFk
|
||||
FROM config;
|
||||
|
||||
SELECT shipmentTransactionTypeFk INTO vTransactionExportTaxFreeFk
|
||||
SELECT shipmentTransactionTypeFk,
|
||||
definitiveExportTransactionTypeFk,
|
||||
pendingServiceTransactionTypeFk,
|
||||
company_getCode(vCompanyFk)
|
||||
INTO vTransactionExportTaxFreeFk,
|
||||
vTransactionExportFk,
|
||||
vDuaTransactionFk,
|
||||
vCompanyCode
|
||||
FROM config;
|
||||
|
||||
SELECT codeSage INTO vInvoiceTypeInformativeCode
|
||||
|
@ -64,8 +66,6 @@ BEGIN
|
|||
WHERE enlazadoSage = FALSE
|
||||
AND Asiento <> 1 ;
|
||||
|
||||
CALL clientSupplier_add(vCompanyFk);
|
||||
CALL pgc_add(vCompanyFk);
|
||||
CALL invoiceOut_manager(vYear, vCompanyFk);
|
||||
CALL invoiceIn_manager(vYear, vCompanyFk);
|
||||
|
||||
|
@ -158,7 +158,7 @@ BEGIN
|
|||
)
|
||||
SELECT 'EN' TipoEntrada,
|
||||
YEAR(x.FECHA) Ejercicio,
|
||||
company_getCode(vCompanyFk) AS CodigoEmpresa,
|
||||
vCompanyCode CodigoEmpresa,
|
||||
x.ASIEN Asiento,
|
||||
IF(EURODEBE <> 0 OR (EURODEBE = 0 AND EUROHABER IS NULL),
|
||||
'D', 'H') CargoAbono,
|
||||
|
@ -291,20 +291,6 @@ BEGIN
|
|||
WHERE m.CargoAbono = 'D'
|
||||
AND m.enlazadoSage = FALSE;
|
||||
|
||||
-- Elimina cuentas de cliente/proveedor que no se utilizarán en la importación
|
||||
DELETE cp
|
||||
FROM clientesProveedores cp
|
||||
LEFT JOIN movConta mc ON mc.codigoCuenta = cp.codigoCuenta
|
||||
AND mc.enlazadoSage = FALSE
|
||||
WHERE mc.codigoCuenta IS NULL;
|
||||
|
||||
-- Elimina cuentas contables que no se utilizarán en la importación
|
||||
DELETE pc
|
||||
FROM planCuentasPGC pc
|
||||
LEFT JOIN movConta mc ON mc.codigoCuenta = pc.codigoCuenta
|
||||
AND mc.enlazadoSage = FALSE
|
||||
WHERE mc.codigoCuenta IS NULL;
|
||||
|
||||
-- DUAS
|
||||
UPDATE movConta mci
|
||||
JOIN vn.XDiario x ON x.ASIEN = mci.Asiento
|
||||
|
@ -411,5 +397,55 @@ BEGIN
|
|||
AND importeDivisa > 0
|
||||
AND ImporteAsiento < 0;
|
||||
|
||||
CREATE OR REPLACE TEMPORARY TABLE tmp.clientSupplier
|
||||
(INDEX(idClientSupplier, `type`))
|
||||
ENGINE = MEMORY
|
||||
WITH client AS(
|
||||
SELECT DISTINCT c.id
|
||||
FROM sage.movConta mc
|
||||
JOIN vn.client c ON c.accountingAccount = mc.CodigoCuenta
|
||||
WHERE NOT enlazadoSage
|
||||
),supplier AS(
|
||||
SELECT DISTINCT s.id
|
||||
FROM sage.movConta mc
|
||||
JOIN vn.supplier s ON s.account = mc.CodigoCuenta
|
||||
WHERE NOT enlazadoSage
|
||||
),clientSupplierSync AS(
|
||||
SELECT idClientSupplier, `type`
|
||||
FROM sage.clientSupplier cs
|
||||
WHERE isSync
|
||||
)
|
||||
SELECT idClientSupplier, `type`
|
||||
FROM sage.clientSupplier cs
|
||||
WHERE NOT isSync
|
||||
UNION
|
||||
SELECT id, 'C'
|
||||
FROM client c
|
||||
LEFT JOIN clientSupplierSync cs ON cs.idClientSupplier = c.id
|
||||
AND cs.Type ='C'
|
||||
WHERE cs.idClientSupplier IS NULL
|
||||
UNION
|
||||
SELECT id, 'P'
|
||||
FROM supplier s
|
||||
LEFT JOIN clientSupplierSync cs ON cs.idClientSupplier = s.id
|
||||
AND cs.Type ='P'
|
||||
WHERE cs.idClientSupplier IS NULL;
|
||||
|
||||
CALL clientSupplier_add(vCompanyFk);
|
||||
|
||||
INSERT IGNORE INTO sage.clientSupplier (companyFk, `type`, idClientSupplier, isSync)
|
||||
SELECT vCompanyCode, `type`, idClientSupplier, FALSE
|
||||
FROM tmp.clientSupplier;
|
||||
|
||||
DROP TEMPORARY TABLE tmp.clientSupplier;
|
||||
|
||||
CALL pgc_add(vCompanyFk);
|
||||
-- Elimina cuentas contables que no se utilizarán en la importación
|
||||
DELETE pc
|
||||
FROM planCuentasPGC pc
|
||||
LEFT JOIN movConta mc ON mc.codigoCuenta = pc.codigoCuenta
|
||||
AND mc.enlazadoSage = FALSE
|
||||
WHERE mc.codigoCuenta IS NULL;
|
||||
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -1,11 +1,16 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `sage`.`clientSupplier_add`(vCompanyFk INT)
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `sage`.`clientSupplier_add`(
|
||||
vCompanyFk INT
|
||||
)
|
||||
BEGIN
|
||||
/**
|
||||
* Prepara los datos de clientes y proveedores para exportarlos a Sage
|
||||
* @vCompanyFk Empresa dela que se quiere trasladar datos
|
||||
* Inserta en la tabla sage.clientesProveedores los datos de clientes y proveedores
|
||||
* que se actualizaran o se daran de alta en Sage
|
||||
* @vCompanyFk Id de empresa
|
||||
* @table tmp.clientSupplier(idClientSupplier, `type`)
|
||||
*/
|
||||
DECLARE vCountryCeutaMelillaFk INT;
|
||||
DECLARE vCompanyCode INT DEFAULT company_getCode(vCompanyFk);
|
||||
DECLARE vCountryCanariasCode, vCountryCeutaMelillaCode VARCHAR(2);
|
||||
|
||||
SELECT SiglaNacion INTO vCountryCanariasCode
|
||||
|
@ -45,7 +50,7 @@ BEGIN
|
|||
Email1,
|
||||
iban)
|
||||
SELECT
|
||||
company_getCode(vCompanyFk),
|
||||
vCompanyCode,
|
||||
'C',
|
||||
c.id,
|
||||
c.socialName,
|
||||
|
@ -53,7 +58,7 @@ BEGIN
|
|||
IFNULL(c.street, ''),
|
||||
c.accountingAccount,
|
||||
@fi := IF(cu.code = LEFT(TRIM(c.fi), 2) AND c.isVies, MID(TRIM(c.fi), 3, LENGTH(TRIM(c.fi))-1), TRIM(c.fi)),
|
||||
IF(c.isVies, CONCAT(IFNULL(cu.viesCode,cu.code), @fi ), TRIM(c.fi)),
|
||||
IF(c.isVies, CONCAT(IFNULL(cu.viesCode,cu.code), @fi ), TRIM(c.fi)),
|
||||
IFNULL(c.postcode, ''),
|
||||
IFNULL(c.city, ''),
|
||||
IFNULL(pr.CodigoProvincia, ''),
|
||||
|
@ -75,15 +80,14 @@ BEGIN
|
|||
IFNULL(SUBSTR(c.email, 1, LOCATE(',', CONCAT(c.email, ','))-1), ''),
|
||||
IFNULL(c.iban, '')
|
||||
FROM vn.`client` c
|
||||
JOIN clientLastTwoMonths clm ON clm.clientFk = c.id
|
||||
JOIN tmp.clientSupplier cs ON cs.idClientSupplier = c.id
|
||||
LEFT JOIN vn.country cu ON cu.id = c.countryFk
|
||||
LEFT JOIN Naciones n ON n.countryFk = cu.id
|
||||
LEFT JOIN vn.province p ON p.id = c.provinceFk
|
||||
LEFT JOIN Provincias pr ON pr.provinceFk = p.id
|
||||
WHERE c.isRelevant
|
||||
AND clm.companyFk = vCompanyFk
|
||||
WHERE cs.type = 'C'
|
||||
UNION ALL
|
||||
SELECT company_getCode(vCompanyFk),
|
||||
SELECT vCompanyCode,
|
||||
'P',
|
||||
s.id,
|
||||
s.name,
|
||||
|
@ -107,18 +111,16 @@ BEGIN
|
|||
IFNULL(s.transactionTypeSageFk, 0),
|
||||
IFNULL(s.withholdingSageFk, '0'),
|
||||
IFNULL(SUBSTR(sc.email, 1, (COALESCE(NULLIF(LOCATE(',', sc.email), 0), 99) - 1)), ''),
|
||||
IFNULL(iban, '')
|
||||
IFNULL(sa.iban, '')
|
||||
FROM vn.supplier s
|
||||
JOIN supplierLastThreeMonths pl ON pl.supplierFk = s.id
|
||||
JOIN tmp.clientSupplier cs ON cs.idClientSupplier = s.id
|
||||
LEFT JOIN vn.country co ON co.id = s.countryFk
|
||||
LEFT JOIN Naciones n ON n.countryFk = co.id
|
||||
LEFT JOIN vn.province p ON p.id = s.provinceFk
|
||||
LEFT JOIN Provincias pr ON pr.provinceFk = p.id
|
||||
LEFT JOIN vn.supplierContact sc ON sc.supplierFk = s.id
|
||||
LEFT JOIN vn.supplierAccount sa ON sa.supplierFk = s.id
|
||||
WHERE pl.companyFk = vCompanyFk AND
|
||||
s.isActive AND
|
||||
s.nif <> ''
|
||||
GROUP BY pl.supplierFk, pl.companyFk;
|
||||
WHERE cs.type = 'P'
|
||||
GROUP BY s.id;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `vn`.`itemShelvingSale_doReserve`
|
||||
ON SCHEDULE EVERY 15 SECOND
|
||||
STARTS '2023-10-16 00:00:00'
|
||||
ON COMPLETION PRESERVE
|
||||
ENABLE
|
||||
DO CALL vn.itemShelvingSale_doReserve$$
|
||||
DELIMITER ;
|
|
@ -1,64 +1,44 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`ticket_get`(vParamFk INT)
|
||||
RETURNS int(11)
|
||||
RETURNS INT(11)
|
||||
NOT DETERMINISTIC
|
||||
READS SQL DATA
|
||||
proc:BEGIN
|
||||
|
||||
/* Devuelve el número de ticket o collection consultando en varias tablas posibles
|
||||
*
|
||||
* @param vParamFk Número a validar
|
||||
* @return vValidFk Identificador validado
|
||||
*/
|
||||
|
||||
DECLARE vValidFk INT;
|
||||
BEGIN
|
||||
/**
|
||||
* Devuelve el número de ticket / collection / sectorCollection consultando
|
||||
* en que tabla se encuantra en la última semana
|
||||
*
|
||||
* @param vParamFk Número a validar
|
||||
* @return vReturn Identificador validado
|
||||
*/
|
||||
DECLARE vReturn INT DEFAULT NULL;
|
||||
DECLARE vDated DATE;
|
||||
|
||||
-- Tabla vn.saleGroup
|
||||
SELECT s.ticketFk INTO vValidFk
|
||||
FROM vn.sale s
|
||||
JOIN vn.saleGroupDetail sgd ON sgd.saleFk = s.id
|
||||
JOIN vn.saleGroup sg ON sg.id = sgd.saleGroupFk
|
||||
WHERE sg.id = vParamFk
|
||||
AND sg.created > TIMESTAMPADD(WEEK,-1, util.VN_CURDATE())
|
||||
LIMIT 1;
|
||||
|
||||
IF vValidFk THEN
|
||||
|
||||
RETURN vValidFk;
|
||||
|
||||
LEAVE proc;
|
||||
|
||||
END IF;
|
||||
SET vDated = util.VN_CURDATE() - INTERVAL 1 WEEK;
|
||||
|
||||
-- Tabla vn.collection
|
||||
SELECT c.id INTO vValidFk
|
||||
FROM vn.collection c
|
||||
WHERE c.id = vParamFk
|
||||
AND c.created > TIMESTAMPADD(WEEK,-1, util.VN_CURDATE());
|
||||
|
||||
IF vValidFk THEN
|
||||
|
||||
RETURN vValidFk;
|
||||
|
||||
LEAVE proc;
|
||||
|
||||
END IF;
|
||||
SELECT COALESCE(
|
||||
(SELECT s.ticketFk
|
||||
FROM sale s
|
||||
JOIN saleGroupDetail sgd ON sgd.saleFk = s.id
|
||||
JOIN saleGroup sg ON sg.id = sgd.saleGroupFk
|
||||
WHERE sg.id = vParamFk
|
||||
AND sg.created > vDated
|
||||
LIMIT 1),
|
||||
(SELECT c.id
|
||||
FROM collection c
|
||||
WHERE c.id = vParamFk
|
||||
AND c.created > vDated),
|
||||
(SELECT id
|
||||
FROM ticket
|
||||
WHERE id = vParamFk
|
||||
AND shipped > vDated),
|
||||
(SELECT id
|
||||
FROM sectorCollection
|
||||
WHERE id = vParamFk
|
||||
AND created > vDated)
|
||||
) INTO vReturn;
|
||||
|
||||
-- Tabla vn.ticket
|
||||
SELECT t.id INTO vValidFk
|
||||
FROM vn.ticket t
|
||||
WHERE t.id = vParamFk
|
||||
AND t.shipped > TIMESTAMPADD(WEEK,-1, util.VN_CURDATE());
|
||||
|
||||
IF vValidFk THEN
|
||||
|
||||
RETURN vValidFk;
|
||||
|
||||
LEAVE proc;
|
||||
|
||||
END IF;
|
||||
|
||||
RETURN NULL;
|
||||
RETURN vReturn;
|
||||
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -0,0 +1,190 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`claimRatio_add`()
|
||||
BEGIN
|
||||
/*
|
||||
* Añade a la tabla greuges todos los cargos necesario y
|
||||
* que luego lo utilizamos para calcular el recobro.
|
||||
*/
|
||||
DECLARE vMonthToRefund INT
|
||||
DEFAULT (SELECT monthsToRefund FROM claimConfig);
|
||||
DECLARE vRecoveryGreugeType INT
|
||||
DEFAULT (SELECT id FROM greugeType WHERE code = 'recovery');
|
||||
DECLARE vManaGreugeType INT
|
||||
DEFAULT (SELECT id FROM greugeType WHERE code = 'mana');
|
||||
DECLARE vClaimGreugeType INT
|
||||
DEFAULT (SELECT id FROM greugeType WHERE code = 'claim');
|
||||
DECLARE vDebtComponentType INT
|
||||
DEFAULT (SELECT id FROM component WHERE code = 'debtCollection');
|
||||
|
||||
IF vMonthToRefund IS NULL
|
||||
OR vRecoveryGreugeType IS NULL
|
||||
OR vManaGreugeType IS NULL
|
||||
OR vClaimGreugeType IS NULL
|
||||
OR vDebtComponentType IS NULL THEN
|
||||
|
||||
CALL util.throw('Required variables not found');
|
||||
END IF;
|
||||
|
||||
-- Reclamaciones demasiado sensibles
|
||||
INSERT INTO greuge(
|
||||
shipped,
|
||||
clientFk,
|
||||
`description`,
|
||||
amount,
|
||||
greugeTypeFk,
|
||||
ticketFk
|
||||
)
|
||||
SELECT c.ticketCreated,
|
||||
c.clientFk,
|
||||
CONCAT('Claim ', c.id,' : ', s.concept),
|
||||
ROUND(-1 * ((c.responsibility - 1) / 4) * s.quantity *
|
||||
s.price * (100 - s.discount) / 100, 2),
|
||||
vClaimGreugeType,
|
||||
s.ticketFk
|
||||
FROM sale s
|
||||
JOIN claimEnd ce ON ce.saleFk = s.id
|
||||
JOIN claimDestination cd ON cd.id = ce.claimDestinationFk
|
||||
JOIN claim c ON c.id = ce.claimFk
|
||||
JOIN claimState cs ON cs.id = c.claimStateFk
|
||||
WHERE cd.description NOT IN ('Bueno', 'Corregido')
|
||||
AND NOT ce.isGreuge
|
||||
AND cs.code = 'resolved';
|
||||
|
||||
-- Reclamaciones que pasan a Maná
|
||||
INSERT INTO greuge(
|
||||
shipped,
|
||||
clientFk,
|
||||
`description`,
|
||||
amount,
|
||||
greugeTypeFk,
|
||||
ticketFk
|
||||
)
|
||||
SELECT c.ticketCreated,
|
||||
c.clientFk,
|
||||
CONCAT('Claim_mana ', c.id,' : ', s.concept),
|
||||
ROUND(((c.responsibility - 1) / 4) * s.quantity *
|
||||
s.price * (100 - s.discount) / 100, 2),
|
||||
vManaGreugeType,
|
||||
s.ticketFk
|
||||
FROM sale s
|
||||
JOIN claimEnd ce ON ce.saleFk = s.id
|
||||
JOIN claimDestination cd ON cd.id = ce.claimDestinationFk
|
||||
JOIN claim c ON c.id = ce.claimFk
|
||||
JOIN claimState cs ON cs.id = c.claimStateFk
|
||||
WHERE cd.description NOT IN ('Bueno', 'Corregido')
|
||||
AND NOT ce.isGreuge
|
||||
AND cs.code = 'resolved'
|
||||
AND c.isChargedToMana;
|
||||
|
||||
-- Marcamos para no repetir
|
||||
UPDATE claimEnd ce
|
||||
JOIN claimDestination cd ON cd.id = ce.claimDestinationFk
|
||||
JOIN claim c ON c.id = ce.claimFk
|
||||
JOIN claimState cs ON cs.id = c.claimStateFk
|
||||
SET ce.isGreuge = TRUE
|
||||
WHERE cd.description NOT IN ('Bueno', 'Corregido')
|
||||
AND NOT ce.isGreuge
|
||||
AND cs.code = 'resolved';
|
||||
|
||||
-- Recobros
|
||||
CREATE OR REPLACE TEMPORARY TABLE tTicketList
|
||||
(PRIMARY KEY (ticketFk))
|
||||
ENGINE = MEMORY
|
||||
SELECT DISTINCT s.ticketFk
|
||||
FROM saleComponent sc
|
||||
JOIN sale s ON sc.saleFk = s.id
|
||||
JOIN ticket t ON t.id = s.ticketFk
|
||||
JOIN ticketLastState ts ON ts.ticketFk = t.id
|
||||
JOIN ticketTracking tt ON tt.id = ts.ticketTrackingFk
|
||||
JOIN state st ON st.id = tt.stateFk
|
||||
JOIN alertLevel al ON al.id = st.alertLevel
|
||||
WHERE sc.componentFk = vDebtComponentType
|
||||
AND NOT sc.isGreuge
|
||||
AND t.shipped >= (SELECT minShipped FROM claimConfig)
|
||||
AND t.shipped < util.VN_CURDATE()
|
||||
AND al.code = 'DELIVERED';
|
||||
|
||||
DELETE g.*
|
||||
FROM greuge g
|
||||
JOIN tTicketList t ON t.ticketFk = g.ticketFk
|
||||
WHERE g.greugeTypeFk = vRecoveryGreugeType;
|
||||
|
||||
INSERT INTO greuge(
|
||||
clientFk,
|
||||
`description`,
|
||||
amount,
|
||||
shipped,
|
||||
greugeTypeFk,
|
||||
ticketFk
|
||||
)
|
||||
SELECT t.clientFk,
|
||||
'Recobro',
|
||||
- ROUND(SUM(sc.value * s.quantity), 2) dif,
|
||||
DATE(t.shipped),
|
||||
vRecoveryGreugeType,
|
||||
tl.ticketFk
|
||||
FROM sale s
|
||||
JOIN ticket t ON t.id = s.ticketFk
|
||||
JOIN tTicketList tl ON tl.ticketFk = t.id
|
||||
JOIN saleComponent sc ON sc.saleFk = s.id
|
||||
AND sc.componentFk = vDebtComponentType
|
||||
GROUP BY t.id
|
||||
HAVING ABS(dif) > 1;
|
||||
|
||||
UPDATE saleComponent sc
|
||||
JOIN sale s ON s.id = sc.saleFk
|
||||
JOIN tTicketList tl ON tl.ticketFk = s.ticketFk
|
||||
SET sc.isGreuge = TRUE
|
||||
WHERE sc.componentFk = vDebtComponentType;
|
||||
|
||||
REPLACE claimRatio(
|
||||
clientFk,
|
||||
yearSale,
|
||||
claimAmount,
|
||||
claimingRate,
|
||||
priceIncreasing
|
||||
)
|
||||
SELECT c.id,
|
||||
12 * cac.invoiced,
|
||||
totalClaims,
|
||||
ROUND(totalClaims / (12 * cac.invoiced), 4),
|
||||
0
|
||||
FROM client c
|
||||
LEFT JOIN bs.clientAnnualConsumption cac ON cac.clientFk = c.id
|
||||
LEFT JOIN (
|
||||
SELECT c.clientFk,
|
||||
ROUND(SUM(-1 * ((c.responsibility - 1) / 4) *
|
||||
s.quantity * s.price * (100 - s.discount)
|
||||
/ 100)) totalClaims
|
||||
FROM sale s
|
||||
JOIN claimEnd ce ON ce.saleFk = s.id
|
||||
JOIN claimDestination cd ON cd.id = ce.claimDestinationFk
|
||||
JOIN claim c ON c.id = ce.claimFk
|
||||
JOIN claimState cs ON cs.id = c.claimStateFk
|
||||
WHERE cd.description NOT IN ('Bueno', 'Corregido')
|
||||
AND cs.code = 'resolved'
|
||||
AND c.ticketCreated >= util.VN_CURDATE() - INTERVAL 1 YEAR
|
||||
GROUP BY c.clientFk
|
||||
) sub ON sub.clientFk = c.id;
|
||||
|
||||
-- Calculamos el porcentaje del recobro para añadirlo al precio de venta
|
||||
UPDATE claimRatio cr
|
||||
JOIN (
|
||||
SELECT clientFk, IFNULL(SUM(amount), 0) greuge
|
||||
FROM greuge
|
||||
WHERE shipped <= util.VN_CURDATE()
|
||||
GROUP BY clientFk
|
||||
) sub ON sub.clientFk = cr.clientFk
|
||||
SET cr.priceIncreasing = GREATEST(0, ROUND(IFNULL(sub.greuge, 0) /
|
||||
(IFNULL(cr.yearSale, 0) * vMonthToRefund / 12 ), 3));
|
||||
|
||||
-- Protección neonatos
|
||||
UPDATE claimRatio cr
|
||||
JOIN firstTicketShipped fts ON fts.clientFk = cr.clientFk
|
||||
SET cr.priceIncreasing = 0,
|
||||
cr.claimingRate = 0
|
||||
WHERE fts.shipped > util.VN_CURDATE() - INTERVAL 1 MONTH;
|
||||
|
||||
DROP TEMPORARY TABLE tTicketList;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -0,0 +1,89 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`collection_addWithReservation`(
|
||||
vItemFk INT,
|
||||
vQuantity INT,
|
||||
vTicketFk INT,
|
||||
vSaleGroupFk INT
|
||||
)
|
||||
BEGIN
|
||||
/**
|
||||
* En el ámbito de las colecciones se añade una línea de sale a un ticket
|
||||
* de una colección en caso de tener disponible y se realiza la reserva.
|
||||
*
|
||||
* @param vItemFk id of item
|
||||
* @param vQuantity quantity to be added to the ticket
|
||||
* @param vTicketFk ticket to which the sales line is added
|
||||
* @param vSaleGroupFk saleGroupFk id to add saleGroupDetail
|
||||
*/
|
||||
|
||||
DECLARE vWarehouseFk INT;
|
||||
DECLARE vCacheAvailableFk INT;
|
||||
DECLARE vAvailable INT;
|
||||
DECLARE vSaleFk INT;
|
||||
DECLARE vConcept VARCHAR(50);
|
||||
DECLARE vItemName VARCHAR(50);
|
||||
DECLARE vHasThrow BOOLEAN DEFAULT FALSE;
|
||||
|
||||
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
||||
BEGIN
|
||||
ROLLBACK;
|
||||
RESIGNAL;
|
||||
END;
|
||||
|
||||
SELECT t.warehouseFk INTO vWarehouseFk
|
||||
FROM ticket t
|
||||
JOIN ticketCollection tc ON tc.ticketFk = t.id
|
||||
WHERE t.id = vTicketFk;
|
||||
|
||||
CALL cache.available_refresh(
|
||||
vCacheAvailableFk,
|
||||
FALSE,
|
||||
vWarehouseFk,
|
||||
util.VN_CURDATE());
|
||||
|
||||
SELECT available INTO vAvailable
|
||||
FROM cache.available
|
||||
WHERE calc_id = vCacheAvailableFk
|
||||
AND item_id = vItemFk;
|
||||
|
||||
IF vAvailable < vQuantity THEN
|
||||
SET vHasThrow = TRUE;
|
||||
ELSE
|
||||
SELECT `name`,
|
||||
CONCAT(getUser(), ' ', DATE_FORMAT(util.VN_NOW(), '%H:%i'), ' ', name)
|
||||
INTO vItemName, vConcept
|
||||
FROM item
|
||||
WHERE id = vItemFk;
|
||||
|
||||
START TRANSACTION;
|
||||
|
||||
INSERT INTO sale
|
||||
SET itemFk = vItemFk,
|
||||
ticketFk = vTicketFk,
|
||||
concept = vConcept,
|
||||
quantity = vQuantity,
|
||||
isAdded = TRUE;
|
||||
|
||||
SELECT LAST_INSERT_ID() INTO vSaleFk;
|
||||
|
||||
CALL sale_calculateComponent(vSaleFk, NULL);
|
||||
CALL itemShelvingSale_addBySale(vSaleFk);
|
||||
|
||||
IF NOT EXISTS (SELECT TRUE FROM itemShelvingSale WHERE saleFk = vSaleFk LIMIT 1) THEN
|
||||
SET vHasThrow = TRUE;
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
IF vHasThrow THEN
|
||||
CALL util.throw("There is no available for the selected item");
|
||||
END IF;
|
||||
|
||||
IF vSaleGroupFk THEN
|
||||
INSERT INTO saleGroupDetail
|
||||
SET saleFk = vSaleFk,
|
||||
saleGroupFk = vSaleGroupFk;
|
||||
END IF;
|
||||
|
||||
COMMIT;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -13,12 +13,39 @@ BEGIN
|
|||
* @param vCollectionFk Id de colección
|
||||
*/
|
||||
DECLARE vHasTooMuchCollections BOOL;
|
||||
DECLARE vItemPackingTypeFk VARCHAR(1);
|
||||
DECLARE vWarehouseFk INT;
|
||||
DECLARE vLockName VARCHAR(215);
|
||||
DECLARE vLockTime INT DEFAULT 30;
|
||||
DECLARE vErrorNumber INT;
|
||||
DECLARE vErrorMsg TEXT;
|
||||
|
||||
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
||||
BEGIN
|
||||
GET DIAGNOSTICS CONDITION 1
|
||||
vErrorNumber = MYSQL_ERRNO,
|
||||
vErrorMsg = MESSAGE_TEXT;
|
||||
|
||||
IF vLockName IS NOT NULL THEN
|
||||
DO RELEASE_LOCK(vLockName);
|
||||
CALL util.debugAdd('collection_assign', JSON_OBJECT(
|
||||
'errorNumber', vErrorNumber,
|
||||
'errorMsg', vErrorMsg,
|
||||
'lockName', vLockName,
|
||||
'userFk', vUserFk
|
||||
)); -- Tmp
|
||||
END IF;
|
||||
|
||||
RESIGNAL;
|
||||
END;
|
||||
|
||||
-- Si hay colecciones sin terminar, sale del proceso
|
||||
CALL collection_get(vUserFk);
|
||||
|
||||
SELECT (pc.maxNotReadyCollections - COUNT(*)) <= 0
|
||||
INTO vHasTooMuchCollections
|
||||
SELECT (pc.maxNotReadyCollections - COUNT(*)) <= 0,
|
||||
collection_assign_lockname
|
||||
INTO vHasTooMuchCollections,
|
||||
vLockName
|
||||
FROM productionConfig pc
|
||||
LEFT JOIN tCollection ON TRUE;
|
||||
|
||||
|
@ -28,6 +55,21 @@ BEGIN
|
|||
CALL util.throw('Hay colecciones pendientes');
|
||||
END IF;
|
||||
|
||||
SELECT warehouseFk, itemPackingTypeFk
|
||||
INTO vWarehouseFk, vItemPackingTypeFk
|
||||
FROM operator
|
||||
WHERE workerFk = vUserFk;
|
||||
|
||||
SET vLockName = CONCAT_WS('/',
|
||||
vLockName,
|
||||
vWarehouseFk,
|
||||
vItemPackingTypeFk
|
||||
);
|
||||
|
||||
IF NOT GET_LOCK(vLockName, vLockTime) THEN
|
||||
CALL util.throw(CONCAT('Cannot get lock: ', vLockName));
|
||||
END IF;
|
||||
|
||||
-- Se eliminan las colecciones sin asignar que estan obsoletas
|
||||
INSERT INTO ticketTracking(stateFk, ticketFk)
|
||||
SELECT s.id, tc.ticketFk
|
||||
|
@ -35,7 +77,7 @@ BEGIN
|
|||
JOIN ticketCollection tc ON tc.collectionFk = c.id
|
||||
JOIN `state` s ON s.code = 'PRINTED_AUTO'
|
||||
JOIN productionConfig pc
|
||||
WHERE c.workerFk IS NULL
|
||||
WHERE c.workerFk IS NULL
|
||||
AND TIMEDIFF(util.VN_NOW(), c.created) > pc.maxNotAssignedCollectionLifeTime;
|
||||
|
||||
DELETE c.*
|
||||
|
@ -75,5 +117,7 @@ BEGIN
|
|||
UPDATE `collection`
|
||||
SET workerFk = vUserFk
|
||||
WHERE id = vCollectionFk;
|
||||
|
||||
DO RELEASE_LOCK(vLockName);
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -0,0 +1,104 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`collection_getAssigned`(
|
||||
vUserFk INT,
|
||||
OUT vCollectionFk INT
|
||||
)
|
||||
BEGIN
|
||||
/**
|
||||
* Comprueba si existen colecciones libres que se ajustan al perfil del usuario
|
||||
* y le asigna la más antigua.
|
||||
* Añade un registro al semillero de colecciones y hace la reserva para la colección
|
||||
*
|
||||
* @param vUserFk Id de usuario
|
||||
* @param vCollectionFk Id de colección
|
||||
*/
|
||||
DECLARE vHasTooMuchCollections BOOL;
|
||||
DECLARE vItemPackingTypeFk VARCHAR(1);
|
||||
DECLARE vWarehouseFk INT;
|
||||
DECLARE vLockName VARCHAR(215);
|
||||
DECLARE vLockTime INT DEFAULT 30;
|
||||
|
||||
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
||||
BEGIN
|
||||
IF vLockName IS NOT NULL THEN
|
||||
DO RELEASE_LOCK(vLockName);
|
||||
END IF;
|
||||
|
||||
RESIGNAL;
|
||||
END;
|
||||
|
||||
-- Si hay colecciones sin terminar, sale del proceso
|
||||
CALL collection_get(vUserFk);
|
||||
|
||||
SELECT (pc.maxNotReadyCollections - COUNT(*)) <= 0,
|
||||
pc.collection_assign_lockname
|
||||
INTO vHasTooMuchCollections,
|
||||
vLockName
|
||||
FROM tCollection tc
|
||||
JOIN productionConfig pc;
|
||||
|
||||
DROP TEMPORARY TABLE tCollection;
|
||||
|
||||
IF vHasTooMuchCollections THEN
|
||||
CALL util.throw('There are pending collections');
|
||||
END IF;
|
||||
|
||||
SELECT warehouseFk, itemPackingTypeFk
|
||||
INTO vWarehouseFk, vItemPackingTypeFk
|
||||
FROM operator
|
||||
WHERE workerFk = vUserFk;
|
||||
|
||||
SET vLockName = CONCAT_WS('/',
|
||||
vLockName,
|
||||
vWarehouseFk,
|
||||
vItemPackingTypeFk
|
||||
);
|
||||
|
||||
IF NOT GET_LOCK(vLockName, vLockTime) THEN
|
||||
CALL util.throw(CONCAT('Cannot get lock: ', vLockName));
|
||||
END IF;
|
||||
|
||||
-- Se eliminan las colecciones sin asignar que estan obsoletas
|
||||
INSERT INTO ticketTracking(stateFk, ticketFk)
|
||||
SELECT s.id, tc.ticketFk
|
||||
FROM collection c
|
||||
JOIN ticketCollection tc ON tc.collectionFk = c.id
|
||||
JOIN state s ON s.code = 'PRINTED_AUTO'
|
||||
JOIN productionConfig pc
|
||||
WHERE c.workerFk IS NULL
|
||||
AND TIMEDIFF(util.VN_NOW(), c.created) > pc.maxNotAssignedCollectionLifeTime;
|
||||
|
||||
DELETE c
|
||||
FROM collection c
|
||||
JOIN productionConfig pc
|
||||
WHERE c.workerFk IS NULL
|
||||
AND TIMEDIFF(util.VN_NOW(), c.created) > pc.maxNotAssignedCollectionLifeTime;
|
||||
|
||||
-- Se añade registro al semillero
|
||||
INSERT INTO collectionHotbed
|
||||
SET userFk = vUserFk;
|
||||
|
||||
-- Comprueba si hay colecciones disponibles que se ajustan a su configuracion
|
||||
SELECT MIN(c.id) INTO vCollectionFk
|
||||
FROM collection c
|
||||
JOIN operator o ON (o.itemPackingTypeFk = c.itemPackingTypeFk
|
||||
OR c.itemPackingTypeFk IS NULL)
|
||||
AND o.numberOfWagons = c.wagons
|
||||
AND o.trainFk = c.trainFk
|
||||
AND o.warehouseFk = c.warehouseFk
|
||||
AND c.workerFk IS NULL
|
||||
WHERE o.workerFk = vUserFk;
|
||||
|
||||
IF vCollectionFk IS NULL THEN
|
||||
CALL collection_new(vUserFk, vCollectionFk);
|
||||
END IF;
|
||||
|
||||
UPDATE collection
|
||||
SET workerFk = vUserFk
|
||||
WHERE id = vCollectionFk;
|
||||
|
||||
CALL itemShelvingSale_addByCollection(vCollectionFk);
|
||||
|
||||
DO RELEASE_LOCK(vLockName);
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -2,61 +2,88 @@ DELIMITER $$
|
|||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`collection_getTickets`(vParamFk INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Selecciona los tickets de una colección/ticket
|
||||
* @param vParamFk ticketFk/collectionFk
|
||||
* @return Retorna ticketFk, level, agencyName, warehouseFk, salesPersonFk, observaciones
|
||||
* Selecciona los tickets de una colección/ticket/sectorCollection
|
||||
* @param vParamFk ticketFk/collectionFk/sectorCollection
|
||||
* @return Retorna ticketFk, level, agencyName, warehouseFk, salesPersonFk, observation
|
||||
*/
|
||||
DECLARE vItemPackingTypeFk VARCHAR(1);
|
||||
DECLARE vYesterday DATE;
|
||||
|
||||
-- Si los sacadores son los de pruebas, pinta los colores
|
||||
SELECT itemPackingTypeFk INTO vItemPackingTypeFk
|
||||
FROM vn.collection
|
||||
SELECT itemPackingTypeFk
|
||||
INTO vItemPackingTypeFk
|
||||
FROM collection
|
||||
WHERE id = vParamFk;
|
||||
|
||||
SET vYesterday = util.yesterday();
|
||||
|
||||
SELECT t.id ticketFk,
|
||||
IF (!(vItemPackingTypeFk <=> 'V'), cc.code,CONCAT(SUBSTRING('ABCDEFGH',tc.wagon, 1),'-',tc.`level` )) `level`,
|
||||
am.name agencyName,
|
||||
t.warehouseFk,
|
||||
w.id salesPersonFk,
|
||||
IFNULL(tob.description,'') observaciones,
|
||||
cc.rgb
|
||||
FROM vn.ticket t
|
||||
LEFT JOIN vn.ticketCollection tc ON t.id = tc.ticketFk
|
||||
LEFT JOIN vn.collection c2 ON c2.id = tc.collectionFk -- PAK 23/12/21
|
||||
LEFT JOIN vn.collectionColors cc
|
||||
ON cc.wagon = tc.wagon
|
||||
AND cc.shelve = tc.`level`
|
||||
AND cc.trainFk = c2.trainFk -- PAK 23/12/21
|
||||
LEFT JOIN vn.zone z ON z.id = t.zoneFk
|
||||
LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk
|
||||
LEFT JOIN vn.client c ON c.id = t.clientFk
|
||||
LEFT JOIN vn.worker w ON w.id = c.salesPersonFk
|
||||
LEFT JOIN vn.ticketObservation tob ON tob.ticketFk = t.id
|
||||
AND tob.observationTypeFk = 1
|
||||
WHERE t.id = vParamFk
|
||||
AND t.shipped >= util.yesterday()
|
||||
UNION ALL
|
||||
WITH observation AS (
|
||||
SELECT tob.ticketFk, tob.description
|
||||
FROM vn.ticketObservation tob
|
||||
JOIN vn.ticketCollection tc ON tc.ticketFk = tob.ticketFk
|
||||
LEFT JOIN vn.observationType ot ON ot.id = tob.observationTypeFk
|
||||
WHERE ot.`code` = 'itemPicker'
|
||||
AND tc.collectionFk = vParamFk
|
||||
)
|
||||
SELECT t.id ticketFk,
|
||||
IF(!(vItemPackingTypeFk <=> 'V'), cc.code, CONCAT(SUBSTRING('ABCDEFGH', tc.wagon, 1), '-', tc.`level`)) `level`,
|
||||
am.name agencyName,
|
||||
t.warehouseFk,
|
||||
w.id salesPersonFk,
|
||||
IFNULL(tob.description, '') observaciones,
|
||||
IF(!(vItemPackingTypeFk <=> 'V'), cc.rgb, NULL) `rgb`
|
||||
w.id salesPersonFk,
|
||||
IFNULL(ob.description,'') observaciones,
|
||||
cc.rgb
|
||||
FROM vn.ticket t
|
||||
JOIN vn.ticketCollection tc ON t.id = tc.ticketFk
|
||||
LEFT JOIN vn.collection c2 ON c2.id = tc.collectionFk -- PAK 23/12/21
|
||||
LEFT JOIN vn.ticketCollection tc ON t.id = tc.ticketFk
|
||||
LEFT JOIN vn.collection c2 ON c2.id = tc.collectionFk
|
||||
LEFT JOIN vn.collectionColors cc
|
||||
ON cc.wagon = tc.wagon
|
||||
AND cc.shelve = tc.`level`
|
||||
AND cc.trainFk = c2.trainFk -- PAK 23/12/21
|
||||
AND cc.shelve = tc.`level`
|
||||
AND cc.trainFk = c2.trainFk
|
||||
LEFT JOIN vn.zone z ON z.id = t.zoneFk
|
||||
LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk
|
||||
LEFT JOIN vn.client c ON c.id = t.clientFk
|
||||
LEFT JOIN vn.worker w ON w.id = c.salesPersonFk
|
||||
LEFT JOIN vn.ticketObservation tob ON tob.ticketFk = t.id
|
||||
AND tob.observationTypeFk = 1
|
||||
WHERE tc.collectionFk = vParamFk;
|
||||
|
||||
LEFT JOIN observation ob ON ob.ticketFk = t.id
|
||||
WHERE t.id = vParamFk
|
||||
AND t.shipped >= vYesterday
|
||||
UNION ALL
|
||||
SELECT t.id ticketFk,
|
||||
IF(NOT(vItemPackingTypeFk <=> 'V'), cc.code, CONCAT(SUBSTRING('ABCDEFGH', tc.wagon, 1), '-', tc.`level`)) `level`,
|
||||
am.name agencyName,
|
||||
t.warehouseFk,
|
||||
w.id salesPersonFk,
|
||||
ob.description,
|
||||
IF(NOT (vItemPackingTypeFk <=> 'V'), cc.rgb, NULL) `rgb`
|
||||
FROM vn.ticket t
|
||||
JOIN vn.ticketCollection tc ON t.id = tc.ticketFk
|
||||
LEFT JOIN vn.collection c2 ON c2.id = tc.collectionFk
|
||||
LEFT JOIN vn.collectionColors cc
|
||||
ON cc.wagon = tc.wagon
|
||||
AND cc.shelve = tc.`level`
|
||||
AND cc.trainFk = c2.trainFk
|
||||
LEFT JOIN vn.zone z ON z.id = t.zoneFk
|
||||
LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk
|
||||
LEFT JOIN vn.client c ON c.id = t.clientFk
|
||||
LEFT JOIN vn.worker w ON w.id = c.salesPersonFk
|
||||
LEFT JOIN observation ob ON ob.ticketFk = t.id
|
||||
WHERE tc.collectionFk = vParamFk
|
||||
UNION ALL
|
||||
SELECT sg.ticketFk,
|
||||
NULL `level`,
|
||||
am.name agencyName,
|
||||
t.warehouseFk,
|
||||
c.salesPersonFk,
|
||||
ob.description,
|
||||
NULL `rgb`
|
||||
FROM vn.sectorCollection sc
|
||||
JOIN vn.sectorCollectionSaleGroup ss ON ss.sectorCollectionFk = sc.id
|
||||
JOIN vn.saleGroup sg ON sg.id = ss.saleGroupFk
|
||||
JOIN vn.ticket t ON t.id = sg.ticketFk
|
||||
LEFT JOIN vn.zone z ON z.id = t.zoneFk
|
||||
LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk
|
||||
LEFT JOIN observation ob ON ob.ticketFk = t.id
|
||||
LEFT JOIN vn.client c ON c.id = t.clientFk
|
||||
WHERE sc.id = vParamFk
|
||||
AND t.shipped >= vYesterday;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -59,7 +59,8 @@ BEGIN
|
|||
'errorNumber', vErrorNumber,
|
||||
'errorMsg', vErrorMsg,
|
||||
'lockName', vLockName,
|
||||
'userFk', vUserFk
|
||||
'userFk', vUserFk,
|
||||
'ticketFk', vTicketFk
|
||||
)); -- Tmp
|
||||
END IF;
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`duaInvoiceInBooking`(vDuaFk INT)
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`duaInvoiceInBooking`(
|
||||
vDuaFk INT
|
||||
)
|
||||
BEGIN
|
||||
/**
|
||||
* Genera el asiento de un DUA y marca las entradas como confirmadas
|
||||
|
@ -29,27 +31,25 @@ BEGIN
|
|||
SET ii.booked = IFNULL(ii.booked, d.booked),
|
||||
ii.operated = IFNULL(ii.operated, d.operated),
|
||||
ii.issued = IFNULL(ii.issued, d.issued),
|
||||
ii.bookEntried = IFNULL(ii.bookEntried, d.bookEntried),
|
||||
e.isBooked = TRUE,
|
||||
e.isConfirmed = TRUE
|
||||
ii.bookEntried = IFNULL(ii.bookEntried, d.bookEntried)
|
||||
WHERE d.id = vDuaFk;
|
||||
|
||||
SELECT ASIEN INTO vBookEntry FROM dua WHERE id = vDuaFk;
|
||||
|
||||
IF vBookEntry IS NULL THEN
|
||||
IF vBookEntry IS NULL THEN
|
||||
SELECT YEAR(IFNULL(ii.bookEntried, d.bookEntried)) INTO vFiscalYear
|
||||
FROM invoiceIn ii
|
||||
JOIN entry e ON e.invoiceInFk = ii.id
|
||||
JOIN `entry` e ON e.invoiceInFk = ii.id
|
||||
JOIN duaEntry de ON de.entryFk = e.id
|
||||
JOIN dua d ON d.id = de.duaFk
|
||||
WHERE d.id = vDuaFk
|
||||
LIMIT 1;
|
||||
CALL ledger_nextTx(vFiscalYear, vBookEntry);
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
OPEN vInvoicesIn;
|
||||
|
||||
l: LOOP
|
||||
l: LOOP
|
||||
SET vDone = FALSE;
|
||||
FETCH vInvoicesIn INTO vInvoiceFk;
|
||||
|
||||
|
@ -70,5 +70,28 @@ l: LOOP
|
|||
JOIN duaInvoiceIn dii ON dii.invoiceInFk = ii.id
|
||||
SET ii.isBooked = TRUE
|
||||
WHERE dii.duaFk = vDuaFk;
|
||||
|
||||
UPDATE `entry` e
|
||||
JOIN (
|
||||
WITH entries AS (
|
||||
SELECT e.id, de.duaFk
|
||||
FROM vn.`entry` e
|
||||
JOIN vn.duaEntry de ON de.entryFk = e.id
|
||||
WHERE de.duaFk = vDuaFk
|
||||
AND (NOT e.isBooked OR NOT e.isConfirmed)
|
||||
),
|
||||
notBookedEntries AS (
|
||||
SELECT e.id
|
||||
FROM vn.duaEntry
|
||||
WHERE duaFk = vDuaFk
|
||||
AND NOT customsValue
|
||||
)
|
||||
SELECT e.id
|
||||
FROM entries e
|
||||
LEFT JOIN notBookedEntries nbe ON nbe.entryFk = e.id
|
||||
WHERE nbe.entryFk IS NULL
|
||||
) sub ON sub.id = e.id
|
||||
SET e.isBooked = TRUE,
|
||||
e.isConfirmed = TRUE;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
|
||||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_addByCollection`(
|
||||
vCollectionFk INT(11)
|
||||
)
|
||||
BEGIN
|
||||
/**
|
||||
* Reserva cantidades con ubicaciones para el contenido de una colección
|
||||
*
|
||||
* @param vCollectionFk Identificador de collection
|
||||
*/
|
||||
DECLARE vDone BOOL DEFAULT FALSE;
|
||||
DECLARE vSaleFk INT;
|
||||
DECLARE vSales CURSOR FOR
|
||||
WITH sales AS (
|
||||
SELECT s.id saleFk, s.quantity, SUM(IFNULL(iss.quantity, 0)) quantityReserved
|
||||
FROM vn.ticketCollection tc
|
||||
JOIN vn.sale s ON s.ticketFk = tc.ticketFk
|
||||
LEFT JOIN vn.itemShelvingSale iss ON iss.saleFk = s.id
|
||||
WHERE tc.collectionFk = vCollectionFk
|
||||
GROUP BY s.id
|
||||
HAVING quantity <> quantityReserved
|
||||
), trackedSales AS (
|
||||
SELECT sa.saleFk
|
||||
FROM sales sa
|
||||
JOIN vn.saleTracking st ON st.saleFk = sa.saleFk
|
||||
JOIN vn.`state` s ON s.id = st.stateFk
|
||||
WHERE st.isChecked
|
||||
AND s.`code` IN ('PREVIOUS_PREPARATION', 'OK PREVIOUS', 'OK STOWAWAY')
|
||||
GROUP BY sa.saleFk
|
||||
) SELECT s.saleFk
|
||||
FROM sales s
|
||||
LEFT JOIN trackedSales ts ON ts.saleFk = s.saleFk
|
||||
WHERE ts.saleFk IS NULL;
|
||||
|
||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||
|
||||
OPEN vSales;
|
||||
l: LOOP
|
||||
SET vDone = FALSE;
|
||||
FETCH vSales INTO vSaleFk;
|
||||
|
||||
IF vDone THEN
|
||||
LEAVE l;
|
||||
END IF;
|
||||
|
||||
CALL itemShelvingSale_addBySale(vSaleFk);
|
||||
END LOOP;
|
||||
CLOSE vSales;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -0,0 +1,102 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_addBySale`(
|
||||
vSaleFk INT
|
||||
)
|
||||
proc: BEGIN
|
||||
/**
|
||||
* Reserva una línea de venta en la ubicación más óptima
|
||||
*
|
||||
* @param vSaleFk Id de sale
|
||||
* @param vItemShelvingSaleFk Id de reserva
|
||||
*/
|
||||
DECLARE vLastPickingOrder INT;
|
||||
DECLARE vDone INT DEFAULT FALSE;
|
||||
DECLARE vItemShelvingFk INT;
|
||||
DECLARE vAvailable INT;
|
||||
DECLARE vReservedQuantity INT;
|
||||
DECLARE vOutStanding INT;
|
||||
DECLARE vUserFk INT;
|
||||
|
||||
DECLARE vItemShelvingAvailable CURSOR FOR
|
||||
SELECT ish.id itemShelvingFk,
|
||||
ish.available
|
||||
FROM sale s
|
||||
JOIN itemShelving ish ON ish.itemFk = s.itemFk
|
||||
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 productionConfig pc
|
||||
WHERE s.id = vSaleFk
|
||||
AND NOT sc.isHideForPickers
|
||||
ORDER BY s.id,
|
||||
p.pickingOrder >= vLastPickingOrder,
|
||||
sh.priority DESC,
|
||||
ish.available >= s.quantity DESC,
|
||||
s.quantity MOD ish.grouping = 0 DESC,
|
||||
ish.grouping DESC,
|
||||
IF(pc.orderMode = 'Location', p.pickingOrder, ish.created);
|
||||
|
||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
||||
BEGIN
|
||||
ROLLBACK;
|
||||
RESIGNAL;
|
||||
END;
|
||||
|
||||
SELECT MAX(p.pickingOrder), s.quantity - SUM(IFNULL(iss.quantity, 0))
|
||||
INTO vLastPickingOrder, vOutStanding
|
||||
FROM sale s
|
||||
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
|
||||
WHERE s.id = vSaleFk;
|
||||
|
||||
IF vOutStanding <= 0 THEN
|
||||
LEAVE proc;
|
||||
END IF;
|
||||
|
||||
SELECT getUser() INTO vUserFk;
|
||||
|
||||
OPEN vItemShelvingAvailable;
|
||||
l: LOOP
|
||||
SET vDone = FALSE;
|
||||
FETCH vItemShelvingAvailable INTO vItemShelvingFk, vAvailable;
|
||||
|
||||
IF vOutStanding <= 0 OR vDone THEN
|
||||
LEAVE l;
|
||||
END IF;
|
||||
|
||||
START TRANSACTION;
|
||||
|
||||
SELECT id INTO vItemShelvingFk
|
||||
FROM itemShelving
|
||||
WHERE id = vItemShelvingFk
|
||||
FOR UPDATE;
|
||||
|
||||
SELECT LEAST(vOutStanding, vAvailable) INTO vReservedQuantity;
|
||||
SET vOutStanding = vOutStanding - vReservedQuantity;
|
||||
|
||||
IF vReservedQuantity > 0 THEN
|
||||
|
||||
INSERT INTO itemShelvingSale(
|
||||
itemShelvingFk,
|
||||
saleFk,
|
||||
quantity,
|
||||
userFk)
|
||||
SELECT vItemShelvingFk,
|
||||
vSaleFk,
|
||||
vReservedQuantity,
|
||||
vUserFk;
|
||||
|
||||
UPDATE itemShelving
|
||||
SET available = available - vReservedQuantity
|
||||
WHERE id = vItemShelvingFk;
|
||||
|
||||
END IF;
|
||||
|
||||
COMMIT;
|
||||
END LOOP;
|
||||
CLOSE vItemShelvingAvailable;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -0,0 +1,41 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE
|
||||
`vn`.`itemShelvingSale_addBySectorCollection`(vSectorCollectionFk INT(11))
|
||||
BEGIN
|
||||
/**
|
||||
* Reserva cantidades con ubicaciones para el contenido de una preparación previa
|
||||
* de la cual ya tiene generada la asociación del saleGroup con sectorCollection
|
||||
*
|
||||
* @param vSectorCollectionFk Identificador de sectorCollection
|
||||
*/
|
||||
DECLARE vDone BOOL DEFAULT FALSE;
|
||||
DECLARE vSaleFk INT;
|
||||
DECLARE vSales CURSOR FOR
|
||||
SELECT s.id
|
||||
FROM sectorCollectionSaleGroup sc
|
||||
JOIN saleGroupDetail sg ON sg.saleGroupFk = sc.saleGroupFk
|
||||
JOIN sale s ON sg.saleFk = s.id
|
||||
JOIN saleTracking str ON str.saleFk = s.id
|
||||
JOIN `state` st ON st.id = str.stateFk
|
||||
AND st.code = 'PREVIOUS_PREPARATION'
|
||||
LEFT JOIN itemShelvingSale iss ON iss.saleFk = s.id
|
||||
WHERE sc.sectorCollectionFk = vSectorCollectionFk
|
||||
AND str.workerFk = account.myUser_getId()
|
||||
AND iss.id IS NULL;
|
||||
|
||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||
|
||||
OPEN vSales;
|
||||
l: LOOP
|
||||
SET vDone = FALSE;
|
||||
FETCH vSales INTO vSaleFk;
|
||||
|
||||
IF vDone THEN
|
||||
LEAVE l;
|
||||
END IF;
|
||||
|
||||
CALL itemShelvingSale_addBySale(vSaleFk);
|
||||
END LOOP;
|
||||
CLOSE vSales;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -0,0 +1,52 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_doReserve`()
|
||||
proc: BEGIN
|
||||
/**
|
||||
* Genera reservas de la tabla vn.itemShelvingSaleReserve
|
||||
*/
|
||||
DECLARE vDone BOOL;
|
||||
DECLARE vSaleFk INT;
|
||||
|
||||
DECLARE vSales CURSOR FOR
|
||||
SELECT DISTINCT saleFk FROM tSale;
|
||||
|
||||
DECLARE CONTINUE HANDLER FOR NOT FOUND
|
||||
SET vDone = TRUE;
|
||||
|
||||
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
|
||||
BEGIN
|
||||
DO RELEASE_LOCK('vn.itemShelvingSale_doReserve');
|
||||
ROLLBACK;
|
||||
RESIGNAL;
|
||||
END;
|
||||
|
||||
IF !GET_LOCK('vn.itemShelvingSale_doReserve', 0) THEN
|
||||
LEAVE proc;
|
||||
END IF;
|
||||
|
||||
CREATE OR REPLACE TEMPORARY TABLE tSale
|
||||
ENGINE = MEMORY
|
||||
SELECT id, saleFk FROM itemShelvingSaleReserve;
|
||||
|
||||
OPEN vSales;
|
||||
|
||||
myLoop: LOOP
|
||||
SET vDone = FALSE;
|
||||
FETCH vSales INTO vSaleFk;
|
||||
|
||||
IF vDone THEN
|
||||
LEAVE myLoop;
|
||||
END IF;
|
||||
|
||||
CALL itemShelvingSale_addBySale (vSaleFk);
|
||||
END LOOP;
|
||||
|
||||
CLOSE vSales;
|
||||
|
||||
DELETE iss FROM itemShelvingSaleReserve iss JOIN tSale s ON s.id = iss.id;
|
||||
|
||||
DROP TEMPORARY TABLE tSale;
|
||||
|
||||
DO RELEASE_LOCK('vn.itemShelvingSale_doReserve');
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -0,0 +1,49 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_reallocate`(
|
||||
vItemShelvingFk INT(10),
|
||||
vItemFk INT(10)
|
||||
)
|
||||
BEGIN
|
||||
/**
|
||||
* Elimina reservas de un itemShelving e intenta reservar en otra ubicación
|
||||
*
|
||||
* @param vItemShelvingFk Id itemShelving
|
||||
*/
|
||||
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
||||
BEGIN
|
||||
ROLLBACK;
|
||||
RESIGNAL;
|
||||
END;
|
||||
|
||||
START TRANSACTION;
|
||||
|
||||
SELECT id INTO vItemShelvingFk
|
||||
FROM itemShelving
|
||||
WHERE id = vItemShelvingFk
|
||||
FOR UPDATE;
|
||||
|
||||
UPDATE itemShelving
|
||||
SET visible = 0,
|
||||
available = 0
|
||||
WHERE id = vItemShelvingFk
|
||||
AND itemFk = vItemFk;
|
||||
|
||||
INSERT INTO itemShelvingSaleReserve (saleFk)
|
||||
SELECT DISTINCT iss.saleFk
|
||||
FROM itemShelvingSale iss
|
||||
JOIN itemShelving ish ON ish.id = iss.itemShelvingFk
|
||||
WHERE iss.itemShelvingFk = vItemShelvingFk
|
||||
AND ish.itemFk = vItemFk
|
||||
AND NOT iss.isPicked;
|
||||
|
||||
DELETE iss
|
||||
FROM itemShelvingSale iss
|
||||
JOIN itemShelving ish ON ish.id = iss.itemShelvingFk
|
||||
WHERE iss.itemShelvingFk = vItemShelvingFk
|
||||
AND ish.itemFk = vItemFk
|
||||
AND NOT iss.isPicked;
|
||||
COMMIT;
|
||||
|
||||
CALL itemShelvingSale_doReserve();
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,92 +0,0 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_reserve`()
|
||||
BEGIN
|
||||
/**
|
||||
* Reserva cantidades con ubicaciones para un conjunto de sales del mismo
|
||||
* almacen.
|
||||
*
|
||||
* @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 ;
|
|
@ -1,29 +0,0 @@
|
|||
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 ;
|
|
@ -1,21 +0,0 @@
|
|||
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 ;
|
|
@ -0,0 +1,34 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_setPicked`(
|
||||
vSaleGroupFk INT(10)
|
||||
)
|
||||
BEGIN
|
||||
/**
|
||||
* Gestiona la reserva de un vn.saleGroup actualizando vn.itemShelvingSale.isPicked
|
||||
* y cambiando el estado de la vn.sale
|
||||
*
|
||||
* @param vSaleGroupFk Id saleGroupFk
|
||||
*/
|
||||
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
||||
BEGIN
|
||||
ROLLBACK;
|
||||
RESIGNAL;
|
||||
END;
|
||||
|
||||
IF NOT (SELECT COUNT(*) FROM saleGroup WHERE id = vSaleGroupFk) THEN
|
||||
CALL util.throw('Sale group not exists');
|
||||
END IF;
|
||||
|
||||
START TRANSACTION;
|
||||
|
||||
UPDATE itemShelvingSale iss
|
||||
JOIN sale s ON s.id = iss.saleFk
|
||||
JOIN saleGroupDetail sg ON sg.saleFk = s.id
|
||||
SET iss.isPicked = TRUE
|
||||
WHERE sg.saleGroupFk = vSaleGroupFk;
|
||||
|
||||
CALL saleTracking_addPreparedSaleGroup(vSaleGroupFk);
|
||||
|
||||
COMMIT;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,118 +1,94 @@
|
|||
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_setQuantity`(
|
||||
vItemShelvingSaleFk INT(10),
|
||||
vQuantity DECIMAL(10,0),
|
||||
vIsItemShelvingSaleEmpty BOOLEAN
|
||||
)
|
||||
BEGIN
|
||||
/**
|
||||
* Gestiona la reserva de un itemShelvingFk, actualizando isPicked y quantity
|
||||
* en itemShelvingSale y 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 la ubicación itemShelvingSale se ha
|
||||
* quedado vacio tras el movimiento
|
||||
*/
|
||||
DECLARE vSaleFk INT;
|
||||
DECLARE vItemShelvingFk INT;
|
||||
DECLARE vReservedQuantity INT;
|
||||
DECLARE vRemainingQuantity INT;
|
||||
DECLARE vItemFk INT;
|
||||
DECLARE vTotalQuantity INT;
|
||||
|
||||
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
||||
BEGIN
|
||||
ROLLBACK;
|
||||
RESIGNAL;
|
||||
END;
|
||||
|
||||
IF (SELECT isPicked FROM itemShelvingSale WHERE id = vItemShelvingSaleFk) THEN
|
||||
CALL util.throw('Reservation completed');
|
||||
END IF;
|
||||
|
||||
SELECT s.itemFk, iss.saleFk, iss.itemShelvingFk, SUM(IFNULL(iss.quantity,0))
|
||||
INTO vItemFk, vSaleFk, vItemShelvingFk, vReservedQuantity
|
||||
FROM itemShelvingSale iss
|
||||
JOIN sale s ON s.id = iss.saleFk
|
||||
WHERE iss.id = vItemShelvingSaleFk
|
||||
AND NOT iss.isPicked;
|
||||
|
||||
IF vQuantity > vReservedQuantity
|
||||
OR (vQuantity < vReservedQuantity AND
|
||||
(NOT vIsItemShelvingSaleEmpty OR vIsItemShelvingSaleEmpty IS NULL))
|
||||
OR (vIsItemShelvingSaleEmpty IS NOT NULL AND vQuantity = vReservedQuantity) THEN
|
||||
CALL util.throw('The quantity cannot be different from the reserved');
|
||||
END IF;
|
||||
|
||||
START TRANSACTION;
|
||||
|
||||
UPDATE itemShelvingSale
|
||||
SET isPicked = TRUE,
|
||||
quantity = vQuantity
|
||||
WHERE id = vItemShelvingSaleFk;
|
||||
|
||||
SELECT id INTO vItemShelvingFk
|
||||
FROM itemShelving
|
||||
WHERE id = vItemShelvingFk
|
||||
FOR UPDATE;
|
||||
|
||||
UPDATE itemShelving
|
||||
SET visible = GREATEST(0, visible - vQuantity)
|
||||
WHERE id = vItemShelvingFk;
|
||||
|
||||
SELECT SUM(IF(isPicked, 0, quantity)), SUM(quantity)
|
||||
INTO vRemainingQuantity, vTotalQuantity
|
||||
FROM itemShelvingSale
|
||||
WHERE saleFk = vSaleFk;
|
||||
|
||||
IF vRemainingQuantity = 0 AND NOT vIsItemShelvingSaleEmpty THEN
|
||||
CALL saleTracking_new(
|
||||
vSaleFk,
|
||||
TRUE,
|
||||
vTotalQuantity,
|
||||
`account`.`myUser_getId`(),
|
||||
NULL,
|
||||
'PREPARED',
|
||||
TRUE);
|
||||
|
||||
UPDATE sale s
|
||||
SET s.quantity = vTotalQuantity,
|
||||
isPicked = TRUE
|
||||
WHERE s.id = vSaleFk;
|
||||
END IF;
|
||||
|
||||
COMMIT;
|
||||
|
||||
IF vIsItemShelvingSaleEmpty AND vQuantity <> vReservedQuantity THEN
|
||||
INSERT INTO itemShelvingSaleReserve (saleFk)
|
||||
SELECT vSaleFk;
|
||||
CALL itemShelvingSale_reallocate(vItemShelvingFk, vItemFk);
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -0,0 +1,60 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_unpicked`(
|
||||
vSelf INT(11)
|
||||
)
|
||||
BEGIN
|
||||
/**
|
||||
* Desmarca una línea que ya estaba sacada, devolviendo la cantidad al itemShelving
|
||||
*
|
||||
* @param vSelf Identificador del itemShelvingSale
|
||||
*/
|
||||
DECLARE vSaleFk INT;
|
||||
DECLARE vReservedQuantity INT;
|
||||
DECLARE vIsSaleGroup BOOL;
|
||||
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
||||
BEGIN
|
||||
ROLLBACK;
|
||||
RESIGNAL;
|
||||
END;
|
||||
|
||||
IF (SELECT NOT isPicked FROM itemShelvingSale WHERE id = vSelf) THEN
|
||||
CALL util.throw('Reserva no completada');
|
||||
END IF;
|
||||
|
||||
SELECT ish.saleFk, ish.quantity, IF(sg.id, TRUE, FALSE)
|
||||
INTO vSaleFk, vReservedQuantity, vIsSaleGroup
|
||||
FROM itemShelvingSale ish
|
||||
LEFT JOIN saleGroupDetail sg ON sg.saleFk = ish.saleFk
|
||||
WHERE ish.id = vSelf;
|
||||
|
||||
/*IF vIsSaleGroup THEN
|
||||
CALL util.throw('Can not unpicked a sale group');
|
||||
END IF;*/
|
||||
|
||||
START TRANSACTION;
|
||||
|
||||
UPDATE itemShelvingSale
|
||||
SET isPicked = FALSE
|
||||
WHERE id = vSelf;
|
||||
|
||||
UPDATE sale s
|
||||
JOIN itemShelvingSale ish ON ish.saleFk = s.id
|
||||
SET s.isPicked = FALSE
|
||||
WHERE ish.id = vSelf;
|
||||
|
||||
UPDATE itemShelvingSale iss
|
||||
JOIN itemShelving ish ON ish.id = iss.itemShelvingFk
|
||||
SET ish.visible = ish.visible + iss.quantity
|
||||
WHERE iss.id = vSelf;
|
||||
|
||||
CALL saleTracking_new(
|
||||
vSaleFk,
|
||||
FALSE,
|
||||
vReservedQuantity,
|
||||
`account`.`myUser_getId`(),
|
||||
NULL,
|
||||
'ON_PREPARATION',
|
||||
TRUE);
|
||||
COMMIT;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -70,4 +70,4 @@ BEGIN
|
|||
WHERE id = vBuyFk;
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
DELIMITER ;
|
|
@ -21,7 +21,8 @@ proc:BEGIN
|
|||
sub.downstairs,
|
||||
sub.visible,
|
||||
CAST(visible - upstairs - downstairs AS DECIMAL(10,0)) nicho,
|
||||
sub.name itemColour
|
||||
sub.name itemColour,
|
||||
CAST(sub2.pendiente AS DECIMAL(10,0)) pendingAmount
|
||||
FROM (SELECT iss.itemFk,
|
||||
CONCAT(i.longName, ' ', IFNULL(i.size, ''),' ', IFNULL(i.subName, '') ) longName,
|
||||
'' size,
|
||||
|
@ -58,7 +59,8 @@ proc:BEGIN
|
|||
0,
|
||||
v.visible,
|
||||
v.visible nicho,
|
||||
ik.name itemColour
|
||||
ik.name itemColour,
|
||||
CAST(sub5.pendiente AS DECIMAL(10,0)) pendingAmount
|
||||
FROM cache.visible v
|
||||
JOIN item i ON i.id = v.item_id
|
||||
LEFT JOIN ink ik ON ik.id = i.inkFk
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingTransfer`(vItemShelvingFk INT, vShelvingFk VARCHAR(3))
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelving_transfer`(
|
||||
vItemShelvingFk INT,
|
||||
vShelvingFk VARCHAR(10)
|
||||
)
|
||||
BEGIN
|
||||
/**
|
||||
* Transfiere producto de una ubicación a otra, fusionando si coincide el
|
||||
|
@ -21,8 +24,7 @@ BEGIN
|
|||
buyFk
|
||||
FROM itemShelving
|
||||
WHERE id = vItemShelvingFk
|
||||
) ish2
|
||||
ON ish2.itemFk = ish.itemFk
|
||||
) ish2 ON ish2.itemFk = ish.itemFk
|
||||
AND ish2.packing = ish.packing
|
||||
AND date(ish2.created) = date(ish.created)
|
||||
AND ish2.buyFk = ish.buyFk
|
||||
|
@ -30,7 +32,7 @@ BEGIN
|
|||
|
||||
IF vNewItemShelvingFk THEN
|
||||
UPDATE itemShelving ish
|
||||
JOIN itemShelving ish2 ON ish2.id = vItemShelvingFk
|
||||
JOIN itemShelving ish2 ON ish2.id = vItemShelvingFk
|
||||
SET ish.visible = ish.visible + ish2.visible
|
||||
WHERE ish.id = vNewItemShelvingFk;
|
||||
|
||||
|
@ -41,7 +43,6 @@ BEGIN
|
|||
SET shelvingFk = vShelvingFk
|
||||
WHERE id = vItemShelvingFk;
|
||||
END IF;
|
||||
|
||||
SELECT true;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
DELIMITER ;
|
|
@ -0,0 +1,18 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sectorCollection_getMyPartial`()
|
||||
BEGIN
|
||||
/**
|
||||
* Devuelve las colecciones del sector que corresponden al usuario conectado, y que estan incompletas
|
||||
*
|
||||
*/
|
||||
SELECT DISTINCT sc.id collectionFk, sc.created
|
||||
FROM vn.sectorCollection sc
|
||||
LEFT JOIN vn.sectorCollectionSaleGroup scsg ON scsg.sectorCollectionFk = sc.id
|
||||
LEFT JOIN vn.saleGroupDetail sgd ON sgd.saleGroupFk = scsg.saleGroupFk
|
||||
LEFT JOIN vn.sale sl ON sl.id = sgd.saleFk
|
||||
LEFT JOIN itemShelvingSale iss ON iss.saleFk = sl.id
|
||||
WHERE sc.userFk = account.myUser_getId()
|
||||
AND (scsg.sectorCollectionFk IS NULL OR NOT iss.isPicked)
|
||||
AND sc.created > util.VN_CURDATE() - INTERVAL 1 DAY;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -0,0 +1,25 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION vn.sectorCollection_hasSalesReserved(vSelf INT) RETURNS tinyint(1)
|
||||
DETERMINISTIC
|
||||
BEGIN
|
||||
/**
|
||||
* Devuelve si sectorCollection tiene reservas
|
||||
* @param vSelf Id de sectorCollection
|
||||
*
|
||||
* returns BOOLEAN
|
||||
*/
|
||||
DECLARE vHasSalesReserved BOOLEAN;
|
||||
|
||||
SELECT DISTINCT COUNT(*) INTO vHasSalesReserved
|
||||
FROM sectorCollection sc
|
||||
JOIN sectorCollectionSaleGroup scsg ON sc.id = scsg.sectorCollectionFk
|
||||
JOIN saleGroup sg ON sg.id = scsg.saleGroupFk
|
||||
JOIN saleGroupDetail sgd ON sgd.saleGroupFk = sg.id
|
||||
JOIN sale s ON s.id = sgd.saleFk
|
||||
JOIN itemShelvingSale iss ON iss.saleFk = s.id
|
||||
JOIN saleTracking st ON st.saleFk = s.id
|
||||
WHERE sc.id = vSelf;
|
||||
|
||||
RETURN vHasSalesReserved;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -22,7 +22,7 @@ BEGIN
|
|||
landed,
|
||||
`in`,
|
||||
`out`,
|
||||
warehouse,
|
||||
sref,
|
||||
buyingValue,
|
||||
IF (
|
||||
NOT (@vItemFk <=> sub.itemFk),
|
||||
|
@ -31,19 +31,20 @@ BEGIN
|
|||
) balance,
|
||||
@vItemFk := sub.itemFk previousItemFk
|
||||
FROM (
|
||||
SELECT supplierFk,
|
||||
itemFk,
|
||||
longName,
|
||||
supplier,
|
||||
CONCAT('E',entryFk) entryFk,
|
||||
landed,
|
||||
`in`,
|
||||
`out`,
|
||||
warehouse,
|
||||
buyingValue
|
||||
FROM supplierPackaging
|
||||
WHERE supplierFk = vSupplierFk
|
||||
AND landed >= vFromDated
|
||||
SELECT sp.supplierFk,
|
||||
sp.itemFk,
|
||||
sp.longName,
|
||||
sp.supplier,
|
||||
CONCAT('E',sp.entryFk) entryFk,
|
||||
sp.landed,
|
||||
sp.`in`,
|
||||
sp.`out`,
|
||||
e.invoiceNumber sref,
|
||||
sp.buyingValue
|
||||
FROM supplierPackaging sp
|
||||
JOIN entry e ON e.id = sp.entryFk
|
||||
WHERE sp.supplierFk = vSupplierFk
|
||||
AND sp.landed >= vFromDated
|
||||
UNION ALL
|
||||
SELECT vSupplierFk,
|
||||
itemFk,
|
||||
|
@ -68,7 +69,7 @@ BEGIN
|
|||
DATE(t.shipped),
|
||||
-LEAST(s.quantity,0) `in`,
|
||||
GREATEST(s.quantity,0) `out`,
|
||||
t.warehouseFk,
|
||||
t.cmrFk,
|
||||
s.price * (100 - s.discount) / 100
|
||||
FROM sale s
|
||||
JOIN item i ON i.id = s.itemFk
|
||||
|
@ -110,7 +111,7 @@ BEGIN
|
|||
DATE(t.shipped),
|
||||
-LEAST(tp.quantity,0) `in`,
|
||||
GREATEST(tp.quantity,0) `out`,
|
||||
t.warehouseFk,
|
||||
t.cmrFk,
|
||||
0
|
||||
FROM ticketPackaging tp
|
||||
JOIN packaging p ON p.id = tp.packagingFk
|
||||
|
@ -155,7 +156,7 @@ BEGIN
|
|||
landed,
|
||||
CAST(`in` AS DECIMAL(10,0)) `in`,
|
||||
CAST(`out` AS DECIMAL(10,0)) `out`,
|
||||
warehouse,
|
||||
sref,
|
||||
buyingValue,
|
||||
balance
|
||||
FROM tSupplierPackaging
|
||||
|
|
|
@ -12,23 +12,21 @@ BEGIN
|
|||
END IF;
|
||||
|
||||
IF !(OLD.started <=> NEW.started AND OLD.ended <=> NEW.ended) THEN
|
||||
|
||||
SELECT COUNT(*) > 0 INTO isOverlapping
|
||||
FROM business b
|
||||
WHERE (util.hasDateOverlapped(
|
||||
NEW.started,
|
||||
IFNULL(NEW.ended, b.started),
|
||||
b.started,
|
||||
IFNULL(b.ended, NEW.started))
|
||||
OR (NEW.ended <=> NULL AND b.ended <=> NULL))
|
||||
AND b.id <> OLD.id
|
||||
AND workerFk = OLD.workerFk;
|
||||
SELECT util.hasDateOverlapped(
|
||||
started,
|
||||
ended,
|
||||
NEW.started,
|
||||
IFNULL(NEW.ended, b.started)
|
||||
) isOverlapped INTO isOverlapping
|
||||
FROM vn.business b
|
||||
WHERE workerFk = NEW.workerFK
|
||||
AND b.id <> NEW.id
|
||||
ORDER BY isOverlapped DESC
|
||||
LIMIT 1;
|
||||
|
||||
IF isOverlapping THEN
|
||||
CALL util.throw ('IS_OVERLAPPING');
|
||||
END IF;
|
||||
|
||||
END IF;
|
||||
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`clientUnpaid_beforeInsert`
|
||||
BEFORE INSERT ON `clientUnpaid`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
SET NEW.editorFk = account.myUser_getId();
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -0,0 +1,8 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`clientUnpaid_beforeUpdate`
|
||||
BEFORE UPDATE ON `clientUnpaid`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
SET NEW.editorFk = account.myUser_getId();
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -3,12 +3,35 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`client_afterUpdate`
|
|||
AFTER UPDATE ON `client`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
IF !(NEW.defaultAddressFk <=> OLD.defaultAddressFk) THEN
|
||||
IF NOT (NEW.defaultAddressFk <=> OLD.defaultAddressFk) THEN
|
||||
UPDATE `address` SET isDefaultAddress = FALSE
|
||||
WHERE clientFk = NEW.id;
|
||||
|
||||
UPDATE `address` SET isDefaultAddress = TRUE
|
||||
WHERE id = NEW.defaultAddressFk;
|
||||
END IF;
|
||||
|
||||
IF NEW.id <> OLD.id
|
||||
OR NOT (NEW.provinceFk <=> OLD.provinceFk)
|
||||
OR NOT (NEW.socialName <=> OLD.socialName)
|
||||
OR NOT (NEW.street <=> OLD.street)
|
||||
OR NOT (NEW.accountingAccount <=> OLD.accountingAccount)
|
||||
OR NOT (NEW.isVies <=> OLD.isVies)
|
||||
OR NOT (NEW.fi <=> OLD.fi)
|
||||
OR NOT (NEW.postcode <=> OLD.postcode)
|
||||
OR NOT (NEW.city <=> OLD.city)
|
||||
OR NOT (NEW.countryFk <=> OLD.countryFk)
|
||||
OR NOT (NEW.taxTypeSageFk <=> OLD.taxTypeSageFk)
|
||||
OR NOT (NEW.transactionTypeSageFk <=> OLD.transactionTypeSageFk)
|
||||
OR NOT (NEW.email <=> OLD.email)
|
||||
OR NOT (NEW.iban <=> OLD.iban)
|
||||
OR NOT (NEW.phone <=> OLD.phone)
|
||||
OR NOT (NEW.mobile <=> OLD.mobile) THEN
|
||||
|
||||
UPDATE sage.clientSupplier
|
||||
SET isSync = FALSE
|
||||
WHERE idClientSupplier IN (NEW.id, OLD.id)
|
||||
AND `type` = 'C';
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -65,11 +65,11 @@ BEGIN
|
|||
END IF;
|
||||
END IF;
|
||||
|
||||
IF !(NEW.salesPersonFk <=> OLD.salesPersonFk) THEN
|
||||
IF NOT (NEW.salesPersonFk <=> OLD.salesPersonFk) THEN
|
||||
SET NEW.lastSalesPersonFk = IFNULL(NEW.salesPersonFk, OLD.salesPersonFk);
|
||||
END IF;
|
||||
|
||||
IF !(NEW.businessTypeFk <=> OLD.businessTypeFk) AND (NEW.businessTypeFk = 'individual' OR OLD.businessTypeFk = 'individual') THEN
|
||||
IF NOT (NEW.businessTypeFk <=> OLD.businessTypeFk) AND (NEW.businessTypeFk = 'individual' OR OLD.businessTypeFk = 'individual') THEN
|
||||
SET NEW.isTaxDataChecked = 0;
|
||||
END IF;
|
||||
END$$
|
||||
|
|
|
@ -2,11 +2,11 @@ DELIMITER $$
|
|||
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemShelvingSale_afterInsert`
|
||||
AFTER INSERT ON `itemShelvingSale`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
|
||||
UPDATE vn.sale
|
||||
SET isPicked = TRUE
|
||||
WHERE id = NEW.saleFk;
|
||||
|
||||
BEGIN
|
||||
|
||||
UPDATE sale s
|
||||
JOIN operator o ON o.workerFk = account.myUser_getId()
|
||||
SET s.isPicked = IF(o.isOnReservationMode, s.isPicked, TRUE)
|
||||
WHERE id = NEW.saleFk;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
DELIMITER ;
|
|
@ -1,22 +0,0 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemShelving_afterInsert`
|
||||
AFTER INSERT ON `itemShelving`
|
||||
FOR EACH ROW
|
||||
INSERT INTO vn.itemShelvingLog( itemShelvingFk,
|
||||
workerFk,
|
||||
accion,
|
||||
itemFk,
|
||||
shelvingFk,
|
||||
visible,
|
||||
`grouping`,
|
||||
packing)
|
||||
VALUES( NEW.id,
|
||||
NEW.userFk,
|
||||
'CREA REGISTRO',
|
||||
NEW.itemFk,
|
||||
NEW.shelvingFk,
|
||||
NEW.visible,
|
||||
NEW.`grouping`,
|
||||
NEW.packing
|
||||
)$$
|
||||
DELIMITER ;
|
|
@ -2,7 +2,8 @@ DELIMITER $$
|
|||
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemShelving_afterUpdate`
|
||||
AFTER UPDATE ON `itemShelving`
|
||||
FOR EACH ROW
|
||||
INSERT INTO itemShelvingLog
|
||||
BEGIN
|
||||
INSERT INTO itemShelvingLog
|
||||
SET itemShelvingFk = NEW.id,
|
||||
workerFk = account.myUser_getId(),
|
||||
accion = 'CAMBIO',
|
||||
|
@ -10,5 +11,8 @@ INSERT INTO itemShelvingLog
|
|||
shelvingFk = NEW.shelvingFk,
|
||||
visible = NEW.visible,
|
||||
`grouping` = NEW.`grouping`,
|
||||
packing = NEW.packing$$
|
||||
packing = NEW.packing,
|
||||
available = NEW.available;
|
||||
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -5,6 +5,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemShelving_beforeIn
|
|||
BEGIN
|
||||
SET NEW.editorFk = account.myUser_getId();
|
||||
SET NEW.userFk = account.myUser_getId();
|
||||
SET NEW.available = NEW.visible;
|
||||
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -3,9 +3,15 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemShelving_beforeUp
|
|||
BEFORE UPDATE ON `itemShelving`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
|
||||
SET NEW.editorFk = account.myUser_getId();
|
||||
IF NEW.userFk IS NULL THEN
|
||||
SET NEW.userFk = account.myUser_getId();
|
||||
END IF;
|
||||
|
||||
IF (NEW.visible <> OLD.visible) THEN
|
||||
SET NEW.available = GREATEST(NEW.available + NEW.visible - OLD.visible, 0);
|
||||
END IF;
|
||||
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`supplier_afterUpdate`
|
||||
BEFORE UPDATE ON `supplier`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
IF NEW.id <> OLD.id
|
||||
OR NOT (NEW.name <=> OLD.name)
|
||||
OR NOT (NEW.street <=> OLD.street)
|
||||
OR NOT (NEW.account <=> OLD.account)
|
||||
OR NOT (NEW.nif <=> OLD.nif)
|
||||
OR NOT (NEW.isVies <=> OLD.isVies)
|
||||
OR NOT (NEW.provinceFk <=> OLD.provinceFk)
|
||||
OR NOT (NEW.countryFk <=> OLD.countryFk)
|
||||
OR NOT (NEW.postCode <=> OLD.postCode)
|
||||
OR NOT (NEW.city <=> OLD.city)
|
||||
OR NOT (NEW.taxTypeSageFk <=> OLD.taxTypeSageFk)
|
||||
OR NOT (NEW.transactionTypeSageFk <=> OLD.transactionTypeSageFk)
|
||||
OR NOT (NEW.withholdingSageFk <=> OLD.withholdingSageFk) THEN
|
||||
|
||||
UPDATE sage.clientSupplier
|
||||
SET isSync = FALSE
|
||||
WHERE idClientSupplier IN (NEW.id, OLD.id)
|
||||
AND `type` = 'P';
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -0,0 +1,11 @@
|
|||
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
||||
SQL SECURITY DEFINER
|
||||
VIEW `vn`.`expeditionTruck`
|
||||
AS SELECT `rs`.`id` AS `id`,
|
||||
`rs`.`roadmapFk` AS `roadmapFk`,
|
||||
`rs`.`eta` AS `eta`,
|
||||
`rs`.`description` AS `description`,
|
||||
`rs`.`bufferFk` AS `bufferFk`,
|
||||
`rs`.`created` AS `created`,
|
||||
`rs`.`userFk` AS `userFk`
|
||||
FROM `vn`.`roadmapStop` `rs`;
|
|
@ -0,0 +1,32 @@
|
|||
ALTER TABLE vn.itemShelvingSale DROP COLUMN IF EXISTS isPicked;
|
||||
|
||||
ALTER TABLE vn.itemShelvingSale
|
||||
ADD isPicked TINYINT(1) DEFAULT FALSE NOT NULL;
|
||||
|
||||
UPDATE vn.itemShelvingSale SET isPicked = TRUE;
|
||||
|
||||
ALTER TABLE vn.productionConfig DROP COLUMN IF EXISTS orderMode;
|
||||
|
||||
ALTER TABLE vn.productionConfig
|
||||
ADD orderMode ENUM('Location', 'Age') NOT NULL DEFAULT 'Location';
|
||||
|
||||
ALTER TABLE vn.itemShelving DROP COLUMN IF EXISTS available;
|
||||
|
||||
ALTER TABLE vn.itemShelving ADD available INT NULL;
|
||||
|
||||
UPDATE vn.itemShelving SET available = visible;
|
||||
|
||||
CREATE TABLE vn.itemShelvingSaleReserve (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`saleFk` int(11) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `itemShelvingSaleReserve_ibfk_1` (`saleFk`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci
|
||||
COMMENT='Queue of changed itemShelvingSale to reserve';
|
||||
|
||||
INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId)
|
||||
VALUES
|
||||
|
||||
('Collection', 'assignCollection', 'WRITE', 'ALLOW', 'ROLE', 'production');
|
||||
|
||||
ALTER TABLE vn.operator ADD IF NOT EXISTS isOnReservationMode TINYINT(1) NOT NULL DEFAULT FALSE;
|
|
@ -0,0 +1,5 @@
|
|||
-- Place your SQL code here
|
||||
USE vn;
|
||||
|
||||
DROP TRIGGER IF EXISTS itemShelving_AFTER_UPDATE;
|
||||
DROP TRIGGER IF EXISTS itemShelving_AFTER_INSERT;
|
|
@ -0,0 +1,5 @@
|
|||
-- Place your SQL code here
|
||||
|
||||
USE vn;
|
||||
|
||||
ALTER TABLE vn.productionConfig ADD itemOlderReviewHours int(11) DEFAULT 0 NOT NULL COMMENT 'Horas que se tienen en cuenta para comprobar si un ítem es más viejo.';
|
|
@ -0,0 +1,9 @@
|
|||
-- 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 salix.ACL (model,property,accessType,permission,principalType,principalId)
|
||||
VALUES ('TrainingCourse','*','*','ALLOW','ROLE','hr');
|
||||
INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId)
|
||||
VALUES ('TrainingCourseType','*','*','ALLOW','ROLE','hr');
|
||||
INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId)
|
||||
VALUES ('TrainingCenter','*','*','ALLOW','ROLE','hr');
|
||||
INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId)
|
||||
VALUES ('Worker','__get__trainingCourse','*','ALLOW','ROLE','hr');
|
|
@ -0,0 +1,12 @@
|
|||
UPDATE IGNORE bs.nightTask
|
||||
SET `schema` = 'vn',
|
||||
`procedure` = 'claimRatio_add'
|
||||
WHERE `procedure` = 'claim_ratio_routine';
|
||||
|
||||
ALTER TABLE vn.claimConfig
|
||||
ADD monthsToRefund int(11) DEFAULT NULL NULL,
|
||||
ADD minShipped date DEFAULT NULL NULL;
|
||||
|
||||
UPDATE IGNORE vn.claimConfig
|
||||
SET monthsToRefund = 4,
|
||||
minShipped = '2016-10-01';
|
|
@ -0,0 +1,9 @@
|
|||
|
||||
CREATE OR REPLACE TABLE sage.clientSupplier (
|
||||
`companyFk` smallint(6) NOT NULL,
|
||||
`type` ENUM('C','P') NOT NULL,
|
||||
`idClientSupplier` INT NOT NULL,
|
||||
`isSync` TINYINT(1) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`companyFk`,`idClientSupplier`,`type`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci
|
||||
COMMENT='Clients and suppliers present in Sage and their synchronization status';
|
|
@ -0,0 +1,9 @@
|
|||
-- Place your SQL code here
|
||||
|
||||
USE vn;
|
||||
|
||||
ALTER TABLE vn.productionConfig ADD sectorFromCode varchar(15) NULL COMMENT 'Sector origen que se revisa ítems más nuevos al parkinear';
|
||||
ALTER TABLE vn.productionConfig ADD sectorToCode varchar(15) NULL COMMENT 'Sector destino que se revisa ítems más nuevos al parkinear';
|
||||
|
||||
ALTER TABLE vn.productionConfig ADD CONSTRAINT productionConfig_sector_FK FOREIGN KEY (sectorFromCode) REFERENCES vn.sector(code) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE vn.productionConfig ADD CONSTRAINT productionConfig_sector_FK_1 FOREIGN KEY (sectorToCode) REFERENCES vn.sector(code) ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
@ -0,0 +1,14 @@
|
|||
-- Place your SQL code here
|
||||
|
||||
USE vn;
|
||||
|
||||
ALTER TABLE vn.itemShelving DROP FOREIGN KEY itemShelvingBuy_FK;
|
||||
ALTER TABLE vn.itemShelving DROP FOREIGN KEY itemShelving_fk2;
|
||||
ALTER TABLE vn.itemShelving DROP INDEX itemShelving_UN;
|
||||
|
||||
ALTER TABLE vn.itemShelving ADD CONSTRAINT itemShelving_fk2 FOREIGN KEY (shelvingFk) REFERENCES vn.shelving(code) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
ALTER TABLE vn.itemShelving ADD CONSTRAINT itemShelvingBuy_FK FOREIGN KEY (buyFk) REFERENCES vn.buy(id) ON DELETE RESTRICT ON UPDATE RESTRICT;
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
ALTER TABLE vn.clientUnpaid
|
||||
ADD editorFk INT UNSIGNED NULL,
|
||||
ADD CONSTRAINT ClientUnpaid_editorFk FOREIGN KEY (editorFk)
|
||||
REFERENCES account.`user`(id);
|
|
@ -0,0 +1 @@
|
|||
ALTER TABLE account.`user` DROP COLUMN password__;
|
|
@ -0,0 +1,18 @@
|
|||
-- Place your SQL code here
|
||||
CREATE TABLE IF NOT EXISTS vn.travelKgPercentage (
|
||||
value INT(3) PRIMARY KEY,
|
||||
className VARCHAR(50)
|
||||
);
|
||||
|
||||
INSERT IGNORE INTO vn.travelKgPercentage (value, className)
|
||||
VALUES
|
||||
(80, 'primary'),
|
||||
(100, 'alert');
|
||||
|
||||
INSERT IGNORE INTO salix.ACL
|
||||
SET model = 'TravelKgPercentage',
|
||||
property = '*',
|
||||
accessType = 'READ',
|
||||
permission = 'ALLOW',
|
||||
principalType = 'ROLE',
|
||||
principalId = 'employee';
|
|
@ -232,5 +232,6 @@
|
|||
"Incoterms and Customs agent are required for a non UEE member": "Incoterms and Customs agent are required for a non UEE member",
|
||||
"It has been invoiced but the PDF could not be generated": "It has been invoiced but the PDF could not be generated",
|
||||
"It has been invoiced but the PDF of refund not be generated": "It has been invoiced but the PDF of refund not be generated",
|
||||
"Cannot add holidays on this day": "Cannot add holidays on this day"
|
||||
}
|
||||
"Cannot add holidays on this day": "Cannot add holidays on this day",
|
||||
"Cannot send mail": "Cannot send mail"
|
||||
}
|
||||
|
|
|
@ -351,7 +351,7 @@
|
|||
"You are not allowed to modify the alias": "No estás autorizado a modificar el alias",
|
||||
"The address of the customer must have information about Incoterms and Customs Agent": "El consignatario del cliente debe tener informado Incoterms y Agente de aduanas",
|
||||
"The line could not be marked": "La linea no puede ser marcada",
|
||||
"This password can only be changed by the user themselves": "Esta contraseña solo puede ser modificada por el propio usuario",
|
||||
"Through this procedure, it is not possible to modify the password of users with verified email": "Mediante este procedimiento, no es posible modificar la contraseña de usuarios con correo verificado",
|
||||
"They're not your subordinate": "No es tu subordinado/a.",
|
||||
"No results found": "No se han encontrado resultados",
|
||||
"InvoiceIn is already booked": "La factura recibida está contabilizada",
|
||||
|
@ -365,5 +365,6 @@
|
|||
"You can only have one PDA": "Solo puedes tener un PDA",
|
||||
"It has been invoiced but the PDF could not be generated": "Se ha facturado pero no se ha podido generar el PDF",
|
||||
"It has been invoiced but the PDF of refund not be generated": "Se ha facturado pero no se ha podido generar el PDF del abono",
|
||||
"Payment method is required": "El método de pago es obligatorio"
|
||||
}
|
||||
"Payment method is required": "El método de pago es obligatorio",
|
||||
"Cannot send mail": "Não é possível enviar o email"
|
||||
}
|
||||
|
|
|
@ -359,5 +359,6 @@
|
|||
"Select ticket or client": "Choisissez un ticket ou un client",
|
||||
"It was not able to create the invoice": "Il n'a pas été possible de créer la facture",
|
||||
"It has been invoiced but the PDF could not be generated": "La facture a été émise mais le PDF n'a pas pu être généré",
|
||||
"It has been invoiced but the PDF of refund not be generated": "Il a été facturé mais le PDF de remboursement n'a pas été généré"
|
||||
"It has been invoiced but the PDF of refund not be generated": "Il a été facturé mais le PDF de remboursement n'a pas été généré",
|
||||
"Cannot send mail": "Impossible d'envoyer le mail"
|
||||
}
|
||||
|
|
|
@ -13,7 +13,11 @@ module.exports = Self => {
|
|||
|
||||
Self.setUnverifiedPassword = async(id, pass, options) => {
|
||||
const {emailVerified} = await models.VnUser.findById(id, {fields: ['emailVerified']}, options);
|
||||
if (emailVerified) throw new ForbiddenError('This password can only be changed by the user themselves');
|
||||
if (emailVerified) {
|
||||
throw new ForbiddenError(
|
||||
'Through this procedure, it is not possible to modify the password of users with verified email'
|
||||
);
|
||||
}
|
||||
|
||||
await models.VnUser.setPassword(id, pass, options);
|
||||
};
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
name: unpaid
|
||||
columns:
|
||||
clientFk: client
|
||||
dated: date
|
||||
amount: amount
|
|
@ -0,0 +1,5 @@
|
|||
name: impagado
|
||||
columns:
|
||||
clientFk: cliente
|
||||
dated: fecha
|
||||
amount: cantidad
|
|
@ -1,6 +1,9 @@
|
|||
{
|
||||
"name": "ClientUnpaid",
|
||||
"base": "VnModel",
|
||||
"mixins": {
|
||||
"Loggable": true
|
||||
},
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "clientUnpaid"
|
||||
|
@ -25,4 +28,4 @@
|
|||
"foreignKey": "clientFk"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethod('getListItemNewer', {
|
||||
description:
|
||||
'Get boolean if any or specific item of the shelving has older created in another shelving or parking',
|
||||
accessType: 'READ',
|
||||
accepts: [{
|
||||
arg: 'shelvingFk',
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'Shelving code'
|
||||
},
|
||||
{
|
||||
arg: 'parking',
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'Parking code'
|
||||
},
|
||||
],
|
||||
returns: {
|
||||
type: 'Array',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/getListItemNewer`,
|
||||
verb: 'GET'
|
||||
}
|
||||
});
|
||||
|
||||
Self.getListItemNewer = async(shelvingFk, parking, options) => {
|
||||
const myOptions = {};
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
const [isParkingToReview] = await Self.rawSql(`
|
||||
SELECT COUNT(p.id) parkingToReview
|
||||
FROM vn.parking p
|
||||
JOIN vn.sector s ON s.id = p.sectorFk
|
||||
JOIN vn.productionConfig pc
|
||||
WHERE p.code = ? AND s.code = pc.sectorToCode;`,
|
||||
[parking], myOptions);
|
||||
|
||||
if (isParkingToReview['parkingToReview'] < 1) return [];
|
||||
|
||||
const result = await Self.rawSql(`
|
||||
WITH tItemShelving AS(
|
||||
SELECT is2.itemFk, is2.created, p.sectorFK, is2.id
|
||||
FROM vn.itemShelving is2
|
||||
JOIN vn.shelving sh ON sh.code = is2.shelvingFk
|
||||
JOIN vn.parking p ON p.id = sh.parkingFk
|
||||
JOIN vn.sector s ON s.id = p.sectorFk
|
||||
JOIN vn.productionConfig pc
|
||||
WHERE is2.shelvingFk = ? AND s.code = pc.sectorFromCode
|
||||
), tItemInSector AS (
|
||||
SELECT is2.itemFk, is2.created, is2.shelvingFk
|
||||
FROM vn.itemShelving is2
|
||||
JOIN vn.shelving sh ON sh.code = is2.shelvingFk
|
||||
JOIN vn.parking p ON p.id = sh.parkingFk
|
||||
JOIN vn.sector s ON s.id = p.sectorFk
|
||||
JOIN vn.productionConfig pc
|
||||
WHERE is2.shelvingFk <> ?
|
||||
AND s.code = pc.sectorFromCode)
|
||||
SELECT ti.itemFK, tis.shelvingFk
|
||||
FROM tItemShelving ti
|
||||
JOIN tItemInSector tis ON tis.itemFk = ti.itemFk
|
||||
JOIN vn.productionConfig pc
|
||||
WHERE ti.created > tis.created + INTERVAL pc.itemOlderReviewHours HOUR;`,
|
||||
[shelvingFk, shelvingFk], myOptions);
|
||||
return result;
|
||||
};
|
||||
};
|
|
@ -1,63 +0,0 @@
|
|||
const UserError = require('vn-loopback/util/user-error');
|
||||
module.exports = Self => {
|
||||
Self.remoteMethod('hasItemOlder', {
|
||||
description:
|
||||
'Get boolean if any or specific item of the shelving has older created in another shelving or parking',
|
||||
accessType: 'READ',
|
||||
accepts: [{
|
||||
arg: 'shelvingFkIn',
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'Shelving code'
|
||||
},
|
||||
{
|
||||
arg: 'parking',
|
||||
type: 'string',
|
||||
description: 'Parking code'
|
||||
},
|
||||
{
|
||||
arg: 'shelvingFkOut',
|
||||
type: 'string',
|
||||
description: 'Shelving code'
|
||||
},
|
||||
{
|
||||
arg: 'itemFk',
|
||||
type: 'integer',
|
||||
description: 'Item id'
|
||||
}],
|
||||
returns: {
|
||||
type: 'boolean',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/hasItemOlder`,
|
||||
verb: 'GET'
|
||||
}
|
||||
});
|
||||
|
||||
Self.hasItemOlder = async(shelvingFkIn, parking, shelvingFkOut, itemFk, options) => {
|
||||
if (!parking && !shelvingFkOut) throw new UserError('Missing data: parking or shelving');
|
||||
|
||||
const myOptions = {};
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
const result = await Self.rawSql(`
|
||||
SELECT COUNT(ish.id) countItemOlder
|
||||
FROM vn.itemShelving ish
|
||||
JOIN (
|
||||
SELECT ish.itemFk, created,shelvingFk
|
||||
FROM vn.itemShelving ish
|
||||
JOIN vn.shelving s ON ish.shelvingFk = s.code
|
||||
WHERE ish.shelvingFk = ?
|
||||
)sub ON sub.itemFK = ish.itemFk
|
||||
JOIN vn.shelving s ON s.code = ish.shelvingFk
|
||||
JOIN vn.parking p ON p.id = s.parkingFk
|
||||
WHERE sub.created > ish.created
|
||||
AND (p.code <> ? OR ? IS NULL)
|
||||
AND (ish.shelvingFk <> ? OR ? IS NULL)
|
||||
AND (ish.itemFk <> ? OR ? IS NULL)`,
|
||||
[shelvingFkIn, parking, parking, shelvingFkOut, shelvingFkOut, itemFk, itemFk], myOptions);
|
||||
return result[0]['countItemOlder'] > 0;
|
||||
};
|
||||
};
|
|
@ -0,0 +1,45 @@
|
|||
|
||||
const {models} = require('vn-loopback/server/server');
|
||||
|
||||
describe('itemShelving getListItemNewer()', () => {
|
||||
it('should return true because there is an older item', async() => {
|
||||
const shelving = 'NCC';
|
||||
const parking = 'A-47-1';
|
||||
|
||||
const sectorCamHighCode = 'CAMARA SECTOR D';
|
||||
const sectorCamCode = 'NAVE ALGEMESI';
|
||||
|
||||
const sectorCamCodeHighId = 1;
|
||||
const sectorCamCodeId = 9991;
|
||||
|
||||
const tx = await models.Sector.beginTransaction({});
|
||||
const myOptions = {transaction: tx};
|
||||
|
||||
try {
|
||||
const sectorHighCam = await models.Sector.findById(sectorCamCodeHighId, null, myOptions);
|
||||
await sectorHighCam.updateAttributes({
|
||||
code: sectorCamHighCode
|
||||
});
|
||||
|
||||
const sectorCam = await models.Sector.findById(sectorCamCodeId, null, myOptions);
|
||||
await sectorCam.updateAttributes({
|
||||
code: sectorCamCode
|
||||
});
|
||||
|
||||
const config = await models.ProductionConfig.findOne();
|
||||
|
||||
await config.updateAttributes({
|
||||
sectorToCode: sectorCamHighCode,
|
||||
sectorFromCode: sectorCamCode
|
||||
});
|
||||
|
||||
const result = await models.ItemShelving.getListItemNewer(shelving, parking, myOptions);
|
||||
|
||||
expect(result.length).toEqual(2);
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
});
|
|
@ -1,45 +0,0 @@
|
|||
|
||||
const {models} = require('vn-loopback/server/server');
|
||||
|
||||
describe('itemShelving hasOlder()', () => {
|
||||
it('should return false because there are not older items', async() => {
|
||||
const shelvingFkIn = 'GVC';
|
||||
const shelvingFkOut = 'HEJ';
|
||||
const result = await models.ItemShelving.hasItemOlder(shelvingFkIn, null, shelvingFkOut);
|
||||
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
|
||||
it('should return false because there are not older items in parking', async() => {
|
||||
const shelvingFkIn = 'HEJ';
|
||||
const parking = '700-01';
|
||||
const result = await models.ItemShelving.hasItemOlder(shelvingFkIn, parking);
|
||||
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
|
||||
it('should return true because there is an older item', async() => {
|
||||
const shelvingFkIn = 'UXN';
|
||||
const shelvingFkOut = 'PCC';
|
||||
const parking = 'A-01-1';
|
||||
const itemFk = 1;
|
||||
|
||||
const tx = await models.ItemShelving.beginTransaction({});
|
||||
const myOptions = {transaction: tx};
|
||||
const filter = {where: {shelvingFk: shelvingFkOut}
|
||||
};
|
||||
try {
|
||||
const itemShelvingBefore = await models.ItemShelving.findOne(filter, myOptions);
|
||||
await itemShelvingBefore.updateAttributes({
|
||||
itemFk: itemFk
|
||||
}, myOptions);
|
||||
const result = await models.ItemShelving.hasItemOlder(shelvingFkIn, parking, null, null, myOptions);
|
||||
|
||||
expect(result).toBe(true);
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
});
|
|
@ -4,5 +4,5 @@ module.exports = Self => {
|
|||
require('../methods/item-shelving/getInventory')(Self);
|
||||
require('../methods/item-shelving/getAlternative')(Self);
|
||||
require('../methods/item-shelving/updateFromSale')(Self);
|
||||
require('../methods/item-shelving/hasItemOlder')(Self);
|
||||
require('../methods/item-shelving/getListItemNewer')(Self);
|
||||
};
|
||||
|
|
|
@ -20,21 +20,4 @@ module.exports = Self => {
|
|||
require('../methods/route/cmrEmail')(Self);
|
||||
require('../methods/route/getExpeditionSummary')(Self);
|
||||
require('../methods/route/getByWorker')(Self);
|
||||
|
||||
Self.validate('kmStart', validateDistance, {
|
||||
message: 'Distance must be lesser than 4000'
|
||||
});
|
||||
|
||||
Self.validate('kmEnd', validateDistance, {
|
||||
message: 'Distance must be lesser than 4000'
|
||||
});
|
||||
|
||||
function validateDistance(err) {
|
||||
if (this.kmEnd) {
|
||||
const routeTotalKm = this.kmEnd - this.kmStart;
|
||||
const routeMaxKm = 4000;
|
||||
if (routeTotalKm > routeMaxKm || this.kmStart > this.kmEnd)
|
||||
err();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -145,15 +145,10 @@ module.exports = Self => {
|
|||
|
||||
const newTicket = await models.Ticket.new(ctx, myOptions);
|
||||
|
||||
const ticketRefund = await models.TicketRefund.findOne({
|
||||
where: {refundTicketFk: ticketId}
|
||||
await models.TicketRefund.create({
|
||||
originalTicketFk: ticketId,
|
||||
refundTicketFk: newTicket.id
|
||||
}, myOptions);
|
||||
if (negative && (withWarehouse || !ticketRefund?.id)) {
|
||||
await models.TicketRefund.create({
|
||||
originalTicketFk: ticketId,
|
||||
refundTicketFk: newTicket.id
|
||||
}, myOptions);
|
||||
}
|
||||
|
||||
return newTicket;
|
||||
}
|
||||
|
|
|
@ -140,7 +140,7 @@ module.exports = Self => {
|
|||
await models.TicketDms.create({ticketFk: ticket.id, dmsFk: dms[0].id}, myOptions);
|
||||
await ticket.updateAttribute('isSigned', true, myOptions);
|
||||
|
||||
await Self.rawSql(`CALL vn.ticket_setState(?, ?)`, [params.ticketFk, params.code], myOptions);
|
||||
await Self.rawSql(`CALL vn.ticket_setState(?, ?)`, [ticketId, 'DELIVERED'], myOptions);
|
||||
|
||||
if (ticket?.address()?.province()?.country()?.code != 'ES' && ticket.cmrFk) {
|
||||
await models.Ticket.saveCmr(ctx, [ticketId], myOptions);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('ticket state()', () => {
|
||||
xdescribe('ticket state()', () => {
|
||||
const salesPersonId = 18;
|
||||
const employeeId = 1;
|
||||
const productionId = 49;
|
||||
|
@ -113,6 +113,7 @@ describe('ticket state()', () => {
|
|||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
spyOn(models.Chat, 'sendCheckingPresence').and.callThrough();
|
||||
const ticket = await models.Ticket.create(sampleTicket, options);
|
||||
activeCtx.accessToken.userId = salesPersonId;
|
||||
const assignedState = await models.State.findOne({where: {code: 'PICKER_DESIGNED'}}, options);
|
||||
|
@ -124,6 +125,7 @@ describe('ticket state()', () => {
|
|||
expect(resAssigned.userFk).toBe(paramsAssigned.userFk);
|
||||
expect(resAssigned.userFk).toBe(1);
|
||||
expect(resAssigned.id).toBeDefined();
|
||||
expect(models.Chat.sendCheckingPresence).not.toHaveBeenCalled();
|
||||
|
||||
activeCtx.accessToken.userId = productionId;
|
||||
const packedState = await models.State.findOne({where: {code: 'PACKED'}}, options);
|
||||
|
@ -183,5 +185,37 @@ describe('ticket state()', () => {
|
|||
throw e;
|
||||
}
|
||||
});
|
||||
|
||||
it('should not call sendCheckingPresence if sales.length is 0 because quantities are equal', async() => {
|
||||
const tx = await models.TicketTracking.beginTransaction({});
|
||||
spyOn(models.Chat, 'sendCheckingPresence').and.callThrough();
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
const ticket = await models.Ticket.create(sampleTicket, options);
|
||||
activeCtx.accessToken.userId = productionId;
|
||||
|
||||
const sampleSale = {
|
||||
ticketFk: ticket.id,
|
||||
itemFk: 1,
|
||||
concept: 'Test',
|
||||
quantity: 10,
|
||||
originalQuantity: 10
|
||||
};
|
||||
await models.Sale.create(sampleSale, options);
|
||||
|
||||
const packedState = await models.State.findOne({where: {code: 'PACKED'}}, options);
|
||||
const params = {ticketFk: ticket.id, stateFk: packedState.id};
|
||||
|
||||
await models.Ticket.state(ctx, params, options);
|
||||
|
||||
expect(models.Chat.sendCheckingPresence).not.toHaveBeenCalled();
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -26,7 +26,6 @@ module.exports = Self => {
|
|||
const models = Self.app.models;
|
||||
const myOptions = {};
|
||||
let tx;
|
||||
let newStateOrder;
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
@ -41,16 +40,11 @@ module.exports = Self => {
|
|||
throw new UserError('State cannot be blank');
|
||||
|
||||
if (params.stateFk) {
|
||||
const {code, order} = await models.State.findById(
|
||||
params.stateFk,
|
||||
{fields: ['code', 'order']},
|
||||
myOptions);
|
||||
const {code} = await models.State.findById(params.stateFk, {fields: ['code']}, myOptions);
|
||||
params.code = code;
|
||||
newStateOrder = order;
|
||||
} else {
|
||||
const {id, order} = await models.State.findOne({where: {code: params.code}}, myOptions);
|
||||
const {id} = await models.State.findOne({where: {code: params.code}}, myOptions);
|
||||
params.stateFk = id;
|
||||
newStateOrder = order;
|
||||
}
|
||||
|
||||
if (!params.userFk) {
|
||||
|
@ -70,59 +64,7 @@ module.exports = Self => {
|
|||
if ((ticketState && !oldStateAllowed) || !newStateAllowed)
|
||||
throw new UserError(`You don't have enough privileges`, 'ACCESS_DENIED');
|
||||
|
||||
const ticket = await models.Ticket.findById(params.ticketFk, {
|
||||
include: [{
|
||||
relation: 'client',
|
||||
scope: {
|
||||
fields: ['salesPersonFk']
|
||||
}
|
||||
}],
|
||||
fields: ['id', 'clientFk']
|
||||
}, myOptions);
|
||||
|
||||
const salesPersonFk = ticket.client().salesPersonFk;
|
||||
const stateChecked = await models.State.findOne({fields: ['order'], where: {code: 'CHECKED'}});
|
||||
|
||||
if (salesPersonFk && newStateOrder >= stateChecked.order) {
|
||||
const sales = await Self.rawSql(`
|
||||
SELECT DISTINCT s.id,
|
||||
s.itemFk,
|
||||
s.concept,
|
||||
s.originalQuantity AS oldQuantity,
|
||||
s.quantity AS newQuantity
|
||||
FROM vn.sale s
|
||||
WHERE s.ticketFk = ?
|
||||
AND s.originalQuantity IS NOT NULL
|
||||
AND s.originalQuantity <> s.quantity
|
||||
`, [params.ticketFk], myOptions);
|
||||
|
||||
if (sales.length) {
|
||||
let changes = '';
|
||||
const url = await models.Url.getUrl();
|
||||
const $t = ctx.req.__;
|
||||
for (let sale of sales) {
|
||||
changes += `\r\n-` + $t('Changes in sales', {
|
||||
itemId: sale.itemFk,
|
||||
concept: sale.concept,
|
||||
oldQuantity: sale.oldQuantity,
|
||||
newQuantity: sale.newQuantity,
|
||||
itemUrl: `${url}item/${sale.itemFk}/summary`
|
||||
});
|
||||
const currentSale = await models.Sale.findById(sale.id, null, myOptions);
|
||||
await currentSale.updateAttributes({
|
||||
originalQuantity: currentSale.quantity
|
||||
}, myOptions);
|
||||
}
|
||||
|
||||
const message = $t('Changed sale quantity', {
|
||||
ticketId: ticket.id,
|
||||
changes: changes,
|
||||
ticketUrl: `${url}ticket/${ticket.id}/sale`
|
||||
});
|
||||
await models.Chat.sendCheckingPresence(ctx, salesPersonFk, message, myOptions);
|
||||
}
|
||||
}
|
||||
await Self.rawSql(`CALL vn.ticket_setState(?, ?)`, [ticket.id, params.code], myOptions);
|
||||
await Self.rawSql(`CALL vn.ticket_setState(?, ?)`, [params.ticketFk, params.code], myOptions);
|
||||
|
||||
const ticketTracking = await models.TicketTracking.findOne({
|
||||
where: {ticketFk: params.ticketFk},
|
||||
|
|
|
@ -42,7 +42,9 @@ describe('worker setPassword()', () => {
|
|||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
expect(e.message).toEqual(`This password can only be changed by the user themselves`);
|
||||
expect(e.message).toEqual(
|
||||
'Through this procedure, it is not possible to modify the password of users with verified email'
|
||||
);
|
||||
await tx.rollback();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -124,6 +124,15 @@
|
|||
},
|
||||
"Locker": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"TrainingCourse": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"TrainingCourseType": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"TrainingCenter": {
|
||||
"dataSource": "vn"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"name": "TrainingCenter",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "trainingCenter"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "number",
|
||||
"id": true,
|
||||
"description": "Identifier"
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"required": true
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
{
|
||||
"name": "TrainingCourse",
|
||||
"description": "List of workers who have completed training",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "trainingCourse"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "number",
|
||||
"id": true,
|
||||
"description": "Identifier"
|
||||
},
|
||||
"workerFk": {
|
||||
"type": "number",
|
||||
"required": true
|
||||
},
|
||||
"trainingCourseTypeFk": {
|
||||
"type": "number",
|
||||
"required": true
|
||||
},
|
||||
"centerFk": {
|
||||
"type" : "number"
|
||||
},
|
||||
"started": {
|
||||
"type" : "date"
|
||||
},
|
||||
"ended": {
|
||||
"type" : "date"
|
||||
},
|
||||
"invoice": {
|
||||
"type" : "string"
|
||||
},
|
||||
"amount": {
|
||||
"type" : "number"
|
||||
},
|
||||
"remark": {
|
||||
"type" : "boolean"
|
||||
},
|
||||
"hasDiscount": {
|
||||
"type" : "boolean"
|
||||
},
|
||||
"hasDiploma": {
|
||||
"type" : "boolean"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"worker": {
|
||||
"type": "belongsTo",
|
||||
"model": "Worker",
|
||||
"foreignKey": "workerFk"
|
||||
},
|
||||
"trainingCourseType": {
|
||||
"type": "belongsTo",
|
||||
"model": "TrainingCourseType",
|
||||
"foreignKey": "trainingCourseTypeFk"
|
||||
},
|
||||
"trainingCenter": {
|
||||
"type": "belongsTo",
|
||||
"model": "TrainingCenter",
|
||||
"foreignKey": "centerFk"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"name": "TrainingCourseType",
|
||||
"description": "List of trainings",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "trainingCourseType"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "number",
|
||||
"id": true,
|
||||
"description": "Identifier"
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"required": true
|
||||
}
|
||||
}
|
||||
}
|
|
@ -115,6 +115,11 @@
|
|||
"type": "hasMany",
|
||||
"model": "Locker",
|
||||
"foreignKey": "workerFk"
|
||||
},
|
||||
"trainingCourse": {
|
||||
"type": "hasMany",
|
||||
"model": "TrainingCourse",
|
||||
"foreignKey": "workerFk"
|
||||
}
|
||||
},
|
||||
"acls": [
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
? 'Click to allow the user to be disabled'
|
||||
: 'Click to exclude the user from getting disabled'}}
|
||||
</vn-item>
|
||||
<vn-item ng-if="!$ctrl.worker.user.emailVerified && $ctrl.vnConfig.storage.currentUserWorkerId !=$ctrl.worker.id" ng-click="setPassword.show()" translate>
|
||||
<vn-item ng-click="setPassword.show()" translate>
|
||||
Change password
|
||||
</vn-item>
|
||||
</slot-menu>
|
||||
|
|
|
@ -2,6 +2,7 @@ const path = require('path');
|
|||
const smtp = require('./smtp');
|
||||
const Component = require('./component');
|
||||
const Report = require('./report');
|
||||
const UserError = require('vn-loopback/util/user-error');
|
||||
|
||||
if (!process.env.OPENSSL_CONF)
|
||||
process.env.OPENSSL_CONF = '/etc/ssl/';
|
||||
|
@ -9,7 +10,6 @@ if (!process.env.OPENSSL_CONF)
|
|||
class Email extends Component {
|
||||
constructor(name, args) {
|
||||
super(name);
|
||||
|
||||
this.args = args;
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,11 @@ class Email extends Component {
|
|||
force: options.force
|
||||
};
|
||||
|
||||
return await smtp.send(mailOptions);
|
||||
try {
|
||||
return await smtp.send(mailOptions);
|
||||
} catch (error) {
|
||||
throw new UserError('Cannot send mail');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ module.exports = {
|
|||
this.checkMainEntity(this.invoice);
|
||||
this.client = await this.findOneFromDef('client', [this.reference]);
|
||||
this.incoterms =
|
||||
await this.findOneFromDef('incoterms', [this.reference, this.reference, this.reference, this.reference]);
|
||||
await this.findOneFromDef('incoterms', [this.reference]);
|
||||
if (!this.incoterms)
|
||||
throw new UserError(`The address of the customer must have information about Incoterms and Customs Agent`);
|
||||
},
|
||||
|
|
|
@ -1,52 +1,31 @@
|
|||
SELECT pack.packages,
|
||||
a.incotermsFk,
|
||||
ic.name incotermsName,
|
||||
t.weight,
|
||||
ca.fiscalName customsAgentName,
|
||||
ca.street customsAgentStreet,
|
||||
ca.nif customsAgentNif,
|
||||
ca.phone customsAgentPhone,
|
||||
ca.email customsAgentEmail,
|
||||
CAST(vol.volume AS DECIMAL (10,2)) volume,
|
||||
intr.intrastat
|
||||
FROM vn.invoiceOut io
|
||||
JOIN vn.supplier su ON su.id = io.companyFk
|
||||
JOIN vn.client c ON c.id = io.clientFk
|
||||
LEFT JOIN vn.province p ON p.id = c.provinceFk
|
||||
JOIN vn.ticket t ON t.refFk = io.ref
|
||||
JOIN vn.address a ON a.id = t.addressFk
|
||||
JOIN vn.incoterms ic ON ic.code = a.incotermsFk
|
||||
LEFT JOIN vn.customsAgent ca ON ca.id = a.customsAgentFk
|
||||
JOIN vn.sale s ON s.ticketFk = t.id
|
||||
JOIN (
|
||||
SELECT SUM(volume) volume, COUNT(*) packages
|
||||
FROM vn.invoiceOut io
|
||||
JOIN vn.ticket t ON t.refFk = io.ref
|
||||
JOIN vn.saleVolume sv ON sv.ticketFk = t.id
|
||||
WHERE t.refFk = ?
|
||||
) vol
|
||||
JOIN vn.itemTaxCountry itc ON itc.countryFk = su.countryFk
|
||||
AND itc.itemFk = s.itemFk
|
||||
JOIN vn.taxClass tc ON tc.id = itc.taxClassFk
|
||||
JOIN vn.invoiceOutSerial ios ON ios.code = io.serial
|
||||
AND ios.taxAreaFk = 'WORLD'
|
||||
JOIN vn.country cty ON cty.id = c.countryFk
|
||||
JOIN vn.payMethod pm ON pm.id = c .payMethodFk
|
||||
JOIN vn.company co ON co.id=io.companyFk
|
||||
JOIN vn.supplierAccount sa ON sa.id=co.supplierAccountFk
|
||||
JOIN (
|
||||
SELECT GROUP_CONCAT(DISTINCT ir.description ORDER BY ir.description SEPARATOR '. ' ) intrastat
|
||||
FROM vn.ticket t
|
||||
JOIN vn.invoiceOut io ON io.ref = t.refFk
|
||||
JOIN vn.sale s ON t.id = s.ticketFk
|
||||
JOIN vn.item i ON i.id = s.itemFk
|
||||
JOIN vn.intrastat ir ON ir.id = i.intrastatFk
|
||||
WHERE t.refFk = ?
|
||||
) intr
|
||||
JOIN (
|
||||
SELECT SUM(packages) packages
|
||||
FROM ticket
|
||||
WHERE refFk = ?
|
||||
) pack
|
||||
WHERE t.refFk = ?
|
||||
LIMIT 1
|
||||
WITH tickets AS(
|
||||
SELECT id, packages, addressFk, weight
|
||||
FROM ticket
|
||||
WHERE refFk= ?
|
||||
), volume AS(
|
||||
SELECT SUM(volume) volume
|
||||
FROM tickets t
|
||||
JOIN vn.saleVolume sv ON sv.ticketFk = t.id
|
||||
), intrastat AS(
|
||||
SELECT GROUP_CONCAT(DISTINCT ir.description ORDER BY ir.description SEPARATOR '. ' ) intrastat
|
||||
FROM tickets t
|
||||
JOIN vn.sale s ON t.id = s.ticketFk
|
||||
JOIN vn.item i ON i.id = s.itemFk
|
||||
JOIN vn.intrastat ir ON ir.id = i.intrastatFk
|
||||
)SELECT SUM(t.packages),
|
||||
a.incotermsFk,
|
||||
ic.name incotermsName,
|
||||
MAX(t.weight) weight,
|
||||
ca.fiscalName customsAgentName,
|
||||
ca.street customsAgentStreet,
|
||||
ca.nif customsAgentNif,
|
||||
ca.phone customsAgentPhone,
|
||||
ca.email customsAgentEmail,
|
||||
CAST(v.volume AS DECIMAL (10,2)) volume,
|
||||
i.intrastat
|
||||
FROM tickets t
|
||||
JOIN vn.address a ON a.id = t.addressFk
|
||||
JOIN vn.incoterms ic ON ic.code = a.incotermsFk
|
||||
LEFT JOIN vn.customsAgent ca ON ca.id = a.customsAgentFk
|
||||
JOIN volume v
|
||||
JOIN intrastat i
|
||||
|
|
Loading…
Reference in New Issue