feat: refs #6403 packingSite to productionConfig #2793
58
CHANGELOG.md
58
CHANGELOG.md
|
@ -1,3 +1,61 @@
|
||||||
|
# Version 24.32 - 2024-08-06
|
||||||
|
|
||||||
|
### Added 🆕
|
||||||
|
|
||||||
|
- chore: refs #7197 add supplierActivityFk filter by:jorgep
|
||||||
|
- feat checkExpeditionPrintOut refs #7751 by:sergiodt
|
||||||
|
- feat(defaulter_filter): add department by:alexm
|
||||||
|
- feat: redirect to lilium page not found by:alexm
|
||||||
|
- feat: refactor buyUltimate refs #7736 by:Carlos Andrés
|
||||||
|
- feat: refs #6403 add delete by:pablone
|
||||||
|
- feat: refs #7126 Added manaClaim calc by:guillermo
|
||||||
|
- feat: refs #7126 Refactor and added columns in bs.waste table & proc by:guillermo
|
||||||
|
- feat: refs #7197 filter by correcting by:jorgep
|
||||||
|
- feat: refs #7297 add new columns by:pablone
|
||||||
|
- feat: refs #7356 new parameters in sql for Weekly tickets front by:Jon
|
||||||
|
- feat: refs #7401 redirect lilium by:pablone
|
||||||
|
- feat: refs #7511 Fix tests by:guillermo
|
||||||
|
- feat: refs #7511 Rename to multiConfig tables by:guillermo
|
||||||
|
- feat: refs #7589 Added display (item_valuateInventory) by:guillermo
|
||||||
|
- feat: refs #7589 Added vItemTypeFk & vItemCategoryFk (item_valuateInventory) by:guillermo
|
||||||
|
- feat: refs #7681 Changes by:guillermo
|
||||||
|
- feat: refs #7681 Optimization and refactor by:guillermo
|
||||||
|
- feat: refs #7683 drop temporary table by:robert
|
||||||
|
- feat: refs #7683 productionControl by:robert
|
||||||
|
- feat: refs #7728 Added throw due date by:guillermo
|
||||||
|
- feat: refs #7740 Ticket before update added restriction by:guillermo
|
||||||
|
- feat(salix): #7648 Add field for endpoint as buyLabel report by:Javier Segarra
|
||||||
|
- feat(salix): #7648 remove white line by:Javier Segarra
|
||||||
|
- feat: tabla config dias margen vctos. refs #7728 by:Carlos Andrés
|
||||||
|
|
||||||
|
### Changed 📦
|
||||||
|
|
||||||
|
- eat: refactor buyUltimate refs #7736 by:Carlos Andrés
|
||||||
|
- feat: refactor buyUltimate refs #7736 by:Carlos Andrés
|
||||||
|
- feat: refs #7681 Optimization and refactor by:guillermo
|
||||||
|
- refactor: refs #7126 Requested changes by:guillermo
|
||||||
|
- refactor: refs #7511 Minor change by:guillermo
|
||||||
|
- refactor: refs #7640 Multipleinventory available by:guillermo
|
||||||
|
- refactor: refs #7681 Changes by:guillermo
|
||||||
|
- refactor: refs #7681 Requested changes by:guillermo
|
||||||
|
|
||||||
|
### Fixed 🛠️
|
||||||
|
|
||||||
|
- add prefix (hotFix_liliumRedirection) by:alexm
|
||||||
|
- fix(client_filter): add recovery by:alexm
|
||||||
|
- fix: defaulter filter correct sql (6943-fix_defaulter_filter) by:alexm
|
||||||
|
- fix(deletExpeditions): merge test → dev by:guillermo
|
||||||
|
- fix: refs #6403 fix mrw cancel shipment return type by:pablone
|
||||||
|
- fix: refs #7126 Added addressWaste type by:guillermo
|
||||||
|
- fix: refs #7126 Fix by:guillermo
|
||||||
|
- fix: refs #7126 Minor change by:guillermo
|
||||||
|
- fix: refs #7126 Primary key no unique data by:guillermo
|
||||||
|
- fix: refs #7126 Slow update by:guillermo
|
||||||
|
- fix: refs #7511 Minor change by:guillermo
|
||||||
|
- fix: refs #7546 Deleted insert util.binlogQueue by:guillermo
|
||||||
|
- fix: refs #7811 Variables pm2 by:guillermo
|
||||||
|
- fix: without path by:alexm
|
||||||
|
|
||||||
# Version 24.28 - 2024-07-09
|
# Version 24.28 - 2024-07-09
|
||||||
|
|
||||||
### Added 🆕
|
### Added 🆕
|
||||||
|
|
|
@ -20,13 +20,14 @@ module.exports = Self => {
|
||||||
if (typeof options == 'object')
|
if (typeof options == 'object')
|
||||||
Object.assign(myOptions, options);
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
|
const randStr = Math.random().toString(36).substring(3);
|
||||||
const result = await Self.rawSql(`
|
const result = await Self.rawSql(`
|
||||||
CALL vn.collection_assign(?, @vCollectionFk);
|
CALL vn.collection_assign(?, @vCollectionFk);
|
||||||
SELECT @vCollectionFk collectionFk
|
SELECT @vCollectionFk ?
|
||||||
`, [userId], myOptions);
|
`, [userId, randStr], myOptions);
|
||||||
|
|
||||||
// Por si entra en el SELECT FOR UPDATE y retorna un array más
|
// Por si entra en SELECT FOR UPDATE una o varias veces
|
||||||
const collectionFk = result[2]?.[0]?.collectionFk || result[3]?.[0]?.collectionFk;
|
const collectionFk = result.find(item => item[0]?.[randStr] !== undefined)?.[0]?.[randStr];
|
||||||
|
|
||||||
if (!collectionFk) throw new UserError('There are not picking tickets');
|
if (!collectionFk) throw new UserError('There are not picking tickets');
|
||||||
await Self.rawSql('CALL vn.collection_printSticker(?, NULL)', [collectionFk], myOptions);
|
await Self.rawSql('CALL vn.collection_printSticker(?, NULL)', [collectionFk], myOptions);
|
||||||
|
|
|
@ -57,8 +57,10 @@ module.exports = Self => {
|
||||||
ROW_NUMBER () OVER (PARTITION BY s.id ORDER BY pickingOrder) currentItemShelving,
|
ROW_NUMBER () OVER (PARTITION BY s.id ORDER BY pickingOrder) currentItemShelving,
|
||||||
COUNT(*) OVER (PARTITION BY s.id ORDER BY s.id) totalItemShelving,
|
COUNT(*) OVER (PARTITION BY s.id ORDER BY s.id) totalItemShelving,
|
||||||
sh.code,
|
sh.code,
|
||||||
IFNULL(p2.code, p.code) parkingCode,
|
p2.code parkingCode,
|
||||||
IFNULL(p2.pickingOrder, p.pickingOrder) pickingOrder,
|
p2.pickingOrder pickingOrder,
|
||||||
|
p.code parkingCodePrevia,
|
||||||
|
p.pickingOrder pickingOrderPrevia,
|
||||||
iss.id itemShelvingSaleFk,
|
iss.id itemShelvingSaleFk,
|
||||||
iss.isPicked
|
iss.isPicked
|
||||||
FROM ticketCollection tc
|
FROM ticketCollection tc
|
||||||
|
@ -95,8 +97,10 @@ module.exports = Self => {
|
||||||
ROW_NUMBER () OVER (PARTITION BY s.id ORDER BY p.pickingOrder),
|
ROW_NUMBER () OVER (PARTITION BY s.id ORDER BY p.pickingOrder),
|
||||||
COUNT(*) OVER (PARTITION BY s.id ORDER BY s.id) ,
|
COUNT(*) OVER (PARTITION BY s.id ORDER BY s.id) ,
|
||||||
sh.code,
|
sh.code,
|
||||||
IFNULL(p2.code, p.code),
|
p2.code,
|
||||||
IFNULL(p2.pickingOrder, p.pickingOrder),
|
p2.pickingOrder,
|
||||||
|
p.code,
|
||||||
|
p.pickingOrder,
|
||||||
iss.id itemShelvingSaleFk,
|
iss.id itemShelvingSaleFk,
|
||||||
iss.isPicked
|
iss.isPicked
|
||||||
FROM sectorCollection sc
|
FROM sectorCollection sc
|
||||||
|
|
|
@ -24,7 +24,7 @@ module.exports = Self => {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx, userId: ctx.req.accessToken.userId};
|
const options = {transaction: tx, userId: ctx.req.accessToken.userId};
|
||||||
const files = await Self.rawSql('SELECT name, checksum, keyValue FROM edi.fileConfig', null, options);
|
const files = await Self.rawSql('SELECT name, checksum, keyValue FROM edi.fileMultiConfig', null, options);
|
||||||
|
|
||||||
const updatableFiles = [];
|
const updatableFiles = [];
|
||||||
for (const file of files) {
|
for (const file of files) {
|
||||||
|
@ -54,7 +54,7 @@ module.exports = Self => {
|
||||||
|
|
||||||
const tables = await Self.rawSql(`
|
const tables = await Self.rawSql(`
|
||||||
SELECT fileName, toTable, file
|
SELECT fileName, toTable, file
|
||||||
FROM edi.tableConfig
|
FROM edi.tableMultiConfig
|
||||||
WHERE file IN (?)`, [fileNames], options);
|
WHERE file IN (?)`, [fileNames], options);
|
||||||
|
|
||||||
for (const table of tables) {
|
for (const table of tables) {
|
||||||
|
@ -85,9 +85,9 @@ module.exports = Self => {
|
||||||
for (const file of updatableFiles) {
|
for (const file of updatableFiles) {
|
||||||
console.log(`Updating file ${file.name} checksum...`);
|
console.log(`Updating file ${file.name} checksum...`);
|
||||||
await Self.rawSql(`
|
await Self.rawSql(`
|
||||||
UPDATE edi.fileConfig
|
UPDATE edi.fileMultiConfig
|
||||||
SET checksum = ?
|
SET checksum = ?
|
||||||
WHERE name = ?`,
|
WHERE name = ?`,
|
||||||
[file.checksum, file.name], options);
|
[file.checksum, file.name], options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,7 +228,7 @@ module.exports = Self => {
|
||||||
|
|
||||||
await Self.rawSql(sqlTemplate, [filePath], options);
|
await Self.rawSql(sqlTemplate, [filePath], options);
|
||||||
await Self.rawSql(`
|
await Self.rawSql(`
|
||||||
UPDATE edi.tableConfig
|
UPDATE edi.tableMultiConfig
|
||||||
SET updated = ?
|
SET updated = ?
|
||||||
WHERE fileName = ?
|
WHERE fileName = ?
|
||||||
`, [Date.vnNew(), baseName], options);
|
`, [Date.vnNew(), baseName], options);
|
||||||
|
|
|
@ -47,7 +47,7 @@ module.exports = Self => {
|
||||||
co.code countryCode,
|
co.code countryCode,
|
||||||
c.fi,
|
c.fi,
|
||||||
c.name clientName,
|
c.name clientName,
|
||||||
a.mobile,
|
IFNULL(a.mobile, c.mobile) mobile,
|
||||||
DATE_FORMAT(t.shipped, '%d/%m/%Y') created,
|
DATE_FORMAT(t.shipped, '%d/%m/%Y') created,
|
||||||
t.shipped,
|
t.shipped,
|
||||||
CONCAT( e.ticketFk, LPAD(e.counter, mc.counterWidth, '0')) reference,
|
CONCAT( e.ticketFk, LPAD(e.counter, mc.counterWidth, '0')) reference,
|
||||||
|
|
|
@ -11,13 +11,6 @@ module.exports = Self => {
|
||||||
arg: 'filter',
|
arg: 'filter',
|
||||||
type: 'object',
|
type: 'object',
|
||||||
description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string',
|
description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string',
|
||||||
http: {source: 'query'}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
arg: 'search',
|
|
||||||
type: 'string',
|
|
||||||
description: 'Value to filter',
|
|
||||||
http: {source: 'query'}
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
returns: {
|
returns: {
|
||||||
|
@ -29,13 +22,11 @@ module.exports = Self => {
|
||||||
verb: 'GET',
|
verb: 'GET',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
Self.filter = async(ctx, filter, options) => {
|
Self.filter = async(filter = {}, options) => {
|
||||||
const myOptions = {};
|
const myOptions = {};
|
||||||
if (typeof options == 'object')
|
if (typeof options == 'object')
|
||||||
Object.assign(myOptions, options);
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
filter = ctx?.filter ?? {};
|
|
||||||
|
|
||||||
const conn = Self.dataSource.connector;
|
const conn = Self.dataSource.connector;
|
||||||
const where = buildFilter(filter?.where, (param, value) => {
|
const where = buildFilter(filter?.where, (param, value) => {
|
||||||
switch (param) {
|
switch (param) {
|
||||||
|
@ -50,31 +41,33 @@ module.exports = Self => {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}) ?? {};
|
}) ?? {};
|
||||||
delete ctx.filter.where;
|
delete filter.where;
|
||||||
|
|
||||||
const stmts = [];
|
const stmts = [];
|
||||||
let stmt;
|
let stmt;
|
||||||
stmt = new ParameterizedSQL(`
|
stmt = new ParameterizedSQL(`
|
||||||
SELECT
|
SELECT
|
||||||
pc.townFk,
|
pc.townFk,
|
||||||
t.provinceFk,
|
t.provinceFk,
|
||||||
p.countryFk,
|
p.countryFk,
|
||||||
pc.code,
|
pc.code,
|
||||||
t.name as town,
|
t.name as town,
|
||||||
p.name as province,
|
p.name as province,
|
||||||
c.name country
|
c.name country
|
||||||
FROM
|
FROM
|
||||||
postCode pc
|
postCode pc
|
||||||
JOIN town t on t.id = pc.townFk
|
JOIN town t on t.id = pc.townFk
|
||||||
JOIN province p on p.id = t.provinceFk
|
JOIN province p on p.id = t.provinceFk
|
||||||
JOIN country c on c.id = p.countryFk
|
JOIN country c on c.id = p.countryFk
|
||||||
`);
|
`);
|
||||||
|
|
||||||
stmt.merge(conn.makeSuffix({where, ...ctx}));
|
stmt.merge(conn.makeSuffix({where}));
|
||||||
|
stmt.merge(conn.makeLimit(filter));
|
||||||
const itemsIndex = stmts.push(stmt) - 1;
|
const itemsIndex = stmts.push(stmt) - 1;
|
||||||
|
|
||||||
const sql = ParameterizedSQL.join(stmts, ';');
|
const sql = ParameterizedSQL.join(stmts, ';');
|
||||||
const result = await conn.executeStmt(sql, myOptions);
|
const result = await conn.executeStmt(sql, myOptions);
|
||||||
|
|
||||||
return itemsIndex === 0 ? result : result[itemsIndex];
|
return itemsIndex === 0 ? result : result[itemsIndex];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,12 +6,9 @@ describe('Postcode filter()', () => {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const ctx = {
|
const results = await models.Postcode.filter({
|
||||||
filter: {
|
|
||||||
},
|
|
||||||
limit: 1
|
limit: 1
|
||||||
};
|
}, options);
|
||||||
const results = await models.Postcode.filter(ctx, options);
|
|
||||||
|
|
||||||
expect(results.length).toEqual(1);
|
expect(results.length).toEqual(1);
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
|
@ -26,14 +23,11 @@ describe('Postcode filter()', () => {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const ctx = {
|
const results = await models.Postcode.filter({
|
||||||
filter: {
|
where: {
|
||||||
where: {
|
search: 46,
|
||||||
search: 46,
|
}
|
||||||
}
|
}, options);
|
||||||
},
|
|
||||||
};
|
|
||||||
const results = await models.Postcode.filter(ctx, options);
|
|
||||||
|
|
||||||
expect(results.length).toEqual(4);
|
expect(results.length).toEqual(4);
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
|
@ -48,14 +42,9 @@ describe('Postcode filter()', () => {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const ctx = {
|
const results = await models.Postcode.filter({where: {
|
||||||
filter: {
|
search: 'Alz',
|
||||||
where: {
|
}}, options);
|
||||||
search: 'Alz',
|
|
||||||
}
|
|
||||||
},
|
|
||||||
};
|
|
||||||
const results = await models.Postcode.filter(ctx, options);
|
|
||||||
|
|
||||||
expect(results.length).toEqual(1);
|
expect(results.length).toEqual(1);
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
|
@ -70,14 +59,9 @@ describe('Postcode filter()', () => {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const ctx = {
|
const results = await models.Postcode.filter({where: {
|
||||||
filter: {
|
search: 'one',
|
||||||
where: {
|
}}, options);
|
||||||
search: 'one',
|
|
||||||
}
|
|
||||||
},
|
|
||||||
};
|
|
||||||
const results = await models.Postcode.filter(ctx, options);
|
|
||||||
|
|
||||||
expect(results.length).toEqual(4);
|
expect(results.length).toEqual(4);
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
|
@ -92,14 +76,11 @@ describe('Postcode filter()', () => {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const ctx = {
|
const results = await models.Postcode.filter({
|
||||||
filter: {
|
where: {
|
||||||
where: {
|
search: 'Ec',
|
||||||
search: 'Ec',
|
}
|
||||||
}
|
}, options);
|
||||||
},
|
|
||||||
};
|
|
||||||
const results = await models.Postcode.filter(ctx, options);
|
|
||||||
|
|
||||||
expect(results.length).toEqual(1);
|
expect(results.length).toEqual(1);
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
"base": "VnModel",
|
"base": "VnModel",
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "salix.defaultViewConfig"
|
"table": "salix.defaultViewMultiConfig"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|
|
@ -14,6 +14,9 @@
|
||||||
},
|
},
|
||||||
"itemFk": {
|
"itemFk": {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
|
},
|
||||||
|
"isChecked": {
|
||||||
|
"type": "boolean"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -9,7 +9,8 @@
|
||||||
"properties": {
|
"properties": {
|
||||||
"code": {
|
"code": {
|
||||||
"id": true,
|
"id": true,
|
||||||
"type": "string"
|
"type": "string",
|
||||||
|
"required": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"relations": {
|
"relations": {
|
||||||
|
|
|
@ -12,7 +12,8 @@
|
||||||
"type": "number"
|
"type": "number"
|
||||||
},
|
},
|
||||||
"name": {
|
"name": {
|
||||||
"type": "string"
|
"type": "string",
|
||||||
|
"required": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"relations": {
|
"relations": {
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
"base": "VnModel",
|
"base": "VnModel",
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "userConfig"
|
"table": "userMultiConfig"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|
|
@ -2,6 +2,5 @@ apps:
|
||||||
- script: ./loopback/server/server.js
|
- script: ./loopback/server/server.js
|
||||||
name: salix-back
|
name: salix-back
|
||||||
instances: 1
|
instances: 1
|
||||||
max_restarts: 3
|
max_restarts: 0
|
||||||
restart_delay: 15000
|
|
||||||
node_args: --tls-min-v1.0 --openssl-legacy-provider
|
node_args: --tls-min-v1.0 --openssl-legacy-provider
|
||||||
|
|
|
@ -3,7 +3,7 @@ USE `util`;
|
||||||
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
|
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
|
||||||
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
|
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
|
||||||
|
|
||||||
INSERT INTO `version` VALUES ('vn-database','11154','04ff3e0cc79b00272d1ebbde7196292eab651c1d','2024-07-23 09:24:55','11163');
|
INSERT INTO `version` VALUES ('vn-database','11161','36dee872d62ba2421c05503f374f6b208c40ecfa','2024-08-06 07:53:56','11180');
|
||||||
|
|
||||||
INSERT INTO `versionLog` VALUES ('vn-database','10107','00-firstScript.sql','jenkins@10.0.2.69','2022-04-23 10:53:53',NULL,NULL);
|
INSERT INTO `versionLog` VALUES ('vn-database','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);
|
INSERT INTO `versionLog` VALUES ('vn-database','10112','00-firstScript.sql','jenkins@10.0.2.69','2022-05-09 09:14:53',NULL,NULL);
|
||||||
|
@ -822,6 +822,7 @@ INSERT INTO `versionLog` VALUES ('vn-database','11034','00-firstScript.sql','jen
|
||||||
INSERT INTO `versionLog` VALUES ('vn-database','11037','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:17',NULL,NULL);
|
INSERT INTO `versionLog` VALUES ('vn-database','11037','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:17',NULL,NULL);
|
||||||
INSERT INTO `versionLog` VALUES ('vn-database','11038','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:17',NULL,NULL);
|
INSERT INTO `versionLog` VALUES ('vn-database','11038','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:17',NULL,NULL);
|
||||||
INSERT INTO `versionLog` VALUES ('vn-database','11040','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:31',NULL,NULL);
|
INSERT INTO `versionLog` VALUES ('vn-database','11040','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:31',NULL,NULL);
|
||||||
|
INSERT INTO `versionLog` VALUES ('vn-database','11042','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-08-06 07:53:54',NULL,NULL);
|
||||||
INSERT INTO `versionLog` VALUES ('vn-database','11044','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:31',NULL,NULL);
|
INSERT INTO `versionLog` VALUES ('vn-database','11044','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:31',NULL,NULL);
|
||||||
INSERT INTO `versionLog` VALUES ('vn-database','11045','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-10 14:53:29',NULL,NULL);
|
INSERT INTO `versionLog` VALUES ('vn-database','11045','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-10 14:53:29',NULL,NULL);
|
||||||
INSERT INTO `versionLog` VALUES ('vn-database','11046','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:46',NULL,NULL);
|
INSERT INTO `versionLog` VALUES ('vn-database','11046','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:46',NULL,NULL);
|
||||||
|
@ -896,14 +897,22 @@ INSERT INTO `versionLog` VALUES ('vn-database','11138','00-firstScript.sql','jen
|
||||||
INSERT INTO `versionLog` VALUES ('vn-database','11139','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-07-08 10:58:01',NULL,NULL);
|
INSERT INTO `versionLog` VALUES ('vn-database','11139','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-07-08 10:58:01',NULL,NULL);
|
||||||
INSERT INTO `versionLog` VALUES ('vn-database','11140','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:23:34',NULL,NULL);
|
INSERT INTO `versionLog` VALUES ('vn-database','11140','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:23:34',NULL,NULL);
|
||||||
INSERT INTO `versionLog` VALUES ('vn-database','11145','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-09 13:55:46',NULL,NULL);
|
INSERT INTO `versionLog` VALUES ('vn-database','11145','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-09 13:55:46',NULL,NULL);
|
||||||
|
INSERT INTO `versionLog` VALUES ('vn-database','11146','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-08-06 07:53:54',NULL,NULL);
|
||||||
INSERT INTO `versionLog` VALUES ('vn-database','11149','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:23:35',NULL,NULL);
|
INSERT INTO `versionLog` VALUES ('vn-database','11149','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:23:35',NULL,NULL);
|
||||||
INSERT INTO `versionLog` VALUES ('vn-database','11150','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:23:35',NULL,NULL);
|
INSERT INTO `versionLog` VALUES ('vn-database','11150','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:23:35',NULL,NULL);
|
||||||
INSERT INTO `versionLog` VALUES ('vn-database','11152','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-16 09:06:11',NULL,NULL);
|
INSERT INTO `versionLog` VALUES ('vn-database','11152','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-16 09:06:11',NULL,NULL);
|
||||||
INSERT INTO `versionLog` VALUES ('vn-database','11154','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:23:35',NULL,NULL);
|
INSERT INTO `versionLog` VALUES ('vn-database','11154','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:23:35',NULL,NULL);
|
||||||
|
INSERT INTO `versionLog` VALUES ('vn-database','11155','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-08-06 07:53:54',NULL,NULL);
|
||||||
|
INSERT INTO `versionLog` VALUES ('vn-database','11156','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-08-06 07:53:54',NULL,NULL);
|
||||||
INSERT INTO `versionLog` VALUES ('vn-database','11157','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-16 13:11:00',NULL,NULL);
|
INSERT INTO `versionLog` VALUES ('vn-database','11157','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-16 13:11:00',NULL,NULL);
|
||||||
INSERT INTO `versionLog` VALUES ('vn-database','11158','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-07-17 17:06:30',NULL,NULL);
|
INSERT INTO `versionLog` VALUES ('vn-database','11158','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-07-17 17:06:30',NULL,NULL);
|
||||||
INSERT INTO `versionLog` VALUES ('vn-database','11159','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-18 17:23:32',NULL,NULL);
|
INSERT INTO `versionLog` VALUES ('vn-database','11159','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-18 17:23:32',NULL,NULL);
|
||||||
INSERT INTO `versionLog` VALUES ('vn-database','11160','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-07-18 13:46:16',NULL,NULL);
|
INSERT INTO `versionLog` VALUES ('vn-database','11160','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-07-18 13:46:16',NULL,NULL);
|
||||||
|
INSERT INTO `versionLog` VALUES ('vn-database','11161','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-08-06 07:53:54',NULL,NULL);
|
||||||
|
INSERT INTO `versionLog` VALUES ('vn-database','11164','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-07-23 11:03:16',NULL,NULL);
|
||||||
|
INSERT INTO `versionLog` VALUES ('vn-database','11168','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-25 08:58:34',NULL,NULL);
|
||||||
|
INSERT INTO `versionLog` VALUES ('vn-database','11169','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-25 12:38:13',NULL,NULL);
|
||||||
|
INSERT INTO `versionLog` VALUES ('vn-database','11177','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-07-30 12:42:28',NULL,NULL);
|
||||||
|
|
||||||
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
|
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
|
||||||
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
|
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
|
||||||
|
@ -2046,13 +2055,14 @@ INSERT INTO `ACL` VALUES (892,'WorkerIncome','*','*','ALLOW','ROLE','hr');
|
||||||
INSERT INTO `ACL` VALUES (893,'PayrollComponent','*','*','ALLOW','ROLE','hr');
|
INSERT INTO `ACL` VALUES (893,'PayrollComponent','*','*','ALLOW','ROLE','hr');
|
||||||
INSERT INTO `ACL` VALUES (894,'Worker','__get__incomes','*','ALLOW','ROLE','hr');
|
INSERT INTO `ACL` VALUES (894,'Worker','__get__incomes','*','ALLOW','ROLE','hr');
|
||||||
INSERT INTO `ACL` VALUES (895,'ItemShelvingLog','*','READ','ALLOW','ROLE','production');
|
INSERT INTO `ACL` VALUES (895,'ItemShelvingLog','*','READ','ALLOW','ROLE','production');
|
||||||
INSERT INTO `ACL` VALUES (896,'Expedition_PrintOut','*','READ','ALLOW','ROLE','production');
|
|
||||||
INSERT INTO `ACL` VALUES (897,'WorkerLog','*','READ','ALLOW','ROLE','employee');
|
INSERT INTO `ACL` VALUES (897,'WorkerLog','*','READ','ALLOW','ROLE','employee');
|
||||||
INSERT INTO `ACL` VALUES (901,'WorkerTimeControl','sendMail','WRITE','ALLOW','ROLE','system');
|
INSERT INTO `ACL` VALUES (901,'WorkerTimeControl','sendMail','WRITE','ALLOW','ROLE','system');
|
||||||
INSERT INTO `ACL` VALUES (902,'Entry','filter','READ','ALLOW','ROLE','supplier');
|
INSERT INTO `ACL` VALUES (902,'Entry','filter','READ','ALLOW','ROLE','supplier');
|
||||||
INSERT INTO `ACL` VALUES (903,'Entry','getBuys','READ','ALLOW','ROLE','supplier');
|
INSERT INTO `ACL` VALUES (903,'Entry','getBuys','READ','ALLOW','ROLE','supplier');
|
||||||
INSERT INTO `ACL` VALUES (904,'Entry','buyLabel','READ','ALLOW','ROLE','supplier');
|
INSERT INTO `ACL` VALUES (904,'Entry','buyLabel','READ','ALLOW','ROLE','supplier');
|
||||||
INSERT INTO `ACL` VALUES (905,'AddressWaste','*','READ','ALLOW','ROLE','production');
|
INSERT INTO `ACL` VALUES (905,'AddressWaste','*','READ','ALLOW','ROLE','production');
|
||||||
|
INSERT INTO `ACL` VALUES (906,'Entry','print','READ','ALLOW','ROLE','supplier');
|
||||||
|
INSERT INTO `ACL` VALUES (907,'Expedition_PrintOut','*','*','ALLOW','ROLE','production');
|
||||||
|
|
||||||
INSERT INTO `fieldAcl` VALUES (1,'Client','name','update','employee');
|
INSERT INTO `fieldAcl` VALUES (1,'Client','name','update','employee');
|
||||||
INSERT INTO `fieldAcl` VALUES (2,'Client','contact','update','employee');
|
INSERT INTO `fieldAcl` VALUES (2,'Client','contact','update','employee');
|
||||||
|
@ -2137,11 +2147,11 @@ INSERT INTO `module` VALUES ('wagon');
|
||||||
INSERT INTO `module` VALUES ('worker');
|
INSERT INTO `module` VALUES ('worker');
|
||||||
INSERT INTO `module` VALUES ('zone');
|
INSERT INTO `module` VALUES ('zone');
|
||||||
|
|
||||||
INSERT INTO `defaultViewConfig` VALUES ('itemsIndex','{\"intrastat\":false,\"stemMultiplier\":false,\"landed\":false,\"producer\":false}');
|
INSERT INTO `defaultViewMultiConfig` VALUES ('itemsIndex','{\"intrastat\":false,\"stemMultiplier\":false,\"landed\":false,\"producer\":false}');
|
||||||
INSERT INTO `defaultViewConfig` VALUES ('latestBuys','{\"intrastat\":false,\"description\":false,\"density\":false,\"isActive\":false,\n \"freightValue\":false,\"packageValue\":false,\"isIgnored\":false,\"price2\":false,\"ektFk\":false,\"weight\":false,\n \"size\":false,\"comissionValue\":false,\"landing\":false}');
|
INSERT INTO `defaultViewMultiConfig` VALUES ('latestBuys','{\"intrastat\":false,\"description\":false,\"density\":false,\"isActive\":false,\n \"freightValue\":false,\"packageValue\":false,\"isIgnored\":false,\"price2\":false,\"ektFk\":false,\"weight\":false,\n \"size\":false,\"comissionValue\":false,\"landing\":false}');
|
||||||
INSERT INTO `defaultViewConfig` VALUES ('ticketsMonitor','{\"id\":false}');
|
INSERT INTO `defaultViewMultiConfig` VALUES ('ticketsMonitor','{\"id\":false}');
|
||||||
INSERT INTO `defaultViewConfig` VALUES ('clientsDetail','{\"id\":true,\"phone\":true,\"city\":true,\"socialName\":true,\"salesPersonFk\":true,\"email\":true,\"name\":false,\"fi\":false,\"credit\":false,\"creditInsurance\":false,\"mobile\":false,\"street\":false,\"countryFk\":false,\"provinceFk\":false,\"postcode\":false,\"created\":false,\"businessTypeFk\":false,\"payMethodFk\":false,\"sageTaxTypeFk\":false,\"sageTransactionTypeFk\":false,\"isActive\":false,\"isVies\":false,\"isTaxDataChecked\":false,\"isEqualizated\":false,\"isFreezed\":false,\"hasToInvoice\":false,\"hasToInvoiceByAddress\":false,\"isToBeMailed\":false,\"hasLcr\":false,\"hasCoreVnl\":false,\"hasSepaVnl\":false}');
|
INSERT INTO `defaultViewMultiConfig` VALUES ('clientsDetail','{\"id\":true,\"phone\":true,\"city\":true,\"socialName\":true,\"salesPersonFk\":true,\"email\":true,\"name\":false,\"fi\":false,\"credit\":false,\"creditInsurance\":false,\"mobile\":false,\"street\":false,\"countryFk\":false,\"provinceFk\":false,\"postcode\":false,\"created\":false,\"businessTypeFk\":false,\"payMethodFk\":false,\"sageTaxTypeFk\":false,\"sageTransactionTypeFk\":false,\"isActive\":false,\"isVies\":false,\"isTaxDataChecked\":false,\"isEqualizated\":false,\"isFreezed\":false,\"hasToInvoice\":false,\"hasToInvoiceByAddress\":false,\"isToBeMailed\":false,\"hasLcr\":false,\"hasCoreVnl\":false,\"hasSepaVnl\":false}');
|
||||||
INSERT INTO `defaultViewConfig` VALUES ('routesList','{\"ID\":true,\"worker\":true,\"agency\":true,\"vehicle\":true,\"date\":true,\"volume\":true,\"description\":true,\"started\":true,\"finished\":true,\"actions\":true}');
|
INSERT INTO `defaultViewMultiConfig` VALUES ('routesList','{\"ID\":true,\"worker\":true,\"agency\":true,\"vehicle\":true,\"date\":true,\"volume\":true,\"description\":true,\"started\":true,\"finished\":true,\"actions\":true}');
|
||||||
|
|
||||||
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
|
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
|
||||||
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
|
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
|
||||||
|
@ -2153,6 +2163,7 @@ USE `vn`;
|
||||||
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
|
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
|
||||||
|
|
||||||
INSERT INTO `alertLevel` VALUES ('FREE',0,1);
|
INSERT INTO `alertLevel` VALUES ('FREE',0,1);
|
||||||
|
INSERT INTO `alertLevel` VALUES ('ON_PREVIOUS',1,1);
|
||||||
INSERT INTO `alertLevel` VALUES ('ON_PREPARATION',2,1);
|
INSERT INTO `alertLevel` VALUES ('ON_PREPARATION',2,1);
|
||||||
INSERT INTO `alertLevel` VALUES ('PACKED',3,0);
|
INSERT INTO `alertLevel` VALUES ('PACKED',3,0);
|
||||||
INSERT INTO `alertLevel` VALUES ('DELIVERED',4,0);
|
INSERT INTO `alertLevel` VALUES ('DELIVERED',4,0);
|
||||||
|
@ -2384,7 +2395,7 @@ 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,NULL);
|
INSERT INTO `department` VALUES (38,'picking','SACADO',17,18,NULL,72,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,NULL);
|
||||||
INSERT INTO `department` VALUES (39,'packing','ENCAJADO',19,20,NULL,72,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,NULL);
|
INSERT INTO `department` VALUES (39,'packing','ENCAJADO',19,20,NULL,72,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,NULL);
|
||||||
INSERT INTO `department` VALUES (41,'administration','ADMINISTRACION',38,39,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL);
|
INSERT INTO `department` VALUES (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,'',1,0,0,0,NULL,NULL,NULL,NULL);
|
INSERT INTO `department` VALUES (43,'VT','VENTAS',40,71,NULL,0,0,0,1,15,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL);
|
||||||
INSERT INTO `department` VALUES (44,'management','GERENCIA',72,73,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
|
INSERT INTO `department` VALUES (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 (45,'logistic','LOGISTICA',74,75,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
|
||||||
INSERT INTO `department` VALUES (46,'delivery','REPARTO',76,77,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL);
|
INSERT INTO `department` VALUES (46,'delivery','REPARTO',76,77,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL);
|
||||||
|
@ -2722,6 +2733,7 @@ INSERT INTO `state` VALUES (36,'Previa Revisando',3,0,'PREVIOUS_CONTROL',2,37,1,
|
||||||
INSERT INTO `state` VALUES (37,'Previa Revisado',3,0,'PREVIOUS_CONTROLLED',2,29,1,0,1,0,0,1,2,0,'warning');
|
INSERT INTO `state` VALUES (37,'Previa Revisado',3,0,'PREVIOUS_CONTROLLED',2,29,1,0,1,0,0,1,2,0,'warning');
|
||||||
INSERT INTO `state` VALUES (38,'Prep Cámara',6,2,'COOLER_PREPARATION',7,14,0,0,0,2,0,0,2,0,'warning');
|
INSERT INTO `state` VALUES (38,'Prep Cámara',6,2,'COOLER_PREPARATION',7,14,0,0,0,2,0,0,2,0,'warning');
|
||||||
INSERT INTO `state` VALUES (41,'Prep Parcial',6,2,'PARTIAL_PREPARATION',7,14,0,0,0,2,0,0,2,0,'warning');
|
INSERT INTO `state` VALUES (41,'Prep Parcial',6,2,'PARTIAL_PREPARATION',7,14,0,0,0,2,0,0,2,0,'warning');
|
||||||
|
INSERT INTO `state` VALUES (42,'Entregado en parte',13,3,'PARTIAL_DELIVERED',NULL,16,0,1,0,0,0,0,0,0,NULL);
|
||||||
|
|
||||||
INSERT INTO `ticketUpdateAction` VALUES (1,'Cambiar los precios en el ticket','renewPrices');
|
INSERT INTO `ticketUpdateAction` VALUES (1,'Cambiar los precios en el ticket','renewPrices');
|
||||||
INSERT INTO `ticketUpdateAction` VALUES (2,'Convertir en maná','mana');
|
INSERT INTO `ticketUpdateAction` VALUES (2,'Convertir en maná','mana');
|
||||||
|
|
|
@ -1292,6 +1292,8 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','srt','grafana','buffer','juan@db-p
|
||||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','greuge','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
|
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','greuge','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','item','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','','Select,Update');
|
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','item','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','','Select,Update');
|
||||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerBoss','itemShelving','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Update','');
|
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerBoss','itemShelving','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Update','');
|
||||||
|
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','agencyIncoming','alexm@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
|
||||||
|
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','addressObservation','carlosap@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','negativeOrigin','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','negativeOrigin','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','deliveryBoss','Vehiculos_consumo','carlosap@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
|
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','deliveryBoss','Vehiculos_consumo','carlosap@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
|
||||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','entryOrder','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Delete','');
|
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','entryOrder','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Delete','');
|
||||||
|
@ -1357,6 +1359,8 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','accounting',
|
||||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','accounting','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','accounting','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','workerActivity','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert','');
|
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','workerActivity','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert','');
|
||||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','ticketRequest','guillermo@10.5.1.3','0000-00-00 00:00:00','Select','');
|
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','ticketRequest','guillermo@10.5.1.3','0000-00-00 00:00:00','Select','');
|
||||||
|
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','deliveryAssistant','Vehiculos_consumo','carlosap@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||||
|
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','budgetState','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryBoss','vehicleState','jgallego@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryBoss','vehicleState','jgallego@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||||
INSERT IGNORE INTO `tables_priv` VALUES ('','srt','grafana','expeditionState','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
INSERT IGNORE INTO `tables_priv` VALUES ('','srt','grafana','expeditionState','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','specialPrice','jgallego@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
|
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','specialPrice','jgallego@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete','');
|
||||||
|
@ -1379,6 +1383,7 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','professionalCategor
|
||||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','production','ticketObservation','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert','');
|
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','production','ticketObservation','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert','');
|
||||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','deliveryNoteState','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','deliveryNoteState','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','deliveryNote','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','deliveryNote','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||||
|
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','inventoryConfig','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','comparative','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','comparative','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','invoiceOutExpense','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','invoiceOutExpense','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','delivery','carlosap@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','delivery','carlosap@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||||
|
@ -1404,6 +1409,7 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','teamBoss','business','guiller
|
||||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','ticketServiceType','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','ticketServiceType','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','business','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','','Select');
|
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','business','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','','Select');
|
||||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','supplierAgencyTerm','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','supplierAgencyTerm','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||||
|
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','itemMinimumQuantity','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','clientRate','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','clientRate','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','entryEditor','Entradas','guillermo@10.5.1.3','0000-00-00 00:00:00','Insert','Update');
|
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','entryEditor','Entradas','guillermo@10.5.1.3','0000-00-00 00:00:00','Insert','Update');
|
||||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','clientInforma','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','clientInforma','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||||
|
@ -1428,6 +1434,8 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','businessReasonEnd','guil
|
||||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','buy_edi','alexm@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','buy_edi','alexm@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','buySource','alexm@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','buySource','alexm@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||||
INSERT IGNORE INTO `tables_priv` VALUES ('','bi','salesPerson','claims_ratio','alexm@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
INSERT IGNORE INTO `tables_priv` VALUES ('','bi','salesPerson','claims_ratio','alexm@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||||
|
INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','employee','shelfMultiConfig','jenkins@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||||
|
INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','clientConfig','carlosap@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','deliveryBoss','albaran','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','deliveryBoss','albaran','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','deliveryBoss','albaran_gestdoc','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','deliveryBoss','albaran_gestdoc','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||||
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','deliveryBoss','albaran_state','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','deliveryBoss','albaran_state','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','');
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -6325,10 +6325,6 @@ BEGIN
|
||||||
SET NEW.userFk = account.myUser_getId();
|
SET NEW.userFk = account.myUser_getId();
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
IF (NEW.visible <> OLD.visible) THEN
|
|
||||||
SET NEW.available = GREATEST(NEW.available + NEW.visible - OLD.visible, 0);
|
|
||||||
END IF;
|
|
||||||
|
|
||||||
END */;;
|
END */;;
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
/*!50003 SET sql_mode = @saved_sql_mode */ ;
|
/*!50003 SET sql_mode = @saved_sql_mode */ ;
|
||||||
|
@ -9224,13 +9220,16 @@ BEGIN
|
||||||
SET NEW.editorFk = account.myUser_getId();
|
SET NEW.editorFk = account.myUser_getId();
|
||||||
|
|
||||||
IF NOT (NEW.routeFk <=> OLD.routeFk) THEN
|
IF NOT (NEW.routeFk <=> OLD.routeFk) THEN
|
||||||
INSERT IGNORE INTO `vn`.`routeRecalc` (`routeFk`)
|
IF NEW.isSigned THEN
|
||||||
SELECT r.id
|
CALL util.throw('A signed ticket cannot be rerouted');
|
||||||
FROM vn.route r
|
END IF;
|
||||||
WHERE r.isOk = FALSE
|
INSERT IGNORE INTO routeRecalc(routeFk)
|
||||||
AND r.id IN (OLD.routeFk,NEW.routeFk)
|
SELECT id
|
||||||
AND r.created >= util.VN_CURDATE()
|
FROM `route`
|
||||||
GROUP BY r.id;
|
WHERE NOT isOk
|
||||||
|
AND id IN (OLD.routeFk, NEW.routeFk)
|
||||||
|
AND created >= util.VN_CURDATE()
|
||||||
|
GROUP BY id;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
IF NOT (DATE(NEW.shipped) <=> DATE(OLD.shipped)) THEN
|
IF NOT (DATE(NEW.shipped) <=> DATE(OLD.shipped)) THEN
|
||||||
|
@ -11143,4 +11142,4 @@ USE `vn2008`;
|
||||||
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
|
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
|
||||||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
||||||
|
|
||||||
-- Dump completed on 2024-07-23 8:19:41
|
-- Dump completed on 2024-08-06 6:03:19
|
||||||
|
|
|
@ -10,9 +10,6 @@ SET foreign_key_checks = 0;
|
||||||
INSERT INTO util.config (id, environment, mockTime, mockUtcTime, mockEnabled)
|
INSERT INTO util.config (id, environment, mockTime, mockUtcTime, mockEnabled)
|
||||||
VALUES (1, 'local', '2001-01-01 12:00:00', '2001-01-01 11:00:00', TRUE);
|
VALUES (1, 'local', '2001-01-01 12:00:00', '2001-01-01 11:00:00', TRUE);
|
||||||
|
|
||||||
INSERT INTO util.binlogQueue (code,logName, `position`)
|
|
||||||
VALUES ('mylogger', 'bin.000001', 4);
|
|
||||||
|
|
||||||
/* #5483
|
/* #5483
|
||||||
INSERT INTO vn.entryConfig (defaultEntry, mailToNotify, inventorySupplierFk, maxLockTime, defaultSupplierFk)
|
INSERT INTO vn.entryConfig (defaultEntry, mailToNotify, inventorySupplierFk, maxLockTime, defaultSupplierFk)
|
||||||
VALUES(1, NULL, 1, 300, 1);
|
VALUES(1, NULL, 1, 300, 1);
|
||||||
|
|
|
@ -1516,23 +1516,23 @@ INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed
|
||||||
(9, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 9', 1, 1, ''),
|
(9, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 9', 1, 1, ''),
|
||||||
(10, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 9', 1, 1, '');
|
(10, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 9', 1, 1, '');
|
||||||
|
|
||||||
INSERT INTO `bs`.`waste`(`buyer`, `year`, `week`, `family`, `itemFk`, `itemTypeFk`, `saleTotal`, `saleWaste`, `rate`)
|
INSERT INTO `bs`.`waste`(`buyerFk`, `year`, `week`, `itemFk`, `itemTypeFk`, `saleTotal`, `saleQuantity`, `saleInternalWaste`, `saleExternalWaste`)
|
||||||
VALUES
|
VALUES
|
||||||
('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Carnation', 1, 1, '1062', '51', '4.8'),
|
('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 1, 1, '1062', '51', '56.20', '56.20'),
|
||||||
('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Carnation Colombia', 2, 1, '35074', '687', '2.0'),
|
('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 2, 1, '35074', '687', '53.12', '89.69'),
|
||||||
('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Carnation Mini', 3, 1, '1777', '13', '0.7'),
|
('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 3, 1, '1777', '13', '12.02', '53.12'),
|
||||||
('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Carnation Short', 4, 1, '3182', '59', '0.6'),
|
('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 4, 1, '3182', '59', '51', '56.20'),
|
||||||
('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Crisantemo', 5, 1, '1747', '13', '0.7'),
|
('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 5, 1, '1747', '13', '53.12', '53.12'),
|
||||||
('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Lilium Oriental', 6, 1, '7182', '59', '0.6'),
|
('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 6, 1, '7182', '59', '51', '53.12'),
|
||||||
('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Alstroemeria', 7, 1, '1777', '13', '0.7'),
|
('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 7, 1, '1777', '13', '89.69', '89.69'),
|
||||||
('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Cymbidium', 1, 1, '4181', '59', '0.6'),
|
('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 8, 1, '4181', '59', '53.12', '53.12'),
|
||||||
('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Cymbidium', 2, 1, '7268', '59', '0.6'),
|
('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 9, 1, '7268', '59', '12.02', '56.20'),
|
||||||
('DavidCharlesHaller', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Containers', 2, 1, '-74', '0', '0.0'),
|
('103', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 2, 1, '-74', '0', '51', '89.69'),
|
||||||
('DavidCharlesHaller', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Packagings', 3, 1, '-7', '0', '0.0'),
|
('103', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 3, 1, '-7', '0', '12.02', '53.12'),
|
||||||
('DavidCharlesHaller', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Freight', 4, 1, '1100', '0', '0.0'),
|
('103', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 4, 1, '1100', '0', '51', '56.20'),
|
||||||
('HankPym', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Funeral Accessories', 5, 1, '848', '-187', '-22.1'),
|
('103', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 5, 1, '848', '-187', '12.02', '89.69'),
|
||||||
('HankPym', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Miscellaneous Accessories', 6, 1, '186', '0', '0.0'),
|
('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'),
|
||||||
('HankPym', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Adhesives', 7, 1, '277', '0', '0.0');
|
('103', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 7, 1, '277', '0', '53.12', '56.20');
|
||||||
|
|
||||||
INSERT INTO `vn`.`buy`(`id`,`entryFk`,`itemFk`,`buyingValue`,`quantity`,`packagingFk`,`stickers`,`freightValue`,`packageValue`,`comissionValue`,`packing`,`grouping`,`groupingMode`,`location`,`price1`,`price2`,`price3`, `printedStickers`,`isChecked`,`isIgnored`,`weight`, `created`)
|
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
|
VALUES
|
||||||
|
@ -1968,7 +1968,7 @@ INSERT INTO `vn`.`orderTicket`(`orderFk`, `ticketFk`)
|
||||||
(21, 21),
|
(21, 21),
|
||||||
(22, 22);
|
(22, 22);
|
||||||
|
|
||||||
INSERT INTO `vn`.`userConfig` (`userFk`, `warehouseFk`, `companyFk`)
|
INSERT INTO `vn`.`userMultiConfig` (`userFk`, `warehouseFk`, `companyFk`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, 1, 69),
|
(1, 1, 69),
|
||||||
(5, 1, 442),
|
(5, 1, 442),
|
||||||
|
|
|
@ -1,31 +1,50 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`waste_addSales`()
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`waste_addSales`()
|
||||||
BEGIN
|
BEGIN
|
||||||
DECLARE vWeek INT;
|
DECLARE vDateFrom DATE DEFAULT util.VN_CURDATE() - INTERVAL WEEKDAY(CURDATE()) DAY;
|
||||||
DECLARE vYear INT;
|
DECLARE vDateTo DATE DEFAULT vDateFrom + INTERVAL 6 DAY;
|
||||||
|
|
||||||
SELECT week, year
|
CALL cache.last_buy_refresh(FALSE);
|
||||||
INTO vWeek, vYear
|
|
||||||
FROM vn.time
|
|
||||||
WHERE dated = util.VN_CURDATE();
|
|
||||||
|
|
||||||
REPLACE bs.waste
|
REPLACE bs.waste
|
||||||
SELECT *, 100 * mermas / total as porcentaje
|
SELECT YEAR(t.shipped),
|
||||||
FROM (
|
WEEK(t.shipped, 4),
|
||||||
SELECT buyer,
|
it.workerFk,
|
||||||
year,
|
it.id,
|
||||||
week,
|
s.itemFk,
|
||||||
family,
|
SUM(s.quantity),
|
||||||
itemFk,
|
SUM((b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity) `value`,
|
||||||
itemTypeFk,
|
SUM (
|
||||||
floor(sum(value)) as total,
|
IF(
|
||||||
floor(sum(IF(typeFk = 'loses', value, 0))) as mermas
|
aw.`type` = 'internal',
|
||||||
FROM vn.saleValue
|
(b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity,
|
||||||
where year = vYear and week = vWeek
|
0
|
||||||
|
)
|
||||||
GROUP BY family, itemFk
|
) internalWaste,
|
||||||
|
SUM (
|
||||||
) sub
|
IF(
|
||||||
ORDER BY mermas DESC;
|
aw.`type` = 'external',
|
||||||
|
(b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity,
|
||||||
|
IF(c.code = 'manaClaim',
|
||||||
|
sc.value * s.quantity,
|
||||||
|
0
|
||||||
|
)
|
||||||
|
)
|
||||||
|
) externalWaste
|
||||||
|
FROM vn.sale s
|
||||||
|
JOIN vn.item i ON i.id = s.itemFk
|
||||||
|
JOIN vn.itemType it ON it.id = i.typeFk
|
||||||
|
JOIN vn.ticket t ON t.id = s.ticketFk
|
||||||
|
JOIN vn.address a FORCE INDEX (PRIMARY) ON a.id = t.addressFk
|
||||||
|
LEFT JOIN vn.addressWaste aw ON aw.addressFk = a.id
|
||||||
|
JOIN vn.warehouse w ON w.id = t.warehouseFk
|
||||||
|
JOIN cache.last_buy lb ON lb.item_id = i.id
|
||||||
|
AND lb.warehouse_id = w.id
|
||||||
|
JOIN vn.buy b ON b.id = lb.buy_id
|
||||||
|
LEFT JOIN vn.saleComponent sc ON sc.saleFk = s.id
|
||||||
|
LEFT JOIN vn.component c ON c.id = sc.componentFk
|
||||||
|
WHERE t.shipped BETWEEN vDateFrom AND vDateTo
|
||||||
|
AND w.isManaged
|
||||||
|
GROUP BY it.id, i.id;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -30,7 +30,7 @@ proc: BEGIN
|
||||||
SELECT inventoried INTO started FROM vn.config LIMIT 1;
|
SELECT inventoried INTO started FROM vn.config LIMIT 1;
|
||||||
SET ended = util.VN_CURDATE(); -- TIMESTAMPADD(DAY, -1, util.VN_CURDATE());
|
SET ended = util.VN_CURDATE(); -- TIMESTAMPADD(DAY, -1, util.VN_CURDATE());
|
||||||
|
|
||||||
CALL vn.buyUltimateFromInterval(NULL, started, ended);
|
CALL vn.buy_getUltimateFromInterval(NULL, NULL, started, ended);
|
||||||
|
|
||||||
DELETE FROM last_buy;
|
DELETE FROM last_buy;
|
||||||
|
|
||||||
|
|
|
@ -10,5 +10,5 @@ AS SELECT `q`.`name` AS `name`,
|
||||||
`c`.`ringInUse` AS `ringinuse`
|
`c`.`ringInUse` AS `ringinuse`
|
||||||
FROM (
|
FROM (
|
||||||
`pbx`.`queue` `q`
|
`pbx`.`queue` `q`
|
||||||
JOIN `pbx`.`queueConfig` `c` ON(`q`.`config` = `c`.`id`)
|
JOIN `pbx`.`queueMultiConfig` `c` ON(`q`.`config` = `c`.`id`)
|
||||||
)
|
)
|
||||||
|
|
|
@ -47,7 +47,7 @@ proc: BEGIN
|
||||||
|
|
||||||
-- Tabla con el ultimo dia de last_buy para cada producto
|
-- Tabla con el ultimo dia de last_buy para cada producto
|
||||||
-- que hace un replace de la anterior.
|
-- que hace un replace de la anterior.
|
||||||
CALL buyUltimate(vWarehouseShipment, util.VN_CURDATE());
|
CALL buy_getUltimate (NULL, vWarehouseShipment, util.VN_CURDATE());
|
||||||
|
|
||||||
INSERT INTO tItemRange
|
INSERT INTO tItemRange
|
||||||
SELECT t.itemFk, tr.landed
|
SELECT t.itemFk, tr.landed
|
||||||
|
|
|
@ -5,39 +5,14 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buyUltimate`(
|
||||||
)
|
)
|
||||||
BEGIN
|
BEGIN
|
||||||
/**
|
/**
|
||||||
* Calcula las últimas compras realizadas hasta una fecha
|
* @deprecated Usar buy_getUltimate
|
||||||
|
* Calcula las últimas compras realizadas hasta una fecha.
|
||||||
*
|
*
|
||||||
|
* @param vItemFk Id del artículo
|
||||||
* @param vWarehouseFk Id del almacén
|
* @param vWarehouseFk Id del almacén
|
||||||
* @param vDated Compras hasta fecha
|
* @param vDated Compras hasta fecha
|
||||||
* @return tmp.buyUltimate
|
* @return tmp.buyUltimate
|
||||||
*/
|
*/
|
||||||
CALL cache.last_buy_refresh (FALSE);
|
CALL buy_getUltimate(NULL, vWarehouseFk, vDated);
|
||||||
|
|
||||||
DROP TEMPORARY TABLE IF EXISTS tmp.buyUltimate;
|
|
||||||
CREATE TEMPORARY TABLE tmp.buyUltimate
|
|
||||||
(PRIMARY KEY (itemFk, warehouseFk),
|
|
||||||
INDEX(itemFk))
|
|
||||||
ENGINE = MEMORY
|
|
||||||
SELECT item_id itemFk, buy_id buyFk, warehouse_id warehouseFk, landing
|
|
||||||
FROM cache.last_buy
|
|
||||||
WHERE warehouse_id = vWarehouseFk OR vWarehouseFk IS NULL;
|
|
||||||
|
|
||||||
IF vDated >= util.VN_CURDATE() THEN
|
|
||||||
CALL buyUltimateFromInterval(vWarehouseFk, util.VN_CURDATE(), vDated);
|
|
||||||
|
|
||||||
REPLACE INTO tmp.buyUltimate
|
|
||||||
SELECT itemFk, buyFk, warehouseFk, landed landing
|
|
||||||
FROM tmp.buyUltimateFromInterval
|
|
||||||
WHERE (warehouseFk = vWarehouseFk OR vWarehouseFk IS NULL)
|
|
||||||
AND landed <= vDated
|
|
||||||
AND NOT isIgnored;
|
|
||||||
|
|
||||||
INSERT IGNORE INTO tmp.buyUltimate
|
|
||||||
SELECT itemFk, buyFk, warehouseFk, landed landing
|
|
||||||
FROM tmp.buyUltimateFromInterval
|
|
||||||
WHERE (warehouseFk = vWarehouseFk OR vWarehouseFk IS NULL)
|
|
||||||
AND landed > vDated
|
|
||||||
ORDER BY isIgnored = FALSE DESC;
|
|
||||||
END IF;
|
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -6,6 +6,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buyUltimateFromInte
|
||||||
)
|
)
|
||||||
BEGIN
|
BEGIN
|
||||||
/**
|
/**
|
||||||
|
* @deprecated Usar buy_getUltimateFromInterval
|
||||||
* Calcula las últimas compras realizadas
|
* Calcula las últimas compras realizadas
|
||||||
* desde un rango de fechas.
|
* desde un rango de fechas.
|
||||||
*
|
*
|
||||||
|
@ -14,153 +15,6 @@ BEGIN
|
||||||
* @param vEnded Fecha fin
|
* @param vEnded Fecha fin
|
||||||
* @return tmp.buyUltimateFromInterval
|
* @return tmp.buyUltimateFromInterval
|
||||||
*/
|
*/
|
||||||
IF vEnded IS NULL THEN
|
CALL vn.buy_getUltimateFromInterval(NULL, vWarehouseFk, vStarted, vEnded);
|
||||||
SET vEnded = vStarted;
|
|
||||||
END IF;
|
|
||||||
|
|
||||||
IF vEnded < vStarted THEN
|
|
||||||
SET vStarted = TIMESTAMPADD(MONTH, -1, vEnded);
|
|
||||||
END IF;
|
|
||||||
|
|
||||||
-- Item
|
|
||||||
DROP TEMPORARY TABLE IF EXISTS tmp.buyUltimateFromInterval;
|
|
||||||
CREATE TEMPORARY TABLE tmp.buyUltimateFromInterval
|
|
||||||
(PRIMARY KEY (itemFk, warehouseFk),
|
|
||||||
INDEX(buyFk), INDEX(landed), INDEX(warehouseFk), INDEX(itemFk))
|
|
||||||
ENGINE = MEMORY
|
|
||||||
SELECT itemFk,
|
|
||||||
warehouseFk,
|
|
||||||
buyFk,
|
|
||||||
landed,
|
|
||||||
isIgnored
|
|
||||||
FROM (SELECT b.itemFk,
|
|
||||||
t.warehouseInFk warehouseFk,
|
|
||||||
b.id buyFk,
|
|
||||||
t.landed,
|
|
||||||
b.isIgnored
|
|
||||||
FROM buy b
|
|
||||||
JOIN entry e ON e.id = b.entryFk
|
|
||||||
JOIN travel t ON t.id = e.travelFk
|
|
||||||
WHERE t.landed BETWEEN vStarted AND vEnded
|
|
||||||
AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk)
|
|
||||||
AND b.price2 > 0
|
|
||||||
ORDER BY NOT b.isIgnored DESC, t.landed DESC, b.id DESC
|
|
||||||
LIMIT 10000000000000000000) sub
|
|
||||||
GROUP BY itemFk, warehouseFk;
|
|
||||||
|
|
||||||
|
|
||||||
INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored)
|
|
||||||
SELECT itemFk,
|
|
||||||
warehouseFk,
|
|
||||||
buyFk,
|
|
||||||
landed,
|
|
||||||
isIgnored
|
|
||||||
FROM (SELECT b.itemFk,
|
|
||||||
t.warehouseInFk warehouseFk,
|
|
||||||
b.id buyFk,
|
|
||||||
t.landed,
|
|
||||||
b.isIgnored
|
|
||||||
FROM buy b
|
|
||||||
JOIN entry e ON e.id = b.entryFk
|
|
||||||
JOIN travel t ON t.id = e.travelFk
|
|
||||||
WHERE t.landed > vEnded
|
|
||||||
AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk)
|
|
||||||
AND b.price2 > 0
|
|
||||||
AND NOT b.isIgnored
|
|
||||||
ORDER BY NOT b.isIgnored DESC, t.landed DESC, b.id DESC
|
|
||||||
LIMIT 10000000000000000000) sub
|
|
||||||
GROUP BY itemFk, warehouseFk;
|
|
||||||
|
|
||||||
INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored)
|
|
||||||
SELECT itemFk,
|
|
||||||
warehouseFk,
|
|
||||||
buyFk,
|
|
||||||
landed,
|
|
||||||
isIgnored
|
|
||||||
FROM (SELECT b.itemFk,
|
|
||||||
t.warehouseInFk warehouseFk,
|
|
||||||
b.id buyFk,
|
|
||||||
t.landed,
|
|
||||||
b.isIgnored
|
|
||||||
FROM buy b
|
|
||||||
JOIN entry e ON e.id = b.entryFk
|
|
||||||
JOIN travel t ON t.id = e.travelFk
|
|
||||||
WHERE t.landed BETWEEN vStarted AND vEnded
|
|
||||||
AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk)
|
|
||||||
AND b.quantity = 0
|
|
||||||
ORDER BY NOT b.isIgnored DESC, t.landed DESC, b.id DESC
|
|
||||||
LIMIT 10000000000000000000) sub
|
|
||||||
GROUP BY itemFk, warehouseFk;
|
|
||||||
|
|
||||||
-- ItemOriginal
|
|
||||||
INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored)
|
|
||||||
SELECT itemFk,
|
|
||||||
warehouseFk,
|
|
||||||
buyFk,
|
|
||||||
landed,
|
|
||||||
isIgnored
|
|
||||||
FROM (SELECT b.itemFk,
|
|
||||||
t.warehouseInFk warehouseFk,
|
|
||||||
b.id buyFk,
|
|
||||||
t.landed,
|
|
||||||
itemOriginalFk,
|
|
||||||
b.isIgnored
|
|
||||||
FROM buy b
|
|
||||||
JOIN entry e ON e.id = b.entryFk
|
|
||||||
JOIN travel t ON t.id = e.travelFk
|
|
||||||
WHERE t.landed BETWEEN vStarted AND vEnded
|
|
||||||
AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk)
|
|
||||||
AND b.price2 > 0
|
|
||||||
AND NOT b.isIgnored
|
|
||||||
AND b.quantity > 0
|
|
||||||
AND itemOriginalFk
|
|
||||||
ORDER BY t.landed DESC, b.id DESC
|
|
||||||
LIMIT 10000000000000000000) sub
|
|
||||||
GROUP BY itemFk, warehouseFk;
|
|
||||||
INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored)
|
|
||||||
SELECT itemFk,
|
|
||||||
warehouseFk,
|
|
||||||
buyFk,
|
|
||||||
landed,
|
|
||||||
isIgnored
|
|
||||||
FROM (SELECT b.itemFk,
|
|
||||||
t.warehouseInFk warehouseFk,
|
|
||||||
b.id buyFk,
|
|
||||||
t.landed,
|
|
||||||
b.isIgnored
|
|
||||||
FROM buy b
|
|
||||||
JOIN entry e ON e.id = b.entryFk
|
|
||||||
JOIN travel t ON t.id = e.travelFk
|
|
||||||
WHERE t.landed > vEnded
|
|
||||||
AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk)
|
|
||||||
AND b.price2 > 0
|
|
||||||
AND NOT b.isIgnored
|
|
||||||
AND itemOriginalFk
|
|
||||||
ORDER BY t.landed DESC, b.id DESC
|
|
||||||
LIMIT 10000000000000000000) sub
|
|
||||||
GROUP BY itemFk, warehouseFk;
|
|
||||||
|
|
||||||
INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored)
|
|
||||||
SELECT itemFk,
|
|
||||||
warehouseFk,
|
|
||||||
buyFk,
|
|
||||||
landed,
|
|
||||||
isIgnored
|
|
||||||
FROM
|
|
||||||
(SELECT b.itemFk,
|
|
||||||
t.warehouseInFk warehouseFk,
|
|
||||||
b.id buyFk,
|
|
||||||
t.landed,
|
|
||||||
b.isIgnored
|
|
||||||
FROM buy b
|
|
||||||
JOIN entry e ON e.id = b.entryFk
|
|
||||||
JOIN travel t ON t.id = e.travelFk
|
|
||||||
WHERE t.landed BETWEEN vStarted AND vEnded
|
|
||||||
AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk)
|
|
||||||
AND b.quantity = 0
|
|
||||||
AND itemOriginalFk
|
|
||||||
ORDER BY t.landed DESC, b.id DESC
|
|
||||||
LIMIT 10000000000000000000) sub
|
|
||||||
GROUP BY itemFk, warehouseFk;
|
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_getUltimate`(
|
||||||
|
vItemFk INT,
|
||||||
|
vWarehouseFk SMALLINT,
|
||||||
|
vDated DATE
|
||||||
|
)
|
||||||
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Calcula las últimas compras realizadas hasta una fecha.
|
||||||
|
*
|
||||||
|
* @param vItemFk Id del artículo
|
||||||
|
* @param vWarehouseFk Id del almacén
|
||||||
|
* @param vDated Compras hasta fecha
|
||||||
|
* @return tmp.buyUltimate
|
||||||
|
*/
|
||||||
|
CALL cache.last_buy_refresh(FALSE);
|
||||||
|
|
||||||
|
CREATE OR REPLACE TEMPORARY TABLE tmp.buyUltimate
|
||||||
|
(PRIMARY KEY (itemFk, warehouseFk),
|
||||||
|
INDEX(itemFk))
|
||||||
|
ENGINE = MEMORY
|
||||||
|
SELECT item_id itemFk, buy_id buyFk, warehouse_id warehouseFk, landing
|
||||||
|
FROM cache.last_buy
|
||||||
|
WHERE (warehouse_id = vWarehouseFk OR vWarehouseFk IS NULL)
|
||||||
|
AND (item_id = vItemFk OR vItemFk IS NULL);
|
||||||
|
|
||||||
|
IF vDated >= util.VN_CURDATE() THEN
|
||||||
|
CALL buy_getUltimateFromInterval(vItemFk, vWarehouseFk, util.VN_CURDATE(), vDated);
|
||||||
|
|
||||||
|
REPLACE INTO tmp.buyUltimate
|
||||||
|
SELECT itemFk, buyFk, warehouseFk, landed landing
|
||||||
|
FROM tmp.buyUltimateFromInterval
|
||||||
|
WHERE (warehouseFk = vWarehouseFk OR vWarehouseFk IS NULL)
|
||||||
|
AND (itemFk = vItemFk OR vItemFk IS NULL)
|
||||||
|
AND landed <= vDated
|
||||||
|
AND NOT isIgnored;
|
||||||
|
|
||||||
|
INSERT IGNORE INTO tmp.buyUltimate
|
||||||
|
SELECT itemFk, buyFk, warehouseFk, landed landing
|
||||||
|
FROM tmp.buyUltimateFromInterval
|
||||||
|
WHERE (warehouseFk = vWarehouseFk OR vWarehouseFk IS NULL)
|
||||||
|
AND (itemFk = vItemFk OR vItemFk IS NULL)
|
||||||
|
AND landed > vDated
|
||||||
|
ORDER BY isIgnored = FALSE DESC;
|
||||||
|
END IF;
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -0,0 +1,175 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_getUltimateFromInterval`(
|
||||||
|
vItemFk INT,
|
||||||
|
vWarehouseFk SMALLINT,
|
||||||
|
vStarted DATE,
|
||||||
|
vEnded DATE
|
||||||
|
)
|
||||||
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Calcula las últimas compras realizadas
|
||||||
|
* desde un rango de fechas.
|
||||||
|
*
|
||||||
|
* @param vItemFk Id del artículo
|
||||||
|
* @param vWarehouseFk Id del almacén si es NULL se actualizan todos
|
||||||
|
* @param vStarted Fecha inicial
|
||||||
|
* @param vEnded Fecha fin
|
||||||
|
* @return tmp.buyUltimateFromInterval
|
||||||
|
*/
|
||||||
|
IF vEnded IS NULL THEN
|
||||||
|
SET vEnded = vStarted;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
IF vEnded < vStarted THEN
|
||||||
|
SET vStarted = vEnded - INTERVAL 1 MONTH;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
-- Item
|
||||||
|
|
||||||
|
CREATE OR REPLACE TEMPORARY TABLE tmp.buyUltimateFromInterval
|
||||||
|
(PRIMARY KEY (itemFk, warehouseFk),
|
||||||
|
INDEX(buyFk), INDEX(landed), INDEX(warehouseFk), INDEX(itemFk))
|
||||||
|
ENGINE = MEMORY
|
||||||
|
SELECT itemFk,
|
||||||
|
warehouseFk,
|
||||||
|
buyFk,
|
||||||
|
landed,
|
||||||
|
isIgnored
|
||||||
|
FROM (SELECT b.itemFk,
|
||||||
|
t.warehouseInFk warehouseFk,
|
||||||
|
b.id buyFk,
|
||||||
|
t.landed,
|
||||||
|
b.isIgnored
|
||||||
|
FROM buy b
|
||||||
|
JOIN entry e ON e.id = b.entryFk
|
||||||
|
JOIN travel t ON t.id = e.travelFk
|
||||||
|
WHERE t.landed BETWEEN vStarted AND vEnded
|
||||||
|
AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk)
|
||||||
|
AND (b.itemFk = vItemFk OR vItemFk IS NULL)
|
||||||
|
AND b.price2 > 0
|
||||||
|
ORDER BY NOT b.isIgnored DESC, t.landed DESC, b.id DESC
|
||||||
|
LIMIT 10000000000000000000) sub
|
||||||
|
GROUP BY itemFk, warehouseFk;
|
||||||
|
|
||||||
|
|
||||||
|
INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored)
|
||||||
|
SELECT itemFk,
|
||||||
|
warehouseFk,
|
||||||
|
buyFk,
|
||||||
|
landed,
|
||||||
|
isIgnored
|
||||||
|
FROM (SELECT b.itemFk,
|
||||||
|
t.warehouseInFk warehouseFk,
|
||||||
|
b.id buyFk,
|
||||||
|
t.landed,
|
||||||
|
b.isIgnored
|
||||||
|
FROM buy b
|
||||||
|
JOIN entry e ON e.id = b.entryFk
|
||||||
|
JOIN travel t ON t.id = e.travelFk
|
||||||
|
WHERE t.landed > vEnded
|
||||||
|
AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk)
|
||||||
|
AND (b.itemFk = vItemFk OR vItemFk IS NULL)
|
||||||
|
AND b.price2 > 0
|
||||||
|
AND NOT b.isIgnored
|
||||||
|
ORDER BY NOT b.isIgnored DESC, t.landed DESC, b.id DESC
|
||||||
|
LIMIT 10000000000000000000) sub
|
||||||
|
GROUP BY itemFk, warehouseFk;
|
||||||
|
|
||||||
|
INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored)
|
||||||
|
SELECT itemFk,
|
||||||
|
warehouseFk,
|
||||||
|
buyFk,
|
||||||
|
landed,
|
||||||
|
isIgnored
|
||||||
|
FROM (SELECT b.itemFk,
|
||||||
|
t.warehouseInFk warehouseFk,
|
||||||
|
b.id buyFk,
|
||||||
|
t.landed,
|
||||||
|
b.isIgnored
|
||||||
|
FROM buy b
|
||||||
|
JOIN entry e ON e.id = b.entryFk
|
||||||
|
JOIN travel t ON t.id = e.travelFk
|
||||||
|
WHERE t.landed BETWEEN vStarted AND vEnded
|
||||||
|
AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk)
|
||||||
|
AND (b.itemFk = vItemFk OR vItemFk IS NULL)
|
||||||
|
AND b.quantity = 0
|
||||||
|
ORDER BY NOT b.isIgnored DESC, t.landed DESC, b.id DESC
|
||||||
|
LIMIT 10000000000000000000) sub
|
||||||
|
GROUP BY itemFk, warehouseFk;
|
||||||
|
|
||||||
|
-- ItemOriginal
|
||||||
|
|
||||||
|
INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored)
|
||||||
|
SELECT itemFk,
|
||||||
|
warehouseFk,
|
||||||
|
buyFk,
|
||||||
|
landed,
|
||||||
|
isIgnored
|
||||||
|
FROM (SELECT b.itemFk,
|
||||||
|
t.warehouseInFk warehouseFk,
|
||||||
|
b.id buyFk,
|
||||||
|
t.landed,
|
||||||
|
itemOriginalFk,
|
||||||
|
b.isIgnored
|
||||||
|
FROM buy b
|
||||||
|
JOIN entry e ON e.id = b.entryFk
|
||||||
|
JOIN travel t ON t.id = e.travelFk
|
||||||
|
WHERE t.landed BETWEEN vStarted AND vEnded
|
||||||
|
AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk)
|
||||||
|
AND (b.itemFk = vItemFk OR vItemFk IS NULL)
|
||||||
|
AND b.price2 > 0
|
||||||
|
AND NOT b.isIgnored
|
||||||
|
AND b.quantity > 0
|
||||||
|
AND itemOriginalFk
|
||||||
|
ORDER BY t.landed DESC, b.id DESC
|
||||||
|
LIMIT 10000000000000000000) sub
|
||||||
|
GROUP BY itemFk, warehouseFk;
|
||||||
|
INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored)
|
||||||
|
SELECT itemFk,
|
||||||
|
warehouseFk,
|
||||||
|
buyFk,
|
||||||
|
landed,
|
||||||
|
isIgnored
|
||||||
|
FROM (SELECT b.itemFk,
|
||||||
|
t.warehouseInFk warehouseFk,
|
||||||
|
b.id buyFk,
|
||||||
|
t.landed,
|
||||||
|
b.isIgnored
|
||||||
|
FROM buy b
|
||||||
|
JOIN entry e ON e.id = b.entryFk
|
||||||
|
JOIN travel t ON t.id = e.travelFk
|
||||||
|
WHERE t.landed > vEnded
|
||||||
|
AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk)
|
||||||
|
AND (b.itemFk = vItemFk OR vItemFk IS NULL)
|
||||||
|
AND b.price2 > 0
|
||||||
|
AND NOT b.isIgnored
|
||||||
|
AND itemOriginalFk
|
||||||
|
ORDER BY t.landed DESC, b.id DESC
|
||||||
|
LIMIT 10000000000000000000) sub
|
||||||
|
GROUP BY itemFk, warehouseFk;
|
||||||
|
|
||||||
|
INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored)
|
||||||
|
SELECT itemFk,
|
||||||
|
warehouseFk,
|
||||||
|
buyFk,
|
||||||
|
landed,
|
||||||
|
isIgnored
|
||||||
|
FROM
|
||||||
|
(SELECT b.itemFk,
|
||||||
|
t.warehouseInFk warehouseFk,
|
||||||
|
b.id buyFk,
|
||||||
|
t.landed,
|
||||||
|
b.isIgnored
|
||||||
|
FROM buy b
|
||||||
|
JOIN entry e ON e.id = b.entryFk
|
||||||
|
JOIN travel t ON t.id = e.travelFk
|
||||||
|
WHERE t.landed BETWEEN vStarted AND vEnded
|
||||||
|
AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk)
|
||||||
|
AND (b.itemFk = vItemFk OR vItemFk IS NULL)
|
||||||
|
AND b.quantity = 0
|
||||||
|
AND itemOriginalFk
|
||||||
|
ORDER BY t.landed DESC, b.id DESC
|
||||||
|
LIMIT 10000000000000000000) sub
|
||||||
|
GROUP BY itemFk, warehouseFk;
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -1,5 +1,9 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_updateGrouping`(vWarehouseFk INT, vItemFk INT, vGrouping INT)
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_updateGrouping`(
|
||||||
|
vWarehouseFk INT,
|
||||||
|
vItemFk INT,
|
||||||
|
vGrouping INT
|
||||||
|
)
|
||||||
BEGIN
|
BEGIN
|
||||||
/**
|
/**
|
||||||
* Actualiza el grouping de las últimas compras de un artículo
|
* Actualiza el grouping de las últimas compras de un artículo
|
||||||
|
@ -8,9 +12,9 @@ BEGIN
|
||||||
* @param vItemFk Id del Artículo
|
* @param vItemFk Id del Artículo
|
||||||
* @param vGrouping Cantidad de grouping
|
* @param vGrouping Cantidad de grouping
|
||||||
*/
|
*/
|
||||||
CALL vn.buyUltimate(vWarehouseFk, util.VN_CURDATE());
|
CALL buy_getUltimate(vItemFk, vWarehouseFk, util.VN_CURDATE());
|
||||||
|
|
||||||
UPDATE vn.buy b
|
UPDATE buy b
|
||||||
JOIN tmp.buyUltimate bu ON b.id = bu.buyFk
|
JOIN tmp.buyUltimate bu ON b.id = bu.buyFk
|
||||||
SET b.`grouping` = vGrouping
|
SET b.`grouping` = vGrouping
|
||||||
WHERE bu.warehouseFk = vWarehouseFk
|
WHERE bu.warehouseFk = vWarehouseFk
|
||||||
|
|
|
@ -8,7 +8,7 @@ BEGIN
|
||||||
* @param vItemFk id del item
|
* @param vItemFk id del item
|
||||||
* @param vPacking packing a actualizar
|
* @param vPacking packing a actualizar
|
||||||
*/
|
*/
|
||||||
CALL buyUltimate(vWarehouseFk, util.VN_CURDATE());
|
CALL buy_getUltimate(vItemFk, vWarehouseFk, util.VN_CURDATE());
|
||||||
|
|
||||||
UPDATE buy b
|
UPDATE buy b
|
||||||
JOIN tmp.buyUltimate bu ON b.id = bu.buyFk
|
JOIN tmp.buyUltimate bu ON b.id = bu.buyFk
|
||||||
|
|
|
@ -29,7 +29,7 @@ BEGIN
|
||||||
|
|
||||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||||
|
|
||||||
CALL vn.zone_getShipped (vLanded, vAddressFk, vAgencyModeFk, vShowExpiredZones);
|
CALL zone_getShipped (vLanded, vAddressFk, vAgencyModeFk, vShowExpiredZones);
|
||||||
|
|
||||||
DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot;
|
DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot;
|
||||||
CREATE TEMPORARY TABLE tmp.ticketLot(
|
CREATE TEMPORARY TABLE tmp.ticketLot(
|
||||||
|
@ -72,9 +72,9 @@ BEGIN
|
||||||
LEAVE l;
|
LEAVE l;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
CALL `cache`.available_refresh (vAvailableCalc, FALSE, vWarehouseFk, vShipped);
|
CALL `cache`.available_refresh(vAvailableCalc, FALSE, vWarehouseFk, vShipped);
|
||||||
CALL `cache`.availableNoRaids_refresh (vAvailableNoRaidsCalc, FALSE, vWarehouseFk, vShipped);
|
CALL `cache`.availableNoRaids_refresh(vAvailableNoRaidsCalc, FALSE, vWarehouseFk, vShipped);
|
||||||
CALL vn.buyUltimate(vWarehouseFk, vShipped);
|
CALL buy_getUltimate(NULL, vWarehouseFk, vShipped);
|
||||||
|
|
||||||
INSERT INTO tmp.ticketLot (warehouseFk, itemFk, available, buyFk, zoneFk)
|
INSERT INTO tmp.ticketLot (warehouseFk, itemFk, available, buyFk, zoneFk)
|
||||||
SELECT vWarehouseFk,
|
SELECT vWarehouseFk,
|
||||||
|
@ -86,17 +86,17 @@ BEGIN
|
||||||
LEFT JOIN cache.availableNoRaids anr ON anr.item_id = a.item_id
|
LEFT JOIN cache.availableNoRaids anr ON anr.item_id = a.item_id
|
||||||
AND anr.calc_id = vAvailableNoRaidsCalc
|
AND anr.calc_id = vAvailableNoRaidsCalc
|
||||||
JOIN tmp.item i ON i.itemFk = a.item_id
|
JOIN tmp.item i ON i.itemFk = a.item_id
|
||||||
JOIN vn.item it ON it.id = i.itemFk
|
JOIN item it ON it.id = i.itemFk
|
||||||
JOIN vn.`zone` z ON z.id = vZoneFk
|
JOIN `zone` z ON z.id = vZoneFk
|
||||||
LEFT JOIN tmp.buyUltimate bu ON bu.itemFk = a.item_id
|
LEFT JOIN tmp.buyUltimate bu ON bu.itemFk = a.item_id
|
||||||
LEFT JOIN edi.supplyResponse sr ON sr.ID = it.supplyResponseFk
|
LEFT JOIN edi.supplyResponse sr ON sr.ID = it.supplyResponseFk
|
||||||
LEFT JOIN edi.VMPSettings v ON v.VMPID = sr.vmpID
|
LEFT JOIN edi.VMPSettings v ON v.VMPID = sr.vmpID
|
||||||
LEFT JOIN edi.marketPlace mp ON mp.id = sr.MarketPlaceID
|
LEFT JOIN edi.marketPlace mp ON mp.id = sr.MarketPlaceID
|
||||||
LEFT JOIN (SELECT isVNHSupplier, isEarlyBird, TRUE AS itemAllowed
|
LEFT JOIN (SELECT isVNHSupplier, isEarlyBird, TRUE AS itemAllowed
|
||||||
FROM vn.addressFilter af
|
FROM addressFilter af
|
||||||
JOIN (SELECT ad.provinceFk, p.countryFk, ad.isLogifloraAllowed
|
JOIN (SELECT ad.provinceFk, p.countryFk, ad.isLogifloraAllowed
|
||||||
FROM vn.address ad
|
FROM address ad
|
||||||
JOIN vn.province p ON p.id = ad.provinceFk
|
JOIN province p ON p.id = ad.provinceFk
|
||||||
WHERE ad.id = vAddressFk
|
WHERE ad.id = vAddressFk
|
||||||
) sub2 ON sub2.provinceFk <=> IFNULL(af.provinceFk, sub2.provinceFk)
|
) sub2 ON sub2.provinceFk <=> IFNULL(af.provinceFk, sub2.provinceFk)
|
||||||
AND sub2.countryFk <=> IFNULL(af.countryFk, sub2.countryFk)
|
AND sub2.countryFk <=> IFNULL(af.countryFk, sub2.countryFk)
|
||||||
|
@ -108,18 +108,18 @@ BEGIN
|
||||||
OR ISNULL(af.afterDated))
|
OR ISNULL(af.afterDated))
|
||||||
) sub ON sub.isVNHSupplier = v.isVNHSupplier
|
) sub ON sub.isVNHSupplier = v.isVNHSupplier
|
||||||
AND (sub.isEarlyBird = mp.isEarlyBird OR ISNULL(sub.isEarlyBird))
|
AND (sub.isEarlyBird = mp.isEarlyBird OR ISNULL(sub.isEarlyBird))
|
||||||
JOIN vn.agencyMode am ON am.id = vAgencyModeFk
|
JOIN agencyMode am ON am.id = vAgencyModeFk
|
||||||
JOIN vn.agency ag ON ag.id = am.agencyFk
|
JOIN agency ag ON ag.id = am.agencyFk
|
||||||
JOIN vn.itemType itt ON itt.id = it.typeFk
|
JOIN itemType itt ON itt.id = it.typeFk
|
||||||
JOIN vn.itemCategory itc on itc.id = itt.categoryFk
|
JOIN itemCategory itc on itc.id = itt.categoryFk
|
||||||
JOIN vn.address ad ON ad.id = vAddressFk
|
JOIN address ad ON ad.id = vAddressFk
|
||||||
LEFT JOIN vn.clientItemType cit
|
LEFT JOIN clientItemType cit
|
||||||
ON cit.clientFk = ad.clientFk
|
ON cit.clientFk = ad.clientFk
|
||||||
AND cit.itemTypeFk = itt.id
|
AND cit.itemTypeFk = itt.id
|
||||||
LEFT JOIN vn.zoneItemType zit
|
LEFT JOIN zoneItemType zit
|
||||||
ON zit.zoneFk = vZoneFk
|
ON zit.zoneFk = vZoneFk
|
||||||
AND zit.itemTypeFk = itt.id
|
AND zit.itemTypeFk = itt.id
|
||||||
LEFT JOIN vn.agencyModeItemType ait
|
LEFT JOIN agencyModeItemType ait
|
||||||
ON ait.agencyModeFk = vAgencyModeFk
|
ON ait.agencyModeFk = vAgencyModeFk
|
||||||
AND ait.itemTypeFk = itt.id
|
AND ait.itemTypeFk = itt.id
|
||||||
WHERE a.calc_id = vAvailableCalc
|
WHERE a.calc_id = vAvailableCalc
|
||||||
|
@ -133,7 +133,7 @@ BEGIN
|
||||||
|
|
||||||
DROP TEMPORARY TABLE tmp.buyUltimate;
|
DROP TEMPORARY TABLE tmp.buyUltimate;
|
||||||
|
|
||||||
CALL vn.catalog_componentCalculate(vZoneFk, vAddressFk, vShipped, vWarehouseFk);
|
CALL catalog_componentCalculate(vZoneFk, vAddressFk, vShipped, vWarehouseFk);
|
||||||
|
|
||||||
INSERT INTO tmp.ticketCalculateItem(
|
INSERT INTO tmp.ticketCalculateItem(
|
||||||
itemFk,
|
itemFk,
|
||||||
|
|
|
@ -7,7 +7,7 @@ DECLARE vCompanyFk INT;
|
||||||
SELECT IFNULL(uc.companyFk, rc.defaultCompanyFk)
|
SELECT IFNULL(uc.companyFk, rc.defaultCompanyFk)
|
||||||
INTO vCompanyFk
|
INTO vCompanyFk
|
||||||
FROM vn.routeConfig rc
|
FROM vn.routeConfig rc
|
||||||
LEFT JOIN userConfig uc ON uc.userFk = workerFk;
|
LEFT JOIN userMultiConfig uc ON uc.userFk = workerFk;
|
||||||
|
|
||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
|
|
|
@ -12,6 +12,7 @@ BEGIN
|
||||||
DECLARE vInvoiceFk INT;
|
DECLARE vInvoiceFk INT;
|
||||||
DECLARE vBookEntry INT;
|
DECLARE vBookEntry INT;
|
||||||
DECLARE vFiscalYear INT;
|
DECLARE vFiscalYear INT;
|
||||||
|
DECLARE vIncorrectInvoiceInDueDay INT;
|
||||||
|
|
||||||
DECLARE vInvoicesIn CURSOR FOR
|
DECLARE vInvoicesIn CURSOR FOR
|
||||||
SELECT DISTINCT e.invoiceInFk
|
SELECT DISTINCT e.invoiceInFk
|
||||||
|
@ -24,6 +25,19 @@ BEGIN
|
||||||
|
|
||||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||||
|
|
||||||
|
SELECT GROUP_CONCAT(ii.id) INTO vIncorrectInvoiceInDueDay
|
||||||
|
FROM invoiceInDueDay iidd
|
||||||
|
JOIN invoiceIn ii ON iidd.invoiceInFk = ii.id
|
||||||
|
JOIN `entry` e ON e.invoiceInFk = ii.id
|
||||||
|
JOIN duaEntry de ON de.entryFk = e.id
|
||||||
|
JOIN invoiceInConfig iic
|
||||||
|
WHERE de.duaFk = vDuaFk
|
||||||
|
AND iidd.dueDated < util.VN_CURDATE() + INTERVAL iic.dueDateMarginDays DAY;
|
||||||
|
|
||||||
|
IF vIncorrectInvoiceInDueDay THEN
|
||||||
|
CALL util.throw(CONCAT('Incorrect due date, invoice: ', vIncorrectInvoiceInDueDay));
|
||||||
|
END IF;
|
||||||
|
|
||||||
UPDATE invoiceIn ii
|
UPDATE invoiceIn ii
|
||||||
JOIN entry e ON e.invoiceInFk = ii.id
|
JOIN entry e ON e.invoiceInFk = ii.id
|
||||||
JOIN duaEntry de ON de.entryFk = e.id
|
JOIN duaEntry de ON de.entryFk = e.id
|
||||||
|
|
|
@ -97,7 +97,7 @@ BEGIN
|
||||||
FROM tmp.itemList;
|
FROM tmp.itemList;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
CALL buyUltimateFromInterval(vWarehouseIn,vInventoryDate, vDateLanded);
|
CALL buy_getUltimateFromInterval(NULL, vWarehouseIn,vInventoryDate, vDateLanded);
|
||||||
|
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tTransfer
|
CREATE OR REPLACE TEMPORARY TABLE tTransfer
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
|
|
|
@ -110,7 +110,7 @@ BEGIN
|
||||||
|
|
||||||
UPDATE itemShelving
|
UPDATE itemShelving
|
||||||
SET isSplit = TRUE
|
SET isSplit = TRUE
|
||||||
WHERE shelvingFk = vShelvingFk;
|
WHERE shelvingFk = vShelvingFk COLLATE utf8_general_ci;
|
||||||
END LOOP;
|
END LOOP;
|
||||||
CLOSE cur;
|
CLOSE cur;
|
||||||
END$$
|
END$$
|
||||||
|
|
|
@ -1,11 +1,18 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`expeditionScan_Put`(vPalletFk INT, vExpeditionFk INT)
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`expeditionScan_Put`(
|
||||||
|
vPalletFk INT,
|
||||||
|
vExpeditionFk INT
|
||||||
|
)
|
||||||
BEGIN
|
BEGIN
|
||||||
|
IF NOT (SELECT TRUE FROM expedition WHERE id = vExpeditionFk LIMIT 1) THEN
|
||||||
|
CALL util.throw('Expedition not exists');
|
||||||
|
END IF;
|
||||||
|
|
||||||
REPLACE vn.expeditionScan(expeditionFk, palletFk)
|
IF NOT (SELECT TRUE FROM expeditionPallet WHERE id = vPalletFk LIMIT 1) THEN
|
||||||
VALUES(vExpeditionFk, vPalletFk);
|
CALL util.throw('Pallet not exists');
|
||||||
|
END IF;
|
||||||
SELECT LAST_INSERT_ID() INTO vPalletFk;
|
|
||||||
|
|
||||||
|
REPLACE expeditionScan(expeditionFk, palletFk)
|
||||||
|
VALUES(vExpeditionFk, vPalletFk);
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceInDueDay_calculate`(vInvoiceInFk INT)
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceInDueDay_calculate`(
|
||||||
|
vInvoiceInFk INT
|
||||||
|
)
|
||||||
BEGIN
|
BEGIN
|
||||||
/**
|
/**
|
||||||
* Calcula los vctos. de una factura recibida
|
* Calcula los vctos. de una factura recibida
|
||||||
|
@ -56,12 +58,13 @@ BEGIN
|
||||||
COUNT(DISTINCT(pdd.detail)) cont,
|
COUNT(DISTINCT(pdd.detail)) cont,
|
||||||
s.payDay,
|
s.payDay,
|
||||||
ii.issued,
|
ii.issued,
|
||||||
DATE(ii.created) + INTERVAL 2 DAY created
|
DATE(ii.created) + INTERVAL iic.dueDateMarginDays DAY created
|
||||||
FROM invoiceIn ii
|
FROM invoiceIn ii
|
||||||
JOIN invoiceInTax iit ON iit.invoiceInFk = ii.id
|
JOIN invoiceInTax iit ON iit.invoiceInFk = ii.id
|
||||||
LEFT JOIN sage.TiposIva ti ON ti.CodigoIva= iit.taxTypeSageFk
|
LEFT JOIN sage.TiposIva ti ON ti.CodigoIva= iit.taxTypeSageFk
|
||||||
JOIN supplier s ON s.id = ii.supplierFk
|
JOIN supplier s ON s.id = ii.supplierFk
|
||||||
JOIN payDemDetail pdd ON pdd.id = s.payDemFk
|
JOIN payDemDetail pdd ON pdd.id = s.payDemFk
|
||||||
|
JOIN invoiceInConfig iic
|
||||||
WHERE ii.id = vInvoiceInFk
|
WHERE ii.id = vInvoiceInFk
|
||||||
GROUP BY ii.id
|
GROUP BY ii.id
|
||||||
)sub
|
)sub
|
||||||
|
|
|
@ -16,9 +16,11 @@ BEGIN
|
||||||
DECLARE vHasRepeatedTransactions BOOL;
|
DECLARE vHasRepeatedTransactions BOOL;
|
||||||
|
|
||||||
SELECT TRUE INTO vHasRepeatedTransactions
|
SELECT TRUE INTO vHasRepeatedTransactions
|
||||||
FROM invoiceInTax
|
FROM invoiceInTax iit
|
||||||
WHERE invoiceInFk = vSelf
|
JOIN invoiceIn ii ON ii.id = iit.invoiceInFk
|
||||||
HAVING COUNT(DISTINCT transactionTypeSageFk) > 1
|
WHERE ii.id = vSelf
|
||||||
|
AND ii.serial = 'E'
|
||||||
|
HAVING COUNT(DISTINCT iit.transactionTypeSageFk) > 1
|
||||||
LIMIT 1;
|
LIMIT 1;
|
||||||
|
|
||||||
IF vHasRepeatedTransactions THEN
|
IF vHasRepeatedTransactions THEN
|
||||||
|
|
|
@ -216,7 +216,7 @@ BEGIN
|
||||||
i.transactionTypeSageFk,
|
i.transactionTypeSageFk,
|
||||||
@vTaxCodeGeneral := i.taxClassCodeFk
|
@vTaxCodeGeneral := i.taxClassCodeFk
|
||||||
FROM tmp.ticketServiceTax tst
|
FROM tmp.ticketServiceTax tst
|
||||||
JOIN invoiceOutTaxConfig i ON i.taxClassCodeFk = tst.code
|
JOIN invoiceOutTaxMultiConfig i ON i.taxClassCodeFk = tst.code
|
||||||
WHERE i.isService
|
WHERE i.isService
|
||||||
HAVING taxableBase
|
HAVING taxableBase
|
||||||
) sub;
|
) sub;
|
||||||
|
@ -229,7 +229,7 @@ BEGIN
|
||||||
i.taxTypeSageFk ,
|
i.taxTypeSageFk ,
|
||||||
i.transactionTypeSageFk
|
i.transactionTypeSageFk
|
||||||
FROM tmp.ticketTax tt
|
FROM tmp.ticketTax tt
|
||||||
JOIN invoiceOutTaxConfig i ON i.taxClassCodeFk = tt.code
|
JOIN invoiceOutTaxMultiConfig i ON i.taxClassCodeFk = tt.code
|
||||||
WHERE !i.isService
|
WHERE !i.isService
|
||||||
GROUP BY tt.pgcFk
|
GROUP BY tt.pgcFk
|
||||||
HAVING taxableBase
|
HAVING taxableBase
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_addBySaleGroup`(
|
||||||
|
vSaleGroupFk INT(11)
|
||||||
|
)
|
||||||
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Reserva cantidades con ubicaciones para el contenido de una preparación previa
|
||||||
|
* a través del saleGroup
|
||||||
|
*
|
||||||
|
* @param vSaleGroupFk Identificador de saleGroup
|
||||||
|
*/
|
||||||
|
DECLARE vDone BOOL DEFAULT FALSE;
|
||||||
|
DECLARE vSaleFk INT;
|
||||||
|
DECLARE vSectorFk INT;
|
||||||
|
DECLARE vSales CURSOR FOR
|
||||||
|
SELECT s.id
|
||||||
|
FROM saleGroupDetail sgd
|
||||||
|
JOIN sale s ON sgd.saleFk = s.id
|
||||||
|
JOIN saleTracking str ON str.saleFk = s.id
|
||||||
|
JOIN `state` st ON st.id = str.stateFk
|
||||||
|
AND st.code = 'PREVIOUS_PREPARATION'
|
||||||
|
LEFT JOIN itemShelvingSale iss ON iss.saleFk = s.id
|
||||||
|
WHERE sgd.saleGroupFk = vSaleGroupFk
|
||||||
|
AND str.workerFk = account.myUser_getId()
|
||||||
|
AND iss.id IS NULL;
|
||||||
|
|
||||||
|
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||||
|
|
||||||
|
SELECT sectorFk INTO vSectorFk
|
||||||
|
FROM operator
|
||||||
|
WHERE workerFk = account.myUser_getId();
|
||||||
|
|
||||||
|
OPEN vSales;
|
||||||
|
l: LOOP
|
||||||
|
SET vDone = FALSE;
|
||||||
|
FETCH vSales INTO vSaleFk;
|
||||||
|
|
||||||
|
IF vDone THEN
|
||||||
|
LEAVE l;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
CALL itemShelvingSale_addBySale(vSaleFk, vSectorFk);
|
||||||
|
END LOOP;
|
||||||
|
CLOSE vSales;
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -30,12 +30,12 @@ BEGIN
|
||||||
FROM itemShelvingSale iss
|
FROM itemShelvingSale iss
|
||||||
JOIN itemShelving ish ON ish.id = iss.itemShelvingFk
|
JOIN itemShelving ish ON ish.id = iss.itemShelvingFk
|
||||||
WHERE iss.itemShelvingFk = vItemShelvingFk
|
WHERE iss.itemShelvingFk = vItemShelvingFk
|
||||||
AND iss.itemFk = vItemFk
|
AND ish.itemFk = vItemFk
|
||||||
AND NOT iss.isPicked
|
AND NOT iss.isPicked
|
||||||
FOR UPDATE;
|
FOR UPDATE;
|
||||||
|
|
||||||
INSERT INTO itemShelvingSaleReserve (saleFk, vSectorFk)
|
INSERT INTO itemShelvingSaleReserve (saleFk, sectorFk)
|
||||||
SELECT DISTINCT iss.saleFk
|
SELECT DISTINCT iss.saleFk, vSectorFk
|
||||||
FROM itemShelvingSale iss
|
FROM itemShelvingSale iss
|
||||||
JOIN itemShelving ish ON ish.id = iss.itemShelvingFk
|
JOIN itemShelving ish ON ish.id = iss.itemShelvingFk
|
||||||
WHERE iss.itemShelvingFk = vItemShelvingFk
|
WHERE iss.itemShelvingFk = vItemShelvingFk
|
||||||
|
|
|
@ -103,7 +103,7 @@ BEGIN
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|
||||||
IF vIsItemShelvingSaleEmpty AND vQuantity <> vReservedQuantity THEN
|
IF vIsItemShelvingSaleEmpty AND vQuantity <> vReservedQuantity THEN
|
||||||
INSERT INTO itemShelvingSaleReserve (saleFk, vSectorFk)
|
INSERT INTO itemShelvingSaleReserve (saleFk, sectorFk)
|
||||||
SELECT vSaleFk, vSectorFk;
|
SELECT vSaleFk, vSectorFk;
|
||||||
CALL itemShelvingSale_reallocate(vItemShelvingFk, vItemFk, vSectorFk);
|
CALL itemShelvingSale_reallocate(vItemShelvingFk, vItemFk, vSectorFk);
|
||||||
END IF;
|
END IF;
|
||||||
|
|
|
@ -15,7 +15,7 @@ BEGIN
|
||||||
JOIN ticket t ON t.id = c.ticketFk
|
JOIN ticket t ON t.id = c.ticketFk
|
||||||
WHERE c.id = vClaimFk;
|
WHERE c.id = vClaimFk;
|
||||||
|
|
||||||
CALL buyUltimate (vWarehouseFk, util.VN_CURDATE());
|
CALL buy_getUltimate(NULL, vWarehouseFk, util.VN_CURDATE());
|
||||||
|
|
||||||
INSERT INTO itemShelving (itemFk, shelvingFk, packing, `grouping`, visible)
|
INSERT INTO itemShelving (itemFk, shelvingFk, packing, `grouping`, visible)
|
||||||
SELECT s.itemFk, vShelvingFk, b.packing, b.`grouping`, cb.quantity AS visible
|
SELECT s.itemFk, vShelvingFk, b.packing, b.`grouping`, cb.quantity AS visible
|
||||||
|
|
|
@ -16,7 +16,8 @@ BEGIN
|
||||||
ish.id,
|
ish.id,
|
||||||
s.priority,
|
s.priority,
|
||||||
ish.isChecked,
|
ish.isChecked,
|
||||||
ic.url
|
ic.url,
|
||||||
|
ish.available
|
||||||
FROM itemShelving ish
|
FROM itemShelving ish
|
||||||
JOIN item i ON i.id = ish.itemFk
|
JOIN item i ON i.id = ish.itemFk
|
||||||
JOIN shelving s ON vSelf = s.code COLLATE utf8_unicode_ci
|
JOIN shelving s ON vSelf = s.code COLLATE utf8_unicode_ci
|
||||||
|
|
|
@ -23,7 +23,7 @@ BEGIN
|
||||||
FROM operator
|
FROM operator
|
||||||
WHERE workerFk = account.myUser_getId();
|
WHERE workerFk = account.myUser_getId();
|
||||||
|
|
||||||
CALL buyUltimate(vWarehouseFk, util.VN_CURDATE());
|
CALL buy_getUltimate(vBarcodeItem, vWarehouseFk, util.VN_CURDATE());
|
||||||
|
|
||||||
SELECT buyFk INTO vBuyFk
|
SELECT buyFk INTO vBuyFk
|
||||||
FROM tmp.buyUltimate
|
FROM tmp.buyUltimate
|
||||||
|
|
|
@ -10,19 +10,20 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_comparative`(
|
||||||
)
|
)
|
||||||
proc: BEGIN
|
proc: BEGIN
|
||||||
/**
|
/**
|
||||||
* Genera una tabla de comparativa de artículos por itemType/comprador/fecha.
|
* Generates a comparison table of items by itemType/buyer/date.
|
||||||
* Los datos se calculan en función de los parámetros proporcionados.
|
* The data is calculated based on the provided parameters.
|
||||||
*
|
*
|
||||||
* @param vDate La fecha para la cual se generará la comparativa.
|
* @param vDate The date for which the comparison will be generated.
|
||||||
* @param vDayRange El rango de días a considerar para la comparativa.
|
* @param vDayRange The range of days to consider for the comparison.
|
||||||
* @param vWarehouseFk El identificador del almacén para filtrar los artículos.
|
* @param vWarehouseFk The warehouse identifier to filter the items.
|
||||||
* @param vAvailableSince La fecha de disponibilidad desde la cual se consideran los artículos disponibles.
|
* @param vAvailableSince The availability date from which the items are considered available.
|
||||||
* @param vBuyerFk El identificador del comprador para filtrar los artículos.
|
* @param vBuyerFk The buyer identifier to filter the items.
|
||||||
* @param vIsFloramondo Indica si se deben incluir solo los artículos de Floramondo (opcional).
|
* @param vIsFloramondo Indicates whether only Floramondo items should be included (optional).
|
||||||
* @param vCountryFk El identificador del país.
|
* @param vCountryFk The country identifier.
|
||||||
* @param tmp.comparativeFilterType(filterFk INT ,itemTypeFk INT)
|
* @param tmp.comparativeFilterType(filterFk INT, itemTypeFk INT)
|
||||||
* @return tmp.comparative
|
* @return tmp.comparative
|
||||||
*/
|
*/
|
||||||
|
|
||||||
DECLARE vDayRangeStart DATE;
|
DECLARE vDayRangeStart DATE;
|
||||||
DECLARE vDayRangeEnd DATE;
|
DECLARE vDayRangeEnd DATE;
|
||||||
DECLARE w1, w2, w3, w4, w5, w6, w7 INT;
|
DECLARE w1, w2, w3, w4, w5, w6, w7 INT;
|
||||||
|
|
|
@ -42,7 +42,7 @@ BEGIN
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
SELECT warehouseFk INTO vWarehouseFk
|
SELECT warehouseFk INTO vWarehouseFk
|
||||||
FROM userConfig
|
FROM userMultiConfig
|
||||||
WHERE userFk = account.myUser_getId();
|
WHERE userFk = account.myUser_getId();
|
||||||
|
|
||||||
IF NOT vWarehouseFk OR vWarehouseFk IS NULL THEN
|
IF NOT vWarehouseFk OR vWarehouseFk IS NULL THEN
|
||||||
|
@ -93,7 +93,7 @@ BEGIN
|
||||||
ORDER BY created DESC
|
ORDER BY created DESC
|
||||||
LIMIT 1;
|
LIMIT 1;
|
||||||
|
|
||||||
CALL buyUltimate(vWarehouseFk, vCurdate);
|
CALL buy_getUltimate(vSelf, vWarehouseFk, vCurdate);
|
||||||
|
|
||||||
SELECT b.entryFk, bu.buyFk,IFNULL(b.buyingValue, 0) INTO vLastEntryFk, vLastBuyFk, vBuyingValueOriginal
|
SELECT b.entryFk, bu.buyFk,IFNULL(b.buyingValue, 0) INTO vLastEntryFk, vLastBuyFk, vBuyingValueOriginal
|
||||||
FROM tmp.buyUltimate bu
|
FROM tmp.buyUltimate bu
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_getInfo`(IN `vBarcode` VARCHAR(22), IN `vWarehouseFk` INT)
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_getInfo`(
|
||||||
|
`vBarcode` VARCHAR(22),
|
||||||
|
`vWarehouseFk` INT
|
||||||
|
)
|
||||||
BEGIN
|
BEGIN
|
||||||
/**
|
/**
|
||||||
* Devuelve información relativa al item correspondiente del vBarcode pasado
|
* Devuelve información relativa al item correspondiente del vBarcode pasado
|
||||||
|
@ -11,12 +14,14 @@ BEGIN
|
||||||
DECLARE vCacheAvailableFk INT;
|
DECLARE vCacheAvailableFk INT;
|
||||||
DECLARE vVisibleItemShelving INT;
|
DECLARE vVisibleItemShelving INT;
|
||||||
DECLARE vItemFk INT;
|
DECLARE vItemFk INT;
|
||||||
|
DECLARE vDated DATE;
|
||||||
|
|
||||||
|
SELECT barcodeToItem(vBarcode), util.VN_CURDATE() INTO vItemFk, vDated;
|
||||||
|
|
||||||
CALL cache.visible_refresh(vCacheVisibleFk, FALSE, vWarehouseFk);
|
CALL cache.visible_refresh(vCacheVisibleFk, FALSE, vWarehouseFk);
|
||||||
CALL cache.available_refresh(vCacheAvailableFk, FALSE, vWarehouseFk, util.VN_CURDATE());
|
CALL cache.available_refresh(vCacheAvailableFk, FALSE, vWarehouseFk, vDated);
|
||||||
CALL buyUltimate(vWarehouseFk, util.VN_CURDATE());
|
CALL buy_getUltimate(vItemFk, vWarehouseFk, vDated);
|
||||||
|
|
||||||
SELECT barcodeToItem(vBarcode) INTO vItemFk;
|
|
||||||
SELECT SUM(visible) INTO vVisibleItemShelving
|
SELECT SUM(visible) INTO vVisibleItemShelving
|
||||||
FROM itemShelvingStock
|
FROM itemShelvingStock
|
||||||
WHERE itemFk = vItemFk
|
WHERE itemFk = vItemFk
|
||||||
|
|
|
@ -1,37 +1,40 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_getMinacum`(IN vWarehouseFk TINYINT, IN vDatedFrom DATETIME, IN vRange INT, IN vItemFk INT)
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_getMinacum`(
|
||||||
|
vWarehouseFk TINYINT,
|
||||||
|
vDated DATE,
|
||||||
|
vRange INT,
|
||||||
|
vItemFk INT
|
||||||
|
)
|
||||||
BEGIN
|
BEGIN
|
||||||
/**
|
/**
|
||||||
* Cálculo del mínimo acumulado, para un item/almacén especificado, en caso de
|
* Cálculo del mínimo acumulado, para un item/almacén
|
||||||
* NULL para todo.
|
* especificado, en caso de NULL para todos.
|
||||||
*
|
*
|
||||||
* @param vWarehouseFk -> warehouseFk
|
* @param vWarehouseFk Id warehouse
|
||||||
* @param vDatedFrom -> fecha inicio
|
* @param vDated Fecha inicio
|
||||||
* @param vRange -> número de días a considerar
|
* @param vRange Número de días a considerar
|
||||||
* @param vItemFk -> Identificador de item
|
* @param vItemFk Id de artículo
|
||||||
* @return tmp.itemMinacum
|
* @return tmp.itemMinacum
|
||||||
*/
|
*/
|
||||||
DECLARE vDatedTo DATETIME;
|
DECLARE vDatedTo DATETIME DEFAULT util.dayEnd(vDated + INTERVAL vRange DAY);
|
||||||
|
|
||||||
SET vDatedFrom = TIMESTAMP(DATE(vDatedFrom), '00:00:00');
|
CREATE OR REPLACE TEMPORARY TABLE tmp.itemCalc
|
||||||
SET vDatedTo = TIMESTAMP(TIMESTAMPADD(DAY, vRange, vDatedFrom), '23:59:59');
|
|
||||||
|
|
||||||
DROP TEMPORARY TABLE IF EXISTS tmp.itemCalc;
|
|
||||||
CREATE TEMPORARY TABLE tmp.itemCalc
|
|
||||||
(INDEX (itemFk, warehouseFk))
|
(INDEX (itemFk, warehouseFk))
|
||||||
|
ENGINE = MEMORY
|
||||||
SELECT sub.itemFk,
|
SELECT sub.itemFk,
|
||||||
sub.dated,
|
sub.dated,
|
||||||
CAST(SUM(sub.quantity) AS SIGNED) quantity,
|
CAST(SUM(sub.quantity) AS SIGNED) quantity,
|
||||||
sub.warehouseFk
|
sub.warehouseFk
|
||||||
FROM (SELECT s.itemFk,
|
FROM (
|
||||||
|
SELECT s.itemFk,
|
||||||
DATE(t.shipped) dated,
|
DATE(t.shipped) dated,
|
||||||
-s.quantity quantity,
|
-s.quantity quantity,
|
||||||
t.warehouseFk
|
t.warehouseFk
|
||||||
FROM sale s
|
FROM sale s
|
||||||
JOIN ticket t ON t.id = s.ticketFk
|
JOIN ticket t ON t.id = s.ticketFk
|
||||||
WHERE t.shipped BETWEEN vDatedFrom AND vDatedTo
|
WHERE t.shipped BETWEEN vDated AND vDatedTo
|
||||||
AND t.warehouseFk
|
AND t.warehouseFk
|
||||||
AND s.quantity != 0
|
AND s.quantity <> 0
|
||||||
AND (vItemFk IS NULL OR s.itemFk = vItemFk)
|
AND (vItemFk IS NULL OR s.itemFk = vItemFk)
|
||||||
AND (vWarehouseFk IS NULL OR t.warehouseFk = vWarehouseFk)
|
AND (vWarehouseFk IS NULL OR t.warehouseFk = vWarehouseFk)
|
||||||
UNION ALL
|
UNION ALL
|
||||||
|
@ -42,10 +45,10 @@ BEGIN
|
||||||
FROM buy b
|
FROM buy b
|
||||||
JOIN entry e ON e.id = b.entryFk
|
JOIN entry e ON e.id = b.entryFk
|
||||||
JOIN travel t ON t.id = e.travelFk
|
JOIN travel t ON t.id = e.travelFk
|
||||||
WHERE t.landed BETWEEN vDatedFrom AND vDatedTo
|
WHERE t.landed BETWEEN vDated AND vDatedTo
|
||||||
AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk)
|
AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk)
|
||||||
AND !e.isExcludedFromAvailable
|
AND NOT e.isExcludedFromAvailable
|
||||||
AND b.quantity != 0
|
AND b.quantity <> 0
|
||||||
AND (vItemFk IS NULL OR b.itemFk = vItemFk)
|
AND (vItemFk IS NULL OR b.itemFk = vItemFk)
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT b.itemFk,
|
SELECT b.itemFk,
|
||||||
|
@ -55,28 +58,45 @@ BEGIN
|
||||||
FROM buy b
|
FROM buy b
|
||||||
JOIN entry e ON e.id = b.entryFk
|
JOIN entry e ON e.id = b.entryFk
|
||||||
JOIN travel t ON t.id = e.travelFk
|
JOIN travel t ON t.id = e.travelFk
|
||||||
WHERE t.shipped BETWEEN vDatedFrom AND vDatedTo
|
WHERE t.shipped BETWEEN vDated AND vDatedTo
|
||||||
AND (vWarehouseFk IS NULL OR t.warehouseOutFk = vWarehouseFk)
|
AND (vWarehouseFk IS NULL OR t.warehouseOutFk = vWarehouseFk)
|
||||||
AND !e.isExcludedFromAvailable
|
AND NOT e.isExcludedFromAvailable
|
||||||
AND b.quantity != 0
|
AND b.quantity <> 0
|
||||||
AND (vItemFk IS NULL OR b.itemFk = vItemFk)
|
AND (vItemFk IS NULL OR b.itemFk = vItemFk)
|
||||||
AND !e.isRaid
|
AND NOT e.isRaid
|
||||||
|
UNION ALL
|
||||||
|
SELECT r.itemFk,
|
||||||
|
r.shipment,
|
||||||
|
-r.amount,
|
||||||
|
r.warehouseFk
|
||||||
|
FROM hedera.orderRow r
|
||||||
|
JOIN hedera.`order` o ON o.id = r.orderFk
|
||||||
|
JOIN client c ON c.id = o.customer_id
|
||||||
|
WHERE r.shipment BETWEEN vDated AND vDatedTo
|
||||||
|
AND (vWarehouseFk IS NULL OR r.warehouseFk = vWarehouseFk)
|
||||||
|
AND r.created >= (
|
||||||
|
SELECT util.VN_NOW() - INTERVAL TIME_TO_SEC(reserveTime) SECOND
|
||||||
|
FROM hedera.orderConfig
|
||||||
|
)
|
||||||
|
AND NOT o.confirmed
|
||||||
|
AND (vItemFk IS NULL OR r.itemFk = vItemFk)
|
||||||
|
AND r.amount <> 0
|
||||||
) sub
|
) sub
|
||||||
GROUP BY sub.itemFk, sub.warehouseFk, sub.dated;
|
GROUP BY sub.itemFk, sub.warehouseFk, sub.dated;
|
||||||
|
|
||||||
CALL item_getAtp(vDatedFrom);
|
CALL item_getAtp(vDated);
|
||||||
DROP TEMPORARY TABLE tmp.itemCalc;
|
|
||||||
|
|
||||||
DROP TEMPORARY TABLE IF EXISTS tmp.itemMinacum;
|
CREATE OR REPLACE TEMPORARY TABLE tmp.itemMinacum
|
||||||
CREATE TEMPORARY TABLE tmp.itemMinacum
|
|
||||||
(INDEX(itemFk))
|
(INDEX(itemFk))
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
SELECT i.itemFk,
|
SELECT itemFk,
|
||||||
i.warehouseFk,
|
warehouseFk,
|
||||||
i.quantity amount
|
quantity amount
|
||||||
FROM tmp.itemAtp i
|
FROM tmp.itemAtp
|
||||||
HAVING amount != 0;
|
WHERE quantity <> 0;
|
||||||
|
|
||||||
DROP TEMPORARY TABLE tmp.itemAtp;
|
DROP TEMPORARY TABLE
|
||||||
|
tmp.itemAtp,
|
||||||
|
tmp.itemCalc;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -13,7 +13,7 @@ BEGIN
|
||||||
*/
|
*/
|
||||||
ALTER TABLE tmp.itemInventory ADD IF NOT EXISTS buy_id INT;
|
ALTER TABLE tmp.itemInventory ADD IF NOT EXISTS buy_id INT;
|
||||||
|
|
||||||
CALL buyUltimate(vWarehouseFk, vDate);
|
CALL buy_getUltimate (NULL, vWarehouseFk, vDate);
|
||||||
|
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tmp
|
CREATE OR REPLACE TEMPORARY TABLE tmp
|
||||||
(KEY (itemFk))
|
(KEY (itemFk))
|
||||||
|
|
|
@ -46,12 +46,18 @@ BEGIN
|
||||||
i.tag8 = JSON_VALUE(vTags, '$.8'),
|
i.tag8 = JSON_VALUE(vTags, '$.8'),
|
||||||
i.tag9 = JSON_VALUE(vTags, '$.9'),
|
i.tag9 = JSON_VALUE(vTags, '$.9'),
|
||||||
i.tag10 = JSON_VALUE(vTags, '$.10'),
|
i.tag10 = JSON_VALUE(vTags, '$.10'),
|
||||||
|
i.tag11 = JSON_VALUE(vTags, '$.11'),
|
||||||
|
i.tag12 = JSON_VALUE(vTags, '$.12'),
|
||||||
|
i.tag13 = JSON_VALUE(vTags, '$.13'),
|
||||||
i.value5 = JSON_VALUE(vValues, '$.5'),
|
i.value5 = JSON_VALUE(vValues, '$.5'),
|
||||||
i.value6 = JSON_VALUE(vValues, '$.6'),
|
i.value6 = JSON_VALUE(vValues, '$.6'),
|
||||||
i.value7 = JSON_VALUE(vValues, '$.7'),
|
i.value7 = JSON_VALUE(vValues, '$.7'),
|
||||||
i.value8 = JSON_VALUE(vValues, '$.8'),
|
i.value8 = JSON_VALUE(vValues, '$.8'),
|
||||||
i.value9 = JSON_VALUE(vValues, '$.9'),
|
i.value9 = JSON_VALUE(vValues, '$.9'),
|
||||||
i.value10 = JSON_VALUE(vValues, '$.10'),
|
i.value10 = JSON_VALUE(vValues, '$.10'),
|
||||||
|
i.value11 = JSON_VALUE(vValues, '$.11'),
|
||||||
|
i.value12 = JSON_VALUE(vValues, '$.12'),
|
||||||
|
i.value13 = JSON_VALUE(vValues, '$.13'),
|
||||||
i.producerFk = p.id,
|
i.producerFk = p.id,
|
||||||
i.inkFk = k.id,
|
i.inkFk = k.id,
|
||||||
i.originFk = IFNULL(o.id, i.originFk)
|
i.originFk = IFNULL(o.id, i.originFk)
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_valuateInventory`(
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_valuateInventory`(
|
||||||
vDated DATE
|
vDated DATE,
|
||||||
|
vItemTypeFk INT,
|
||||||
|
vItemCategoryFk INT
|
||||||
)
|
)
|
||||||
BEGIN
|
BEGIN
|
||||||
DECLARE vInventoried DATE;
|
DECLARE vInventoried DATE;
|
||||||
|
@ -61,11 +63,14 @@ BEGIN
|
||||||
JOIN `entry` e ON e.id = b.entryFk
|
JOIN `entry` e ON e.id = b.entryFk
|
||||||
JOIN travel tr ON tr.id = e.travelFk
|
JOIN travel tr ON tr.id = e.travelFk
|
||||||
JOIN itemType t ON t.id = i.typeFk
|
JOIN itemType t ON t.id = i.typeFk
|
||||||
|
JOIN itemCategory ic ON ic.id = t.categoryFk
|
||||||
JOIN warehouse w ON w.id = tr.warehouseInFk
|
JOIN warehouse w ON w.id = tr.warehouseInFk
|
||||||
WHERE tr.landed = vDateDayEnd
|
WHERE tr.landed = vDateDayEnd
|
||||||
AND e.supplierFk = vInventorySupplierFk
|
AND e.supplierFk = vInventorySupplierFk
|
||||||
AND w.valuatedInventory
|
AND w.valuatedInventory
|
||||||
AND t.isInventory
|
AND t.isInventory
|
||||||
|
AND (t.id = vItemTypeFk OR vItemTypeFk IS NULL)
|
||||||
|
AND (ic.id = vItemCategoryFk OR vItemCategoryFk IS NULL)
|
||||||
GROUP BY tr.warehouseInFk, b.itemFk;
|
GROUP BY tr.warehouseInFk, b.itemFk;
|
||||||
ELSE
|
ELSE
|
||||||
INSERT INTO tInventory(warehouseFk, itemFk, quantity, warehouseInventory)
|
INSERT INTO tInventory(warehouseFk, itemFk, quantity, warehouseInventory)
|
||||||
|
@ -78,11 +83,14 @@ BEGIN
|
||||||
JOIN `entry` e ON e.id = b.entryFk
|
JOIN `entry` e ON e.id = b.entryFk
|
||||||
JOIN travel tr ON tr.id = e.travelFk
|
JOIN travel tr ON tr.id = e.travelFk
|
||||||
JOIN itemType t ON t.id = i.typeFk
|
JOIN itemType t ON t.id = i.typeFk
|
||||||
|
JOIN itemCategory ic ON ic.id = t.categoryFk
|
||||||
JOIN warehouse w ON w.id = tr.warehouseInFk
|
JOIN warehouse w ON w.id = tr.warehouseInFk
|
||||||
WHERE tr.landed = vInventoried
|
WHERE tr.landed = vInventoried
|
||||||
AND e.supplierFk = vInventorySupplierFk
|
AND e.supplierFk = vInventorySupplierFk
|
||||||
AND w.valuatedInventory
|
AND w.valuatedInventory
|
||||||
AND t.isInventory
|
AND t.isInventory
|
||||||
|
AND (t.id = vItemTypeFk OR vItemTypeFk IS NULL)
|
||||||
|
AND (ic.id = vItemCategoryFk OR vItemCategoryFk IS NULL)
|
||||||
GROUP BY tr.warehouseInFk, b.itemFk;
|
GROUP BY tr.warehouseInFk, b.itemFk;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
|
@ -97,6 +105,7 @@ BEGIN
|
||||||
JOIN `entry` e ON e.id = b.entryFk
|
JOIN `entry` e ON e.id = b.entryFk
|
||||||
JOIN travel tr ON tr.id = e.travelFk
|
JOIN travel tr ON tr.id = e.travelFk
|
||||||
JOIN itemType t ON t.id = i.typeFk
|
JOIN itemType t ON t.id = i.typeFk
|
||||||
|
JOIN itemCategory ic ON ic.id = t.categoryFk
|
||||||
JOIN warehouse w ON w.id = tr.warehouseInFk
|
JOIN warehouse w ON w.id = tr.warehouseInFk
|
||||||
WHERE tr.landed BETWEEN vInventoried AND vDateDayEnd
|
WHERE tr.landed BETWEEN vInventoried AND vDateDayEnd
|
||||||
AND IF(tr.landed = util.VN_CURDATE(), tr.isReceived, TRUE)
|
AND IF(tr.landed = util.VN_CURDATE(), tr.isReceived, TRUE)
|
||||||
|
@ -104,6 +113,8 @@ BEGIN
|
||||||
AND w.valuatedInventory
|
AND w.valuatedInventory
|
||||||
AND t.isInventory
|
AND t.isInventory
|
||||||
AND e.supplierFk <> vInventorySupplierFk
|
AND e.supplierFk <> vInventorySupplierFk
|
||||||
|
AND (t.id = vItemTypeFk OR vItemTypeFk IS NULL)
|
||||||
|
AND (ic.id = vItemCategoryFk OR vItemCategoryFk IS NULL)
|
||||||
ON DUPLICATE KEY UPDATE tInventory.quantity = tInventory.quantity + (b.quantity * IF(vHasNotInventory, -1, 1));
|
ON DUPLICATE KEY UPDATE tInventory.quantity = tInventory.quantity + (b.quantity * IF(vHasNotInventory, -1, 1));
|
||||||
|
|
||||||
-- Descontamos las salidas
|
-- Descontamos las salidas
|
||||||
|
@ -117,11 +128,14 @@ BEGIN
|
||||||
JOIN `entry` e ON e.id = b.entryFk
|
JOIN `entry` e ON e.id = b.entryFk
|
||||||
JOIN travel tr ON tr.id = e.travelFk
|
JOIN travel tr ON tr.id = e.travelFk
|
||||||
JOIN itemType t ON t.id = i.typeFk
|
JOIN itemType t ON t.id = i.typeFk
|
||||||
|
JOIN itemCategory ic ON ic.id = t.categoryFk
|
||||||
JOIN warehouse w ON w.id = tr.warehouseOutFk
|
JOIN warehouse w ON w.id = tr.warehouseOutFk
|
||||||
WHERE tr.shipped BETWEEN vInventoried AND vDateDayEnd
|
WHERE tr.shipped BETWEEN vInventoried AND vDateDayEnd
|
||||||
AND NOT e.isRaid
|
AND NOT e.isRaid
|
||||||
AND w.valuatedInventory
|
AND w.valuatedInventory
|
||||||
AND t.isInventory
|
AND t.isInventory
|
||||||
|
AND (t.id = vItemTypeFk OR vItemTypeFk IS NULL)
|
||||||
|
AND (ic.id = vItemCategoryFk OR vItemCategoryFk IS NULL)
|
||||||
ON DUPLICATE KEY UPDATE tInventory.quantity = tInventory.quantity + (b.quantity * IF(vHasNotInventory,1,-1));
|
ON DUPLICATE KEY UPDATE tInventory.quantity = tInventory.quantity + (b.quantity * IF(vHasNotInventory,1,-1));
|
||||||
|
|
||||||
-- Descontamos las lineas de venta
|
-- Descontamos las lineas de venta
|
||||||
|
@ -135,10 +149,13 @@ BEGIN
|
||||||
JOIN `client` c ON c.id = t.clientFk
|
JOIN `client` c ON c.id = t.clientFk
|
||||||
JOIN item i ON i.id = s.itemFk
|
JOIN item i ON i.id = s.itemFk
|
||||||
JOIN itemType it ON it.id = i.typeFk
|
JOIN itemType it ON it.id = i.typeFk
|
||||||
|
JOIN itemCategory ic ON ic.id = it.categoryFk
|
||||||
JOIN warehouse w ON w.id = t.warehouseFk
|
JOIN warehouse w ON w.id = t.warehouseFk
|
||||||
WHERE t.shipped BETWEEN vInventoried AND vDateDayEnd
|
WHERE t.shipped BETWEEN vInventoried AND vDateDayEnd
|
||||||
AND w.valuatedInventory
|
AND w.valuatedInventory
|
||||||
AND it.isInventory
|
AND it.isInventory
|
||||||
|
AND (it.id = vItemTypeFk OR vItemTypeFk IS NULL)
|
||||||
|
AND (ic.id = vItemCategoryFk OR vItemCategoryFk IS NULL)
|
||||||
ON DUPLICATE KEY UPDATE tInventory.quantity = tInventory.quantity + s.quantity * IF(vHasNotInventory, 1, -1);
|
ON DUPLICATE KEY UPDATE tInventory.quantity = tInventory.quantity + s.quantity * IF(vHasNotInventory, 1, -1);
|
||||||
|
|
||||||
-- Volver a poner lo que esta aun en las estanterias
|
-- Volver a poner lo que esta aun en las estanterias
|
||||||
|
@ -153,11 +170,14 @@ BEGIN
|
||||||
JOIN `client` c ON c.id = t.clientFk
|
JOIN `client` c ON c.id = t.clientFk
|
||||||
JOIN item i ON i.id = s.itemFk
|
JOIN item i ON i.id = s.itemFk
|
||||||
JOIN itemType it ON it.id = i.typeFk
|
JOIN itemType it ON it.id = i.typeFk
|
||||||
|
JOIN itemCategory ic ON ic.id = it.categoryFk
|
||||||
JOIN warehouse w ON w.id = t.warehouseFk
|
JOIN warehouse w ON w.id = t.warehouseFk
|
||||||
WHERE t.shipped BETWEEN vDated AND vDateDayEnd
|
WHERE t.shipped BETWEEN vDated AND vDateDayEnd
|
||||||
AND NOT (s.isPicked OR t.isLabeled)
|
AND NOT (s.isPicked OR t.isLabeled)
|
||||||
AND w.valuatedInventory
|
AND w.valuatedInventory
|
||||||
AND it.isInventory
|
AND it.isInventory
|
||||||
|
AND (it.id = vItemTypeFk OR vItemTypeFk IS NULL)
|
||||||
|
AND (ic.id = vItemCategoryFk OR vItemCategoryFk IS NULL)
|
||||||
ON DUPLICATE KEY UPDATE tInventory.quantity = tInventory.quantity + s.quantity * IF(vHasNotInventory, 0, 1);
|
ON DUPLICATE KEY UPDATE tInventory.quantity = tInventory.quantity + s.quantity * IF(vHasNotInventory, 0, 1);
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
|
@ -172,6 +192,7 @@ BEGIN
|
||||||
JOIN `entry` e ON e.id = b.entryFk
|
JOIN `entry` e ON e.id = b.entryFk
|
||||||
JOIN travel tr ON tr.id = e.travelFk
|
JOIN travel tr ON tr.id = e.travelFk
|
||||||
JOIN itemType t ON t.id = i.typeFk
|
JOIN itemType t ON t.id = i.typeFk
|
||||||
|
JOIN itemCategory ic ON ic.id = t.categoryFk
|
||||||
JOIN warehouse wIn ON wIn.id = tr.warehouseInFk
|
JOIN warehouse wIn ON wIn.id = tr.warehouseInFk
|
||||||
JOIN warehouse wOut ON wOut.id = tr.warehouseOutFk
|
JOIN warehouse wOut ON wOut.id = tr.warehouseOutFk
|
||||||
WHERE vDated >= tr.shipped AND vDated < tr.landed
|
WHERE vDated >= tr.shipped AND vDated < tr.landed
|
||||||
|
@ -179,9 +200,11 @@ BEGIN
|
||||||
AND wIn.valuatedInventory
|
AND wIn.valuatedInventory
|
||||||
AND t.isInventory
|
AND t.isInventory
|
||||||
AND e.isConfirmed
|
AND e.isConfirmed
|
||||||
|
AND (t.id = vItemTypeFk OR vItemTypeFk IS NULL)
|
||||||
|
AND (ic.id = vItemCategoryFk OR vItemCategoryFk IS NULL)
|
||||||
ON DUPLICATE KEY UPDATE tInventory.quantity = tInventory.quantity + (b.quantity);
|
ON DUPLICATE KEY UPDATE tInventory.quantity = tInventory.quantity + (b.quantity);
|
||||||
|
|
||||||
CALL buyUltimate(NULL, vDateDayEnd);
|
CALL buy_getUltimate (NULL, NULL, vDateDayEnd);
|
||||||
|
|
||||||
DELETE FROM tInventory WHERE quantity IS NULL OR NOT quantity;
|
DELETE FROM tInventory WHERE quantity IS NULL OR NOT quantity;
|
||||||
|
|
||||||
|
@ -204,7 +227,8 @@ BEGIN
|
||||||
ic.name itemCategoryName,
|
ic.name itemCategoryName,
|
||||||
ti.cost,
|
ti.cost,
|
||||||
ti.total,
|
ti.total,
|
||||||
ti.warehouseInventory
|
ti.warehouseInventory,
|
||||||
|
ic.display
|
||||||
FROM tInventory ti
|
FROM tInventory ti
|
||||||
JOIN warehouse w ON w.id = warehouseFk
|
JOIN warehouse w ON w.id = warehouseFk
|
||||||
JOIN item i ON i.id = ti.itemFk
|
JOIN item i ON i.id = ti.itemFk
|
||||||
|
|
|
@ -139,31 +139,35 @@ proc: BEGIN
|
||||||
CALL item_getAtp(vDate);
|
CALL item_getAtp(vDate);
|
||||||
CALL travel_upcomingArrivals(vWarehouseFk, vDate);
|
CALL travel_upcomingArrivals(vWarehouseFk, vDate);
|
||||||
|
|
||||||
UPDATE tmp.itemInventory ai
|
CREATE OR REPLACE TEMPORARY TABLE tItemAvailableCalc
|
||||||
JOIN (
|
(PRIMARY KEY (itemFk))
|
||||||
SELECT it.itemFk,
|
ENGINE = MEMORY
|
||||||
SUM(it.quantity) quantity,
|
SELECT it.itemFk,
|
||||||
im.quantity minQuantity
|
SUM(it.quantity) quantity,
|
||||||
FROM tmp.itemCalc it
|
im.quantity minQuantity
|
||||||
JOIN tmp.itemAtp im ON im.itemFk = it.itemFk
|
FROM tmp.itemCalc it
|
||||||
JOIN item i ON i.id = it.itemFk
|
JOIN tmp.itemAtp im ON im.itemFk = it.itemFk
|
||||||
LEFT JOIN origin o ON o.id = i.originFk
|
JOIN item i ON i.id = it.itemFk
|
||||||
LEFT JOIN tmp.itemTravel t ON t.wh = o.warehouseFk
|
LEFT JOIN origin o ON o.id = i.originFk
|
||||||
WHERE it.dated < IF(vMaxDays < 0 AND t.landing IS NOT NULL,
|
LEFT JOIN tmp.itemTravel t ON t.wh = o.warehouseFk
|
||||||
t.landing,
|
WHERE it.dated < IF(vMaxDays < 0 AND t.landing IS NOT NULL,
|
||||||
vDateToTomorrow)
|
t.landing,
|
||||||
GROUP BY it.itemFk
|
vDateToTomorrow)
|
||||||
) sub ON sub.itemFk = ai.id
|
GROUP BY it.itemFk;
|
||||||
SET ai.avalaible = IF(sub.minQuantity > 0,
|
|
||||||
ai.avalaible,
|
UPDATE tmp.itemInventory it
|
||||||
ai.avalaible + sub.minQuantity),
|
JOIN tItemAvailableCalc iac ON iac.itemFk = it.id
|
||||||
ai.sd = ai.inventory + sub.quantity;
|
SET it.avalaible = IF(iac.minQuantity > 0,
|
||||||
|
it.avalaible,
|
||||||
|
it.avalaible + iac.minQuantity),
|
||||||
|
it.sd = it.inventory + iac.quantity;
|
||||||
|
|
||||||
DROP TEMPORARY TABLE
|
DROP TEMPORARY TABLE
|
||||||
tmp.itemTravel,
|
tmp.itemTravel,
|
||||||
tmp.itemCalc,
|
tmp.itemCalc,
|
||||||
tmp.itemAtp,
|
tmp.itemAtp,
|
||||||
tItemInventoryCalc,
|
tItemInventoryCalc,
|
||||||
tItemVisibleCalc;
|
tItemVisibleCalc,
|
||||||
|
tItemAvailableCalc;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -174,27 +174,30 @@ proc: BEGIN
|
||||||
WHERE NOT `lines`;
|
WHERE NOT `lines`;
|
||||||
|
|
||||||
-- Lineas por linea de encajado
|
-- Lineas por linea de encajado
|
||||||
|
CREATE OR REPLACE TEMPORARY TABLE tItemPackingType
|
||||||
|
(PRIMARY KEY(ticketFk))
|
||||||
|
ENGINE = MEMORY
|
||||||
|
SELECT ticketFk,
|
||||||
|
SUM(sub.H) H,
|
||||||
|
SUM(sub.V) V,
|
||||||
|
SUM(sub.N) N
|
||||||
|
FROM (
|
||||||
|
SELECT t.ticketFk,
|
||||||
|
SUM(i.itemPackingTypeFk = 'H') H,
|
||||||
|
SUM(i.itemPackingTypeFk = 'V') V,
|
||||||
|
SUM(i.itemPackingTypeFk IS NULL) N
|
||||||
|
FROM tmp.productionTicket t
|
||||||
|
JOIN sale s ON s.ticketFk = t.ticketFk
|
||||||
|
JOIN item i ON i.id = s.itemFk
|
||||||
|
GROUP BY t.ticketFk, i.itemPackingTypeFk
|
||||||
|
) sub
|
||||||
|
GROUP BY ticketFk;
|
||||||
|
|
||||||
UPDATE tmp.productionBuffer pb
|
UPDATE tmp.productionBuffer pb
|
||||||
JOIN (
|
JOIN tItemPackingType ti ON ti.ticketFk = pb.ticketFk
|
||||||
SELECT ticketFk,
|
SET pb.H = ti.H,
|
||||||
SUM(sub.H) H,
|
pb.V = ti.V,
|
||||||
SUM(sub.V) V,
|
pb.N = ti.N;
|
||||||
SUM(sub.N) N
|
|
||||||
FROM (
|
|
||||||
SELECT t.ticketFk,
|
|
||||||
SUM(i.itemPackingTypeFk = 'H') H,
|
|
||||||
SUM(i.itemPackingTypeFk = 'V') V,
|
|
||||||
SUM(i.itemPackingTypeFk IS NULL) N
|
|
||||||
FROM tmp.productionTicket t
|
|
||||||
JOIN sale s ON s.ticketFk = t.ticketFk
|
|
||||||
JOIN item i ON i.id = s.itemFk
|
|
||||||
GROUP BY t.ticketFk, i.itemPackingTypeFk
|
|
||||||
) sub
|
|
||||||
GROUP BY ticketFk
|
|
||||||
) sub2 ON sub2.ticketFk = pb.ticketFk
|
|
||||||
SET pb.H = sub2.H,
|
|
||||||
pb.V = sub2.V,
|
|
||||||
pb.N = sub2.N;
|
|
||||||
|
|
||||||
-- Colecciones segun tipo de encajado
|
-- Colecciones segun tipo de encajado
|
||||||
UPDATE tmp.productionBuffer pb
|
UPDATE tmp.productionBuffer pb
|
||||||
|
@ -273,6 +276,7 @@ proc: BEGIN
|
||||||
tmp.risk,
|
tmp.risk,
|
||||||
tmp.ticket_problems,
|
tmp.ticket_problems,
|
||||||
tmp.ticketWithPrevia,
|
tmp.ticketWithPrevia,
|
||||||
tItemShelvingStock;
|
tItemShelvingStock,
|
||||||
|
tItemPackingType;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -1,14 +1,18 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`route_updateM3`(vRoute INT)
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`route_updateM3`(
|
||||||
|
vSelf INT
|
||||||
|
)
|
||||||
BEGIN
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Actualiza el volumen de la ruta.
|
||||||
|
*
|
||||||
|
* @param vSelf Id ruta
|
||||||
|
*/
|
||||||
|
DECLARE vVolume DECIMAL(10,1)
|
||||||
|
DEFAULT (SELECT SUM(volume) FROM saleVolume WHERE routeFk = vSelf);
|
||||||
|
|
||||||
UPDATE vn.route r
|
UPDATE `route`
|
||||||
LEFT JOIN (
|
SET m3 = IFNULL(vVolume, 0)
|
||||||
SELECT routeFk, SUM(volume) AS m3
|
WHERE id = vSelf;
|
||||||
FROM saleVolume
|
|
||||||
WHERE routeFk = vRoute
|
|
||||||
) v ON v.routeFk = r.id
|
|
||||||
SET r.m3 = IFNULL(v.m3,0)
|
|
||||||
WHERE r.id =vRoute;
|
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -10,15 +10,10 @@ BEGIN
|
||||||
* @param vSaleGroupFk id de la preparación previa
|
* @param vSaleGroupFk id de la preparación previa
|
||||||
* @param vParkingFk id del parking
|
* @param vParkingFk id del parking
|
||||||
*/
|
*/
|
||||||
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
|
||||||
BEGIN
|
|
||||||
RESIGNAL;
|
|
||||||
END;
|
|
||||||
|
|
||||||
UPDATE saleGroup sg
|
UPDATE saleGroup sg
|
||||||
SET sg.parkingFk = vParkingFk
|
SET sg.parkingFk = vParkingFk
|
||||||
WHERE sg.id = vSaleGroupFk
|
WHERE sg.id = vSaleGroupFk
|
||||||
AND sg.created >= util.VN_CURDATE() - INTERVAL 1 WEEK;
|
AND sg.created >= util.VN_CURDATE() - INTERVAL 1 WEEK;
|
||||||
|
|
||||||
CALL ticket_setNextState(ticket_get(vSaleGroupFk));
|
CALL ticket_setNextState(ticket_get(vSaleGroupFk));
|
||||||
END$$
|
END$$
|
||||||
|
|
|
@ -13,7 +13,7 @@ BEGIN
|
||||||
DECLARE vAvailableCache INT;
|
DECLARE vAvailableCache INT;
|
||||||
DECLARE vVisibleCache INT;
|
DECLARE vVisibleCache INT;
|
||||||
DECLARE vDone BOOL;
|
DECLARE vDone BOOL;
|
||||||
DECLARE vComponentCount INT;
|
DECLARE vRequiredComponent INT;
|
||||||
|
|
||||||
DECLARE vCursor CURSOR FOR
|
DECLARE vCursor CURSOR FOR
|
||||||
SELECT DISTINCT tt.warehouseFk, IF(vIsTodayRelative, util.VN_CURDATE(), DATE(tt.shipped))
|
SELECT DISTINCT tt.warehouseFk, IF(vIsTodayRelative, util.VN_CURDATE(), DATE(tt.shipped))
|
||||||
|
@ -54,7 +54,7 @@ BEGIN
|
||||||
SELECT ticketFk, clientFk
|
SELECT ticketFk, clientFk
|
||||||
FROM tmp.sale_getProblems;
|
FROM tmp.sale_getProblems;
|
||||||
|
|
||||||
SELECT COUNT(*) INTO vComponentCount
|
SELECT COUNT(*) INTO vRequiredComponent
|
||||||
FROM component
|
FROM component
|
||||||
WHERE isRequired;
|
WHERE isRequired;
|
||||||
|
|
||||||
|
@ -96,20 +96,18 @@ BEGIN
|
||||||
|
|
||||||
-- Faltan componentes
|
-- Faltan componentes
|
||||||
INSERT INTO tmp.sale_problems(ticketFk, hasComponentLack, saleFk)
|
INSERT INTO tmp.sale_problems(ticketFk, hasComponentLack, saleFk)
|
||||||
SELECT ticketFk, (vComponentCount > nComp) hasComponentLack, saleFk
|
SELECT t.id, COUNT(c.id) < vRequiredComponent hasComponentLack, s.id
|
||||||
FROM (
|
FROM tmp.ticket_list tl
|
||||||
SELECT COUNT(s.id) nComp, tl.ticketFk, s.id saleFk
|
JOIN ticket t ON t.id = tl.ticketFk
|
||||||
FROM tmp.ticket_list tl
|
JOIN sale s ON s.ticketFk = t.id
|
||||||
JOIN sale s ON s.ticketFk = tl.ticketFk
|
JOIN agencyMode am ON am.id = t.agencyModeFk
|
||||||
LEFT JOIN saleComponent sc ON sc.saleFk = s.id
|
JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk
|
||||||
LEFT JOIN component c ON c.id = sc.componentFk AND c.isRequired
|
LEFT JOIN saleComponent sc ON sc.saleFk = s.id
|
||||||
JOIN ticket t ON t.id = tl.ticketFk
|
LEFT JOIN component c ON c.id = sc.componentFk
|
||||||
JOIN agencyMode am ON am.id = t.agencyModeFk
|
AND c.isRequired
|
||||||
JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk
|
WHERE dm.code IN ('AGENCY','DELIVERY','PICKUP')
|
||||||
WHERE dm.code IN ('AGENCY','DELIVERY','PICKUP')
|
AND s.quantity > 0
|
||||||
AND s.quantity > 0
|
GROUP BY s.id
|
||||||
GROUP BY s.id
|
|
||||||
) sub
|
|
||||||
HAVING hasComponentLack;
|
HAVING hasComponentLack;
|
||||||
|
|
||||||
-- Cliente congelado
|
-- Cliente congelado
|
||||||
|
@ -276,7 +274,7 @@ BEGIN
|
||||||
ON DUPLICATE KEY UPDATE itemDelay = sub.problem, saleFk = sub.saleFk;
|
ON DUPLICATE KEY UPDATE itemDelay = sub.problem, saleFk = sub.saleFk;
|
||||||
|
|
||||||
-- Redondeo: Cantidad pedida incorrecta en al grouping de la última compra
|
-- Redondeo: Cantidad pedida incorrecta en al grouping de la última compra
|
||||||
CALL buyUltimate(vWarehouseFk, vDate);
|
CALL buy_getUltimate(NULL, vWarehouseFk, vDate);
|
||||||
INSERT INTO tmp.sale_problems(ticketFk, hasRounding, saleFk)
|
INSERT INTO tmp.sale_problems(ticketFk, hasRounding, saleFk)
|
||||||
SELECT ticketFk, problem ,saleFk
|
SELECT ticketFk, problem ,saleFk
|
||||||
FROM (
|
FROM (
|
||||||
|
|
|
@ -78,7 +78,7 @@ proc: BEGIN
|
||||||
DROP TEMPORARY TABLE tmp.zoneGetLanded;
|
DROP TEMPORARY TABLE tmp.zoneGetLanded;
|
||||||
|
|
||||||
-- rellena la tabla buyUltimate con la ultima compra
|
-- rellena la tabla buyUltimate con la ultima compra
|
||||||
CALL buyUltimate (vWarehouseFk, vShipped);
|
CALL buy_getUltimate(NULL, vWarehouseFk, vShipped);
|
||||||
|
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tmp.sale
|
CREATE OR REPLACE TEMPORARY TABLE tmp.sale
|
||||||
(PRIMARY KEY (saleFk)) ENGINE = MEMORY
|
(PRIMARY KEY (saleFk)) ENGINE = MEMORY
|
||||||
|
|
|
@ -53,7 +53,7 @@ BEGIN
|
||||||
JOIN ticket t ON t.id = s.ticketFk
|
JOIN ticket t ON t.id = s.ticketFk
|
||||||
WHERE s.id = vSaleFk;
|
WHERE s.id = vSaleFk;
|
||||||
|
|
||||||
CALL buyUltimate(vWarehouseFk, vDate);
|
CALL buy_getUltimate(vNewItemFk, vWarehouseFk, vDate);
|
||||||
|
|
||||||
SELECT `grouping`, groupingMode, packing
|
SELECT `grouping`, groupingMode, packing
|
||||||
INTO vGrouping,vGroupingMode,vPacking
|
INTO vGrouping,vGroupingMode,vPacking
|
||||||
|
@ -61,6 +61,8 @@ BEGIN
|
||||||
JOIN tmp.buyUltimate tmp ON b.id = tmp.buyFk
|
JOIN tmp.buyUltimate tmp ON b.id = tmp.buyFk
|
||||||
WHERE tmp.itemFk = vNewItemFk AND tmp.WarehouseFk = vWarehouseFk;
|
WHERE tmp.itemFk = vNewItemFk AND tmp.WarehouseFk = vWarehouseFk;
|
||||||
|
|
||||||
|
DROP TEMPORARY TABLE tmp.buyUltimate;
|
||||||
|
|
||||||
IF vGroupingMode = 'packing' AND vPacking > 0 THEN
|
IF vGroupingMode = 'packing' AND vPacking > 0 THEN
|
||||||
SET vRoundQuantity = vPacking;
|
SET vRoundQuantity = vPacking;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
|
@ -11,24 +11,29 @@ BEGIN
|
||||||
*/
|
*/
|
||||||
DECLARE vSaleFk INT;
|
DECLARE vSaleFk INT;
|
||||||
DECLARE vHasProblem INT;
|
DECLARE vHasProblem INT;
|
||||||
|
DECLARE vIsProblemCalcNeeded BOOL;
|
||||||
DECLARE vDone BOOL;
|
DECLARE vDone BOOL;
|
||||||
DECLARE vSaleList CURSOR FOR SELECT saleFk, hasProblem FROM tmp.sale;
|
DECLARE vSaleList CURSOR FOR
|
||||||
|
SELECT saleFk, hasProblem, isProblemCalcNeeded
|
||||||
|
FROM tmp.sale;
|
||||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||||
|
|
||||||
OPEN vSaleList;
|
OPEN vSaleList;
|
||||||
l: LOOP
|
l: LOOP
|
||||||
SET vDone = FALSE;
|
SET vDone = FALSE;
|
||||||
FETCH vSaleList INTO vSaleFk, vHasProblem;
|
FETCH vSaleList INTO vSaleFk, vHasProblem, vIsProblemCalcNeeded;
|
||||||
|
|
||||||
IF vDone THEN
|
IF vDone THEN
|
||||||
LEAVE l;
|
LEAVE l;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
UPDATE sale
|
UPDATE sale
|
||||||
SET problem = CONCAT(
|
SET problem = IF (vIsProblemCalcNeeded,
|
||||||
IF(vHasProblem,
|
CONCAT(
|
||||||
CONCAT(problem, ',', vProblemCode),
|
IF(vHasProblem,
|
||||||
REPLACE(problem, vProblemCode , '')))
|
CONCAT(problem, ',', vProblemCode),
|
||||||
|
REPLACE(problem, vProblemCode , ''))),
|
||||||
|
NULL)
|
||||||
WHERE id = vSaleFk;
|
WHERE id = vSaleFk;
|
||||||
END LOOP;
|
END LOOP;
|
||||||
CLOSE vSaleList;
|
CLOSE vSaleList;
|
||||||
|
|
|
@ -14,7 +14,7 @@ BEGIN
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
SELECT vSelf saleFk,
|
SELECT vSelf saleFk,
|
||||||
sale_hasComponentLack(vSelf) hasProblem,
|
sale_hasComponentLack(vSelf) hasProblem,
|
||||||
ticket_isProblemCalcNeeded(ticketFk) isProblemCalcNeeded
|
(ticket_isProblemCalcNeeded(ticketFk) AND quantity > 0) isProblemCalcNeeded
|
||||||
FROM sale
|
FROM sale
|
||||||
WHERE id = vSelf;
|
WHERE id = vSelf;
|
||||||
|
|
||||||
|
|
|
@ -14,9 +14,9 @@ BEGIN
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
SELECT saleFk,
|
SELECT saleFk,
|
||||||
sale_hasComponentLack(saleFk) hasProblem,
|
sale_hasComponentLack(saleFk) hasProblem,
|
||||||
ticket_isProblemCalcNeeded(ticketFk) isProblemCalcNeeded
|
(ticket_isProblemCalcNeeded(ticketFk) AND quantity > 0) isProblemCalcNeeded
|
||||||
FROM (
|
FROM (
|
||||||
SELECT s.id saleFk, s.ticketFk
|
SELECT s.id saleFk, s.ticketFk, s.quantity
|
||||||
FROM ticket t
|
FROM ticket t
|
||||||
JOIN sale s ON s.ticketFk = t.id
|
JOIN sale s ON s.ticketFk = t.id
|
||||||
LEFT JOIN saleComponent sc ON sc.saleFk = s.id
|
LEFT JOIN saleComponent sc ON sc.saleFk = s.id
|
||||||
|
|
|
@ -19,7 +19,7 @@ BEGIN
|
||||||
JOIN ticket t ON t.id = s.ticketFk
|
JOIN ticket t ON t.id = s.ticketFk
|
||||||
WHERE s.id = vSelf;
|
WHERE s.id = vSelf;
|
||||||
|
|
||||||
CALL buyUltimate(vWarehouseFk, vShipped);
|
CALL buy_getUltimate(vItemFk, vWarehouseFk, vShipped);
|
||||||
|
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tmp.sale
|
CREATE OR REPLACE TEMPORARY TABLE tmp.sale
|
||||||
SELECT vSelf saleFk,
|
SELECT vSelf saleFk,
|
||||||
|
|
|
@ -13,12 +13,6 @@ BEGIN
|
||||||
DECLARE vParkingFk INT;
|
DECLARE vParkingFk INT;
|
||||||
DECLARE vLastWeek DATE;
|
DECLARE vLastWeek DATE;
|
||||||
|
|
||||||
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
|
||||||
BEGIN
|
|
||||||
ROLLBACK;
|
|
||||||
RESIGNAL;
|
|
||||||
END;
|
|
||||||
|
|
||||||
SET vParkingCode = REPLACE(vParkingCode, ' ', '');
|
SET vParkingCode = REPLACE(vParkingCode, ' ', '');
|
||||||
|
|
||||||
SELECT id INTO vParkingFk
|
SELECT id INTO vParkingFk
|
||||||
|
@ -29,8 +23,6 @@ BEGIN
|
||||||
CALL util.throw('parkingNotExist');
|
CALL util.throw('parkingNotExist');
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
START TRANSACTION;
|
|
||||||
|
|
||||||
SET vLastWeek = util.VN_CURDATE() - INTERVAL 1 WEEK;
|
SET vLastWeek = util.VN_CURDATE() - INTERVAL 1 WEEK;
|
||||||
|
|
||||||
-- Comprobamos si es una prep. previa, ticket, colección o shelving
|
-- Comprobamos si es una prep. previa, ticket, colección o shelving
|
||||||
|
@ -45,7 +37,5 @@ BEGIN
|
||||||
ELSE
|
ELSE
|
||||||
CALL util.throw('paramNotExist');
|
CALL util.throw('paramNotExist');
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
COMMIT;
|
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`shelving_setParking`(IN `vShelvingCode` VARCHAR(8), IN `vParkingFk` INT)
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`shelving_setParking`(IN `vShelvingCode` VARCHAR(8), IN `vParkingFk` INT)
|
||||||
proc: BEGIN
|
BEGIN
|
||||||
/**
|
/**
|
||||||
* Aparca una matrícula en un parking
|
* Aparca una matrícula en un parking
|
||||||
*
|
*
|
||||||
* @param vShelvingCode code de la matrícula
|
* @param vShelvingCode code de la matrícula
|
||||||
* @param vParkingFk id del parking
|
* @param vParkingFk id del parking
|
||||||
*/
|
*/
|
||||||
INSERT INTO vn.shelvingLog (originFk, userFk, action , description,changedModel,changedModelId)
|
INSERT INTO shelvingLog (originFk, userFk, action , description,changedModel,changedModelId)
|
||||||
SELECT s.id, account.myUser_getId(), 'update', CONCAT("Cambio parking ",vShelvingCode," de ", p.code," a ", pNew.code),'Shelving',s.id
|
SELECT s.id, account.myUser_getId(), 'update', CONCAT("Cambio parking ",vShelvingCode," de ", p.code," a ", pNew.code),'Shelving',s.id
|
||||||
FROM parking p
|
FROM parking p
|
||||||
JOIN shelving s ON s.parkingFk = p.id
|
JOIN shelving s ON s.parkingFk = p.id
|
||||||
JOIN parking pNew ON pNew.id = vParkingFk
|
JOIN parking pNew ON pNew.id = vParkingFk
|
||||||
WHERE s.code = vShelvingCode COLLATE utf8_unicode_ci;
|
WHERE s.code = vShelvingCode COLLATE utf8_unicode_ci;
|
||||||
|
|
||||||
UPDATE vn.shelving
|
UPDATE shelving
|
||||||
SET parkingFk = vParkingFk,
|
SET parkingFk = vParkingFk,
|
||||||
parked = util.VN_NOW(),
|
parked = util.VN_NOW(),
|
||||||
isPrinted = TRUE
|
isPrinted = TRUE
|
||||||
|
|
|
@ -36,6 +36,6 @@ BEGIN
|
||||||
WHERE warehouse_id = vAuctionWarehouseFk
|
WHERE warehouse_id = vAuctionWarehouseFk
|
||||||
ON DUPLICATE KEY UPDATE quantity = tmp.item.quantity + VALUES(quantity);
|
ON DUPLICATE KEY UPDATE quantity = tmp.item.quantity + VALUES(quantity);
|
||||||
|
|
||||||
CALL buyUltimate(vAuctionWarehouseFk, vDated);
|
CALL buy_getUltimate(NULL, vAuctionWarehouseFk, vDated);
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -56,13 +56,12 @@ BEGIN
|
||||||
FROM zone
|
FROM zone
|
||||||
WHERE id = vZoneFk;
|
WHERE id = vZoneFk;
|
||||||
|
|
||||||
CALL buyUltimate(vWarehouseFk, vShipped);
|
CALL buy_getUltimate(NULL, vWarehouseFk, vShipped);
|
||||||
|
|
||||||
DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot;
|
DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot;
|
||||||
CREATE TEMPORARY TABLE tmp.ticketLot ENGINE = MEMORY (
|
CREATE TEMPORARY TABLE tmp.ticketLot ENGINE = MEMORY (
|
||||||
SELECT
|
SELECT vWarehouseFk warehouseFk,
|
||||||
vWarehouseFk AS warehouseFk,
|
NULL available,
|
||||||
NULL AS available,
|
|
||||||
s.itemFk,
|
s.itemFk,
|
||||||
bu.buyFk,
|
bu.buyFk,
|
||||||
vZoneFk zoneFk
|
vZoneFk zoneFk
|
||||||
|
|
|
@ -21,11 +21,6 @@ BEGIN
|
||||||
|
|
||||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||||
|
|
||||||
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
|
||||||
BEGIN
|
|
||||||
RESIGNAL;
|
|
||||||
END;
|
|
||||||
|
|
||||||
INSERT INTO vn.ticketParking(ticketFk, parkingFk)
|
INSERT INTO vn.ticketParking(ticketFk, parkingFk)
|
||||||
SELECT IFNULL(tc2.ticketFk, t.id), vParkingFk
|
SELECT IFNULL(tc2.ticketFk, t.id), vParkingFk
|
||||||
FROM ticket t
|
FROM ticket t
|
||||||
|
|
|
@ -12,24 +12,28 @@ BEGIN
|
||||||
*/
|
*/
|
||||||
DECLARE vTicketFk INT;
|
DECLARE vTicketFk INT;
|
||||||
DECLARE vHasProblem INT;
|
DECLARE vHasProblem INT;
|
||||||
|
DECLARE vIsProblemCalcNeeded BOOL;
|
||||||
DECLARE vDone BOOL;
|
DECLARE vDone BOOL;
|
||||||
DECLARE vTicketList CURSOR FOR SELECT ticketFk, hasProblem FROM tmp.ticket;
|
DECLARE vTicketList CURSOR FOR
|
||||||
|
SELECT ticketFk, hasProblem, isProblemCalcNeeded
|
||||||
|
FROM tmp.ticket;
|
||||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||||
|
|
||||||
OPEN vTicketList;
|
OPEN vTicketList;
|
||||||
l: LOOP
|
l: LOOP
|
||||||
SET vDone = FALSE;
|
SET vDone = FALSE;
|
||||||
FETCH vTicketList INTO vTicketFk, vHasProblem;
|
FETCH vTicketList INTO vTicketFk, vHasProblem, vIsProblemCalcNeeded;
|
||||||
|
|
||||||
IF vDone THEN
|
IF vDone THEN
|
||||||
LEAVE l;
|
LEAVE l;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
UPDATE ticket
|
UPDATE ticket
|
||||||
SET problem = CONCAT(
|
SET problem = IF(vIsProblemCalcNeeded,
|
||||||
IF(vHasProblem,
|
CONCAT(IF(vHasProblem,
|
||||||
CONCAT(problem, ',', vProblemCode),
|
CONCAT(problem, ',', vProblemCode),
|
||||||
REPLACE(problem, vProblemCode , '')))
|
REPLACE(problem, vProblemCode , ''))),
|
||||||
|
NULL)
|
||||||
WHERE id = vTicketFk;
|
WHERE id = vTicketFk;
|
||||||
END LOOP;
|
END LOOP;
|
||||||
CLOSE vTicketList;
|
CLOSE vTicketList;
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setProblemRiskByClient`(
|
||||||
|
vClientFk INT
|
||||||
|
)
|
||||||
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Updates future ticket risk for a client.
|
||||||
|
*
|
||||||
|
* @param vClientFk Id client
|
||||||
|
*/
|
||||||
|
DECLARE vDone INT DEFAULT FALSE;
|
||||||
|
DECLARE vTicketFk INT;
|
||||||
|
DECLARE vTickets CURSOR FOR
|
||||||
|
SELECT id
|
||||||
|
FROM ticket
|
||||||
|
WHERE clientFk = vClientFk
|
||||||
|
AND shipped >= util.VN_CURDATE()
|
||||||
|
AND refFk IS NULL;
|
||||||
|
|
||||||
|
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||||
|
|
||||||
|
OPEN vTickets;
|
||||||
|
l: LOOP
|
||||||
|
SET vDone = FALSE;
|
||||||
|
FETCH vTickets INTO vTicketFk;
|
||||||
|
|
||||||
|
IF vDone THEN
|
||||||
|
LEAVE l;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
CALL vn.ticket_setProblemRisk(vTicketFk);
|
||||||
|
END LOOP;
|
||||||
|
CLOSE vTickets;
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -16,7 +16,7 @@ BEGIN
|
||||||
FROM ticket
|
FROM ticket
|
||||||
WHERE id = vSelf;
|
WHERE id = vSelf;
|
||||||
|
|
||||||
CALL buyUltimate(vWarehouseFk, vDated);
|
CALL buy_getUltimate(NULL, vWarehouseFk, vDated);
|
||||||
|
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tmp.sale
|
CREATE OR REPLACE TEMPORARY TABLE tmp.sale
|
||||||
(INDEX(saleFk, isProblemCalcNeeded))
|
(INDEX(saleFk, isProblemCalcNeeded))
|
||||||
|
|
|
@ -1,92 +1,81 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setRisk`(
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setRisk`(
|
||||||
vClientFk INT)
|
vClientFk INT
|
||||||
|
)
|
||||||
BEGIN
|
BEGIN
|
||||||
/**
|
/**
|
||||||
* Update the risk for a client with pending tickets
|
* Update the risk for a client with pending tickets.
|
||||||
*
|
*
|
||||||
* @param vClientFk Id cliente
|
* @param vClientFk Id cliente
|
||||||
*/
|
*/
|
||||||
DECLARE vHasDebt BOOL;
|
IF (SELECT COUNT(*) FROM client WHERE id = vClientFk AND typeFk = 'normal') THEN
|
||||||
DECLARE vStarted DATETIME;
|
|
||||||
|
|
||||||
SELECT COUNT(*) INTO vHasDebt
|
|
||||||
FROM `client`
|
|
||||||
WHERE id = vClientFk
|
|
||||||
AND typeFk = 'normal';
|
|
||||||
|
|
||||||
IF vHasDebt THEN
|
|
||||||
|
|
||||||
SELECT util.VN_CURDATE() - INTERVAL riskScope MONTH INTO vStarted
|
|
||||||
FROM clientConfig;
|
|
||||||
|
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tTicketRisk
|
CREATE OR REPLACE TEMPORARY TABLE tTicketRisk
|
||||||
(KEY (ticketFk))
|
(PRIMARY KEY (ticketFk))
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
WITH ticket AS(
|
WITH ticket AS (
|
||||||
SELECT id ticketFk,
|
SELECT t.id ticketFk,
|
||||||
companyFk,
|
t.companyFk,
|
||||||
DATE(shipped) dated,
|
DATE(t.shipped) dated,
|
||||||
totalWithVat,
|
t.totalWithVat,
|
||||||
ticket_isProblemCalcNeeded(id) isProblemCalcNeeded
|
ticket_isProblemCalcNeeded(t.id) isProblemCalcNeeded
|
||||||
FROM vn.ticket
|
FROM vn.ticket t
|
||||||
WHERE clientFk = vClientFk
|
JOIN vn.clientConfig cc
|
||||||
AND refFk IS NULL
|
WHERE t.clientFk = vClientFk
|
||||||
AND NOT isDeleted
|
AND t.refFk IS NULL
|
||||||
AND IFNULL(totalWithVat, 0) <> 0
|
AND NOT t.isDeleted
|
||||||
AND shipped > vStarted
|
AND IFNULL(t.totalWithVat, 0) <> 0
|
||||||
), balance AS(
|
AND t.shipped > (util.VN_CURDATE() - INTERVAL cc.riskScope MONTH)
|
||||||
SELECT SUM(amount)amount, companyFk
|
), uninvoiced AS (
|
||||||
FROM (
|
|
||||||
SELECT amount, companyFk
|
|
||||||
FROM vn.clientRisk
|
|
||||||
WHERE clientFk = vClientFk
|
|
||||||
UNION ALL
|
|
||||||
SELECT -(SUM(amount) / 100) amount, tm.companyFk
|
|
||||||
FROM hedera.tpvTransaction t
|
|
||||||
JOIN hedera.tpvMerchant tm ON t.id = t.merchantFk
|
|
||||||
WHERE clientFk = vClientFk
|
|
||||||
AND receiptFk IS NULL
|
|
||||||
AND status = 'ok'
|
|
||||||
) sub
|
|
||||||
WHERE companyFk
|
|
||||||
GROUP BY companyFk
|
|
||||||
), uninvoiced AS(
|
|
||||||
SELECT companyFk, dated, SUM(totalWithVat) amount
|
SELECT companyFk, dated, SUM(totalWithVat) amount
|
||||||
FROM ticket
|
FROM ticket
|
||||||
GROUP BY companyFk, dated
|
GROUP BY companyFk, dated
|
||||||
), receipt AS(
|
), companies AS (
|
||||||
SELECT companyFk, DATE(payed) dated, SUM(amountPaid) amount
|
SELECT DISTINCT companyFk FROM uninvoiced
|
||||||
FROM vn.receipt
|
), balance AS (
|
||||||
WHERE clientFk = vClientFk
|
SELECT SUM(IFNULL(amount, 0))amount, companyFk
|
||||||
AND payed > util.VN_CURDATE()
|
FROM (
|
||||||
GROUP BY companyFk, DATE(payed)
|
SELECT cr.amount, c.companyFk
|
||||||
), risk AS(
|
FROM companies c
|
||||||
|
LEFT JOIN vn.clientRisk cr ON cr.companyFk = c.companyFk
|
||||||
|
AND cr.clientFk = vClientFk
|
||||||
|
UNION ALL
|
||||||
|
SELECT -(SUM(t.amount) / 100) amount, c.companyFk
|
||||||
|
FROM companies c
|
||||||
|
LEFT JOIN hedera.tpvMerchant tm ON tm.companyFk = c.companyFk
|
||||||
|
LEFT JOIN hedera.tpvTransaction t ON t.merchantFk = tm.id
|
||||||
|
AND t.clientFk = vClientFk
|
||||||
|
AND t.receiptFk IS NULL
|
||||||
|
AND t.`status` = 'ok'
|
||||||
|
) sub
|
||||||
|
WHERE companyFk
|
||||||
|
GROUP BY companyFk
|
||||||
|
), receipt AS (
|
||||||
|
SELECT r.companyFk, DATE(r.payed) dated, SUM(r.amountPaid) amount
|
||||||
|
FROM vn.receipt r
|
||||||
|
JOIN companies c ON c.companyFk = r.companyFk
|
||||||
|
WHERE r.clientFk = vClientFk
|
||||||
|
AND r.payed > util.VN_CURDATE()
|
||||||
|
GROUP BY r.companyFk, DATE(r.payed)
|
||||||
|
), risk AS (
|
||||||
SELECT b.companyFk,
|
SELECT b.companyFk,
|
||||||
ui.dated,
|
ui.dated,
|
||||||
SUM(ui.amount) OVER (PARTITION BY b.companyFk ORDER BY ui.dated ) +
|
SUM(ui.amount) OVER (PARTITION BY b.companyFk ORDER BY ui.dated) +
|
||||||
b.amount +
|
b.amount +
|
||||||
SUM(IFNULL(r.amount, 0)) amount
|
SUM(IFNULL(r.amount, 0)) amount
|
||||||
FROM balance b
|
FROM balance b
|
||||||
JOIN uninvoiced ui ON ui.companyFk = b.companyFk
|
JOIN uninvoiced ui ON ui.companyFk = b.companyFk
|
||||||
LEFT JOIN receipt r ON r.dated > ui.dated AND r.companyFk = ui.companyFk
|
LEFT JOIN receipt r ON r.dated > ui.dated
|
||||||
|
AND r.companyFk = ui.companyFk
|
||||||
GROUP BY b.companyFk, ui.dated
|
GROUP BY b.companyFk, ui.dated
|
||||||
)
|
)
|
||||||
SELECT ti.ticketFk, r.amount, ti.isProblemCalcNeeded
|
SELECT ti.ticketFk, r.amount, ti.isProblemCalcNeeded
|
||||||
FROM ticket ti
|
FROM ticket ti
|
||||||
JOIN risk r ON r.dated = ti.dated AND r.companyFk = ti.companyFk;
|
JOIN risk r ON r.dated = ti.dated
|
||||||
|
AND r.companyFk = ti.companyFk;
|
||||||
|
|
||||||
UPDATE ticket t
|
UPDATE ticket t
|
||||||
JOIN tTicketRisk tr ON tr.ticketFk = t.id
|
JOIN tTicketRisk tr ON tr.ticketFk = t.id
|
||||||
SET t.risk = tr.amount
|
SET t.risk = IF(tr.isProblemCalcNeeded, tr.amount, NULL);
|
||||||
WHERE tr.isProblemCalcNeeded
|
|
||||||
ORDER BY t.id;
|
|
||||||
|
|
||||||
UPDATE ticket t
|
|
||||||
JOIN tTicketRisk tr ON tr.ticketFk = t.id
|
|
||||||
SET t.risk = NULL
|
|
||||||
WHERE tr.isProblemCalcNeeded
|
|
||||||
ORDER BY t.id;
|
|
||||||
|
|
||||||
DROP TEMPORARY TABLE tTicketRisk;
|
DROP TEMPORARY TABLE tTicketRisk;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
|
@ -9,9 +9,5 @@ BEGIN
|
||||||
SET NEW.userFk = account.myUser_getId();
|
SET NEW.userFk = account.myUser_getId();
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
IF (NEW.visible <> OLD.visible) THEN
|
|
||||||
SET NEW.available = GREATEST(NEW.available + NEW.visible - OLD.visible, 0);
|
|
||||||
END IF;
|
|
||||||
|
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -8,13 +8,22 @@ BEGIN
|
||||||
SET NEW.editorFk = account.myUser_getId();
|
SET NEW.editorFk = account.myUser_getId();
|
||||||
|
|
||||||
IF NOT (NEW.routeFk <=> OLD.routeFk) THEN
|
IF NOT (NEW.routeFk <=> OLD.routeFk) THEN
|
||||||
INSERT IGNORE INTO `vn`.`routeRecalc` (`routeFk`)
|
IF NEW.isSigned AND NOT (
|
||||||
SELECT r.id
|
SELECT (COUNT(s.id) = COUNT(cb.saleFk)
|
||||||
FROM vn.route r
|
AND SUM(s.quantity) = SUM(cb.quantity))
|
||||||
WHERE r.isOk = FALSE
|
FROM sale s
|
||||||
AND r.id IN (OLD.routeFk,NEW.routeFk)
|
LEFT JOIN claimBeginning cb ON cb.saleFk = s.id
|
||||||
AND r.created >= util.VN_CURDATE()
|
WHERE s.ticketFk = NEW.id
|
||||||
GROUP BY r.id;
|
) THEN
|
||||||
|
CALL util.throw('A signed ticket cannot be rerouted');
|
||||||
|
END IF;
|
||||||
|
INSERT IGNORE INTO routeRecalc(routeFk)
|
||||||
|
SELECT id
|
||||||
|
FROM `route`
|
||||||
|
WHERE NOT isOk
|
||||||
|
AND id IN (OLD.routeFk, NEW.routeFk)
|
||||||
|
AND created >= util.VN_CURDATE()
|
||||||
|
GROUP BY id;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
IF NOT (DATE(NEW.shipped) <=> DATE(OLD.shipped)) THEN
|
IF NOT (DATE(NEW.shipped) <=> DATE(OLD.shipped)) THEN
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
ALTER TABLE bs.waste ADD buyerFk int(10) unsigned NOT NULL;
|
||||||
|
USE vn;
|
||||||
|
CREATE OR REPLACE TEMPORARY TABLE tBuyers
|
||||||
|
ENGINE = MEMORY
|
||||||
|
WITH tDistinctBuyers AS (
|
||||||
|
SELECT DISTINCT buyer
|
||||||
|
FROM bs.waste w
|
||||||
|
)
|
||||||
|
SELECT buyer, u.id
|
||||||
|
FROM tDistinctBuyers tdb
|
||||||
|
JOIN account.`user` u ON u.name = tdb.buyer COLLATE utf8mb3_unicode_ci;
|
||||||
|
|
||||||
|
UPDATE bs.waste w
|
||||||
|
JOIN tBuyers tb ON tb.buyer = w.buyer
|
||||||
|
SET w.buyerFk = tb.id;
|
||||||
|
|
||||||
|
DROP TEMPORARY TABLE tBuyers;
|
||||||
|
|
||||||
|
ALTER TABLE bs.waste
|
||||||
|
DROP PRIMARY KEY,
|
||||||
|
DROP COLUMN family,
|
||||||
|
DROP COLUMN rate,
|
||||||
|
DROP COLUMN buyer;
|
||||||
|
|
||||||
|
ALTER TABLE bs.waste CHANGE buyerFk buyerFk int(10) unsigned NOT NULL AFTER `week`;
|
||||||
|
ALTER TABLE bs.waste ADD CONSTRAINT waste_user_FK FOREIGN KEY (buyerFk) REFERENCES account.user(id) ON DELETE RESTRICT ON UPDATE RESTRICT;
|
||||||
|
ALTER TABLE bs.waste ADD saleQuantity int(11) DEFAULT NULL NULL;
|
||||||
|
ALTER TABLE bs.waste MODIFY COLUMN saleTotal decimal(10,2) DEFAULT NULL NULL;
|
||||||
|
ALTER TABLE bs.waste MODIFY COLUMN saleWaste decimal(10,2) DEFAULT NULL NULL;
|
||||||
|
ALTER TABLE bs.waste CHANGE saleWaste saleInternalWaste decimal(10,2) DEFAULT NULL NULL;
|
||||||
|
ALTER TABLE bs.waste ADD saleExternalWaste decimal(10,2) DEFAULT NULL NULL;
|
||||||
|
ALTER TABLE bs.waste CHANGE saleQuantity saleQuantity decimal(10,2) DEFAULT NULL NULL AFTER itemTypeFk;
|
||||||
|
ALTER TABLE bs.waste CHANGE itemFk itemFk int(11) DEFAULT 0 NOT NULL AFTER itemTypeFk;
|
||||||
|
|
||||||
|
CREATE OR REPLACE TEMPORARY TABLE tWasteUnique
|
||||||
|
SELECT *
|
||||||
|
FROM bs.waste
|
||||||
|
GROUP BY `year`, `week`, buyerFk, itemTypeFk, itemFk
|
||||||
|
HAVING COUNT(*) > 1;
|
||||||
|
|
||||||
|
DELETE w.* FROM bs.waste w
|
||||||
|
JOIN tWasteUnique twu ON twu.`year` = w.`year`
|
||||||
|
AND twu.`week` = w.`week`
|
||||||
|
AND twu.`buyerFk` = w.`buyerFk`
|
||||||
|
AND twu.`itemTypeFk` = w.`itemTypeFk`
|
||||||
|
AND twu.`itemFk` = w.`itemFk`;
|
||||||
|
|
||||||
|
INSERT INTO bs.waste
|
||||||
|
SELECT * FROM tWasteUnique;
|
||||||
|
|
||||||
|
ALTER TABLE bs.waste ADD CONSTRAINT waste_pk PRIMARY KEY (`year`, `week`, buyerFk, itemTypeFk, itemFk);
|
||||||
|
|
||||||
|
DROP TEMPORARY TABLE tWasteUnique;
|
|
@ -0,0 +1,11 @@
|
||||||
|
RENAME TABLE hedera.shelfConfig TO hedera.shelfMultiConfig ;
|
||||||
|
RENAME TABLE pbx.queueConfig TO pbx.queueMultiConfig ;
|
||||||
|
RENAME TABLE salix.defaultViewConfig TO salix.defaultViewMultiConfig;
|
||||||
|
RENAME TABLE edi.fileConfig TO edi.fileMultiConfig;
|
||||||
|
RENAME TABLE edi.imapConfig TO edi.imapMultiConfig;
|
||||||
|
RENAME TABLE edi.tableConfig TO edi.tableMultiConfig;
|
||||||
|
RENAME TABLE vn.invoiceOutTaxConfig TO vn.invoiceOutTaxMultiConfig;
|
||||||
|
RENAME TABLE vn.userConfig TO vn.userMultiConfig;
|
||||||
|
RENAME TABLE vn.conveyorConfig TO vn.conveyorMultiConfig;
|
||||||
|
|
||||||
|
GRANT SELECT ON TABLE hedera.shelfMultiConfig TO employee;
|
|
@ -0,0 +1,2 @@
|
||||||
|
ALTER TABLE vn.invoiceInConfig
|
||||||
|
ADD dueDateMarginDays INT UNSIGNED DEFAULT 2 NULL;
|
|
@ -0,0 +1,8 @@
|
||||||
|
ALTER TABLE vn.item ADD IF NOT EXISTS tag11 varchar(20) DEFAULT NULL NULL;
|
||||||
|
ALTER TABLE vn.item ADD IF NOT EXISTS value11 varchar(50) DEFAULT NULL NULL;
|
||||||
|
|
||||||
|
ALTER TABLE vn.item ADD IF NOT EXISTS tag12 varchar(20) DEFAULT NULL NULL;
|
||||||
|
ALTER TABLE vn.item ADD IF NOT EXISTS value12 varchar(50) DEFAULT NULL NULL;
|
||||||
|
|
||||||
|
ALTER TABLE vn.item ADD IF NOT EXISTS tag13 varchar(20) DEFAULT NULL NULL;
|
||||||
|
ALTER TABLE vn.item ADD IF NOT EXISTS value13 varchar(50) DEFAULT NULL NULL;
|
|
@ -0,0 +1,8 @@
|
||||||
|
|
||||||
|
ALTER TABLE dipole.expedition_PrintOut ADD isChecked BOOL DEFAULT FALSE NOT NULL COMMENT 'Indica si la expedición ha sido revisada por un revisor';
|
||||||
|
|
||||||
|
DELETE FROM salix.ACL
|
||||||
|
WHERE model = 'Expedition_PrintOut';
|
||||||
|
|
||||||
|
INSERT INTO salix.ACL ( model, property, accessType, permission, principalType, principalId)
|
||||||
|
VALUES( 'Expedition_PrintOut', '*', '*', 'ALLOW', 'ROLE', 'production');
|
|
@ -0,0 +1,2 @@
|
||||||
|
ALTER TABLE IF EXISTS vn.itemShelving
|
||||||
|
MODIFY COLUMN IF EXISTS isSplit tinyint(1) DEFAULT 0 NOT NULL COMMENT 'Este valor cambia al splitar un carro que se ha quedado en holanda';
|
|
@ -0,0 +1,6 @@
|
||||||
|
-- Place your SQL code here
|
||||||
|
|
||||||
|
ALTER TABLE vn.itemShelvingSaleReserve DROP FOREIGN KEY IF EXISTS itemShelvingSaleReserve_sector_FK;
|
||||||
|
|
||||||
|
ALTER TABLE vn.itemShelvingSaleReserve ADD CONSTRAINT itemShelvingSaleReserve_sector_FK
|
||||||
|
FOREIGN KEY IF NOT EXISTS (sectorFk) REFERENCES vn.sector(id) ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
@ -1,62 +0,0 @@
|
||||||
import selectors from '../../helpers/selectors.js';
|
|
||||||
import getBrowser from '../../helpers/puppeteer';
|
|
||||||
|
|
||||||
describe('Route summary path', () => {
|
|
||||||
let browser;
|
|
||||||
let page;
|
|
||||||
|
|
||||||
beforeAll(async() => {
|
|
||||||
browser = await getBrowser();
|
|
||||||
page = browser.page;
|
|
||||||
await page.loginAndModule('employee', 'route');
|
|
||||||
await page.waitToClick(selectors.routeIndex.previewButton);
|
|
||||||
await page.waitToClick(selectors.routeSummary.goToRouteSummaryButton);
|
|
||||||
});
|
|
||||||
|
|
||||||
afterAll(async() => {
|
|
||||||
await browser.close();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should reach the first route summary section', async() => {
|
|
||||||
await page.waitForState('route.card.summary');
|
|
||||||
});
|
|
||||||
|
|
||||||
it(`should display details from the route on the header`, async() => {
|
|
||||||
await page.waitForTextInElement(selectors.routeSummary.header, 'first route');
|
|
||||||
const result = await page.waitToGetProperty(selectors.routeSummary.header, 'innerText');
|
|
||||||
|
|
||||||
expect(result).toContain('first route');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should display some route details like the cost', async() => {
|
|
||||||
const result = await page.waitToGetProperty(selectors.routeSummary.cost, 'innerText');
|
|
||||||
|
|
||||||
expect(result).toContain('€10.00');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should click on the first ticket ID making the descriptor popover visible', async() => {
|
|
||||||
await page.waitForState('route.card.summary');
|
|
||||||
await page.waitForTimeout(250);
|
|
||||||
await page.waitToClick(selectors.routeSummary.firstTicketID);
|
|
||||||
await page.waitForSelector(selectors.routeSummary.firstTicketDescriptor);
|
|
||||||
const visible = await page.isVisible(selectors.routeSummary.firstTicketDescriptor);
|
|
||||||
|
|
||||||
expect(visible).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should close the ticket descriptor', async() => {
|
|
||||||
await page.closePopup();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should click on the first alias making the client descriptor popover visible', async() => {
|
|
||||||
await page.waitToClick(selectors.routeSummary.firstAlias);
|
|
||||||
await page.waitForSelector(selectors.routeSummary.firstClientDescriptor);
|
|
||||||
const visible = await page.isVisible(selectors.routeSummary.firstClientDescriptor);
|
|
||||||
|
|
||||||
expect(visible).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should close the client descriptor', async() => {
|
|
||||||
await page.closePopup();
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,42 +0,0 @@
|
||||||
import getBrowser from '../../helpers/puppeteer';
|
|
||||||
|
|
||||||
describe('Route basic Data path', () => {
|
|
||||||
let browser;
|
|
||||||
let page;
|
|
||||||
|
|
||||||
beforeAll(async() => {
|
|
||||||
browser = await getBrowser();
|
|
||||||
page = browser.page;
|
|
||||||
await page.loginAndModule('delivery', 'route');
|
|
||||||
await page.accessToSearchResult('1');
|
|
||||||
await page.accessToSection('route.card.basicData');
|
|
||||||
});
|
|
||||||
|
|
||||||
afterAll(async() => {
|
|
||||||
await browser.close();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should edit the route basic data and confirm the route was edited', async() => {
|
|
||||||
const nextMonth = Date.vnNew();
|
|
||||||
nextMonth.setMonth(nextMonth.getMonth() + 1);
|
|
||||||
nextMonth.setUTCHours(0, 0, 0, 0);
|
|
||||||
|
|
||||||
const form = 'vn-route-basic-data form';
|
|
||||||
const values = {
|
|
||||||
worker: 'adminBossNick',
|
|
||||||
vehicle: '1111-IMK',
|
|
||||||
created: nextMonth,
|
|
||||||
kmStart: 1,
|
|
||||||
kmEnd: 2,
|
|
||||||
started: '08:00',
|
|
||||||
finished: '12:30',
|
|
||||||
};
|
|
||||||
|
|
||||||
const message = await page.sendForm(form, values);
|
|
||||||
await page.reloadSection('route.card.basicData');
|
|
||||||
const formValues = await page.fetchForm(form, Object.keys(values));
|
|
||||||
|
|
||||||
expect(message.isSuccess).toBeTrue();
|
|
||||||
expect(formValues).toEqual(values);
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,91 +0,0 @@
|
||||||
import selectors from '../../helpers/selectors.js';
|
|
||||||
import getBrowser from '../../helpers/puppeteer';
|
|
||||||
|
|
||||||
describe('Route create path', () => {
|
|
||||||
let browser;
|
|
||||||
let page;
|
|
||||||
|
|
||||||
beforeAll(async() => {
|
|
||||||
browser = await getBrowser();
|
|
||||||
page = browser.page;
|
|
||||||
await page.loginAndModule('employee', 'route');
|
|
||||||
});
|
|
||||||
|
|
||||||
afterAll(async() => {
|
|
||||||
await browser.close();
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('as employee', () => {
|
|
||||||
it('should click on the add new route button and open the creation form', async() => {
|
|
||||||
await page.waitToClick(selectors.routeIndex.addNewRouteButton);
|
|
||||||
await page.waitForState('route.create');
|
|
||||||
});
|
|
||||||
|
|
||||||
it(`should attempt to create a new route but fail since employee has no access rights`, async() => {
|
|
||||||
await page.write(selectors.createRouteView.description, 'faster faster!!');
|
|
||||||
await page.waitToClick(selectors.createRouteView.submitButton);
|
|
||||||
const message = await page.waitForSnackbar();
|
|
||||||
|
|
||||||
expect(message.text).toContain('Access Denied');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('as delivery', () => {
|
|
||||||
beforeAll(async() => {
|
|
||||||
await page.login('delivery');
|
|
||||||
await page.selectModule('route');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should again click on the add new route button and open the creation form', async() => {
|
|
||||||
await page.waitToClick(selectors.routeIndex.addNewRouteButton);
|
|
||||||
await page.waitForState('route.create');
|
|
||||||
});
|
|
||||||
|
|
||||||
it(`should create a new route`, async() => {
|
|
||||||
await page.autocompleteSearch(selectors.createRouteView.worker, 'teamManagerNick');
|
|
||||||
await page.pickDate(selectors.createRouteView.createdDatePicker);
|
|
||||||
await page.autocompleteSearch(selectors.createRouteView.vehicleAuto, '4444-IMK');
|
|
||||||
await page.autocompleteSearch(selectors.createRouteView.agency, 'Teleportation device');
|
|
||||||
await page.write(selectors.createRouteView.description, 'faster faster!!');
|
|
||||||
await page.waitToClick(selectors.createRouteView.submitButton);
|
|
||||||
const message = await page.waitForSnackbar();
|
|
||||||
|
|
||||||
expect(message.text).toContain('Data saved!');
|
|
||||||
});
|
|
||||||
|
|
||||||
it(`should confirm the redirection to the created route summary`, async() => {
|
|
||||||
await page.waitForState('route.card.summary');
|
|
||||||
});
|
|
||||||
|
|
||||||
it(`should navigate back to the route index`, async() => {
|
|
||||||
await page.waitToClick(selectors.globalItems.returnToModuleIndexButton);
|
|
||||||
await page.waitForState('route.index');
|
|
||||||
});
|
|
||||||
|
|
||||||
let count;
|
|
||||||
it(`should count the amount of routes before clonation`, async() => {
|
|
||||||
await page.waitForFunction(selector => {
|
|
||||||
return document.querySelectorAll(selector).length > 6;
|
|
||||||
}, {}, selectors.routeIndex.anyResult);
|
|
||||||
count = await page.countElement(selectors.routeIndex.anyResult);
|
|
||||||
|
|
||||||
expect(count).toBeGreaterThanOrEqual(7);
|
|
||||||
});
|
|
||||||
|
|
||||||
it(`should clone the first route`, async() => {
|
|
||||||
await page.waitToClick(selectors.routeIndex.firstRouteCheckbox);
|
|
||||||
await page.waitToClick(selectors.routeIndex.cloneButton);
|
|
||||||
await page.waitToClick(selectors.routeIndex.submitClonationButton);
|
|
||||||
const message = await page.waitForSnackbar();
|
|
||||||
|
|
||||||
expect(message.text).toContain('Data saved!');
|
|
||||||
});
|
|
||||||
|
|
||||||
it(`should reload the section and count the amount of routes after clonation`, async() => {
|
|
||||||
await page.waitForNumberOfElements(selectors.routeIndex.anyResult, count + 1);
|
|
||||||
const result = await page.countElement(selectors.routeIndex.anyResult);
|
|
||||||
|
|
||||||
expect(result).toEqual(count + 1);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,59 +0,0 @@
|
||||||
import selectors from '../../helpers/selectors.js';
|
|
||||||
import getBrowser from '../../helpers/puppeteer';
|
|
||||||
|
|
||||||
describe('Route tickets path', () => {
|
|
||||||
let browser;
|
|
||||||
let page;
|
|
||||||
|
|
||||||
beforeAll(async() => {
|
|
||||||
browser = await getBrowser();
|
|
||||||
page = browser.page;
|
|
||||||
await page.loginAndModule('delivery', 'route');
|
|
||||||
await page.accessToSearchResult('2');
|
|
||||||
await page.accessToSection('route.card.tickets');
|
|
||||||
});
|
|
||||||
|
|
||||||
afterAll(async() => {
|
|
||||||
await browser.close();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should modify the first ticket priority', async() => {
|
|
||||||
await page.writeOnEditableTD(selectors.routeTickets.firstTicketPriority, '9');
|
|
||||||
await page.keyboard.press('Enter');
|
|
||||||
const message = await page.waitForSnackbar();
|
|
||||||
|
|
||||||
expect(message.text).toContain('Data saved!');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should confirm the buscaman button is disabled', async() => {
|
|
||||||
await page.waitForSelector(`${selectors.routeTickets.buscamanButton}.disabled`);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should check the first ticket checkbox and confirm the buscamanButton button is no longer disabled', async() => {
|
|
||||||
await page.waitForSelector(`${selectors.routeTickets.buscamanButton}.disabled`, {visible: false});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should check the route volume on the descriptor', async() => {
|
|
||||||
const result = await page.waitToGetProperty(selectors.routeDescriptor.volume, 'innerText');
|
|
||||||
|
|
||||||
expect(result).toEqual('0.2 / 50 m³');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should count how many tickets are in route', async() => {
|
|
||||||
const result = await page.countElement(selectors.routeTickets.anyTicket);
|
|
||||||
|
|
||||||
expect(result).toEqual(1);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should delete the first ticket in route', async() => {
|
|
||||||
await page.waitToClick(selectors.routeTickets.firstTicketDeleteButton);
|
|
||||||
await page.waitToClick(selectors.routeTickets.confirmButton);
|
|
||||||
const message = await page.waitForSnackbar();
|
|
||||||
|
|
||||||
expect(message.text).toContain('Ticket removed from route');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should now count how many tickets are in route to find one less', async() => {
|
|
||||||
await page.waitForNumberOfElements(selectors.routeTickets.anyTicket, 0);
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -233,5 +233,7 @@
|
||||||
"It has been invoiced but the PDF could not be generated": "It has been invoiced but the PDF could not be generated",
|
"It has been invoiced but the PDF could not be generated": "It has been invoiced but the PDF could not be generated",
|
||||||
"It has been invoiced but the PDF of refund not be generated": "It has been invoiced but the PDF of refund not be generated",
|
"It has been invoiced but the PDF of refund not be generated": "It has been invoiced but the PDF of refund not be generated",
|
||||||
"Cannot add holidays on this day": "Cannot add holidays on this day",
|
"Cannot add holidays on this day": "Cannot add holidays on this day",
|
||||||
"Cannot send mail": "Cannot send mail"
|
"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"
|
||||||
}
|
}
|
|
@ -367,5 +367,7 @@
|
||||||
"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",
|
"It has been invoiced but the PDF of refund not be generated": "Se ha facturado pero no se ha podido generar el PDF del abono",
|
||||||
"Payment method is required": "El método de pago es obligatorio",
|
"Payment method is required": "El método de pago es obligatorio",
|
||||||
"Cannot send mail": "Não é possível enviar o email",
|
"Cannot send mail": "Não é possível enviar o email",
|
||||||
"CONSTRAINT `supplierAccountTooShort` failed for `vn`.`supplier`": "La cuenta debe tener exactamente 10 dígitos"
|
"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"
|
||||||
}
|
}
|
|
@ -29,7 +29,7 @@ module.exports = Self => {
|
||||||
SELECT COUNT(*) > 0 isCustomer
|
SELECT COUNT(*) > 0 isCustomer
|
||||||
FROM salix.Account A
|
FROM salix.Account A
|
||||||
JOIN salix.Role r ON r.id = A.roleFK
|
JOIN salix.Role r ON r.id = A.roleFK
|
||||||
WHERE r.name = 'customer'
|
WHERE r.name IN ('customer', 'supplier')
|
||||||
AND A.id IN (?)`;
|
AND A.id IN (?)`;
|
||||||
const [result] = await Self.rawSql(query, [id], myOptions);
|
const [result] = await Self.rawSql(query, [id], myOptions);
|
||||||
const {isCustomer} = result;
|
const {isCustomer} = result;
|
||||||
|
|
|
@ -60,7 +60,7 @@ module.exports = Self => {
|
||||||
DISTINCT c.id clientFk,
|
DISTINCT c.id clientFk,
|
||||||
c.name clientName,
|
c.name clientName,
|
||||||
c.salesPersonFk,
|
c.salesPersonFk,
|
||||||
c.businessTypeFk,
|
c.businessTypeFk = 'worker' isWorker,
|
||||||
u.name salesPersonName,
|
u.name salesPersonName,
|
||||||
d.amount,
|
d.amount,
|
||||||
co.created,
|
co.created,
|
||||||
|
@ -71,14 +71,24 @@ module.exports = Self => {
|
||||||
d.defaulterSinced,
|
d.defaulterSinced,
|
||||||
cn.name country,
|
cn.name country,
|
||||||
c.countryFk,
|
c.countryFk,
|
||||||
pm.name payMethod
|
pm.name payMethod,
|
||||||
FROM vn.defaulter d
|
r.finished IS NULL hasRecovery,
|
||||||
JOIN vn.client c ON c.id = d.clientFk
|
dp.id departmentFk,
|
||||||
JOIN vn.country cn ON cn.id = c.countryFk
|
dp.name departmentName
|
||||||
JOIN vn.payMethod pm ON pm.id = c.payMethodFk
|
FROM defaulter d
|
||||||
LEFT JOIN vn.clientObservation co ON co.clientFk = c.id
|
JOIN client c ON c.id = d.clientFk
|
||||||
|
JOIN country cn ON cn.id = c.countryFk
|
||||||
|
JOIN payMethod pm ON pm.id = c.payMethodFk
|
||||||
|
LEFT JOIN clientObservation co ON co.clientFk = c.id
|
||||||
LEFT JOIN account.user u ON u.id = c.salesPersonFk
|
LEFT JOIN account.user u ON u.id = c.salesPersonFk
|
||||||
LEFT JOIN account.user uw ON uw.id = co.workerFk
|
LEFT JOIN account.user uw ON uw.id = co.workerFk
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT MAX(started), clientFk, finished
|
||||||
|
FROM recovery
|
||||||
|
GROUP BY clientFk
|
||||||
|
) r ON r.clientFk = c.id
|
||||||
|
LEFT JOIN workerDepartment wd ON wd.workerFk = u.id
|
||||||
|
JOIN department dp ON dp.id = wd.departmentFk
|
||||||
WHERE
|
WHERE
|
||||||
d.created = ?
|
d.created = ?
|
||||||
AND d.amount > 0
|
AND d.amount > 0
|
||||||
|
|
|
@ -52,8 +52,8 @@ module.exports = Self => {
|
||||||
else {
|
else {
|
||||||
const userConfig = await models.UserConfig.findById(userId, {fields: ['warehouseFk']}, myOptions);
|
const userConfig = await models.UserConfig.findById(userId, {fields: ['warehouseFk']}, myOptions);
|
||||||
await Self.rawSql(
|
await Self.rawSql(
|
||||||
'CALL vn.buyUltimate(?,?)',
|
'CALL buy_getUltimate(?, ?, ?)',
|
||||||
[userConfig.warehouseFk, null],
|
[args.item, userConfig.warehouseFk, null],
|
||||||
myOptions
|
myOptions
|
||||||
);
|
);
|
||||||
let buyUltimate = await Self.rawSql(
|
let buyUltimate = await Self.rawSql(
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('buyLabel', {
|
Self.remoteMethodCtx('buyLabel', {
|
||||||
description: 'Returns the entry buys labels',
|
description: 'Returns the entry buy labels',
|
||||||
accessType: 'READ',
|
accessType: 'READ',
|
||||||
accepts: [
|
accepts: [
|
||||||
{
|
{
|
||||||
|
|
|
@ -95,6 +95,16 @@ module.exports = Self => {
|
||||||
type: 'date',
|
type: 'date',
|
||||||
description: `The to date filter`
|
description: `The to date filter`
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
arg: 'fromShipped',
|
||||||
|
type: 'date',
|
||||||
|
description: `The from shipped date filter`
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'toShipped',
|
||||||
|
type: 'date',
|
||||||
|
description: `The to shipped date filter`
|
||||||
|
},
|
||||||
{
|
{
|
||||||
arg: 'days',
|
arg: 'days',
|
||||||
type: 'number',
|
type: 'number',
|
||||||
|
@ -133,8 +143,12 @@ module.exports = Self => {
|
||||||
return {'e.created': {gte: value}};
|
return {'e.created': {gte: value}};
|
||||||
case 'from':
|
case 'from':
|
||||||
return {'t.landed': {gte: value}};
|
return {'t.landed': {gte: value}};
|
||||||
|
case 'fromShipped':
|
||||||
|
return {'t.shipped': {gte: value}};
|
||||||
case 'to':
|
case 'to':
|
||||||
return {'t.landed': {lte: value}};
|
return {'t.landed': {lte: value}};
|
||||||
|
case 'toShipped':
|
||||||
|
return {'t.shipped': {lte: value}};
|
||||||
case 'id':
|
case 'id':
|
||||||
case 'isBooked':
|
case 'isBooked':
|
||||||
case 'isConfirmed':
|
case 'isConfirmed':
|
||||||
|
|
|
@ -101,7 +101,8 @@ module.exports = Self => {
|
||||||
'groupingMode',
|
'groupingMode',
|
||||||
'inkFk',
|
'inkFk',
|
||||||
'originFk',
|
'originFk',
|
||||||
'producerFk'
|
'producerFk',
|
||||||
|
'comment'
|
||||||
],
|
],
|
||||||
include: [
|
include: [
|
||||||
{
|
{
|
||||||
|
|
|
@ -73,7 +73,8 @@ module.exports = Self => {
|
||||||
}, myOptions);
|
}, myOptions);
|
||||||
|
|
||||||
const travel = entry.travel();
|
const travel = entry.travel();
|
||||||
await Self.rawSql('CALL buyUltimate(?, ?)', [
|
await Self.rawSql('CALL buy_getUltimate(?, ?, ?)', [
|
||||||
|
null,
|
||||||
travel.warehouseInFk,
|
travel.warehouseInFk,
|
||||||
travel.landed
|
travel.landed
|
||||||
], myOptions);
|
], myOptions);
|
||||||
|
|
|
@ -50,7 +50,8 @@ module.exports = Self => {
|
||||||
|
|
||||||
const stmts = [];
|
const stmts = [];
|
||||||
let stmt;
|
let stmt;
|
||||||
stmt = new ParameterizedSQL(`CALL buyUltimate(?, ?)`, [
|
stmt = new ParameterizedSQL(`CALL buy_getUltimate(?, ?, ?)`, [
|
||||||
|
null,
|
||||||
travel.warehouseInFk,
|
travel.warehouseInFk,
|
||||||
travel.landed
|
travel.landed
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -0,0 +1,58 @@
|
||||||
|
const UserError = require('vn-loopback/util/user-error');
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.remoteMethodCtx('print', {
|
||||||
|
description: 'Print stickers of all entries',
|
||||||
|
accessType: 'READ',
|
||||||
|
accepts: [
|
||||||
|
{
|
||||||
|
arg: 'id',
|
||||||
|
type: 'number',
|
||||||
|
required: true,
|
||||||
|
description: 'The entry id',
|
||||||
|
http: {source: 'path'}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
returns: [
|
||||||
|
{
|
||||||
|
arg: 'body',
|
||||||
|
type: 'file',
|
||||||
|
root: true
|
||||||
|
}, {
|
||||||
|
arg: 'Content-Type',
|
||||||
|
type: 'String',
|
||||||
|
http: {target: 'header'}
|
||||||
|
}, {
|
||||||
|
arg: 'Content-Disposition',
|
||||||
|
type: 'String',
|
||||||
|
http: {target: 'header'}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
http: {
|
||||||
|
path: '/:id/print',
|
||||||
|
verb: 'GET'
|
||||||
|
},
|
||||||
|
accessScopes: ['DEFAULT', 'read:multimedia']
|
||||||
|
});
|
||||||
|
|
||||||
|
Self.print = async function(ctx, id, options) {
|
||||||
|
const models = Self.app.models;
|
||||||
|
const myOptions = {};
|
||||||
|
if (typeof options == 'object')
|
||||||
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
|
// Importación dinámica porque no admite commonjs
|
||||||
|
const PDFMerger = ((await import('pdf-merger-js')).default);
|
||||||
|
const merger = new PDFMerger();
|
||||||
|
const buys = await models.Buy.find({where: {entryFk: id}}, myOptions);
|
||||||
|
|
||||||
|
for (const buy of buys) {
|
||||||
|
if (buy.stickers < 1) continue;
|
||||||
|
ctx.args.id = buy.id;
|
||||||
|
const pdfBuffer = await models.Entry.buyLabel(ctx, myOptions);
|
||||||
|
await merger.add(new Uint8Array(pdfBuffer[0]));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!merger._doc) throw new UserError('The entry not have stickers');
|
||||||
|
return [await merger.saveAsBuffer(), 'application/pdf', `filename="entry-${id}.pdf"`];
|
||||||
|
};
|
||||||
|
};
|
|
@ -10,6 +10,7 @@ module.exports = Self => {
|
||||||
require('../methods/entry/addFromPackaging')(Self);
|
require('../methods/entry/addFromPackaging')(Self);
|
||||||
require('../methods/entry/addFromBuy')(Self);
|
require('../methods/entry/addFromBuy')(Self);
|
||||||
require('../methods/entry/buyLabel')(Self);
|
require('../methods/entry/buyLabel')(Self);
|
||||||
|
require('../methods/entry/print')(Self);
|
||||||
|
|
||||||
Self.observe('before save', async function(ctx, options) {
|
Self.observe('before save', async function(ctx, options) {
|
||||||
if (ctx.isNewInstance) return;
|
if (ctx.isNewInstance) return;
|
||||||
|
|
|
@ -82,7 +82,15 @@ module.exports = Self => {
|
||||||
{
|
{
|
||||||
arg: 'correctedFk',
|
arg: 'correctedFk',
|
||||||
type: 'number',
|
type: 'number',
|
||||||
description: 'The corrected invoice',
|
description: 'The rectified invoice',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'correctingFk',
|
||||||
|
type: 'Boolean',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'supplierActivityFk',
|
||||||
|
type: 'string',
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
returns: {
|
returns: {
|
||||||
|
@ -111,6 +119,7 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
|
|
||||||
let correctings;
|
let correctings;
|
||||||
|
let correcteds;
|
||||||
if (args.correctedFk) {
|
if (args.correctedFk) {
|
||||||
correctings = await models.InvoiceInCorrection.find({
|
correctings = await models.InvoiceInCorrection.find({
|
||||||
fields: ['correctingFk'],
|
fields: ['correctingFk'],
|
||||||
|
@ -118,6 +127,9 @@ module.exports = Self => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (args.correctingFk || args.correctingFk === false)
|
||||||
|
correcteds = await models.InvoiceInCorrection.find();
|
||||||
|
|
||||||
const where = buildFilter(ctx.args, (param, value) => {
|
const where = buildFilter(ctx.args, (param, value) => {
|
||||||
switch (param) {
|
switch (param) {
|
||||||
case 'search':
|
case 'search':
|
||||||
|
@ -141,8 +153,14 @@ module.exports = Self => {
|
||||||
return {[`ii.${param}`]: value};
|
return {[`ii.${param}`]: value};
|
||||||
case 'awbCode':
|
case 'awbCode':
|
||||||
return {'sub.code': value};
|
return {'sub.code': value};
|
||||||
|
case 'correctingFk':
|
||||||
|
return args.correctingFk
|
||||||
|
? {'ii.id': {inq: correcteds.map(x => x.correctingFk)}}
|
||||||
|
: {'ii.id': {nin: correcteds.map(x => x.correctingFk)}};
|
||||||
case 'correctedFk':
|
case 'correctedFk':
|
||||||
return {'ii.id': {inq: correctings.map(x => x.correctingFk)}};
|
return {'ii.id': {inq: correctings.map(x => x.correctingFk)}};
|
||||||
|
case 'supplierActivityFk':
|
||||||
|
return {'s.supplierActivityFk': value};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
const UserError = require('vn-loopback/util/user-error');
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethod('updateFromSale', {
|
Self.remoteMethod('updateFromSale', {
|
||||||
description: 'Update the visible items',
|
description: 'Update the visible items',
|
||||||
|
@ -32,6 +33,9 @@ module.exports = Self => {
|
||||||
include: {relation: 'itemShelving'}
|
include: {relation: 'itemShelving'}
|
||||||
}, myOptions);
|
}, myOptions);
|
||||||
|
|
||||||
|
if (!itemShelvingSale?.itemShelving())
|
||||||
|
throw new UserError('The sale not exists in the item shelving');
|
||||||
|
|
||||||
const itemShelving = itemShelvingSale.itemShelving();
|
const itemShelving = itemShelvingSale.itemShelving();
|
||||||
const quantity = itemShelving.visible + itemShelvingSale.quantity;
|
const quantity = itemShelving.visible + itemShelvingSale.quantity;
|
||||||
|
|
||||||
|
|
|
@ -27,28 +27,42 @@ module.exports = Self => {
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.getWasteByItem = async(buyer, family, options) => {
|
Self.getWasteByItem = async(buyer, family, options) => {
|
||||||
|
const models = Self.app.models;
|
||||||
const myOptions = {};
|
const myOptions = {};
|
||||||
|
|
||||||
if (typeof options == 'object')
|
if (typeof options == 'object')
|
||||||
Object.assign(myOptions, options);
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
|
const user = await models.VnUser.findOne({
|
||||||
|
fields: ['id'],
|
||||||
|
where: {name: buyer}
|
||||||
|
});
|
||||||
|
|
||||||
|
const itemType = await models.ItemType.findOne({
|
||||||
|
fields: ['id'],
|
||||||
|
where: {name: family}
|
||||||
|
}, options);
|
||||||
|
|
||||||
const date = Date.vnNew();
|
const date = Date.vnNew();
|
||||||
date.setHours(0, 0, 0, 0);
|
date.setHours(0, 0, 0, 0);
|
||||||
const wastes = await Self.rawSql(`
|
const wastes = await Self.rawSql(`
|
||||||
SELECT *, 100 * dwindle / total AS percentage
|
SELECT *, 100 * dwindle / total percentage
|
||||||
FROM (
|
FROM (
|
||||||
SELECT buyer,
|
SELECT u.name buyer,
|
||||||
ws.family,
|
it.name family,
|
||||||
ws.itemFk,
|
w.itemFk,
|
||||||
sum(ws.saleTotal) AS total,
|
SUM(w.saleTotal) total,
|
||||||
sum(ws.saleWaste) AS dwindle
|
SUM(w.saleInternalWaste + w.saleExternalWaste) dwindle
|
||||||
FROM bs.waste ws
|
FROM bs.waste w
|
||||||
WHERE buyer = ? AND family = ?
|
JOIN account.user u ON u.id = w.buyerFk
|
||||||
AND year = YEAR(TIMESTAMPADD(WEEK,-1, ?))
|
JOIN vn.itemType it ON it.id = w.itemTypeFk
|
||||||
AND week = WEEK(TIMESTAMPADD(WEEK,-1, ?), 1)
|
WHERE w.buyerFk = ? AND w.itemTypeFk = ?
|
||||||
GROUP BY buyer, itemFk
|
AND w.year = YEAR(TIMESTAMPADD(WEEK, -1, ?))
|
||||||
) sub
|
AND w.week = WEEK(TIMESTAMPADD(WEEK, -1, ?), 1)
|
||||||
ORDER BY family, percentage DESC`, [buyer, family, date, date], myOptions);
|
GROUP BY w.buyerFk, w.itemFk
|
||||||
|
) sub
|
||||||
|
ORDER BY family, percentage DESC
|
||||||
|
`, [user.id, itemType.id, date, date], myOptions);
|
||||||
|
|
||||||
const details = [];
|
const details = [];
|
||||||
|
|
||||||
|
|
|
@ -22,31 +22,37 @@ module.exports = Self => {
|
||||||
const date = Date.vnNew();
|
const date = Date.vnNew();
|
||||||
date.setHours(0, 0, 0, 0);
|
date.setHours(0, 0, 0, 0);
|
||||||
const wastes = await Self.rawSql(`
|
const wastes = await Self.rawSql(`
|
||||||
SELECT *, 100 * dwindle / total AS percentage
|
SELECT *, 100 * dwindle / total percentage
|
||||||
FROM (
|
FROM (
|
||||||
SELECT buyer,
|
SELECT u.name buyer,
|
||||||
ws.family,
|
it.name family,
|
||||||
sum(ws.saleTotal) AS total,
|
w.itemFk,
|
||||||
sum(ws.saleWaste) AS dwindle
|
SUM(w.saleTotal) total,
|
||||||
FROM bs.waste ws
|
SUM(w.saleInternalWaste + w.saleExternalWaste) dwindle
|
||||||
WHERE year = YEAR(TIMESTAMPADD(WEEK,-1, ?))
|
FROM bs.waste w
|
||||||
AND week = WEEK(TIMESTAMPADD(WEEK,-1, ?), 1)
|
JOIN account.user u ON u.id = w.buyerFk
|
||||||
GROUP BY buyer, family
|
JOIN vn.itemType it ON it.id = w.itemTypeFk
|
||||||
) sub
|
WHERE year = YEAR(TIMESTAMPADD(WEEK, -1, ?))
|
||||||
ORDER BY percentage DESC`, [date, date], myOptions);
|
AND week = WEEK(TIMESTAMPADD(WEEK, -1, ?), 1)
|
||||||
|
GROUP BY buyerFk, itemTypeFk
|
||||||
|
) sub
|
||||||
|
ORDER BY percentage DESC
|
||||||
|
`, [date, date], myOptions);
|
||||||
|
|
||||||
const wastesTotal = await Self.rawSql(`
|
const wastesTotal = await Self.rawSql(`
|
||||||
SELECT *, 100 * dwindle / total AS percentage
|
SELECT *, 100 * dwindle / total percentage
|
||||||
FROM (
|
FROM (
|
||||||
SELECT buyer,
|
SELECT u.name buyer,
|
||||||
sum(ws.saleTotal) AS total,
|
SUM(w.saleTotal) total,
|
||||||
sum(ws.saleWaste) AS dwindle
|
SUM(w.saleInternalWaste + w.saleExternalWaste) dwindle
|
||||||
FROM bs.waste ws
|
FROM bs.waste w
|
||||||
WHERE year = YEAR(TIMESTAMPADD(WEEK,-1, ?))
|
JOIN account.user u ON u.id = w.buyerFk
|
||||||
AND week = WEEK(TIMESTAMPADD(WEEK,-1, ?), 1)
|
WHERE w.year = YEAR(TIMESTAMPADD(WEEK, -1, ?))
|
||||||
GROUP BY buyer
|
AND w.week = WEEK(TIMESTAMPADD(WEEK, -1, ?), 1)
|
||||||
|
GROUP BY w.buyerFk
|
||||||
) sub
|
) sub
|
||||||
ORDER BY percentage DESC`, [date, date], myOptions);
|
ORDER BY percentage DESC
|
||||||
|
`, [date, date], myOptions);
|
||||||
|
|
||||||
const details = [];
|
const details = [];
|
||||||
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue