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

This commit is contained in:
Carlos Satorres 2024-10-01 06:30:02 +02:00
commit 1927a914e6
107 changed files with 5514 additions and 5292 deletions

View File

@ -38,7 +38,7 @@ module.exports = Self => {
{
arg: 'hasFile',
type: 'Boolean',
description: 'True if has an attached file'
description: 'True if has the original in paper'
},
{
arg: 'hasFileAttached',

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

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

View File

@ -15,9 +15,6 @@
"nickname": {
"type": "string",
"required": true
},
"display": {
"type": "boolean"
}
},
"acls": [

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

@ -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

@ -179,12 +179,12 @@ INSERT INTO `vn`.`country`(`id`, `name`, `isUeeMember`, `code`, `currencyFk`, `i
(30,'Canarias', 1, 'IC', 1, 24, 4, 1, 2);
INSERT INTO `vn`.`warehouse`(`id`, `name`, `code`, `isComparative`, `isInventory`, `hasAvailable`, `isManaged`, `hasDms`, `hasComission`, `countryFk`, `hasProduction`, `isOrigin`, `isDestiny`)
VALUES (1, 'Warehouse One', 'ALG', 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
VALUES
(1, 'Warehouse One', 'ALG', 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
(2, 'Warehouse Two', NULL, 1, 1, 1, 1, 0, 1, 13, 1, 1, 0),
(3, 'Warehouse Three', NULL, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0),
(4, 'Warehouse Four', NULL, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1),
(5, 'Warehouse Five', NULL, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0),
(6, 'Warehouse six', 'VNH', 1, 1, 1, 1, 0, 0, 1, 1, 0, 0),
(13, 'Inventory', 'inv', 1, 1, 1, 0, 0, 0, 1, 0, 0, 0),
(60, 'Algemesi', NULL, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0);
@ -1506,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
@ -1520,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);
@ -1543,7 +1544,7 @@ INSERT INTO `bs`.`waste`(`buyerFk`, `year`, `week`, `itemFk`, `itemTypeFk`, `sal
('103', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 6, 1, '186', '0', '51', '53.12', '56.20', '56.20', '56.20'),
('103', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 7, 1, '277', '0', '53.12', '56.20', '56.20', '56.20', '56.20');
INSERT INTO vn.buy(id,entryFk,itemFk,buyingValue,quantity,packagingFk,stickers,freightValue,packageValue,comissionValue,packing,grouping,groupingMode,location,price1,price2,price3,printedStickers,isChecked,isIgnored,weight,created)
INSERT INTO `vn`.`buy`(`id`,`entryFk`,`itemFk`,`buyingValue`,`quantity`,`packagingFk`,`stickers`,`freightValue`,`packageValue`,`comissionValue`,`packing`,`grouping`,`groupingMode`,`location`,`price1`,`price2`,`price3`, `printedStickers`,`isChecked`,`isIgnored`,`weight`, `created`)
VALUES
(1, 1, 1, 50, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 'packing', NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE() - INTERVAL 2 MONTH),
(2, 2, 1, 50, 100, 4, 1, 1.500, 1.500, 0.000, 1, 1, 'packing', NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE() - INTERVAL 1 MONTH),
@ -1559,8 +1560,7 @@ INSERT INTO vn.buy(id,entryFk,itemFk,buyingValue,quantity,packagingFk,stickers,f
(12, 6, 4, 1.25, 0, 3, 1, 2.500, 2.500, 0.000, 10, 10, 'grouping', NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE()),
(13, 7, 1, 50, 0, 3, 1, 2.000, 2.000, 0.000, 1, 1, 'packing', NULL, 0.00, 99.6, 99.4, 0, 1, 0, 4, util.VN_CURDATE()),
(14, 7, 2, 5, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 'grouping', NULL, 0.00, 7.30, 7.00, 0, 1, 0, 4, util.VN_CURDATE()),
(15, 7, 4, 1.25, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 'grouping', NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE()),
(16, 99,1,50.0000, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 'packing', NULL, 0.00, 99.60, 99.40, 0, 1, 0, 1.00, '2024-07-30 08:13:51.000');
(15, 7, 4, 1.25, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 'grouping', NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE());
INSERT INTO `hedera`.`order`(`id`, `date_send`, `customer_id`, `delivery_method_id`, `agency_id`, `address_id`, `company_id`, `note`, `source_app`, `confirmed`,`total`, `date_make`, `first_row_stamp`, `confirm_date`)
VALUES
@ -2522,14 +2522,15 @@ INSERT INTO `vn`.`thermograph`(`id`, `model`)
('138350-0', 'DISPOSABLE');
INSERT INTO `vn`.`travelThermograph`(`thermographFk`, `created`, `warehouseFk`, `travelFk`, `temperatureFk`, `result`, `dmsFk`)
INSERT INTO `vn`.`travelThermograph`
(`thermographFk`, `created`, `warehouseFk`, `travelFk`, `temperatureFk`, `minTemperature`, `maxTemperature`, `result`, `dmsFk`)
VALUES
('TMM190901395', util.VN_CURDATE(), 1, 1, 'WARM', 'Ok', NULL),
('TL.BBA85422', DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 2, 'COOL', 'Ok', NULL),
('TL.BBA85422', util.VN_CURDATE(), 2, 1, 'COOL', 'can not read the temperature', NULL),
('TZ1905012010', util.VN_CURDATE(), 1, 1, 'WARM', 'Temperature in range', 5),
('138350-0', DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 1, 'WARM', NULL, 5),
('138350-0', util.VN_CURDATE(), 1, NULL, 'COOL', NULL, NULL);
('TMM190901395', util.VN_CURDATE(), 1, 1, 'WARM', NULL, NULL, 'Ok', NULL),
('TL.BBA85422', DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 2, 'COOL', NULL, NULL, 'Ok', NULL),
('TL.BBA85422', util.VN_CURDATE(), 2, 1, 'COOL', NULL, NULL, 'can not read the temperature', NULL),
('TZ1905012010', util.VN_CURDATE(), 1, 1, 'WARM', NULL, NULL, 'Temperature in range', 5),
('138350-0', DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 1, 'WARM', 2, 12, NULL, 5),
('138350-0', util.VN_CURDATE(), 1, NULL, 'COOL', NULL, NULL, NULL, NULL);
REPLACE INTO `vn`.`incoterms`(`code`, `name`)
VALUES
@ -3186,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
@ -3937,37 +3938,43 @@ 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)
VALUES(35, 1.00, 1.00, '2001-01-01');
INSERT INTO vn.auctionConfig (id,conversionCoefficient,warehouseFk)
VALUES (1,0.6,6);
INSERT INTO vn.payrollComponent (id, name, isSalaryAgreed, isVariable, isException)
VALUES (1, 'Salario1', 1, 0, 0),
INSERT INTO vn.payrollComponent
(id, name, isSalaryAgreed, isVariable, isException)
VALUES
(1, 'Salario1', 1, 0, 0),
(2, 'Salario2', 1, 1, 0),
(3, 'Salario3', 1, 0, 1);
INSERT INTO vn.workerIncome (debit, credit, incomeTypeFk, paymentDate, workerFk, concept)
VALUES (1000.00, 900.00, 2, '2000-01-01', 1106, NULL),
INSERT INTO vn.workerIncome
(debit, credit, incomeTypeFk, paymentDate, workerFk, concept)
VALUES
(1000.00, 900.00, 2, '2000-01-01', 1106, NULL),
(1001.00, 800.00, 2, '2000-01-01', 1106, NULL);
INSERT INTO dipole.printer (id, description) VALUES(1, '');
INSERT INTO dipole.expedition_PrintOut (expeditionFk, ticketFk, addressFk, street, postalCode, city, shopName, isPrinted, created, printerFk, routeFk, parkingCode, truckName, clientFk, phone, province, agency, m3, workerCode, itemFk, quantity, longName, shelvingFk, comments)
VALUES(1, 1, 0, ' ', ' ', ' ', ' ', 0, '2001-01-01 00:00:00', 1, 0, ' ', ' ', 0, NULL, '', NULL, 0.000, NULL, 10, NULL, NULL, 'NCC', NULL);
INSERT INTO dipole.printer (id, description)
VALUES(1, '');
INSERT INTO vn.accountDetail (id, value, accountDetailTypeFk, supplierAccountFk)
VALUES (21, 'ES12345B12345678', 3, 241),
(35, 'ES12346B12345679', 3, 241);
INSERT INTO dipole.expedition_PrintOut (expeditionFk, ticketFk, addressFk, street, postalCode, city, shopName, isPrinted, created, printerFk, routeFk, parkingCode,
truckName, clientFk, phone, province, agency, m3, workerCode, itemFk, quantity, longName, shelvingFk, comments)
VALUES(1, 1, 0, ' ', ' ', ' ', ' ', 0, '2001-01-01 00:00:00', 1, 0, ' ', ' ', 0, NULL, '', NULL, 0.000, NULL, 10, NULL, NULL, 'NCC', NULL);
INSERT INTO vn.accountDetailType (id, description, code)
VALUES (1, 'IBAN', 'iban'),
(2, 'SWIFT', 'swift'),
(3, 'Referencia Remesas', 'remRef'),
(4, 'Referencia Transferencias', 'trnRef'),
(5, 'Referencia Nominas', 'payRef'),
(6, 'ABA', 'aba');
INSERT INTO vn.accountDetail
(id, value, accountDetailTypeFk, supplierAccountFk)
VALUES
(21, 'ES12345B12345678', 3, 241),
(35, 'ES12346B12345679', 3, 241);
INSERT INTO vn.accountDetailType
(id, description, code)
VALUES
(1, 'IBAN', 'iban'),
(2, 'SWIFT', 'swift'),
(3, 'Referencia Remesas', 'remRef'),
(4, 'Referencia Transferencias', 'trnRef'),
(5, 'Referencia Nominas', 'payRef'),
(6, 'ABA', 'aba');
INSERT IGNORE INTO ormConfig
SET id =1,

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,41 @@ 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)
LEFT JOIN zoneGeo zg ON zg.id = pd.zoneGeoFk
LEFT JOIN zoneGeo zg2 ON zg2.id = address_getGeo(vAddressFk)
WHERE (pd.fromDated IS NULL OR pd.fromDated <= vShipped)
AND (pd.toDated IS NULL OR pd.toDated >= vShipped)
AND (pd.zoneGeoFk IS NULL OR zg2.lft BETWEEN zg.lft AND zg.rgt)
GROUP BY itemFk;
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 +131,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 +339,7 @@ BEGIN
tmp.ticketComponentBase,
tmp.ticketComponentRate,
tmp.ticketComponentCopy,
tSpecialPrice;
tPriceDelta,
tSpecialPrice;
END$$
DELIMITER ;

View File

@ -1,8 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`clearShelvingList`(vShelvingFk VARCHAR(8))
BEGIN
UPDATE vn.itemShelving
SET visible = 0
WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk COLLATE utf8_unicode_ci;
END$$
DELIMITER ;

View File

@ -1,6 +1,6 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`collection_new`(
vUserFk INT,
vUserFk INT,
OUT vCollectionFk INT
)
BEGIN
@ -128,8 +128,9 @@ BEGIN
SELECT TRUE
FROM tmp.productionBuffer pb
JOIN state s ON s.id = pb.state
WHERE s.code = 'PICKER_DESIGNED'
AND pb.workerCode = vWorkerCode
WHERE (s.code = 'PICKER_DESIGNED'
AND pb.workerCode = vWorkerCode)
OR s.code = 'LAST_CALL'
) INTO vHasAssignedTickets;
-- Se dejan en la tabla tmp.productionBuffer sólo aquellos tickets adecuados
@ -138,8 +139,9 @@ BEGIN
DELETE pb
FROM tmp.productionBuffer pb
JOIN state s ON s.id = pb.state
WHERE s.code <> 'PICKER_DESIGNED'
OR pb.workerCode <> vWorkerCode;
WHERE (s.code <> 'PICKER_DESIGNED'
OR pb.workerCode <> vWorkerCode)
AND s.code <> 'LAST_CALL';
ELSE
DELETE pb
FROM tmp.productionBuffer pb
@ -172,27 +174,26 @@ BEGIN
END IF;
-- 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);
AND (pb.HH <> pb2.HH OR pb.mm <> pb2.mm);
END IF;
SELECT ticketFk INTO vFirstTicketFk
FROM tmp.productionBuffer
ORDER BY HH,
mm,
productionOrder DESC,
m3 DESC,
agency,
zona,
routeFk,
ticketFk
LIMIT 1;
OPEN vTickets;
l: LOOP
SET vDone = FALSE;
@ -246,7 +247,7 @@ BEGIN
SELECT wagon INTO vFreeWagonFk
FROM tTrain
GROUP BY wagon
HAVING SUM(IFNULL(ticketFk, 0)) = 0
HAVING COUNT(ticketFk) = 0
ORDER BY wagon
LIMIT 1;
@ -263,7 +264,7 @@ BEGIN
JOIN (SELECT wagon
FROM tTrain
GROUP BY wagon
HAVING SUM(IFNULL(ticketFk, 0)) = 0
HAVING COUNT(ticketFk) = 0
) sub ON sub.wagon = tt.wagon;
END IF;
END IF;
@ -323,4 +324,4 @@ BEGIN
tTrain,
tmp.productionBuffer;
END$$
DELIMITER ;
DELIMITER ;

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

