Merge branch 'dev' into 7567-movingCleanFix
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Guillermo Bonet 2024-08-21 07:34:05 +00:00
commit 0bd64a790e
673 changed files with 10053 additions and 23839 deletions

View File

@ -1,3 +1,141 @@
# Version 24.32 - 2024-08-06
### Added 🆕
- chore: refs #7197 add supplierActivityFk filter by:jorgep
- feat checkExpeditionPrintOut refs #7751 by:sergiodt
- feat(defaulter_filter): add department by:alexm
- feat: redirect to lilium page not found by:alexm
- feat: refactor buyUltimate refs #7736 by:Carlos Andrés
- feat: refs #6403 add delete by:pablone
- feat: refs #7126 Added manaClaim calc by:guillermo
- feat: refs #7126 Refactor and added columns in bs.waste table & proc by:guillermo
- feat: refs #7197 filter by correcting by:jorgep
- feat: refs #7297 add new columns by:pablone
- feat: refs #7356 new parameters in sql for Weekly tickets front by:Jon
- feat: refs #7401 redirect lilium by:pablone
- feat: refs #7511 Fix tests by:guillermo
- feat: refs #7511 Rename to multiConfig tables by:guillermo
- feat: refs #7589 Added display (item_valuateInventory) by:guillermo
- feat: refs #7589 Added vItemTypeFk & vItemCategoryFk (item_valuateInventory) by:guillermo
- feat: refs #7681 Changes by:guillermo
- feat: refs #7681 Optimization and refactor by:guillermo
- feat: refs #7683 drop temporary table by:robert
- feat: refs #7683 productionControl by:robert
- feat: refs #7728 Added throw due date by:guillermo
- feat: refs #7740 Ticket before update added restriction by:guillermo
- feat(salix): #7648 Add field for endpoint as buyLabel report by:Javier Segarra
- feat(salix): #7648 remove white line by:Javier Segarra
- feat: tabla config dias margen vctos. refs #7728 by:Carlos Andrés
### Changed 📦
- eat: refactor buyUltimate refs #7736 by:Carlos Andrés
- feat: refactor buyUltimate refs #7736 by:Carlos Andrés
- feat: refs #7681 Optimization and refactor by:guillermo
- refactor: refs #7126 Requested changes by:guillermo
- refactor: refs #7511 Minor change by:guillermo
- refactor: refs #7640 Multipleinventory available by:guillermo
- refactor: refs #7681 Changes by:guillermo
- refactor: refs #7681 Requested changes by:guillermo
### Fixed 🛠️
- add prefix (hotFix_liliumRedirection) by:alexm
- fix(client_filter): add recovery by:alexm
- fix: defaulter filter correct sql (6943-fix_defaulter_filter) by:alexm
- fix(deletExpeditions): merge test → dev by:guillermo
- fix: refs #6403 fix mrw cancel shipment return type by:pablone
- fix: refs #7126 Added addressWaste type by:guillermo
- fix: refs #7126 Fix by:guillermo
- fix: refs #7126 Minor change by:guillermo
- fix: refs #7126 Primary key no unique data by:guillermo
- fix: refs #7126 Slow update by:guillermo
- fix: refs #7511 Minor change by:guillermo
- fix: refs #7546 Deleted insert util.binlogQueue by:guillermo
- fix: refs #7811 Variables pm2 by:guillermo
- fix: without path by:alexm
# Version 24.28 - 2024-07-09
### Added 🆕
- feat boxPicking refs #7357 by:sergiodt
- feat boxPicking refs #7357 (origin/7357_dipole_review) by:sergiodt
- feat:concurrency issue refs #6861 by:Carlos Andrés
- feat expeditionPalletPrint refs #5210 by:sergiodt
- feat front-reservas refs #6861 (origin/6861-Reservas-front) by:sergiodt
- feat itemShelving_filterBuyer refs #7023 by:sergiodt
- feat itemShelvingLog refs #7168 by:sergiodt
- feat itemShelvingSale refs #6861 by:sergiodt
- feat: previas con reserva refs #6861 by:Carlos Andrés
- feat: previas con sitema de reservas refs #6861 by:Carlos Andrés
- feat: previas con sitema de reservas refs #6861 (origin/6861-Pasar-modo-trabajo-de-previa-a-reservas) by:Carlos Andrés
- feat refactor setParking REGEXP refs #7575 (origin/7575_setParking_regExp) by:sergiodt
- feat: refs #6238 add travelKgPercentage table and model (origin/6238-addPercentage) by:jorgep
- feat: refs #6286 check if is teamBoss (origin/6286-setRightWorkerTimeControlAcls) by:jorgep
- feat: refs #6701 Fix error by:guillermo
- feat: refs #6861 trigger by:sergiodt
- feat: refs #7027 mailError managed by:jgallego
- feat: refs #7168 Added vRecords param in proc by:guillermo
- feat: refs #7168 Minor change by:guillermo
- feat: refs #7216 logUnpaid (origin/7216-clientUnpaid) by:jgallego
- feat: refs #7216 triggers by:jgallego
- feat: refs #7296 by:robert
- feat: refs #7296 drop column expeditionTruckFk by:robert
- feat: refs #7490 Changes (origin/7490-duaInvoiceInBooking) by:guillermo
- feat: refs #7545 Deleted hasIncoterms client column (origin/7545-hasIncoterms) by:guillermo
- feat: refs #7555 remove account.password__ by:alexm
- feat: return sql check error by:alexm
- feat roadmap refs #7195 by:sergiodt
- #refs 5890 feat:add assignCollection by:sergiodt
- refs#5890 feat: delete trigger and modify getTickets by:sergiodt
- refs #5890 feat:itemShelving_add by:sergiodt
- refs #5890 feat:reserves by:sergiodt
- refs #5890 feat:trigger by:sergiodt
- refs #5890 feat: triggers by:sergiodt
- refs #6861 feat: getLock by:sergiodt
- refs #6861 feat: obsrevation by:sergiodt
- refs #6861 feat: previas a reservas by:sergiodt
- refs #6861 feat:reserve previos by:sergiodt
- refs #6861 feat: reservePrevious by:sergiodt
- refs #6861 feat:reserveWithReservation by:sergiodt
- refs #6861 feat:sectoCollection reserve by:sergiodt
- refs #6861 feat: skipTest by:sergiodt
- refs #6861 feat: trigger by:sergiodt
### Changed 📦
- feat refactor setParking REGEXP refs #7575 (origin/7575_setParking_regExp) by:sergiodt
- refactor: refs #5447 changed models by:Jon
- refactor: refs #6238 drop useless round by:jorgep
- refactor: refs #6286 replace name by:jorgep
- refactor: refs #6701 Refactor claim_ratio_routine by:guillermo
- refactor: refs #7490 Added final update by:guillermo
- refactor: refs #7490 Deleted update duaInvoiceInBooking by:guillermo
- refactor: refs #7490 Minor changes by:guillermo
- refactor: refs #7519 Minor change by:guillermo
### Fixed 🛠️
- acls, fixtures, models by:carlossa
- fix: refs #6238 delete unused SQL script by:jorgep
- fix: refs #6238 insert ignore by:jorgep
- fix: refs #6238 use scheme by:jorgep
- fix: refs #6286 replace id for reason by:jorgep
- fix: refs #6286 update WorkerTimeControl permissions by:jorgep
- fix(WorkerIncome): refs #7409 fix models by:alexm
- refs #5890 fix: dev by:sergiodt
- refs #6897 fix entry Salix by:carlossa
- refs #6897 fix es.yml by:carlossa
- refs #6897 fix redirection by:carlossa
- refs #6897 fix remove by:carlossa
- refs #7406 fix back by:carlossa
- refs #7406 fix pr by:carlossa
- refs #7409 fix acls by:carlossa
- refs #7409 fix back (origin/7409-workerIncome) by:carlossa
- refs #7409 fix pr by:carlossa
# Version 24.24 - 2024-06-11
### Added 🆕

View File

