Merge branch '7884-AddLabelerField' of https://gitea.verdnatura.es/verdnatura/salix into 7884-AddLabelerField
gitea/salix/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
Jon Elias 2024-09-30 12:07:56 +02:00
commit eacc2d5d2a
88 changed files with 5652 additions and 5057 deletions

View File

@ -12,9 +12,8 @@ const ticket1 = {
'addressFk': 1,
'agencyModeFk': 999
};
let expedition;
const expedition1 = {
'id': 17,
'agencyModeFk': 999,
'ticketFk': 44,
'freightItemFk': 71,
@ -47,7 +46,7 @@ describe('MRWConfig createShipment()', () => {
await createMrwConfig();
await models.Ticket.create(ticket1);
await models.Expedition.create(expedition1);
expedition = await models.Expedition.create(expedition1);
});
afterAll(async() => {
@ -93,7 +92,7 @@ describe('MRWConfig createShipment()', () => {
}
it('should create a shipment and return a base64Binary label', async() => {
const {file} = await models.MrwConfig.createShipment(expedition1.id);
const {file} = await models.MrwConfig.createShipment(expedition.id);
expect(file).toEqual(mockBase64Binary);
});
@ -101,7 +100,7 @@ describe('MRWConfig createShipment()', () => {
it('should fail if mrwConfig has no data', async() => {
let error;
await models.MrwConfig.destroyAll();
await models.MrwConfig.createShipment(expedition1.id).catch(e => {
await models.MrwConfig.createShipment(expedition.id).catch(e => {
error = e;
}).finally(async() => {
expect(error.message).toEqual(`MRW service is not configured`);
@ -126,7 +125,7 @@ describe('MRWConfig createShipment()', () => {
yesterday.setDate(yesterday.getDate() - 1);
await models.Ticket.updateAll({id: ticket1.id}, {shipped: yesterday});
await models.MrwConfig.createShipment(expedition1.id).catch(e => {
await models.MrwConfig.createShipment(expedition.id).catch(e => {
error = e;
}).finally(async() => {
expect(error.message).toEqual(`This ticket has a shipped date earlier than today`);
@ -136,7 +135,7 @@ describe('MRWConfig createShipment()', () => {
it('should send mail if you are past the dead line and is not notified today', async() => {
await models.MrwConfig.updateAll({id: 1}, {expeditionDeadLine: '10:00:00', notified: null});
await models.MrwConfig.createShipment(expedition1.id);
await models.MrwConfig.createShipment(expedition.id);
const notification = await getLastNotification();
expect(notification.notificationFk).toEqual(filter.notificationFk);
@ -144,7 +143,7 @@ describe('MRWConfig createShipment()', () => {
it('should send mail if you are past the dead line and it is notified from another day', async() => {
await models.MrwConfig.updateAll({id: 1}, {expeditionDeadLine: '10:00:00', notified: new Date()});
await models.MrwConfig.createShipment(expedition1.id);
await models.MrwConfig.createShipment(expedition.id);
const notification = await getLastNotification();
expect(notification.notificationFk).toEqual(filter.notificationFk);
@ -152,7 +151,7 @@ describe('MRWConfig createShipment()', () => {
it('should not send mail if you are past the dead line and it is notified', async() => {
await models.MrwConfig.updateAll({id: 1}, {expeditionDeadLine: '10:00:00', notified: Date.vnNew()});
await models.MrwConfig.createShipment(expedition1.id);
await models.MrwConfig.createShipment(expedition.id);
const notification = await getLastNotification();
expect(notification).toEqual(null);

View File

@ -29,7 +29,7 @@ describe('Postcode filter()', () => {
}
}, options);
expect(results.length).toEqual(4);
expect(results.length).toEqual(5);
await tx.rollback();
} catch (e) {
await tx.rollback();
@ -63,7 +63,7 @@ describe('Postcode filter()', () => {
search: 'one',
}}, options);
expect(results.length).toEqual(4);
expect(results.length).toEqual(5);
await tx.rollback();
} catch (e) {
await tx.rollback();

View File

@ -0,0 +1,88 @@
const axios = require('axios');
const UserError = require('vn-loopback/util/user-error');
const moment = require('moment');
module.exports = Self => {
Self.remoteMethod('sendOrders', {
description: 'Sends a set of orders',
accessType: 'WRITE',
accepts: [{
arg: 'tickets',
type: ['number'],
required: true
}
],
returns: {
type: 'string',
root: true
},
http: {
path: `/sendOrders`,
verb: 'POST'
}
});
Self.sendOrders = async tickets => {
const config = await Self.app.models.QuadmindsApiConfig.findOne();
if (!config) throw new UserError('Config params not set');
if (tickets.length > config.maxObjects)
throw new UserError(`Quadminds does not support more than ${config.maxObjects} tickets`);
let poisData = [];
let isOk;
for (let offset = 0; !isOk; offset = offset + config.limit) {
const pois = await axios.get(`${config.url}pois/search?limit=${config.limit}&offset=${offset}`, {
headers: {
'Accept': 'application/json',
'X-Saas-Apikey': config.key
}
});
pois.data.data.length ? poisData.push(...pois.data.data) : isOk = true;
}
const poiMap = new Map(poisData.map(poi => [poi.code, poi._id]));
let orders = await Self.rawSql(`
SELECT a.id poiCode,
t.id code,
t.shipped date,
'PEDIDO' operation,
t.totalWithVat totalAmount,
t.totalWithoutVat totalAmountWithoutTaxes,
SUM(sv.volume) volume
FROM ticket t
JOIN address a ON a.id = t.addressFk
JOIN saleVolume sv ON sv.ticketFk = t.id
WHERE t.id IN (?)
GROUP BY t.id
`, [tickets]);
// Transformo code en string ya que lo obtenermos como integer
orders = orders.map(order => {
return {
...order,
poiId: poiMap.get(order.poiCode.toString()) || undefined,
code: order.code.toString(),
date: moment(order.date).format('YYYY-MM-DD'),
totalAmount: order.totalAmount || undefined,
totalAmountWithoutTaxes: order.totalAmountWithoutTaxes || undefined,
timeWindow: [{
from: config.orderTimeFrom,
to: config.orderTimeTo
}],
orderMeasures: [{
constraintId: 3, // Volumen
value: order.volume
}]
};
});
await axios.post(`${config.url}orders`, orders, {
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'X-Saas-Apikey': config.key
}
});
};
};

View File

@ -0,0 +1,87 @@
const axios = require('axios');
const UserError = require('vn-loopback/util/user-error');
module.exports = Self => {
Self.remoteMethod('sendPois', {
description: 'Sends a set of pois',
accessType: 'WRITE',
accepts: [{
arg: 'tickets',
type: ['number'],
required: true
}
],
returns: {
type: 'string',
root: true
},
http: {
path: `/sendPois`,
verb: 'POST'
}
});
Self.sendPois = async tickets => {
const config = await Self.app.models.QuadmindsApiConfig.findOne();
if (!config) throw new UserError('Config params not set');
if (tickets.length > config.maxObjects)
throw new UserError(`Quadminds does not support more than ${config.maxObjects} tickets`);
let pois = await Self.rawSql(`
WITH deliveryNotes AS (
SELECT t.id, t.routeFk, tn.description
FROM ticket t
JOIN ticketObservation tn ON tn.ticketFk = t.id
JOIN observationType ot ON ot.id = tn.observationTypeFk
WHERE ot.code = 'delivery'
)
SELECT a.id code,
c.socialName name,
IF(ABS(a.latitude - ROUND(a.latitude)) < 0.000001, NULL, a.latitude) latitude,
IF(ABS(a.longitude - ROUND(a.longitude)) < 0.000001, NULL, a.longitude) longitude,
a.street,
a.city locality,
p.name state,
co.name country,
CONCAT_WS(', ', IFNULL(a.street, ''), IFNULL(a.city, ''), IFNULL(p.name, '')) longAddress,
CONCAT(IFNULL(a.mobile, c.mobile)) phoneNumber,
dn.description poiDeliveryComments,
c.email email
FROM ticket t
JOIN address a ON a.id = t.addressFk
JOIN province p ON p.id = a.provinceFk
JOIN country co ON co.id = p.countryFk
JOIN client c ON c.id = t.clientFk
LEFT JOIN deliveryNotes dn ON dn.id = t.id
WHERE t.id IN (?)
GROUP BY t.id
`, [tickets]);
// Transformo code en string ya que lo obtenermos como integer
pois = pois.map(poi => {
return {
...poi,
code: poi.code.toString(),
latitude: poi.latitude || undefined,
longitude: poi.longitude || undefined,
address: {
street: poi.street || undefined,
locality: poi.locality || undefined,
state: poi.state || undefined,
country: poi.country || undefined
},
poiDeliveryComments: poi.poiDeliveryComments || undefined,
phoneNumber: poi.phoneNumber || undefined,
email: poi.email || undefined
};
});
await axios.post(`${config.url}pois`, pois, {
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'X-Saas-Apikey': config.key
}
});
};
};

View File

@ -26,7 +26,7 @@ module.exports = Self => {
description: 'The user lang'
}, {
arg: 'twoFactor',
type: 'string',
type: 'any',
description: 'The user twoFactor'
}
],

View File

@ -124,6 +124,9 @@
"Province": {
"dataSource": "vn"
},
"QuadmindsApiConfig": {
"dataSource": "vn"
},
"Autonomy": {
"dataSource": "vn"
},

View File

@ -0,0 +1,4 @@
module.exports = Self => {
require('../methods/quadminds-api-config/sendPois')(Self);
require('../methods/quadminds-api-config/sendOrders')(Self);
};

View File

@ -0,0 +1,34 @@
{
"name": "QuadmindsApiConfig",
"base": "VnModel",
"options": {
"mysql": {
"table": "quadmindsApiConfig"
}
},
"properties": {
"id": {
"type": "number",
"id": true,
"required": true
},
"url": {
"type": "string"
},
"key": {
"type": "string"
},
"maxObjects": {
"type": "number"
},
"limit": {
"type": "number"
},
"orderTimeFrom": {
"type": "string"
},
"orderTimeTo": {
"type": "string"
}
}
}

View File

@ -165,7 +165,8 @@
"hasGrant",
"realm",
"email",
"emailVerified"
"emailVerified",
"twoFactor"
]
}
}

View File

@ -1,9 +1,10 @@
USE `util`;
/*M!999999\- enable the sandbox mode */
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!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','11209','3cc19549e4a9d61542b5ba906ccaf9fc90a805ce','2024-09-03 15:04:20','11212');
INSERT INTO `version` VALUES ('vn-database','11196','91ee956fbd1557848e4ab522bc5d39b2ec10e9b2','2024-09-18 07:28:14','11245');
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);
@ -874,9 +875,11 @@ INSERT INTO `versionLog` VALUES ('vn-database','11103','00-firstScript.sql','jen
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','11108','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-09-17 07:38:39',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','11112','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-09-17 07:38:40',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);
@ -884,6 +887,8 @@ INSERT INTO `versionLog` VALUES ('vn-database','11118','00-firstScript.sql','jen
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','11124','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-09-17 07:38:40',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11124','01-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-09-17 07:38:40',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);
@ -940,6 +945,7 @@ INSERT INTO `versionLog` VALUES ('vn-database','11177','00-firstScript.sql','jen
INSERT INTO `versionLog` VALUES ('vn-database','11179','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-08-20 08:34:43',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11180','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-08-20 08:34:43',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11182','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-08-09 08:19:36',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11183','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-09-17 07:38:42',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11185','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-03 08:57:44',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11187','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-03 08:57:44',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11189','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-03 08:58:00',NULL,NULL);
@ -953,16 +959,27 @@ INSERT INTO `versionLog` VALUES ('vn-database','11193','01-firstScript.sql','jen
INSERT INTO `versionLog` VALUES ('vn-database','11193','02-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-03 08:58:01',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11194','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-03 08:58:01',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11195','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-03 08:58:01',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11196','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-09-18 07:28:14',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11197','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-03 08:58:01',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11201','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-08-27 13:04:26',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11204','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-03 08:58:01',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11205','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-09-04 13:54:55',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11206','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-09-17 07:38:42',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11207','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-09-17 07:38:42',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11209','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-03 08:58:01',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11211','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-09-17 07:38:42',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11213','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-09-06 06:31:13',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11215','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-09-17 07:38:42',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11217','00-hederaMessages.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-09-09 12:21:45',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11229','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-16 08:24:17',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11239','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-09-17 12:57:06',NULL,NULL);
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
USE `account`;
/*M!999999\- enable the sandbox mode */
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
@ -1089,7 +1106,6 @@ INSERT INTO `roleInherit` VALUES (37,34,1,NULL);
INSERT INTO `roleInherit` VALUES (38,34,13,NULL);
INSERT INTO `roleInherit` VALUES (39,34,33,NULL);
INSERT INTO `roleInherit` VALUES (40,35,1,NULL);
INSERT INTO `roleInherit` VALUES (42,36,47,NULL);
INSERT INTO `roleInherit` VALUES (43,37,1,NULL);
INSERT INTO `roleInherit` VALUES (44,38,37,NULL);
INSERT INTO `roleInherit` VALUES (45,38,64,NULL);
@ -1328,6 +1344,7 @@ 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 `roleInherit` VALUES (376,124,21,19336);
INSERT INTO `roleInherit` VALUES (377,47,49,19295);
INSERT INTO `userPassword` VALUES (1,7,1,0,2,1);
@ -1340,6 +1357,7 @@ INSERT INTO `mailConfig` VALUES (1,'verdnatura.es');
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
USE `salix`;
/*M!999999\- enable the sandbox mode */
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
@ -1559,8 +1577,8 @@ INSERT INTO `ACL` VALUES (279,'MailAlias','*','READ','ALLOW','ROLE','marketing',
INSERT INTO `ACL` VALUES (283,'EntryObservation','*','*','ALLOW','ROLE','buyer',NULL);
INSERT INTO `ACL` VALUES (284,'LdapConfig','*','*','ALLOW','ROLE','sysadmin',NULL);
INSERT INTO `ACL` VALUES (285,'SambaConfig','*','*','ALLOW','ROLE','sysadmin',NULL);
INSERT INTO `ACL` VALUES (286,'ACL','*','*','ALLOW','ROLE','developer',NULL);
INSERT INTO `ACL` VALUES (287,'AccessToken','*','*','ALLOW','ROLE','developer',NULL);
INSERT INTO `ACL` VALUES (286,'ACL','*','READ','ALLOW','ROLE','developer',10578);
INSERT INTO `ACL` VALUES (287,'AccessToken','*','*','ALLOW','ROLE','developerBoss',10578);
INSERT INTO `ACL` VALUES (293,'RoleInherit','*','*','ALLOW','ROLE','it',NULL);
INSERT INTO `ACL` VALUES (294,'RoleRole','*','*','ALLOW','ROLE','it',NULL);
INSERT INTO `ACL` VALUES (295,'AccountConfig','*','*','ALLOW','ROLE','sysadmin',NULL);
@ -1569,7 +1587,7 @@ INSERT INTO `ACL` VALUES (297,'Sale','clone','WRITE','ALLOW','ROLE','invoicing',
INSERT INTO `ACL` VALUES (298,'InvoiceInDueDay','*','*','ALLOW','ROLE','administrative',NULL);
INSERT INTO `ACL` VALUES (299,'Collection','setSaleQuantity','*','ALLOW','ROLE','employee',NULL);
INSERT INTO `ACL` VALUES (302,'AgencyTerm','*','*','ALLOW','ROLE','administrative',NULL);
INSERT INTO `ACL` VALUES (303,'ClaimLog','*','READ','ALLOW','ROLE','claimManager',NULL);
INSERT INTO `ACL` VALUES (303,'ClaimLog','*','READ','ALLOW','ROLE','employee',19294);
INSERT INTO `ACL` VALUES (304,'Edi','updateData','WRITE','ALLOW','ROLE','employee',NULL);
INSERT INTO `ACL` VALUES (305,'EducationLevel','*','*','ALLOW','ROLE','employee',NULL);
INSERT INTO `ACL` VALUES (306,'InvoiceInIntrastat','*','*','ALLOW','ROLE','employee',NULL);
@ -1863,7 +1881,6 @@ INSERT INTO `ACL` VALUES (611,'State','find','READ','ALLOW','ROLE','employee',NU
INSERT INTO `ACL` VALUES (612,'State','findById','READ','ALLOW','ROLE','employee',NULL);
INSERT INTO `ACL` VALUES (613,'State','findOne','READ','ALLOW','ROLE','employee',NULL);
INSERT INTO `ACL` VALUES (614,'Worker','find','READ','ALLOW','ROLE','employee',NULL);
INSERT INTO `ACL` VALUES (615,'Worker','findById','READ','ALLOW','ROLE','employee',NULL);
INSERT INTO `ACL` VALUES (616,'Worker','findOne','READ','ALLOW','ROLE','employee',NULL);
INSERT INTO `ACL` VALUES (617,'Worker','filter','READ','ALLOW','ROLE','employee',NULL);
INSERT INTO `ACL` VALUES (618,'Worker','getWorkedHours','READ','ALLOW','ROLE','employee',NULL);
@ -1887,7 +1904,7 @@ INSERT INTO `ACL` VALUES (654,'Ticket','editZone','WRITE','ALLOW','ROLE','logist
INSERT INTO `ACL` VALUES (655,'Entry','addFromPackaging','WRITE','ALLOW','ROLE','production',NULL);
INSERT INTO `ACL` VALUES (656,'Entry','addFromBuy','WRITE','ALLOW','ROLE','production',NULL);
INSERT INTO `ACL` VALUES (657,'Supplier','getItemsPackaging','READ','ALLOW','ROLE','production',NULL);
INSERT INTO `ACL` VALUES (658,'Ticket','closeAll','WRITE','ALLOW','ROLE','system',NULL);
INSERT INTO `ACL` VALUES (658,'Ticket','closeAll','WRITE','ALLOW','ROLE','system',19295);
INSERT INTO `ACL` VALUES (659,'Account','*','*','ALLOW','ROLE','developerBoss',NULL);
INSERT INTO `ACL` VALUES (664,'MailForward','*','*','ALLOW','ROLE','itManagement',NULL);
INSERT INTO `ACL` VALUES (667,'VnUser','*','*','ALLOW','ROLE','itManagement',NULL);
@ -1959,7 +1976,7 @@ INSERT INTO `ACL` VALUES (746,'Claim','getSummary','READ','ALLOW','ROLE','claimV
INSERT INTO `ACL` VALUES (747,'CplusRectificationType','*','READ','ALLOW','ROLE','administrative',NULL);
INSERT INTO `ACL` VALUES (748,'SiiTypeInvoiceOut','*','READ','ALLOW','ROLE','salesPerson',NULL);
INSERT INTO `ACL` VALUES (749,'InvoiceCorrectionType','*','READ','ALLOW','ROLE','salesPerson',NULL);
INSERT INTO `ACL` VALUES (750,'InvoiceOut','transfer','WRITE','ALLOW','ROLE','administrative',NULL);
INSERT INTO `ACL` VALUES (750,'InvoiceOut','transferInvoice','WRITE','ALLOW','ROLE','administrative',NULL);
INSERT INTO `ACL` VALUES (751,'Application','executeProc','*','ALLOW','ROLE','employee',NULL);
INSERT INTO `ACL` VALUES (752,'Application','executeFunc','*','ALLOW','ROLE','employee',NULL);
INSERT INTO `ACL` VALUES (753,'NotificationSubscription','getList','READ','ALLOW','ROLE','employee',NULL);
@ -2107,6 +2124,19 @@ INSERT INTO `ACL` VALUES (905,'AddressWaste','*','READ','ALLOW','ROLE','producti
INSERT INTO `ACL` VALUES (906,'Entry','print','READ','ALLOW','ROLE','supplier',NULL);
INSERT INTO `ACL` VALUES (907,'Expedition_PrintOut','*','*','ALLOW','ROLE','production',NULL);
INSERT INTO `ACL` VALUES (908,'Docuware','upload','WRITE','ALLOW','ROLE','hrBuyer',13657);
INSERT INTO `ACL` VALUES (909,'Entry','getBuysCsv','READ','ALLOW','ROLE','supplier',19295);
INSERT INTO `ACL` VALUES (910,'MedicalReview','*','*','ALLOW','ROLE','hr',10578);
INSERT INTO `ACL` VALUES (911,'MedicalCenter','*','*','ALLOW','ROLE','hr',10578);
INSERT INTO `ACL` VALUES (912,'Worker','__get__medicalReview','*','ALLOW','ROLE','hr',10578);
INSERT INTO `ACL` VALUES (913,'VnToken','*','READ','ALLOW','ROLE','developer',10578);
INSERT INTO `ACL` VALUES (914,'VnToken','killSession','*','ALLOW','ROLE','developer',10578);
INSERT INTO `ACL` VALUES (915,'ACL','*','WRITE','ALLOW','ROLE','developerBoss',10578);
INSERT INTO `ACL` VALUES (916,'Entry','getBuysCsv','READ','ALLOW','ROLE','supplier',10578);
INSERT INTO `ACL` VALUES (917,'InvoiceOut','refundAndInvoice','WRITE','ALLOW','ROLE','administrative',10578);
INSERT INTO `ACL` VALUES (918,'Worker','__get__descriptor','READ','ALLOW','ROLE','employee',10578);
INSERT INTO `ACL` VALUES (919,'Worker','findById','READ','ALLOW','ROLE','$subordinate',10578);
INSERT INTO `ACL` VALUES (920,'QuadmindsApiConfig','*','*','ALLOW','ROLE','delivery',19295);
INSERT INTO `ACL` VALUES (921,'Worker','findById','READ','ALLOW','ROLE','employee',NULL);
INSERT INTO `fieldAcl` VALUES (1,'Client','name','update','employee');
INSERT INTO `fieldAcl` VALUES (2,'Client','contact','update','employee');
@ -2202,6 +2232,7 @@ INSERT INTO `defaultViewMultiConfig` VALUES ('routesList','{\"ID\":true,\"worker
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
USE `vn`;
/*M!999999\- enable the sandbox mode */
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
@ -2426,7 +2457,7 @@ INSERT INTO `continent` VALUES (3,'África','AF');
INSERT INTO `continent` VALUES (4,'Europa','EU');
INSERT INTO `continent` VALUES (5,'Oceanía','OC');
INSERT INTO `department` VALUES (1,'VN','VERDNATURA',1,112,763,0,0,0,0,26,NULL,'/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (1,'VN','VERDNATURA',1,114,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,'PREVIOUS');
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);
@ -2437,28 +2468,28 @@ INSERT INTO `department` VALUES (37,'PROD','PRODUCCION',14,37,NULL,72,1,1,1,11,1
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,'ON_PREPARATION');
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,'PACKING');
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,0,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,'DELIVERY');
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,'STORAGE');
INSERT INTO `department` VALUES (49,NULL,'PROPIEDAD',80,81,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (52,NULL,'CARGA AEREA',82,83,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (43,'VT','VENTAS',40,73,NULL,0,0,0,1,16,1,'/1/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (44,'management','GERENCIA',74,75,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',76,77,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',78,79,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,'DELIVERY');
INSERT INTO `department` VALUES (48,'storage','ALMACENAJE',80,81,NULL,0,1,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,'STORAGE');
INSERT INTO `department` VALUES (49,NULL,'PROPIEDAD',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 (52,NULL,'CARGA AEREA',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 (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 (54,NULL,'ORNAMENTALES',86,87,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,'FIELD');
INSERT INTO `department` VALUES (59,'maintenance','MANTENIMIENTO',90,91,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (58,'CMP','CAMPOS',88,91,NULL,72,0,0,1,1,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,'FIELD');
INSERT INTO `department` VALUES (59,'maintenance','MANTENIMIENTO',92,93,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,0,NULL,1,1,0,0,NULL,NULL,NULL,'CLAIM');
INSERT INTO `department` VALUES (61,NULL,'VNH',92,95,NULL,73,0,0,1,1,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (66,NULL,'VERDNAMADRID',96,97,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (61,NULL,'VNH',94,97,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',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 (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 (69,NULL,'VERDNABARNA',100,101,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 (86,NULL,'LIMPIEZA',102,103,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',104,105,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',95,96,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,'PREVIOUS');
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);
@ -2466,22 +2497,23 @@ INSERT INTO `department` VALUES (95,'spainTeam1','EQUIPO ESPAÑA 1',51,52,24065,
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 (124,NULL,'CONTROL INTERNO',106,107,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,'PALLETIZING');
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,'ON_CHECKING');
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 (131,'greenhouse','INVERNADERO',89,90,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 (135,'routers','ENRUTADORES',108,109,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',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 (137,'sorter','SORTER',112,113,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 `department` VALUES (147,'spainTeamAsia','EQUIPO ESPAÑA ASIA',71,72,40214,0,0,0,2,0,43,'/1/43/','esA_equipo',0,'esA@verdnatura.es',0,0,0,0,NULL,NULL,'5500',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);
@ -2575,7 +2607,7 @@ INSERT INTO `siiTypeInvoiceOut` VALUES (9,'R5','Factura rectificativa en factura
INSERT INTO `state` VALUES (1,'Arreglar',2,0,'FIXING',NULL,1,0,0,0,0,0,0,4,1,'alert');
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 (3,'OK',3,0,'OK',3,28,1,0,1,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,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');
@ -2643,6 +2675,7 @@ INSERT INTO `workerTimeControlError` VALUES (9,'UNDEFINED_ERROR','Error sin defi
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
USE `cache`;
/*M!999999\- enable the sandbox mode */
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
@ -2667,6 +2700,7 @@ INSERT INTO `cache` VALUES (14,'lastBuy','23:59:00');
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
USE `hedera`;
/*M!999999\- enable the sandbox mode */
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
@ -2701,7 +2735,7 @@ INSERT INTO `language` VALUES ('mn','Португалий','Mongolian',1);
INSERT INTO `language` VALUES ('pt','Português','Portuguese',1);
INSERT INTO `link` VALUES (16,'Printing server','Manage the CUPS printing server','http://printnatura.verdnatura.es','printer');
INSERT INTO `link` VALUES (20,'Webmail','Verdnatura webmail','https://webmail.verdnatura.es/','mail');
INSERT INTO `link` VALUES (20,'Webmail','Verdnatura webmail','https://mail.verdnatura.es/','mail');
INSERT INTO `link` VALUES (23,'Verdnatura Beta','Trial version of the web page','https://test-shop.verdnatura.es/','vn');
INSERT INTO `link` VALUES (25,'Shared folder','Shared folder','https://cdn.verdnatura.es/share','backup');
INSERT INTO `link` VALUES (29,'phpMyAdmin','Manage MySQL database','https://pma.verdnatura.es/','pma');
@ -2710,16 +2744,16 @@ INSERT INTO `link` VALUES (33,'Gitea','Version control system','https://gitea.ve
INSERT INTO `link` VALUES (34,'Wiknatura','Verdnatura wiki page','https://wiki.verdnatura.es/','wiki');
INSERT INTO `link` VALUES (35,'phpLDAPadmin','Manage the LDAP database','https://pla.verdnatura.es/','pla');
INSERT INTO `link` VALUES (36,'Applications','Access applications repository','https://cdn.verdnatura.es/vn-access','access');
INSERT INTO `link` VALUES (37,'Jenkins','CI and CD system','https://jenkins.verdnatura.es','jenkins');
INSERT INTO `link` VALUES (38,'osTicket','User service center','https://cau.verdnatura.es','osticket');
INSERT INTO `link` VALUES (39,'Redmine','Flexible project management','https://redmine.verdnatura.es','redmine');
INSERT INTO `link` VALUES (40,'Grafana','Analytics & monitoring solution','https://grafana.verdnatura.es','grafana');
INSERT INTO `link` VALUES (41,'Rocket.Chat','Communications platform','https://chat.verdnatura.es','rocketchat');
INSERT INTO `link` VALUES (42,'Salix','ERP software','https://salix.verdnatura.es','salix');
INSERT INTO `link` VALUES (43,'Docker','Container management','https://docker.verdnatura.es','docker');
INSERT INTO `link` VALUES (44,'Proxmox','Virtual environment','https://mox.verdnatura.es','proxmox');
INSERT INTO `link` VALUES (45,'Shinobi','Network video recorder','https://shinobi.verdnatura.es','shinobi');
INSERT INTO `link` VALUES (46,'DokuWiki','Internal documentation','https://doku.verdnatura.es','dokuwiki');
INSERT INTO `link` VALUES (37,'Jenkins','CI and CD system','https://jenkins.verdnatura.es/','jenkins');
INSERT INTO `link` VALUES (38,'osTicket','User service center','https://cau.verdnatura.es/','osticket');
INSERT INTO `link` VALUES (39,'Redmine','Flexible project management','https://redmine.verdnatura.es/','redmine');
INSERT INTO `link` VALUES (40,'Grafana','Analytics & monitoring solution','https://grafana.verdnatura.es/','grafana');
INSERT INTO `link` VALUES (41,'Rocket.Chat','Communications platform','https://chat.verdnatura.es/','rocketchat');
INSERT INTO `link` VALUES (42,'Salix','ERP software','https://salix.verdnatura.es/','salix');
INSERT INTO `link` VALUES (43,'Kubernetes','Container management','https://kube.verdnatura.es/','docker');
INSERT INTO `link` VALUES (44,'Proxmox','Virtual environment','https://pve.verdnatura.es/','proxmox');
INSERT INTO `link` VALUES (45,'Shinobi','Network video recorder','https://shinobi.verdnatura.es/','shinobi');
INSERT INTO `link` VALUES (46,'xWiki','Internal documentation','https://xwiki.verdnatura.es/','dokuwiki');
INSERT INTO `location` VALUES (2,'39.2095886','-0.4173501','Valencia','Calle Fenollar, 2','46680','Algemesi','Valencia','963 242 100','es');
INSERT INTO `location` VALUES (3,'40.4564969','-3.4875829','Madrid','Avenida de la Constitución, 3 - Nave E','28850','Torrejón de Ardoz','Madrid','963 242 100',NULL);
@ -2769,6 +2803,8 @@ INSERT INTO `message` VALUES (18,'orderNotOwnedByUser','The order belongs to ano
INSERT INTO `message` VALUES (19,'orderConfirmed','The order has already been confirmed and cannot be modified');
INSERT INTO `message` VALUES (20,'clientNotVerified','Incomplete tax data, please contact your sales representative');
INSERT INTO `message` VALUES (21,'quantityLessThanMin','The quantity cannot be less than the minimum');
INSERT INTO `message` VALUES (22,'ORDER_ROW_UNAVAILABLE','The ordered quantity exceeds the available');
INSERT INTO `message` VALUES (23,'AMOUNT_NOT_MATCH_GROUPING','The quantity ordered does not match the grouping');
INSERT INTO `metatag` VALUES (2,'title','Verdnatura Levante SL, mayorista de flores, plantas y complementos para floristería y decoración');
INSERT INTO `metatag` VALUES (3,'description','Verdnatura Levante SL, mayorista de flores, plantas y complementos para floristería y decoración. Envío a toda España, pedidos por internet o por teléfono.');
@ -2935,6 +2971,7 @@ INSERT INTO `tpvResponse` VALUES (9999,'Operación que ha sido redirigida al emi
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
USE `sage`;
/*M!999999\- enable the sandbox mode */
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,12 +1 @@
CREATE USER 'vn'@'localhost';
GRANT SELECT,
INSERT,
UPDATE,
DELETE,
DROP,
CREATE TEMPORARY TABLES,
EXECUTE,
EVENT,
TRIGGER
ON *.* TO 'vn'@'localhost';
-- Executed after dump

View File

@ -1 +1,14 @@
-- Executed before dump
CREATE USER 'vn'@'localhost';
GRANT SELECT,
INSERT,
UPDATE,
DELETE,
DROP,
CREATE TEMPORARY TABLES,
EXECUTE,
EVENT,
TRIGGER
ON *.* TO 'vn'@'localhost';

View File

@ -335,21 +335,21 @@ INSERT INTO `vn`.`payDem`(`id`, `payDem`)
(2, 20),
(7, 0);
INSERT INTO `vn`.`autonomy`(`id`, `name`, `countryFk`)
INSERT INTO `vn`.`autonomy`(`id`, `name`, `countryFk`, `hasDailyInvoice`)
VALUES
(1, 'Autonomy one', 1),
(2, 'Autonomy two', 1),
(3, 'Autonomy three', 2),
(4, 'Autonomy four', 13);
(1, 'Autonomy one', 1, 1),
(2, 'Autonomy two', 1, 0),
(3, 'Autonomy three', 2, 0),
(4, 'Autonomy four', 13, 0);
INSERT INTO `vn`.`province`(`id`, `name`, `countryFk`, `autonomyFk`, `warehouseFk`)
VALUES
(1, 'Province one', 1, 1, NULL),
(2, 'Province two', 1, 1, NULL),
(3, 'Province three', 30, 2, NULL),
(4, 'Province four', 2, 3, NULL),
(5, 'Province five', 13, 4, NULL);
(1, 'Province one', 1, 1, NULL),
(2, 'Province two', 1, 1, NULL),
(3, 'Province three', 30, 2, NULL),
(4, 'Province four', 2, 3, NULL),
(5, 'Province five', 13, 4, NULL);
INSERT INTO `vn`.`town`(`id`, `name`, `provinceFk`)
VALUES
@ -365,6 +365,7 @@ INSERT INTO `vn`.`postCode`(`code`, `townFk`, `geoFk`)
('46460', 2, 6),
('46680', 3, 6),
('46600', 4, 7),
('46600',1, 6),
('EC170150', 5, 8);
INSERT INTO `vn`.`clientType`(`code`, `type`)
@ -397,7 +398,7 @@ INSERT INTO `vn`.`client`(`id`,`name`,`fi`,`socialName`,`contact`,`street`,`city
(1107, 'Hank Pym', '09854837G', 'ANT MAN', 'Hawk', 'ANTHILL, SAN FRANCISCO, CALIFORNIA', 'Gotham', 46460, 1111111111, 222222222, 1, 'HankPym@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 0, 0, NULL, 0, 0, 19, 0, 'florist','normal'),
(1108, 'Charles Xavier', '22641921P', 'PROFESSOR X', 'Beast', '3800 VICTORY PKWY, CINCINNATI, OH 45207, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'CharlesXavier@mydomain.com', NULL, 0, 1234567890, 0, 5, 1, 300, 13, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, NULL, 0, 0, 19, 0, 'florist','normal'),
(1109, 'Bruce Banner', '16104829E', 'HULK', 'Black widow', 'SOMEWHERE IN NEW YORK', 'Gotham', 46460, 1111111111, 222222222, 1, 'BruceBanner@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 0, 0, NULL, 0, 0, 9, 0, 'florist','normal'),
(1110, 'Jessica Jones', '58282869H', 'JESSICA JONES', 'Luke Cage', 'NYCC 2015 POSTER', 'Gotham', 46460, 1111111111, 222222222, 1, 'JessicaJones@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 0, 0, NULL, 0, 0, NULL, 0, 'florist','normal'),
(1110, 'Jessica Jones', '58282869H', 'JESSICA JONES', 'Luke Cage', 'NYCC 2015 POSTER', 'Gotham', 46460, 1111111111, 222222222, 1, 'JessicaJones@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, NULL, 1, 'florist','normal'),
(1111, 'Missing', NULL, 'MISSING MAN', 'Anton', 'THE SPACE, UNIVERSE FAR AWAY', 'Gotham', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 0, 1, 0, NULL, 1, 0, NULL, 0, 'others','loses'),
(1112, 'Trash', NULL, 'GARBAGE MAN', 'Unknown name', 'NEW YORK CITY, UNDERGROUND', 'Gotham', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 0, 1, 0, NULL, 1, 0, NULL, 0, 'others','loses');
@ -821,10 +822,10 @@ INSERT INTO `vn`.`ticketTracking`(`ticketFk`, `stateFk`, `userFk`, `created`)
(12, 3, 19, util.VN_NOW()),
(13, 3, 19, util.VN_NOW()),
(14, 3, 19, util.VN_NOW()),
(15, 2, 19, util.VN_NOW()),
(15, 10, 19, util.VN_NOW()),
(16, 3, 19, util.VN_NOW()),
(17, 2, 19, util.VN_NOW()),
(18, 2, 19, util.VN_NOW()),
(37, 10, 19, util.VN_NOW()),
(19, 2, 19, util.VN_NOW()),
(20, 1, 19, DATE_ADD(util.VN_NOW(), INTERVAL +1 MONTH)),
(21, 1, 19, DATE_ADD(util.VN_NOW(), INTERVAL +1 MONTH)),
@ -1031,19 +1032,20 @@ INSERT INTO `vn`.`expeditionStateType`(`id`, `description`, `code`)
INSERT INTO `vn`.`expedition`(`id`, `agencyModeFk`, `ticketFk`, `freightItemFk`, `created`, `counter`, `workerFk`, `externalId`, `packagingFk`, `stateTypeFk`, `hostFk`)
VALUES
(1, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 18, 'UR9000006041', 94, 1, 'pc1'),
(2, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 18, 'UR9000006041', 94, 1, NULL),
(3, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 3, 18, 'UR9000006041', 94, 2, NULL),
(4, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 4, 18, 'UR9000006041', 94, 2, NULL),
(5, 1, 2, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 18, NULL, 94, 3, NULL),
(6, 7, 3, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), 1, 18, NULL, 94, 3, NULL),
(7, 2, 4, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), 1, 18, NULL, 94, NULL,NULL),
(8, 3, 5, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), 1, 18, NULL, 94, 1, NULL),
(9, 3, 6, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 18, NULL, 94, 2, NULL),
(10, 7, 7, 71, util.VN_NOW(), 1, 18, NULL, 94, 3, NULL),
(11, 7, 8, 71, util.VN_NOW(), 1, 18, NULL, 94, 3, NULL),
(12, 7, 9, 71, util.VN_NOW(), 1, 18, NULL, 94, 3, NULL),
(13, 1, 10,71, util.VN_NOW(), 1, 18, NULL, 94, 3, NULL);
(1, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 18, 'UR9000006041', 94, 1, 'pc1'),
(2, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 18, 'UR9000006041', 94, 1, NULL),
(3, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 3, 18, 'UR9000006041', 94, 2, NULL),
(4, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 4, 18, 'UR9000006041', 94, 2, NULL),
(5, 1, 2, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 18, NULL, 94, 3, NULL),
(6, 7, 3, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), 1, 18, NULL, 94, 3, NULL),
(7, 2, 4, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), 1, 18, NULL, 94, NULL,NULL),
(8, 3, 5, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), 1, 18, NULL, 94, 1, NULL),
(9, 3, 6, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 18, NULL, 94, 2, NULL),
(10, 7, 7, 71, util.VN_NOW(), 1, 18, NULL, 94, 3, NULL),
(11, 7, 8, 71, util.VN_NOW(), 1, 18, NULL, 94, 3, NULL),
(12, 7, 9, 71, util.VN_NOW(), 1, 18, NULL, 94, 3, NULL),
(13, 1, 10, 71, util.VN_NOW(), 1, 18, NULL, 94, 3, NULL),
(14, 1, 37, 71, util.VN_NOW(), 1, 18, NULL, 94, 3, NULL);
INSERT INTO `vn`.`expeditionState`(`id`, `created`, `expeditionFk`, `typeFk`, `userFk`)
@ -1478,7 +1480,8 @@ INSERT INTO `vn`.`ticketWeekly`(`ticketFk`, `weekDay`)
(2, 1),
(3, 2),
(5, 6),
(15, 6);
(15, 6),
(17, 6);
INSERT INTO `vn`.`awb` (id, code, package, weight, created, amount, transitoryFk, taxFk)
VALUES
@ -1503,7 +1506,8 @@ INSERT INTO `vn`.`travel`(`id`,`shipped`, `landed`, `warehouseInFk`, `warehouseO
(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),
(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),
(11, util.VN_CURDATE() , util.VN_CURDATE() + INTERVAL 1 DAY, 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4);
(11, util.VN_CURDATE() - INTERVAL 1 DAY , util.VN_CURDATE(), 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4),
(12, util.VN_CURDATE() , util.VN_CURDATE() + INTERVAL 1 DAY, 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4);
INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed`, `companyFk`, `invoiceNumber`, `reference`, `isExcludedFromAvailable`, `isRaid`, `evaNotes`)
VALUES
@ -1517,7 +1521,7 @@ INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed
(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 10', 1, 1, ''),
(99, 69, '2000-12-01 00:00:00.000', 11, 0, 442, 'IN2009', 'Movement 99', 1, 1, '');
(99, 69, '2000-12-01 00:00:00.000', 11, 0, 442, 'IN2009', 'Movement 99', 0, 0, '');
INSERT INTO `vn`.`entryConfig` (`defaultEntry`, `inventorySupplierFk`, `defaultSupplierFk`)
VALUES (2, 4, 1);
@ -3183,7 +3187,7 @@ UPDATE vn.department
SET workerFk = null;
INSERT INTO vn.packaging
VALUES('--', 2745600.00, 100.00, 120.00, 220.00, 0.00, 1, '2001-01-01 00:00:00.000', NULL, NULL, NULL, 0.00, 16, 0.00, 0, NULL, 0.00, NULL, NULL, 0, NULL, 0, 0);
VALUES('--', 2745600.00, 100.00, 120.00, 220.00, 0.00, 1, '2001-01-01 00:00:00.000', NULL, NULL, NULL, 0.00, 16, 0.00, 0, NULL, 0.00, NULL, NULL, 0, NULL, 0, 0,0);
INSERT IGNORE INTO vn.intrastat
@ -3934,7 +3938,7 @@ INSERT INTO vn.medicalReview
(id, workerFk, centerFk, `date`, `time`, isFit, amount, invoice, remark)
VALUES(3, 9, 2, '2000-01-01', '8:00', 1, 150.0, NULL, NULL);
INSERT INTO vn.stockBought (workerFk, bought, reserve, dated)
INSERT INTO vn.stockBought (workerFk, bought, reserve, dated)
VALUES(35, 1.00, 1.00, '2001-01-01');
INSERT INTO vn.auctionConfig (id,conversionCoefficient,warehouseFk)
@ -3966,6 +3970,6 @@ INSERT INTO vn.accountDetailType (id, description, code)
(5, 'Referencia Nominas', 'payRef'),
(6, 'ABA', 'aba');
INSERT IGNORE INTO ormConfig
INSERT IGNORE INTO ormConfig
SET id =1,
selectLimit = 1000;

View File

@ -1,8 +1,22 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`waste_addSales`()
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`waste_addSales`(
vDateFrom DATE,
vDateTo DATE
)
BEGIN
DECLARE vDateFrom DATE DEFAULT util.VN_CURDATE() - INTERVAL WEEKDAY(util.VN_CURDATE()) DAY;
DECLARE vDateTo DATE DEFAULT vDateFrom + INTERVAL 6 DAY;
/**
* Recalcula las mermas de un periodo.
*
* @param vDateFrom Fecha desde
* @param vDateTo Fecha hasta
*/
IF vDateFrom IS NULL THEN
SET vDateFrom = util.VN_CURDATE() - INTERVAL WEEKDAY(util.VN_CURDATE()) DAY;
END IF;
IF vDateTo IS NULL THEN
SET vDateTo = vDateFrom + INTERVAL 6 DAY;
END IF;
CALL cache.last_buy_refresh(FALSE);
@ -56,6 +70,6 @@ BEGIN
JOIN vn.buy b ON b.id = lb.buy_id
WHERE t.shipped BETWEEN vDateFrom AND vDateTo
AND w.isManaged
GROUP BY i.id;
GROUP BY YEAR(t.shipped), WEEK(t.shipped, 4), i.id;
END$$
DELIMITER ;

View File

@ -0,0 +1,6 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`waste_addSalesLauncher`()
BEGIN
CALL waste_addSales(NULL, NULL);
END$$
DELIMITER ;

View File

@ -1,8 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`MIDNIGHT`(vDate DATE)
RETURNS datetime
DETERMINISTIC
BEGIN
RETURN TIMESTAMP(vDate,'23:59:59');
END$$
DELIMITER ;

View File

@ -1,30 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`routeProposal_`(vTicketFk INT)
RETURNS int(11)
NOT DETERMINISTIC
READS SQL DATA
BEGIN
DECLARE vRouteFk INT;
DECLARE vAddressFk INT;
DECLARE vShipped DATETIME;
SELECT addressFk, date(shipped) INTO vAddressFk, vShipped
FROM vn.ticket
WHERE id = vTicketFk;
SELECT routeFk INTO vRouteFk
FROM
(SELECT t.routeFk, sum(af.friendship) friendshipSum
FROM vn.ticket t
JOIN cache.addressFriendship af ON af.addressFk2 = t.addressFk AND af.addressFk1 = vAddressFk
WHERE t.shipped BETWEEN vShipped and MIDNIGHT(vShipped)
AND t.routeFk
GROUP BY routeFk
ORDER BY friendshipSum DESC
) sub
LIMIT 1;
RETURN vRouteFk;
END$$
DELIMITER ;

View File

@ -126,7 +126,10 @@ BEGIN
AND a.available > 0
AND (sub.itemAllowed OR NOT it.isFloramondo OR anr.available > 0)
AND (ag.isAnyVolumeAllowed OR NOT itt.isUnconventionalSize)
AND (itc.isReclining OR it.`size` IS NULL OR it.`size` < z.itemMaxSize OR z.itemMaxSize IS NULL)
AND (it.`size` IS NULL
OR IF(itc.isReclining,
it.size <= z.itemMaxLength OR z.itemMaxLength IS NULL,
it.size <= z.itemMaxSize OR z.itemMaxSize IS NULL))
AND cit.id IS NULL
AND zit.id IS NULL
AND ait.id IS NULL;

View File

@ -7,7 +7,7 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`catalog_componentCalc
)
BEGIN
/**
* Calcula los componentes de los articulos de tmp.ticketLot
* Calcula los componentes de los articulos de la tabla tmp.ticketLot
*
* @param vZoneFk para calcular el transporte
* @param vAddressFk Consignatario
@ -25,18 +25,38 @@ BEGIN
FROM address
WHERE id = vAddressFk;
CREATE OR REPLACE TEMPORARY TABLE tSpecialPrice
CREATE OR REPLACE TEMPORARY TABLE tPriceDelta
(INDEX (itemFk))
ENGINE = MEMORY
SELECT * FROM (
ENGINE = MEMORY
SELECT i.id itemFk,
SUM(IFNULL(pd.absIncreasing,0)) absIncreasing,
SUM(IFNULL(pd.ratIncreasing,0)) ratIncreasing,
pd.warehouseFk
FROM item i
JOIN priceDelta pd
ON pd.itemTypeFk = i.typeFk
AND (pd.minSize IS NULL OR pd.minSize <= i.`size`)
AND (pd.maxSize IS NULL OR pd.maxSize >= i.`size`)
AND (pd.inkFk IS NULL OR pd.inkFk = i.inkFk)
AND (pd.originFk IS NULL OR pd.originFk = i.originFk)
AND (pd.producerFk IS NULL OR pd.producerFk = i.producerFk)
AND (pd.warehouseFk IS NULL OR pd.warehouseFk = vWarehouseFk)
WHERE (pd.fromDated IS NULL OR pd.fromDated <= vShipped)
AND (pd.toDated IS NULL OR pd.toDated >= vShipped)
GROUP BY i.id;
CREATE OR REPLACE TEMPORARY TABLE tSpecialPrice
(INDEX (itemFk))
ENGINE = MEMORY
SELECT * FROM (
SELECT *
FROM specialPrice
WHERE (clientFk = vClientFk OR clientFk IS NULL)
AND started <= vShipped
AND (ended >= vShipped OR ended IS NULL)
ORDER BY (clientFk = vClientFk) DESC, id DESC
LIMIT 10000000000000000000) t
GROUP BY itemFk;
FROM specialPrice
WHERE (clientFk = vClientFk OR clientFk IS NULL)
AND started <= vShipped
AND (ended >= vShipped OR ended IS NULL)
ORDER BY (clientFk = vClientFk) DESC, id DESC
LIMIT 10000000000000000000) t
GROUP BY itemFk;
CREATE OR REPLACE TEMPORARY TABLE tmp.ticketComponentCalculate
(PRIMARY KEY (itemFk, warehouseFk))
@ -108,6 +128,19 @@ BEGIN
JOIN tmp.ticketComponentCalculate tcc ON tcc.itemFk = tc.itemFk AND tcc.warehouseFk = tc.warehouseFk
GROUP BY tc.itemFk, warehouseFk;
-- Bonus del comprador a un rango de productos
INSERT INTO tmp.ticketComponent(warehouseFk, itemFk, componentFk, cost)
SELECT
tcb.warehouseFk,
tcb.itemFk,
c.id,
IFNULL(tcb.base * tpd.ratIncreasing / 100,0) + IFNULL(tpd.absIncreasing,0)
FROM tmp.ticketComponentBase tcb
JOIN component c ON c.code = 'bonus'
JOIN tPriceDelta tpd
ON tpd.itemFk = tcb.itemFk
AND tpd.warehouseFk = tcb.warehouseFk;
-- RECOBRO
INSERT INTO tmp.ticketComponent(warehouseFk, itemFk, componentFk, cost)
SELECT tcb.warehouseFk, tcb.itemFk, c2.id,
@ -303,6 +336,7 @@ BEGIN
tmp.ticketComponentBase,
tmp.ticketComponentRate,
tmp.ticketComponentCopy,
tSpecialPrice;
tPriceDelta,
tSpecialPrice;
END$$
DELIMITER ;

View File

@ -1,8 +1,5 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`collection_new`(
vUserFk INT,
OUT vCollectionFk INT
)
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`collection_new`(vUserFk INT, OUT vCollectionFk INT)
BEGIN
/**
* Genera colecciones de tickets sin asignar trabajador.
@ -15,29 +12,30 @@ BEGIN
DECLARE vLinesLimit INT;
DECLARE vTicketLines INT;
DECLARE vVolumeLimit DECIMAL;
DECLARE vSizeLimit INT;
DECLARE vTicketVolume DECIMAL;
DECLARE vSizeLimit INT;
DECLARE vMaxTickets INT;
DECLARE vStateCode VARCHAR(45);
DECLARE vStateFk VARCHAR(45);
DECLARE vFirstTicketFk INT;
DECLARE vHour INT;
DECLARE vMinute INT;
DECLARE vWorkerCode VARCHAR(3);
DECLARE vWagonCounter INT DEFAULT 1;
DECLARE vWagonCounter INT DEFAULT 0;
DECLARE vTicketFk INT;
DECLARE vItemPackingTypeFk VARCHAR(1);
DECLARE vHasAssignedTickets BOOL;
DECLARE vHasAssignedTickets BOOLEAN;
DECLARE vHasUniqueCollectionTime BOOL;
DECLARE vHeight INT;
DECLARE vVolume INT;
DECLARE vLiters INT;
DECLARE vLines INT;
DECLARE vTotalLines INT DEFAULT 0;
DECLARE vTotalVolume INT DEFAULT 0;
DECLARE vFreeWagonFk INT;
DECLARE vDone INT DEFAULT FALSE;
DECLARE vLockName VARCHAR(215);
DECLARE vLockTime INT DEFAULT 30;
DECLARE vFreeWagonFk INT;
DECLARE vErrorNumber INT;
DECLARE vErrorMsg TEXT;
DECLARE vTickets CURSOR FOR
DECLARE c1 CURSOR FOR
SELECT ticketFk, `lines`, m3
FROM tmp.productionBuffer
WHERE ticketFk <> vFirstTicketFk
ORDER BY HH,
mm,
productionOrder DESC,
@ -50,6 +48,26 @@ BEGIN
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
GET DIAGNOSTICS CONDITION 1
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);
END IF;
RESIGNAL;
END;
SELECT pc.ticketTrolleyMax * o.numberOfWagons,
pc.hasUniqueCollectionTime,
w.code,
@ -60,26 +78,36 @@ BEGIN
o.trainFk,
o.linesLimit,
o.volumeLimit,
o.sizeLimit
o.sizeLimit,
pc.collection_new_lockname
INTO vMaxTickets,
vHasUniqueCollectionTime,
vWorkerCode,
vWarehouseFk,
vItemPackingTypeFk,
vStateCode,
vWagons,
vTrainFk,
vLinesLimit,
vVolumeLimit,
vSizeLimit
FROM worker w
JOIN operator o ON o.workerFk = w.id
vHasUniqueCollectionTime,
vWorkerCode,
vWarehouseFk,
vItemPackingTypeFk,
vStateFk,
vWagons,
vTrainFk,
vLinesLimit,
vVolumeLimit,
vSizeLimit,
vLockName
FROM productionConfig pc
JOIN worker w ON w.id = vUserFk
JOIN state st ON st.`code` = 'ON_PREPARATION'
JOIN productionConfig pc
WHERE w.id = vUserFk;
JOIN operator o ON o.workerFk = vUserFk;
SET vLockName = CONCAT_WS('/',
vLockName,
vWarehouseFk,
vItemPackingTypeFk
);
IF NOT GET_LOCK(vLockName, vLockTime) THEN
CALL util.throw(CONCAT('Cannot get lock: ', vLockName));
END IF;
-- Se prepara el tren, con tantos vagones como sea necesario.
CREATE OR REPLACE TEMPORARY TABLE tTrain
(wagon INT,
shelve INT,
@ -90,58 +118,59 @@ BEGIN
PRIMARY KEY(wagon, shelve))
ENGINE = MEMORY;
INSERT INTO tTrain (wagon, shelve, liters, `lines`, height)
WITH RECURSIVE wagonSequence AS (
SELECT vWagonCounter wagon
UNION ALL
SELECT wagon + 1 wagon
FROM wagonSequence
WHERE wagon < vWagonCounter + vWagons -1
)
SELECT ws.wagon, cv.`level`, cv.liters, cv.`lines`, cv.height
FROM wagonSequence ws
JOIN vn.collectionVolumetry cv ON cv.trainFk = vTrainFk
WHILE vWagons > vWagonCounter DO
SET vWagonCounter = vWagonCounter + 1;
INSERT INTO tTrain(wagon, shelve, liters, `lines`, height)
SELECT vWagonCounter, cv.`level` , cv.liters , cv.`lines` , cv.height
FROM collectionVolumetry cv
WHERE cv.trainFk = vTrainFk
AND cv.itemPackingTypeFk = vItemPackingTypeFk;
END WHILE;
-- Esto desaparecerá cuando tengamos la table cache.ticket
CALL productionControl(vWarehouseFk, 0);
ALTER TABLE tmp.productionBuffer
ADD COLUMN liters INT,
ADD COLUMN height INT;
-- Se obtiene nº de colección.
INSERT INTO collection
SET itemPackingTypeFk = vItemPackingTypeFk,
trainFk = vTrainFk,
wagons = vWagons,
warehouseFk = vWarehouseFk;
SELECT LAST_INSERT_ID() INTO vCollectionFk;
-- Los tickets de recogida en Algemesí sólo se sacan si están asignados.
-- Los pedidos con riesgo no se sacan aunque se asignen.
DELETE pb
DELETE pb.*
FROM tmp.productionBuffer pb
JOIN state s ON s.id = pb.state
WHERE (pb.agency = 'REC_ALGEMESI'
AND s.code <> 'PICKER_DESIGNED')
OR pb.problem LIKE '%RIESGO%';
-- Si hay tickets asignados, nos centramos exclusivamente en esos tickets
-- y los sacamos independientemente de problemas o tamaños
SELECT EXISTS (
SELECT TRUE
FROM tmp.productionBuffer pb
JOIN state s ON s.id = pb.state
WHERE s.code = 'PICKER_DESIGNED'
AND pb.workerCode = vWorkerCode
) INTO vHasAssignedTickets;
-- Comprobamos si hay tickets asignados. En ese caso, nos centramos
-- exclusivamente en esos tickets y los sacamos independientemente
-- de problemas o tamaños
SELECT COUNT(*) INTO vHasAssignedTickets
FROM tmp.productionBuffer pb
JOIN state s ON s.id = pb.state
WHERE s.code = 'PICKER_DESIGNED'
AND pb.workerCode = vWorkerCode;
-- Se dejan en la tabla tmp.productionBuffer sólo aquellos tickets adecuados
IF vHasAssignedTickets THEN
DELETE pb
DELETE pb.*
FROM tmp.productionBuffer pb
JOIN state s ON s.id = pb.state
WHERE s.code <> 'PICKER_DESIGNED'
OR pb.workerCode <> vWorkerCode;
ELSE
DELETE pb
DELETE pb.*
FROM tmp.productionBuffer pb
JOIN state s ON s.id = pb.state
JOIN agencyMode am ON am.id = pb.agencyModeFk
@ -164,66 +193,73 @@ BEGIN
OR (NOT pb.H AND pb.V > 0 AND vItemPackingTypeFk = 'H')
OR (NOT pb.V AND vItemPackingTypeFk = 'V')
OR (pc.isPreviousPreparationRequired AND pb.previousWithoutParking)
OR LENGTH(pb.problem)
OR LENGTH(pb.problem) > 0
OR pb.lines > vLinesLimit
OR pb.m3 > vVolumeLimit
OR sub.maxSize > vSizeLimit
OR pb.hasPlantTray;
END IF;
-- Es importante que el primer ticket se coja en todos los casos
SELECT ticketFk,
HH,
mm,
`lines`,
m3
INTO vFirstTicketFk,
vHour,
vMinute,
vTicketLines,
vTicketVolume
FROM tmp.productionBuffer
ORDER BY HH,
mm,
productionOrder DESC,
m3 DESC,
agency,
zona,
routeFk,
ticketFk
LIMIT 1;
-- Hay que excluir aquellos que no tengan la misma hora de preparacion, si procede
IF vHasUniqueCollectionTime THEN
SELECT ticketFk INTO vFirstTicketFk
FROM tmp.productionBuffer
ORDER BY HH,
mm,
productionOrder DESC,
m3 DESC,
agency,
zona,
routeFk,
ticketFk
LIMIT 1;
DELETE pb
FROM tmp.productionBuffer pb
JOIN tmp.productionBuffer pb2 ON pb2.ticketFk = vFirstTicketFk
AND (pb.HH <> pb2.HH OR pb.mm <> pb2.mm);
DELETE FROM tmp.productionBuffer
WHERE HH <> vHour
OR mm <> vMinute;
END IF;
OPEN vTickets;
l: LOOP
SET vDone = FALSE;
FETCH vTickets INTO vTicketFk, vTicketLines, vTicketVolume;
SET vTicketFk = vFirstTicketFk;
SET @lines = 0;
SET @volume = 0;
IF vDone THEN
LEAVE l;
END IF;
OPEN c1;
read_loop: LOOP
SET vDone = FALSE;
-- Buscamos un ticket que cumpla con los requisitos en el listado
IF (vLinesLimit IS NULL OR (vTotalLines + vTicketLines) <= vLinesLimit)
AND (vVolumeLimit IS NULL OR (vTotalVolume + vTicketVolume) <= vVolumeLimit) THEN
IF ((vTicketLines + @lines) <= vLinesLimit OR vLinesLimit IS NULL)
AND ((vTicketVolume + @volume) <= vVolumeLimit OR vVolumeLimit IS NULL) THEN
CALL ticket_splitItemPackingType(vTicketFk, vItemPackingTypeFk);
DROP TEMPORARY TABLE tmp.ticketIPT;
SELECT COUNT(*), SUM(litros), MAX(i.`size`), SUM(sv.volume)
INTO vLines, vLiters, vHeight, vVolume
FROM saleVolume sv
JOIN sale s ON s.id = sv.saleFk
JOIN item i ON i.id = s.itemFk
WHERE sv.ticketFk = vTicketFk;
SET vTotalVolume = vTotalVolume + vVolume,
vTotalLines = vTotalLines + vLines;
UPDATE tmp.productionBuffer pb
SET pb.liters = vLiters,
pb.`lines` = vLines,
pb.height = vHeight
JOIN (
SELECT SUM(litros) liters,
@lines:= COUNT(*) + @lines,
COUNT(*) `lines`,
MAX(i.`size`) height,
@volume := SUM(sv.volume) + @volume,
SUM(sv.volume) volume
FROM saleVolume sv
JOIN sale s ON s.id = sv.saleFk
JOIN item i ON i.id = s.itemFk
WHERE sv.ticketFk = vTicketFk
) sub
SET pb.liters = sub.liters,
pb.`lines` = sub.`lines`,
pb.height = sub.height
WHERE pb.ticketFk = vTicketFk;
UPDATE tTrain tt
@ -240,13 +276,17 @@ BEGIN
tt.height
LIMIT 1;
-- Si no le encuentra una balda, intentamos darle un carro entero libre
-- Si no le encuentra una balda adecuada, intentamos darle un carro entero si queda alguno libre
IF NOT (SELECT COUNT(*) FROM tTrain WHERE ticketFk) THEN
SELECT wagon INTO vFreeWagonFk
FROM tTrain
GROUP BY wagon
HAVING SUM(IFNULL(ticketFk, 0)) = 0
SELECT tt.wagon
INTO vFreeWagonFk
FROM tTrain tt
LEFT JOIN (
SELECT DISTINCT wagon
FROM tTrain
WHERE ticketFk IS NOT NULL
) nn ON nn.wagon = tt.wagon
WHERE nn.wagon IS NULL
ORDER BY wagon
LIMIT 1;
@ -255,35 +295,38 @@ BEGIN
SET ticketFk = vFirstTicketFk
WHERE wagon = vFreeWagonFk;
-- Se anulan el resto de carros libres,
-- máximo un carro con pedido excesivo
DELETE tt
-- Se anulan el resto de carros libres para que sólo uno lleve un pedido excesivo
DELETE tt.*
FROM tTrain tt
JOIN (SELECT wagon
FROM tTrain
GROUP BY wagon
HAVING SUM(IFNULL(ticketFk, 0)) = 0
) sub ON sub.wagon = tt.wagon;
LEFT JOIN (
SELECT DISTINCT wagon
FROM tTrain
WHERE ticketFk IS NOT NULL
) nn ON nn.wagon = tt.wagon
WHERE nn.wagon IS NULL;
END IF;
END IF;
END IF;
FETCH c1 INTO vTicketFk, vTicketLines, vTicketVolume;
IF vDone OR NOT (SELECT COUNT(*) FROM tTrain WHERE ticketFk IS NULL) THEN
LEAVE read_loop;
END IF;
ELSE
FETCH c1 INTO vTicketFk, vTicketLines, vTicketVolume;
IF vDone THEN
LEAVE read_loop;
END IF;
END IF;
END LOOP;
CLOSE vTickets;
CLOSE c1;
IF (SELECT COUNT(*) FROM tTrain WHERE ticketFk) THEN
-- Se obtiene nº de colección
INSERT INTO collection
SET itemPackingTypeFk = vItemPackingTypeFk,
trainFk = vTrainFk,
wagons = vWagons,
warehouseFk = vWarehouseFk;
SELECT LAST_INSERT_ID() INTO vCollectionFk;
UPDATE collection c
JOIN state st ON st.code = 'ON_PREPARATION'
SET c.stateFk = st.id
WHERE c.id = vCollectionFk;
-- Asigna las bandejas
INSERT IGNORE INTO ticketCollection(ticketFk, collectionFk, `level`, wagon, liters)
SELECT tt.ticketFk, vCollectionFk, tt.shelve, tt.wagon, tt.liters
FROM tTrain tt
@ -291,34 +334,37 @@ BEGIN
ORDER BY tt.wagon, tt.shelve;
-- Actualiza el estado de los tickets
CALL collection_setState(vCollectionFk, vStateCode);
CALL collection_setState(vCollectionFk, vStateFk);
-- Aviso para la preparacion previa
INSERT INTO ticketDown(ticketFk, collectionFk)
SELECT tc.ticketFk, tc.collectionFk
FROM ticketCollection tc
WHERE tc.collectionFk = vCollectionFk;
CALL collection_mergeSales(vCollectionFk);
CALL sales_mergeByCollection(vCollectionFk);
UPDATE `collection` c
JOIN(
JOIN (
SELECT COUNT(*) saleTotalCount,
SUM(s.isPicked <> 0) salePickedCount
FROM ticketCollection tc
JOIN sale s ON s.ticketFk = tc.ticketFk
WHERE tc.collectionFk = vCollectionFk
AND s.quantity > 0
)sub
WHERE tc.collectionFk = vCollectionFk
AND s.quantity > 0
) sub
SET c.saleTotalCount = sub.saleTotalCount,
c.salePickedCount = sub.salePickedCount
WHERE c.id = vCollectionFk;
ELSE
SET vCollectionFk = NULL;
DELETE FROM `collection`
WHERE id = vCollectionFk;
SET vCollectionFk = NULL;
END IF;
DO RELEASE_LOCK(vLockName);
DROP TEMPORARY TABLE
tTrain,
tmp.productionBuffer;

View File

@ -1,79 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemFuentesBalance`(vDaysInFuture INT)
BEGIN
/* Se utiliza para calcular la necesidad de mover mercancia entre el almacén de fuentes y el nuestro
*
* @param vDaysInFuture Rango de dias para calcular entradas y salidas
*
*/
DECLARE vWarehouseFk INT;
SELECT s.warehouseFk INTO vWarehouseFk
FROM vn.sector s
WHERE s.code = 'FUENTES_PICASSE';
CALL cache.stock_refresh(FALSE);
SELECT i.id itemFk,
i.longName,
i.size,
i.subName,
v.amount - IFNULL(fue.Fuentes,0) - IFNULL(alb.albenfruit,0) as visible,
fue.Fuentes,
alb.Albenfruit,
sale.venta,
IFNULL(buy.compra,0) + IFNULL(mov.traslado,0) as compra,
IFNULL(v.amount,0) + IFNULL(sale.venta,0) + IFNULL(buy.compra,0) + IFNULL(mov.traslado,0)
- IFNULL(fue.Fuentes,0) - IFNULL(alb.albenfruit,0) as saldo
FROM vn.item i
JOIN vn.itemType it ON it.id = i.typeFk
JOIN vn.itemCategory ic ON ic.id = it.categoryFk
LEFT JOIN (
SELECT ish.itemFk, CAST(SUM(ish.visible) AS DECIMAL(10,0)) AS Fuentes
FROM vn.itemShelving ish
JOIN vn.shelving sh ON sh.code = ish.shelvingFk
JOIN vn.parking p ON p.id = sh.parkingFk
JOIN vn.sector s ON s.id = p.sectorFk
WHERE s.code = 'FUENTES_PICASSE'
GROUP BY ish.itemFk
) fue ON fue.itemFk = i.id
LEFT JOIN (
SELECT ish.itemFk, CAST(SUM(ish.visible) AS DECIMAL(10,0)) AS Albenfruit
FROM vn.itemShelving ish
JOIN vn.shelving sh ON sh.code = ish.shelvingFk
JOIN vn.parking p ON p.id = sh.parkingFk
JOIN vn.sector s ON s.id = p.sectorFk
WHERE s.code = 'ALBENFRUIT'
GROUP BY ish.itemFk
) alb ON alb.itemFk = i.id
LEFT JOIN cache.stock v ON i.id = v.item_id AND v.warehouse_id = vWarehouseFk
LEFT JOIN (
SELECT itemFk item_id, CAST(sum(quantity)AS DECIMAL(10,0)) as venta
FROM itemTicketOut
WHERE shipped BETWEEN util.VN_CURDATE() AND TIMESTAMPADD(DAY,vDaysInFuture , util.dayend(util.VN_CURDATE()))
AND warehouseFk = vWarehouseFk
GROUP BY itemFk
) sale ON sale.item_id = i.id
LEFT JOIN (
SELECT itemFk item_id, CAST(sum(quantity)AS DECIMAL(10,0)) as compra
FROM itemEntryIn
WHERE landed BETWEEN util.VN_CURDATE() AND TIMESTAMPADD(DAY,vDaysInFuture , util.dayend(util.VN_CURDATE()))
AND warehouseInFk = vWarehouseFk
AND isVirtualStock = FALSE
GROUP BY itemFk
) buy ON buy.item_id = i.id
LEFT JOIN (
SELECT itemFk item_id, CAST(sum(quantity)AS DECIMAL(10,0)) as traslado
FROM itemEntryOut
WHERE shipped BETWEEN util.VN_CURDATE() AND TIMESTAMPADD(DAY,vDaysInFuture , util.dayend(util.VN_CURDATE()))
AND warehouseOutFk = vWarehouseFk
GROUP BY itemFk
) mov ON mov.item_id = i.id
WHERE (v.amount OR fue.Fuentes OR alb.Albenfruit)
AND i.itemPackingTypeFk = 'H'
AND ic.shortLife;
END$$
DELIMITER ;

View File

@ -38,7 +38,7 @@ BEGIN
AND IFNULL(sub3.transit,0) < s.quantity
AND s.isPicked = FALSE
AND s.reserved = FALSE
AND t.shipped BETWEEN util.VN_CURDATE() AND MIDNIGHT(util.VN_CURDATE())
AND t.shipped BETWEEN util.VN_CURDATE() AND util.midnight()
AND tst.isPreviousPreparable = TRUE
AND t.warehouseFk = vWarehouseFk
AND iss.sectorFk = vSectorFk

View File

@ -48,6 +48,13 @@ proc: BEGIN
RESIGNAL;
END;
START TRANSACTION;
SELECT id INTO vSaleFk
FROM sale
WHERE id = vSaleFk
FOR UPDATE;
SELECT MAX(p.pickingOrder), s.quantity - SUM(IFNULL(iss.quantity, 0)), s.quantity
INTO vLastPickingOrder, vOutStanding, vSaleQuantity
FROM sale s
@ -57,7 +64,8 @@ proc: BEGIN
LEFT JOIN parking p ON p.id = sh.parkingFk
WHERE s.id = vSaleFk;
IF vOutStanding <= 0 THEN
IF vOutStanding <= 0 THEN
COMMIT;
LEAVE proc;
END IF;
@ -84,10 +92,8 @@ proc: BEGIN
END IF;
LEAVE l;
END IF;
START TRANSACTION;
SELECT id INTO vItemShelvingFk
SELECT id INTO vItemShelvingFk
FROM itemShelving
WHERE id = vItemShelvingFk
FOR UPDATE;
@ -115,9 +121,8 @@ proc: BEGIN
WHERE id = vItemShelvingFk;
END IF;
COMMIT;
END LOOP;
CLOSE vItemShelvingAvailable;
COMMIT;
END$$
DELIMITER ;

View File

@ -1,15 +1,13 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`stockTraslation`(
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`item_calculateStock`(
vDated DATE
)
BEGIN
/**
* Calcula el stock del almacén de subasta desde FechaInventario hasta vDated
* sin tener en cuenta las salidas del mismo dia vDated
* para ver el transporte a reservar
* Calculate the stock of the auction warehouse from the inventory date to vDated
*
* @param vDated Fecha hasta la cual calcula el stock
* @return tmp.item
* @param vDated Date to calculate the stock.
* @return tmp.item, tmp.buyUltimate
*/
DECLARE vAuctionWarehouseFk INT;

View File

@ -1,58 +1,64 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`previousSticker_get`(vSaleGroupFk INT)
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`previousSticker_get`(
vSaleGroupFk INT
)
BEGIN
/**
* Devuelve los campos a imprimir en una etiqueta de preparación previa.
* Actualiza el valor de vn.saleGroup.parkingFk en el caso de que exista un
* Actualiza el valor de saleGroup.parkingFk en el caso de que exista un
* saleGroup del mismo ticket con parking, del mismo sector, para que todos se
* pongan juntos.
*
* @param vSaleGroupFk Identificador de vn.saleGroup
* @param vSaleGroupFk Identificador de saleGroup
*/
DECLARE vTicketFk INT;
DECLARE vParkingFk INT;
DECLARE vSectorFk INT;
DECLARE vTicketLines INT;
SELECT s.ticketFk
INTO vTicketFk
FROM vn.saleGroupDetail sgd
JOIN vn.sale s ON s.id = sgd.saleFk
WHERE sgd.saleGroupFk = vSaleGroupFk
LIMIT 1;
WITH ticketData AS(
SELECT DISTINCT s.ticketFk
FROM vn.saleGroupDetail sgd
JOIN vn.sale s ON s.id = sgd.saleFk
WHERE sgd.saleGroupFk = vSaleGroupFk
)
SELECT COUNT(*), s.ticketFk INTO vTicketLines, vTicketFk
FROM vn.sale s
JOIN ticketData td ON td.ticketFk = s.ticketFk;
SELECT sg.parkingFk, sc.sectorFk
INTO vParkingFk, vSectorFk
FROM vn.saleGroup sg
JOIN vn.sectorCollectionSaleGroup scsg ON scsg.saleGroupFk = sg.id
JOIN vn.sectorCollection sc ON sc.id = scsg.sectorCollectionFk
JOIN vn.saleGroupDetail sgd ON sgd.saleGroupFk = sg.id
JOIN vn.sale s ON s.id = sgd.saleFk
FROM saleGroup sg
JOIN sectorCollectionSaleGroup scsg ON scsg.saleGroupFk = sg.id
JOIN sectorCollection sc ON sc.id = scsg.sectorCollectionFk
JOIN saleGroupDetail sgd ON sgd.saleGroupFk = sg.id
JOIN sale s ON s.id = sgd.saleFk
WHERE s.ticketFk = vTicketFk
AND sg.parkingFk IS NOT NULL
LIMIT 1;
UPDATE vn.saleGroup sg
UPDATE saleGroup sg
SET sg.parkingFk = vParkingFk
WHERE sg.id = vSaleGroupFk
AND sg.sectorFk = vSectorFk;
SELECT sgd.saleGroupFk,
t.id ticketFk,
p.code as location,
t.observations,
COUNT(*) previousLines,
IF(HOUR(t.shipped), HOUR(t.shipped), HOUR(z.`hour`)) shippingHour,
IF(MINUTE(t.shipped), MINUTE(t.shipped), MINUTE(z.`hour`)) shippingMinute ,
IFNULL(MAX(i.itemPackingTypeFk),'H') itemPackingTypeFk ,
count(*) items,
vTicketLines ticketLines,
p.code `location`,
sc.description sector
FROM vn.sale s
JOIN vn.item i ON i.id = s.itemFk
JOIN vn.saleGroupDetail sgd ON sgd.saleFk = s.id
JOIN vn.saleGroup sg ON sg.id = sgd.saleGroupFk
JOIN vn.sector sc ON sc.id = sg.sectorFk
JOIN vn.ticket t ON t.id = s.ticketFk
LEFT JOIN vn.parking p ON p.id = sg.parkingFk
LEFT JOIN vn.`zone` z ON z.id = t.zoneFk
FROM sale s
JOIN item i ON i.id = s.itemFk
JOIN saleGroupDetail sgd ON sgd.saleFk = s.id
JOIN saleGroup sg ON sg.id = sgd.saleGroupFk
JOIN sector sc ON sc.id = sg.sectorFk
JOIN ticket t ON t.id = s.ticketFk
LEFT JOIN parking p ON p.id = sg.parkingFk
LEFT JOIN `zone` z ON z.id = t.zoneFk
WHERE sgd.saleGroupFk = vSaleGroupFk;
END$$
DELIMITER ;

View File

@ -268,15 +268,14 @@ proc: BEGIN
UPDATE tmp.productionBuffer pb
JOIN sale s ON s.ticketFk = pb.ticketFk
JOIN item i ON i.id = s.itemFk
JOIN itemType it ON it.id = i.typeFk
JOIN itemCategory ic ON ic.id = it.categoryFk
JOIN cache.last_buy lb ON lb.warehouse_id = vWarehouseFk AND lb.item_id = s.itemFk
JOIN cache.last_buy lb ON lb.warehouse_id = vWarehouseFk
AND lb.item_id = s.itemFk
JOIN buy b ON b.id = lb.buy_id
JOIN packaging p ON p.id = b.packagingFk
JOIN productionConfig pc
SET hasPlantTray = TRUE
WHERE ic.code = 'plant'
AND p.`depth` >= pc.minPlantTrayLength
SET pb.hasPlantTray = TRUE
WHERE p.isPlantTray
AND s.quantity >= b.packing
AND pb.isOwn;
DROP TEMPORARY TABLE

View File

@ -25,8 +25,9 @@ UPDATE shelving sh
AND (
sh.parked IS NULL
OR
sh.parked < TIMESTAMPADD(MONTH,-1,util.VN_CURDATE())
)
sh.parked < util.VN_CURDATE() - INTERVAL 2 WEEK
)
AND IF(code REGEXP '^[A-Za-z]{2}[0-9]', LEFT (code, 2) NOT IN (
SELECT DISTINCT LEFT(its.shelvingFk, 2)
FROM itemShelving its

View File

@ -1,12 +1,17 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`stockBought_calculate`()
BEGIN
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`stockBought_calculate`(
vDated DATE
)
proc: BEGIN
/**
* Inserts the purchase volume per buyer
* into stockBought according to the current date.
* Calculate the stock of the auction warehouse from the inventory date to vDated
* without taking into account the outputs of the same day vDated
*
* @param vDated Date to calculate the stock.
*/
DECLARE vDated DATE;
SET vDated = util.VN_CURDATE();
IF vDated < util.VN_CURDATE() THEN
LEAVE proc;
END IF;
CREATE OR REPLACE TEMPORARY TABLE tStockBought
SELECT workerFk, reserve
@ -16,26 +21,27 @@ BEGIN
DELETE FROM stockBought WHERE dated = vDated;
INSERT INTO stockBought (workerFk, bought, dated)
CALL item_calculateStock(vDated);
INSERT INTO stockBought(workerFk, bought, dated)
SELECT it.workerFk,
ROUND(SUM(
(ac.conversionCoefficient *
(b.quantity / b.packing) *
(ti.quantity / b.packing) *
buy_getVolume(b.id)
) / (vc.trolleyM3 * 1000000)
), 1),
) / vc.palletM3 / 1000000, 1) bought,
vDated
FROM entry e
JOIN travel t ON t.id = e.travelFk
JOIN warehouse w ON w.id = t.warehouseInFk
JOIN buy b ON b.entryFk = e.id
JOIN item i ON i.id = b.itemFk
JOIN itemType it ON it.id = i.typeFk
JOIN auctionConfig ac
FROM itemType it
JOIN item i ON i.typeFk = it.id
LEFT JOIN tmp.item ti ON ti.itemFk = i.id
JOIN itemCategory ic ON ic.id = it.categoryFk
JOIN warehouse wh ON wh.code = 'VNH'
JOIN tmp.buyUltimate bu ON bu.itemFk = i.id
AND bu.warehouseFk = wh.id
JOIN buy b ON b.id = bu.buyFk
JOIN volumeConfig vc
WHERE t.shipped = vDated
AND t.warehouseInFk = ac.warehouseFk
GROUP BY it.workerFk;
WHERE ic.display
GROUP BY it.workerFk
HAVING bought;
UPDATE stockBought s
JOIN tStockBought ts ON ts.workerFk = s.workerFk
@ -45,8 +51,12 @@ BEGIN
INSERT INTO stockBought (workerFk, reserve, dated)
SELECT ts.workerFk, ts.reserve, vDated
FROM tStockBought ts
WHERE ts.workerFk NOT IN (SELECT workerFk FROM stockBought WHERE dated = vDated);
WHERE ts.workerFk NOT IN (
SELECT workerFk
FROM stockBought
WHERE dated = vDated
);
DROP TEMPORARY TABLE tStockBought;
DROP TEMPORARY TABLE tStockBought, tmp.item, tmp.buyUltimate;
END$$
DELIMITER ;

View File

@ -23,7 +23,7 @@ BEGIN
WHERE dated = vDated
AND userFk = vWorker;
CALL stockTraslation(vDated);
CALL item_calculateStock(vDated);
INSERT INTO stockBuyed(userFk, buyed, `dated`, reserved, requested, description)
SELECT it.workerFk,

View File

@ -18,7 +18,7 @@ BEGIN
DELETE FROM stockBuyed WHERE dated = vDated;
CALL stockTraslation(vDated);
CALL item_calculateStock(vDated);
INSERT INTO stockBuyed(userFk, buyed, `dated`, description)
SELECT it.workerFk,

View File

@ -3,47 +3,41 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_mergeSales`(
vSelf INT
)
BEGIN
DECLARE vHasSalesToMerge BOOL;
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
ROLLBACK;
RESIGNAL;
END;
START TRANSACTION;
SELECT id INTO vSelf
FROM ticket
WHERE id = vSelf FOR UPDATE;
CREATE OR REPLACE TEMPORARY TABLE tSalesToPreserve
(PRIMARY KEY (id))
ENGINE = MEMORY
SELECT s.id, s.itemFk, SUM(s.quantity) newQuantity
SELECT s.id, s.itemFk, SUM(s.quantity) newQuantity
FROM sale s
JOIN item i ON i.id = s.itemFk
JOIN itemType it ON it.id = i.typeFk
WHERE s.ticketFk = vSelf
AND it.isMergeable
GROUP BY s.itemFk, s.price, s.discount
HAVING COUNT(*) > 1;
GROUP BY s.itemFk, s.price, s.discount;
SELECT COUNT(*) INTO vHasSalesToMerge
FROM tSalesToPreserve;
START TRANSACTION;
IF vHasSalesToMerge THEN
UPDATE sale s
JOIN tSalesToPreserve stp ON stp.id = s.id
SET s.quantity = newQuantity;
UPDATE sale s
JOIN tSalesToPreserve stp ON stp.id = s.id
SET s.quantity = newQuantity
WHERE s.ticketFk = vSelf;
DELETE s
FROM sale s
JOIN tSalesToPreserve stp ON stp.itemFk = s.itemFk
WHERE s.ticketFk = vSelf
AND s.id <> stp.id;
END IF;
DELETE s.*
FROM sale s
LEFT JOIN tSalesToPreserve stp ON stp.id = s.id
JOIN item i ON i.id = s.itemFk
JOIN itemType it ON it.id = i.typeFk
WHERE s.ticketFk = vSelf
AND stp.id IS NULL
AND it.isMergeable;
COMMIT;
DROP TEMPORARY TABLE tSalesToPreserve;
END$$
DELIMITER ;

View File

@ -4,7 +4,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setVolume`(
)
BEGIN
/**
* Update the volume ticket
* Update the volume ticket.
*
* @param vSelf Ticket id
*/

View File

@ -4,26 +4,36 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setVolumeIte
)
BEGIN
/**
* Update the volume tickets of item
* Update the volume of tickets containing the item.
*
* @param vSelf Ticket id
* @param vItemFk Item id
*/
CREATE OR REPLACE TEMPORARY TABLE tTicket
(PRIMARY KEY (id))
ENGINE = MEMORY
SELECT t.id, SUM(s.quantity * ic.cm3delivery / 1000000) volume
DECLARE vTicket INT;
DECLARE vDone BOOL;
DECLARE vTickets CURSOR FOR
SELECT DISTINCT t.id
FROM sale s
JOIN ticket t ON t.id = s.ticketFk
JOIN itemCost ic ON ic.itemFk = s.itemFk
AND ic.warehouseFk = t.warehouseFk
WHERE s.itemFk = vItemFk
AND t.shipped >= util.VN_CURDATE()
GROUP BY t.id;
AND t.refFk IS NULL;
UPDATE ticket t
JOIN tTicket tt ON tt.id = t.id
SET t.volume = tt.volume;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
DROP TEMPORARY TABLE tTicket;
OPEN vTickets;
l: LOOP
FETCH vTickets INTO vTicket;
IF vDone THEN
LEAVE l;
END IF;
CALL ticket_setVolume(vTicket);
END LOOP l;
CLOSE vTickets;
END$$
DELIMITER ;

View File

@ -5,84 +5,122 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_splitItemPacki
)
BEGIN
/**
* Clona y reparte las líneas de ventas de un ticket en funcion del tipo de empaquetado.
* Respeta el id de ticket inicial para el tipo de empaquetado propuesto.
* Clona y reparte las ventas de un ticket en funcion del tipo de empaquetado.
* Respeta el id inicial para el tipo propuesto.
*
* @param vSelf Id ticket
* @param vOriginalItemPackingTypeFk Tipo empaquetado al que se mantiene el ticket original
* @param vOriginalItemPackingTypeFk Tipo para el que se reserva el número de ticket original
* @return table tmp.ticketIPT(ticketFk, itemPackingTypeFk)
*/
DECLARE vDone INT DEFAULT FALSE;
DECLARE vHasItemPackingType BOOL;
DECLARE vItemPackingTypeFk INT;
DECLARE vItemPackingTypeFk VARCHAR(1) DEFAULT 'H';
DECLARE vNewTicketFk INT;
DECLARE vPackingTypesToSplit INT;
DECLARE vDone INT DEFAULT FALSE;
DECLARE vItemPackingTypes CURSOR FOR
SELECT DISTINCT itemPackingTypeFk
FROM tSalesToMove;
DECLARE vSaleGroup CURSOR FOR
SELECT itemPackingTypeFk
FROM tSaleGroup
WHERE itemPackingTypeFk IS NOT NULL
ORDER BY (itemPackingTypeFk = vOriginalItemPackingTypeFk) DESC;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
SELECT COUNT(*) INTO vHasItemPackingType
FROM ticket t
JOIN sale s ON s.ticketFk = t.id
JOIN item i ON i.id = s.itemFk
WHERE t.id = vSelf
AND i.itemPackingTypeFk = vOriginalItemPackingTypeFk;
START TRANSACTION;
IF NOT vHasItemPackingType THEN
CALL util.throw('The ticket has not sales with the itemPackingType');
END IF;
SELECT id
FROM sale
WHERE ticketFk = vSelf
AND NOT quantity
FOR UPDATE;
CREATE OR REPLACE TEMPORARY TABLE tSalesToMove (
ticketFk INT,
saleFk INT,
itemPackingTypeFk INT
) ENGINE=MEMORY;
DELETE FROM sale
WHERE NOT quantity
AND ticketFk = vSelf;
INSERT INTO tSalesToMove (saleFk, itemPackingTypeFk)
SELECT s.id, i.itemPackingTypeFk
FROM ticket t
JOIN sale s ON s.ticketFk = t.id
JOIN item i ON i.id = s.itemFk
WHERE t.id = vSelf
AND i.itemPackingTypeFk <> vOriginalItemPackingTypeFk;
CREATE OR REPLACE TEMPORARY TABLE tSale
(PRIMARY KEY (id))
ENGINE = MEMORY
SELECT s.id, i.itemPackingTypeFk, IFNULL(sv.litros, 0) litros
FROM sale s
JOIN item i ON i.id = s.itemFk
LEFT JOIN saleVolume sv ON sv.saleFk = s.id
WHERE s.ticketFk = vSelf;
OPEN vItemPackingTypes;
CREATE OR REPLACE TEMPORARY TABLE tSaleGroup
ENGINE = MEMORY
SELECT itemPackingTypeFk, SUM(litros) totalLitros
FROM tSale
GROUP BY itemPackingTypeFk;
l: LOOP
SET vDone = FALSE;
FETCH vItemPackingTypes INTO vItemPackingTypeFk;
IF vDone THEN
LEAVE l;
END IF;
CALL ticket_Clone(vSelf, vNewTicketFk);
UPDATE tSalesToMove
SET ticketFk = vNewTicketFk
WHERE itemPackingTypeFk = vItemPackingTypeFk;
END LOOP;
CLOSE vItemPackingTypes;
UPDATE sale s
JOIN tSalesToMove stm ON stm.saleFk = s.id
SET s.ticketFk = stm.ticketFk
WHERE stm.ticketFk;
SELECT COUNT(*) INTO vPackingTypesToSplit
FROM tSaleGroup
WHERE itemPackingTypeFk IS NOT NULL;
CREATE OR REPLACE TEMPORARY TABLE tmp.ticketIPT(
ticketFk INT,
itemPackingTypeFk VARCHAR(1)
) ENGINE=MEMORY
SELECT ticketFk, itemPackingTypeFk
FROM tSalesToMove
GROUP BY ticketFk
UNION
SELECT vSelf, vOriginalItemPackingTypeFk;
) ENGINE = MEMORY;
DROP TEMPORARY TABLE tSalesToMove;
CASE vPackingTypesToSplit
WHEN 0 THEN
INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk)
VALUES(vSelf, vItemPackingTypeFk);
WHEN 1 THEN
INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk)
SELECT vSelf, itemPackingTypeFk
FROM tSaleGroup
WHERE itemPackingTypeFk IS NOT NULL;
ELSE
OPEN vSaleGroup;
FETCH vSaleGroup INTO vItemPackingTypeFk;
INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk)
VALUES(vSelf, vItemPackingTypeFk);
l: LOOP
SET vDone = FALSE;
FETCH vSaleGroup INTO vItemPackingTypeFk;
IF vDone THEN
LEAVE l;
END IF;
CALL ticket_Clone(vSelf, vNewTicketFk);
INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk)
VALUES(vNewTicketFk, vItemPackingTypeFk);
END LOOP;
CLOSE vSaleGroup;
SELECT s.id
FROM sale s
JOIN tSale ts ON ts.id = s.id
JOIN tmp.ticketIPT t ON t.itemPackingTypeFk = ts.itemPackingTypeFk
FOR UPDATE;
UPDATE sale s
JOIN tSale ts ON ts.id = s.id
JOIN tmp.ticketIPT t ON t.itemPackingTypeFk = ts.itemPackingTypeFk
SET s.ticketFk = t.ticketFk;
SELECT itemPackingTypeFk INTO vItemPackingTypeFk
FROM tSaleGroup sg
WHERE sg.itemPackingTypeFk IS NOT NULL
ORDER BY sg.itemPackingTypeFk
LIMIT 1;
UPDATE sale s
JOIN tSale ts ON ts.id = s.id
JOIN tmp.ticketIPT t ON t.itemPackingTypeFk = vItemPackingTypeFk
SET s.ticketFk = t.ticketFk
WHERE ts.itemPackingTypeFk IS NULL;
END CASE;
COMMIT;
DROP TEMPORARY TABLE
tSale,
tSaleGroup;
END$$
DELIMITER ;
DELIMITER ;

View File

@ -1,5 +1,7 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`worker_getHierarchy`(vUserFk INT)
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`worker_getHierarchy`(
vUserFk INT
)
BEGIN
/**
* Retorna una tabla temporal con los trabajadores que tiene
@ -12,15 +14,16 @@ BEGIN
(PRIMARY KEY (workerFk))
ENGINE = MEMORY
WITH RECURSIVE workerHierarchy AS (
SELECT id workerFk, bossFk, 0 depth
SELECT id workerFk, bossFk, 0 `depth`, CAST(id AS CHAR(255)) `path`
FROM vn.worker
WHERE id = vUserFk
UNION ALL
SELECT w.id, w.bossFk, wh.depth + 1
SELECT w.id, w.bossFk, wh.`depth` + 1, CONCAT(wh.`path`, ',', w.id)
FROM vn.worker w
JOIN workerHierarchy wh ON w.bossFk = wh.workerFk
WHERE NOT FIND_IN_SET(w.id, wh.`path`)
)
SELECT *
SELECT *
FROM workerHierarchy
ORDER BY depth, workerFk;
END$$

View File

@ -71,7 +71,10 @@ BEGIN
SET NEW.currencyFk = entry_getCurrency(NEW.currencyFk, NEW.supplierFk);
END IF;
IF NOT (NEW.travelFk <=> OLD.travelFk) OR NOT (NEW.currencyFk <=> OLD.currencyFk) THEN
IF NOT (NEW.travelFk <=> OLD.travelFk)
OR NOT (NEW.currencyFk <=> OLD.currencyFk)
OR NOT (NEW.supplierFk <=> OLD.supplierFk) THEN
SET NEW.commission = entry_getCommission(NEW.travelFk, NEW.currencyFk, NEW.supplierFk);
END IF;
END$$

View File

@ -13,4 +13,4 @@ FROM (
`vn`.`ticketState` `ts`
JOIN `vn`.`ticket` `t` ON(`t`.`id` = `ts`.`ticketFk`)
)
WHERE `t`.`shipped` BETWEEN `util`.`VN_CURDATE`() AND `MIDNIGHT`(`util`.`VN_CURDATE`())
WHERE `t`.`shipped` BETWEEN `util`.`VN_CURDATE`() AND `util`.`midnight`()

View File

@ -0,0 +1,7 @@
RENAME TABLE vn.quadMindsApiConfig TO vn.quadmindsApiConfig;
ALTER TABLE vn.quadmindsApiConfig
ADD maxObjects INT NULL COMMENT 'Número máximo de objetos en el array por petición',
ADD `limit` INT NULL COMMENT 'Limite de objetos solicitados por petición',
ADD `orderTimeFrom` VARCHAR(5) NULL COMMENT 'Inicio de ventana horaria de pedido',
ADD `orderTimeTo` VARCHAR(5) NULL COMMENT 'Fin de ventana horaria de pedido';

View File

@ -0,0 +1,3 @@
UPDATE bs.nightTask
SET `procedure` = 'waste_addSalesLauncher'
WHERE `procedure` = 'waste_addSales';

View File

@ -0,0 +1,2 @@
-- Place your SQL code here
ALTER TABLE vn.packaging ADD IF NOT EXISTS isPlantTray BOOL DEFAULT FALSE NOT NULL COMMENT 'The container is a plant tray. Used to restrict the picking of full plant trays, to make previous picking.';

View File

@ -0,0 +1 @@
GRANT EXECUTE ON PROCEDURE bs.waste_addSales TO buyerBoss;

View File

@ -0,0 +1,2 @@
ALTER TABLE vn.packaging ADD IF NOT EXISTS isPlantTray BOOL DEFAULT FALSE NOT NULL
COMMENT 'The container is a plant tray. Used to restrict the picking of full plant trays, to make previous picking.';

View File

@ -0,0 +1 @@
DELETE FROM salix.ACL WHERE model = 'Worker' AND property = 'findById' AND principalId = 'employee';

View File

@ -0,0 +1,4 @@
UPDATE salix.ACL SET principalId = 'employee' WHERE model = 'Worker' AND principalId = '$subordinate';
INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId)
VALUES ('Worker', '__get__advancedSummary', 'READ', 'ALLOW', 'ROLE', 'hr'),
('Worker', '__get__summary', 'READ', 'ALLOW', 'ROLE', 'employee');

View File

@ -0,0 +1,3 @@
ALTER TABLE vn.`zone`
ADD COLUMN IF NOT EXISTS itemMaxLength int(11) NULL COMMENT 'Longitud maxima para articulos acostados que esa agencia puede transportar',
MODIFY COLUMN itemMaxSize int(11) DEFAULT NULL NULL COMMENT 'Altura maxima de los articulos que esa agencia puede transportar';

View File

@ -0,0 +1,3 @@
-- Place your SQL code here
ALTER TABLE vn.parking DROP FOREIGN KEY IF EXISTS parking_fk1;
ALTER TABLE vn.parking ADD CONSTRAINT parking_fk1 FOREIGN KEY (sectorFk) REFERENCES vn.sector(id) ON DELETE RESTRICT ON UPDATE CASCADE;

View File

@ -0,0 +1,3 @@
INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId)
VALUES ('Postcode','*','WRITE','ALLOW','ROLE','administrative');

View File

@ -0,0 +1,2 @@
ALTER TABLE vn.worker
CHANGE isF11Allowed isF11Allowed__ TINYINT(1) NOT NULL DEFAULT 0 COMMENT '@deprecated 2024-09-22';

View File

@ -0,0 +1,6 @@
INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId)
VALUES ('Province','*','WRITE','ALLOW','ROLE','administrative');
INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId)
VALUES ('Town','*','WRITE','ALLOW','ROLE','administrative');

View File

@ -0,0 +1,31 @@
-- vn.priceDelta definition
CREATE OR REPLACE TABLE vn.priceDelta (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`itemTypeFk` smallint(5) unsigned NOT NULL,
`minSize` int(10) unsigned DEFAULT NULL COMMENT 'Minimum item.size',
`maxSize` int(10) unsigned DEFAULT NULL COMMENT 'Maximum item.size',
`inkFk` varchar(3) DEFAULT NULL,
`originFk` tinyint(2) unsigned DEFAULT NULL,
`producerFk` mediumint(3) unsigned DEFAULT NULL,
`fromDated` date DEFAULT NULL,
`toDated` date DEFAULT NULL,
`absIncreasing` decimal(10,3) DEFAULT NULL COMMENT 'Absolute increasing of final price',
`ratIncreasing` int(11) DEFAULT NULL COMMENT 'Increasing ratio for the cost price',
`warehouseFk` smallint(6) unsigned NOT NULL,
`created` timestamp NOT NULL DEFAULT current_timestamp(),
`editorFk` int(10) unsigned DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `priceDelta_itemType_FK` (`itemTypeFk`),
KEY `priceDelta_ink_FK` (`inkFk`),
KEY `priceDelta_producer_FK` (`producerFk`),
KEY `priceDelta_warehouse_FK` (`warehouseFk`),
KEY `priceDelta_worker_FK` (`editorFk`),
CONSTRAINT `priceDelta_ink_FK` FOREIGN KEY (`inkFk`) REFERENCES `ink` (`id`) ON UPDATE CASCADE,
CONSTRAINT `priceDelta_itemType_FK` FOREIGN KEY (`itemTypeFk`) REFERENCES `itemType` (`id`) ON UPDATE CASCADE,
CONSTRAINT `priceDelta_producer_FK` FOREIGN KEY (`producerFk`) REFERENCES `producer` (`id`) ON UPDATE CASCADE,
CONSTRAINT `priceDelta_warehouse_FK` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE,
CONSTRAINT `priceDelta_worker_FK` FOREIGN KEY (`editorFk`) REFERENCES `worker` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Defines the increasing o decreasing for ranges of items';
GRANT INSERT, SELECT, UPDATE, DELETE ON TABLE vn.priceDelta TO buyer;

View File

@ -0,0 +1,32 @@
-- Place your SQL code here
-- vn.priceDelta definition
CREATE OR REPLACE TABLE vn.priceDelta (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`itemTypeFk` smallint(5) unsigned NOT NULL,
`minSize` int(10) unsigned DEFAULT NULL COMMENT 'Minimum item.size',
`maxSize` int(10) unsigned DEFAULT NULL COMMENT 'Maximum item.size',
`inkFk` varchar(3) DEFAULT NULL,
`originFk` tinyint(2) unsigned DEFAULT NULL,
`producerFk` mediumint(3) unsigned DEFAULT NULL,
`fromDated` date DEFAULT NULL,
`toDated` date DEFAULT NULL,
`absIncreasing` decimal(10,3) DEFAULT NULL COMMENT 'Absolute increasing of final price',
`ratIncreasing` int(11) DEFAULT NULL COMMENT 'Increasing ratio for the cost price',
`warehouseFk` smallint(6) unsigned NOT NULL,
`created` timestamp NOT NULL DEFAULT current_timestamp(),
`editorFk` int(10) unsigned DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `priceDelta_itemType_FK` (`itemTypeFk`),
KEY `priceDelta_ink_FK` (`inkFk`),
KEY `priceDelta_producer_FK` (`producerFk`),
KEY `priceDelta_warehouse_FK` (`warehouseFk`),
KEY `priceDelta_worker_FK` (`editorFk`),
CONSTRAINT `priceDelta_ink_FK` FOREIGN KEY (`inkFk`) REFERENCES `ink` (`id`) ON UPDATE CASCADE,
CONSTRAINT `priceDelta_itemType_FK` FOREIGN KEY (`itemTypeFk`) REFERENCES `itemType` (`id`) ON UPDATE CASCADE,
CONSTRAINT `priceDelta_producer_FK` FOREIGN KEY (`producerFk`) REFERENCES `producer` (`id`) ON UPDATE CASCADE,
CONSTRAINT `priceDelta_warehouse_FK` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE,
CONSTRAINT `priceDelta_worker_FK` FOREIGN KEY (`editorFk`) REFERENCES `worker` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Defines the increasing o decreasing for ranges of items';
GRANT INSERT, SELECT, UPDATE, DELETE ON TABLE vn.priceDelta TO buyer;

View File

@ -19,7 +19,7 @@ describe('Ticket descriptor path', () => {
it('should count the amount of tickets in the turns section', async() => {
const result = await page.countElement(selectors.ticketsIndex.weeklyTicket);
expect(result).toEqual(5);
expect(result).toEqual(6);
});
it('should go back to the ticket index then search and access a ticket summary', async() => {
@ -106,7 +106,7 @@ describe('Ticket descriptor path', () => {
await page.doSearch();
const nResults = await page.countElement(selectors.ticketsIndex.searchWeeklyResult);
expect(nResults).toEqual(5);
expect(nResults).toEqual(6);
});
it('should update the agency then remove it afterwards', async() => {

View File

@ -1,12 +1,9 @@
const UserError = require('vn-loopback/util/user-error');
module.exports = async function(app) {
const models = app.models;
models.VnRole.registerResolver('$subordinate', async(role, ctx) => {
Object.assign(ctx, {req: {accessToken: {userId: ctx.accessToken.userId}}});
const isSubordinate = await models.Worker.isSubordinate(ctx, +ctx.modelId);
if (!isSubordinate) throw new UserError(`You don't have enough privileges`);
if (!ctx.accessToken) return false;
const httpCtx = {req: {accessToken: {userId: ctx.accessToken.userId}}};
return models.Worker.isSubordinate(httpCtx, +ctx.modelId);
});
};

View File

@ -1,4 +1,7 @@
{
"Account": {
"dataSource": "vn"
},
"AccountConfig": {
"dataSource": "vn"
},
@ -47,9 +50,6 @@
"SipConfig": {
"dataSource": "vn"
},
"Account": {
"dataSource": "vn"
},
"UserLog": {
"dataSource": "vn"
},

View File

@ -43,8 +43,14 @@ module.exports = Self => {
include: [{
relation: 'province',
scope: {
fields: ['id', 'name']
}
fields: ['id', 'name', 'countryFk'],
include: [
{
relation: 'country',
scope: {fields: ['id', 'name']},
},
],
},
}, {
relation: 'agencyMode',
scope: {

View File

@ -29,15 +29,13 @@ module.exports = Self => {
dated.setHours(0, 0, 0, 0);
today.setHours(0, 0, 0, 0);
if (dated.getTime() === today.getTime())
await models.StockBought.rawSql(`CALL vn.stockBought_calculate()`);
await models.StockBought.rawSql(`CALL vn.stockBought_calculate(?)`, [dated]);
const filter = {
where: {
dated: dated
},
where: {dated},
include: [
{
fields: ['workerFk', 'reserve', 'bought'],
relation: 'worker',
scope: {
include: [

View File

@ -11,6 +11,7 @@ module.exports = Self => {
arg: 'dated',
type: 'string',
description: 'The date to filter',
required: true,
}
],
returns: {
@ -24,35 +25,50 @@ module.exports = Self => {
});
Self.getStockBoughtDetail = async(workerFk, dated) => {
if (!dated) {
dated = Date.vnNew();
dated.setHours(0, 0, 0, 0);
const models = Self.app.models;
const myOptions = {};
let tx;
let result;
if (typeof options == 'object')
Object.assign(myOptions, options);
if (!myOptions.transaction) {
tx = await Self.beginTransaction({});
myOptions.transaction = tx;
}
try {
await models.StockBought.rawSql(`CALL vn.item_calculateStock(?)`, [dated], myOptions);
result = await Self.rawSql(
`SELECT b.entryFk entryFk,
i.id itemFk,
i.name itemName,
ti.quantity,
(ac.conversionCoefficient * (ti.quantity / b.packing) * buy_getVolume(b.id))
/ (vc.trolleyM3 * 1000000) volume,
b.packagingFk packagingFk,
b.packing
FROM tmp.item ti
JOIN item i ON i.id = ti.itemFk
JOIN itemType it ON i.typeFk = it.id
JOIN itemCategory ic ON ic.id = it.categoryFk
JOIN worker w ON w.id = it.workerFk
JOIN auctionConfig ac
JOIN tmp.buyUltimate bu ON bu.itemFk = i.id
AND bu.warehouseFk = ac.warehouseFk
JOIN buy b ON b.id = bu.buyFk
JOIN volumeConfig vc
WHERE ic.display
AND w.id = ?`,
[workerFk], myOptions
);
await Self.rawSql(`DROP TEMPORARY TABLE tmp.item, tmp.buyUltimate;`, [], myOptions);
if (tx) await tx.commit();
return result;
} catch (e) {
await tx.rollback();
throw e;
}
return Self.rawSql(
`SELECT e.id entryFk,
i.id itemFk,
i.longName itemName,
b.quantity,
ROUND((ac.conversionCoefficient *
(b.quantity / b.packing) *
buy_getVolume(b.id)
) / (vc.trolleyM3 * 1000000),
2
) volume,
b.packagingFk,
b.packing
FROM entry e
JOIN travel t ON t.id = e.travelFk
JOIN buy b ON b.entryFk = e.id
JOIN item i ON i.id = b.itemFk
JOIN itemType it ON it.id = i.typeFk
JOIN worker w ON w.id = it.workerFk
JOIN auctionConfig ac
JOIN volumeConfig vc
WHERE t.warehouseInFk = ac.warehouseFk
AND it.workerFk = ?
AND t.shipped = util.VN_CURDATE()`,
[workerFk]
);
};
};

View File

@ -83,8 +83,10 @@ module.exports = Self => {
const invoiceOutSerial = await Self.app.models.InvoiceOutSerial.findById(serial);
if (invoiceOutSerial?.taxAreaFk == 'WORLD') {
const address = await Self.app.models.Address.findById(addressId);
if (!address || !address.customsAgentFk || !address.incotermsFk)
throw new UserError('The address of the customer must have information about Incoterms and Customs Agent');
if (!address?.customsAgentFk || !address.incotermsFk) {
throw new UserError(
'The address of the customer must have information about Incoterms and Customs Agent');
}
}
return serial;

View File

@ -33,7 +33,7 @@ module.exports = Self => {
const [isParkingToReview] = await Self.rawSql(`
SELECT COUNT(p.id) parkingToReview
FROM vn.parking p
FROM vn.parking p
JOIN vn.sector s ON s.id = p.sectorFk
JOIN vn.productionConfig pc
WHERE p.code = ? AND s.code = pc.sectorToCode;`,
@ -59,11 +59,11 @@ module.exports = Self => {
JOIN vn.productionConfig pc
WHERE is2.shelvingFk <> ?
AND s.code = pc.sectorFromCode)
SELECT ti.itemFK, tis.shelvingFk
SELECT ti.itemFK, tis.shelvingFk
FROM tItemShelving ti
JOIN tItemInSector tis ON tis.itemFk = ti.itemFk
JOIN vn.productionConfig pc
WHERE ti.created + INTERVAL pc.itemOlderReviewHours HOUR < tis.created ;`,
WHERE ti.created + INTERVAL pc.itemOlderReviewHours HOUR < tis.created;`,
[shelvingFk, shelvingFk], myOptions);
return result;
};

View File

@ -1,6 +1,6 @@
const {models} = require('vn-loopback/server/server');
describe('item lastEntriesFilter()', () => {
it('should return one entry for the given item', async() => {
it('should return two entry for the given item', async() => {
const minDate = Date.vnNew();
minDate.setHours(0, 0, 0, 0);
const maxDate = Date.vnNew();
@ -13,7 +13,7 @@ describe('item lastEntriesFilter()', () => {
const filter = {where: {itemFk: 1, landed: {between: [minDate, maxDate]}}};
const result = await models.Item.lastEntriesFilter(filter, options);
expect(result.length).toEqual(1);
expect(result.length).toEqual(2);
await tx.rollback();
} catch (e) {
@ -22,7 +22,7 @@ describe('item lastEntriesFilter()', () => {
}
});
it('should return five entries for the given item', async() => {
it('should return six entries for the given item', async() => {
const minDate = Date.vnNew();
minDate.setHours(0, 0, 0, 0);
minDate.setMonth(minDate.getMonth() - 2, 1);
@ -37,7 +37,7 @@ describe('item lastEntriesFilter()', () => {
const filter = {where: {itemFk: 1, landed: {between: [minDate, maxDate]}}};
const result = await models.Item.lastEntriesFilter(filter, options);
expect(result.length).toEqual(5);
expect(result.length).toEqual(6);
await tx.rollback();
} catch (e) {

View File

@ -39,7 +39,7 @@ describe('SalesMonitor salesFilter()', () => {
const filter = {};
const result = await models.SalesMonitor.salesFilter(ctx, filter, options);
expect(result.length).toBeGreaterThan(10);
expect(result.length).toBeGreaterThan(9);
await tx.rollback();
} catch (e) {
@ -146,13 +146,20 @@ describe('SalesMonitor salesFilter()', () => {
try {
const options = {transaction: tx};
const alertLevel = await models.AlertLevel.findOne({
where: {code: 'FREE'},
options
});
const alertLevelFree = alertLevel.id;
const ctx = {req: {accessToken: {userId: 9}}, args: {pending: false}};
const filter = {order: 'alertLevel ASC'};
const result = await models.SalesMonitor.salesFilter(ctx, filter, options);
const firstRow = result[0];
expect(result.length).toEqual(15);
expect(firstRow.alertLevel).not.toEqual(0);
result.forEach(row => {
expect(row.alertLevel).toBeGreaterThan(alertLevelFree);
});
await tx.rollback();
} catch (e) {

View File

@ -39,6 +39,8 @@ module.exports = Self => {
const {reportMail} = agencyMode();
let user;
let account;
let userEmail;
ctx.args.recipients = reportMail ? reportMail.split(',').map(email => email.trim()) : [];
if (workerFk) {
user = await models.VnUser.findById(workerFk, {
@ -48,10 +50,17 @@ module.exports = Self => {
account = await models.Account.findById(workerFk);
}
if (user?.active && account) ctx.args.recipient = user.emailUser().email;
else ctx.args.recipient = reportMail;
if (user?.active && account)
userEmail = user.emailUser().email;
if (userEmail)
ctx.args.recipients.push(userEmail);
ctx.args.recipients = [...new Set(ctx.args.recipients)];
if (!ctx.args.recipients.length)
throw new UserError('An email is necessary');
if (!ctx.args.recipient) throw new UserError('An email is necessary');
return Self.sendTemplate(ctx, 'driver-route');
};
};

View File

@ -81,7 +81,7 @@ module.exports = Self => {
let stmts = [];
let stmt;
stmt = new ParameterizedSQL(
`SELECT
`SELECT
s.id,
s.name AS socialName,
s.nickname AS alias,
@ -92,10 +92,13 @@ module.exports = Self => {
s.payDay,
s.phone,
s.city,
s.countryFk,
c.name country,
pm.name AS payMethod,
pd.payDem AS payDem
FROM vn.supplier s
LEFT JOIN vn.payMethod pm ON pm.id = s.payMethodFk
LEFT JOIN vn.country c ON c.id = s.countryFk
LEFT JOIN vn.payDem pd ON pd.id = s.payDemFk`
);

View File

@ -38,13 +38,14 @@ module.exports = Self => {
Object.assign(myOptions, options);
const where = buildFilter(ctx.args, (param, value) => {
switch (param) {
case 'search':
return {or: [
{'t.id': value},
{'c.id': value},
{'c.name': {like: `%${value}%`}}
]};
if (param === 'search') {
return {
or: [
{'t.id': value},
{'c.id': value},
{'c.name': {like: `%${value}%`}}
]
};
}
});
@ -66,7 +67,7 @@ module.exports = Self => {
FROM ticketWeekly tw
JOIN ticket t ON t.id = tw.ticketFk
JOIN client c ON c.id = t.clientFk
JOIN account.user u ON u.id = c.salesPersonFk
LEFT JOIN account.user u ON u.id = c.salesPersonFk
JOIN warehouse wh ON wh.id = t.warehouseFk
LEFT JOIN agencyMode am ON am.id = tw.agencyModeFk`
);

View File

@ -13,11 +13,11 @@ describe('ticket-weekly filter()', () => {
const ctx = {req: {accessToken: {userId: authUserId}}, args: {filter: filter}};
const result = await models.TicketWeekly.filter(ctx, null, options);
const totalRecords = await models.TicketWeekly.count();
const firstRow = result[0];
expect(firstRow.ticketFk).toEqual(2);
expect(result.length).toEqual(4);
expect(result.length).toEqual(totalRecords);
await tx.rollback();
} catch (e) {

View File

@ -1,79 +0,0 @@
const closure = require('./closure');
module.exports = Self => {
Self.remoteMethodCtx('closeByAgency', {
description: 'Makes the closure process by agency mode',
accessType: 'WRITE',
accepts: [
{
arg: 'agencyModeFk',
type: ['number'],
required: true,
description: 'The agencies mode ids',
},
{
arg: 'warehouseFk',
type: 'number',
description: 'The ticket warehouse id',
required: true
},
{
arg: 'to',
type: 'date',
description: 'Max closure date',
required: true
}
],
returns: {
type: 'object',
root: true
},
http: {
path: `/close-by-agency`,
verb: 'POST'
}
});
Self.closeByAgency = async ctx => {
const args = ctx.args;
const tickets = await Self.rawSql(`
SELECT
t.id,
t.clientFk,
t.companyFk,
c.name clientName,
c.email recipient,
c.salesPersonFk,
c.isToBeMailed,
c.hasToInvoice,
co.hasDailyInvoice,
eu.email salesPersonEmail
FROM expedition e
JOIN ticket t ON t.id = e.ticketFk
JOIN ticketState ts ON ts.ticketFk = t.id
JOIN alertLevel al ON al.id = ts.alertLevel
JOIN client c ON c.id = t.clientFk
JOIN province p ON p.id = c.provinceFk
JOIN country co ON co.id = p.countryFk
LEFT JOIN account.emailUser eu ON eu.userFk = c.salesPersonFk
WHERE al.code = 'PACKED'
AND t.agencyModeFk IN(?)
AND t.warehouseFk = ?
AND DATE(t.shipped) BETWEEN DATE_ADD(?, INTERVAL -2 DAY)
AND util.dayEnd(?)
AND t.refFk IS NULL
GROUP BY e.ticketFk`, [
args.agencyModeFk,
args.warehouseFk,
args.to,
args.to
]);
await closure(Self, tickets);
return {
message: 'Success'
};
};
};

View File

@ -1,75 +0,0 @@
const closure = require('./closure');
const {Email} = require('vn-print');
module.exports = Self => {
Self.remoteMethodCtx('closeByRoute', {
description: 'Makes the closure process by route',
accessType: 'WRITE',
accepts: [
{
arg: 'routeFk',
type: 'number',
required: true,
description: 'The routes ids',
},
],
returns: {
type: 'object',
root: true
},
http: {
path: `/close-by-route`,
verb: 'POST'
}
});
Self.closeByRoute = async ctx => {
const args = ctx.args;
const tickets = await Self.rawSql(`
SELECT
t.id,
t.clientFk,
t.companyFk,
c.name clientName,
c.email recipient,
c.salesPersonFk,
c.isToBeMailed,
c.hasToInvoice,
co.hasDailyInvoice,
eu.email salesPersonEmail
FROM expedition e
JOIN ticket t ON t.id = e.ticketFk
JOIN ticketState ts ON ts.ticketFk = t.id
JOIN alertLevel al ON al.id = ts.alertLevel
JOIN client c ON c.id = t.clientFk
JOIN province p ON p.id = c.provinceFk
JOIN country co ON co.id = p.countryFk
LEFT JOIN account.emailUser eu ON eu.userFk = c.salesPersonFk
WHERE al.code = 'PACKED'
AND t.routeFk = ?
AND t.refFk IS NULL
GROUP BY e.ticketFk`, [args.routeFk]);
await closure(Self, tickets);
// Send route report to the agency
const [agencyMail] = await Self.rawSql(`
SELECT am.reportMail
FROM route r
JOIN agencyMode am ON am.id = r.agencyModeFk
WHERE r.id = ?`, [args.routeFk]);
if (agencyMail) {
const email = new Email('driver-route', {
id: args.routeFk,
recipient: agencyMail
});
await email.send();
}
return {
message: 'Success'
};
};
};

View File

@ -23,11 +23,25 @@ module.exports = Self => {
}
});
Self.closeByTicket = async ctx => {
Self.closeByTicket = async(ctx, options) => {
let tx;
const myOptions = {};
if (typeof options == 'object')
Object.assign(myOptions, options);
if (!myOptions.transaction) {
tx = await Self.beginTransaction({});
myOptions.transaction = tx;
}
const userId = ctx.req.accessToken.userId;
myOptions.userId = userId;
const args = ctx.args;
const tickets = await Self.rawSql(`
SELECT
SELECT
t.id,
t.clientFk,
t.companyFk,
@ -37,7 +51,8 @@ module.exports = Self => {
c.isToBeMailed,
c.hasToInvoice,
co.hasDailyInvoice,
eu.email salesPersonEmail
eu.email salesPersonEmail,
t.addressFk
FROM expedition e
JOIN ticket t ON t.id = e.ticketFk
JOIN ticketState ts ON ts.ticketFk = t.id
@ -49,9 +64,14 @@ module.exports = Self => {
WHERE al.code = 'PACKED'
AND t.id = ?
AND t.refFk IS NULL
GROUP BY e.ticketFk`, [args.id]);
GROUP BY e.ticketFk`,
[args.id],
myOptions);
await closure(Self, tickets);
await closure(ctx, Self, tickets, myOptions);
if (tx)
await tx.commit();
return {
message: 'Success'

View File

@ -1,13 +1,22 @@
/* eslint max-len: ["error", { "code": 150 }]*/
const Report = require('vn-print/core/report');
const Email = require('vn-print/core/email');
const smtp = require('vn-print/core/smtp');
const config = require('vn-print/core/config');
const storage = require('vn-print/core/storage');
module.exports = async function(ctx, Self, tickets, reqArgs = {}) {
module.exports = async function(ctx, Self, tickets, options) {
const userId = ctx.req.accessToken.userId;
const myOptions = {userId};
if (typeof options == 'object')
Object.assign(myOptions, options);
let tx;
if (!myOptions.transaction) {
tx = await Self.beginTransaction({});
myOptions.transaction = tx;
}
if (tickets.length == 0) return;
const failedtickets = [];
@ -17,7 +26,7 @@ module.exports = async function(ctx, Self, tickets, reqArgs = {}) {
await Self.rawSql(
`CALL vn.ticket_closeByTicket(?)`,
[ticket.id],
{userId}
myOptions
);
const [invoiceOut] = await Self.rawSql(`
@ -26,7 +35,7 @@ module.exports = async function(ctx, Self, tickets, reqArgs = {}) {
JOIN invoiceOut io ON io.ref = t.refFk
JOIN company cny ON cny.id = io.companyFk
WHERE t.id = ?
`, [ticket.id]);
`, [ticket.id], myOptions);
const mailOptions = {
overrideAttachments: true,
@ -63,7 +72,7 @@ module.exports = async function(ctx, Self, tickets, reqArgs = {}) {
await Self.rawSql(
'UPDATE invoiceOut SET hasPdf = true WHERE id = ?',
[invoiceOut.id],
{userId},
myOptions
);
if (isToBeMailed) {
@ -108,7 +117,9 @@ module.exports = async function(ctx, Self, tickets, reqArgs = {}) {
WHERE t.clientFk = ?
AND NOT t.isDeleted
AND c.isVies
`, [ticket.clientFk]);
`,
[ticket.clientFk],
myOptions);
if (firstOrder == 1) {
const args = {
@ -127,20 +138,22 @@ module.exports = async function(ctx, Self, tickets, reqArgs = {}) {
SELECT id
FROM sample
WHERE code = 'incoterms-authorization'
`);
`,
null,
myOptions);
await Self.rawSql(`
INSERT INTO clientSample (clientFk, typeFk, companyFk) VALUES(?, ?, ?)
`, [ticket.clientFk, sample.id, ticket.companyFk], {userId});
`,
[ticket.clientFk, sample.id, ticket.companyFk],
myOptions);
}
} catch (error) {
// Domain not found
if (error.responseCode == 450) {
await invalidEmail(ticket);
continue;
}
// Save tickets on a list of failed ids
failedtickets.push({
id: ticket.id,
stacktrace: error,
@ -148,7 +161,6 @@ module.exports = async function(ctx, Self, tickets, reqArgs = {}) {
}
}
// Send email with failed tickets
if (failedtickets.length > 0) {
let body = 'This following tickets have failed:<br/><br/>';
@ -164,11 +176,14 @@ module.exports = async function(ctx, Self, tickets, reqArgs = {}) {
}).catch(err => console.error(err));
}
if (tx)
await tx.commit();
async function invalidEmail(ticket) {
await Self.rawSql(
`UPDATE client SET email = NULL WHERE id = ?`,
[ticket.clientFk],
{userId},
myOptions
);
const body = `No se ha podido enviar el albarán <strong>${ticket.id}</strong>

View File

@ -76,7 +76,8 @@ module.exports = Self => {
{
arg: 'myTeam',
type: 'boolean',
description: `Whether to show only tickets for the current logged user team (For now it shows only the current user tickets)`
description: `Whether to show only tickets for the current logged user team
(For now it shows only the current user tickets)`
},
{
arg: 'problems',
@ -258,7 +259,8 @@ module.exports = Self => {
MINUTE(z.hour) zoneMinute,
z.name zoneName,
z.id zoneFk,
CAST(z.hour AS CHAR) hour
CAST(z.hour AS CHAR) hour,
a.nickname addressNickname
FROM ticket t
LEFT JOIN invoiceOut io ON t.refFk = io.ref
LEFT JOIN zone z ON z.id = t.zoneFk

View File

@ -39,7 +39,7 @@ module.exports = Self => {
}, myOptions);
for (const ticketId of tickets) {
const ticket = await models.Ticket.findById(ticketId, myOptions);
const ticket = await models.Ticket.findById(ticketId, null, myOptions);
if (ticket.cmrFk) {
const hasDmsCmr = await Self.rawSql(`

View File

@ -0,0 +1,119 @@
const models = require('vn-loopback/server/server').models;
const LoopBackContext = require('loopback-context');
const smtp = require('vn-print/core/smtp');
const Email = require('vn-print/core/email');
const config = require('vn-print/core/config');
const closure = require('../closure');
describe('Ticket closure functionality', () => {
const userId = 19;
const companyFk = 442;
const activeCtx = {
getLocale: () => 'es',
accessToken: {userId: userId},
headers: {origin: 'http://localhost:5000'},
};
let ctx = {req: activeCtx};
let tx;
let options;
beforeEach(async() => {
LoopBackContext.getCurrentContext = () => ({
active: activeCtx,
});
tx = await models.Sale.beginTransaction({});
options = {transaction: tx};
});
afterEach(async() => {
await tx.rollback();
});
it('should successfully close a ticket and not invoiced', async() => {
const ticketId = 15;
const tickets = [{
id: ticketId,
clientFk: 1101,
companyFk,
addressFk: 1,
isToBeMailed: true,
recipient: 'some@email.com',
salesPersonFk: userId
}];
const ticketStateBefore = await models.TicketState.findById(ticketId, null, options);
await closure(ctx, models.Ticket, tickets, options);
const ticketStateAfter = await models.TicketState.findById(ticketId, null, options);
expect(ticketStateBefore.code).not.toBe(ticketStateAfter.code);
const ticketAfter = await models.TicketState.findById(ticketId, null, options);
expect(ticketAfter.refFk).toBeUndefined();
});
it('should send Incoterms authorization email on first order', async() => {
const ticketId = 37;
ctx.args = {
id: ticketId,
};
const ticket = await models.Ticket.findById(ticketId, null, options);
spyOn(Email.prototype, 'send').and.returnValue(Promise.resolve());
await models.Ticket.closeByTicket(ctx, options);
const sample = await models.Sample.findOne({
where: {code: 'incoterms-authorization'},
fields: ['id']
},
options);
const insertedSample = await models.ClientSample.findOne({
where: {
clientFk: ticket.clientFk,
typeFk: sample.id,
companyFk: companyFk
}
}, options);
expect(insertedSample.clientFk).toEqual(ticket.clientFk);
});
it('should report failed tickets and set client email to null', async() => {
const ticketId = 37;
const clientId = 1110;
const tickets = [{
id: ticketId,
clientFk: clientId,
companyFk,
addressFk: 1,
isToBeMailed: true,
recipient: 'invalid@example.com',
salesPersonFk: userId
}];
spyOn(Email.prototype, 'send').and.callFake(() => {
const error = new Error('Invalid email');
error.responseCode = 450;
return Promise.reject(error);
});
await closure(ctx, models.Ticket, tickets, options);
const client = await models.Client.findById(clientId, null, options);
expect(client.email).toBeNull();
const reportEmail = await smtp.send({
to: config.app.reportEmail,
subject: '[API] Nightly ticket closure report',
html: `This following tickets have failed:`
});
expect(reportEmail).not.toBeNull();
});
});

View File

@ -21,7 +21,7 @@ describe('ticket filter()', () => {
}
});
it('should return the tickets matching the problems on true', async() => {
it('should return at least one ticket matching the problems on true', async() => {
const tx = await models.Ticket.beginTransaction({});
try {
@ -41,7 +41,15 @@ describe('ticket filter()', () => {
const filter = {};
const result = await models.Ticket.filter(ctx, filter, options);
expect(result.length).toBeGreaterThan(3);
const hasProblemTicket = result.some(ticket =>
ticket.isFreezed === true ||
ticket.hasRisk === true ||
ticket.hasTicketRequest === true ||
(typeof ticket.hasRounding === 'string' && ticket.hasRounding.trim().length > 0) ||
(typeof ticket.itemShortage === 'string' && ticket.itemShortage.trim().length > 0)
);
expect(hasProblemTicket).toBe(true);
await tx.rollback();
} catch (e) {
@ -71,7 +79,13 @@ describe('ticket filter()', () => {
const filter = {};
const result = await models.Ticket.filter(ctx, filter, options);
expect(result.length).toEqual(11);
result.forEach(ticket => {
expect(ticket.isFreezed).toEqual(null);
expect(ticket.hasRisk).toEqual(null);
expect(ticket.hasTicketRequest).toEqual(null);
expect(ticket.itemShortage).toEqual(null);
expect(ticket.hasRounding).toEqual(null);
});
await tx.rollback();
} catch (e) {

View File

@ -65,7 +65,7 @@ describe('ticket isEditableOrThrow()', () => {
const options = {transaction: tx};
const ctx = {req: {accessToken: {userId: 1}}};
await models.Ticket.isEditableOrThrow(ctx, 15, options);
await models.Ticket.isEditableOrThrow(ctx, 17, options);
await tx.rollback();
} catch (e) {
error = e;

View File

@ -33,8 +33,6 @@ module.exports = function(Self) {
require('../methods/ticket/deliveryNoteCsvEmail')(Self);
require('../methods/ticket/closeAll')(Self);
require('../methods/ticket/closeByTicket')(Self);
require('../methods/ticket/closeByAgency')(Self);
require('../methods/ticket/closeByRoute')(Self);
require('../methods/ticket/getTicketsFuture')(Self);
require('../methods/ticket/merge')(Self);
require('../methods/ticket/getTicketsAdvance')(Self);

View File

@ -349,13 +349,6 @@
message="Recalculate components">
</vn-confirm>
<!-- Client balance popup-->
<vn-client-balance-create
vn-id="balance-create"
company-fk="$ctrl.vnConfig.companyFk"
client-fk="$ctrl.ticket.client.id">
</vn-client-balance-create>
<!-- Send pdf to tablet -->
<vn-confirm
vn-id="pdfToTablet"

View File

@ -79,6 +79,10 @@ module.exports = Self => {
arg: 'landingHour',
type: 'string',
description: 'The landing hour'
}, {
arg: 'daysOnward',
type: 'number',
description: 'The days onward'
}
],
returns: {
@ -92,8 +96,11 @@ module.exports = Self => {
});
Self.filter = async(ctx, filter) => {
let conn = Self.dataSource.connector;
let where = buildFilter(ctx.args, (param, value) => {
const conn = Self.dataSource.connector;
const today = Date.vnNew();
const future = Date.vnNew();
const where = buildFilter(ctx.args, (param, value) => {
switch (param) {
case 'search':
return /^\d+$/.test(value)
@ -109,6 +116,12 @@ module.exports = Self => {
return {'t.landed': {gte: value}};
case 'landedTo':
return {'t.landed': {lte: value}};
case 'daysOnward':
today.setHours(0, 0, 0, 0);
future.setDate(today.getDate() + value);
future.setHours(23, 59, 59, 999);
return {'t.landed': {between: [today, future]}};
case 'id':
case 'agencyModeFk':
case 'warehouseOutFk':

View File

@ -14,7 +14,6 @@ columns:
hasMachineryAuthorized: machinery authorized
seniority: seniority
isTodayRelative: today relative
isF11Allowed: F11 allowed
sectorFk: sector
maritalStatus: marital status
labelerFk: labeler

View File

@ -14,7 +14,6 @@ columns:
hasMachineryAuthorized: maquinaria autorizada
seniority: antigüedad
isTodayRelative: relativo hoy
isF11Allowed: F11 autorizado
sectorFk: sector
maritalStatus: estado civil
labelerFk: etiquetadora

View File

@ -55,9 +55,6 @@
"birth": {
"type": "date"
},
"isF11Allowed": {
"type": "boolean"
},
"sex": {
"type": "string"
},
@ -205,6 +202,74 @@
}
}
]
},
"summary": {
"include": [
{
"relation": "user",
"scope": {
"fields": [
"name",
"nickname",
"roleFk"
],
"include": [
{
"relation": "role",
"scope": {
"fields": [
"name"
]
}
},
{
"relation": "emailUser",
"scope": {
"fields": [
"email"
]
}
}
]
}
},
{
"relation": "department",
"scope": {
"include": {
"relation": "department",
"scope": {
"fields": [
"name"
]
}
}
}
},
{
"relation": "boss"
},
{
"relation": "client"
},
{
"relation": "sip"
}
]
},
"advancedSummary": {
"fields": [
"id",
"fiDueDate",
"sex",
"seniority",
"fi",
"isFreelance",
"isSsDiscounted",
"hasMachineryAuthorized",
"isDisable",
"birth"
]
}
}
}

View File

@ -42,6 +42,9 @@
},
"itemMaxSize": {
"type": "number"
},
"itemMaxLength": {
"type": "number"
}
},
"relations": {

View File

@ -394,4 +394,4 @@ localFixtures:
- zoneExclusionGeo
- zoneGeo
- zoneIncluded
- zoneWarehouse
- zoneWarehouse

View File

@ -1,6 +1,6 @@
{
"name": "salix-back",
"version": "24.40.0",
"version": "24.42.0",
"author": "Verdnatura Levante SL",
"description": "Salix backend",
"license": "GPL-3.0",

View File

@ -33,7 +33,7 @@ class Email extends Component {
const attachments = [];
const getAttachments = async(componentPath, files) => {
for (const file of files) {
const fileCopy = Object.assign({}, file);
const fileCopy = {...file};
const fileName = fileCopy.filename;
if (options.overrideAttachments && !fileName.includes('.png')) continue;

View File

@ -19,7 +19,7 @@
<div class="packing">{{previa.itemPackingTypeFk}}</div>
<div class="dated">{{previa.shippingHour}}:{{previa.shippingMinute}}</div>
</div>
<div class="size">{{previa.items}}</div>
<div class="size">{{previa.previousLines}}</div>
</div>
</div>
</div>