@ -1,58 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelvingMakeFromDate`(IN `vShelvingFk` VARCHAR(8), IN `vBarcode` VARCHAR(22), IN `vQuantity` INT, IN `vPackagingFk` VARCHAR(10), IN `vGrouping` INT, IN `vPacking` INT, IN `vWarehouseFk` INT, `vCreated` VARCHAR(22))
BEGIN
DECLARE vItemFk INT;
SELECT vn.barcodeToItem(vBarcode) INTO vItemFk;
SELECT itemFk INTO vItemFk
FROM vn.buy b
WHERE b.id = vItemFk;
IF (SELECT COUNT(*) FROM vn.shelving WHERE code = vShelvingFk COLLATE utf8_unicode_ci) = 0 THEN
INSERT IGNORE INTO vn.parking(`code`) VALUES(vShelvingFk);
INSERT INTO vn.shelving(`code`, parkingFk)
SELECT vShelvingFk, id
FROM vn.parking
WHERE `code` = vShelvingFk COLLATE utf8_unicode_ci;
END IF;
IF (SELECT COUNT(*) FROM vn.itemShelving
WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk
AND itemFk = vItemFk
AND packing = vPacking) = 1 THEN
UPDATE vn.itemShelving
SET visible = visible+vQuantity,
created = vCreated
WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk
AND itemFk = vItemFk
AND packing = vPacking;
ELSE
CALL cache.last_buy_refresh(FALSE);
INSERT INTO itemShelving( itemFk,
shelvingFk,
visible,
created,
`grouping`,
packing,
packagingFk)
SELECT vItemFk,
vShelvingFk,
vQuantity,
vCreated,
IF(vGrouping = 0, IFNULL(b.packing, vPacking), vGrouping) `grouping`,
IF(vPacking = 0, b.packing, vPacking) packing,
IF(vPackagingFk = '', b.packagingFk, vPackagingFk) packaging
FROM vn.item i
LEFT JOIN cache.last_buy lb ON i.id = lb.item_id AND lb.warehouse_id = vWarehouseFk
LEFT JOIN vn.buy b ON b.id = lb.buy_id
WHERE i.id = vItemFk;
END IF;
END$$
DELIMITER ;

View File

@ -1,20 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelvingPlacementSupplyAdd`(vItemShelvingFk INT, vItemPlacementSupplyFk INT, vQuantity INT)
BEGIN
INSERT INTO vn.itemShelvingPlacementSupply( itemShelvingFk,
itemPlacementSupplyFk,
quantity,
userFk)
VALUES (vItemShelvingFk,
vItemPlacementSupplyFk,
vQuantity,
getUser());
UPDATE vn.itemShelving
SET visible = visible - vQuantity
WHERE id = vItemShelvingFk;
END$$
DELIMITER ;