@ -20,9 +20,14 @@ module.exports = Self => {
if (typeof options == 'object')
Object.assign(myOptions, options);
const [, , [{collectionFk}]] =
await Self.rawSql('CALL vn.collection_assign(?, @vCollectionFk); SELECT @vCollectionFk collectionFk',
[userId], myOptions);
const randStr = Math.random().toString(36).substring(3);
const result = await Self.rawSql(`
CALL vn.collection_assign(?, @vCollectionFk);
SELECT @vCollectionFk ?
`, [userId, randStr], myOptions);
// Por si entra en SELECT FOR UPDATE una o varias veces
const collectionFk = result.find(item => item[0]?.[randStr] !== undefined)?.[0]?.[randStr];
if (!collectionFk) throw new UserError('There are not picking tickets');
await Self.rawSql('CALL vn.collection_printSticker(?, NULL)', [collectionFk], myOptions);

View File

@ -57,14 +57,15 @@ module.exports = Self => {
ROW_NUMBER () OVER (PARTITION BY s.id ORDER BY pickingOrder) currentItemShelving,
COUNT(*) OVER (PARTITION BY s.id ORDER BY s.id) totalItemShelving,
sh.code,
IFNULL(p2.code, p.code) parkingCode,
IFNULL(p2.pickingOrder, p.pickingOrder) pickingOrder,
p2.code parkingCode,
p2.pickingOrder pickingOrder,
p.code parkingCodePrevia,
p.pickingOrder pickingOrderPrevia,
iss.id itemShelvingSaleFk,
iss.isPicked
FROM ticketCollection tc
LEFT JOIN collection c ON c.id = tc.collectionFk
JOIN ticket t ON t.id = tc.ticketFk
JOIN sale s ON s.ticketFk = t.id
JOIN sale s ON s.ticketFk = tc.ticketFk
LEFT JOIN saleGroupDetail sgd ON sgd.saleFk = s.id
LEFT JOIN saleGroup sg ON sg.id = sgd.saleGroupFk
LEFT JOIN parking p2 ON p2.id = sg.parkingFk
@ -96,16 +97,17 @@ module.exports = Self => {
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),
p2.code,
p2.pickingOrder,
p.code,
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 saleGroupDetail sgd ON sgd.saleGroupFk = sg.id
JOIN sale s ON s.id = sgd.saleFk
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

View File

@ -24,7 +24,7 @@ module.exports = Self => {
try {
const options = {transaction: tx, userId: ctx.req.accessToken.userId};
const files = await Self.rawSql('SELECT name, checksum, keyValue FROM edi.fileConfig', null, options);
const files = await Self.rawSql('SELECT name, checksum, keyValue FROM edi.fileMultiConfig', null, options);
const updatableFiles = [];
for (const file of files) {
@ -54,7 +54,7 @@ module.exports = Self => {
const tables = await Self.rawSql(`
SELECT fileName, toTable, file
FROM edi.tableConfig
FROM edi.tableMultiConfig
WHERE file IN (?)`, [fileNames], options);
for (const table of tables) {
@ -85,9 +85,9 @@ module.exports = Self => {
for (const file of updatableFiles) {
console.log(`Updating file ${file.name} checksum...`);
await Self.rawSql(`
UPDATE edi.fileConfig
SET checksum = ?
WHERE name = ?`,
UPDATE edi.fileMultiConfig
SET checksum = ?
WHERE name = ?`,
[file.checksum, file.name], options);
}
@ -228,7 +228,7 @@ module.exports = Self => {
await Self.rawSql(sqlTemplate, [filePath], options);
await Self.rawSql(`
UPDATE edi.tableConfig
UPDATE edi.tableMultiConfig
SET updated = ?
WHERE fileName = ?
`, [Date.vnNew(), baseName], options);

View File

@ -2,7 +2,7 @@
<soap:Header>
<mrw:AuthInfo>
<mrw:CodigoFranquicia><%= mrw.franchiseCode %></mrw:CodigoFranquicia>
<mrw:CodigoAbonado><%= mrw.subscriberCode %></mrw:CodigoAbonado>
<mrw:CodigoAbonado><%= clientType %></mrw:CodigoAbonado>
<mrw:CodigoDepartamento/>
<mrw:UserName><%= mrw.user %></mrw:UserName>
<mrw:Password><%= mrw.password %></mrw:Password>

View File

@ -13,7 +13,7 @@ module.exports = Self => {
required: true
}],
returns: {
type: ['object'],
type: 'boolean',
root: true
},
http: {
@ -27,9 +27,9 @@ module.exports = Self => {
const mrw = await models.MrwConfig.findOne();
const {externalId} = await models.Expedition.findById(expeditionFk);
const clientType = await models.MrwConfig.getClientType(expeditionFk);
const template = fs.readFileSync(__dirname + '/cancelShipment.ejs', 'utf-8');
const renderedXml = ejs.render(template, {mrw, externalId});
const renderedXml = ejs.render(template, {mrw, externalId, clientType});
const response = await axios.post(mrw.url, renderedXml, {
headers: {
'Content-Type': 'application/soap+xml; charset=utf-8'
@ -39,6 +39,7 @@ module.exports = Self => {
const xmlString = response.data;
const parser = new DOMParser();
const xmlDoc = parser.parseFromString(xmlString, 'text/xml');
return xmlDoc.getElementsByTagName('Mensaje')[0].textContent;
const result = xmlDoc.getElementsByTagName('Mensaje')[0].textContent;
return result.toLowerCase().includes('se ha cancelado correctamente');
};
};

View File

@ -3,7 +3,7 @@
<soap:Header>
<mrw:AuthInfo>
<mrw:CodigoFranquicia><%= mrw.franchiseCode %></mrw:CodigoFranquicia>
<mrw:CodigoAbonado><%= mrw.subscriberCode %></mrw:CodigoAbonado>
<mrw:CodigoAbonado><%= clientType %></mrw:CodigoAbonado>
<mrw:CodigoDepartamento/>
<mrw:UserName><%= mrw.user %></mrw:UserName>
<mrw:Password><%= mrw.password %></mrw:Password>
@ -25,7 +25,7 @@
</mrw:Direccion>
<mrw:Nif><%= expeditionData.fi %></mrw:Nif>
<mrw:Nombre><%= expeditionData.clientName %></mrw:Nombre>
<mrw:Telefono><%= expeditionData.phone %></mrw:Telefono>
<mrw:Telefono><%= expeditionData.mobile %></mrw:Telefono>
<mrw:Observaciones><%= expeditionData.deliveryObservation %></mrw:Observaciones>
</mrw:DatosEntrega>
<mrw:DatosServicio>

View File

@ -22,6 +22,7 @@ module.exports = Self => {
Self.createShipment = async expeditionFk => {
const models = Self.app.models;
const mrw = await Self.getConfig();
const clientType = await models.MrwConfig.getClientType(expeditionFk);
const today = Date.vnNew();
const [hours, minutes] = mrw?.expeditionDeadLine ? mrw.expeditionDeadLine.split(':').map(Number) : [0, 0];
@ -46,13 +47,13 @@ module.exports = Self => {
co.code countryCode,
c.fi,
c.name clientName,
c.phone,
IFNULL(a.mobile, c.mobile) mobile,
DATE_FORMAT(t.shipped, '%d/%m/%Y') created,
t.shipped,
CONCAT( e.ticketFk, LPAD(e.counter, mc.counterWidth, '0')) reference,
LPAD(IF(mw.serviceType IS NULL, ms.serviceType, mw.serviceType), mc.serviceTypeWidth,'0') serviceType,
LPAD(IF(mw.serviceType IS NULL, ms.serviceType, mw.serviceType), mc.serviceTypeWidth, '0') serviceType,
IF(mw.weekdays, 'S', 'N') weekDays,
oa.description deliveryObservation
ta.description deliveryObservation
FROM expedition e
JOIN ticket t ON e.ticketFk = t.id
JOIN agencyMode am ON am.id = t.agencyModeFk
@ -61,9 +62,8 @@ module.exports = Self => {
AND mw.weekDays & (1 << WEEKDAY(t.landed))
JOIN client c ON t.clientFk = c.id
JOIN address a ON t.addressFk = a.id
LEFT JOIN addressObservation oa ON oa.addressFk = a.id
LEFT JOIN observationType ot ON ot.id = oa.observationTypeFk
AND ot.code = 'delivery'
LEFT JOIN ticketObservation ta ON ta.ticketFk = t.id
AND ta.observationTypeFk IN (SELECT id FROM observationType ot WHERE ot.code = 'agency')
JOIN province p ON a.provinceFk = p.id
JOIN country co ON co.id = p.countryFk
JOIN mrwConfig mc
@ -72,22 +72,19 @@ module.exports = Self => {
const [expeditionData] = await Self.rawSql(query, [expeditionFk]);
if (!expeditionData)
throw new UserError(`This expedition is not a MRW shipment`);
if (expeditionData?.shipped.setHours(0, 0, 0, 0) < today.setHours(0, 0, 0, 0))
throw new UserError(`This ticket has a shipped date earlier than today`);
const shipmentResponse = await Self.sendXmlDoc(
__dirname + `/createShipment.ejs`,
{mrw, expeditionData},
{mrw, expeditionData, clientType},
'application/soap+xml'
);
const shipmentId = Self.getTextByTag(shipmentResponse, 'NumeroEnvio');
if (!shipmentId) throw new UserError(Self.getTextByTag(shipmentResponse, 'Mensaje'));
const file = await models.MrwConfig.getLabel(shipmentId);
const file = await models.MrwConfig.getLabel(shipmentId, clientType);
return {shipmentId, file};
};

View File

@ -2,7 +2,7 @@
<soapenv:Header>
<mrw:AuthInfo>
<mrw:CodigoFranquicia><%= mrw.franchiseCode %></mrw:CodigoFranquicia>
<mrw:CodigoAbonado><%= mrw.subscriberCode %></mrw:CodigoAbonado>
<mrw:CodigoAbonado><%= clientType %></mrw:CodigoAbonado>
<mrw:CodigoDepartamento/>
<mrw:UserName><%= mrw.user %></mrw:UserName>
<mrw:Password><%= mrw.password %></mrw:Password>

View File

@ -6,7 +6,13 @@ module.exports = Self => {
arg: 'shipmentId',
type: 'string',
required: true
}],
},
{
arg: 'clientType',
type: 'string',
required: true
},
],
returns: {
type: 'string',
root: true
@ -17,10 +23,14 @@ module.exports = Self => {
}
});
Self.getLabel = async shipmentId => {
Self.getLabel = async(shipmentId, clientType) => {
const mrw = await Self.getConfig();
const getLabelResponse = await Self.sendXmlDoc(__dirname + `/getLabel.ejs`, {mrw, shipmentId}, 'text/xml');
const getLabelResponse = await Self.sendXmlDoc(
__dirname + `/getLabel.ejs`,
{mrw, shipmentId, clientType},
'text/xml'
);
return Self.getTextByTag(getLabelResponse, 'EtiquetaFile');
};

View File

@ -40,15 +40,12 @@ describe('MRWConfig createShipment()', () => {
);
await models.MrwService.create(
{'agencyModeCodeFk': 'mrw', 'clientType': '000001', 'serviceType': 105, 'kg': 10}
);
await createMrwConfig();
await models.Application.rawSql(
`INSERT INTO vn.mrwService
SET agencyModeCodeFk = 'mrw',
clientType = 1,
serviceType = 1,
kg = 1`, null
);
await models.Ticket.create(ticket1);
await models.Expedition.create(expedition1);
});
@ -82,7 +79,8 @@ describe('MRWConfig createShipment()', () => {
'user': 'user',
'password': 'password',
'franchiseCode': 'franchiseCode',
'subscriberCode': 'subscriberCode'
'subscriberCode': 'subscriberCode',
'clientTypeWidth': 6
}
);
}
@ -115,10 +113,10 @@ describe('MRWConfig createShipment()', () => {
it('should fail if expeditionFk is not a MrwExpedition', async() => {
let error;
await models.MrwConfig.createShipment(undefined).catch(e => {
await models.MrwConfig.createShipment(15).catch(e => {
error = e;
}).finally(async() => {
expect(error.message).toEqual(`This expedition is not a MRW shipment`);
expect(error.message).toEqual(`ClientType not available`);
});
});

View File

@ -11,13 +11,6 @@ module.exports = Self => {
arg: 'filter',
type: 'object',
description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string',
http: {source: 'query'}
},
{
arg: 'search',
type: 'string',
description: 'Value to filter',
http: {source: 'query'}
},
],
returns: {
@ -29,13 +22,11 @@ module.exports = Self => {
verb: 'GET',
},
});
Self.filter = async(ctx, filter, options) => {
Self.filter = async(filter = {}, options) => {
const myOptions = {};
if (typeof options == 'object')
Object.assign(myOptions, options);
filter = ctx?.filter ?? {};
const conn = Self.dataSource.connector;
const where = buildFilter(filter?.where, (param, value) => {
switch (param) {
@ -50,31 +41,33 @@ module.exports = Self => {
};
}
}) ?? {};
delete ctx.filter.where;
delete filter.where;
const stmts = [];
let stmt;
stmt = new ParameterizedSQL(`
SELECT
pc.townFk,
t.provinceFk,
p.countryFk,
pc.code,
t.name as town,
p.name as province,
c.name country
FROM
postCode pc
JOIN town t on t.id = pc.townFk
JOIN province p on p.id = t.provinceFk
JOIN country c on c.id = p.countryFk
SELECT
pc.townFk,
t.provinceFk,
p.countryFk,
pc.code,
t.name as town,
p.name as province,
c.name country
FROM
postCode pc
JOIN town t on t.id = pc.townFk
JOIN province p on p.id = t.provinceFk
JOIN country c on c.id = p.countryFk
`);
stmt.merge(conn.makeSuffix({where, ...ctx}));
stmt.merge(conn.makeSuffix({where}));
stmt.merge(conn.makeLimit(filter));
const itemsIndex = stmts.push(stmt) - 1;
const sql = ParameterizedSQL.join(stmts, ';');
const result = await conn.executeStmt(sql, myOptions);
return itemsIndex === 0 ? result : result[itemsIndex];
};
};

View File

@ -6,12 +6,9 @@ describe('Postcode filter()', () => {
const options = {transaction: tx};
try {
const ctx = {
filter: {
},
const results = await models.Postcode.filter({
limit: 1
};
const results = await models.Postcode.filter(ctx, options);
}, options);
expect(results.length).toEqual(1);
await tx.rollback();
@ -26,14 +23,11 @@ describe('Postcode filter()', () => {
const options = {transaction: tx};
try {
const ctx = {
filter: {
where: {
search: 46,
}
},
};
const results = await models.Postcode.filter(ctx, options);
const results = await models.Postcode.filter({
where: {
search: 46,
}
}, options);
expect(results.length).toEqual(4);
await tx.rollback();
@ -48,14 +42,9 @@ describe('Postcode filter()', () => {
const options = {transaction: tx};
try {
const ctx = {
filter: {
where: {
search: 'Alz',
}
},
};
const results = await models.Postcode.filter(ctx, options);
const results = await models.Postcode.filter({where: {
search: 'Alz',
}}, options);
expect(results.length).toEqual(1);
await tx.rollback();
@ -70,14 +59,9 @@ describe('Postcode filter()', () => {
const options = {transaction: tx};
try {
const ctx = {
filter: {
where: {
search: 'one',
}
},
};
const results = await models.Postcode.filter(ctx, options);
const results = await models.Postcode.filter({where: {
search: 'one',
}}, options);
expect(results.length).toEqual(4);
await tx.rollback();
@ -92,14 +76,11 @@ describe('Postcode filter()', () => {
const options = {transaction: tx};
try {
const ctx = {
filter: {
where: {
search: 'Ec',
}
},
};
const results = await models.Postcode.filter(ctx, options);
const results = await models.Postcode.filter({
where: {
search: 'Ec',
}
}, options);
expect(results.length).toEqual(1);
await tx.rollback();

View File

@ -20,7 +20,7 @@ module.exports = Self => {
}
});
Self.renderer = async (expeditionFk) => {
Self.renderer = async expeditionFk => {
const models = Self.app.models;
const viaexpressConfig = await models.ViaexpressConfig.findOne({
@ -109,7 +109,7 @@ module.exports = Self => {
const ticket = expedition.ticket();
const sender = ticket.company().client();
const shipped = ticket.shipped.toISOString();
const isInterdia = (ticket.agencyModeFk === viaexpressConfig.agencyModeFk)
const isInterdia = (ticket.agencyModeFk === viaexpressConfig.agencyModeFk);
const data = {
viaexpressConfig,
sender,

View File

@ -67,7 +67,9 @@ module.exports = Self => {
if (vnUser.twoFactor === 'email') {
const $ = Self.app.models;
const code = String(Math.floor(Math.random() * 999999));
const min = 100000;
const max = 999999;
const code = String(Math.floor(Math.random() * (max - min + 1)) + min);
const maxTTL = ((60 * 1000) * 5); // 5 min
await $.AuthCode.upsertWithWhere({userFk: vnUser.id}, {
userFk: vnUser.id,

View File

@ -24,6 +24,10 @@ module.exports = Self => {
arg: 'lang',
type: 'string',
description: 'The user lang'
}, {
arg: 'twoFactor',
type: 'string',
description: 'The user twoFactor'
}
],
http: {
@ -32,8 +36,8 @@ module.exports = Self => {
}
});
Self.updateUser = async(ctx, id, name, nickname, email, lang) => {
Self.updateUser = async(ctx, id, name, nickname, email, lang, twoFactor) => {
await Self.userSecurity(ctx, id);
await Self.upsertWithWhere({id}, {name, nickname, email, lang});
await Self.upsertWithWhere({id}, {name, nickname, email, lang, twoFactor});
};
};

View File

@ -58,7 +58,7 @@ module.exports = Self => {
fields: ['name', 'twoFactor']
}, myOptions);
if (user.name !== username)
if (user.name.toLowerCase() !== username.toLowerCase())
throw new UserError('Authentication failed');
await authCode.destroy(myOptions);

View File

@ -0,0 +1,50 @@
module.exports = Self => {
Self.remoteMethodCtx('add', {
description: 'Add activity if the activity is different or is the same but have exceed time for break',
accessType: 'WRITE',
accepts: [
{
arg: 'code',
type: 'string',
description: 'Code for activity'
},
{
arg: 'model',
type: 'string',
description: 'Origin model from insert'
},
],
http: {
path: `/add`,
verb: 'POST'
}
});
Self.add = async(ctx, code, model, options) => {
const userId = ctx.req.accessToken.userId;
const myOptions = {};
if (typeof options == 'object')
Object.assign(myOptions, options);
return await Self.rawSql(`
INSERT INTO workerActivity (workerFk, workerActivityTypeFk, model)
SELECT ?, ?, ?
FROM workerTimeControlParams wtcp
LEFT JOIN (
SELECT wa.workerFk,
wa.created,
wat.code
FROM workerActivity wa
LEFT JOIN workerActivityType wat ON wat.code = wa.workerActivityTypeFk
WHERE wa.workerFk = ?
ORDER BY wa.created DESC
LIMIT 1
) sub ON TRUE
WHERE sub.workerFk IS NULL
OR sub.code <> ?
OR TIMESTAMPDIFF(SECOND, sub.created, util.VN_NOW()) > wtcp.dayBreak;`
, [userId, code, model, userId, code], myOptions);
};
};

View File

@ -0,0 +1,30 @@
const {models} = require('vn-loopback');
describe('workerActivity insert()', () => {
const ctx = beforeAll.getCtx(1106);
it('should insert in workerActivity', async() => {
const tx = await models.WorkerActivity.beginTransaction({});
let count = 0;
const options = {transaction: tx};
try {
await models.WorkerActivityType.create(
{'code': 'STOP', 'description': 'STOP'}, options
);
await models.WorkerActivity.add(ctx, 'STOP', 'APP', options);
count = await models.WorkerActivity.count(
{'workerFK': 1106}, options
);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
expect(count).toEqual(1);
});
});

View File

@ -28,6 +28,9 @@
"Company": {
"dataSource": "vn"
},
"Config": {
"dataSource": "vn"
},
"Continent": {
"dataSource": "vn"
},
@ -115,6 +118,9 @@
"NotificationSubscription": {
"dataSource": "vn"
},
"OrmConfig": {
"dataSource": "vn"
},
"Province": {
"dataSource": "vn"
},
@ -192,5 +198,8 @@
},
"RouteConfig": {
"dataSource": "vn"
},
"MrwService": {
"dataSource": "vn"
}
}

22
back/models/config.json Normal file
View File

@ -0,0 +1,22 @@
{
"name": "Config",
"base": "VnModel",
"options": {
"mysql": {
"table": "config"
}
},
"properties": {
"inventoried": {
"type": "date"
}
},
"acls": [
{
"accessType": "READ",
"principalType": "ROLE",
"principalId": "$authenticated",
"permission": "ALLOW"
}
]
}

View File

@ -3,7 +3,7 @@
"base": "VnModel",
"options": {
"mysql": {
"table": "salix.defaultViewConfig"
"table": "salix.defaultViewMultiConfig"
}
},
"properties": {

View File

@ -14,6 +14,9 @@
},
"itemFk": {
"type": "number"
},
"isChecked": {
"type": "boolean"
}
}
}

View File

@ -31,5 +31,30 @@ module.exports = Self => {
});
return parser.parseFromString(data.data, 'text/xml');
};
Self.getClientType = async function(expeditionFk) {
if (!expeditionFk) throw new UserError(`No expeditionFk defined`);
const {clientTypeWidth} = await Self.getConfig();
const result = await Self.app.models.Expedition.findById(expeditionFk,
{include: [{
relation: 'ticket',
scope: {
include: {
relation: 'agencyMode',
scope: {
include: {
relation: 'mrwService',
}
}
}
}
}]}
);
const clientType = result?.ticket()?.agencyMode()?.mrwService()?.clientType;
if (!clientType || !clientTypeWidth) throw new UserError(`ClientType not available`);
return clientType.toString().padStart(clientTypeWidth, '0');
};
};

View File

@ -45,6 +45,9 @@
},
"notified":{
"type": "date"
},
"clientTypeWidth": {
"type": "number"
}
}
}

View File

@ -0,0 +1,33 @@
{
"name": "MrwService",
"base": "VnModel",
"options": {
"mysql": {
"table": "mrwService"
}
},
"properties": {
"agencyModeCodeFk": {
"id": true,
"type": "string",
"required": true
},
"clientType": {
"type": "number",
"required": true
},
"serviceType": {
"type": "number"
},
"kg": {
"type": "number"
}
},
"relations": {
"agency": {
"type": "hasOne",
"model": "AgencyMode",
"foreignKey": "code"
}
}
}

View File

@ -0,0 +1,26 @@
{
"name": "OrmConfig",
"base": "VnModel",
"options": {
"mysql": {
"table": "ormConfig"
}
},
"properties": {
"id": {
"type": "number",
"id": true
},
"selectLimit": {
"type": "number"
}
},
"acls": [
{
"accessType": "*",
"principalType": "ROLE",
"principalId": "$authenticated",
"permission": "ALLOW"
}
]
}

View File

@ -9,7 +9,8 @@
"properties": {
"code": {
"id": true,
"type": "string"
"type": "string",
"required": true
}
},
"relations": {
@ -47,4 +48,4 @@
}
}
}
}
}

View File

@ -12,7 +12,8 @@
"type": "number"
},
"name": {
"type": "string"
"type": "string",
"required": true
}
},
"relations": {
@ -54,4 +55,4 @@
"fields": ["id", "name", "provinceFk"]
}
}
}
}

View File

@ -3,7 +3,7 @@
"base": "VnModel",
"options": {
"mysql": {
"table": "userConfig"
"table": "userMultiConfig"
}
},
"properties": {

View File

@ -101,9 +101,10 @@ module.exports = function(Self) {
const headers = httpRequest.headers;
const origin = headers.origin;
const defaultHash = '/reset-password?access_token=$token$';
const defaultHash = '!/reset-password?access_token=$token$';
const recoverHashes = {
hedera: 'verificationToken=$token$'
hedera: '!verificationToken=$token$',
lilium: '/resetPassword?access_token=$token$'
};
const app = info.options?.app;
@ -115,7 +116,7 @@ module.exports = function(Self) {
const params = {
recipient: info.email,
lang: user.lang,
url: origin + '/#!' + recoverHash
url: origin + '/#' + recoverHash
};
const options = Object.assign({}, info.options);

View File

@ -0,0 +1,3 @@
module.exports = Self => {
require('../methods/workerActivity/add')(Self);
};

View File

@ -22,18 +22,18 @@
},
"description": {
"type": "string"
}
},
"relations": {
"workerFk": {
"type": "belongsTo",
"model": "Worker",
"foreignKey": "workerFk"
},
"relations": {
"workerFk": {
"type": "belongsTo",
"model": "Worker",
"foreignKey": "workerFk"
},
"workerActivityTypeFk": {
"type": "belongsTo",
"model": "WorkerActivityType",
"foreignKey": "workerActivityTypeFk"
}
"workerActivityTypeFk": {
"type": "belongsTo",
"model": "WorkerActivityType",
"foreignKey": "workerActivityTypeFk"
}
}
}

View File

@ -2,6 +2,6 @@ apps:
- script: ./loopback/server/server.js
name: salix-back
instances: 1
max_restarts: 3
restart_delay: 15000
max_restarts: 0
autorestart: false
node_args: --tls-min-v1.0 --openssl-legacy-provider

View File

@ -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','11114','cf0f80142fed798c3307565a69158d7dba9276c4','2024-06-25 09:25:54','11115');
INSERT INTO `version` VALUES ('vn-database','11161','36dee872d62ba2421c05503f374f6b208c40ecfa','2024-08-06 07:53:56','11180');
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);
@ -644,6 +644,7 @@ INSERT INTO `versionLog` VALUES ('vn-database','10849','15-invoiceInLog.sql','je
INSERT INTO `versionLog` VALUES ('vn-database','10849','16-travelLog.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-02-15 09:45:55',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10849','17-packingSiteDeviceLog.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-02-15 09:45:55',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10851','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-01-30 13:31:15',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10852','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-09 07:39:37',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10853','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-02-15 09:46:05',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10853','00-secondScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-02-15 09:46:06',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10854','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-01-30 16:20:34',NULL,NULL);
@ -763,6 +764,7 @@ INSERT INTO `versionLog` VALUES ('vn-database','10955','00-firstScript.sql','jen
INSERT INTO `versionLog` VALUES ('vn-database','10956','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-04 07:34:58',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10957','00-aclTicketClone.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-04 07:34:58',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10959','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-18 13:32:25',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10960','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:22:12',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10962','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-25 08:27:35',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10964','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-18 07:40:52',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10967','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-18 07:40:52',NULL,NULL);
@ -776,7 +778,9 @@ INSERT INTO `versionLog` VALUES ('vn-database','10975','01-expeditionFk.sql','je
INSERT INTO `versionLog` VALUES ('vn-database','10976','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-18 07:40:57',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10977','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-18 07:40:57',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10978','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-06-11 08:32:33',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10983','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-09 07:39:37',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10984','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-07 07:31:59',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10986','00-addSummaryId.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:22:12',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10988','00-pbx_prefix.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-04-11 17:00:16',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10990','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-07 07:31:59',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10991','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-14 07:45:26',NULL,NULL);
@ -818,6 +822,7 @@ INSERT INTO `versionLog` VALUES ('vn-database','11034','00-firstScript.sql','jen
INSERT INTO `versionLog` VALUES ('vn-database','11037','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:17',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11038','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:17',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11040','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:31',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11042','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-08-06 07:53:54',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11044','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:31',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11045','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-10 14:53:29',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11046','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:46',NULL,NULL);
@ -844,24 +849,70 @@ INSERT INTO `versionLog` VALUES ('vn-database','11068','00-firstScript.sql','jen
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','11073','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-09 07:39:38',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','11081','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-09 07:39:38',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','11086','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-06-27 10:02:02',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','11099','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-09 07:39:38',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11100','00-modifyTimeControlAcls.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-09 07:39:38',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11101','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-09 07:39:38',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11102','00-createTravelKgPercentage.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-09 07:39:38',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11103','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-09 07:39:38',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11104','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-09 07:39:38',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','11110','00-clientUnpaid.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-09 07:39:38',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11111','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-09 07:39:38',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);
INSERT INTO `versionLog` VALUES ('vn-database','11116','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-09 07:39:38',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11117','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-09 07:39:38',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11118','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-07-19 12:28:49',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11119','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:22:13',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11120','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:22:15',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11121','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:22:15',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11126','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:22:15',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11128','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:22:15',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11129','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:22:15',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11130','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:22:15',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11131','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:22:15',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11134','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-07-05 11:02:07',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11135','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:22:16',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11136','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:22:16',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11137','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:23:33',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11138','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:23:34',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11139','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-07-08 10:58:01',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11140','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:23:34',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11145','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-09 13:55:46',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11146','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-08-06 07:53:54',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11149','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:23:35',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11150','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:23:35',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11152','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-16 09:06:11',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11154','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:23:35',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11155','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-08-06 07:53:54',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11156','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-08-06 07:53:54',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11157','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-16 13:11:00',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11158','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-07-17 17:06:30',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11159','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-18 17:23:32',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11160','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-07-18 13:46:16',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11161','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-08-06 07:53:54',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11164','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-07-23 11:03:16',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11168','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-25 08:58:34',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11169','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-25 12:38:13',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11177','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-07-30 12:42:28',NULL,NULL);
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
@ -958,6 +1009,7 @@ INSERT INTO `role` VALUES (126,'greenhouseBoss','Jefe de invernadero',1,'2023-11
INSERT INTO `role` VALUES (127,'timeControl','Tablet para fichar',1,'2024-01-09 16:36:56','2024-01-09 16:36:56',NULL);
INSERT INTO `role` VALUES (129,'buyerAssistant','Comprador que tienes mas permisos para ayudar al buyerBoss en algunas tareas',1,'2024-02-06 06:59:12','2024-02-06 06:59:12',783);
INSERT INTO `role` VALUES (130,'reviewer','Revisor de producción',1,'2024-06-11 00:00:00','2024-06-11 00:00:00',10578);
INSERT INTO `role` VALUES (131,'supplier','Privilegios básicos de un proveedor',1,'2024-07-05 10:18:58','2024-07-05 10:18:58',19295);
INSERT INTO `roleInherit` VALUES (1,1,2,NULL);
INSERT INTO `roleInherit` VALUES (2,1,3,NULL);
@ -1228,6 +1280,9 @@ 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 `roleInherit` VALUES (372,126,13,19295);
INSERT INTO `roleInherit` VALUES (373,131,2,19295);
INSERT INTO `roleInherit` VALUES (375,120,131,1437);
INSERT INTO `userPassword` VALUES (1,7,1,0,2,1);
@ -1441,7 +1496,7 @@ INSERT INTO `ACL` VALUES (260,'PrintServerQueue','*','WRITE','ALLOW','ROLE','emp
INSERT INTO `ACL` VALUES (261,'SupplierAccount','*','*','ALLOW','ROLE','administrative');
INSERT INTO `ACL` VALUES (262,'Entry','*','*','ALLOW','ROLE','administrative');
INSERT INTO `ACL` VALUES (263,'InvoiceIn','*','READ','ALLOW','ROLE','administrative');
INSERT INTO `ACL` VALUES (264,'StarredModule','*','*','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (264,'StarredModule','*','*','ALLOW','ROLE','$authenticated');
INSERT INTO `ACL` VALUES (265,'ItemBotanical','*','WRITE','ALLOW','ROLE','logisticBoss');
INSERT INTO `ACL` VALUES (266,'ZoneLog','*','READ','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (267,'Genus','*','WRITE','ALLOW','ROLE','logisticBoss');
@ -1889,8 +1944,8 @@ INSERT INTO `ACL` VALUES (775,'WorkerTimeControl','clockIn','WRITE','ALLOW','ROL
INSERT INTO `ACL` VALUES (776,'WorkerTimeControl','addTimeEntry','WRITE','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (777,'WorkerTimeControl','deleteTimeEntry','WRITE','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (778,'WorkerTimeControl','updateTimeEntry','WRITE','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (779,'WorkerTimeControl','sendMail','WRITE','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (780,'WorkerTimeControl','updateWorkerTimeControlMail','WRITE','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (779,'WorkerTimeControl','sendMail','WRITE','ALLOW','ROLE','developer');
INSERT INTO `ACL` VALUES (780,'WorkerTimeControl','updateMailState','WRITE','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (781,'WorkerTimeControl','weeklyHourRecordEmail','WRITE','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (782,'WorkerTimeControl','getMailStates','READ','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (783,'WorkerTimeControl','resendWeeklyHourEmail','WRITE','ALLOW','ROLE','employee');
@ -1941,7 +1996,6 @@ INSERT INTO `ACL` VALUES (830,'InvoiceIn','*','READ','ALLOW','ROLE','deliveryBos
INSERT INTO `ACL` VALUES (831,'InvoiceIn','exchangeRateUpdate','*','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (832,'AgencyLog','*','READ','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (833,'AgencyWorkCenter','*','READ','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (834,'AgencyMode','*','READ','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (835,'Agency','*','READ','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (836,'Agency','*','WRITE','ALLOW','ROLE','deliveryAssistant');
INSERT INTO `ACL` VALUES (837,'AgencyWorkCenter','*','WRITE','ALLOW','ROLE','deliveryAssistant');
@ -1983,6 +2037,32 @@ 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 `ACL` VALUES (878,'MrwConfig','getLabel','READ','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (879,'AgencyMode','*','*','ALLOW','ROLE','deliveryAssistant');
INSERT INTO `ACL` VALUES (880,'Collection','assignCollection','WRITE','ALLOW','ROLE','production');
INSERT INTO `ACL` VALUES (881,'TrainingCourse','*','*','ALLOW','ROLE','hr');
INSERT INTO `ACL` VALUES (882,'TrainingCourseType','*','*','ALLOW','ROLE','hr');
INSERT INTO `ACL` VALUES (883,'TrainingCenter','*','*','ALLOW','ROLE','hr');
INSERT INTO `ACL` VALUES (884,'Worker','__get__trainingCourse','*','ALLOW','ROLE','hr');
INSERT INTO `ACL` VALUES (885,'WorkerTimeControl','addTimeEntry','WRITE','ALLOW','ROLE','hr');
INSERT INTO `ACL` VALUES (886,'WorkerTimeControl','deleteTimeEntry','WRITE','ALLOW','ROLE','hr');
INSERT INTO `ACL` VALUES (887,'WorkerTimeControl','updateTimeEntry','WRITE','ALLOW','ROLE','hr');
INSERT INTO `ACL` VALUES (888,'WorkerTimeControl','weeklyHourRecordEmail','WRITE','ALLOW','ROLE','hr');
INSERT INTO `ACL` VALUES (889,'WorkerTimeControl','sendMail','WRITE','ALLOW','ROLE','hr');
INSERT INTO `ACL` VALUES (890,'WorkerTimeControl','updateMailState','WRITE','ALLOW','ROLE','hr');
INSERT INTO `ACL` VALUES (891,'TravelKgPercentage','*','READ','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (892,'WorkerIncome','*','*','ALLOW','ROLE','hr');
INSERT INTO `ACL` VALUES (893,'PayrollComponent','*','*','ALLOW','ROLE','hr');
INSERT INTO `ACL` VALUES (894,'Worker','__get__incomes','*','ALLOW','ROLE','hr');
INSERT INTO `ACL` VALUES (895,'ItemShelvingLog','*','READ','ALLOW','ROLE','production');
INSERT INTO `ACL` VALUES (897,'WorkerLog','*','READ','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (901,'WorkerTimeControl','sendMail','WRITE','ALLOW','ROLE','system');
INSERT INTO `ACL` VALUES (902,'Entry','filter','READ','ALLOW','ROLE','supplier');
INSERT INTO `ACL` VALUES (903,'Entry','getBuys','READ','ALLOW','ROLE','supplier');
INSERT INTO `ACL` VALUES (904,'Entry','buyLabel','READ','ALLOW','ROLE','supplier');
INSERT INTO `ACL` VALUES (905,'AddressWaste','*','READ','ALLOW','ROLE','production');
INSERT INTO `ACL` VALUES (906,'Entry','print','READ','ALLOW','ROLE','supplier');
INSERT INTO `ACL` VALUES (907,'Expedition_PrintOut','*','*','ALLOW','ROLE','production');
INSERT INTO `fieldAcl` VALUES (1,'Client','name','update','employee');
INSERT INTO `fieldAcl` VALUES (2,'Client','contact','update','employee');
@ -2067,11 +2147,11 @@ INSERT INTO `module` VALUES ('wagon');
INSERT INTO `module` VALUES ('worker');
INSERT INTO `module` VALUES ('zone');
INSERT INTO `defaultViewConfig` VALUES ('itemsIndex','{\"intrastat\":false,\"stemMultiplier\":false,\"landed\":false,\"producer\":false}');
INSERT INTO `defaultViewConfig` VALUES ('latestBuys','{\"intrastat\":false,\"description\":false,\"density\":false,\"isActive\":false,\n \"freightValue\":false,\"packageValue\":false,\"isIgnored\":false,\"price2\":false,\"ektFk\":false,\"weight\":false,\n \"size\":false,\"comissionValue\":false,\"landing\":false}');
INSERT INTO `defaultViewConfig` VALUES ('ticketsMonitor','{\"id\":false}');
INSERT INTO `defaultViewConfig` VALUES ('clientsDetail','{\"id\":true,\"phone\":true,\"city\":true,\"socialName\":true,\"salesPersonFk\":true,\"email\":true,\"name\":false,\"fi\":false,\"credit\":false,\"creditInsurance\":false,\"mobile\":false,\"street\":false,\"countryFk\":false,\"provinceFk\":false,\"postcode\":false,\"created\":false,\"businessTypeFk\":false,\"payMethodFk\":false,\"sageTaxTypeFk\":false,\"sageTransactionTypeFk\":false,\"isActive\":false,\"isVies\":false,\"isTaxDataChecked\":false,\"isEqualizated\":false,\"isFreezed\":false,\"hasToInvoice\":false,\"hasToInvoiceByAddress\":false,\"isToBeMailed\":false,\"hasLcr\":false,\"hasCoreVnl\":false,\"hasSepaVnl\":false}');
INSERT INTO `defaultViewConfig` VALUES ('routesList','{\"ID\":true,\"worker\":true,\"agency\":true,\"vehicle\":true,\"date\":true,\"volume\":true,\"description\":true,\"started\":true,\"finished\":true,\"actions\":true}');
INSERT INTO `defaultViewMultiConfig` VALUES ('itemsIndex','{\"intrastat\":false,\"stemMultiplier\":false,\"landed\":false,\"producer\":false}');
INSERT INTO `defaultViewMultiConfig` VALUES ('latestBuys','{\"intrastat\":false,\"description\":false,\"density\":false,\"isActive\":false,\n \"freightValue\":false,\"packageValue\":false,\"isIgnored\":false,\"price2\":false,\"ektFk\":false,\"weight\":false,\n \"size\":false,\"comissionValue\":false,\"landing\":false}');
INSERT INTO `defaultViewMultiConfig` VALUES ('ticketsMonitor','{\"id\":false}');
INSERT INTO `defaultViewMultiConfig` VALUES ('clientsDetail','{\"id\":true,\"phone\":true,\"city\":true,\"socialName\":true,\"salesPersonFk\":true,\"email\":true,\"name\":false,\"fi\":false,\"credit\":false,\"creditInsurance\":false,\"mobile\":false,\"street\":false,\"countryFk\":false,\"provinceFk\":false,\"postcode\":false,\"created\":false,\"businessTypeFk\":false,\"payMethodFk\":false,\"sageTaxTypeFk\":false,\"sageTransactionTypeFk\":false,\"isActive\":false,\"isVies\":false,\"isTaxDataChecked\":false,\"isEqualizated\":false,\"isFreezed\":false,\"hasToInvoice\":false,\"hasToInvoiceByAddress\":false,\"isToBeMailed\":false,\"hasLcr\":false,\"hasCoreVnl\":false,\"hasSepaVnl\":false}');
INSERT INTO `defaultViewMultiConfig` VALUES ('routesList','{\"ID\":true,\"worker\":true,\"agency\":true,\"vehicle\":true,\"date\":true,\"volume\":true,\"description\":true,\"started\":true,\"finished\":true,\"actions\":true}');
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
@ -2083,9 +2163,10 @@ USE `vn`;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
INSERT INTO `alertLevel` VALUES ('FREE',0,1);
INSERT INTO `alertLevel` VALUES ('ON_PREPARATION',1,1);
INSERT INTO `alertLevel` VALUES ('PACKED',2,0);
INSERT INTO `alertLevel` VALUES ('DELIVERED',3,0);
INSERT INTO `alertLevel` VALUES ('ON_PREVIOUS',1,1);
INSERT INTO `alertLevel` VALUES ('ON_PREPARATION',2,1);
INSERT INTO `alertLevel` VALUES ('PACKED',3,0);
INSERT INTO `alertLevel` VALUES ('DELIVERED',4,0);
INSERT INTO `bookingPlanner` VALUES (5,'2017-07-01 00:00:00','4770000002','WORLD',7,4,1);
INSERT INTO `bookingPlanner` VALUES (6,'2017-07-01 00:00:00','4770000010','NATIONAL',3,1,1);
@ -2284,18 +2365,18 @@ INSERT INTO `component` VALUES (47,'promocion Italia',4,NULL,NULL,1,'italianOffe
INSERT INTO `component` VALUES (48,'fusión de lineas',4,NULL,NULL,1,'lineFusion',0);
INSERT INTO `component` VALUES (49,'sustitución',4,NULL,NULL,1,'substitution',0);
INSERT INTO `componentType` VALUES (1,'coste',1,0,'COST');
INSERT INTO `componentType` VALUES (2,'com ventas',1,1,NULL);
INSERT INTO `componentType` VALUES (3,'com compras',1,1,NULL);
INSERT INTO `componentType` VALUES (4,'empresa',1,1,'MARGIN');
INSERT INTO `componentType` VALUES (5,'cliente',0,0,NULL);
INSERT INTO `componentType` VALUES (6,'agencia',0,0,'FREIGHT');
INSERT INTO `componentType` VALUES (7,'cartera_comercial',0,0,'MANA');
INSERT INTO `componentType` VALUES (8,'cartera_producto',0,1,NULL);
INSERT INTO `componentType` VALUES (9,'maniobra',1,0,NULL);
INSERT INTO `componentType` VALUES (10,'cartera_comprador',0,1,NULL);
INSERT INTO `componentType` VALUES (11,'errores',0,1,NULL);
INSERT INTO `componentType` VALUES (12,'otros',0,1,NULL);
INSERT INTO `componentType` VALUES (1,'cost','coste',1,0);
INSERT INTO `componentType` VALUES (2,NULL,'com ventas',1,1);
INSERT INTO `componentType` VALUES (3,NULL,'com compras',1,1);
INSERT INTO `componentType` VALUES (4,'margin','empresa',1,1);
INSERT INTO `componentType` VALUES (5,NULL,'cliente',0,0);
INSERT INTO `componentType` VALUES (6,'freight','agencia',0,0);
INSERT INTO `componentType` VALUES (7,'mana','cartera_comercial',0,0);
INSERT INTO `componentType` VALUES (8,NULL,'cartera_producto',0,1);
INSERT INTO `componentType` VALUES (9,NULL,'maniobra',1,0);
INSERT INTO `componentType` VALUES (10,NULL,'cartera_comprador',0,1);
INSERT INTO `componentType` VALUES (11,NULL,'errores',0,1);
INSERT INTO `componentType` VALUES (12,'other','otros',0,1);
INSERT INTO `continent` VALUES (1,'Asia','AS');
INSERT INTO `continent` VALUES (2,'América','AM');
@ -2303,61 +2384,62 @@ 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,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);
INSERT INTO `department` VALUES (34,'accounting','CONTABILIDAD',6,7,NULL,0,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (35,'finance','FINANZAS',8,9,NULL,0,0,0,1,0,1,'/1/',NULL,1,'begonya@verdnatura.es',1,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (36,'labor','LABORAL',10,11,NULL,0,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (37,'PROD','PRODUCCION',12,35,NULL,72,1,1,1,11,1,'/1/',NULL,0,NULL,0,1,1,1,NULL,NULL,NULL,NULL);
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,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',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',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',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',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',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',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',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',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',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 `department` VALUES (1,'VN','VERDNATURA',1,112,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,5,NULL,72,0,0,1,1,1,'/1/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (23,'CMA','CAMARA',15,16,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',6,7,NULL,72,0,0,1,0,1,'/1/','informatica-cau',1,NULL,1,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (34,'accounting','CONTABILIDAD',8,9,NULL,0,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (35,'finance','FINANZAS',10,11,NULL,0,0,0,1,0,1,'/1/',NULL,1,'begonya@verdnatura.es',1,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (36,'labor','LABORAL',12,13,NULL,0,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (37,'PROD','PRODUCCION',14,37,NULL,72,1,1,1,11,1,'/1/',NULL,0,NULL,0,1,1,1,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (38,'picking','SACADO',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 (39,'packing','ENCAJADO',19,20,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',38,39,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',40,71,NULL,0,0,0,1,15,1,'/1/',NULL,1,NULL,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 (53,'marketing','MARKETING Y COMUNICACIÓN',41,42,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 (55,NULL,'TALLER NATURAL',21,22,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',23,24,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 (60,'claims','RECLAMACIONES',43,44,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 (68,NULL,'COMPLEMENTOS',25,26,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 (80,'spainTeam5','EQUIPO ESPAÑA 5',45,46,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 (91,'artificial','ARTIFICIAL',27,28,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',47,48,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',49,50,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',51,52,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',53,54,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',55,56,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',57,58,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',104,105,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',59,60,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',29,30,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',31,32,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',33,34,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 (135,'routers','ENRUTADORES',106,107,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',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 (137,'sorter','SORTER',110,111,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 (141,NULL,'PREVIA',35,36,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (146,NULL,'VERDNACOLOMBIA',3,4,NULL,72,0,0,2,0,22,'/1/22/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `docuware` VALUES (1,'deliveryNote','Albaranes cliente','find','find','N__ALBAR_N',NULL);
INSERT INTO `docuware` VALUES (2,'deliveryNote','Albaranes cliente','store','Archivar','N__ALBAR_N',NULL);
@ -2619,38 +2701,39 @@ INSERT INTO `state` VALUES (1,'Arreglar',2,0,'FIXING',NULL,1,0,0,0,0,0,0,4,1,'al
INSERT INTO `state` VALUES (2,'Libre',2,0,'FREE',NULL,2,0,0,0,0,0,0,4,1,'notice');
INSERT INTO `state` VALUES (3,'OK',3,0,'OK',3,28,1,0,0,0,1,1,3,0,'success');
INSERT INTO `state` VALUES (4,'Impreso',4,0,'PRINTED',2,29,1,0,1,0,0,1,2,0,'success');
INSERT INTO `state` VALUES (5,'Preparación',6,1,'ON_PREPARATION',7,14,0,0,0,2,0,0,2,0,'warning');
INSERT INTO `state` VALUES (6,'En Revisión',7,1,'ON_CHECKING',NULL,6,0,1,0,3,0,0,1,0,'warning');
INSERT INTO `state` VALUES (5,'Preparación',6,2,'ON_PREPARATION',7,14,0,0,0,2,0,0,2,0,'warning');
INSERT INTO `state` VALUES (6,'En Revisión',7,2,'ON_CHECKING',NULL,6,0,1,0,3,0,0,1,0,'warning');
INSERT INTO `state` VALUES (7,'Sin Acabar',1,0,'NOT_READY',NULL,7,0,0,0,0,0,0,4,1,'alert');
INSERT INTO `state` VALUES (8,'Revisado',8,1,'CHECKED',NULL,8,0,1,0,3,0,0,1,0,'warning');
INSERT INTO `state` VALUES (9,'Encajando',9,2,'PACKING',NULL,9,0,1,0,0,0,0,1,0,NULL);
INSERT INTO `state` VALUES (10,'Encajado',10,2,'PACKED',NULL,10,0,1,0,0,0,0,0,0,NULL);
INSERT INTO `state` VALUES (11,'Facturado',0,3,'INVOICED',NULL,11,0,1,0,0,0,0,0,0,NULL);
INSERT INTO `state` VALUES (8,'Revisado',8,2,'CHECKED',NULL,8,0,1,0,3,0,0,1,0,'warning');
INSERT INTO `state` VALUES (9,'Encajando',9,3,'PACKING',NULL,9,0,1,0,0,0,0,1,0,NULL);
INSERT INTO `state` VALUES (10,'Encajado',10,3,'PACKED',NULL,10,0,1,0,0,0,0,0,0,NULL);
INSERT INTO `state` VALUES (11,'Facturado',0,4,'INVOICED',NULL,11,0,1,0,0,0,0,0,0,NULL);
INSERT INTO `state` VALUES (12,'Bloqueado',0,0,'BLOCKED',NULL,12,0,0,0,0,0,0,4,1,'alert');
INSERT INTO `state` VALUES (13,'En Reparto',11,3,'ON_DELIVERY',NULL,13,0,1,0,0,0,0,0,0,NULL);
INSERT INTO `state` VALUES (14,'Preparado',6,1,'PREPARED',NULL,14,0,1,0,2,0,0,1,0,'warning');
INSERT INTO `state` VALUES (15,'Pte Recogida',12,3,'WAITING_FOR_PICKUP',NULL,15,0,1,0,0,0,0,0,0,NULL);
INSERT INTO `state` VALUES (16,'Entregado',13,3,'DELIVERED',NULL,16,0,1,0,0,0,0,0,0,NULL);
INSERT INTO `state` VALUES (13,'En Reparto',11,4,'ON_DELIVERY',NULL,13,0,1,0,0,0,0,0,0,NULL);
INSERT INTO `state` VALUES (14,'Preparado',6,2,'PREPARED',NULL,14,0,1,0,2,0,0,1,0,'warning');
INSERT INTO `state` VALUES (15,'Pte Recogida',12,4,'WAITING_FOR_PICKUP',NULL,15,0,1,0,0,0,0,0,0,NULL);
INSERT INTO `state` VALUES (16,'Entregado',13,4,'DELIVERED',NULL,16,0,1,0,0,0,0,0,0,NULL);
INSERT INTO `state` VALUES (20,'Asignado',4,0,'PICKER_DESIGNED',NULL,20,1,0,0,0,0,0,2,0,'success');
INSERT INTO `state` VALUES (21,'Retornado',4,1,'PRINTED_BACK',6,21,0,0,0,0,0,0,2,0,'success');
INSERT INTO `state` VALUES (21,'Retornado',4,2,'PRINTED_BACK',6,21,0,0,0,0,0,0,2,0,'success');
INSERT INTO `state` VALUES (22,'Pte. Ampliar',2,0,'EXPANDABLE',NULL,22,0,0,0,0,0,0,4,1,'alert');
INSERT INTO `state` VALUES (23,'URGENTE',5,1,'LAST_CALL',NULL,23,1,0,1,0,0,0,4,1,'success');
INSERT INTO `state` VALUES (23,'URGENTE',5,2,'LAST_CALL',NULL,23,1,0,1,0,0,0,4,1,'success');
INSERT INTO `state` VALUES (24,'Encadenado',4,0,'CHAINED',4,24,0,0,0,0,0,0,3,1,'success');
INSERT INTO `state` VALUES (25,'Embarcando',3,0,'BOARDING',5,25,1,0,0,0,0,0,3,0,'alert');
INSERT INTO `state` VALUES (26,'Prep Previa',5,0,'PREVIOUS_PREPARATION',1,28,1,0,0,1,0,0,2,0,'warning');
INSERT INTO `state` VALUES (27,'Prep Asistida',5,1,'ASSISTED_PREPARATION',7,27,0,0,0,0,0,0,2,0,'success');
INSERT INTO `state` VALUES (27,'Prep Asistida',5,2,'ASSISTED_PREPARATION',7,27,0,0,0,0,0,0,2,0,'success');
INSERT INTO `state` VALUES (28,'Previa OK',3,0,'OK PREVIOUS',3,28,1,0,1,1,1,1,3,0,'warning');
INSERT INTO `state` VALUES (29,'Previa Impreso',4,0,'PRINTED PREVIOUS',2,29,1,0,1,0,0,1,2,0,'success');
INSERT INTO `state` VALUES (30,'Embarcado',4,1,'BOARD',5,30,0,0,0,2,0,0,3,0,'success');
INSERT INTO `state` VALUES (31,'Polizon Impreso',4,1,'PRINTED STOWAWAY',2,29,1,0,1,0,0,1,2,0,'success');
INSERT INTO `state` VALUES (32,'Polizon OK',3,1,'OK STOWAWAY',3,31,1,0,0,1,1,1,3,0,'warning');
INSERT INTO `state` VALUES (30,'Embarcado',4,2,'BOARD',5,30,0,0,0,2,0,0,3,0,'success');
INSERT INTO `state` VALUES (31,'Polizon Impreso',4,2,'PRINTED STOWAWAY',2,29,1,0,1,0,0,1,2,0,'success');
INSERT INTO `state` VALUES (32,'Polizon OK',3,2,'OK STOWAWAY',3,31,1,0,0,1,1,1,3,0,'warning');
INSERT INTO `state` VALUES (33,'Auto_Impreso',4,0,'PRINTED_AUTO',2,29,1,0,1,0,0,1,2,0,'success');
INSERT INTO `state` VALUES (34,'Pte Pago',3,0,'WAITING_FOR_PAYMENT',NULL,34,0,0,0,0,0,0,4,1,'alert');
INSERT INTO `state` VALUES (35,'Semi-Encajado',9,2,'HALF_PACKED',NULL,10,0,1,0,0,0,0,1,0,NULL);
INSERT INTO `state` VALUES (35,'Semi-Encajado',9,3,'HALF_PACKED',NULL,10,0,1,0,0,0,0,1,0,NULL);
INSERT INTO `state` VALUES (36,'Previa Revisando',3,0,'PREVIOUS_CONTROL',2,37,1,0,0,4,0,1,2,0,'warning');
INSERT INTO `state` VALUES (37,'Previa Revisado',3,0,'PREVIOUS_CONTROLLED',2,29,1,0,1,0,0,1,2,0,'warning');
INSERT INTO `state` VALUES (38,'Prep Cámara',6,1,'COOLER_PREPARATION',7,14,0,0,0,2,0,0,2,0,'warning');
INSERT INTO `state` VALUES (41,'Prep Parcial',6,1,'PARTIAL_PREPARATION',7,14,0,0,0,2,0,0,2,0,'warning');
INSERT INTO `state` VALUES (38,'Prep Cámara',6,2,'COOLER_PREPARATION',7,14,0,0,0,2,0,0,2,0,'warning');
INSERT INTO `state` VALUES (41,'Prep Parcial',6,2,'PARTIAL_PREPARATION',7,14,0,0,0,2,0,0,2,0,'warning');
INSERT INTO `state` VALUES (42,'Entregado en parte',13,3,'PARTIAL_DELIVERED',NULL,16,0,1,0,0,0,0,0,0,NULL);
INSERT INTO `ticketUpdateAction` VALUES (1,'Cambiar los precios en el ticket','renewPrices');
INSERT INTO `ticketUpdateAction` VALUES (2,'Convertir en maná','mana');

View File

@ -259,7 +259,7 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','albaran'
INSERT IGNORE INTO `tables_priv` VALUES ('','vncontrol','salesPerson','inter','alexm@%','0000-00-00 00:00:00','Insert','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','albaran_gestdoc','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','albaran_state','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','Articles','alexm@%','0000-00-00 00:00:00','Select,Insert,Update','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','Articles','alexm@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','awb','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','awb','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','awb_component','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
@ -281,8 +281,6 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vncontrol','employee','inter','ale
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','awb_gestdoc','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','awb','alexm@%','0000-00-00 00:00:00','Insert,Update','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','agency','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','buySource','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','buy_edi','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','buy_edi_k04','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','buy_edi_k03','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','buy_edi_k04','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
@ -313,7 +311,6 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','Cajas','
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','production','cmrConfig','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','hrBoss','awb_recibida','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','hrBoss','awb','juan@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','Compres','alexm@%','0000-00-00 00:00:00','Select,Update','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','buy_edi','alexm@%','0000-00-00 00:00:00','Update','');
INSERT IGNORE INTO `tables_priv` VALUES ('','salix','developer','ACL','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','Vehiculos_consumo','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
@ -348,7 +345,7 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','empresa','alex
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','sectorType','guillermo@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','Tintas','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','claimManager','Movimientos','juan@%','0000-00-00 00:00:00','Insert,Delete','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','Entradas','guillermo@10.5.1.3','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','Compres','alexm@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Update','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','salesPerson','ticket_observation','juan@%','0000-00-00 00:00:00','Insert,Update','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','Entradas_dits','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','sale','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
@ -364,7 +361,7 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','tickets_
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','hrBoss','tickets_gestdoc','alexm@%','0000-00-00 00:00:00','Delete','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','tickets_gestdoc','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','Tickets','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','Entradas','alexm@%','0000-00-00 00:00:00','Update','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','Entradas','alexm@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Update','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyerBoss','Tintas','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','filtros','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','Entradas_kop','alexm@%','0000-00-00 00:00:00','Select','');
@ -372,9 +369,9 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','flight','jenki
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','warehouse_pickup','jenkins@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','zones','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','claimManager','warehouse_pickup','jenkins@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','businessReasonEnd','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','businessCalendar','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','business','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','Entradas','alexm@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','buy','alexm@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','buySource','alexm@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','adminOfficer','budgetNotes','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','packager','specialLabels','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','budgetDms','alexm@%','0000-00-00 00:00:00','Select,Insert','');
@ -383,7 +380,7 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','edi','grafana','offerList','juan@d
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','bookingPlanner','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','budgetInvoiceIn','juan@10.5.1.2','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','beach','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','business','alexm@%','0000-00-00 00:00:00','Insert,Update,Delete','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','business','alexm@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','Movimientos_revisar','alexm@%','0000-00-00 00:00:00','Select,Insert','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','Movimientos_mark','alexm@%','0000-00-00 00:00:00','Select,Delete','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','Movimientos_componentes','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
@ -414,7 +411,6 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','salesPerson','Movimientos
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','handmadeBoss','Reservas','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyerBoss','bankEntity','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','Ordenes','alexm@%','0000-00-00 00:00:00','Select,Update','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','awb','juan@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','Origen','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','pago','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','awb','alexm@%','0000-00-00 00:00:00','Update','');
@ -468,6 +464,7 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','productionAssi','Reservas
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','cmr','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','Rutas','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','address','alexm@%','0000-00-00 00:00:00','Insert','');
INSERT IGNORE INTO `tables_priv` VALUES ('','pbx','grafana','queue','root@localhost','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','address','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','accountingType','guillermo@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','itemShelvingStock_byWarehouse','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select','');
@ -485,7 +482,6 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','absenceType','alexm@%','
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','artificialBoss','Entradas_Auto','alexm@%','0000-00-00 00:00:00','Select,Insert','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','productionAssi','Vehiculos_consumo','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','tblContadores','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','buyMark','juan@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','calendar','juan@10.5.1.2','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','calendarHolidays','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','claimManager','claim','alexm@%','0000-00-00 00:00:00','Select','');
@ -638,7 +634,6 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','ppeGroup','a
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','floramondoNotOfferDay__','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','fuelType','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','ppeDMS','alexm@%','0000-00-00 00:00:00','Select,Insert,Delete','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','manager','genericAllocation','alexm@%','0000-00-00 00:00:00','Select,Insert,Update','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','ppeComponent','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','ppe','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','glsExpedition__','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
@ -744,7 +739,7 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','mrw','guille
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','mrwService','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','ppePlan','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hrBoss','accountingConfig','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','buy','alexm@%','0000-00-00 00:00:00','Delete','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','buy','carlosap@10.5.1.8','0000-00-00 00:00:00','Select,Update,Delete','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','buy','alexm@%','0000-00-00 00:00:00','Delete','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','saleGoal','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','packager','packingSiteLog','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Insert','');
@ -759,9 +754,8 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenance','moving','guill
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hrBoss','machineDetail','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hrBoss','machineDms','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','claimManager','vehicle','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','awb','alexm@%','0000-00-00 00:00:00','Insert,Update','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','awb','alexm@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hrBoss','machine','alexm@%','0000-00-00 00:00:00','Select,Insert,Update','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','buy','juan@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select,Update','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','Entradas_dits','alexm@%','0000-00-00 00:00:00','Insert,Update','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','workerTimeControlMail','alexm@%','0000-00-00 00:00:00','Select,Update','');
INSERT IGNORE INTO `tables_priv` VALUES ('','bi','coolerBoss','rotacion','alexm@%','0000-00-00 00:00:00','Select','');
@ -784,6 +778,7 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','vehicleState
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','vehicleEvent','alexm@%','0000-00-00 00:00:00','Select,Insert','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','cooler','Tintas','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','itemBotanical','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','productionConfigLog','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','account','developer','signInLog','juan@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','ticketTracking','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','deviceProductionState','alexm@%','0000-00-00 00:00:00','Select','');
@ -794,6 +789,7 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','printServerQueue__
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','artificialBoss','buy','alexm@%','0000-00-00 00:00:00','Update','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','hr','Movimientos','alexm@%','0000-00-00 00:00:00','Update','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerAssist','buy','alexm@%','0000-00-00 00:00:00','Update','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','itemMinimumQuantity','jenkins@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','adminOfficer','receipt','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Insert','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyerBoss','producer','alexm@%','0000-00-00 00:00:00','Update','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','link','alexm@%','0000-00-00 00:00:00','Select','');
@ -909,7 +905,6 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','adminBoss','ticketService','a
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','adminBoss','ticketServiceType','alexm@%','0000-00-00 00:00:00','Select,Insert','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','ticketState','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','ticketStateToday','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','bi','employee','claims_ratio','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','greugeType','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','time','alexm@%','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','ticketWeekly','alexm@%','0000-00-00 00:00:00','Select','');
@ -1011,7 +1006,7 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','calendar','juan@db-
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','campaign','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','ticketService','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','report','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','buyer','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','buyer','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','bs','grafana','defaulter','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','componentType','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','clientManaCache','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
@ -1282,7 +1277,7 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','bs','grafana','workerProductivityC
INSERT IGNORE INTO `tables_priv` VALUES ('','srt','grafana','antenna','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','cmr','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','accounting','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','creditClassification','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','creditClassification','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','ticketLog','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','srt','grafana','moving','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','claimDevelopment','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
@ -1297,6 +1292,8 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','srt','grafana','buffer','juan@db-p
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','greuge','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','item','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','','Select,Update');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerBoss','itemShelving','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Update','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','agencyIncoming','alexm@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','addressObservation','carlosap@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
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','');
@ -1362,6 +1359,8 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','accounting',
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','grafana','ticketRequest','guillermo@10.5.1.3','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','deliveryAssistant','Vehiculos_consumo','carlosap@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','budgetState','guillermo@db-proxy1.servers.dc.verdnatura.es','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 +1383,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','inventoryConfig','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','');
@ -1397,13 +1397,20 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','bs','buyer','waste','alexm@db-prox
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','clientObservation','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','grafana','visit','root@localhost','0000-00-00 00:00:00','Select','');
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','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','bankPolicy','jgallego@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','bankPolicyDetail','jgallego@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','bankPolicyReview','jgallego@db-proxy2.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 ('','vn','greenhouseBoss','business','alexm@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','teamBoss','business','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','ticketServiceType','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','business','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','','Select');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','supplierAgencyTerm','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','itemMinimumQuantity','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','clientRate','guillermo@db-proxy1.servers.dc.verdnatura.es','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','');
@ -1422,6 +1429,32 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenanceBoss','expedition
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','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','genericAllocation','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','businessReasonEnd','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','buy_edi','alexm@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','buySource','alexm@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','bi','salesPerson','claims_ratio','alexm@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','employee','shelfMultiConfig','jenkins@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','clientConfig','carlosap@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','deliveryBoss','albaran','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','deliveryBoss','albaran_gestdoc','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','deliveryBoss','albaran_state','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryBoss','deliveryNote','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryBoss','deliveryNoteDms','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryBoss','deliveryNoteState','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesPerson','buy','alexm@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','entryType','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionBoss','claimDestination','juan@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','entryLog','alexm@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','dipole','grafana','expedition_PrintOut','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','ticketObservation','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','recovery','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','observationType','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','clientInforma','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','accountingType','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','bankPolicyDetail','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','bankPolicyReview','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','bankPolicy','guillermo@db-proxy2.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 */;
@ -1481,6 +1514,10 @@ 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','employee','business','workerFk','0000-00-00 00:00:00','Select');
INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','business','id','0000-00-00 00:00:00','Select');
INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','business','departmentFk','0000-00-00 00:00:00','Select');
INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','business','companyCodeFk','0000-00-00 00:00:00','Select');
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');
@ -1889,6 +1926,7 @@ 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','production','itemshelving_transfer','PROCEDURE','alexm@db-proxy1.servers.dc.verdnatura.es','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');
@ -2018,7 +2056,7 @@ INSERT IGNORE INTO `procs_priv` VALUES ('','account','developer','user_hasrouti
INSERT IGNORE INTO `procs_priv` VALUES ('','account','grafana','user_hasRole','FUNCTION','jgallego@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','util','guest','time_generate','PROCEDURE','jenkins@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','itemshelving_addbyclaim','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','itemshelvingtransfer','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','itemShelvingSale_addByCollection','PROCEDURE','carlosap@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','itemshelving_addlist','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','itemshelving_selfconsumption','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','item_getsimilar','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
@ -2070,7 +2108,6 @@ INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','itemshelving_add','
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','itemshelving_getsaledate','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','itemshelving_filterbuyer','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','itemshelving_addbyclaim','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','itemshelvingtransfer','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','itemshelving_addlist','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','itemshelving_selfconsumption','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','item_getsimilar','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00');
@ -2145,6 +2182,17 @@ INSERT IGNORE INTO `procs_priv` VALUES ('','vn','claimManager','buy_recalcPrice
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','buy_recalcPricesByBuy','PROCEDURE','jenkins@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','hr','ledger_nextTx','PROCEDURE','guillermo@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','hr','ledger_docompensation','PROCEDURE','guillermo@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','itemShelvingSale_setQuantity','PROCEDURE','carlosap@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','itemShelvingSale_unpicked','PROCEDURE','carlosap@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','collection_getAssigned','PROCEDURE','carlosap@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','collection_addWithReservation','PROCEDURE','carlosap@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','itemShelvingSale_addBySectorCollection','PROCEDURE','carlosap@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','sectorCollection_hasSalesReserved','FUNCTION','carlosap@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','itemShelvingSale_reallocate','PROCEDURE','carlosap@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','itemShelvingSale_setPicked','PROCEDURE','carlosap@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','sectorCollection_getMyPartial','PROCEDURE','carlosap@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','grafana-write','item_ValuateInventory','PROCEDURE','guillermo@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
INSERT IGNORE INTO `procs_priv` VALUES ('','vn','guest','ticketCalculatePurge','PROCEDURE','jenkins@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00');
/*!40000 ALTER TABLE `procs_priv` ENABLE KEYS */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
@ -2185,7 +2233,8 @@ INSERT IGNORE INTO `global_priv` VALUES ('','financial','{\"access\": 0, \"vers
INSERT IGNORE INTO `global_priv` VALUES ('','financialBoss','{\"access\": 0, \"version_id\": 101106, \"is_role\": true}');
INSERT IGNORE INTO `global_priv` VALUES ('','floranet','{\"access\":0,\"version_id\":101106,\"is_role\":true}');
INSERT IGNORE INTO `global_priv` VALUES ('','grafana','{\"access\":0,\"version_id\":101106,\"is_role\":true}');
INSERT IGNORE INTO `global_priv` VALUES ('','greenhouseBoss','{\"access\":0,\"version_id\":100707,\"is_role\":true}');
INSERT IGNORE INTO `global_priv` VALUES ('','grafana-write','{\"access\":0,\"version_id\":101106,\"is_role\":true}');
INSERT IGNORE INTO `global_priv` VALUES ('','greenhouseBoss','{\"access\":0,\"version_id\":101106,\"is_role\":true}');
INSERT IGNORE INTO `global_priv` VALUES ('','guest','{\"access\": 0, \"max_questions\": 40000, \"max_updates\": 1000, \"max_connections\": 150000, \"max_user_connections\": 200, \"max_statement_time\": 0.000000, \"is_role\": true, \"version_id\": 101106}');
INSERT IGNORE INTO `global_priv` VALUES ('','handmadeBoss','{\"access\":0,\"version_id\":101106,\"is_role\":true}');
INSERT IGNORE INTO `global_priv` VALUES ('','hedera-web','{\"access\":0,\"version_id\":100707,\"is_role\":true}');
@ -2201,7 +2250,7 @@ INSERT IGNORE INTO `global_priv` VALUES ('','logisticBoss','{\"access\":0,\"ver
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\":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 ('','manager','{\"access\":0,\"version_id\":101106,\"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}');
INSERT IGNORE INTO `global_priv` VALUES ('','officeBoss','{\"access\":0,\"version_id\":101106,\"is_role\":true}');
@ -2220,6 +2269,7 @@ INSERT IGNORE INTO `global_priv` VALUES ('','salesPerson','{\"access\": 0, \"is
INSERT IGNORE INTO `global_priv` VALUES ('','salesTeamBoss','{\"access\":0,\"version_id\":100707,\"is_role\":true}');
INSERT IGNORE INTO `global_priv` VALUES ('','salix','{\"access\":33555456,\"version_id\":100707,\"is_role\":true}');
INSERT IGNORE INTO `global_priv` VALUES ('','sysadmin','{\"access\": 201326592, \"is_role\": true, \"version_id\": 100707}');
INSERT IGNORE INTO `global_priv` VALUES ('','teamBoss','{\"access\":0,\"version_id\":101106,\"is_role\":true}');
/*!40000 ALTER TABLE `global_priv` ENABLE KEYS */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;

File diff suppressed because it is too large Load Diff

View File

@ -175,6 +175,70 @@ 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 `account`.`mailAliasAccount_beforeInsert`
BEFORE INSERT ON `mailAliasAccount`
FOR EACH ROW
BEGIN
SET NEW.editorFk = account.myUser_getId();
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 `account`.`mailAliasAccount_beforeUpdate`
BEFORE UPDATE ON `mailAliasAccount`
FOR EACH ROW
BEGIN
SET NEW.editorFk = account.myUser_getId();
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 `account`.`mailAliasAccount_afterDelete`
AFTER DELETE ON `mailAliasAccount`
FOR EACH ROW
BEGIN
INSERT INTO userLog
SET `action` = 'delete',
`changedModel` = 'MailAliasAccount',
`changedModelId` = OLD.id,
`userFk` = account.myUser_getId();
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 `account`.`mailForward_beforeInsert`
BEFORE INSERT ON `mailForward`
FOR EACH ROW
@ -3616,6 +3680,46 @@ 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`.`clientUnpaid_beforeInsert`
BEFORE INSERT ON `clientUnpaid`
FOR EACH ROW
BEGIN
SET NEW.editorFk = account.myUser_getId();
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`.`clientUnpaid_beforeUpdate`
BEFORE UPDATE ON `clientUnpaid`
FOR EACH ROW
BEGIN
SET NEW.editorFk = account.myUser_getId();
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`.`cmr_beforeDelete`
BEFORE DELETE ON `cmr`
FOR EACH ROW
@ -4044,29 +4148,22 @@ DELIMITER ;
/*!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 = utf8mb3 */ ;
/*!50003 SET character_set_results = utf8mb3 */ ;
/*!50003 SET collation_connection = utf8mb3_general_ci */ ;
/*!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 = 'NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`delivery_beforeInsert`
BEFORE INSERT ON `delivery`
FOR EACH ROW
BEGIN
IF (NEW.longitude IS NOT NULL AND NEW.latitude IS NOT NULL AND NEW.ticketFK IS NOT NULL)
IF (NEW.longitude IS NOT NULL
AND NEW.latitude IS NOT NULL
AND NEW.ticketFK IS NOT NULL)
THEN
UPDATE address
SET longitude = NEW.longitude,
latitude = NEW.latitude
WHERE id IN (
SELECT addressFK
FROM ticket
WHERE id = NEW.ticketFk
);
CALL address_updateCoordinates(NEW.ticketFk, NEW.longitude, NEW.latitude);
END IF;
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@ -4076,29 +4173,22 @@ DELIMITER ;
/*!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 = utf8mb3 */ ;
/*!50003 SET character_set_results = utf8mb3 */ ;
/*!50003 SET collation_connection = utf8mb3_general_ci */ ;
/*!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 = 'NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`delivery_beforeUpdate`
BEFORE UPDATE ON `delivery`
FOR EACH ROW
BEGIN
IF (NEW.longitude IS NOT NULL AND NEW.latitude IS NOT NULL AND NEW.ticketFK IS NOT NULL)
IF (NEW.longitude IS NOT NULL
AND NEW.latitude IS NOT NULL
AND NEW.ticketFK IS NOT NULL)
THEN
UPDATE address
SET longitude = NEW.longitude,
latitude = NEW.latitude
WHERE id IN (
SELECT addressFK
FROM ticket
WHERE id = NEW.ticketFk
);
CALL address_updateCoordinates(NEW.ticketFk, NEW.longitude, NEW.latitude);
END IF;
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@ -4671,11 +4761,9 @@ BEGIN
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
@ -6138,13 +6226,12 @@ 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`.`itemShelving_beforeInsert`
BEFORE INSERT ON `itemShelving`
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemMinimumQuantity_beforeInsert`
BEFORE INSERT ON `itemMinimumQuantity`
FOR EACH ROW
BEGIN
SET NEW.editorFk = account.myUser_getId();
SET NEW.userFk = account.myUser_getId();
CALL itemMinimumQuantity_check(NEW.id, NEW.itemFk, NEW.started, NEW.ended, NEW.warehouseFk);
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@ -6160,26 +6247,60 @@ 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`.`itemShelving_afterInsert`
AFTER INSERT ON `itemShelving`
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemMinimumQuantity_beforeUpdate`
BEFORE UPDATE ON `itemMinimumQuantity`
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
) */;;
BEGIN
SET NEW.editorFk = account.myUser_getId();
CALL itemMinimumQuantity_check(NEW.id, NEW.itemFk, NEW.started, NEW.ended, NEW.warehouseFk);
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`.`itemMinimumQuantity_afterDelete`
AFTER DELETE ON `itemMinimumQuantity`
FOR EACH ROW
BEGIN
INSERT INTO itemLog
SET `action` = 'delete',
`changedModel` = 'ItemMinimumQuantity',
`changedModelId` = OLD.id,
`userFk` = account.myUser_getId();
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`.`itemShelving_beforeInsert`
BEFORE INSERT ON `itemShelving`
FOR EACH ROW
BEGIN
SET NEW.editorFk = account.myUser_getId();
SET NEW.userFk = account.myUser_getId();
SET NEW.available = NEW.visible;
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
@ -6198,10 +6319,12 @@ DELIMITER ;;
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;
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@ -6220,7 +6343,8 @@ DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 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',
@ -6228,7 +6352,10 @@ INSERT INTO itemShelvingLog
shelvingFk = NEW.shelvingFk,
visible = NEW.visible,
`grouping` = NEW.`grouping`,
packing = NEW.packing */;;
packing = NEW.packing,
available = NEW.available;
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
@ -6294,15 +6421,39 @@ 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`.`itemShelving_afterDelete`
AFTER DELETE ON `itemShelving`
FOR EACH ROW
BEGIN
INSERT INTO shelvingLog
SET `action` = 'delete',
`changedModel` = 'itemShelving',
`changedModelId` = OLD.id,
`userFk` = account.myUser_getId();
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`.`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 ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@ -7147,6 +7298,70 @@ 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`.`productionConfig_beforeInsert`
BEFORE INSERT ON `productionConfig`
FOR EACH ROW
BEGIN
SET NEW.editorFk = account.myUser_getId();
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`.`productionConfig_beforeUpdate`
BEFORE UPDATE ON `productionConfig`
FOR EACH ROW
BEGIN
SET NEW.editorFk = account.myUser_getId();
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`.`productionConfig_afterDelete`
AFTER DELETE ON `productionConfig`
FOR EACH ROW
BEGIN
INSERT INTO productionConfig
SET `action` = 'delete',
`changedModel` = 'ProductionConfig',
`changedModelId` = OLD.id,
`userFk` = account.myUser_getId();
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`.`projectNotes_beforeInsert`
BEFORE INSERT ON `projectNotes`
FOR EACH ROW
@ -9005,13 +9220,16 @@ BEGIN
SET NEW.editorFk = account.myUser_getId();
IF NOT (NEW.routeFk <=> OLD.routeFk) THEN
INSERT IGNORE INTO `vn`.`routeRecalc` (`routeFk`)
SELECT r.id
FROM vn.route r
WHERE r.isOk = FALSE
AND r.id IN (OLD.routeFk,NEW.routeFk)
AND r.created >= util.VN_CURDATE()
GROUP BY r.id;
IF NEW.isSigned THEN
CALL util.throw('A signed ticket cannot be rerouted');
END IF;
INSERT IGNORE INTO routeRecalc(routeFk)
SELECT id
FROM `route`
WHERE NOT isOk
AND id IN (OLD.routeFk, NEW.routeFk)
AND created >= util.VN_CURDATE()
GROUP BY id;
END IF;
IF NOT (DATE(NEW.shipped) <=> DATE(OLD.shipped)) THEN
@ -10924,4 +11142,4 @@ USE `vn2008`;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2024-06-25 7:27:06
-- Dump completed on 2024-08-06 6:03:19

View File

@ -10,9 +10,6 @@ SET foreign_key_checks = 0;
INSERT INTO util.config (id, environment, mockTime, mockUtcTime, mockEnabled)
VALUES (1, 'local', '2001-01-01 12:00:00', '2001-01-01 11:00:00', TRUE);
INSERT INTO util.binlogQueue (code,logName, `position`)
VALUES ('mylogger', 'bin.000001', 4);
/* #5483
INSERT INTO vn.entryConfig (defaultEntry, mailToNotify, inventorySupplierFk, maxLockTime, defaultSupplierFk)
VALUES(1, NULL, 1, 300, 1);
@ -314,5 +311,4 @@ INSERT INTO mysql.roles_mapping (`User`, `Host`, `Role`, `Admin_option`)
SELECT SUBSTR(`User`, @prefixLen + 1), `Host`, `Role`, `Admin_option`
FROM mysql.roles_mapping
WHERE `User` LIKE @prefixedLike AND `Host` = @genRoleHost;
FLUSH PRIVILEGES;

View File

@ -115,10 +115,13 @@ INSERT INTO `hedera`.`tpvConfig`(`id`, `currency`, `terminal`, `transactionType`
VALUES
(1, 978, 1, 0, 2000, 9, 0);
INSERT INTO hedera.orderConfig (`id`, `employeeFk`, `defaultAgencyFk`, `guestMethod`, `guestAgencyFk`, `reserveTime`, `defaultCompanyFk`)
VALUES (1, 1, 2, 'PICKUP', 1, '00:20:00', 442);
INSERT INTO `account`.`user`(`id`,`name`,`nickname`, `password`,`role`,`active`,`email`,`lang`, `image`)
VALUES
(1101, 'brucewayne', 'Bruce Wayne', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'BruceWayne@mydomain.com', 'es','1101'),
(1102, 'petterparker', 'Petter Parker', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'PetterParker@mydomain.com', 'en','1102'),
(1102, 'petterparker', 'Petter Parker', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 131, 1, 'PetterParker@mydomain.com', 'en','1102'),
(1103, 'clarkkent', 'Clark Kent', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'ClarkKent@mydomain.com', 'fr','1103'),
(1104, 'tonystark', 'Tony Stark', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'TonyStark@mydomain.com', 'es','1104'),
(1105, 'maxeisenhardt', 'Max Eisenhardt', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'MaxEisenhardt@mydomain.com', 'pt','1105'),
@ -301,6 +304,17 @@ UPDATE `vn`.`agencyMode` SET `deliveryMethodFk` = 1 WHERE `id` = 8;
UPDATE `vn`.`agencyMode` SET `deliveryMethodFk` = 4 WHERE `id` = 23;
UPDATE `vn`.`agencyMode` SET `deliveryMethodFk` = 1 WHERE `id` = 10;
UPDATE `vn`.`agencyMode` SET `description` = 'inhouse pickup' WHERE `id` = 1;
UPDATE `vn`.`agencyMode` SET `description` = 'Super-Man delivery' WHERE `id` = 2;
UPDATE `vn`.`agencyMode` SET `description` = 'Teleportation device' WHERE `id` = 3;
UPDATE `vn`.`agencyMode` SET `description` = 'Entanglement' WHERE `id` = 4;
UPDATE `vn`.`agencyMode` SET `description` = 'Quantum break device' WHERE `id` = 5;
UPDATE `vn`.`agencyMode` SET `description` = 'Walking' WHERE `id` = 6;
UPDATE `vn`.`agencyMode` SET `description` = 'Gotham247' WHERE `id` = 7;
UPDATE `vn`.`agencyMode` SET `description` = 'Gotham247Expensive' WHERE `id` = 8;
UPDATE `vn`.`agencyMode` SET `description` = 'Other agency' WHERE `id` = 10;
UPDATE `vn`.`agencyMode` SET `description` = 'Refund' WHERE `id` = 23;
UPDATE `vn`.`agencyMode` SET `web` = 1, `reportMail` = 'no-reply@gothamcity.com';
UPDATE `vn`.`agencyMode` SET `code` = 'refund' WHERE `id` = 23;
@ -528,7 +542,8 @@ INSERT INTO `vn`.`observationType`(`id`,`description`, `code`)
(5, 'Administrative', 'administrative'),
(6, 'Weight', 'weight'),
(7, 'InvoiceOut', 'invoiceOut'),
(8, 'DropOff', 'dropOff');
(8, 'DropOff', 'dropOff'),
(9, 'Sustitución', 'substitution');
INSERT INTO `vn`.`addressObservation`(`id`,`addressFk`,`observationTypeFk`,`description`)
VALUES
@ -978,6 +993,14 @@ INSERT INTO `vn`.`priceFixed`(`id`, `itemFk`, `rate0`, `rate1`, `rate2`, `rate3`
(2, 3, 10, 10, 10, 10, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), 0, 1, util.VN_CURDATE()),
(3, 13, 8.5, 10, 7.5, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), 1, 2, util.VN_CURDATE());
INSERT INTO `vn`.`itemMinimumQuantity`(`itemFk`, `quantity`, `started`, `ended`, `warehouseFk`)
VALUES
(1, 5, util.VN_CURDATE() - INTERVAL 2 MONTH, util.VN_CURDATE() + INTERVAL 1 MONTH, 1),
(2, 10, util.VN_CURDATE() - INTERVAL 2 DAY, util.VN_CURDATE() - INTERVAL 1 DAY, 2),
(3, 15, util.VN_CURDATE() + INTERVAL 3 DAY, util.VN_CURDATE() + INTERVAL 2 WEEK, 3),
(2, 10, util.VN_CURDATE() + INTERVAL 2 MONTH, NULL, 5),
(4, 8, util.VN_CURDATE() - INTERVAL 3 MONTH, NULL, NULL);
INSERT INTO `vn`.`expeditionBoxVol`(`boxFk`, `m3`, `ratio`)
VALUES
(71,0.141,1);
@ -1477,7 +1500,8 @@ INSERT INTO `vn`.`travel`(`id`,`shipped`, `landed`, `warehouseInFk`, `warehouseO
(5, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 3, 3, 1, 50.00, 500, 'fifth travel', 1, 1, 5),
(6, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 4, 4, 1, 50.00, 500, 'sixth travel', 1, 2, 6),
(7, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 4, 1, 50.00, 500, 'seventh travel', 2, 1, 7),
(8, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 1, 1, 50.00, 500, 'eight travel', 1, 2, 10);
(8, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 1, 1, 50.00, 500, 'eight travel', 1, 2, 10),
(10, DATE_ADD(util.VN_CURDATE(), INTERVAL + 5 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL + 5 DAY), 5, 1, 1, 50.00, 500, 'nineth travel', 1, 2, 10);
INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed`, `companyFk`, `invoiceNumber`, `reference`, `isExcludedFromAvailable`, `isRaid`, `evaNotes`)
VALUES
@ -1488,25 +1512,27 @@ INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed
(5, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 0, 442, 'IN2005', 'Movement 5', 0, 0, 'observation five'),
(6, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 6, 0, 442, 'IN2006', 'Movement 6', 0, 0, 'observation six'),
(7, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'IN2007', 'Movement 7', 0, 0, 'observation seven'),
(8, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'IN2008', 'Movement 8', 1, 1, '');
(8, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'IN2008', 'Movement 8', 1, 1, ''),
(9, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 9', 1, 1, ''),
(10, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 9', 1, 1, '');
INSERT INTO `bs`.`waste`(`buyer`, `year`, `week`, `family`, `itemFk`, `itemTypeFk`, `saleTotal`, `saleWaste`, `rate`)
INSERT INTO `bs`.`waste`(`buyerFk`, `year`, `week`, `itemFk`, `itemTypeFk`, `saleTotal`, `saleWasteQuantity`, `saleInternalWaste`, `saleExternalWaste`)
VALUES
('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Carnation', 1, 1, '1062', '51', '4.8'),
('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Carnation Colombia', 2, 1, '35074', '687', '2.0'),
('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Carnation Mini', 3, 1, '1777', '13', '0.7'),
('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Carnation Short', 4, 1, '3182', '59', '0.6'),
('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Crisantemo', 5, 1, '1747', '13', '0.7'),
('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Lilium Oriental', 6, 1, '7182', '59', '0.6'),
('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Alstroemeria', 7, 1, '1777', '13', '0.7'),
('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Cymbidium', 1, 1, '4181', '59', '0.6'),
('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Cymbidium', 2, 1, '7268', '59', '0.6'),
('DavidCharlesHaller', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Containers', 2, 1, '-74', '0', '0.0'),
('DavidCharlesHaller', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Packagings', 3, 1, '-7', '0', '0.0'),
('DavidCharlesHaller', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Freight', 4, 1, '1100', '0', '0.0'),
('HankPym', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Funeral Accessories', 5, 1, '848', '-187', '-22.1'),
('HankPym', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Miscellaneous Accessories', 6, 1, '186', '0', '0.0'),
('HankPym', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Adhesives', 7, 1, '277', '0', '0.0');
('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 1, 1, '1062', '51', '56.20', '56.20'),
('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 2, 1, '35074', '687', '53.12', '89.69'),
('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 3, 1, '1777', '13', '12.02', '53.12'),
('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 4, 1, '3182', '59', '51', '56.20'),
('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 5, 1, '1747', '13', '53.12', '53.12'),
('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 6, 1, '7182', '59', '51', '53.12'),
('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 7, 1, '1777', '13', '89.69', '89.69'),
('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 8, 1, '4181', '59', '53.12', '53.12'),
('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 9, 1, '7268', '59', '12.02', '56.20'),
('103', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 2, 1, '-74', '0', '51', '89.69'),
('103', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 3, 1, '-7', '0', '12.02', '53.12'),
('103', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 4, 1, '1100', '0', '51', '56.20'),
('103', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 5, 1, '848', '-187', '12.02', '89.69'),
('103', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 6, 1, '186', '0', '51', '53.12'),
('103', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 7, 1, '277', '0', '53.12', '56.20');
INSERT INTO `vn`.`buy`(`id`,`entryFk`,`itemFk`,`buyingValue`,`quantity`,`packagingFk`,`stickers`,`freightValue`,`packageValue`,`comissionValue`,`packing`,`grouping`,`groupingMode`,`location`,`price1`,`price2`,`price3`, `printedStickers`,`isChecked`,`isIgnored`,`weight`, `created`)
VALUES
@ -1942,7 +1968,7 @@ INSERT INTO `vn`.`orderTicket`(`orderFk`, `ticketFk`)
(21, 21),
(22, 22);
INSERT INTO `vn`.`userConfig` (`userFk`, `warehouseFk`, `companyFk`)
INSERT INTO `vn`.`userMultiConfig` (`userFk`, `warehouseFk`, `companyFk`)
VALUES
(1, 1, 69),
(5, 1, 442),

View File

@ -1,31 +1,45 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`waste_addSales`()
BEGIN
DECLARE vWeek INT;
DECLARE vYear INT;
DECLARE vDateFrom DATE DEFAULT util.VN_CURDATE() - INTERVAL WEEKDAY(util.VN_CURDATE()) DAY;
DECLARE vDateTo DATE DEFAULT vDateFrom + INTERVAL 6 DAY;
CALL cache.last_buy_refresh(FALSE);
SELECT week, year
INTO vWeek, vYear
FROM vn.time
WHERE dated = util.VN_CURDATE();
REPLACE bs.waste
SELECT *, 100 * mermas / total as porcentaje
FROM (
SELECT buyer,
year,
week,
family,
itemFk,
itemTypeFk,
floor(sum(value)) as total,
floor(sum(IF(typeFk = 'loses', value, 0))) as mermas
FROM vn.saleValue
where year = vYear and week = vWeek
GROUP BY family, itemFk
) sub
ORDER BY mermas DESC;
SELECT YEAR(t.shipped),
WEEK(t.shipped, 4),
it.workerFk,
it.id,
s.itemFk,
SUM((b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity),
SUM(IF(aw.`type`, s.quantity, 0)),
SUM(
IF(
aw.`type` = 'internal',
(b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity,
0
)
),
SUM(
IF(
aw.`type` = 'external',
(b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity,
0
)
)
FROM vn.sale s
JOIN vn.item i ON i.id = s.itemFk
JOIN vn.itemType it ON it.id = i.typeFk
JOIN vn.ticket t ON t.id = s.ticketFk
JOIN vn.address a FORCE INDEX (PRIMARY) ON a.id = t.addressFk
LEFT JOIN vn.addressWaste aw ON aw.addressFk = a.id
JOIN vn.warehouse w ON w.id = t.warehouseFk
JOIN cache.last_buy lb ON lb.item_id = i.id
AND lb.warehouse_id = w.id
JOIN vn.buy b ON b.id = lb.buy_id
WHERE t.shipped BETWEEN vDateFrom AND vDateTo
AND w.isManaged
GROUP BY i.id;
END$$
DELIMITER ;

View File

@ -30,7 +30,7 @@ proc: BEGIN
SELECT inventoried INTO started FROM vn.config LIMIT 1;
SET ended = util.VN_CURDATE(); -- TIMESTAMPADD(DAY, -1, util.VN_CURDATE());
CALL vn.buyUltimateFromInterval(NULL, started, ended);
CALL vn.buy_getUltimateFromInterval(NULL, NULL, started, ended);
DELETE FROM last_buy;

View File

@ -1,13 +1,13 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `cache`.`visible_refresh`(OUT v_calc INT, v_refresh BOOL, v_warehouse INT)
proc: BEGIN
proc:BEGIN
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
CALL cache_calc_unlock (v_calc);
RESIGNAL;
END;
CALL cache_calc_start (v_calc, v_refresh, 'visible', v_warehouse);
CALL cache_calc_start (v_calc, v_refresh, 'visible', v_warehouse);
IF !v_refresh THEN
LEAVE proc;
@ -15,22 +15,26 @@ proc: BEGIN
-- Calculamos el stock hasta ayer
CALL `cache`.stock_refresh(false);
CALL cache.stock_refresh(false);
CREATE OR REPLACE TEMPORARY TABLE tmp.itemVisible
(PRIMARY KEY (item_id))
ENGINE = MEMORY
SELECT item_id, amount stock, amount visible FROM `cache`.stock
WHERE warehouse_id = v_warehouse;
SELECT s.item_id, SUM(s.amount) stock, SUM(s.amount) visible
FROM stock s
JOIN vn.warehouse w ON w.id = s.warehouse_id
WHERE (v_warehouse IS NULL OR s.warehouse_id = v_warehouse)
AND w.isComparative
GROUP BY s.item_id;
-- Calculamos los movimientos confirmados de hoy
CALL vn.item_GetVisible(v_warehouse, NULL);
CALL vn.item_calcVisible(NULL, v_warehouse);
DELETE FROM visible WHERE calc_id = v_calc;
INSERT INTO visible (calc_id, item_id,visible)
SELECT v_calc, item_id, visible FROM tmp.itemVisible;
CALL cache_calc_end (v_calc);
CALL cache_calc_end (v_calc);
DROP TEMPORARY TABLE tmp.itemVisible;
END$$

View File

@ -25,12 +25,7 @@ BEGIN
JOIN vn.warehouse w ON w.id = p.warehouseFk
ORDER BY warehouseFk, `grouping`;
DROP TEMPORARY TABLE
tmp.ticketCalculateItem,
tmp.ticketComponentPrice,
tmp.ticketComponent,
tmp.ticketLot,
tmp.zoneGetShipped,
tmp.item;
CALL vn.ticketCalculatePurge();
DROP TEMPORARY TABLE tmp.item;
END$$
DELIMITER ;

View File

@ -56,11 +56,23 @@ BEGIN
CALL util.throw ('ORDER_ROW_UNAVAILABLE');
END IF;
SELECT IFNULL(minQuantity, 0) INTO vMinQuantity
FROM vn.item
WHERE id = vItem;
WITH itemMinQuantityPriority AS (
SELECT quantity,
ROW_NUMBER() OVER (
PARTITION BY itemFk
ORDER BY warehouseFk IS NULL
) priority
FROM vn.itemMinimumQuantity
WHERE itemFk = vItem
AND `started` <= vShipment
AND (`ended` >= vShipment OR `ended` IS NULL)
AND (warehouseFk = vWarehouse OR warehouseFk IS NULL)
)
SELECT quantity INTO vMinQuantity
FROM itemMinQuantityPriority
WHERE priority = 1;
IF vAmount < LEAST(vMinQuantity, vAvailable) THEN
IF vAmount < LEAST(IFNULL(vMinQuantity, 0), vAvailable) THEN
CALL util.throw ('quantityLessThanMin');
END IF;

View File

@ -1,59 +1,62 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`order_confirmWithUser`(vSelf INT, vUserId INT)
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`order_confirmWithUser`(
vSelf INT,
vUserFk INT
)
BEGIN
/**
* Confirms an order, creating each of its tickets on the corresponding
* date, store and user.
* Confirms an order, creating each of its tickets
* on the corresponding date, store and user.
*
* @param vSelf The order identifier
* @param vUser The user identifier
*/
DECLARE vOk BOOL;
DECLARE vDone BOOL DEFAULT FALSE;
DECLARE vWarehouse INT;
DECLARE vHasRows BOOL;
DECLARE vDone BOOL;
DECLARE vWarehouseFk INT;
DECLARE vShipment DATE;
DECLARE vTicket INT;
DECLARE vShipmentDayEnd DATETIME;
DECLARE vTicketFk INT;
DECLARE vNotes VARCHAR(255);
DECLARE vItem INT;
DECLARE vItemFk INT;
DECLARE vConcept VARCHAR(30);
DECLARE vAmount INT;
DECLARE vAvailable INT;
DECLARE vPrice DECIMAL(10,2);
DECLARE vSale INT;
DECLARE vRate INT;
DECLARE vRowId INT;
DECLARE vSaleFk INT;
DECLARE vRowFk INT;
DECLARE vPriceFixed DECIMAL(10,2);
DECLARE vDelivery DATE;
DECLARE vAddress INT;
DECLARE vIsConfirmed BOOL;
DECLARE vClientId INT;
DECLARE vCompanyId INT;
DECLARE vAgencyModeId INT;
DECLARE TICKET_FREE INT DEFAULT 2;
DECLARE vCalc INT;
DECLARE vIsLogifloraItem BOOL;
DECLARE vOldQuantity INT;
DECLARE vNewQuantity INT;
DECLARE vLanded DATE;
DECLARE vAddressFk INT;
DECLARE vClientFk INT;
DECLARE vCompanyFk INT;
DECLARE vAgencyModeFk INT;
DECLARE vCalcFk INT;
DECLARE vIsTaxDataChecked BOOL;
DECLARE cDates CURSOR FOR
SELECT zgs.shipped, r.warehouse_id
DECLARE vDates CURSOR FOR
SELECT zgs.shipped, r.warehouseFk
FROM `order` o
JOIN order_row r ON r.order_id = o.id
LEFT JOIN tmp.zoneGetShipped zgs ON zgs.warehouseFk = r.warehouse_id
WHERE o.id = vSelf AND r.amount != 0
GROUP BY r.warehouse_id;
JOIN orderRow r ON r.orderFk = o.id
LEFT JOIN tmp.zoneGetShipped zgs ON zgs.warehouseFk = r.warehouseFk
WHERE o.id = vSelf
AND r.amount
GROUP BY r.warehouseFk;
DECLARE cRows CURSOR FOR
SELECT r.id, r.item_id, i.name, r.amount, r.price, r.rate, i.isFloramondo
FROM order_row r
JOIN vn.item i ON i.id = r.item_id
WHERE r.amount != 0
AND r.warehouse_id = vWarehouse
AND r.order_id = vSelf
DECLARE vRows CURSOR FOR
SELECT r.id,
r.itemFk,
i.name,
r.amount,
r.price
FROM orderRow r
JOIN vn.item i ON i.id = r.itemFk
WHERE r.amount
AND r.warehouseFk = vWarehouseFk
AND r.orderFk = vSelf
ORDER BY r.rate DESC;
DECLARE CONTINUE HANDLER FOR NOT FOUND
SET vDone = TRUE;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
@ -62,26 +65,36 @@ BEGIN
END;
-- Carga los datos del pedido
SELECT o.date_send, o.address_id, o.note, a.clientFk,
o.company_id, o.agency_id, c.isTaxDataChecked
INTO vDelivery, vAddress, vNotes, vClientId,
vCompanyId, vAgencyModeId, vIsTaxDataChecked
FROM hedera.`order` o
SELECT o.date_send,
o.address_id,
o.note,
a.clientFk,
o.company_id,
o.agency_id,
c.isTaxDataChecked
INTO vLanded,
vAddressFk,
vNotes,
vClientFk,
vCompanyFk,
vAgencyModeFk,
vIsTaxDataChecked
FROM `order` o
JOIN vn.address a ON a.id = o.address_id
JOIN vn.client c ON c.id = a.clientFk
WHERE o.id = vSelf;
-- Verifica si el cliente tiene los datos comprobados
IF NOT vIsTaxDataChecked THEN
CALL util.throw ('clientNotVerified');
CALL util.throw('clientNotVerified');
END IF;
-- Carga las fechas de salida de cada almacen
CALL vn.zone_getShipped (vDelivery, vAddress, vAgencyModeId, FALSE);
CALL vn.zone_getShipped(vLanded, vAddressFk, vAgencyModeFk, FALSE);
-- Trabajador que realiza la accion
IF vUserId IS NULL THEN
SELECT employeeFk INTO vUserId FROM orderConfig;
IF vUserFk IS NULL THEN
SELECT employeeFk INTO vUserFk FROM orderConfig;
END IF;
START TRANSACTION;
@ -89,207 +102,188 @@ BEGIN
CALL order_checkEditable(vSelf);
-- Check order is not empty
SELECT COUNT(*) > 0 INTO vHasRows
FROM orderRow
WHERE orderFk = vSelf
AND amount > 0;
SELECT COUNT(*) > 0 INTO vOk
FROM order_row WHERE order_id = vSelf AND amount > 0;
IF NOT vOk THEN
CALL util.throw ('ORDER_EMPTY');
IF NOT vHasRows THEN
CALL util.throw('ORDER_EMPTY');
END IF;
-- Crea los tickets del pedido
OPEN cDates;
lDates:
LOOP
SET vTicket = NULL;
OPEN vDates;
lDates: LOOP
SET vTicketFk = NULL;
SET vDone = FALSE;
FETCH cDates INTO vShipment, vWarehouse;
FETCH vDates INTO vShipment, vWarehouseFk;
IF vDone THEN
LEAVE lDates;
END IF;
-- Busca un ticket existente que coincida con los parametros
WITH tPrevia AS
(SELECT DISTINCT s.ticketFk
SET vShipmentDayEnd = util.dayEnd(vShipment);
-- Busca un ticket libre disponible
WITH tPrevia AS (
SELECT DISTINCT s.ticketFk
FROM vn.sale s
JOIN vn.saleGroupDetail sgd ON sgd.saleFk = s.id
JOIN vn.ticket t ON t.id = s.ticketFk
WHERE t.shipped BETWEEN vShipment AND util.dayend(vShipment)
)
SELECT t.id INTO vTicket
WHERE t.shipped BETWEEN vShipment AND vShipmentDayEnd
)
SELECT t.id INTO vTicketFk
FROM vn.ticket t
JOIN vn.alertLevel al ON al.code = 'FREE'
LEFT JOIN tPrevia tp ON tp.ticketFk = t.id
LEFT JOIN vn.ticketState tls on tls.ticketFk = t.id
JOIN hedera.`order` o
ON o.address_id = t.addressFk
AND vWarehouse = t.warehouseFk
AND o.date_send = t.landed
AND DATE(t.shipped) = vShipment
LEFT JOIN vn.ticketState tls ON tls.ticketFk = t.id
JOIN hedera.`order` o ON o.address_id = t.addressFk
AND t.shipped BETWEEN vShipment AND vShipmentDayEnd
AND t.warehouseFk = vWarehouseFk
AND o.date_send = t.landed
WHERE o.id = vSelf
AND t.refFk IS NULL
AND tp.ticketFk IS NULL
AND (tls.alertLevel IS NULL OR tls.alertLevel = al.id)
LIMIT 1;
-- Comprobamos si hay un ticket de previa disponible
IF vTicketFk IS NULL THEN
WITH tItemPackingTypeOrder AS (
SELECT GROUP_CONCAT(
DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk
) distinctItemPackingTypes,
o.address_id
FROM vn.item i
JOIN hedera.orderRow oro ON oro.itemFk = i.id
JOIN hedera.`order` o ON o.id = oro.orderFk
WHERE oro.orderFk = vSelf
),
tItemPackingTypeTicket AS (
SELECT t.id,
GROUP_CONCAT(
DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk
) distinctItemPackingTypes
FROM vn.ticket t
JOIN vn.ticketState tls ON tls.ticketFk = t.id
JOIN vn.alertLevel al ON al.id = tls.alertLevel
JOIN vn.sale s ON s.ticketFk = t.id
JOIN vn.item i ON i.id = s.itemFk
JOIN tItemPackingTypeOrder ipto
WHERE t.shipped BETWEEN vShipment AND vShipmentDayEnd
AND t.refFk IS NULL
AND t.warehouseFk = vWarehouseFk
AND t.addressFk = ipto.address_id
AND al.code = 'ON_PREVIOUS'
GROUP BY t.id
)
SELECT iptt.id INTO vTicketFk
FROM tItemPackingTypeTicket iptt
JOIN tItemPackingTypeOrder ipto
WHERE INSTR(iptt.distinctItemPackingTypes, ipto.distinctItemPackingTypes)
LIMIT 1;
END IF;
-- Crea el ticket en el caso de no existir uno adecuado
IF vTicket IS NULL
THEN
IF vTicketFk IS NULL THEN
SET vShipment = IFNULL(vShipment, util.VN_CURDATE());
CALL vn.ticket_add(
vClientId,
vClientFk,
vShipment,
vWarehouse,
vCompanyId,
vAddress,
vAgencyModeId,
vWarehouseFk,
vCompanyFk,
vAddressFk,
vAgencyModeFk,
NULL,
vDelivery,
vUserId,
vLanded,
vUserFk,
TRUE,
vTicket
vTicketFk
);
ELSE
INSERT INTO vn.ticketTracking
SET ticketFk = vTicket,
userFk = vUserId,
stateFk = TICKET_FREE;
SET ticketFk = vTicketFk,
userFk = vUserFk,
stateFk = (SELECT id FROM vn.state WHERE code = 'FREE');
END IF;
INSERT IGNORE INTO vn.orderTicket
SET orderFk = vSelf,
ticketFk = vTicket;
ticketFk = vTicketFk;
-- Añade las notas
IF vNotes IS NOT NULL AND vNotes != ''
THEN
INSERT INTO vn.ticketObservation SET
ticketFk = vTicket,
observationTypeFk = 4 /* salesperson */ ,
IF vNotes IS NOT NULL AND vNotes <> '' THEN
INSERT INTO vn.ticketObservation
SET ticketFk = vTicketFk,
observationTypeFk = (SELECT id FROM vn.observationType WHERE code = 'salesPerson'),
`description` = vNotes
ON DUPLICATE KEY UPDATE
`description` = CONCAT(VALUES(`description`),'. ', `description`);
END IF;
-- Añade los movimientos y sus componentes
OPEN cRows;
OPEN vRows;
lRows: LOOP
SET vSaleFk = NULL;
SET vDone = FALSE;
FETCH cRows INTO vRowId, vItem, vConcept, vAmount, vPrice, vRate, vIsLogifloraItem;
FETCH vRows INTO vRowFk, vItemFk, vConcept, vAmount, vPrice;
IF vDone THEN
LEAVE lRows;
END IF;
SET vSale = NULL;
SELECT s.id, s.quantity INTO vSale, vOldQuantity
SELECT s.id INTO vSaleFk
FROM vn.sale s
WHERE ticketFk = vTicket
WHERE ticketFk = vTicketFk
AND price = vPrice
AND itemFk = vItem
AND itemFk = vItemFk
AND discount = 0
LIMIT 1;
IF vSale THEN
IF vSaleFk THEN
UPDATE vn.sale
SET quantity = quantity + vAmount,
originalQuantity = quantity
WHERE id = vSale;
SELECT s.quantity INTO vNewQuantity
FROM vn.sale s
WHERE id = vSale;
WHERE id = vSaleFk;
ELSE
-- Obtiene el coste
SELECT SUM(rc.`price`) valueSum INTO vPriceFixed
FROM orderRowComponent rc
JOIN vn.component c ON c.id = rc.componentFk
JOIN vn.componentType ct ON ct.id = c.typeFk AND ct.isBase
WHERE rc.rowFk = vRowId;
JOIN vn.componentType ct ON ct.id = c.typeFk
AND ct.isBase
WHERE rc.rowFk = vRowFk;
INSERT INTO vn.sale
SET itemFk = vItem,
ticketFk = vTicket,
SET itemFk = vItemFk,
ticketFk = vTicketFk,
concept = vConcept,
quantity = vAmount,
price = vPrice,
priceFixed = vPriceFixed,
isPriceFixed = TRUE;
SET vSale = LAST_INSERT_ID();
SET vSaleFk = LAST_INSERT_ID();
INSERT INTO vn.saleComponent
(saleFk, componentFk, `value`)
SELECT vSale, rc.componentFk, rc.price
INSERT INTO vn.saleComponent (saleFk, componentFk, `value`)
SELECT vSaleFk, rc.componentFk, rc.price
FROM orderRowComponent rc
JOIN vn.component c ON c.id = rc.componentFk
WHERE rc.rowFk = vRowId
GROUP BY vSale, rc.componentFk;
WHERE rc.rowFk = vRowFk
GROUP BY vSaleFk, rc.componentFk;
END IF;
UPDATE order_row SET Id_Movimiento = vSale
WHERE id = vRowId;
-- Inserta en putOrder si la compra es de Floramondo
IF vIsLogifloraItem THEN
CALL cache.availableNoRaids_refresh(vCalc,FALSE,vWarehouse,vShipment);
SET @available := 0;
SELECT GREATEST(0,available) INTO @available
FROM cache.availableNoRaids
WHERE calc_id = vCalc
AND item_id = vItem;
UPDATE cache.availableNoRaids
SET available = GREATEST(0,available - vAmount)
WHERE item_id = vItem
AND calc_id = vCalc;
INSERT INTO edi.putOrder (
deliveryInformationID,
supplyResponseId,
quantity ,
EndUserPartyId,
EndUserPartyGLN,
FHAdminNumber,
saleFk
)
SELECT di.ID,
i.supplyResponseFk,
CEIL((vAmount - @available)/ sr.NumberOfItemsPerCask),
o.address_id ,
vClientId,
IFNULL(ca.fhAdminNumber, fhc.defaultAdminNumber),
vSale
FROM edi.deliveryInformation di
JOIN vn.item i ON i.supplyResponseFk = di.supplyResponseID
JOIN edi.supplyResponse sr ON sr.ID = i.supplyResponseFk
LEFT JOIN edi.clientFHAdminNumber ca ON ca.clientFk = vClientId
JOIN edi.floraHollandConfig fhc
JOIN hedera.`order` o ON o.id = vSelf
WHERE i.id = vItem
AND di.LatestOrderDateTime > util.VN_NOW()
AND vAmount > @available
LIMIT 1;
END IF;
UPDATE orderRow
SET saleFk = vSaleFk
WHERE id = vRowFk;
END LOOP;
CLOSE cRows;
CLOSE vRows;
END LOOP;
CLOSE vDates;
CLOSE cDates;
UPDATE `order` SET confirmed = TRUE, confirm_date = util.VN_NOW()
UPDATE `order`
SET confirmed = TRUE,
confirm_date = util.VN_NOW()
WHERE id = vSelf;
COMMIT;

View File

@ -10,5 +10,5 @@ AS SELECT `q`.`name` AS `name`,
`c`.`ringInUse` AS `ringinuse`
FROM (
`pbx`.`queue` `q`
JOIN `pbx`.`queueConfig` `c` ON(`q`.`config` = `c`.`id`)
JOIN `pbx`.`queueMultiConfig` `c` ON(`q`.`config` = `c`.`id`)
)

View File

@ -0,0 +1,12 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `salix`.`ACL_afterDelete`
AFTER DELETE ON `ACL`
FOR EACH ROW
BEGIN
INSERT INTO ACLLog
SET `action` = 'delete',
`changedModel` = 'Acl',
`changedModelId` = OLD.id,
`userFk` = account.myUser_getId();
END$$
DELIMITER ;

View File

@ -0,0 +1,8 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `salix`.`ACL_beforeInsert`
BEFORE INSERT ON `ACL`
FOR EACH ROW
BEGIN
SET NEW.editorFk = account.myUser_getId();
END$$
DELIMITER ;

View File

@ -0,0 +1,8 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `salix`.`ACL_beforeUpdate`
BEFORE UPDATE ON `ACL`
FOR EACH ROW
BEGIN
SET NEW.editorFk = account.myUser_getId();
END$$
DELIMITER ;

View File

@ -0,0 +1,22 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `vn`.`claim_changeState`
ON SCHEDULE EVERY 1 DAY
STARTS '2024-06-06 07:52:46.000'
ON COMPLETION PRESERVE
ENABLE
DO BEGIN
DECLARE vClaimState INT;
SELECT id INTO vClaimState
FROM claimState cs
WHERE cs.code = 'canceled';
UPDATE claim c
JOIN claimState cs ON cs.id = c.claimStateFk
SET c.claimStateFk = vClaimState
WHERE c.created < util.VN_CURDATE() - INTERVAL 2 MONTH
AND cs.code IN('incomplete','coming','waiting','out');
END$$
DELIMITER ;

View File

@ -0,0 +1,12 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `vn`.`travel_setDelivered`
ON SCHEDULE EVERY 1 DAY
STARTS '2024-07-12 00:10:00.000'
ON COMPLETION PRESERVE
ENABLE
DO BEGIN
UPDATE travel t
SET t.isDelivered = TRUE
WHERE t.shipped < util.VN_CURDATE();
END$$
DELIMITER ;

View File

@ -0,0 +1,27 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`ticket_isProblemCalcNeeded`(
vSelf INT
)
RETURNS BOOL
DETERMINISTIC
BEGIN
/**
* Check if the ticket requires to update column vn.ticket.problem
*
* @param vSelf Id ticket
* @return BOOL
*/
DECLARE vIsProblemCalcNeeded BOOL;
SELECT COUNT(*) INTO vIsProblemCalcNeeded
FROM ticket t
JOIN client c ON c.id = t.clientFk
JOIN agencyMode am ON am.id = t.agencyModeFk
JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk
WHERE t.id = vSelf
AND dm.code IN ('AGENCY','DELIVERY','PICKUP')
AND c.typeFk = 'normal';
RETURN vIsProblemCalcNeeded;
END$$
DELIMITER ;

View File

@ -0,0 +1,25 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`address_updateCoordinates`(
vTicketFk INT,
vLongitude DECIMAL(11,7),
vLatitude DECIMAL(11,7))
BEGIN
/**
* Actualiza las coordenadas de una dirección.
*
* @param vTicketFk Id del ticket
* @param vLongitude Longitud de la dirección
* @param vLatitude Latitud de la dirección
*/
DECLARE vAddressFK INT;
SELECT addressFK INTO vAddressFK
FROM ticket
WHERE id = vTicketFk;
UPDATE address
SET longitude = vLongitude,
latitude = vLatitude
WHERE id = vAddressFK;
END$$
DELIMITER ;

View File

@ -47,7 +47,7 @@ proc: BEGIN
-- Tabla con el ultimo dia de last_buy para cada producto
-- que hace un replace de la anterior.
CALL buyUltimate(vWarehouseShipment, util.VN_CURDATE());
CALL buy_getUltimate (NULL, vWarehouseShipment, util.VN_CURDATE());
INSERT INTO tItemRange
SELECT t.itemFk, tr.landed

View File

@ -1,39 +1,18 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buyUltimate`(vWarehouseFk SMALLINT, vDated DATE)
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buyUltimate`(
vWarehouseFk SMALLINT,
vDated DATE
)
BEGIN
/**
* Calcula las últimas compras realizadas hasta una fecha
* @deprecated Usar buy_getUltimate
* Calcula las últimas compras realizadas hasta una fecha.
*
* @param vItemFk Id del artículo
* @param vWarehouseFk Id del almacén
* @param vDated Compras hasta fecha
* @return tmp.buyUltimate
*/
CALL cache.last_buy_refresh (FALSE);
DROP TEMPORARY TABLE IF EXISTS tmp.buyUltimate;
CREATE TEMPORARY TABLE tmp.buyUltimate
(PRIMARY KEY (itemFk, warehouseFk),
INDEX(itemFk))
ENGINE = MEMORY
SELECT item_id itemFk, buy_id buyFk, warehouse_id warehouseFk, landing
FROM cache.last_buy
WHERE warehouse_id = vWarehouseFk OR vWarehouseFk IS NULL;
CALL buyUltimateFromInterval(vWarehouseFk, util.VN_CURDATE(), vDated);
REPLACE INTO tmp.buyUltimate
SELECT itemFk, buyFk, warehouseFk, landed landing
FROM tmp.buyUltimateFromInterval
WHERE (warehouseFk = vWarehouseFk OR vWarehouseFk IS NULL)
AND landed <= vDated
AND NOT isIgnored;
INSERT IGNORE INTO tmp.buyUltimate
SELECT itemFk, buyFk, warehouseFk, landed landing
FROM tmp.buyUltimateFromInterval
WHERE (warehouseFk = vWarehouseFk OR vWarehouseFk IS NULL)
AND landed > vDated
ORDER BY isIgnored = FALSE DESC;
CALL buy_getUltimate(NULL, vWarehouseFk, vDated);
END$$
DELIMITER ;

View File

@ -1,7 +1,12 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buyUltimateFromInterval`(vWarehouseFk SMALLINT, vStarted DATE, vEnded DATE)
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buyUltimateFromInterval`(
vWarehouseFk SMALLINT,
vStarted DATE,
vEnded DATE
)
BEGIN
/**
* @deprecated Usar buy_getUltimateFromInterval
* Calcula las últimas compras realizadas
* desde un rango de fechas.
*
@ -10,128 +15,6 @@ BEGIN
* @param vEnded Fecha fin
* @return tmp.buyUltimateFromInterval
*/
IF vEnded IS NULL THEN
SET vEnded = vStarted;
END IF;
IF vEnded < vStarted THEN
SET vStarted = TIMESTAMPADD(MONTH, -1, vEnded);
END IF;
-- Item
DROP TEMPORARY TABLE IF EXISTS tmp.buyUltimateFromInterval;
CREATE TEMPORARY TABLE tmp.buyUltimateFromInterval
(PRIMARY KEY (itemFk, warehouseFk), INDEX(buyFk), INDEX(landed), INDEX(warehouseFk), INDEX(itemFk))
ENGINE = MEMORY
SELECT itemFk,
warehouseFk,
buyFk,
MAX(landed) landed,
isIgnored
FROM (SELECT b.itemFk,
t.warehouseInFk warehouseFk,
b.id buyFk,
t.landed,
b.isIgnored
FROM buy b
JOIN entry e ON e.id = b.entryFk
JOIN travel t ON t.id = e.travelFk
WHERE t.landed BETWEEN vStarted AND vEnded
AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk)
AND b.price2 > 0
ORDER BY NOT b.isIgnored DESC, t.landed DESC, b.id DESC
LIMIT 10000000000000000000) sub
GROUP BY itemFk, warehouseFk;
INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored)
SELECT
b.itemFk,
t.warehouseInFk warehouseFk,
b.id buyFk,
t.landed,
b.isIgnored
FROM buy b
JOIN entry e ON e.id = b.entryFk
JOIN travel t ON t.id = e.travelFk
WHERE t.landed > vEnded
AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk)
AND b.price2 > 0
AND NOT b.isIgnored
GROUP BY itemFk, warehouseInFk;
INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored)
SELECT
b.itemFk,
t.warehouseInFk warehouseFk,
b.id buyFk,
t.landed,
b.isIgnored
FROM buy b
JOIN entry e ON e.id = b.entryFk
JOIN travel t ON t.id = e.travelFk
WHERE t.landed BETWEEN vStarted AND vEnded
AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk)
AND b.quantity = 0
GROUP BY itemFk, warehouseInFk;
-- ItemOriginal
INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored)
SELECT itemFk,
warehouseFk,
buyFk,
MAX(landed) landed,
isIgnored
FROM (SELECT b.itemFk,
t.warehouseInFk warehouseFk,
b.id buyFk,
t.landed,
itemOriginalFk,
b.isIgnored
FROM buy b
JOIN entry e ON e.id = b.entryFk
JOIN travel t ON t.id = e.travelFk
WHERE t.landed BETWEEN vStarted AND vEnded
AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk)
AND b.price2 > 0
AND NOT b.isIgnored
AND b.quantity > 0
AND itemOriginalFk
ORDER BY t.landed DESC, b.id DESC
LIMIT 10000000000000000000) sub
GROUP BY itemOriginalFk, warehouseFk;
INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored)
SELECT
b.itemFk,
t.warehouseInFk warehouseFk,
b.id buyFk,
t.landed,
b.isIgnored
FROM buy b
JOIN entry e ON e.id = b.entryFk
JOIN travel t ON t.id = e.travelFk
WHERE t.landed > vEnded
AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk)
AND b.price2 > 0
AND NOT b.isIgnored
AND itemOriginalFk
GROUP BY itemOriginalFk, warehouseInFk;
INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored)
SELECT
b.itemFk,
t.warehouseInFk warehouseFk,
b.id buyFk,
t.landed,
b.isIgnored
FROM buy b
JOIN entry e ON e.id = b.entryFk
JOIN travel t ON t.id = e.travelFk
WHERE t.landed BETWEEN vStarted AND vEnded
AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk)
AND b.quantity = 0
AND itemOriginalFk
GROUP BY itemOriginalFk, warehouseInFk;
CALL vn.buy_getUltimateFromInterval(NULL, vWarehouseFk, vStarted, vEnded);
END$$
DELIMITER ;

View File

@ -0,0 +1,47 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_getUltimate`(
vItemFk INT,
vWarehouseFk SMALLINT,
vDated DATE
)
BEGIN
/**
* Calcula las últimas compras realizadas hasta una fecha.
*
* @param vItemFk Id del artículo
* @param vWarehouseFk Id del almacén
* @param vDated Compras hasta fecha
* @return tmp.buyUltimate
*/
CALL cache.last_buy_refresh(FALSE);
CREATE OR REPLACE TEMPORARY TABLE tmp.buyUltimate
(PRIMARY KEY (itemFk, warehouseFk),
INDEX(itemFk))
ENGINE = MEMORY
SELECT item_id itemFk, buy_id buyFk, warehouse_id warehouseFk, landing
FROM cache.last_buy
WHERE (warehouse_id = vWarehouseFk OR vWarehouseFk IS NULL)
AND (item_id = vItemFk OR vItemFk IS NULL);
IF vDated >= util.VN_CURDATE() THEN
CALL buy_getUltimateFromInterval(vItemFk, vWarehouseFk, util.VN_CURDATE(), vDated);
REPLACE INTO tmp.buyUltimate
SELECT itemFk, buyFk, warehouseFk, landed landing
FROM tmp.buyUltimateFromInterval
WHERE (warehouseFk = vWarehouseFk OR vWarehouseFk IS NULL)
AND (itemFk = vItemFk OR vItemFk IS NULL)
AND landed <= vDated
AND NOT isIgnored;
INSERT IGNORE INTO tmp.buyUltimate
SELECT itemFk, buyFk, warehouseFk, landed landing
FROM tmp.buyUltimateFromInterval
WHERE (warehouseFk = vWarehouseFk OR vWarehouseFk IS NULL)
AND (itemFk = vItemFk OR vItemFk IS NULL)
AND landed > vDated
ORDER BY isIgnored = FALSE DESC;
END IF;
END$$
DELIMITER ;

View File

@ -0,0 +1,175 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_getUltimateFromInterval`(
vItemFk INT,
vWarehouseFk SMALLINT,
vStarted DATE,
vEnded DATE
)
BEGIN
/**
* Calcula las últimas compras realizadas
* desde un rango de fechas.
*
* @param vItemFk Id del artículo
* @param vWarehouseFk Id del almacén si es NULL se actualizan todos
* @param vStarted Fecha inicial
* @param vEnded Fecha fin
* @return tmp.buyUltimateFromInterval
*/
IF vEnded IS NULL THEN
SET vEnded = vStarted;
END IF;
IF vEnded < vStarted THEN
SET vStarted = vEnded - INTERVAL 1 MONTH;
END IF;
-- Item
CREATE OR REPLACE TEMPORARY TABLE tmp.buyUltimateFromInterval
(PRIMARY KEY (itemFk, warehouseFk),
INDEX(buyFk), INDEX(landed), INDEX(warehouseFk), INDEX(itemFk))
ENGINE = MEMORY
SELECT itemFk,
warehouseFk,
buyFk,
landed,
isIgnored
FROM (SELECT b.itemFk,
t.warehouseInFk warehouseFk,
b.id buyFk,
t.landed,
b.isIgnored
FROM buy b
JOIN entry e ON e.id = b.entryFk
JOIN travel t ON t.id = e.travelFk
WHERE t.landed BETWEEN vStarted AND vEnded
AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk)
AND (b.itemFk = vItemFk OR vItemFk IS NULL)
AND b.price2 > 0
ORDER BY NOT b.isIgnored DESC, t.landed DESC, b.id DESC
LIMIT 10000000000000000000) sub
GROUP BY itemFk, warehouseFk;
INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored)
SELECT itemFk,
warehouseFk,
buyFk,
landed,
isIgnored
FROM (SELECT b.itemFk,
t.warehouseInFk warehouseFk,
b.id buyFk,
t.landed,
b.isIgnored
FROM buy b
JOIN entry e ON e.id = b.entryFk
JOIN travel t ON t.id = e.travelFk
WHERE t.landed > vEnded
AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk)
AND (b.itemFk = vItemFk OR vItemFk IS NULL)
AND b.price2 > 0
AND NOT b.isIgnored
ORDER BY NOT b.isIgnored DESC, t.landed DESC, b.id DESC
LIMIT 10000000000000000000) sub
GROUP BY itemFk, warehouseFk;
INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored)
SELECT itemFk,
warehouseFk,
buyFk,
landed,
isIgnored
FROM (SELECT b.itemFk,
t.warehouseInFk warehouseFk,
b.id buyFk,
t.landed,
b.isIgnored
FROM buy b
JOIN entry e ON e.id = b.entryFk
JOIN travel t ON t.id = e.travelFk
WHERE t.landed BETWEEN vStarted AND vEnded
AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk)
AND (b.itemFk = vItemFk OR vItemFk IS NULL)
AND b.quantity = 0
ORDER BY NOT b.isIgnored DESC, t.landed DESC, b.id DESC
LIMIT 10000000000000000000) sub
GROUP BY itemFk, warehouseFk;
-- ItemOriginal
INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored)
SELECT itemFk,
warehouseFk,
buyFk,
landed,
isIgnored
FROM (SELECT b.itemFk,
t.warehouseInFk warehouseFk,
b.id buyFk,
t.landed,
itemOriginalFk,
b.isIgnored
FROM buy b
JOIN entry e ON e.id = b.entryFk
JOIN travel t ON t.id = e.travelFk
WHERE t.landed BETWEEN vStarted AND vEnded
AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk)
AND (b.itemFk = vItemFk OR vItemFk IS NULL)
AND b.price2 > 0
AND NOT b.isIgnored
AND b.quantity > 0
AND itemOriginalFk
ORDER BY t.landed DESC, b.id DESC
LIMIT 10000000000000000000) sub
GROUP BY itemFk, warehouseFk;
INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored)
SELECT itemFk,
warehouseFk,
buyFk,
landed,
isIgnored
FROM (SELECT b.itemFk,
t.warehouseInFk warehouseFk,
b.id buyFk,
t.landed,
b.isIgnored
FROM buy b
JOIN entry e ON e.id = b.entryFk
JOIN travel t ON t.id = e.travelFk
WHERE t.landed > vEnded
AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk)
AND (b.itemFk = vItemFk OR vItemFk IS NULL)
AND b.price2 > 0
AND NOT b.isIgnored
AND itemOriginalFk
ORDER BY t.landed DESC, b.id DESC
LIMIT 10000000000000000000) sub
GROUP BY itemFk, warehouseFk;
INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored)
SELECT itemFk,
warehouseFk,
buyFk,
landed,
isIgnored
FROM
(SELECT b.itemFk,
t.warehouseInFk warehouseFk,
b.id buyFk,
t.landed,
b.isIgnored
FROM buy b
JOIN entry e ON e.id = b.entryFk
JOIN travel t ON t.id = e.travelFk
WHERE t.landed BETWEEN vStarted AND vEnded
AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk)
AND (b.itemFk = vItemFk OR vItemFk IS NULL)
AND b.quantity = 0
AND itemOriginalFk
ORDER BY t.landed DESC, b.id DESC
LIMIT 10000000000000000000) sub
GROUP BY itemFk, warehouseFk;
END$$
DELIMITER ;

View File

@ -1,5 +1,9 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_updateGrouping`(vWarehouseFk INT, vItemFk INT, vGrouping INT)
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_updateGrouping`(
vWarehouseFk INT,
vItemFk INT,
vGrouping INT
)
BEGIN
/**
* Actualiza el grouping de las últimas compras de un artículo
@ -8,9 +12,9 @@ BEGIN
* @param vItemFk Id del Artículo
* @param vGrouping Cantidad de grouping
*/
CALL vn.buyUltimate(vWarehouseFk, util.VN_CURDATE());
CALL buy_getUltimate(vItemFk, vWarehouseFk, util.VN_CURDATE());
UPDATE vn.buy b
UPDATE buy b
JOIN tmp.buyUltimate bu ON b.id = bu.buyFk
SET b.`grouping` = vGrouping
WHERE bu.warehouseFk = vWarehouseFk

View File

@ -8,7 +8,7 @@ BEGIN
* @param vItemFk id del item
* @param vPacking packing a actualizar
*/
CALL buyUltimate(vWarehouseFk, util.VN_CURDATE());
CALL buy_getUltimate(vItemFk, vWarehouseFk, util.VN_CURDATE());
UPDATE buy b
JOIN tmp.buyUltimate bu ON b.id = bu.buyFk

View File

@ -29,7 +29,7 @@ BEGIN
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
CALL vn.zone_getShipped (vLanded, vAddressFk, vAgencyModeFk, vShowExpiredZones);
CALL zone_getShipped (vLanded, vAddressFk, vAgencyModeFk, vShowExpiredZones);
DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot;
CREATE TEMPORARY TABLE tmp.ticketLot(
@ -45,8 +45,7 @@ BEGIN
CALL catalog_componentPrepare();
DROP TEMPORARY TABLE IF EXISTS tmp.ticketCalculateItem;
CREATE TEMPORARY TABLE tmp.ticketCalculateItem(
CREATE OR REPLACE TEMPORARY TABLE tmp.ticketCalculateItem(
itemFk INT(11) NOT NULL,
available INT(11),
producer VARCHAR(50),
@ -60,11 +59,11 @@ BEGIN
price DECIMAL(10,2),
priceKg DECIMAL(10,2),
`grouping` INT(10) UNSIGNED,
minQuantity INT(10) UNSIGNED,
PRIMARY KEY `itemFk` (`itemFk`)
) ENGINE = MEMORY DEFAULT CHARSET=utf8;
OPEN cTravelTree;
l: LOOP
SET vDone = FALSE;
FETCH cTravelTree INTO vZoneFk, vWarehouseFk, vShipped;
@ -73,9 +72,9 @@ BEGIN
LEAVE l;
END IF;
CALL `cache`.available_refresh (vAvailableCalc, FALSE, vWarehouseFk, vShipped);
CALL `cache`.availableNoRaids_refresh (vAvailableNoRaidsCalc, FALSE, vWarehouseFk, vShipped);
CALL vn.buyUltimate(vWarehouseFk, vShipped);
CALL `cache`.available_refresh(vAvailableCalc, FALSE, vWarehouseFk, vShipped);
CALL `cache`.availableNoRaids_refresh(vAvailableNoRaidsCalc, FALSE, vWarehouseFk, vShipped);
CALL buy_getUltimate(NULL, vWarehouseFk, vShipped);
INSERT INTO tmp.ticketLot (warehouseFk, itemFk, available, buyFk, zoneFk)
SELECT vWarehouseFk,
@ -87,17 +86,17 @@ BEGIN
LEFT JOIN cache.availableNoRaids anr ON anr.item_id = a.item_id
AND anr.calc_id = vAvailableNoRaidsCalc
JOIN tmp.item i ON i.itemFk = a.item_id
JOIN vn.item it ON it.id = i.itemFk
JOIN vn.`zone` z ON z.id = vZoneFk
JOIN item it ON it.id = i.itemFk
JOIN `zone` z ON z.id = vZoneFk
LEFT JOIN tmp.buyUltimate bu ON bu.itemFk = a.item_id
LEFT JOIN edi.supplyResponse sr ON sr.ID = it.supplyResponseFk
LEFT JOIN edi.VMPSettings v ON v.VMPID = sr.vmpID
LEFT JOIN edi.marketPlace mp ON mp.id = sr.MarketPlaceID
LEFT JOIN (SELECT isVNHSupplier, isEarlyBird, TRUE AS itemAllowed
FROM vn.addressFilter af
FROM addressFilter af
JOIN (SELECT ad.provinceFk, p.countryFk, ad.isLogifloraAllowed
FROM vn.address ad
JOIN vn.province p ON p.id = ad.provinceFk
FROM address ad
JOIN province p ON p.id = ad.provinceFk
WHERE ad.id = vAddressFk
) sub2 ON sub2.provinceFk <=> IFNULL(af.provinceFk, sub2.provinceFk)
AND sub2.countryFk <=> IFNULL(af.countryFk, sub2.countryFk)
@ -109,18 +108,18 @@ BEGIN
OR ISNULL(af.afterDated))
) sub ON sub.isVNHSupplier = v.isVNHSupplier
AND (sub.isEarlyBird = mp.isEarlyBird OR ISNULL(sub.isEarlyBird))
JOIN vn.agencyMode am ON am.id = vAgencyModeFk
JOIN vn.agency ag ON ag.id = am.agencyFk
JOIN vn.itemType itt ON itt.id = it.typeFk
JOIN vn.itemCategory itc on itc.id = itt.categoryFk
JOIN vn.address ad ON ad.id = vAddressFk
LEFT JOIN vn.clientItemType cit
JOIN agencyMode am ON am.id = vAgencyModeFk
JOIN agency ag ON ag.id = am.agencyFk
JOIN itemType itt ON itt.id = it.typeFk
JOIN itemCategory itc on itc.id = itt.categoryFk
JOIN address ad ON ad.id = vAddressFk
LEFT JOIN clientItemType cit
ON cit.clientFk = ad.clientFk
AND cit.itemTypeFk = itt.id
LEFT JOIN vn.zoneItemType zit
LEFT JOIN zoneItemType zit
ON zit.zoneFk = vZoneFk
AND zit.itemTypeFk = itt.id
LEFT JOIN vn.agencyModeItemType ait
LEFT JOIN agencyModeItemType ait
ON ait.agencyModeFk = vAgencyModeFk
AND ait.itemTypeFk = itt.id
WHERE a.calc_id = vAvailableCalc
@ -134,9 +133,9 @@ BEGIN
DROP TEMPORARY TABLE tmp.buyUltimate;
CALL vn.catalog_componentCalculate(vZoneFk, vAddressFk, vShipped, vWarehouseFk);
CALL catalog_componentCalculate(vZoneFk, vAddressFk, vShipped, vWarehouseFk);
INSERT INTO tmp.ticketCalculateItem (
INSERT INTO tmp.ticketCalculateItem(
itemFk,
available,
producer,
@ -149,9 +148,9 @@ BEGIN
origin,
price,
priceKg,
`grouping`)
SELECT
tl.itemFk,
`grouping`,
minQuantity)
SELECT tl.itemFk,
SUM(tl.available) available,
p.name producer,
i.name item,
@ -163,7 +162,8 @@ BEGIN
o.code origin,
bl.price,
bl.priceKg,
bl.`grouping`
bl.`grouping`,
mq.quantity
FROM tmp.ticketLot tl
JOIN item i ON tl.itemFk = i.id
LEFT JOIN producer p ON p.id = i.producerFk AND p.isVisible
@ -179,12 +179,28 @@ BEGIN
) sub
GROUP BY itemFk
) bl ON bl.itemFk = tl.itemFk
WHERE tl.zoneFk = vZoneFk AND tl.warehouseFk = vWarehouseFk
LEFT JOIN (
WITH itemMinQuantityPriority AS (
SELECT itemFk,
quantity,
ROW_NUMBER() OVER (
PARTITION BY itemFk
ORDER BY warehouseFk IS NULL
) priority
FROM vn.itemMinimumQuantity
WHERE `started` <= vShipped
AND (`ended` >= vShipped OR `ended` IS NULL)
AND (warehouseFk = vWarehouseFk OR warehouseFk IS NULL)
)
SELECT itemFk, quantity
FROM itemMinQuantityPriority
WHERE priority = 1
) mq ON mq.itemFk = tl.itemFk
WHERE tl.zoneFk = vZoneFk
AND tl.warehouseFk = vWarehouseFk
GROUP BY tl.itemFk
ON DUPLICATE KEY UPDATE available = available + VALUES(available);
END LOOP;
CLOSE cTravelTree;
END$$
DELIMITER ;

View File

@ -28,6 +28,10 @@ BEGIN
DELETE FROM ticketDown WHERE created < util.yesterday();
DELETE FROM entryLog WHERE creationDate < v2Months;
DELETE IGNORE FROM expedition WHERE created < v26Months;
DELETE cs
FROM sms s
JOIN clientSms cs ON cs.smsFk = s.id
WHERE s.created < v18Months;
DELETE FROM sms WHERE created < v18Months;
DELETE FROM saleTracking WHERE created < v1Years;
DELETE FROM productionError WHERE dated < v1Years;

View File

@ -34,20 +34,25 @@ BEGIN
DECLARE vIsTaxDataChecked TINYINT(1);
DECLARE vHasCoreVnl BOOLEAN;
DECLARE vMandateTypeFk INT;
DECLARE vHasDailyInvoice BOOLEAN;
SELECT defaultPayMethodFk,
defaultDueDay,
defaultCredit,
defaultIsTaxDataChecked,
defaultHasCoreVnl,
defaultMandateTypeFk
SELECT cc.defaultPayMethodFk,
cc.defaultDueDay,
cc.defaultCredit,
cc.defaultIsTaxDataChecked,
cc.defaultHasCoreVnl,
cc.defaultMandateTypeFk,
c.hasDailyInvoice
INTO vPayMethodFk,
vDueDay,
vDefaultCredit,
vIsTaxDataChecked,
vHasCoreVnl,
vMandateTypeFk
FROM clientConfig;
vMandateTypeFk,
vHasDailyInvoice
FROM clientConfig cc
LEFT JOIN province p ON p.id = vProvinceFk
LEFT JOIN country c ON c.id = p.countryFk;
INSERT INTO `client`
SET id = vUserFk,
@ -65,7 +70,8 @@ BEGIN
credit = vDefaultCredit,
isTaxDataChecked = vIsTaxDataChecked,
hasCoreVnl = vHasCoreVnl,
isEqualizated = FALSE
isEqualizated = FALSE,
hasDailyInvoice = vHasDailyInvoice
ON duplicate KEY UPDATE
payMethodFk = vPayMethodFk,
dueDay = vDueDay,

View File

@ -21,6 +21,7 @@ BEGIN
AND a.id IS NULL
AND u.active
AND c.created < util.VN_CURDATE() - INTERVAL vMonths MONTH
AND NOT u.role = (SELECT id FROM `role` WHERE name = 'supplier')
AND u.id NOT IN (
SELECT DISTINCT c.id
FROM client c

View File

@ -3,7 +3,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`collection_addWithR
vItemFk INT,
vQuantity INT,
vTicketFk INT,
vSaleGroupFk INT
vSaleGroupFk INT,
vSectorFk INT
)
BEGIN
/**
@ -67,7 +68,7 @@ BEGIN
SELECT LAST_INSERT_ID() INTO vSaleFk;
CALL sale_calculateComponent(vSaleFk, NULL);
CALL itemShelvingSale_addBySale(vSaleFk);
CALL itemShelvingSale_addBySale(vSaleFk, vSectorFk);
IF NOT EXISTS (SELECT TRUE FROM itemShelvingSale WHERE saleFk = vSaleFk LIMIT 1) THEN
SET vHasThrow = TRUE;

View File

@ -26,16 +26,16 @@ BEGIN
vErrorNumber = MYSQL_ERRNO,
vErrorMsg = MESSAGE_TEXT;
CALL util.debugAdd('collection_assign', JSON_OBJECT(
'errorNumber', vErrorNumber,
'errorMsg', vErrorMsg,
'lockName', vLockName,
'userFk', vUserFk
)); -- Tmp
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;

View File

@ -9,10 +9,11 @@ BEGIN
DECLARE vWarehouseFk INT;
DECLARE vWagons INT;
DECLARE vTrainFk INT;
DECLARE vLinesLimit INT DEFAULT NULL;
DECLARE vLinesLimit INT;
DECLARE vTicketLines INT;
DECLARE vVolumeLimit DECIMAL DEFAULT NULL;
DECLARE vVolumeLimit DECIMAL;
DECLARE vTicketVolume DECIMAL;
DECLARE vSizeLimit INT;
DECLARE vMaxTickets INT;
DECLARE vStateFk VARCHAR(45);
DECLARE vFirstTicketFk INT;
@ -53,17 +54,17 @@ BEGIN
vErrorNumber = MYSQL_ERRNO,
vErrorMsg = MESSAGE_TEXT;
CALL util.debugAdd('collection_new', JSON_OBJECT(
'errorNumber', vErrorNumber,
'errorMsg', vErrorMsg,
'lockName', vLockName,
'userFk', vUserFk,
'ticketFk', vTicketFk
)); -- Tmp
IF vLockName IS NOT NULL THEN
DO RELEASE_LOCK(vLockName);
CALL util.debugAdd('collection_new', JSON_OBJECT(
'errorNumber', vErrorNumber,
'errorMsg', vErrorMsg,
'lockName', vLockName,
'userFk', vUserFk,
'ticketFk', vTicketFk
)); -- Tmp
END IF;
RESIGNAL;
END;
@ -77,6 +78,7 @@ BEGIN
o.trainFk,
o.linesLimit,
o.volumeLimit,
o.sizeLimit,
pc.collection_new_lockname
INTO vMaxTickets,
vHasUniqueCollectionTime,
@ -88,6 +90,7 @@ BEGIN
vTrainFk,
vLinesLimit,
vVolumeLimit,
vSizeLimit,
vLockName
FROM productionConfig pc
JOIN worker w ON w.id = vUserFk
@ -172,6 +175,14 @@ BEGIN
JOIN state s ON s.id = pb.state
JOIN agencyMode am ON am.id = pb.agencyModeFk
JOIN agency a ON a.id = am.agencyFk
LEFT JOIN (
SELECT pb.ticketFk, MAX(i.`size`) maxSize
FROM tmp.productionBuffer pb
JOIN ticket t ON t.id = pb.ticketfk
JOIN sale s ON s.ticketFk = t.id
JOIN item i ON i.id = s.itemFk
GROUP BY pb.ticketFk
) sub ON sub.ticketFk = pb.ticketFk
JOIN productionConfig pc
WHERE pb.shipped <> util.VN_CURDATE()
OR (pb.ubicacion IS NULL AND a.isOwn)
@ -183,8 +194,9 @@ BEGIN
OR (NOT pb.V AND vItemPackingTypeFk = 'V')
OR (pc.isPreviousPreparationRequired AND pb.previousWithoutParking)
OR LENGTH(pb.problem) > 0
OR (pb.lines >= vLinesLimit AND vLinesLimit IS NOT NULL)
OR (pb.m3 >= vVolumeLimit AND vVolumeLimit IS NOT NULL);
OR (pb.lines > vLinesLimit AND vLinesLimit IS NOT NULL)
OR (pb.m3 > vVolumeLimit AND vVolumeLimit IS NOT NULL)
OR ((sub.maxSize > vSizeLimit OR sub.maxSize IS NOT NULL) AND vSizeLimit IS NOT NULL);
END IF;
-- Es importante que el primer ticket se coja en todos los casos

View File

@ -1,15 +1,18 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`collection_setParking`(IN `vCollectionFk` VARCHAR(8), IN `vParkingFk` INT)
proc: BEGIN
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`collection_setParking`(
vSelf INT,
vParkingFk INT
)
BEGIN
/**
* Aparca una colección en un parking.
*
* @param vCollectionFk Id de la colección
* @param vParkingFk Id del parking
* @param vSelf Id colección
* @param vParkingFk Id parking
*/
REPLACE vn.ticketParking(ticketFk, parkingFk)
REPLACE ticketParking(ticketFk, parkingFk)
SELECT tc.ticketFk, vParkingFk
FROM vn.ticketCollection tc
WHERE tc.collectionFk = vCollectionFk;
FROM ticketCollection tc
WHERE tc.collectionFk = vSelf;
END$$
DELIMITER ;

View File

@ -7,7 +7,7 @@ DECLARE vCompanyFk INT;
SELECT IFNULL(uc.companyFk, rc.defaultCompanyFk)
INTO vCompanyFk
FROM vn.routeConfig rc
LEFT JOIN userConfig uc ON uc.userFk = workerFk;
LEFT JOIN userMultiConfig uc ON uc.userFk = workerFk;
SELECT

View File

@ -12,6 +12,7 @@ BEGIN
DECLARE vInvoiceFk INT;
DECLARE vBookEntry INT;
DECLARE vFiscalYear INT;
DECLARE vIncorrectInvoiceInDueDay INT;
DECLARE vInvoicesIn CURSOR FOR
SELECT DISTINCT e.invoiceInFk
@ -24,6 +25,19 @@ BEGIN
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
SELECT GROUP_CONCAT(ii.id) INTO vIncorrectInvoiceInDueDay
FROM invoiceInDueDay iidd
JOIN invoiceIn ii ON iidd.invoiceInFk = ii.id
JOIN `entry` e ON e.invoiceInFk = ii.id
JOIN duaEntry de ON de.entryFk = e.id
JOIN invoiceInConfig iic
WHERE de.duaFk = vDuaFk
AND iidd.dueDated < util.VN_CURDATE() + INTERVAL iic.dueDateMarginDays DAY;
IF vIncorrectInvoiceInDueDay THEN
CALL util.throw(CONCAT('Incorrect due date, invoice: ', vIncorrectInvoiceInDueDay));
END IF;
UPDATE invoiceIn ii
JOIN entry e ON e.invoiceInFk = ii.id
JOIN duaEntry de ON de.entryFk = e.id
@ -81,7 +95,7 @@ BEGIN
AND (NOT e.isBooked OR NOT e.isConfirmed)
),
notBookedEntries AS (
SELECT e.id
SELECT entryFk
FROM vn.duaEntry
WHERE duaFk = vDuaFk
AND NOT customsValue

View File

@ -97,7 +97,7 @@ BEGIN
FROM tmp.itemList;
END IF;
CALL buyUltimateFromInterval(vWarehouseIn,vInventoryDate, vDateLanded);
CALL buy_getUltimateFromInterval(NULL, vWarehouseIn,vInventoryDate, vDateLanded);
CREATE OR REPLACE TEMPORARY TABLE tTransfer
ENGINE = MEMORY

View File

@ -15,7 +15,7 @@ BEGIN
DECLARE cur CURSOR FOR
SELECT bb.id buyFk,
FLOOR(ish.visible / ish.packing) ishStickers,
LEAST(bb.stickers, FLOOR(ish.visible / ish.packing)) ishStickers,
bb.stickers buyStickers
FROM itemShelving ish
JOIN (SELECT b.id, b.itemFk, b.stickers
@ -23,7 +23,6 @@ BEGIN
WHERE b.entryFk = vFromEntryFk
ORDER BY b.stickers DESC
LIMIT 10000000000000000000) bb ON bb.itemFk = ish.itemFk
AND bb.stickers >= FLOOR(ish.visible / ish.packing)
WHERE ish.shelvingFk = vShelvingFk COLLATE utf8_general_ci
AND NOT ish.isSplit
GROUP BY ish.id;
@ -110,7 +109,7 @@ BEGIN
UPDATE itemShelving
SET isSplit = TRUE
WHERE shelvingFk = vShelvingFk;
WHERE shelvingFk = vShelvingFk COLLATE utf8_general_ci;
END LOOP;
CLOSE cur;
END$$

View File

@ -1,5 +1,10 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`expeditionPallet_build`(IN vExpeditions JSON, IN vArcId INT, IN vWorkerFk INT, OUT vPalletFk INT)
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`expeditionPallet_build`(
vExpeditions JSON,
vArcId INT,
vWorkerFk INT,
OUT vPalletFk INT
)
BEGIN
/** Construye un pallet de expediciones.
*
@ -7,28 +12,22 @@ BEGIN
* en cuyo caso actualiza ese pallet.
*
* @param vExpeditions JSON_ARRAY con esta estructura [exp1, exp2, exp3, ...]
* @param vArcId INT Identificador de vn.arcRead
* @param vWorkerFk INT Identificador de vn.worker
* @param out vPalletFk Identificador de vn.expeditionPallet
* @param vArcId INT Identificador de arcRead
* @param vWorkerFk INT Identificador de worker
* @param out vPalletFk Identificador de expeditionPallet
*/
DECLARE vCounter INT;
DECLARE vExpeditionFk INT;
DECLARE vTruckFk INT;
DECLARE vPrinterFk INT;
DECLARE vExpeditionStateTypeFk INT;
DROP TEMPORARY TABLE IF EXISTS tExpedition;
CREATE TEMPORARY TABLE tExpedition
SELECT
e.id expeditionFk,
r.id routeFk,
ep.id palletFk
FROM
vn.expedition e,
vn.route r,
vn.expeditionPallet ep
LIMIT 0;
ALTER TABLE tExpedition ADD PRIMARY KEY (expeditionFk);
CREATE OR REPLACE TEMPORARY TABLE tExpedition (
expeditionFk INT,
routeFk INT,
palletFk INT,
PRIMARY KEY (expeditionFk)
);
SET vCounter = JSON_LENGTH(vExpeditions);
@ -39,53 +38,58 @@ BEGIN
INSERT IGNORE INTO tExpedition(expeditionFk, routeFk, palletFk)
SELECT vExpeditionFk, t.routeFk, es.palletFk
FROM vn.expedition e
LEFT JOIN vn.ticket t ON t.id = e.ticketFk
LEFT JOIN vn.expeditionScan es ON es.expeditionFk = e.id
FROM expedition e
LEFT JOIN ticket t ON t.id = e.ticketFk
LEFT JOIN expeditionScan es ON es.expeditionFk = e.id
WHERE e.id = vExpeditionFk;
END WHILE;
SELECT palletFk INTO vPalletFk
FROM (
SELECT palletFk, count(*) n
FROM tExpedition
WHERE palletFk > 0
GROUP BY palletFk
ORDER BY n DESC
LIMIT 100 ) sub
SELECT palletFk, count(*) n
FROM tExpedition
WHERE palletFk > 0
GROUP BY palletFk
ORDER BY n DESC
LIMIT 100
) sub
LIMIT 1;
IF vPalletFk IS NULL THEN
SELECT roadmapStopFk
INTO vTruckFk
FROM (
SELECT rm.roadmapStopFk, count(*) n
FROM vn.routesMonitor rm
JOIN tExpedition e ON e.routeFk = rm.routeFk
GROUP BY roadmapStopFk
ORDER BY n DESC
LIMIT 1) sub;
SELECT roadmapStopFk INTO vTruckFk
FROM (
SELECT rm.roadmapStopFk, count(*) n
FROM routesMonitor rm
JOIN tExpedition e ON e.routeFk = rm.routeFk
GROUP BY roadmapStopFk
ORDER BY n DESC
LIMIT 1
) sub;
IF vTruckFk IS NULL THEN
CALL util.throw ('TRUCK_NOT_AVAILABLE');
END IF;
INSERT INTO vn.expeditionPallet(truckFk)
VALUES(vTruckFk);
INSERT INTO expeditionPallet SET truckFk = vTruckFk;
SET vPalletFk = LAST_INSERT_ID();
END IF;
INSERT INTO vn.expeditionScan(expeditionFk, palletFk, workerFk)
INSERT INTO expeditionScan(expeditionFk, palletFk, workerFk)
SELECT expeditionFk, vPalletFk, vWorkerFk
FROM tExpedition
ON DUPLICATE KEY UPDATE palletFk = vPalletFk, workerFk = vWorkerFk;
SELECT printerFk INTO vPrinterFk
FROM vn.arcRead
WHERE id = vArcId;
SELECT id INTO vExpeditionStateTypeFk
FROM expeditionStateType
WHERE code = 'PALLETIZED';
CALL vn.report_print(
INSERT INTO expeditionState(expeditionFk, typeFk)
SELECT expeditionFk, vExpeditionStateTypeFk FROM tExpedition;
SELECT printerFk INTO vPrinterFk FROM arcRead WHERE id = vArcId;
CALL report_print(
'LabelPalletExpedition',
vPrinterFk,
account.myUser_getId(),
@ -93,7 +97,7 @@ BEGIN
'high'
);
UPDATE vn.expeditionPallet SET isPrint = TRUE WHERE id = vPalletFk;
UPDATE expeditionPallet SET isPrint = TRUE WHERE id = vPalletFk;
DROP TEMPORARY TABLE tExpedition;
END$$

View File

@ -1,11 +1,18 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`expeditionScan_Put`(vPalletFk INT, vExpeditionFk INT)
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`expeditionScan_Put`(
vPalletFk INT,
vExpeditionFk INT
)
BEGIN
REPLACE vn.expeditionScan(expeditionFk, palletFk)
VALUES(vExpeditionFk, vPalletFk);
SELECT LAST_INSERT_ID() INTO vPalletFk;
IF NOT (SELECT TRUE FROM expedition WHERE id = vExpeditionFk LIMIT 1) THEN
CALL util.throw('Expedition not exists');
END IF;
IF NOT (SELECT TRUE FROM expeditionPallet WHERE id = vPalletFk LIMIT 1) THEN
CALL util.throw('Pallet not exists');
END IF;
REPLACE expeditionScan(expeditionFk, palletFk)
VALUES(vExpeditionFk, vPalletFk);
END$$
DELIMITER ;

View File

@ -1,5 +1,7 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceInDueDay_calculate`(vInvoiceInFk INT)
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceInDueDay_calculate`(
vInvoiceInFk INT
)
BEGIN
/**
* Calcula los vctos. de una factura recibida
@ -56,12 +58,13 @@ BEGIN
COUNT(DISTINCT(pdd.detail)) cont,
s.payDay,
ii.issued,
DATE(ii.created) + INTERVAL 2 DAY created
DATE(ii.created) + INTERVAL iic.dueDateMarginDays DAY created
FROM invoiceIn ii
JOIN invoiceInTax iit ON iit.invoiceInFk = ii.id
LEFT JOIN sage.TiposIva ti ON ti.CodigoIva= iit.taxTypeSageFk
JOIN supplier s ON s.id = ii.supplierFk
JOIN payDemDetail pdd ON pdd.id = s.payDemFk
JOIN payDemDetail pdd ON pdd.id = s.payDemFk
JOIN invoiceInConfig iic
WHERE ii.id = vInvoiceInFk
GROUP BY ii.id
)sub

View File

@ -13,30 +13,18 @@ BEGIN
* @param vBookEntry Id de asiento, si es NULL se genera uno nuevo
*/
DECLARE vFiscalYear INT;
DECLARE vDistinctTransactions INT;
DECLARE vHasRepeatedTransactions BOOL;
SELECT COUNT(DISTINCT iit.transactionTypeSageFk) INTO vDistinctTransactions
FROM invoiceIn ii
JOIN invoiceInTax iit ON iit.invoiceInFk = ii.id
JOIN invoiceInSerial iis ON iis.code = ii.serial
WHERE iit.invoiceInFk = vSelf
AND iis.taxAreaFk = 'CEE'
AND iit.transactionTypeSageFk;
IF vDistinctTransactions > 1 THEN
CALL util.throw ('This invoice does not allow different types of transactions');
END IF;
SELECT TRUE INTO vHasRepeatedTransactions
FROM invoiceInTax
WHERE invoiceInFk = vSelf
GROUP BY transactionTypeSageFk
HAVING COUNT(transactionTypeSageFk) > 1
FROM invoiceInTax iit
JOIN invoiceIn ii ON ii.id = iit.invoiceInFk
WHERE ii.id = vSelf
AND ii.serial = 'E'
HAVING COUNT(DISTINCT iit.transactionTypeSageFk) > 1
LIMIT 1;
IF vHasRepeatedTransactions THEN
CALL util.throw ('This invoice contains repeated types of transactions');
CALL util.throw ('This invoice contains different types of transactions');
END IF;
CREATE OR REPLACE TEMPORARY TABLE tInvoiceIn

View File

@ -216,7 +216,7 @@ BEGIN
i.transactionTypeSageFk,
@vTaxCodeGeneral := i.taxClassCodeFk
FROM tmp.ticketServiceTax tst
JOIN invoiceOutTaxConfig i ON i.taxClassCodeFk = tst.code
JOIN invoiceOutTaxMultiConfig i ON i.taxClassCodeFk = tst.code
WHERE i.isService
HAVING taxableBase
) sub;
@ -229,7 +229,7 @@ BEGIN
i.taxTypeSageFk ,
i.transactionTypeSageFk
FROM tmp.ticketTax tt
JOIN invoiceOutTaxConfig i ON i.taxClassCodeFk = tt.code
JOIN invoiceOutTaxMultiConfig i ON i.taxClassCodeFk = tt.code
WHERE !i.isService
GROUP BY tt.pgcFk
HAVING taxableBase

View File

@ -0,0 +1,28 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemMinimumQuantity_check`(
vSelf INT,
vItemFk INT,
vStarted DATE,
vEnded DATE,
vWarehouseFk INT
)
BEGIN
DECLARE vHasCollision BOOL;
IF vStarted IS NULL THEN
CALL util.throw('The field "started" cannot be null');
END IF;
SELECT COUNT(*) INTO vHasCollision
FROM itemMinimumQuantity
WHERE vItemFk = itemFk
AND ((vStarted <= ended OR ended IS NULL)
AND (vStarted >= `started` OR vEnded IS NULL))
AND (vWarehouseFk <=> warehouseFk)
AND vSelf <> id;
IF vHasCollision THEN
CALL util.throw('A line with the same configuration already exists');
END IF;
END$$
DELIMITER ;

View File

@ -44,7 +44,7 @@ BEGIN
LEAVE l;
END IF;
CALL itemShelvingSale_addBySale(vSaleFk);
CALL itemShelvingSale_addBySale(vSaleFk, NULL);
END LOOP;
CLOSE vSales;
END$$

View File

@ -1,102 +1,119 @@
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 $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_addBySale`(
vSaleFk INT,
vSectorFk 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
* @param vSectorFk Id del sector del operator
*/
DECLARE vLastPickingOrder INT;
DECLARE vDone INT DEFAULT FALSE;
DECLARE vItemShelvingFk INT;
DECLARE vAvailable INT;
DECLARE vReservedQuantity INT;
DECLARE vOutStanding INT;
DECLARE vUserFk INT;
DECLARE vTotalReservedQuantity INT;
DECLARE vSaleQuantity 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
AND (sc.id = vSectorFk OR vSectorFk IS NULL)
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)), s.quantity
INTO vLastPickingOrder, vOutStanding, vSaleQuantity
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
SELECT SUM(IFNULL(quantity, 0))
INTO vTotalReservedQuantity
FROM itemShelvingSale
WHERE saleFk = vSaleFk;
IF vTotalReservedQuantity <> vSaleQuantity THEN
UPDATE sale
SET quantity = vTotalReservedQuantity
WHERE id = vSaleFk;
END IF;
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,
isPicked)
SELECT vItemShelvingFk,
vSaleFk,
vReservedQuantity,
vUserFk,
FALSE;
UPDATE itemShelving
SET available = available - vReservedQuantity
WHERE id = vItemShelvingFk;
END IF;
COMMIT;
END LOOP;
CLOSE vItemShelvingAvailable;
END$$
DELIMITER ;

View File

@ -0,0 +1,46 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_addBySaleGroup`(
vSaleGroupFk INT(11)
)
BEGIN
/**
* Reserva cantidades con ubicaciones para el contenido de una preparación previa
* a través del saleGroup
*
* @param vSaleGroupFk Identificador de saleGroup
*/
DECLARE vDone BOOL DEFAULT FALSE;
DECLARE vSaleFk INT;
DECLARE vSectorFk INT;
DECLARE vSales CURSOR FOR
SELECT s.id
FROM saleGroupDetail sgd
JOIN sale s ON sgd.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 sgd.saleGroupFk = vSaleGroupFk
AND str.workerFk = account.myUser_getId()
AND iss.id IS NULL;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
SELECT sectorFk INTO vSectorFk
FROM operator
WHERE workerFk = account.myUser_getId();
OPEN vSales;
l: LOOP
SET vDone = FALSE;
FETCH vSales INTO vSaleFk;
IF vDone THEN
LEAVE l;
END IF;
CALL itemShelvingSale_addBySale(vSaleFk, vSectorFk);
END LOOP;
CLOSE vSales;
END$$
DELIMITER ;

View File

@ -10,8 +10,9 @@ BEGIN
*/
DECLARE vDone BOOL DEFAULT FALSE;
DECLARE vSaleFk INT;
DECLARE vSectorFk INT;
DECLARE vSales CURSOR FOR
SELECT s.id
SELECT DISTINCT s.id
FROM sectorCollectionSaleGroup sc
JOIN saleGroupDetail sg ON sg.saleGroupFk = sc.saleGroupFk
JOIN sale s ON sg.saleFk = s.id
@ -25,6 +26,10 @@ BEGIN
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
SELECT sectorFk INTO vSectorFk
FROM operator
WHERE workerFk = account.myUser_getId();
OPEN vSales;
l: LOOP
SET vDone = FALSE;
@ -34,7 +39,7 @@ BEGIN
LEAVE l;
END IF;
CALL itemShelvingSale_addBySale(vSaleFk);
CALL itemShelvingSale_addBySale(vSaleFk, vSectorFk);
END LOOP;
CLOSE vSales;
END$$

View File

@ -6,9 +6,10 @@ proc: BEGIN
*/
DECLARE vDone BOOL;
DECLARE vSaleFk INT;
DECLARE vSectorFk INT;
DECLARE vSales CURSOR FOR
SELECT DISTINCT saleFk FROM tSale;
SELECT DISTINCT saleFk, sectorFk FROM tSale;
DECLARE CONTINUE HANDLER FOR NOT FOUND
SET vDone = TRUE;
@ -26,24 +27,25 @@ proc: BEGIN
CREATE OR REPLACE TEMPORARY TABLE tSale
ENGINE = MEMORY
SELECT id, saleFk FROM itemShelvingSaleReserve;
SELECT id, saleFk, sectorFk FROM itemShelvingSaleReserve;
OPEN vSales;
myLoop: LOOP
SET vDone = FALSE;
FETCH vSales INTO vSaleFk;
FETCH vSales INTO vSaleFk, vSectorFk;
IF vDone THEN
LEAVE myLoop;
END IF;
CALL itemShelvingSale_addBySale (vSaleFk);
CALL itemShelvingSale_addBySale (vSaleFk, vSectorFk);
END LOOP;
CLOSE vSales;
DELETE iss FROM itemShelvingSaleReserve iss JOIN tSale s ON s.id = iss.id;
DELETE iss FROM itemShelvingSaleReserve iss
JOIN tSale s ON s.id = iss.id AND s.sectorFk = iss.sectorFk;
DROP TEMPORARY TABLE tSale;

View File

@ -1,49 +1,55 @@
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 $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_reallocate`(
vItemShelvingFk INT(10),
vItemFk INT(10),
vSectorFk INT
)
BEGIN
/**
* Elimina reservas de un itemShelving e intenta reservar en otra ubicación
*
* @param vItemShelvingFk Id itemShelving
* @param vItemFk Id del artículo
* @param vSectorFk Id del sector
*/
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
ROLLBACK;
RESIGNAL;
END;
START TRANSACTION;
UPDATE itemShelving
SET visible = 0,
available = 0
WHERE id = vItemShelvingFk
AND itemFk = vItemFk;
SELECT iss.id
FROM itemShelvingSale iss
JOIN itemShelving ish ON ish.id = iss.itemShelvingFk
WHERE iss.itemShelvingFk = vItemShelvingFk
AND ish.itemFk = vItemFk
AND NOT iss.isPicked
FOR UPDATE;
INSERT INTO itemShelvingSaleReserve (saleFk, sectorFk)
SELECT DISTINCT iss.saleFk, vSectorFk
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 ;

View File

@ -2,7 +2,8 @@ DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_setQuantity`(
vItemShelvingSaleFk INT(10),
vQuantity DECIMAL(10,0),
vIsItemShelvingSaleEmpty BOOLEAN
vIsItemShelvingSaleEmpty BOOLEAN,
vSectorFk INT
)
BEGIN
/**
@ -14,6 +15,7 @@ BEGIN
* @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
* @param vSectorFk Id del sector
*/
DECLARE vSaleFk INT;
DECLARE vItemShelvingFk INT;
@ -21,6 +23,7 @@ BEGIN
DECLARE vRemainingQuantity INT;
DECLARE vItemFk INT;
DECLARE vTotalQuantity INT;
DECLARE vStateCode VARCHAR(45);
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
@ -28,21 +31,35 @@ BEGIN
RESIGNAL;
END;
IF vQuantity > vReservedQuantity
OR (vQuantity < vReservedQuantity AND NOT vIsItemShelvingSaleEmpty)
OR (vQuantity = vReservedQuantity AND vIsItemShelvingSaleEmpty) THEN
CALL util.throw('The quantity cannot be different from the reserved');
END IF;
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
SELECT s.itemFk,
iss.saleFk,
iss.itemShelvingFk,
SUM(IFNULL(iss.quantity,0)),
IF(sgd.id, 'PREVIOUS_PREPARATION', 'PREPARED')
INTO vItemFk,
vSaleFk,
vItemShelvingFk,
vReservedQuantity,
vStateCode
FROM itemShelvingSale iss
JOIN sale s ON s.id = iss.saleFk
LEFT JOIN vn.saleGroupDetail sgd ON sgd.saleFk = 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
OR (vQuantity < vReservedQuantity AND NOT vIsItemShelvingSaleEmpty)
OR (vQuantity = vReservedQuantity AND vIsItemShelvingSaleEmpty) THEN
CALL util.throw('The quantity cannot be different from the reserved');
END IF;
@ -62,7 +79,7 @@ BEGIN
SET visible = GREATEST(0, visible - vQuantity)
WHERE id = vItemShelvingFk;
SELECT SUM(IF(isPicked, 0, quantity)), SUM(quantity)
SELECT SUM(IF(isPicked OR id = vItemShelvingSaleFk, 0, quantity)), SUM(quantity)
INTO vRemainingQuantity, vTotalQuantity
FROM itemShelvingSale
WHERE saleFk = vSaleFk;
@ -74,7 +91,7 @@ BEGIN
vTotalQuantity,
`account`.`myUser_getId`(),
NULL,
'PREPARED',
vStateCode,
TRUE);
UPDATE sale s
@ -86,9 +103,9 @@ BEGIN
COMMIT;
IF vIsItemShelvingSaleEmpty AND vQuantity <> vReservedQuantity THEN
INSERT INTO itemShelvingSaleReserve (saleFk)
SELECT vSaleFk;
CALL itemShelvingSale_reallocate(vItemShelvingFk, vItemFk);
INSERT INTO itemShelvingSaleReserve (saleFk, sectorFk)
SELECT vSaleFk, vSectorFk;
CALL itemShelvingSale_reallocate(vItemShelvingFk, vItemFk, vSectorFk);
END IF;
END$$
DELIMITER ;

View File

@ -15,7 +15,7 @@ BEGIN
JOIN ticket t ON t.id = c.ticketFk
WHERE c.id = vClaimFk;
CALL buyUltimate (vWarehouseFk, util.VN_CURDATE());
CALL buy_getUltimate(NULL, vWarehouseFk, util.VN_CURDATE());
INSERT INTO itemShelving (itemFk, shelvingFk, packing, `grouping`, visible)
SELECT s.itemFk, vShelvingFk, b.packing, b.`grouping`, cb.quantity AS visible

View File

@ -16,7 +16,8 @@ BEGIN
ish.id,
s.priority,
ish.isChecked,
ic.url
ic.url,
ish.available
FROM itemShelving ish
JOIN item i ON i.id = ish.itemFk
JOIN shelving s ON vSelf = s.code COLLATE utf8_unicode_ci

View File

@ -23,7 +23,7 @@ BEGIN
FROM operator
WHERE workerFk = account.myUser_getId();
CALL buyUltimate(vWarehouseFk, util.VN_CURDATE());
CALL buy_getUltimate(vBarcodeItem, vWarehouseFk, util.VN_CURDATE());
SELECT buyFk INTO vBuyFk
FROM tmp.buyUltimate

View File

@ -1,43 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_GetVisible`(vWarehouse SMALLINT, vItem INT)
BEGIN
DECLARE vTomorrow DATETIME DEFAULT TIMESTAMPADD(DAY, 1, util.VN_CURDATE());
INSERT INTO tmp.itemVisible (item_id, visible)
SELECT item_id, SUM(amount) amount
FROM (
SELECT i.itemFk AS item_id, quantity AS amount
FROM itemTicketOut i
LEFT JOIN ticketState ts ON ts.ticketFk = i.ticketFk
JOIN state s ON s.id = ts.stateFk
LEFT JOIN (SELECT DISTINCT saleFk
FROM saleTracking st
JOIN state s ON s.id = st.stateFk
WHERE st.created > util.VN_CURDATE()
AND (s.isPicked OR st.isChecked)
) stPrevious ON `stPrevious`.`saleFk` = i.saleFk
WHERE i.warehouseFk = vWarehouse
AND (vItem IS NULL OR i.itemFk = vItem)
AND (s.isPicked OR i.reserved OR stPrevious.saleFk )
AND i.shipped >= util.VN_CURDATE() AND i.shipped < vTomorrow
UNION ALL
SELECT iei.itemFk, quantity
FROM itemEntryIn iei
WHERE (iei.isReceived != FALSE /*OR ip.modificationDate > util.VN_CURDATE()*/)
AND iei.landed >= util.VN_CURDATE() AND iei.landed < vTomorrow
AND iei.warehouseInFk = vWarehouse
AND (vItem IS NULL OR iei.itemFk = vItem)
AND iei.isVirtualStock is FALSE
UNION ALL
SELECT itemFk, quantity
FROM itemEntryOut
WHERE isDelivered != FALSE
AND shipped >= util.VN_CURDATE() AND shipped < vTomorrow
AND warehouseOutFk = vWarehouse
AND (vItem IS NULL OR itemFk = vItem)
) t
GROUP BY item_id
ON DUPLICATE KEY UPDATE
visible = IFNULL(stock,0) + VALUES(visible);
END$$
DELIMITER ;

View File

@ -0,0 +1,62 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_calcVisible`(
vSelf INT,
vWarehouseFk INT
)
BEGIN
/**
* Calcula el visible de un artículo o de todos.
*
* @param vWarehouse Warehouse id
* @param vSelf Item id
* @param tmp.itemVisible(item_id, stock, visible)
*/
DECLARE vDated DATE DEFAULT util.VN_CURDATE();
DECLARE vTomorrow DATETIME DEFAULT util.tomorrow();
INSERT INTO tmp.itemVisible(item_id, visible)
SELECT itemFk, SUM(quantity)
FROM (
SELECT i.itemFk, i.quantity
FROM itemTicketOut i
LEFT JOIN ticketState ts ON ts.ticketFk = i.ticketFk
JOIN `state` s ON s.id = ts.stateFk
JOIN warehouse w ON w.id = i.warehouseFk
LEFT JOIN (
SELECT DISTINCT st.saleFk
FROM saleTracking st
JOIN state s ON s.id = st.stateFk
WHERE st.created > vDated
AND (s.isPicked OR st.isChecked)
) stPrevious ON `stPrevious`.`saleFk` = i.saleFk
WHERE (vWarehouseFk IS NULL OR i.warehouseFk = vWarehouseFk)
AND (vSelf IS NULL OR i.itemFk = vSelf)
AND (s.isPicked OR i.reserved OR stPrevious.saleFk)
AND i.shipped >= vDated AND i.shipped < vTomorrow
AND w.isComparative
UNION ALL
SELECT iei.itemFk, iei.quantity
FROM itemEntryIn iei
JOIN warehouse w ON w.id = iei.warehouseInFk
WHERE iei.isReceived
AND iei.landed >= vDated AND iei.landed < vTomorrow
AND (vWarehouseFk IS NULL OR iei.warehouseInFk = vWarehouseFk)
AND (vSelf IS NULL OR iei.itemFk = vSelf)
AND NOT iei.isVirtualStock
AND w.isComparative
UNION ALL
SELECT ieo.itemFk, ieo.quantity
FROM itemEntryOut ieo
JOIN warehouse w ON w.id = ieo.warehouseOutFk
WHERE ieo.isDelivered
AND ieo.shipped >= vDated
AND ieo.shipped < vTomorrow
AND (vWarehouseFk IS NULL OR ieo.warehouseOutFk = vWarehouseFk)
AND (vSelf IS NULL OR ieo.itemFk = vSelf)
AND w.isComparative
) t
GROUP BY itemFk
ON DUPLICATE KEY UPDATE
visible = IFNULL(stock, 0) + VALUES(visible);
END$$
DELIMITER ;

View File

@ -10,19 +10,20 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_comparative`(
)
proc: BEGIN
/**
* Genera una tabla de comparativa de artículos por itemType/comprador/fecha.
* Los datos se calculan en función de los parámetros proporcionados.
* Generates a comparison table of items by itemType/buyer/date.
* The data is calculated based on the provided parameters.
*
* @param vDate La fecha para la cual se generará la comparativa.
* @param vDayRange El rango de días a considerar para la comparativa.
* @param vWarehouseFk El identificador del almacén para filtrar los artículos.
* @param vAvailableSince La fecha de disponibilidad desde la cual se consideran los artículos disponibles.
* @param vBuyerFk El identificador del comprador para filtrar los artículos.
* @param vIsFloramondo Indica si se deben incluir solo los artículos de Floramondo (opcional).
* @param vCountryFk El identificador del país.
* @param tmp.comparativeFilterType(filterFk INT ,itemTypeFk INT)
* @param vDate The date for which the comparison will be generated.
* @param vDayRange The range of days to consider for the comparison.
* @param vWarehouseFk The warehouse identifier to filter the items.
* @param vAvailableSince The availability date from which the items are considered available.
* @param vBuyerFk The buyer identifier to filter the items.
* @param vIsFloramondo Indicates whether only Floramondo items should be included (optional).
* @param vCountryFk The country identifier.
* @param tmp.comparativeFilterType(filterFk INT, itemTypeFk INT)
* @return tmp.comparative
*/
DECLARE vDayRangeStart DATE;
DECLARE vDayRangeEnd DATE;
DECLARE w1, w2, w3, w4, w5, w6, w7 INT;

View File

@ -42,7 +42,7 @@ BEGIN
END IF;
SELECT warehouseFk INTO vWarehouseFk
FROM userConfig
FROM userMultiConfig
WHERE userFk = account.myUser_getId();
IF NOT vWarehouseFk OR vWarehouseFk IS NULL THEN
@ -93,7 +93,7 @@ BEGIN
ORDER BY created DESC
LIMIT 1;
CALL buyUltimate(vWarehouseFk, vCurdate);
CALL buy_getUltimate(vSelf, vWarehouseFk, vCurdate);
SELECT b.entryFk, bu.buyFk,IFNULL(b.buyingValue, 0) INTO vLastEntryFk, vLastBuyFk, vBuyingValueOriginal
FROM tmp.buyUltimate bu

View File

@ -2,94 +2,84 @@ DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_getBalance`(
vItemFk INT,
vWarehouseFk INT,
vDate DATETIME
vDated DATETIME
)
BEGIN
/**
* @vItemFk item a buscar
* @vWarehouseFk almacen donde buscar
* @vDate Si la fecha es null, muestra el histórico desde el inventario.
* Si la fecha no es null, muestra histórico desde la fecha de vDate.
* Calcula el balance de un artículo.
*
* @vItemFk Id de artículo
* @vWarehouseFk Id de almacén
* @vDated Fecha a calcular, si es NULL muestra el histórico desde el inventario
*/
DECLARE vDateInventory DATETIME;
DECLARE vDateInventory DATETIME
DEFAULT (
SELECT IF(vDated, uc.mockUtcTime, c.inventoried)
FROM config c
JOIN util.config uc
);
DECLARE vSupplierInventoryFk INT
DEFAULT (SELECT supplierFk FROM inventoryConfig);
IF vDate IS NULL THEN
SELECT inventoried INTO vDateInventory
FROM config;
ELSE
SELECT mockUtcTime INTO vDateInventory
FROM util.config;
IF NOT vSupplierInventoryFk OR NOT vDateInventory THEN
CALL util.throw('Config variables are not set');
END IF;
CREATE OR REPLACE TEMPORARY TABLE tItemDiary(
shipped DATE,
`in` INT(11),
`out` INT(11),
alertLevel INT(11),
stateName VARCHAR(20),
`name` VARCHAR(50),
reference VARCHAR(50),
origin INT(11),
clientFk INT(11),
isPicked INT(11),
isTicket TINYINT(1),
lineFk INT(11),
`order` TINYINT(3) UNSIGNED,
clientType VARCHAR(20),
claimFk INT(10) UNSIGNED,
inventorySupplierFk INT(10)
);
INSERT INTO tItemDiary
CREATE OR REPLACE TEMPORARY TABLE tItemDiary
ENGINE = MEMORY
WITH entriesIn AS (
SELECT tr.landed shipped,
SELECT 'entry' originType,
e.id originId,
tr.landed shipped,
b.quantity `in`,
NULL `out`,
st.alertLevel ,
st.name stateName,
s.name `name`,
e.invoiceNumber reference,
e.id origin,
s.id clientFk,
'supplier' entityType,
s.id entityId,
s.name entityName,
IF(st.`code` = 'DELIVERED', TRUE, FALSE) isPicked,
FALSE isTicket,
b.id lineFk,
NULL `order`,
NULL clientType,
NULL claimFk,
ec.inventorySupplierFk
vSupplierInventoryFk inventorySupplierFk
FROM vn.buy b
JOIN vn.entry e ON e.id = b.entryFk
JOIN vn.travel tr ON tr.id = e.travelFk
JOIN vn.supplier s ON s.id = e.supplierFk
JOIN vn.state st ON st.`code` = IF( tr.landed < util.VN_CURDATE()
JOIN vn.state st ON st.`code` = IF(tr.landed < util.VN_CURDATE()
OR (util.VN_CURDATE() AND tr.isReceived),
'DELIVERED',
'FREE')
JOIN vn.entryConfig ec
WHERE tr.landed >= vDateInventory
AND vWarehouseFk = tr.warehouseInFk
AND (s.id <> ec.inventorySupplierFk OR vDate IS NULL)
AND tr.warehouseInFk = vWarehouseFk
AND (s.id <> vSupplierInventoryFk OR vDated IS NULL)
AND b.itemFk = vItemFk
AND NOT e.isExcludedFromAvailable
AND NOT e.isRaid
), entriesOut AS (
SELECT tr.shipped,
),
entriesOut AS (
SELECT 'entry',
e.id originType,
tr.shipped,
NULL,
b.quantity,
st.alertLevel,
st.name stateName,
s.name ,
e.invoiceNumber,
e.id entryFk,
s.id supplierFk,
'supplier' entityType,
s.id entityId,
s.name,
IF(st.`code` = 'DELIVERED' , TRUE, FALSE),
FALSE isTicket,
b.id,
NULL `order`,
NULL clientType,
NULL claimFk,
ec.inventorySupplierFk
vSupplierInventoryFk
FROM vn.buy b
JOIN vn.entry e ON e.id = b.entryFk
JOIN vn.travel tr ON tr.id = e.travelFk
@ -99,86 +89,108 @@ BEGIN
OR (tr.shipped = util.VN_CURDATE() AND tr.isReceived),
'DELIVERED',
'FREE')
JOIN vn.entryConfig ec
WHERE tr.shipped >= vDateInventory
AND vWarehouseFk = tr.warehouseOutFk
AND (s.id <> ec.inventorySupplierFk OR vDate IS NULL)
AND tr.warehouseOutFk = vWarehouseFk
AND (s.id <> vSupplierInventoryFk OR vDated IS NULL)
AND b.itemFk = vItemFk
AND NOT e.isExcludedFromAvailable
AND NOT w.isFeedStock
AND NOT e.isRaid
), sales AS (
SELECT DATE(t.shipped) shipped,
s.quantity,
st2.alertLevel,
st2.name,
t.nickname,
t.refFk,
t.id ticketFk,
t.clientFk,
s.id saleFk,
st.`order`,
c.typeFk,
cb.claimFk
FROM vn.sale s
JOIN vn.ticket t ON t.id = s.ticketFk
LEFT JOIN vn.ticketState ts ON ts.ticketFk = t.id
LEFT JOIN vn.state st ON st.`code` = ts.`code`
JOIN vn.client c ON c.id = t.clientFk
JOIN vn.state st2 ON st2.`code` = IF(t.shipped < util.VN_CURDATE(),
'DELIVERED',
IF (t.shipped > util.dayEnd(util.VN_CURDATE()),
'FREE',
IFNULL(ts.code, 'FREE')))
LEFT JOIN vn.claimBeginning cb ON s.id = cb.saleFk
WHERE t.shipped >= vDateInventory
AND s.itemFk = vItemFk
AND vWarehouseFk = t.warehouseFk
),sale AS (
SELECT s.shipped,
),
sales AS (
WITH itemSales AS (
SELECT DATE(t.shipped) shipped,
s.quantity,
st2.alertLevel,
st2.name,
t.refFk,
t.id ticketFk,
'client' entityType,
t.clientFk entityId,
t.nickname,
s.id saleFk,
st.`order`,
c.typeFk,
cb.claimFk
FROM vn.sale s
JOIN vn.ticket t ON t.id = s.ticketFk
LEFT JOIN vn.ticketState ts ON ts.ticketFk = t.id
LEFT JOIN vn.state st ON st.code = ts.code
JOIN vn.client c ON c.id = t.clientFk
JOIN vn.state st2 ON st2.`code` = IF(t.shipped < util.VN_CURDATE(),
'DELIVERED',
IF (t.shipped > util.dayEnd(util.VN_CURDATE()),
'FREE',
IFNULL(st.code, 'FREE')))
LEFT JOIN vn.claimBeginning cb ON cb.saleFk = s.id
WHERE t.shipped >= vDateInventory
AND s.itemFk = vItemFk
AND t.warehouseFk = vWarehouseFk
)
SELECT 'ticket',
s.ticketFk,
s.shipped,
NULL `in`,
s.quantity,
s.alertLevel,
s.name,
s.nickname,
s.refFk,
s.ticketFk,
s.clientFk,
IF(stk.saleFk, TRUE, NULL),
s.entityType,
s.entityId,
s.nickname,
IF(stk.saleFk, TRUE, FALSE),
TRUE,
s.saleFk,
s.`order`,
s.typeFk,
s.claimFk,
NULL
FROM sales s
FROM itemSales s
LEFT JOIN vn.state stPrep ON stPrep.`code` = 'PREPARED'
LEFT JOIN vn.saleTracking stk ON stk.saleFk = s.saleFk
AND stk.stateFk = stPrep.id
GROUP BY s.saleFk
) SELECT shipped,
`in`,
`out`,
alertLevel,
stateName,
`name`,
reference,
origin,
clientFk,
isPicked,
isTicket,
lineFk,
`order`,
clientType,
claimFk,
inventorySupplierFk
FROM entriesIn
),
orders AS (
SELECT 'order' originType,
o.id originId,
r.shipment,
NULL 'in',
r.amount,
NULL alertLevel,
NULL stateName,
NULL invoiceNumber,
'client' entityType,
c.id,
c.name,
FALSE,
FALSE isTicket,
NULL buyFk,
NULL 'order',
c.typeFk,
NULL claimFk,
NULL
FROM hedera.orderRow r
JOIN hedera.`order` o ON o.id = r.orderFk
JOIN vn.client c ON c.id = o.customer_id
WHERE r.shipment >= vDateInventory
AND r.warehouseFk = vWarehouseFk
AND r.created >= (
SELECT SUBTIME(util.VN_NOW(), reserveTime)
FROM hedera.orderConfig
)
AND NOT o.confirmed
AND r.itemFk = vItemFk
)
SELECT * FROM entriesIn
UNION ALL
SELECT * FROM entriesOut
UNION ALL
SELECT * FROM sale
ORDER BY shipped,
(inventorySupplierFk = clientFk) DESC,
SELECT * FROM sales
UNION ALL
SELECT * FROM orders
ORDER BY shipped DESC,
(inventorySupplierFk = entityId) DESC,
alertLevel DESC,
isTicket,
`order` DESC,
@ -186,19 +198,20 @@ BEGIN
`in` DESC,
`out` DESC;
IF vDate IS NULL THEN
IF vDated IS NULL THEN
SET @a := 0;
SET @currentLineFk := 0;
SET @shipped := '';
SELECT DATE(@shipped:= t.shipped) shipped,
SELECT t.originType,
t.originId,
DATE(@shipped:= t.shipped) shipped,
t.alertLevel,
t.stateName,
t.origin,
t.reference,
t.clientFk,
t.name,
t.entityType,
t.entityId,
t.entityName,
t.`in` invalue,
t.`out`,
@a := @a + IFNULL(t.`in`, 0) - IFNULL(t.`out`, 0) balance,
@ -214,37 +227,41 @@ BEGIN
t.`order`
FROM tItemDiary t
LEFT JOIN alertLevel a ON a.id = t.alertLevel;
ELSE
SELECT IFNULL(SUM(IFNULL(`in`, 0)) - SUM(IFNULL(`out`, 0)), 0) INTO @a
FROM tItemDiary
WHERE shipped < vDate;
WHERE shipped < vDated;
SELECT vDate shipped,
0 alertLevel,
0 stateName,
0 origin,
'' reference,
0 clientFk,
'Inventario calculado',
SELECT NULL originType,
NULL originId,
vDated shipped,
NULL alertLevel,
NULL stateName,
NULL reference,
NULL entityType,
NULL entityId,
'Inventario calculado' entityName,
@a invalue,
NULL `out`,
@a balance,
0 lastPreparedLineFk,
0 isTicket,
0 lineFk,
0 isPicked,
0 clientType,
0 claimFk,
NULL lastPreparedLineFk,
NULL isTicket,
NULL lineFk,
NULL isPicked,
NULL clientType,
NULL claimFk,
NULL `order`
UNION ALL
SELECT shipped,
SELECT originType,
originId,
shipped,
alertlevel,
stateName,
origin,
reference,
clientFk,
name, `in`,
reference,
entityType,
entityId,
entityName,
`in`,
`out`,
@a := @a + IFNULL(`in`, 0) - IFNULL(`out`, 0),
0,
@ -255,7 +272,7 @@ BEGIN
claimFk,
`order`
FROM tItemDiary
WHERE shipped >= vDate;
WHERE shipped >= vDated;
END IF;
DROP TEMPORARY TABLE tItemDiary;

View File

@ -1,5 +1,8 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_getInfo`(IN `vBarcode` VARCHAR(22), IN `vWarehouseFk` INT)
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_getInfo`(
`vBarcode` VARCHAR(22),
`vWarehouseFk` INT
)
BEGIN
/**
* Devuelve información relativa al item correspondiente del vBarcode pasado
@ -11,12 +14,14 @@ BEGIN
DECLARE vCacheAvailableFk INT;
DECLARE vVisibleItemShelving INT;
DECLARE vItemFk INT;
DECLARE vDated DATE;
SELECT barcodeToItem(vBarcode), util.VN_CURDATE() INTO vItemFk, vDated;
CALL cache.visible_refresh(vCacheVisibleFk, FALSE, vWarehouseFk);
CALL cache.available_refresh(vCacheAvailableFk, FALSE, vWarehouseFk, util.VN_CURDATE());
CALL buyUltimate(vWarehouseFk, util.VN_CURDATE());
SELECT barcodeToItem(vBarcode) INTO vItemFk;
CALL cache.available_refresh(vCacheAvailableFk, FALSE, vWarehouseFk, vDated);
CALL buy_getUltimate(vItemFk, vWarehouseFk, vDated);
SELECT SUM(visible) INTO vVisibleItemShelving
FROM itemShelvingStock
WHERE itemFk = vItemFk

View File

@ -1,37 +1,40 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_getMinacum`(IN vWarehouseFk TINYINT, IN vDatedFrom DATETIME, IN vRange INT, IN vItemFk INT)
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_getMinacum`(
vWarehouseFk TINYINT,
vDated DATE,
vRange INT,
vItemFk INT
)
BEGIN
/**
* Cálculo del mínimo acumulado, para un item/almacén especificado, en caso de
* NULL para todo.
* Cálculo del mínimo acumulado, para un item/almacén
* especificado, en caso de NULL para todos.
*
* @param vWarehouseFk -> warehouseFk
* @param vDatedFrom -> fecha inicio
* @param vRange -> número de días a considerar
* @param vItemFk -> Identificador de item
* @param vWarehouseFk Id warehouse
* @param vDated Fecha inicio
* @param vRange Número de días a considerar
* @param vItemFk Id de artículo
* @return tmp.itemMinacum
*/
DECLARE vDatedTo DATETIME;
DECLARE vDatedTo DATETIME DEFAULT util.dayEnd(vDated + INTERVAL vRange DAY);
SET vDatedFrom = TIMESTAMP(DATE(vDatedFrom), '00:00:00');
SET vDatedTo = TIMESTAMP(TIMESTAMPADD(DAY, vRange, vDatedFrom), '23:59:59');
DROP TEMPORARY TABLE IF EXISTS tmp.itemCalc;
CREATE TEMPORARY TABLE tmp.itemCalc
CREATE OR REPLACE TEMPORARY TABLE tmp.itemCalc
(INDEX (itemFk, warehouseFk))
ENGINE = MEMORY
SELECT sub.itemFk,
sub.dated,
CAST(SUM(sub.quantity) AS SIGNED) quantity,
sub.warehouseFk
FROM (SELECT s.itemFk,
FROM (
SELECT s.itemFk,
DATE(t.shipped) dated,
-s.quantity quantity,
t.warehouseFk
FROM sale s
JOIN ticket t ON t.id = s.ticketFk
WHERE t.shipped BETWEEN vDatedFrom AND vDatedTo
WHERE t.shipped BETWEEN vDated AND vDatedTo
AND t.warehouseFk
AND s.quantity != 0
AND s.quantity <> 0
AND (vItemFk IS NULL OR s.itemFk = vItemFk)
AND (vWarehouseFk IS NULL OR t.warehouseFk = vWarehouseFk)
UNION ALL
@ -42,10 +45,10 @@ BEGIN
FROM buy b
JOIN entry e ON e.id = b.entryFk
JOIN travel t ON t.id = e.travelFk
WHERE t.landed BETWEEN vDatedFrom AND vDatedTo
WHERE t.landed BETWEEN vDated AND vDatedTo
AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk)
AND !e.isExcludedFromAvailable
AND b.quantity != 0
AND NOT e.isExcludedFromAvailable
AND b.quantity <> 0
AND (vItemFk IS NULL OR b.itemFk = vItemFk)
UNION ALL
SELECT b.itemFk,
@ -55,28 +58,45 @@ BEGIN
FROM buy b
JOIN entry e ON e.id = b.entryFk
JOIN travel t ON t.id = e.travelFk
WHERE t.shipped BETWEEN vDatedFrom AND vDatedTo
WHERE t.shipped BETWEEN vDated AND vDatedTo
AND (vWarehouseFk IS NULL OR t.warehouseOutFk = vWarehouseFk)
AND !e.isExcludedFromAvailable
AND b.quantity != 0
AND NOT e.isExcludedFromAvailable
AND b.quantity <> 0
AND (vItemFk IS NULL OR b.itemFk = vItemFk)
AND !e.isRaid
AND NOT e.isRaid
UNION ALL
SELECT r.itemFk,
r.shipment,
-r.amount,
r.warehouseFk
FROM hedera.orderRow r
JOIN hedera.`order` o ON o.id = r.orderFk
JOIN client c ON c.id = o.customer_id
WHERE r.shipment BETWEEN vDated AND vDatedTo
AND (vWarehouseFk IS NULL OR r.warehouseFk = vWarehouseFk)
AND r.created >= (
SELECT util.VN_NOW() - INTERVAL TIME_TO_SEC(reserveTime) SECOND
FROM hedera.orderConfig
)
AND NOT o.confirmed
AND (vItemFk IS NULL OR r.itemFk = vItemFk)
AND r.amount <> 0
) sub
GROUP BY sub.itemFk, sub.warehouseFk, sub.dated;
CALL item_getAtp(vDatedFrom);
DROP TEMPORARY TABLE tmp.itemCalc;
CALL item_getAtp(vDated);
DROP TEMPORARY TABLE IF EXISTS tmp.itemMinacum;
CREATE TEMPORARY TABLE tmp.itemMinacum
CREATE OR REPLACE TEMPORARY TABLE tmp.itemMinacum
(INDEX(itemFk))
ENGINE = MEMORY
SELECT i.itemFk,
i.warehouseFk,
i.quantity amount
FROM tmp.itemAtp i
HAVING amount != 0;
SELECT itemFk,
warehouseFk,
quantity amount
FROM tmp.itemAtp
WHERE quantity <> 0;
DROP TEMPORARY TABLE tmp.itemAtp;
DROP TEMPORARY TABLE
tmp.itemAtp,
tmp.itemCalc;
END$$
DELIMITER ;

View File

@ -63,7 +63,7 @@ BEGIN
WHEN b.groupingMode = 'grouping' THEN b.grouping
WHEN b.groupingMode = 'packing' THEN b.packing
ELSE 1
END AS minQuantity,
END minQuantity,
v.visible located,
b.price2
FROM vn.item i

View File

@ -13,7 +13,7 @@ BEGIN
*/
ALTER TABLE tmp.itemInventory ADD IF NOT EXISTS buy_id INT;
CALL buyUltimate(vWarehouseFk, vDate);
CALL buy_getUltimate (NULL, vWarehouseFk, vDate);
CREATE OR REPLACE TEMPORARY TABLE tmp
(KEY (itemFk))

View File

@ -46,12 +46,18 @@ BEGIN
i.tag8 = JSON_VALUE(vTags, '$.8'),
i.tag9 = JSON_VALUE(vTags, '$.9'),
i.tag10 = JSON_VALUE(vTags, '$.10'),
i.tag11 = JSON_VALUE(vTags, '$.11'),
i.tag12 = JSON_VALUE(vTags, '$.12'),
i.tag13 = JSON_VALUE(vTags, '$.13'),
i.value5 = JSON_VALUE(vValues, '$.5'),
i.value6 = JSON_VALUE(vValues, '$.6'),
i.value7 = JSON_VALUE(vValues, '$.7'),
i.value8 = JSON_VALUE(vValues, '$.8'),
i.value9 = JSON_VALUE(vValues, '$.9'),
i.value10 = JSON_VALUE(vValues, '$.10'),
i.value11 = JSON_VALUE(vValues, '$.11'),
i.value12 = JSON_VALUE(vValues, '$.12'),
i.value13 = JSON_VALUE(vValues, '$.13'),
i.producerFk = p.id,
i.inkFk = k.id,
i.originFk = IFNULL(o.id, i.originFk)

View File

@ -6,7 +6,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_setVisibleDisc
vAddressFk INT)
BEGIN
/**
* Procedimiento para dar dar de baja/alta un item, si vAddressFk es NULL se entiende que se da de alta y se toma el addressFk de la configuración
* Procedimiento para dar dar de baja/alta un item, si vAdressFk es NULL
* se entiende que se da de alta y se toma el addressFk de la configuración
*
* @param vItemFk Identificador del ítem
* @param vWarehouseFk id del warehouse

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