View File

@ -18,7 +18,8 @@ BEGIN
getUser());
UPDATE itemShelving
SET visible = visible - vQuantity
SET visible = visible - vQuantity,
available = available - vQuantity
WHERE id = vItemShelvingFk;
UPDATE vn.saleTracking

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

@ -6,12 +6,12 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_selfCons
)
BEGIN
/**
* Leave the indicated amount on the shelf
* Leave the indicated amount on the shelve
* and create a ticket with the difference.
*
* @param vShelvingFk id of the shelf where the item is located.
* @param vShelvingFk id of the shelve where the item is located.
* @param vItemFk article of which the self-consumption ticket is to be created.
* @param vQuantity amount that will stay on the shelf
* @param vQuantity amount that will stay on the shelve
*/
DECLARE vVisible INT;
DECLARE vClientFk INT;
@ -80,7 +80,8 @@ BEGIN
WHERE id = vItemFk;
UPDATE itemShelving
SET visible = IF(id = vItemShelvingFk, vQuantity, 0)
SET visible = IF(id = vItemShelvingFk, vQuantity, 0),
available = IF(id = vItemShelvingFk, vQuantity, 0)
WHERE shelvingFk = vShelvingFk
AND itemFk = vItemFk;

View File

@ -31,7 +31,8 @@ BEGIN
IF vNewItemShelvingFk THEN
UPDATE itemShelving ish
JOIN itemShelving ish2 ON ish2.id = vItemShelvingFk
SET ish.visible = ish.visible + ish2.visible
SET ish.visible = ish.visible + ish2.visible,
ish.available = ish.available + ish2.available
WHERE ish.id = vNewItemShelvingFk;
DELETE FROM itemShelving

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

@ -303,7 +303,8 @@ BEGIN
WHERE id = vTargetItemShelvingFk;
ELSE
UPDATE itemShelving
SET visible = vCurrentVisible - vQuantity
SET visible = vCurrentVisible - vQuantity,
available = GREATEST(0, available - vQuantity)
WHERE id = vTargetItemShelvingFk;
END IF;

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

@ -15,13 +15,11 @@ proc: BEGIN
DECLARE vEndingDate DATETIME;
DECLARE vIsTodayRelative BOOLEAN;
SELECT util.dayEnd(util.VN_CURDATE()) + INTERVAL LEAST(vScopeDays, maxProductionScopeDays) DAY
INTO vEndingDate
FROM productionConfig;
SELECT isTodayRelative INTO vIsTodayRelative
FROM worker
WHERE id = getUser(); -- Cambiar por account.myUser_getId(), falta dar permisos
SELECT w.isTodayRelative, util.dayEnd(util.VN_CURDATE()) + INTERVAL LEAST(vScopeDays, pc.maxProductionScopeDays) DAY
INTO vIsTodayRelative,vEndingDate
FROM worker w
JOIN productionConfig pc
WHERE w.id = account.myUser_getId();
CALL prepareTicketList(util.yesterday(), vEndingDate);
@ -268,16 +266,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
AND pb.isOwn;
SET pb.hasPlantTray = TRUE
WHERE p.isPlantTray
AND s.quantity >= b.packing
AND pb.isOwn;
DROP TEMPORARY TABLE
tmp.productionTicket,

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,52 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`stockBought_calculate`()
BEGIN
/**
* Inserts the purchase volume per buyer
* into stockBought according to the current date.
*/
DECLARE vDated DATE;
SET vDated = util.VN_CURDATE();
CREATE OR REPLACE TEMPORARY TABLE tStockBought
SELECT workerFk, reserve
FROM stockBought
WHERE dated = vDated
AND reserve;
DELETE FROM stockBought WHERE dated = vDated;
INSERT INTO stockBought (workerFk, bought, dated)
SELECT it.workerFk,
ROUND(SUM(
(ac.conversionCoefficient *
(b.quantity / b.packing) *
buy_getVolume(b.id)
) / (vc.trolleyM3 * 1000000)
), 1),
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
JOIN volumeConfig vc
WHERE t.shipped = vDated
AND t.warehouseInFk = ac.warehouseFk
GROUP BY it.workerFk;
UPDATE stockBought s
JOIN tStockBought ts ON ts.workerFk = s.workerFk
SET s.reserve = ts.reserve
WHERE s.dated = vDated;
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);
DROP TEMPORARY TABLE tStockBought;
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,6 +3,12 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_mergeSales`(
vSelf INT
)
BEGIN
/**
* Para un ticket se agrupa las diferentes líneas de venta de un mismo artículo en una sola
* siempre y cuando tengan el mismo precio y dto.
*
* @param vSelf Id de ticket
*/
DECLARE vHasSalesToMerge BOOL;
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
@ -19,7 +25,7 @@ BEGIN
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
@ -28,8 +34,7 @@ BEGIN
GROUP BY s.itemFk, s.price, s.discount
HAVING COUNT(*) > 1;
SELECT COUNT(*) INTO vHasSalesToMerge
FROM tSalesToPreserve;
SELECT COUNT(*) INTO vHasSalesToMerge FROM tSalesToPreserve;
IF vHasSalesToMerge THEN
UPDATE sale s

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

@ -3,13 +3,13 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_splitItemPacki
vSelf INT,
vOriginalItemPackingTypeFk VARCHAR(1)
)
BEGIN
proc: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.
* Respeta el id de ticket original para el tipo de empaquetado propuesto.
*
* @param vSelf Id ticket
* @param vOriginalItemPackingTypeFk Tipo empaquetado al que se mantiene el ticket original
* @param vOriginalItemPackingTypeFk Tipo empaquetado que se mantiene el ticket original
* @return table tmp.ticketIPT(ticketFk, itemPackingTypeFk)
*/
DECLARE vDone INT DEFAULT FALSE;
@ -30,8 +30,14 @@ BEGIN
WHERE t.id = vSelf
AND i.itemPackingTypeFk = vOriginalItemPackingTypeFk;
CREATE OR REPLACE TEMPORARY TABLE tmp.ticketIPT(
ticketFk INT,
itemPackingTypeFk VARCHAR(1)
) ENGINE=MEMORY
SELECT vSelf ticketFk, vOriginalItemPackingTypeFk itemPackingTypeFk;
IF NOT vHasItemPackingType THEN
CALL util.throw('The ticket has not sales with the itemPackingType');
LEAVE proc;
END IF;
CREATE OR REPLACE TEMPORARY TABLE tSalesToMove (
@ -69,20 +75,15 @@ BEGIN
CLOSE vItemPackingTypes;
UPDATE sale s
JOIN tSalesToMove stm ON stm.saleFk = s.id
JOIN tSalesToMove stm ON stm.saleFk = s.id
SET s.ticketFk = stm.ticketFk
WHERE stm.ticketFk;
CREATE OR REPLACE TEMPORARY TABLE tmp.ticketIPT(
ticketFk INT,
itemPackingTypeFk VARCHAR(1)
) ENGINE=MEMORY
INSERT INTO tmp.ticketIPT (ticketFk, itemPackingTypeFk)
SELECT ticketFk, itemPackingTypeFk
FROM tSalesToMove
GROUP BY ticketFk
UNION
SELECT vSelf, vOriginalItemPackingTypeFk;
GROUP BY ticketFk;
DROP TEMPORARY TABLE tSalesToMove;
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

@ -0,0 +1,18 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemShelving_afterInsert`
AFTER INSERT ON `itemShelving`
FOR EACH ROW
BEGIN
INSERT INTO itemShelvingLog
SET itemShelvingFk = NEW.id,
workerFk = account.myUser_getId(),
accion = 'CREA REGISTRO',
itemFk = NEW.itemFk,
shelvingFk = NEW.shelvingFk,
visible = NEW.visible,
`grouping` = NEW.`grouping`,
packing = NEW.packing,
available = NEW.available;
END$$
DELIMITER ;

View File

@ -2,12 +2,10 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn`.`buyer`
AS SELECT DISTINCT `u`.`id` AS `userFk`,
`u`.`nickname` AS `nickname`,
`ic`.`display` AS `display`
`u`.`nickname` AS `nickname`
FROM (
`account`.`user` `u`
JOIN `vn`.`itemType` `it` ON(`it`.`workerFk` = `u`.`id`)
JOIN `vn`.`itemCategory` `ic` ON(`ic`.`id` = `it`.`categoryFk`)
)
WHERE `u`.`active` <> 0
ORDER BY `u`.`nickname`

View File

@ -13,6 +13,5 @@ AS SELECT `am`.`id` AS `Id_Agencia`,
`am`.`reportMail` AS `send_mail`,
`am`.`isActive` AS `tpv`,
`am`.`code` AS `code`,
`am`.`showAgencyName` AS `show_AgencyName`,
`am`.`isRiskFree` AS `isRiskFree`
FROM `vn`.`agencyMode` `am`

View File

@ -1,30 +0,0 @@
-- Place your SQL code here
-- vn.stockBought definition
CREATE TABLE IF NOT EXISTS vn.stockBought (
id INT UNSIGNED auto_increment NOT NULL,
workerFk int(10) unsigned NOT NULL,
bought decimal(10,2) NOT NULL COMMENT 'purchase volume in m3 for the day',
reserve decimal(10,2) NULL COMMENT 'reserved volume in m3 for the day',
dated DATE NOT NULL DEFAULT current_timestamp(),
CONSTRAINT stockBought_pk PRIMARY KEY (id),
CONSTRAINT stockBought_unique UNIQUE KEY (workerFk,dated),
CONSTRAINT stockBought_worker_FK FOREIGN KEY (workerFk) REFERENCES vn.worker(id)
)
ENGINE=InnoDB
DEFAULT CHARSET=utf8mb3
COLLATE=utf8mb3_unicode_ci;
INSERT IGNORE vn.stockBought (workerFk, bought, reserve, dated)
SELECT userFk, SUM(buyed), SUM(IFNULL(reserved,0)), dated
FROM vn.stockBuyed
WHERE userFk IS NOT NULL
AND buyed IS NOT NULL
GROUP BY userFk, dated;
INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId)
VALUES ('StockBought','*','READ','ALLOW','ROLE','buyer'),
('StockBought','*','WRITE','ALLOW','ROLE','buyer'),
('Buyer','*','READ','ALLOW','ROLE','buyer');

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,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,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,3 @@
ALTER TABLE `vn`.`travelThermograph`
ADD COLUMN `maxTemperature` DECIMAL(5,2) NULL AFTER `temperatureFk`,
ADD COLUMN `minTemperature` DECIMAL(5,2) NULL AFTER `maxTemperature`;

View File

@ -0,0 +1,2 @@
ALTER TABLE `vn`.`travelThermograph` DROP FOREIGN KEY travelThermographDmsFgn;
ALTER TABLE `vn`.`travelThermograph` ADD CONSTRAINT travelThermographDmsFgn FOREIGN KEY (dmsFk) REFERENCES vn.dms(id) ON DELETE CASCADE ON UPDATE CASCADE;

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

@ -0,0 +1,2 @@
ALTER TABLE vn.agencyMode
CHANGE IF EXISTS showAgencyName showAgencyName__ tinyint(1) DEFAULT 1 COMMENT '@deprecated 2024-09-24';

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

@ -0,0 +1 @@
ALTER TABLE dipole.expedition_PrintOut DROP COLUMN IF EXISTS isChecked;

View File

@ -0,0 +1,3 @@
-- Place your SQL code here
ALTER TABLE vn.priceDelta ADD IF NOT EXISTS zoneGeoFk int(11) NULL COMMENT 'Application area for the bonus component';
ALTER TABLE vn.priceDelta ADD CONSTRAINT priceDelta_zoneGeo_FK FOREIGN KEY IF NOT EXISTS (zoneGeoFk) REFERENCES vn.zoneGeo(id) ON DELETE RESTRICT ON UPDATE CASCADE;

View File

@ -1,64 +0,0 @@
import selectors from '../../helpers/selectors.js';
import getBrowser from '../../helpers/puppeteer';
describe('Travel thermograph path', () => {
const thermographName = '7H3-37H3RN4L-FL4M3';
let browser;
let page;
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('buyer', 'travel');
await page.write(selectors.travelIndex.generalSearchFilter, '3');
await page.keyboard.press('Enter');
await page.accessToSection('travel.card.thermograph.index');
});
afterAll(async() => {
await browser.close();
});
it('should reach the thermograph section', async() => {
await page.waitForState('travel.card.thermograph.index');
});
it('should click the add thermograph floating button', async() => {
await page.waitToClick(selectors.travelThermograph.add);
await page.waitForState('travel.card.thermograph.create');
});
it('should click on the add thermograph icon of the thermograph autocomplete', async() => {
await page.waitToClick(selectors.travelThermograph.addThermographIcon);
await page.write(selectors.travelThermograph.newThermographId, thermographName);
await page.autocompleteSearch(selectors.travelThermograph.newThermographModel, 'TEMPMATE');
await page.autocompleteSearch(selectors.travelThermograph.newThermographWarehouse, 'Warehouse Two');
await page.autocompleteSearch(selectors.travelThermograph.newThermographTemperature, 'Warm');
await page.waitToClick(selectors.travelThermograph.createThermographButton);
});
it('should select the file to upload', async() => {
let currentDir = process.cwd();
let filePath = `${currentDir}/e2e/assets/thermograph.jpeg`;
const [fileChooser] = await Promise.all([
page.waitForFileChooser(),
page.waitToClick(selectors.travelThermograph.uploadIcon)
]);
await fileChooser.accept([filePath]);
await page.waitToClick(selectors.travelThermograph.upload);
const message = await page.waitForSnackbar();
const state = await page.getState();
expect(message.text).toContain('Data saved!');
expect(state).toBe('travel.card.thermograph.index');
});
it('should check everything was saved correctly', async() => {
const result = await page.waitToGetProperty(selectors.travelThermograph.createdThermograph, 'innerText');
expect(result).toContain(thermographName);
});
});

View File

@ -57,7 +57,7 @@ export default class App {
getUrl(route, appName = 'lilium') {
const index = window.location.hash.indexOf(route.toLowerCase());
const newRoute = index < 0 ? route : window.location.hash.substring(index);
let newRoute = index < 0 ? route : window.location.hash.substring(index);
const env = process.env.NODE_ENV;
const filter = {
where: {and: [
@ -66,6 +66,11 @@ export default class App {
]}
};
if (this.logger.$params.q)
newRoute = newRoute.concat(`?table=${this.logger.$params.q}`);
return this.logger.$http.get('Urls/findOne', {filter})
.then(res => {
if (res && res.data)

View File

@ -235,10 +235,10 @@
"Cannot add holidays on this day": "Cannot add holidays on this day",
"Cannot send mail": "Cannot send mail",
"CONSTRAINT `chkParkingCodeFormat` failed for `vn`.`parking`": "CONSTRAINT `chkParkingCodeFormat` failed for `vn`.`parking`",
"This postcode already exists": "This postcode already exists",
"Original invoice not found": "Original invoice not found",
"There is already a tray with the same height": "There is already a tray with the same height",
"The height must be greater than 50cm": "The height must be greater than 50cm",
"The maximum height of the wagon is 200cm": "The maximum height of the wagon is 200cm",
"This postcode already exists": "This postcode already exists",
"This buyer has already made a reservation for this date": "This buyer has already made a reservation for this date"
}
"The quantity claimed cannot be greater than the quantity of the line": "The quantity claimed cannot be greater than the quantity of the line"
}

View File

@ -366,9 +366,11 @@
"The invoices have been created but the PDFs could not be generated": "Se ha facturado pero no se ha podido generar el PDF",
"It has been invoiced but the PDF of refund not be generated": "Se ha facturado pero no se ha podido generar el PDF del abono",
"Payment method is required": "El método de pago es obligatorio",
"Cannot send mail": "No se ha podido enviar el correo",
"Cannot send mail": "Não é possível enviar o email",
"CONSTRAINT `supplierAccountTooShort` failed for `vn`.`supplier`": "La cuenta debe tener exactamente 10 dígitos",
"The sale not exists in the item shelving": "La venta no existe en la estantería del artículo",
"The entry not have stickers": "La entrada no tiene etiquetas",
"Too many records": "Demasiados registros",
"Original invoice not found": "Factura original no encontrada",
"The entry has no lines or does not exist": "La entrada no tiene lineas o no existe",
"Weight already set": "El peso ya está establecido",
@ -377,6 +379,7 @@
"The height must be greater than 50cm": "La altura debe ser superior a 50cm",
"The maximum height of the wagon is 200cm": "La altura máxima es 200cm",
"The entry does not have stickers": "La entrada no tiene etiquetas",
"Too many records": "Demasiados registros",
"This buyer has already made a reservation for this date": "Este comprador ya ha hecho una reserva para esta fecha"
}
"This buyer has already made a reservation for this date": "Este comprador ya ha hecho una reserva para esta fecha",
"No valid travel thermograph found": "No se encontró un termógrafo válido",
"The quantity claimed cannot be greater than the quantity of the line": "La cantidad reclamada no puede ser mayor que la cantidad de la línea"
}

View File

@ -361,6 +361,6 @@
"The invoices have been created but the PDFs could not be generated": "La facture a été émise mais le PDF n'a pas pu être généré",
"It has been invoiced but the PDF of refund not be generated": "Il a été facturé mais le PDF de remboursement n'a pas été généré",
"Cannot send mail": "Impossible d'envoyer le mail",
"Original invoice not found": "Facture originale introuvable"
"Original invoice not found": "Facture originale introuvable",
"The quantity claimed cannot be greater than the quantity of the line": "Le montant réclamé ne peut pas être supérieur au montant de la ligne"
}

View File

@ -360,6 +360,7 @@
"It was not able to create the invoice": "Não foi possível criar a fatura",
"The invoices have been created but the PDFs could not be generated": "Foi faturado, mas o PDF não pôde ser gerado",
"It has been invoiced but the PDF of refund not be generated": "Foi faturado mas não foi gerado o PDF do reembolso",
"Original invoice not found": "Fatura original não encontrada"
"Original invoice not found": "Fatura original não encontrada",
"Cannot send mail": "Não é possível enviar o email",
"The quantity claimed cannot be greater than the quantity of the line": "O valor reclamado não pode ser superior ao valor da linha"
}

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,6 +1,5 @@
const ForbiddenError = require('vn-loopback/util/forbiddenError');
const UserError = require('vn-loopback/util/user-error');
module.exports = Self => {
Self.rewriteDbError(function(err) {

View File

@ -0,0 +1,55 @@
const models = require('vn-loopback/server/server').models;
const LoopBackContext = require('loopback-context');
describe('ClaimBeginning model()', () => {
const claimFk = 1;
const activeCtx = {
accessToken: {userId: 18},
headers: {origin: 'localhost:5000'},
__: () => {}
};
beforeEach(() => {
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
active: activeCtx
});
});
it('should change quantity claimed', async() => {
const tx = await models.ClaimBeginning.beginTransaction({});
let error;
try {
const options = {transaction: tx};
const claim = await models.ClaimBeginning.findOne({where: {claimFk}}, options);
const sale = await models.Sale.findById(claim.saleFk, {}, options);
await claim.updateAttribute('quantity', sale.quantity - 1, options);
await tx.rollback();
} catch (e) {
error = e;
await tx.rollback();
}
expect(error).toBeUndefined();
});
it('should throw error when quantity claimed is greater than quantity of the sale', async() => {
const tx = await models.ClaimBeginning.beginTransaction({});
let error;
try {
const options = {transaction: tx};
const claim = await models.ClaimBeginning.findOne({where: {claimFk}}, options);
const sale = await models.Sale.findById(claim.saleFk, {}, options);
await claim.updateAttribute('quantity', sale.quantity + 1, options);
await tx.rollback();
} catch (e) {
error = e;
await tx.rollback();
}
expect(error.toString()).toContain('The quantity claimed cannot be greater than the quantity of the line');
});
});

View File

@ -10,16 +10,21 @@ module.exports = Self => {
});
Self.observe('before save', async ctx => {
const options = ctx.options;
const models = Self.app.models;
const saleFk = ctx?.currentInstance?.saleFk || ctx?.instance?.saleFk;
const sale = await models.Sale.findById(saleFk, {fields: ['ticketFk', 'quantity']}, options);
if (ctx.isNewInstance) {
const models = Self.app.models;
const options = ctx.options;
const instance = ctx.instance;
const ticket = await models.Sale.findById(instance.saleFk, {fields: ['ticketFk']}, options);
const claim = await models.Claim.findById(instance.claimFk, {fields: ['ticketFk']}, options);
if (ticket.ticketFk != claim.ticketFk)
const claim = await models.Claim.findById(ctx.instance.claimFk, {fields: ['ticketFk']}, options);
if (sale.ticketFk != claim.ticketFk)
throw new UserError(`Cannot create a new claimBeginning from a different ticket`);
}
await claimIsEditable(ctx);
if (sale?.quantity && ctx.data?.quantity && ctx.data.quantity > sale?.quantity)
throw new UserError('The quantity claimed cannot be greater than the quantity of the line');
});
Self.observe('before delete', async ctx => {

View File

@ -52,7 +52,7 @@ module.exports = Self => {
await merger.add(new Uint8Array(pdfBuffer[0]));
}
if (!merger._doc) throw new UserError('The entry does not have stickers');
if (!merger._doc) throw new UserError('The entry not have stickers');
await Self.rawSql(`
UPDATE buy

View File

@ -39,7 +39,7 @@ describe('Entry filter()', () => {
const result = await models.Entry.filter(ctx, options);
expect(result.length).toEqual(12);
expect(result.length).toEqual(11);
await tx.rollback();
} catch (e) {
@ -131,7 +131,7 @@ describe('Entry filter()', () => {
const result = await models.Entry.filter(ctx, options);
expect(result.length).toEqual(11);
expect(result.length).toEqual(10);
await tx.rollback();
} catch (e) {

View File

@ -1,60 +0,0 @@
module.exports = Self => {
Self.remoteMethod('getStockBought', {
description: 'Returns the stock bought for a given date',
accessType: 'READ',
accepts: [{
arg: 'workerFk',
type: 'number',
description: 'The id for a buyer',
},
{
arg: 'dated',
type: 'date',
description: 'The date to filter',
}
],
returns: {
type: ['object'],
root: true
},
http: {
path: `/getStockBought`,
verb: 'GET'
}
});
Self.getStockBought = async(workerFk, dated = Date.vnNew()) => {
const models = Self.app.models;
const today = Date.vnNew();
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()`);
const filter = {
where: {
dated: dated
},
include: [
{
relation: 'worker',
scope: {
include: [
{
relation: 'user',
scope: {
fields: ['id', 'name']
}
}
]
}
}
]
};
if (workerFk) filter.where.workerFk = workerFk;
return models.StockBought.find(filter);
};
};

View File

@ -1,58 +0,0 @@
module.exports = Self => {
Self.remoteMethod('getStockBoughtDetail', {
description: 'Returns the detail of stock bought for a given date and a worker',
accessType: 'READ',
accepts: [{
arg: 'workerFk',
type: 'number',
description: 'The worker to filter',
required: true,
}, {
arg: 'dated',
type: 'string',
description: 'The date to filter',
}
],
returns: {
type: ['object'],
root: true
},
http: {
path: `/getStockBoughtDetail`,
verb: 'GET'
}
});
Self.getStockBoughtDetail = async(workerFk, dated) => {
if (!dated) {
dated = Date.vnNew();
dated.setHours(0, 0, 0, 0);
}
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

@ -25,8 +25,5 @@
},
"EntryType": {
"dataSource": "vn"
},
"StockBought": {
"dataSource": "vn"
}
}

View File

@ -1,10 +0,0 @@
const UserError = require('vn-loopback/util/user-error');
module.exports = Self => {
require('../methods/stock-bought/getStockBought')(Self);
require('../methods/stock-bought/getStockBoughtDetail')(Self);
Self.rewriteDbError(function(err) {
if (err.code === 'ER_DUP_ENTRY')
return new UserError(`This buyer has already made a reservation for this date`);
return err;
});
};

View File

@ -1,34 +0,0 @@
{
"name": "StockBought",
"base": "VnModel",
"options": {
"mysql": {
"table": "stockBought"
}
},
"properties": {
"id": {
"type": "number",
"id": true
},
"workerFk": {
"type": "number"
},
"bought": {
"type": "number"
},
"reserve": {
"type": "number"
},
"dated": {
"type": "date"
}
},
"relations": {
"worker": {
"type": "belongsTo",
"model": "Worker",
"foreignKey": "workerFk"
}
}
}

View File

@ -64,7 +64,7 @@ module.exports = Self => {
try {
const client = await models.Client.findById(args.clientId, {
fields: ['id', 'hasToInvoiceByAddress']
}, options);
}, myOptions);
if (client.hasToInvoiceByAddress) {
await Self.rawSql('CALL ticketToInvoiceByAddress(?, ?, ?, ?)', [
@ -72,13 +72,13 @@ module.exports = Self => {
args.maxShipped,
args.addressId,
args.companyFk
], options);
], myOptions);
} else {
await Self.rawSql('CALL invoiceFromClient(?, ?, ?)', [
args.maxShipped,
client.id,
args.companyFk
], options);
], myOptions);
}
const invoiceId = await models.Ticket.makeInvoice(
@ -87,7 +87,7 @@ module.exports = Self => {
args.companyFk,
args.invoiceDate,
null,
options
myOptions
);
if (tx) await tx.commit();

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

@ -38,9 +38,13 @@ module.exports = Self => {
const itemShelving = itemShelvingSale.itemShelving();
const quantity = itemShelving.visible + itemShelvingSale.quantity;
const available = itemShelving.available + itemShelvingSale.quantity;
await itemShelving.updateAttributes(
{visible: quantity},
{
visible: quantity,
available: available
},
myOptions
);
if (tx) await tx.commit();

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,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

@ -75,7 +75,11 @@ module.exports = Self => {
const itemShelving = await models.ItemShelving.findById(itemShelvingFk, null, myOptions);
await itemShelving.updateAttributes({visible: itemShelving.visible - quantity}, myOptions);
await itemShelving.updateAttributes(
{
visible: itemShelving.visible - quantity,
available: itemShelving.available - quantity
}, myOptions);
await Self.updateAll(
{saleFk},

View File

@ -67,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

@ -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

@ -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

@ -56,14 +56,16 @@ module.exports = Self => {
model: model
}, myOptions);
await Self.rawSql(`
INSERT INTO travelThermograph(thermographFk, warehouseFk, temperatureFk, created)
VALUES (?, ?, ?, ?)
`, [thermograph.id, warehouseId, temperatureFk, date], myOptions);
const travelThermograph = await models.TravelThermograph.create({
thermographFk: thermograph.id,
warehouseFk: warehouseId,
temperatureFk: temperatureFk,
created: date
}, myOptions);
if (tx) await tx.commit();
return thermograph;
return travelThermograph;
} catch (err) {
if (tx) await tx.rollback();
throw err;

View File

@ -6,47 +6,42 @@ describe('Termograph createThermograph()', () => {
const temperatureFk = 'COOL';
const warehouseId = 1;
const ctx = beforeAll.getCtx();
let tx;
beforeEach(async() => {
tx = await models.Thermograph.beginTransaction({});
});
afterEach(async() => {
await tx.rollback();
});
it(`should create a thermograph which is saved in both thermograph and travelThermograph`, async() => {
const tx = await models.Thermograph.beginTransaction({});
const options = {transaction: tx};
try {
const options = {transaction: tx};
const createdThermograph = await models.Thermograph.createThermograph(
ctx, thermographId, model, temperatureFk, warehouseId, options);
const createdThermograph = await models.Thermograph.createThermograph(ctx, thermographId, model, temperatureFk, warehouseId, options);
expect(createdThermograph.thermographFk).toEqual(thermographId);
expect(createdThermograph.id).toEqual(thermographId);
expect(createdThermograph.model).toEqual(model);
const createdTravelThermograph =
await models.TravelThermograph.findOne({where: {thermographFk: thermographId}}, options);
const createdTravelThermograpth = await models.TravelThermograph.findOne({where: {thermographFk: thermographId}}, options);
expect(createdTravelThermograpth.warehouseFk).toEqual(warehouseId);
expect(createdTravelThermograpth.temperatureFk).toEqual(temperatureFk);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
expect(createdTravelThermograph.warehouseFk).toEqual(warehouseId);
expect(createdTravelThermograph.temperatureFk).toEqual(temperatureFk);
});
it(`should throw an error when trying to created repeated thermograph`, async() => {
const tx = await models.Thermograph.beginTransaction({});
let error;
it(`should throw an error when trying to create a repeated thermograph`, async() => {
try {
const options = {transaction: tx};
await models.Thermograph.createThermograph(ctx, thermographId, model, temperatureFk, warehouseId, options);
await models.Thermograph.createThermograph(ctx, thermographId, model, temperatureFk, warehouseId, options);
await tx.rollback();
await models.Thermograph.createThermograph(
ctx, thermographId, model, temperatureFk, warehouseId, options);
await models.Thermograph.createThermograph(
ctx, thermographId, model, temperatureFk, warehouseId, options);
fail('Expected an error to be thrown when trying to create a repeated thermograph');
} catch (e) {
await tx.rollback();
error = e;
expect(e.message).toBe('This thermograph id already exists');
}
expect(error.message).toBe('This thermograph id already exists');
});
});

View File

@ -1,103 +0,0 @@
const UserError = require('vn-loopback/util/user-error');
module.exports = Self => {
Self.remoteMethodCtx('createThermograph', {
description: 'Creates a new travel thermograph',
accessType: 'WRITE',
accepts: [{
arg: 'id',
type: 'number',
description: 'The travel id',
http: {source: 'path'}
},
{
arg: 'thermographId',
type: 'string',
description: 'The thermograph id',
required: true
},
{
arg: 'state',
type: 'string',
required: true
},
{
arg: 'warehouseId',
type: 'number',
description: 'The warehouse id',
required: true
},
{
arg: 'companyId',
type: 'number',
description: 'The company id',
required: true
},
{
arg: 'dmsTypeId',
type: 'number',
description: 'The dms type id',
required: true
},
{
arg: 'reference',
type: 'string',
required: true
},
{
arg: 'description',
type: 'string',
required: true
}],
returns: {
type: 'object',
root: true
},
http: {
path: `/:id/createThermograph`,
verb: 'POST'
}
});
Self.createThermograph = async(ctx, id, thermographId, state, options) => {
const models = Self.app.models;
let tx;
const myOptions = {};
if (typeof options == 'object')
Object.assign(myOptions, options);
if (!myOptions.transaction) {
tx = await Self.beginTransaction({});
myOptions.transaction = tx;
}
try {
const travelThermograph = await models.TravelThermograph.findOne({
where: {
thermographFk: thermographId,
travelFk: null
}
}, myOptions);
if (!travelThermograph)
throw new UserError('No valid travel thermograph found');
const uploadedFiles = await models.Dms.uploadFile(ctx, myOptions);
const firstDms = uploadedFiles[0];
await travelThermograph.updateAttributes({
dmsFk: firstDms.id,
travelFk: id,
result: state
}, myOptions);
if (tx) await tx.commit();
return travelThermograph;
} catch (err) {
if (tx) await tx.rollback();
throw err;
}
};
};

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

@ -0,0 +1,131 @@
const UserError = require('vn-loopback/util/user-error');
module.exports = Self => {
Self.remoteMethodCtx('saveThermograph', {
description: 'Creates or updates a travel thermograph',
accessType: 'WRITE',
accepts: [{
arg: 'id',
type: 'number',
description: 'The travel id',
http: {source: 'path'}
},
{
arg: 'travelThermographFk',
type: 'number',
description: 'The travel thermograph id',
required: true
},
{
arg: 'state',
type: 'string',
required: true
},
{
arg: 'maxTemperature',
type: 'number',
description: 'The maximum temperature'
},
{
arg: 'minTemperature',
type: 'number',
description: 'The minimum temperature'
},
{
arg: 'temperatureFk',
type: 'string',
description: 'Range of temperature'
}, {
arg: 'warehouseId',
type: 'Number',
description: 'The warehouse id'
}, {
arg: 'companyId',
type: 'Number',
description: 'The company id'
}, {
arg: 'dmsTypeId',
type: 'Number',
description: 'The dms type id'
}, {
arg: 'reference',
type: 'String'
}, {
arg: 'description',
type: 'String'
}, {
arg: 'hasFileAttached',
type: 'Boolean',
description: 'True if has an attached file'
}],
returns: {type: 'object', root: true},
http: {path: `/:id/saveThermograph`, verb: 'POST'}
});
Self.saveThermograph = async(
ctx,
id,
travelThermographFk,
state,
maxTemperature,
minTemperature,
temperatureFk,
warehouseId,
companyId,
dmsTypeId,
reference,
description,
hasFileAttached,
options
) => {
const models = Self.app.models;
let tx;
const myOptions = {};
if (typeof options == 'object')
Object.assign(myOptions, options);
let dmsFk;
if (!myOptions.transaction) {
tx = await Self.beginTransaction({});
myOptions.transaction = tx;
}
try {
const travelThermograph = await models.TravelThermograph.findById(
travelThermographFk,
{fields: ['id', 'dmsFk', 'warehouseFk']},
myOptions
);
if (!travelThermograph)
throw new UserError('No valid travel thermograph found');
if (travelThermograph.dmsFk) {
await models.Dms.updateFile(ctx, travelThermograph.dmsFk, myOptions);
dmsFk = travelThermograph.dmsFk;
} else {
const uploadedFiles = await models.Dms.uploadFile(ctx, myOptions);
const firstDms = uploadedFiles[0];
dmsFk = firstDms.id;
}
await travelThermograph.updateAttributes({
dmsFk,
travelFk: id,
result: state,
maxTemperature,
minTemperature,
temperatureFk
}, myOptions);
if (tx) await tx.commit();
return travelThermograph;
} catch (err) {
if (tx) await tx.rollback();
throw err;
}
};
};

View File

@ -1,51 +0,0 @@
const models = require('vn-loopback/server/server').models;
describe('Travel createThermograph()', () => {
beforeAll.mockLoopBackContext();
const travelId = 3;
const currentUserId = 1102;
const thermographId = '138350-0';
const ctx = {req: {accessToken: {userId: currentUserId}}, args: {dmsTypeId: 1}};
it(`should set the travelFk and dmsFk properties to the travel thermograph`, async() => {
const tx = await models.Travel.beginTransaction({});
try {
const options = {transaction: tx};
spyOn(models.Dms, 'uploadFile').and.returnValue([{id: 5}]);
travelThermographBefore = await models.TravelThermograph.findOne({
where: {
thermographFk: thermographId,
travelFk: null
}
}, options);
await models.Travel.createThermograph(ctx, travelId, thermographId, options);
const travelThermographAfter = await models.TravelThermograph.findOne({
where: {
thermographFk: thermographId,
travelFk: travelId
}
}, options);
expect(models.Dms.uploadFile).toHaveBeenCalledWith(ctx, jasmine.any(Object));
expect(travelThermographBefore).toBeDefined();
expect(travelThermographBefore.thermographFk).toEqual(thermographId);
expect(travelThermographBefore.travelFk).toBeNull();
expect(travelThermographAfter).toBeDefined();
expect(travelThermographAfter.thermographFk).toEqual(thermographId);
expect(travelThermographAfter.travelFk).toEqual(travelId);
expect(travelThermographAfter.dmsFk).toEqual(5);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});

View File

@ -0,0 +1,69 @@
const models = require('vn-loopback/server/server').models;
describe('Thermograph saveThermograph()', () => {
const ctx = beforeAll.getCtx();
const travelFk = 1;
const thermographId = '138350-0';
const warehouseFk = '1';
const state = 'COMPLETED';
const maxTemperature = 30;
const minTemperature = 10;
const temperatureFk = 'COOL';
let tx;
let options;
beforeEach(async() => {
options = {transaction: tx};
tx = await models.Sale.beginTransaction({});
options.transaction = tx;
});
afterEach(async() => {
await tx.rollback();
});
it('should update an existing travel thermograph', async() => {
const dmsFk = 5;
spyOn(models.Dms, 'uploadFile').and.returnValue([{id: dmsFk}]);
const travelThermograph = await models.TravelThermograph.create({
travelFk,
thermographFk: thermographId,
temperatureFk,
warehouseFk,
}, options);
const updatedThermograph = await models.Travel.saveThermograph(
ctx,
travelFk,
travelThermograph.id,
state,
maxTemperature,
minTemperature,
temperatureFk,
null,
null,
null,
null,
null,
null, options
);
expect(updatedThermograph.result).toEqual(state);
expect(updatedThermograph.maxTemperature).toEqual(maxTemperature);
expect(updatedThermograph.minTemperature).toEqual(minTemperature);
expect(updatedThermograph.temperatureFk).toEqual(temperatureFk);
expect(updatedThermograph.dmsFk).toEqual(dmsFk);
});
it('should throw an error if no valid travel thermograph is found', async() => {
try {
await models.Travel.saveThermograph(
ctx, null, 'notExists', state, maxTemperature, minTemperature, temperatureFk, options
);
fail('Expected an error to be thrown when no valid travel thermograph is found');
} catch (e) {
expect(e.message).toBe('No valid travel thermograph found');
}
});
});

View File

@ -1,83 +0,0 @@
const UserError = require('vn-loopback/util/user-error');
module.exports = Self => {
Self.remoteMethodCtx('updateThermograph', {
description: 'Updates a travel thermograph',
accessType: 'WRITE',
accepts: [{
arg: 'id',
type: 'Number',
description: 'The travel id',
http: {source: 'path'}
}, {
arg: 'thermographId',
type: 'String',
description: 'The thermograph id',
required: true
}, {
arg: 'state',
type: 'String',
required: true
}, {
arg: 'warehouseId',
type: 'Number',
description: 'The warehouse id'
}, {
arg: 'companyId',
type: 'Number',
description: 'The company id'
}, {
arg: 'dmsTypeId',
type: 'Number',
description: 'The dms type id'
}, {
arg: 'reference',
type: 'String'
}, {
arg: 'description',
type: 'String'
}, {
arg: 'hasFileAttached',
type: 'Boolean',
description: 'True if has an attached file'
}],
returns: {
type: 'Object',
root: true
},
http: {
path: `/:id/updateThermograph`,
verb: 'POST'
}
});
Self.updateThermograph = async(ctx, id, thermographId, state) => {
const models = Self.app.models;
const tx = await Self.beginTransaction({});
try {
const options = {transaction: tx};
const travelThermograph = await models.TravelThermograph.findOne({
where: {
thermographFk: thermographId,
travelFk: id
}
}, options);
if (!travelThermograph)
throw new UserError('No valid travel thermograph found');
const dmsFk = travelThermograph.dmsFk;
await models.Dms.updateFile(ctx, dmsFk, options);
await travelThermograph.updateAttributes({
result: state
}, options);
await tx.commit();
return travelThermograph;
} catch (e) {
await tx.rollback();
throw e;
}
};
};

View File

@ -28,6 +28,14 @@
"warehouseFk": {
"type": "number",
"required": true
},
"maxTemperature": {
"type": "number",
"description": "Maximum temperature"
},
"minTemperature": {
"type": "number",
"description": "Minimum temperature"
}
},
"relations": {

View File

@ -4,9 +4,8 @@ module.exports = Self => {
require('../methods/travel/getTravel')(Self);
require('../methods/travel/getEntries')(Self);
require('../methods/travel/filter')(Self);
require('../methods/travel/createThermograph')(Self);
require('../methods/travel/deleteThermograph')(Self);
require('../methods/travel/updateThermograph')(Self);
require('../methods/travel/saveThermograph')(Self);
require('../methods/travel/extraCommunityFilter')(Self);
require('../methods/travel/getAverageDays')(Self);
require('../methods/travel/cloneWithEntries')(Self);

View File

@ -87,7 +87,7 @@ class Controller extends Section {
}
onSubmit() {
const query = `Travels/${this.travel.id}/createThermograph`;
const query = `Travels/${this.travel.id}/saveThermograph`;
const options = {
method: 'POST',
url: query,

View File

@ -34,7 +34,7 @@ class Controller extends Section {
const filter = encodeURIComponent(JSON.stringify(filterObj));
const path = `TravelThermographs/${this.$params.thermographId}?filter=${filter}`;
this.$http.get(path).then(res => {
const thermograph = res.data && res.data;
const thermograph = res.data;
this.thermograph = {
thermographId: thermograph.thermographFk,
state: thermograph.result,
@ -51,7 +51,7 @@ class Controller extends Section {
}
onSubmit() {
const query = `travels/${this.$params.id}/updateThermograph`;
const query = `travels/${this.$params.id}/saveThermograph`;
const options = {
method: 'POST',
url: query,
@ -62,8 +62,8 @@ class Controller extends Section {
transformRequest: files => {
const formData = new FormData();
for (let i = 0; i < files.length; i++)
formData.append(files[i].name, files[i]);
for (const element of files)
formData.append(element.name, element);
return formData;
},

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