diff --git a/Jenkinsfile b/Jenkinsfile
index 03ac84de3..4a1f9ba54 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -62,13 +62,13 @@ pipeline {
}
}
}
- // stage('Backend') {
- // steps {
- // nodejs('node-v14') {
- // sh 'gulp launchBackTest --ci'
- // }
- // }
- // }
+ stage('Backend') {
+ steps {
+ nodejs('node-v14') {
+ sh 'npm run test:back:ci'
+ }
+ }
+ }
}
}
stage('Build') {
diff --git a/README.md b/README.md
index 1e3ad5e9e..f73a8551b 100644
--- a/README.md
+++ b/README.md
@@ -54,17 +54,17 @@ $ gulp docker
For client-side unit tests run from project's root.
```
-$ jest
+$ npm run test:front
```
For server-side unit tests run from project's root.
```
-$ gulp backTest
+$ npm run test:back
```
For end-to-end tests run from project's root.
```
-$ gulp e2e
+$ npm run test:e2e
```
## Visual Studio Code extensions
diff --git a/back/methods/account/acl.js b/back/methods/account/acl.js
index c1dcdc11b..bc1990e1d 100644
--- a/back/methods/account/acl.js
+++ b/back/methods/account/acl.js
@@ -23,7 +23,13 @@ module.exports = Self => {
let models = Self.app.models;
let user = await models.Account.findById(userId, {
- fields: ['id', 'name', 'nickname', 'email']
+ fields: ['id', 'name', 'nickname', 'email', 'lang'],
+ include: {
+ relation: 'userConfig',
+ scope: {
+ fields: ['darkMode']
+ }
+ }
});
let roles = await models.RoleMapping.find({
diff --git a/back/methods/account/change-password.js b/back/methods/account/change-password.js
index 25b63b9a8..c0956b193 100644
--- a/back/methods/account/change-password.js
+++ b/back/methods/account/change-password.js
@@ -5,17 +5,17 @@ module.exports = Self => {
accepts: [
{
arg: 'id',
- type: 'Number',
+ type: 'number',
description: 'The user id',
http: {source: 'path'}
}, {
arg: 'oldPassword',
- type: 'String',
+ type: 'string',
description: 'The old password',
required: true
}, {
arg: 'newPassword',
- type: 'String',
+ type: 'string',
description: 'The new password',
required: true
}
diff --git a/back/methods/account/specs/change-password.spec.js b/back/methods/account/specs/change-password.spec.js
index 9f1130df5..17fadb3c6 100644
--- a/back/methods/account/specs/change-password.spec.js
+++ b/back/methods/account/specs/change-password.spec.js
@@ -1,9 +1,12 @@
-const app = require('vn-loopback/server/server');
+const {models} = require('vn-loopback/server/server');
describe('account changePassword()', () => {
it('should throw an error when old password is wrong', async() => {
- let req = app.models.Account.changePassword(null, 1, 'wrongOldPass', 'newPass');
+ let err;
+ await models.Account.changePassword(1, 'wrongPassword', 'nightmare.9999')
+ .catch(error => err = error.sqlMessage);
- await expectAsync(req).toBeRejected();
+ expect(err).toBeDefined();
+ expect(err).toEqual('Invalid password');
});
});
diff --git a/back/methods/chat/sendCheckingPresence.js b/back/methods/chat/sendCheckingPresence.js
index 5c27d72fd..2217aaee2 100644
--- a/back/methods/chat/sendCheckingPresence.js
+++ b/back/methods/chat/sendCheckingPresence.js
@@ -46,7 +46,7 @@ module.exports = Self => {
const {data} = await Self.getUserStatus(recipient.name);
if (data) {
- if (data.status === 'offline') {
+ if (data.status === 'offline' || data.status === 'busy') {
// Send message to department room
const workerDepartment = await models.WorkerDepartment.findById(recipientId, {
include: {
@@ -58,6 +58,8 @@ module.exports = Self => {
if (channelName)
return Self.send(ctx, `#${channelName}`, `@${recipient.name} ➔ ${message}`);
+ else
+ return Self.send(ctx, `@${recipient.name}`, message);
} else
return Self.send(ctx, `@${recipient.name}`, message);
}
diff --git a/back/methods/collection/collectionFaults.js b/back/methods/collection/collectionFaults.js
deleted file mode 100644
index 395c7e581..000000000
--- a/back/methods/collection/collectionFaults.js
+++ /dev/null
@@ -1,35 +0,0 @@
-module.exports = Self => {
- Self.remoteMethod('collectionFaults', {
- description: 'Update sale of a collection',
- accessType: 'WRITE',
- accepts: [{
- arg: 'shelvingFk',
- type: 'String',
- required: true,
- description: 'The shalving id'
- }, {
- arg: 'quantity',
- type: 'Number',
- required: true,
- description: 'The quantity to sale'
- }, {
- arg: 'itemFk',
- type: 'Number',
- required: true,
- description: 'The ticket id'
- }],
- returns: {
- type: 'Object',
- root: true
- },
- http: {
- path: `/collectionFaults`,
- verb: 'POST'
- }
- });
-
- Self.collectionFaults = async(shelvingFk, quantity, itemFk) => {
- query = `CALL vn.collection_faults(?,?,?)`;
- return await Self.rawSql(query, [shelvingFk, quantity, itemFk]);
- };
-};
diff --git a/back/methods/collection/setSaleQuantity.js b/back/methods/collection/setSaleQuantity.js
index 82451b8be..644c44a60 100644
--- a/back/methods/collection/setSaleQuantity.js
+++ b/back/methods/collection/setSaleQuantity.js
@@ -1,5 +1,5 @@
module.exports = Self => {
- Self.remoteMethodCtx('setSaleQuantity', {
+ Self.remoteMethod('setSaleQuantity', {
description: 'Update sale quantity',
accessType: 'WRITE',
accepts: [{
@@ -24,11 +24,13 @@ module.exports = Self => {
}
});
- Self.setSaleQuantity = async ctx => {
- const args = ctx.args;
+ Self.setSaleQuantity = async(saleId, quantity) => {
const models = Self.app.models;
- const sale = await models.Sale.findById(args.saleId,);
- return await sale.updateAttribute('quantity', args.quantity);
+ const sale = await models.Sale.findById(saleId);
+ return await sale.updateAttributes({
+ originalQuantity: sale.quantity,
+ quantity: quantity
+ });
};
};
diff --git a/back/methods/collection/spec/collectionFauls.spec.js b/back/methods/collection/spec/collectionFauls.spec.js
deleted file mode 100644
index 210dcdf63..000000000
--- a/back/methods/collection/spec/collectionFauls.spec.js
+++ /dev/null
@@ -1,9 +0,0 @@
-const app = require('vn-loopback/server/server');
-describe('collectionFaults()', () => {
- it('return shelving afected', async() => {
- let response = await app.models.Collection.collectionFaults('UXN', 0, 1);
-
- expect(response.length).toBeGreaterThan(0);
- expect(response[0][0].shelvingFk).toEqual('UXN');
- });
-});
diff --git a/back/methods/collection/spec/newCollection.spec.js b/back/methods/collection/spec/newCollection.spec.js
index 88d105b4b..6abe73f8e 100644
--- a/back/methods/collection/spec/newCollection.spec.js
+++ b/back/methods/collection/spec/newCollection.spec.js
@@ -1,8 +1,8 @@
const app = require('vn-loopback/server/server');
-// #3400 analizar que hacer con rutas de back colletion
-xdescribe('newCollection()', () => {
- it('return a new collection', async() => {
+describe('newCollection()', () => {
+ it('should return a new collection', async() => {
+ pending('#3400 analizar que hacer con rutas de back collection');
let ctx = {req: {accessToken: {userId: 1106}}};
let response = await app.models.Collection.newCollection(ctx, 1, 1, 1);
diff --git a/back/methods/collection/spec/setSaleQuantity.spec.js b/back/methods/collection/spec/setSaleQuantity.spec.js
index 4e3c8c4aa..5d06a4383 100644
--- a/back/methods/collection/spec/setSaleQuantity.spec.js
+++ b/back/methods/collection/spec/setSaleQuantity.spec.js
@@ -5,19 +5,12 @@ describe('setSaleQuantity()', () => {
const saleId = 30;
const newQuantity = 10;
- const ctx = {
- args: {
- saleId: saleId,
- quantity: newQuantity
- }
- };
-
const originalSale = await models.Sale.findById(saleId);
- await models.Collection.setSaleQuantity(ctx);
+ await models.Collection.setSaleQuantity(saleId, newQuantity);
const updateSale = await models.Sale.findById(saleId);
- expect(updateSale.quantity).toBeLessThan(originalSale.quantity);
+ expect(updateSale.originalQuantity).toEqual(originalSale.quantity);
expect(updateSale.quantity).toEqual(newQuantity);
});
});
diff --git a/back/methods/dms/deleteTrashFiles.js b/back/methods/dms/deleteTrashFiles.js
new file mode 100644
index 000000000..9d16e9d81
--- /dev/null
+++ b/back/methods/dms/deleteTrashFiles.js
@@ -0,0 +1,57 @@
+const fs = require('fs-extra');
+const path = require('path');
+
+module.exports = Self => {
+ Self.remoteMethod('deleteTrashFiles', {
+ description: 'Deletes files that have trash type',
+ accessType: 'WRITE',
+ returns: {
+ type: 'object',
+ root: true
+ },
+ http: {
+ path: `/deleteTrashFiles`,
+ verb: 'POST'
+ }
+ });
+
+ Self.deleteTrashFiles = async(options) => {
+ const tx = await Self.beginTransaction({});
+ const myOptions = {};
+
+ if (typeof options == 'object')
+ Object.assign(myOptions, options);
+
+ if (!myOptions.transaction)
+ myOptions.transaction = tx;
+
+ try {
+ const models = Self.app.models;
+ const DmsContainer = models.DmsContainer;
+
+ const trashDmsType = await models.DmsType.findOne({
+ where: {code: 'trash'}
+ }, myOptions);
+
+ const dmsToDelete = await models.Dms.find({
+ where: {
+ dmsTypeFk: trashDmsType.id
+ }
+ }, myOptions);
+
+ for (let dms of dmsToDelete) {
+ const pathHash = DmsContainer.getHash(dms.id);
+ const dmsContainer = await DmsContainer.container(pathHash);
+ const dstFile = path.join(dmsContainer.client.root, pathHash, dms.file);
+ await fs.unlink(dstFile);
+ await dms.destroy(myOptions);
+ }
+ if (tx) await tx.commit();
+
+ } catch (e) {
+ if (tx) await tx.rollback();
+
+ throw e;
+ }
+ };
+};
diff --git a/back/methods/docuware/specs/checkFile.spec.js b/back/methods/docuware/specs/checkFile.spec.js
index 2ebde0df4..0d0e4d71a 100644
--- a/back/methods/docuware/specs/checkFile.spec.js
+++ b/back/methods/docuware/specs/checkFile.spec.js
@@ -12,9 +12,9 @@ describe('docuware download()', () => {
}
};
- const fileCabinetName = 'deliveryClientTest';
+ const fileCabinetName = 'deliveryClient';
const dialogDisplayName = 'find';
- const dialogName = 'findTest';
+ const dialogName = 'findTicket';
const gotGetResponse = {
body: JSON.stringify(
diff --git a/back/methods/docuware/specs/download.spec.js b/back/methods/docuware/specs/download.spec.js
index 436063fd8..dc80c67d8 100644
--- a/back/methods/docuware/specs/download.spec.js
+++ b/back/methods/docuware/specs/download.spec.js
@@ -14,9 +14,9 @@ describe('docuware download()', () => {
};
it('should return the downloaded file name', async() => {
- const fileCabinetName = 'deliveryClientTest';
+ const fileCabinetName = 'deliveryClient';
const dialogDisplayName = 'find';
- const dialogName = 'findTest';
+ const dialogName = 'findTicket';
const gotGetResponse = {
body: JSON.stringify(
{
diff --git a/back/methods/edi/sql/bucket.sql b/back/methods/edi/sql/bucket.sql
index 92121386c..33dca6796 100644
--- a/back/methods/edi/sql/bucket.sql
+++ b/back/methods/edi/sql/bucket.sql
@@ -1,5 +1,5 @@
LOAD DATA LOCAL INFILE ?
- INTO TABLE bucket
+ INTO TABLE `edi`.`bucket`
FIELDS TERMINATED BY ';'
LINES TERMINATED BY '\n' (@col1, @col2, @col3, @col4, @col5, @col6, @col7, @col8, @col9, @col10, @col11, @col12)
SET
diff --git a/back/methods/edi/sql/bucket_type.sql b/back/methods/edi/sql/bucket_type.sql
index 68498f183..f748fac84 100644
--- a/back/methods/edi/sql/bucket_type.sql
+++ b/back/methods/edi/sql/bucket_type.sql
@@ -1,5 +1,5 @@
LOAD DATA LOCAL INFILE ?
- INTO TABLE bucket_type
+ INTO TABLE `edi`.`bucket_type`
FIELDS TERMINATED BY ';'
LINES TERMINATED BY '\n' (@col1, @col2, @col3, @col4, @col5, @col6)
SET
diff --git a/back/methods/edi/sql/feature.sql b/back/methods/edi/sql/feature.sql
index 081cfde7b..7486a5bd3 100644
--- a/back/methods/edi/sql/feature.sql
+++ b/back/methods/edi/sql/feature.sql
@@ -1,5 +1,5 @@
LOAD DATA LOCAL INFILE ?
- INTO TABLE `feature`
+ INTO TABLE `edi`.`feature`
FIELDS TERMINATED BY ';'
LINES TERMINATED BY '\n' (@col1, @col2, @col3, @col4, @col5, @col6, @col7)
SET
diff --git a/back/methods/edi/sql/genus.sql b/back/methods/edi/sql/genus.sql
index dd882629c..52b85f020 100644
--- a/back/methods/edi/sql/genus.sql
+++ b/back/methods/edi/sql/genus.sql
@@ -1,5 +1,5 @@
LOAD DATA LOCAL INFILE ?
- INTO TABLE genus
+ INTO TABLE `edi`.`genus`
FIELDS TERMINATED BY ';'
LINES TERMINATED BY '\n' (@col1, @col2, @col3, @col4, @col5, @col6)
SET
diff --git a/back/methods/edi/sql/item.sql b/back/methods/edi/sql/item.sql
index 543c83381..8d794c7cf 100644
--- a/back/methods/edi/sql/item.sql
+++ b/back/methods/edi/sql/item.sql
@@ -1,5 +1,5 @@
LOAD DATA LOCAL INFILE ?
- INTO TABLE item
+ INTO TABLE `edi`.`item`
FIELDS TERMINATED BY ';'
LINES TERMINATED BY '\n' (@col1, @col2, @col3, @col4, @col5, @col6, @col7, @col8, @col9, @col10, @col11, @col12)
SET
diff --git a/back/methods/edi/sql/item_feature.sql b/back/methods/edi/sql/item_feature.sql
index 23b0f3afa..f16da6ed0 100644
--- a/back/methods/edi/sql/item_feature.sql
+++ b/back/methods/edi/sql/item_feature.sql
@@ -1,5 +1,5 @@
LOAD DATA LOCAL INFILE ?
- INTO TABLE `item_feature`
+ INTO TABLE `edi`.`item_feature`
FIELDS TERMINATED BY ';'
LINES TERMINATED BY '\n' (@col1, @col2, @col3, @col4, @col5, @col6, @col7, @col8)
SET
diff --git a/back/methods/edi/sql/item_group.sql b/back/methods/edi/sql/item_group.sql
index 31da6c57f..1a57d7727 100644
--- a/back/methods/edi/sql/item_group.sql
+++ b/back/methods/edi/sql/item_group.sql
@@ -1,5 +1,5 @@
LOAD DATA LOCAL INFILE ?
- INTO TABLE item_group
+ INTO TABLE `edi`.`item_group`
FIELDS TERMINATED BY ';'
LINES TERMINATED BY '\n' (@col1, @col2, @col3, @col4, @col5, @col6)
SET
diff --git a/back/methods/edi/sql/plant.sql b/back/methods/edi/sql/plant.sql
index 50720fba5..8d6f90b78 100644
--- a/back/methods/edi/sql/plant.sql
+++ b/back/methods/edi/sql/plant.sql
@@ -1,5 +1,5 @@
LOAD DATA LOCAL INFILE ?
- INTO TABLE plant
+ INTO TABLE `edi`.`plant`
FIELDS TERMINATED BY ';'
LINES TERMINATED BY '\n' (@col1, @col2, @col3, @col4, @col5, @col6, @col7, @col8, @col9)
SET
diff --git a/back/methods/edi/sql/specie.sql b/back/methods/edi/sql/specie.sql
index e27478ae8..956ec2b69 100644
--- a/back/methods/edi/sql/specie.sql
+++ b/back/methods/edi/sql/specie.sql
@@ -1,5 +1,5 @@
LOAD DATA LOCAL INFILE ?
- INTO TABLE specie
+ INTO TABLE `edi`.`specie`
FIELDS TERMINATED BY ';'
LINES TERMINATED BY '\n' (@col1, @col2, @col3, @col4, @col5, @col6, @col7)
SET
diff --git a/back/methods/edi/sql/supplier.sql b/back/methods/edi/sql/supplier.sql
index a1d3376d6..aa2ddc4d8 100644
--- a/back/methods/edi/sql/supplier.sql
+++ b/back/methods/edi/sql/supplier.sql
@@ -1,5 +1,5 @@
LOAD DATA LOCAL INFILE ?
- INTO TABLE edi.supplier
+ INTO TABLE `edi`.`supplier`
FIELDS TERMINATED BY ';'
LINES TERMINATED BY '\n' (@col1, @col2, @col3, @col4, @col5, @col6, @col7, @col8, @col9, @col10, @col11, @col12, @col13, @col14, @col15, @col16, @col17, @col18, @col19, @col20)
SET
diff --git a/back/methods/edi/sql/type.sql b/back/methods/edi/sql/type.sql
index 88c4ac026..1ff60fb0b 100644
--- a/back/methods/edi/sql/type.sql
+++ b/back/methods/edi/sql/type.sql
@@ -1,5 +1,5 @@
LOAD DATA LOCAL INFILE ?
- INTO TABLE `type`
+ INTO TABLE `edi`.`type`
FIELDS TERMINATED BY ';'
LINES TERMINATED BY '\n' (@col1, @col2, @col3, @col4, @col5, @col6, @col7)
SET
diff --git a/back/methods/edi/sql/value.sql b/back/methods/edi/sql/value.sql
index c8c4deef5..2a469f201 100644
--- a/back/methods/edi/sql/value.sql
+++ b/back/methods/edi/sql/value.sql
@@ -1,5 +1,5 @@
LOAD DATA LOCAL INFILE ?
- INTO TABLE `value`
+ INTO TABLE `edi`.`value`
FIELDS TERMINATED BY ';'
LINES TERMINATED BY '\n' (@col1, @col2, @col3, @col4, @col5, @col6, @col7)
SET
diff --git a/back/methods/edi/updateData.js b/back/methods/edi/updateData.js
index df77906da..33ad76e6d 100644
--- a/back/methods/edi/updateData.js
+++ b/back/methods/edi/updateData.js
@@ -22,6 +22,9 @@ module.exports = Self => {
const container = await models.TempContainer.container('edi');
const tempPath = path.join(container.client.root, container.name);
+ // Temporary file clean
+ await fs.rmdir(`${tempPath}/*`, {recursive: true});
+
const [ftpConfig] = await Self.rawSql('SELECT host, user, password FROM edi.ftpConfig');
console.debug(`Openning FTP connection to ${ftpConfig.host}...\n`);
@@ -48,6 +51,12 @@ module.exports = Self => {
tempDir = `${tempPath}/${fileName}`;
tempFile = `${tempPath}/${fileName}.zip`;
+ // if (fs.existsSync(tempFile))
+ // await fs.unlink(tempFile);
+
+ // if (fs.existsSync(tempDir))
+ // await fs.rmdir(tempDir, {recursive: true});
+
await extractFile({
ftpClient: ftpClient,
file: file,
@@ -61,7 +70,6 @@ module.exports = Self => {
if (fs.existsSync(tempFile))
await fs.unlink(tempFile);
- await fs.rmdir(tempDir, {recursive: true});
console.error(error);
}
}
@@ -86,9 +94,6 @@ module.exports = Self => {
zip.extractAllTo(paths.tempDir, false);
- if (fs.existsSync(paths.tempFile))
- await fs.unlink(paths.tempFile);
-
await dumpData({file, entries, paths});
await fs.rmdir(paths.tempDir, {recursive: true});
@@ -99,57 +104,59 @@ module.exports = Self => {
const toTable = file.toTable;
const baseName = file.fileName;
- for (const zipEntry of entries) {
- const entryName = zipEntry.entryName;
- console.log(`Reading file ${entryName}...`);
+ const tx = await Self.beginTransaction({});
- const startIndex = (entryName.length - 10);
- const endIndex = (entryName.length - 4);
- const dateString = entryName.substring(startIndex, endIndex);
- const lastUpdated = new Date();
+ try {
+ const options = {transaction: tx};
- // Format string date to a date object
- let updated = null;
- if (file.updated) {
- updated = new Date(file.updated);
- updated.setHours(0, 0, 0, 0);
- }
+ const tableName = `edi.${toTable}`;
+ await Self.rawSql(`DELETE FROM ??`, [tableName], options);
- lastUpdated.setFullYear(`20${dateString.substring(4, 6)}`);
- lastUpdated.setMonth(parseInt(dateString.substring(2, 4)) - 1);
- lastUpdated.setDate(dateString.substring(0, 2));
- lastUpdated.setHours(0, 0, 0, 0);
+ for (const zipEntry of entries) {
+ const entryName = zipEntry.entryName;
+ console.log(`Reading file ${entryName}...`);
- if (updated && lastUpdated <= updated) {
- console.debug(`Table ${toTable} already updated, skipping...`);
- continue;
- }
+ const startIndex = (entryName.length - 10);
+ const endIndex = (entryName.length - 4);
+ const dateString = entryName.substring(startIndex, endIndex);
+ const lastUpdated = new Date();
- console.log('Dumping data...');
- const templatePath = path.join(__dirname, `./sql/${toTable}.sql`);
- const sqlTemplate = fs.readFileSync(templatePath, 'utf8');
+ // Format string date to a date object
+ let updated = null;
+ if (file.updated) {
+ updated = new Date(file.updated);
+ updated.setHours(0, 0, 0, 0);
+ }
- const rawPath = path.join(paths.tempDir, entryName);
+ lastUpdated.setFullYear(`20${dateString.substring(4, 6)}`);
+ lastUpdated.setMonth(parseInt(dateString.substring(2, 4)) - 1);
+ lastUpdated.setDate(dateString.substring(0, 2));
+ lastUpdated.setHours(0, 0, 0, 0);
- try {
- const tx = await Self.beginTransaction({});
- const options = {transaction: tx};
+ if (updated && lastUpdated <= updated) {
+ console.debug(`Table ${toTable} already updated, skipping...`);
+ continue;
+ }
+
+ console.log('Dumping data...');
+ const templatePath = path.join(__dirname, `./sql/${toTable}.sql`);
+ const sqlTemplate = fs.readFileSync(templatePath, 'utf8');
+
+ const rawPath = path.join(paths.tempDir, entryName);
- await Self.rawSql(`DELETE FROM edi.${toTable}`, null, options);
await Self.rawSql(sqlTemplate, [rawPath], options);
await Self.rawSql(`
- UPDATE edi.fileConfig
- SET updated = ?
- WHERE fileName = ?
- `, [lastUpdated, baseName], options);
-
- tx.commit();
- } catch (error) {
- tx.rollback();
- throw error;
+ UPDATE edi.fileConfig
+ SET updated = ?
+ WHERE fileName = ?
+ `, [lastUpdated, baseName], options);
}
- console.log(`Updated table ${toTable}\n`);
+ tx.commit();
+ } catch (error) {
+ tx.rollback();
+ throw error;
}
+ console.log(`Updated table ${toTable}\n`);
}
};
diff --git a/back/model-config.json b/back/model-config.json
index 4ce11b99d..343210383 100644
--- a/back/model-config.json
+++ b/back/model-config.json
@@ -68,6 +68,12 @@
"Language": {
"dataSource": "vn"
},
+ "MachineWorker": {
+ "dataSource": "vn"
+ },
+ "MobileAppVersionControl": {
+ "dataSource": "vn"
+ },
"Module": {
"dataSource": "vn"
},
diff --git a/back/models/account.json b/back/models/account.json
index b59cf39c2..5f0b05f9b 100644
--- a/back/models/account.json
+++ b/back/models/account.json
@@ -47,7 +47,7 @@
"type": "date"
},
"image": {
- "type": "String"
+ "type": "string"
}
},
"relations": {
@@ -71,6 +71,11 @@
"type": "hasOne",
"model": "Worker",
"foreignKey": "userFk"
+ },
+ "userConfig": {
+ "type": "hasOne",
+ "model": "UserConfig",
+ "foreignKey": "userFk"
}
},
"acls": [
diff --git a/back/models/accounting-type.json b/back/models/accounting-type.json
index be08ac533..086be9d13 100644
--- a/back/models/accounting-type.json
+++ b/back/models/accounting-type.json
@@ -28,6 +28,9 @@
},
"maxAmount": {
"type": "number"
+ },
+ "daysInFuture": {
+ "type": "number"
}
},
"acls": [{
diff --git a/back/models/app-version-control.json b/back/models/app-version-control.json
new file mode 100644
index 000000000..46c53be3c
--- /dev/null
+++ b/back/models/app-version-control.json
@@ -0,0 +1,24 @@
+{
+ "name": "MobileAppVersionControl",
+ "base": "VnModel",
+ "options": {
+ "mysql": {
+ "table": "vn.mobileAppVersionControl"
+ }
+ },
+ "properties": {
+ "id": {
+ "type": "number",
+ "id": true
+ },
+ "appName": {
+ "type": "string"
+ },
+ "version": {
+ "type": "string"
+ },
+ "isVersionCritical": {
+ "type": "boolean"
+ }
+ }
+}
diff --git a/back/models/autonomy.json b/back/models/autonomy.json
index ce9ac0bc6..8c9d82936 100644
--- a/back/models/autonomy.json
+++ b/back/models/autonomy.json
@@ -9,7 +9,7 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"id": true,
"description": "Identifier"
},
diff --git a/back/models/bank-entity.json b/back/models/bank-entity.json
index c45cd4336..35d1116bd 100644
--- a/back/models/bank-entity.json
+++ b/back/models/bank-entity.json
@@ -8,15 +8,15 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"id": true,
"description": "Identifier"
},
"bic": {
- "type": "String"
+ "type": "string"
},
"name": {
- "type": "String"
+ "type": "string"
}
},
"relations": {
diff --git a/back/models/bank.json b/back/models/bank.json
index 33a2637d6..da73b1141 100644
--- a/back/models/bank.json
+++ b/back/models/bank.json
@@ -8,35 +8,35 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"id": true,
"description": "Identifier"
},
"bank": {
- "type": "String",
+ "type": "string",
"required": true
},
"account": {
- "type": "String",
+ "type": "string",
"required": true
},
"accountingTypeFk": {
- "type": "Number",
+ "type": "number",
"required": true,
"mysql": {
"columnName": "cash"
}
},
"entityFk": {
- "type": "Number",
+ "type": "number",
"required": true
},
"isActive": {
- "type": "Boolean",
+ "type": "boolean",
"required": true
},
"currencyFk": {
- "type": "Number",
+ "type": "number",
"required": true
}
},
diff --git a/back/models/chat-config.json b/back/models/chat-config.json
index d4f708b7a..bdfbeb60d 100644
--- a/back/models/chat-config.json
+++ b/back/models/chat-config.json
@@ -10,20 +10,20 @@
"properties": {
"id": {
"id": true,
- "type": "Number",
+ "type": "number",
"description": "Identifier"
},
"host": {
- "type": "String"
+ "type": "string"
},
"api": {
- "type": "String"
+ "type": "string"
},
"user": {
- "type": "String"
+ "type": "string"
},
"password": {
- "type": "String"
+ "type": "string"
}
},
"acls": [{
diff --git a/back/models/collection.js b/back/models/collection.js
index 29a0c4c32..436414f62 100644
--- a/back/models/collection.js
+++ b/back/models/collection.js
@@ -3,5 +3,4 @@ module.exports = Self => {
require('../methods/collection/newCollection')(Self);
require('../methods/collection/getSectors')(Self);
require('../methods/collection/setSaleQuantity')(Self);
- require('../methods/collection/collectionFaults')(Self);
};
diff --git a/back/models/company.json b/back/models/company.json
index eb349477b..a36b43b69 100644
--- a/back/models/company.json
+++ b/back/models/company.json
@@ -10,11 +10,11 @@
"properties": {
"id": {
"id": true,
- "type": "Number",
+ "type": "number",
"description": "Identifier"
},
"code": {
- "type": "String"
+ "type": "string"
},
"expired": {
"type": "date"
diff --git a/back/models/country.json b/back/models/country.json
index 8364636fc..8fa25b88e 100644
--- a/back/models/country.json
+++ b/back/models/country.json
@@ -9,7 +9,7 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"id": true,
"description": "Identifier"
},
@@ -21,7 +21,7 @@
"type": "string"
},
"isUeeMember": {
- "type": "Boolean"
+ "type": "boolean"
}
},
"relations": {
diff --git a/back/models/delivery.json b/back/models/delivery.json
index 7c3c5c621..65a0eef1b 100644
--- a/back/models/delivery.json
+++ b/back/models/delivery.json
@@ -9,17 +9,17 @@
"properties": {
"id": {
"id": true,
- "type": "Number",
+ "type": "number",
"forceId": false
},
"date": {
- "type": "Date"
+ "type": "date"
},
"m3":{
- "type": "Number"
+ "type": "number"
},
"warehouseFk":{
- "type": "Number"
+ "type": "number"
}
}
}
diff --git a/back/models/dms-type.json b/back/models/dms-type.json
index b51c810ac..c7a1815fe 100644
--- a/back/models/dms-type.json
+++ b/back/models/dms-type.json
@@ -9,7 +9,7 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"id": true,
"description": "Identifier"
},
diff --git a/back/models/dms.js b/back/models/dms.js
index 91291a0c2..24c072f56 100644
--- a/back/models/dms.js
+++ b/back/models/dms.js
@@ -5,6 +5,7 @@ module.exports = Self => {
require('../methods/dms/uploadFile')(Self);
require('../methods/dms/removeFile')(Self);
require('../methods/dms/updateFile')(Self);
+ require('../methods/dms/deleteTrashFiles')(Self);
Self.checkRole = async function(ctx, id) {
const models = Self.app.models;
diff --git a/back/models/dms.json b/back/models/dms.json
index f517a23ff..0259e5487 100644
--- a/back/models/dms.json
+++ b/back/models/dms.json
@@ -13,7 +13,7 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"id": true,
"description": "Identifier"
},
@@ -36,7 +36,7 @@
"type": "boolean"
},
"created": {
- "type": "Date"
+ "type": "date"
}
},
"relations": {
diff --git a/back/models/email-user.json b/back/models/email-user.json
index e983635ce..81c01ab0c 100644
--- a/back/models/email-user.json
+++ b/back/models/email-user.json
@@ -9,7 +9,7 @@
"properties": {
"userFk": {
"id": true,
- "type": "Number",
+ "type": "number",
"required": true
},
"email": {
diff --git a/back/models/image-collection-size.json b/back/models/image-collection-size.json
index adb92d16b..9452456ee 100644
--- a/back/models/image-collection-size.json
+++ b/back/models/image-collection-size.json
@@ -8,20 +8,20 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"id": true,
"description": "Identifier"
},
"width": {
- "type": "Number",
+ "type": "number",
"required": true
},
"height": {
- "type": "Number",
+ "type": "number",
"required": true
},
"crop": {
- "type": "Boolean",
+ "type": "boolean",
"required": true
}
},
diff --git a/back/models/image-collection.json b/back/models/image-collection.json
index fd019ecc3..186ab0208 100644
--- a/back/models/image-collection.json
+++ b/back/models/image-collection.json
@@ -8,32 +8,32 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"id": true,
"description": "Identifier"
},
"name": {
- "type": "String",
+ "type": "string",
"required": true
},
"desc": {
- "type": "String",
+ "type": "string",
"required": true
},
"maxWidth": {
- "type": "Number",
+ "type": "number",
"required": true
},
"maxHeight": {
- "type": "Number",
+ "type": "number",
"required": true
},
"model": {
- "type": "String",
+ "type": "string",
"required": true
},
"property": {
- "type": "String",
+ "type": "string",
"required": true
}
},
diff --git a/back/models/machine-worker.json b/back/models/machine-worker.json
new file mode 100644
index 000000000..2244a533f
--- /dev/null
+++ b/back/models/machine-worker.json
@@ -0,0 +1,33 @@
+{
+ "name": "MachineWorker",
+ "base": "VnModel",
+ "options": {
+ "mysql": {
+ "table": "vn.machineWorker"
+ }
+ },
+ "properties": {
+ "id": {
+ "type": "number",
+ "id": true
+ },
+ "workerFk": {
+ "type": "number"
+ },
+ "machineFk": {
+ "type": "number"
+ },
+ "inTime": {
+ "type": "date",
+ "mysql": {
+ "columnName": "inTimed"
+ }
+ },
+ "outTime": {
+ "type": "date",
+ "mysql": {
+ "columnName": "outTimed"
+ }
+ }
+ }
+}
diff --git a/back/models/postcode.json b/back/models/postcode.json
index e28a77dc4..eadc2c86c 100644
--- a/back/models/postcode.json
+++ b/back/models/postcode.json
@@ -9,7 +9,7 @@
"properties": {
"code": {
"id": true,
- "type": "String"
+ "type": "string"
}
},
"relations": {
diff --git a/back/models/sage-withholding.json b/back/models/sage-withholding.json
index dddbcfd74..87f00a01c 100644
--- a/back/models/sage-withholding.json
+++ b/back/models/sage-withholding.json
@@ -11,7 +11,7 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"id": true,
"description": "Identifier",
"mysql": {
diff --git a/back/models/town.json b/back/models/town.json
index 41633fe0a..4ad729791 100644
--- a/back/models/town.json
+++ b/back/models/town.json
@@ -9,10 +9,10 @@
"properties": {
"id": {
"id": true,
- "type": "Number"
+ "type": "number"
},
"name": {
- "type": "String"
+ "type": "string"
}
},
"relations": {
diff --git a/back/models/user-config-view.json b/back/models/user-config-view.json
index 8ffbc6f48..f9235725c 100644
--- a/back/models/user-config-view.json
+++ b/back/models/user-config-view.json
@@ -9,18 +9,18 @@
"properties": {
"id": {
"id": true,
- "type": "Number"
+ "type": "number"
},
"userFk": {
- "type": "String",
+ "type": "string",
"required": true
},
"tableCode": {
- "type": "String",
+ "type": "string",
"required": true
},
"configuration": {
- "type": "Object"
+ "type": "object"
}
},
"relations": {
diff --git a/back/models/user-config.json b/back/models/user-config.json
index 336f26f63..8e4684713 100644
--- a/back/models/user-config.json
+++ b/back/models/user-config.json
@@ -9,20 +9,23 @@
"properties": {
"userFk": {
"id": true,
- "type": "Number",
+ "type": "number",
"required": true
},
"warehouseFk": {
- "type": "Number"
+ "type": "number"
},
"companyFk": {
- "type": "Number"
+ "type": "number"
},
"created": {
- "type": "Date"
+ "type": "date"
},
"updated": {
- "type": "Date"
+ "type": "date"
+ },
+ "darkMode": {
+ "type": "boolean"
}
},
"relations": {
diff --git a/back/models/user-log.json b/back/models/user-log.json
index e3e3a6752..43ccbfa43 100644
--- a/back/models/user-log.json
+++ b/back/models/user-log.json
@@ -9,40 +9,40 @@
"properties": {
"id": {
"id": true,
- "type": "Number",
+ "type": "number",
"forceId": false
},
"originFk": {
- "type": "Number",
+ "type": "number",
"required": true
},
"userFk": {
- "type": "Number"
+ "type": "number"
},
"action": {
- "type": "String",
+ "type": "string",
"required": true
},
"changedModel": {
- "type": "String"
+ "type": "string"
},
"oldInstance": {
- "type": "Object"
+ "type": "object"
},
"newInstance": {
- "type": "Object"
+ "type": "object"
},
"creationDate": {
- "type": "Date"
+ "type": "date"
},
"changedModelId": {
- "type": "Number"
+ "type": "number"
},
"changedModelValue": {
- "type": "String"
+ "type": "string"
},
"description": {
- "type": "String"
+ "type": "string"
}
},
"relations": {
diff --git a/back/models/user.json b/back/models/user.json
index 1d8f8f3a5..921362e0e 100644
--- a/back/models/user.json
+++ b/back/models/user.json
@@ -9,7 +9,7 @@
"properties": {
"id": {
"id": true,
- "type": "Number",
+ "type": "number",
"forceId": false
},
"username":{
diff --git a/back/models/warehouse.json b/back/models/warehouse.json
index 1d8ca44e3..eb86e2114 100644
--- a/back/models/warehouse.json
+++ b/back/models/warehouse.json
@@ -10,17 +10,17 @@
"properties": {
"id": {
"id": true,
- "type": "Number",
+ "type": "number",
"forceId": false
},
"name": {
- "type": "String"
+ "type": "string"
},
"code": {
- "type": "String"
+ "type": "string"
},
"isInventory": {
- "type": "Number"
+ "type": "number"
},
"isManaged":{
"type": "boolean"
diff --git a/back/nodemonConfig.json b/back/nodemonConfig.json
new file mode 100644
index 000000000..a1c9ca84f
--- /dev/null
+++ b/back/nodemonConfig.json
@@ -0,0 +1,24 @@
+{
+ "verbose": true,
+ "watch": [
+ "back/**/*.js",
+ "modules/**/*.js"
+ ],
+ "ignore": [
+ "modules/account/front/**/*",
+ "modules/claim/front/**/*",
+ "modules/client/front/**/*",
+ "modules/entry/front/**/*",
+ "modules/invoiceIn/front/**/*",
+ "modules/invoiceOut/front/**/*",
+ "modules/item/front/**/*",
+ "modules/monitor/front/**/*",
+ "modules/order/front/**/*",
+ "modules/route/front/**/*",
+ "modules/supplier/front/**/*",
+ "modules/ticket/front/**/*",
+ "modules/travel/front/**/*",
+ "modules/worker/front/**/*",
+ "modules/zone/front/**/*"
+ ]
+}
\ No newline at end of file
diff --git a/back/tests.js b/back/tests.js
index c715c96bf..809906177 100644
--- a/back/tests.js
+++ b/back/tests.js
@@ -1,4 +1,5 @@
-require('require-yaml');
+const Docker = require('../db/docker.js');
+let dataSources = require('../loopback/server/datasources.json');
process.on('warning', warning => {
console.log(warning.name);
@@ -6,34 +7,64 @@ process.on('warning', warning => {
console.log(warning.stack);
});
-let verbose = false;
+async function test() {
+ let isCI = false;
-if (process.argv[2] === '--v')
- verbose = true;
+ if (process.argv[2] === 'ci')
+ isCI = true;
-let Jasmine = require('jasmine');
-let jasmine = new Jasmine();
-let SpecReporter = require('jasmine-spec-reporter').SpecReporter;
+ const container = new Docker();
-let serviceSpecs = [
- `${__dirname}/**/*[sS]pec.js`,
- `${__dirname}/../loopback/**/*[sS]pec.js`,
- `${__dirname}/../modules/*/back/**/*.[sS]pec.js`
-];
+ await container.run(isCI);
+ dataSources = JSON.parse(JSON.stringify(dataSources));
-jasmine.loadConfig({
- spec_dir: '.',
- spec_files: serviceSpecs,
- helpers: []
-});
+ Object.assign(dataSources.vn, {
+ host: container.dbConf.host,
+ port: container.dbConf.port
+ });
-jasmine.addReporter(new SpecReporter({
- spec: {
- // displayStacktrace: 'summary',
- displaySuccessful: verbose,
- displayFailedSpec: true,
- displaySpecDuration: true
+ const bootOptions = {dataSources};
+ const app = require('vn-loopback/server/server');
+ app.boot(bootOptions);
+
+ const Jasmine = require('jasmine');
+ const jasmine = new Jasmine();
+
+ const SpecReporter = require('jasmine-spec-reporter').SpecReporter;
+ jasmine.addReporter(new SpecReporter({
+ spec: {
+ displaySuccessful: isCI,
+ displayPending: isCI
+ },
+ summary: {
+ displayPending: false,
+ }
+ }));
+
+ if (isCI) {
+ const JunitReporter = require('jasmine-reporters');
+ jasmine.addReporter(new JunitReporter.JUnitXmlReporter());
+
+ jasmine.jasmine.DEFAULT_TIMEOUT_INTERVAL = 30000;
}
-}));
-jasmine.execute();
+ const backSpecs = [
+ './back/**/*[sS]pec.js',
+ './loopback/**/*[sS]pec.js',
+ './modules/*/back/**/*.[sS]pec.js'
+ ];
+
+ jasmine.loadConfig({
+ spec_dir: '.',
+ spec_files: backSpecs,
+ helpers: [],
+ });
+
+ jasmine.exitOnCompletion = false;
+ await jasmine.execute();
+ if (app) await app.disconnect();
+ if (container) await container.rm();
+ console.log('app disconnected & container removed');
+}
+
+test();
diff --git a/db/changes/10451-april/00-account_user.sql b/db/changes/10451-april/00-account_user.sql
new file mode 100644
index 000000000..2988c310e
--- /dev/null
+++ b/db/changes/10451-april/00-account_user.sql
@@ -0,0 +1 @@
+ALTER TABLE `vn`.`userConfig` ADD darkMode tinyint(1) DEFAULT 1 NOT NULL COMMENT 'Salix interface dark mode';
\ No newline at end of file
diff --git a/db/changes/10451-april/00-aclExpeditionState.sql b/db/changes/10451-april/00-aclExpeditionState.sql
new file mode 100644
index 000000000..d26117bbf
--- /dev/null
+++ b/db/changes/10451-april/00-aclExpeditionState.sql
@@ -0,0 +1,2 @@
+INSERT INTO `salix`.`ACL`(`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
+VALUES('ExpeditionState', '*', 'READ', 'ALLOW', 'ROLE', 'employee');
\ No newline at end of file
diff --git a/db/changes/10451-april/00-aclExpense.sql b/db/changes/10451-april/00-aclExpense.sql
new file mode 100644
index 000000000..55ca8c389
--- /dev/null
+++ b/db/changes/10451-april/00-aclExpense.sql
@@ -0,0 +1,5 @@
+INSERT INTO `salix`.`ACL`(`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
+ VALUES('Expense', '*', 'READ', 'ALLOW', 'ROLE', 'employee');
+
+INSERT INTO `salix`.`ACL`(`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
+ VALUES('Expense', '*', 'WRITE', 'ALLOW', 'ROLE', 'administrative');
diff --git a/db/changes/10451-april/00-aclSupplierActivity.sql b/db/changes/10451-april/00-aclSupplierActivity.sql
new file mode 100644
index 000000000..bf73a1506
--- /dev/null
+++ b/db/changes/10451-april/00-aclSupplierActivity.sql
@@ -0,0 +1,5 @@
+INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
+VALUES('SupplierActivity', '*', 'READ', 'ALLOW', 'ROLE', 'employee');
+
+INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
+VALUES('SupplierActivity', '*', 'WRITE', 'ALLOW', 'ROLE', 'administrative');
diff --git a/db/changes/10451-april/00-ticket_doRefund.sql b/db/changes/10451-april/00-ticket_doRefund.sql
deleted file mode 100644
index d2177e67f..000000000
--- a/db/changes/10451-april/00-ticket_doRefund.sql
+++ /dev/null
@@ -1,113 +0,0 @@
-DROP PROCEDURE IF EXISTS vn.ticket_doRefund;
-
-DELIMITER $$
-$$
-CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_doRefund`(IN vOriginTicket INT, OUT vNewTicket INT)
-BEGIN
-
- DECLARE vDone BIT DEFAULT 0;
- DECLARE vCustomer MEDIUMINT;
- DECLARE vWarehouse TINYINT;
- DECLARE vCompany MEDIUMINT;
- DECLARE vAddress MEDIUMINT;
- DECLARE vRefundAgencyMode INT;
- DECLARE vItemFk INT;
- DECLARE vQuantity DECIMAL (10,2);
- DECLARE vConcept VARCHAR(50);
- DECLARE vPrice DECIMAL (10,2);
- DECLARE vDiscount TINYINT;
- DECLARE vSaleNew INT;
- DECLARE vSaleMain INT;
- DECLARE vZoneFk INT;
- DECLARE vDescription VARCHAR(50);
- DECLARE vTaxClassFk INT;
- DECLARE vTicketServiceTypeFk INT;
-
- DECLARE cSales CURSOR FOR
- SELECT *
- FROM tmp.sale;
-
- DECLARE cTicketServices CURSOR FOR
- SELECT *
- FROM tmp.ticketService;
-
- DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = 1;
-
- SELECT id INTO vRefundAgencyMode
- FROM agencyMode WHERE `name` = 'ABONO';
-
- SELECT clientFk, warehouseFk, companyFk, addressFk
- INTO vCustomer, vWarehouse, vCompany, vAddress
- FROM ticket
- WHERE id = vOriginTicket;
-
- SELECT id INTO vZoneFk
- FROM zone WHERE agencyModeFk = vRefundAgencyMode
- LIMIT 1;
-
- INSERT INTO vn.ticket (
- clientFk,
- shipped,
- addressFk,
- agencyModeFk,
- nickname,
- warehouseFk,
- companyFk,
- landed,
- zoneFk
- )
- SELECT
- vCustomer,
- vn.VN_CURDATE(),
- vAddress,
- vRefundAgencyMode,
- a.nickname,
- vWarehouse,
- vCompany,
- vn.VN_CURDATE(),
- vZoneFk
- FROM address a
- WHERE a.id = vAddress;
-
- SET vNewTicket = LAST_INSERT_ID();
-
- SET vDone := 0;
- OPEN cSales;
- FETCH cSales INTO vSaleMain, vItemFk, vQuantity, vConcept, vPrice, vDiscount;
-
- WHILE NOT vDone DO
-
- INSERT INTO vn.sale(ticketFk, itemFk, quantity, concept, price, discount)
- VALUES( vNewTicket, vItemFk, vQuantity, vConcept, vPrice, vDiscount );
-
- SET vSaleNew = LAST_INSERT_ID();
-
- INSERT INTO vn.saleComponent(saleFk,componentFk,`value`)
- SELECT vSaleNew,componentFk,`value`
- FROM vn.saleComponent
- WHERE saleFk = vSaleMain;
-
- FETCH cSales INTO vSaleMain, vItemFk, vQuantity, vConcept, vPrice, vDiscount;
-
- END WHILE;
- CLOSE cSales;
-
- SET vDone := 0;
- OPEN cTicketServices;
- FETCH cTicketServices INTO vDescription, vQuantity, vPrice, vTaxClassFk, vTicketServiceTypeFk;
-
- WHILE NOT vDone DO
-
- INSERT INTO vn.ticketService(description, quantity, price, taxClassFk, ticketFk, ticketServiceTypeFk)
- VALUES(vDescription, vQuantity, vPrice, vTaxClassFk, vNewTicket, vTicketServiceTypeFk);
-
- FETCH cTicketServices INTO vDescription, vQuantity, vPrice, vTaxClassFk, vTicketServiceTypeFk;
-
- END WHILE;
- CLOSE cTicketServices;
-
- INSERT INTO vn.ticketRefund(refundTicketFk, originalTicketFk)
- VALUES(vNewTicket, vOriginTicket);
-
-END$$
-DELIMITER ;
diff --git a/db/changes/10460-mother/00-clientConfig.sql b/db/changes/10460-mother/00-clientConfig.sql
new file mode 100644
index 000000000..cd67a5797
--- /dev/null
+++ b/db/changes/10460-mother/00-clientConfig.sql
@@ -0,0 +1,5 @@
+ALTER TABLE `vn`.`clientConfig` ADD `maxCreditRows` int(11) NULL COMMENT 'Máximo número de registros a mantener en la tabla clientCredit';
+
+UPDATE `vn`.`clientConfig`
+ SET `maxCreditRows` = 10
+ WHERE `id` = 1;
\ No newline at end of file
diff --git a/db/changes/10460-mother/00-dmsForeignKey.sql b/db/changes/10460-mother/00-dmsForeignKey.sql
new file mode 100644
index 000000000..6a4736fdd
--- /dev/null
+++ b/db/changes/10460-mother/00-dmsForeignKey.sql
@@ -0,0 +1,8 @@
+ALTER TABLE `vn`.`propertyDms` DROP FOREIGN KEY propertyDms_FK;
+ALTER TABLE `vn`.`propertyDms` ADD CONSTRAINT propertyDms_FK FOREIGN KEY (dmsFk) REFERENCES `vn`.`dms`(id) ON DELETE CASCADE ON UPDATE CASCADE;
+
+ALTER TABLE `vn`.`clientDms` DROP FOREIGN KEY clientDms_ibfk_2;
+ALTER TABLE `vn`.`clientDms` ADD CONSTRAINT clientDms_ibfk_2 FOREIGN KEY (dmsFk) REFERENCES `vn`.`dms`(id) ON DELETE CASCADE ON UPDATE CASCADE;
+
+ALTER TABLE `vn`.`workerDocument` DROP FOREIGN KEY workerDocument_ibfk_2;
+ALTER TABLE `vn`.`workerDocument` ADD CONSTRAINT workerDocument_ibfk_2 FOREIGN KEY (document) REFERENCES `vn`.`dms`(id) ON DELETE CASCADE ON UPDATE CASCADE;
diff --git a/db/changes/10460-mother/01-dmsType.sql b/db/changes/10460-mother/01-dmsType.sql
new file mode 100644
index 000000000..649ffbc71
--- /dev/null
+++ b/db/changes/10460-mother/01-dmsType.sql
@@ -0,0 +1,5 @@
+ALTER TABLE `vn`.`dmsType` ADD monthToDelete INT UNSIGNED DEFAULT NULL NULL;
+ALTER TABLE `vn`.`dmsType` MODIFY COLUMN monthToDelete int(10) unsigned DEFAULT NULL NULL COMMENT 'Meses en el pasado para ir borrando registros, dejar a null para no borrarlos nunca';
+UPDATE `vn`.`dmsType`
+ SET monthToDelete=6
+ WHERE id=20;
diff --git a/db/changes/10460-mother/02-dmsTrigger.sql b/db/changes/10460-mother/02-dmsTrigger.sql
new file mode 100644
index 000000000..d4525440b
--- /dev/null
+++ b/db/changes/10460-mother/02-dmsTrigger.sql
@@ -0,0 +1,18 @@
+
+DELIMITER $$
+$$
+CREATE TRIGGER `vn`.`dms_beforeDelete`
+BEFORE DELETE
+ON dms FOR EACH ROW
+BEGIN
+ DECLARE vCanNotBeDeleted INT;
+ SELECT COUNT(*) INTO vCanNotBeDeleted
+ FROM dmsType dt
+ WHERE NOT (code <=> 'trash')
+ AND dt.id = OLD.dmsTypeFk;
+
+ IF vCanNotBeDeleted THEN
+ CALL util.throw('A dms can not be deleted');
+ END IF;
+END$$
+DELIMITER ;
diff --git a/db/changes/10460-mother/03-clean.sql b/db/changes/10460-mother/03-clean.sql
new file mode 100644
index 000000000..13951394f
--- /dev/null
+++ b/db/changes/10460-mother/03-clean.sql
@@ -0,0 +1,175 @@
+DROP PROCEDURE IF EXISTS vn.clean;
+
+DELIMITER $$
+$$
+CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`clean`()
+BEGIN
+ DECLARE vDateShort DATETIME;
+ DECLARE vOneYearAgo DATE;
+ DECLARE vFourYearsAgo DATE;
+ DECLARE v18Month DATE;
+ DECLARE v26Month DATE;
+ DECLARE v3Month DATE;
+ DECLARE vTrashId varchar(15);
+
+ SET vDateShort = TIMESTAMPADD(MONTH, -2, CURDATE());
+ SET vOneYearAgo = TIMESTAMPADD(YEAR,-1,CURDATE());
+ SET vFourYearsAgo = TIMESTAMPADD(YEAR,-4,CURDATE());
+ SET v18Month = TIMESTAMPADD(MONTH, -18,CURDATE());
+ SET v26Month = TIMESTAMPADD(MONTH, -26,CURDATE());
+ SET v3Month = TIMESTAMPADD(MONTH, -3, CURDATE());
+
+ DELETE FROM ticketParking WHERE created < vDateShort;
+ DELETE FROM routesMonitor WHERE dated < vDateShort;
+ DELETE FROM workerTimeControlLog WHERE created < vDateShort;
+ DELETE FROM `message` WHERE sendDate < vDateShort;
+ DELETE FROM messageInbox WHERE sendDate < vDateShort;
+ DELETE FROM messageInbox WHERE sendDate < vDateShort;
+ DELETE FROM workerTimeControl WHERE timed < vFourYearsAgo;
+ DELETE FROM itemShelving WHERE created < CURDATE() AND visible = 0;
+ DELETE FROM ticketDown WHERE created < TIMESTAMPADD(DAY,-1,CURDATE());
+ DELETE FROM entryLog WHERE creationDate < vDateShort;
+ DELETE IGNORE FROM expedition WHERE created < v26Month;
+ DELETE FROM sms WHERE created < v18Month;
+ DELETE FROM saleTracking WHERE created < vOneYearAgo;
+ DELETE tobs FROM ticketObservation tobs
+ JOIN ticket t ON tobs.ticketFk = t.id WHERE t.shipped < TIMESTAMPADD(YEAR,-2,CURDATE());
+ DELETE sc.* FROM saleCloned sc JOIN sale s ON s.id = sc.saleClonedFk JOIN ticket t ON t.id = s.ticketFk WHERE t.shipped < vOneYearAgo;
+ DELETE FROM sharingCart where ended < vDateShort;
+ DELETE FROM sharingClient where ended < vDateShort;
+ DELETE tw.* FROM ticketWeekly tw
+ LEFT JOIN sale s ON s.ticketFk = tw.ticketFk WHERE s.itemFk IS NULL;
+ DELETE FROM claim WHERE ticketCreated < vFourYearsAgo;
+ DELETE FROM message WHERE sendDate < vDateShort;
+ -- Robert ubicacion anterior de trevelLog comentario para debug
+ DELETE sc FROM saleChecked sc
+ JOIN sale s ON sc.saleFk = s.id WHERE s.created < vDateShort;
+ DELETE FROM zoneEvent WHERE `type` = 'day' AND dated < v3Month;
+ DELETE bm
+ FROM buyMark bm
+ JOIN buy b ON b.id = bm.id
+ JOIN entry e ON e.id = b.entryFk
+ JOIN travel t ON t.id = e.travelFk
+ WHERE t.landed <= vDateShort;
+ DELETE FROM stowaway WHERE created < v3Month;
+ DELETE FROM vn.buy WHERE created < vDateShort AND entryFk = 9200;
+ DELETE FROM vn.itemShelvingLog WHERE created < vDateShort;
+ DELETE FROM vn.stockBuyed WHERE creationDate < vDateShort;
+
+
+ -- Equipos duplicados
+ DELETE w.*
+ FROM workerTeam w
+ JOIN (SELECT id, team, workerFk, COUNT(*) - 1 as duplicated
+ FROM workerTeam
+ GROUP BY team,workerFk
+ HAVING duplicated
+ ) d ON d.team = w.team AND d.workerFk = w.workerFk AND d.id != w.id;
+
+ DELETE sc
+ FROM saleComponent sc
+ JOIN sale s ON s.id= sc.saleFk
+ JOIN ticket t ON t.id= s.ticketFk
+ WHERE t.shipped < v18Month;
+
+ DELETE c
+ FROM vn.claim c
+ JOIN vn.claimState cs ON cs.id = c.claimStateFk
+ WHERE cs.description = "Anulado" AND
+ c.created < vDateShort;
+ DELETE
+ FROM vn.expeditionTruck
+ WHERE ETD < v3Month;
+
+ -- borrar travels sin entradas
+ DROP TEMPORARY TABLE IF EXISTS tmp.thermographToDelete;
+ CREATE TEMPORARY TABLE tmp.thermographToDelete
+ SELECT th.id,th.dmsFk
+ FROM vn.travel t
+ LEFT JOIN vn.entry e ON e.travelFk = t.id
+ JOIN vn.travelThermograph th ON th.travelFk = t.id
+ WHERE t.shipped < TIMESTAMPADD(MONTH, -3, CURDATE()) AND e.travelFk IS NULL;
+
+ SELECT dt.id into vTrashId
+ FROM vn.dmsType dt
+ WHERE dt.code = 'trash';
+
+ UPDATE tmp.thermographToDelete th
+ JOIN vn.dms d ON d.id = th.dmsFk
+ SET d.dmsTypeFk = vTrashId;
+
+ DELETE th
+ FROM tmp.thermographToDelete tmp
+ JOIN vn.travelThermograph th ON th.id = tmp.id;
+
+ DELETE t
+ FROM vn.travel t
+ LEFT JOIN vn.entry e ON e.travelFk = t.id
+ WHERE t.shipped < TIMESTAMPADD(MONTH, -3, CURDATE()) AND e.travelFk IS NULL;
+
+ UPDATE dms d
+ JOIN dmsType dt ON dt.id = d.dmsTypeFk
+ SET d.dmsTypeFk = vTrashId
+ WHERE created < TIMESTAMPADD(MONTH, -dt.monthToDelete, CURDATE());
+
+ -- borrar entradas sin compras
+ DROP TEMPORARY TABLE IF EXISTS tmp.entryToDelete;
+ CREATE TEMPORARY TABLE tmp.entryToDelete
+ SELECT e.*
+ FROM vn.entry e
+ LEFT JOIN vn.buy b ON b.entryFk = e.id
+ JOIN vn.entryConfig ec ON e.id != ec.defaultEntry
+ WHERE e.dated < TIMESTAMPADD(MONTH, -3, CURDATE()) AND b.entryFK IS NULL;
+
+ DELETE e
+ FROM vn.entry e
+ JOIN tmp.entryToDelete tmp ON tmp.id = e.id;
+
+ -- borrar de route registros menores a 4 años
+ DROP TEMPORARY TABLE IF EXISTS tmp.routeToDelete;
+ CREATE TEMPORARY TABLE tmp.routeToDelete
+ SELECT *
+ FROM vn.route r
+ WHERE created < TIMESTAMPADD(YEAR,-4,CURDATE());
+
+ UPDATE tmp.routeToDelete tmp
+ JOIN vn.dms d ON d.id = tmp.gestdocFk
+ SET d.dmsTypeFk = vTrashId;
+
+ DELETE r
+ FROM tmp.routeToDelete tmp
+ JOIN vn.route r ON r.id = tmp.id;
+
+ -- borrar registros de dua y awb menores a 2 años
+ DROP TEMPORARY TABLE IF EXISTS tmp.duaToDelete;
+ CREATE TEMPORARY TABLE tmp.duaToDelete
+ SELECT *
+ FROM vn.dua
+ WHERE operated < TIMESTAMPADD(YEAR,-2,CURDATE());
+
+ UPDATE tmp.duaToDelete tm
+ JOIN vn.dms d ON d.id = tm.gestdocFk
+ SET d.dmsTypeFk = vTrashId;
+
+ DELETE d
+ FROM tmp.duaToDelete tmp
+ JOIN vn.dua d ON d.id = tmp.id;
+
+ DELETE FROM vn.awb WHERE created < TIMESTAMPADD(YEAR,-2,CURDATE());
+
+ -- Borra los ficheros gestDoc
+ INSERT INTO vn.printServerQueue(priorityFk, labelReportFk)VALUES(1,11);
+
+ -- Borra los registros de collection y ticketcollection
+ DELETE FROM vn.collection WHERE created < vDateShort;
+
+ DROP TEMPORARY TABLE IF EXISTS tmp.thermographToDelete;
+ DROP TEMPORARY TABLE IF EXISTS tmp.entryToDelete;
+ DROP TEMPORARY TABLE IF EXISTS tmp.duaToDelete;
+
+ DELETE FROM travelLog WHERE creationDate < v3Month;
+
+ CALL shelving_clean;
+
+END$$
+DELIMITER ;
diff --git a/db/changes/10460-mother/04-acl.sql b/db/changes/10460-mother/04-acl.sql
new file mode 100644
index 000000000..c1dc4f6ed
--- /dev/null
+++ b/db/changes/10460-mother/04-acl.sql
@@ -0,0 +1,2 @@
+INSERT INTO `salix`.`ACL` (model,property,accessType,permission,principalType,principalId)
+ VALUES ('Dms','deleteTrashFiles','WRITE','ALLOW','ROLE','employee')
\ No newline at end of file
diff --git a/db/changes/10451-april/00-ClientUnpaid.sql b/db/changes/10461-mother/00-ClientUnpaid.sql
similarity index 87%
rename from db/changes/10451-april/00-ClientUnpaid.sql
rename to db/changes/10461-mother/00-ClientUnpaid.sql
index d84fe494a..16deedace 100644
--- a/db/changes/10451-april/00-ClientUnpaid.sql
+++ b/db/changes/10461-mother/00-ClientUnpaid.sql
@@ -3,8 +3,8 @@ CREATE TABLE `vn`.`clientUnpaid` (
`dated` date NOT NULL,
`amount` double DEFAULT 0,
PRIMARY KEY (`clientFk`),
- CONSTRAINT `clientUnpaid_clientFk` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE
+ CONSTRAINT `clientUnpaid_clientFk` FOREIGN KEY (`clientFk`) REFERENCES `vn`.`client` (`id`) ON UPDATE CASCADE
);
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
- VALUES('ClientUnpaid', '*', '*', 'ALLOW', 'ROLE', 'administrative');
\ No newline at end of file
+ VALUES('ClientUnpaid', '*', '*', 'ALLOW', 'ROLE', 'administrative');
diff --git a/db/changes/10461-mother/00-invoiceOut_queue.sql b/db/changes/10461-mother/00-invoiceOut_queue.sql
new file mode 100644
index 000000000..2b9f45e0f
--- /dev/null
+++ b/db/changes/10461-mother/00-invoiceOut_queue.sql
@@ -0,0 +1,8 @@
+CREATE TABLE `vn`.`invoiceOut_queue` (
+ `invoiceFk` int(10) unsigned not null,
+ `queued` datetime default now() not null,
+ `printed` datetime null,
+ `status` VARCHAR(50) DEFAULT '' NULL,
+ CONSTRAINT `invoiceOut_queue_pk` PRIMARY KEY (`invoiceFk`),
+ CONSTRAINT `invoiceOut_queue_invoiceOut_id_fk` FOREIGN KEY (`invoiceFk`) REFERENCES `vn`.`invoiceOut` (`id`) ON UPDATE CASCADE ON DELETE CASCADE
+) comment 'Queue for PDF invoicing';
diff --git a/db/changes/10470-family/00-accountingType.sql b/db/changes/10470-family/00-accountingType.sql
new file mode 100644
index 000000000..f3c092a34
--- /dev/null
+++ b/db/changes/10470-family/00-accountingType.sql
@@ -0,0 +1,2 @@
+ALTER TABLE `vn`.`accountingType` ADD daysInFuture INT NULL;
+ALTER TABLE `vn`.`accountingType` MODIFY COLUMN daysInFuture int(11) DEFAULT 0 NULL;
\ No newline at end of file
diff --git a/db/changes/10470-family/00-aclItemType.sql b/db/changes/10470-family/00-aclItemType.sql
new file mode 100644
index 000000000..836a69dfd
--- /dev/null
+++ b/db/changes/10470-family/00-aclItemType.sql
@@ -0,0 +1,4 @@
+INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
+ VALUES
+ ('ItemType', '*', 'READ', 'ALLOW', 'ROLE', 'employee'),
+ ('ItemType', '*', 'WRITE', 'ALLOW', 'ROLE', 'buyer');
\ No newline at end of file
diff --git a/db/changes/10470-family/00-aclMdb.sql b/db/changes/10470-family/00-aclMdb.sql
new file mode 100644
index 000000000..c57f60eb3
--- /dev/null
+++ b/db/changes/10470-family/00-aclMdb.sql
@@ -0,0 +1,14 @@
+CREATE TABLE `vn`.`mdbBranch` (
+ `name` VARCHAR(255),
+ PRIMARY KEY(`name`)
+);
+
+CREATE TABLE `vn`.`mdbVersion` (
+ `app` VARCHAR(255) NOT NULL,
+ `branchFk` VARCHAR(255) NOT NULL,
+ `version` INT,
+ CONSTRAINT `mdbVersion_branchFk` FOREIGN KEY (`branchFk`) REFERENCES `vn`.`mdbBranch` (`name`) ON DELETE CASCADE ON UPDATE CASCADE
+);
+
+INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
+ VALUES('MdbVersion', '*', '*', 'ALLOW', 'ROLE', 'developer');
diff --git a/db/changes/10470-family/00-defaultViewConfig.sql b/db/changes/10470-family/00-defaultViewConfig.sql
new file mode 100644
index 000000000..d423599b1
--- /dev/null
+++ b/db/changes/10470-family/00-defaultViewConfig.sql
@@ -0,0 +1,3 @@
+INSERT INTO `salix`.`defaultViewConfig` (tableCode, columns)
+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}');
+
diff --git a/db/changes/10470-family/00-ticket_doRefund.sql b/db/changes/10470-family/00-ticket_doRefund.sql
new file mode 100644
index 000000000..f4ecf29d7
--- /dev/null
+++ b/db/changes/10470-family/00-ticket_doRefund.sql
@@ -0,0 +1,127 @@
+DROP PROCEDURE IF EXISTS `vn`.`ticket_doRefund`;
+
+DELIMITER $$
+$$
+CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_doRefund`(OUT vNewTicket INT)
+BEGIN
+/**
+ * Crea un ticket de abono a partir de tmp.sale y/o tmp.ticketService
+ *
+ * @return vNewTicket
+ */
+ DECLARE vDone BIT DEFAULT 0;
+ DECLARE vClientFk MEDIUMINT;
+ DECLARE vWarehouse TINYINT;
+ DECLARE vCompany MEDIUMINT;
+ DECLARE vAddress MEDIUMINT;
+ DECLARE vRefundAgencyMode INT;
+ DECLARE vItemFk INT;
+ DECLARE vQuantity DECIMAL (10,2);
+ DECLARE vConcept VARCHAR(50);
+ DECLARE vPrice DECIMAL (10,2);
+ DECLARE vDiscount TINYINT;
+ DECLARE vSaleNew INT;
+ DECLARE vSaleMain INT;
+ DECLARE vZoneFk INT;
+ DECLARE vDescription VARCHAR(50);
+ DECLARE vTaxClassFk INT;
+ DECLARE vTicketServiceTypeFk INT;
+ DECLARE vOriginTicket INT;
+
+ DECLARE cSales CURSOR FOR
+ SELECT s.id, s.itemFk, - s.quantity, s.concept, s.price, s.discount
+ FROM tmp.sale s;
+
+ DECLARE cTicketServices CURSOR FOR
+ SELECT ts.description, - ts.quantity, ts.price, ts.taxClassFk, ts.ticketServiceTypeFk
+ FROM tmp.ticketService ts;
+
+ DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
+
+ SELECT sub.ticketFk INTO vOriginTicket
+ FROM (
+ SELECT s.ticketFk
+ FROM tmp.sale s
+ UNION ALL
+ SELECT ts.ticketFk
+ FROM tmp.ticketService ts
+ ) sub
+ LIMIT 1;
+
+ SELECT id INTO vRefundAgencyMode
+ FROM agencyMode WHERE `name` = 'ABONO';
+
+ SELECT clientFk, warehouseFk, companyFk, addressFk
+ INTO vClientFk, vWarehouse, vCompany, vAddress
+ FROM ticket
+ WHERE id = vOriginTicket;
+
+ SELECT id INTO vZoneFk
+ FROM zone WHERE agencyModeFk = vRefundAgencyMode
+ LIMIT 1;
+
+ INSERT INTO vn.ticket (
+ clientFk,
+ shipped,
+ addressFk,
+ agencyModeFk,
+ nickname,
+ warehouseFk,
+ companyFk,
+ landed,
+ zoneFk
+ )
+ SELECT
+ vClientFk,
+ CURDATE(),
+ vAddress,
+ vRefundAgencyMode,
+ a.nickname,
+ vWarehouse,
+ vCompany,
+ CURDATE(),
+ vZoneFk
+ FROM address a
+ WHERE a.id = vAddress;
+
+ SET vNewTicket = LAST_INSERT_ID();
+
+ SET vDone := FALSE;
+ OPEN cSales;
+ FETCH cSales INTO vSaleMain, vItemFk, vQuantity, vConcept, vPrice, vDiscount;
+
+ WHILE NOT vDone DO
+
+ INSERT INTO vn.sale(ticketFk, itemFk, quantity, concept, price, discount)
+ VALUES( vNewTicket, vItemFk, vQuantity, vConcept, vPrice, vDiscount );
+
+ SET vSaleNew = LAST_INSERT_ID();
+
+ INSERT INTO vn.saleComponent(saleFk,componentFk,`value`)
+ SELECT vSaleNew,componentFk,`value`
+ FROM vn.saleComponent
+ WHERE saleFk = vSaleMain;
+
+ FETCH cSales INTO vSaleMain, vItemFk, vQuantity, vConcept, vPrice, vDiscount;
+
+ END WHILE;
+ CLOSE cSales;
+
+ SET vDone := FALSE;
+ OPEN cTicketServices;
+ FETCH cTicketServices INTO vDescription, vQuantity, vPrice, vTaxClassFk, vTicketServiceTypeFk;
+
+ WHILE NOT vDone DO
+
+ INSERT INTO vn.ticketService(description, quantity, price, taxClassFk, ticketFk, ticketServiceTypeFk)
+ VALUES(vDescription, vQuantity, vPrice, vTaxClassFk, vNewTicket, vTicketServiceTypeFk);
+
+ FETCH cTicketServices INTO vDescription, vQuantity, vPrice, vTaxClassFk, vTicketServiceTypeFk;
+
+ END WHILE;
+ CLOSE cTicketServices;
+
+ INSERT INTO vn.ticketRefund(refundTicketFk, originalTicketFk)
+ VALUES(vNewTicket, vOriginTicket);
+END$$
+DELIMITER ;
diff --git a/db/docker.js b/db/docker.js
index ea9fe8ed1..34026f85f 100644
--- a/db/docker.js
+++ b/db/docker.js
@@ -24,7 +24,10 @@ module.exports = class Docker {
let d = new Date();
let pad = v => v < 10 ? '0' + v : v;
let stamp = `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`;
+
+ log('Building container image...');
await this.execP(`docker build --build-arg STAMP=${stamp} -t salix-db ./db`);
+ log('Image built.');
let dockerArgs;
@@ -39,6 +42,7 @@ module.exports = class Docker {
let runChown = process.platform != 'linux';
+ log('Starting container...');
const container = await this.execP(`docker run --env RUN_CHOWN=${runChown} -d ${dockerArgs} salix-db`);
this.id = container.stdout.trim();
@@ -158,6 +162,7 @@ module.exports = class Docker {
return reject(new Error('Docker exited, please see the docker logs for more info'));
let conn = mysql.createConnection(myConf);
+
conn.on('error', () => {});
conn.connect(err => {
conn.destroy();
diff --git a/db/dump/dumpedFixtures.sql b/db/dump/dumpedFixtures.sql
index 9e8bbd0b9..464933607 100644
--- a/db/dump/dumpedFixtures.sql
+++ b/db/dump/dumpedFixtures.sql
@@ -22,9 +22,29 @@ USE `util`;
LOCK TABLES `config` WRITE;
/*!40000 ALTER TABLE `config` DISABLE KEYS */;
-INSERT INTO `config` VALUES (1,'10411',0,'production',NULL);
+INSERT INTO `config` VALUES (1,'10450',0,'production',NULL);
/*!40000 ALTER TABLE `config` ENABLE KEYS */;
UNLOCK TABLES;
+
+--
+-- Dumping data for table `version`
+--
+
+LOCK TABLES `version` WRITE;
+/*!40000 ALTER TABLE `version` DISABLE KEYS */;
+INSERT INTO `version` VALUES ('salix','10230','53f69ae8e526a4a5d827c237a5b076d38507b392','2020-11-09 11:06:43',NULL),('vn-database','10129','7ebb66d5a9e47920e2c5ebfdf373bdf9d1bd6221','2022-05-03 13:46:59','10131');
+/*!40000 ALTER TABLE `version` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Dumping data for table `versionLog`
+--
+
+LOCK TABLES `versionLog` WRITE;
+/*!40000 ALTER TABLE `versionLog` DISABLE KEYS */;
+INSERT INTO `versionLog` VALUES ('vn-database','00001','00-test.sql','juan@10.5.1.3','2022-01-31 10:12:26',NULL,NULL),('vn-database','00003','00-sage.sql','juan@10.5.1.3','2022-01-31 10:12:26',NULL,NULL),('vn-database','10008','00-alterRoleConfig.sql','juan@10.5.1.3','2022-01-31 10:12:26',NULL,NULL),('vn-database','10014','00-rolePrefix.sql','jenkins@10.0.2.68','2022-02-11 00:13:25',NULL,NULL),('vn-database','10017','01-firstScript.sql','jenkins@10.0.2.70','2022-03-09 11:36:54',NULL,NULL),('vn-database','10021','00-bankAccount.sql','jenkins@10.0.2.69','2022-03-16 14:11:22',NULL,NULL),('vn-database','10023','00-firstScript.sql','jenkins@10.0.2.69','2022-03-16 15:05:29',NULL,NULL),('vn-database','10026','00-invoiceInIntrastat.sql','jenkins@10.0.2.69','2022-03-21 15:10:53',NULL,NULL),('vn-database','10027','00-Clientes_cedidos.sql','jenkins@10.0.2.69','2022-03-22 15:58:12',NULL,NULL),('vn-database','10028','00-item_last_buy_.sql','jenkins@10.0.2.69','2022-03-22 15:58:12',NULL,NULL),('vn-database','10029','00-bankToViewAccountingToTable.sql','jenkins@10.0.2.69','2022-03-22 15:58:12',NULL,NULL),('vn-database','10030','00-KkejarNiche.sql','jenkins@10.0.2.69','2022-03-22 15:58:12',NULL,NULL),('vn-database','10036','00-updateBuyConfig.sql','jenkins@10.0.2.69','2022-03-29 12:36:54',NULL,NULL),('vn-database','10037','00-firstScript.sql','jenkins@10.0.2.69','2022-03-28 11:14:26',NULL,NULL),('vn-database','10038','00-printServerQueue.sql','jenkins@10.0.2.69','2022-03-29 08:13:24',NULL,NULL),('vn-database','10048','00-firstScript.sql','jenkins@10.0.2.69','2022-03-30 12:29:06',NULL,NULL),('vn-database','10058','00-vehicleAddFields.sql','jenkins@10.0.2.69','2022-04-06 08:48:34',NULL,NULL),('vn-database','10060','00-firstScript.sql','jenkins@10.0.2.69','2022-04-07 08:50:11',NULL,NULL),('vn-database','10062','00-firstScript.sql','jenkins@10.0.2.69','2022-04-06 10:51:45',NULL,NULL),('vn-database','10064','00-firstScript.sql','jenkins@10.0.2.69','2022-04-06 13:57:11',NULL,NULL),('vn-database','10066','00-firstScript.sql','jenkins@10.0.2.69','2022-04-07 08:50:12',NULL,NULL),('vn-database','10067','00-firstScript.sql','jenkins@10.0.2.69','2022-04-08 10:18:20',NULL,NULL),('vn-database','10071','00-packingSiteLog.sql','jenkins@10.0.2.69','2022-04-08 09:37:30',NULL,NULL),('vn-database','10072','00-firstScript.sql','jenkins@10.0.2.69','2022-04-08 11:01:46',NULL,NULL),('vn-database','10073','00-firstScript.sql','jenkins@10.0.2.69','2022-04-08 13:40:56',NULL,NULL),('vn-database','10074','00-firstScript.sql','jenkins@10.0.2.69','2022-04-10 13:15:05',NULL,NULL),('vn-database','10077','00-firstScript.sql','jenkins@10.0.2.69','2022-04-12 08:07:15',NULL,NULL),('vn-database','10078','00-firstScript.sql','jenkins@10.0.2.69','2022-04-13 07:44:21',NULL,NULL),('vn-database','10079','00-firstScript.sql','jenkins@10.0.2.69','2022-04-12 12:01:37',NULL,NULL),('vn-database','10086','00-firstScript.sql','jenkins@10.0.2.69','2022-04-13 08:58:34',NULL,NULL),('vn-database','10087','00-firstScript.sql','jenkins@10.0.2.69','2022-04-13 09:39:49',NULL,NULL),('vn-database','10088','00-firstScript.sql','jenkins@10.0.2.69','2022-04-13 15:05:12',NULL,NULL),('vn-database','10089','00-firstScript.sql','jenkins@10.0.2.69','2022-04-18 14:12:52',NULL,NULL),('vn-database','10090','00-firstScript.sql','jenkins@10.0.2.69','2022-04-18 14:34:46',NULL,NULL),('vn-database','10092','00-firstScript.sql','jenkins@10.0.2.69','2022-04-19 14:45:46',NULL,NULL),('vn-database','10093','00-autoradioConfig.sql','jenkins@10.0.2.69','2022-05-03 09:16:47',NULL,NULL),('vn-database','10094','00-firstScript.sql','jenkins@10.0.2.69','2022-04-20 10:57:30',NULL,NULL),('vn-database','10099','00-firstScript.sql','jenkins@10.0.2.69','2022-04-20 14:35:27',NULL,NULL),('vn-database','10100','00-firstScript.sql','jenkins@10.0.2.69','2022-04-20 14:35:27',NULL,NULL),('vn-database','10101','00-firstScript.sql','jenkins@10.0.2.69','2022-04-21 14:59:31',NULL,NULL),('vn-database','10107','00-firstScript.sql','jenkins@10.0.2.69','2022-04-23 10:53:53',NULL,NULL),('vn-database','10114','00-updateConfig.sql','jenkins@10.0.2.69','2022-04-27 13:37:25',NULL,NULL),('vn-database','10116','00-firstScript.sql','jenkins@10.0.2.69','2022-04-28 11:10:14',NULL,NULL),('vn-database','10118','00-firstScript.sql','jenkins@10.0.2.69','2022-04-29 08:10:15',NULL,NULL),('vn-database','10127','00-firstScript.sql','jenkins@10.0.2.69','2022-05-02 11:04:46',NULL,NULL),('vn-database','10128','00-firstScript.sql','jenkins@10.0.2.69','2022-05-02 13:04:31',NULL,NULL),('vn-database','10129','00-firstScript.sql','jenkins@10.0.2.69','2022-05-03 08:21:01',NULL,NULL);
+/*!40000 ALTER TABLE `versionLog` ENABLE KEYS */;
+UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
@@ -34,7 +54,7 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
--- Dump completed on 2022-03-28 9:44:13
+-- Dump completed on 2022-05-04 15:58:27
USE `account`;
-- MariaDB dump 10.19 Distrib 10.6.7-MariaDB, for debian-linux-gnu (x86_64)
--
@@ -120,7 +140,7 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
--- Dump completed on 2022-03-28 9:44:14
+-- Dump completed on 2022-05-04 15:58:27
USE `salix`;
-- MariaDB dump 10.19 Distrib 10.6.7-MariaDB, for debian-linux-gnu (x86_64)
--
@@ -144,7 +164,7 @@ USE `salix`;
LOCK TABLES `ACL` WRITE;
/*!40000 ALTER TABLE `ACL` DISABLE KEYS */;
-INSERT INTO `ACL` VALUES (1,'Account','*','*','ALLOW','ROLE','employee'),(3,'Address','*','*','ALLOW','ROLE','employee'),(5,'AgencyService','*','READ','ALLOW','ROLE','employee'),(7,'Client','*','*','ALLOW','ROLE','employee'),(9,'ClientObservation','*','*','ALLOW','ROLE','employee'),(11,'ContactChannel','*','READ','ALLOW','ROLE','trainee'),(13,'Employee','*','READ','ALLOW','ROLE','employee'),(14,'PayMethod','*','READ','ALLOW','ROLE','trainee'),(16,'FakeProduction','*','READ','ALLOW','ROLE','employee'),(17,'Warehouse','* ','READ','ALLOW','ROLE','trainee'),(18,'State','*','READ','ALLOW','ROLE','employee'),(20,'TicketState','*','*','ALLOW','ROLE','employee'),(24,'Delivery','*','READ','ALLOW','ROLE','employee'),(25,'Zone','*','READ','ALLOW','ROLE','employee'),(26,'ClientCredit','*','*','ALLOW','ROLE','employee'),(27,'ClientCreditLimit','*','READ','ALLOW','ROLE','trainee'),(30,'GreugeType','*','READ','ALLOW','ROLE','trainee'),(31,'Mandate','*','READ','ALLOW','ROLE','trainee'),(32,'MandateType','*','READ','ALLOW','ROLE','trainee'),(33,'Company','*','READ','ALLOW','ROLE','trainee'),(34,'Greuge','*','READ','ALLOW','ROLE','trainee'),(35,'AddressObservation','*','*','ALLOW','ROLE','employee'),(36,'ObservationType','*','*','ALLOW','ROLE','employee'),(37,'Greuge','*','WRITE','ALLOW','ROLE','employee'),(38,'AgencyMode','*','READ','ALLOW','ROLE','employee'),(39,'ItemTag','*','WRITE','ALLOW','ROLE','buyer'),(40,'ItemBotanical','*','WRITE','ALLOW','ROLE','buyer'),(41,'ItemBotanical','*','READ','ALLOW','ROLE','employee'),(42,'ItemPlacement','*','WRITE','ALLOW','ROLE','buyer'),(43,'ItemPlacement','*','WRITE','ALLOW','ROLE','replenisher'),(44,'ItemPlacement','*','READ','ALLOW','ROLE','employee'),(45,'ItemBarcode','*','READ','ALLOW','ROLE','employee'),(46,'ItemBarcode','*','WRITE','ALLOW','ROLE','buyer'),(47,'ItemBarcode','*','WRITE','ALLOW','ROLE','replenisher'),(51,'ItemTag','*','READ','ALLOW','ROLE','employee'),(53,'Item','*','READ','ALLOW','ROLE','employee'),(54,'Item','*','WRITE','ALLOW','ROLE','buyer'),(55,'Recovery','*','READ','ALLOW','ROLE','trainee'),(56,'Recovery','*','WRITE','ALLOW','ROLE','administrative'),(58,'CreditClassification','*','*','ALLOW','ROLE','insurance'),(60,'CreditInsurance','*','*','ALLOW','ROLE','insurance'),(61,'InvoiceOut','*','READ','ALLOW','ROLE','employee'),(62,'Ticket','*','*','ALLOW','ROLE','employee'),(63,'TicketObservation','*','*','ALLOW','ROLE','employee'),(64,'Route','*','READ','ALLOW','ROLE','employee'),(65,'Sale','*','READ','ALLOW','ROLE','employee'),(66,'TicketTracking','*','READ','ALLOW','ROLE','employee'),(68,'TicketPackaging','*','*','ALLOW','ROLE','employee'),(69,'Packaging','*','READ','ALLOW','ROLE','employee'),(70,'Packaging','*','WRITE','ALLOW','ROLE','logistic'),(71,'SaleChecked','*','READ','ALLOW','ROLE','employee'),(72,'SaleComponent','*','READ','ALLOW','ROLE','employee'),(73,'Expedition','*','READ','ALLOW','ROLE','employee'),(74,'Expedition','*','WRITE','ALLOW','ROLE','deliveryBoss'),(75,'Expedition','*','WRITE','ALLOW','ROLE','production'),(76,'AnnualAverageInvoiced','*','READ','ALLOW','ROLE','employee'),(77,'WorkerMana','*','READ','ALLOW','ROLE','employee'),(78,'TicketTracking','*','WRITE','ALLOW','ROLE','production'),(79,'TicketTracking','changeState','*','ALLOW','ROLE','employee'),(80,'Sale','deleteSales','*','ALLOW','ROLE','employee'),(81,'Sale','moveToTicket','*','ALLOW','ROLE','employee'),(82,'Sale','updateQuantity','*','ALLOW','ROLE','employee'),(83,'Sale','updatePrice','*','ALLOW','ROLE','employee'),(84,'Sale','updateDiscount','*','ALLOW','ROLE','employee'),(85,'SaleTracking','*','READ','ALLOW','ROLE','employee'),(86,'Order','*','*','ALLOW','ROLE','employee'),(87,'OrderRow','*','*','ALLOW','ROLE','employee'),(88,'ClientContact','*','*','ALLOW','ROLE','employee'),(89,'Sale','moveToNewTicket','*','ALLOW','ROLE','employee'),(90,'Sale','reserve','*','ALLOW','ROLE','employee'),(91,'TicketWeekly','*','READ','ALLOW','ROLE','employee'),(94,'Agency','landsThatDay','*','ALLOW','ROLE','employee'),(96,'ClaimEnd','*','READ','ALLOW','ROLE','employee'),(97,'ClaimEnd','*','WRITE','ALLOW','ROLE','claimManager'),(98,'ClaimBeginning','*','*','ALLOW','ROLE','employee'),(99,'ClaimDevelopment','*','READ','ALLOW','ROLE','employee'),(100,'ClaimDevelopment','*','WRITE','ALLOW','ROLE','claimManager'),(101,'Claim','*','*','ALLOW','ROLE','employee'),(102,'Claim','createFromSales','*','ALLOW','ROLE','employee'),(103,'ClaimEnd','importTicketSales','WRITE','ALLOW','ROLE','claimManager'),(104,'Item','*','WRITE','ALLOW','ROLE','marketingBoss'),(105,'ItemBarcode','*','WRITE','ALLOW','ROLE','marketingBoss'),(106,'ItemBotanical','*','WRITE','ALLOW','ROLE','marketingBoss'),(108,'ItemPlacement','*','WRITE','ALLOW','ROLE','marketingBoss'),(109,'UserConfig','*','*','ALLOW','ROLE','employee'),(110,'Bank','*','READ','ALLOW','ROLE','trainee'),(111,'ClientLog','*','READ','ALLOW','ROLE','trainee'),(112,'Defaulter','*','READ','ALLOW','ROLE','employee'),(113,'ClientRisk','*','READ','ALLOW','ROLE','trainee'),(114,'Receipt','*','READ','ALLOW','ROLE','trainee'),(115,'Receipt','*','WRITE','ALLOW','ROLE','administrative'),(116,'BankEntity','*','*','ALLOW','ROLE','employee'),(117,'ClientSample','*','*','ALLOW','ROLE','employee'),(118,'WorkerTeam','*','*','ALLOW','ROLE','salesPerson'),(119,'Travel','*','READ','ALLOW','ROLE','employee'),(120,'Travel','*','WRITE','ALLOW','ROLE','buyer'),(121,'Item','regularize','*','ALLOW','ROLE','employee'),(122,'TicketRequest','*','*','ALLOW','ROLE','employee'),(123,'Worker','*','*','ALLOW','ROLE','employee'),(124,'Client','confirmTransaction','WRITE','ALLOW','ROLE','administrative'),(125,'Agency','getAgenciesWithWarehouse','*','ALLOW','ROLE','employee'),(126,'Client','activeWorkersWithRole','*','ALLOW','ROLE','employee'),(127,'TicketLog','*','READ','ALLOW','ROLE','employee'),(129,'TicketService','*','*','ALLOW','ROLE','employee'),(130,'Expedition','*','WRITE','ALLOW','ROLE','packager'),(131,'CreditInsurance','*','READ','ALLOW','ROLE','trainee'),(132,'CreditClassification','*','READ','ALLOW','ROLE','trainee'),(133,'ItemTag','*','WRITE','ALLOW','ROLE','marketingBoss'),(135,'ZoneGeo','*','READ','ALLOW','ROLE','employee'),(136,'ZoneCalendar','*','READ','ALLOW','ROLE','employee'),(137,'ZoneIncluded','*','READ','ALLOW','ROLE','employee'),(138,'LabourHoliday','*','READ','ALLOW','ROLE','employee'),(139,'LabourHolidayLegend','*','READ','ALLOW','ROLE','employee'),(140,'LabourHolidayType','*','READ','ALLOW','ROLE','employee'),(141,'Zone','*','*','ALLOW','ROLE','deliveryBoss'),(142,'ZoneCalendar','*','WRITE','ALLOW','ROLE','deliveryBoss'),(143,'ZoneIncluded','*','*','ALLOW','ROLE','deliveryBoss'),(144,'Stowaway','*','*','ALLOW','ROLE','employee'),(145,'Ticket','getPossibleStowaways','READ','ALLOW','ROLE','employee'),(147,'UserConfigView','*','*','ALLOW','ROLE','employee'),(148,'UserConfigView','*','*','ALLOW','ROLE','employee'),(149,'Sip','*','READ','ALLOW','ROLE','employee'),(150,'Sip','*','WRITE','ALLOW','ROLE','hr'),(151,'Department','*','READ','ALLOW','ROLE','employee'),(152,'Department','*','WRITE','ALLOW','ROLE','hr'),(153,'Route','*','READ','ALLOW','ROLE','employee'),(154,'Route','*','WRITE','ALLOW','ROLE','delivery'),(155,'Calendar','*','READ','ALLOW','ROLE','hr'),(156,'WorkerLabour','*','READ','ALLOW','ROLE','hr'),(157,'Calendar','absences','READ','ALLOW','ROLE','employee'),(158,'ItemTag','*','WRITE','ALLOW','ROLE','accessory'),(160,'TicketServiceType','*','READ','ALLOW','ROLE','employee'),(161,'TicketConfig','*','READ','ALLOW','ROLE','employee'),(162,'InvoiceOut','delete','WRITE','ALLOW','ROLE','invoicing'),(163,'InvoiceOut','book','WRITE','ALLOW','ROLE','invoicing'),(165,'TicketDms','*','*','ALLOW','ROLE','employee'),(167,'Worker','isSubordinate','READ','ALLOW','ROLE','employee'),(168,'Worker','mySubordinates','READ','ALLOW','ROLE','employee'),(169,'WorkerTimeControl','filter','READ','ALLOW','ROLE','employee'),(170,'WorkerTimeControl','addTime','WRITE','ALLOW','ROLE','employee'),(171,'TicketServiceType','*','WRITE','ALLOW','ROLE','administrative'),(172,'Sms','*','READ','ALLOW','ROLE','employee'),(173,'Sms','send','WRITE','ALLOW','ROLE','employee'),(174,'Agency','getLanded','READ','ALLOW','ROLE','employee'),(175,'Agency','getShipped','READ','ALLOW','ROLE','employee'),(176,'Device','*','*','ALLOW','ROLE','employee'),(177,'Device','*','*','ALLOW','ROLE','employee'),(178,'WorkerTimeControl','*','*','ALLOW','ROLE','employee'),(179,'ItemLog','*','READ','ALLOW','ROLE','employee'),(180,'RouteLog','*','READ','ALLOW','ROLE','employee'),(181,'Dms','removeFile','WRITE','ALLOW','ROLE','employee'),(182,'Dms','uploadFile','WRITE','ALLOW','ROLE','employee'),(183,'Dms','downloadFile','READ','ALLOW','ROLE','employee'),(184,'Client','uploadFile','WRITE','ALLOW','ROLE','employee'),(185,'ClientDms','removeFile','WRITE','ALLOW','ROLE','employee'),(186,'ClientDms','*','READ','ALLOW','ROLE','trainee'),(187,'Ticket','uploadFile','WRITE','ALLOW','ROLE','employee'),(190,'Route','updateVolume','WRITE','ALLOW','ROLE','deliveryBoss'),(191,'Agency','getLanded','READ','ALLOW','ROLE','employee'),(192,'Agency','getShipped','READ','ALLOW','ROLE','employee'),(194,'Postcode','*','WRITE','ALLOW','ROLE','deliveryBoss'),(195,'Ticket','addSale','WRITE','ALLOW','ROLE','employee'),(196,'Dms','updateFile','WRITE','ALLOW','ROLE','employee'),(197,'Dms','*','READ','ALLOW','ROLE','trainee'),(198,'ClaimDms','removeFile','WRITE','ALLOW','ROLE','employee'),(199,'ClaimDms','*','READ','ALLOW','ROLE','employee'),(200,'Claim','uploadFile','WRITE','ALLOW','ROLE','employee'),(201,'Sale','updateConcept','WRITE','ALLOW','ROLE','employee'),(202,'Claim','updateClaimAction','WRITE','ALLOW','ROLE','claimManager'),(203,'UserPhone','*','*','ALLOW','ROLE','employee'),(204,'WorkerDms','removeFile','WRITE','ALLOW','ROLE','hr'),(205,'WorkerDms','*','READ','ALLOW','ROLE','hr'),(206,'Chat','*','*','ALLOW','ROLE','employee'),(207,'Chat','sendMessage','*','ALLOW','ROLE','employee'),(208,'Sale','recalculatePrice','WRITE','ALLOW','ROLE','employee'),(209,'Ticket','recalculateComponents','WRITE','ALLOW','ROLE','employee'),(211,'TravelLog','*','READ','ALLOW','ROLE','buyer'),(212,'Thermograph','*','*','ALLOW','ROLE','buyer'),(213,'TravelThermograph','*','WRITE','ALLOW','ROLE','buyer'),(214,'Entry','*','*','ALLOW','ROLE','buyer'),(215,'TicketWeekly','*','WRITE','ALLOW','ROLE','buyer'),(216,'TravelThermograph','*','READ','ALLOW','ROLE','employee'),(218,'Intrastat','*','*','ALLOW','ROLE','buyer'),(219,'Account','acl','READ','ALLOW','ROLE','account'),(220,'Account','getCurrentUserData','READ','ALLOW','ROLE','account'),(221,'UserConfig','getUserConfig','READ','ALLOW','ROLE','account'),(222,'Client','*','READ','ALLOW','ROLE','trainee'),(226,'ClientObservation','*','READ','ALLOW','ROLE','trainee'),(227,'Address','*','READ','ALLOW','ROLE','trainee'),(228,'AddressObservation','*','READ','ALLOW','ROLE','trainee'),(230,'ClientCredit','*','READ','ALLOW','ROLE','trainee'),(231,'ClientContact','*','READ','ALLOW','ROLE','trainee'),(232,'ClientSample','*','READ','ALLOW','ROLE','trainee'),(233,'EntryLog','*','READ','ALLOW','ROLE','buyer'),(234,'WorkerLog','*','READ','ALLOW','ROLE','salesAssistant'),(235,'CustomsAgent','*','*','ALLOW','ROLE','employee'),(236,'Buy','*','*','ALLOW','ROLE','buyer'),(237,'WorkerDms','filter','*','ALLOW','ROLE','employee'),(238,'Town','*','WRITE','ALLOW','ROLE','deliveryBoss'),(239,'Province','*','WRITE','ALLOW','ROLE','deliveryBoss'),(240,'supplier','*','WRITE','ALLOW','ROLE','administrative'),(241,'SupplierContact','*','WRITE','ALLOW','ROLE','administrative'),(242,'supplier','*','WRITE','ALLOW','ROLE','administrative'),(244,'supplier','*','WRITE','ALLOW','ROLE','administrative'),(246,'Account','changePassword','*','ALLOW','ROLE','account'),(247,'UserAccount','exists','*','ALLOW','ROLE','account'),(248,'RoleMapping','*','READ','ALLOW','ROLE','account'),(249,'UserPassword','*','READ','ALLOW','ROLE','account'),(250,'Town','*','WRITE','ALLOW','ROLE','deliveryBoss'),(251,'Province','*','WRITE','ALLOW','ROLE','deliveryBoss'),(252,'Supplier','*','READ','ALLOW','ROLE','employee'),(253,'Supplier','*','WRITE','ALLOW','ROLE','administrative'),(254,'SupplierLog','*','READ','ALLOW','ROLE','employee'),(256,'Image','*','WRITE','ALLOW','ROLE','employee'),(257,'FixedPrice','*','*','ALLOW','ROLE','buyer'),(258,'PayDem','*','READ','ALLOW','ROLE','employee'),(259,'Client','createReceipt','*','ALLOW','ROLE','salesAssistant'),(260,'PrintServerQueue','*','WRITE','ALLOW','ROLE','employee'),(261,'SupplierAccount','*','*','ALLOW','ROLE','administrative'),(262,'Entry','*','*','ALLOW','ROLE','administrative'),(263,'InvoiceIn','*','*','ALLOW','ROLE','administrative'),(264,'StarredModule','*','*','ALLOW','ROLE','employee'),(265,'ItemBotanical','*','WRITE','ALLOW','ROLE','logisticBoss'),(266,'ZoneLog','*','READ','ALLOW','ROLE','employee'),(267,'Genus','*','WRITE','ALLOW','ROLE','logisticBoss'),(268,'Specie','*','WRITE','ALLOW','ROLE','logisticBoss'),(269,'InvoiceOut','createPdf','WRITE','ALLOW','ROLE','employee'),(270,'SupplierAddress','*','*','ALLOW','ROLE','employee'),(271,'SalesMonitor','*','*','ALLOW','ROLE','employee'),(272,'InvoiceInLog','*','*','ALLOW','ROLE','employee'),(273,'InvoiceInTax','*','*','ALLOW','ROLE','administrative'),(274,'InvoiceInLog','*','READ','ALLOW','ROLE','administrative'),(275,'InvoiceOut','createManualInvoice','WRITE','ALLOW','ROLE','invoicing'),(276,'InvoiceOut','globalInvoicing','WRITE','ALLOW','ROLE','invoicing'),(277,'Role','*','*','ALLOW','ROLE','it'),(278,'RoleInherit','*','WRITE','ALLOW','ROLE','grant'),(279,'MailAlias','*','*','ALLOW','ROLE','marketing'),(282,'UserAccount','*','WRITE','ALLOW','ROLE','it'),(283,'EntryObservation','*','*','ALLOW','ROLE','buyer'),(284,'LdapConfig','*','*','ALLOW','ROLE','sysadmin'),(285,'SambaConfig','*','*','ALLOW','ROLE','sysadmin'),(286,'ACL','*','*','ALLOW','ROLE','developer'),(287,'AccessToken','*','*','ALLOW','ROLE','developer'),(288,'MailAliasAccount','*','*','ALLOW','ROLE','marketing'),(289,'MailAliasAccount','*','*','ALLOW','ROLE','hr'),(290,'MailAlias','*','*','ALLOW','ROLE','hr'),(291,'MailForward','*','*','ALLOW','ROLE','marketing'),(292,'MailForward','*','*','ALLOW','ROLE','hr'),(293,'RoleInherit','*','*','ALLOW','ROLE','it'),(294,'RoleRole','*','*','ALLOW','ROLE','it'),(295,'AccountConfig','*','*','ALLOW','ROLE','sysadmin'),(296,'Collection','*','READ','ALLOW','ROLE','employee'),(297,'Sale','payBack','WRITE','ALLOW','ROLE','employee'),(298,'InvoiceInDueDay','*','*','ALLOW','ROLE','administrative');
+INSERT INTO `ACL` VALUES (1,'Account','*','*','ALLOW','ROLE','employee'),(3,'Address','*','*','ALLOW','ROLE','employee'),(5,'AgencyService','*','READ','ALLOW','ROLE','employee'),(7,'Client','*','*','ALLOW','ROLE','employee'),(9,'ClientObservation','*','*','ALLOW','ROLE','employee'),(11,'ContactChannel','*','READ','ALLOW','ROLE','trainee'),(13,'Employee','*','READ','ALLOW','ROLE','employee'),(14,'PayMethod','*','READ','ALLOW','ROLE','trainee'),(16,'FakeProduction','*','READ','ALLOW','ROLE','employee'),(17,'Warehouse','* ','READ','ALLOW','ROLE','trainee'),(18,'State','*','READ','ALLOW','ROLE','employee'),(20,'TicketState','*','*','ALLOW','ROLE','employee'),(24,'Delivery','*','READ','ALLOW','ROLE','employee'),(25,'Zone','*','READ','ALLOW','ROLE','employee'),(26,'ClientCredit','*','*','ALLOW','ROLE','employee'),(27,'ClientCreditLimit','*','READ','ALLOW','ROLE','trainee'),(30,'GreugeType','*','READ','ALLOW','ROLE','trainee'),(31,'Mandate','*','READ','ALLOW','ROLE','trainee'),(32,'MandateType','*','READ','ALLOW','ROLE','trainee'),(33,'Company','*','READ','ALLOW','ROLE','trainee'),(34,'Greuge','*','READ','ALLOW','ROLE','trainee'),(35,'AddressObservation','*','*','ALLOW','ROLE','employee'),(36,'ObservationType','*','*','ALLOW','ROLE','employee'),(37,'Greuge','*','WRITE','ALLOW','ROLE','employee'),(38,'AgencyMode','*','READ','ALLOW','ROLE','employee'),(39,'ItemTag','*','WRITE','ALLOW','ROLE','buyer'),(40,'ItemBotanical','*','WRITE','ALLOW','ROLE','buyer'),(41,'ItemBotanical','*','READ','ALLOW','ROLE','employee'),(42,'ItemPlacement','*','WRITE','ALLOW','ROLE','buyer'),(43,'ItemPlacement','*','WRITE','ALLOW','ROLE','replenisher'),(44,'ItemPlacement','*','READ','ALLOW','ROLE','employee'),(45,'ItemBarcode','*','READ','ALLOW','ROLE','employee'),(46,'ItemBarcode','*','WRITE','ALLOW','ROLE','buyer'),(47,'ItemBarcode','*','WRITE','ALLOW','ROLE','replenisher'),(51,'ItemTag','*','READ','ALLOW','ROLE','employee'),(53,'Item','*','READ','ALLOW','ROLE','employee'),(54,'Item','*','WRITE','ALLOW','ROLE','buyer'),(55,'Recovery','*','READ','ALLOW','ROLE','trainee'),(56,'Recovery','*','WRITE','ALLOW','ROLE','administrative'),(58,'CreditClassification','*','*','ALLOW','ROLE','insurance'),(60,'CreditInsurance','*','*','ALLOW','ROLE','insurance'),(61,'InvoiceOut','*','READ','ALLOW','ROLE','employee'),(62,'Ticket','*','*','ALLOW','ROLE','employee'),(63,'TicketObservation','*','*','ALLOW','ROLE','employee'),(64,'Route','*','READ','ALLOW','ROLE','employee'),(65,'Sale','*','READ','ALLOW','ROLE','employee'),(66,'TicketTracking','*','READ','ALLOW','ROLE','employee'),(68,'TicketPackaging','*','*','ALLOW','ROLE','employee'),(69,'Packaging','*','READ','ALLOW','ROLE','employee'),(70,'Packaging','*','WRITE','ALLOW','ROLE','logistic'),(71,'SaleChecked','*','READ','ALLOW','ROLE','employee'),(72,'SaleComponent','*','READ','ALLOW','ROLE','employee'),(73,'Expedition','*','READ','ALLOW','ROLE','employee'),(74,'Expedition','*','WRITE','ALLOW','ROLE','deliveryBoss'),(75,'Expedition','*','WRITE','ALLOW','ROLE','production'),(76,'AnnualAverageInvoiced','*','READ','ALLOW','ROLE','employee'),(77,'WorkerMana','*','READ','ALLOW','ROLE','employee'),(78,'TicketTracking','*','WRITE','ALLOW','ROLE','production'),(79,'TicketTracking','changeState','*','ALLOW','ROLE','employee'),(80,'Sale','deleteSales','*','ALLOW','ROLE','employee'),(81,'Sale','moveToTicket','*','ALLOW','ROLE','employee'),(82,'Sale','updateQuantity','*','ALLOW','ROLE','employee'),(83,'Sale','updatePrice','*','ALLOW','ROLE','employee'),(84,'Sale','updateDiscount','*','ALLOW','ROLE','employee'),(85,'SaleTracking','*','READ','ALLOW','ROLE','employee'),(86,'Order','*','*','ALLOW','ROLE','employee'),(87,'OrderRow','*','*','ALLOW','ROLE','employee'),(88,'ClientContact','*','*','ALLOW','ROLE','employee'),(89,'Sale','moveToNewTicket','*','ALLOW','ROLE','employee'),(90,'Sale','reserve','*','ALLOW','ROLE','employee'),(91,'TicketWeekly','*','READ','ALLOW','ROLE','employee'),(94,'Agency','landsThatDay','*','ALLOW','ROLE','employee'),(96,'ClaimEnd','*','READ','ALLOW','ROLE','employee'),(97,'ClaimEnd','*','WRITE','ALLOW','ROLE','claimManager'),(98,'ClaimBeginning','*','*','ALLOW','ROLE','employee'),(99,'ClaimDevelopment','*','READ','ALLOW','ROLE','employee'),(100,'ClaimDevelopment','*','WRITE','ALLOW','ROLE','claimManager'),(101,'Claim','*','*','ALLOW','ROLE','employee'),(102,'Claim','createFromSales','*','ALLOW','ROLE','employee'),(104,'Item','*','WRITE','ALLOW','ROLE','marketingBoss'),(105,'ItemBarcode','*','WRITE','ALLOW','ROLE','marketingBoss'),(106,'ItemBotanical','*','WRITE','ALLOW','ROLE','marketingBoss'),(108,'ItemPlacement','*','WRITE','ALLOW','ROLE','marketingBoss'),(109,'UserConfig','*','*','ALLOW','ROLE','employee'),(110,'Bank','*','READ','ALLOW','ROLE','trainee'),(111,'ClientLog','*','READ','ALLOW','ROLE','trainee'),(112,'Defaulter','*','READ','ALLOW','ROLE','employee'),(113,'ClientRisk','*','READ','ALLOW','ROLE','trainee'),(114,'Receipt','*','READ','ALLOW','ROLE','trainee'),(115,'Receipt','*','WRITE','ALLOW','ROLE','administrative'),(116,'BankEntity','*','*','ALLOW','ROLE','employee'),(117,'ClientSample','*','*','ALLOW','ROLE','employee'),(118,'WorkerTeam','*','*','ALLOW','ROLE','salesPerson'),(119,'Travel','*','READ','ALLOW','ROLE','employee'),(120,'Travel','*','WRITE','ALLOW','ROLE','buyer'),(121,'Item','regularize','*','ALLOW','ROLE','employee'),(122,'TicketRequest','*','*','ALLOW','ROLE','employee'),(123,'Worker','*','*','ALLOW','ROLE','employee'),(124,'Client','confirmTransaction','WRITE','ALLOW','ROLE','administrative'),(125,'Agency','getAgenciesWithWarehouse','*','ALLOW','ROLE','employee'),(126,'Client','activeWorkersWithRole','*','ALLOW','ROLE','employee'),(127,'TicketLog','*','READ','ALLOW','ROLE','employee'),(129,'TicketService','*','*','ALLOW','ROLE','employee'),(130,'Expedition','*','WRITE','ALLOW','ROLE','packager'),(131,'CreditInsurance','*','READ','ALLOW','ROLE','trainee'),(132,'CreditClassification','*','READ','ALLOW','ROLE','trainee'),(133,'ItemTag','*','WRITE','ALLOW','ROLE','marketingBoss'),(135,'ZoneGeo','*','READ','ALLOW','ROLE','employee'),(136,'ZoneCalendar','*','READ','ALLOW','ROLE','employee'),(137,'ZoneIncluded','*','READ','ALLOW','ROLE','employee'),(138,'LabourHoliday','*','READ','ALLOW','ROLE','employee'),(139,'LabourHolidayLegend','*','READ','ALLOW','ROLE','employee'),(140,'LabourHolidayType','*','READ','ALLOW','ROLE','employee'),(141,'Zone','*','*','ALLOW','ROLE','deliveryBoss'),(142,'ZoneCalendar','*','WRITE','ALLOW','ROLE','deliveryBoss'),(143,'ZoneIncluded','*','*','ALLOW','ROLE','deliveryBoss'),(144,'Stowaway','*','*','ALLOW','ROLE','employee'),(145,'Ticket','getPossibleStowaways','READ','ALLOW','ROLE','employee'),(147,'UserConfigView','*','*','ALLOW','ROLE','employee'),(148,'UserConfigView','*','*','ALLOW','ROLE','employee'),(149,'Sip','*','READ','ALLOW','ROLE','employee'),(150,'Sip','*','WRITE','ALLOW','ROLE','hr'),(151,'Department','*','READ','ALLOW','ROLE','employee'),(152,'Department','*','WRITE','ALLOW','ROLE','hr'),(153,'Route','*','READ','ALLOW','ROLE','employee'),(154,'Route','*','WRITE','ALLOW','ROLE','delivery'),(155,'Calendar','*','READ','ALLOW','ROLE','hr'),(156,'WorkerLabour','*','READ','ALLOW','ROLE','hr'),(157,'Calendar','absences','READ','ALLOW','ROLE','employee'),(158,'ItemTag','*','WRITE','ALLOW','ROLE','accessory'),(160,'TicketServiceType','*','READ','ALLOW','ROLE','employee'),(161,'TicketConfig','*','READ','ALLOW','ROLE','employee'),(162,'InvoiceOut','delete','WRITE','ALLOW','ROLE','invoicing'),(163,'InvoiceOut','book','WRITE','ALLOW','ROLE','invoicing'),(165,'TicketDms','*','*','ALLOW','ROLE','employee'),(167,'Worker','isSubordinate','READ','ALLOW','ROLE','employee'),(168,'Worker','mySubordinates','READ','ALLOW','ROLE','employee'),(169,'WorkerTimeControl','filter','READ','ALLOW','ROLE','employee'),(170,'WorkerTimeControl','addTime','WRITE','ALLOW','ROLE','employee'),(171,'TicketServiceType','*','WRITE','ALLOW','ROLE','administrative'),(172,'Sms','*','READ','ALLOW','ROLE','employee'),(173,'Sms','send','WRITE','ALLOW','ROLE','employee'),(174,'Agency','getLanded','READ','ALLOW','ROLE','employee'),(175,'Agency','getShipped','READ','ALLOW','ROLE','employee'),(176,'Device','*','*','ALLOW','ROLE','employee'),(177,'Device','*','*','ALLOW','ROLE','employee'),(178,'WorkerTimeControl','*','*','ALLOW','ROLE','employee'),(179,'ItemLog','*','READ','ALLOW','ROLE','employee'),(180,'RouteLog','*','READ','ALLOW','ROLE','employee'),(181,'Dms','removeFile','WRITE','ALLOW','ROLE','employee'),(182,'Dms','uploadFile','WRITE','ALLOW','ROLE','employee'),(183,'Dms','downloadFile','READ','ALLOW','ROLE','employee'),(184,'Client','uploadFile','WRITE','ALLOW','ROLE','employee'),(185,'ClientDms','removeFile','WRITE','ALLOW','ROLE','employee'),(186,'ClientDms','*','READ','ALLOW','ROLE','trainee'),(187,'Ticket','uploadFile','WRITE','ALLOW','ROLE','employee'),(190,'Route','updateVolume','WRITE','ALLOW','ROLE','deliveryBoss'),(191,'Agency','getLanded','READ','ALLOW','ROLE','employee'),(192,'Agency','getShipped','READ','ALLOW','ROLE','employee'),(194,'Postcode','*','WRITE','ALLOW','ROLE','deliveryBoss'),(195,'Ticket','addSale','WRITE','ALLOW','ROLE','employee'),(196,'Dms','updateFile','WRITE','ALLOW','ROLE','employee'),(197,'Dms','*','READ','ALLOW','ROLE','trainee'),(198,'ClaimDms','removeFile','WRITE','ALLOW','ROLE','employee'),(199,'ClaimDms','*','READ','ALLOW','ROLE','employee'),(200,'Claim','uploadFile','WRITE','ALLOW','ROLE','employee'),(201,'Sale','updateConcept','WRITE','ALLOW','ROLE','employee'),(202,'Claim','updateClaimAction','WRITE','ALLOW','ROLE','claimManager'),(203,'UserPhone','*','*','ALLOW','ROLE','employee'),(204,'WorkerDms','removeFile','WRITE','ALLOW','ROLE','hr'),(205,'WorkerDms','*','READ','ALLOW','ROLE','hr'),(206,'Chat','*','*','ALLOW','ROLE','employee'),(207,'Chat','sendMessage','*','ALLOW','ROLE','employee'),(208,'Sale','recalculatePrice','WRITE','ALLOW','ROLE','employee'),(209,'Ticket','recalculateComponents','WRITE','ALLOW','ROLE','employee'),(211,'TravelLog','*','READ','ALLOW','ROLE','buyer'),(212,'Thermograph','*','*','ALLOW','ROLE','buyer'),(213,'TravelThermograph','*','WRITE','ALLOW','ROLE','buyer'),(214,'Entry','*','*','ALLOW','ROLE','buyer'),(215,'TicketWeekly','*','WRITE','ALLOW','ROLE','buyer'),(216,'TravelThermograph','*','READ','ALLOW','ROLE','employee'),(218,'Intrastat','*','*','ALLOW','ROLE','buyer'),(219,'Account','acl','READ','ALLOW','ROLE','account'),(220,'Account','getCurrentUserData','READ','ALLOW','ROLE','account'),(221,'UserConfig','getUserConfig','READ','ALLOW','ROLE','account'),(222,'Client','*','READ','ALLOW','ROLE','trainee'),(226,'ClientObservation','*','READ','ALLOW','ROLE','trainee'),(227,'Address','*','READ','ALLOW','ROLE','trainee'),(228,'AddressObservation','*','READ','ALLOW','ROLE','trainee'),(230,'ClientCredit','*','READ','ALLOW','ROLE','trainee'),(231,'ClientContact','*','READ','ALLOW','ROLE','trainee'),(232,'ClientSample','*','READ','ALLOW','ROLE','trainee'),(233,'EntryLog','*','READ','ALLOW','ROLE','buyer'),(234,'WorkerLog','*','READ','ALLOW','ROLE','salesAssistant'),(235,'CustomsAgent','*','*','ALLOW','ROLE','employee'),(236,'Buy','*','*','ALLOW','ROLE','buyer'),(237,'WorkerDms','filter','*','ALLOW','ROLE','employee'),(238,'Town','*','WRITE','ALLOW','ROLE','deliveryBoss'),(239,'Province','*','WRITE','ALLOW','ROLE','deliveryBoss'),(240,'supplier','*','WRITE','ALLOW','ROLE','administrative'),(241,'SupplierContact','*','WRITE','ALLOW','ROLE','administrative'),(242,'supplier','*','WRITE','ALLOW','ROLE','administrative'),(244,'supplier','*','WRITE','ALLOW','ROLE','administrative'),(246,'Account','changePassword','*','ALLOW','ROLE','account'),(247,'UserAccount','exists','*','ALLOW','ROLE','account'),(248,'RoleMapping','*','READ','ALLOW','ROLE','account'),(249,'UserPassword','*','READ','ALLOW','ROLE','account'),(250,'Town','*','WRITE','ALLOW','ROLE','deliveryBoss'),(251,'Province','*','WRITE','ALLOW','ROLE','deliveryBoss'),(252,'Supplier','*','READ','ALLOW','ROLE','employee'),(253,'Supplier','*','WRITE','ALLOW','ROLE','administrative'),(254,'SupplierLog','*','READ','ALLOW','ROLE','employee'),(256,'Image','*','WRITE','ALLOW','ROLE','employee'),(257,'FixedPrice','*','*','ALLOW','ROLE','buyer'),(258,'PayDem','*','READ','ALLOW','ROLE','employee'),(259,'Client','createReceipt','*','ALLOW','ROLE','salesAssistant'),(260,'PrintServerQueue','*','WRITE','ALLOW','ROLE','employee'),(261,'SupplierAccount','*','*','ALLOW','ROLE','administrative'),(262,'Entry','*','*','ALLOW','ROLE','administrative'),(263,'InvoiceIn','*','*','ALLOW','ROLE','administrative'),(264,'StarredModule','*','*','ALLOW','ROLE','employee'),(265,'ItemBotanical','*','WRITE','ALLOW','ROLE','logisticBoss'),(266,'ZoneLog','*','READ','ALLOW','ROLE','employee'),(267,'Genus','*','WRITE','ALLOW','ROLE','logisticBoss'),(268,'Specie','*','WRITE','ALLOW','ROLE','logisticBoss'),(269,'InvoiceOut','createPdf','WRITE','ALLOW','ROLE','employee'),(270,'SupplierAddress','*','*','ALLOW','ROLE','employee'),(271,'SalesMonitor','*','*','ALLOW','ROLE','employee'),(272,'InvoiceInLog','*','*','ALLOW','ROLE','employee'),(273,'InvoiceInTax','*','*','ALLOW','ROLE','administrative'),(274,'InvoiceInLog','*','READ','ALLOW','ROLE','administrative'),(275,'InvoiceOut','createManualInvoice','WRITE','ALLOW','ROLE','invoicing'),(276,'InvoiceOut','globalInvoicing','WRITE','ALLOW','ROLE','invoicing'),(277,'Role','*','*','ALLOW','ROLE','it'),(278,'RoleInherit','*','WRITE','ALLOW','ROLE','grant'),(279,'MailAlias','*','*','ALLOW','ROLE','marketing'),(282,'UserAccount','*','WRITE','ALLOW','ROLE','it'),(283,'EntryObservation','*','*','ALLOW','ROLE','buyer'),(284,'LdapConfig','*','*','ALLOW','ROLE','sysadmin'),(285,'SambaConfig','*','*','ALLOW','ROLE','sysadmin'),(286,'ACL','*','*','ALLOW','ROLE','developer'),(287,'AccessToken','*','*','ALLOW','ROLE','developer'),(288,'MailAliasAccount','*','*','ALLOW','ROLE','marketing'),(289,'MailAliasAccount','*','*','ALLOW','ROLE','hr'),(290,'MailAlias','*','*','ALLOW','ROLE','hr'),(291,'MailForward','*','*','ALLOW','ROLE','marketing'),(292,'MailForward','*','*','ALLOW','ROLE','hr'),(293,'RoleInherit','*','*','ALLOW','ROLE','it'),(294,'RoleRole','*','*','ALLOW','ROLE','it'),(295,'AccountConfig','*','*','ALLOW','ROLE','sysadmin'),(296,'Collection','*','READ','ALLOW','ROLE','employee'),(297,'Sale','payBack','WRITE','ALLOW','ROLE','employee'),(298,'InvoiceInDueDay','*','*','ALLOW','ROLE','administrative'),(299,'Collection','setSaleQuantity','*','ALLOW','ROLE','employee'),(300,'Docuware','*','*','ALLOW','ROLE','employee'),(301,'Agency','*','READ','ALLOW','ROLE','employee'),(302,'AgencyTerm','*','*','ALLOW','ROLE','administrative'),(303,'ClaimLog','*','READ','ALLOW','ROLE','claimManager'),(304,'Edi','updateData','WRITE','ALLOW','ROLE','employee'),(305,'EducationLevel','*','*','ALLOW','ROLE','employee'),(306,'InvoiceInIntrastat','*','*','ALLOW','ROLE','employee'),(307,'SupplierAgencyTerm','*','*','ALLOW','ROLE','administrative'),(308,'InvoiceInIntrastat','*','*','ALLOW','ROLE','employee');
/*!40000 ALTER TABLE `ACL` ENABLE KEYS */;
UNLOCK TABLES;
@@ -174,7 +194,7 @@ UNLOCK TABLES;
LOCK TABLES `defaultViewConfig` WRITE;
/*!40000 ALTER TABLE `defaultViewConfig` DISABLE KEYS */;
-INSERT INTO `defaultViewConfig` VALUES ('itemsIndex','{\"intrastat\":false,\"stemMultiplier\":false,\"landed\":false}'),('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}'),('ticketsMonitor','{\"id\":false}');
+INSERT INTO `defaultViewConfig` VALUES ('itemsIndex','{\"intrastat\":false,\"stemMultiplier\":false,\"landed\":false,\"producer\":false}'),('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}'),('ticketsMonitor','{\"id\":false}');
/*!40000 ALTER TABLE `defaultViewConfig` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
@@ -186,7 +206,7 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
--- Dump completed on 2022-03-28 9:44:14
+-- Dump completed on 2022-05-04 15:58:28
USE `vn`;
-- MariaDB dump 10.19 Distrib 10.6.7-MariaDB, for debian-linux-gnu (x86_64)
--
@@ -340,7 +360,7 @@ UNLOCK TABLES;
LOCK TABLES `component` WRITE;
/*!40000 ALTER TABLE `component` DISABLE KEYS */;
-INSERT INTO `component` VALUES (10,'Precios Especiales',4,NULL,NULL,1,'specialPrices',0),(14,'porte extra por dia semana',6,NULL,NULL,1,'extraCostPerWeekDay',0),(15,'reparto',6,NULL,NULL,1,'delivery',1),(17,'recobro',5,NULL,NULL,1,'debtCollection',0),(21,'ajuste',11,NULL,NULL,1,'adjustment',0),(22,'venta por paquete',9,1,NULL,0,'salePerPackage',0),(23,'venta por caja',9,2,NULL,0,'salePerBox',0),(28,'valor de compra',1,NULL,NULL,1,'purchaseValue',1),(29,'margen',4,NULL,NULL,1,'margin',1),(32,'descuento ultimas unidades',9,3,-0.05,0,'lastUnitsDiscount',0),(33,'venta por caja',9,1,NULL,0,'salePerBox',0),(34,'descuento comprador',4,NULL,NULL,1,'buyerDiscount',0),(35,'cartera comprador',10,NULL,NULL,1,NULL,0),(36,'descuadre',12,NULL,NULL,1,'imbalance',0),(37,'maná',7,4,NULL,0,'mana',0),(38,'embolsado',9,NULL,NULL,1,'bagged',0),(39,'maná auto',7,NULL,NULL,1,'autoMana',0),(40,'cambios Santos 2016',4,NULL,NULL,1,NULL,0),(41,'bonificacion porte',6,NULL,NULL,1,'freightCharge',0),(42,'promocion Francia',4,NULL,NULL,1,'frenchOffer',0),(43,'promocion Floramondo',4,NULL,NULL,1,'floramondoPromo',0),(44,'rappel cadena',2,NULL,NULL,1,'rappel',0);
+INSERT INTO `component` VALUES (10,'Precios Especiales',4,NULL,NULL,1,'specialPrices',0),(14,'porte extra por dia semana',6,NULL,NULL,1,'extraCostPerWeekDay',0),(15,'reparto',6,NULL,NULL,1,'delivery',1),(17,'recobro',5,NULL,NULL,1,'debtCollection',0),(21,'ajuste',11,NULL,NULL,1,'adjustment',0),(22,'venta por paquete',9,1,NULL,0,'salePerPackage',0),(23,'venta por caja',9,2,NULL,0,'salePerBox',0),(28,'valor de compra',1,NULL,NULL,1,'purchaseValue',1),(29,'margen',4,NULL,NULL,1,'margin',1),(32,'descuento ultimas unidades',9,3,-0.05,0,'lastUnitsDiscount',0),(33,'venta por caja',9,1,NULL,0,'salePerBox',0),(34,'descuento comprador',4,NULL,NULL,1,'buyerDiscount',0),(35,'cartera comprador',10,NULL,NULL,1,NULL,0),(36,'descuadre',12,NULL,NULL,1,'imbalance',0),(37,'maná',7,4,NULL,0,'mana',0),(38,'embolsado',9,NULL,NULL,1,'bagged',0),(39,'maná auto',7,NULL,NULL,1,'autoMana',0),(40,'cambios Santos 2016',4,NULL,NULL,1,NULL,0),(41,'bonificacion porte',6,NULL,NULL,1,'freightCharge',0),(42,'promocion Francia',4,NULL,NULL,1,'frenchOffer',0),(43,'promocion Floramondo',4,NULL,NULL,1,'floramondoPromo',0),(44,'rappel cadena',2,NULL,NULL,1,'rappel',0),(45,'maná reclamacion',7,4,NULL,0,'manaClaim',0);
/*!40000 ALTER TABLE `component` ENABLE KEYS */;
UNLOCK TABLES;
@@ -370,7 +390,7 @@ UNLOCK TABLES;
LOCK TABLES `department` WRITE;
/*!40000 ALTER TABLE `department` DISABLE KEYS */;
-INSERT INTO `department` VALUES (1,NULL,'VERDNATURA',1,94,763,0,NULL,NULL,NULL,0,0,0,30,NULL,'/',NULL,0,NULL,0,0,0,0),(22,NULL,'COMPRAS',2,3,NULL,72,596,2,5,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0),(23,NULL,'CAMARA',13,14,NULL,72,3758,2,6,1,1,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,1),(31,'IT','INFORMATICA',4,5,NULL,72,127,3,9,0,0,1,0,1,'/1/','informatica-cau',1,NULL,1,0,0,0),(34,NULL,'CONTABILIDAD',6,7,NULL,0,NULL,NULL,NULL,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0),(35,NULL,'FINANZAS',8,9,NULL,0,NULL,NULL,NULL,0,0,1,0,1,'/1/',NULL,1,'finanzas@verdnatura.es',1,0,0,0),(36,NULL,'LABORAL',10,11,NULL,0,NULL,NULL,NULL,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0),(37,NULL,'PRODUCCION',12,27,NULL,72,3758,3,11,1,1,1,7,1,'/1/',NULL,0,NULL,0,1,1,1),(38,NULL,'SACADO',15,16,NULL,72,230,4,14,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0),(39,NULL,'ENCAJADO',17,18,NULL,72,3758,4,12,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0),(41,NULL,'ADMINISTRACION',28,29,NULL,72,599,3,8,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0),(43,NULL,'VENTAS',30,49,NULL,0,NULL,NULL,NULL,0,0,1,9,1,'/1/',NULL,1,'',1,0,0,0),(44,NULL,'GERENCIA',50,51,NULL,72,300,2,7,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0),(45,NULL,'LOGISTICA',52,53,NULL,72,596,3,19,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0),(46,NULL,'REPARTO',54,55,NULL,72,659,3,10,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,0,0),(48,NULL,'ALMACENAJE',56,57,NULL,0,3758,NULL,NULL,1,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0),(49,NULL,'PROPIEDAD',58,59,NULL,72,1008,1,1,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0),(52,NULL,'CARGA AEREA',60,61,NULL,72,163,4,28,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0),(53,NULL,'MARKETING Y COMUNICACIÓN',62,63,NULL,72,1238,0,0,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0),(54,NULL,'ORNAMENTALES',64,65,NULL,72,433,3,21,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0),(55,NULL,'TALLER NATURAL',66,67,NULL,72,3758,2,23,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,1,0),(56,NULL,'TALLER ARTIFICIAL',68,69,NULL,72,1780,2,24,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,1,0),(58,NULL,'CAMPOS',70,71,NULL,72,3758,2,2,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0),(59,NULL,'MANTENIMIENTO',72,73,NULL,72,1907,4,16,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0),(60,NULL,'RECLAMACIONES',74,75,NULL,72,563,3,20,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0),(61,NULL,'VNH',76,77,NULL,73,1297,3,17,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0),(63,NULL,'VENTAS FRANCIA',31,32,NULL,72,277,2,27,0,0,2,0,43,'/1/43/',NULL,0,NULL,0,0,0,0),(66,NULL,'VERDNAMADRID',78,79,NULL,72,163,3,18,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0),(68,NULL,'COMPLEMENTOS',19,20,NULL,72,617,3,26,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0),(69,NULL,'VERDNABARNA',80,81,NULL,74,432,3,22,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0),(80,NULL,'EQUIPO J VALLES',33,34,NULL,72,693,3,4,0,0,2,0,43,'/1/43/','jvp_equipo',1,'direccioncomercial@verdnatura.es',1,0,0,0),(86,NULL,'LIMPIEZA',82,83,NULL,72,599,0,0,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0),(89,NULL,'COORDINACION',84,85,NULL,0,3758,NULL,NULL,1,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0),(90,NULL,'TRAILER',86,87,NULL,0,NULL,NULL,NULL,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0),(91,NULL,'ARTIFICIAL',21,22,NULL,0,3758,NULL,NULL,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0),(92,NULL,'EQUIPO SILVERIO',35,36,NULL,0,NULL,NULL,NULL,0,0,2,0,43,'/1/43/','sdc_equipo',1,'direccioncomercial@verdnatura.es',1,0,0,0),(93,NULL,'CONFECCION',88,89,NULL,0,3758,NULL,NULL,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,1,0),(94,NULL,'EQUIPO J BROCAL',37,38,NULL,0,NULL,NULL,NULL,0,0,2,0,43,'/1/43/','jes_equipo',1,'direccioncomercial@verdnatura.es',1,0,0,0),(95,NULL,'EQUIPO C ZAMBRANO',39,40,NULL,0,NULL,NULL,NULL,0,0,2,0,43,'/1/43/','czg_equipo',1,'direccioncomercial@verdnatura.es',1,0,0,0),(96,NULL,'EQUIPO C LOPEZ',41,42,NULL,0,NULL,NULL,NULL,0,0,2,0,43,'/1/43/','cla_equipo',1,'direccioncomercial@verdnatura.es',1,0,0,0),(115,NULL,'EQUIPO CLAUDI',43,44,NULL,0,NULL,NULL,NULL,0,0,2,0,43,'/1/43/','csr_equipo',1,'direccioncomercial@verdnatura.es',1,0,0,0),(123,NULL,'EQUIPO ELENA BASCUÑANA',45,46,NULL,0,NULL,NULL,NULL,0,0,2,0,43,'/1/43/','ebt_equipo',1,'direccioncomercial@verdnatura.es',1,0,0,0),(124,NULL,'CONTROL INTERNO',90,91,NULL,72,NULL,NULL,NULL,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0),(125,NULL,'EQUIPO MIRIAM MAR',47,48,NULL,0,NULL,NULL,NULL,0,0,2,0,43,'/1/43/','mir_equipo',1,'direccioncomercial@verdnatura.es',1,0,0,0),(126,NULL,'PRESERVADO',92,93,NULL,0,NULL,NULL,NULL,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,1,0),(128,NULL,'PALETIZADO',23,24,NULL,0,NULL,NULL,NULL,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0),(130,NULL,'REVISION',25,26,NULL,0,NULL,NULL,NULL,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0);
+INSERT INTO `department` VALUES (1,NULL,'VERDNATURA',1,94,763,0,NULL,NULL,NULL,0,0,0,30,NULL,'/',NULL,0,NULL,0,0,0,0,NULL),(22,NULL,'COMPRAS',2,3,NULL,72,596,2,5,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL),(23,NULL,'CAMARA',13,14,NULL,72,3758,2,6,1,1,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,1,NULL),(31,'IT','INFORMATICA',4,5,NULL,72,127,3,9,0,0,1,0,1,'/1/','informatica-cau',1,NULL,1,0,0,0,NULL),(34,NULL,'CONTABILIDAD',6,7,NULL,0,NULL,NULL,NULL,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL),(35,NULL,'FINANZAS',8,9,NULL,0,NULL,NULL,NULL,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL),(36,NULL,'LABORAL',10,11,NULL,0,NULL,NULL,NULL,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL),(37,NULL,'PRODUCCION',12,27,NULL,72,3758,3,11,1,1,1,7,1,'/1/',NULL,0,NULL,0,1,1,1,NULL),(38,NULL,'SACADO',15,16,NULL,72,230,4,14,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL),(39,NULL,'ENCAJADO',17,18,NULL,72,3758,4,12,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL),(41,NULL,'ADMINISTRACION',28,29,NULL,72,599,3,8,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL),(43,'VT','VENTAS',30,49,NULL,0,NULL,NULL,NULL,0,0,1,9,1,'/1/',NULL,1,'',1,0,0,0,NULL),(44,NULL,'GERENCIA',50,51,NULL,72,300,2,7,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(45,NULL,'LOGISTICA',52,53,NULL,72,596,3,19,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL),(46,NULL,'REPARTO',54,55,NULL,72,659,3,10,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,0,0,NULL),(48,NULL,'ALMACENAJE',56,57,NULL,0,3758,NULL,NULL,1,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(49,NULL,'PROPIEDAD',58,59,NULL,72,1008,1,1,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(52,NULL,'CARGA AEREA',60,61,NULL,72,163,4,28,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(53,NULL,'MARKETING Y COMUNICACIÓN',62,63,NULL,72,1238,0,0,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL),(54,NULL,'ORNAMENTALES',64,65,NULL,72,433,3,21,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(55,NULL,'TALLER NATURAL',66,67,3366,72,3758,2,23,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,1,0,1118),(56,NULL,'TALLER ARTIFICIAL',68,69,8470,72,1780,2,24,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,1,0,1927),(58,NULL,'CAMPOS',70,71,NULL,72,3758,2,2,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(59,NULL,'MANTENIMIENTO',72,73,NULL,72,1907,4,16,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(60,NULL,'RECLAMACIONES',74,75,NULL,72,563,3,20,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL),(61,NULL,'VNH',76,77,NULL,73,1297,3,17,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(63,NULL,'VENTAS FRANCIA',31,32,NULL,72,277,2,27,0,0,2,0,43,'/1/43/',NULL,0,NULL,0,0,0,0,NULL),(66,NULL,'VERDNAMADRID',78,79,NULL,72,163,3,18,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(68,NULL,'COMPLEMENTOS',19,20,NULL,72,617,3,26,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL),(69,NULL,'VERDNABARNA',80,81,NULL,74,432,3,22,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(80,NULL,'EQUIPO J VALLES',33,34,NULL,72,693,3,4,0,0,2,0,43,'/1/43/','jvp_equipo',1,'direccioncomercial@verdnatura.es',1,0,0,0,NULL),(86,NULL,'LIMPIEZA',82,83,NULL,72,599,0,0,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(89,NULL,'COORDINACION',84,85,NULL,0,3758,NULL,NULL,1,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(90,NULL,'TRAILER',86,87,NULL,0,NULL,NULL,NULL,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(91,NULL,'ARTIFICIAL',21,22,NULL,0,3758,NULL,NULL,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL),(92,NULL,'EQUIPO SILVERIO',35,36,NULL,0,NULL,NULL,NULL,0,0,2,0,43,'/1/43/','sdc_equipo',1,'direccioncomercial@verdnatura.es',1,0,0,0,NULL),(93,NULL,'CONFECCION',88,89,NULL,0,3758,NULL,NULL,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,1,0,NULL),(94,NULL,'EQUIPO J BROCAL',37,38,NULL,0,NULL,NULL,NULL,0,0,2,0,43,'/1/43/','jes_equipo',1,'direccioncomercial@verdnatura.es',1,0,0,0,NULL),(95,NULL,'EQUIPO C ZAMBRANO',39,40,NULL,0,NULL,NULL,NULL,0,0,2,0,43,'/1/43/','czg_equipo',1,'direccioncomercial@verdnatura.es',1,0,0,0,NULL),(96,NULL,'EQUIPO C LOPEZ',41,42,NULL,0,NULL,NULL,NULL,0,0,2,0,43,'/1/43/','cla_equipo',1,'direccioncomercial@verdnatura.es',1,0,0,0,NULL),(115,NULL,'EQUIPO CLAUDI',43,44,NULL,0,NULL,NULL,NULL,0,0,2,0,43,'/1/43/','csr_equipo',1,'direccioncomercial@verdnatura.es',1,0,0,0,NULL),(123,NULL,'EQUIPO ELENA BASCUÑANA',45,46,NULL,0,NULL,NULL,NULL,0,0,2,0,43,'/1/43/','ebt_equipo',1,'direccioncomercial@verdnatura.es',1,0,0,0,NULL),(124,NULL,'CONTROL INTERNO',90,91,NULL,72,NULL,NULL,NULL,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL),(125,NULL,'EQUIPO MIRIAM MAR',47,48,NULL,0,NULL,NULL,NULL,0,0,2,0,43,'/1/43/','mir_equipo',1,'direccioncomercial@verdnatura.es',1,0,0,0,NULL),(126,NULL,'PRESERVADO',92,93,NULL,0,NULL,NULL,NULL,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,1,0,NULL),(128,NULL,'PALETIZADO',23,24,NULL,0,NULL,NULL,NULL,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL),(130,NULL,'REVISION',25,26,NULL,0,NULL,NULL,NULL,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL);
/*!40000 ALTER TABLE `department` ENABLE KEYS */;
UNLOCK TABLES;
@@ -410,105 +430,7 @@ UNLOCK TABLES;
LOCK TABLES `state` WRITE;
/*!40000 ALTER TABLE `state` DISABLE KEYS */;
-INSERT INTO vn.state
-(id, name, `order`, alertLevel, code, sectorProdPriority, nextStateFk, isPreviousPreparable, isPicked, isPreparable, semaphore, isPrintable, isOK, graphCategory, isNotValidated, classColor)
-VALUES(1, 'Arreglar', 2, 0, 'FIXING', NULL, 1, 0, 0, 0, 0, 0, 0, 4, 1, 'alert');
-INSERT INTO vn.state
-(id, name, `order`, alertLevel, code, sectorProdPriority, nextStateFk, isPreviousPreparable, isPicked, isPreparable, semaphore, isPrintable, isOK, graphCategory, isNotValidated, classColor)
-VALUES(2, 'Libre', 2, 0, 'FREE', NULL, 2, 1, 0, 0, 0, 1, 0, 4, 1, 'notice');
-INSERT INTO vn.state
-(id, name, `order`, alertLevel, code, sectorProdPriority, nextStateFk, isPreviousPreparable, isPicked, isPreparable, semaphore, isPrintable, isOK, graphCategory, isNotValidated, classColor)
-VALUES(3, 'OK', 3, 0, 'OK', 3, 28, 1, 0, 0, 0, 1, 1, 3, 0, 'success');
-INSERT INTO vn.state
-(id, name, `order`, alertLevel, code, sectorProdPriority, nextStateFk, isPreviousPreparable, isPicked, isPreparable, semaphore, isPrintable, isOK, graphCategory, isNotValidated, classColor)
-VALUES(4, 'Impreso', 4, 0, 'PRINTED', 2, 29, 1, 0, 1, 0, 0, 1, 2, 0, 'success');
-INSERT INTO vn.state
-(id, name, `order`, alertLevel, code, sectorProdPriority, nextStateFk, isPreviousPreparable, isPicked, isPreparable, semaphore, isPrintable, isOK, graphCategory, isNotValidated, classColor)
-VALUES(5, 'Preparación', 6, 1, 'ON_PREPARATION', 7, 5, 0, 0, 0, 2, 0, 0, 2, 0, 'warning');
-INSERT INTO vn.state
-(id, name, `order`, alertLevel, code, sectorProdPriority, nextStateFk, isPreviousPreparable, isPicked, isPreparable, semaphore, isPrintable, isOK, graphCategory, isNotValidated, classColor)
-VALUES(6, 'En Revisión', 7, 1, 'ON_CHECKING', NULL, 6, 0, 1, 0, 3, 0, 0, 1, 0, 'warning');
-INSERT INTO vn.state
-(id, name, `order`, alertLevel, code, sectorProdPriority, nextStateFk, isPreviousPreparable, isPicked, isPreparable, semaphore, isPrintable, isOK, graphCategory, isNotValidated, classColor)
-VALUES(7, 'Sin Acabar', 1, 0, 'NOT_READY', NULL, 7, 0, 0, 0, 0, 0, 0, 4, 1, 'alert');
-INSERT INTO vn.state
-(id, name, `order`, alertLevel, code, sectorProdPriority, nextStateFk, isPreviousPreparable, isPicked, isPreparable, semaphore, isPrintable, isOK, graphCategory, isNotValidated, classColor)
-VALUES(8, 'Revisado', 8, 1, 'CHECKED', NULL, 8, 0, 1, 0, 3, 0, 0, 1, 0, 'warning');
-INSERT INTO vn.state
-(id, name, `order`, alertLevel, code, sectorProdPriority, nextStateFk, isPreviousPreparable, isPicked, isPreparable, semaphore, isPrintable, isOK, graphCategory, isNotValidated, classColor)
-VALUES(9, 'Encajando', 9, 2, 'PACKING', NULL, 9, 0, 1, 0, 0, 0, 0, 1, 0, NULL);
-INSERT INTO vn.state
-(id, name, `order`, alertLevel, code, sectorProdPriority, nextStateFk, isPreviousPreparable, isPicked, isPreparable, semaphore, isPrintable, isOK, graphCategory, isNotValidated, classColor)
-VALUES(10, 'Encajado', 10, 2, 'PACKED', NULL, 10, 0, 1, 0, 0, 0, 0, 0, 0, NULL);
-INSERT INTO vn.state
-(id, name, `order`, alertLevel, code, sectorProdPriority, nextStateFk, isPreviousPreparable, isPicked, isPreparable, semaphore, isPrintable, isOK, graphCategory, isNotValidated, classColor)
-VALUES(11, 'Facturado', 0, 3, 'INVOICED', NULL, 11, 0, 1, 0, 0, 0, 0, 0, 0, NULL);
-INSERT INTO vn.state
-(id, name, `order`, alertLevel, code, sectorProdPriority, nextStateFk, isPreviousPreparable, isPicked, isPreparable, semaphore, isPrintable, isOK, graphCategory, isNotValidated, classColor)
-VALUES(12, 'Bloqueado', 0, 0, 'BLOCKED', NULL, 12, 0, 0, 0, 0, 0, 0, 4, 1, 'alert');
-INSERT INTO vn.state
-(id, name, `order`, alertLevel, code, sectorProdPriority, nextStateFk, isPreviousPreparable, isPicked, isPreparable, semaphore, isPrintable, isOK, graphCategory, isNotValidated, classColor)
-VALUES(13, 'En Reparto', 11, 3, 'ON_DELIVERY', NULL, 13, 0, 1, 0, 0, 0, 0, 0, 0, NULL);
-INSERT INTO vn.state
-(id, name, `order`, alertLevel, code, sectorProdPriority, nextStateFk, isPreviousPreparable, isPicked, isPreparable, semaphore, isPrintable, isOK, graphCategory, isNotValidated, classColor)
-VALUES(14, 'Preparado', 6, 1, 'PREPARED', NULL, 14, 0, 1, 0, 2, 0, 0, 1, 0, 'warning');
-INSERT INTO vn.state
-(id, name, `order`, alertLevel, code, sectorProdPriority, nextStateFk, isPreviousPreparable, isPicked, isPreparable, semaphore, isPrintable, isOK, graphCategory, isNotValidated, classColor)
-VALUES(15, 'Pte Recogida', 12, 3, 'WAITING_FOR_PICKUP', NULL, 15, 0, 1, 0, 0, 0, 0, 0, 0, NULL);
-INSERT INTO vn.state
-(id, name, `order`, alertLevel, code, sectorProdPriority, nextStateFk, isPreviousPreparable, isPicked, isPreparable, semaphore, isPrintable, isOK, graphCategory, isNotValidated, classColor)
-VALUES(16, 'Entregado', 13, 3, 'DELIVERED', NULL, 16, 0, 1, 0, 0, 0, 0, 0, 0, NULL);
-INSERT INTO vn.state
-(id, name, `order`, alertLevel, code, sectorProdPriority, nextStateFk, isPreviousPreparable, isPicked, isPreparable, semaphore, isPrintable, isOK, graphCategory, isNotValidated, classColor)
-VALUES(20, 'Asignado', 4, 0, 'PICKER_DESIGNED', NULL, 20, 1, 0, 0, 0, 0, 0, 2, 0, 'success');
-INSERT INTO vn.state
-(id, name, `order`, alertLevel, code, sectorProdPriority, nextStateFk, isPreviousPreparable, isPicked, isPreparable, semaphore, isPrintable, isOK, graphCategory, isNotValidated, classColor)
-VALUES(21, 'Retornado', 4, 1, 'PRINTED_BACK', 6, 21, 0, 0, 0, 0, 0, 0, 2, 0, 'success');
-INSERT INTO vn.state
-(id, name, `order`, alertLevel, code, sectorProdPriority, nextStateFk, isPreviousPreparable, isPicked, isPreparable, semaphore, isPrintable, isOK, graphCategory, isNotValidated, classColor)
-VALUES(22, 'Pte. Ampliar', 2, 0, 'EXPANDABLE', NULL, 22, 0, 0, 0, 0, 0, 0, 4, 1, 'alert');
-INSERT INTO vn.state
-(id, name, `order`, alertLevel, code, sectorProdPriority, nextStateFk, isPreviousPreparable, isPicked, isPreparable, semaphore, isPrintable, isOK, graphCategory, isNotValidated, classColor)
-VALUES(23, 'URGENTE', 5, 1, 'LAST_CALL', NULL, 23, 1, 0, 1, 0, 0, 0, 4, 1, 'success');
-INSERT INTO vn.state
-(id, name, `order`, alertLevel, code, sectorProdPriority, nextStateFk, isPreviousPreparable, isPicked, isPreparable, semaphore, isPrintable, isOK, graphCategory, isNotValidated, classColor)
-VALUES(24, 'Encadenado', 4, 0, 'CHAINED', 4, 24, 0, 0, 0, 0, 0, 0, 3, 1, 'success');
-INSERT INTO vn.state
-(id, name, `order`, alertLevel, code, sectorProdPriority, nextStateFk, isPreviousPreparable, isPicked, isPreparable, semaphore, isPrintable, isOK, graphCategory, isNotValidated, classColor)
-VALUES(25, 'Embarcando', 3, 0, 'BOARDING', 5, 25, 1, 0, 0, 0, 0, 0, 3, 0, 'alert');
-INSERT INTO vn.state
-(id, name, `order`, alertLevel, code, sectorProdPriority, nextStateFk, isPreviousPreparable, isPicked, isPreparable, semaphore, isPrintable, isOK, graphCategory, isNotValidated, classColor)
-VALUES(26, 'Prep Previa', 5, 1, 'PREVIOUS_PREPARATION', 1, 28, 0, 0, 0, 1, 0, 0, 2, 0, 'warning');
-INSERT INTO vn.state
-(id, name, `order`, alertLevel, code, sectorProdPriority, nextStateFk, isPreviousPreparable, isPicked, isPreparable, semaphore, isPrintable, isOK, graphCategory, isNotValidated, classColor)
-VALUES(27, 'Prep Asistida', 5, 1, 'ASSISTED_PREPARATION', 7, 27, 0, 0, 0, 0, 0, 0, 2, 0, 'success');
-INSERT INTO vn.state
-(id, name, `order`, alertLevel, code, sectorProdPriority, nextStateFk, isPreviousPreparable, isPicked, isPreparable, semaphore, isPrintable, isOK, graphCategory, isNotValidated, classColor)
-VALUES(28, 'Previa OK', 3, 1, 'OK PREVIOUS', 3, 28, 0, 0, 0, 1, 1, 1, 3, 0, 'warning');
-INSERT INTO vn.state
-(id, name, `order`, alertLevel, code, sectorProdPriority, nextStateFk, isPreviousPreparable, isPicked, isPreparable, semaphore, isPrintable, isOK, graphCategory, isNotValidated, classColor)
-VALUES(29, 'Previa Impreso', 4, 1, 'PRINTED PREVIOUS', 2, 29, 0, 0, 1, 1, 0, 1, 3, 0, 'success');
-INSERT INTO vn.state
-(id, name, `order`, alertLevel, code, sectorProdPriority, nextStateFk, isPreviousPreparable, isPicked, isPreparable, semaphore, isPrintable, isOK, graphCategory, isNotValidated, classColor)
-VALUES(30, 'Embarcado', 4, 1, 'BOARD', 5, 30, 0, 0, 0, 2, 0, 0, 3, 0, 'success');
-INSERT INTO vn.state
-(id, name, `order`, alertLevel, code, sectorProdPriority, nextStateFk, isPreviousPreparable, isPicked, isPreparable, semaphore, isPrintable, isOK, graphCategory, isNotValidated, classColor)
-VALUES(31, 'Polizon Impreso', 4, 1, 'PRINTED STOWAWAY', 2, 29, 1, 0, 1, 0, 0, 1, 3, 0, 'success');
-INSERT INTO vn.state
-(id, name, `order`, alertLevel, code, sectorProdPriority, nextStateFk, isPreviousPreparable, isPicked, isPreparable, semaphore, isPrintable, isOK, graphCategory, isNotValidated, classColor)
-VALUES(32, 'Polizon OK', 3, 1, 'OK STOWAWAY', 3, 31, 1, 0, 0, 1, 1, 1, 3, 0, 'warning');
-INSERT INTO vn.state
-(id, name, `order`, alertLevel, code, sectorProdPriority, nextStateFk, isPreviousPreparable, isPicked, isPreparable, semaphore, isPrintable, isOK, graphCategory, isNotValidated, classColor)
-VALUES(33, 'Auto_Impreso', 4, 0, 'PRINTED_AUTO', 2, 29, 1, 0, 1, 0, 0, 1, 2, 0, 'success');
-INSERT INTO vn.state
-(id, name, `order`, alertLevel, code, sectorProdPriority, nextStateFk, isPreviousPreparable, isPicked, isPreparable, semaphore, isPrintable, isOK, graphCategory, isNotValidated, classColor)
-VALUES(34, 'Pte Pago', 3, 0, 'WAITING_FOR_PAYMENT', NULL, 34, 0, 0, 0, 0, 0, 0, 4, 1, 'alert');
-INSERT INTO vn.state
-(id, name, `order`, alertLevel, code, sectorProdPriority, nextStateFk, isPreviousPreparable, isPicked, isPreparable, semaphore, isPrintable, isOK, graphCategory, isNotValidated, classColor)
-VALUES(35, 'Semi-Encajado', 9, 2, 'HALF_PACKED', NULL, 10, 0, 1, 0, 0, 0, 0, 1, 0, NULL);
-INSERT INTO vn.state
-(id, name, `order`, alertLevel, code, sectorProdPriority, nextStateFk, isPreviousPreparable, isPicked, isPreparable, semaphore, isPrintable, isOK, graphCategory, isNotValidated, classColor)
-VALUES(36, 'Control Previa', 3, 1, 'PREVIOUS_CONTROL', 1, 36, 0, 1, 0, 4, 0, 1, 3, 0, 'warning');
+INSERT INTO `state` VALUES (1,'Arreglar',2,0,'FIXING',NULL,1,0,0,0,0,0,0,4,1,'alert'),(2,'Libre',2,0,'FREE',NULL,2,1,0,0,0,1,0,4,1,'notice'),(3,'OK',3,0,'OK',3,28,1,0,0,0,1,1,3,0,'success'),(4,'Impreso',4,0,'PRINTED',2,29,1,0,1,0,0,1,2,0,'success'),(5,'Preparación',6,1,'ON_PREPARATION',7,5,0,0,0,2,0,0,2,0,'warning'),(6,'En Revisión',7,1,'ON_CHECKING',NULL,6,0,1,0,3,0,0,1,0,'warning'),(7,'Sin Acabar',1,0,'NOT_READY',NULL,7,0,0,0,0,0,0,4,1,'alert'),(8,'Revisado',8,1,'CHECKED',NULL,8,0,1,0,3,0,0,1,0,'warning'),(9,'Encajando',9,2,'PACKING',NULL,9,0,1,0,0,0,0,1,0,NULL),(10,'Encajado',10,2,'PACKED',NULL,10,0,1,0,0,0,0,0,0,NULL),(11,'Facturado',0,3,'INVOICED',NULL,11,0,1,0,0,0,0,0,0,NULL),(12,'Bloqueado',0,0,'BLOCKED',NULL,12,0,0,0,0,0,0,4,1,'alert'),(13,'En Reparto',11,3,'ON_DELIVERY',NULL,13,0,1,0,0,0,0,0,0,NULL),(14,'Preparado',6,1,'PREPARED',NULL,14,0,1,0,2,0,0,1,0,'warning'),(15,'Pte Recogida',12,3,'WAITING_FOR_PICKUP',NULL,15,0,1,0,0,0,0,0,0,NULL),(16,'Entregado',13,3,'DELIVERED',NULL,16,0,1,0,0,0,0,0,0,NULL),(20,'Asignado',4,0,'PICKER_DESIGNED',NULL,20,1,0,0,0,0,0,2,0,'success'),(21,'Retornado',4,1,'PRINTED_BACK',6,21,0,0,0,0,0,0,2,0,'success'),(22,'Pte. Ampliar',2,0,'EXPANDABLE',NULL,22,0,0,0,0,0,0,4,1,'alert'),(23,'URGENTE',5,1,'LAST_CALL',NULL,23,1,0,1,0,0,0,4,1,'success'),(24,'Encadenado',4,0,'CHAINED',4,24,0,0,0,0,0,0,3,1,'success'),(25,'Embarcando',3,0,'BOARDING',5,25,1,0,0,0,0,0,3,0,'alert'),(26,'Prep Previa',5,1,'PREVIOUS_PREPARATION',1,28,0,0,0,1,0,0,2,0,'warning'),(27,'Prep Asistida',5,1,'ASSISTED_PREPARATION',7,27,0,0,0,0,0,0,2,0,'success'),(28,'Previa OK',3,1,'OK PREVIOUS',3,28,0,0,0,1,1,1,3,0,'warning'),(29,'Previa Impreso',4,1,'PRINTED PREVIOUS',2,29,0,0,1,1,0,1,3,0,'success'),(30,'Embarcado',4,1,'BOARD',5,30,0,0,0,2,0,0,3,0,'success'),(31,'Polizon Impreso',4,1,'PRINTED STOWAWAY',2,29,1,0,1,0,0,1,3,0,'success'),(32,'Polizon OK',3,1,'OK STOWAWAY',3,31,1,0,0,1,1,1,3,0,'warning'),(33,'Auto_Impreso',4,0,'PRINTED_AUTO',2,29,1,0,1,0,0,1,2,0,'success'),(34,'Pte Pago',3,0,'WAITING_FOR_PAYMENT',NULL,34,0,0,0,0,0,0,4,1,'alert'),(35,'Semi-Encajado',9,2,'HALF_PACKED',NULL,10,0,1,0,0,0,0,1,0,NULL),(36,'Control Previa',3,1,'PREVIOUS_CONTROL',1,36,0,1,0,4,0,1,3,0,'warning');
/*!40000 ALTER TABLE `state` ENABLE KEYS */;
UNLOCK TABLES;
@@ -550,7 +472,7 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
--- Dump completed on 2022-03-28 9:44:14
+-- Dump completed on 2022-05-04 15:58:28
USE `cache`;
-- MariaDB dump 10.19 Distrib 10.6.7-MariaDB, for debian-linux-gnu (x86_64)
--
@@ -586,7 +508,7 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
--- Dump completed on 2022-03-28 9:44:14
+-- Dump completed on 2022-05-04 15:58:28
USE `hedera`;
-- MariaDB dump 10.19 Distrib 10.6.7-MariaDB, for debian-linux-gnu (x86_64)
--
@@ -604,6 +526,16 @@ USE `hedera`;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
+--
+-- Dumping data for table `browser`
+--
+
+LOCK TABLES `browser` WRITE;
+/*!40000 ALTER TABLE `browser` DISABLE KEYS */;
+INSERT INTO `browser` VALUES ('Chrome',29),('Firefox',20),('Iceweasel',20),('IE',12),('Opera',12),('Safari',9);
+/*!40000 ALTER TABLE `browser` ENABLE KEYS */;
+UNLOCK TABLES;
+
--
-- Dumping data for table `imageCollection`
--
@@ -614,6 +546,106 @@ INSERT INTO `imageCollection` VALUES (1,'catalog','Artículo',3840,2160,'Item','
/*!40000 ALTER TABLE `imageCollection` ENABLE KEYS */;
UNLOCK TABLES;
+--
+-- Dumping data for table `imageCollectionSize`
+--
+
+LOCK TABLES `imageCollectionSize` WRITE;
+/*!40000 ALTER TABLE `imageCollectionSize` DISABLE KEYS */;
+INSERT INTO `imageCollectionSize` VALUES (2,1,50,50,1),(3,1,200,200,1),(5,5,200,200,1),(6,1,70,70,1),(8,5,50,50,1),(9,1,1600,900,0),(13,6,160,160,1),(14,6,520,520,1),(15,6,1600,1600,1);
+/*!40000 ALTER TABLE `imageCollectionSize` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Dumping data for table `language`
+--
+
+LOCK TABLES `language` WRITE;
+/*!40000 ALTER TABLE `language` DISABLE KEYS */;
+INSERT INTO `language` VALUES ('ca','Català','Catalan',1),('en','English','English',1),('es','Español','Spanish',1),('fr','Français','French',1),('mn','Португалий','Mongolian',1),('pt','Português','Portuguese',1);
+/*!40000 ALTER TABLE `language` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Dumping data for table `link`
+--
+
+LOCK TABLES `link` WRITE;
+/*!40000 ALTER TABLE `link` DISABLE KEYS */;
+INSERT INTO `link` VALUES (16,'Printing server','Manage the CUPS printing server','http://server.verdnatura.es:631','printer'),(20,'Webmail','Verdnatura webmail','https://webmail.verdnatura.es/','mail'),(23,'Verdnatura Beta','Trial version of the web page','https://test.verdnatura.es/','vn'),(25,'Shared folder','Shared folder','/share','backup'),(29,'phpMyAdmin','Manage MySQL database','https://pma.verdnatura.es/','pma'),(30,'Nagios','Monitoring system','https://nagios.verdnatura.es/','nagios'),(33,'Gitea','Version control system','https://gitea.verdnatura.es/','git'),(34,'Wiknatura','Verdnatura wiki page','https://wiki.verdnatura.es/','wiki'),(35,'phpLDAPadmin','Manage the LDAP database','https://pla.verdnatura.es/','pla'),(36,'Applications','Access applications repository','/vn-access','backup');
+/*!40000 ALTER TABLE `link` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Dumping data for table `location`
+--
+
+LOCK TABLES `location` WRITE;
+/*!40000 ALTER TABLE `location` DISABLE KEYS */;
+INSERT INTO `location` VALUES (2,'39.2095886','-0.4173501','Valencia','Calle Fenollar, 2','46680','Algemesi','Valencia','963 242 100','es'),(3,'40.4564969','-3.4875829','Madrid','Avenida de la Constitución, 3 - Nave E','28850','Torrejón de Ardoz','Madrid','916 774 777',NULL),(4,'41.4962045','2.3765504','Barcelona','Camí del crist, 33','08340','Vilassar de Mar','Barcelona','607 562 391','ca'),(5,'52.2612312','4.7818154','Holland','Aalsmeer Flower Auction','1430 BA','Legmeerdijk 313','Aalsmeer','Nederland','nl'),(6,'43.4375416','5.2261456','Marseille','ruben@verdnatura.es','13054','Marigname','Marseille','+33 781 533 900','fr');
+/*!40000 ALTER TABLE `location` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Dumping data for table `menu`
+--
+
+LOCK TABLES `menu` WRITE;
+/*!40000 ALTER TABLE `menu` DISABLE KEYS */;
+INSERT INTO `menu` VALUES (1,'Home','cms/home',6,NULL,1),(2,'Orders',NULL,11,NULL,1),(3,'Catalog','ecomerce/catalog',6,NULL,2),(5,'About',NULL,6,NULL,2),(6,'Location','cms/location',6,5,2),(7,'Administration',NULL,1,NULL,2),(8,'Users','admin/users',1,7,2),(9,'Connections','admin/connections',1,7,2),(11,'Agencies','agencies/packages',3,NULL,2),(12,'News','news/news',1,7,3),(14,'Why','cms/why',6,5,2),(15,'Photos','admin/photos',1,7,3),(16,'Training','cms/training',6,NULL,2),(17,'Configuration',NULL,11,NULL,3),(19,'Control panel','admin/links',1,7,1),(20,'About us','cms/about',6,5,1),(21,'Basket','ecomerce/basket',11,NULL,1),(22,'Last orders','ecomerce/orders',11,2,2),(23,'Invoices','ecomerce/invoices',11,2,2),(24,'Account','account/conf',11,17,1),(25,'Addresses','account/address-list',11,17,2),(26,'Shelves','reports/shelves',1,29,1),(27,'Items list','reports/items-form',1,29,1),(28,'Visits','admin/visits',1,7,2),(29,'Reports',NULL,1,NULL,2),(30,'Items','admin/items',1,7,3);
+/*!40000 ALTER TABLE `menu` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Dumping data for table `message`
+--
+
+LOCK TABLES `message` WRITE;
+/*!40000 ALTER TABLE `message` DISABLE KEYS */;
+INSERT INTO `message` VALUES (1,'ORDER_DATE_HOLIDAY','No es posible realizar pedidos para días festivos'),(2,'ORDER_EMPTY','El pedido esta vacío'),(3,'ORDER_UNAVAILABLE','Algunos artículos ya no están disponibles, verifica las cantidades resaltadas en rojo'),(4,'SURVEY_MAX_ONE_VOTE','Solo es posible realizar un voto por encuesta'),(5,'ORDER_MAX_EXCEEDED','Has excedido el número máximo de pedidos por confirmar, por favor elimina o confirma los pedidos iniciados'),(6,'LOGIN_INCORRECT','Usuario o contraseña incorrectos. Recuerda que se hace distinción entre mayúsculas y minúsculas.'),(7,'ORDER_DATE_PAST','La fecha de su pedido debe ser mayor o igual al día de hoy'),(8,'ORDER_DATE_LAST','No es posible realizar más para hoy, por favor atrasa la fecha de tu pedido a mañana o días posteriores'),(9,'ORDER_DATE_SUNDAY','No es posible confirmar pedidos para Domingo'),(10,'ORDER_DATE_SATURATED','Estamos saturados de pedidos, por favor selecciona otra fecha de envío o recogida '),(11,'USER_DISCONNECTED','Has sido desconectado del servidor, por favor vuelve a iniciar sesión'),(12,'UNAUTH_ACTION','Acción no permitida'),(13,'ORDER_INVALID_AGENCY','La agencia de envío no es válida'),(14,'ORDER_EMPTY_ADDRESS','Selecciona una dirección de envío'),(15,'ORDER_AMOUNT_ROUNDED','Este artículo se vende agrupado y la cantidad ha sido redondeada'),(16,'ORDER_ALREADY_CONFIRMED','Este pedido ya estaba confirmado');
+/*!40000 ALTER TABLE `message` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Dumping data for table `metatag`
+--
+
+LOCK TABLES `metatag` WRITE;
+/*!40000 ALTER TABLE `metatag` DISABLE KEYS */;
+INSERT INTO `metatag` VALUES (2,'title','Verdnatura Levante SL, mayorista de flores, plantas y complementos para floristería y decoración'),(3,'description','Verdnatura Levante SL, mayorista de flores, plantas y complementos para floristería y decoración. Envío a toda España, pedidos por internet o por teléfono.'),(4,'keywords','verdnatura, mayorista, floristería, flores, verdes, plantas, ramos, complementos, artificial, natural, decoración, rosas, helecho, fern, clavel, lilium, orquídea, tulipan, crisantemo, cala, gerbera, hiedra, eucaliptus, cinerea, aralia'),(6,'revisit-after','15 days'),(7,'rating','general'),(8,'author','Juan Ferrer Toribio'),(9,'owner','Verdnatura Levante S.L.'),(10,'robots','index, follow');
+/*!40000 ALTER TABLE `metatag` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Dumping data for table `newsTag`
+--
+
+LOCK TABLES `newsTag` WRITE;
+/*!40000 ALTER TABLE `newsTag` DISABLE KEYS */;
+INSERT INTO `newsTag` VALUES ('course','Curso'),('new','Noticia'),('offer','Oferta');
+/*!40000 ALTER TABLE `newsTag` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Dumping data for table `restPriv`
+--
+
+LOCK TABLES `restPriv` WRITE;
+/*!40000 ALTER TABLE `restPriv` DISABLE KEYS */;
+INSERT INTO `restPriv` VALUES (1,'tpv/transaction',2),(2,'dms/add',1),(3,'image/upload',1),(4,'misc/sms',1),(5,'core/supplant',1),(6,'core/sync-user',5),(7,'core/set-password',1),(8,'core/change-password',11),(9,'misc/access-version',9);
+/*!40000 ALTER TABLE `restPriv` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Dumping data for table `social`
+--
+
+LOCK TABLES `social` WRITE;
+/*!40000 ALTER TABLE `social` DISABLE KEYS */;
+INSERT INTO `social` VALUES (1,'Blog','https://blog.verdnatura.es/','blog.svg',0),(3,'Facebook','http://www.facebook.com/verdnatura','facebook.svg',2),(4,'YouTube','http://www.youtube.com/user/verdnatura','youtube.svg',2),(5,'Twitter','https://twitter.com/Verdnatura','twitter.svg',1),(6,'Instagram','https://www.instagram.com/verdnatura','instagram.svg',2),(7,'Linkedin','https://www.linkedin.com/company/verdnatura','linkedin.svg',1),(8,'Pinterest','https://es.pinterest.com/verdnatura/','pinterest.svg',1);
+/*!40000 ALTER TABLE `social` ENABLE KEYS */;
+UNLOCK TABLES;
+
--
-- Dumping data for table `tpvError`
--
@@ -633,16 +665,6 @@ LOCK TABLES `tpvResponse` WRITE;
INSERT INTO `tpvResponse` VALUES (101,'Tarjeta Caducada'),(102,'Tarjeta en excepción transitoria o bajo sospecha de fraude'),(104,'Operación no permitida para esa tarjeta o terminal'),(106,'Intentos de PIN excedidos'),(116,'Disponible Insuficiente'),(118,'Tarjeta no Registrada'),(125,'Tarjeta no efectiva'),(129,'Código de seguridad (CVV2/CVC2) incorrecto'),(180,'Tarjeta ajena al servicio'),(184,'Error en la autenticación del titular'),(190,'Denegación sin especificar motivo'),(191,'Fecha de caducidad errónea'),(202,'Tarjeta en excepción transitoria o bajo sospecha de fraude con retirada de tarjeta'),(904,'Comercio no registrado en FUC'),(909,'Error de sistema'),(912,'Emisor no Disponible'),(913,'Pedido repetido'),(944,'Sesión Incorrecta'),(950,'Operación de devolución no permitida'),(9064,'Número de posiciones de la tarjeta incorrecto'),(9078,'No existe método de pago válido para esa tarjeta'),(9093,'Tarjeta no existente'),(9094,'Rechazo servidores internacionales'),(9104,'A petición del usuario se ha cancelado el pago'),(9218,'El comercio no permite op. seguras por entrada /operaciones'),(9253,'Tarjeta no cumple el check-digit'),(9256,'El comercio no puede realizar preautorizaciones'),(9257,'Esta tarjeta no permite operativa de preautorizaciones'),(9261,'Operación detenida por superar el control de restricciones en la entrada al SIS'),(9912,'Emisor no Disponible'),(9913,'Error en la confirmación que el comercio envía al TPV Virtual (solo aplicable en la opción de sincronización SOAP)'),(9914,'Confirmación “KO” del comercio (solo aplicable en la opción de sincronización SOAP)'),(9915,'A petición del usuario se ha cancelado el pago'),(9928,'Anulación de autorización en diferido realizada por el SIS (proceso batch)'),(9929,'Anulación de autorización en diferido realizada por el comercio'),(9998,'Operación en proceso de solicitud de datos de tarjeta'),(9999,'Operación que ha sido redirigida al emisora autenticar');
/*!40000 ALTER TABLE `tpvResponse` ENABLE KEYS */;
UNLOCK TABLES;
-
---
--- Dumping data for table `imageCollectionSize`
---
-
-LOCK TABLES `imageCollectionSize` WRITE;
-/*!40000 ALTER TABLE `imageCollectionSize` DISABLE KEYS */;
-INSERT INTO `imageCollectionSize` VALUES (2,1,50,50,1),(3,1,200,200,1),(5,5,200,200,1),(6,1,70,70,1),(8,5,50,50,1),(9,1,1600,900,0),(13,6,160,160,1),(14,6,520,520,1),(15,6,1600,1600,1);
-/*!40000 ALTER TABLE `imageCollectionSize` ENABLE KEYS */;
-UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
@@ -652,7 +674,7 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
--- Dump completed on 2022-03-28 9:44:14
+-- Dump completed on 2022-05-04 15:58:28
USE `postgresql`;
-- MariaDB dump 10.19 Distrib 10.6.7-MariaDB, for debian-linux-gnu (x86_64)
--
@@ -738,7 +760,7 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
--- Dump completed on 2022-03-28 9:44:14
+-- Dump completed on 2022-05-04 15:58:28
USE `sage`;
-- MariaDB dump 10.19 Distrib 10.6.7-MariaDB, for debian-linux-gnu (x86_64)
--
@@ -794,4 +816,4 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
--- Dump completed on 2022-03-28 9:44:14
+-- Dump completed on 2022-05-04 15:58:29
diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql
index 9450103c7..01b38737e 100644
--- a/db/dump/fixtures.sql
+++ b/db/dump/fixtures.sql
@@ -114,28 +114,7 @@ INSERT INTO `vn`.`educationLevel` (`id`, `name`)
INSERT INTO `vn`.`worker`(`id`,`code`, `firstName`, `lastName`, `userFk`, `bossFk`)
SELECT id,UPPER(LPAD(role, 3, '0')), name, name, id, 9
- FROM `vn`.`user`;
-
-ALTER TABLE `vn`.`worker` ADD `originCountryFk` mediumint(8) unsigned NULL COMMENT 'País de origen';
-ALTER TABLE `vn`.`worker` ADD `educationLevelFk` SMALLINT NULL;
-ALTER TABLE `vn`.`worker` ADD `SSN` varchar(15) NULL;
-ALTER TABLE `vn`.`worker` CHANGE `maritalStatus__` `maritalStatus` enum('S','M') CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL;
-ALTER TABLE `vn`.`worker` MODIFY COLUMN `maritalStatus` enum('S','M') CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL;
-ALTER TABLE `vn`.`worker` CHANGE `maritalStatus` maritalStatus enum('S','M') CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL AFTER sectorFk;
-ALTER TABLE `vn`.`worker` ADD CONSTRAINT `worker_FK_2` FOREIGN KEY (`educationLevelFk`) REFERENCES `vn`.`educationLevel`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
-ALTER TABLE `vn`.`worker` ADD CONSTRAINT `worker_FK_1` FOREIGN KEY (`originCountryFk`) REFERENCES `vn`.`country`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
-
-UPDATE `vn`.`worker` `w`
- SET `maritalStatus` = 'S';
-
-UPDATE `vn`.`worker` `w`
- SET `originCountryFk` = '1';
-
-UPDATE `vn`.`worker` `w`
- SET `educationLevelFk` = '2';
-
-UPDATE `vn`.`worker` `w`
- SET `SSN` = '123456789123';
+ FROM `vn`.`user`;
UPDATE `vn`.`worker` SET bossFk = NULL WHERE id = 20;
UPDATE `vn`.`worker` SET bossFk = 20 WHERE id = 1 OR id = 9;
@@ -180,13 +159,19 @@ INSERT INTO `account`.`mailForward`(`account`, `forwardTo`)
VALUES
(1, 'employee@domain.local');
-INSERT INTO `vn`.`worker`(`id`, `code`, `firstName`, `lastName`, `userFk`,`bossFk`, `phone`)
+INSERT INTO `vn`.`printer` (`id`, `name`, `path`, `isLabeler`)
VALUES
- (1106, 'LGN', 'David Charles', 'Haller', 1106, 19, 432978106),
- (1107, 'ANT', 'Hank' , 'Pym' , 1107, 19, 432978107),
- (1108, 'DCX', 'Charles' , 'Xavier', 1108, 19, 432978108),
- (1109, 'HLK', 'Bruce' , 'Banner', 1109, 19, 432978109),
- (1110, 'JJJ', 'Jessica' , 'Jones' , 1110, 19, 432978110);
+ (1, 'printer1', 'path1', 0),
+ (2, 'printer2', 'path2', 1);
+
+
+INSERT INTO `vn`.`worker`(`id`, `code`, `firstName`, `lastName`, `userFk`,`bossFk`, `phone`, `sectorFk`, `labelerFk`)
+ VALUES
+ (1106, 'LGN', 'David Charles', 'Haller', 1106, 19, 432978106, NULL, NULL),
+ (1107, 'ANT', 'Hank' , 'Pym' , 1107, 19, 432978107, NULL, 1),
+ (1108, 'DCX', 'Charles' , 'Xavier', 1108, 19, 432978108, 1, NULL),
+ (1109, 'HLK', 'Bruce' , 'Banner', 1109, 19, 432978109, 1, 2),
+ (1110, 'JJJ', 'Jessica' , 'Jones' , 1110, 19, 432978110, 2, 1);
INSERT INTO `vn`.`currency`(`id`, `code`, `name`, `ratio`)
VALUES
@@ -194,7 +179,7 @@ INSERT INTO `vn`.`currency`(`id`, `code`, `name`, `ratio`)
(2, 'USD', 'Dollar USA', 1.4),
(3, 'GBP', 'Libra', 1),
(4, 'JPY', 'Yen Japones', 1);
-
+
INSERT INTO `vn`.`country`(`id`, `country`, `isUeeMember`, `code`, `currencyFk`, `ibanLength`, `continentFk`, `hasDailyInvoice`, `CEE`)
VALUES
(1, 'España', 1, 'ES', 1, 24, 4, 0, 1),
@@ -207,15 +192,6 @@ INSERT INTO `vn`.`country`(`id`, `country`, `isUeeMember`, `code`, `currencyFk`,
(19,'Francia', 1, 'FR', 1, 27, 4, 0, 1),
(30,'Canarias', 1, 'IC', 1, 24, 4, 1, 2);
-INSERT INTO `hedera`.`language` (`code`, `name`, `orgName`, `isActive`)
- VALUES
- ('ca', 'Català' , 'Catalan' , TRUE),
- ('en', 'English' , 'English' , TRUE),
- ('es', 'Español' , 'Spanish' , TRUE),
- ('fr', 'Français' , 'French' , TRUE),
- ('mn', 'Португалий', 'Mongolian' , TRUE),
- ('pt', 'Português' , 'Portuguese', TRUE);
-
INSERT INTO `vn`.`warehouseAlias`(`id`, `name`)
VALUES
(1, 'Main Warehouse'),
@@ -242,25 +218,27 @@ INSERT INTO `vn`.`parking` (`id`, `column`, `row`, `sectorFk`, `code`, `pickingO
INSERT INTO `vn`.`shelving` (`code`, `parkingFk`, `isPrinted`, `priority`, `parked`, `userFk`)
VALUES
- ('GVC', '1', '0', '1', '0', '1106'),
- ('HEJ', '2', '0', '1', '0', '1106');
+ ('GVC', 1, 0, 1, 0, 1106),
+ ('HEJ', 2, 0, 1, 0, 1106),
+ ('UXN', 1, 0, 1, 0, 1106);
-INSERT INTO `vn`.`accountingType`(`id`, `description`, `receiptDescription`,`code`, `maxAmount`)
+INSERT INTO `vn`.`accountingType`(`id`, `description`, `receiptDescription`,`code`, `maxAmount`, `daysInFuture`)
VALUES
- (1, 'CC y Polizas de crédito', NULL, NULL, NULL),
- (2, 'Cash', 'Cash', 'cash', 1000),
- (3, 'Credit card', 'Credit Card', 'creditCard', NULL),
- (4, 'Finalcial lines', NULL, NULL, NULL),
- (5, 'Other products', NULL, NULL, NULL),
- (6, 'Loans', NULL, NULL, NULL),
- (7, 'Leasing', NULL, NULL, NULL),
- (8, 'Compensations', 'Compensations', 'compensation', NULL);
+ (1, 'CC and credit policies', 'Transfers', 'wireTransfer', NULL, 1),
+ (2, 'Cash', 'Cash', 'cash', 1000, 0),
+ (3, 'Credit card', 'Credit Card', 'creditCard', NULL, 0),
+ (4, 'Finalcial lines', NULL, NULL, NULL, 0),
+ (5, 'Other products', NULL, NULL, NULL, 0),
+ (6, 'Loans', NULL, NULL, NULL, 0),
+ (7, 'Leasing', NULL, NULL, NULL, 0),
+ (8, 'Compensations', 'Compensations', 'compensation', NULL, 0);
INSERT INTO `vn`.`bank`(`id`, `bank`, `account`, `cash`, `entityFk`, `isActive`, `currencyFk`)
VALUES
(1, 'Pay on receipt', '5720000001', 3, 0, 1, 1),
(2, 'Cash', '5700000001', 2, 0, 1, 1),
(3, 'Compensation', '4000000000', 8, 0, 1, 1),
+ (4, 'Transfers', '4000000001', 1, 0, 1, 1),
(3117, 'Caixa Rural d''Algemesi', '5720000000', 8, 3117, 1, 1);
@@ -402,9 +380,9 @@ INSERT INTO `vn`.`clientManaCache`(`clientFk`, `mana`, `dated`)
(1103, 0, DATE_ADD(vn.VN_CURDATE(), INTERVAL -1 MONTH)),
(1104, -30, DATE_ADD(vn.VN_CURDATE(), INTERVAL -1 MONTH));
-INSERT INTO `vn`.`clientConfig`(`riskTolerance`)
+INSERT INTO `vn`.`clientConfig`(`riskTolerance`, `maxCreditRows`)
VALUES
- (200);
+ (200, 10);
INSERT INTO `vn`.`address`(`id`, `nickname`, `street`, `city`, `postalCode`, `provinceFk`, `phone`, `mobile`, `isActive`, `clientFk`, `agencyModeFk`, `longitude`, `latitude`, `isEqualizated`, `isDefaultAddress`)
VALUES
@@ -482,17 +460,17 @@ DROP TEMPORARY TABLE tmp.address;
INSERT INTO `vn`.`clientCredit`(`id`, `clientFk`, `workerFk`, `amount`, `created`)
VALUES
- (1 , 1101, 5, 300, DATE_ADD(vn.VN_CURDATE(), INTERVAL -1 MONTH)),
- (2 , 1101, 5, 900, DATE_ADD(vn.VN_CURDATE(), INTERVAL -2 MONTH)),
- (3 , 1101, 5, 800, DATE_ADD(vn.VN_CURDATE(), INTERVAL -3 MONTH)),
- (4 , 1101, 5, 700, DATE_ADD(vn.VN_CURDATE(), INTERVAL -4 MONTH)),
- (5 , 1101, 5, 600, DATE_ADD(vn.VN_CURDATE(), INTERVAL -5 MONTH)),
+ (1 , 1101, 5, 300, DATE_ADD(vn.VN_CURDATE(), INTERVAL -11 MONTH)),
+ (2 , 1101, 5, 900, DATE_ADD(vn.VN_CURDATE(), INTERVAL -10 MONTH)),
+ (3 , 1101, 5, 800, DATE_ADD(vn.VN_CURDATE(), INTERVAL -9 MONTH)),
+ (4 , 1101, 5, 700, DATE_ADD(vn.VN_CURDATE(), INTERVAL -8 MONTH)),
+ (5 , 1101, 5, 600, DATE_ADD(vn.VN_CURDATE(), INTERVAL -7 MONTH)),
(6 , 1101, 5, 500, DATE_ADD(vn.VN_CURDATE(), INTERVAL -6 MONTH)),
- (7 , 1101, 5, 400, DATE_ADD(vn.VN_CURDATE(), INTERVAL -7 MONTH)),
- (8 , 1101, 9, 300, DATE_ADD(vn.VN_CURDATE(), INTERVAL -8 MONTH)),
- (9 , 1101, 9, 200, DATE_ADD(vn.VN_CURDATE(), INTERVAL -9 MONTH)),
- (10, 1101, 9, 100, DATE_ADD(vn.VN_CURDATE(), INTERVAL -10 MONTH)),
- (11, 1101, 9, 50 , DATE_ADD(vn.VN_CURDATE(), INTERVAL -11 MONTH)),
+ (7 , 1101, 5, 400, DATE_ADD(vn.VN_CURDATE(), INTERVAL -5 MONTH)),
+ (8 , 1101, 9, 300, DATE_ADD(vn.VN_CURDATE(), INTERVAL -4 MONTH)),
+ (9 , 1101, 9, 200, DATE_ADD(vn.VN_CURDATE(), INTERVAL -3 MONTH)),
+ (10, 1101, 9, 100, DATE_ADD(vn.VN_CURDATE(), INTERVAL -2 MONTH)),
+ (11, 1101, 9, 50 , DATE_ADD(vn.VN_CURDATE(), INTERVAL -1 MONTH)),
(12, 1102, 9, 800, vn.VN_CURDATE()),
(14, 1104, 9, 90 , vn.VN_CURDATE()),
(15, 1105, 9, 90 , vn.VN_CURDATE());
@@ -833,14 +811,19 @@ INSERT INTO `vn`.`itemCategory`(`id`, `name`, `display`, `color`, `icon`, `code`
(7, 'Accessories', 1, NULL, 'icon-accessory', 'accessory'),
(8, 'Fruit', 1, NULL, 'icon-fruit', 'fruit');
-INSERT INTO `vn`.`itemType`(`id`, `code`, `name`, `categoryFk`, `warehouseFk`, `life`,`workerFk`, `isPackaging`)
+INSERT INTO `vn`.`temperature`(`code`, `name`, `description`)
VALUES
- (1, 'CRI', 'Crisantemo', 2, 1, 31, 35, 0),
- (2, 'ITG', 'Anthurium', 1, 1, 31, 35, 0),
- (3, 'WPN', 'Paniculata', 2, 1, 31, 35, 0),
- (4, 'PRT', 'Delivery ports', 3, 1, NULL, 35, 1),
- (5, 'CON', 'Container', 3, 1, NULL, 35, 1),
- (6, 'ALS', 'Alstroemeria', 1, 1, 31, 16, 0);
+ ('warm', 'Warm', 'Warm'),
+ ('cool', 'Cool', 'Cool');
+
+INSERT INTO `vn`.`itemType`(`id`, `code`, `name`, `categoryFk`, `warehouseFk`, `life`,`workerFk`, `isPackaging`, `temperatureFk`)
+ VALUES
+ (1, 'CRI', 'Crisantemo', 2, 1, 31, 35, 0, 'cool'),
+ (2, 'ITG', 'Anthurium', 1, 1, 31, 35, 0, 'cool'),
+ (3, 'WPN', 'Paniculata', 2, 1, 31, 35, 0, 'cool'),
+ (4, 'PRT', 'Delivery ports', 3, 1, NULL, 35, 1, 'warm'),
+ (5, 'CON', 'Container', 3, 1, NULL, 35, 1, 'warm'),
+ (6, 'ALS', 'Alstroemeria', 1, 1, 31, 16, 0, 'warm');
INSERT INTO `vn`.`ink`(`id`, `name`, `picture`, `showOrder`, `hex`)
VALUES
@@ -898,25 +881,25 @@ INSERT INTO `vn`.`itemFamily`(`code`, `description`)
('VT', 'Sales');
INSERT INTO `vn`.`item`(`id`, `typeFk`, `size`, `inkFk`, `stems`, `originFk`, `description`, `producerFk`, `intrastatFk`, `expenceFk`,
- `comment`, `relevancy`, `image`, `subName`, `minPrice`, `stars`, `family`, `isFloramondo`, `genericFk`, `itemPackingTypeFk`, `hasMinPrice`)
+ `comment`, `relevancy`, `image`, `subName`, `minPrice`, `stars`, `family`, `isFloramondo`, `genericFk`, `itemPackingTypeFk`, `hasMinPrice`, `packingShelve`)
VALUES
- (1, 2, 70, 'YEL', 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '1', NULL, 0, 1, 'VT', 0, NULL, 'V', 0),
- (2, 2, 70, 'BLU', 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '2', NULL, 0, 2, 'VT', 0, NULL, 'H', 0),
- (3, 1, 60, 'YEL', 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '3', NULL, 0, 5, 'VT', 0, NULL, NULL, 0),
- (4, 1, 60, 'YEL', 1, 1, 'Increases block', 1, 05080000, 4751000000, NULL, 0, '4', NULL, 0, 3, 'VT', 0, NULL, NULL, 0),
- (5, 3, 30, 'RED', 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '5', NULL, 0, 3, 'VT', 0, NULL, NULL, 0),
- (6, 5, 30, 'RED', 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '6', NULL, 0, 4, 'VT', 0, NULL, NULL, 0),
- (7, 5, 90, 'BLU', 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '7', NULL, 0, 4, 'VT', 0, NULL, NULL, 0),
- (8, 2, 70, 'YEL', 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '8', NULL, 0, 5, 'VT', 0, NULL, NULL, 0),
- (9, 2, 70, 'BLU', 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '9', NULL, 0, 4, 'VT', 1, NULL, NULL, 0),
- (10, 1, 60, 'YEL', 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '10', NULL, 0, 4, 'VT', 0, NULL, NULL, 0),
- (11, 1, 60, 'YEL', 1, 1, NULL, 1, 05080000, 4751000000, NULL, 0, '11', NULL, 0, 4, 'VT', 0, NULL, NULL, 0),
- (12, 3, 30, 'RED', 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '12', NULL, 0, 3, 'VT', 0, NULL, NULL, 0),
- (13, 5, 30, 'RED', 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '13', NULL, 1, 2, 'VT', 1, NULL, NULL, 1),
- (14, 5, 90, 'BLU', 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 4, 'VT', 1, NULL, NULL, 0),
- (15, 4, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 0, 'EMB', 0, NULL, NULL, 0),
- (16, 6, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 0, 'EMB', 0, NULL, NULL, 0),
- (71, 6, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 0, 'VT', 0, NULL, NULL, 0);
+ (1, 2, 70, 'YEL', 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '1', NULL, 0, 1, 'VT', 0, NULL, 'V', 0, 15),
+ (2, 2, 70, 'BLU', 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '2', NULL, 0, 2, 'VT', 0, NULL, 'H', 0, 10),
+ (3, 1, 60, 'YEL', 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '3', NULL, 0, 5, 'VT', 0, NULL, NULL, 0, 5),
+ (4, 1, 60, 'YEL', 1, 1, 'Increases block', 1, 05080000, 4751000000, NULL, 0, '4', NULL, 0, 3, 'VT', 0, NULL, NULL, 0, NULL),
+ (5, 3, 30, 'RED', 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '5', NULL, 0, 3, 'VT', 0, NULL, NULL, 0, NULL),
+ (6, 5, 30, 'RED', 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '6', NULL, 0, 4, 'VT', 0, NULL, NULL, 0, NULL),
+ (7, 5, 90, 'BLU', 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '7', NULL, 0, 4, 'VT', 0, NULL, NULL, 0, NULL),
+ (8, 2, 70, 'YEL', 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '8', NULL, 0, 5, 'VT', 0, NULL, NULL, 0, NULL),
+ (9, 2, 70, 'BLU', 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '9', NULL, 0, 4, 'VT', 1, NULL, NULL, 0, NULL),
+ (10, 1, 60, 'YEL', 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '10', NULL, 0, 4, 'VT', 0, NULL, NULL, 0, NULL),
+ (11, 1, 60, 'YEL', 1, 1, NULL, 1, 05080000, 4751000000, NULL, 0, '11', NULL, 0, 4, 'VT', 0, NULL, NULL, 0, NULL),
+ (12, 3, 30, 'RED', 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '12', NULL, 0, 3, 'VT', 0, NULL, NULL, 0, NULL),
+ (13, 5, 30, 'RED', 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '13', NULL, 1, 2, 'VT', 1, NULL, NULL, 1, NULL),
+ (14, 5, 90, 'BLU', 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 4, 'VT', 1, NULL, NULL, 0, NULL),
+ (15, 4, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 0, 'EMB', 0, NULL, NULL, 0, NULL),
+ (16, 6, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 0, 'EMB', 0, NULL, NULL, 0, NULL),
+ (71, 6, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 0, 'VT', 0, NULL, NULL, 0, NULL);
-- Update the taxClass after insert of the items
UPDATE `vn`.`itemTaxCountry` SET `taxClassFk` = 2
@@ -943,18 +926,35 @@ INSERT INTO `vn`.`packaging`(`id`, `volume`, `width`, `height`, `depth`, `isPack
('cc', 1640038.00, 56.00, 220.00, 128.00, 1, vn.VN_CURDATE(), 15, 90.00),
('pallet 100', 2745600.00, 100.00, 220.00, 120.00, 1, vn.VN_CURDATE(), 16, 0.00);
-INSERT INTO `vn`.`expedition`(`id`, `agencyModeFk`, `ticketFk`, `isBox`, `created`, `itemFk`, `counter`, `checked`, `workerFk`, `externalId`, `packagingFk`)
+INSERT INTO `vn`.`expeditionStateType`(`id`, `description`, `code`)
VALUES
- (1, 1, 1, 71, DATE_ADD(vn.VN_CURDATE(), INTERVAL -1 MONTH), 15, 1, 1, 18, 'UR9000006041', 94),
- (2, 1, 1, 71, DATE_ADD(vn.VN_CURDATE(), INTERVAL -1 MONTH), 16, 2, 1, 18, 'UR9000006041', 94),
- (3, 1, 1, 71, DATE_ADD(vn.VN_CURDATE(), INTERVAL -1 MONTH), NULL, 3, 1, 18, 'UR9000006041', 94),
- (4, 1, 1, 71, DATE_ADD(vn.VN_CURDATE(), INTERVAL -1 MONTH), NULL, 4, 1, 18, 'UR9000006041', 94),
- (5, 1, 2, 71, DATE_ADD(vn.VN_CURDATE(), INTERVAL -1 MONTH), NULL, 1, 1, 18, NULL, 94),
- (6, 7, 3, 71, DATE_ADD(vn.VN_CURDATE(), INTERVAL -2 MONTH), NULL, 1, 1, 18, NULL, 94),
- (7, 2, 4, 71, DATE_ADD(vn.VN_CURDATE(), INTERVAL -3 MONTH), NULL, 1, 1, 18, NULL, 94),
- (8, 3, 5, 71, DATE_ADD(vn.VN_CURDATE(), INTERVAL -4 MONTH), NULL, 1, 1, 18, NULL, 94),
- (9, 3, 6, 71, DATE_ADD(vn.VN_CURDATE(), INTERVAL -1 MONTH), NULL, 1, 1, 18, NULL, 94),
- (10, 7, 7, 71, vn.VN_NOW(), NULL, 1, 1, 18, NULL, 94);
+ (1, 'En reparto', 'ON DELIVERY'),
+ (2, 'Entregada', 'DELIVERED'),
+ (3, 'Perdida', 'LOST');
+
+
+INSERT INTO `vn`.`expedition`(`id`, `agencyModeFk`, `ticketFk`, `isBox`, `created`, `itemFk`, `counter`, `checked`, `workerFk`, `externalId`, `packagingFk`, `stateTypeFk`)
+ VALUES
+ (1, 1, 1, 71, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 15, 1, 1, 18, 'UR9000006041', 94, 1),
+ (2, 1, 1, 71, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 16, 2, 1, 18, 'UR9000006041', 94, 1),
+ (3, 1, 1, 71, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), NULL, 3, 1, 18, 'UR9000006041', 94, 2),
+ (4, 1, 1, 71, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), NULL, 4, 1, 18, 'UR9000006041', 94, 2),
+ (5, 1, 2, 71, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), NULL, 1, 1, 18, NULL, 94, 3),
+ (6, 7, 3, 71, DATE_ADD(CURDATE(), INTERVAL -2 MONTH), NULL, 1, 1, 18, NULL, 94, 3),
+ (7, 2, 4, 71, DATE_ADD(CURDATE(), INTERVAL -3 MONTH), NULL, 1, 1, 18, NULL, 94, NULL),
+ (8, 3, 5, 71, DATE_ADD(CURDATE(), INTERVAL -4 MONTH), NULL, 1, 1, 18, NULL, 94, 1),
+ (9, 3, 6, 71, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), NULL, 1, 1, 18, NULL, 94, 2),
+ (10, 7, 7, 71, NOW(), NULL, 1, 1, 18, NULL, 94, 3);
+
+
+INSERT INTO `vn`.`expeditionState`(`id`, `created`, `expeditionFk`, `typeFk`, `userFk`)
+ VALUES
+ (1, DATE_ADD(vn.VN_CURDATE()), 1, 1, 1),
+ (2, DATE_ADD(vn.VN_CURDATE()), 2, 1, 1),
+ (3, DATE_ADD(vn.VN_CURDATE()), 3, 1, 1),
+ (4, DATE_ADD(vn.VN_CURDATE()), 3, 2, 1106),
+ (5, DATE_ADD(vn.VN_CURDATE()), 5, 1, 1106),
+ (6, DATE_ADD(vn.VN_CURDATE()), 5, 3, 1106);
INSERT INTO `vn`.`ticketPackaging`(`id`, `ticketFk`, `packagingFk`, `quantity`, `created`, `pvp`)
VALUES
@@ -1138,10 +1138,11 @@ INSERT INTO `vn`.`saleComponent`(`saleFk`, `componentFk`, `value`)
(32, 36, -92.324),
(32, 39, 0.994);
-INSERT INTO `vn`.`itemShelving` (`id`, `itemFk`, `shelvingFk`, `shelve`, `deep`, `quantity`, `visible`, `available`, `grouping`, `packing`, `level`, `userFk`)
+INSERT INTO `vn`.`itemShelving` (`itemFk`, `shelvingFk`, `shelve`, `visible`, `grouping`, `packing`, `userFk`)
VALUES
- ('1', '2', 'GVC', 'A', '0', '1', '1', '1', '1', '1', '1', '1106'),
- ('2', '4', 'HEJ', 'A', '0', '2', '1', '1', '1', '1', '1', '1106');
+ (2, 'GVC', 'A', 1, 1, 1, 1106),
+ (4, 'HEJ', 'A', 1, 1, 1, 1106),
+ (1, 'UXN', 'A', 2, 12, 12, 1106);
INSERT INTO `vn`.`itemShelvingSale` (`itemShelvingFk`, `saleFk`, `quantity`, `created`, `userFk`)
VALUES
@@ -1195,14 +1196,6 @@ INSERT INTO `vn`.`parking` (`column`, `row`, `sectorFk`, `code`, `pickingOrder`)
VALUES
('100', '01', 1, '100-01', 1);
-INSERT INTO `vn`.`shelving` (`code`, `parkingFk`, `priority`, `userFk`)
- VALUES
- ('UXN', 1, 1, 1106);
-
-INSERT INTO `vn`.`itemShelving` (`itemFk`, `shelvingFk`, `shelve`, `deep`, `quantity`, `visible`, `available`, `grouping`, `packing`, `level`, `userFk`)
- VALUES
- (1, 'UXN', 'A', 2, 12, 12, 12, 12, 12, 1, 1106);
-
INSERT INTO `vn`.`ticketCollection` (`ticketFk`, `collectionFk`, `level`)
VALUES
(1, 1, 1);
@@ -1392,11 +1385,11 @@ INSERT INTO `vn`.`supplierAddress`(`id`, `supplierFk`, `nickname`, `street`, `pr
(5, 442, 'GCR building', 'Bristol district', 1, '46000', 'Gotham', '111111111', '222222222'),
(6, 442, 'The Gotham Tonight building', 'Bristol district', 1, '46000', 'Gotham', '111111111', '222222222');
-INSERT INTO `vn`.`supplier`(`id`, `name`, `nickname`,`account`,`countryFk`,`nif`, `commission`, `created`, `isActive`, `street`, `city`, `provinceFk`, `postCode`, `payMethodFk`, `payDemFk`, `payDay`, `taxTypeSageFk`, `withholdingSageFk`, `transactionTypeSageFk`, `workerFk`, `supplierActivityFk`, `isPayMethodChecked`)
+INSERT INTO `vn`.`supplier`(`id`, `name`, `nickname`,`account`,`countryFk`,`nif`, `commission`, `created`, `isActive`, `street`, `city`, `provinceFk`, `postCode`, `payMethodFk`, `payDemFk`, `payDay`, `taxTypeSageFk`, `withholdingSageFk`, `transactionTypeSageFk`, `workerFk`, `supplierActivityFk`, `isPayMethodChecked`, `healthRegister`)
VALUES
- (1, 'Plants SL', 'Plants nick', 4100000001, 1, '06089160W', 0, vn.VN_CURDATE(), 1, 'supplier address 1', 'PONTEVEDRA', 1, 15214, 1, 1, 15, 4, 1, 1, 18, 'flowerPlants', 1),
- (2, 'Farmer King', 'The farmer', 4000020002, 1, '87945234L', 0, vn.VN_CURDATE(), 1, 'supplier address 2', 'SILLA', 2, 43022, 1, 2, 10, 93, 2, 8, 18, 'animals', 1),
- (442, 'Verdnatura Levante SL', 'Verdnatura', 5115000442, 1, '06815934E', 0, vn.VN_CURDATE(), 1, 'supplier address 3', 'SILLA', 1, 43022, 1, 2, 15, 6, 9, 3, 18, 'flowerPlants', 1);
+ (1, 'Plants SL', 'Plants nick', 4100000001, 1, '06089160W', 0, vn.VN_CURDATE(), 1, 'supplier address 1', 'PONTEVEDRA', 1, 15214, 1, 1, 15, 4, 1, 1, 18, 'flowerPlants', 1, '400664487V'),
+ (2, 'Farmer King', 'The farmer', 4000020002, 1, '87945234L', 0, vn.VN_CURDATE(), 1, 'supplier address 2', 'SILLA', 2, 43022, 1, 2, 10, 93, 2, 8, 18, 'animals', 1, '400664487V'),
+ (442, 'Verdnatura Levante SL', 'Verdnatura', 5115000442, 1, '06815934E', 0, vn.VN_CURDATE(), 1, 'supplier address 3', 'SILLA', 1, 43022, 1, 2, 15, 6, 9, 3, 18, 'complements', 1, '400664487V');
INSERT INTO `vn`.`supplierContact`(`id`, `supplierFk`, `phone`, `mobile`, `email`, `observation`, `name`)
VALUES
@@ -1700,51 +1693,59 @@ INSERT INTO `hedera`.`orderRowComponent`(`rowFk`, `componentFk`, `price`)
INSERT INTO `hedera`.`visit`(`id`, `firstAgentFk`)
VALUES
- (1, NULL),
- (2, NULL),
- (3, NULL),
- (4, NULL),
- (5, NULL),
- (6, NULL),
- (7, NULL),
- (8, NULL),
- (9, NULL);
+ (1, NULL),
+ (2, NULL),
+ (3, NULL),
+ (4, NULL),
+ (5, NULL),
+ (6, NULL),
+ (7, NULL),
+ (8, NULL),
+ (9, NULL),
+ (10, NULL),
+ (11, NULL);
INSERT INTO `hedera`.`visitAgent`(`id`, `visitFk`)
VALUES
- (1, 1),
- (2, 2),
- (3, 3),
- (4, 4),
- (5, 5),
- (6, 6),
- (7, 7),
- (8, 8),
- (9, 9);
+ (1, 1),
+ (2, 2),
+ (3, 3),
+ (4, 4),
+ (5, 5),
+ (6, 6),
+ (7, 7),
+ (8, 8),
+ (9, 9),
+ (10, 10),
+ (11, 11);
INSERT INTO `hedera`.`visitAccess`(`id`, `agentFk`, `stamp`)
VALUES
- (1, 1, vn.VN_CURDATE()),
- (2, 2, vn.VN_CURDATE()),
- (3, 3, vn.VN_CURDATE()),
- (4, 4, vn.VN_CURDATE()),
- (5, 5, vn.VN_CURDATE()),
- (6, 6, vn.VN_CURDATE()),
- (7, 7, vn.VN_CURDATE()),
- (8, 8, vn.VN_CURDATE()),
- (9, 9, vn.VN_CURDATE());
+ (1, 1, vn.VN_CURDATE()),
+ (2, 2, vn.VN_CURDATE()),
+ (3, 3, vn.VN_CURDATE()),
+ (4, 4, vn.VN_CURDATE()),
+ (5, 5, vn.VN_CURDATE()),
+ (6, 6, vn.VN_CURDATE()),
+ (7, 7, vn.VN_CURDATE()),
+ (8, 8, vn.VN_CURDATE()),
+ (9, 9, vn.VN_CURDATE()),
+ (10, 10, vn.VN_CURDATE()),
+ (11, 11, vn.VN_CURDATE());
INSERT INTO `hedera`.`visitUser`(`id`, `accessFk`, `userFk`, `stamp`)
VALUES
- (1, 1, 1101, vn.VN_CURDATE()),
- (2, 2, 1101, vn.VN_CURDATE()),
- (3, 3, 1101, vn.VN_CURDATE()),
- (4, 4, 1102, vn.VN_CURDATE()),
- (5, 5, 1102, vn.VN_CURDATE()),
- (6, 6, 1102, vn.VN_CURDATE()),
- (7, 7, 1103, vn.VN_CURDATE()),
- (8, 8, 1103, vn.VN_CURDATE()),
- (9, 9, 1103, vn.VN_CURDATE());
+ (1, 1, 1101, vn.VN_CURDATE()),
+ (2, 2, 1101, vn.VN_CURDATE()),
+ (3, 3, 1101, vn.VN_CURDATE()),
+ (4, 4, 1102, vn.VN_CURDATE()),
+ (5, 5, 1102, vn.VN_CURDATE()),
+ (6, 6, 1102, vn.VN_CURDATE()),
+ (7, 7, 1103, vn.VN_CURDATE()),
+ (8, 8, 1103, vn.VN_CURDATE()),
+ (9, 9, 1103, vn.VN_CURDATE()),
+ (10, 10, 1102, DATE_SUB(vn.VN_CURDATE(), INTERVAL 1 DAY)),
+ (11, 11, 1103, DATE_SUB(vn.VN_CURDATE(), INTERVAL 1 DAY));
INSERT INTO `hedera`.`userSession`(`created`, `lastUpdate`, `ssid`, `data`, `userVisitFk`)
VALUES
@@ -2326,13 +2327,19 @@ INSERT INTO `vn`.`dmsType`(`id`, `name`, `path`, `readRoleFk`, `writeRoleFk`, `c
INSERT INTO `vn`.`dms`(`id`, `dmsTypeFk`, `file`, `contentType`, `workerFk`, `warehouseFk`, `companyFk`, `hardCopyNumber`, `hasFile`, `reference`, `description`, `created`)
VALUES
- (1, 14, '1.txt', 'text/plain', 5, 1, 442, NULL, FALSE, 'Ticket:11', 'Ticket:11 dms for the ticket', vn.VN_CURDATE()),
- (2, 5, '2.txt', 'text/plain', 5, 1, 442, 1, TRUE, 'Client:104', 'Client:104 dms for the client', vn.VN_CURDATE()),
- (3, 5, '3.txt', 'text/plain', 5, 1, 442, NULL, TRUE, 'Client: 104', 'Client:104 readme', vn.VN_CURDATE()),
- (4, 3, '4.txt', 'text/plain', 5, 1, 442, NULL, TRUE, 'Worker: 106', 'Worker:106 readme', vn.VN_CURDATE()),
- (5, 5, '5.txt', 'text/plain', 5, 1, 442, NULL, TRUE, 'travel: 1', 'dmsForThermograph', vn.VN_CURDATE()),
- (6, 5, '6.txt', 'text/plain', 5, 1, 442, NULL, TRUE, 'NotExists', 'DoesNotExists', vn.VN_CURDATE());
+ (1, 14, '1.txt', 'text/plain', 5, 1, 442, NULL, FALSE, 'Ticket:11', 'Ticket:11 dms for the ticket', vn.VN_CURDATE()),
+ (2, 5, '2.txt', 'text/plain', 5, 1, 442, 1, TRUE, 'Client:104', 'Client:104 dms for the client', vn.VN_CURDATE()),
+ (3, 5, '3.txt', 'text/plain', 5, 1, 442, NULL, TRUE, 'Client: 104', 'Client:104 readme', vn.VN_CURDATE()),
+ (4, 3, '4.txt', 'text/plain', 5, 1, 442, NULL, TRUE, 'Worker: 106', 'Worker:106 readme', vn.VN_CURDATE()),
+ (5, 5, '5.txt', 'text/plain', 5, 1, 442, NULL, TRUE, 'travel: 1', 'dmsForThermograph', vn.VN_CURDATE()),
+ (6, 5, '6.txt', 'text/plain', 5, 1, 442, NULL, TRUE, 'NotExists', 'DoesNotExists', vn.VN_CURDATE()),
+ (7, 20, '7.jpg', 'image/jpeg', 9, 1, 442, NULL, FALSE, '1', 'TICKET ID DEL CLIENTE BRUCE WAYNE ID 1101', vn.VN_CURDATE()),
+ (8, 20, '8.mp4', 'video/mp4', 9, 1, 442, NULL, FALSE, '1', 'TICKET ID DEL CLIENTE BRUCE WAYNE ID 1101', vn.VN_CURDATE());
+INSERT INTO `vn`.`claimDms`(`claimFk`, `dmsFk`)
+ VALUES
+ (1, 7),
+ (1, 8);
INSERT INTO `vn`.`ticketDms`(`ticketFk`, `dmsFk`)
VALUES
@@ -2363,11 +2370,6 @@ INSERT INTO `vn`.`workerTimeControlParams` (`id`, `dayBreak`, `weekBreak`, `week
(1, 43200, 129600, 734400, 43200, 50400, 259200, 1296000, 36000);
INSERT IGNORE INTO `vn`.`greugeConfig` (`id`, `freightPickUpPrice`) VALUES ('1', '11');
-
-INSERT INTO `vn`.`temperature`(`code`, `name`, `description`)
- VALUES
- ('warm', 'Warm', 'Warm'),
- ('cool', 'Cool', 'Cool');
INSERT INTO `vn`.`thermograph`(`id`, `model`)
VALUES
@@ -2592,7 +2594,7 @@ INSERT INTO `bs`.`sale` (`saleFk`, `amount`, `dated`, `typeFk`, `clientFk`)
INSERT INTO `vn`.`docuware` (`code`, `fileCabinetName`, `dialogName` , `find`)
VALUES
- ('deliveryClientTest', 'deliveryClientTest', 'findTest', 'word');
+ ('deliveryClient', 'deliveryClient', 'findTicket', 'word');
INSERT INTO `vn`.`docuwareConfig` (`url`)
VALUES
@@ -2617,3 +2619,30 @@ INSERT INTO `vn`.`supplierAgencyTerm` (`agencyFk`, `supplierFk`, `minimumPackage
(3, 2, 0, 15.00, 0.00, NULL, 0, 0.00, 0),
(4, 2, 0, 20.00, 0.00, NULL, 0, 0.00, 0),
(5, 442, 0, 0.00, 3.05, NULL, 0, 0.00, 0);
+
+INSERT INTO `vn`.`mobileAppVersionControl` (`appName`, `version`, `isVersionCritical`)
+ VALUES
+ ('delivery', '9.2', 0),
+ ('warehouse', '8.1', 0);
+
+INSERT INTO `vn`.`machine` (`plate`, `maker`, `model`, `warehouseFk`, `departmentFk`, `type`, `use`, `productionYear`, `workerFk`, `companyFk`)
+ VALUES
+ ('RE-001', 'STILL', 'LTX-20', 60, 23, 'ELECTRIC TOW', 'Drag cars', 2020, 103, 442),
+ ('RE-002', 'STILL', 'LTX-20', 60, 23, 'ELECTRIC TOW', 'Drag cars', 2020, 103, 442);
+
+INSERT INTO `vn`.`machineWorker` (`workerFk`, `machineFk`, `inTimed`, `outTimed`)
+ VALUES
+ (1106, 1, CURDATE(), CURDATE()),
+ (1106, 1, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), DATE_ADD(CURDATE(), INTERVAL +1 DAY)),
+ (1106, 2, CURDATE(), NULL),
+ (1106, 2, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), DATE_ADD(CURDATE(), INTERVAL +1 DAY));
+
+INSERT INTO `vn`.`mdbBranch` (`name`)
+ VALUES
+ ('test'),
+ ('master');
+
+INSERT INTO `vn`.`mdbVersion` (`app`, `branchFk`, `version`)
+ VALUES
+ ('tpv', 'test', '1'),
+ ('lab', 'master', '1');
\ No newline at end of file
diff --git a/db/dump/structure.sql b/db/dump/structure.sql
index c764e877e..700c06e3b 100644
--- a/db/dump/structure.sql
+++ b/db/dump/structure.sql
@@ -2674,22 +2674,6 @@ CREATE TABLE `compradores_evolution` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
---
--- Table structure for table `conveyorStats`
---
-
-DROP TABLE IF EXISTS `conveyorStats`;
-/*!40101 SET @saved_cs_client = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `conveyorStats` (
- `created` datetime NOT NULL,
- `saturacion` int(11) DEFAULT NULL,
- `velocidad` int(11) DEFAULT NULL,
- `rutas` int(11) DEFAULT NULL,
- PRIMARY KEY (`created`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-/*!40101 SET character_set_client = @saved_cs_client */;
-
--
-- Table structure for table `customerEvolution`
--
@@ -3062,21 +3046,6 @@ CREATE TABLE `nightTaskConfig` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
---
--- Table structure for table `novemberSales`
---
-
-DROP TABLE IF EXISTS `novemberSales`;
-/*!40101 SET @saved_cs_client = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `novemberSales` (
- `ticketFk` int(11) NOT NULL,
- `saleFk` int(11) NOT NULL DEFAULT 0,
- `año` int(4) DEFAULT NULL,
- `importe` decimal(28,8) DEFAULT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-/*!40101 SET character_set_client = @saved_cs_client */;
-
--
-- Temporary table structure for view `packingSpeed`
--
@@ -3190,32 +3159,6 @@ SET character_set_client = utf8;
) ENGINE=MyISAM */;
SET character_set_client = @saved_cs_client;
---
--- Table structure for table `salaries2018`
---
-
-DROP TABLE IF EXISTS `salaries2018`;
-/*!40101 SET @saved_cs_client = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `salaries2018` (
- `person_id` int(11) NOT NULL DEFAULT 0,
- `sex` enum('M','F') CHARACTER SET utf8 NOT NULL DEFAULT 'F' COMMENT 'M Masculino F Femenino',
- `edad` int(6) DEFAULT NULL,
- `antiguedad` int(6) DEFAULT NULL,
- `Modalidad` varchar(22) CHARACTER SET utf8mb4 NOT NULL DEFAULT '',
- `reason` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
- `worker` varchar(82) CHARACTER SET utf8 DEFAULT NULL,
- `totalDays` decimal(32,0) DEFAULT NULL,
- `totalAnual` decimal(16,0) DEFAULT NULL,
- `virtualMonthlySalary` decimal(16,0) DEFAULT NULL,
- `departamento` varchar(45) COLLATE utf8_unicode_ci NOT NULL,
- `category_name` varchar(50) CHARACTER SET utf8 NOT NULL,
- `level_name` varchar(5) CHARACTER SET utf8 DEFAULT NULL,
- `thisYearDateStart` varchar(10) CHARACTER SET utf8mb4 DEFAULT NULL,
- PRIMARY KEY (`person_id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-/*!40101 SET character_set_client = @saved_cs_client */;
-
--
-- Table structure for table `sale`
--
@@ -4131,43 +4074,11 @@ DELIMITER ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `carteras_add`()
BEGIN
-
-DELETE FROM bs.carteras
-WHERE Año >= YEAR(vn.VN_CURDATE()) - 1;
-
-INSERT INTO bs.carteras(Año,Mes,CodigoTrabajador,Peso)
-SELECT year as Año, month as Mes, CodigoTrabajador, sum(importe) as Peso
-FROM vn2008.time t
-JOIN bs.ventas v on t.date = v.fecha
-JOIN vn2008.Clientes c on c.Id_Cliente = v.Id_Cliente
-JOIN vn2008.Trabajadores tr on tr.Id_Trabajador = c.Id_Trabajador
-WHERE t.year >= YEAR(vn.VN_CURDATE()) - 1
-GROUP BY CodigoTrabajador, Año, Mes;
-
-
-END ;;
-DELIMITER ;
-/*!50003 SET sql_mode = @saved_sql_mode */ ;
-/*!50003 SET character_set_client = @saved_cs_client */ ;
-/*!50003 SET character_set_results = @saved_cs_results */ ;
-/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `carteras_add2` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `carteras_add2`()
-BEGIN
/**
- * Inserta en "bs.carteras".
+ * Inserta en @bs.carteras.
*/
DELETE FROM bs.carteras
- WHERE Año >= YEAR(vn.VN_CURDATE()) - 1;
+ WHERE Año >= YEAR(vn.VN_CURDATE()) - 1;
INSERT INTO bs.carteras(Año,Mes,CodigoTrabajador,Peso)
SELECT t.year AS Año, t.month AS Mes, w.code AS CodigoTrabajador, SUM(v.importe) AS Peso
@@ -4197,9 +4108,11 @@ CREATE DEFINER=`root`@`localhost` PROCEDURE `clean`()
BEGIN
DECLARE vFourYearsAgo DATETIME;
DECLARE vOneYearAgo DATETIME;
+ DECLARE vTwoYearAgo DATETIME;
- SET vFourYearsAgo = TIMESTAMPADD(YEAR, -4,vn.VN_CURDATE());
SET vOneYearAgo = TIMESTAMPADD(YEAR, -1,vn.VN_CURDATE());
+ SET vTwoYearAgo = TIMESTAMPADD(YEAR, -2,vn.VN_CURDATE());
+ SET vFourYearsAgo = TIMESTAMPADD(YEAR, -4,vn.VN_CURDATE());
DELETE FROM bs.clientNewBorn
WHERE lastShipped < vOneYearAgo;
@@ -4212,6 +4125,12 @@ BEGIN
DELETE FROM payMethodClientEvolution
WHERE dated < vFourYearsAgo;
+
+ DELETE FROM bs.salesByclientSalesPerson
+ WHERE dated < vFourYearsAgo;
+
+ DELETE FROM bs.m3
+ WHERE fecha < vTwoYearAgo;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -4624,51 +4543,14 @@ DELIMITER ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `compradores_add`(IN intYEAR INT, IN intWEEK_START INT, IN intWEEK_END INT)
-BEGIN
-
-REPLACE bs.compradores
-
-SELECT tp.Id_Trabajador
- , intYEAR as año
- , tm.week as semana
- , sum(importe) as importe
- , 0 as comision
-
-FROM bs.ventas v
-JOIN vn2008.time tm on tm.date = v.fecha
-JOIN vn2008.Tipos tp using(tipo_id)
-WHERE tm.year = intYEAR and tm.week between intWEEK_START and intWEEK_END
-AND reino_id != 6
-GROUP BY tp.Id_Trabajador, tm.week;
-
-
-
-
-END ;;
-DELIMITER ;
-/*!50003 SET sql_mode = @saved_sql_mode */ ;
-/*!50003 SET character_set_client = @saved_cs_client */ ;
-/*!50003 SET character_set_results = @saved_cs_results */ ;
-/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `compradores_add2` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `compradores_add2`(IN vYear INT, IN vWeekFrom INT, IN vWeekTo INT)
+CREATE DEFINER=`root`@`localhost` PROCEDURE `compradores_add`(IN vYear INT, IN vWeekFrom INT, IN vWeekTo INT)
BEGIN
/**
* Sustituye los registros de "bs.compradores".
*
* @param vYear: año ventas
* @param vWeekFrom: semana desde
- * @param vWeekTo: semana hastas
+ * @param vWeekTo: semana hasta
*/
REPLACE bs.compradores
SELECT it.workerFk AS Id_Trabajador, vYear AS año, tm.week AS semana, SUM(importe) AS importe, 0 AS comision
@@ -4840,91 +4722,6 @@ DELIMITER ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `fondo_evolution_add`()
BEGIN
-/*
-
-Inserta en la tabla fondo_maniobra los saldos acumulados en los ultimos 365 dias
-
-*/
-
-DECLARE datFEC DATE DEFAULT '2015-01-01';
-
-
-SELECT TIMESTAMPADD(DAY,1,MAX(fecha)) INTO datFEC FROM bs.fondo_maniobra;
-
- WHILE datFEC < vn.VN_CURDATE() DO
-
- -- esto solo sirve para no aburrirse mientras esperamos...
-
- IF day(datFEC) mod 28 = 0 then
- SELECT datFEC;
- end if;
-
-
- REPLACE bs.fondo_maniobra(Fecha, clientes_facturas, clientes_cobros,proveedores_facturas,proveedores_pagos, fondo)
- SELECT datFEC as Fecha, Facturas, Cobros,Recibidas,Pagos, Facturas + Cobros + Recibidas + Pagos
- FROM
- (
- SELECT Sum(Facturas.Importe) AS Facturas
- FROM vn2008.Facturas
- INNER JOIN vn2008.Clientes ON Facturas.Id_Cliente = Clientes.Id_cliente
- WHERE Clientes.`real`
- AND empresa_id <>1381
- AND Fecha between '2011-01-01' and datFEC) fac
- JOIN
- (
- SELECT - Sum(Entregado) AS Cobros
- FROM vn2008.Recibos
- INNER JOIN vn2008.Clientes ON Recibos.Id_Cliente = Clientes.Id_cliente
- WHERE Clientes.`real`
- AND empresa_id <> 1381
- AND Fechacobro Between '2011-01-01' and datFEC) cob
- JOIN
- (
- SELECT - Sum(cantidad) AS Recibidas
- FROM vn2008.recibida
- INNER JOIN vn2008.recibida_vencimiento ON recibida.id = recibida_vencimiento.recibida_id
- WHERE empresa_id <> 1381
- AND recibida.fecha Between '2015-01-01' and datFEC) rec
- JOIN
- (
- SELECT Sum(importe) AS Pagos
- FROM vn2008.pago
- WHERE empresa_id <>1381 AND pago.fecha Between '2015-01-01' and datFEC) pag;
-
-
-
- UPDATE bs.fondo_maniobra
- JOIN
- (SELECT avg(fondo) as media
- FROM bs.fondo_maniobra
- WHERE fecha <= datFEC) sub
- SET fondo_medio = media
- WHERE fecha = datFEC;
-
-
- SET datFEC = TIMESTAMPADD(DAY,1,datFEC);
-
- END WHILE;
-
-
-END ;;
-DELIMITER ;
-/*!50003 SET sql_mode = @saved_sql_mode */ ;
-/*!50003 SET character_set_client = @saved_cs_client */ ;
-/*!50003 SET character_set_results = @saved_cs_results */ ;
-/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `fondo_evolution_add2` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `fondo_evolution_add2`()
-BEGIN
/**
* Inserta en la tabla fondo_maniobra los saldos acumulados en los ultimos 365 dias
*/
@@ -5353,25 +5150,41 @@ DELIMITER ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `manaCustomerUpdate`()
BEGIN
-DECLARE vToDated DATE;
+ DECLARE vToDated DATE;
DECLARE vFromDated DATE;
DECLARE vForDeleteDated DATE;
- DECLARE vManaId INT DEFAULT 37;
- DECLARE vManaAutoId INT DEFAULT 39;
- DECLARE vManaBankId INT DEFAULT 66;
- DECLARE vManaGreugeTypeId INT DEFAULT 3;
+ DECLARE vManaId INT;
+ DECLARE vManaAutoId INT;
+ DECLARE vClaimManaId INT;
+ DECLARE vManaBankId INT;
+ DECLARE vManaGreugeTypeId INT;
- SELECT IFNULL(max(dated), '2016-01-01')
- INTO vFromDated
- FROM bs.manaCustomer;
+ SELECT id INTO vManaId
+ FROM vn.component WHERE code = 'mana';
+
+ SELECT id INTO vManaAutoId
+ FROM vn.component WHERE code = 'autoMana';
- DELETE
- FROM bs.manaCustomer
+ SELECT id INTO vClaimManaId
+ FROM vn.component WHERE code = 'manaClaim';
+
+ SELECT id INTO vManaBankId
+ FROM vn.bank WHERE code = 'mana';
+
+ SELECT id INTO vManaGreugeTypeId
+ FROM vn.greugeType WHERE code = 'mana';
+
+ SELECT IFNULL(MAX(dated), '2016-01-01')
+ INTO vFromDated
+ FROM vn.clientManaCache;
+
+ DELETE
+ FROM vn.clientManaCache
WHERE dated = vFromDated;
- SELECT IFNULL(max(dated), '2016-01-01')
+ SELECT IFNULL(MAX(dated), '2016-01-01')
INTO vFromDated
- FROM bs.manaCustomer;
+ FROM vn.clientManaCache;
WHILE timestampadd(DAY,30,vFromDated) < vn.VN_CURDATE() DO
@@ -5382,31 +5195,25 @@ DECLARE vToDated DATE;
vToDated,
vForDeleteDated;
- DELETE FROM bs.manaCustomer
+ DELETE FROM vn.clientManaCache
WHERE dated <= vForDeleteDated;
-
- INSERT INTO bs.manaCustomer(Id_Cliente, Mana, dated)
-
+ INSERT INTO vn.clientManaCache(clientFk, mana, dated)
SELECT
Id_Cliente,
cast(sum(mana) as decimal(10,2)) as mana,
vToDated as dated
FROM
-
(
SELECT cs.Id_Cliente, Cantidad * Valor as mana
FROM vn2008.Tickets t
JOIN vn2008.Consignatarios cs using(Id_Consigna)
JOIN vn2008.Movimientos m on m.Id_Ticket = t.Id_Ticket
JOIN vn2008.Movimientos_componentes mc on mc.Id_Movimiento = m.Id_Movimiento
- WHERE Id_Componente IN (vManaAutoId, vManaId)
+ WHERE Id_Componente IN (vManaAutoId, vManaId, vClaimManaId)
AND t.Fecha > vFromDated
AND date(t.Fecha) <= vToDated
-
-
UNION ALL
-
SELECT r.Id_Cliente, - Entregado
FROM vn2008.Recibos r
WHERE Id_Banco = vManaBankId
@@ -5414,25 +5221,21 @@ DECLARE vToDated DATE;
AND Fechacobro <= vToDated
UNION ALL
-
SELECT g.Id_Cliente, g.Importe
FROM vn2008.Greuges g
WHERE Greuges_type_id = vManaGreugeTypeId
AND Fecha > vFromDated
AND Fecha <= vToDated
-
UNION ALL
-
- SELECT Id_Cliente, mana
- FROM bs.manaCustomer
- WHERE dated = vFromDated
+ SELECT clientFk, mana
+ FROM vn.clientManaCache
+ WHERE dated = vFromDated
) sub
-
GROUP BY Id_Cliente
HAVING Id_Cliente;
SET vFromDated = vToDated;
-
+
END WHILE;
END ;;
@@ -7834,9 +7637,10 @@ proc: BEGIN
JOIN vn.entry e ON b.entryFk = e.id
JOIN vn.travel t ON t.id = e.travelFk
JOIN vn.warehouse w ON w.id = t.warehouseInFk
+ JOIN vn.supplier s ON s.id = e.supplierFk
WHERE t.landed BETWEEN vInventoryDate AND vStartDate
AND t.warehouseInFk = vWarehouse
- AND NOT e.isInventory
+ AND s.name != 'INVENTARIO'
AND NOT e.isRaid
GROUP BY b.itemFk
) c
@@ -16345,9 +16149,9 @@ DELIMITER ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_general_ci */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `order_confirmWithUser`(IN `vOrder` INT, IN `vUserId` INT)
BEGIN
@@ -16472,7 +16276,7 @@ BEGIN
SET vShipment = IFNULL(vShipment, vn.VN_CURDATE());
- CALL vn.ticketCreateWithUser(
+ CALL vn.ticket_add(
vClientId,
vShipment,
vWarehouse,
@@ -16482,6 +16286,7 @@ BEGIN
NULL,
vDelivery,
vUserId,
+ TRUE,
vTicket
);
ELSE
@@ -19048,8 +18853,9 @@ CREATE TABLE `business_labour_payroll` (
`importepactado` decimal(10,2) NOT NULL DEFAULT 0.00,
PRIMARY KEY (`business_id`),
KEY `business_labour_payroll_cod_categoria_idx` (`cod_categoria`),
- KEY `business_labour_payroll_cod_contrato` (`cod_contrato`),
+ KEY `business_labour_payroll_FK` (`cod_contrato`),
CONSTRAINT `business_labour_payroll_FK` FOREIGN KEY (`cod_contrato`) REFERENCES `vn`.`workerBusinessType` (`id`) ON UPDATE CASCADE,
+ CONSTRAINT `business_labour_payroll_cod_categoria` FOREIGN KEY (`cod_categoria`) REFERENCES `vn2008`.`payroll_categorias` (`codcategoria`) ON UPDATE CASCADE,
CONSTRAINT `business_labour_payroll_fk1` FOREIGN KEY (`business_id`) REFERENCES `business` (`business_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -25082,6 +24888,25 @@ CREATE TABLE `version` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
+--
+-- Table structure for table `versionLog`
+--
+
+DROP TABLE IF EXISTS `versionLog`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `versionLog` (
+ `code` varchar(200) COLLATE utf8_unicode_ci NOT NULL,
+ `number` char(11) COLLATE utf8_unicode_ci NOT NULL,
+ `file` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
+ `user` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
+ `updated` datetime NOT NULL,
+ `errorNumber` int(10) unsigned DEFAULT NULL,
+ `errorMessage` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
+ PRIMARY KEY (`code`,`number`,`file`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
--
-- Dumping events for database 'util'
--
@@ -26615,6 +26440,8 @@ CREATE TABLE `addressFilter` (
`isVNHSupplier` tinyint(1) DEFAULT 0 COMMENT 'corresponde al campo edi.VMPSettings.isVNHSupplier',
`isEarlyBird` tinyint(1) DEFAULT 0 COMMENT 'corresponde al campo edi.marketPlace.isEarlybird',
`warehouseFk` smallint(5) unsigned DEFAULT NULL,
+ `beforeDated` date DEFAULT NULL,
+ `afterDated` date DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `addressFilter_FK` (`provinceFk`),
KEY `addressFilter_FK_1` (`countryFk`),
@@ -26678,7 +26505,7 @@ CREATE TABLE `agency` (
`labelZone` tinyint(4) NOT NULL DEFAULT 0,
`workCenterFk` int(11) DEFAULT NULL,
`supplierFk__` int(11) DEFAULT NULL,
- `isAnyVolumeAllowed` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Permite vender productos que tengan vn.itemType.IsUnconventionalSize = TRUE',
+ `isAnyVolumeAllowed` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Permite vender productos que tengan vn.itemType.IsUnconventionalSize = TRUE',
PRIMARY KEY (`id`),
KEY `warehouse_id` (`warehouseFk`),
KEY `Id_Banco` (`bankFk`),
@@ -26786,6 +26613,26 @@ SET character_set_client = utf8;
) ENGINE=MyISAM */;
SET character_set_client = @saved_cs_client;
+--
+-- Temporary table structure for view `agencyTerm`
+--
+
+DROP TABLE IF EXISTS `agencyTerm`;
+/*!50001 DROP VIEW IF EXISTS `agencyTerm`*/;
+SET @saved_cs_client = @@character_set_client;
+SET character_set_client = utf8;
+/*!50001 CREATE TABLE `agencyTerm` (
+ `agencyFk` tinyint NOT NULL,
+ `minimumPackages` tinyint NOT NULL,
+ `kmPrice` tinyint NOT NULL,
+ `packagePrice` tinyint NOT NULL,
+ `routePrice` tinyint NOT NULL,
+ `minimumKm` tinyint NOT NULL,
+ `minimumM3` tinyint NOT NULL,
+ `m3Price` tinyint NOT NULL
+) ENGINE=MyISAM */;
+SET character_set_client = @saved_cs_client;
+
--
-- Table structure for table `agencyTermConfig`
--
@@ -26871,11 +26718,9 @@ CREATE TABLE `autoRadioConfig` (
`id` int(11) NOT NULL,
`password` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL,
`user` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL,
- `port` int(11) DEFAULT NULL,
`url` varchar(75) COLLATE utf8_unicode_ci DEFAULT NULL,
- `login` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL,
`client` int(32) DEFAULT NULL,
- `center` int(32) DEFAULT NULL,
+ `center` varchar(2) COLLATE utf8_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -27342,15 +27187,15 @@ CREATE TABLE `budgetNotes` (
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8 */ ;
-/*!50003 SET character_set_results = utf8 */ ;
-/*!50003 SET collation_connection = utf8_general_ci */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
-/*!50003 CREATE*/ /*!50017 DEFINER=`$manager`@`%`*/ /*!50003 TRIGGER budgetNotes_BeforeInsert
-BEFORE INSERT
-ON budgetNotes FOR EACH ROW
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`budgetNotes_BeforeInsert`
+ BEFORE INSERT ON `budgetNotes`
+ FOR EACH ROW
BEGIN
IF ISNULL(NEW.userFk) THEN
@@ -27486,6 +27331,7 @@ trig: BEGIN
DECLARE vGrouping INT;
DECLARE vGroupingMode TINYINT;
DECLARE vGenericFk INT;
+ DECLARE vGenericInDate BOOL;
IF @isModeInventory THEN
LEAVE trig;
@@ -27524,9 +27370,20 @@ trig: BEGIN
IF vGenericFk THEN
- SET NEW.itemOriginalFk = NEW.itemFk;
-
- SET NEW.itemFk = vGenericFk;
+ SELECT COUNT(*) INTO vGenericInDate
+ FROM vn.genericAllocation ga
+ JOIN vn.entry e ON e.id = NEW.entryFk
+ JOIN vn.travel tr on tr.id = e.travelFk
+ WHERE ga.itemFk = vGenericFk
+ AND tr.landed BETWEEN ga.startDated AND ga.endDated;
+
+ IF vGenericInDate THEN
+
+ SET NEW.itemOriginalFk = NEW.itemFk;
+
+ SET NEW.itemFk = vGenericFk;
+
+ END IF;
END IF;
@@ -27575,8 +27432,8 @@ DELIMITER ;;
BEFORE UPDATE ON `buy`
FOR EACH ROW
trig:BEGIN
-
DECLARE vGenericFk INT;
+ DECLARE vGenericInDate BOOL;
IF @isTriggerDisabled THEN
@@ -27596,12 +27453,22 @@ trig:BEGIN
IF vGenericFk THEN
- SET NEW.itemOriginalFk = NEW.itemFk;
-
- SET NEW.itemFk = vGenericFk;
+ SELECT COUNT(*) INTO vGenericInDate
+ FROM vn.genericAllocation ga
+ JOIN vn.entry e ON e.id = NEW.entryFk
+ JOIN vn.travel tr on tr.id = e.travelFk
+ WHERE ga.itemFk = vGenericFk
+ AND tr.landed BETWEEN ga.startDated AND ga.endDated;
+
+ IF vGenericInDate THEN
+
+ SET NEW.itemOriginalFk = NEW.itemFk;
+
+ SET NEW.itemFk = vGenericFk;
+
+ END IF;
END IF;
-
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -27625,6 +27492,8 @@ trig: BEGIN
DECLARE vBuyerFk INT;
DECLARE vIsBuyerToBeEmailed BOOL;
DECLARE vItemName VARCHAR(50);
+ DECLARE vIsInventory BOOL;
+ DECLARE vEmail VARCHAR(255);
IF !(NEW.id <=> OLD.id)
OR !(NEW.entryFk <=> OLD.entryFk)
@@ -27676,7 +27545,34 @@ trig: BEGIN
'Este email se ha generado automáticamente'
);
END IF;
+ END IF;
+
+ SELECT e.isInventory INTO vIsInventory
+ FROM entry e
+ WHERE e.id = NEW.entryFk;
+
+ SELECT e.mailToNotify INTO vEmail
+ FROM entryConfig e
+ LIMIT 1;
+
+ IF vIsInventory AND
+ (!(NEW.quantity <=> OLD.quantity)
+ OR !(NEW.price1<=>OLD.price1)
+ OR !(NEW.price2<=>OLD.price2)
+ OR !(NEW.price3<=>OLD.price3)) THEN
+
+ CALL mail_insert(
+ vEmail,
+ NULL,
+ CONCAT('Se ha modificado la entrada ', NEW.entryFk ,' del Artículo ', NEW.itemFk, ' siendo inventario'),
+ CONCAT(
+ 'Antes: Cantidad: ', OLD.quantity, ' Precio1: ', OLD.price1, ' Precio2: ', OLD.price2, ' Precio3: ', OLD.price3,
+ ' ',
+ 'Despues: Cantidad: ', NEW.quantity, ' Precio1: ', NEW.price1, ' Precio2: ', NEW.price2, ' Precio3: ', NEW.price3
+ )
+ );
END IF;
+
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -27929,7 +27825,7 @@ CREATE TABLE `claim` (
`created` timestamp NULL DEFAULT current_timestamp(),
`ticketFk` int(11) DEFAULT NULL,
`hasToPickUp` tinyint(1) NOT NULL,
- `packages` smallint(10) unsigned DEFAULT 0 COMMENT 'packages received by the client',
+ `packages` smallint(10) unsigned DEFAULT '0' COMMENT 'packages received by the client',
PRIMARY KEY (`id`),
KEY `cl_dep_id` (`claimDepartmentFk__`),
KEY `cl_est_id` (`claimStateFk`),
@@ -28215,9 +28111,9 @@ CREATE TABLE `claimState` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`code` varchar(45) CHARACTER SET utf8 DEFAULT NULL,
`description` varchar(15) COLLATE utf8_unicode_ci NOT NULL,
- `roleFk` int(10) unsigned NOT NULL DEFAULT 1,
- `priority` int(11) NOT NULL DEFAULT 1,
- `hasToNotify` tinyint(4) DEFAULT 0,
+ `roleFk` int(10) unsigned NOT NULL DEFAULT '1',
+ `priority` int(11) NOT NULL DEFAULT '1',
+ `hasToNotify` tinyint(4) DEFAULT '0',
PRIMARY KEY (`id`),
KEY `roleFgn_idx` (`roleFk`),
CONSTRAINT `roleFgn` FOREIGN KEY (`roleFk`) REFERENCES `account`.`role` (`id`) ON UPDATE CASCADE
@@ -28613,6 +28509,46 @@ CREATE TABLE `clientDms` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
+--
+-- Table structure for table `clientItemCategory`
+--
+
+DROP TABLE IF EXISTS `clientItemCategory`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `clientItemCategory` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `clientFk` int(11) NOT NULL,
+ `itemCategoryFk` int(10) unsigned NOT NULL,
+ PRIMARY KEY (`id`),
+ KEY `clientItemCategory_FK` (`clientFk`),
+ KEY `clientItemCategory_FK_1` (`itemCategoryFk`),
+ CONSTRAINT `clientItemCategory_FK` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `clientItemCategory_FK_1` FOREIGN KEY (`itemCategoryFk`) REFERENCES `itemCategory` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Table structure for table `clientItemType`
+--
+
+DROP TABLE IF EXISTS `clientItemType`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `clientItemType` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ `clientFk` int(11) NOT NULL,
+ `itemTypeFk` varchar(3) COLLATE utf8_unicode_ci NOT NULL,
+ `isAllowed` tinyint(1) DEFAULT '0',
+ PRIMARY KEY (`id`),
+ KEY `clientItemType_FK` (`clientFk`),
+ KEY `clientItemType_FK_1` (`itemTypeFk`),
+ CONSTRAINT `clientItemType_FK` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `clientItemType_FK_1` FOREIGN KEY (`itemTypeFk`) REFERENCES `itemType` (`code`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='son familias de productos que se quieren sustraer a la oferta del cliente';
+/*!40101 SET character_set_client = @saved_cs_client */;
+
--
-- Table structure for table `clientLog`
--
@@ -28900,6 +28836,7 @@ CREATE TABLE `cmr` (
`merchandiseDetail` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`state` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
`landed` datetime DEFAULT NULL COMMENT 'Hora de llegada a destino',
+ `ead` datetime DEFAULT NULL COMMENT 'Estimated Arriving Date',
PRIMARY KEY (`id`),
KEY `cmr_fk1_idx` (`ticketFk`),
KEY `cmr_fk2_idx` (`companyFk`),
@@ -28962,7 +28899,8 @@ DROP TABLE IF EXISTS `cmrConfig`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `cmrConfig` (
- `dayOfMonth` int(11) DEFAULT NULL
+ `dayOfMonth` int(11) DEFAULT NULL,
+ `landingDays` tinyint(4) NOT NULL DEFAULT '1'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -29619,6 +29557,7 @@ CREATE TABLE `country` (
`isUeeMember` tinyint(4) NOT NULL DEFAULT 0,
`ibanLength` tinyint(4) DEFAULT NULL,
`continentFk` tinyint(4) DEFAULT NULL,
+ `a3Code` int(11) DEFAULT NULL COMMENT 'Código país para a3',
PRIMARY KEY (`id`),
KEY `Id_Paisreal` (`politicalCountryFk`),
KEY `currency_id_fk_idx` (`currencyFk`),
@@ -30140,15 +30079,18 @@ CREATE TABLE `department` (
`chatName` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL,
`isTeleworking` tinyint(1) DEFAULT 0,
`notificationEmail` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL,
- `hasToRefill` tinyint(1) DEFAULT 0 COMMENT 'Rellenar días sin fichadas presenciales',
- `hasToSendMail` tinyint(1) DEFAULT 0 COMMENT 'Para el envio de mail en el procedimiento workerTimeControl_sendMail()',
- `hasToCheckLogin` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Para comprobar en el login de la app',
- `hasToMistake` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Indica si al departamento pueden serles puestos errores',
+ `hasToRefill` tinyint(1) DEFAULT '0' COMMENT 'Rellenar días sin fichadas presenciales',
+ `hasToSendMail` tinyint(1) DEFAULT '0' COMMENT 'Para el envio de mail en el procedimiento workerTimeControl_sendMail()',
+ `hasToCheckLogin` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Para comprobar en el login de la app',
+ `hasToMistake` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Indica si al departamento pueden serles puestos errores',
+ `clientFk` int(11) DEFAULT NULL COMMENT 'Cuenta de cliente que se utiliza para los compras de consumo departamental',
PRIMARY KEY (`id`),
UNIQUE KEY `name_UNIQUE` (`name`),
KEY `fk_department_Trabajadores1_idx` (`workerFk`),
KEY `dep_org_ibfk_3_idx` (`companyFk`),
KEY `lft_rgt_depth_idx` (`lft`,`rgt`,`depth`),
+ KEY `department_FK` (`clientFk`),
+ CONSTRAINT `department_FK` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `fk_department_Trabajadores1` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -31147,6 +31089,7 @@ DROP TABLE IF EXISTS `entryConfig`;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `entryConfig` (
`defaultEntry` int(11) NOT NULL,
+ `mailToNotify` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
PRIMARY KEY (`defaultEntry`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -32261,6 +32204,10 @@ CREATE TABLE `genericAllocation` (
`numFlores` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL,
`category` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`productor` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
+ `longName` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
+ `size` int(11) DEFAULT NULL,
+ `startDated` date DEFAULT NULL,
+ `endDated` date DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `genericAllocation_FK` (`itemFk`),
KEY `genericAllocation_FK_1` (`typeFk`),
@@ -32270,6 +32217,8 @@ CREATE TABLE `genericAllocation` (
KEY `genericAllocation_numFlores_IDX` (`numFlores`) USING BTREE,
KEY `genericAllocation_category_IDX` (`category`) USING BTREE,
KEY `genericAllocation_productor_IDX` (`productor`) USING BTREE,
+ KEY `genericAllocation_longName_IDX` (`longName`) USING BTREE,
+ KEY `genericAllocation_size_IDX` (`size`) USING BTREE,
CONSTRAINT `genericAllocation_FK` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Almacena los filtros para asignar códigos genéricos a los items';
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -32473,33 +32422,35 @@ DROP TABLE IF EXISTS `host`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `host` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
`code` varchar(30) CHARACTER SET utf8 NOT NULL,
`description` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`workerFk` int(10) unsigned DEFAULT NULL,
`windowsSerial` varchar(40) COLLATE utf8_unicode_ci DEFAULT NULL,
`printerFk` tinyint(3) unsigned DEFAULT NULL,
- `itemPackingTypeFk` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL,
- `packingSite` tinyint(3) unsigned DEFAULT NULL,
- `warehouseFk` smallint(5) unsigned DEFAULT 60,
- `companyFk` smallint(5) unsigned DEFAULT 442,
- `bankFk` int(11) DEFAULT 13,
- `routeDaysBefore` smallint(6) DEFAULT 2,
- `routeDaysAfter` smallint(6) DEFAULT 1,
- `updated` timestamp NULL DEFAULT current_timestamp(),
- PRIMARY KEY (`code`),
+ `itemPackingTypeFk__` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL,
+ `packingSite__` tinyint(3) unsigned DEFAULT NULL,
+ `warehouseFk` smallint(5) unsigned DEFAULT '60',
+ `companyFk` smallint(5) unsigned DEFAULT '442',
+ `bankFk` int(11) DEFAULT '13',
+ `routeDaysBefore` smallint(6) DEFAULT '2',
+ `routeDaysAfter` smallint(6) DEFAULT '1',
+ `updated` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `host_UN` (`code`),
KEY `configHost_FK_3` (`companyFk`),
KEY `configHost_FK` (`printerFk`),
- KEY `configHost_FK_1` (`itemPackingTypeFk`),
+ KEY `configHost_FK_1` (`itemPackingTypeFk__`),
KEY `configHost_FK_2` (`warehouseFk`),
KEY `configHost_FK_4` (`bankFk`),
KEY `configHost_FK_5` (`workerFk`),
CONSTRAINT `configHost_FK` FOREIGN KEY (`printerFk`) REFERENCES `printer` (`id`) ON UPDATE CASCADE,
- CONSTRAINT `configHost_FK_1` FOREIGN KEY (`itemPackingTypeFk`) REFERENCES `itemPackingType` (`code`) ON UPDATE CASCADE,
+ CONSTRAINT `configHost_FK_1` FOREIGN KEY (`itemPackingTypeFk__`) REFERENCES `itemPackingType` (`code`) ON UPDATE CASCADE,
CONSTRAINT `configHost_FK_2` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE,
CONSTRAINT `configHost_FK_3` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON UPDATE CASCADE,
CONSTRAINT `configHost_FK_4` FOREIGN KEY (`bankFk`) REFERENCES `accounting` (`id`) ON UPDATE CASCADE,
CONSTRAINT `configHost_FK_5` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -33040,7 +32991,7 @@ CREATE TABLE `invoiceInIntrastat` (
PRIMARY KEY (`id`),
KEY `intrastat_id` (`intrastatFk`),
KEY `invoiceInIntrastat_FK` (`invoiceInFk`),
- CONSTRAINT `invoiceInIntrastat_FK` FOREIGN KEY (`invoiceInFk`) REFERENCES `invoiceIn` (`id`),
+ CONSTRAINT `invoiceInIntrastat_FK` FOREIGN KEY (`invoiceInFk`) REFERENCES `invoiceIn` (`id`) ON DELETE CASCADE,
CONSTRAINT `invoiceInIntrastat_ibfk_1` FOREIGN KEY (`intrastatFk`) REFERENCES `intrastat` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -33520,10 +33471,10 @@ CREATE TABLE `item` (
`minimum` decimal(10,0) unsigned NOT NULL DEFAULT 3 COMMENT 'Cantidad máxima de cajas / cubos que cabe en un nicho',
`upToDown` decimal(10,0) unsigned NOT NULL DEFAULT 0 COMMENT 'Se muestra el precio por kilo ',
`supplyResponseFk` int(11) DEFAULT NULL,
- `hasKgPrice` tinyint(1) NOT NULL DEFAULT 0,
- `sectorFk` int(11) DEFAULT 2,
- `isFloramondo` tinyint(1) NOT NULL DEFAULT 0,
- `isFragile` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'articulos solo para recogidas por su fragilidad',
+ `hasKgPrice` tinyint(1) NOT NULL DEFAULT '0',
+ `sectorFk` int(11) DEFAULT NULL,
+ `isFloramondo` tinyint(1) NOT NULL DEFAULT '0',
+ `isFragile` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'articulos solo para recogidas por su fragilidad',
`numberOfItemsPerCask` int(11) DEFAULT NULL COMMENT 'Campo para Floramondo',
`embalageCode` int(11) DEFAULT NULL COMMENT 'Campo para Floramondo',
`quality` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Campo para Floramondo',
@@ -33550,6 +33501,8 @@ CREATE TABLE `item` (
KEY `item_id12` (`quality`),
KEY `item_family` (`family`),
KEY `item_FK` (`genericFk`),
+ KEY `item_size_IDX` (`size`) USING BTREE,
+ KEY `item_size_IDX2` (`longName`) USING BTREE,
CONSTRAINT `item_FK` FOREIGN KEY (`genericFk`) REFERENCES `item` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
CONSTRAINT `item_expenceFk` FOREIGN KEY (`expenceFk`) REFERENCES `expence` (`id`) ON UPDATE CASCADE,
CONSTRAINT `item_family` FOREIGN KEY (`family`) REFERENCES `itemFamily` (`code`) ON UPDATE CASCADE,
@@ -33800,11 +33753,14 @@ CREATE TABLE `itemCategory` (
`merchandise` tinyint(1) NOT NULL DEFAULT 1,
`icon` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL,
`code` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL,
- `isReclining` tinyint(4) NOT NULL DEFAULT 1,
+ `isReclining` tinyint(4) NOT NULL DEFAULT '1',
+ `departmentFk` int(11) DEFAULT NULL COMMENT 'Departamento responsable del manufacturado de esta categoria',
PRIMARY KEY (`id`),
UNIQUE KEY `reino_UNIQUE` (`name`),
KEY `itemCategory_idx3` (`merchandise`),
- KEY `itemCategoryDisplayIdx` (`display`)
+ KEY `itemCategoryDisplayIdx` (`display`),
+ KEY `itemCategory_FK` (`departmentFk`),
+ CONSTRAINT `itemCategory_FK` FOREIGN KEY (`departmentFk`) REFERENCES `department` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
@@ -33874,6 +33830,18 @@ SET character_set_client = utf8;
) ENGINE=MyISAM */;
SET character_set_client = @saved_cs_client;
+--
+-- Table structure for table `itemConfig`
+--
+
+DROP TABLE IF EXISTS `itemConfig`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `itemConfig` (
+ `isItemTagTriggerDisabled` tinyint(1) NOT NULL DEFAULT '1'
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
--
-- Table structure for table `itemConversor__`
--
@@ -34344,16 +34312,16 @@ CREATE TABLE `itemShelving` (
`itemFk` int(11) NOT NULL,
`shelvingFk` varchar(10) CHARACTER SET utf8 NOT NULL,
`shelve` varchar(2) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'A',
- `deep` int(11) unsigned NOT NULL DEFAULT 1,
- `quantity` int(11) NOT NULL DEFAULT 0,
- `visible` int(11) NOT NULL DEFAULT 0,
- `available` int(11) NOT NULL DEFAULT 0,
- `created` timestamp NOT NULL DEFAULT current_timestamp(),
+ `deep__` int(11) unsigned NOT NULL DEFAULT '1',
+ `quantity__` int(11) NOT NULL DEFAULT '0',
+ `visible` int(11) NOT NULL DEFAULT '0',
+ `available__` int(11) NOT NULL DEFAULT '0',
+ `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`priority` int(11) unsigned DEFAULT NULL COMMENT 'El 0 es la mínima prioridad',
`grouping` smallint(5) unsigned DEFAULT NULL,
`packing` int(11) unsigned DEFAULT NULL,
`packagingFk` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL,
- `level` varchar(45) COLLATE utf8_unicode_ci NOT NULL DEFAULT '1',
+ `level__` varchar(45) COLLATE utf8_unicode_ci NOT NULL DEFAULT '1',
`userFk` int(10) unsigned DEFAULT NULL,
`stars` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
@@ -34401,29 +34369,25 @@ DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemShelving_AFTER_INSERT`
AFTER INSERT ON `itemShelving`
FOR EACH ROW
-INSERT INTO vn.itemShelvingLog(itemShelvingFk,
- workerFk,
- accion,
- itemFk,
- shelvingFk,
- quantity,
- available,
- visible,
- `grouping`,
- packing,
- stars)
- VALUES( NEW.id,
- NEW.userFk,
- 'CREA REGISTRO',
- NEW.itemFk,
- NEW.shelvingFk,
- NEW.quantity,
- NEW.available,
- NEW.visible,
- NEW.`grouping`,
- NEW.packing,
- NEW.stars
- ) */;;
+INSERT INTO vn.itemShelvingLog( itemShelvingFk,
+ workerFk,
+ accion,
+ itemFk,
+ shelvingFk,
+ visible,
+ `grouping`,
+ packing,
+ stars)
+ VALUES( NEW.id,
+ NEW.userFk,
+ 'CREA REGISTRO',
+ NEW.itemFk,
+ NEW.shelvingFk,
+ NEW.visible,
+ NEW.`grouping`,
+ NEW.packing,
+ NEW.stars
+ ) */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
@@ -34461,29 +34425,25 @@ DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemShelving_AFTER_UPDATE`
AFTER UPDATE ON `itemShelving`
FOR EACH ROW
-INSERT INTO vn.itemShelvingLog(itemShelvingFk,
- workerFk,
- accion,
- itemFk,
- shelvingFk,
- quantity,
- available,
- visible,
- `grouping`,
- packing,
- stars)
- VALUES( NEW.id,
- account.userGetId(),
- 'CAMBIO',
- NEW.itemFk,
- NEW.shelvingFk,
- NEW.quantity,
- NEW.available,
- NEW.visible,
- NEW.`grouping`,
- NEW.packing,
- NEW.stars
- ) */;;
+INSERT INTO vn.itemShelvingLog( itemShelvingFk,
+ workerFk,
+ accion,
+ itemFk,
+ shelvingFk,
+ visible,
+ `grouping`,
+ packing,
+ stars)
+ VALUES( NEW.id,
+ account.userGetId(),
+ 'CAMBIO',
+ NEW.itemFk,
+ NEW.shelvingFk,
+ NEW.visible,
+ NEW.`grouping`,
+ NEW.packing,
+ NEW.stars
+ ) */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
@@ -34635,7 +34595,6 @@ SET character_set_client = utf8;
/*!50001 CREATE TABLE `itemShelvingPlacementSupplyStock` (
`itemShelvingFk` tinyint NOT NULL,
`itemFk` tinyint NOT NULL,
- `quantity` tinyint NOT NULL,
`packing` tinyint NOT NULL,
`stock` tinyint NOT NULL,
`longName` tinyint NOT NULL,
@@ -34650,30 +34609,6 @@ SET character_set_client = utf8;
) ENGINE=MyISAM */;
SET character_set_client = @saved_cs_client;
---
--- Temporary table structure for view `itemShelvingPlacementSupplyStock__`
---
-
-DROP TABLE IF EXISTS `itemShelvingPlacementSupplyStock__`;
-/*!50001 DROP VIEW IF EXISTS `itemShelvingPlacementSupplyStock__`*/;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
-/*!50001 CREATE TABLE `itemShelvingPlacementSupplyStock__` (
- `itemShelvingFk` tinyint NOT NULL,
- `itemFk` tinyint NOT NULL,
- `quantity` tinyint NOT NULL,
- `packing` tinyint NOT NULL,
- `stock` tinyint NOT NULL,
- `longName` tinyint NOT NULL,
- `size` tinyint NOT NULL,
- `subName` tinyint NOT NULL,
- `shelving` tinyint NOT NULL,
- `parking` tinyint NOT NULL,
- `created` tinyint NOT NULL,
- `priority` tinyint NOT NULL
-) ENGINE=MyISAM */;
-SET character_set_client = @saved_cs_client;
-
--
-- Table structure for table `itemShelvingSale`
--
@@ -34715,30 +34650,6 @@ BEGIN
SET isPicked = TRUE
WHERE id = NEW.saleFk;
-END */;;
-DELIMITER ;
-/*!50003 SET sql_mode = @saved_sql_mode */ ;
-/*!50003 SET character_set_client = @saved_cs_client */ ;
-/*!50003 SET character_set_results = @saved_cs_results */ ;
-/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-DELIMITER ;;
-/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemShelvingSale_AFTER_DELETE`
- AFTER DELETE ON `itemShelvingSale`
- FOR EACH ROW
-BEGIN
-
- UPDATE vn.itemShelving
- SET visible = visible + OLD.quantity
- WHERE itemShelving.id = OLD.itemShelvingFk;
-
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -34904,7 +34815,12 @@ DELIMITER ;;
FOR EACH ROW
trig: BEGIN
DECLARE vItemFk INT;
- IF @isTriggerDisabled THEN
+ DECLARE visTriggerDisabled BOOL;
+
+ SELECT isItemTagTriggerDisabled INTO visTriggerDisabled
+ FROM vn.itemConfig;
+
+ IF @isTriggerDisabled OR visTriggerDisabled THEN
LEAVE trig;
END IF;
@@ -34957,7 +34873,12 @@ DELIMITER ;;
FOR EACH ROW
trig: BEGIN
DECLARE vItemFk INT;
- IF @isTriggerDisabled THEN
+ DECLARE visTriggerDisabled BOOL;
+
+ SELECT isItemTagTriggerDisabled INTO visTriggerDisabled
+ FROM vn.itemConfig;
+
+ IF @isTriggerDisabled OR visTriggerDisabled THEN
LEAVE trig;
END IF;
@@ -34988,7 +34909,12 @@ DELIMITER ;;
FOR EACH ROW
trig: BEGIN
DECLARE vItemFk INT;
- IF @isTriggerDisabled THEN
+ DECLARE visTriggerDisabled BOOL;
+
+ SELECT isItemTagTriggerDisabled INTO visTriggerDisabled
+ FROM vn.itemConfig;
+
+ IF @isTriggerDisabled OR visTriggerDisabled THEN
LEAVE trig;
END IF;
@@ -35841,7 +35767,7 @@ CREATE TABLE `mrw` (
`shipped` date DEFAULT NULL,
`price` decimal(10,2) DEFAULT NULL,
PRIMARY KEY (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
@@ -36161,19 +36087,25 @@ CREATE TABLE `packagingGifts` (
/*!40101 SET character_set_client = @saved_cs_client */;
--
--- Temporary table structure for view `packingSite`
+-- Table structure for table `packingSite`
--
DROP TABLE IF EXISTS `packingSite`;
-/*!50001 DROP VIEW IF EXISTS `packingSite`*/;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
-/*!50001 CREATE TABLE `packingSite` (
- `hostFk` tinyint NOT NULL,
- `printerFk` tinyint NOT NULL,
- `code` tinyint NOT NULL
-) ENGINE=MyISAM */;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `packingSite` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `code` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL,
+ `hostFk` int(11) NOT NULL,
+ `printerFk` tinyint(3) unsigned DEFAULT NULL,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `packingSite_UN` (`code`),
+ KEY `packingSite_FK_1` (`printerFk`),
+ KEY `packingSite_FK` (`hostFk`),
+ CONSTRAINT `packingSite_FK` FOREIGN KEY (`hostFk`) REFERENCES `host` (`id`),
+ CONSTRAINT `packingSite_FK_1` FOREIGN KEY (`printerFk`) REFERENCES `printer` (`id`)
+) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `packingSiteLog`
@@ -36184,8 +36116,7 @@ DROP TABLE IF EXISTS `packingSiteLog`;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `packingSiteLog` (
`id` int(11) NOT NULL AUTO_INCREMENT,
- `itemPackingTypeFk` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL,
- `packingSite` tinyint(3) unsigned DEFAULT NULL,
+ `packingSiteFk` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL,
`hostFk` varchar(15) COLLATE utf8_unicode_ci NOT NULL,
`workerFk` int(10) unsigned NOT NULL,
`printerModelFk` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
@@ -36195,12 +36126,12 @@ CREATE TABLE `packingSiteLog` (
PRIMARY KEY (`id`),
UNIQUE KEY `packingSiteLog_UN` (`id`),
KEY `packingSiteLog_FK` (`workerFk`),
- KEY `packingSiteLog_FK_3` (`itemPackingTypeFk`),
KEY `packingSiteLog_FK_4` (`typeErrorFk`),
KEY `packingSiteLog_FK_1` (`printerModelFk`),
+ KEY `packingSiteLog_FK_2` (`packingSiteFk`),
CONSTRAINT `packingSiteLog_FK` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`),
CONSTRAINT `packingSiteLog_FK_1` FOREIGN KEY (`printerModelFk`) REFERENCES `printerModel` (`code`) ON UPDATE CASCADE,
- CONSTRAINT `packingSiteLog_FK_3` FOREIGN KEY (`itemPackingTypeFk`) REFERENCES `itemPackingType` (`code`) ON UPDATE CASCADE,
+ CONSTRAINT `packingSiteLog_FK_2` FOREIGN KEY (`packingSiteFk`) REFERENCES `packingSite` (`code`) ON UPDATE CASCADE,
CONSTRAINT `packingSiteLog_FK_4` FOREIGN KEY (`typeErrorFk`) REFERENCES `packingSiteTypeError` (`code`) ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -36219,25 +36150,6 @@ CREATE TABLE `packingSiteTypeError` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
---
--- Table structure for table `packingSite__`
---
-
-DROP TABLE IF EXISTS `packingSite__`;
-/*!40101 SET @saved_cs_client = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `packingSite__` (
- `code` varchar(10) COLLATE utf8_unicode_ci NOT NULL,
- `hostFk` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL,
- `printerFk` tinyint(3) unsigned DEFAULT NULL,
- PRIMARY KEY (`code`),
- KEY `packingSite_FK` (`hostFk`),
- KEY `packingSite_FK_1` (`printerFk`),
- CONSTRAINT `packingSite_FK` FOREIGN KEY (`hostFk`) REFERENCES `vn2008`.`config_host__` (`config_host_id`),
- CONSTRAINT `packingSite_FK_1` FOREIGN KEY (`printerFk`) REFERENCES `printer` (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-/*!40101 SET character_set_client = @saved_cs_client */;
-
--
-- Table structure for table `parking`
--
@@ -37099,7 +37011,6 @@ CREATE TABLE `printServerQueue` (
`created` timestamp NOT NULL DEFAULT current_timestamp(),
`reportFk__` tinyint(3) unsigned DEFAULT NULL,
PRIMARY KEY (`id`),
- UNIQUE KEY `Id_Impresora_2` (`printerFk`,`priorityFk`,`labelReportFk`,`statusFk`,`param1`,`workerFk`,`param2`),
KEY `Id_estado` (`statusFk`),
KEY `Id_Impresora` (`printerFk`),
KEY `Id_Prioridad` (`priorityFk`),
@@ -37107,8 +37018,8 @@ CREATE TABLE `printServerQueue` (
KEY `printServerQueue_FK` (`labelReportFk`),
CONSTRAINT `printServerQueue_FK` FOREIGN KEY (`labelReportFk`) REFERENCES `labelReport` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `printServerQueue_ibfk_3` FOREIGN KEY (`priorityFk`) REFERENCES `queuePriority` (`id`) ON UPDATE CASCADE,
- CONSTRAINT `printServerQueue_ibfk_4` FOREIGN KEY (`printerFk`) REFERENCES `vn2008`.`Impresoras__` (`Id_Impresora`) ON UPDATE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+ CONSTRAINT `printServerQueue_printerFk` FOREIGN KEY (`printerFk`) REFERENCES `printer` (`id`) ON UPDATE CASCADE
+) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
@@ -37154,6 +37065,49 @@ CREATE TABLE `printerModel` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
+--
+-- Temporary table structure for view `printer__`
+--
+
+DROP TABLE IF EXISTS `printer__`;
+/*!50001 DROP VIEW IF EXISTS `printer__`*/;
+SET @saved_cs_client = @@character_set_client;
+SET character_set_client = utf8;
+/*!50001 CREATE TABLE `printer__` (
+ `id` tinyint NOT NULL,
+ `path` tinyint NOT NULL,
+ `name` tinyint NOT NULL,
+ `reference` tinyint NOT NULL,
+ `isLabeler` tinyint NOT NULL,
+ `description` tinyint NOT NULL
+) ENGINE=MyISAM */;
+SET character_set_client = @saved_cs_client;
+
+--
+-- Temporary table structure for view `printer`
+--
+
+DROP TABLE IF EXISTS `printer`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `printer` (
+ `id` tinyint(3) unsigned NOT NULL,
+ `name` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
+ `path` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
+ `modelFk` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
+ `macWifi` varchar(20) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
+ `ipAddress` varchar(15) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
+ `reference` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
+ `isLabeler` tinyint(1) DEFAULT 0 COMMENT 'Indica si es impresora de etiquetas',
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `printer_UN` (`reference`),
+ UNIQUE KEY `printer_UN1` (`macWifi`),
+ UNIQUE KEY `printer_UN2` (`name`),
+ KEY `printer_FK` (`modelFk`),
+ CONSTRAINT `printer_FK` FOREIGN KEY (`modelFk`) REFERENCES `printerModel` (`code`) ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
--
-- Table structure for table `printingQueueCheck`
--
@@ -37194,12 +37148,18 @@ DROP TABLE IF EXISTS `productionConfig`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `productionConfig` (
- `isPreviousPreparationRequired` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Impide que los sacadores reciban tickets que tengan productos de prep previa',
- `ticketPrintedMax` int(10) unsigned NOT NULL DEFAULT 8 COMMENT 'numero máxido de tickets por carro que se ponen en impreso al pedir colección',
- `ticketTrolleyMax` int(10) unsigned NOT NULL DEFAULT 4 COMMENT 'numero máximo de tickets por carro para asignar baldas en una colección',
- `rookieDays` int(11) NOT NULL DEFAULT 3 COMMENT 'dias en que se cuida con especial cuidado los pedidos de un cliente por ser nuevo o recuperado',
- `notBuyingMonths` int(11) NOT NULL DEFAULT 3 COMMENT 'numero de meses que han de pasar desde su ultima compra para considerar nueva la siguiente compra',
- `id` int(11) NOT NULL DEFAULT 1,
+ `isPreviousPreparationRequired` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Impide que los sacadores reciban tickets que tengan productos de prep previa',
+ `ticketPrintedMax` int(10) unsigned NOT NULL DEFAULT '8' COMMENT 'numero máxido de tickets por carro que se ponen en impreso al pedir colección',
+ `ticketTrolleyMax` int(10) unsigned NOT NULL DEFAULT '4' COMMENT 'numero máximo de tickets por carro para asignar baldas en una colección',
+ `rookieDays` int(11) NOT NULL DEFAULT '3' COMMENT 'dias en que se cuida con especial cuidado los pedidos de un cliente por ser nuevo o recuperado',
+ `notBuyingMonths` int(11) NOT NULL DEFAULT '3' COMMENT 'numero de meses que han de pasar desde su ultima compra para considerar nueva la siguiente compra',
+ `id` int(11) NOT NULL DEFAULT '1',
+ `isZoneClosedByExpeditionActivated` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'activa el procedimiento vn.zone_getClosed',
+ `maxNotReadyCollections` int(11) NOT NULL DEFAULT '5',
+ `minTicketsToCloseZone` int(11) DEFAULT '15' COMMENT 'mínimo numero de tickets que deben de tener expediciones para cerrar una zona',
+ `movingTicketDelRoute` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'Si está activo, al cambiar la fecha de un ticket desde el F11, le quita la ruta',
+ `defaultZone` int(11) NOT NULL DEFAULT '697',
+ `defautlAgencyMode` int(11) NOT NULL DEFAULT '1328' COMMENT 'SENDING',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Recoge los parámetros que condicionan la producción';
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -37442,14 +37402,14 @@ DROP TABLE IF EXISTS `propertyNotes`;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `propertyNotes` (
`id` int(11) NOT NULL AUTO_INCREMENT,
- `propertyFk` int(10) unsigned NOT NULL,
- `created` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
+ `propertyFk` int(11) NOT NULL,
+ `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`note` text COLLATE utf8_unicode_ci NOT NULL,
`userFk` int(10) unsigned DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `propertyNotes_FK_1` (`userFk`),
KEY `propertyNotes_FK` (`propertyFk`),
- CONSTRAINT `propertyNotes_FK` FOREIGN KEY (`propertyFk`) REFERENCES `account`.`user` (`id`),
+ CONSTRAINT `propertyNotes_FK` FOREIGN KEY (`propertyFk`) REFERENCES `property` (`id`),
CONSTRAINT `propertyNotes_FK_1` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -38501,32 +38461,20 @@ BEGIN
'Este email se ha generado automáticamente' )
);
END IF;
- END IF;
-
- IF !(ABS(NEW.isPicked) <=> ABS(OLD.isPicked)) AND NEW.quantity > 0 THEN
-
- UPDATE vn.collection c
- JOIN vn.ticketCollection tc ON tc.collectionFk = c.id AND tc.ticketFk = NEW.ticketFk
- /*JOIN vn.item i ON i.id = NEW.itemFk
- AND (c.itemPackingTypeFk = i.itemPackingTypeFk
- OR ISNULL(c.itemPackingTypeFk))*/
- SET c.salePickedCount = c.salePickedCount + IF(NEW.isPicked != 0, 1, -1);
-
-
- END IF;
-
- IF !(NEW.quantity <=> OLD.quantity) AND (NEW.quantity = 0 OR OLD.quantity = 0) THEN
-
- UPDATE vn.collection c
- JOIN vn.ticketCollection tc ON tc.collectionFk = c.id AND tc.ticketFk = NEW.ticketFk
- /*JOIN vn.item i ON i.id = NEW.itemFk
- AND (c.itemPackingTypeFk = i.itemPackingTypeFk
- OR ISNULL(c.itemPackingTypeFk))*/
- SET c.saleTotalCount = c.saleTotalCount + IF(OLD.quantity = 0, 1, -1);
-
- END IF;
-
- IF !(NEW.quantity <=> OLD.quantity) THEN
+ IF (OLD.quantity > NEW.quantity) THEN
+ INSERT INTO saleComponent(saleFk, componentFk, value)
+ SELECT NEW.id, cm.id, sc.value
+ FROM saleComponent sc
+ JOIN component cd ON cd.id = sc.componentFk
+ JOIN component cm ON cm.code = 'mana'
+ WHERE saleFk = NEW.id AND cd.code = 'lastUnitsDiscount'
+ ON DUPLICATE KEY UPDATE value = sc.value + VALUES(value);
+
+ DELETE sc.*
+ FROM vn.saleComponent sc
+ JOIN component c ON c.id = sc.componentFk
+ WHERE saleFk = NEW.id AND c.code = 'lastUnitsDiscount';
+ END IF;
INSERT IGNORE INTO `vn`.`routeRecalc` (`routeFk`)
SELECT r.id
FROM vn.sale s
@@ -38537,6 +38485,22 @@ BEGIN
AND r.created >= vn.VN_CURDATE()
GROUP BY r.id;
END IF;
+
+ IF !(ABS(NEW.isPicked) <=> ABS(OLD.isPicked)) AND NEW.quantity > 0 THEN
+
+ UPDATE vn.collection c
+ JOIN vn.ticketCollection tc ON tc.collectionFk = c.id AND tc.ticketFk = NEW.ticketFk
+ SET c.salePickedCount = c.salePickedCount + IF(NEW.isPicked != 0, 1, -1);
+
+ END IF;
+
+ IF !(NEW.quantity <=> OLD.quantity) AND (NEW.quantity = 0 OR OLD.quantity = 0) THEN
+
+ UPDATE vn.collection c
+ JOIN vn.ticketCollection tc ON tc.collectionFk = c.id AND tc.ticketFk = NEW.ticketFk
+ SET c.saleTotalCount = c.saleTotalCount + IF(OLD.quantity = 0, 1, -1);
+
+ END IF;
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -38782,8 +38746,8 @@ CREATE TABLE `saleGoal` (
`rank` smallint(6) NOT NULL,
`walletWeightFrom` int(11) NOT NULL,
`walletWeightTo` int(11) DEFAULT NULL,
- `goal` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
- `goalType` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL,
+ `goal` decimal(10,2) DEFAULT NULL,
+ `goalType` smallint(6) DEFAULT NULL COMMENT 'grado',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -40014,14 +39978,14 @@ CREATE TABLE `state` (
`code` varchar(45) CHARACTER SET utf8 NOT NULL,
`sectorProdPriority` tinyint(3) DEFAULT NULL,
`nextStateFk` tinyint(4) NOT NULL COMMENT 'Estado al que tiene que cambiar el ticket despues de preparacion previa',
- `isPreviousPreparable` tinyint(1) NOT NULL DEFAULT 0,
- `isPicked` tinyint(1) NOT NULL DEFAULT 0,
- `isPreparable` tinyint(1) NOT NULL DEFAULT 0,
- `semaphore` int(11) NOT NULL DEFAULT 0,
- `isPrintable` tinyint(4) NOT NULL DEFAULT 0,
- `isOK` tinyint(4) NOT NULL DEFAULT 0,
- `graphCategory` int(11) NOT NULL DEFAULT 0,
- `isNotValidated` tinyint(1) DEFAULT 0 COMMENT 'Los tienen que ser validados por un comercial para prepararse',
+ `isPreviousPreparable` tinyint(1) NOT NULL DEFAULT '0',
+ `isPicked` tinyint(1) NOT NULL DEFAULT '0',
+ `isPreparable` tinyint(1) NOT NULL DEFAULT '0',
+ `semaphore` int(11) NOT NULL DEFAULT '0',
+ `isPrintable` tinyint(4) NOT NULL DEFAULT '0',
+ `isOK` tinyint(4) NOT NULL DEFAULT '0',
+ `graphCategory` int(11) NOT NULL DEFAULT '0',
+ `isNotValidated` tinyint(1) DEFAULT '0' COMMENT 'Los tienen que ser validados por un comercial para prepararse',
`classColor` varchar(12) COLLATE utf8_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `code_UNIQUE` (`code`),
@@ -40046,8 +40010,8 @@ CREATE TABLE `stockBuyed` (
`creationDate` timestamp NULL DEFAULT current_timestamp(),
`reserved` decimal(10,2) DEFAULT NULL,
`requested` decimal(10,2) DEFAULT NULL,
+ `description` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`),
- UNIQUE KEY `date_UNIQUE` (`date`,`user`),
KEY `stockBuyed_user_idx` (`user`),
CONSTRAINT `stockBuyedUserFk` FOREIGN KEY (`user`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
@@ -40288,6 +40252,30 @@ CREATE TABLE `supplierAgencyTerm` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
+--
+-- Table structure for table `supplierAgencyTerm`
+--
+
+DROP TABLE IF EXISTS `supplierAgencyTerm`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `supplierAgencyTerm` (
+ `agencyFk` smallint(5) unsigned NOT NULL,
+ `supplierFk` int(11) DEFAULT NULL,
+ `minimumPackages` int(11) NOT NULL DEFAULT '0' COMMENT 'numero minimo de bultos',
+ `kmPrice` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT 'precio extra por km',
+ `packagePrice` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT 'precio extra por bulto',
+ `routePrice` decimal(10,2) DEFAULT NULL COMMENT 'precio fijo por ruta',
+ `minimumKm` int(11) NOT NULL DEFAULT '0',
+ `minimumM3` decimal(10,2) NOT NULL DEFAULT '0.00',
+ `m3Price` decimal(10,2) NOT NULL DEFAULT '0.00',
+ PRIMARY KEY (`agencyFk`),
+ KEY `agencyTerm_FK_1` (`supplierFk`),
+ CONSTRAINT `agencyTerm_FK` FOREIGN KEY (`agencyFk`) REFERENCES `agency` (`id`) ON UPDATE CASCADE,
+ CONSTRAINT `agencyTerm_FK_1` FOREIGN KEY (`supplierFk`) REFERENCES `supplier` (`id`) ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
--
-- Table structure for table `supplierContact`
--
@@ -41437,7 +41425,7 @@ CREATE TABLE `ticketRefund` (
KEY `ticketRefund_FK_1` (`originalTicketFk`),
CONSTRAINT `ticketRefund_FK` FOREIGN KEY (`refundTicketFk`) REFERENCES `ticket` (`id`) ON UPDATE CASCADE,
CONSTRAINT `ticketRefund_FK_1` FOREIGN KEY (`originalTicketFk`) REFERENCES `ticket` (`id`) ON UPDATE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -42426,7 +42414,7 @@ CREATE TABLE `travelThermograph` (
`created` date NOT NULL,
`warehouseFk` smallint(6) unsigned NOT NULL,
`travelFk` int(10) unsigned DEFAULT NULL,
- `temperature` enum('COOL','WARM','DRY') COLLATE utf8_unicode_ci DEFAULT NULL,
+ `temperature__` enum('COOL','WARM','DRY') COLLATE utf8_unicode_ci DEFAULT NULL,
`result` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL,
`dmsFk` int(11) DEFAULT NULL,
`temperatureFk` varchar(10) CHARACTER SET utf8 DEFAULT 'cool' COMMENT 'En la versión de Agosto de Salix se empezará a usar este campo y se actualizaran los anteriores mirando temperature.',
@@ -42443,30 +42431,6 @@ CREATE TABLE `travelThermograph` (
CONSTRAINT `travelThermographWarehouseFgn` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON DELETE CASCADE
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Registra cada termografo que se ha introducido en cada travel';
/*!40101 SET character_set_client = @saved_cs_client */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-DELIMITER ;;
-/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`travelThermograph_beforeInsert`
- BEFORE INSERT ON `travelThermograph`
- FOR EACH ROW
-BEGIN
-
- IF NEW.temperature IS NULL THEN
- SET NEW.temperature = UCASE(NEW.temperatureFk);
- END IF;
-
-END */;;
-DELIMITER ;
-/*!50003 SET sql_mode = @saved_sql_mode */ ;
-/*!50003 SET character_set_client = @saved_cs_client */ ;
-/*!50003 SET character_set_results = @saved_cs_results */ ;
-/*!50003 SET collation_connection = @saved_col_connection */ ;
--
-- Table structure for table `trolley`
@@ -42599,14 +42563,21 @@ CREATE TABLE `vehicle` (
`isActive` tinyint(4) NOT NULL DEFAULT 1,
`warehouseFk` smallint(6) unsigned DEFAULT NULL,
`description` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL,
- `deliveryPointFk` int(11) DEFAULT 6 COMMENT 'Direccion para Buscaman',
- `isKmTruckRate` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'Computar km como camión en el cálculo de salario de reparto',
- `photo` blob DEFAULT NULL,
+ `deliveryPointFk` int(11) DEFAULT '6' COMMENT 'Direccion para Buscaman',
+ `isKmTruckRate` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'Computar km como camión en el cálculo de salario de reparto',
+ `photo` blob,
+ `chassis` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'numero de bastidor',
+ `fuelTypeFk` int(11) DEFAULT NULL,
+ `ppeFk` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `empresa_id` (`companyFk`),
KEY `provinceFk_idx` (`warehouseFk`),
KEY `vehicle_deliveryPointFk_idx` (`deliveryPointFk`),
+ KEY `vehicle_FK` (`fuelTypeFk`),
+ KEY `vehicle_FK_1` (`ppeFk`),
CONSTRAINT `provinceFk` FOREIGN KEY (`warehouseFk`) REFERENCES `province` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
+ CONSTRAINT `vehicle_FK` FOREIGN KEY (`fuelTypeFk`) REFERENCES `fuelType` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
+ CONSTRAINT `vehicle_FK_1` FOREIGN KEY (`ppeFk`) REFERENCES `ppe` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
CONSTRAINT `vehicle_deliveryPointFk` FOREIGN KEY (`deliveryPointFk`) REFERENCES `deliveryPoint` (`id`) ON UPDATE CASCADE,
CONSTRAINT `vehicle_ibfk_1` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
@@ -42939,7 +42910,6 @@ CREATE TABLE `worker` (
`fi__` varchar(9) COLLATE utf8_unicode_ci DEFAULT NULL,
`address__` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
`birthed__` date NOT NULL,
- `maritalStatus__` enum('soltero/a','casado/a') COLLATE utf8_unicode_ci NOT NULL,
`phone` varchar(9) COLLATE utf8_unicode_ci NOT NULL,
`clientFk__` int(11) DEFAULT NULL,
`userFk` int(10) unsigned DEFAULT NULL,
@@ -42950,6 +42920,11 @@ CREATE TABLE `worker` (
`isTodayRelative` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Para el F11. Calcula los problemas de visiblidad en funcion del dia actual',
`isF11Allowed` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Usuario autorizado para abrir el F11',
`sectorFk` int(11) DEFAULT NULL COMMENT 'Sector que tiene asociado el trabajador.',
+ `maritalStatus` enum('S','M') COLLATE utf8_unicode_ci NOT NULL,
+ `labelerFk` tinyint(3) unsigned DEFAULT NULL,
+ `originCountryFk` mediumint(8) unsigned DEFAULT NULL COMMENT 'País de origen',
+ `educationLevelFk` smallint(6) DEFAULT NULL,
+ `SSN` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `CodigoTrabajador_UNIQUE` (`code`),
UNIQUE KEY `user` (`user__`),
@@ -42957,7 +42932,13 @@ CREATE TABLE `worker` (
UNIQUE KEY `Id_Cliente_Interno` (`clientFk__`),
KEY `sub` (`sub`),
KEY `boss_idx` (`bossFk`),
+ KEY `worker_FK` (`labelerFk`),
+ KEY `worker_FK_2` (`educationLevelFk`),
+ KEY `worker_FK_1` (`originCountryFk`),
CONSTRAINT `Clientes` FOREIGN KEY (`clientFk__`) REFERENCES `client` (`id`) ON UPDATE CASCADE,
+ CONSTRAINT `worker_FK` FOREIGN KEY (`labelerFk`) REFERENCES `printer` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `worker_FK_1` FOREIGN KEY (`originCountryFk`) REFERENCES `country` (`id`) ON UPDATE CASCADE,
+ CONSTRAINT `worker_FK_2` FOREIGN KEY (`educationLevelFk`) REFERENCES `educationLevel` (`id`) ON UPDATE CASCADE,
CONSTRAINT `worker_ibfk_1` FOREIGN KEY (`id`) REFERENCES `account`.`user` (`id`)
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -46354,6 +46335,42 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
+/*!50003 DROP FUNCTION IF EXISTS `firstDayOfWeek` */;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+DELIMITER ;;
+CREATE DEFINER=`root`@`localhost` FUNCTION `firstDayOfWeek`(vYear INT, vWeek INT) RETURNS date
+ DETERMINISTIC
+BEGIN
+/**
+ * Returns the date of the first day of the week
+ *
+ * @param vYear The year
+ * @param vWeek The week number
+ * @return Date of the first day of the week
+ */
+ DECLARE vDate DATE;
+
+ SELECT dated INTO vDate
+ FROM `time`
+ WHERE `year` = vYear
+ AND `week` = vWeek
+ ORDER BY dated
+ LIMIT 1;
+
+ RETURN vDate;
+END ;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP FUNCTION IF EXISTS `getAlert3State` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -47759,6 +47776,42 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
+/*!50003 DROP FUNCTION IF EXISTS `lastDayOfWeek` */;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+DELIMITER ;;
+CREATE DEFINER=`root`@`localhost` FUNCTION `lastDayOfWeek`(vYear INT, vWeek INT) RETURNS date
+ DETERMINISTIC
+BEGIN
+/**
+ * Returns the date of the last day of the week
+ *
+ * @param vYear The year
+ * @param vWeek The week number
+ * @return Date of the first day of the week
+ */
+ DECLARE vDate DATE;
+
+ SELECT dated INTO vDate
+ FROM `time`
+ WHERE `year` = vYear
+ AND `week` = vWeek
+ ORDER BY dated DESC
+ LIMIT 1;
+
+ RETURN vDate;
+END ;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP FUNCTION IF EXISTS `machineWorker_Worker` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -49000,7 +49053,7 @@ BEGIN
LIMIT 1;
IF vTicket IS NULL THEN
- CALL vn.ticketCreateWithUser(
+ CALL vn.ticket_add(
vClientFk,
IFNULL(vShipped, vn.VN_CURDATE()),
vWarehouseFk,
@@ -49010,6 +49063,7 @@ BEGIN
NULL,
vShipped,
`account`.`myUser_getId`(),
+ TRUE,
vTicket
);
END IF;
@@ -50370,9 +50424,9 @@ DELIMITER ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_general_ci */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `buyUltimate`(vWarehouseFk SMALLINT, vDated DATE)
BEGIN
@@ -50408,7 +50462,6 @@ BEGIN
WHERE (warehouseFk = vWarehouseFk OR vWarehouseFk IS NULL)
AND landed > vDated;
- DROP TEMPORARY TABLE tmp.buyUltimateFromInterval;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -51317,28 +51370,27 @@ DELIMITER ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8 */ ;
-/*!50003 SET character_set_results = utf8 */ ;
-/*!50003 SET collation_connection = utf8_general_ci */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `catalog_calculate`(vLanded DATE, vAddressFk INT, vAgencyModeFk INT)
-BEGIN
-
- /**
- * Calcula los articulos disponibles y sus precios
- *
- * @table tmp.item(itemFk) Listado de artÃculos a calcular
- * @param vLanded Fecha de recepcion de mercancia
- * @param vAddressFk Id del consignatario
- * @param vAgencyModeFk Id de la agencia
- * @return tmp.ticketCalculateItem(itemFk, available, producer,
- * item, size, stems, category, inkFk, image, origin, price)
- * @return tmp.ticketLot(warehouseFk, itemFk, available, buyFk)
- * @return tmp.ticketComponent
- * @return tmp.ticketComponentPrice
- */
+BEGIN
+/**
+ * Calcula los articulos disponibles y sus precios
+ *
+ * @table tmp.item(itemFk) Listado de artículos a calcular
+ * @param vLanded Fecha de recepcion de mercancia
+ * @param vAddressFk Id del consignatario
+ * @param vAgencyModeFk Id de la agencia
+ * @return tmp.ticketCalculateItem(itemFk, available, producer,
+ * item, size, stems, category, inkFk, image, origin, price)
+ * @return tmp.ticketLot(warehouseFk, itemFk, available, buyFk)
+ * @return tmp.ticketComponent
+ * @return tmp.ticketComponentPrice
+ */
DECLARE vAvailableCalc INT;
DECLARE vAvailableNoRaidsCalc INT;
@@ -51381,6 +51433,7 @@ BEGIN
origin VARCHAR(3),
price DECIMAL(10,2),
priceKg DECIMAL(10,2),
+ `grouping` INT(10) UNSIGNED,
PRIMARY KEY `itemFk` (`itemFk`)
) ENGINE = MEMORY DEFAULT CHARSET=utf8;
@@ -51409,8 +51462,11 @@ BEGIN
AND anr.calc_id = vAvailableNoRaidsCalc
JOIN tmp.item i ON i.itemFk = a.item_id
JOIN vn.item it ON it.id = i.itemFk
+ JOIN vn.`zone` z ON z.id = vZoneFk
LEFT JOIN tmp.buyUltimate bu ON bu.itemFk = a.item_id
- LEFT JOIN edi.supplyOffer so ON so.srId = 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.marketPlace mp ON mp.id = sr.MarketPlaceID
LEFT JOIN (SELECT isVNHSupplier, isEarlyBird, TRUE AS itemAllowed
FROM vn.addressFilter af
JOIN (SELECT ad.provinceFk, p.countryFk, ad.isLogifloraAllowed
@@ -51421,16 +51477,31 @@ BEGIN
AND sub2.countryFk <=> IFNULL(af.countryFk, sub2.countryFk)
AND sub2.isLogifloraAllowed <=> IFNULL(af.isLogifloraAllowed, sub2.isLogifloraAllowed)
WHERE vWarehouseFk = af.warehouseFk
- ) sub ON sub.isVNHSupplier = so.isVNHSupplier
- AND IFNULL(sub.isEarlyBird, so.isEarlyBird) = so.isEarlyBird
+ AND (vShipped < af.beforeDated
+ OR ISNULL(af.beforeDated)
+ OR vShipped > af.afterDated
+ OR ISNULL(af.afterDated))
+ ) sub ON sub.isVNHSupplier = v.isVNHSupplier
+ AND (sub.isEarlyBird = mp.isEarlyBird OR ISNULL(sub.isEarlyBird))
JOIN vn.agencyMode am ON am.id = vAgencyModeFk
JOIN vn.agency ag ON ag.id = am.agencyFk
JOIN vn.itemType itt ON itt.id = it.typeFk
+ JOIN vn.itemCategory itc on itc.id = itt.categoryFk
+ JOIN vn.address ad ON ad.id = vAddressFk
+ LEFT JOIN vn.clientItemType cit
+ ON cit.clientFk = ad.clientFk
+ AND cit.itemTypeFk = itt.id
+ LEFT JOIN vn.clientItemCategory cic
+ ON cic.clientFk = ad.clientFk
+ AND cic.itemCategoryFk = itc.id
WHERE a.calc_id = vAvailableCalc
AND a.available > 0
AND (sub.itemAllowed OR NOT it.isFloramondo OR anr.available > 0)
- AND (ag.isAnyVolumeAllowed OR NOT itt.isUnconventionalSize);
-
+ AND (ag.isAnyVolumeAllowed OR NOT itt.isUnconventionalSize)
+ AND (itc.isReclining OR ISNULL(it.`size`) OR it.`size` < z.itemMaxSize OR ISNULL(z.itemMaxSize))
+ AND NOT (cit.isAllowed <=> FALSE)
+ AND (ISNULL(cic.itemCategoryFk) OR cit.isAllowed);
+
DROP TEMPORARY TABLE tmp.buyUltimate;
CALL vn.catalog_componentCalculate(vZoneFk, vAddressFk, vShipped, vWarehouseFk);
@@ -51447,7 +51518,8 @@ BEGIN
image,
origin,
price,
- priceKg)
+ priceKg,
+ `grouping`)
SELECT
tl.itemFk,
SUM(tl.available) available,
@@ -51460,17 +51532,20 @@ BEGIN
i.image,
o.code origin,
bl.price,
- bl.priceKg
+ bl.priceKg,
+ bl.`grouping`
FROM tmp.ticketLot tl
JOIN item i ON tl.itemFk = i.id
LEFT JOIN producer p ON p.id = i.producerFk AND p.isVisible
JOIN origin o ON o.id = i.originFk
JOIN (
- SELECT *
- FROM (SELECT price, itemFk, priceKg
+ SELECT price, itemFk, priceKg, MIN(`grouping`) `grouping`
+ FROM (
+ SELECT price, itemFk, priceKg, `grouping`
FROM tmp.ticketComponentPrice
WHERE warehouseFk = vWarehouseFk
- ORDER BY (rate = 2) DESC) sub
+ ORDER BY (rate = 2) DESC
+ ) sub
GROUP BY itemFk
) bl ON bl.itemFk = tl.itemFk
WHERE tl.zoneFk = vZoneFk AND tl.warehouseFk = vWarehouseFk
@@ -51481,339 +51556,6 @@ BEGIN
CLOSE cTravelTree;
-END ;;
-DELIMITER ;
-/*!50003 SET sql_mode = @saved_sql_mode */ ;
-/*!50003 SET character_set_client = @saved_cs_client */ ;
-/*!50003 SET character_set_results = @saved_cs_results */ ;
-/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `catalog_calculate_beta` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8 */ ;
-/*!50003 SET character_set_results = utf8 */ ;
-/*!50003 SET collation_connection = utf8_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `catalog_calculate_beta`(vLanded DATE, vAddressFk INT, vAgencyModeFk INT)
-BEGIN
-
- /**
- * Calcula los articulos disponibles y sus precios
- *
- * @table tmp.item(itemFk) Listado de artÃculos a calcular
- * @param vLanded Fecha de recepcion de mercancia
- * @param vAddressFk Id del consignatario
- * @param vAgencyModeFk Id de la agencia
- * @return tmp.ticketCalculateItem(itemFk, available, producer,
- * item, size, stems, category, inkFk, image, origin, price)
- * @return tmp.ticketLot(warehouseFk, itemFk, available, buyFk)
- * @return tmp.ticketComponent
- * @return tmp.ticketComponentPrice
- */
-
- DECLARE vAvailableCalc INT;
- DECLARE vAvailableNoRaidsCalc INT;
- DECLARE vShipped DATE;
- DECLARE vWarehouseFk SMALLINT;
- DECLARE vZoneFk INT;
- DECLARE vDone BOOL;
- DECLARE cTravelTree CURSOR FOR
- SELECT zoneFk, warehouseFk, shipped FROM tmp.zoneGetShipped;
-
- DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
-
- CALL vn.zone_getShipped (vLanded, vAddressFk, vAgencyModeFk, FALSE);
-
- DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot;
- CREATE TEMPORARY TABLE tmp.ticketLot(
- `warehouseFk` smallint(5) unsigned NOT NULL,
- `itemFk` int(11) NOT NULL,
- `available` double DEFAULT NULL,
- `buyFk` int(11) DEFAULT NULL,
- `fix` tinyint(3) unsigned DEFAULT '0', -- este campo parece obsoleto
- `zoneFk` int(11) NOT NULL,
- KEY `itemFk` (`itemFk`),
- KEY `item_warehouse` (`itemFk`,`warehouseFk`) USING HASH
- ) ENGINE=MEMORY DEFAULT CHARSET=utf8;
-
- CALL catalog_componentPrepare();
-
- DROP TEMPORARY TABLE IF EXISTS tmp.ticketCalculateItem;
- CREATE TEMPORARY TABLE tmp.ticketCalculateItem(
- itemFk INT(11) NOT NULL,
- available INT(11),
- producer VARCHAR(50),
- item VARCHAR(50),
- size INT(10) UNSIGNED,
- stems INT(11),
- category VARCHAR(3),
- inkFk VARCHAR(3),
- image VARCHAR(50),
- origin VARCHAR(3),
- price DECIMAL(10,2),
- priceKg DECIMAL(10,2),
- PRIMARY KEY `itemFk` (`itemFk`)
- ) ENGINE = MEMORY DEFAULT CHARSET=utf8;
-
- OPEN cTravelTree;
-
- l: LOOP
- SET vDone = FALSE;
- FETCH cTravelTree INTO vZoneFk, vWarehouseFk, vShipped;
-
- IF vDone THEN
- LEAVE l;
- END IF;
-
- CALL `cache`.available_refresh (vAvailableCalc, FALSE, vWarehouseFk, vShipped);
- CALL `cache`.availableNoRaids_refresh (vAvailableNoRaidsCalc, FALSE, vWarehouseFk, vShipped);
- CALL vn.buyUltimate(vWarehouseFk, vShipped);
-
- INSERT INTO tmp.ticketLot (warehouseFk, itemFk, available, buyFk, zoneFk)
- SELECT vWarehouseFk,
- a.item_id,
- IFNULL(a.available, 0),
- bu.buyFk,
- vZoneFk
- FROM `cache`.available a
- LEFT JOIN cache.availableNoRaids anr ON anr.item_id = a.item_id
- AND anr.calc_id = vAvailableNoRaidsCalc
- JOIN tmp.item i ON i.itemFk = a.item_id
- JOIN vn.item it ON it.id = i.itemFk
- LEFT JOIN tmp.buyUltimate bu ON bu.itemFk = a.item_id
- LEFT JOIN edi.supplyOffer so ON so.srId = it.supplyResponseFk
- LEFT JOIN (SELECT isVNHSupplier, isEarlyBird, TRUE AS itemAllowed
- FROM vn.addressFilter af
- JOIN (SELECT ad.provinceFk, p.countryFk, ad.isLogifloraAllowed
- FROM vn.address ad
- JOIN vn.province p ON p.id = ad.provinceFk
- WHERE ad.id = vAddressFk
- ) sub2 ON sub2.provinceFk <=> IFNULL(af.provinceFk, sub2.provinceFk)
- AND sub2.countryFk <=> IFNULL(af.countryFk, sub2.countryFk)
- AND sub2.isLogifloraAllowed <=> IFNULL(af.isLogifloraAllowed, sub2.isLogifloraAllowed)
- WHERE vWarehouseFk = af.warehouseFk
- ) sub ON sub.isVNHSupplier = so.isVNHSupplier
- AND IFNULL(sub.isEarlyBird, so.isEarlyBird) = so.isEarlyBird
- JOIN vn.agencyMode am ON am.id = vAgencyModeFk
- JOIN vn.agency ag ON ag.id = am.agencyFk
- JOIN vn.itemType itt ON itt.id = it.typeFk
- WHERE a.calc_id = vAvailableCalc
- AND a.available > 0
- AND (sub.itemAllowed OR NOT it.isFloramondo OR anr.available > 0)
- AND (ag.isAnyVolumeAllowed OR NOT itt.isUnconventionalSize);
-
- DROP TEMPORARY TABLE tmp.buyUltimate;
-
- CALL vn.catalog_componentCalculate_beta(vZoneFk, vAddressFk, vShipped, vWarehouseFk);
-
- INSERT INTO tmp.ticketCalculateItem (
- itemFk,
- available,
- producer,
- item,
- size,
- stems,
- category,
- inkFk,
- image,
- origin,
- price,
- priceKg)
- SELECT
- tl.itemFk,
- SUM(tl.available) available,
- p.name producer,
- i.name item,
- i.size size,
- i.stems,
- i.category,
- i.inkFk,
- i.image,
- o.code origin,
- bl.price,
- bl.priceKg
- FROM tmp.ticketLot tl
- JOIN item i ON tl.itemFk = i.id
- LEFT JOIN producer p ON p.id = i.producerFk AND p.isVisible
- JOIN origin o ON o.id = i.originFk
- JOIN (
- SELECT *
- FROM (SELECT price, itemFk, priceKg
- FROM tmp.ticketComponentPrice
- WHERE warehouseFk = vWarehouseFk
- ORDER BY (rate = 2) DESC) sub
- GROUP BY itemFk
- ) bl ON bl.itemFk = tl.itemFk
- WHERE tl.zoneFk = vZoneFk AND tl.warehouseFk = vWarehouseFk
- GROUP BY tl.itemFk
- ON DUPLICATE KEY UPDATE available = available + VALUES(available);
-
- END LOOP;
-
- CLOSE cTravelTree;
-
-END ;;
-DELIMITER ;
-/*!50003 SET sql_mode = @saved_sql_mode */ ;
-/*!50003 SET character_set_client = @saved_cs_client */ ;
-/*!50003 SET character_set_results = @saved_cs_results */ ;
-/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `catalog_calculate__` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8 */ ;
-/*!50003 SET character_set_results = utf8 */ ;
-/*!50003 SET collation_connection = utf8_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `catalog_calculate__`(
- vLanded DATE,
- vAddressFk INT,
- vAgencyModeFk INT)
-proc: BEGIN
-/**
- * Calcula los articulos disponibles y sus precios
- *
- * @table tmp.item(itemFk) Listado de artÃculos a calcular
- * @param vLanded Fecha de recepcion de mercancia
- * @param vAddressFk Id del consignatario
- * @param vAgencyModeFk Id de la agencia
- * @return tmp.ticketCalculateItem(itemFk, available, producer,
- * item, size, stems, category, inkFk, image, origin, price)
- * @return tmp.ticketLot(warehouseFk, itemFk, available, buyFk)
- * @return tmp.ticketComponent
- * @return tmp.ticketComponentPrice
- * @return tmp.zoneGetShipped
- */
-
- DECLARE vAvailableCalc INT;
- DECLARE vShipped DATE;
- DECLARE vWarehouseFk SMALLINT;
- DECLARE vZoneFk INT;
- DECLARE vDone BOOL;
- DECLARE cTravelTree CURSOR FOR
- SELECT zoneFk, warehouseFk, shipped FROM tmp.zoneGetShipped;
-
- DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
-
- -- Establece los almacenes y las fechas que van a entrar al disponible
-
- CALL vn.zone_getShipped (vLanded, vAddressFk, vAgencyModeFk, FALSE);
-
- DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot;
- CREATE TEMPORARY TABLE tmp.ticketLot(
- `warehouseFk` smallint(5) unsigned NOT NULL,
- `itemFk` int(11) NOT NULL,
- `available` double DEFAULT NULL,
- `buyFk` int(11) DEFAULT NULL,
- `fix` tinyint(3) unsigned DEFAULT '0',
- `zoneFk` int(11) NOT NULL,
- KEY `itemFk` (`itemFk`),
- KEY `item_warehouse` (`itemFk`,`warehouseFk`) USING HASH
- ) ENGINE=MEMORY DEFAULT CHARSET=utf8;
-
- CALL catalog_componentPrepare();
-
- DROP TEMPORARY TABLE IF EXISTS tmp.ticketCalculateItem;
- CREATE TEMPORARY TABLE tmp.ticketCalculateItem(
- itemFk INT(11) NOT NULL,
- available INT(11),
- producer VARCHAR(50),
- item VARCHAR(50),
- size INT(10) UNSIGNED,
- stems INT(11),
- category VARCHAR(3),
- inkFk VARCHAR(3),
- image VARCHAR(50),
- origin VARCHAR(3),
- price DECIMAL(10,2),
- priceKg DECIMAL(10,2),
- PRIMARY KEY `itemFk` (`itemFk`)
- ) ENGINE = MEMORY DEFAULT CHARSET=utf8;
-
- OPEN cTravelTree;
-
- l: LOOP
- SET vDone = FALSE;
- FETCH cTravelTree INTO vZoneFk, vWarehouseFk, vShipped;
-
- IF vDone THEN
- LEAVE l;
- END IF;
-
- CALL `cache`.available_refresh (vAvailableCalc, FALSE, vWarehouseFk, vShipped);
- CALL buyUltimate (vWarehouseFk, vShipped);
-
- INSERT INTO tmp.ticketLot (warehouseFk, itemFk, available, buyFk, zoneFk)
- SELECT vWarehouseFk,
- i.item_id,
- IFNULL(i.available, 0),
- bu.buyFk,
- vZoneFk
- FROM `cache`.available i
- JOIN tmp.item br ON br.itemFk = i.item_id
- LEFT JOIN item it ON it.id = i.item_id -- esta linea sobra ?
- LEFT JOIN tmp.buyUltimate bu ON bu.itemFk = i.item_id
- WHERE i.calc_id = vAvailableCalc
- AND i.available > 0;
-
- CALL util.debugAdd('ticketLot: ', (SELECT COUNT(*) FROM tmp.ticketLot));
-
- DROP TEMPORARY TABLE tmp.buyUltimate;
-
- CALL vn.catalog_componentCalculate(vZoneFk, vAddressFk, vShipped, vWarehouseFk);
-
- INSERT INTO tmp.ticketCalculateItem (
- itemFk,
- available,
- producer,
- item,
- size,
- stems,
- category,
- inkFk,
- image,
- origin,
- price,
- priceKg)
- SELECT
- tl.itemFk,
- SUM(tl.available) available,
- p.name producer,
- i.name item,
- i.size size,
- i.stems,
- i.category,
- i.inkFk,
- i.image,
- o.code origin,
- bl.price,
- bl.priceKg
- FROM tmp.ticketLot tl
- JOIN item i ON tl.itemFk = i.id
- LEFT JOIN producer p ON p.id = i.producerFk AND p.isVisible
- JOIN origin o ON o.id = i.originFk
- JOIN (
- SELECT *
- FROM (SELECT price, itemFk, priceKg
- FROM tmp.ticketComponentPrice
- WHERE warehouseFk = vWarehouseFk
- ORDER BY (rate = 2) DESC) sub
- GROUP BY itemFk
- ) bl ON bl.itemFk = tl.itemFk
- WHERE tl.zoneFk = vZoneFk AND tl.warehouseFk = vWarehouseFk
- GROUP BY tl.itemFk
- ON DUPLICATE KEY UPDATE available = available + VALUES(available);
-
- END LOOP;
-
- CLOSE cTravelTree;
-
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -51824,11 +51566,11 @@ DELIMITER ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8 */ ;
-/*!50003 SET character_set_results = utf8 */ ;
-/*!50003 SET collation_connection = utf8_general_ci */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `catalog_componentCalculate`( vZoneFk INT,
vAddressFk INT,
@@ -51848,341 +51590,6 @@ BEGIN
* @return tmp.ticketComponentPrice (warehouseFk, itemFk, rate, `grouping`, price, priceKg)
*/
- DECLARE vClientFk INT;
- DECLARE vIsFrenchVNHBuyer BOOLEAN DEFAULT FALSE;
- DECLARE vVNHWarehouseFk INT DEFAULT 7;
- DECLARE vFrenchDiscount DECIMAL(3,2) DEFAULT 0.12;
-
- SELECT clientFk INTO vClientFK
- FROM address
- WHERE id = vAddressFk;
-
- SELECT (c.country = 'FRANCIA' AND vWarehouseFk = vVNHWarehouseFk)
- INTO vIsFrenchVNHBuyer
- FROM vn.country c
- JOIN vn.province p ON p.countryFk = c.id
- JOIN vn.address a ON a.provinceFk = p.id
- WHERE a.id = vAddressFk;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentCalculate;
-
- CREATE TEMPORARY TABLE tmp.ticketComponentCalculate
- (PRIMARY KEY (itemFk, warehouseFk))
- ENGINE = MEMORY
- SELECT
- tl.itemFk,
- tl.warehouseFk,
- tl.available,
- -- IF((@rate2 := IFNULL(pf.rate2, b.price2)) < i.minPrice AND i.hasMinPrice, i.minPrice, @rate2) rate2,
- IF(i.hasMinPrice, GREATEST(i.minPrice,IFNULL(pf.rate2, b.price2)),IFNULL(pf.rate2, b.price2)) rate2,
- IF(i.hasMinPrice, GREATEST(i.minPrice,IFNULL(pf.rate3, b.price3)),IFNULL(pf.rate3, b.price3)) rate3,
- -- @minPrice := IF((@rate3 := IFNULL(pf.rate3, b.price3)) < i.minPrice AND i.hasMinPrice, i.minPrice, @rate3) rate3,
- -- TRUE AS minPrice,
- IFNULL(pf.packing, GREATEST(b.grouping, b.packing)) packing,
- IFNULL(pf.`grouping`, b.`grouping`) `grouping`,
- ABS(IFNULL(pf.box, b.groupingMode)) groupingMode,
- tl.buyFk,
- i.typeFk,
- IF(i.hasKgPrice, b.weight / b.packing, NULL) weightGrouping
- FROM tmp.ticketLot tl
- JOIN buy b ON b.id = tl.buyFk
- JOIN item i ON i.id = tl.itemFk
- JOIN itemType it ON it.id = i.typeFk
- JOIN itemCategory ic ON ic.id = it.categoryFk
- LEFT JOIN specialPrice sp ON sp.itemFk = i.id
- AND sp.clientFk = vClientFk
- LEFT JOIN (
- SELECT * FROM (
- SELECT pf.itemFk,
- pf.`grouping`,
- pf.packing,
- pf.box,
- pf.rate2,
- pf.rate3,
- zw.warehouseFk
- FROM priceFixed pf
- JOIN zoneWarehouse zw ON zw.zoneFk = vZoneFk
- AND zw.warehouseFk IN (pf.warehouseFk,0)
- WHERE vShipped BETWEEN pf.started AND pf.ended
- ORDER BY pf.itemFk, pf.warehouseFk DESC
- ) tpf
- GROUP BY tpf.itemFk, tpf.warehouseFk
- ) pf ON pf.itemFk = tl.itemFk
- AND pf.warehouseFk = tl.warehouseFk
- WHERE b.buyingValue + b.freightValue + b.packageValue + b.comissionValue > 0.01
- AND ic.merchandise
- AND tl.zoneFk = vZoneFk
- AND tl.warehouseFk = vWarehouseFk;
-
- -- Coste
- INSERT INTO tmp.ticketComponent (warehouseFk, itemFk, componentFk, cost)
- SELECT
- tcc.warehouseFk,
- tcc.itemFk,
- c2.id,
- b.buyingValue + b.freightValue + b.packageValue + b.comissionValue
- FROM tmp.ticketComponentCalculate tcc
- JOIN vn.component c2 ON c2.code = 'purchaseValue'
- JOIN buy b ON b.id = tcc.buyFk;
-
- -- Margen
- INSERT INTO tmp.ticketComponent (warehouseFk, itemFk, componentFk, cost)
- SELECT
- tcc.warehouseFk,
- tcc.itemFk,
- c2.id,
- tcc.rate3 - b.buyingValue - b.freightValue - b.packageValue - b.comissionValue
- FROM tmp.ticketComponentCalculate tcc
- JOIN vn.component c2 ON c2.code = 'margin'
- JOIN buy b ON b.id = tcc.buyFk;
-
- -- Promo Francia
- IF vIsFrenchVNHBuyer THEN
-
- INSERT INTO tmp.ticketComponent (warehouseFk, itemFk, componentFk, cost)
- SELECT
- tcc.warehouseFk,
- tcc.itemFk,
- c2.id,
- - vFrenchDiscount * (b.buyingValue + b.freightValue + b.packageValue + b.comissionValue) / ( 1 - vFrenchDiscount)
- FROM tmp.ticketComponentCalculate tcc
- JOIN vn.component c2 ON c2.code = 'frenchOffer'
- JOIN buy b ON b.id = tcc.buyFk;
-
- END IF;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentBase;
- CREATE TEMPORARY TABLE tmp.ticketComponentBase ENGINE = MEMORY
- SELECT tc.itemFk, ROUND(SUM(tc.cost), 4) AS base, tc.warehouseFk
- FROM tmp.ticketComponent tc
- JOIN tmp.ticketComponentCalculate tcc ON tcc.itemFk = tc.itemFk AND tcc.warehouseFk = tc.warehouseFk
- GROUP BY tc.itemFk, warehouseFk;
-
- -- RECOBRO
- INSERT INTO tmp.ticketComponent(warehouseFk, itemFk, componentFk, cost)
- SELECT tcb.warehouseFk, tcb.itemFk, c2.id,
- ROUND(tcb.base *
- LEAST(
- MAX(GREATEST(IFNULL(cr.priceIncreasing,0),
- IFNULL(cr1.priceIncreasing,0),
- IFNULL(cr2.priceIncreasing,0))
- ),
- 0.25),
- 3)
- FROM tmp.ticketComponentBase tcb
- JOIN vn.component c2 ON c2.code = 'debtCollection'
- JOIN claimRatio cr ON cr.clientFk = vClientFk
- LEFT JOIN clientYoke cy1 ON cy1.leftOx = cr.clientFk
- LEFT JOIN claimRatio cr1 ON cr1.clientFk = cy1.rightOx
- LEFT JOIN clientYoke cy2 ON cy2.rightOx = cr.clientFk
- LEFT JOIN claimRatio cr2 ON cr2.clientFk = cy2.leftOx
- WHERE GREATEST(IFNULL(cr.priceIncreasing,0), IFNULL(cr1.priceIncreasing,0), IFNULL(cr2.priceIncreasing,0)) > 0.009
- GROUP BY tcb.itemFk;
-
- -- Mana auto
- INSERT INTO tmp.ticketComponent(warehouseFk, itemFk, componentFk, cost)
- SELECT tcb.warehouseFk, tcb.itemFk, c2.id, ROUND(base * (0.01 + wm.pricesModifierRate), 3) as manaAuto
- FROM tmp.ticketComponentBase tcb
- JOIN `client` c on c.id = vClientFk
- JOIN workerMana wm ON c.salesPersonFk = wm.workerFk
- JOIN vn.component c2 ON c2.code = 'autoMana'
- WHERE wm.isPricesModifierActivated
- HAVING manaAuto <> 0;
-
- -- Precios especiales
- INSERT INTO tmp.ticketComponent(warehouseFk, itemFk, componentFk, cost)
- SELECT tcb.warehouseFk,
- tcb.itemFk,
- c2.id,
- GREATEST(
- IFNULL(ROUND(tcb.base * c2.tax, 4), 0),
- IF(i.hasMinPrice, i.minPrice,0) - tcc.rate3
- ) cost
- FROM tmp.ticketComponentBase tcb
- JOIN vn.component c2 ON c2.code = 'lastUnitsDiscount'
- JOIN tmp.ticketComponentCalculate tcc ON tcc.itemFk = tcb.itemFk AND tcc.warehouseFk = tcb.warehouseFk
- LEFT JOIN specialPrice sp ON sp.clientFk = vClientFk AND sp.itemFk = tcc.itemFk
- JOIN vn.item i ON i.id = tcb.itemFk
- WHERE sp.value IS NULL
- AND i.supplyResponseFk IS NULL;
-
- -- Venta por paquetes
- INSERT INTO tmp.ticketComponent(warehouseFk, itemFk, componentFk, cost)
- SELECT tcc.warehouseFk, tcc.itemFk, c2.id, tcc.rate2 - tcc.rate3
- FROM tmp.ticketComponentCalculate tcc
- JOIN vn.component c2 ON c2.code = 'salePerPackage'
- JOIN buy b ON b.id = tcc.buyFk
- LEFT JOIN specialPrice sp ON sp.clientFk = vClientFk AND sp.itemFk = tcc.itemFk
- WHERE sp.value IS NULL;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.zone;
- CREATE TEMPORARY TABLE IF NOT EXISTS tmp.zone (INDEX (id))
- ENGINE = MEMORY
- SELECT vZoneFk id;
-
- CALL zone_getOptionsForShipment(vShipped, TRUE);
-
- -- Reparto
- INSERT INTO tmp.ticketComponent
- SELECT tcc.warehouseFK,
- tcc.itemFk,
- c2.id,
- z.inflation * ROUND(ic.cm3delivery * (IFNULL(zo.price,5000) - IFNULL(zo.bonus,0)) / (1000 * vc.standardFlowerBox) , 4) cost
- FROM tmp.ticketComponentCalculate tcc
- JOIN item i ON i.id = tcc.itemFk
- JOIN tmp.zoneOption zo ON zo.zoneFk = vZoneFk
- JOIN zone z ON z.id = vZoneFk
- JOIN agencyMode am ON am.id = z.agencyModeFk
- JOIN vn.volumeConfig vc
- JOIN vn.component c2 ON c2.code = 'delivery'
- LEFT JOIN itemCost ic ON ic.warehouseFk = tcc.warehouseFk
- AND ic.itemFk = tcc.itemFk
- HAVING cost <> 0;
-
- DROP TEMPORARY TABLE tmp.zoneOption;
- /*
- -- Extra reparto
- INSERT INTO tmp.ticketComponent(warehouseFk, itemFk, componentFk, cost)
- SELECT tcc.warehouseFk, tcc.itemFk, c2.id, ap.packagingValue cost
- FROM tmp.ticketComponentCalculate tcc
- JOIN vn.addressForPackaging ap
- JOIN vn.component c2 ON c2.code = 'bagged'
- WHERE ap.addressFk = vAddressFk;
- */
-
- DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentCopy;
- CREATE TEMPORARY TABLE tmp.ticketComponentCopy ENGINE = MEMORY
- SELECT * FROM tmp.ticketComponent;
-
- -- Precio especial
- INSERT INTO tmp.ticketComponent
- SELECT tcc.warehouseFk,
- tcc.itemFk,
- c2.id,
- sp.value - SUM(tcc.cost) sumCost
- FROM tmp.ticketComponentCopy tcc
- JOIN component c ON c.id = tcc.componentFk
- JOIN specialPrice sp ON sp.clientFk = vClientFK AND sp.itemFk = tcc.itemFk
- JOIN vn.component c2 ON c2.code = 'specialPrices'
- WHERE c.classRate IS NULL
- AND tcc.warehouseFk = vWarehouseFk
- GROUP BY tcc.itemFk, tcc.warehouseFk
- HAVING ABS(sumCost) > 0.001;
-
- -- Rappel
- INSERT INTO tmp.ticketComponent
- SELECT tcc.warehouseFk,
- tcc.itemFk,
- IFNULL(c.componentFk ,c2.id),
- SUM(tcc.cost) * ((1/(1-c.rappel/100)) -1) sumCost
- FROM tmp.ticketComponentCopy tcc
- JOIN vn.clientChain cc ON cc.clientFk = vClientFk
- JOIN vn.`chain` c ON c.id = cc.chainFk
- JOIN vn.component c2 ON c2.code = 'rappel'
- WHERE tcc.warehouseFk = vWarehouseFk
- GROUP BY tcc.itemFk, tcc.warehouseFk;
-
-
- DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentSum;
- CREATE TEMPORARY TABLE tmp.ticketComponentSum
- (INDEX (itemFk, warehouseFk))
- ENGINE = MEMORY
- SELECT SUM(cost) sumCost, tc.itemFk, tc.warehouseFk, c.classRate
- FROM tmp.ticketComponent tc
- JOIN component c ON c.id = tc.componentFk
- GROUP BY tc.itemFk, tc.warehouseFk, c.classRate;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentRate;
- CREATE TEMPORARY TABLE tmp.ticketComponentRate ENGINE = MEMORY
- SELECT tcc.warehouseFk,
- tcc.itemFk,
- 1 rate,
- IF(tcc.groupingMode = 1, tcc.`grouping`, 1) `grouping`,
- CAST(SUM(tcs.sumCost) AS DECIMAL(10,2)) price,
- CAST(SUM(tcs.sumCost) AS DECIMAL(10,2)) / weightGrouping priceKg
- FROM tmp.ticketComponentCalculate tcc
- JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk
- AND tcs.warehouseFk = tcc.warehouseFk
- WHERE IFNULL(tcs.classRate, 1) = 1
- AND tcc.groupingMode < 2 AND (tcc.packing > tcc.`grouping` or tcc.groupingMode = 0)
- GROUP BY tcs.warehouseFk, tcs.itemFk;
-
- INSERT INTO tmp.ticketComponentRate (warehouseFk, itemFk, rate, `grouping`, price, priceKg)
- SELECT
- tcc.warehouseFk,
- tcc.itemFk,
- 2 rate,
- tcc.packing `grouping`,
- SUM(tcs.sumCost) price,
- SUM(tcs.sumCost) / weightGrouping priceKg
- FROM tmp.ticketComponentCalculate tcc
- JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk
- AND tcs.warehouseFk = tcc.warehouseFk
- WHERE tcc.available IS NULL OR (IFNULL(tcs.classRate, 2) = 2
- AND tcc.packing > 0 AND tcc.available >= tcc.packing)
- GROUP BY tcs.warehouseFk, tcs.itemFk;
-
- INSERT INTO tmp.ticketComponentRate (warehouseFk, itemFk, rate, `grouping`, price, priceKg)
- SELECT
- tcc.warehouseFk,
- tcc.itemFk,
- 3 rate,
- tcc.available `grouping`,
- SUM(tcs.sumCost) price,
- SUM(tcs.sumCost) / weightGrouping priceKg
- FROM tmp.ticketComponentCalculate tcc
- JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk
- AND tcs.warehouseFk = tcc.warehouseFk
- WHERE IFNULL(tcs.classRate, 3) = 3
- GROUP BY tcs.warehouseFk, tcs.itemFk;
-
- INSERT INTO tmp.ticketComponentPrice (warehouseFk, itemFk, rate, `grouping`, price, priceKg)
- SELECT * FROM (
- SELECT * FROM tmp.ticketComponentRate ORDER BY price
- ) t
- GROUP BY itemFk, warehouseFk, `grouping`;
-
- DROP TEMPORARY TABLE
- tmp.ticketComponentCalculate,
- tmp.ticketComponentSum,
- tmp.ticketComponentBase,
- tmp.ticketComponentRate,
- tmp.ticketComponentCopy;
-
-END ;;
-DELIMITER ;
-/*!50003 SET sql_mode = @saved_sql_mode */ ;
-/*!50003 SET character_set_client = @saved_cs_client */ ;
-/*!50003 SET character_set_results = @saved_cs_results */ ;
-/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `catalog_componentCalculate_beta` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8 */ ;
-/*!50003 SET character_set_results = utf8 */ ;
-/*!50003 SET collation_connection = utf8_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `catalog_componentCalculate_beta`( vZoneFk INT,
- vAddressFk INT,
- vShipped DATE,
- vWarehouseFk INT)
-BEGIN
- /**
- * Calcula los componentes de los articulos de tmp.ticketLot
- *
- * @param vZoneFk para calcular el transporte
- * @param vAddressFk Consignatario
- * @param vShipped dia de salida del pedido
- * @param vWarehouseFk warehouse de salida del pedido
- * @table tmp.ticketLot (warehouseFk, available, itemFk, buyFk, zoneFk)
- * @table tmp.ticketComponent(warehouseFk, itemFk, componentFk, cost)
- *
- * @return tmp.ticketComponentPrice (warehouseFk, itemFk, rate, `grouping`, price, priceKg)
- */
-
DECLARE vClientFk INT;
DECLARE vIsFrenchVNHBuyer BOOLEAN DEFAULT FALSE;
DECLARE vVNHWarehouseFk INT DEFAULT 7;
@@ -52510,456 +51917,6 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `catalog_componentCalculate__` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8 */ ;
-/*!50003 SET character_set_results = utf8 */ ;
-/*!50003 SET collation_connection = utf8_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `catalog_componentCalculate__`(
- vZoneFk INT,
- vAddressFk INT,
- vShipped DATE,
- vWarehouseFk INT)
-proc: BEGIN
-/**
- * Calcula los componentes de los articulos de tmp.ticketLot
- *
- * @param vZoneFk para calcular el transporte
- * @param vAddressFk Consignatario
- * @param vShipped dia de salida del pedido
- * @param vWarehouseFk warehouse de salida del pedido
- * @param tmp.ticketLot (warehouseFk, available, itemFk, buyFk, zoneFk)
- * @table tmp.ticketComponent(warehouseFk, itemFk, componentFk, cost)
- *
- * @return tmp.ticketComponentPrice (warehouseFk, itemFk, rate, `grouping`, price, priceKg)
- */
- DECLARE vClientFk INT;
- DECLARE vMinimumDensityWeight INT DEFAULT 167;
- DECLARE vBoxVolume BIGINT;
- DECLARE vSpecialPriceComponent INT DEFAULT 10;
- DECLARE vDeliveryComponent INT DEFAULT 15;
- DECLARE vRecoveryComponent INT DEFAULT 17;
- DECLARE vSellByPacketComponent INT DEFAULT 22;
- DECLARE vBuyValueComponent INT DEFAULT 28;
- DECLARE vMarginComponent INT DEFAULT 29;
- DECLARE vDiscountLastItemComponent INT DEFAULT 32;
- DECLARE vExtraBaggedComponent INT DEFAULT 38;
- DECLARE vManaAutoComponent INT DEFAULT 39;
- DECLARE vFrenchOffer INT DEFAULT 42;
- DECLARE vIsFrenchVNHBuyer BOOLEAN DEFAULT FALSE;
- DECLARE vVNHWarehouseFk INT DEFAULT 7;
- DECLARE vFloramondoWarehouseFk INT DEFAULT 40;
- DECLARE vIsLogifloraAllowed BOOLEAN DEFAULT 0;
- DECLARE vMaxLogifloraDays INT;
- DECLARE vRangeLogifloraDays INT DEFAULT 3;
- DECLARE vVisibleCache INT;
- DECLARE vRappelComponent INT DEFAULT 44;
- DECLARE vIsZonePremium BOOL;
- DECLARE vFrenchDiscount DECIMAL(3,2) DEFAULT 0.12;
- DECLARE vIsCatalonianBuyer BOOL;
- DECLARE visAnyVolumeAllowed BOOL;
-
- SELECT (COUNT(*) > 0) INTO vIsZonePremium
- FROM vn.zoneFilter zf
- WHERE zf.zoneFk = vZoneFk;
-
- SELECT vc.standardFlowerBox * 1000 INTO vBoxVolume
- FROM vn.volumeConfig vc;
-
- SELECT clientFk, isLogifloraAllowed INTO vClientFK, vIsLogifloraAllowed
- FROM address
- WHERE id = vAddressFk;
-
- SELECT (c.country IN ('Francia','Suiza') AND vWarehouseFk IN (vVNHWarehouseFk, vFloramondoWarehouseFk))
- INTO vIsFrenchVNHBuyer
- FROM vn.country c
- JOIN vn.province p ON p.countryFk = c.id
- JOIN vn.address a ON a.provinceFk = p.id
- WHERE a.id = vAddressFk;
-
- SELECT (p.name = 'Barcelona' AND vWarehouseFk = vVNHWarehouseFk)
- INTO vIsCatalonianBuyer
- FROM vn.province p
- JOIN vn.address a ON a.provinceFk = p.id
- WHERE a.id = vAddressFk; -- PAK 18/10/21
-
- SELECT travellingDays INTO vMaxLogifloraDays
- FROM edi.warehouseFloramondo
- WHERE warehouseFk = vWarehouseFk;
-
- -- Se eliminan los productos de tamaños no convencionales, salvo agencias que lo permitan
- SELECT a.isAnyVolumeAllowed INTO visAnyVolumeAllowed
- FROM vn.agency a
- JOIN vn.agencyMode am ON am.agencyFk = a.id
- JOIN vn.`zone`z ON z.agencyModeFk = am.id
- WHERE z.id = vZoneFk;
-
- IF NOT vIsAnyVolumeAllowed THEN
-
- DELETE tl.*
- FROM tmp.ticketLot tl
- JOIN vn.item i ON i.id = tl.itemFk
- JOIN vn.itemType it ON it.id = i.typeFk
- WHERE it.isUnconventionalSize;
-
- END IF;
-
- -- Esto sirve para que los franceses compren sólo por las cuentas de VNH
- DELETE tl.*
- FROM tmp.ticketLot tl
- JOIN vn.item i ON i.id = tl.itemFk
- JOIN edi.supplyResponse sr ON sr.ID = i.supplyResponseFk
- JOIN edi.VMPSettings v ON v.VMPID = sr.vmpID
- WHERE v.isVNHSupplier != vIsFrenchVNHBuyer;
-
- IF (NOT vIsLogifloraAllowed AND vVNHWarehouseFk != vWarehouseFk)
- OR NOT vn.isLogifloraDay(vShipped, vWarehouseFk)
- -- OR NOT(vIsCatalonianBuyer OR vIsFrenchVNHBuyer)
- THEN
-
- CALL cache.visible_refresh(vVisibleCache, FALSE, vWarehouseFk);
-
- DELETE tl FROM tmp.ticketLot tl
- JOIN item i ON i.id = tl.itemFk
- LEFT JOIN cache.last_buy lb ON lb.item_id = i.id AND lb.warehouse_id = vWarehouseFk
- LEFT JOIN vn.buy b ON b.id = lb.buy_id
- LEFT JOIN vn.entry e ON e.id = b.entryFk
- LEFT JOIN vn.supplier s ON s.id = e.supplierFk -- PAK 13/10/21
- LEFT JOIN cache.visible v ON v.calc_id = vVisibleCache AND v.item_id = i.id
- LEFT JOIN (SELECT DISTINCT s.itemFk
- FROM vn.sale s
- JOIN vn.ticket t ON t.id = s.ticketFk
- WHERE t.warehouseFk = vWarehouseFk
- AND t.addressFk = vAddressFk
- AND t.shipped = vShipped
- AND t.zoneFk = vZoneFk) sub ON sub.itemFk = i.id
- WHERE (i.supplyResponseFk
- AND (IFNULL(e.isRaid,TRUE)
- OR s.nickname = 'INVENTARIO') -- PAK 13/10/21
- AND ISNULL(sub.itemFk)
- AND IFNULL(v.visible,0) = 0
- AND vWarehouseFk = tl.warehouseFk);
-
- END IF;
-
- -- Eliminem productes de la oferta que no deuen vore els francesos
- IF vIsFrenchVNHBuyer THEN
-
- CALL cache.visible_refresh(vVisibleCache, FALSE, vWarehouseFk);
-
- DELETE tl FROM tmp.ticketLot tl
- JOIN item i ON i.id = tl.itemFk
- JOIN edi.supplyResponse sr ON sr.ID = i.supplyResponseFk
- JOIN edi.marketPlace mp ON mp.id = sr.MarketPlaceID
- LEFT JOIN cache.visible v ON v.calc_id = vVisibleCache AND v.item_id = i.id
- LEFT JOIN (SELECT DISTINCT s.itemFk
- FROM vn.sale s
- JOIN vn.ticket t ON t.id = s.ticketFk
- WHERE t.warehouseFk = vWarehouseFk
- AND t.addressFk = vAddressFk
- AND t.shipped = vShipped
- AND t.zoneFk = vZoneFk) sub ON sub.itemFk = i.id
- WHERE (mp.isEarlyBird = FALSE
- AND IFNULL(sub.itemFk,0) = 0
- AND IFNULL(v.visible ,0) = 0);
-
- END IF;
-
- -- Eliminem productes de la oferta que no deuen vore les zones PREMIUM
- IF vIsZonePremium THEN
-
- DELETE tl.*
- FROM tmp.ticketLot tl
- JOIN item i ON i.id = tl.itemFk
- LEFT JOIN vn.zoneFilter zf ON zf.itemTypeFk = i.typeFk
- AND zf.zoneFk = vZoneFk
- AND i.`size` <= zf.sizeMax
- WHERE zf.id IS NULL ;
-
- END IF;
-
- -- Eliminem productes de la oferta que la zona no pot transportar
- DELETE tl.*
- FROM tmp.ticketLot tl
- JOIN item i ON i.id = tl.itemFk
- JOIN vn.zone z ON z.id = vZoneFk
- WHERE i.size > z.itemMaxSize;
-
- SET @rate2 := 0;
- SET @rate3 := 0;
- SET @minPrice := 0;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentCalculate;
- CREATE TEMPORARY TABLE tmp.ticketComponentCalculate
- (PRIMARY KEY (itemFk, warehouseFk))
- ENGINE = MEMORY
- SELECT
- tl.itemFk,
- tl.warehouseFk,
- tl.available,
- IF((@rate2 := IFNULL(pf.rate2, b.price2)) < i.minPrice AND i.hasMinPrice, i.minPrice, @rate2) * 1.0 rate2,
- @minPrice := IF((@rate3 := IFNULL(pf.rate3, b.price3)) < i.minPrice AND i.hasMinPrice, i.minPrice, @rate3) * 1.0 rate3,
- IFNULL(@minPrice, 0) AS minPrice,
- IFNULL(pf.packing, GREATEST(b.grouping, b.packing)) packing,
- IFNULL(pf.`grouping`, b.`grouping`) `grouping`,
- ABS(IFNULL(pf.box, b.groupingMode)) groupingMode,
- tl.buyFk,
- i.typeFk,
- IF(i.hasKgPrice, b.weight / b.packing, NULL) weightGrouping
- FROM tmp.ticketLot tl
- JOIN buy b ON b.id = tl.buyFk
- JOIN item i ON i.id = tl.itemFk
- JOIN itemType it ON it.id = i.typeFk
- LEFT JOIN itemCategory ic ON ic.id = it.categoryFk
- LEFT JOIN specialPrice sp ON sp.itemFk = i.id AND sp.clientFk = vClientFk
- LEFT JOIN (
- SELECT * FROM (
- SELECT pf.itemFk, pf.`grouping`, pf.packing, pf.box, pf.rate2, pf.rate3, zw.warehouseFk
- FROM priceFixed pf
- JOIN zoneWarehouse zw ON zw.zoneFk = vZoneFk AND (zw.warehouseFk = pf.warehouseFk OR pf.warehouseFk = 0)
- WHERE vShipped BETWEEN pf.started AND pf.ended ORDER BY pf.itemFk, pf.warehouseFk DESC
- ) tpf
- GROUP BY tpf.itemFk, tpf.warehouseFk
- ) pf ON pf.itemFk = tl.itemFk AND pf.warehouseFk = tl.warehouseFk
- WHERE b.buyingValue + b.freightValue + b.packageValue + b.comissionValue > 0.01 AND ic.merchandise <> 0
- AND tl.zoneFk = vZoneFk AND tl.warehouseFk = vWarehouseFk;
-
- -- Coste
- INSERT INTO tmp.ticketComponent (warehouseFk, itemFk, componentFk, cost)
- SELECT
- tcc.warehouseFk,
- tcc.itemFk,
- vBuyValueComponent,
- b.buyingValue + b.freightValue + b.packageValue + b.comissionValue
- FROM tmp.ticketComponentCalculate tcc
- JOIN buy b ON b.id = tcc.buyFk;
-
- -- Margen
- INSERT INTO tmp.ticketComponent (warehouseFk, itemFk, componentFk, cost)
- SELECT
- tcc.warehouseFk,
- tcc.itemFk,
- vMarginComponent,
- tcc.rate3 - b.buyingValue - b.freightValue - b.packageValue - b.comissionValue
- FROM tmp.ticketComponentCalculate tcc
- JOIN buy b ON b.id = tcc.buyFk;
-
- -- Promo Francia
- IF vIsFrenchVNHBuyer THEN
-
- INSERT INTO tmp.ticketComponent (warehouseFk, itemFk, componentFk, cost)
- SELECT
- tcc.warehouseFk,
- tcc.itemFk,
- vFrenchOffer,
- - vFrenchDiscount * (b.buyingValue + b.freightValue + b.packageValue + b.comissionValue) / ( 1 - vFrenchDiscount)
- FROM tmp.ticketComponentCalculate tcc
- JOIN buy b ON b.id = tcc.buyFk;
-
- END IF;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentBase;
- CREATE TEMPORARY TABLE tmp.ticketComponentBase ENGINE = MEMORY
- SELECT tc.itemFk, ROUND(SUM(tc.cost), 4) AS base, tc.warehouseFk
- FROM tmp.ticketComponent tc
- JOIN tmp.ticketComponentCalculate tcc ON tcc.itemFk = tc.itemFk AND tcc.warehouseFk = tc.warehouseFk
- GROUP BY tc.itemFk, warehouseFk;
-
- -- RECOBRO
- INSERT INTO tmp.ticketComponent(warehouseFk, itemFk, componentFk, cost)
- SELECT tcb.warehouseFk, tcb.itemFk, vRecoveryComponent,
- ROUND(tcb.base * LEAST(MAX(GREATEST(IFNULL(cr.priceIncreasing,0), IFNULL(cr1.priceIncreasing,0), IFNULL(cr2.priceIncreasing,0))), 0.25), 3)
- FROM tmp.ticketComponentBase tcb
- JOIN claimRatio cr ON cr.clientFk = vClientFk
- LEFT JOIN clientYoke cy1 ON cy1.leftOx = cr.clientFk
- LEFT JOIN claimRatio cr1 ON cr1.clientFk = cy1.rightOx
- LEFT JOIN clientYoke cy2 ON cy2.rightOx = cr.clientFk
- LEFT JOIN claimRatio cr2 ON cr2.clientFk = cy2.leftOx
- WHERE GREATEST(IFNULL(cr.priceIncreasing,0), IFNULL(cr1.priceIncreasing,0), IFNULL(cr2.priceIncreasing,0)) > 0.009
- GROUP BY tcb.itemFk;
-
- -- Mana auto
- INSERT INTO tmp.ticketComponent(warehouseFk, itemFk, componentFk, cost)
- SELECT tcb.warehouseFk, tcb.itemFk, vManaAutoComponent, ROUND(base * (0.01 + wm.pricesModifierRate), 3) as manaAuto
- FROM tmp.ticketComponentBase tcb
- JOIN `client` c on c.id = vClientFk
- JOIN workerMana wm ON c.salesPersonFk = wm.workerFk
- WHERE wm.isPricesModifierActivated
- HAVING manaAuto <> 0;
-
- -- Precios especiales
- INSERT INTO tmp.ticketComponent
- SELECT tcb.warehouseFk,
- tcb.itemFk,
- c.id,
- GREATEST(IFNULL(ROUND(tcb.base * c.tax, 4), 0), tcc.minPrice - tcc.rate3)
- FROM tmp.ticketComponentBase tcb
- JOIN component c
- JOIN tmp.ticketComponentCalculate tcc ON tcc.itemFk = tcb.itemFk AND tcc.warehouseFk = tcb.warehouseFk
- LEFT JOIN specialPrice sp ON sp.clientFk = vClientFk AND sp.itemFk = tcc.itemFk
- JOIN vn.item i ON i.id = tcb.itemFk
- WHERE c.id = vDiscountLastItemComponent
- AND c.tax <> 0
- AND tcc.minPrice < tcc.rate3
- AND sp.value IS NULL
- AND i.supplyResponseFk IS NULL; -- FLORAMONDO
-
- -- Venta por paquetes
- INSERT INTO tmp.ticketComponent
- SELECT tcc.warehouseFk, tcc.itemFk, vSellByPacketComponent, tcc.rate2 - tcc.rate3
- FROM tmp.ticketComponentCalculate tcc
- JOIN buy b ON b.id = tcc.buyFk
- LEFT JOIN specialPrice sp ON sp.clientFk = vClientFk AND sp.itemFk = tcc.itemFk
- WHERE sp.value IS NULL;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.zone;
- CREATE TEMPORARY TABLE IF NOT EXISTS tmp.zone (INDEX (id))
- ENGINE = MEMORY
- SELECT vZoneFk id;
-
- CALL zone_getOptionsForShipment(vShipped, TRUE);
-
- -- Reparto
- INSERT INTO tmp.ticketComponent
- SELECT tcc.warehouseFK,
- tcc.itemFk,
- vDeliveryComponent,
- z.inflation * ROUND(ic.cm3delivery * (IFNULL(zo.price,5000) - IFNULL(zo.bonus,0)) / vBoxVolume, 4) cost
- FROM tmp.ticketComponentCalculate tcc
- JOIN item i ON i.id = tcc.itemFk
- JOIN tmp.zoneOption zo ON zo.zoneFk = vZoneFk
- JOIN zone z ON z.id = vZoneFk
- JOIN agencyMode am ON am.id = z.agencyModeFk
- LEFT JOIN itemCost ic ON ic.warehouseFk = tcc.warehouseFk
- AND ic.itemFk = tcc.itemFk
- HAVING cost <> 0;
-
- DROP TEMPORARY TABLE tmp.zoneOption;
-
- -- Extra reparto
- IF (SELECT COUNT(*) FROM vn.addressForPackaging WHERE addressFk = vAddressFk) THEN
- INSERT INTO tmp.ticketComponent
- SELECT tcc.warehouseFk, b.itemFk, vExtraBaggedComponent, ap.packagingValue cost
- FROM tmp.ticketComponentCalculate tcc
- JOIN vn.addressForPackaging ap
- WHERE ap.addressFk = vAddressFk;
- END IF;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentCopy;
- CREATE TEMPORARY TABLE tmp.ticketComponentCopy ENGINE = MEMORY
- SELECT * FROM tmp.ticketComponent;
-
- -- Precio especial
- INSERT INTO tmp.ticketComponent
- SELECT tcc.warehouseFk,
- tcc.itemFk,
- vSpecialPriceComponent,
- sp.value - SUM(tcc.cost) sumCost
- FROM tmp.ticketComponentCopy tcc
- JOIN component c ON c.id = tcc.componentFk
- JOIN specialPrice sp ON sp.clientFk = vClientFK AND sp.itemFk = tcc.itemFk
- WHERE c.classRate IS NULL
- AND tcc.warehouseFk = vWarehouseFk
- GROUP BY tcc.itemFk, tcc.warehouseFk
- HAVING ABS(sumCost) > 0.001;
-
- -- Rappel
- INSERT INTO tmp.ticketComponent
- SELECT tcc.warehouseFk,
- tcc.itemFk,
- IFNULL(c.componentFk ,vRappelComponent),
- SUM(tcc.cost) * ((1/(1-c.rappel/100)) -1) sumCost
- FROM tmp.ticketComponentCopy tcc
- JOIN vn.clientChain cc ON cc.clientFk = vClientFk
- JOIN vn.`chain` c ON c.id = cc.chainFk
- WHERE tcc.warehouseFk = vWarehouseFk
- GROUP BY tcc.itemFk, tcc.warehouseFk;
-
-
- DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentSum;
- CREATE TEMPORARY TABLE tmp.ticketComponentSum
- (INDEX (itemFk, warehouseFk))
- ENGINE = MEMORY
- SELECT SUM(cost) sumCost, tc.itemFk, tc.warehouseFk, c.classRate
- FROM tmp.ticketComponent tc
- JOIN component c ON c.id = tc.componentFk
- GROUP BY tc.itemFk, tc.warehouseFk, c.classRate;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentRate;
- CREATE TEMPORARY TABLE tmp.ticketComponentRate ENGINE = MEMORY
- SELECT tcc.warehouseFk,
- tcc.itemFk,
- 1 rate,
- IF(tcc.groupingMode = 1, tcc.`grouping`, 1) `grouping`,
- CAST(SUM(tcs.sumCost) AS DECIMAL(10,2)) price,
- CAST(SUM(tcs.sumCost) AS DECIMAL(10,2)) / weightGrouping priceKg
- FROM tmp.ticketComponentCalculate tcc
- JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk
- AND tcs.warehouseFk = tcc.warehouseFk
- WHERE IFNULL(tcs.classRate, 1) = 1
- AND tcc.groupingMode < 2 AND (tcc.packing > tcc.`grouping` or tcc.groupingMode = 0)
- GROUP BY tcs.warehouseFk, tcs.itemFk;
-
- INSERT INTO tmp.ticketComponentRate (warehouseFk, itemFk, rate, `grouping`, price, priceKg)
- SELECT
- tcc.warehouseFk,
- tcc.itemFk,
- 2 rate,
- tcc.packing `grouping`,
- SUM(tcs.sumCost) price,
- SUM(tcs.sumCost) / weightGrouping priceKg
- FROM tmp.ticketComponentCalculate tcc
- JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk
- AND tcs.warehouseFk = tcc.warehouseFk
- WHERE tcc.available IS NULL OR (IFNULL(tcs.classRate, 2) = 2
- AND tcc.packing > 0 AND tcc.available >= tcc.packing)
- GROUP BY tcs.warehouseFk, tcs.itemFk;
-
- IF vIsZonePremium THEN
-
- DELETE
- FROM tmp.ticketComponentRate
- WHERE rate = 1;
-
- END IF;
-
- INSERT INTO tmp.ticketComponentRate (warehouseFk, itemFk, rate, `grouping`, price, priceKg)
- SELECT
- tcc.warehouseFk,
- tcc.itemFk,
- 3 rate,
- tcc.available `grouping`,
- SUM(tcs.sumCost) price,
- SUM(tcs.sumCost) / weightGrouping priceKg
- FROM tmp.ticketComponentCalculate tcc
- JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk
- AND tcs.warehouseFk = tcc.warehouseFk
- WHERE IFNULL(tcs.classRate, 3) = 3
- GROUP BY tcs.warehouseFk, tcs.itemFk;
-
- INSERT INTO tmp.ticketComponentPrice (warehouseFk, itemFk, rate, `grouping`, price, priceKg)
- SELECT * FROM (
- SELECT * FROM tmp.ticketComponentRate ORDER BY price
- ) t
- GROUP BY itemFk, warehouseFk, `grouping`;
-
- DROP TEMPORARY TABLE
- tmp.ticketComponentCalculate,
- tmp.ticketComponentSum,
- tmp.ticketComponentBase,
- tmp.ticketComponentRate,
- tmp.ticketComponentCopy;
-END ;;
-DELIMITER ;
-/*!50003 SET sql_mode = @saved_sql_mode */ ;
-/*!50003 SET character_set_client = @saved_cs_client */ ;
-/*!50003 SET character_set_results = @saved_cs_results */ ;
-/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `catalog_componentPrepare` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -54088,7 +53045,7 @@ BEGIN
FROM vn.warehouse
WHERE hasConfectionTeam;
- CALL vn.ticketCreateWithUser(
+ CALL vn.ticket_add(
vClientFk
,vn.VN_CURDATE()
,vWarehouseFk -- Algemesi
@@ -54098,6 +53055,7 @@ BEGIN
,NULL -- route
,vn.VN_CURDATE()
,account.myUser_getId()
+ ,TRUE
,vNewTicket);
INSERT INTO vn.sale(ticketFk, itemFk, quantity, concept, price)
@@ -54538,7 +53496,12 @@ DELIMITER ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `cmr_getByTicket`(vTicketFk INT)
BEGIN
+
+ DECLARE vLandingDays INT;
+ SELECT landingDays INTO vLandingDays
+ FROM vn.cmrConfig;
+
IF vTicketFk THEN
IF (SELECT count(ticketFk) FROM vn.cmr WHERE ticketFk = vTicketFk) THEN
@@ -54547,8 +53510,8 @@ BEGIN
ELSE
- INSERT INTO vn.cmr(ticketFk, companyFk, addressFromFk, addressToFk, supplierFk)
- SELECT vTicketFk, t.companyFk, a.id, t.addressFk, ag.supplierFk
+ INSERT INTO vn.cmr(ticketFk, companyFk, addressFromFk, addressToFk, supplierFk, ead)
+ SELECT vTicketFk, t.companyFk, a.id, t.addressFk, ag.supplierFk, vLandingDays
FROM vn.ticket t
JOIN vn.agencyMode am ON am.id = t.agencyModeFk
JOIN vn.agency ag ON ag.id = am.agencyFk
@@ -54562,7 +53525,7 @@ BEGIN
ELSE
- INSERT INTO vn.cmr(created) VALUES(vn.VN_NOW());
+ INSERT INTO vn.cmr(created, ead) VALUES(vn.VN_NOW(), vn.VN_NOW() + INTERVAL vLandingDays DAY);
SELECT LAST_INSERT_ID();
@@ -54997,54 +53960,6 @@ BEGIN
CALL vn.sale_calculateComponent(vSaleFk, null);
-END ;;
-DELIMITER ;
-/*!50003 SET sql_mode = @saved_sql_mode */ ;
-/*!50003 SET character_set_client = @saved_cs_client */ ;
-/*!50003 SET character_set_results = @saved_cs_results */ ;
-/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `collection_faults` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `collection_faults`(
- vShelvingFk VARCHAR(10),
- vQuantity INT,
- vItemFk INT)
-BEGIN
- DECLARE vQuantityTotal INT DEFAULT 0;
- DECLARE vshelve VARCHAR(2);
- DECLARE vdeep INT(11);
- DECLARE vpriority INT(11);
- DECLARE vgrouping SMALLINT(5);
- DECLARE vpacking INT(11);
- DECLARE vpackagingFk VARCHAR(10);
- DECLARE vlevel VARCHAR(45);
- DECLARE vuserFk INT(10);
-
-
- SELECT SUM(quantity),shelve,deep,priority,`grouping`,packing,packagingFk,`level`,userFk
- INTO vQuantityTotal,vshelve,vdeep,vpriority,vgrouping,vpacking,vpackagingFk,vlevel,vuserFk
- FROM vn.itemShelving
- WHERE shelvingFk = vShelvingFk COLLATE utf8_unicode_ci AND itemFk = vItemFk
- GROUP BY itemFk;
-
- SELECT vQuantityTotal - vQuantity INTO vQuantityTotal;
-
- DELETE FROM vn.itemShelving WHERE shelvingFk = vShelvingFk COLLATE utf8_unicode_ci AND itemFk = vItemFk;
-
- INSERT INTO vn.itemShelving (itemFk, shelvingFk,shelve,deep,quantity,visible,available,priority,`grouping`,packing,packagingFk,`level`,userFk )
- VALUES (vItemFk,vShelvingFk,vshelve,vdeep,vQuantityTotal,vQuantityTotal,vQuantityTotal,vpriority,vgrouping,vpacking,vpackagingFk,vlevel,vuserFk );
-
- SELECT * FROM vn.itemShelving
- WHERE shelvingFk = vShelvingFk COLLATE utf8_unicode_ci AND itemFk = vItemFk;
-
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -55264,7 +54179,16 @@ BEGIN
WHERE c.id = vClientFk
LIMIT 1;
- CALL ticketCreateWithUser(vClientFk, vn.VN_NOW(), vWarehouseFk, 442, vConsignatario, NULL, NULL, NULL, account.userGetId(), vTicketFk);
+ CALL ticket_add(vClientFk,
+ vn.VN_NOW(), vWarehouseFk,
+ 442,
+ vConsignatario,
+ NULL,
+ NULL,
+ NULL,
+ account.userGetId(),
+ TRUE,
+ vTicketFk);
SELECT t.id INTO vTicketFk FROM vn.ticket t WHERE t.created > DATE_SUB(vn.VN_NOW(), INTERVAL 1 DAY) AND t.clientFk = vClientFk AND t.warehouseFk = vWarehouseFk LIMIT 1;
@@ -55838,19 +54762,24 @@ proc:BEGIN
DECLARE vMaxTicketPrinted INT;
DECLARE vItemPackingTypeFk VARCHAR(1);
DECLARE hasAssignedTickets BOOLEAN;
- DECLARE vMaxNotReadyCollections INT DEFAULT 0;
+ DECLARE vMaxNotReadyCollections INT;
DECLARE vNotReadyCollections INT;
DECLARE vTrainFk INT DEFAULT 1;
-
- /*IF NOT vn.deviceProductionUser_Exists(vn.getUser()) THEN
+ DECLARE vUserFk INT;
+ DECLARE vHourMatters BOOL DEFAULT TRUE;
+
+ SELECT pc.ticketPrintedMax * vWagons, pc.ticketTrolleyMax * vWagons, pc.maxNotReadyCollections
+ INTO vMaxTicketPrinted, vMaxTickets, vMaxNotReadyCollections
+ FROM vn.productionConfig pc;
+ /*IF NOT vn.deviceProductionUser_Exists(vUserFk) THEN
LEAVE proc;
END IF;*/
- SELECT w.code INTO vWorkerCode
+ SELECT w.code, w.id INTO vWorkerCode, vUserFk
FROM vn.worker w
- WHERE w.id = vn.getUser();
+ WHERE w.id =account.userGetId();
-- Establecemos el almacén y si es un sector de preparación previa, así como el estado para los tickets que se vayan preparando
SELECT isPreviousPrepared, warehouseFk, itemPackingTypeFk
@@ -55861,8 +54790,8 @@ proc:BEGIN
-- Si está habilitado el modo cazador para las motos, y el usuario no esta registrado, se sale.
IF (SELECT isTractorHuntingMode FROM vn.deviceProductionConfig dpc) AND vItemPackingTypeFk = 'H' THEN
- IF (SELECT COUNT(*) FROM vn.workerWithoutTractor wwt WHERE wwt.workerFk = account.userGetId()) THEN
- INSERT INTO tmp.kk(userFk) VALUES(vn.getUser());
+ IF (SELECT COUNT(*) FROM vn.workerWithoutTractor wwt WHERE wwt.workerFk = vUserFk) THEN
+ CALL util.throw('Usuario no registrado con moto');
LEAVE proc;
END IF;
END IF;
@@ -55870,23 +54799,29 @@ proc:BEGIN
-- Si hay colecciones sin terminar, sale del proceso
SELECT count(*) INTO vNotReadyCollections
- FROM vn.collection c
- WHERE c.workerFk = vn.getUser()
- AND c.saleTotalCount > c.salePickedCount + 1
- AND c.created > TIMESTAMPADD(HOUR , -5,vn.VN_NOW());
+ FROM (
+ SELECT count(DISTINCT s.id) totalRow, count(DISTINCT st.id) pickedRow
+ FROM vn.collection c
+ JOIN vn.ticketCollection tc ON tc.collectionFk = c.id
+ JOIN vn.sale s ON s.ticketFk = tc.ticketFk
+ JOIN vn.state ss ON ss.code = 'PREPARED'
+ LEFT JOIN vn.saleTracking st ON st.saleFk = s.id AND st.stateFk = ss.id
+ WHERE c.workerFk = vUserFk
+ AND c.created >= TIMESTAMPADD(HOUR , -6,vn.VN_NOW())
+ AND s.quantity != 0
+ GROUP BY c.id
+ HAVING totalRow > pickedRow) sub;
IF vMaxNotReadyCollections < vNotReadyCollections THEN
-
+
+ CALL util.throw('Hay colecciones pendientes');
LEAVE proc;
END IF;
- SELECT ticketPrintedMax * vWagons, ticketTrolleyMax * vWagons
- INTO vMaxTicketPrinted, vMaxTickets
- FROM vn.productionConfig pc;
-
IF vIsPreviousPrepared THEN
+ CALL util.throw('Es de preparación previa');
LEAVE proc; -- Hasta que tengamos el altillo, vamos a cancelar esta opcion
SELECT id INTO vStateFk
@@ -55907,6 +54842,8 @@ proc:BEGIN
SET vTrainFk = 2;
+ SET vHourMatters = FALSE;
+
DELETE pb.*
FROM tmp.productionBuffer pb
JOIN vn.volumeConfig vc
@@ -55916,7 +54853,7 @@ proc:BEGIN
-- Se obtiene nº de colección y el buffer con los pedidos preparables
INSERT INTO vn.collection
- SET workerFk = account.myUser_getId(),
+ SET workerFk = vUserFk,
itemPackingTypeFk = vItemPackingTypeFk,
trainFk = vTrainFk;
@@ -55996,7 +54933,7 @@ proc:BEGIN
AND (
(pb.H > 0 AND vItemPackingTypeFk = 'H' AND ISNULL(pb.collectionH))
OR (pb.V > 0 AND vItemPackingTypeFk = 'V' AND ISNULL(pb.collectionV))
- OR (pb.N > 0 AND ISNULL(pb.collectionH) AND ISNULL(pb.collectionV))
+ OR (pb.H = 0 AND pb.V = 0 AND pb.N > 0 AND ISNULL(pb.collectionH) AND ISNULL(pb.collectionV))
)
AND (pc.isPreviousPreparationRequired = FALSE
OR pb.previousWithoutParking = FALSE);
@@ -56006,7 +54943,7 @@ proc:BEGIN
-- AutoPRINT
INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador)
- SELECT s2.id, pb.ticketFk, vn.getUser()
+ SELECT s2.id, pb.ticketFk, vUserFk
FROM tmp.productionBuffer pb
JOIN vn.agencyMode am ON am.id = pb.agencyModeFk
JOIN vn.agency a ON a.id = am.agencyFk
@@ -56025,7 +54962,7 @@ proc:BEGIN
AND (
(pb.H > 0 AND vItemPackingTypeFk = 'H' AND ISNULL(pb.collectionH))
OR (pb.V > 0 AND vItemPackingTypeFk = 'V' AND ISNULL(pb.collectionV))
- OR (pb.N > 0 AND ISNULL(pb.collectionH) AND ISNULL(pb.collectionV))
+ OR (pb.H = 0 AND pb.V = 0 AND pb.N > 0 AND ISNULL(pb.collectionH) AND ISNULL(pb.collectionV))
)
AND t.created < TIMESTAMPADD(MINUTE, - tc.pickingDelay , vn.VN_NOW())
AND (pc.isPreviousPreparationRequired = FALSE
@@ -56051,7 +54988,7 @@ proc:BEGIN
WHERE (
(pb.H > 0 AND vItemPackingTypeFk = 'H' AND ISNULL(pb.collectionH))
OR (pb.V > 0 AND vItemPackingTypeFk = 'V' AND ISNULL(pb.collectionV))
- OR (pb.N > 0 AND ISNULL(pb.collectionH) AND ISNULL(pb.collectionV))
+ OR (pb.H = 0 AND pb.V = 0 AND pb.N > 0 AND ISNULL(pb.collectionH) AND ISNULL(pb.collectionV))
)
AND (pb.ubicacion IS NOT NULL
OR a.isOwn = FALSE )
@@ -56139,11 +55076,15 @@ proc:BEGIN
LIMIT 1;
-- Hay que excluir aquellos que no tengan la misma hora de preparación
- DELETE
- FROM tmp.ticket
- WHERE HH != vHour
- OR mm != vMinute;
+ IF vHourMatters THEN
+ DELETE
+ FROM tmp.ticket
+ WHERE HH != vHour
+ OR mm != vMinute;
+
+ END IF;
+
-- En el caso de pedidos de más volumen de un carro, la colección será monoticket. Pero si el primer pedido
-- no es monoticket, excluimos a los de más de un carro
IF (SELECT (t.shelveLiters > vc.trolleyM3 * 1000)
@@ -56345,7 +55286,7 @@ proc:BEGIN
-- Actualiza el estado de los tickets
INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador)
- SELECT vStateFk, ticketFk, account.myUser_getId()
+ SELECT vStateFk, ticketFk, vUserFk
FROM vn.ticketCollection tc
WHERE tc.collectionFk = vCollectionFk;
@@ -56375,6 +55316,7 @@ proc:BEGIN
ELSE
+ CALL util.throw('No ha sido posible obtener colección');
DELETE FROM vn.collection WHERE id = vCollectionFk;
END IF;
@@ -56384,7 +55326,8 @@ proc:BEGIN
tmp.ticketShelveLiters,
tmp.ticket,
tmp.wagonsVolumetry,
- tmp.ticketShelve;
+ tmp.ticketShelve,
+ tmp.productionBuffer;
END ;;
DELIMITER ;
@@ -56392,7 +55335,7 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `collection_reject` */;
+/*!50003 DROP PROCEDURE IF EXISTS `collection_newWithWagon_beta` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
@@ -56402,25 +55345,671 @@ DELIMITER ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `collection_reject`(vSale INT, vQuantity INT)
+CREATE DEFINER=`root`@`localhost` PROCEDURE `collection_newWithWagon_beta`(vUserFk INT, vSectorFk INT, vWagons INT)
+proc:BEGIN
+
+ DECLARE vIsPreviousPrepared BOOLEAN;
+ DECLARE vCollectionFk INT;
+ DECLARE vWarehouseFk INT;
+ DECLARE vMaxTickets INT;
+ DECLARE vStateFk INT;
+ DECLARE vFirstTicketFk INT;
+ DECLARE vHour INT;
+ DECLARE vMinute INT;
+ DECLARE vWorkerCode VARCHAR(3);
+ DECLARE vWagon INT;
+ DECLARE vWagonCounter INT;
+ DECLARE vShelve INT;
+ DECLARE vTicket INT;
+ DECLARE vTicketToSplit INT;
+ DECLARE vPrintedTickets INT;
+ DECLARE vMaxTicketPrinted INT;
+ DECLARE vItemPackingTypeFk VARCHAR(1);
+ DECLARE hasAssignedTickets BOOLEAN;
+ DECLARE vMaxNotReadyCollections INT DEFAULT 0;
+ DECLARE vNotReadyCollections INT;
+ DECLARE vTrainFk INT DEFAULT 1;
+ DECLARE vNow DATETIME;
+
+ SELECT ticketPrintedMax * vWagons, ticketTrolleyMax * vWagons, pc.maxNotReadyCollections , vn.VN_NOW()
+ INTO vMaxTicketPrinted, vMaxTickets, vMaxNotReadyCollections, vNow
+ FROM vn.productionConfig pc;
+
+ SELECT w.code INTO vWorkerCode
+ FROM vn.worker w
+ WHERE w.id = vUserFk;
+
+ -- Establecemos el almacén y si es un sector de preparación previa, así como el estado para los tickets que se vayan preparando
+ SELECT isPreviousPrepared, warehouseFk, itemPackingTypeFk
+ INTO vIsPreviousPrepared, vWarehouseFk, vItemPackingTypeFk
+ FROM vn.sector
+ WHERE id = vSectorFk; -- Hola
+
+-- Si está habilitado el modo cazador para las motos, y el usuario no esta registrado, se sale.
+
+ IF (SELECT isTractorHuntingMode FROM vn.deviceProductionConfig dpc) AND vItemPackingTypeFk = 'H' THEN
+ IF (SELECT COUNT(*) FROM vn.workerWithoutTractor wwt WHERE wwt.workerFk = vUserFk) THEN
+ CALL util.throw('Usuario no registrado con moto');
+ LEAVE proc;
+ END IF;
+ END IF;
+
+-- Si hay colecciones sin terminar, sale del proceso
+ SELECT count(*) INTO vNotReadyCollections
+ FROM (
+ SELECT count(DISTINCT s.id) totalRow, count(DISTINCT st.id) pickedRow
+ FROM vn.collection c
+ JOIN vn.ticketCollection tc ON tc.collectionFk = c.id
+ JOIN vn.sale s ON s.ticketFk = tc.ticketFk
+ JOIN vn.state ss ON ss.code = 'PREPARED'
+ LEFT JOIN vn.saleTracking st ON st.saleFk = s.id AND st.stateFk = ss.id
+ WHERE c.workerFk = vUserFk
+ AND c.created >= TIMESTAMPADD(HOUR , -6,vn.VN_NOW())
+ AND s.quantity != 0
+ GROUP BY c.id
+ HAVING totalRow > pickedRow) sub;
+
+call util.debugAdd('wargo',CONCAT('vMaxNotReadyCollections ', vMaxNotReadyCollections));
+call util.debugAdd('wargo',CONCAT('vNotReadyCollections ',vNotReadyCollections));
+
+ IF vMaxNotReadyCollections < vNotReadyCollections THEN
+
+ CALL util.throw('Hay colecciones pendientes');
+ LEAVE proc;
+
+ END IF;
+
+ IF vIsPreviousPrepared THEN
+
+ CALL util.throw('Es de preparación previa');
+ LEAVE proc; -- Hasta que tengamos el altillo, vamos a cancelar esta opcion
+
+ SELECT id INTO vStateFk
+ FROM vn.state
+ WHERE `code` = 'PREVIOUS_PREPARATION';
+
+ ELSE
+
+ SELECT id INTO vStateFk
+ FROM vn.state
+ WHERE `code` = 'ON_PREPARATION';
+
+ END IF;
+
+ CALL vn.productionControl(vWarehouseFk, 0);
+
+ -- Esto hay que corregirlo añadiendo un nuevo parámetro al proc. PAK 23/12/21
+ IF vSectorFk = 65 THEN -- Pedidos pequeños
+
+ SET vTrainFk = 2;
+
+ DELETE pb.*
+ FROM tmp.productionBuffer pb
+ JOIN vn.volumeConfig vc
+ WHERE pb.m3 * 1000 > vc.minTicketVolume;
+
+ END IF;
+
+ -- Se obtiene nº de colección y el buffer con los pedidos preparables
+ INSERT INTO vn.collection
+ SET workerFk = vUserFk,
+ itemPackingTypeFk = vItemPackingTypeFk,
+ trainFk = vTrainFk;
+
+ SELECT LAST_INSERT_ID() INTO vCollectionFk;
+
+ -- 05/08/2021 PAK Jose Frau pide que los tickets de recogida en Algemesí sólo se saquen si están asignados.
+ DELETE pb.*
+ FROM tmp.productionBuffer pb
+ JOIN vn.state s ON s.id = pb.state
+ WHERE pb.agency = 'REC_ALGEMESI'
+ AND s.code != 'PICKER_DESIGNED';
+
+ -- 2/3/2022 PAK Se acuerda con Pepe que los pedidos con riesgo no se sacan aunque se asignen.
+ DELETE pb.*
+ FROM tmp.productionBuffer pb
+ WHERE pb.problem LIKE '%RIESGO%';
+
+ -- Comprobamos si hay tickets asignados. En ese caso, nos centramos exclusivamente en esos tickets
+ -- y los sacamos independientemente de problemas o tamaños
+ SELECT COUNT(*) INTO hasAssignedTickets
+ FROM tmp.productionBuffer pb
+ JOIN vn.state s ON s.id = pb.state
+ WHERE s.code = 'PICKER_DESIGNED'
+ AND pb.workerCode = vWorkerCode;
+
+ IF hasAssignedTickets THEN
+
+ UPDATE vn.collection
+ SET itemPackingTypeFk = NULL
+ WHERE id = vCollectionFk;
+
+ DROP TEMPORARY TABLE IF EXISTS tmp.ticketToSplit;
+ CREATE TEMPORARY TABLE tmp.ticketToSplit
+ SELECT pb.ticketFk
+ FROM tmp.productionBuffer pb
+ JOIN vn.state s ON s.id = pb.state
+ WHERE s.code = 'PICKER_DESIGNED'
+ AND pb.workerCode = vWorkerCode
+ ORDER BY HH,
+ mm,
+ s.`order` DESC,
+ pb.m3 DESC;
+
+ WHILE (SELECT COUNT(*) FROM tmp.ticketToSplit) DO
+
+ SELECT MIN(ticketFk) INTO vTicketToSplit
+ FROM tmp.ticketToSplit;
+
+ CALL vn.ticket_splitItemPackingType(vTicketToSplit);
+
+ INSERT INTO vn.ticketCollection(ticketFk, collectionFk)
+ SELECT ticketFk, vCollectionFk
+ FROM tmp.ticketIPT
+ WHERE (itemPackingTypeFk = vItemPackingTypeFk) ;
+
+ DELETE FROM tmp.ticketToSplit
+ WHERE ticketFk = vTicketToSplit;
+
+ DROP TEMPORARY TABLE tmp.ticketIPT;
+
+ END WHILE;
+
+ CALL vn.productionControl(vWarehouseFk, 0);
+
+ ELSE
+
+ SELECT COUNT(*) INTO vPrintedTickets
+ FROM tmp.productionBuffer pb
+ JOIN vn.state s ON s.id = pb.state
+ JOIN vn.agencyMode am ON am.id = pb.agencyModeFk
+ JOIN vn.agency a ON a.id = am.agencyFk
+ JOIN vn.productionConfig pc
+ WHERE pb.shipped = vn.VN_CURDATE()
+ AND (pb.ubicacion IS NOT NULL
+ OR a.isOwn = FALSE )
+ AND s.isPreparable
+ AND (
+ (pb.H > 0 AND vItemPackingTypeFk = 'H' AND ISNULL(pb.collectionH))
+ OR (pb.V > 0 AND vItemPackingTypeFk = 'V' AND ISNULL(pb.collectionV))
+ OR (pb.N > 0 AND ISNULL(pb.collectionH) AND ISNULL(pb.collectionV))
+ )
+ AND (pc.isPreviousPreparationRequired = FALSE
+ OR pb.previousWithoutParking = FALSE);
+
+call util.debugAdd('wargo',CONCAT('vMaxTicketPrinted ', vMaxTicketPrinted));
+call util.debugAdd('wargo',CONCAT('vPrintedTickets ',vPrintedTickets));
+
+ SET vMaxTicketPrinted = vMaxTicketPrinted - vPrintedTickets;
+
+ -- AutoPRINT
+
+ INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador)
+ SELECT s2.id, pb.ticketFk, vUserFk
+ FROM tmp.productionBuffer pb
+ JOIN vn.agencyMode am ON am.id = pb.agencyModeFk
+ JOIN vn.agency a ON a.id = am.agencyFk
+ JOIN vn.state s ON s.id = pb.state
+ JOIN vn.state s2 ON s2.code = 'PRINTED_AUTO'
+ JOIN vn.ticket t ON t.id = pb.ticketFk
+ JOIN vn.ticketConfig tc
+ JOIN vn.productionConfig pc
+ WHERE pb.shipped = vn.VN_CURDATE()
+ AND (LENGTH(pb.problem) = 0
+ OR (pb.problem = 'PEQUEÑO' AND vTrainFk = 2))
+ AND (pb.ubicacion IS NOT NULL
+ OR a.isOwn = FALSE )
+ AND s.isPrintable
+ AND s.isOK
+ AND (
+ (pb.H > 0 AND vItemPackingTypeFk = 'H' AND ISNULL(pb.collectionH))
+ OR (pb.V > 0 AND vItemPackingTypeFk = 'V' AND ISNULL(pb.collectionV))
+ OR (pb.N > 0 AND ISNULL(pb.collectionH) AND ISNULL(pb.collectionV))
+ )
+ AND t.created < TIMESTAMPADD(MINUTE, - tc.pickingDelay , vn.VN_NOW())
+ AND (pc.isPreviousPreparationRequired = FALSE
+ OR pb.previousWithoutParking = FALSE)
+ ORDER BY HH,
+ mm,
+ s.`order` DESC,
+ pb.m3 DESC
+ LIMIT vMaxTicketPrinted;
+
+ -- Se seleccionan los primeros tickets, asignando colección para dejarlos bloqueados a otros sacadores.
+ -- Se splitan los tickets preparables, para que solo tengan un tipo de empaquetado
+
+ DROP TEMPORARY TABLE IF EXISTS tmp.ticketToSplit;
+ CREATE TEMPORARY TABLE tmp.ticketToSplit
+ SELECT pb.ticketFk, IFNULL((pb.H + pb.V = 0),TRUE) isNeutral
+ FROM tmp.productionBuffer pb
+ JOIN vn.agencyMode am ON am.id = pb.agencyModeFk
+ JOIN vn.agency a ON a.id = am.agencyFk
+ JOIN vn.ticketStateToday tst ON tst.ticket = pb.ticketFk
+ JOIN vn.state s ON s.id = tst.state
+ JOIN vn.productionConfig pc
+ WHERE (
+ (pb.H > 0 AND vItemPackingTypeFk = 'H' AND ISNULL(pb.collectionH))
+ OR (pb.V > 0 AND vItemPackingTypeFk = 'V' AND ISNULL(pb.collectionV))
+ OR (pb.H = 0 AND pb.V = 0 AND pb.N > 0 AND ISNULL(pb.collectionH) AND ISNULL(pb.collectionV))
+ )
+ AND (pb.ubicacion IS NOT NULL
+ OR a.isOwn = FALSE )
+ AND LENGTH(pb.problem) = 0
+ AND s.isPreparable
+ AND (pc.isPreviousPreparationRequired = FALSE
+ OR pb.previousWithoutParking = FALSE)
+ ORDER BY pb.HH, pb.mm, s.`order` DESC
+ LIMIT vMaxTickets;
+
+call util.debugAdd('wargo',CONCAT('tmp.ticketToSplit ', (SELECT COUNT(*) FROM tmp.ticketToSplit)));
+
+ WHILE (SELECT COUNT(*) FROM tmp.ticketToSplit) DO
+
+ SELECT MIN(ticketFk) INTO vTicketToSplit
+ FROM tmp.ticketToSplit;
+
+
+ IF (SELECT isNeutral
+ FROM tmp.ticketToSplit
+ WHERE ticketFk = vTicketToSplit) THEN
+
+ INSERT INTO vn.ticketCollection(ticketFk, collectionFk)
+ VALUES(vTicketToSplit, vCollectionFk);
+
+call util.debugAdd('wargo',CONCAT('neutral ', vTicketToSplit));
+
+ ELSE
+
+ CALL vn.ticket_splitItemPackingType(vTicketToSplit);
+
+ INSERT INTO vn.ticketCollection(ticketFk, collectionFk)
+ SELECT ticketFk, vCollectionFk
+ FROM tmp.ticketIPT
+ WHERE itemPackingTypeFk = vItemPackingTypeFk;
+
+call util.debugAdd('wargo',CONCAT('NO neutral ',
+ (SELECT ticketFk FROM tmp.ticketIPT WHERE itemPackingTypeFk = vItemPackingTypeFk)));
+
+ DROP TEMPORARY TABLE tmp.ticketIPT;
+
+ END IF;
+
+ DELETE FROM tmp.ticketToSplit
+ WHERE ticketFk = vTicketToSplit;
+
+ END WHILE;
+
+ END IF;
+
+call util.debugAdd('wargo',CONCAT('vn.ticketCollection ',
+ (SELECT COUNT(*) FROM vn.ticketCollection WHERE collectionFk = vCollectionFk)));
+
+ -- Creamos una tabla temporal con los datos que necesitamos para depurar la colección
+ DROP TEMPORARY TABLE IF EXISTS tmp.ticket;
+ CREATE TEMPORARY TABLE tmp.ticket
+ SELECT pb.ticketFk,
+ pb.`lines`,
+ pb.m3 * 1000 liters,
+ 0 as height,
+ 0 as shelve,
+ 0 as wagon,
+ 0 AS shelveLiters,
+ pb.productionOrder,
+ pb.HH,
+ pb.mm
+ FROM tmp.productionBuffer pb
+ JOIN vn.ticketCollection tc ON tc.ticketFk = pb.ticketFk
+ WHERE tc.collectionFk = vCollectionFk
+ LIMIT vMaxTickets;
+
+ -- Voumen de las lineas de los pedidos, de acuerdo con el packingShelve establecido por los controladores
+ DROP TEMPORARY TABLE IF EXISTS tmp.ticketShelveLiters;
+ CREATE TEMPORARY TABLE tmp.ticketShelveLiters
+ SELECT t.ticketFk, SUM(s.quantity * vc.shelveVolume / i.packingShelve) shelveLiters
+ FROM tmp.ticket t
+ JOIN vn.sale s ON s.ticketFk = t.ticketFk
+ JOIN vn.item i ON i.id = s.itemFk
+ JOIN vn.volumeConfig vc
+ WHERE i.packingShelve
+ GROUP BY t.ticketFk;
+
+ UPDATE tmp.ticket t
+ JOIN tmp.ticketShelveLiters tsl ON tsl.ticketFk = t.ticketFk
+ SET t.shelveLiters = tsl.shelveLiters;
+
+ -- Es importante que el primer ticket se coja en todos los casos
+
+ SET vFirstTicketFk = 0;
+
+ SELECT ticketFk, HH, mm
+ INTO vFirstTicketFk, vHour, vMinute
+ FROM tmp.ticket
+ ORDER BY productionOrder DESC, HH, mm
+ LIMIT 1;
+
+call util.debugAdd('wargo',CONCAT('vFirstTicketFk ', vFirstTicketFk));
+call util.debugAdd('wargo',CONCAT('vHour ', vHour));
+call util.debugAdd('wargo',CONCAT('vMinute ', vMinute));
+
+call util.debugAdd('wargo',CONCAT('tmp.ticket ', (SELECT COUNT(*) FROM tmp.ticket)));
+
+ -- Hay que excluir aquellos que no tengan la misma hora de preparación
+ DELETE
+ FROM tmp.ticket
+ WHERE HH != vHour
+ OR mm != vMinute;
+
+call util.debugAdd('wargo',CONCAT('tmp.ticket misma hora ', (SELECT COUNT(*) FROM tmp.ticket)));
+
+ -- En el caso de pedidos de más volumen de un carro, la colección será monoticket. Pero si el primer pedido
+ -- no es monoticket, excluimos a los de más de un carro
+ IF (SELECT (t.shelveLiters > vc.trolleyM3 * 1000)
+ FROM tmp.ticket t
+ JOIN vn.volumeConfig vc
+ WHERE t.ticketFk = vFirstTicketFk) THEN
+
+ DELETE
+ FROM tmp.ticket
+ WHERE ticketFk != vFirstTicketFk;
+
+ ELSE
+
+ DELETE t.*
+ FROM tmp.ticket t
+ JOIN vn.volumeConfig vc
+ WHERE t.shelveLiters > vc.trolleyM3 * 1000;
+
+ END IF;
+
+call util.debugAdd('wargo',CONCAT('tmp.ticket volumen ', (SELECT COUNT(*) FROM tmp.ticket)));
+
+ -- Elimina los tickets bloqueados que no se van a preparar
+ DELETE tc.*
+ FROM vn.ticketCollection tc
+ LEFT JOIN tmp.ticket t ON t.ticketFk = tc.ticketFk
+ WHERE tc.collectionFk = vCollectionFk
+ AND t.ticketFk IS NULL;
+
+call util.debugAdd('wargo',CONCAT('vn.ticketCollection ',
+ (SELECT COUNT(*) FROM vn.ticketCollection WHERE collectionFk = vCollectionFk)));
+
+ -- Construccion del tren
+
+ -- Establece altura máxima por pedido, porque las plantas no se pueden recostar.
+ UPDATE tmp.ticket t
+ JOIN
+ ( SELECT MAX(i.size) maxHeigth,
+ tc.ticketFk
+ FROM vn.ticketCollection tc
+ JOIN vn.sale s ON s.ticketFk = tc.ticketFk
+ JOIN vn.item i ON i.id = s.itemFk
+ WHERE i.itemPackingTypeFk = 'V'
+ AND tc.collectionFk = vCollectionFk
+ GROUP BY tc.ticketFk) sub ON sub.ticketFk = t.ticketFk
+ SET t.height = IFNULL(sub.maxHeigth,0);
+
+ -- Vamos a generar una tabla con todas las posibilidades de asignacion de pedido
+ DROP TEMPORARY TABLE IF EXISTS tmp.wagonsVolumetry;
+ CREATE TEMPORARY TABLE tmp.wagonsVolumetry
+ SELECT cv.`level` as shelve,
+ 1 as wagon,
+ cv.`lines`,
+ cv.liters,
+ cv.height
+ FROM vn.collectionVolumetry cv
+ WHERE cv.itemPackingTypeFk = IFNULL(vItemPackingTypeFk, 'H')
+ AND cv.trainFk = vTrainFk;
+
+ SET vWagonCounter = 1;
+
+ WHILE vWagonCounter < vWagons DO
+
+ SET vWagonCounter = vWagonCounter + 1;
+
+ INSERT INTO tmp.wagonsVolumetry(shelve, wagon, `lines`, liters, height)
+ SELECT cv.`level` as shelve,
+ vWagonCounter as wagon,
+ cv.`lines`,
+ cv.liters,
+ cv.height
+ FROM vn.collectionVolumetry cv
+ WHERE cv.itemPackingTypeFk = IFNULL(vItemPackingTypeFk, 'H')
+ AND cv.trainFk = vTrainFk;
+
+ END WHILE;
+
+ DROP TEMPORARY TABLE IF EXISTS tmp.ticketShelve;
+ CREATE TEMPORARY TABLE tmp.ticketShelve
+ SELECT ticketFk, shelve, wagon, linesDif, LitersDif, heightDif
+ FROM (
+ SELECT t.ticketFk,
+ wv.shelve,
+ wv.wagon,
+ t.productionOrder,
+ CAST(wv.`lines` AS SIGNED) - t.`lines` as linesDif,
+ CAST(wv.liters AS SIGNED) - t.shelveLiters as litersDif,
+ CAST(wv.height AS SIGNED) - t.height as heightDif
+ FROM tmp.wagonsVolumetry wv
+ JOIN tmp.ticket t
+ ) sub
+ WHERE linesDif >= 0
+ AND litersDif >= 0
+ AND heightDif >= 0
+ ORDER BY productionOrder DESC, linesDif, LitersDif, heightDif ;
+
+ -- Insertamos una opcion virtual para carro completo. Todo ticket tiene que poder entrar en un carro completo....
+ INSERT INTO tmp.ticketShelve(ticketFk, shelve, wagon, linesDif, LitersDif, heightDif)
+ SELECT t.ticketFk, 0, wv.wagon, 999, 999,999
+ FROM tmp.ticket t
+ JOIN tmp.wagonsVolumetry wv
+ GROUP BY t.ticketFk, wv.wagon;
+
+ SET vWagonCounter = 0;
+
+ WHILE vWagonCounter < vWagons DO
+
+ SET vWagonCounter = vWagonCounter + 1;
+
+ -- Asignamos la primera balda util al primer pedido
+ IF vWagonCounter = 1 THEN
+
+ SELECT shelve INTO vShelve
+ FROM tmp.ticketShelve
+ WHERE ticketFk = vFirstTicketFk
+ AND wagon = vWagonCounter
+ ORDER BY heightDif, litersDif, linesDif
+ LIMIT 1;
+
+ ELSE
+
+ SELECT shelve, ticketFk INTO vShelve, vFirstTicketFk
+ FROM tmp.ticketShelve
+ WHERE wagon = vWagonCounter
+ ORDER BY heightDif, litersDif, linesDif
+ LIMIT 1;
+
+ END IF;
+
+ IF vShelve > 0 THEN
+
+ UPDATE tmp.ticket
+ SET shelve = vShelve,
+ wagon = vWagonCounter
+ WHERE ticketFk = vFirstTicketFk;
+
+ DELETE FROM tmp.ticketShelve
+ WHERE ticketFk = vFirstTicketFk
+ OR (shelve = vShelve AND wagon = vWagonCounter);
+
+ WHILE (SELECT COUNT(*) FROM tmp.ticketShelve WHERE wagon = vWagonCounter) DO
+
+ SELECT ticketFk, shelve
+ INTO vTicket, vShelve
+ FROM tmp.ticketShelve
+ WHERE wagon = vWagonCounter
+ LIMIT 1;
+
+ UPDATE tmp.ticket
+ SET shelve = vShelve,
+ wagon = vWagonCounter
+ WHERE ticketFk = vTicket;
+
+ DELETE FROM tmp.ticketShelve
+ WHERE ticketFk = vTicket
+ OR (shelve = vShelve AND wagon = vWagonCounter);
+
+ END WHILE;
+
+ ELSE
+
+ UPDATE tmp.ticket
+ SET shelve = 1, wagon = vWagonCounter
+ WHERE ticketFk = vFirstTicketFk;
+
+ DELETE FROM tmp.ticketShelve
+ WHERE ticketFk = vFirstTicketFk
+ AND wagon != vWagonCounter;
+
+ END IF;
+
+ END WHILE;
+
+ -- Eliminamos los que se han quedado sin balda
+ DELETE FROM tmp.ticket WHERE shelve = 0;
+
+ -- Elimina los tickets bloqueados que no se van a preparar
+ DELETE tc.*
+ FROM vn.ticketCollection tc
+ LEFT JOIN tmp.ticket t ON t.ticketFk = tc.ticketFk
+ WHERE tc.collectionFk = vCollectionFk
+ AND t.ticketFk IS NULL;
+
+call util.debugAdd('wargo',CONCAT('vn.ticketCollection bloqueados ',
+ (SELECT COUNT(*) FROM vn.ticketCollection WHERE collectionFk = vCollectionFk)));
+
+ -- Elimina los tickets que ya estan en otra coleccion
+ DELETE tc.*
+ FROM vn.ticketCollection tc
+ JOIN vn.ticketCollection tc2 ON tc2.ticketFk = tc.ticketFk
+ WHERE tc.collectionFk = vCollectionFk
+ AND tc2.collectionFk != vCollectionFk;
+
+call util.debugAdd('wargo',CONCAT('vn.ticketCollection otra coleccion ',
+ (SELECT COUNT(*) FROM vn.ticketCollection WHERE collectionFk = vCollectionFk)));
+
+ -- Actualiza el estado de la colección
+ UPDATE vn.collection c
+ JOIN vn.state st ON st.code = 'ON_PREPARATION'
+ SET c.stateFk = st.id
+ WHERE c.id = vCollectionFk;
+
+ -- Asigna las bandejas
+ UPDATE vn.ticketCollection tc
+ JOIN tmp.ticket t ON t.ticketFk = tc.ticketFk
+ SET tc.level = t.shelve,
+ tc.wagon = t.wagon,
+ tc.itemCount = t.`lines`,
+ tc.liters = t.shelveLiters;
+
+ -- Actualiza el estado de los tickets
+ INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador)
+ SELECT vStateFk, ticketFk, vUserFk
+ FROM vn.ticketCollection tc
+ WHERE tc.collectionFk = vCollectionFk;
+
+ -- Aviso para la preparacion previa
+ INSERT INTO vn.ticketDown(ticketFk, collectionFk)
+ SELECT tc.ticketFk, tc.collectionFk
+ FROM vn.ticketCollection tc
+ WHERE tc.collectionFk = vCollectionFk;
+
+ SELECT * FROM util.debug
+ where variable = 'wargo'
+ and created >= vNow
+ order by created;
+
+ IF (SELECT count(*) FROM vn.ticketCollection WHERE collectionFk = vCollectionFk) THEN
+
+ CALL vn.salesMerge_byCollection(vCollectionFk);
+
+ UPDATE vn.collection c
+ JOIN (SELECT count(*) saleTotalCount ,
+ sum(s.isPicked != 0) salePickedCount
+ FROM vn.ticketCollection tc
+ JOIN vn.sale s ON s.ticketFk = tc.ticketFk
+ WHERE tc.collectionFk = vCollectionFk
+ AND s.quantity > 0
+ ) sub
+ SET c.saleTotalCount = sub.saleTotalCount,
+ c.salePickedCount = sub.salePickedCount
+ WHERE c.id = vCollectionFk;
+
+ SELECT vCollectionFk;
+
+ ELSE
+
+ DELETE FROM vn.collection WHERE id = vCollectionFk;
+
+ CALL util.throw('No se ha obtenido colección');
+
+ END IF;
+
+ DROP TEMPORARY TABLE
+ tmp.ticketToSplit,
+ tmp.ticketShelveLiters,
+ tmp.ticket,
+ tmp.wagonsVolumetry,
+ tmp.ticketShelve,
+ tmp.productionBuffer;
+
+END ;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
+/*!50003 DROP PROCEDURE IF EXISTS `collection_printSticker` */;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+DELIMITER ;;
+CREATE DEFINER=`root`@`localhost` PROCEDURE `collection_printSticker`(vCollection INT)
BEGIN
-
- DECLARE vDescription VARCHAR(100);
- DECLARE vOriginalQuantity INT;
- DECLARE vConcept VARCHAR(100);
- DECLARE vOrigin INT;
- SELECT concept INTO vConcept FROM sale WHERE id = vSale;
- SELECT ticketFk INTO vOrigin FROM sale WHERE id = vSale;
- SELECT quantity INTO vOriginalQuantity FROM sale WHERE id = vSale;
- SELECT CONCAT("Cambio cantidad ",vConcept," de ", vOriginalQuantity," a ", vQuantity) INTO vDescription;
+ /*Imprime una etiqueta amarilla a partir de una colección
+ *
+ * @param vCollection colección
+ * @param vPrinterFk id de la impresora
+ */
- INSERT INTO ticketLog (originFk, userFk, action , description)
- VALUES(vOrigin, getUser(), 'update', vDescription);
+ DECLARE vLabelReportFk INT;
+ DECLARE vLabelerFk INT;
- UPDATE sale SET originalQuantity = vOriginalQuantity, quantity = vQuantity WHERE id = vSale;
+ SELECT s.labelReportFk, w.labelerFk INTO vLabelReportFk, vLabelerFk
+ FROM worker w
+ LEFT JOIN sector s ON s.id= w.sectorFk
+ WHERE w.id=account.myUser_getId() ;
+
+ IF vLabelReportFk AND vLabelerFk THEN
+
+ INSERT INTO ticketTrolley(ticket, labelCount)
+ SELECT ticketFk, 1
+ FROM ticketCollection
+ WHERE collectionFk = vCollection
+ ON DUPLICATE KEY UPDATE labelCount = labelCount + 1;
+
+ INSERT INTO printServerQueue(labelReportFk, param1, workerFk,printerFk)
+ SELECT vLabelReportFk, vCollection, getUser(),vLabelerFk;
+
+ END IF;
+
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -58378,10 +57967,10 @@ BEGIN
putOrderFk,
`ref`,
kop)
- SELECT year(vn.VN_CURDATE()) entryYear,
+ SELECT year(curdate()) entryYear,
p.id deliveryNumber ,
vn.VN_CURDATE() fec,
- vn.VN_CURTIME() hor,
+ CURTIME() hor,
i.longName item,
sr.NumberOfItemsPerCask pac,
p.quantity qty,
@@ -59179,63 +58768,61 @@ DELIMITER ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `entry_fixMisfit`(vSelf INT)
BEGIN
-
- /* Arregla el descuadre de una entrada, agregando registros en vn.buy para compensar la diferencia
- * entre las etiquetas impresas y las etiquetas esperadas
- *
- */
-
+/**
+ * Arregla el descuadre de una entrada, agregando registros en vn.buy
+ * para compensar la diferencia * entre las etiquetas impresas y las esperadas
+ *
+ * @param vSelf Identificador de la entrada
+ */
INSERT INTO vn.buy(entryFk, itemFk)
- SELECT vSelf, i.id
- FROM vn.item i
+ SELECT vSelf, i.id
+ FROM vn.item i
WHERE i.description = 'MISFIT'
LIMIT 1;
- INSERT INTO vn.buy(entryFk,
- itemFk,
- quantity,
- buyingValue,
- freightValue,
- isIgnored,
- stickers,
- packing,
- `grouping`,
- groupingMode,
- containerFk,
- comissionValue,
- packageValue,
- location,
- packageFk,
- price1,
- price2,
- price3,
- minPrice,
+ INSERT INTO vn.buy(entryFk,
+ itemFk,
+ quantity,
+ buyingValue,
+ freightValue,
+ isIgnored,
+ stickers,
+ packing,
+ `grouping`,
+ groupingMode,
+ containerFk,
+ comissionValue,
+ packageValue,
+ location,
+ packageFk,
+ price1,
+ price2,
+ price3,
+ minPrice,
producer)
SELECT vSelf,
- itemFk,
- (printedStickers - stickers) * packing AS quantity,
- buyingValue,
- freightValue,
- TRUE isIgnored,
- printedStickers - stickers,
- packing,
- `grouping`,
- groupingMode,
- containerFk,
- comissionValue,
- packageValue,
- location,
- packageFk,
- price1,
- price2,
- price3,
- minPrice,
+ itemFk,
+ (printedStickers - stickers) * packing quantity,
+ buyingValue,
+ freightValue,
+ TRUE isIgnored,
+ printedStickers - stickers,
+ packing,
+ `grouping`,
+ groupingMode,
+ containerFk,
+ comissionValue,
+ packageValue,
+ location,
+ packageFk,
+ price1,
+ price2,
+ price3,
+ minPrice,
producer
FROM vn.buy b
WHERE b.entryFk = vSelf
AND b.printedStickers != b.stickers;
-
-
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -59298,23 +58885,21 @@ DELIMITER ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_general_ci */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `entry_moveNotPrinted`(vSelf INT, vDays INT, vChangeEntry BOOL, OUT vNewEntryFk INT)
BEGIN
-
- /**
- * Crea una entrada a futuro y divide las lineas de vn.buy de la entrada original en función
- * de las etiquetas impresas
- *
- * @param vSelf Identificador de vn.entry
- * @param vDays Número de dias a futuro que se quiere la nueva entrada
- *
- * @return vNewEntryFk Identificador de la nueva entrada
- */
-
+/**
+ * Crea una entrada a futuro y divide las lineas de vn.buy de la entrada original en función
+ * de las etiquetas impresas
+ *
+ * @param vSelf Identificador de vn.entry
+ * @param vDays Número de dias a futuro que se quiere la nueva entrada
+ *
+ * @return vNewEntryFk Identificador de la nueva entrada
+ */
DECLARE vNewTravelFk INT;
DECLARE vTravelFk INT;
@@ -59323,7 +58908,6 @@ BEGIN
WHERE id = vSelf;
CALL vn.travel_clone(vTravelFk, vDays, vNewTravelFk);
-
CALL vn.entry_cloneWithoutBuy(vSelf, vNewEntryFk);
UPDATE vn.entry e
@@ -59331,10 +58915,12 @@ BEGIN
e.evaNotes = CONCAT('No impresas de: ', vSelf, ' ', IFNULL(e.evaNotes,''))
WHERE e.id = vNewEntryFk;
- UPDATE vn.buy b
- SET b.entryFk = vNewEntryFk
- WHERE b.printedStickers = 0
- AND b.entryFk = vSelf;
+ IF vChangeEntry THEN
+ UPDATE vn.buy b
+ SET b.entryFk = vNewEntryFk
+ WHERE b.printedStickers = 0
+ AND b.entryFk = vSelf;
+ END IF;
INSERT INTO vn.buy( entryFk,
itemFk,
@@ -59387,10 +58973,59 @@ BEGIN
IF vChangeEntry THEN
UPDATE vn.buy
SET stickers = printedStickers,
- quantity = printedStickers * packing
+ quantity = printedStickers * packing
WHERE entryFk = vSelf;
+ ELSE
+ INSERT INTO vn.buy(entryFk, itemFk)
+ SELECT vSelf, i.id
+ FROM vn.item i
+ WHERE i.description = 'MISFIT'
+ LIMIT 1;
+
+ INSERT INTO vn.buy(entryFk,
+ itemFk,
+ quantity,
+ buyingValue,
+ freightValue,
+ isIgnored,
+ stickers,
+ packing,
+ `grouping`,
+ groupingMode,
+ containerFk,
+ comissionValue,
+ packageValue,
+ location,
+ packageFk,
+ price1,
+ price2,
+ price3,
+ minPrice,
+ producer)
+ SELECT vSelf,
+ itemFk,
+ (printedStickers - stickers) * packing quantity,
+ buyingValue,
+ freightValue,
+ TRUE isIgnored,
+ printedStickers - stickers,
+ packing,
+ `grouping`,
+ groupingMode,
+ containerFk,
+ comissionValue,
+ packageValue,
+ location,
+ packageFk,
+ price1,
+ price2,
+ price3,
+ minPrice,
+ producer
+ FROM vn.buy
+ WHERE entryFk = vSelf
+ AND printedStickers != stickers;
END IF;
-
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -59456,48 +59091,68 @@ DELIMITER ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `entry_splitByShelving`(vShelvingFk VARCHAR(3), vFromEntryFk INT, vToEntryFk INT)
BEGIN
- /**
- * Divide las compras entre dos entradas de acuerdo con lo ubicado en una matr�cula
- *
- * @param vShelvingFk Identificador de vn.shelving
- * @param vFromEntryFk Entrada origen
- * @param vToEntryFk Entrada destino
- */
-
- DECLARE vItemFk INT;
- DECLARE vStickers INT;
+/**
+ * Divide las compras entre dos entradas de acuerdo con lo ubicado en una matr�cula
+ *
+ * @param vShelvingFk Identificador de vn.shelving
+ * @param vFromEntryFk Entrada origen
+ * @param vToEntryFk Entrada destino
+ */
DECLARE vBuyFk INT;
- DECLARE vHasSameStickers BOOL;
+ DECLARE ishStickers INT;
+ DECLARE buyStickers INT;
DECLARE vDone BOOLEAN DEFAULT FALSE;
+
DECLARE cur CURSOR FOR
- SELECT itemFk, FLOOR(quantity / packing) AS stickers
- FROM vn.itemShelving WHERE shelvingFk = vShelvingFk COLLATE utf8_general_ci ;
+ SELECT bb.id buyFk,
+ FLOOR(ish.visible / ish.packing) AS ishStickers,
+ bb.stickers buyStickers
+ FROM vn.itemShelving ish
+ JOIN (SELECT b.id, b.itemFk, b.stickers
+ FROM vn.buy b
+ WHERE b.entryFk = vFromEntryFk
+ ORDER BY b.stickers DESC) bb ON bb.itemFk = ish.itemFk
+ AND bb.stickers >= FLOOR(ish.visible / ish.packing)
+ WHERE shelvingFk = vShelvingFk COLLATE utf8_general_ci
+ GROUP BY ish.id;
+
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
+ -- Cantidades de la matrícula que exceden la de las entradas
+ SELECT ish.itemFk,
+ i.longName,
+ FLOOR(ish.visible / ish.packing) AS etiEnMatricula,
+ bb.stickers etiEnEntrada
+ FROM vn.itemShelving ish
+ JOIN vn.item i ON i.id = ish.itemFk
+ LEFT JOIN (SELECT b.id, b.itemFk, b.stickers
+ FROM vn.buy b
+ WHERE b.entryFk = vFromEntryFk
+ ORDER BY b.stickers DESC) bb ON bb.itemFk = ish.itemFk
+ WHERE shelvingFk = vShelvingFk COLLATE utf8_general_ci
+ AND IFNULL(bb.stickers,0) < FLOOR(ish.visible / ish.packing)
+ GROUP BY ish.id;
+
OPEN cur;
read_loop: LOOP
-
- FETCH cur INTO vItemFk, vStickers;
-
- IF vDone THEN
- LEAVE read_loop;
- END IF;
+ SET vDone = FALSE;
- SELECT b.id, (stickers = vStickers) INTO vBuyFk, vHasSameStickers
- FROM vn.buy
- WHERE entryFk = vFromEntryFk
- AND itemFk = vItemFk
- AND stickers >= vStickers
- LIMIT 1;
-
- IF vHasSameStickers THEN
-
- UPDATE vn.buy SET entryFk = vToEntryFk WHERE id = vBuyFk;
+ FETCH cur INTO vBuyFk, ishStickers, buyStickers;
+
+ IF vDone THEN
+ LEAVE read_loop;
+ END IF;
+ IF ishStickers = buyStickers THEN
+ UPDATE vn.buy
+ SET entryFk = vToEntryFk
+ WHERE id = vBuyFk;
ELSE
-
- UPDATE vn.buy SET stickers = stickers - vStickers WHERE id = vBuyFk;
+ UPDATE vn.buy
+ SET stickers = stickers - ishStickers,
+ quantity = stickers * packing
+ WHERE id = vBuyFk;
INSERT INTO vn.buy(entryFk,
itemFk,
@@ -59530,11 +59185,11 @@ BEGIN
SELECT
vToEntryFk,
itemFk,
- vStickers * packing,
+ ishStickers * packing,
buyingValue,
freightValue,
isIgnored,
- vStickers,
+ ishStickers,
packing,
`grouping`,
groupingMode,
@@ -59548,7 +59203,7 @@ BEGIN
price3,
minPrice,
producer,
- vStickers,
+ ishStickers,
workerFk,
isChecked,
isPickedOff,
@@ -59560,11 +59215,9 @@ BEGIN
WHERE id = vBuyFk;
END IF;
-
END LOOP;
CLOSE cur;
-
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -60011,6 +59664,39 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
+/*!50003 DROP PROCEDURE IF EXISTS `expeditionPallet_printLabel` */;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+DELIMITER ;;
+CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionPallet_printLabel`(vPalletFk INT)
+BEGIN
+
+ DECLARE vLabel INT;
+ DECLARE vPrinterFk INT;
+
+ UPDATE vn.expeditionPallet
+ SET isPrint = FALSE
+ WHERE id = vPalletFk;
+
+ SELECT s.labelReportFk, w.labelerFk INTO vLabel, vPrinterFK
+ FROM worker w
+ LEFT JOIN sector s ON s.id= w.sectorFk
+ WHERE w.id=account.myUser_getId() ;
+
+ INSERT INTO printServerQueue (printerFk, labelReportFk, statusFk, param1, workerFk)
+ VALUES(vPrinterFK, vLabel, 1, vPalletFk, account.myUser_getId());
+END ;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `expeditionPallet_PrintSet` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -60307,6 +59993,42 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
+/*!50003 DROP PROCEDURE IF EXISTS `expeditionState_addByPallet` */;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+DELIMITER ;;
+CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionState_addByPallet`(vPalletFk INT, vStateCode VARCHAR(100))
+BEGIN
+/**
+ * Inserta nuevos registros en la tabla vn.expeditionState
+ *
+ * @param vPalletFk Identificador de vn.expedition
+ * @param vStateCode Corresponde a vn.expeditionStateType.code
+ */
+ DROP TEMPORARY TABLE IF EXISTS tmp.expeditionScan;
+ CREATE TEMPORARY TABLE tmp.expeditionScan
+ SELECT expeditionFk, est.id typeFk
+ FROM vn.expeditionScan e
+ JOIN vn.expeditionStateType est ON est.code = vStateCode
+ WHERE e.palletFk = vPalletFk;
+
+ INSERT INTO vn.expeditionState(expeditionFk, typeFk)
+ SELECT expeditionFk, typeFk
+ FROM tmp.expeditionScan;
+
+ DROP TEMPORARY TABLE IF EXISTS tmp.expeditionScan;
+END ;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `expeditionState_addByRoute` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -60420,9 +60142,9 @@ DELIMITER ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_general_ci */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `expedition_getFromRoute`(vRouteFk INT)
BEGIN
@@ -60431,7 +60153,6 @@ BEGIN
* @param vRouteFk Id de la ruta
*/
-
SELECT e.id,
e.ticketFk,
e.checked,
@@ -60442,7 +60163,8 @@ BEGIN
a.postalCode,
t.addressFk,
a.nickname,
- sub2.itemPackingTypeConcat
+ sub2.itemPackingTypeConcat,
+ est.code
FROM expedition e
JOIN ticket t ON t.id = e.ticketFk
JOIN ticketState ts ON ts.ticketFk = e.ticketFk
@@ -60458,9 +60180,9 @@ BEGIN
GROUP BY t.id,i.itemPackingTypeFk)sub
GROUP BY sub.ticketFk
) sub2 ON sub2.ticketFk = t.id
+ LEFT JOIN expeditionStateType est ON est.id = e.stateTypeFk
WHERE t.routeFk = vRouteFk AND e.isBox <> FALSE;
-
-
+
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -66066,70 +65788,6 @@ BEGIN
DELETE FROM vn.itemShelving WHERE id = vId;
-END ;;
-DELIMITER ;
-/*!50003 SET sql_mode = @saved_sql_mode */ ;
-/*!50003 SET character_set_client = @saved_cs_client */ ;
-/*!50003 SET character_set_results = @saved_cs_results */ ;
-/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `itemShelvingEdit__` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingEdit__`(vVisible INT,vPacking INT,vId INT)
-BEGIN
-
- /*
- * @deprecated: utilizar itemShelving_update
- */
- UPDATE vn.itemShelving SET available = vVisible, visible = vVisible, packing = vPacking WHERE id = vId;
-
-END ;;
-DELIMITER ;
-/*!50003 SET sql_mode = @saved_sql_mode */ ;
-/*!50003 SET character_set_client = @saved_cs_client */ ;
-/*!50003 SET character_set_results = @saved_cs_results */ ;
-/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `itemShelvingList__` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingList__`(IN `vShelvingFk` VARCHAR(8))
-BEGIN
-
- /*
- * @deprecated:Utilizar itemShelving_get
- */
-
- /*MODIFICADA POR QUIQUE: OBTENEMOS DEEP Y PARKING*/
- SELECT ish.itemFk as item,
- IFNULL(i.longName, CONCAT(i.name, ' ',i.size)) as description,
- ish.visible as visible,
- ceil(ish.visible/ish.packing) as stickers,
- ish.packing as packing,
- IF (p.`column` IS NULL,"",p.`column`) as col,
- IF (p.`row` IS NULL,"",p.`row`) as `row`,
- IF (p.`code` IS NULL,"",p.`code`) as `code`,
- ish.id,
- s.priority
- FROM vn.itemShelving ish
- JOIN vn.item i ON i.id = ish.itemFk
- INNER JOIN vn.shelving s ON vShelvingFk = s.code COLLATE utf8_unicode_ci
- LEFT JOIN vn.parking p ON s.parkingFk = p.id
- WHERE ish.shelvingFk COLLATE utf8_unicode_ci =vShelvingFk COLLATE utf8_unicode_ci;
-
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -66194,155 +65852,63 @@ DELIMITER ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingMakeFromDate`(IN `vShelvingFk` VARCHAR(8), IN `vBarcode` VARCHAR(22), IN `vShelve` VARCHAR(2), IN `vDeep` INT, IN `vQuantity` INT, IN `vPackagingFk` VARCHAR(10), IN `vGrouping` INT, IN `vPacking` INT, IN `vWarehouseFk` INT, IN `vLevel` INT,`vCreated` VARCHAR(22))
+CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingMakeFromDate`(IN `vShelvingFk` VARCHAR(8), IN `vBarcode` VARCHAR(22), IN `vShelve` VARCHAR(2), IN `vQuantity` INT, IN `vPackagingFk` VARCHAR(10), IN `vGrouping` INT, IN `vPacking` INT, IN `vWarehouseFk` INT, `vCreated` VARCHAR(22))
BEGIN
-
-
DECLARE vItemFk INT;
-
-
-
- SELECT vn.barcodeToItem(vBarcode) INTO vItemFk;
-
- SELECT itemFk INTO vItemFk
- FROM vn.buy b
+ SELECT vn.barcodeToItem(vBarcode) INTO vItemFk;
+
+ SELECT itemFk INTO vItemFk
+ FROM vn.buy b
WHERE b.id = vItemFk;
-
-
- IF (SELECT COUNT(*) FROM vn.shelving WHERE code = vShelvingFk COLLATE utf8_unicode_ci) = 0 THEN
-
- INSERT IGNORE INTO vn.parking(`code`) VALUES(vShelvingFk);
- INSERT INTO vn.shelving(`code`, parkingFk)
- SELECT vShelvingFk, id
- FROM vn.parking
- WHERE `code` = vShelvingFk COLLATE utf8_unicode_ci;
-
- END IF;
-
- IF (SELECT COUNT(*) FROM vn.itemShelving
- WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk
- AND itemFk = vItemFk
- AND packing = vPacking) = 1 THEN
- UPDATE vn.itemShelving SET quantity = quantity+vQuantity,visible = visible+vQuantity,available = available+vQuantity, created = vCreated
- WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk AND itemFk = vItemFk AND packing = vPacking;
-
- ELSE
- CALL cache.last_buy_refresh(FALSE);
- INSERT INTO itemShelving( itemFk,
- shelvingFk,
- shelve,
- deep,
- quantity,
- visible,
- available,
- created,
- `grouping`,
- packing,
- packagingFk,
- level)
- SELECT
- vItemFk,
- vShelvingFk,
- vShelve,
- vDeep,
- vQuantity,
- vQuantity,
- vQuantity,
- vCreated,
- IF(vGrouping = 0, IFNULL(b.packing, vPacking), vGrouping) as `grouping`,
- IF(vPacking = 0, b.packing, vPacking) as packing,
- IF(vPackagingFk = '', b.packageFk, vPackagingFk) as packaging,
- vLevel
- FROM vn.item i
- LEFT JOIN cache.last_buy lb ON i.id = lb.item_id AND lb.warehouse_id = vWarehouseFk
- LEFT JOIN vn.buy b ON b.id = lb.buy_id
- WHERE i.id = vItemFk;
- END IF;
-
-END ;;
-DELIMITER ;
-/*!50003 SET sql_mode = @saved_sql_mode */ ;
-/*!50003 SET character_set_client = @saved_cs_client */ ;
-/*!50003 SET character_set_results = @saved_cs_results */ ;
-/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `itemShelvingMake__` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingMake__`(IN `vShelvingFk` VARCHAR(8), IN `vBarcode` VARCHAR(22), IN `vShelve` VARCHAR(2), IN `vDeep` INT, IN `vQuantity` INT, IN `vPackagingFk` VARCHAR(10), IN `vGrouping` INT, IN `vPacking` INT, IN `vWarehouseFk` INT, IN `vLevel` INT)
-BEGIN
-
-
- /*
- * @deprecated:utilizar itemShelving_add
- */
-
- DECLARE vItemFk INT;
+ IF (SELECT COUNT(*) FROM vn.shelving WHERE code = vShelvingFk COLLATE utf8_unicode_ci) = 0 THEN
- SELECT vn.barcodeToItem(vBarcode) INTO vItemFk;
-
- /*SELECT itemFk INTO vItemFk
- FROM vn.buy b
- WHERE b.id = vItemFk;*/
-
- IF (SELECT COUNT(*) FROM vn.shelving WHERE code = vShelvingFk COLLATE utf8_unicode_ci) = 0 THEN
-
- INSERT IGNORE INTO vn.parking(`code`) VALUES(vShelvingFk);
- INSERT INTO vn.shelving(`code`, parkingFk)
- SELECT vShelvingFk, id
- FROM vn.parking
+ INSERT IGNORE INTO vn.parking(`code`) VALUES(vShelvingFk);
+ INSERT INTO vn.shelving(`code`, parkingFk)
+ SELECT vShelvingFk, id
+ FROM vn.parking
WHERE `code` = vShelvingFk COLLATE utf8_unicode_ci;
-
+
END IF;
-
+
IF (SELECT COUNT(*) FROM vn.itemShelving
- WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk
- AND itemFk = vItemFk
- AND packing = vPacking) = 1 THEN
+ WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk
+ AND itemFk = vItemFk
+ AND packing = vPacking) = 1 THEN
+
+ UPDATE vn.itemShelving
+ SET visible = visible+vQuantity,
+ created = vCreated
+ WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk
+ AND itemFk = vItemFk
+ AND packing = vPacking;
- UPDATE vn.itemShelving SET quantity = quantity+vQuantity,visible = visible+vQuantity,available = available+vQuantity
- WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk AND itemFk = vItemFk AND packing = vPacking;
-
ELSE
- CALL cache.last_buy_refresh(FALSE);
- INSERT INTO itemShelving( itemFk,
- shelvingFk,
- shelve,
- deep,
- quantity,
- visible,
- available,
- `grouping`,
- packing,
- packagingFk,
- level)
-
- SELECT
- vItemFk,
- vShelvingFk,
- vShelve,
- vDeep,
- vQuantity,
- vQuantity,
- vQuantity,
- IF(vGrouping = 0, IFNULL(b.packing, vPacking), vGrouping) as `grouping`,
- IF(vPacking = 0, b.packing, vPacking) as packing,
- IF(vPackagingFk = '', b.packageFk, vPackagingFk) as packaging,
- vLevel
- FROM vn.item i
- LEFT JOIN cache.last_buy lb ON i.id = lb.item_id AND lb.warehouse_id = vWarehouseFk
- LEFT JOIN vn.buy b ON b.id = lb.buy_id
- WHERE i.id = vItemFk;
- END IF;
+ CALL cache.last_buy_refresh(FALSE);
+ INSERT INTO itemShelving( itemFk,
+ shelvingFk,
+ shelve,
+ visible,
+ created,
+ `grouping`,
+ packing,
+ packagingFk)
+ SELECT vItemFk,
+ vShelvingFk,
+ vShelve,
+ vQuantity,
+ vCreated,
+ IF(vGrouping = 0, IFNULL(b.packing, vPacking), vGrouping) `grouping`,
+ IF(vPacking = 0, b.packing, vPacking) packing,
+ IF(vPackagingFk = '', b.packageFk, vPackagingFk) packaging
+ FROM vn.item i
+ LEFT JOIN cache.last_buy lb ON i.id = lb.item_id AND lb.warehouse_id = vWarehouseFk
+ LEFT JOIN vn.buy b ON b.id = lb.buy_id
+ WHERE i.id = vItemFk;
+ END IF;
+
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -66406,20 +65972,18 @@ DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingPlacementSupplyAdd`(vItemShelvingFk INT, vItemPlacementSupplyFk INT, vQuantity INT)
BEGIN
- INSERT INTO vn.itemShelvingPlacementSupply( itemShelvingFk,
- itemPlacementSupplyFk,
- quantity,
+ INSERT INTO vn.itemShelvingPlacementSupply( itemShelvingFk,
+ itemPlacementSupplyFk,
+ quantity,
userFk)
- VALUES ( vItemShelvingFk,
- vItemPlacementSupplyFk,
- vQuantity,
- getUser());
-
- UPDATE vn.itemShelving
- SET quantity = quantity - vQuantity,
- visible = visible - vQuantity,
- available = available - vQuantity
- WHERE id = vItemShelvingFk;
+ VALUES (vItemShelvingFk,
+ vItemPlacementSupplyFk,
+ vQuantity,
+ getUser());
+
+ UPDATE vn.itemShelving
+ SET visible = visible - vQuantity
+ WHERE id = vItemShelvingFk;
END ;;
@@ -66837,25 +66401,27 @@ DELIMITER ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingRadar_Urgent`(vWorkerFk INT)
+CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingRadar_Urgent`()
BEGIN
+/**
+ * Devuelve lo mismo que itemShelving_filterBuyer per sin filtrar
+ */
DECLARE vCalcVisibleFk INT;
DECLARE vWarehouseFk INT DEFAULT 60;
- -- Eliminar cuando tengamos programador de Android
-
CALL cache.visible_refresh(vCalcVisibleFk, TRUE, vWarehouseFk);
SELECT * FROM
(SELECT sub.itemFk,
sub.longName,
- CONCAT('Hoy saldrán ', CAST(sub2.pendiente AS DECIMAL(10,0)), ' unidades.') `size`,
+ CONCAT(DATE_FORMAT(sub2.etd,'%H:%i'), ' salen ', CAST(sub2.pendiente AS DECIMAL(10,0)), ' unidades.') `size`,
CONCAT(IF(sub2.itemFk, IF(sub2.pendiente > (sub.upstairs + sub.downstairs),'(1) ','(2) '),'(3) ' ),sub.producer) producer,
sub.upstairs,
sub.downstairs,
sub.visible,
sub.sectorFk,
- CAST(visible - upstairs - downstairs AS DECIMAL(10,0)) nicho
+ CAST(visible - upstairs - downstairs AS DECIMAL(10,0)) nicho,
+ sub2.etd
FROM (SELECT iss.itemFk,
CONCAT(i.longName,' ',i.size,' ',IFNULL(i.subName,'') ) longName,
'' size,
@@ -66863,19 +66429,19 @@ BEGIN
0 upstairs,
SUM(IFNULL(iss.visible,0)) downstairs,
IF(it.isPackaging, null, IFNULL(v.visible,0)) visible,
- 0 sectorFk
+ IFNULL(iss.sectorFk,0) sectorFk
FROM itemShelvingStock iss
JOIN sector s ON s.id = iss.sectorFk
JOIN item i on i.id = iss.itemFk
JOIN itemType it ON it.id = i.typeFk
- LEFT JOIN cache.visible v ON v.item_id = iss.itemFk AND v.calc_id = vCalcVisibleFk
+ LEFT JOIN cache.visible v ON v.item_id = iss.itemFk AND v.calc_id = @vCalcVisibleFk
WHERE s.warehouseFk = vWarehouseFk
- AND it.workerFk = vWorkerFk
GROUP BY itemFk
- ) sub LEFT JOIN (SELECT s.itemFk, SUM(s.quantity) pendiente
+ ) sub LEFT JOIN (SELECT s.itemFk, SUM(s.quantity) pendiente, MIN(zc.`hour`) etd
FROM sale s
LEFT JOIN saleTracking st ON st.saleFk = s.id
- JOIN ticket t ON t.id = s.ticketFk
+ JOIN ticket t ON t.id = s.ticketFk
+ LEFT JOIN vn.zoneClosure zc ON zc.zoneFk = t.zoneFk
JOIN client c on c.id = t.clientFk
JOIN clientType ct ON ct.id = c.clientTypeFk
WHERE t.shipped BETWEEN vn.VN_CURDATE() AND util.dayend(vn.VN_CURDATE())
@@ -66886,21 +66452,23 @@ BEGIN
UNION ALL
SELECT v.item_id ,
i.longName,
- CONCAT('Hoy saldrán ', CAST(sub5.pendiente AS DECIMAL(10,0)), ' unidades.') `size`,
+ CONCAT(DATE_FORMAT(sub5.etd,'%H:%i'), ' salen ', CAST(sub5.pendiente AS DECIMAL(10,0)), ' unidades.') `size`,
CONCAT(IF(sub5.pendiente,'(0) ','(3) ')) producer,
0,
0,
v.visible,
- 0,
- v.visible nicho
+ IFNULL(iss.sectorFk,0),
+ v.visible nicho,
+ sub5.etd
FROM cache.visible v
JOIN item i ON i.id = v.item_id
JOIN itemType it ON it.id = i.typeFk
LEFT JOIN itemShelvingStock iss ON iss.itemFk = v.item_id
- LEFT JOIN (SELECT s.itemFk , SUM(s.quantity) pendiente
+ LEFT JOIN (SELECT s.itemFk , SUM(s.quantity) pendiente, MIN(zc.`hour`) etd
FROM sale s
LEFT JOIN saleTracking st ON st.saleFk = s.id
- JOIN ticket t ON t.id = s.ticketFk
+ JOIN ticket t ON t.id = s.ticketFk
+ LEFT JOIN vn.zoneClosure zc ON zc.zoneFk = t.zoneFk
JOIN client c on c.id = t.clientFk
JOIN clientType ct ON ct.id = c.clientTypeFk
WHERE t.shipped BETWEEN vn.VN_CURDATE() AND util.dayend(vn.VN_CURDATE())
@@ -66908,107 +66476,11 @@ BEGIN
AND ct.code IN ('normal', 'trust')
GROUP BY s.itemFk
) sub5 ON sub5.itemFk = v.item_id
- WHERE v.calc_id = vCalcVisibleFk
+ WHERE v.calc_id = @vCalcVisibleFk
AND ISNULL(iss.itemFk)
- AND it.workerFk = vWorkerFk
) sub3
WHERE nicho
- ORDER BY producer;
-
-END ;;
-DELIMITER ;
-/*!50003 SET sql_mode = @saved_sql_mode */ ;
-/*!50003 SET character_set_client = @saved_cs_client */ ;
-/*!50003 SET character_set_results = @saved_cs_results */ ;
-/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `itemShelvingRadar_Urgent__` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingRadar_Urgent__`(vWorkerFk INT)
-BEGIN
- DECLARE vCalcVisibleFk INT;
- DECLARE vWarehouseFk INT DEFAULT 60;
- -- DECLARE vSectorFk INt;
- -- DECLARE vFatherSectorFk INT;
-
- -- Eliminar cuando tengamos programador de Android
-
- CALL cache.visible_refresh(vCalcVisibleFk, TRUE, vWarehouseFk);
-
- SELECT * FROM (
- SELECT sub.itemFk,
- sub.longName,
- CONCAT('Hoy saldrán ', CAST(sub2.pendiente AS DECIMAL(10,0)), ' unidades.') `size`,
- CONCAT(IF(sub2.itemFk, IF(sub2.pendiente > (sub.upstairs + sub.downstairs),'(1) ','(2) '),'(3) ' ),sub.producer) producer,
- sub.upstairs,
- sub.downstairs,
- sub.visible,
- sub.sectorFk,
- CAST(visible - upstairs - downstairs AS DECIMAL(10,0)) AS nicho
- FROM (
- SELECT iss.itemFk,
- CONCAT(i.longName,' ',i.size,' ',IFNULL(i.subName,'') ) longName,
- '' size,
- CONCAT(iss.parkingCode , ' ', iss.shelvingFk) producer,
- 0 upstairs,
- SUM(IFNULL(iss.visible,0)) downstairs,
- IF(it.isPackaging, null, IFNULL(v.visible,0)) as visible,
- 0 as sectorFk
- FROM vn.itemShelvingStock iss
- JOIN vn.sector s ON s.id = iss.sectorFk
- JOIN vn.item i on i.id = iss.itemFk
- JOIN vn.itemType it ON it.id = i.typeFk
- LEFT JOIN cache.visible v ON v.item_id = iss.itemFk AND v.calc_id = vCalcVisibleFk
- WHERE s.warehouseFk = vWarehouseFk
- AND it.workerFk = vWorkerFk
- GROUP BY itemFk
- ) sub
- LEFT JOIN (SELECT s.itemFk , sum(s.quantity) as pendiente
- FROM vn.sale s
- LEFT JOIN vn.saleTracking st ON st.saleFk = s.id
- JOIN vn.ticket t ON t.id = s.ticketFk
- JOIN vn.client c on c.id = t.clientFk
- WHERE t.shipped BETWEEN vn.VN_CURDATE() AND util.dayend(vn.VN_CURDATE())
- AND ISNULL(st.saleFk)
- AND (c.clientTypeFk = 1 OR c.clientTypeFk = 5)
- GROUP BY s.itemFk) sub2 ON sub2.itemFk = sub.itemFk
-
- UNION ALL
-
- SELECT v.item_id ,
- i.longName,
- CONCAT('Hoy saldrán ', CAST(sub5.pendiente AS DECIMAL(10,0)), ' unidades.') `size`,
- CONCAT(IF(sub5.pendiente,'(0) ','(3) ')) producer,
- 0,
- 0,
- v.visible,
- 0,
- v.visible AS nicho
- FROM cache.visible v
- JOIN vn.item i ON i.id = v.item_id
- JOIN vn.itemType it ON it.id = i.typeFk
- LEFT JOIN vn.itemShelvingStock iss ON iss.itemFk = v.item_id
- LEFT JOIN (SELECT s.itemFk , sum(s.quantity) as pendiente
- FROM vn.sale s
- LEFT JOIN vn.saleTracking st ON st.saleFk = s.id
- JOIN vn.ticket t ON t.id = s.ticketFk
- JOIN vn.client c on c.id = t.clientFk
- WHERE t.shipped BETWEEN vn.VN_CURDATE() AND util.dayend(vn.VN_CURDATE())
- AND ISNULL(st.saleFk)
- AND (c.clientTypeFk = 1 OR c.clientTypeFk = 5)
- GROUP BY s.itemFk) sub5 ON sub5.itemFk = v.item_id
- WHERE v.calc_id = vCalcVisibleFk
- AND ISNULL(iss.itemFk)
- AND it.workerFk = vWorkerFk) sub3
- WHERE nicho
- ORDER BY producer;
+ ORDER BY LEFT(producer,3), etd, producer;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -67028,20 +66500,21 @@ DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingSaleAdd`(vItemShelvingFk INT, saleFk INT, vQuantity INT)
BEGIN
-IF saleFk <> 0 THEN
- INSERT INTO vn.itemShelvingSale( itemShelvingFk,
- saleFk,
- quantity,
- userFk)
- VALUES ( vItemShelvingFk,
- saleFk,
+ IF saleFk <> 0 THEN
+ INSERT INTO vn.itemShelvingSale(itemShelvingFk,
+ saleFk,
+ quantity,
+ userFk)
+ VALUES (vItemShelvingFk,
+ saleFk,
vQuantity,
getUser());
-
-END IF;
- UPDATE vn.itemShelving SET quantity = (quantity - vQuantity), available = (available - vQuantity), visible = (visible - vQuantity)
- WHERE id = vItemShelvingFk;
+ END IF;
+
+ UPDATE vn.itemShelving
+ SET visible = (visible - vQuantity)
+ WHERE id = vItemShelvingFk;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -67054,39 +66527,34 @@ DELIMITER ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_general_ci */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingSaleSupplyAdd`(vItemShelvingFk INT, saleFk INT, vQuantity INT)
BEGIN
-
-/*
+/**
* Añade línea a itemShelvingSale y regulariza el carro
*
* @param vItemShelvingFk Id itemShelving
* @param saleFk Id de sale
* @param vQuantity cantidad a regularizar
- *
*/
-
- INSERT INTO itemShelvingSale( itemShelvingFk,
- saleFk,
- quantity,
- userFk)
- VALUES ( vItemShelvingFk,
- saleFk,
- vQuantity,
- getUser());
+ INSERT INTO itemShelvingSale(itemShelvingFk,
+ saleFk,
+ quantity,
+ userFk)
+ VALUES (vItemShelvingFk,
+ saleFk,
+ vQuantity,
+ getUser());
UPDATE itemShelving
- SET quantity = quantity - vQuantity,
- visible = visible - vQuantity,
- available = available - vQuantity
- WHERE id = vItemShelvingFk;
+ SET visible = visible - vQuantity
+ WHERE id = vItemShelvingFk;
UPDATE vn2008.Movimientos_mark
- SET valor = 1
+ SET valor = 1
WHERE Id_Movimiento = saleFk;
END ;;
@@ -67095,137 +66563,6 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `itemShelvingSaleSupplyAddVoz` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingSaleSupplyAddVoz`(vItemShelvingFk VARCHAR(50), saleFk INT, vQuantity INT,idMovimiento INT)
-BEGIN
-
-
-/*INSERT INTO `vn`.`errorLogApp` (`error`, `workerFk`) VALUES (CONCAT(vItemShelvingFk," ",saleFk), '14255');*/
-
-DECLARE vItemShelvingFkAux INT;
-DECLARE vItemFk INT;
-
-SELECT itemFk INTO vItemFk FROM vn.sale WHERE id = saleFk;
-
-SELECT id INTO vItemShelvingFkAux FROM vn.itemShelving WHERE shelvingFk = vItemShelvingFk COLLATE utf8_general_ci AND itemFk = vItemFk;
-
-INSERT INTO vn.itemShelvingSale( itemShelvingFk,
- saleFk,
- quantity,
- userFk)
- VALUES ( vItemShelvingFkAux,
- saleFk,
- vQuantity,
- getUser());
-
- UPDATE vn.itemShelving
- SET quantity = quantity - vQuantity,
- visible = visible - vQuantity,
- available = available - vQuantity
- WHERE id = vItemShelvingFkAux;
-
- UPDATE vn2008.Movimientos_mark
- SET valor = 1
- WHERE Id_Movimiento = idMovimiento;
-
-END ;;
-DELIMITER ;
-/*!50003 SET sql_mode = @saved_sql_mode */ ;
-/*!50003 SET character_set_client = @saved_cs_client */ ;
-/*!50003 SET character_set_results = @saved_cs_results */ ;
-/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `itemShelvingSaleSupplyAdd_` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingSaleSupplyAdd_`(vItemShelvingFk INT, saleFk INT, vQuantity INT,idMovimiento INT)
-BEGIN
-
-INSERT INTO vn.itemShelvingSale( itemShelvingFk,
- saleFk,
- quantity,
- userFk)
- VALUES ( vItemShelvingFk,
- saleFk,
- vQuantity,
- getUser());
-
- UPDATE vn.itemShelving
- SET quantity = quantity - vQuantity,
- visible = visible - vQuantity,
- available = available - vQuantity
- WHERE id = vItemShelvingFk;
-
- UPDATE vn2008.Movimientos_mark
- SET valor = 1
- WHERE Id_Movimiento = idMovimiento;
-
-END ;;
-DELIMITER ;
-/*!50003 SET sql_mode = @saved_sql_mode */ ;
-/*!50003 SET character_set_client = @saved_cs_client */ ;
-/*!50003 SET character_set_results = @saved_cs_results */ ;
-/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `itemShelvingTicketSource__` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingTicketSource__`(vTicketFk INT)
-BEGIN
- DECLARE vCalcFk INT;
- DECLARE vWarehouseFk INT;
-
- SELECT warehouseFk INTO vWarehouseFk
- FROM vn.ticket
- WHERE id = vTicketFk;
- SET vCalcFk = cache.ticketShippingCalcIdGet(vWarehouseFk);
-
- SELECT
- s.id,
- ubication,
- s.quantity,
- sis.quantity as Reserved,
- s.itemFk,
- s.concept,
- s.ticketFk,
- s.isPicked,
- ish.packing,
- FLOOR(sis.quantity / ish.packing) as stickers,
- sis.quantity MOD ish.packing as rest,
- ts.shippingHour,
- ts.shippingMinute
- FROM vn.saleItemShelving sis
- JOIN vn.itemShelving ish ON ish.id = sis.itemShelvingFk
- JOIN vn.sale s ON s.id = sis.saleFk
- JOIN cache.ticketShipping ts ON ts.calc_id = vCalcFk AND ts.ticketFk = vTicketFk
- WHERE s.ticketFk = vTicketFk;
-END ;;
-DELIMITER ;
-/*!50003 SET sql_mode = @saved_sql_mode */ ;
-/*!50003 SET character_set_client = @saved_cs_client */ ;
-/*!50003 SET character_set_results = @saved_cs_results */ ;
-/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `itemShelvingTransfer` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -67255,84 +66592,118 @@ DELIMITER ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8 */ ;
-/*!50003 SET character_set_results = utf8 */ ;
-/*!50003 SET collation_connection = utf8_general_ci */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelving_add`(IN vShelvingFk VARCHAR(8), IN vBarcode VARCHAR(22), IN vShelve VARCHAR(2), IN vDeep INT, IN vQuantity INT, IN vPackagingFk VARCHAR(10), IN vGrouping INT, IN vPacking INT, IN vWarehouseFk INT, IN vLevel INT)
+CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelving_add`(IN vShelvingFk VARCHAR(8), IN vBarcode VARCHAR(22), IN vShelve VARCHAR(2), IN vQuantity INT, IN vPackagingFk VARCHAR(10), IN vGrouping INT, IN vPacking INT, IN vWarehouseFk INT)
BEGIN
+
/**
* Añade registro o lo actualiza si ya existe.
*
* @param vShelvingFk matrícula del carro
* @param vBarcode el id del registro
* @param vShelve de itemshleving
- * @param vDeep indica profundidad
* @param vQuantity indica la cantidad del producto
* @param vPackagingFk el packaging del producto en itemShelving, NULL para coger el de la ultima compra
* @param vGrouping el grouping del producto en itemShelving, NULL para coger el de la ultima compra
* @param vPacking el packing del producto, NULL para coger el de la ultima compra
* @param vWarehouseFk indica el sector
- * @param vLevel indica el level
*
**/
-
- DECLARE vItemFk INT;
- SELECT barcodeToItem(vBarcode) INTO vItemFk;
-
+ DECLARE vItemFk INT;
+
+ SELECT barcodeToItem(vBarcode) INTO vItemFk;
+
IF (SELECT COUNT(*) FROM shelving WHERE code = vShelvingFk COLLATE utf8_unicode_ci) = 0 THEN
-
+
INSERT IGNORE INTO parking(code) VALUES(vShelvingFk);
- INSERT INTO shelving(code, parkingFk)
+ INSERT INTO shelving(code, parkingFk)
SELECT vShelvingFk, id
FROM parking
- WHERE `code` = vShelvingFk COLLATE utf8_unicode_ci;
-
- END IF;
-
- IF (SELECT COUNT(*) FROM itemShelving
+ WHERE `code` = vShelvingFk COLLATE utf8_unicode_ci;
+
+ END IF;
+
+ IF (SELECT COUNT(*) FROM itemShelving
WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk
AND itemFk = vItemFk
AND packing = vPacking) = 1 THEN
- UPDATE itemShelving SET quantity = quantity+vQuantity,visible = visible+vQuantity,available = available+vQuantity
- WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk AND itemFk = vItemFk AND packing = vPacking;
-
- ELSE
+ UPDATE itemShelving
+ SET visible = visible+vQuantity
+ WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk AND itemFk = vItemFk AND packing = vPacking;
+
+ ELSE
CALL cache.last_buy_refresh(FALSE);
- INSERT INTO itemShelving( itemFk,
- shelvingFk,
- shelve,
- deep,
- quantity,
- visible,
- available,
- grouping,
- packing,
- packagingFk,
- level)
-
- SELECT
- vItemFk,
- vShelvingFk,
- vShelve,
- vDeep,
- vQuantity,
- vQuantity,
- vQuantity,
- IFNULL(vGrouping, b.grouping),
- IFNULL(vPacking, b.packing),
- IFNULL(vPackagingFk, b.packageFk),
- vLevel
- FROM item i
+ INSERT INTO itemShelving( itemFk,
+ shelvingFk,
+ shelve,
+ visible,
+ grouping,
+ packing,
+ packagingFk)
+
+ SELECT vItemFk,
+ vShelvingFk,
+ vShelve,
+ vQuantity,
+ IFNULL(vGrouping, b.grouping),
+ IFNULL(vPacking, b.packing),
+ IFNULL(vPackagingFk, b.packageFk)
+ FROM item i
LEFT JOIN cache.last_buy lb ON i.id = lb.item_id AND lb.warehouse_id = vWarehouseFk
LEFT JOIN buy b ON b.id = lb.buy_id
WHERE i.id = vItemFk;
- END IF;
+ END IF;
+END ;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
+/*!50003 DROP PROCEDURE IF EXISTS `itemShelving_addByClaim` */;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+DELIMITER ;;
+CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelving_addByClaim`(vClaimFk INT, vShelvingFk VARCHAR(3))
+BEGIN
+/**
+ * Insert items of claim into itemShelving.
+ *
+ * @param vClaimFk The claim
+ * @param vShelvingFk The shelving
+ * @table tmp.buyUltimate
+ */
+ DECLARE vWarehouseFk INT;
+
+ SELECT t.warehouseFk INTO vWarehouseFk
+ FROM claim c
+ JOIN ticket t ON t.id = c.ticketFk
+ WHERE c.id = vClaimFk;
+
+ CALL buyUltimate (vWarehouseFk, vn.VN_CURDATE());
+
+ INSERT INTO itemShelving (itemFk, shelvingFk, packing, `grouping`, visible)
+ SELECT s.itemFk, vShelvingFk, b.packing, b.`grouping`, cb.quantity AS visible
+ FROM claim c
+ JOIN claimBeginning cb ON c.id = cb.claimFk
+ JOIN sale s ON s.id = cb.saleFk
+ JOIN ticket t ON t.id = s.ticketFk
+ JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk AND bu.warehouseFk = t.warehouseFk
+ JOIN buy b ON b.id = bu.buyFk
+ WHERE c.id = vClaimFk;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -67420,6 +66791,11 @@ proc:BEGIN
*/
DECLARE vCalcVisibleFk INT;
+ IF vBuyerFk = 103 THEN -- hay que arreglarlo despues de la campaña PAK 23/04/2022
+ CALL vn.itemShelvingRadar_Urgent();
+ LEAVE proc;
+ END IF;
+
CALL cache.visible_refresh(vCalcVisibleFk, TRUE, vWarehouseFk);
SELECT * FROM
@@ -67490,7 +66866,6 @@ proc:BEGIN
) sub3
WHERE nicho
ORDER BY producer;
-
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -67551,30 +66926,25 @@ DELIMITER ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelving_getInfo`(vItemFk VARCHAR(22))
BEGIN
-
- /*
- * Muestra información realtiva a la ubicación de un ítem
- *
- * @param vItemFk Id del ítem
- *
- */
-
- SELECT vn.barcodeToItem(vItemFk) INTO vItemFk;
+/**
+ * Muestra información realtiva a la ubicación de un item
+ *
+ * @param vItemFk Id del item
+ */
+ SELECT vn.barcodeToItem(vItemFk)
+ INTO vItemFk;
- SELECT pk.code as Parking,
- sh.code as Matricula,
- ish.visible as visible,
- ish.available as Disponible,
- ish.level as level,
- ish.created as created,
- ish.itemFk as itemFk,
- sh.priority
+ SELECT pk.code Parking,
+ sh.code Matricula,
+ ish.visible visible,
+ ish.created created,
+ ish.itemFk itemFk,
+ sh.priority
FROM vn.itemShelving ish
JOIN vn.shelving sh ON sh.`code` = ish.shelvingFk
JOIN vn.parking pk ON pk.id = sh.parkingFk
WHERE ish.itemFk = vItemFk
ORDER BY sh.priority DESC, created ASC;
-
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -67784,12 +67154,11 @@ BEGIN
* @param vPacking el packing del del producto en itemShelving
* @param vGrouping el grouping del producto en itemShelving
*/
- UPDATE itemShelving SET
- available = vVisible,
- visible = vVisible,
- packing = vPacking,
- grouping = vGrouping
- WHERE id = vShelf;
+ UPDATE itemShelving
+ SET visible = vVisible,
+ packing = vPacking,
+ grouping = vGrouping
+ WHERE id = vShelf;
END ;;
DELIMITER ;
@@ -67944,38 +67313,6 @@ BEGIN
WHERE calc_id = vCalc
AND item_id = vItemFk;
-END ;;
-DELIMITER ;
-/*!50003 SET sql_mode = @saved_sql_mode */ ;
-/*!50003 SET character_set_client = @saved_cs_client */ ;
-/*!50003 SET character_set_results = @saved_cs_results */ ;
-/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `itemStockVisible_verify` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `itemStockVisible_verify`(vItemFk INT, vQuantity INT)
-BEGIN
-
- INSERT INTO vn.itemShelving(itemFk,
- shelvingFk,
- quantity,
- visible,
- available,
- packing)
- VALUES( vItemFk,
- 'FAL',
- -vQuantity,
- -vQuantity,
- -vQuantity,
- -vQuantity);
-
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -68830,8 +68167,8 @@ BEGIN
JOIN supplier s ON s.id = e.supplierFk
JOIN alertLevel al ON al.id =
CASE
- WHEN tr.shipped < vn.VN_CURDATE() THEN 3
- WHEN tr.shipped = vn.VN_CURDATE() AND tr.isReceived = TRUE THEN 3
+ WHEN tr.landed < vn.VN_CURDATE() THEN 3
+ WHEN tr.landed = vn.VN_CURDATE() AND tr.isReceived = TRUE THEN 3
ELSE 0
END
JOIN state st ON st.code = al.code
@@ -69957,32 +69294,46 @@ DELIMITER ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `item_setGeneric`(vSelf INT)
BEGIN
-
- /* Asigna el código genérico a un item
- *
- * @param vSelf identificador de vn.item
- */
-
+/**
+ * Asigna el código genérico a un item, salvo que sea un código de item genérico.
+ *
+ * @param vSelf identificador de vn.item
+ */
DECLARE vGenericFk INT;
-
- SELECT ga.itemFk INTO vGenericFk
- FROM vn.genericAllocation ga
- JOIN vn.item i ON (i.typeFk = ga.typeFk OR ISNULL(ga.typeFk))
- JOIN vn.itemTag it1 ON it1.itemFk = i.id AND (it1.value = ga.origin OR ISNULL(ga.origin))
- JOIN vn.itemTag it2 ON it2.itemFk = i.id AND (it2.value = ga.color OR ISNULL(ga.color))
- JOIN vn.itemTag it3 ON it3.itemFk = i.id AND (it3.value = ga.quality OR ISNULL(ga.quality))
- JOIN vn.itemTag it4 ON it4.itemFk = i.id AND (it4.value = ga.numFlores OR ISNULL(ga.numFlores))
- JOIN vn.itemTag it5 ON it5.itemFk = i.id AND (it5.value = ga.category OR ISNULL(ga.category))
- JOIN vn.itemTag it6 ON it6.itemFk = i.id AND (it6.value = ga.productor OR ISNULL(ga.productor))
- WHERE i.id = vSelf
- AND ga.itemFk != vSelf
- AND NOT i.isFloramondo
- LIMIT 1;
+ SELECT itemFk INTO vGenericFk
+ FROM (
+ SELECT itemFk, (sum(matches) = maxMatches) `match`
+ FROM (
+ SELECT ga.id gaid,
+ ga.itemFk,
+ (it.value <=> ga.origin)
+ + (it.value <=> ga.color)
+ + (it.value <=> ga.quality)
+ + (it.value <=> ga.numFlores)
+ + (it.value <=> ga.category)
+ + (it.value <=> ga.productor) matches,
+ !ISNULL(ga.origin)
+ +!ISNULL(ga.color)
+ +!ISNULL(ga.quality)
+ +!ISNULL(ga.numFlores)
+ +!ISNULL(ga.category)
+ +!ISNULL(ga.productor) maxMatches
+ FROM vn.item i
+ JOIN vn.itemTag it ON it.itemFk = i.id
+ JOIN vn.genericAllocation ga
+ ON (i.typeFk = ga.typeFk OR ga.typeFk IS NULL)
+ AND (i.longName = ga.longName OR ga.longName IS NULL)
+ AND (i.`size` = ga.`size` OR ga.`size` IS NULL)
+ AND i.id != ga.itemFk
+ WHERE i.id = vSelf
+ AND NOT i.isFloramondo) sub
+ GROUP BY gaid
+ HAVING `match`) sub2;
+
UPDATE vn.item
SET genericFk = vGenericFk
WHERE id = vSelf;
-
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -71013,11 +70364,11 @@ DELIMITER ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
+/*!50003 SET character_set_client = utf8 */ ;
+/*!50003 SET character_set_results = utf8 */ ;
+/*!50003 SET collation_connection = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `manaSpellersRequery`(vWorkerFk INTEGER)
BEGIN
@@ -71031,6 +70382,7 @@ BEGIN
DECLARE vToDated DATE DEFAULT TIMESTAMPADD(DAY,1,vn.VN_CURDATE());
DECLARE vMana INT;
DECLARE vAutoMana INT;
+ DECLARE vClaimMana INT;
DECLARE vManaBank INT;
DECLARE vManaGreugeType INT;
@@ -71045,6 +70397,9 @@ BEGIN
SELECT id INTO vAutoMana
FROM `component` WHERE code = 'autoMana';
+ SELECT id INTO vClaimMana
+ FROM `component` WHERE code = 'manaClaim';
+
SELECT id INTO vManaBank
FROM `bank` WHERE code = 'mana';
@@ -71063,7 +70418,7 @@ BEGIN
JOIN client c ON c.id = a.clientFk
JOIN sale s ON s.ticketFk = t.id
JOIN saleComponent sc ON sc.saleFk = s.id
- WHERE c.salesPersonFk = vWorkerFk AND sc.componentFk IN (vMana, vAutoMana)
+ WHERE c.salesPersonFk = vWorkerFk AND sc.componentFk IN (vMana, vAutoMana, vClaimMana)
AND t.shipped > vFromDated AND t.shipped < vToDated
UNION ALL
SELECT - r.amountPaid
@@ -71788,7 +71143,7 @@ BEGIN
IF vIsInvoiceable THEN
- CALL ticketCreateWithUser(vClient,
+ CALL ticket_add(vClient,
vDateEnd,
vWarehouse,
vCompany,
@@ -71797,6 +71152,7 @@ BEGIN
NULL,
vDateEnd,
account.userGetId(),
+ TRUE,
vNewTicket);
INSERT INTO ticketPackaging(
@@ -72603,21 +71959,48 @@ DELIMITER ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `previousSticker_get`(vSaleGroupFk INT)
BEGIN
-
- /*
- * Devuelve los campos a imprimir en una etiqueta de preparación previa
- *
- * @param vSaleGroupFk Identificador de vn.saleGroup
- */
+/**
+ * Devuelve los campos a imprimir en una etiqueta de preparación previa.
+ * Actualiza el valor de vn.saleGroup.parkingFk en el caso de que exista un saleGroup del mismo ticket
+ * con parking, del mismo sector, para que todos se pongan juntos
+ *
+ * @param vSaleGroupFk Identificador de vn.saleGroup
+ */
+ DECLARE vTicketFk INT;
+ DECLARE vParkingFk INT;
+ DECLARE vSectorFk INT;
- SELECT sgd.saleGroupFk,
+ SELECT s.ticketFk
+ INTO vTicketFk
+ FROM vn.saleGroupDetail sgd
+ JOIN vn.sale s ON s.id = sgd.saleFk
+ WHERE sgd.saleGroupFk = vSaleGroupFk
+ LIMIT 1;
+
+ SELECT sg.parkingFk, sc.sectorFk
+ INTO vParkingFk, vSectorFk
+ FROM vn.saleGroup sg
+ JOIN vn.sectorCollectionSaleGroup scsg ON scsg.saleGroupFk = sg.id
+ JOIN vn.sectorCollection sc ON sc.id = scsg.sectorCollectionFk
+ JOIN vn.saleGroupDetail sgd ON sgd.saleGroupFk = sg.id
+ JOIN vn.sale s ON s.id = sgd.saleFk
+ WHERE s.ticketFk = vTicketFk
+ AND sg.parkingFk IS NOT NULL
+ LIMIT 1;
+
+ UPDATE vn.saleGroup sg
+ SET sg.parkingFk = vParkingFk
+ WHERE sg.id = vSaleGroupFk
+ AND sg.sectorFk = vSectorFk;
+
+ SELECT sgd.saleGroupFk,
t.id ticketFk,
p.code as location,
t.observations,
- IF(HOUR(t.shipped), HOUR(t.shipped), HOUR(z.`hour`)) shippingHour,
- IF(MINUTE(t.shipped), MINUTE(t.shipped), MINUTE(z.`hour`)) shippingMinute ,
- IFNULL(MAX(i.itemPackingTypeFk),'H') itemPackingTypeFk ,
- count(*) items
+ IF(HOUR(t.shipped), HOUR(t.shipped), HOUR(z.`hour`)) shippingHour,
+ IF(MINUTE(t.shipped), MINUTE(t.shipped), MINUTE(z.`hour`)) shippingMinute ,
+ IFNULL(MAX(i.itemPackingTypeFk),'H') itemPackingTypeFk ,
+ count(*) items
FROM vn.sale s
JOIN vn.item i ON i.id = s.itemFk
JOIN vn.saleGroupDetail sgd ON sgd.saleFk = s.id
@@ -72626,7 +72009,6 @@ BEGIN
LEFT JOIN vn.parking p ON p.id = sg.parkingFk
LEFT JOIN vn.`zone` z ON z.id = t.zoneFk
WHERE sgd.saleGroupFk = vSaleGroupFk;
-
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -73050,8 +72432,10 @@ proc: BEGIN
-- Clientes Nuevos o Recuperados
UPDATE tmp.productionBuffer pb
LEFT JOIN bs.clientNewBorn cnb ON cnb.clientFk = pb.clientFk
+ JOIN vn.productionConfig pc
SET pb.problem = TRIM(CAST(CONCAT('NUEVO ', pb.problem) AS CHAR(255)))
- WHERE ISNULL(cnb.clientFk) OR cnb.isRookie ;
+ WHERE (ISNULL(cnb.clientFk) OR cnb.isRookie)
+ AND pc.rookieDays;
-- Líneas y volumen por ticket
UPDATE tmp.productionBuffer pb
@@ -74176,104 +73560,57 @@ DELIMITER ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_general_ci */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `reportLabelCollection_get`(vSelf INT)
-BEGIN
-
+CREATE DEFINER=`root`@`localhost` PROCEDURE `reportLabelCollection_get`(vParam INT)
+BEGIN
/**
- * Obtiene los datos necesarios de un ticket o colección
+ * Obtiene los datos de etiquetas a partir de de un ticket o colección.
*
- * @param vSelf Ticket/Colección del que sacar los datos
- **/
-
- DECLARE vItemPackingTypeFk VARCHAR(1);
+ * @param vParam Ticket/Colección del que sacar los datos
+ */
DECLARE vIsTicket BOOL;
- -- Averiguamos si es un ticket o una colección
SELECT IF(id, TRUE, FALSE) INTO vIsTicket
- FROM vn.ticket
- WHERE created > (vn.VN_CURDATE() - INTERVAL 1 MONTH)
- AND id = vSelf;
-
- -- Si los sacadores NO son de V, pinta los colores
- SELECT itemPackingTypeFk INTO vItemPackingTypeFk
- FROM vn.collection
- WHERE id = vSelf;
-
- IF !(vItemPackingTypeFk <=> 'V') THEN
-
- SELECT CONCAT(tc.collectionFk, ' ', LEFT(cc.code,4)) `level`,
- tc.ticketFk,
- LEFT(IF(t.routeFk IS NULL, am.name, zo.name ), 12) agencyDescription,
- am.name,
- t.clientFk,
- COUNT(*) notes,
- w.code workerCode,
- tt.labelCount,
- IF(HOUR(t.shipped), TIME(t.shipped), TIME(zo.`hour`)) horaagencia,
- t.shipped,
- COUNT(*) lineas,
- t.nickName,
- CONCAT(CAST(SUM(sv.volume) AS DECIMAL(5,2)) , "m³") m3
- FROM vn.ticket t
- JOIN vn.ticketCollection tc ON tc.ticketFk = t.id
- JOIN vn.collection c ON c.id = tc.collectionFk
- JOIN vn.collectionColors cc ON cc.shelve = tc.`level`
- AND cc.wagon = tc.wagon
- AND cc.trainFk = c.trainFk
- JOIN vn.sale s ON s.ticketFk = t.id
- LEFT JOIN vn.saleVolume sv ON sv.saleFk = s.id
- JOIN vn.worker w ON w.id = c.workerFk
- JOIN vn.agencyMode am ON am.id = t.agencyModeFk
- LEFT JOIN vn.ticketTrolley tt ON tt.ticket = t.id
- LEFT JOIN vn.address a ON a.id = t.addressFk
- LEFT JOIN vn.route r ON r.id = t.routeFk
- LEFT JOIN vn.zoneEstimatedDelivery ze ON ze.zoneFk = t.zoneFk
- LEFT JOIN vn.agencyMode agm ON r.agencyModeFk =agm.id
- LEFT JOIN vn.zone zo ON t.zoneFk = zo.id
- WHERE IF(vIsTicket, tc.ticketFk = vSelf, tc.collectionFk = vSelf)
- GROUP BY t.id
- ORDER BY cc.code;
-
- ELSE
-
- SELECT CONCAT(tc.collectionFk,' ', SUBSTRING('ABCDEFGH',tc.wagon, 1), '-', tc.`level`) `level`,
- tc.ticketFk,
- LEFT(IF(t.routeFk IS NULL, am.name, zo.name ), 12) agencyDescription,
- am.name,
- t.clientFk,
- CAST(IF(ic.code = 'plant', CONCAT(MAX(i.`size`),' cm'), COUNT(*)) AS CHAR) notes,
- w.code workerCode,
- tt.labelCount,
- IF(HOUR(t.shipped), TIME(t.shipped), TIME(zo.`hour`)) horaagencia,
- t.shipped,
- COUNT(*) lineas,
- t.nickName,
- CONCAT(CAST(SUM(sv.volume) AS DECIMAL(5,2)), "m³") m3
- FROM vn.ticket t
- JOIN vn.ticketCollection tc ON tc.ticketFk = t.id
- JOIN vn.collection c ON c.id = tc.collectionFk
- JOIN vn.sale s ON s.ticketFk = t.id
- LEFT JOIN vn.saleVolume sv ON sv.saleFk = s.id
- JOIN vn.item i ON i.id = s.itemFk
- JOIN vn.itemType it ON it.id = i.typeFk
- JOIN vn.itemCategory ic ON ic.id = it.categoryFk
- JOIN vn.worker w ON w.id = c.workerFk
- JOIN vn.agencyMode am ON am.id = t.agencyModeFk
- LEFT JOIN vn.ticketTrolley tt ON tt.ticket = t.id
- LEFT JOIN vn.address a ON a.id = t.addressFk
- LEFT JOIN vn.route r ON r.id = t.routeFk
- LEFT JOIN vn.zoneEstimatedDelivery ze ON ze.zoneFk = t.zoneFk
- LEFT JOIN vn.agencyMode agm ON r.agencyModeFk =agm.id
- LEFT JOIN vn.`zone` zo ON t.zoneFk = zo.id
- WHERE IF(vIsTicket, tc.ticketFk = vSelf, tc.collectionFk = vSelf)
- GROUP BY t.id;
-
- END IF;
+ FROM ticket
+ WHERE created > (CURRENT_DATE() - INTERVAL 1 MONTH)
+ AND id = vParam;
+ SELECT c.itemPackingTypeFk,
+ CONCAT(tc.collectionFk, ' ', LEFT(cc.code, 4)) color,
+ CONCAT(tc.collectionFk, ' ', SUBSTRING('ABCDEFGH',tc.wagon, 1), '-', tc.`level`) levelV,
+ tc.ticketFk,
+ LEFT(IF(t.routeFk IS NULL, am.name, zo.name ), 12) agencyDescription,
+ am.name,
+ t.clientFk,
+ CONCAT(CAST(SUM(sv.volume) AS DECIMAL(5, 2)), 'm³') m3 ,
+ CAST(IF(ic.code = 'plant', CONCAT(MAX(i.`size`),' cm'), COUNT(*)) AS CHAR) size,
+ w.code workerCode,
+ tt.labelCount,
+ IF(HOUR(t.shipped), TIME(t.shipped), TIME(zo.`hour`)) agencyHour,
+ t.shipped,
+ COUNT(*) lineCount,
+ t.nickName
+ FROM ticket t
+ JOIN ticketCollection tc ON tc.ticketFk = t.id
+ JOIN collection c ON c.id = tc.collectionFk
+ JOIN collectionColors cc ON cc.shelve = tc.`level`
+ AND cc.wagon = tc.wagon
+ AND cc.trainFk = c.trainFk
+ JOIN sale s ON s.ticketFk = t.id
+ LEFT JOIN saleVolume sv ON sv.saleFk = s.id
+ JOIN item i ON i.id = s.itemFk
+ JOIN itemType it ON it.id = i.typeFk
+ JOIN itemCategory ic ON ic.id = it.categoryFk
+ JOIN worker w ON w.id = c.workerFk
+ JOIN agencyMode am ON am.id = t.agencyModeFk
+ LEFT JOIN ticketTrolley tt ON tt.ticket = t.id
+ LEFT JOIN `zone` zo ON t.zoneFk = zo.id
+ WHERE IF(vIsTicket, tc.ticketFk = vParam, tc.collectionFk = vParam)
+ GROUP BY t.id
+ ORDER BY cc.`code`;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -75078,18 +74415,17 @@ DELIMITER ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `saleGroup_add`()
+CREATE DEFINER=`root`@`localhost` PROCEDURE `saleGroup_add`(vSectorFk INT)
BEGIN
-
- /*
- * Añade un nuevo registro a la tabla y devuelve su id
- */
-
- INSERT INTO vn.saleGroup(userFk)
- VALUES (account.myUser_getId());
+/**
+ * Añade un nuevo registro a la tabla y devuelve su id.
+ *
+ * @param vSectorFk Identificador de vn.sector
+ */
+ INSERT INTO vn.saleGroup(userFk, sectorFk)
+ VALUES (account.myUser_getId(), vSectorFk);
SELECT LAST_INSERT_ID();
-
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -76284,12 +75620,12 @@ DELIMITER ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sale_getFromTicketOrCollection`(vParam INT)
BEGIN
-/*
- * Visualizar lineas de la tabla sale a través del parámetro vParam que puede ser ticket o collection
+/**
+ * Visualizar lineas de la tabla sale a través del parámetro vParam que puede
+ * ser ticket o collection.
*
* @param vParam Identificador de ticket o collection
*/
-
DECLARE vItemPackingTypeFk VARCHAR(1);
DECLARE vIsCollection BOOL;
@@ -76301,7 +75637,6 @@ BEGIN
DROP TEMPORARY TABLE IF EXISTS tmp.ticket2;
IF vIsCollection THEN
-
CREATE TEMPORARY TABLE tmp.ticket
(INDEX (id))
ENGINE = MEMORY
@@ -76329,8 +75664,6 @@ BEGIN
SELECT vParam id;
END IF;
-
-
SELECT s.ticketFk,
sgd.saleGroupFk,
s.id as saleFk,
@@ -76365,7 +75698,8 @@ BEGIN
sub2.originalQuantity as startQuantity, -- eliminar cuando tengamos la nueva apk
IFNULL(c.workerFk,getUser()) as workerFk,
IFNULL(SUM(iss.quantity),0) as pickedQuantity,
- i.packingShelve
+ i.packingShelve,
+ MIN(iss.created) picked
FROM tmp.ticket t
JOIN sale s ON s.ticketFk = t.id
JOIN ticket tt ON tt.id = t.id
@@ -76391,10 +75725,9 @@ BEGIN
LEFT JOIN parking p ON p.id = sg.parkingFk
GROUP BY s.id;
-
- DROP TEMPORARY TABLE tmp.ticket;
- DROP TEMPORARY TABLE tmp.ticket2;
-
+ DROP TEMPORARY TABLE
+ tmp.ticket,
+ tmp.ticket2;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -76413,15 +75746,13 @@ DELIMITER ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sale_getProblems`(IN vIsTodayRelative tinyint(1))
BEGIN
- /**
- * Calcula los problemas de cada venta
- * para un conjunto de tickets.
- *
- * @param vIsTodayRelative Indica si se calcula el disponible como si todo saliera hoy
- * @table tmp.sale_getProblems(ticketFk, clientFk, warehouseFk, shipped) Identificadores de los tickets a calcular
- * @return tmp.sale_problems
- */
-
+/**
+ * Calcula los problemas de cada venta para un conjunto de tickets.
+ *
+ * @param vIsTodayRelative Indica si se calcula el disponible como si todo saliera hoy
+ * @table tmp.sale_getProblems(ticketFk, clientFk, warehouseFk, shipped) Identificadores de los tickets a calcular
+ * @return tmp.sale_problems
+ */
DECLARE vWarehouseFk INT;
DECLARE vDate DATE;
DECLARE vAvailableCache INT;
@@ -76437,6 +75768,13 @@ BEGIN
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = 1;
+ DELETE tt.*
+ FROM tmp.sale_getProblems tt
+ JOIN vn.ticketObservation tto ON tto.ticketFk = tt.ticketFk
+ JOIN vn.observationType ot ON ot.id = tto.observationTypeFk
+ WHERE ot.code = 'administrative'
+ AND tto.description = 'Miriam';
+
DROP TEMPORARY TABLE IF EXISTS tmp.sale_problems;
CREATE TEMPORARY TABLE tmp.sale_problems (
ticketFk INT(11),
@@ -76446,10 +75784,10 @@ BEGIN
hasHighRisk TINYINT(1) DEFAULT 0,
hasTicketRequest INTEGER(1) DEFAULT 0,
isAvailable INTEGER(1) DEFAULT 1,
- itemShortage VARCHAR(250),
+ itemShortage VARCHAR(255),
isTaxDataChecked INTEGER(1) DEFAULT 1,
- itemDelay VARCHAR(250),
- itemLost VARCHAR(250),
+ itemDelay VARCHAR(255),
+ itemLost VARCHAR(255),
hasComponentLack INTEGER(1),
isTooLittle BOOL DEFAULT FALSE,
PRIMARY KEY (ticketFk, saleFk)
@@ -76468,20 +75806,23 @@ BEGIN
-- Too Little
INSERT INTO tmp.sale_problems(ticketFk, isTooLittle)
- SELECT sub.ticketFk, TRUE
- FROM (SELECT tl.ticketFk, SUM(sv.litros) litros, t.totalWithoutVat
- FROM tmp.ticket_list tl
- JOIN vn.saleVolume sv ON sv.ticketFk = tl.ticketFk
- JOIN vn.ticket t ON t.id = tl.ticketFk
- JOIN vn.zoneClosure zc ON zc.zoneFk = t.zoneFk AND zc.dated = vn.VN_CURDATE()
- JOIN vn.agencyMode am ON am.id = t.agencyModeFk
- JOIN vn.deliveryMethod dm ON dm.id = am.deliveryMethodFk
- WHERE vn.VN_NOW() < TIMESTAMPADD(MINUTE,MINUTE(zc.`hour`) ,TIMESTAMPADD(HOUR,HOUR(zc.`hour`),vn.VN_CURDATE()))
- AND dm.code IN('AGENCY','DELIVERY','PICKUP')
- GROUP BY tl.ticketFk) sub
+ SELECT tp.ticketFk, TRUE
+ FROM tmp.sale_getProblems tp
+ JOIN vn.ticket t ON t.id = tp.ticketFk
+ JOIN (SELECT t.addressFk, SUM(sv.litros) litros, t.totalWithoutVat
+ FROM tmp.ticket_list tl
+ JOIN vn.saleVolume sv ON sv.ticketFk = tl.ticketFk
+ JOIN vn.ticket t ON t.id = tl.ticketFk
+ JOIN vn.zoneClosure zc ON zc.zoneFk = t.zoneFk AND zc.dated = vn.VN_CURDATE()
+ JOIN vn.agencyMode am ON am.id = t.agencyModeFk
+ JOIN vn.deliveryMethod dm ON dm.id = am.deliveryMethodFk
+ WHERE vn.VN_NOW() < TIMESTAMPADD(MINUTE,MINUTE(zc.`hour`) ,TIMESTAMPADD(HOUR,HOUR(zc.`hour`),vn.VN_CURDATE()))
+ AND dm.code IN('AGENCY','DELIVERY','PICKUP')
+ AND t.shipped BETWEEN vn.VN_CURDATE() AND util.midnight()
+ GROUP BY t.addressFk) sub ON sub.addressFk = t.addressFk
JOIN vn.volumeConfig vc
WHERE sub.litros < vc.minTicketVolume
- AND sub.totalWithoutVat < vc.minTicketValue;
+ AND sub.totalWithoutVat < vc.minTicketValue;
-- Faltan componentes
INSERT INTO tmp.sale_problems(ticketFk, hasComponentLack, saleFk)
@@ -76570,7 +75911,7 @@ BEGIN
SELECT ticketFk, problem, saleFk
FROM (
SELECT tl.ticketFk,
- CONCAT('F: ',GROUP_CONCAT(i.id, ' ', i.longName, ' ')) problem,
+ LEFT(CONCAT('F: ',GROUP_CONCAT(i.id, ' ', i.longName, ' ')),250) problem,
s.id AS saleFk
FROM tmp.ticket_list tl
JOIN vn.ticket t ON t.id = tl.ticketFk
@@ -76598,7 +75939,7 @@ BEGIN
INSERT INTO tmp.sale_problems(ticketFk, itemLost, saleFk)
SELECT ticketFk, problem, saleFk
FROM (
- SELECT tl.ticketFk, GROUP_CONCAT('I: ',i.id, ' ', i.longName, ' ') problem, s.id AS saleFk
+ SELECT tl.ticketFk, LEFT(GROUP_CONCAT('I: ',i.id, ' ', i.longName, ' '),250) problem, s.id AS saleFk
FROM tmp.ticket_list tl
JOIN vn.ticket t ON t.id = tl.ticketFk
JOIN vn.sale s ON s.ticketFk = t.id
@@ -76624,7 +75965,7 @@ BEGIN
INSERT INTO tmp.sale_problems(ticketFk, itemDelay, saleFk)
SELECT ticketFk, problem, saleFk
FROM (
- SELECT tl.ticketFk, GROUP_CONCAT('R: ',i.id, ' ', i.longName, ' ') problem, s.id AS saleFk
+ SELECT tl.ticketFk, LEFT(GROUP_CONCAT('R: ',i.id, ' ', i.longName, ' '),250) problem, s.id AS saleFk
FROM tmp.ticket_list tl
JOIN vn.ticket t ON t.id = tl.ticketFk
JOIN vn.sale s ON s.ticketFk = t.id
@@ -76661,7 +76002,6 @@ BEGIN
DROP TEMPORARY TABLE
tmp.clientGetDebt,
tmp.ticket_list;
-
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -77371,23 +76711,22 @@ DELIMITER ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8 */ ;
-/*!50003 SET character_set_results = utf8 */ ;
-/*!50003 SET collation_connection = utf8_general_ci */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sectorCollection_new`(vSectorFk INT)
BEGIN
- /**
- * Inserta una nueva colección, si el usuario no tiene ninguna vacia.
- * Esto se hace para evitar que por error se generen colecciones sin sentido.
- *
- * @param vSectorFk Identificador de vn.sector
- */
-
- DECLARE hasEmptyCollections BOOLEAN;
+/**
+ * Inserta una nueva colección, si el usuario no tiene ninguna vacia.
+ * Esto se hace para evitar que por error se generen colecciones sin sentido.
+ *
+ * @param vSectorFk Identificador de vn.sector
+ */
+ DECLARE hasEmptyCollections BOOL;
DECLARE vUserFk INT;
SET vUserFk = account.myUser_getId();
@@ -77397,14 +76736,13 @@ BEGIN
LEFT JOIN vn.sectorCollectionSaleGroup scsg ON scsg.sectorCollectionFk = sc.id
WHERE ISNULL(scsg.id)
AND sc.userFk = vUserFk
- AND sc.sectorFk = vSectorFk;
+ AND sc.sectorFk = vSectorFk
+ AND sc.created >= vn.VN_CURDATE();
IF NOT hasEmptyCollections THEN
-
INSERT INTO vn.sectorCollection(userFk, sectorFk)
VALUES(vUserFk, vSectorFk);
END IF;
-
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -78266,7 +77604,7 @@ BEGIN
JOIN vn.warehouse w ON w.id = s.warehouseFk
LEFT JOIN tmp.stock s ON s.itemFk = ish.itemFk
WHERE (w.name = 'Algemesi'
- OR (w.name = 'NuncaJamas' AND ish.created < vn.VN_CURDATE()))
+ OR (w.name = 'NuncaJamas' AND ish.created < curdate()))
AND ish.visible
GROUP BY ish.shelvingFk
HAVING lineas = spam OR isSpam;
@@ -78477,105 +77815,6 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `stockBuyed` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_general_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `stockBuyed`(vDate DATE)
-BEGIN
- DECLARE vVolume DECIMAL(10,2);
- DECLARE vWarehouse INT DEFAULT 7;
- DECLARE vRuben INT;
- DECLARE vClaudi INT;
- DECLARE vJose INT;
-
- SELECT w.id INTO vRuben
- FROM vn.worker w
- WHERE w.code = 'RET';
-
- SELECT w.id INTO vClaudi
- FROM vn.worker w
- WHERE w.code = 'CSR';
-
- SELECT w.id INTO vJose
- FROM vn.worker w
- WHERE w.code = 'ATJ';
-
- CALL stockTraslation(vDate);
-
- -- SELECT Volumen INTO vVolume FROM vn2008.Cubos WHERE Id_Cubo = 'cc' LIMIT 1;
-
- INSERT INTO stockBuyed(user, buyed, `date`)
- SELECT tr.user_id, SUM(( amount / c.packing ) * vn.buy_getVolume(Id_Compra)) / vc.palletM3 / 1000000 buyed, vDate
- FROM tmp_item i
- JOIN vn2008.Articles a ON a.Id_Article = i.item_id
- JOIN vn2008.Tipos t ON a.tipo_id = t.tipo_id
- JOIN vn2008.reinos r ON r.id = t.reino_id
- JOIN vn2008.Trabajadores tr ON tr.Id_Trabajador = t.Id_Trabajador
- JOIN tmp.buyUltimate bu ON bu.itemFk = Id_Article AND bu.warehouseFk = vWarehouse
- JOIN vn2008.Compres c ON c.Id_compra = bu.buyFk
- JOIN vn.volumeConfig vc
- WHERE r.display <> 0
- GROUP BY tr.Id_Trabajador
- ON DUPLICATE KEY UPDATE buyed = VALUES(buyed);
-
- INSERT INTO stockBuyed(USER, buyed, `date`)
- SELECT vRuben, @amount := SUM(ic.cm3 * io.amount / vc.palletM3 / 1000000), vDate
- FROM vn2008.item_out io
- JOIN vn.itemCost ic ON ic.itemFk = io.item_id AND ic.warehouseFk = vWarehouse
- JOIN vn.ticket t ON t.id = io.ticketFk
- JOIN vn.address a ON a.id = t.addressFk
- JOIN vn.province p ON p.id = a.provinceFk
- JOIN vn.country c ON c.id = p.countryFk
- JOIN vn.volumeConfig vc
- WHERE dat = vDate
- AND warehouse_id = vWarehouse
- AND c.country = 'Francia'
- ON DUPLICATE KEY UPDATE buyed = buyed + @amount;
-
- INSERT INTO stockBuyed(USER, buyed, `date`)
- SELECT vJose, @amount := SUM(ic.cm3 * io.amount / vc.palletM3 / 1000000), vDate
- FROM vn2008.item_out io
- JOIN vn.itemCost ic ON ic.itemFk = io.item_id AND ic.warehouseFk = vWarehouse
- JOIN vn.ticket t ON t.id = io.ticketFk
- JOIN vn.address a ON a.id = t.addressFk
- JOIN vn.province p ON p.id = a.provinceFk
- JOIN vn.country c ON c.id = p.countryFk
- JOIN vn.volumeConfig vc
- WHERE dat = vDate
- AND warehouse_id = vWarehouse
- AND c.country = 'Holanda'
- ON DUPLICATE KEY UPDATE buyed = buyed + @amount;
-
- INSERT INTO stockBuyed(USER, buyed, `date`)
- SELECT vClaudi, @amount := SUM(ic.cm3 * io.amount / vc.palletM3 / 1000000), vDate
- FROM vn2008.item_out io
- JOIN vn.itemCost ic ON ic.itemFk = io.item_id AND ic.warehouseFk = vWarehouse
- JOIN vn.ticket t ON t.id = io.ticketFk
- JOIN vn.address a ON a.id = t.addressFk
- JOIN vn.province p ON p.id = a.provinceFk
- JOIN vn.country c ON c.id = p.countryFk
- JOIN vn.volumeConfig vc
- WHERE dat BETWEEN vDate AND util.dayend(vDate)
- AND warehouse_id = vWarehouse
- AND c.country NOT IN ('Francia','Holanda')
- ON DUPLICATE KEY UPDATE buyed = buyed + @amount;
-
- DROP TEMPORARY TABLE
- tmp.buyUltimate,
- tmp_item;
-END ;;
-DELIMITER ;
-/*!50003 SET sql_mode = @saved_sql_mode */ ;
-/*!50003 SET character_set_client = @saved_cs_client */ ;
-/*!50003 SET character_set_results = @saved_cs_results */ ;
-/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `stockBuyedByWorker` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -78649,6 +77888,69 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
+/*!50003 DROP PROCEDURE IF EXISTS `stockBuyed_add` */;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+DELIMITER ;;
+CREATE DEFINER=`root`@`localhost` PROCEDURE `stockBuyed_add`(vDated DATE)
+BEGIN
+/**
+ * Inserta el volumen de compra por comprador en vn.stockBuyed de acuerdo con la fecha
+ *
+ * @param vDated Fecha de compra
+ */
+ CALL vn.stockTraslation(vDated);
+
+ DELETE
+ FROM vn.stockBuyed
+ WHERE `date` = vDated;
+
+ INSERT INTO vn.stockBuyed(`user`, buyed, `date`, description)
+ SELECT it.workerFk,
+ SUM(( ti.amount / b.packing ) * vn.buy_getVolume(b.id)) / vc.palletM3 / 1000000 buyed,
+ vDated,
+ u.name
+ FROM tmp_item ti
+ JOIN vn.item i ON i.id = ti.item_id
+ JOIN vn.itemType it ON it.id = i.typeFk
+ JOIN vn.itemCategory ic ON ic.id = it.categoryFk
+ JOIN vn.warehouse wh ON wh.code = 'VNH'
+ JOIN tmp.buyUltimate bu ON bu.itemFk = i.id AND bu.warehouseFk = wh.id
+ JOIN vn.buy b ON b.id = bu.buyFk
+ JOIN vn.volumeConfig vc
+ JOIN account.`user` u ON u.id = it.workerFk
+ WHERE ic.display != 0
+ GROUP BY it.workerFk;
+
+ INSERT INTO stockBuyed(buyed, `date`, description)
+ SELECT SUM(ic.cm3 * ito.quantity / vc.palletM3 / 1000000), vDated, IF(c.country = 'España',p.name,c.country) destiny
+ FROM vn.itemTicketOut ito
+ JOIN vn.ticket t ON t.id = ito.ticketFk
+ JOIN vn.address a ON a.id = t.addressFk
+ JOIN vn.province p ON p.id = a.provinceFk
+ JOIN vn.country c ON c.id = p.countryFk
+ JOIN vn.warehouse wh ON wh.id = t.warehouseFk
+ JOIN vn.itemCost ic ON ic.itemFk = ito.itemFk AND ic.warehouseFk = t.warehouseFk
+ JOIN vn.volumeConfig vc
+ WHERE ito.shipped BETWEEN vDated AND util.dayend(vDated)
+ AND wh.code = 'VNH'
+ GROUP BY destiny;
+
+ DROP TEMPORARY TABLE
+ tmp.buyUltimate,
+ tmp_item;
+END ;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `stockTraslation` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -80514,11 +79816,11 @@ DELIMITER ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8 */ ;
-/*!50003 SET character_set_results = utf8 */ ;
-/*!50003 SET collation_connection = utf8_general_ci */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketCreateWithUser`(
vClientId INT
@@ -80532,191 +79834,19 @@ CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketCreateWithUser`(
,vUserId INT
,OUT vNewTicket INT)
BEGIN
--- si se modifica algo avisad a jgallego
- DECLARE vZoneFk INT;
- DECLARE vPrice DECIMAL(10,2);
- DECLARE vBonus DECIMAL(10,2);
-
- IF vClientId IS NULL THEN
- CALL util.throw ('CLIENT_NOT_ESPECIFIED');
- END IF;
-
- IF NOT vAddressFk OR vAddressFk IS NULL THEN
- SELECT id INTO vAddressFk
- FROM address
- WHERE clientFk = vClientId AND isDefaultAddress;
- END IF;
-
- IF vAgencyModeFk IS NOT NULL THEN
-
- CALL vn.zone_getShipped (vlanded, vAddressFk, vAgencyModeFk, TRUE);
-
- SELECT zoneFk, price, bonus INTO vZoneFk, vPrice, vBonus
- FROM tmp.zoneGetShipped
- WHERE shipped = vShipped AND warehouseFk = vWarehouseFk LIMIT 1;
-
- IF vZoneFk IS NULL OR vZoneFk = 0 THEN
- CALL util.throw ('NOT_ZONE_WITH_THIS_PARAMETERS');
- END IF;
- END IF;
- INSERT INTO ticket (
- clientFk,
- shipped,
- addressFk,
- agencyModeFk,
- nickname,
- warehouseFk,
- routeFk,
- companyFk,
- landed,
- zoneFk,
- zonePrice,
- zoneBonus
- )
- SELECT
- vClientId,
- vShipped,
- a.id,
- vAgencyModeFk,
- a.nickname,
- vWarehouseFk,
- IF(vRouteFk,vRouteFk,NULL),
- vCompanyFk,
- vlanded,
- vZoneFk,
- vPrice,
- vBonus
- FROM address a
- JOIN agencyMode am ON am.id = a.agencyModeFk
- WHERE a.id = vAddressFk;
-
- SET vNewTicket = LAST_INSERT_ID();
-
- INSERT INTO ticketObservation(ticketFk, observationTypeFk, description)
- SELECT vNewTicket, ao.observationTypeFk, ao.description
- FROM addressObservation ao
- JOIN address a ON a.id = ao.addressFk
- WHERE a.id = vAddressFk;
-
- IF (SELECT COUNT(*) FROM bs.clientNewBorn cnb
- WHERE cnb.clientFk = vClientId
- AND NOT cnb.isRookie) = 0 THEN
-
- CALL vn.ticketObservation_addNewBorn(vNewTicket);
- END IF;
-
- INSERT INTO vn.ticketLog
- SET originFk = vNewTicket, userFk = vUserId, `action` = 'insert', description = CONCAT('Ha creado el ticket:', ' ', vNewTicket);
-
- IF (SELECT ct.isCreatedAsServed FROM vn.clientType ct JOIN vn.client c ON c.typeFk = ct.code WHERE c.id = vClientId ) <> FALSE THEN
- INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador)
- SELECT id, vNewTicket, account.myUser_getId()
- FROM state
- WHERE `code` = 'DELIVERED';
- END IF;
-END ;;
-DELIMITER ;
-/*!50003 SET sql_mode = @saved_sql_mode */ ;
-/*!50003 SET character_set_client = @saved_cs_client */ ;
-/*!50003 SET character_set_results = @saved_cs_results */ ;
-/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `ticketCreateWithUser__` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketCreateWithUser__`(
- vClientId INT
- ,vShipped DATE
- ,vWarehouseFk INT
- ,vCompanyFk INT
- ,vAddressFk INT
- ,vAgencyModeFk INT
- ,vRouteFk INT
- ,vlanded DATE
- ,vUserId INT
- ,OUT vNewTicket INT)
-BEGIN
-
- DECLARE vZoneFk INT;
- DECLARE vPrice DECIMAL(10,2);
- DECLARE vBonus DECIMAL(10,2);
-
- IF vClientId IS NULL THEN
- CALL util.throw ('CLIENT_NOT_ESPECIFIED');
- END IF;
-
- IF NOT vAddressFk OR vAddressFk IS NULL THEN
- SELECT id INTO vAddressFk
- FROM address
- WHERE clientFk = vClientId AND isDefaultAddress;
- END IF;
-
- IF vAgencyModeFk IS NOT NULL THEN
-
- CALL vn.zone_getShippedWarehouse(vlanded, vAddressFk, vAgencyModeFk);
-
- SELECT zoneFk, price, bonus INTO vZoneFk, vPrice, vBonus
- FROM tmp.zoneGetShipped
- WHERE shipped = vShipped AND warehouseFk = vWarehouseFk LIMIT 1;
-
- IF vZoneFk IS NULL OR vZoneFk = 0 THEN
- CALL util.throw ('NOT_ZONE_WITH_THIS_PARAMETERS');
- END IF;
- END IF;
- INSERT INTO ticket (
- clientFk,
- shipped,
- addressFk,
- agencyModeFk,
- nickname,
- warehouseFk,
- routeFk,
- companyFk,
- landed,
- zoneFk,
- zonePrice,
- zoneBonus
- )
- SELECT
- vClientId,
- vShipped,
- a.id,
- vAgencyModeFk,
- a.nickname,
- vWarehouseFk,
- IF(vRouteFk,vRouteFk,NULL),
- vCompanyFk,
- vlanded,
- vZoneFk,
- vPrice,
- vBonus
- FROM address a
- JOIN agencyMode am ON am.id = a.agencyModeFk
- WHERE a.id = vAddressFk;
-
- SET vNewTicket = LAST_INSERT_ID();
-
- INSERT INTO ticketObservation(ticketFk, observationTypeFk, description)
- SELECT vNewTicket, ao.observationTypeFk, ao.description
- FROM addressObservation ao
- JOIN address a ON a.id = ao.addressFk
- WHERE a.id = vAddressFk;
-
- INSERT INTO vn.ticketLog
- SET originFk = vNewTicket, userFk = vUserId, `action` = 'insert', description = CONCAT('Ha creado el ticket:', ' ', vNewTicket);
-
- IF (SELECT ct.isCreatedAsServed FROM vn.clientType ct JOIN vn.client c ON c.typeFk = ct.code WHERE c.id = vClientId ) <> FALSE THEN
- INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador)
- SELECT id, vNewTicket, getWorker()
- FROM state
- WHERE `code` = 'DELIVERED';
- END IF;
+ CALL ticket_add(
+ vClientId,
+ vShipped,
+ vWarehouseFk,
+ vCompanyFk,
+ vAddressFk,
+ vAgencyModeFk,
+ vRouteFk,
+ vlanded,
+ vUserId,
+ TRUE,
+ vNewTicket
+ );
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -81519,11 +80649,11 @@ DELIMITER ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8 */ ;
-/*!50003 SET character_set_results = utf8 */ ;
-/*!50003 SET collation_connection = utf8_general_ci */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketPackagingRecovery__`()
BEGIN
@@ -81554,8 +80684,17 @@ BEGIN
WHILE NOT done DO
- CALL vn.ticketCreate(vClientFk,vShipped,vWarehouseFk,vCompanyFk, NULL, NULL, NULL,
- vShipped,vTicketNewFk);
+ CALL vn.ticket_add(vClientFk,
+ vShipped,
+ vWarehouseFk,
+ vCompanyFk,
+ NULL,
+ NULL,
+ NULL,
+ vShipped,
+ account.userGetId(),
+ TRUE,
+ vTicketNewFk);
UPDATE vn.ticketPackaging set ticketFk = vTicketNewFk WHERE ticketFk = vTicketFk;
@@ -82518,6 +81657,99 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
+/*!50003 DROP PROCEDURE IF EXISTS `ticket_canAdvance` */;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+DELIMITER ;;
+CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_canAdvance`(vDated DATE, vWarehouseFk INT)
+BEGIN
+/**
+ * Devuelve los tickets y la cantidad de lineas de venta que se pueden adelantar.
+ *
+ * @param vDated Fecha de los tickets que se quieren adelantar.
+ * @param vWarehouseFk Almacén
+ */
+ DECLARE vDateInventory DATE;
+ DECLARE vDateToAdvance DATE;
+
+ SELECT inventoried INTO vDateInventory FROM vn.config;
+
+ SET vDateToAdvance = TIMESTAMPADD(DAY,-1,vDated);
+
+ DROP TEMPORARY TABLE IF EXISTS tmp.stock;
+ CREATE TEMPORARY TABLE tmp.stock
+ (itemFk INT PRIMARY KEY,
+ amount INT)
+ ENGINE = MEMORY;
+
+ INSERT INTO tmp.stock(itemFk, amount)
+ SELECT itemFk, SUM(quantity) amount FROM
+ (
+ SELECT itemFk, quantity
+ FROM vn.itemTicketOut
+ WHERE shipped >= vDateInventory
+ AND shipped < vDated
+ AND warehouseFk = vWarehouseFk
+ UNION ALL
+ SELECT itemFk, quantity
+ FROM vn.itemEntryIn
+ WHERE landed >= vDateInventory
+ AND landed < vDated
+ AND isVirtualStock = FALSE
+ AND warehouseInFk = vWarehouseFk
+ UNION ALL
+ SELECT itemFk, quantity
+ FROM vn.itemEntryOut
+ WHERE shipped >= vDateInventory
+ AND shipped < vDated
+ AND warehouseOutFk = vWarehouseFk
+ ) t
+ GROUP BY itemFk HAVING amount != 0;
+
+ SELECT s.ticketFk ticketFuture,
+ sum((s.quantity <= IFNULL(st.amount,0))) hasStock,
+ count(DISTINCT s.id) saleCount,
+ st.name tfState,
+ GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk) tfIpt,
+ t2.ticketFk,
+ t2.state,
+ t2.ipt
+ FROM vn.ticket t
+ JOIN vn.ticketState ts ON ts.ticketFk = t.id
+ JOIN vn.state st ON st.id = ts.stateFk
+ LEFT JOIN (SELECT
+ t2.id ticketFk,
+ t2.addressFk,
+ st.name state,
+ GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk) ipt
+ FROM vn.ticket t2
+ JOIN vn.sale s ON s.ticketFk = t2.id
+ JOIN vn.item i ON i.id = s.itemFk
+ JOIN vn.ticketState ts ON ts.ticketFk = t2.id
+ JOIN vn.state st ON st.id = ts.stateFk
+ WHERE t2.shipped BETWEEN vDateToAdvance AND util.dayend(vDateToAdvance)
+ AND t2.warehouseFk = vWarehouseFk
+ GROUP BY t2.id) t2 ON t2.addressFk = t.addressFk
+ JOIN vn.sale s ON s.ticketFk = t.id
+ JOIN vn.item i ON i.id = s.itemFk
+ LEFT JOIN tmp.stock st ON st.itemFk = s.itemFk
+ WHERE t.shipped BETWEEN vDated AND util.dayend(vDated)
+ AND t.warehouseFk = vWarehouseFk
+ GROUP BY t.id;
+
+ DROP TEMPORARY TABLE tmp.stock;
+END ;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticket_canMerge` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -82530,36 +81762,52 @@ DELIMITER ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_canMerge`(vDated DATE, vScopeDays INT, vLitersMax INT, vLinesMax INT, vWarehouseFk INT)
BEGIN
-
- /* Devuelve un listado de tickets susceptibles de fusionarse con otros tickets en el futuro
- *
- * @param vDated Fecha en cuestión
- * @param vScopeDays Dias en el futuro a sondear
- * @param vLitersMax Volumen máximo de los tickets a catapultar
- * @param vLinesMax Número máximo de lineas de los tickets a catapultar
- * @param vWarehouseFk Identificador de vn.warehouse
- */
-
+/**
+ * Devuelve un listado de tickets susceptibles de fusionarse con otros tickets en el futuro
+ *
+ * @param vDated Fecha en cuestión
+ * @param vScopeDays Dias en el futuro a sondear
+ * @param vLitersMax Volumen máximo de los tickets a catapultar
+ * @param vLinesMax Número máximo de lineas de los tickets a catapultar
+ * @param vWarehouseFk Identificador de vn.warehouse
+ */
SELECT sv.ticketFk ,
+ GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk) ipt,
CAST(sum(litros) AS DECIMAL(10,0)) liters,
CAST(count(*) AS DECIMAL(10,0)) `lines`,
+ st.name state,
sub2.id ticketFuture,
- sub2.shipped
+ sub2.shipped,
+ sub2.iptd tfIpt,
+ sub2.state tfState
FROM vn.saleVolume sv
+ JOIN vn.sale s ON s.id = sv.saleFk
+ JOIN vn.item i ON i.id = s.itemFk
JOIN vn.ticket t ON t.id = sv.ticketFk
JOIN vn.address a ON a.id = t.addressFk
JOIN vn.province p ON p.id = a.provinceFk
JOIN vn.country c ON c.id = p.countryFk
JOIN vn.ticketState ts ON ts.ticketFk = t.id
+ JOIN vn.state st ON st.id = ts.stateFk
JOIN vn.alertLevel al ON al.id = ts.alertLevel
LEFT JOIN vn.ticketParking tp ON tp.ticketFk = t.id
LEFT JOIN (
SELECT * FROM (
- SELECT t.addressFk , t.id, t.shipped
+ SELECT
+ t.addressFk ,
+ t.id,
+ t.shipped,
+ st.name state,
+ GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk) iptd
FROM vn.ticket t
+ JOIN vn.ticketState ts ON ts.ticketFk = t.id
+ JOIN vn.state st ON st.id = ts.stateFk
+ JOIN vn.sale s ON s.ticketFk = t.id
+ JOIN vn.item i ON i.id = s.itemFk
WHERE t.shipped BETWEEN TIMESTAMPADD(DAY, vScopeDays,vDated)
AND util.dayend(TIMESTAMPADD(DAY, vScopeDays,vDated))
AND t.warehouseFk = vWarehouseFk
+ GROUP BY t.id
) sub
GROUP BY sub.addressFk
) sub2 ON sub2.addressFk = t.addressFk AND t.id != sub2.id
@@ -83014,13 +82262,12 @@ BEGIN
JOIN vn.sale saleClon ON saleOriginal.itemFk = saleClon.itemFk AND saleOriginal.quantity = saleClon.quantity
WHERE saleOriginal.ticketFk = vTicketFk AND saleClon.ticketFk = vNewTicket;
- INSERT INTO ticketRequest (description,ordered,shipped,salesPersonCode,buyerCode,quantity,price,itemFk,clientFk,response,
- total,buyed,saleFk)
- SELECT o.description,o.ordered,vShipment,o.salesPersonCode,o.buyerCode,o.quantity,o.price,o.itemFk,o.clientFk,o.response,
- o.total,o.buyed,s2.id
- FROM sale s JOIN ticketRequest o ON o.saleFk = s.id
- JOIN sale s2 ON s.concept = s2.concept AND s.quantity = s2.quantity AND s.itemFk = s2.itemFk
- WHERE s.ticketFk = vTicketFk AND s2.ticketFk = vNewTicket;
+ INSERT INTO ticketRequest (description,ordered,shipped,quantity,price,itemFk,clientFk,response,
+ total,buyed,requesterFk,attenderFk,ticketFk)
+ SELECT description,ordered,shipped,quantity,price,itemFk,clientFk,response,
+ total,buyed,requesterFk,attenderFk,vNewTicket
+ FROM ticketRequest
+ WHERE ticketFk =vTicketFk;
INSERT INTO ticketObservation(ticketFk,observationTypeFk,description) VALUES(vNewTicket,4,CONCAT('turno desde ticket: ',vTicketFk))
ON DUPLICATE KEY UPDATE description = CONCAT(ticketObservation.description,VALUES(description),' ');
@@ -83776,7 +83023,7 @@ BEGIN
CREATE TEMPORARY TABLE tmp.ticket
SELECT ticketFk
FROM tmp.productionBuffer
- WHERE shipped = vn.VN_CURDATE()
+ WHERE shipped = curdate()
AND problem LIKE '%I:%'
AND (HH <= vHour OR HH = vHour AND mm < vMinute)
AND alertLevel = 0;
@@ -83887,6 +83134,7 @@ proc: BEGIN
DECLARE vDone BOOL;
DECLARE vTicketFk INT;
+ DECLARE vError INT;
DECLARE cCur CURSOR FOR
SELECT ticketFk FROM ticketRecalc;
@@ -83898,6 +83146,17 @@ proc: BEGIN
BEGIN
DO RELEASE_LOCK('vn.ticket_doRecalc');
ROLLBACK;
+ GET DIAGNOSTICS CONDITION 2 @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
+ SET vError = IFNULL(@errno, 0) ;
+ IF NOT(vError = 1105 OR vError = 1751) THEN
+ CALL `vn`.`mail_insert`('cau@verdnatura.es',
+ NULL,
+ 'Problema al recalcular el total de ticket',
+ CONCAT('Se ha detectado un problema en ticket_doRecalc al calcular el total del ticket : ',
+ vTicketFk,' el error es el: ',
+ CONCAT('ERROR ', IFNULL(@errno, 0), ': ', ifnull(@text, '')))
+ );
+ END IF;
RESIGNAL;
END;
@@ -84166,11 +83425,11 @@ DELIMITER ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8 */ ;
-/*!50003 SET character_set_results = utf8 */ ;
-/*!50003 SET collation_connection = utf8_general_ci */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`%` PROCEDURE `ticket_getMovable`(vTicketFk INT, vDatedNew DATETIME, vWarehouseFk INT)
BEGIN
@@ -84211,7 +83470,8 @@ BEGIN
WHERE t.id = vTicketFk;
DROP TEMPORARY TABLE IF EXISTS tmp.itemList;
- DROP TEMPORARY TABLE IF EXISTS tmp.itemMinacum;
+ DROP TEMPORARY TABLE IF EXISTS tmp.itemMinacum;
+
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -84362,6 +83622,156 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
+/*!50003 DROP PROCEDURE IF EXISTS `ticket_getSplitList` */;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+DELIMITER ;;
+CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_getSplitList`(vDated DATE, vHour TIME, vWarehouseFk INT)
+BEGIN
+/**
+ * Devuelve un listado con los tickets posibles para splitar HOY.
+ *
+ * @param vDated Fecha a estudiar
+ * @param vHour Hora a partir de la cual todavía se puede enviar, si la fecha es la de hoy
+ * @param vWarehouseFk Almacén
+ */
+ DECLARE vAvailableCache INT;
+ DECLARE vVisibleCache INT;
+
+ CALL cache.available_refresh(vAvailableCache, FALSE, vWarehouseFk, vn.VN_CURDATE());
+ CALL cache.visible_refresh(vVisibleCache, FALSE, vWarehouseFk);
+ CALL `vn`.`zoneClosure_recalc`();
+
+ DROP TEMPORARY TABLE IF EXISTS tmp.salesToSplit;
+
+ CREATE TEMPORARY TABLE tmp.salesToSplit
+ (saleFk INT PRIMARY KEY,
+ ticketFk INT,
+ problem VARCHAR(1)) ENGINE = MEMORY;
+
+ INSERT INTO tmp.salesToSplit(saleFk, ticketFk, problem)
+ SELECT s.id, s.ticketFk, 'F'
+ FROM vn.ticket t
+ JOIN vn.sale s ON s.ticketFk = t.id
+ JOIN vn.item i ON i.id = s.itemFk
+ JOIN vn.itemType it on it.id = i.typeFk
+ JOIN vn.itemCategory ic ON ic.id = it.categoryFk
+ LEFT JOIN cache.visible v ON v.item_id = i.id AND v.calc_id = vVisibleCache
+ LEFT JOIN cache.available av ON av.item_id = i.id AND av.calc_id = vAvailableCache
+ LEFT JOIN vn.itemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk
+ WHERE IFNULL(v.visible,0) < s.quantity
+ AND IFNULL(av.available ,0) < s.quantity
+ AND IFNULL(issw.visible, 0) < s.quantity
+ AND s.isPicked = FALSE
+ AND s.reserved = FALSE
+ AND ic.merchandise = TRUE
+ AND t.shipped BETWEEN vn.VN_CURDATE() AND util.dayend(vn.VN_CURDATE())
+ AND NOT i.generic
+ AND t.warehouseFk = vWarehouseFk;
+
+ INSERT IGNORE INTO tmp.salesToSplit(saleFk, ticketFk, problem)
+ SELECT s.id, s.ticketFk, 'I'
+ FROM vn.ticket t
+ JOIN vn.sale s ON s.ticketFk = t.id
+ JOIN vn.item i ON i.id = s.itemFk
+ JOIN vn.itemType it on it.id = i.typeFk
+ JOIN vn.itemCategory ic ON ic.id = it.categoryFk
+ LEFT JOIN cache.visible v ON v.item_id = s.itemFk AND v.calc_id = vVisibleCache
+ LEFT JOIN vn.itemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk
+ WHERE IFNULL(v.visible,0) >= s.quantity
+ AND IFNULL(issw.visible, 0) < s.quantity
+ AND s.quantity > 0
+ AND s.isPicked = FALSE
+ AND s.reserved = FALSE
+ AND ic.merchandise = TRUE
+ AND t.shipped BETWEEN vn.VN_CURDATE() AND util.dayend(vn.VN_CURDATE())
+ AND NOT i.generic
+ AND t.warehouseFk = vWarehouseFk;
+
+ INSERT IGNORE INTO tmp.salesToSplit(saleFk, ticketFk, problem)
+ SELECT s.id, s.ticketFk, 'R'
+ FROM vn.ticket t
+ JOIN vn.sale s ON s.ticketFk = t.id
+ JOIN vn.item i ON i.id = s.itemFk
+ JOIN vn.itemType it on it.id = i.typeFk
+ JOIN vn.itemCategory ic ON ic.id = it.categoryFk
+ LEFT JOIN cache.visible v ON v.item_id = s.itemFk AND v.calc_id = vVisibleCache
+ LEFT JOIN cache.available av ON av.item_id = i.id AND av.calc_id = vAvailableCache
+ LEFT JOIN vn.itemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk
+ WHERE IFNULL(v.visible,0) < s.quantity
+ AND IFNULL(av.available ,0) >= s.quantity
+ AND IFNULL(issw.visible, 0) < s.quantity
+ AND s.quantity > 0
+ AND s.isPicked = FALSE
+ AND s.reserved = FALSE
+ AND ic.merchandise = TRUE
+ AND t.shipped BETWEEN vn.VN_CURDATE() AND util.dayend(vn.VN_CURDATE())
+ AND NOT i.generic
+ AND t.warehouseFk = vWarehouseFk;
+
+ DROP TEMPORARY TABLE IF EXISTS tmp.ticketsToSplit;
+
+ CREATE TEMPORARY TABLE tmp.ticketsToSplit
+ (ticketFk INT PRIMARY KEY,
+ problems VARCHAR(100),
+ addressFk INT,
+ ipt VARCHAR(10),
+ etd TIME) ENGINE = MEMORY;
+
+ INSERT INTO tmp.ticketsToSplit
+ SELECT
+ ss.ticketFk,
+ GROUP_CONCAT(DISTINCT ss.problem ORDER BY ss.problem) problems,
+ t.addressFk,
+ GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk) ipt,
+ zc.`hour` etd
+ FROM tmp.salesToSplit ss
+ JOIN vn.ticket t ON t.id = ss.ticketFk
+ JOIN vn.sale s ON s.id = ss.saleFk
+ JOIN vn.item i ON i.id = s.itemFk
+ LEFT JOIN vn.zoneClosure zc ON zc.zoneFk = t.zoneFk
+ GROUP BY ss.ticketFk;
+
+ SELECT
+ ts.*,
+ t.id ticketFuture,
+ st.name state,
+ zc.`hour` tfEtd,
+ GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk) tfIpt,
+ st2.name tfState
+ FROM tmp.ticketsToSplit ts
+ LEFT JOIN vn.ticketState ts2 ON ts2.ticketFk = ts.ticketFk
+ LEFT JOIN vn.state st ON st.id = ts2.stateFk
+ LEFT JOIN vn.ticket t
+ ON t.id != ts.ticketFk
+ AND t.addressFk = ts.addressFk
+ AND t.shipped BETWEEN vDated AND util.dayend(vDated)
+ LEFT JOIN vn.zoneClosure zc ON zc.zoneFk = t.zoneFk AND zc.dated = vDated
+ LEFT JOIN vn.sale s ON s.ticketFk = t.id
+ LEFT JOIN vn.item i ON i.id = s.itemFk
+ LEFT JOIN vn.ticketState tst ON tst.ticketFk = t.id
+ LEFT JOIN vn.state st2 ON st2.id = tst.stateFk
+ WHERE (t.id IS NULL
+ OR (vDated > vn.VN_CURDATE())
+ OR (vDated = vn.VN_CURDATE() AND vHour >= zc.`hour`))
+ AND ts.etd <= vHour
+ GROUP BY ts.ticketFk, t.id
+ ORDER BY ts.etd, ts.ticketFk;
+
+ DROP TEMPORARY TABLE
+ tmp.ticketsToSplit;
+END ;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticket_getTax` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -85219,6 +84629,96 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
+/*!50003 DROP PROCEDURE IF EXISTS `ticket_split` */;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+DELIMITER ;;
+CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_split`(vTicketFk INT, vTicketFutureFk INT, vDated DATE)
+proc:BEGIN
+/**
+ * Mueve las lineas con problemas a otro ticket existente o a uno nuevo.
+ *
+ * @param vTicketFk Identificador del ticket a splittar
+ * @param vTicketFutureFk Identificador del ticket al que se quieren mover las lineas
+ * @param vDate Fecha a la que se va a mover
+ * @table tmp.salesToSplit(saleFk, ticketFk, problem)
+ */
+ DECLARE vHasFullProblem BOOL;
+ DECLARE vProblemLines INT;
+ DECLARE vTotalLines INT;
+
+ SELECT COUNT(*) INTO vProblemLines
+ FROM tmp.salesToSplit
+ WHERE ticketFk = vTicketFk;
+
+ SELECT count(*) INTO vTotalLines
+ FROM vn.sale s
+ WHERE s.ticketFk = vTicketFk;
+
+ SET vHasFullProblem = (vTotalLines = vProblemLines);
+
+ -- Ticket completo
+ IF vHasFullProblem THEN
+
+ UPDATE vn.ticket
+ SET landed = vDated + 1,
+ shipped = vDated,
+ nickname = CONCAT('(',DAY(curdate()),') ', nickname )
+ WHERE id = vTicketFk;
+
+ SELECT CONCAT("Se ha cambiado el ticket ", vTicketFk, " al dia ", vDated);
+ LEAVE proc;
+
+ END IF;
+
+ -- Ticket a futuro existe
+ IF vTicketFutureFk THEN
+
+ UPDATE vn.sale s
+ JOIN tmp.salesToSplit ss ON s.id = ss.saleFk
+ SET s.ticketFk = vTicketFutureFk,
+ s.concept = CONCAT('(s) ', s.concept)
+ WHERE ss.ticketFk = vTicketFk;
+
+ SELECT CONCAT("Se han movido lineas del ticket ", vTicketFk,
+ " al ticket existente ", vTicketFutureFk,"(", vDated,")");
+ LEAVE proc;
+
+ END IF;
+
+ -- Ticket nuevo
+ CALL vn.ticket_Clone(vTicketFk, vTicketFutureFk);
+
+ UPDATE vn.ticket t
+ JOIN vn.productionConfig pc
+ SET t.landed = vDated + 1,
+ t.shipped = vDated,
+ t.agencyModeFk = pc.defautlAgencyMode,
+ t.zoneFk = pc.defaultZone
+ WHERE t.id = vTicketFutureFk;
+
+ UPDATE vn.sale s
+ JOIN tmp.salesToSplit sts ON sts.saleFk = s.id
+ SET s.ticketFk = vTicketFutureFk,
+ s.concept = CONCAT('(s) ', s.concept)
+ WHERE sts.ticketFk = vTicketFk;
+
+ CALL vn.ticketStateUpdate(vTicketFutureFk, 'FIXING');
+
+ SELECT CONCAT("Se han movido lineas del ticket ", vTicketFk,
+ " al nuevo ticket ", vTicketFutureFk,"(", vDated,")");
+END ;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticket_splitItemPackingType` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -86229,9 +85729,9 @@ DELIMITER ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_general_ci */ ;
+/*!50003 SET character_set_client = utf8 */ ;
+/*!50003 SET character_set_results = utf8 */ ;
+/*!50003 SET collation_connection = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
@@ -86256,17 +85756,23 @@ BEGIN
CREATE TEMPORARY TABLE tmp.timeControl
(INDEX(id), INDEX(journeyCounter))
ENGINE = MEMORY
- SELECT wtc.id,
- wtc.direction,
- wtc.timed,
- IF(wtc.direction = 'in' OR @hasOut OR wtc.userFk <> @lastUserFk, @journeyCounter := @journeyCounter + 1, @journeyCounter) journeyCounter,
- @lastUserFk := wtc.userFk workerFk,
- IF(wtc.direction = 'out', @hasOut:= TRUE, @hasOut:= FALSE)
- FROM workerTimeControl wtc
- JOIN tmp.`user` w ON w.userFk = wtc.userFk
- WHERE wtc.timed BETWEEN DATE_SUB(vDatedFrom, INTERVAL 1 DAY) AND DATE_ADD(vDatedTo, INTERVAL 1 DAY)
- ORDER BY wtc.userFk, wtc.timed;
-
+ SELECT sub.id,
+ sub.direction,
+ sub.timed,
+ IF(sub.direction = 'in' OR @hasOut OR sub.userFk <> @lastUserFk, @journeyCounter := @journeyCounter + 1, @journeyCounter) journeyCounter,
+ @lastUserFk := sub.userFk workerFk,
+ IF(sub.direction = 'out', @hasOut:= TRUE, @hasOut:= FALSE)
+ FROM (
+ SELECT DISTINCT wtc.id,
+ wtc.direction,
+ wtc.timed,
+ wtc.userFk
+ FROM workerTimeControl wtc
+ JOIN tmp.`user` w ON w.userFk = wtc.userFk
+ WHERE wtc.timed BETWEEN DATE_SUB(vDatedFrom, INTERVAL 1 DAY) AND DATE_ADD(vDatedTo, INTERVAL 1 DAY)
+ ORDER BY wtc.userFk, wtc.timed
+ ) sub;
+
DROP TEMPORARY TABLE IF EXISTS tmp.timeControlAux;
CREATE TEMPORARY TABLE tmp.timeControlAux
(INDEX(id), INDEX(journeyCounter))
@@ -86292,7 +85798,7 @@ BEGIN
OR timeWork >= vDayMaxTime
)sub ON sub.journeyCounter = tca.journeyCounter
WHERE sub.timed BETWEEN vDatedFrom AND vDatedTo;
-
+
DROP TEMPORARY TABLE IF EXISTS tmp.timeControl;
DROP TEMPORARY TABLE IF EXISTS tmp.timeControlAux;
@@ -90708,29 +90214,19 @@ DELIMITER ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_general_ci */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_sendMailByDepartment`(IN vWeek int, IN vYear int, IN vWorkerFk int)
+CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_sendMailByDepartment`(IN vDatedFrom DATETIME, IN vDatedTo DATETIME, IN vWorkerFk INT)
BEGIN
-
- /**
- * Inserta el registro de horario semanalmente de PRODUCCION, CAMARA, REPARTO, TALLER NATURAL y TALLER ARTIFICIAL en vn.mail.
- *
- * @param vWeek
- * @param vYear
- * @param vWorkerFk -> En el caso de querer generarlo para todos los empleados deberá de informarse como NULL
- */
-
- DECLARE vDateStart DATETIME;
- DECLARE vDateEnd DATETIME;
-
- SELECT CONCAT (MIN(dated), ' 00:00:00'), CONCAT (MAX(dated), ' 23:59:59') INTO vDateStart, vDateEnd
- FROM time
- WHERE year = vYear AND
- week = vWeek;
-
+/**
+ * Inserta el registro de horario semanalmente de PRODUCCION, CAMARA, REPARTO, TALLER NATURAL y TALLER ARTIFICIAL en vn.mail.
+ *
+ * @param vDatedFrom
+ * @param vDatedTo
+ * @param vWorkerFk -> En el caso de querer generarlo para todos los empleados deberá de pasarse = NULL
+ */
SET session group_concat_max_len = 15000;
DROP TEMPORARY TABLE IF EXISTS tmp.timeControlCalculate;
@@ -90738,15 +90234,15 @@ BEGIN
DROP TEMPORARY TABLE IF EXISTS tmp.reportHours;
IF vWorkerFk IS NULL THEN
- CALL timeControl_calculateAll(vDateStart,vDateEnd);
- CALL timeBusiness_calculateAll(vDateStart,vDateEnd);
+ CALL timeControl_calculateAll(vDatedFrom,vDatedTo);
+ CALL timeBusiness_calculateAll(vDatedFrom,vDatedTo);
ELSE
- CALL timeControl_calculateByUser(vWorkerFk,vDateStart,vDateEnd);
- CALL timeBusiness_calculateByUser(vWorkerFk,vDateStart,vDateEnd);
+ CALL timeControl_calculateByUser(vWorkerFk,vDatedFrom,vDatedTo);
+ CALL timeBusiness_calculateByUser(vWorkerFk,vDatedFrom,vDatedTo);
END IF;
CREATE TEMPORARY TABLE tmp.reportHours
- SELECT t.dated,
+ SELECT t.dated,
IF (tm.hoursWeek IS NULL,'', GROUP_CONCAT(DATE_FORMAT(wtc.timed,'%H:%i') ORDER BY wtc.timed ASC SEPARATOR ' ') ) timeWorkDay,
SEC_TO_TIME(IFNULL(tm.timeWorkSeconds, 0)) tm,
SEC_TO_TIME(IFNULL(tc.timeWorkSeconds, 0)) tc,
@@ -90775,12 +90271,11 @@ BEGIN
LEFT JOIN client c ON c.id = w.id
WHERE wc.name NOT IN ('VNH')
AND d.hasToSendMail
- AND (wl.ended >= vn.VN_CURDATE() OR wl.ended IS NULL)
GROUP BY tm.userFk,t.dated
ORDER BY tm.userFk,t.dated;
INSERT INTO vn.mail (receiver, replyTo, subject, body)
- SELECT eu.email, 'laboral@verdnatura.es', CONCAT('Registro de horas semana ', vWeek, ' año ', vYear) ,
+ SELECT eu.email, 'laboral@verdnatura.es', CONCAT('Registro de horas semana ', WEEK(vDatedFrom), ' año ', YEAR(vDatedFrom)) ,
CONCAT('
@@ -90866,16 +90361,12 @@ DELIMITER ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_sendMailByDepartmentLauncher`()
BEGIN
- DECLARE vWeek,vYear INT;
+ DECLARE vDatedFrom, vDatedTo DATETIME;
IF (DAYNAME(vn.VN_CURDATE()) = 'miércoles') THEN
- SELECT week,year INTO vWeek,vYear
- FROM vn.time
- WHERE dated IN (DATE_ADD(vn.VN_CURDATE(), INTERVAL -10 DAY), DATE_ADD(vn.VN_CURDATE(), INTERVAL -4 DAY))
- GROUP BY year,week
- LIMIT 1;
-
- CALL vn.workerTimeControl_sendMailByDepartment(vWeek, vYear, NULL);
+ SELECT DATE_SUB(vn.VN_CURDATE(), INTERVAL 9 DAY), CONCAT(DATE_SUB(vn.VN_CURDATE(), INTERVAL 3 DAY), ' 23:59:59') INTO vDatedFrom, vDatedTo;
+
+ CALL vn.workerTimeControl_sendMailByDepartment(vDatedFrom, vDatedTo, NULL);
END IF;
END ;;
DELIMITER ;
@@ -92804,37 +92295,6 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `zonePromo_Make__` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `zonePromo_Make__`()
-BEGIN
-
- INSERT INTO vn.sale(ticketFk, itemFk, quantity, concept, price)
- SELECT t.id , 98, - packages, '-- DIA DE COMPRA BONIFICADO --', zp.amount
- FROM vn.ticket t
- JOIN vn.zonePromo zp ON zp.zoneFk = t.zoneFk AND zp.dated = DATE(t.shipped)
- WHERE zp.isDone = FALSE
- AND zp.dated < vn.VN_CURDATE()
- AND t.refFk IS NULL;
-
- UPDATE vn.zonePromo
- SET isDone = TRUE
- WHERE dated < vn.VN_CURDATE();
-
-END ;;
-DELIMITER ;
-/*!50003 SET sql_mode = @saved_sql_mode */ ;
-/*!50003 SET character_set_client = @saved_cs_client */ ;
-/*!50003 SET character_set_results = @saved_cs_results */ ;
-/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `zone_doCalcInitialize` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -93006,6 +92466,53 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
+/*!50003 DROP PROCEDURE IF EXISTS `zone_getClosed` */;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+DELIMITER ;;
+CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getClosed`()
+proc:BEGIN
+/**
+ * Devuelve una tabla con las zonas cerradas para hoy
+ *
+ * @table tmp.closedZones(zoneFk, warehouseFk);
+ */
+ DROP TEMPORARY TABLE IF EXISTS tmp.closedZones;
+
+ CREATE TEMPORARY TABLE tmp.closedZones (
+ `zoneFk` int(11) NOT NULL,
+ `warehouseFk` smallint(6) unsigned NOT NULL,
+ PRIMARY KEY `zoneFk` (`zoneFk`,`warehouseFk`),
+ KEY `warehouseFk` (`warehouseFk`))
+ ENGINE=MEMORY DEFAULT CHARSET=utf8;
+
+ INSERT INTO tmp.closedZones(zoneFk, warehouseFk)
+ SELECT zoneFk, warehouseFk
+ FROM (
+ SELECT t.zoneFk, t.warehouseFk, count(DISTINCT t.id) numTickets, pc.minTicketsToCloseZone
+ FROM vn.ticket t
+ JOIN vn.expedition e ON e.ticketFk = t.id
+ JOIN vn.`zone`z on z.id = t.zoneFk
+ JOIN vn.agencyMode am ON am.id = z.agencyModeFk
+ JOIN vn.agency a ON a.id = am.agencyFk
+ JOIN vn.productionConfig pc
+ WHERE a.isOwn
+ AND pc.isZoneClosedByExpeditionActivated
+ AND e.created >= vn.VN_CURDATE()
+ GROUP BY t.zoneFk, t.warehouseFk
+ HAVING numTickets >= minTicketsToCloseZone) sub;
+ END ;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `zone_getCollisions` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -93298,34 +92805,42 @@ DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getLanded`(vShipped DATE, vAddressFk INT, vAgencyModeFk INT, vWarehouseFk INT, vShowExpiredZones BOOLEAN)
BEGIN
/**
-* Devuelve una tabla temporal con el dia de recepcion para vShipped.
-*
-* @param vShipped Fecha de preparacion de mercancia
-* @param vAddressFk Id de consignatario, %NULL para recogida
-* @param vAgencyModeFk Id agencia
-* @param vWarehouseFk vWarehouseFk
-* @table tmp.zoneGetLanded Datos de recepción
-*/
+ * Devuelve una tabla temporal con el dia de recepcion para vShipped.
+ * Excluye las que tengan cajas preparadas
+ *
+ * @param vShipped Fecha de preparacion de mercancia
+ * @param vAddressFk Id de consignatario, %NULL para recogida
+ * @param vAgencyModeFk Id agencia
+ * @param vWarehouseFk vWarehouseFk
+ * @table tmp.zoneGetLanded Datos de recepción
+ */
+ CALL vn.zone_getFromGeo(address_getGeo(vAddressFk));
- CALL zone_getFromGeo(address_getGeo(vAddressFk));
- CALL zone_getOptionsForShipment(vShipped, vShowExpiredZones);
+ CALL vn.zone_getOptionsForShipment(vShipped, vShowExpiredZones);
+
+ CALL vn.zone_getClosed();
DROP TEMPORARY TABLE IF EXISTS tmp.zoneGetLanded;
CREATE TEMPORARY TABLE tmp.zoneGetLanded
ENGINE = MEMORY
SELECT vWarehouseFk warehouseFk,
- TIMESTAMPADD(DAY,zo.travelingDays, vShipped) landed,
+ TIMESTAMPADD(DAY,zo.travelingDays, vShipped) landed,
zo.zoneFk
FROM tmp.zoneOption zo
- JOIN zone z ON z.id = zo.zoneFk
- JOIN zoneWarehouse zw ON zw.zoneFk = z.id
- WHERE agencyModeFk = vAgencyModeFk
- AND zw.warehouseFk = vWarehouseFk;
-
+ JOIN vn.`zone` z ON z.id = zo.zoneFk
+ JOIN vn.zoneWarehouse zw ON zw.zoneFk = z.id
+ LEFT JOIN tmp.closedZones cz
+ ON cz.warehouseFk = zw.warehouseFk
+ AND cz.zoneFk = zw.zoneFk
+ AND zo.shipped = vn.VN_CURDATE()
+ WHERE z.agencyModeFk = vAgencyModeFk
+ AND zw.warehouseFk = vWarehouseFk
+ AND (ISNULL(cz.zoneFk) OR vShowExpiredZones);
+
DROP TEMPORARY TABLE
- tmp.zone,
- tmp.zoneOption;
-
+ tmp.`zone`,
+ tmp.zoneOption,
+ tmp.closedZones;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -93778,7 +93293,8 @@ BEGIN
l.travelingDays,
IFNULL(e.price, z.price) price,
IFNULL(e.bonus, z.bonus) bonus,
- l.landed
+ l.landed,
+ vShipped shipped
FROM tmp.zone t
JOIN zone z ON z.id = t.id
JOIN zoneEvent e ON e.zoneFk = t.id
@@ -93815,123 +93331,6 @@ BEGIN
WHERE vShipped < vn.VN_CURDATE()
OR (vShipped = vn.VN_CURDATE() AND vn.VN_CURTIME() > `hour`);
END IF;
-END ;;
-DELIMITER ;
-/*!50003 SET sql_mode = @saved_sql_mode */ ;
-/*!50003 SET character_set_client = @saved_cs_client */ ;
-/*!50003 SET character_set_results = @saved_cs_results */ ;
-/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `zone_getOptionsForShipment_beta` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getOptionsForShipment_beta`(vShipped DATE, vShowExpiredZones BOOLEAN)
-BEGIN
-/**
- * Gets computed options for the passed zones and shipping date.
- *
- * @table tmp.zones(id) The zones ids
- * @param vShipped The shipping date
- * @return tmp.zoneOption(zoneFk, hour, travelingDays, price, bonus, specificity) The computed options
- */
- DECLARE vHour TIME DEFAULT TIME(vn.VN_NOW());
-
- DROP TEMPORARY TABLE IF EXISTS tLandings;
- CREATE TEMPORARY TABLE tLandings
- (INDEX (eventFk))
- ENGINE = MEMORY
- SELECT e.id eventFk,
- @travelingDays := IFNULL(e.travelingDays, z.travelingDays) travelingDays,
- TIMESTAMPADD(DAY, @travelingDays, vShipped) landed
- FROM tmp.zone t
- JOIN zone z ON z.id = t.id
- JOIN zoneEvent e ON e.zoneFk = t.id;
-
- SELECT * FROM tLandings
- JOIN vn.zoneEvent ze ON ze.id = eventFk
- WHERE ze.zoneFk = 25;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.zoneOption;
- CREATE TEMPORARY TABLE tmp.zoneOption
- ENGINE = MEMORY
- SELECT *
- FROM (
- SELECT t.id zoneFk,
- TIME(IFNULL(e.`hour`, z.`hour`)) `hour`,
- l.travelingDays,
- IFNULL(e.price, z.price) price,
- IFNULL(e.bonus, z.bonus) bonus,
- l.landed
- FROM tmp.zone t
- JOIN zone z ON z.id = t.id
- JOIN zoneEvent e ON e.zoneFk = t.id
- JOIN tLandings l ON l.eventFk = e.id
- WHERE (
- e.`type` = 'day'
- AND e.`dated` = l.landed
- ) OR (
- e.`type` != 'day'
- AND e.weekDays & (1 << WEEKDAY(l.landed))
- AND (e.`started` IS NULL OR l.landed >= e.`started`)
- AND (e.`ended` IS NULL OR l.landed <= e.`ended`)
- )
- ORDER BY
- zoneFk,
- CASE
- WHEN e.`type` = 'day'
- THEN -1
- WHEN e.`type` = 'range'
- THEN 2
- ELSE 3
- END
- ) t
- GROUP BY zoneFk;
-
- SELECT e.id, e.type, (e.`dated` = l.landed), e.`dated` , l.landed, t.id zoneFk,
- TIME(IFNULL(e.`hour`, z.`hour`)) `hour`,
- l.travelingDays,
- IFNULL(e.price, z.price) price,
- IFNULL(e.bonus, z.bonus) bonus,
- l.landed
- FROM tmp.zone t
- JOIN zone z ON z.id = t.id
- JOIN zoneEvent e ON e.zoneFk = t.id
- JOIN tLandings l ON l.eventFk = e.id
- WHERE zoneFk = 25
- ORDER BY
- zoneFk,
- CASE
- WHEN e.`type` = 'day'
- THEN 1
- WHEN e.`type` = 'range'
- THEN 2
- ELSE 3
- END;
-
- SELECT * FROm tmp.zoneOption WHERE zoneFk = 25;
-
- DROP TEMPORARY TABLE tLandings;
-
- DELETE t FROM tmp.zoneOption t
- JOIN zoneExclusion e
- ON e.zoneFk = t.zoneFk AND e.`dated` = t.landed;
-
- SELECT * FROm tmp.zoneOption WHERE zoneFk = 25;
-
- IF NOT vShowExpiredZones THEN
- DELETE FROM tmp.zoneOption
- WHERE vShipped < vn.VN_CURDATE()
- OR (vShipped = vn.VN_CURDATE() AND vn.VN_CURTIME() > `hour`);
- END IF;
-
-
-
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -93952,36 +93351,99 @@ CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getShipped`(vLanded DATE, vAdd
BEGIN
/**
* Devuelve la mínima fecha de envío para cada warehouse
- *
+ * Excluye aquellas zonas que ya tienen cajas preparadas en ese almacén
+ *
* @param vLanded La fecha de recepcion
* @param vAddressFk Id del consignatario
* @param vAgencyModeFk Id de la agencia
* @return tmp.zoneGetShipped
- */
- CALL zone_getFromGeo(address_getGeo(vAddressFk));
- CALL zone_getOptionsForLanding(vLanded, vShowExpiredZones);
-
+ */
+ CALL vn.zone_getFromGeo(address_getGeo(vAddressFk));
+ CALL vn.zone_getOptionsForLanding(vLanded, vShowExpiredZones);
+ CALL vn.zone_getClosed();
+
DROP TEMPORARY TABLE IF EXISTS tmp.zoneGetShipped;
CREATE TEMPORARY TABLE tmp.zoneGetShipped
ENGINE = MEMORY
SELECT * FROM (
- SELECT zo.zoneFk,
- TIMESTAMPADD(DAY,-zo.travelingDays, vLanded) shipped,
- zo.`hour`,
+ SELECT zo.zoneFk,
+ zo.shipped,
+ zo.`hour`,
zw.warehouseFk,
- z.agencyModeFk,
- zo.price,
- zo.bonus
+ z.agencyModeFk,
+ zo.price,
+ zo.bonus
FROM tmp.zoneOption zo
- JOIN zoneWarehouse zw ON zw.zoneFk = zo.zoneFk
- JOIN zone z ON z.id = zo.zoneFk
+ JOIN vn.zoneWarehouse zw ON zw.zoneFk = zo.zoneFk
+ JOIN vn.`zone` z ON z.id = zo.zoneFk
+ LEFT JOIN tmp.closedZones cz
+ ON cz.warehouseFk = zw.warehouseFk
+ AND cz.zoneFk = zw.zoneFk
+ AND zo.shipped = vn.VN_CURDATE()
WHERE z.agencyModeFk = vAgencyModeFk
- ORDER BY shipped) t
+ AND (ISNULL(cz.zoneFk) OR vShowExpiredZones)
+ ORDER BY shipped) t
GROUP BY warehouseFk;
-
+
DROP TEMPORARY TABLE
- tmp.zone,
- tmp.zoneOption;
+ tmp.`zone`,
+ tmp.zoneOption,
+ tmp.closedZones;
+END ;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
+/*!50003 DROP PROCEDURE IF EXISTS `zone_getState` */;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+DELIMITER ;;
+CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getState`(vDated DATE)
+BEGIN
+/**
+ * Devuelve las zonas y el estado para la fecha solicitada
+ *
+ * @param vDated Fecha en cuestión
+ */
+ DROP TEMPORARY TABLE IF EXISTS tmp.zone;
+
+ CREATE TEMPORARY TABLE tmp.zone (
+ id INT PRIMARY KEY)
+ ENGINE=MEMORY;
+
+ INSERT INTO tmp.zone(id)
+ SELECT id
+ FROM vn.zone;
+
+ CALL vn.zone_getOptionsForShipment(vDated, TRUE);
+
+ CALL vn.zone_getClosed();
+
+ SELECT zo.zoneFk,
+ zo.`hour`etd,
+ (zo.`hour` <= TIME(now())) isLate,
+ !ISNULL(cz.zoneFk) isFull,
+ zw.warehouseFk,
+ zo.landed
+ FROM tmp.zoneOption zo
+ JOIN vn.zone z ON z.id = zo.zoneFk
+ JOIN vn.zoneWarehouse zw ON zw.zoneFk = z.id
+ LEFT JOIN tmp.closedZones cz
+ ON cz.warehouseFk = zw.warehouseFk
+ AND cz.zoneFk = zo.zoneFk;
+
+ DROP TEMPORARY TABLE
+ tmp.closedZones,
+ tmp.zoneOption,
+ tmp.zone;
+
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -95560,6 +95022,25 @@ USE `vn`;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
+--
+-- Final view structure for view `agencyTerm`
+--
+
+/*!50001 DROP TABLE IF EXISTS `agencyTerm`*/;
+/*!50001 DROP VIEW IF EXISTS `agencyTerm`*/;
+/*!50001 SET @saved_cs_client = @@character_set_client */;
+/*!50001 SET @saved_cs_results = @@character_set_results */;
+/*!50001 SET @saved_col_connection = @@collation_connection */;
+/*!50001 SET character_set_client = utf8 */;
+/*!50001 SET character_set_results = utf8 */;
+/*!50001 SET collation_connection = utf8_general_ci */;
+/*!50001 CREATE ALGORITHM=UNDEFINED */
+/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
+/*!50001 VIEW `agencyTerm` AS select `sat`.`agencyFk` AS `agencyFk`,`sat`.`minimumPackages` AS `minimumPackages`,`sat`.`kmPrice` AS `kmPrice`,`sat`.`packagePrice` AS `packagePrice`,`sat`.`routePrice` AS `routePrice`,`sat`.`minimumKm` AS `minimumKm`,`sat`.`minimumM3` AS `minimumM3`,`sat`.`m3Price` AS `m3Price` from `supplierAgencyTerm` `sat` */;
+/*!50001 SET character_set_client = @saved_cs_client */;
+/*!50001 SET character_set_results = @saved_cs_results */;
+/*!50001 SET collation_connection = @saved_col_connection */;
+
--
-- Final view structure for view `annualAverageInvoiced`
--
@@ -96543,26 +96024,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `itemShelvingPlacementSupplyStock` AS select `ish`.`id` AS `itemShelvingFk`,`ish`.`itemFk` AS `itemFk`,`ish`.`quantity` AS `quantity`,`ish`.`packing` AS `packing`,`ish`.`visible` AS `stock`,`i`.`longName` AS `longName`,`i`.`size` AS `size`,`i`.`subName` AS `subName`,`sh`.`code` AS `shelving`,`p`.`code` AS `parking`,`ish`.`created` AS `created`,ifnull(`sh`.`priority`,1) AS `priority`,`p`.`id` AS `parkingFk`,`p`.`sectorFk` AS `sectorFk` from (((`itemShelving` `ish` join `shelving` `sh` on(`sh`.`code` = `ish`.`shelvingFk`)) left join `parking` `p` on(`p`.`id` = `sh`.`parkingFk`)) join `item` `i` on(`i`.`id` = `ish`.`itemFk`)) group by `ish`.`id` */;
-/*!50001 SET character_set_client = @saved_cs_client */;
-/*!50001 SET character_set_results = @saved_cs_results */;
-/*!50001 SET collation_connection = @saved_col_connection */;
-
---
--- Final view structure for view `itemShelvingPlacementSupplyStock__`
---
-
-/*!50001 DROP TABLE IF EXISTS `itemShelvingPlacementSupplyStock__`*/;
-/*!50001 DROP VIEW IF EXISTS `itemShelvingPlacementSupplyStock__`*/;
-/*!50001 SET @saved_cs_client = @@character_set_client */;
-/*!50001 SET @saved_cs_results = @@character_set_results */;
-/*!50001 SET @saved_col_connection = @@collation_connection */;
-/*!50001 SET character_set_client = utf8mb4 */;
-/*!50001 SET character_set_results = utf8mb4 */;
-/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
-/*!50001 CREATE ALGORITHM=UNDEFINED */
-/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `itemShelvingPlacementSupplyStock__` AS select `ish`.`id` AS `itemShelvingFk`,`ish`.`itemFk` AS `itemFk`,`ish`.`quantity` AS `quantity`,`ish`.`packing` AS `packing`,`ish`.`visible` AS `stock`,`i`.`longName` AS `longName`,`i`.`size` AS `size`,`i`.`subName` AS `subName`,`sh`.`code` AS `shelving`,`p`.`code` AS `parking`,`ish`.`created` AS `created`,ifnull(`sh`.`priority`,1) AS `priority` from (((((`itemShelving` `ish` join `shelving` `sh` on(`sh`.`code` = `ish`.`shelvingFk`)) left join `parking` `p` on(`p`.`id` = `sh`.`parkingFk`)) join `item` `i` on(`i`.`id` = `ish`.`itemFk`)) left join `itemShelvingSale` `iss` on(`iss`.`itemShelvingFk` = `ish`.`id`)) left join `itemShelvingPlacementSupply` `isps` on(`isps`.`itemShelvingFk` = `ish`.`id`)) group by `ish`.`id` */;
+/*!50001 VIEW `itemShelvingPlacementSupplyStock` AS select `ish`.`id` AS `itemShelvingFk`,`ish`.`itemFk` AS `itemFk`,`ish`.`packing` AS `packing`,`ish`.`visible` AS `stock`,`i`.`longName` AS `longName`,`i`.`size` AS `size`,`i`.`subName` AS `subName`,`sh`.`code` AS `shelving`,`p`.`code` AS `parking`,`ish`.`created` AS `created`,ifnull(`sh`.`priority`,1) AS `priority`,`p`.`id` AS `parkingFk`,`p`.`sectorFk` AS `sectorFk` from (((`itemShelving` `ish` join `shelving` `sh` on((`sh`.`code` = `ish`.`shelvingFk`))) left join `parking` `p` on((`p`.`id` = `sh`.`parkingFk`))) join `item` `i` on((`i`.`id` = `ish`.`itemFk`))) group by `ish`.`id` */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -96929,11 +96391,30 @@ USE `vn`;
/*!50001 SET collation_connection = @saved_col_connection */;
--
--- Final view structure for view `packingSite`
+-- Final view structure for view `payDemDetail__`
--
-/*!50001 DROP TABLE IF EXISTS `packingSite`*/;
-/*!50001 DROP VIEW IF EXISTS `packingSite`*/;
+/*!50001 DROP TABLE IF EXISTS `payDemDetail__`*/;
+/*!50001 DROP VIEW IF EXISTS `payDemDetail__`*/;
+/*!50001 SET @saved_cs_client = @@character_set_client */;
+/*!50001 SET @saved_cs_results = @@character_set_results */;
+/*!50001 SET @saved_col_connection = @@collation_connection */;
+/*!50001 SET character_set_client = utf8mb4 */;
+/*!50001 SET character_set_results = utf8mb4 */;
+/*!50001 SET collation_connection = utf8mb4_general_ci */;
+/*!50001 CREATE ALGORITHM=UNDEFINED */
+/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
+/*!50001 VIEW `payDemDetail__` AS select `pdd`.`id` AS `id`,`pdd`.`detalle` AS `detail` from `vn2008`.`pay_dem_det` `pdd` */;
+/*!50001 SET character_set_client = @saved_cs_client */;
+/*!50001 SET character_set_results = @saved_cs_results */;
+/*!50001 SET collation_connection = @saved_col_connection */;
+
+--
+-- Final view structure for view `payment__`
+--
+
+/*!50001 DROP TABLE IF EXISTS `payment__`*/;
+/*!50001 DROP VIEW IF EXISTS `payment__`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
/*!50001 SET @saved_col_connection = @@collation_connection */;
@@ -96942,7 +96423,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `packingSite` AS select `h`.`code` AS `hostFk`,`h`.`printerFk` AS `printerFk`,concat(`h`.`itemPackingTypeFk`,`h`.`packingSite`) AS `code` from `host` `h` where `h`.`itemPackingTypeFk` is not null order by `h`.`itemPackingTypeFk`,`h`.`packingSite` */;
+/*!50001 VIEW `payment__` AS select `p`.`id` AS `id`,`p`.`fecha` AS `received`,`p`.`dueDated` AS `dueDated`,`p`.`id_proveedor` AS `supplierFk`,`p`.`importe` AS `amount`,`p`.`id_moneda` AS `currencyFk`,`p`.`divisa` AS `divisa`,`p`.`id_banco` AS `bankFk`,`p`.`pay_met_id` AS `payMethodFk`,`p`.`empresa_id` AS `companyFk`,`p`.`pago_sdc_id` AS `exchangeInsuranceFk`,`p`.`conciliado` AS `isConciliated` from `vn2008`.`pago` `p` */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -97379,7 +96860,45 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `ticketLastUpdatedList` AS select `s`.`ticketFk` AS `ticketFk`,`st`.`created` AS `created` from (`vn`.`saleTracking` `st` join `vn`.`sale` `s` on(`s`.`id` = `st`.`saleFk`)) where `st`.`created` > vn.VN_CURDATE() union all select `i`.`Id_Ticket` AS `Id_Ticket`,`i`.`odbc_date` AS `odbc_date` from `vncontrol`.`inter` `i` where `i`.`odbc_date` > vn.VN_CURDATE() union all select `s`.`ticketFk` AS `ticketFk`,`iss`.`created` AS `created` from (`vn`.`itemShelvingSale` `iss` join `vn`.`sale` `s` on(`s`.`id` = `iss`.`saleFk`)) where `iss`.`created` > vn.VN_CURDATE() */;
+/*!50001 VIEW `ticketLastUpdatedList` AS select `s`.`ticketFk` AS `ticketFk`,`st`.`created` AS `created` from (`vn`.`saleTracking` `st` join `vn`.`sale` `s` on((`s`.`id` = `st`.`saleFk`))) where (`st`.`created` > curdate()) union all select `i`.`Id_Ticket` AS `Id_Ticket`,`i`.`odbc_date` AS `odbc_date` from `vncontrol`.`inter` `i` where (`i`.`odbc_date` > curdate()) union all select `s`.`ticketFk` AS `ticketFk`,`iss`.`created` AS `created` from (`vn`.`itemShelvingSale` `iss` join `vn`.`sale` `s` on((`s`.`id` = `iss`.`saleFk`))) where (`iss`.`created` > curdate()) */;
+/*!50001 SET character_set_client = @saved_cs_client */;
+/*!50001 SET character_set_results = @saved_cs_results */;
+/*!50001 SET collation_connection = @saved_col_connection */;
+
+--
+-- Final view structure for view `ticketLocation`
+--
+
+/*!50001 DROP TABLE IF EXISTS `ticketLocation`*/;
+/*!50001 DROP VIEW IF EXISTS `ticketLocation`*/;
+/*!50001 SET @saved_cs_client = @@character_set_client */;
+/*!50001 SET @saved_cs_results = @@character_set_results */;
+/*!50001 SET @saved_col_connection = @@collation_connection */;
+/*!50001 SET character_set_client = utf8mb4 */;
+/*!50001 SET character_set_results = utf8mb4 */;
+/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
+/*!50001 CREATE ALGORITHM=UNDEFINED */
+/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
+/*!50001 VIEW `ticketLocation` AS select `tl`.`Id_Ticket` AS `ticketFk`,`tl`.`longitude` AS `longitude`,`tl`.`latitude` AS `latitude` from `vn2008`.`ticket_location` `tl` */;
+/*!50001 SET character_set_client = @saved_cs_client */;
+/*!50001 SET character_set_results = @saved_cs_results */;
+/*!50001 SET collation_connection = @saved_col_connection */;
+
+--
+-- Final view structure for view `ticketMRW`
+--
+
+/*!50001 DROP TABLE IF EXISTS `ticketMRW`*/;
+/*!50001 DROP VIEW IF EXISTS `ticketMRW`*/;
+/*!50001 SET @saved_cs_client = @@character_set_client */;
+/*!50001 SET @saved_cs_results = @@character_set_results */;
+/*!50001 SET @saved_col_connection = @@collation_connection */;
+/*!50001 SET character_set_client = utf8mb4 */;
+/*!50001 SET character_set_results = utf8mb4 */;
+/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
+/*!50001 CREATE ALGORITHM=UNDEFINED */
+/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
+/*!50001 VIEW `ticketMRW` AS select `Tickets`.`Id_Agencia` AS `id_Agencia`,`Tickets`.`empresa_id` AS `empresa_id`,`Consignatarios`.`consignatario` AS `Consignatario`,`Consignatarios`.`domicilio` AS `DOMICILIO`,`Consignatarios`.`poblacion` AS `POBLACION`,`Consignatarios`.`codPostal` AS `CODPOSTAL`,`Consignatarios`.`telefono` AS `telefono`,ifnull(ifnull(ifnull(ifnull(`Consignatarios`.`movil`,`Clientes`.`movil`),`Consignatarios`.`telefono`),`Clientes`.`telefono`),0) AS `movil`,`Clientes`.`if` AS `IF`,`Tickets`.`Id_Ticket` AS `Id_Ticket`,`Tickets`.`warehouse_id` AS `warehouse_id`,`Consignatarios`.`id_consigna` AS `Id_Consigna`,`Paises`.`Codigo` AS `CodigoPais`,`Tickets`.`Fecha` AS `Fecha`,`province`.`province_id` AS `province_id`,`Tickets`.`landing` AS `landing` from ((((`vn2008`.`Clientes` join `vn2008`.`Consignatarios` on((`Clientes`.`id_cliente` = `Consignatarios`.`Id_cliente`))) join `vn2008`.`Tickets` on((`Consignatarios`.`id_consigna` = `Tickets`.`Id_Consigna`))) join `vn2008`.`province` on((`Consignatarios`.`province_id` = `province`.`province_id`))) join `vn2008`.`Paises` on((`province`.`Paises_Id` = `Paises`.`Id`))) */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -97931,4 +97450,4 @@ USE `vncontrol`;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
--- Dump completed on 2022-03-31 15:08:35
+-- Dump completed on 2022-05-04 15:56:23
diff --git a/db/export-data.sh b/db/export-data.sh
index 135047f04..900e630f7 100755
--- a/db/export-data.sh
+++ b/db/export-data.sh
@@ -14,6 +14,8 @@ echo "" > "$DUMPED_FILE"
TABLES=(
util
config
+ version
+ versionLog
)
dump_tables ${TABLES[@]}
@@ -74,10 +76,20 @@ dump_tables ${TABLES[@]}
TABLES=(
hedera
+ browser
imageCollection
+ imageCollectionSize
+ language
+ link
+ location
+ menu
+ message
+ metatag
+ newsTag
+ restPriv
+ social
tpvError
tpvResponse
- imageCollectionSize
)
dump_tables ${TABLES[@]}
diff --git a/db/export-structure.sh b/db/export-structure.sh
index 7a3780067..1ecbcb3f0 100755
--- a/db/export-structure.sh
+++ b/db/export-structure.sh
@@ -49,6 +49,7 @@ IGNORETABLES=(
--ignore-table=vn.grantGroup
--ignore-table=vn.invoiceCorrection__
--ignore-table=vn.itemTaxCountrySpain
+ --ignore-table=vn.itemShelvingPlacementSupplyStock__
--ignore-table=vn.itemFreeNumber__
--ignore-table=vn.mail__
--ignore-table=vn.manaSpellers
@@ -59,7 +60,6 @@ IGNORETABLES=(
--ignore-table=vn.plantpassportAuthority__
--ignore-table=vn.preparationException
--ignore-table=vn.priceFixed__
- --ignore-table=vn.printer
--ignore-table=vn.printingQueue
--ignore-table=vn.printServerQueue__
--ignore-table=vn.promissoryNote
diff --git a/docker-compose.yml b/docker-compose.yml
index 1d80a4b62..4fc5dc811 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -32,6 +32,7 @@ services:
- /mnt/appdata/pdfs:/var/lib/salix/pdfs
- /mnt/appdata/dms:/var/lib/salix/dms
- /mnt/appdata/image:/var/lib/salix/image
+ - /mnt/appdata/vn-access:/var/lib/salix/vn-access
deploy:
replicas: ${BACK_REPLICAS:?}
placement:
diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js
index 799eb8fe7..770911d0e 100644
--- a/e2e/helpers/selectors.js
+++ b/e2e/helpers/selectors.js
@@ -101,6 +101,47 @@ export default {
email: 'vn-user-mail-forwarding vn-textfield[ng-model="data.forwardTo"]',
save: 'vn-user-mail-forwarding vn-submit'
},
+ accountAcl: {
+ addAcl: 'vn-acl-index button vn-icon[icon="add"]',
+ thirdAcl: 'vn-acl-index vn-list> a:nth-child(3)',
+ deleteThirdAcl: 'vn-acl-index vn-list > a:nth-child(3) > vn-item-section > vn-icon-button[icon="delete"]',
+ role: 'vn-acl-create vn-autocomplete[ng-model="$ctrl.acl.principalId"]',
+ model: 'vn-acl-create vn-autocomplete[ng-model="$ctrl.acl.model"]',
+ property: 'vn-acl-create vn-autocomplete[ng-model="$ctrl.acl.property"]',
+ accessType: 'vn-acl-create vn-autocomplete[ng-model="$ctrl.acl.accessType"]',
+ permission: 'vn-acl-create vn-autocomplete[ng-model="$ctrl.acl.permission"]',
+ save: 'vn-acl-create vn-submit'
+ },
+ accountConnections: {
+ firstConnection: 'vn-connections vn-list > a:nth-child(1)',
+ deleteFirstConnection: 'vn-connections vn-list > a:nth-child(1) > vn-item-section > vn-icon-button[icon="exit_to_app"]'
+ },
+ accountAccounts: {
+ syncRoles: 'vn-account-accounts vn-button[label="Synchronize roles"]',
+ syncUser: 'vn-account-accounts vn-button[label="Synchronize user"]',
+ syncAll: 'vn-account-accounts vn-button[label="Synchronize all"]',
+ syncUserName: 'vn-textfield[ng-model="$ctrl.syncUser"]',
+ syncUserPassword: 'vn-textfield[ng-model="$ctrl.syncPassword"]',
+ buttonAccept: 'button[response="accept"]'
+ },
+ accountLdap: {
+ checkEnable: 'vn-account-ldap vn-check[ng-model="watcher.hasData"]',
+ server: 'vn-account-ldap vn-textfield[ng-model="$ctrl.config.server"]',
+ rdn: 'vn-account-ldap vn-textfield[ng-model="$ctrl.config.rdn"]',
+ password: 'vn-account-ldap vn-textfield[ng-model="$ctrl.config.password"]',
+ userDn: 'vn-account-ldap vn-textfield[ng-model="$ctrl.config.userDn"]',
+ groupDn: 'vn-account-ldap vn-textfield[ng-model="$ctrl.config.groupDn"]',
+ save: 'vn-account-ldap vn-submit'
+ },
+ accountSamba: {
+ checkEnable: 'vn-account-samba vn-check[ng-model="watcher.hasData"]',
+ adDomain: 'vn-account-samba vn-textfield[ng-model="$ctrl.config.adDomain"]',
+ adController: 'vn-account-samba vn-textfield[ng-model="$ctrl.config.adController"]',
+ adUser: 'vn-account-samba vn-textfield[ng-model="$ctrl.config.adUser"]',
+ adPassword: 'vn-account-samba vn-textfield[ng-model="$ctrl.config.adPassword"]',
+ verifyCert: 'vn-account-samba vn-check[ng-model="$ctrl.config.verifyCert"]',
+ save: 'vn-account-samba vn-submit'
+ },
clientsIndex: {
createClientButton: `vn-float-button`
},
@@ -731,7 +772,7 @@ export default {
claimAction: {
importClaimButton: 'vn-claim-action vn-button[label="Import claim"]',
anyLine: 'vn-claim-action vn-tbody > vn-tr',
- firstDeleteLine: 'vn-claim-action vn-tr:nth-child(1) vn-icon-button[icon="delete"]',
+ firstDeleteLine: 'vn-claim-action tr:nth-child(1) vn-icon-button[icon="delete"]',
isPaidWithManaCheckbox: 'vn-claim-action vn-check[ng-model="$ctrl.claim.isChargedToMana"]'
},
ordersIndex: {
@@ -982,8 +1023,8 @@ export default {
save: 'vn-invoice-in-basic-data button[type=submit]'
},
invoiceInTax: {
- addTaxButton: 'vn-invoice-in-tax vn-icon-button[icon="add_circle"]',
- thirdExpence: 'vn-invoice-in-tax vn-horizontal:nth-child(3) > vn-autocomplete[ng-model="invoiceInTax.expenseFk"]',
+ addTaxButton: 'vn-invoice-in-tax vn-icon-button[vn-tooltip="Add tax"]',
+ thirdExpense: 'vn-invoice-in-tax vn-horizontal:nth-child(3) > vn-autocomplete[ng-model="invoiceInTax.expenseFk"]',
thirdTaxableBase: 'vn-invoice-in-tax vn-horizontal:nth-child(3) > vn-input-number[ng-model="invoiceInTax.taxableBase"]',
thirdTaxType: 'vn-invoice-in-tax vn-horizontal:nth-child(3) > vn-autocomplete[ng-model="invoiceInTax.taxTypeSageFk"]',
thirdTransactionType: 'vn-invoice-in-tax vn-horizontal:nth-child(3) > vn-autocomplete[ng-model="invoiceInTax.transactionTypeSageFk"]',
@@ -1133,7 +1174,7 @@ export default {
entryLatestBuys: {
firstBuy: 'vn-entry-latest-buys tbody > tr:nth-child(1)',
allBuysCheckBox: 'vn-entry-latest-buys thead vn-check',
- secondBuyCheckBox: 'vn-entry-latest-buys tbody tr:nth-child(2) vn-check[ng-model="buy.$checked"]',
+ secondBuyCheckBox: 'vn-entry-latest-buys tbody tr:nth-child(2) vn-check[ng-model="buy.checked"]',
editBuysButton: 'vn-entry-latest-buys vn-button[icon="edit"]',
fieldAutocomplete: 'vn-autocomplete[ng-model="$ctrl.editedColumn.field"]',
newValueInput: 'vn-textfield[ng-model="$ctrl.editedColumn.newValue"]',
diff --git a/e2e/helpers/tests.js b/e2e/helpers/tests.js
new file mode 100644
index 000000000..aac9963dd
--- /dev/null
+++ b/e2e/helpers/tests.js
@@ -0,0 +1,87 @@
+require('@babel/register')({presets: ['@babel/env']});
+require('core-js/stable');
+require('regenerator-runtime/runtime');
+
+const axios = require('axios');
+const Docker = require('../../db/docker.js');
+const e2eConfig = require('./config.js');
+const log = require('fancy-log');
+
+process.on('warning', warning => {
+ console.log(warning.name);
+ console.log(warning.message);
+ console.log(warning.stack);
+});
+
+async function test() {
+ if (process.argv[2] === 'show')
+ process.env.E2E_SHOW = true;
+
+ const container = new Docker('salix-db');
+
+ await container.run();
+
+ const Jasmine = require('jasmine');
+ const jasmine = new Jasmine();
+
+ const specFiles = [
+ `./e2e/paths/01*/*[sS]pec.js`,
+ `./e2e/paths/02*/*[sS]pec.js`,
+ `./e2e/paths/03*/*[sS]pec.js`,
+ `./e2e/paths/04*/*[sS]pec.js`,
+ `./e2e/paths/05*/*[sS]pec.js`,
+ `./e2e/paths/06*/*[sS]pec.js`,
+ `./e2e/paths/07*/*[sS]pec.js`,
+ `./e2e/paths/08*/*[sS]pec.js`,
+ `./e2e/paths/09*/*[sS]pec.js`,
+ `./e2e/paths/10*/*[sS]pec.js`,
+ `./e2e/paths/11*/*[sS]pec.js`,
+ `./e2e/paths/12*/*[sS]pec.js`,
+ `./e2e/paths/13*/*[sS]pec.js`,
+ `./e2e/paths/**/*[sS]pec.js`
+ ];
+
+ jasmine.loadConfig({
+ spec_dir: '.',
+ spec_files: specFiles,
+ helpers: [],
+ random: false,
+ });
+
+ await backendStatus();
+
+ jasmine.jasmine.DEFAULT_TIMEOUT_INTERVAL = 30000;
+ await jasmine.execute();
+}
+
+async function backendStatus() {
+ log('Awaiting backend connection...');
+
+ const milliseconds = 1000;
+ const maxAttempts = 10;
+
+ return new Promise(resolve => {
+ let timer;
+ let attempts = 1;
+ timer = setInterval(async() => {
+ try {
+ attempts++;
+ const url = `${e2eConfig.url}/api/Applications/status`;
+ const {data} = await axios.get(url);
+
+ if (data == true) {
+ clearInterval(timer);
+ log('Backend connection stablished!');
+ resolve(attempts);
+ }
+ } catch (error) {
+ if (error && attempts >= maxAttempts) {
+ log('Could not connect to backend');
+ process.exit();
+ }
+ }
+ }, milliseconds);
+ });
+}
+
+test();
diff --git a/e2e/paths/02-client/12_lock_of_verified_data.spec.js b/e2e/paths/02-client/12_lock_of_verified_data.spec.js
index 701531c76..139af0cea 100644
--- a/e2e/paths/02-client/12_lock_of_verified_data.spec.js
+++ b/e2e/paths/02-client/12_lock_of_verified_data.spec.js
@@ -111,7 +111,7 @@ describe('Client lock verified data path', () => {
await page.waitToClick(selectors.clientFiscalData.saveButton);
const message = await page.waitForSnackbar();
- expect(message.text).toContain(`You can't make changes on a client with verified data`);
+ expect(message.text).toContain(`Not enough privileges to edit a client with verified data`);
});
});
@@ -135,7 +135,7 @@ describe('Client lock verified data path', () => {
await page.waitToClick(selectors.clientFiscalData.saveButton);
const message = await page.waitForSnackbar();
- expect(message.text).toContain('Data saved!');
+ expect(message.text).toContain(`Data saved!`);
});
it('should now confirm the social name have been edited once and for all', async() => {
diff --git a/e2e/paths/09-invoice-in/04_tax.spec.js b/e2e/paths/09-invoice-in/04_tax.spec.js
index 364a25d7e..b1dbe2008 100644
--- a/e2e/paths/09-invoice-in/04_tax.spec.js
+++ b/e2e/paths/09-invoice-in/04_tax.spec.js
@@ -19,7 +19,7 @@ describe('InvoiceIn tax path', () => {
it('should add a new tax', async() => {
await page.waitToClick(selectors.invoiceInTax.addTaxButton);
- await page.autocompleteSearch(selectors.invoiceInTax.thirdExpence, '6210000567');
+ await page.autocompleteSearch(selectors.invoiceInTax.thirdExpense, '6210000567');
await page.write(selectors.invoiceInTax.thirdTaxableBase, '100');
await page.autocompleteSearch(selectors.invoiceInTax.thirdTaxType, '6');
await page.autocompleteSearch(selectors.invoiceInTax.thirdTransactionType, 'Operaciones exentas');
@@ -37,9 +37,9 @@ describe('InvoiceIn tax path', () => {
expect(result).toEqual('Taxable base €1,323.16');
});
- it('should navigate back to the tax section and check the reciently added line contains the expected expense', async() => {
+ it('should navigate back to tax section, check the reciently added line contains the expected expense', async() => {
await page.accessToSection('invoiceIn.card.tax');
- const result = await page.waitToGetProperty(selectors.invoiceInTax.thirdExpence, 'value');
+ const result = await page.waitToGetProperty(selectors.invoiceInTax.thirdExpense, 'value');
expect(result).toEqual('6210000567: Alquiler VNH');
});
diff --git a/e2e/paths/14-account/04_acl.spec.js b/e2e/paths/14-account/04_acl.spec.js
new file mode 100644
index 000000000..c400dbfb2
--- /dev/null
+++ b/e2e/paths/14-account/04_acl.spec.js
@@ -0,0 +1,60 @@
+import selectors from '../../helpers/selectors.js';
+import getBrowser from '../../helpers/puppeteer';
+
+describe('Account ACL path', () => {
+ let browser;
+ let page;
+
+ beforeAll(async() => {
+ browser = await getBrowser();
+ page = browser.page;
+ await page.loginAndModule('developer', 'account');
+ await page.accessToSection('account.acl');
+ });
+
+ afterAll(async() => {
+ await browser.close();
+ });
+
+ it('should go to create new acl', async() => {
+ await page.waitToClick(selectors.accountAcl.addAcl);
+ await page.waitForState('account.acl.create');
+ });
+
+ it('should create new acl', async() => {
+ await page.autocompleteSearch(selectors.accountAcl.role, 'sysadmin');
+ await page.autocompleteSearch(selectors.accountAcl.model, 'UserAccount');
+ await page.autocompleteSearch(selectors.accountAcl.accessType, '*');
+ await page.autocompleteSearch(selectors.accountAcl.permission, 'ALLOW');
+ await page.waitToClick(selectors.accountAcl.save);
+ const message = await page.waitForSnackbar();
+
+ expect(message.text).toContain('Data saved!');
+ });
+
+ it('should navigate to edit', async() => {
+ await page.doSearch();
+ await page.waitToClick(selectors.accountAcl.thirdAcl);
+ await page.waitForState('account.acl.edit');
+ });
+
+ it('should edit the third acl', async() => {
+ await page.autocompleteSearch(selectors.accountAcl.model, 'Supplier');
+ await page.autocompleteSearch(selectors.accountAcl.accessType, 'READ');
+ await page.waitToClick(selectors.accountAcl.save);
+ const message = await page.waitForSnackbar();
+
+ expect(message.text).toContain('Data saved!');
+ });
+
+ it('should delete the third result', async() => {
+ const result = await page.waitToGetProperty(selectors.accountAcl.thirdAcl, 'innerText');
+ await page.waitToClick(selectors.accountAcl.deleteThirdAcl);
+ await page.waitToClick(selectors.globalItems.acceptButton);
+ const message = await page.waitForSnackbar();
+ const newResult = await page.waitToGetProperty(selectors.accountAcl.thirdAcl, 'innerText');
+
+ expect(message.text).toContain('ACL removed');
+ expect(result).not.toEqual(newResult);
+ });
+});
diff --git a/e2e/paths/14-account/05_connections.spec.js b/e2e/paths/14-account/05_connections.spec.js
new file mode 100644
index 000000000..89b286101
--- /dev/null
+++ b/e2e/paths/14-account/05_connections.spec.js
@@ -0,0 +1,33 @@
+import selectors from '../../helpers/selectors.js';
+import getBrowser from '../../helpers/puppeteer';
+
+describe('Account Connections path', () => {
+ let browser;
+ let page;
+ const account = 'sysadmin';
+
+ beforeAll(async() => {
+ browser = await getBrowser();
+ page = browser.page;
+ await page.loginAndModule(account, 'account');
+ await page.accessToSection('account.connections');
+ });
+
+ afterAll(async() => {
+ await browser.close();
+ });
+
+ it('should check this is the last connection', async() => {
+ const firstResult = await page.waitToGetProperty(selectors.accountConnections.firstConnection, 'innerText');
+
+ expect(firstResult).toContain(account);
+ });
+
+ it('should kill this connection and then get redirected to the login page', async() => {
+ await page.waitToClick(selectors.accountConnections.deleteFirstConnection);
+ await page.waitToClick(selectors.globalItems.acceptButton);
+ const message = await page.waitForSnackbar();
+
+ expect(message.text).toContain('Your session has expired, please login again');
+ });
+});
diff --git a/e2e/paths/14-account/06_accounts.spec.js b/e2e/paths/14-account/06_accounts.spec.js
new file mode 100644
index 000000000..83893e0cf
--- /dev/null
+++ b/e2e/paths/14-account/06_accounts.spec.js
@@ -0,0 +1,49 @@
+import selectors from '../../helpers/selectors.js';
+import getBrowser from '../../helpers/puppeteer';
+
+describe('Account Accounts path', () => {
+ let browser;
+ let page;
+
+ beforeAll(async() => {
+ browser = await getBrowser();
+ page = browser.page;
+ await page.loginAndModule('sysadmin', 'account');
+ await page.accessToSection('account.accounts');
+ });
+
+ afterAll(async() => {
+ await browser.close();
+ });
+
+ it('should sync roles', async() => {
+ await page.waitToClick(selectors.accountAccounts.syncRoles);
+ const message = await page.waitForSnackbar();
+
+ expect(message.text).toContain('Roles synchronized!');
+ });
+
+ it('should sync user', async() => {
+ await page.waitToClick(selectors.accountAccounts.syncUser);
+ await page.write(selectors.accountAccounts.syncUserName, 'sysadmin');
+ await page.write(selectors.accountAccounts.syncUserPassword, 'nightmare');
+
+ await page.waitToClick(selectors.accountAccounts.buttonAccept);
+
+ const message = await page.waitForSnackbar();
+
+ expect(message.text).toContain('User synchronized!');
+ });
+
+ it('should relogin', async() => {
+ await page.loginAndModule('sysadmin', 'account');
+ await page.accessToSection('account.accounts');
+ });
+
+ it('should sync all', async() => {
+ await page.waitToClick(selectors.accountAccounts.syncAll);
+ const message = await page.waitForSnackbar();
+
+ expect(message.text).toContain('Synchronizing in the background');
+ });
+});
diff --git a/e2e/paths/14-account/07_ldap.spec.js b/e2e/paths/14-account/07_ldap.spec.js
new file mode 100644
index 000000000..a3b8137d3
--- /dev/null
+++ b/e2e/paths/14-account/07_ldap.spec.js
@@ -0,0 +1,32 @@
+import selectors from '../../helpers/selectors.js';
+import getBrowser from '../../helpers/puppeteer';
+
+describe('Account LDAP path', () => {
+ let browser;
+ let page;
+
+ beforeAll(async() => {
+ browser = await getBrowser();
+ page = browser.page;
+ await page.loginAndModule('sysadmin', 'account');
+ await page.accessToSection('account.ldap');
+ });
+
+ afterAll(async() => {
+ await browser.close();
+ });
+
+ it('should set data and save', async() => {
+ await page.waitToClick(selectors.accountLdap.checkEnable);
+ await page.write(selectors.accountLdap.server, '1234');
+ await page.write(selectors.accountLdap.rdn, '1234');
+ await page.write(selectors.accountLdap.password, 'nightmare');
+ await page.write(selectors.accountLdap.userDn, 'sysadmin');
+ await page.write(selectors.accountLdap.groupDn, '1234');
+ await page.waitToClick(selectors.accountLdap.save);
+
+ const message = await page.waitForSnackbar();
+
+ expect(message.text).toContain('Data saved!');
+ });
+});
diff --git a/e2e/paths/14-account/08_samba.spec.js b/e2e/paths/14-account/08_samba.spec.js
new file mode 100644
index 000000000..c3db026dc
--- /dev/null
+++ b/e2e/paths/14-account/08_samba.spec.js
@@ -0,0 +1,32 @@
+import selectors from '../../helpers/selectors.js';
+import getBrowser from '../../helpers/puppeteer';
+
+describe('Account Samba path', () => {
+ let browser;
+ let page;
+
+ beforeAll(async() => {
+ browser = await getBrowser();
+ page = browser.page;
+ await page.loginAndModule('sysadmin', 'account');
+ await page.accessToSection('account.samba');
+ });
+
+ afterAll(async() => {
+ await browser.close();
+ });
+
+ it('should set data and save', async() => {
+ await page.waitToClick(selectors.accountSamba.checkEnable);
+ await page.write(selectors.accountSamba.adDomain, '1234');
+ await page.write(selectors.accountSamba.adController, '1234');
+ await page.write(selectors.accountSamba.adUser, 'nightmare');
+ await page.write(selectors.accountSamba.adPassword, 'sysadmin');
+ await page.waitToClick(selectors.accountSamba.verifyCert);
+ await page.waitToClick(selectors.accountSamba.save);
+
+ const message = await page.waitForSnackbar();
+
+ expect(message.text).toContain('Data saved!');
+ });
+});
diff --git a/front/core/components/multi-check/locale/en.yml b/front/core/components/multi-check/locale/en.yml
new file mode 100644
index 000000000..ea52dcf8f
--- /dev/null
+++ b/front/core/components/multi-check/locale/en.yml
@@ -0,0 +1 @@
+SelectAllRows: Select the {{rows}} row(s)
\ No newline at end of file
diff --git a/front/core/components/multi-check/locale/es.yml b/front/core/components/multi-check/locale/es.yml
new file mode 100644
index 000000000..5365c3392
--- /dev/null
+++ b/front/core/components/multi-check/locale/es.yml
@@ -0,0 +1,3 @@
+SelectAllRows: Seleccionar las {{rows}} fila(s)
+All: Se han seleccionado
+row(s) have been selected.: fila(s).
\ No newline at end of file
diff --git a/front/core/components/multi-check/multi-check.html b/front/core/components/multi-check/multi-check.html
index fb950aaff..fe485e19b 100644
--- a/front/core/components/multi-check/multi-check.html
+++ b/front/core/components/multi-check/multi-check.html
@@ -2,4 +2,25 @@
ng-model="$ctrl.checked"
indeterminate="$ctrl.isIndeterminate"
translate-attr="{title: 'Check all'}">
-
\ No newline at end of file
+
+
+
+
+
+ All
+
+ {{$ctrl.rows}}
+
+ row(s) have been selected.
+
+ {{$ctrl.allRowsText}}
+
+
+
\ No newline at end of file
diff --git a/front/core/components/multi-check/multi-check.js b/front/core/components/multi-check/multi-check.js
index afa1bc3c4..041603f13 100644
--- a/front/core/components/multi-check/multi-check.js
+++ b/front/core/components/multi-check/multi-check.js
@@ -106,6 +106,9 @@ export default class MultiCheck extends FormInput {
this.toggle();
this.emit('change', value);
+
+ if (!value)
+ this.checkedDummyCount = null;
}
/**
@@ -132,12 +135,48 @@ export default class MultiCheck extends FormInput {
areAllUnchecked() {
if (!this.model || !this.model.data) return;
+ this.checkedDummyCount = null;
const data = this.model.data;
return data.every(item => {
return item[this.checkField] === false;
});
}
+ countRows() {
+ if (!this.model || !this.model.data) return;
+
+ const data = this.model.data;
+ const params = {
+ filter: {
+ limit: null
+ }
+ };
+ if (this.model.userFilter)
+ Object.assign(params.filter, this.model.userFilter);
+ if (this.model.userParams)
+ Object.assign(params, this.model.userParams);
+
+ this.rows = data.length;
+ this.$http.get(this.model.url, {params})
+ .then(res => {
+ this.allRowsCount = res.data.length;
+ this.allRowsText = this.$t('SelectAllRows', {
+ rows: this.allRowsCount
+ });
+ });
+ }
+
+ checkDummy() {
+ if (this.checkedDummyCount)
+ return this.checkedDummyCount = null;
+
+ this.checkedDummyCount = this.allRowsCount;
+ }
+
+ isCheckedDummy() {
+ return this.checked && this.checkDummyEnabled;
+ }
+
/**
* Toggles checked property on
* all instances
@@ -158,7 +197,9 @@ ngModule.vnComponent('vnMultiCheck', {
checkField: '@?',
checkAll: '=?',
checked: '=?',
- disabled: ''
+ disabled: '',
+ checkDummyEnabled: '',
+ checkedDummyCount: '=?'
}
});
diff --git a/front/core/components/multi-check/multi-check.spec.js b/front/core/components/multi-check/multi-check.spec.js
index c8069da3c..5cb8cbbef 100644
--- a/front/core/components/multi-check/multi-check.spec.js
+++ b/front/core/components/multi-check/multi-check.spec.js
@@ -4,10 +4,14 @@ import crudModel from 'core/mocks/crud-model';
describe('Component vnMultiCheck', () => {
let controller;
let $element;
+ let $httpBackend;
+ let $httpParamSerializer;
beforeEach(ngModule('vnCore'));
- beforeEach(inject($componentController => {
+ beforeEach(inject(($componentController, _$httpBackend_, _$httpParamSerializer_) => {
+ $httpBackend = _$httpBackend_;
+ $httpParamSerializer = _$httpParamSerializer_;
$element = angular.element(`
`);
controller = $componentController('vnMultiCheck', {$element: $element});
controller._model = crudModel;
@@ -26,6 +30,14 @@ describe('Component vnMultiCheck', () => {
expect(controller._checked).toEqual(crudModel);
expect(controller.toggle).toHaveBeenCalledWith();
});
+
+ it(`should set checkedDummyCount to null`, () => {
+ jest.spyOn(controller, 'toggle');
+ controller.checkedDummyCount = 12;
+ controller.checked = null;
+
+ expect(controller.checkedDummyCount).toBeNull();
+ });
});
describe('toggle()', () => {
@@ -132,4 +144,76 @@ describe('Component vnMultiCheck', () => {
expect(thirdRow.checked).toBeTruthy();
});
});
+
+ describe('countRows()', () => {
+ it(`should count visible rows and all rows of model`, () => {
+ controller.model.url = 'modelUrl/filter';
+ const data = controller.model.data;
+ const filter = {
+ limit: null
+ };
+ const serializedParams = $httpParamSerializer({filter});
+
+ const response = [
+ {id: 1, name: 'My item 1'},
+ {id: 2, name: 'My item 2'},
+ {id: 3, name: 'My item 3'},
+ {id: 4, name: 'My item 4'},
+ {id: 5, name: 'My item 5'},
+ {id: 6, name: 'My item 6'}
+ ];
+
+ controller.countRows();
+ $httpBackend.expectGET(`modelUrl/filter?${serializedParams}`).respond(response);
+ $httpBackend.flush();
+
+ expect(controller.rows).toEqual(data.length);
+ expect(controller.allRowsCount).toEqual(response.length);
+ expect(controller.allRowsCount).toBeGreaterThan(controller.rows);
+ });
+ });
+
+ describe('checkDummy()', () => {
+ const allRows = 1234;
+ it(`should set the checked dummy count to all rows count if there was no count yet`, () => {
+ controller.checkedDummyCount = null;
+ controller.allRowsCount = allRows;
+ controller.checkDummy();
+
+ expect(controller.checkedDummyCount).toEqual(controller.allRowsCount);
+ });
+
+ it(`should remove the dummy count if there was an existing one`, () => {
+ controller.checkedDummyCount = allRows;
+ controller.checkDummy();
+
+ expect(controller.checkedDummyCount).toBeNull();
+ });
+ });
+
+ describe('isCheckedDummy()', () => {
+ it(`should return true only if is checked and checked dummy is enabled`, () => {
+ controller.checked = true;
+ controller.checkDummyEnabled = true;
+ const isCheckedDummy = controller.isCheckedDummy();
+
+ expect(isCheckedDummy).toEqual(true);
+ });
+
+ it(`should return false if not checked`, () => {
+ controller.checked = false;
+ controller.checkDummyEnabled = true;
+ const isCheckedDummy = controller.isCheckedDummy();
+
+ expect(isCheckedDummy).toEqual(false);
+ });
+
+ it(`should return false if checked dummy is disabled`, () => {
+ controller.checked = true;
+ controller.checkDummyEnabled = false;
+ const isCheckedDummy = controller.isCheckedDummy();
+
+ expect(isCheckedDummy).toEqual(false);
+ });
+ });
});
diff --git a/front/core/components/multi-check/style.scss b/front/core/components/multi-check/style.scss
index 79c2397bc..15f462e8f 100644
--- a/front/core/components/multi-check/style.scss
+++ b/front/core/components/multi-check/style.scss
@@ -1,5 +1,10 @@
+@import "variables";
vn-multi-check {
.vn-check {
margin-bottom: 12px
}
+}
+
+.bold{
+ font-weight: bold;
}
\ No newline at end of file
diff --git a/front/core/components/smart-table/index.html b/front/core/components/smart-table/index.html
index c2af9b41e..a3295c47e 100644
--- a/front/core/components/smart-table/index.html
+++ b/front/core/components/smart-table/index.html
@@ -46,11 +46,13 @@
-
-
+
+
+
+
`)(this.$inputsScope);
+
if (options && options.autocomplete) {
let props = ``;
@@ -346,16 +357,29 @@ export default class SmartTable extends Component {
on-change="$ctrl.searchByColumn('${field}')"
clear-disabled="true"
/>`)(this.$inputsScope);
- } else {
+ }
+
+ if (options && options.checkbox) {
input = this.$compile(`
- `)(this.$inputsScope);
}
+
+ if (options && options.datepicker) {
+ input = this.$compile(`
+ `)(this.$inputsScope);
+ }
+
cell.appendChild(input[0]);
}
searchRow.appendChild(cell);
@@ -372,13 +396,12 @@ export default class SmartTable extends Component {
searchByColumn(field) {
const searchCriteria = this.$inputsScope.searchProps[field];
- const emptySearch = searchCriteria == '' || null;
+ const emptySearch = searchCriteria === '' || searchCriteria == null;
const filters = this.filterSanitizer(field);
if (filters && filters.userFilter)
this.model.userFilter = filters.userFilter;
-
if (!emptySearch)
this.addFilter(field, this.$inputsScope.searchProps[field]);
else this.model.refresh();
@@ -497,7 +520,8 @@ ngModule.vnComponent('smartTable', {
controller: SmartTable,
transclude: {
table: '?slotTable',
- actions: '?slotActions'
+ actions: '?slotActions',
+ pagination: '?slotPagination'
},
bindings: {
model: '',
diff --git a/front/core/styles/icons/salixfont.css b/front/core/styles/icons/salixfont.css
index 530772246..6b2482bee 100644
--- a/front/core/styles/icons/salixfont.css
+++ b/front/core/styles/icons/salixfont.css
@@ -26,7 +26,7 @@
.icon-agency-term:before {
content: "\e950";
}
-.icon-deaulter:before {
+.icon-defaulter:before {
content: "\e94b";
}
.icon-100:before {
diff --git a/gulpfile.js b/gulpfile.js
index 0f7277afc..d7e7d8e86 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -3,8 +3,6 @@ const gulp = require('gulp');
const PluginError = require('plugin-error');
const argv = require('minimist')(process.argv.slice(2));
const log = require('fancy-log');
-const got = require('got');
-const e2eConfig = require('./e2e/helpers/config.js');
const Docker = require('./db/docker.js');
// Configuration
@@ -67,188 +65,6 @@ back.description = `Starts backend and database service`;
const defaultTask = gulp.parallel(front, back);
defaultTask.description = `Starts all application services`;
-
-// Backend tests - Private method
-
-async function launchBackTest(done) {
- let err;
- let dataSources = require('./loopback/server/datasources.json');
-
- const container = new Docker();
- await container.run(argv.ci);
-
- dataSources = JSON.parse(JSON.stringify(dataSources));
-
- Object.assign(dataSources.vn, {
- host: container.dbConf.host,
- port: container.dbConf.port
- });
-
- let bootOptions = {dataSources};
-
- let app = require(`./loopback/server/server`);
-
- try {
- app.boot(bootOptions);
-
- await new Promise((resolve, reject) => {
- const jasmine = require('gulp-jasmine');
-
- const options = {
- verbose: false,
- includeStackTrace: false,
- errorOnFail: false,
- timeout: 5000,
- config: {}
- };
-
- if (argv.ci) {
- const reporters = require('jasmine-reporters');
- options.reporter = new reporters.JUnitXmlReporter();
- }
-
- let backSpecFiles = [
- 'back/helpers.spec.js',
- 'back/**/*.spec.js',
- 'loopback/**/*.spec.js',
- 'modules/*/back/**/*.spec.js'
- ];
-
- gulp.src(backSpecFiles)
- .pipe(jasmine(options))
- .on('end', resolve)
- .on('error', reject)
- .resume();
- });
- } catch (e) {
- err = e;
- }
- await app.disconnect();
- await container.rm();
- done();
- if (err)
- throw err;
-}
-launchBackTest.description = `
- Runs the backend tests once using a random container, can receive --ci arg to save reports on a xml file`;
-
-// Backend tests
-
-function backTest(done) {
- const nodemon = require('gulp-nodemon');
-
- nodemon({
- exec: ['node --tls-min-v1.0 ./node_modules/gulp/bin/gulp.js'],
- args: ['launchBackTest'],
- watch: backSources,
- done: done
- });
-}
-backTest.description = `Watches for changes in modules to execute backTest task`;
-
-// End to end tests
-function e2eSingleRun() {
- require('@babel/register')({presets: ['@babel/env']});
- require('core-js/stable');
- require('regenerator-runtime/runtime');
-
- const jasmine = require('gulp-jasmine');
- const SpecReporter = require('jasmine-spec-reporter').SpecReporter;
-
- if (argv.show || argv.s)
- process.env.E2E_SHOW = true;
-
- const specFiles = [
- `${__dirname}/e2e/paths/01*/*[sS]pec.js`,
- `${__dirname}/e2e/paths/02*/*[sS]pec.js`,
- `${__dirname}/e2e/paths/03*/*[sS]pec.js`,
- `${__dirname}/e2e/paths/04*/*[sS]pec.js`,
- `${__dirname}/e2e/paths/05*/*[sS]pec.js`,
- `${__dirname}/e2e/paths/06*/*[sS]pec.js`,
- `${__dirname}/e2e/paths/07*/*[sS]pec.js`,
- `${__dirname}/e2e/paths/08*/*[sS]pec.js`,
- `${__dirname}/e2e/paths/09*/*[sS]pec.js`,
- `${__dirname}/e2e/paths/10*/*[sS]pec.js`,
- `${__dirname}/e2e/paths/11*/*[sS]pec.js`,
- `${__dirname}/e2e/paths/12*/*[sS]pec.js`,
- `${__dirname}/e2e/paths/13*/*[sS]pec.js`,
- `${__dirname}/e2e/paths/**/*[sS]pec.js`
- ];
-
- return gulp.src(specFiles).pipe(jasmine({
- errorOnFail: false,
- timeout: 30000,
- config: {
- random: false,
- // TODO: Waiting for this option to be implemented
- // https://github.com/jasmine/jasmine/issues/1533
- stopSpecOnExpectationFailure: false
- },
- reporter: [
- new SpecReporter({
- spec: {
- displayStacktrace: 'none',
- displaySuccessful: true,
- displayFailedSpec: true,
- displaySpecDuration: true,
- },
- summary: {
- displayStacktrace: 'raw',
- displayPending: false
- },
- colors: {
- enabled: true,
- successful: 'brightGreen',
- failed: 'brightRed'
- },
- // stacktrace: {
- // filter: stacktrace => {
- // const lines = stacktrace.split('\n');
- // const filtered = [];
- // for (let i = 1; i < lines.length; i++) {
- // if (/e2e\/paths/.test(lines[i]))
- // filtered.push(lines[i]);
- // }
- // return filtered.join('\n');
- // }
- // }
- })
- ]
- }));
-}
-
-e2e = gulp.series(docker, async function isBackendReady() {
- const attempts = await backendStatus();
- log(`Backend ready after ${attempts} attempt(s)`);
-
- return attempts;
-}, e2eSingleRun);
-e2e.description = `Restarts database and runs the e2e tests`;
-
-async function backendStatus() {
- const milliseconds = 250;
- return new Promise(resolve => {
- let timer;
- let attempts = 1;
- timer = setInterval(async() => {
- try {
- const url = `${e2eConfig.url}/api/Applications/status`;
- const {body} = await got.get(url);
-
- if (body == 'true') {
- clearInterval(timer);
- resolve(attempts);
- } else
- attempts++;
- } catch (error) {
- if (error || attempts > 100) // 250ms * 100 => 25s timeout
- throw new Error('Could not connect to backend');
- }
- }, milliseconds);
- });
-}
-backendStatus.description = `Performs a simple requests to check the backend status`;
-
function install() {
const install = require('gulp-install');
const print = require('gulp-print');
@@ -432,9 +248,6 @@ module.exports = {
back,
backOnly,
backWatch,
- backTest,
- launchBackTest,
- e2e,
i,
install,
build,
@@ -445,6 +258,5 @@ module.exports = {
locales,
localesRoutes,
watch,
- docker,
- backendStatus,
+ docker
};
diff --git a/jest.front.config.js b/jest.front.config.js
index dbea13950..a03c61d11 100644
--- a/jest.front.config.js
+++ b/jest.front.config.js
@@ -47,5 +47,6 @@ module.exports = {
'^.+\\.js?$': 'babel-jest',
'^.+\\.html$': 'html-loader-jest'
},
+ reporters: ['default', 'jest-junit']
};
diff --git a/loopback/common/models/field-acl.json b/loopback/common/models/field-acl.json
index 25ed949b9..a3f74aca2 100644
--- a/loopback/common/models/field-acl.json
+++ b/loopback/common/models/field-acl.json
@@ -9,19 +9,19 @@
"properties": {
"id": {
"id": true,
- "type": "Number"
+ "type": "number"
},
"model": {
- "type": "String"
+ "type": "string"
},
"property":{
- "type": "String"
+ "type": "string"
},
"actionType":{
- "type": "String"
+ "type": "string"
},
"role":{
- "type": "String"
+ "type": "string"
}
}
}
diff --git a/loopback/locale/en.json b/loopback/locale/en.json
index b7242befb..b7e9b43d3 100644
--- a/loopback/locale/en.json
+++ b/loopback/locale/en.json
@@ -12,7 +12,6 @@
"That payment method requires an IBAN": "That payment method requires an IBAN",
"That payment method requires a BIC": "That payment method requires a BIC",
"The default consignee can not be unchecked": "The default consignee can not be unchecked",
- "You can't make changes on a client with verified data": "You can't make changes on a client with verified data",
"Enter an integer different to zero": "Enter an integer different to zero",
"Package cannot be blank": "Package cannot be blank",
"The new quantity should be smaller than the old one": "The new quantity should be smaller than the old one",
@@ -123,5 +122,6 @@
"The type of business must be filled in basic data": "The type of business must be filled in basic data",
"The worker has hours recorded that day": "The worker has hours recorded that day",
"isWithoutNegatives": "isWithoutNegatives",
- "routeFk": "routeFk"
+ "routeFk": "routeFk",
+ "Not enough privileges to edit a client with verified data": "Not enough privileges to edit a client with verified data"
}
\ No newline at end of file
diff --git a/loopback/locale/es.json b/loopback/locale/es.json
index 77bd21780..9e2b8989b 100644
--- a/loopback/locale/es.json
+++ b/loopback/locale/es.json
@@ -50,7 +50,7 @@
"You don't have enough privileges to change that field": "No tienes permisos para cambiar ese campo",
"Warehouse cannot be blank": "El almacén no puede quedar en blanco",
"Agency cannot be blank": "La agencia no puede quedar en blanco",
- "You can't make changes on a client with verified data": "No puedes hacer cambios en un cliente con datos comprobados",
+ "Not enough privileges to edit a client with verified data": "No tienes permisos para hacer cambios en un cliente con datos comprobados",
"This address doesn't exist": "Este consignatario no existe",
"You must delete the claim id %d first": "Antes debes borrar la reclamación %d",
"You don't have enough privileges": "No tienes suficientes permisos",
@@ -224,5 +224,7 @@
"The agency is already assigned to another autonomous": "La agencia ya está asignada a otro autónomo",
"date in the future": "Fecha en el futuro",
"reference duplicated": "Referencia duplicada",
- "This ticket is already a refund": "Este ticket ya es un abono"
+ "This ticket is already a refund": "Este ticket ya es un abono",
+ "isWithoutNegatives": "isWithoutNegatives",
+ "routeFk": "routeFk"
}
\ No newline at end of file
diff --git a/loopback/server/datasources.json b/loopback/server/datasources.json
index 8b741ec97..5dade9c2e 100644
--- a/loopback/server/datasources.json
+++ b/loopback/server/datasources.json
@@ -39,7 +39,8 @@
"multipart/x-zip",
"image/png",
"image/jpeg",
- "image/jpg"
+ "image/jpg",
+ "video/mp4"
]
},
"dmsStorage": {
@@ -84,5 +85,28 @@
"application/octet-stream",
"application/pdf"
]
+ },
+ "claimStorage": {
+ "name": "claimStorage",
+ "connector": "loopback-component-storage",
+ "provider": "filesystem",
+ "root": "./storage/dms",
+ "maxFileSize": "31457280",
+ "allowedContentTypes": [
+ "image/png",
+ "image/jpeg",
+ "image/jpg",
+ "video/mp4"
+ ]
+ },
+ "accessStorage": {
+ "name": "accessStorage",
+ "connector": "loopback-component-storage",
+ "provider": "filesystem",
+ "root": "./storage/access",
+ "maxFileSize": "524288000",
+ "allowedContentTypes": [
+ "application/x-7z-compressed"
+ ]
}
}
\ No newline at end of file
diff --git a/modules/account/back/models/samba-config.json b/modules/account/back/models/samba-config.json
index 1bde4cdb6..732c9b071 100644
--- a/modules/account/back/models/samba-config.json
+++ b/modules/account/back/models/samba-config.json
@@ -29,7 +29,7 @@
"type": "string"
},
"verifyCert": {
- "type": "Boolean"
+ "type": "boolean"
}
}
}
diff --git a/modules/account/back/models/sip-config.json b/modules/account/back/models/sip-config.json
index 088f18224..6c5ba3db3 100644
--- a/modules/account/back/models/sip-config.json
+++ b/modules/account/back/models/sip-config.json
@@ -11,7 +11,7 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"id": true
}
}
diff --git a/modules/account/back/models/sip.json b/modules/account/back/models/sip.json
index 7a7cb8605..21671f4bf 100644
--- a/modules/account/back/models/sip.json
+++ b/modules/account/back/models/sip.json
@@ -8,7 +8,7 @@
},
"properties": {
"userFk": {
- "type": "Number",
+ "type": "number",
"id": true,
"description": "The user id",
"mysql": {
@@ -16,7 +16,7 @@
}
},
"extension": {
- "type": "String",
+ "type": "string",
"required": true
}
},
diff --git a/modules/account/front/role/summary/index.js b/modules/account/front/role/summary/index.js
index 0a08fe8b2..4f321fa98 100644
--- a/modules/account/front/role/summary/index.js
+++ b/modules/account/front/role/summary/index.js
@@ -6,7 +6,6 @@ class Controller extends Component {
this._role = value;
this.$.summary = null;
if (!value) return;
-
this.$http.get(`Roles/${value.id}`)
.then(res => this.$.summary = res.data);
}
diff --git a/modules/claim/back/methods/claim-end/deleteClamedSales.js b/modules/claim/back/methods/claim-end/deleteClamedSales.js
new file mode 100644
index 000000000..a6142c0fd
--- /dev/null
+++ b/modules/claim/back/methods/claim-end/deleteClamedSales.js
@@ -0,0 +1,49 @@
+module.exports = Self => {
+ Self.remoteMethodCtx('deleteClamedSales', {
+ description: 'Deletes the claimed sales',
+ accessType: 'WRITE',
+ accepts: [{
+ arg: 'sales',
+ type: ['object'],
+ required: true,
+ description: 'The sales to remove'
+ }],
+ returns: {
+ type: ['object'],
+ root: true
+ },
+ http: {
+ path: `/deleteClamedSales`,
+ verb: 'POST'
+ }
+ });
+
+ Self.deleteClamedSales = async(ctx, sales, options) => {
+ const models = Self.app.models;
+ const myOptions = {};
+ const tx = await Self.beginTransaction({});
+
+ if (typeof options == 'object')
+ Object.assign(myOptions, options);
+
+ if (!myOptions.transaction)
+ myOptions.transaction = tx;
+
+ try {
+ const promises = [];
+ for (let sale of sales) {
+ const deletedSale = models.ClaimEnd.destroyById(sale.id, myOptions);
+ promises.push(deletedSale);
+ }
+
+ const deletedSales = await Promise.all(promises);
+
+ if (tx) await tx.commit();
+
+ return deletedSales;
+ } catch (e) {
+ if (tx) await tx.rollback();
+ throw e;
+ }
+ };
+};
diff --git a/modules/claim/back/methods/claim-end/filter.js b/modules/claim/back/methods/claim-end/filter.js
new file mode 100644
index 000000000..0dda16a3a
--- /dev/null
+++ b/modules/claim/back/methods/claim-end/filter.js
@@ -0,0 +1,69 @@
+
+const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
+
+module.exports = Self => {
+ Self.remoteMethodCtx('filter', {
+ description: 'Find all instances of the model matched by filter from the data source.',
+ accessType: 'READ',
+ accepts: [
+ {
+ arg: 'filter',
+ type: 'object',
+ description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string',
+ http: {source: 'query'}
+ }, {
+ arg: 'search',
+ type: 'string',
+ description: `If it's and integer searchs by id, otherwise it searchs by client id`,
+ http: {source: 'query'}
+ }
+ ],
+ returns: {
+ type: ['object'],
+ root: true
+ },
+ http: {
+ path: `/filter`,
+ verb: 'GET'
+ }
+ });
+
+ Self.filter = async(ctx, filter, options) => {
+ const conn = Self.dataSource.connector;
+ const myOptions = {};
+
+ if (typeof options == 'object')
+ Object.assign(myOptions, options);
+
+ const stmts = [];
+
+ const stmt = new ParameterizedSQL(
+ `SELECT *
+ FROM (
+ SELECT
+ ce.id,
+ ce.claimFk,
+ s.itemFk,
+ s.ticketFk,
+ ce.claimDestinationFk,
+ t.landed,
+ s.quantity,
+ s.concept,
+ s.price,
+ s.discount,
+ s.quantity * s.price * ((100 - s.discount) / 100) total
+ FROM vn.claimEnd ce
+ LEFT JOIN vn.sale s ON s.id = ce.saleFk
+ LEFT JOIN vn.ticket t ON t.id = s.ticketFk
+ ) ce`
+ );
+
+ stmt.merge(conn.makeSuffix(filter));
+ const itemsIndex = stmts.push(stmt) - 1;
+
+ const sql = ParameterizedSQL.join(stmts, ';');
+ const result = await conn.executeStmt(sql, myOptions);
+
+ return itemsIndex === 0 ? result : result[itemsIndex];
+ };
+};
diff --git a/modules/claim/back/methods/claim/downloadFile.js b/modules/claim/back/methods/claim/downloadFile.js
new file mode 100644
index 000000000..750356b0b
--- /dev/null
+++ b/modules/claim/back/methods/claim/downloadFile.js
@@ -0,0 +1,59 @@
+const UserError = require('vn-loopback/util/user-error');
+
+module.exports = Self => {
+ Self.remoteMethodCtx('downloadFile', {
+ description: 'Get the claim file',
+ accessType: 'READ',
+ accepts: [
+ {
+ arg: 'id',
+ type: 'Number',
+ description: 'The document 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/downloadFile`,
+ verb: 'GET'
+ }
+ });
+
+ Self.downloadFile = async function(ctx, id) {
+ const models = Self.app.models;
+ const ClaimContainer = models.ClaimContainer;
+ const dms = await models.Dms.findById(id);
+ const pathHash = ClaimContainer.getHash(dms.id);
+ try {
+ await ClaimContainer.getFile(pathHash, dms.file);
+ } catch (e) {
+ if (e.code != 'ENOENT')
+ throw e;
+
+ const error = new UserError(`File doesn't exists`);
+ error.statusCode = 404;
+
+ throw error;
+ }
+
+ const stream = ClaimContainer.downloadStream(pathHash, dms.file);
+
+ return [stream, dms.contentType, `filename="${dms.file}"`];
+ };
+};
diff --git a/modules/claim/back/methods/claim/regularizeClaim.js b/modules/claim/back/methods/claim/regularizeClaim.js
index 29c7320f5..ab8ea58a4 100644
--- a/modules/claim/back/methods/claim/regularizeClaim.js
+++ b/modules/claim/back/methods/claim/regularizeClaim.js
@@ -86,7 +86,6 @@ module.exports = Self => {
};
ticketFk = await createTicket(ctx, myOptions);
}
-
await models.Sale.create({
ticketFk: ticketFk,
itemFk: sale.itemFk,
diff --git a/modules/claim/back/methods/claim/specs/downloadFile.spec.js b/modules/claim/back/methods/claim/specs/downloadFile.spec.js
new file mode 100644
index 000000000..3e46a9bc3
--- /dev/null
+++ b/modules/claim/back/methods/claim/specs/downloadFile.spec.js
@@ -0,0 +1,13 @@
+const app = require('vn-loopback/server/server');
+
+describe('claim downloadFile()', () => {
+ const dmsId = 7;
+
+ it('should return a response for an employee with image content-type', async() => {
+ const workerId = 1107;
+ const ctx = {req: {accessToken: {userId: workerId}}};
+ const result = await app.models.Claim.downloadFile(ctx, dmsId);
+
+ expect(result[1]).toEqual('image/jpeg');
+ });
+});
diff --git a/modules/claim/back/methods/claim/specs/uploadFile.spec.js b/modules/claim/back/methods/claim/specs/uploadFile.spec.js
new file mode 100644
index 000000000..952d80d27
--- /dev/null
+++ b/modules/claim/back/methods/claim/specs/uploadFile.spec.js
@@ -0,0 +1,18 @@
+const app = require('vn-loopback/server/server');
+
+describe('claim uploadFile()', () => {
+ it(`should return an error for a user without enough privileges`, async() => {
+ const clientId = 1101;
+ const ticketDmsTypeId = 14;
+ const ctx = {req: {accessToken: {userId: clientId}}, args: {dmsTypeId: ticketDmsTypeId}};
+
+ let error;
+ await app.models.Claim.uploadFile(ctx).catch(e => {
+ error = e;
+ }).finally(() => {
+ expect(error.message).toEqual(`You don't have enough privileges`);
+ });
+
+ expect(error).toBeDefined();
+ });
+});
diff --git a/modules/claim/back/methods/claim/updateClaimDestination.js b/modules/claim/back/methods/claim/updateClaimDestination.js
new file mode 100644
index 000000000..190883c6d
--- /dev/null
+++ b/modules/claim/back/methods/claim/updateClaimDestination.js
@@ -0,0 +1,55 @@
+
+module.exports = Self => {
+ Self.remoteMethod('updateClaimDestination', {
+ description: 'Update a claim with privileges',
+ accessType: 'WRITE',
+ accepts: [{
+ arg: 'rows',
+ type: ['object'],
+ required: true,
+ description: `the sales which will be modified the claimDestinationFk`
+ }, {
+ arg: 'claimDestinationFk',
+ type: 'number',
+ required: true
+ }],
+ returns: {
+ type: 'object',
+ root: true
+ },
+ http: {
+ path: `/updateClaimDestination`,
+ verb: 'post'
+ }
+ });
+
+ Self.updateClaimDestination = async(rows, claimDestinationFk, options) => {
+ const tx = await Self.beginTransaction({});
+ const myOptions = {};
+
+ if (typeof options == 'object')
+ Object.assign(myOptions, options);
+
+ if (!myOptions.transaction)
+ myOptions.transaction = tx;
+
+ try {
+ const models = Self.app.models;
+ const promises = [];
+ for (let row of rows) {
+ const claimEnd = await models.ClaimEnd.findById(row.id, null, myOptions);
+ const updatedClaimEnd = claimEnd.updateAttribute('claimDestinationFk', claimDestinationFk, myOptions);
+ promises.push(updatedClaimEnd);
+ }
+
+ const updatedSales = await Promise.all(promises);
+
+ if (tx) await tx.commit();
+
+ return updatedSales;
+ } catch (e) {
+ if (tx) await tx.rollback();
+ throw e;
+ }
+ };
+};
diff --git a/modules/claim/back/methods/claim/uploadFile.js b/modules/claim/back/methods/claim/uploadFile.js
index 81ad40219..3d0737cf8 100644
--- a/modules/claim/back/methods/claim/uploadFile.js
+++ b/modules/claim/back/methods/claim/uploadFile.js
@@ -1,6 +1,10 @@
+const UserError = require('vn-loopback/util/user-error');
+const fs = require('fs-extra');
+const path = require('path');
+
module.exports = Self => {
Self.remoteMethodCtx('uploadFile', {
- description: 'Upload and attach a document',
+ description: 'Upload and attach a file',
accessType: 'WRITE',
accepts: [{
arg: 'id',
@@ -53,22 +57,54 @@ module.exports = Self => {
});
Self.uploadFile = async(ctx, id, options) => {
- let tx;
+ const tx = await Self.beginTransaction({});
const myOptions = {};
if (typeof options == 'object')
Object.assign(myOptions, options);
- if (!myOptions.transaction) {
- tx = await Self.beginTransaction({});
+ if (!myOptions.transaction)
myOptions.transaction = tx;
- }
+
const models = Self.app.models;
const promises = [];
+ const TempContainer = models.TempContainer;
+ const ClaimContainer = models.ClaimContainer;
+ const fileOptions = {};
+ const args = ctx.args;
+ let srcFile;
try {
- const uploadedFiles = await models.Dms.uploadFile(ctx, myOptions);
- uploadedFiles.forEach(dms => {
+ const hasWriteRole = await models.DmsType.hasWriteRole(ctx, args.dmsTypeId, myOptions);
+ if (!hasWriteRole)
+ throw new UserError(`You don't have enough privileges`);
+
+ // Upload file to temporary path
+ const tempContainer = await TempContainer.container('dms');
+ const uploaded = await TempContainer.upload(tempContainer.name, ctx.req, ctx.result, fileOptions);
+ const files = Object.values(uploaded.files).map(file => {
+ return file[0];
+ });
+
+ const addedDms = [];
+ for (const uploadedFile of files) {
+ const newDms = await createDms(ctx, uploadedFile, myOptions);
+ const pathHash = ClaimContainer.getHash(newDms.id);
+
+ const file = await TempContainer.getFile(tempContainer.name, uploadedFile.name);
+ srcFile = path.join(file.client.root, file.container, file.name);
+
+ const claimContainer = await ClaimContainer.container(pathHash);
+ const dstFile = path.join(claimContainer.client.root, pathHash, newDms.file);
+
+ await fs.move(srcFile, dstFile, {
+ overwrite: true
+ });
+
+ addedDms.push(newDms);
+ }
+
+ addedDms.forEach(dms => {
const newClaimDms = models.ClaimDms.create({
claimFk: id,
dmsFk: dms.id
@@ -83,7 +119,34 @@ module.exports = Self => {
return resolvedPromises;
} catch (e) {
if (tx) await tx.rollback();
+
+ if (fs.existsSync(srcFile))
+ await fs.unlink(srcFile);
+
throw e;
}
};
+
+ async function createDms(ctx, file, myOptions) {
+ const models = Self.app.models;
+ const myUserId = ctx.req.accessToken.userId;
+ const args = ctx.args;
+
+ const newDms = await models.Dms.create({
+ workerFk: myUserId,
+ dmsTypeFk: args.dmsTypeId,
+ companyFk: args.companyId,
+ warehouseFk: args.warehouseId,
+ reference: args.reference,
+ description: args.description,
+ contentType: file.type,
+ hasFile: args.hasFile
+ }, myOptions);
+
+ let fileName = file.name;
+ const extension = models.DmsContainer.getFileExtension(fileName);
+ fileName = `${newDms.id}.${extension}`;
+
+ return newDms.updateAttribute('file', fileName, myOptions);
+ }
};
diff --git a/modules/claim/back/model-config.json b/modules/claim/back/model-config.json
index 16d34543c..d4d772b58 100644
--- a/modules/claim/back/model-config.json
+++ b/modules/claim/back/model-config.json
@@ -37,5 +37,8 @@
},
"ClaimLog": {
"dataSource": "vn"
+ },
+ "ClaimContainer": {
+ "dataSource": "claimStorage"
}
}
diff --git a/modules/claim/back/models/claim-beginning.json b/modules/claim/back/models/claim-beginning.json
index abdae440a..afa21f817 100644
--- a/modules/claim/back/models/claim-beginning.json
+++ b/modules/claim/back/models/claim-beginning.json
@@ -13,12 +13,12 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"id": true,
"description": "Identifier"
},
"quantity": {
- "type": "Number",
+ "type": "number",
"required": true
}
},
diff --git a/modules/claim/back/models/claim-container.json b/modules/claim/back/models/claim-container.json
new file mode 100644
index 000000000..446be77b9
--- /dev/null
+++ b/modules/claim/back/models/claim-container.json
@@ -0,0 +1,10 @@
+{
+ "name": "ClaimContainer",
+ "base": "Container",
+ "acls": [{
+ "accessType": "READ",
+ "principalType": "ROLE",
+ "principalId": "$everyone",
+ "permission": "ALLOW"
+ }]
+}
\ No newline at end of file
diff --git a/modules/claim/back/models/claim-destination.json b/modules/claim/back/models/claim-destination.json
index 8782fb815..60f948899 100644
--- a/modules/claim/back/models/claim-destination.json
+++ b/modules/claim/back/models/claim-destination.json
@@ -8,12 +8,12 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"id": true,
"description": "Identifier"
},
"description": {
- "type": "String",
+ "type": "string",
"required": true
}
},
diff --git a/modules/claim/back/models/claim-development.json b/modules/claim/back/models/claim-development.json
index 2e8eb2f01..02061fab7 100644
--- a/modules/claim/back/models/claim-development.json
+++ b/modules/claim/back/models/claim-development.json
@@ -12,7 +12,7 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"id": true,
"description": "Identifier"
},
diff --git a/modules/claim/back/models/claim-dms.json b/modules/claim/back/models/claim-dms.json
index 9ef964886..a215b6bb7 100644
--- a/modules/claim/back/models/claim-dms.json
+++ b/modules/claim/back/models/claim-dms.json
@@ -17,7 +17,7 @@
],
"properties": {
"dmsFk": {
- "type": "Number",
+ "type": "number",
"id": true,
"required": true
}
diff --git a/modules/claim/back/models/claim-end.js b/modules/claim/back/models/claim-end.js
new file mode 100644
index 000000000..75ecda59a
--- /dev/null
+++ b/modules/claim/back/models/claim-end.js
@@ -0,0 +1,4 @@
+module.exports = Self => {
+ require('../methods/claim-end/filter')(Self);
+ require('../methods/claim-end/deleteClamedSales')(Self);
+};
diff --git a/modules/claim/back/models/claim-end.json b/modules/claim/back/models/claim-end.json
index d908c252b..12d79f71b 100644
--- a/modules/claim/back/models/claim-end.json
+++ b/modules/claim/back/models/claim-end.json
@@ -12,7 +12,7 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"id": true,
"description": "Identifier"
}
diff --git a/modules/claim/back/models/claim-log.json b/modules/claim/back/models/claim-log.json
index 28b3f88ec..519cfe1ea 100644
--- a/modules/claim/back/models/claim-log.json
+++ b/modules/claim/back/models/claim-log.json
@@ -9,40 +9,40 @@
"properties": {
"id": {
"id": true,
- "type": "Number",
+ "type": "number",
"forceId": false
},
"originFk": {
- "type": "Number",
+ "type": "number",
"required": true
},
"userFk": {
- "type": "Number"
+ "type": "number"
},
"action": {
- "type": "String",
+ "type": "string",
"required": true
},
"changedModel": {
- "type": "String"
+ "type": "string"
},
"oldInstance": {
- "type": "Object"
+ "type": "object"
},
"newInstance": {
- "type": "Object"
+ "type": "object"
},
"creationDate": {
- "type": "Date"
+ "type": "date"
},
"changedModelId": {
- "type": "Number"
+ "type": "number"
},
"changedModelValue": {
- "type": "String"
+ "type": "string"
},
"description": {
- "type": "String"
+ "type": "string"
}
},
"relations": {
diff --git a/modules/claim/back/models/claim-ratio.json b/modules/claim/back/models/claim-ratio.json
index 196db72f6..605da98c6 100644
--- a/modules/claim/back/models/claim-ratio.json
+++ b/modules/claim/back/models/claim-ratio.json
@@ -9,23 +9,23 @@
"validateUpsert": true,
"properties": {
"clientFk": {
- "type": "Number",
+ "type": "number",
"id": true
},
"yearSale": {
- "type": "Number"
+ "type": "number"
},
"claimAmount": {
- "type": "Number"
+ "type": "number"
},
"claimingRate": {
- "type": "Number"
+ "type": "number"
},
"priceIncreasing": {
- "type": "Number"
+ "type": "number"
},
"packingRate": {
- "type": "Number"
+ "type": "number"
}
},
"relations": {
diff --git a/modules/claim/back/models/claim-reason.json b/modules/claim/back/models/claim-reason.json
index 562acc14e..8d51b8079 100644
--- a/modules/claim/back/models/claim-reason.json
+++ b/modules/claim/back/models/claim-reason.json
@@ -8,12 +8,12 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"id": true,
"description": "Identifier"
},
"description": {
- "type": "String"
+ "type": "string"
}
},
"acls": [
diff --git a/modules/claim/back/models/claim-redelivery.json b/modules/claim/back/models/claim-redelivery.json
index 8611a3a44..d153c7a8e 100644
--- a/modules/claim/back/models/claim-redelivery.json
+++ b/modules/claim/back/models/claim-redelivery.json
@@ -8,12 +8,12 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"id": true,
"description": "Identifier"
},
"description": {
- "type": "String",
+ "type": "string",
"required": true
}
},
diff --git a/modules/claim/back/models/claim-responsible.json b/modules/claim/back/models/claim-responsible.json
index 6bd06605b..bdc5df0ec 100644
--- a/modules/claim/back/models/claim-responsible.json
+++ b/modules/claim/back/models/claim-responsible.json
@@ -8,16 +8,16 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"id": true,
"description": "Identifier"
},
"description": {
- "type": "String",
+ "type": "string",
"required": true
},
"responsability": {
- "type": "Number",
+ "type": "number",
"required": true
}
},
diff --git a/modules/claim/back/models/claim-result.json b/modules/claim/back/models/claim-result.json
index 468f271de..2c9630696 100644
--- a/modules/claim/back/models/claim-result.json
+++ b/modules/claim/back/models/claim-result.json
@@ -8,12 +8,12 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"id": true,
"description": "Identifier"
},
"description": {
- "type": "String"
+ "type": "string"
}
},
"acls": [
diff --git a/modules/claim/back/models/claim.js b/modules/claim/back/models/claim.js
index fba11cfb6..e6dc50073 100644
--- a/modules/claim/back/models/claim.js
+++ b/modules/claim/back/models/claim.js
@@ -7,4 +7,6 @@ module.exports = Self => {
require('../methods/claim/uploadFile')(Self);
require('../methods/claim/updateClaimAction')(Self);
require('../methods/claim/isEditable')(Self);
+ require('../methods/claim/updateClaimDestination')(Self);
+ require('../methods/claim/downloadFile')(Self);
};
diff --git a/modules/claim/back/models/claim.json b/modules/claim/back/models/claim.json
index 431290812..a3490ccf4 100644
--- a/modules/claim/back/models/claim.json
+++ b/modules/claim/back/models/claim.json
@@ -12,7 +12,7 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"id": true,
"description": "Identifier"
},
diff --git a/modules/claim/front/action/index.html b/modules/claim/front/action/index.html
index 6c0e2402d..059764ae2 100644
--- a/modules/claim/front/action/index.html
+++ b/modules/claim/front/action/index.html
@@ -1,10 +1,8 @@
-
-
-
-
-
- Id
- Ticket
- Destination
- Landed
- Quantity
- Description
- Price
- Disc.
- Total
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+ Id
+ Ticket
+ Destination
+ Landed
+ Quantity
+ Description
+ Price
+ Disc.
+ Total
+
+
+
+
-
-
+
+
+
+
+
- {{::saleClaimed.sale.itemFk | zeroFill:6}}
-
-
-
-
+
+
+
- {{::saleClaimed.sale.ticketFk}}
-
-
-
+ ng-click="ticketDescriptor.show($event, saleClaimed.ticketFk)">
+ {{::saleClaimed.ticketFk}}
+
+
+
-
- {{::saleClaimed.sale.ticket.landed | date: 'dd/MM/yyyy'}}
- {{::saleClaimed.sale.quantity}}
- {{::saleClaimed.sale.concept}}
- {{::saleClaimed.sale.price | currency: 'EUR':2}}
- {{::saleClaimed.sale.discount}} %
-
- {{saleClaimed.sale.quantity * saleClaimed.sale.price *
- ((100 - saleClaimed.sale.discount) / 100) | currency: 'EUR':2}}
-
-
+
+ {{::saleClaimed.landed | date: 'dd/MM/yyyy'}}
+ {{::saleClaimed.quantity}}
+ {{::saleClaimed.concept}}
+ {{::saleClaimed.price | currency: 'EUR':2}}
+ {{::saleClaimed.discount}} %
+ {{saleClaimed.total | currency: 'EUR':2}}
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
\ No newline at end of file
+
+
+
+
+
+
+ {{$ctrl.$t('Change destination to all selected rows', {total: $ctrl.checked.length})}}
+
+
+
+
+
+
+
+
+ Save
+
+
\ No newline at end of file
diff --git a/modules/claim/front/action/index.js b/modules/claim/front/action/index.js
index 4b3214211..10b629f27 100644
--- a/modules/claim/front/action/index.js
+++ b/modules/claim/front/action/index.js
@@ -5,6 +5,7 @@ import './style.scss';
export default class Controller extends Section {
constructor($element, $) {
super($element, $);
+ this.newDestination;
this.filter = {
include: [
{relation: 'sale',
@@ -21,6 +22,81 @@ export default class Controller extends Section {
};
this.getResolvedState();
this.maxResponsibility = 5;
+ this.smartTableOptions = {
+ activeButtons: {
+ search: true
+ },
+ columns: [
+ {
+ field: 'claimDestinationFk',
+ autocomplete: {
+ url: 'ClaimDestinations',
+ showField: 'description',
+ valueField: 'id'
+ }
+ },
+ {
+ field: 'landed',
+ searchable: false
+ }
+ ]
+ };
+ }
+
+ exprBuilder(param, value) {
+ switch (param) {
+ case 'itemFk':
+ case 'ticketFk':
+ case 'claimDestinationFk':
+ case 'quantity':
+ case 'price':
+ case 'discount':
+ case 'total':
+ return {[param]: value};
+ case 'concept':
+ return {[param]: {like: `%${value}%`}};
+ case 'landed':
+ return {[param]: {between: this.dateRange(value)}};
+ }
+ }
+
+ dateRange(value) {
+ const minHour = new Date(value);
+ minHour.setHours(0, 0, 0, 0);
+ const maxHour = new Date(value);
+ maxHour.setHours(23, 59, 59, 59);
+
+ return [minHour, maxHour];
+ }
+
+ get checked() {
+ const salesClaimed = this.$.model.data || [];
+
+ const checkedSalesClaimed = [];
+ for (let saleClaimed of salesClaimed) {
+ if (saleClaimed.$checked)
+ checkedSalesClaimed.push(saleClaimed);
+ }
+
+ return checkedSalesClaimed;
+ }
+
+ updateDestination(saleClaimed, claimDestinationFk) {
+ const data = {rows: [saleClaimed], claimDestinationFk: claimDestinationFk};
+ this.$http.post(`Claims/updateClaimDestination`, data).then(() => {
+ this.vnApp.showSuccess(this.$t('Data saved!'));
+ }).catch(e => {
+ this.$.model.refresh();
+ throw e;
+ });
+ }
+
+ removeSales(saleClaimed) {
+ const params = {sales: [saleClaimed]};
+ this.$http.post(`ClaimEnds/deleteClamedSales`, params).then(() => {
+ this.$.model.refresh();
+ this.vnApp.showSuccess(this.$t('Data saved!'));
+ });
}
getResolvedState() {
@@ -54,8 +130,8 @@ export default class Controller extends Section {
calculateTotals() {
this.claimedTotal = 0;
this.salesClaimed.forEach(sale => {
- const price = sale.sale.quantity * sale.sale.price;
- const discount = (sale.sale.discount * (sale.sale.quantity * sale.sale.price)) / 100;
+ const price = sale.quantity * sale.price;
+ const discount = (sale.discount * (sale.quantity * sale.price)) / 100;
this.claimedTotal += price - discount;
});
}
@@ -125,6 +201,24 @@ export default class Controller extends Section {
onSave() {
this.vnApp.showSuccess(this.$t('Data saved!'));
}
+
+ onResponse() {
+ const rowsToEdit = [];
+ for (let row of this.checked)
+ rowsToEdit.push({id: row.id});
+
+ const data = {
+ rows: rowsToEdit,
+ claimDestinationFk: this.newDestination
+ };
+
+ const query = `Claims/updateClaimDestination`;
+ this.$http.post(query, data)
+ .then(() => {
+ this.$.model.refresh();
+ this.vnApp.showSuccess(this.$t('Data saved!'));
+ });
+ }
}
ngModule.vnComponent('vnClaimAction', {
diff --git a/modules/claim/front/action/index.spec.js b/modules/claim/front/action/index.spec.js
index f25f2eb3c..458d5e831 100644
--- a/modules/claim/front/action/index.spec.js
+++ b/modules/claim/front/action/index.spec.js
@@ -43,9 +43,9 @@ describe('claim', () => {
describe('calculateTotals()', () => {
it('should calculate the total price of the items claimed', () => {
controller.salesClaimed = [
- {sale: {quantity: 5, price: 2, discount: 0}},
- {sale: {quantity: 10, price: 2, discount: 0}},
- {sale: {quantity: 10, price: 2, discount: 0}}
+ {quantity: 5, price: 2, discount: 0},
+ {quantity: 10, price: 2, discount: 0},
+ {quantity: 10, price: 2, discount: 0}
];
controller.calculateTotals();
@@ -151,5 +151,17 @@ describe('claim', () => {
expect(controller.vnApp.showMessage).toHaveBeenCalledWith('Greuge added');
});
});
+
+ describe('onResponse()', () => {
+ it('should perform a post query and show a success message', () => {
+ jest.spyOn(controller.vnApp, 'showSuccess');
+
+ $httpBackend.expect('POST', `Claims/updateClaimDestination`).respond({});
+ controller.onResponse();
+ $httpBackend.flush();
+
+ expect(controller.vnApp.showSuccess).toHaveBeenCalled();
+ });
+ });
});
});
diff --git a/modules/claim/front/action/locale/es.yml b/modules/claim/front/action/locale/es.yml
index 22b2740b3..97640d9dc 100644
--- a/modules/claim/front/action/locale/es.yml
+++ b/modules/claim/front/action/locale/es.yml
@@ -7,4 +7,7 @@ Regularize: Regularizar
Do you want to insert greuges?: Desea insertar greuges?
Insert greuges on client card: Insertar greuges en la ficha del cliente
Greuge added: Greuge añadido
-ClaimGreugeDescription: Reclamación id {{claimId}}
\ No newline at end of file
+ClaimGreugeDescription: Reclamación id {{claimId}}
+Change destination: Cambiar destino
+Change destination to all selected rows: Cambiar destino a {{total}} fila(s) seleccionada(s)
+Add observation to all selected clients: Añadir observación a {{total}} cliente(s) seleccionado(s)
diff --git a/modules/claim/front/action/style.scss b/modules/claim/front/action/style.scss
index bac316287..cda6779c8 100644
--- a/modules/claim/front/action/style.scss
+++ b/modules/claim/front/action/style.scss
@@ -6,7 +6,7 @@ vn-claim-action {
align-content: center;
vn-tool-bar {
- flex: 1
+ flex: none
}
.vn-check {
@@ -39,4 +39,8 @@ vn-claim-action {
max-height: 350px;
}
}
+
+ .right {
+ margin-left: 370px;
+ }
}
\ No newline at end of file
diff --git a/modules/claim/front/photos/index.html b/modules/claim/front/photos/index.html
index 9cc6c649c..9e00ee02f 100644
--- a/modules/claim/front/photos/index.html
+++ b/modules/claim/front/photos/index.html
@@ -1,6 +1,7 @@
+ zoom-image="{{$ctrl.getImagePath(photo.dmsFk)}}"
+ ng-if="photo.dms.contentType != 'video/mp4'">
+
+
+
diff --git a/modules/claim/front/photos/index.js b/modules/claim/front/photos/index.js
index 2b77c6abc..62e439a91 100644
--- a/modules/claim/front/photos/index.js
+++ b/modules/claim/front/photos/index.js
@@ -6,6 +6,13 @@ class Controller extends Section {
constructor($element, $, vnFile) {
super($element, $);
this.vnFile = vnFile;
+ this.filter = {
+ include: [
+ {
+ relation: 'dms'
+ }
+ ]
+ };
}
deleteDms(index) {
@@ -13,7 +20,7 @@ class Controller extends Section {
return this.$http.post(`ClaimDms/${dmsFk}/removeFile`)
.then(() => {
this.$.model.remove(index);
- this.vnApp.showSuccess(this.$t('Photo deleted'));
+ this.vnApp.showSuccess(this.$t('File deleted'));
});
}
@@ -81,13 +88,13 @@ class Controller extends Section {
data: this.dms.files
};
this.$http(options).then(() => {
- this.vnApp.showSuccess(this.$t('Photo uploaded!'));
+ this.vnApp.showSuccess(this.$t('File uploaded!'));
this.$.model.refresh();
});
}
getImagePath(dmsId) {
- return this.vnFile.getPath(`/api/dms/${dmsId}/downloadFile`);
+ return this.vnFile.getPath(`/api/Claims/${dmsId}/downloadFile`);
}
}
diff --git a/modules/claim/front/photos/locale/es.yml b/modules/claim/front/photos/locale/es.yml
index 8ccc1dba4..d2ee9ffbd 100644
--- a/modules/claim/front/photos/locale/es.yml
+++ b/modules/claim/front/photos/locale/es.yml
@@ -1,5 +1,5 @@
Are you sure you want to continue?: ¿Seguro que quieres continuar?
Drag & Drop photos here...: Arrastra y suelta fotos aquí...
-Photo deleted: Foto eliminada
-Photo uploaded!: Foto subida!
-Select photo: Seleccionar foto
\ No newline at end of file
+File deleted: Archivo eliminado
+File uploaded!: Archivo subido!
+Select file: Seleccionar fichero
\ No newline at end of file
diff --git a/modules/claim/front/photos/style.scss b/modules/claim/front/photos/style.scss
index d747dd9b8..101cb0da2 100644
--- a/modules/claim/front/photos/style.scss
+++ b/modules/claim/front/photos/style.scss
@@ -29,4 +29,19 @@ vn-claim-photos {
height: 288px;
}
}
-}
\ No newline at end of file
+
+ .video {
+ width: 100%;
+ height: 100%;
+ object-fit: cover;
+ cursor: pointer;
+ box-shadow: 0 2px 2px 0 rgba(0,0,0,.14),
+ 0 3px 1px -2px rgba(0,0,0,.2),
+ 0 1px 5px 0 rgba(0,0,0,.12);
+ border: 2px solid transparent;
+
+ }
+ .video:hover {
+ border: 2px solid $color-primary
+ }
+}
diff --git a/modules/claim/front/summary/index.html b/modules/claim/front/summary/index.html
index 282c55b00..5d90da516 100644
--- a/modules/claim/front/summary/index.html
+++ b/modules/claim/front/summary/index.html
@@ -1,5 +1,6 @@
@@ -106,8 +107,13 @@
+ zoom-image="{{$ctrl.getImagePath(photo.dmsFk)}}"
+ ng-if="photo.dms.contentType != 'video/mp4'">
+
+
+
diff --git a/modules/claim/front/summary/index.js b/modules/claim/front/summary/index.js
index 721f51846..7cd4805e9 100644
--- a/modules/claim/front/summary/index.js
+++ b/modules/claim/front/summary/index.js
@@ -6,6 +6,13 @@ class Controller extends Summary {
constructor($element, $, vnFile) {
super($element, $);
this.vnFile = vnFile;
+ this.filter = {
+ include: [
+ {
+ relation: 'dms'
+ }
+ ]
+ };
}
$onChanges() {
diff --git a/modules/claim/front/summary/style.scss b/modules/claim/front/summary/style.scss
index e81213658..5b4e32f7a 100644
--- a/modules/claim/front/summary/style.scss
+++ b/modules/claim/front/summary/style.scss
@@ -10,4 +10,19 @@ vn-claim-summary {
vn-textarea *{
height: 80px;
}
+
+ .video {
+ width: 100%;
+ height: 100%;
+ object-fit: cover;
+ cursor: pointer;
+ box-shadow: 0 2px 2px 0 rgba(0,0,0,.14),
+ 0 3px 1px -2px rgba(0,0,0,.2),
+ 0 1px 5px 0 rgba(0,0,0,.12);
+ border: 2px solid transparent;
+
+ }
+ .video:hover {
+ border: 2px solid $color-primary
+ }
}
\ No newline at end of file
diff --git a/modules/client/back/methods/client/extendedListFilter.js b/modules/client/back/methods/client/extendedListFilter.js
new file mode 100644
index 000000000..8e02cd413
--- /dev/null
+++ b/modules/client/back/methods/client/extendedListFilter.js
@@ -0,0 +1,159 @@
+
+const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
+const buildFilter = require('vn-loopback/util/filter').buildFilter;
+const mergeFilters = require('vn-loopback/util/filter').mergeFilters;
+
+module.exports = Self => {
+ Self.remoteMethodCtx('extendedListFilter', {
+ description: 'Find all clients matched by the filter',
+ accessType: 'READ',
+ accepts: [
+ {
+ arg: 'filter',
+ type: 'object',
+ },
+ {
+ arg: 'search',
+ type: 'string',
+ description: `If it's and integer searchs by id, otherwise it searchs by name`,
+ },
+ {
+ arg: 'name',
+ type: 'string',
+ description: 'The client name',
+ },
+ {
+ arg: 'salesPersonFk',
+ type: 'number',
+ },
+ {
+ arg: 'fi',
+ type: 'string',
+ description: 'The client fiscal id',
+ },
+ {
+ arg: 'socialName',
+ type: 'string',
+ },
+ {
+ arg: 'city',
+ type: 'string',
+ },
+ {
+ arg: 'postcode',
+ type: 'string',
+ },
+ {
+ arg: 'provinceFk',
+ type: 'number',
+ },
+ {
+ arg: 'email',
+ type: 'string',
+ },
+ {
+ arg: 'phone',
+ type: 'string',
+ },
+ ],
+ returns: {
+ type: ['object'],
+ root: true
+ },
+ http: {
+ path: `/extendedListFilter`,
+ verb: 'GET'
+ }
+ });
+
+ Self.extendedListFilter = async(ctx, filter, options) => {
+ const conn = Self.dataSource.connector;
+ const myOptions = {};
+
+ if (typeof options == 'object')
+ Object.assign(myOptions, options);
+
+ const where = buildFilter(ctx.args, (param, value) => {
+ switch (param) {
+ case 'search':
+ return /^\d+$/.test(value)
+ ? {'c.id': {inq: value}}
+ : {'c.name': {like: `%${value}%`}};
+ case 'name':
+ case 'salesPersonFk':
+ case 'fi':
+ case 'socialName':
+ case 'city':
+ case 'postcode':
+ case 'provinceFk':
+ case 'email':
+ case 'phone':
+ param = `c.${param}`;
+ return {[param]: value};
+ }
+ });
+
+ filter = mergeFilters(filter, {where});
+
+ const stmts = [];
+ const stmt = new ParameterizedSQL(
+ `SELECT
+ c.id,
+ c.name,
+ c.socialName,
+ c.fi,
+ c.credit,
+ c.creditInsurance,
+ c.phone,
+ c.mobile,
+ c.street,
+ c.city,
+ c.postcode,
+ c.email,
+ c.created,
+ c.isActive,
+ c.isVies,
+ c.isTaxDataChecked,
+ c.isEqualizated,
+ c.isFreezed,
+ c.hasToInvoice,
+ c.hasToInvoiceByAddress,
+ c.isToBeMailed,
+ c.hasSepaVnl,
+ c.hasLcr,
+ c.hasCoreVnl,
+ ct.id AS countryFk,
+ ct.country,
+ p.id AS provinceFk,
+ p.name AS province,
+ u.id AS salesPersonFk,
+ u.name AS salesPerson,
+ bt.code AS businessTypeFk,
+ bt.description AS businessType,
+ pm.id AS payMethodFk,
+ pm.name AS payMethod,
+ sti.CodigoIva AS sageTaxTypeFk,
+ sti.Iva AS sageTaxType,
+ stt.CodigoTransaccion AS sageTransactionTypeFk,
+ stt.Transaccion AS sageTransactionType
+ FROM client c
+ LEFT JOIN account.user u ON u.id = c.salesPersonFk
+ LEFT JOIN country ct ON ct.id = c.countryFk
+ LEFT JOIN province p ON p.id = c.provinceFk
+ LEFT JOIN businessType bt ON bt.code = c.businessTypeFk
+ LEFT JOIN payMethod pm ON pm.id = c.payMethodFk
+ LEFT JOIN sage.TiposIva sti ON sti.CodigoIva = c.taxTypeSageFk
+ LEFT JOIN sage.TiposTransacciones stt ON stt.CodigoTransaccion = c.transactionTypeSageFk
+ `
+ );
+
+ stmt.merge(conn.makeWhere(filter.where));
+ stmt.merge(conn.makePagination(filter));
+
+ const clientsIndex = stmts.push(stmt) - 1;
+ const sql = ParameterizedSQL.join(stmts, ';');
+ const result = await conn.executeStmt(sql, myOptions);
+
+ return clientsIndex === 0 ? result : result[clientsIndex];
+ };
+};
diff --git a/modules/client/back/methods/client/sendSms.js b/modules/client/back/methods/client/sendSms.js
index cc11d17be..9d6a12416 100644
--- a/modules/client/back/methods/client/sendSms.js
+++ b/modules/client/back/methods/client/sendSms.js
@@ -39,7 +39,7 @@ module.exports = Self => {
const userId = ctx.req.accessToken.userId;
- const sms = await models.Sms.send(ctx, id, destination, message);
+ const sms = await models.Sms.send(ctx, destination, message);
const logRecord = {
originFk: id,
userFk: userId,
diff --git a/modules/client/back/methods/client/specs/addressesPropagateRe.spec.js b/modules/client/back/methods/client/specs/addressesPropagateRe.spec.js
index 069c7bd25..74d80b964 100644
--- a/modules/client/back/methods/client/specs/addressesPropagateRe.spec.js
+++ b/modules/client/back/methods/client/specs/addressesPropagateRe.spec.js
@@ -1,6 +1,22 @@
const models = require('vn-loopback/server/server').models;
+const LoopBackContext = require('loopback-context');
describe('Client addressesPropagateRe', () => {
+ beforeAll(async() => {
+ const activeCtx = {
+ accessToken: {userId: 9},
+ http: {
+ req: {
+ headers: {origin: 'http://localhost'}
+ }
+ }
+ };
+
+ spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
+ active: activeCtx
+ });
+ });
+
it('should propagate the isEqualizated on both addresses of Mr Wayne and set hasToInvoiceByAddress to false', async() => {
const tx = await models.Client.beginTransaction({});
diff --git a/modules/client/back/methods/client/specs/createAddress.spec.js b/modules/client/back/methods/client/specs/createAddress.spec.js
index d6178ae0d..0841ad98c 100644
--- a/modules/client/back/methods/client/specs/createAddress.spec.js
+++ b/modules/client/back/methods/client/specs/createAddress.spec.js
@@ -1,4 +1,5 @@
const models = require('vn-loopback/server/server').models;
+const LoopBackContext = require('loopback-context');
describe('Address createAddress', () => {
const clientFk = 1101;
@@ -6,6 +7,21 @@ describe('Address createAddress', () => {
const incotermsFk = 'FAS';
const customAgentOneId = 1;
+ beforeAll(async() => {
+ const activeCtx = {
+ accessToken: {userId: 9},
+ http: {
+ req: {
+ headers: {origin: 'http://localhost'}
+ }
+ }
+ };
+
+ spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
+ active: activeCtx
+ });
+ });
+
it('should throw a non uee member error if no incoterms is defined', async() => {
const tx = await models.Client.beginTransaction({});
diff --git a/modules/client/back/methods/client/specs/createWithUser.spec.js b/modules/client/back/methods/client/specs/createWithUser.spec.js
index 4c827c745..7d4261aee 100644
--- a/modules/client/back/methods/client/specs/createWithUser.spec.js
+++ b/modules/client/back/methods/client/specs/createWithUser.spec.js
@@ -1,4 +1,5 @@
const models = require('vn-loopback/server/server').models;
+const LoopBackContext = require('loopback-context');
describe('Client Create', () => {
const newAccount = {
@@ -12,6 +13,21 @@ describe('Client Create', () => {
businessTypeFk: 'florist'
};
+ beforeAll(async() => {
+ const activeCtx = {
+ accessToken: {userId: 9},
+ http: {
+ req: {
+ headers: {origin: 'http://localhost'}
+ }
+ }
+ };
+
+ spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
+ active: activeCtx
+ });
+ });
+
it(`should not find Deadpool as he's not created yet`, async() => {
const tx = await models.Client.beginTransaction({});
diff --git a/modules/client/back/methods/client/specs/extendedListFilter.spec.js b/modules/client/back/methods/client/specs/extendedListFilter.spec.js
new file mode 100644
index 000000000..907c03ef9
--- /dev/null
+++ b/modules/client/back/methods/client/specs/extendedListFilter.spec.js
@@ -0,0 +1,180 @@
+const { models } = require('vn-loopback/server/server');
+
+describe('client extendedListFilter()', () => {
+ it('should return the clients matching the filter with a limit of 20 rows', async() => {
+ const tx = await models.Client.beginTransaction({});
+
+ try {
+ const options = {transaction: tx};
+
+ const ctx = {req: {accessToken: {userId: 1}}, args: {}};
+ const filter = {limit: '20'};
+ const result = await models.Client.extendedListFilter(ctx, filter, options);
+
+ expect(result.length).toEqual(20);
+
+ await tx.rollback();
+ } catch (e) {
+ await tx.rollback();
+ throw e;
+ }
+ });
+
+ it('should return the client "Bruce Wayne" matching the search argument with his name', async() => {
+ const tx = await models.Client.beginTransaction({});
+
+ try {
+ const options = {transaction: tx};
+
+ const ctx = {req: {accessToken: {userId: 1}}, args: {search: 'Bruce Wayne'}};
+ const filter = {};
+ const result = await models.Client.extendedListFilter(ctx, filter, options);
+
+ const firstResult = result[0];
+
+ expect(result.length).toEqual(1);
+ expect(firstResult.name).toEqual('Bruce Wayne');
+
+ await tx.rollback();
+ } catch (e) {
+ await tx.rollback();
+ throw e;
+ }
+ });
+
+ it('should return the client "Bruce Wayne" matching the search argument with his id', async() => {
+ const tx = await models.Client.beginTransaction({});
+
+ try {
+ const options = {transaction: tx};
+
+ const ctx = {req: {accessToken: {userId: 1}}, args: {search: '1101'}};
+ const filter = {};
+ const result = await models.Client.extendedListFilter(ctx, filter, options);
+
+ const firstResult = result[0];
+
+ expect(result.length).toEqual(1);
+ expect(firstResult.name).toEqual('Bruce Wayne');
+
+ await tx.rollback();
+ } catch (e) {
+ await tx.rollback();
+ throw e;
+ }
+ });
+
+ it('should return the client "Bruce Wayne" matching the name argument', async() => {
+ const tx = await models.Client.beginTransaction({});
+
+ try {
+ const options = {transaction: tx};
+
+ const ctx = {req: {accessToken: {userId: 1}}, args: {name: 'Bruce Wayne'}};
+ const filter = {};
+ const result = await models.Client.extendedListFilter(ctx, filter, options);
+
+ const firstResult = result[0];
+
+ expect(result.length).toEqual(1);
+ expect(firstResult.name).toEqual('Bruce Wayne');
+
+ await tx.rollback();
+ } catch (e) {
+ await tx.rollback();
+ throw e;
+ }
+ });
+
+ it('should return the clients matching the "salesPersonFk" argument', async() => {
+ const tx = await models.Client.beginTransaction({});
+ const salesPersonId = 18;
+
+ try {
+ const options = {transaction: tx};
+
+ const ctx = {req: {accessToken: {userId: 1}}, args: {salesPersonFk: salesPersonId}};
+ const filter = {};
+ const result = await models.Client.extendedListFilter(ctx, filter, options);
+
+ const randomIndex = Math.floor(Math.random() * result.length);
+ const randomResultClient = result[randomIndex];
+
+ expect(result.length).toBeGreaterThanOrEqual(5);
+ expect(randomResultClient.salesPersonFk).toEqual(salesPersonId);
+
+ await tx.rollback();
+ } catch (e) {
+ await tx.rollback();
+ throw e;
+ }
+ });
+
+ it('should return the clients matching the "fi" argument', async() => {
+ const tx = await models.Client.beginTransaction({});
+
+ try {
+ const options = {transaction: tx};
+
+ const ctx = {req: {accessToken: {userId: 1}}, args: {fi: '251628698'}};
+ const filter = {};
+ const result = await models.Client.extendedListFilter(ctx, filter, options);
+
+ const firstClient = result[0];
+
+ expect(result.length).toEqual(1);
+ expect(firstClient.name).toEqual('Max Eisenhardt');
+
+ await tx.rollback();
+ } catch (e) {
+ await tx.rollback();
+ throw e;
+ }
+ });
+
+ it('should return the clients matching the "city" argument', async() => {
+ const tx = await models.Client.beginTransaction({});
+
+ try {
+ const options = {transaction: tx};
+
+ const ctx = {req: {accessToken: {userId: 1}}, args: {city: 'Silla'}};
+ const filter = {};
+ const result = await models.Client.extendedListFilter(ctx, filter, options);
+
+ const randomIndex = Math.floor(Math.random() * result.length);
+ const randomResultClient = result[randomIndex];
+
+ expect(result.length).toBeGreaterThanOrEqual(20);
+ expect(randomResultClient.city.toLowerCase()).toEqual('silla');
+
+ await tx.rollback();
+ } catch (e) {
+ await tx.rollback();
+ throw e;
+ }
+ });
+
+ it('should return the clients matching the "postcode" argument', async() => {
+ const tx = await models.Client.beginTransaction({});
+
+ try {
+ const options = {transaction: tx};
+
+ const ctx = {req: {accessToken: {userId: 1}}, args: {postcode: '46460'}};
+ const filter = {};
+ const result = await models.Client.extendedListFilter(ctx, filter, options);
+
+ const randomIndex = Math.floor(Math.random() * result.length);
+ const randomResultClient = result[randomIndex];
+
+ expect(result.length).toBeGreaterThanOrEqual(20);
+ expect(randomResultClient.postcode).toEqual('46460');
+
+ await tx.rollback();
+ } catch (e) {
+ await tx.rollback();
+ throw e;
+ }
+ });
+});
diff --git a/modules/client/back/methods/client/specs/updateAddress.spec.js b/modules/client/back/methods/client/specs/updateAddress.spec.js
index 5597c6e5a..6f02323c5 100644
--- a/modules/client/back/methods/client/specs/updateAddress.spec.js
+++ b/modules/client/back/methods/client/specs/updateAddress.spec.js
@@ -1,4 +1,5 @@
const models = require('vn-loopback/server/server').models;
+const LoopBackContext = require('loopback-context');
describe('Address updateAddress', () => {
const clientId = 1101;
@@ -13,6 +14,21 @@ describe('Address updateAddress', () => {
}
};
+ beforeAll(async() => {
+ const activeCtx = {
+ accessToken: {userId: 9},
+ http: {
+ req: {
+ headers: {origin: 'http://localhost'}
+ }
+ }
+ };
+
+ spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
+ active: activeCtx
+ });
+ });
+
it('should throw the non uee member error if no incoterms is defined', async() => {
const tx = await models.Client.beginTransaction({});
@@ -33,7 +49,6 @@ describe('Address updateAddress', () => {
error = e;
}
- expect(error).toBeDefined();
expect(error.message).toEqual('Incoterms is required for a non UEE member');
});
@@ -57,7 +72,6 @@ describe('Address updateAddress', () => {
error = e;
}
- expect(error).toBeDefined();
expect(error.message).toEqual('Customs agent is required for a non UEE member');
});
@@ -91,8 +105,11 @@ describe('Address updateAddress', () => {
it('should return an error for a user without enough privileges', async() => {
const tx = await models.Client.beginTransaction({});
+ let error;
+
try {
const options = {transaction: tx};
+ ctx.req.accessToken.userId = employeeId;
ctx.args = {
isLogifloraAllowed: true
};
@@ -124,8 +141,10 @@ describe('Address updateAddress', () => {
expect(address.isLogifloraAllowed).toEqual(true);
await tx.rollback();
+ ctx.req.accessToken.userId = employeeId;
} catch (e) {
await tx.rollback();
+ ctx.req.accessToken.userId = employeeId;
throw e;
}
});
diff --git a/modules/client/back/methods/client/specs/updateFiscalData.spec.js b/modules/client/back/methods/client/specs/updateFiscalData.spec.js
index 7c0bc0599..a08f97faf 100644
--- a/modules/client/back/methods/client/specs/updateFiscalData.spec.js
+++ b/modules/client/back/methods/client/specs/updateFiscalData.spec.js
@@ -1,10 +1,25 @@
const models = require('vn-loopback/server/server').models;
+const LoopBackContext = require('loopback-context');
describe('Client updateFiscalData', () => {
const clientId = 1101;
const employeeId = 1;
const salesAssistantId = 21;
const administrativeId = 5;
+ const activeCtx = {
+ accessToken: {userId: employeeId},
+ http: {
+ req: {
+ headers: {origin: 'http://localhost'}
+ }
+ }
+ };
+
+ beforeEach(() => {
+ spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
+ active: activeCtx
+ });
+ });
it('should return an error if the user is not salesAssistant and the isTaxDataChecked value is true', async() => {
const tx = await models.Client.beginTransaction({});
@@ -24,7 +39,7 @@ describe('Client updateFiscalData', () => {
error = e;
}
- expect(error.message).toEqual(`You can't make changes on a client with verified data`);
+ expect(error.message).toEqual(`Not enough privileges to edit a client with verified data`);
});
it('should return an error if the salesAssistant did not fill the sage data before checking verified data', async() => {
diff --git a/modules/client/back/methods/client/specs/updatePortfolio.spec.js b/modules/client/back/methods/client/specs/updatePortfolio.spec.js
index 4830156fc..f56555c08 100644
--- a/modules/client/back/methods/client/specs/updatePortfolio.spec.js
+++ b/modules/client/back/methods/client/specs/updatePortfolio.spec.js
@@ -12,11 +12,13 @@ describe('Client updatePortfolio', () => {
const expectedResult = 841.63;
- await models.Client.rawSql(`UPDATE vn.client SET salesPersonFk = ${salesPersonId} WHERE id = ${clientId}; `);
+ const clientQuery = `UPDATE vn.client SET salesPersonFk = ${salesPersonId} WHERE id = ${clientId}; `;
+ await models.Client.rawSql(clientQuery);
await models.Client.updatePortfolio();
- let [salesPerson] = await models.Client.rawSql(`SELECT portfolioWeight FROM bs.salesPerson WHERE workerFk = ${salesPersonId}; `, null, options);
+ const portfolioQuery = `SELECT portfolioWeight FROM bs.salesPerson WHERE workerFk = ${salesPersonId}; `;
+ const [salesPerson] = await models.Client.rawSql(portfolioQuery, null, options);
expect(salesPerson.portfolioWeight).toEqual(expectedResult);
@@ -26,8 +28,9 @@ describe('Client updatePortfolio', () => {
throw e;
}
});
- // task 3817
- xit('should keep the same portfolioWeight when a salesperson is unassigned of a client', async() => {
+
+ it('should keep the same portfolioWeight when a salesperson is unassigned of a client', async() => {
+ pending('task 3817');
const salesPersonId = 19;
const tx = await models.Client.beginTransaction({});
@@ -40,7 +43,8 @@ describe('Client updatePortfolio', () => {
await models.Client.updatePortfolio();
- let [salesPerson] = await models.Client.rawSql(`SELECT portfolioWeight FROM bs.salesPerson WHERE workerFk = ${salesPersonId}; `, null, options);
+ const portfolioQuery = `SELECT portfolioWeight FROM bs.salesPerson WHERE workerFk = ${salesPersonId}; `;
+ const [salesPerson] = await models.Client.rawSql(portfolioQuery, null, options);
expect(salesPerson.portfolioWeight).toEqual(expectedResult);
diff --git a/modules/client/back/methods/client/updateAddress.js b/modules/client/back/methods/client/updateAddress.js
index d7e20b876..cae797f6b 100644
--- a/modules/client/back/methods/client/updateAddress.js
+++ b/modules/client/back/methods/client/updateAddress.js
@@ -89,11 +89,12 @@ module.exports = function(Self) {
const args = ctx.args;
const userId = ctx.req.accessToken.userId;
const myOptions = {};
- const isSalesAssistant = await models.Account.hasRole(userId, 'salesAssistant', myOptions);
if (typeof options == 'object')
Object.assign(myOptions, options);
+ const isSalesAssistant = await models.Account.hasRole(userId, 'salesAssistant', myOptions);
+
if (args.isLogifloraAllowed && !isSalesAssistant)
throw new UserError(`You don't have enough privileges`);
diff --git a/modules/client/back/methods/client/updateFiscalData.js b/modules/client/back/methods/client/updateFiscalData.js
index 539d89d3a..7ae842c6e 100644
--- a/modules/client/back/methods/client/updateFiscalData.js
+++ b/modules/client/back/methods/client/updateFiscalData.js
@@ -129,7 +129,7 @@ module.exports = Self => {
const client = await models.Client.findById(clientId, null, myOptions);
if (!isSalesAssistant && client.isTaxDataChecked)
- throw new UserError(`You can't make changes on a client with verified data`);
+ throw new UserError(`Not enough privileges to edit a client with verified data`);
// Sage data validation
const taxDataChecked = args.isTaxDataChecked;
diff --git a/modules/client/back/methods/sms/send.js b/modules/client/back/methods/sms/send.js
index 08daf83a1..94b2b6c27 100644
--- a/modules/client/back/methods/sms/send.js
+++ b/modules/client/back/methods/sms/send.js
@@ -6,10 +6,6 @@ module.exports = Self => {
description: 'Sends SMS to a destination phone',
accessType: 'WRITE',
accepts: [
- {
- arg: 'destinationFk',
- type: 'integer'
- },
{
arg: 'destination',
type: 'string',
@@ -31,7 +27,7 @@ module.exports = Self => {
}
});
- Self.send = async(ctx, destinationFk, destination, message) => {
+ Self.send = async(ctx, destination, message) => {
const userId = ctx.req.accessToken.userId;
const smsConfig = await Self.app.models.SmsConfig.findOne();
@@ -68,7 +64,6 @@ module.exports = Self => {
const newSms = {
senderFk: userId,
- destinationFk: destinationFk || null,
destination: destination,
message: message,
status: error
diff --git a/modules/client/back/methods/sms/send.spec.js b/modules/client/back/methods/sms/send.spec.js
index 7ca78b214..8eee85bd6 100644
--- a/modules/client/back/methods/sms/send.spec.js
+++ b/modules/client/back/methods/sms/send.spec.js
@@ -3,7 +3,7 @@ const app = require('vn-loopback/server/server');
describe('sms send()', () => {
it('should not return status error', async() => {
const ctx = {req: {accessToken: {userId: 1}}};
- const result = await app.models.Sms.send(ctx, 1105, '123456789', 'My SMS Body');
+ const result = await app.models.Sms.send(ctx, '123456789', 'My SMS Body');
expect(result.status).toBeUndefined();
});
diff --git a/modules/client/back/model-config.json b/modules/client/back/model-config.json
index b6bf715b1..4feb3b168 100644
--- a/modules/client/back/model-config.json
+++ b/modules/client/back/model-config.json
@@ -14,6 +14,9 @@
"Client": {
"dataSource": "vn"
},
+ "ClientConfig": {
+ "dataSource": "vn"
+ },
"ClientContact": {
"dataSource": "vn"
},
diff --git a/modules/client/back/models/address-observation.json b/modules/client/back/models/address-observation.json
index 3096c8e5d..2fdb8bc0f 100644
--- a/modules/client/back/models/address-observation.json
+++ b/modules/client/back/models/address-observation.json
@@ -8,7 +8,7 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"id": true,
"description": "Identifier"
},
diff --git a/modules/client/back/models/address.json b/modules/client/back/models/address.json
index dd533cb32..0dcbbf7fe 100644
--- a/modules/client/back/models/address.json
+++ b/modules/client/back/models/address.json
@@ -14,7 +14,7 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"id": true,
"description": "Identifier"
},
@@ -43,10 +43,10 @@
"type": "boolean"
},
"longitude": {
- "type": "Number"
+ "type": "number"
},
"latitude": {
- "type": "Number"
+ "type": "number"
},
"isEqualizated": {
"type": "boolean"
diff --git a/modules/client/back/models/client-config.json b/modules/client/back/models/client-config.json
new file mode 100644
index 000000000..90d47333d
--- /dev/null
+++ b/modules/client/back/models/client-config.json
@@ -0,0 +1,22 @@
+{
+ "name": "ClientConfig",
+ "base": "VnModel",
+ "options": {
+ "mysql": {
+ "table": "clientConfig"
+ }
+ },
+ "properties": {
+ "id": {
+ "type": "number",
+ "id": true,
+ "description": "Identifier"
+ },
+ "riskTolerance": {
+ "type": "number"
+ },
+ "maxCreditRows": {
+ "type": "number"
+ }
+ }
+}
\ No newline at end of file
diff --git a/modules/client/back/models/client-contact.json b/modules/client/back/models/client-contact.json
index ea916c072..514ebbf5e 100644
--- a/modules/client/back/models/client-contact.json
+++ b/modules/client/back/models/client-contact.json
@@ -3,34 +3,34 @@
"description": "Client phone contacts",
"base": "Loggable",
"log": {
- "model": "ClientLog",
- "relation": "client",
- "showField": "name"
+ "model": "ClientLog",
+ "relation": "client",
+ "showField": "name"
},
"options": {
- "mysql": {
- "table": "clientContact"
- }
+ "mysql": {
+ "table": "clientContact"
+ }
},
"validateUpsert": true,
"properties": {
- "id": {
- "type": "Number",
- "id": true,
- "description": "Identifier"
- },
- "name": {
- "type": "string"
- },
- "phone": {
- "type": "string"
- }
+ "id": {
+ "type": "number",
+ "id": true,
+ "description": "Identifier"
+ },
+ "name": {
+ "type": "string"
+ },
+ "phone": {
+ "type": "string"
+ }
},
"relations": {
- "client": {
- "type": "belongsTo",
- "model": "Client",
- "foreignKey": "clientFk"
- }
+ "client": {
+ "type": "belongsTo",
+ "model": "Client",
+ "foreignKey": "clientFk"
+ }
}
- }
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/modules/client/back/models/client-credit-limit.json b/modules/client/back/models/client-credit-limit.json
index 5263fb94b..740f0cf53 100644
--- a/modules/client/back/models/client-credit-limit.json
+++ b/modules/client/back/models/client-credit-limit.json
@@ -1,26 +1,26 @@
{
- "name": "ClientCreditLimit",
- "base": "VnModel",
- "options": {
- "mysql": {
- "table": "clientCreditLimit"
- }
- },
- "properties": {
- "id": {
- "type": "Number",
- "id": true,
- "description": "Identifier"
+ "name": "ClientCreditLimit",
+ "base": "VnModel",
+ "options": {
+ "mysql": {
+ "table": "clientCreditLimit"
+ }
},
- "maxAmount": {
- "type": "Number"
+ "properties": {
+ "id": {
+ "type": "number",
+ "id": true,
+ "description": "Identifier"
+ },
+ "maxAmount": {
+ "type": "number"
+ }
+ },
+ "relations": {
+ "role": {
+ "type": "belongsTo",
+ "model": "Role",
+ "foreignKey": "roleFk"
+ }
}
- },
- "relations": {
- "role": {
- "type": "belongsTo",
- "model": "Role",
- "foreignKey": "roleFk"
- }
- }
}
\ No newline at end of file
diff --git a/modules/client/back/models/client-credit.js b/modules/client/back/models/client-credit.js
new file mode 100644
index 000000000..01fe8214a
--- /dev/null
+++ b/modules/client/back/models/client-credit.js
@@ -0,0 +1,23 @@
+module.exports = Self => {
+ Self.observe('after save', async ctx => {
+ const instance = ctx.instance;
+ const models = Self.app.models;
+
+ const clientConfig = await models.ClientConfig.findOne();
+ const maxCreditRows = clientConfig.maxCreditRows;
+
+ const clientCredit = await models.ClientCredit.find({
+ where: {clientFk: instance.clientFk},
+ order: 'created DESC',
+ limit: maxCreditRows
+ }, ctx.options);
+
+ const lastCredit = clientCredit[maxCreditRows - 1];
+ if (lastCredit) {
+ await models.ClientCredit.destroyAll({
+ clientFk: instance.clientFk,
+ created: {lt: lastCredit.created}
+ }, ctx.options);
+ }
+ });
+};
diff --git a/modules/client/back/models/client-credit.json b/modules/client/back/models/client-credit.json
index 2b71fbe2d..b92639b80 100644
--- a/modules/client/back/models/client-credit.json
+++ b/modules/client/back/models/client-credit.json
@@ -1,36 +1,36 @@
{
- "name": "ClientCredit",
- "description": "Log of credit changes",
- "base": "VnModel",
- "options": {
- "mysql": {
- "table": "clientCredit"
- }
- },
- "validateUpsert": true,
- "properties": {
- "id": {
- "type": "Number",
- "id": true,
- "description": "Identifier"
+ "name": "ClientCredit",
+ "description": "Log of credit changes",
+ "base": "VnModel",
+ "options": {
+ "mysql": {
+ "table": "clientCredit"
+ }
},
- "amount": {
- "type": "Number"
+ "validateUpsert": true,
+ "properties": {
+ "id": {
+ "type": "number",
+ "id": true,
+ "description": "Identifier"
+ },
+ "amount": {
+ "type": "number"
+ },
+ "created": {
+ "type": "date"
+ }
},
- "created": {
- "type": "date"
+ "relations": {
+ "client": {
+ "type": "belongsTo",
+ "model": "Client",
+ "foreignKey": "clientFk"
+ },
+ "worker": {
+ "type": "belongsTo",
+ "model": "Worker",
+ "foreignKey": "workerFk"
+ }
}
- },
- "relations": {
- "client": {
- "type": "belongsTo",
- "model": "Client",
- "foreignKey": "clientFk"
- },
- "worker": {
- "type": "belongsTo",
- "model": "Worker",
- "foreignKey": "workerFk"
- }
- }
}
\ No newline at end of file
diff --git a/modules/client/back/models/client-dms.json b/modules/client/back/models/client-dms.json
index 28ad21917..88b4349df 100644
--- a/modules/client/back/models/client-dms.json
+++ b/modules/client/back/models/client-dms.json
@@ -13,12 +13,12 @@
},
"properties": {
"dmsFk": {
- "type": "Number",
+ "type": "number",
"id": true,
"required": true
},
"clientFk": {
- "type": "Number",
+ "type": "number",
"required": true
}
},
diff --git a/modules/client/back/models/client-log.json b/modules/client/back/models/client-log.json
index 50c892e85..9c0933c0c 100644
--- a/modules/client/back/models/client-log.json
+++ b/modules/client/back/models/client-log.json
@@ -9,40 +9,40 @@
"properties": {
"id": {
"id": true,
- "type": "Number",
+ "type": "number",
"forceId": false
},
"originFk": {
- "type": "Number",
+ "type": "number",
"required": true
},
"userFk": {
- "type": "Number"
+ "type": "number"
},
"action": {
- "type": "String",
+ "type": "string",
"required": true
},
"changedModel": {
- "type": "String"
+ "type": "string"
},
"oldInstance": {
- "type": "Object"
+ "type": "object"
},
"newInstance": {
- "type": "Object"
+ "type": "object"
},
"creationDate": {
- "type": "Date"
+ "type": "date"
},
"changedModelId": {
- "type": "Number"
+ "type": "number"
},
"changedModelValue": {
- "type": "String"
+ "type": "string"
},
"description": {
- "type": "String"
+ "type": "string"
}
},
"relations": {
diff --git a/modules/client/back/models/client-observation.json b/modules/client/back/models/client-observation.json
index a9c7b483a..d3059377d 100644
--- a/modules/client/back/models/client-observation.json
+++ b/modules/client/back/models/client-observation.json
@@ -13,12 +13,12 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"id": true,
"description": "Identifier"
},
"clientFk": {
- "type": "Number"
+ "type": "number"
},
"text": {
"type": "string",
diff --git a/modules/client/back/models/client-risk.json b/modules/client/back/models/client-risk.json
index f76483fca..eac36affb 100644
--- a/modules/client/back/models/client-risk.json
+++ b/modules/client/back/models/client-risk.json
@@ -2,22 +2,22 @@
"name": "ClientRisk",
"base": "VnModel",
"options": {
- "mysql": {
- "table": "clientRisk"
- }
+ "mysql": {
+ "table": "clientRisk"
+ }
},
"properties": {
- "clientFk": {
- "type": "Number",
- "id": true
- },
- "companyFk": {
- "type": "Number",
- "id": true
- },
- "amount": {
- "type": "Number"
- }
+ "clientFk": {
+ "type": "number",
+ "id": true
+ },
+ "companyFk": {
+ "type": "number",
+ "id": true
+ },
+ "amount": {
+ "type": "number"
+ }
},
"relations": {
"client": {
@@ -31,4 +31,4 @@
"foreignKey": "companyFk"
}
}
- }
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/modules/client/back/models/client-sample.json b/modules/client/back/models/client-sample.json
index 812da8be8..920758217 100644
--- a/modules/client/back/models/client-sample.json
+++ b/modules/client/back/models/client-sample.json
@@ -14,7 +14,7 @@
"properties": {
"id": {
"id": true,
- "type": "Number",
+ "type": "number",
"description": "Identifier"
},
"created": {
diff --git a/modules/client/back/models/client-type.json b/modules/client/back/models/client-type.json
index a91cc38b6..eeae845eb 100644
--- a/modules/client/back/models/client-type.json
+++ b/modules/client/back/models/client-type.json
@@ -8,17 +8,17 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"id": true
},
"code": {
- "type": "String"
+ "type": "string"
},
"type": {
- "type": "String"
+ "type": "string"
},
"isCreatedAsServed": {
- "type": "Number"
+ "type": "number"
}
}
}
\ No newline at end of file
diff --git a/modules/client/back/models/client-unpaid.json b/modules/client/back/models/client-unpaid.json
index a3d1a684c..0fc3a9195 100644
--- a/modules/client/back/models/client-unpaid.json
+++ b/modules/client/back/models/client-unpaid.json
@@ -2,21 +2,21 @@
"name": "ClientUnpaid",
"base": "VnModel",
"options": {
- "mysql": {
- "table": "clientUnpaid"
- }
+ "mysql": {
+ "table": "clientUnpaid"
+ }
},
"properties": {
- "clientFk": {
- "type": "number",
- "id": true
- },
- "dated": {
- "type": "date"
- },
- "amount": {
- "type": "Number"
- }
+ "clientFk": {
+ "type": "number",
+ "id": true
+ },
+ "dated": {
+ "type": "date"
+ },
+ "amount": {
+ "type": "number"
+ }
},
"relations": {
"client": {
diff --git a/modules/client/back/models/client.js b/modules/client/back/models/client.js
index 5ccc1ec64..90a9b9e23 100644
--- a/modules/client/back/models/client.js
+++ b/modules/client/back/models/client.js
@@ -31,6 +31,7 @@ module.exports = Self => {
require('../methods/client/createReceipt')(Self);
require('../methods/client/updatePortfolio')(Self);
require('../methods/client/checkDuplicated')(Self);
+ require('../methods/client/extendedListFilter')(Self);
// Validations
@@ -46,10 +47,6 @@ module.exports = Self => {
message: 'TIN must be unique'
});
- Self.validatesUniquenessOf('socialName', {
- message: 'The company name must be unique'
- });
-
Self.validatesFormatOf('email', {
message: 'Invalid email',
allowNull: true,
@@ -63,17 +60,37 @@ module.exports = Self => {
min: 3, max: 10
});
+ Self.validateAsync('socialName', socialNameIsUnique, {
+ message: 'The company name must be unique'
+ });
+
+ async function socialNameIsUnique(err, done) {
+ const filter = {
+ where: {
+ and: [
+ {socialName: this.socialName},
+ {isActive: true},
+ {id: {neq: this.id}}
+ ]
+ }
+ };
+ const client = await Self.app.models.Client.findOne(filter);
+ if (client)
+ err();
+ done();
+ }
+
Self.validateAsync('iban', ibanNeedsValidation, {
message: 'The IBAN does not have the correct format'
});
async function ibanNeedsValidation(err, done) {
- let filter = {
+ const filter = {
fields: ['code'],
where: {id: this.countryFk}
};
- let country = await Self.app.models.Country.findOne(filter);
- let code = country ? country.code.toLowerCase() : null;
+ const country = await Self.app.models.Country.findOne(filter);
+ const code = country ? country.code.toLowerCase() : null;
if (code != 'es')
return done();
@@ -90,12 +107,12 @@ module.exports = Self => {
if (!this.isTaxDataChecked)
return done();
- let filter = {
+ const filter = {
fields: ['code'],
where: {id: this.countryFk}
};
- let country = await Self.app.models.Country.findOne(filter);
- let code = country ? country.code.toLowerCase() : null;
+ const country = await Self.app.models.Country.findOne(filter);
+ const code = country ? country.code.toLowerCase() : null;
if (!this.fi || !validateTin(this.fi, code))
err();
@@ -118,8 +135,8 @@ module.exports = Self => {
function cannotHaveET(err) {
if (!this.fi) return;
- let tin = this.fi.toUpperCase();
- let cannotHaveET = /^[A-B]/.test(tin);
+ const tin = this.fi.toUpperCase();
+ const cannotHaveET = /^[A-B]/.test(tin);
if (cannotHaveET && this.isEqualizated)
err();
@@ -208,6 +225,33 @@ module.exports = Self => {
throw new UserError(`The type of business must be filled in basic data`);
});
+ Self.observe('before save', async ctx => {
+ const changes = ctx.data || ctx.instance;
+ const orgData = ctx.currentInstance;
+ const models = Self.app.models;
+
+ const loopBackContext = LoopBackContext.getCurrentContext();
+ const userId = loopBackContext.active.accessToken.userId;
+
+ const isSalesAssistant = await models.Account.hasRole(userId, 'salesAssistant', ctx.options);
+ const hasChanges = orgData && changes;
+
+ const isTaxDataChecked = hasChanges && (changes.isTaxDataChecked || orgData.isTaxDataChecked);
+ const isTaxDataCheckedChanged = hasChanges && orgData.isTaxDataChecked != isTaxDataChecked;
+
+ const sageTaxType = hasChanges && (changes.sageTaxTypeFk || orgData.sageTaxTypeFk);
+ const sageTaxTypeChanged = hasChanges && orgData.sageTaxTypeFk != sageTaxType;
+
+ const sageTransactionType = hasChanges && (changes.sageTransactionTypeFk || orgData.sageTransactionTypeFk);
+ const sageTransactionTypeChanged = hasChanges && orgData.sageTransactionTypeFk != sageTransactionType;
+
+ const cantEditVerifiedData = isTaxDataCheckedChanged && !isSalesAssistant;
+ const cantChangeSageData = (sageTaxTypeChanged || sageTransactionTypeChanged) && !isSalesAssistant;
+
+ if (cantEditVerifiedData || cantChangeSageData)
+ throw new UserError(`You don't have enough privileges`);
+ });
+
Self.observe('before save', async function(ctx) {
const changes = ctx.data || ctx.instance;
const orgData = ctx.currentInstance;
@@ -221,10 +265,10 @@ module.exports = Self => {
const socialNameChanged = hasChanges
&& orgData.socialName != socialName;
- const dataCheckedChanged = hasChanges
+ const isTaxDataCheckedChanged = hasChanges
&& orgData.isTaxDataChecked != isTaxDataChecked;
- if ((socialNameChanged || dataCheckedChanged) && !isAlpha(socialName))
+ if ((socialNameChanged || isTaxDataCheckedChanged) && !isAlpha(socialName))
throw new UserError(`The social name has an invalid format`);
if (changes.salesPerson === null) {
diff --git a/modules/client/back/models/client.json b/modules/client/back/models/client.json
index 6404cfba0..b9951e8bb 100644
--- a/modules/client/back/models/client.json
+++ b/modules/client/back/models/client.json
@@ -12,7 +12,7 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"id": true,
"description": "Identifier"
},
@@ -55,16 +55,16 @@
"type": "boolean"
},
"credit": {
- "type": "Number"
+ "type": "number"
},
"creditInsurance": {
- "type": "Number"
+ "type": "number"
},
"iban": {
"type": "string"
},
"dueDay": {
- "type": "Number"
+ "type": "number"
},
"isEqualizated": {
"type": "boolean",
@@ -105,7 +105,7 @@
"type": "boolean"
},
"quality": {
- "type": "Number"
+ "type": "number"
},
"isVies": {
"type": "boolean"
@@ -117,7 +117,7 @@
"type": "string"
},
"created": {
- "type": "Date"
+ "type": "date"
},
"sageTaxTypeFk": {
"type": "number",
diff --git a/modules/client/back/models/contact-channel.json b/modules/client/back/models/contact-channel.json
index 3a5de2140..75151b9f9 100644
--- a/modules/client/back/models/contact-channel.json
+++ b/modules/client/back/models/contact-channel.json
@@ -1,20 +1,20 @@
{
- "name": "ContactChannel",
- "base": "VnModel",
- "options": {
- "mysql": {
- "table": "contactChannel"
- }
- },
- "properties": {
- "id": {
- "type": "Number",
- "id": true,
- "description": "Identifier"
+ "name": "ContactChannel",
+ "base": "VnModel",
+ "options": {
+ "mysql": {
+ "table": "contactChannel"
+ }
},
- "name": {
- "type": "string",
- "required": true
+ "properties": {
+ "id": {
+ "type": "number",
+ "id": true,
+ "description": "Identifier"
+ },
+ "name": {
+ "type": "string",
+ "required": true
+ }
}
- }
}
\ No newline at end of file
diff --git a/modules/client/back/models/credit-classification.json b/modules/client/back/models/credit-classification.json
index 2e636af63..543f8359e 100644
--- a/modules/client/back/models/credit-classification.json
+++ b/modules/client/back/models/credit-classification.json
@@ -1,42 +1,42 @@
{
- "name": "CreditClassification",
- "description": "Clasified clients",
- "base": "VnModel",
- "options": {
- "mysql": {
- "table": "creditClassification"
- }
- },
- "properties": {
- "id": {
- "id": true,
- "type": "Number",
- "description": "Identifier"
+ "name": "CreditClassification",
+ "description": "Clasified clients",
+ "base": "VnModel",
+ "options": {
+ "mysql": {
+ "table": "creditClassification"
+ }
},
- "started": {
- "type": "date",
- "required": true,
- "mysql": {
- "columnName": "dateStart"
- }
+ "properties": {
+ "id": {
+ "id": true,
+ "type": "number",
+ "description": "Identifier"
+ },
+ "started": {
+ "type": "date",
+ "required": true,
+ "mysql": {
+ "columnName": "dateStart"
+ }
+ },
+ "finished": {
+ "type": "date",
+ "mysql": {
+ "columnName": "dateEnd"
+ }
+ }
},
- "finished": {
- "type": "date",
- "mysql": {
- "columnName": "dateEnd"
- }
+ "relations": {
+ "customer": {
+ "type": "belongsTo",
+ "model": "Client",
+ "foreignKey": "client"
+ },
+ "insurances": {
+ "type": "hasMany",
+ "model": "CreditInsurance",
+ "foreignKey": "creditClassification"
+ }
}
- },
- "relations": {
- "customer": {
- "type": "belongsTo",
- "model": "Client",
- "foreignKey": "client"
- },
- "insurances": {
- "type": "hasMany",
- "model": "CreditInsurance",
- "foreignKey": "creditClassification"
- }
- }
-}
+}
\ No newline at end of file
diff --git a/modules/client/back/models/credit-insurance.json b/modules/client/back/models/credit-insurance.json
index 6a9d04677..db4154978 100644
--- a/modules/client/back/models/credit-insurance.json
+++ b/modules/client/back/models/credit-insurance.json
@@ -10,11 +10,11 @@
"properties": {
"id": {
"id": true,
- "type": "Number",
+ "type": "number",
"description": "Identifier"
},
"credit": {
- "type": "Number"
+ "type": "number"
},
"created": {
"type": "date",
@@ -23,7 +23,7 @@
}
},
"grade": {
- "type": "Number"
+ "type": "number"
}
},
"relations": {
diff --git a/modules/client/back/models/customs-agent.json b/modules/client/back/models/customs-agent.json
index f72d7bf28..3a2e0258f 100644
--- a/modules/client/back/models/customs-agent.json
+++ b/modules/client/back/models/customs-agent.json
@@ -8,26 +8,26 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"description": "Identifier",
"id": true
},
"fiscalName": {
- "type": "String",
+ "type": "string",
"required": true
},
"street": {
- "type": "String"
+ "type": "string"
},
"nif": {
- "type": "String",
+ "type": "string",
"required": true
},
"phone": {
- "type": "String"
+ "type": "string"
},
"email": {
- "type": "String"
+ "type": "string"
}
}
}
\ No newline at end of file
diff --git a/modules/client/back/models/defaulter.json b/modules/client/back/models/defaulter.json
index 829326435..ddff1d214 100644
--- a/modules/client/back/models/defaulter.json
+++ b/modules/client/back/models/defaulter.json
@@ -9,19 +9,19 @@
},
"properties": {
"id": {
- "type": "Number"
+ "type": "number"
},
"created": {
- "type": "Date"
+ "type": "date"
},
"amount": {
- "type": "Number"
+ "type": "number"
},
"defaulterSinced": {
- "type": "Number"
+ "type": "number"
},
"hasChanged": {
- "type": "Number"
+ "type": "number"
}
},
"relations": {
diff --git a/modules/client/back/models/greuge-config.json b/modules/client/back/models/greuge-config.json
index b72348023..1ba66668d 100644
--- a/modules/client/back/models/greuge-config.json
+++ b/modules/client/back/models/greuge-config.json
@@ -8,7 +8,7 @@
},
"properties": {
"freightPickUpPrice": {
- "type": "Number"
+ "type": "number"
}
},
"acls": [{
diff --git a/modules/client/back/models/greuge-type.json b/modules/client/back/models/greuge-type.json
index 5c5b1870d..36b14e147 100644
--- a/modules/client/back/models/greuge-type.json
+++ b/modules/client/back/models/greuge-type.json
@@ -9,14 +9,14 @@
"properties": {
"id": {
"id": true,
- "type": "Number",
+ "type": "number",
"description": "Identifier"
},
"name": {
- "type": "String"
+ "type": "string"
},
"code": {
- "type": "String"
+ "type": "string"
}
},
"acls": [
diff --git a/modules/client/back/models/greuge.json b/modules/client/back/models/greuge.json
index 2abc33f7c..918ff0ca5 100644
--- a/modules/client/back/models/greuge.json
+++ b/modules/client/back/models/greuge.json
@@ -14,15 +14,15 @@
"properties": {
"id": {
"id": true,
- "type": "Number",
+ "type": "number",
"description": "Identifier"
},
"description": {
- "type": "String",
+ "type": "string",
"required": true
},
"amount": {
- "type": "Number",
+ "type": "number",
"required": true
},
"shipped": {
@@ -32,7 +32,7 @@
"type": "date"
},
"greugeTypeFk": {
- "type": "Number",
+ "type": "number",
"required": true
}
diff --git a/modules/client/back/models/incoterms.json b/modules/client/back/models/incoterms.json
index 915a5b59a..fdf743c14 100644
--- a/modules/client/back/models/incoterms.json
+++ b/modules/client/back/models/incoterms.json
@@ -8,12 +8,12 @@
},
"properties": {
"code": {
- "type": "String",
+ "type": "string",
"description": "Identifier",
"id": true
},
"name": {
- "type": "String"
+ "type": "string"
}
},
"acls": [
diff --git a/modules/client/back/models/mandate-type.json b/modules/client/back/models/mandate-type.json
index 8bd46ce19..ec189f089 100644
--- a/modules/client/back/models/mandate-type.json
+++ b/modules/client/back/models/mandate-type.json
@@ -9,11 +9,11 @@
"properties": {
"id": {
"id": true,
- "type": "Number",
+ "type": "number",
"description": "Identifier"
},
"name": {
- "type": "String"
+ "type": "string"
}
}
}
\ No newline at end of file
diff --git a/modules/client/back/models/mandate.json b/modules/client/back/models/mandate.json
index a671c45f1..914b23ce2 100644
--- a/modules/client/back/models/mandate.json
+++ b/modules/client/back/models/mandate.json
@@ -9,11 +9,11 @@
"properties": {
"id": {
"id": true,
- "type": "Number",
+ "type": "number",
"description": "Identifier"
},
"code": {
- "type": "String"
+ "type": "string"
},
"created": {
"type": "date"
diff --git a/modules/client/back/models/observation-type.json b/modules/client/back/models/observation-type.json
index 5a7bdcfdd..474c5faac 100644
--- a/modules/client/back/models/observation-type.json
+++ b/modules/client/back/models/observation-type.json
@@ -9,15 +9,15 @@
"properties": {
"id": {
"id": true,
- "type": "Number",
+ "type": "number",
"description": "Identifier"
},
"description": {
- "type": "String",
+ "type": "string",
"required": true
},
"code": {
- "type": "String",
+ "type": "string",
"required": true
}
},
diff --git a/modules/client/back/models/pay-method.json b/modules/client/back/models/pay-method.json
index 4080a0953..c83c21e2f 100644
--- a/modules/client/back/models/pay-method.json
+++ b/modules/client/back/models/pay-method.json
@@ -8,7 +8,7 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"id": true,
"description": "Identifier"
},
@@ -23,7 +23,7 @@
"type": "string"
},
"outstandingDebt": {
- "type": "Number"
+ "type": "number"
},
"isIbanRequiredForClients": {
"type": "boolean"
diff --git a/modules/client/back/models/recovery.json b/modules/client/back/models/recovery.json
index 5a26cd842..de4183924 100644
--- a/modules/client/back/models/recovery.json
+++ b/modules/client/back/models/recovery.json
@@ -2,40 +2,40 @@
"name": "Recovery",
"base": "Loggable",
"log": {
- "model": "ClientLog",
- "relation": "client"
+ "model": "ClientLog",
+ "relation": "client"
},
"options": {
- "mysql": {
- "table": "recovery"
- }
+ "mysql": {
+ "table": "recovery"
+ }
},
"properties": {
- "id": {
- "id": true,
- "type": "Number",
- "description": "Identifier"
- },
- "started": {
- "type": "date",
- "required": true
- },
- "finished": {
- "type": "date"
- },
- "amount": {
- "type": "Number",
- "required": true
- },
- "period": {
- "type": "Number"
- }
+ "id": {
+ "id": true,
+ "type": "number",
+ "description": "Identifier"
+ },
+ "started": {
+ "type": "date",
+ "required": true
+ },
+ "finished": {
+ "type": "date"
+ },
+ "amount": {
+ "type": "number",
+ "required": true
+ },
+ "period": {
+ "type": "number"
+ }
},
"relations": {
- "client": {
- "type": "belongsTo",
- "model": "Client",
- "foreignKey": "clientFk"
- }
+ "client": {
+ "type": "belongsTo",
+ "model": "Client",
+ "foreignKey": "clientFk"
+ }
}
- }
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/modules/client/back/models/sage-tax-type.json b/modules/client/back/models/sage-tax-type.json
index b60ef20cd..97af7353c 100644
--- a/modules/client/back/models/sage-tax-type.json
+++ b/modules/client/back/models/sage-tax-type.json
@@ -8,7 +8,7 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"id": true,
"description": "Identifier",
"mysql": {
diff --git a/modules/client/back/models/sage-transaction-type.json b/modules/client/back/models/sage-transaction-type.json
index dbe8f3b39..1903c650c 100644
--- a/modules/client/back/models/sage-transaction-type.json
+++ b/modules/client/back/models/sage-transaction-type.json
@@ -8,7 +8,7 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"id": true,
"description": "Identifier",
"mysql": {
diff --git a/modules/client/back/models/sms-config.json b/modules/client/back/models/sms-config.json
index f48c6198d..ba78e4a8d 100644
--- a/modules/client/back/models/sms-config.json
+++ b/modules/client/back/models/sms-config.json
@@ -9,18 +9,18 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"id": true,
"description": "Identifier"
},
"uri": {
- "type": "String"
+ "type": "string"
},
"apiKey": {
- "type": "String"
+ "type": "string"
},
"title": {
- "type": "String"
+ "type": "string"
}
}
}
diff --git a/modules/client/back/models/sms.json b/modules/client/back/models/sms.json
index e6e6ff64c..29438fc67 100644
--- a/modules/client/back/models/sms.json
+++ b/modules/client/back/models/sms.json
@@ -9,30 +9,30 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"id": true,
"description": "Identifier"
},
"sender": {
- "type": "String",
+ "type": "string",
"required": true
},
"destination": {
- "type": "String",
+ "type": "string",
"required": true
},
"message": {
- "type": "String",
+ "type": "string",
"required": true
},
"statusCode": {
- "type": "Number"
+ "type": "number"
},
"status": {
- "type": "String"
+ "type": "string"
},
"created": {
- "type": "Date"
+ "type": "date"
}
},
"relations": {
diff --git a/modules/client/back/models/specs/address.spec.js b/modules/client/back/models/specs/address.spec.js
index cae18258f..f0b421d35 100644
--- a/modules/client/back/models/specs/address.spec.js
+++ b/modules/client/back/models/specs/address.spec.js
@@ -1,20 +1,36 @@
-const app = require('vn-loopback/server/server');
+const models = require('vn-loopback/server/server').models;
+const LoopBackContext = require('loopback-context');
describe('loopback model address', () => {
let createdAddressId;
const clientId = 1101;
- afterAll(async() => {
- let client = await app.models.Client.findById(clientId);
+ const activeCtx = {
+ accessToken: {userId: 9},
+ http: {
+ req: {
+ headers: {origin: 'http://localhost'}
+ }
+ }
+ };
- await app.models.Address.destroyById(createdAddressId);
+ beforeAll(() => {
+ spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
+ active: activeCtx
+ });
+ });
+
+ afterAll(async() => {
+ const client = await models.Client.findById(clientId);
+
+ await models.Address.destroyById(createdAddressId);
await client.updateAttribute('isEqualizated', false);
});
describe('observe()', () => {
it('should throw an error when deactivating a consignee if its the default address', async() => {
let error;
- let address = await app.models.Address.findById(1);
+ const address = await models.Address.findById(1);
await address.updateAttribute('isActive', false)
.catch(e => {
@@ -27,13 +43,13 @@ describe('loopback model address', () => {
});
it('should set isEqualizated to true of a given Client to trigger any new address to have it', async() => {
- let client = await app.models.Client.findById(clientId);
+ const client = await models.Client.findById(clientId);
expect(client.isEqualizated).toBeFalsy();
await client.updateAttribute('isEqualizated', true);
- let newAddress = await app.models.Address.create({
+ const newAddress = await models.Address.create({
clientFk: clientId,
agencyModeFk: 5,
city: 'here',
diff --git a/modules/client/back/models/specs/clientCredit.spec.js b/modules/client/back/models/specs/clientCredit.spec.js
new file mode 100644
index 000000000..fcd86c979
--- /dev/null
+++ b/modules/client/back/models/specs/clientCredit.spec.js
@@ -0,0 +1,53 @@
+const models = require('vn-loopback/server/server').models;
+
+describe('Client Credit', () => {
+ const instance = {id: 1101, name: 'Bruce Banner'};
+
+ describe('after save', () => {
+ it('should delete old rows of clientCredit', async() => {
+ const tx = await models.ClientCredit.beginTransaction({});
+ const clientConfig = await models.ClientConfig.findOne({
+ where: {id: 1}
+ });
+
+ let rowsBefore;
+ let rowsAfter;
+
+ try {
+ const options = {transaction: tx};
+ const salesAssistant = await models.Account.findOne({
+ where: {name: 'salesAssistant'}
+ }, options);
+
+ rowsBefore = await models.ClientCredit.find({
+ where: {clientFk: instance.id},
+ order: 'created DESC',
+ }, options);
+
+ await models.ClientCredit.create({
+ amount: 355,
+ clientFk: instance.id,
+ workerFk: salesAssistant.id
+ }, options);
+
+ rowsAfter = await models.ClientCredit.find({
+ where: {clientFk: instance.id},
+ order: 'created DESC',
+ }, options);
+
+ await tx.rollback();
+ } catch (e) {
+ await tx.rollback();
+ throw e;
+ }
+
+ const FirstRowsBefore = rowsBefore[0];
+ const FirstRowsAfter = rowsAfter[0];
+
+ expect(FirstRowsAfter.id).toBeGreaterThan(FirstRowsBefore.id);
+
+ expect(rowsBefore.length).toBeGreaterThanOrEqual(clientConfig.maxCreditRows);
+ expect(rowsAfter.length).toEqual(clientConfig.maxCreditRows);
+ });
+ });
+});
diff --git a/modules/client/back/models/tpv-error.json b/modules/client/back/models/tpv-error.json
index 61e2a7156..d62203f40 100644
--- a/modules/client/back/models/tpv-error.json
+++ b/modules/client/back/models/tpv-error.json
@@ -8,7 +8,7 @@
},
"properties": {
"code": {
- "type": "String",
+ "type": "string",
"id": true,
"description": "Identifier"
},
diff --git a/modules/client/back/models/tpv-merchant.json b/modules/client/back/models/tpv-merchant.json
index db5c937d8..d4dba6cb1 100644
--- a/modules/client/back/models/tpv-merchant.json
+++ b/modules/client/back/models/tpv-merchant.json
@@ -8,7 +8,7 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"id": true,
"description": "Identifier"
},
diff --git a/modules/client/back/models/tpv-response.json b/modules/client/back/models/tpv-response.json
index d3a382b5f..674ba434c 100644
--- a/modules/client/back/models/tpv-response.json
+++ b/modules/client/back/models/tpv-response.json
@@ -8,7 +8,7 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"id": true,
"description": "Identifier"
},
diff --git a/modules/client/back/models/tpv-transaction.json b/modules/client/back/models/tpv-transaction.json
index 011616d98..2d926cc40 100644
--- a/modules/client/back/models/tpv-transaction.json
+++ b/modules/client/back/models/tpv-transaction.json
@@ -8,33 +8,33 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"id": true,
"description": "Identifier"
},
"merchantFk": {
- "type": "Number"
+ "type": "number"
},
"clientFk": {
- "type": "Number"
+ "type": "number"
},
"receiptFk": {
- "type": "Number"
+ "type": "number"
},
"amount": {
- "type": "Number"
+ "type": "number"
},
"response": {
- "type": "Number"
+ "type": "number"
},
"errorCode": {
- "type": "String"
+ "type": "string"
},
"status": {
- "type": "String"
+ "type": "string"
},
"created": {
- "type": "Date"
+ "type": "date"
}
},
"relations": {
diff --git a/modules/client/front/balance/create/index.js b/modules/client/front/balance/create/index.js
index 454e5e44d..c6a6e7ff9 100644
--- a/modules/client/front/balance/create/index.js
+++ b/modules/client/front/balance/create/index.js
@@ -6,12 +6,7 @@ class Controller extends Dialog {
super($element, $, $transclude);
this.vnReport = vnReport;
-
- const tomorrow = new Date();
- tomorrow.setDate(tomorrow.getDate() + 1);
- this.receipt = {
- payed: tomorrow
- };
+ this.receipt = {};
}
set payed(value) {
@@ -72,6 +67,10 @@ class Controller extends Dialog {
`${accountingType && accountingType.receiptDescription}`;
}
this.maxAmount = accountingType && accountingType.maxAmount;
+
+ this.receipt.payed = new Date();
+ if (accountingType.daysInFuture)
+ this.receipt.payed.setDate(this.receipt.payed.getDate() + accountingType.daysInFuture);
}
}
diff --git a/modules/client/front/descriptor/index.html b/modules/client/front/descriptor/index.html
index de7a86d3b..cad226416 100644
--- a/modules/client/front/descriptor/index.html
+++ b/modules/client/front/descriptor/index.html
@@ -105,7 +105,7 @@
diff --git a/modules/client/front/descriptor/locale/es.yml b/modules/client/front/descriptor/locale/es.yml
index e6aca9665..71723e654 100644
--- a/modules/client/front/descriptor/locale/es.yml
+++ b/modules/client/front/descriptor/locale/es.yml
@@ -3,5 +3,6 @@ View consumer report: Ver informe de consumo
From date: Fecha desde
To date: Fecha hasta
Go to user: Ir al usuario
+Go to supplier: Ir al proveedor
Client invoices list: Listado de facturas del cliente
Pay method: Forma de pago
\ No newline at end of file
diff --git a/modules/client/front/extended-list/index.html b/modules/client/front/extended-list/index.html
new file mode 100644
index 000000000..b45a0bc5f
--- /dev/null
+++ b/modules/client/front/extended-list/index.html
@@ -0,0 +1,319 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Identifier
+
+
+ Name
+
+
+ Social name
+
+
+ Tax number
+
+
+ Salesperson
+
+
+ Credit
+
+
+ Credit insurance
+
+
+ Phone
+
+
+ Mobile
+
+
+ Street
+
+
+ Country
+
+
+ Province
+
+
+ City
+
+
+ Postcode
+
+
+ Email
+
+
+ Created
+
+
+ Business type
+
+
+ Billing data
+
+
+ Sage tax type
+
+
+ Sage tr. type
+
+
+ Active
+
+
+ Vies
+
+
+ Verified data
+
+
+ Is equalizated
+
+
+ Freezed
+
+
+ Invoice
+
+
+ Invoice by address
+
+
+ Mailing
+
+
+ Received LCR
+
+
+ Received core VNL
+
+
+ Received B2B VNL
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{::client.id}}
+
+
+ {{::client.name}}
+ {{::client.socialName}}
+ {{::client.fi}}
+
+
+ {{::client.salesPerson | dashIfEmpty}}
+
+
+ {{::client.credit}}
+ {{::client.creditInsurance | dashIfEmpty}}
+ {{::client.phone | dashIfEmpty}}
+ {{::client.mobile | dashIfEmpty}}
+ {{::client.street | dashIfEmpty}}
+ {{::client.country | dashIfEmpty}}
+ {{::client.province | dashIfEmpty}}
+ {{::client.city | dashIfEmpty}}
+ {{::client.postcode | dashIfEmpty}}
+ {{::client.email | dashIfEmpty}}
+ {{::client.created | date:'dd/MM/yyyy'}}
+ {{::client.businessType | dashIfEmpty}}
+ {{::client.payMethod | dashIfEmpty}}
+ {{::client.sageTaxType | dashIfEmpty}}
+ {{::client.sageTransactionType | dashIfEmpty}}
+
+
+ {{ ::client.isActive ? 'Yes' : 'No' | translate}}
+
+
+
+
+ {{ ::client.isVies ? 'Yes' : 'No' | translate}}
+
+
+
+
+ {{ ::client.isTaxDataChecked ? 'Yes' : 'No' | translate}}
+
+
+
+
+ {{ ::client.isEqualizated ? 'Yes' : 'No' | translate}}
+
+
+
+
+ {{ ::client.isFreezed ? 'Yes' : 'No' | translate}}
+
+
+
+
+ {{ ::client.hasToInvoice ? 'Yes' : 'No' | translate}}
+
+
+
+
+ {{ ::client.hasToInvoiceByAddress ? 'Yes' : 'No' | translate}}
+
+
+
+
+ {{ ::client.isToBeMailed ? 'Yes' : 'No' | translate}}
+
+
+
+
+ {{ ::client.hasLcr ? 'Yes' : 'No' | translate}}
+
+
+
+
+ {{ ::client.hasCoreVnl ? 'Yes' : 'No' | translate}}
+
+
+
+
+ {{ ::client.hasSepaVnl ? 'Yes' : 'No' | translate}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Filter by selection
+
+
+ Exclude selection
+
+
+ Remove filter
+
+
+ Remove all filters
+
+
+
\ No newline at end of file
diff --git a/modules/client/front/extended-list/index.js b/modules/client/front/extended-list/index.js
new file mode 100644
index 000000000..8eed48d01
--- /dev/null
+++ b/modules/client/front/extended-list/index.js
@@ -0,0 +1,184 @@
+import ngModule from '../module';
+import Section from 'salix/components/section';
+import './style.scss';
+
+class Controller extends Section {
+ constructor($element, $) {
+ super($element, $);
+
+ this.smartTableOptions = {
+ activeButtons: {
+ search: true,
+ shownColumns: true,
+ },
+ columns: [
+ {
+ field: 'socialName',
+ autocomplete: {
+ url: 'Clients',
+ showField: 'socialName',
+ valueField: 'socialName',
+ }
+ },
+ {
+ field: 'created',
+ datepicker: true
+ },
+ {
+ field: 'countryFk',
+ autocomplete: {
+ url: 'Countries',
+ showField: 'country',
+ }
+ },
+ {
+ field: 'provinceFk',
+ autocomplete: {
+ url: 'Provinces'
+ }
+ },
+ {
+ field: 'salesPersonFk',
+ autocomplete: {
+ url: 'Workers/activeWithInheritedRole',
+ where: `{role: 'salesPerson'}`,
+ searchFunction: '{firstName: $search}',
+ showField: 'nickname',
+ valueField: 'id',
+ }
+ },
+ {
+ field: 'businessTypeFk',
+ autocomplete: {
+ url: 'BusinessTypes',
+ valueField: 'code',
+ showField: 'description',
+ }
+ },
+ {
+ field: 'payMethodFk',
+ autocomplete: {
+ url: 'PayMethods',
+ }
+ },
+ {
+ field: 'sageTaxTypeFk',
+ autocomplete: {
+ url: 'SageTaxTypes',
+ showField: 'vat',
+ }
+ },
+ {
+ field: 'sageTransactionTypeFk',
+ autocomplete: {
+ url: 'SageTransactionTypes',
+ showField: 'transaction',
+ }
+ },
+ {
+ field: 'isActive',
+ checkbox: true
+ },
+ {
+ field: 'isVies',
+ checkbox: true
+ },
+ {
+ field: 'isTaxDataChecked',
+ checkbox: true
+ },
+ {
+ field: 'isEqualizated',
+ checkbox: true
+ },
+ {
+ field: 'isFreezed',
+ checkbox: true
+ },
+ {
+ field: 'hasToInvoice',
+ checkbox: true
+ },
+ {
+ field: 'hasToInvoiceByAddress',
+ checkbox: true
+ },
+ {
+ field: 'isToBeMailed',
+ checkbox: true
+ },
+ {
+ field: 'hasSepaVnl',
+ checkbox: true
+ },
+ {
+ field: 'hasLcr',
+ checkbox: true
+ },
+ {
+ field: 'hasCoreVnl',
+ checkbox: true
+ }
+ ]
+ };
+ }
+
+ exprBuilder(param, value) {
+ switch (param) {
+ case 'created':
+ return {'c.created': {
+ between: this.dateRange(value)}
+ };
+ case 'id':
+ case 'name':
+ case 'socialName':
+ case 'fi':
+ case 'credit':
+ case 'creditInsurance':
+ case 'phone':
+ case 'mobile':
+ case 'street':
+ case 'city':
+ case 'postcode':
+ case 'email':
+ case 'isActive':
+ case 'isVies':
+ case 'isTaxDataChecked':
+ case 'isEqualizated':
+ case 'isFreezed':
+ case 'hasToInvoice':
+ case 'hasToInvoiceByAddress':
+ case 'isToBeMailed':
+ case 'hasSepaVnl':
+ case 'hasLcr':
+ case 'hasCoreVnl':
+ case 'countryFk':
+ case 'provinceFk':
+ case 'salesPersonFk':
+ case 'businessTypeFk':
+ case 'payMethodFk':
+ case 'sageTaxTypeFk':
+ case 'sageTransactionTypeFk':
+ return {[`c.${param}`]: value};
+ }
+ }
+
+ dateRange(value) {
+ const minHour = new Date(value);
+ minHour.setHours(0, 0, 0, 0);
+ const maxHour = new Date(value);
+ maxHour.setHours(23, 59, 59, 59);
+
+ return [minHour, maxHour];
+ }
+
+ preview(client) {
+ this.clientSelected = client;
+ this.$.preview.show();
+ }
+}
+
+ngModule.vnComponent('vnClientExtendedList', {
+ template: require('./index.html'),
+ controller: Controller
+});
diff --git a/modules/client/front/extended-list/locale/es.yml b/modules/client/front/extended-list/locale/es.yml
new file mode 100644
index 000000000..ea56f3af2
--- /dev/null
+++ b/modules/client/front/extended-list/locale/es.yml
@@ -0,0 +1,3 @@
+Mailing: Env. emails
+Sage tr. type: Tipo tr. sage
+Yes: Sí
\ No newline at end of file
diff --git a/modules/client/front/extended-list/style.scss b/modules/client/front/extended-list/style.scss
new file mode 100644
index 000000000..7625b5d16
--- /dev/null
+++ b/modules/client/front/extended-list/style.scss
@@ -0,0 +1,6 @@
+@import "variables";
+
+vn-chip.success,
+vn-chip.alert {
+ color: $color-font-bg
+}
\ No newline at end of file
diff --git a/modules/client/front/fiscal-data/index.html b/modules/client/front/fiscal-data/index.html
index f3fd42e76..1f3533327 100644
--- a/modules/client/front/fiscal-data/index.html
+++ b/modules/client/front/fiscal-data/index.html
@@ -33,7 +33,7 @@
label="Social name"
ng-model="$ctrl.client.socialName"
rule
- info="You can use letters and spaces"
+ info="Only letters, numbers and spaces can be used"
required="true">
{{clientId}} ya tiene este teléfono o email. ¿Quieres continuar?
Sage tax type: Tipo de impuesto Sage
diff --git a/modules/client/front/index.js b/modules/client/front/index.js
index ea732beea..a5782c789 100644
--- a/modules/client/front/index.js
+++ b/modules/client/front/index.js
@@ -47,3 +47,4 @@ import './consumption-search-panel';
import './defaulter';
import './notification';
import './unpaid';
+import './extended-list';
diff --git a/modules/client/front/locale/es.yml b/modules/client/front/locale/es.yml
index 4eb99318c..de4b91e0b 100644
--- a/modules/client/front/locale/es.yml
+++ b/modules/client/front/locale/es.yml
@@ -33,6 +33,7 @@ Search client by id or name: Buscar clientes por identificador o nombre
# Sections
Clients: Clientes
+Extended list: Listado extendido
Defaulter: Morosos
New client: Nuevo cliente
Fiscal data: Datos fiscales
diff --git a/modules/client/front/notification/index.js b/modules/client/front/notification/index.js
index 12a1a4acb..0506ea4ba 100644
--- a/modules/client/front/notification/index.js
+++ b/modules/client/front/notification/index.js
@@ -81,7 +81,7 @@ export default class Controller extends Section {
clientIds: clientIds
}, this.campaign);
- this.$http.post('notify/consumption', params)
+ this.$http.post('schedule/consumption', params)
.then(() => this.$.filters.hide())
.then(() => this.vnApp.showSuccess(this.$t('Notifications sent!')));
}
diff --git a/modules/client/front/notification/index.spec.js b/modules/client/front/notification/index.spec.js
index 13c6bc513..8847357f7 100644
--- a/modules/client/front/notification/index.spec.js
+++ b/modules/client/front/notification/index.spec.js
@@ -74,7 +74,7 @@ describe('Client notification', () => {
clientIds: [1101, 1102]
}, controller.campaign);
- $httpBackend.expect('POST', `notify/consumption`, params).respond(200, params);
+ $httpBackend.expect('POST', `schedule/consumption`, params).respond(200, params);
controller.onSendClientConsumption();
$httpBackend.flush();
diff --git a/modules/client/front/routes.json b/modules/client/front/routes.json
index 293243470..6616443bb 100644
--- a/modules/client/front/routes.json
+++ b/modules/client/front/routes.json
@@ -7,6 +7,7 @@
"menus": {
"main": [
{"state": "client.index", "icon": "person"},
+ {"state": "client.extendedList", "icon": "person"},
{"state": "client.notification", "icon": "campaign"},
{"state": "client.defaulter", "icon": "icon-defaulter"}
],
@@ -381,6 +382,12 @@
"component": "vn-client-unpaid",
"acl": ["administrative"],
"description": "Unpaid"
+ },
+ {
+ "url": "/extended-list",
+ "state": "client.extendedList",
+ "component": "vn-client-extended-list",
+ "description": "Extended list"
}
]
}
diff --git a/modules/client/front/search-panel/locale/es.yml b/modules/client/front/search-panel/locale/es.yml
index 93d2faf53..b0d0649c8 100644
--- a/modules/client/front/search-panel/locale/es.yml
+++ b/modules/client/front/search-panel/locale/es.yml
@@ -1,7 +1,7 @@
Client id: Id cliente
Tax number: NIF/CIF
Name: Nombre
-Social name: Razon social
+Social name: Razón social
Town/City: Ciudad
Postcode: Código postal
Email: E-mail
diff --git a/modules/entry/back/methods/entry/editLatestBuys.js b/modules/entry/back/methods/entry/editLatestBuys.js
index fb0397d2b..72bee98ae 100644
--- a/modules/entry/back/methods/entry/editLatestBuys.js
+++ b/modules/entry/back/methods/entry/editLatestBuys.js
@@ -1,27 +1,32 @@
module.exports = Self => {
- Self.remoteMethod('editLatestBuys', {
+ Self.remoteMethodCtx('editLatestBuys', {
description: 'Updates a column for one or more buys',
accessType: 'WRITE',
accepts: [{
arg: 'field',
- type: 'String',
+ type: 'string',
required: true,
description: `the column to edit`
},
{
arg: 'newValue',
- type: 'Any',
+ type: 'any',
required: true,
description: `The new value to save`
},
{
arg: 'lines',
- type: ['Object'],
+ type: ['object'],
required: true,
description: `the buys which will be modified`
+ },
+ {
+ arg: 'filter',
+ type: 'object',
+ description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string'
}],
returns: {
- type: 'Object',
+ type: 'object',
root: true
},
http: {
@@ -30,7 +35,7 @@ module.exports = Self => {
}
});
- Self.editLatestBuys = async(field, newValue, lines, options) => {
+ Self.editLatestBuys = async(ctx, field, newValue, lines, filter, options) => {
let tx;
const myOptions = {};
@@ -64,17 +69,19 @@ module.exports = Self => {
const models = Self.app.models;
const model = models[modelName];
-
try {
const promises = [];
+ const value = {};
+ value[field] = newValue;
+
+ if (filter) {
+ ctx.args.filter = {where: filter, limit: null};
+ lines = await models.Buy.latestBuysFilter(ctx, null, myOptions);
+ }
const targets = lines.map(line => {
return line[identifier];
});
-
- const value = {};
- value[field] = newValue;
-
for (let target of targets)
promises.push(model.upsertWithWhere({id: target}, value, myOptions));
diff --git a/modules/entry/back/methods/entry/latestBuysFilter.js b/modules/entry/back/methods/entry/latestBuysFilter.js
index 590aceeed..745ce530d 100644
--- a/modules/entry/back/methods/entry/latestBuysFilter.js
+++ b/modules/entry/back/methods/entry/latestBuysFilter.js
@@ -86,7 +86,7 @@ module.exports = Self => {
}
],
returns: {
- type: ['Object'],
+ type: ['object'],
root: true
},
http: {
diff --git a/modules/entry/back/methods/entry/specs/editLatestBuys.spec.js b/modules/entry/back/methods/entry/specs/editLatestBuys.spec.js
index b17b0ab21..2413c18f6 100644
--- a/modules/entry/back/methods/entry/specs/editLatestBuys.spec.js
+++ b/modules/entry/back/methods/entry/specs/editLatestBuys.spec.js
@@ -6,7 +6,7 @@ describe('Buy editLatestsBuys()', () => {
const options = {transaction: tx};
try {
- let ctx = {
+ const ctx = {
args: {
search: 'Ranged weapon longbow 2m'
}
@@ -18,7 +18,35 @@ describe('Buy editLatestsBuys()', () => {
const newValue = 99;
const lines = [{itemFk: original.itemFk, id: original.id}];
- await models.Buy.editLatestBuys(field, newValue, lines, options);
+ await models.Buy.editLatestBuys(ctx, field, newValue, lines, null, options);
+
+ const [result] = await models.Buy.latestBuysFilter(ctx, null, options);
+
+ expect(result[field]).toEqual(newValue);
+
+ await tx.rollback();
+ } catch (e) {
+ await tx.rollback();
+ throw e;
+ }
+ });
+
+ it('should change the value of a given column for filter', async() => {
+ const tx = await models.Buy.beginTransaction({});
+ const options = {transaction: tx};
+
+ try {
+ const filter = {typeFk: 1};
+ const ctx = {
+ args: {
+ filter: filter
+ }
+ };
+
+ const field = 'size';
+ const newValue = 88;
+
+ await models.Buy.editLatestBuys(ctx, field, newValue, null, filter, options);
const [result] = await models.Buy.latestBuysFilter(ctx, null, options);
diff --git a/modules/entry/back/methods/entry/specs/importBuysPreview.spec.js b/modules/entry/back/methods/entry/specs/importBuysPreview.spec.js
index edfdac988..41971a64c 100644
--- a/modules/entry/back/methods/entry/specs/importBuysPreview.spec.js
+++ b/modules/entry/back/methods/entry/specs/importBuysPreview.spec.js
@@ -1,5 +1,6 @@
const models = require('vn-loopback/server/server').models;
const LoopBackContext = require('loopback-context');
+const activeCtx = {accessToken: {userId: 9}};
describe('entry importBuysPreview()', () => {
const entryId = 1;
diff --git a/modules/entry/back/models/entry-log.json b/modules/entry/back/models/entry-log.json
index c63a55d9e..6f8edaf25 100644
--- a/modules/entry/back/models/entry-log.json
+++ b/modules/entry/back/models/entry-log.json
@@ -9,40 +9,40 @@
"properties": {
"id": {
"id": true,
- "type": "Number",
+ "type": "number",
"forceId": false
},
"originFk": {
- "type": "Number",
+ "type": "number",
"required": true
},
"userFk": {
- "type": "Number"
+ "type": "number"
},
"action": {
- "type": "String",
+ "type": "string",
"required": true
},
"changedModel": {
- "type": "String"
+ "type": "string"
},
"oldInstance": {
- "type": "Object"
+ "type": "object"
},
"newInstance": {
- "type": "Object"
+ "type": "object"
},
"creationDate": {
- "type": "Date"
+ "type": "date"
},
"changedModelId": {
- "type": "String"
+ "type": "string"
},
"changedModelValue": {
- "type": "String"
+ "type": "string"
},
"description": {
- "type": "String"
+ "type": "string"
}
},
"relations": {
diff --git a/modules/entry/back/models/entry-observation.json b/modules/entry/back/models/entry-observation.json
index 535735d83..0c63dd663 100644
--- a/modules/entry/back/models/entry-observation.json
+++ b/modules/entry/back/models/entry-observation.json
@@ -13,11 +13,11 @@
"properties": {
"id": {
"id": true,
- "type": "Number",
+ "type": "number",
"description": "Identifier"
},
"description": {
- "type": "String",
+ "type": "string",
"required": true
}
},
diff --git a/modules/entry/front/latest-buys/index.html b/modules/entry/front/latest-buys/index.html
index 4eeeeedce..adeda5e56 100644
--- a/modules/entry/front/latest-buys/index.html
+++ b/modules/entry/front/latest-buys/index.html
@@ -29,9 +29,11 @@
+ checked="$ctrl.checkAll"
+ check-field="checked"
+ check-dummy-enabled="true"
+ checked-dummy-count="$ctrl.checkedDummyCount">
Picture
@@ -126,7 +128,7 @@
}">
@@ -146,12 +148,12 @@
- {{::buy.packing | dashIfEmpty}}
+ {{::buy.packing | dashIfEmpty}}
- {{::buy.grouping | dashIfEmpty}}
+ {{::buy.grouping | dashIfEmpty}}
{{::buy.quantity}}
diff --git a/modules/entry/front/latest-buys/index.js b/modules/entry/front/latest-buys/index.js
index 385e7e4b6..ec1109b81 100644
--- a/modules/entry/front/latest-buys/index.js
+++ b/modules/entry/front/latest-buys/index.js
@@ -6,7 +6,7 @@ export default class Controller extends Section {
constructor($element, $) {
super($element, $);
this.editedColumn;
- this.$checkAll = false;
+ this.checkAll = false;
this.smartTableOptions = {
activeButtons: {
@@ -91,7 +91,7 @@ export default class Controller extends Section {
const buys = this.$.model.data || [];
const checkedBuys = [];
for (let buy of buys) {
- if (buy.$checked)
+ if (buy.checked)
checkedBuys.push(buy);
}
@@ -142,6 +142,9 @@ export default class Controller extends Section {
}
get totalChecked() {
+ if (this.checkedDummyCount)
+ return this.checkedDummyCount;
+
return this.checked.length;
}
@@ -156,6 +159,23 @@ export default class Controller extends Section {
lines: rowsToEdit
};
+ if (this.checkedDummyCount && this.checkedDummyCount > 0) {
+ const params = {};
+ if (this.$.model.userParams) {
+ const userParams = this.$.model.userParams;
+ for (let param in userParams) {
+ let newParam = this.exprBuilder(param, userParams[param]);
+ if (!newParam)
+ newParam = {[param]: userParams[param]};
+ Object.assign(params, newParam);
+ }
+ }
+ if (this.$.model.userFilter)
+ Object.assign(params, this.$.model.userFilter.where);
+
+ data.filter = params;
+ }
+
return this.$http.post('Buys/editLatestBuys', data)
.then(() => {
this.uncheck();
diff --git a/modules/entry/front/latest-buys/index.spec.js b/modules/entry/front/latest-buys/index.spec.js
index e9392a797..76e122d80 100644
--- a/modules/entry/front/latest-buys/index.spec.js
+++ b/modules/entry/front/latest-buys/index.spec.js
@@ -31,10 +31,10 @@ describe('Entry', () => {
describe('get checked', () => {
it(`should return a set of checked lines`, () => {
controller.$.model.data = [
- {$checked: true, id: 1},
- {$checked: true, id: 2},
- {$checked: true, id: 3},
- {$checked: false, id: 4},
+ {checked: true, id: 1},
+ {checked: true, id: 2},
+ {checked: true, id: 3},
+ {checked: false, id: 4},
];
let result = controller.checked;
diff --git a/modules/entry/front/summary/index.html b/modules/entry/front/summary/index.html
index f443a94fe..a95b2f18a 100644
--- a/modules/entry/front/summary/index.html
+++ b/modules/entry/front/summary/index.html
@@ -1,6 +1,6 @@
diff --git a/modules/entry/front/summary/index.js b/modules/entry/front/summary/index.js
index c949dba64..6e18bc959 100644
--- a/modules/entry/front/summary/index.js
+++ b/modules/entry/front/summary/index.js
@@ -4,6 +4,9 @@ import Summary from 'salix/components/summary';
class Controller extends Summary {
get entry() {
+ if (!this._entry)
+ return this.$params;
+
return this._entry;
}
diff --git a/modules/invoiceIn/back/methods/invoice-in/filter.js b/modules/invoiceIn/back/methods/invoice-in/filter.js
index 7e497d39a..f5eab9099 100644
--- a/modules/invoiceIn/back/methods/invoice-in/filter.js
+++ b/modules/invoiceIn/back/methods/invoice-in/filter.js
@@ -144,6 +144,7 @@ module.exports = Self => {
ii.isBooked,
ii.supplierRef,
ii.docFk AS dmsFk,
+ dm.file,
ii.supplierFk,
ii.expenceFkDeductible deductibleExpenseFk,
s.name AS supplierName,
@@ -156,7 +157,8 @@ module.exports = Self => {
LEFT JOIN duaInvoiceIn dii ON dii.invoiceInFk = ii.id
LEFT JOIN dua d ON d.id = dii.duaFk
LEFT JOIN awb ON awb.id = d.awbFk
- LEFT JOIN company co ON co.id = ii.companyFk`
+ LEFT JOIN company co ON co.id = ii.companyFk
+ LEFT JOIN dms dm ON dm.id = ii.docFk`
);
const sqlWhere = conn.makeWhere(filter.where);
diff --git a/modules/invoiceIn/back/methods/invoice-in/getTotals.js b/modules/invoiceIn/back/methods/invoice-in/getTotals.js
index 918467010..f35c10617 100644
--- a/modules/invoiceIn/back/methods/invoice-in/getTotals.js
+++ b/modules/invoiceIn/back/methods/invoice-in/getTotals.js
@@ -30,7 +30,7 @@ module.exports = Self => {
SUM(iidd.amount) totalDueDay
FROM vn.invoiceIn ii
LEFT JOIN (SELECT SUM(iit.taxableBase) totalTaxableBase,
- SUM(iit.taxableBase * (1 + (ti.PorcentajeIva / 100))) totalVat
+ CAST(SUM(iit.taxableBase * (1 + (ti.PorcentajeIva / 100))) AS DECIMAL(10,2)) totalVat
FROM vn.invoiceInTax iit
LEFT JOIN sage.TiposIva ti ON ti.CodigoIva = iit.taxTypeSageFk
WHERE iit.invoiceInFk = ?) iit ON TRUE
diff --git a/modules/invoiceIn/front/create/index.html b/modules/invoiceIn/front/create/index.html
index 4ec724854..16ecf26cf 100644
--- a/modules/invoiceIn/front/create/index.html
+++ b/modules/invoiceIn/front/create/index.html
@@ -13,13 +13,14 @@
vn-id="supplier"
url="Suppliers"
label="Supplier"
- search-function="{or: [{id: $search}, {name: {like: '%'+ $search +'%'}}]}"
+ search-function="{or: [{id: $search}, {name: {like: '%'+ $search +'%'}}, {nif: {like: '%'+ $search +'%'}}]}"
+ fields="['nif']"
show-field="name"
value-field="id"
ng-model="$ctrl.invoiceIn.supplierFk"
order="id"
vn-focus>
- {{id}}: {{name}}
+ {{id}}: {{nif}}: {{name}}
-
-
{{id}}: {{bank}}
diff --git a/modules/invoiceIn/front/dueDay/index.js b/modules/invoiceIn/front/dueDay/index.js
index 22b697f7e..3cc1c81e8 100644
--- a/modules/invoiceIn/front/dueDay/index.js
+++ b/modules/invoiceIn/front/dueDay/index.js
@@ -17,6 +17,12 @@ class Controller extends Section {
this.card.reload();
});
}
+
+ bankSearchFunc($search) {
+ return /^\d+$/.test($search)
+ ? {id: $search}
+ : {bank: {like: '%' + $search + '%'}};
+ }
}
ngModule.vnComponent('vnInvoiceInDueDay', {
diff --git a/modules/invoiceIn/front/index/index.html b/modules/invoiceIn/front/index/index.html
index 62074be33..008d615b1 100644
--- a/modules/invoiceIn/front/index/index.html
+++ b/modules/invoiceIn/front/index/index.html
@@ -13,7 +13,7 @@
Supplier ref.
Serial number
Serial
- Account
+ File
Issued
Is booked
AWB
@@ -27,7 +27,7 @@
class="clickable vn-tr search-result"
ui-sref="invoiceIn.card.summary({id: {{::invoiceIn.id}}})">
{{::invoiceIn.id}}
-
+
@@ -36,8 +36,13 @@
{{::invoiceIn.supplierRef | dashIfEmpty}}
{{::invoiceIn.serialNumber}}
- {{::invoiceIn.serial}}
- {{::invoiceIn.account}}
+ {{::invoiceIn.serial}}
+
+
+ {{::invoiceIn.file}}
+
+
{{::invoiceIn.issued | date:'dd/MM/yyyy' | dashIfEmpty}}
{{id}}: {{name}}
+
+
+
+
-
\ No newline at end of file
+
+
+
+
+
+
+ {{$ctrl.$t('New expense')}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Save
+
+
\ No newline at end of file
diff --git a/modules/invoiceIn/front/tax/index.js b/modules/invoiceIn/front/tax/index.js
index 53cfc5598..d05a77f29 100644
--- a/modules/invoiceIn/front/tax/index.js
+++ b/modules/invoiceIn/front/tax/index.js
@@ -1,7 +1,12 @@
import ngModule from '../module';
import Section from 'salix/components/section';
+import UserError from 'core/lib/user-error';
class Controller extends Section {
+ constructor($element, $, vnWeekDays) {
+ super($element, $);
+ this.expense = {};
+ }
taxRate(invoiceInTax, taxRateSelection) {
const taxTypeSage = taxRateSelection && taxRateSelection.rate;
const taxableBase = invoiceInTax && invoiceInTax.taxableBase;
@@ -26,6 +31,27 @@ class Controller extends Section {
this.card.reload();
});
}
+
+ onResponse() {
+ try {
+ if (!this.expense.code)
+ throw new Error(`The code can't be empty`);
+ if (!this.expense.description)
+ throw new UserError(`The description can't be empty`);
+
+ const data = [{
+ id: this.expense.code,
+ isWithheld: this.expense.isWithheld,
+ name: this.expense.description
+ }];
+
+ this.$http.post(`Expenses`, data) .then(() => {
+ this.vnApp.showSuccess(this.$t('Expense saved!'));
+ });
+ } catch (e) {
+ this.vnApp.showError(this.$t(e.message));
+ }
+ }
}
ngModule.vnComponent('vnInvoiceInTax', {
diff --git a/modules/invoiceIn/front/tax/index.spec.js b/modules/invoiceIn/front/tax/index.spec.js
index 20d5d40d8..c62ada9ca 100644
--- a/modules/invoiceIn/front/tax/index.spec.js
+++ b/modules/invoiceIn/front/tax/index.spec.js
@@ -1,16 +1,19 @@
import './index.js';
import watcher from 'core/mocks/watcher';
import crudModel from 'core/mocks/crud-model';
+const UserError = require('vn-loopback/util/user-error');
describe('InvoiceIn', () => {
describe('Component tax', () => {
let controller;
let $scope;
let vnApp;
+ let $httpBackend;
beforeEach(ngModule('invoiceIn'));
- beforeEach(inject(($componentController, $rootScope, _vnApp_) => {
+ beforeEach(inject(($componentController, $rootScope, _vnApp_, _$httpBackend_) => {
+ $httpBackend = _$httpBackend_;
vnApp = _vnApp_;
jest.spyOn(vnApp, 'showError');
$scope = $rootScope.$new();
@@ -19,6 +22,7 @@ describe('InvoiceIn', () => {
const $element = angular.element(' ');
controller = $componentController('vnInvoiceInTax', {$element, $scope});
+ controller.$.model = crudModel;
controller.invoiceIn = {id: 1};
}));
@@ -55,5 +59,56 @@ describe('InvoiceIn', () => {
expect(controller.card.reload).toHaveBeenCalledWith();
});
});
+
+ describe('onResponse()', () => {
+ it('should return success message', () => {
+ controller.expense = {
+ code: 7050000005,
+ isWithheld: 0,
+ description: 'Test'
+ };
+
+ const data = [{
+ id: controller.expense.code,
+ isWithheld: controller.expense.isWithheld,
+ name: controller.expense.description
+ }];
+
+ jest.spyOn(controller.vnApp, 'showSuccess');
+ $httpBackend.expect('POST', `Expenses`, data).respond();
+
+ controller.onResponse();
+ $httpBackend.flush();
+
+ expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Expense saved!');
+ });
+
+ it('should return an error if code is empty', () => {
+ controller.expense = {
+ code: null,
+ isWithheld: 0,
+ description: 'Test'
+ };
+
+ jest.spyOn(controller.vnApp, 'showError');
+ controller.onResponse();
+
+ expect(controller.vnApp.showError).toHaveBeenCalledWith(`The code can't be empty`);
+ });
+
+ it('should return an error if description is empty', () => {
+ controller.expense = {
+ code: 7050000005,
+ isWithheld: 0,
+ description: null
+ };
+
+ jest.spyOn(controller.vnApp, 'showError');
+ controller.onResponse();
+
+ expect(controller.vnApp.showError).toHaveBeenCalledWith(`The description can't be empty`);
+ });
+ });
});
});
+
diff --git a/modules/invoiceIn/front/tax/locale/es.yml b/modules/invoiceIn/front/tax/locale/es.yml
new file mode 100644
index 000000000..3ff68ea40
--- /dev/null
+++ b/modules/invoiceIn/front/tax/locale/es.yml
@@ -0,0 +1,7 @@
+Create expense: Crear gasto
+New expense: Nuevo gasto
+It's a withholding: Es una retención
+The fields can't be empty: Los campos no pueden estar vacíos
+The code can't be empty: El código no puede estar vacío
+The description can't be empty: La descripción no puede estar vacía
+Expense saved!: Gasto guardado!
\ No newline at end of file
diff --git a/modules/invoiceOut/back/methods/invoiceOut/globalInvoicing.js b/modules/invoiceOut/back/methods/invoiceOut/globalInvoicing.js
index 6b901872e..7f2cbb442 100644
--- a/modules/invoiceOut/back/methods/invoiceOut/globalInvoicing.js
+++ b/modules/invoiceOut/back/methods/invoiceOut/globalInvoicing.js
@@ -1,5 +1,3 @@
-const UserError = require('vn-loopback/util/user-error');
-
module.exports = Self => {
Self.remoteMethodCtx('globalInvoicing', {
description: 'Make a global invoice',
@@ -140,6 +138,9 @@ module.exports = Self => {
if (newInvoice.id) {
await Self.rawSql('CALL invoiceOutBooking(?)', [newInvoice.id], myOptions);
+ query = `INSERT IGNORE INTO invoiceOut_queue(invoiceFk) VALUES(?)`;
+ await Self.rawSql(query, [newInvoice.id], myOptions);
+
invoicesIds.push(newInvoice.id);
}
} catch (e) {
@@ -160,10 +161,6 @@ module.exports = Self => {
throw e;
}
- // Print invoices PDF
- for (let invoiceId of invoicesIds)
- await Self.createPdf(ctx, invoiceId);
-
return invoicesIds;
};
@@ -212,7 +209,13 @@ module.exports = Self => {
const query = `SELECT
c.id,
- SUM(IFNULL(s.quantity * s.price * (100-s.discount)/100, 0) + IFNULL(ts.quantity * ts.price,0)) AS sumAmount,
+ SUM(IFNULL
+ (
+ s.quantity *
+ s.price * (100-s.discount)/100,
+ 0)
+ + IFNULL(ts.quantity * ts.price,0)
+ ) AS sumAmount,
c.hasToInvoiceByAddress,
c.email,
c.isToBeMailed,
diff --git a/modules/invoiceOut/back/methods/invoiceOut/specs/createManualInvoice.spec.js b/modules/invoiceOut/back/methods/invoiceOut/specs/createManualInvoice.spec.js
index f1c1bbab8..b166caf78 100644
--- a/modules/invoiceOut/back/methods/invoiceOut/specs/createManualInvoice.spec.js
+++ b/modules/invoiceOut/back/methods/invoiceOut/specs/createManualInvoice.spec.js
@@ -93,6 +93,9 @@ describe('InvoiceOut createManualInvoice()', () => {
it('should throw an error for a non-invoiceable client', async() => {
spyOn(models.InvoiceOut, 'createPdf').and.returnValue(new Promise(resolve => resolve(true)));
+ spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
+ active: activeCtx
+ });
const tx = await models.InvoiceOut.beginTransaction({});
const options = {transaction: tx};
diff --git a/modules/invoiceOut/back/models/invoice-out.json b/modules/invoiceOut/back/models/invoice-out.json
index 45c4c2774..2bf5182e8 100644
--- a/modules/invoiceOut/back/models/invoice-out.json
+++ b/modules/invoiceOut/back/models/invoice-out.json
@@ -9,21 +9,21 @@
"properties": {
"id": {
"id": true,
- "type": "Number",
+ "type": "number",
"description": "Identifier"
},
"ref": {
- "type": "String",
+ "type": "string",
"required": true
},
"serial": {
- "type": "String"
+ "type": "string"
},
"issued": {
"type": "date"
},
"amount": {
- "type": "Number"
+ "type": "number"
},
"created": {
"type": "date"
@@ -35,7 +35,7 @@
"type": "date"
},
"hasPdf": {
- "type": "Boolean"
+ "type": "boolean"
}
},
"relations": {
diff --git a/modules/invoiceOut/back/models/tax-class.json b/modules/invoiceOut/back/models/tax-class.json
index fa5676466..a259b874a 100644
--- a/modules/invoiceOut/back/models/tax-class.json
+++ b/modules/invoiceOut/back/models/tax-class.json
@@ -8,16 +8,16 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"description": "Identifier",
"id": true
},
"description": {
- "type": "String",
+ "type": "string",
"required": true
},
"code": {
- "type": "String",
+ "type": "string",
"required": true
}
},
diff --git a/modules/invoiceOut/back/models/tax-code.json b/modules/invoiceOut/back/models/tax-code.json
index dfd69139e..b515ca334 100644
--- a/modules/invoiceOut/back/models/tax-code.json
+++ b/modules/invoiceOut/back/models/tax-code.json
@@ -8,7 +8,7 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"id": true,
"description": "Identifier"
},
@@ -16,7 +16,7 @@
"type": "date"
},
"code": {
- "type": "String"
+ "type": "string"
},
"rate": {
"type": "number"
@@ -25,10 +25,10 @@
"type": "number"
},
"type": {
- "type": "String"
+ "type": "string"
},
"isActive": {
- "type": "Boolean"
+ "type": "boolean"
}
},
"relations": {
diff --git a/modules/invoiceOut/back/models/tax-type.json b/modules/invoiceOut/back/models/tax-type.json
index 4e30446b0..46a73835d 100644
--- a/modules/invoiceOut/back/models/tax-type.json
+++ b/modules/invoiceOut/back/models/tax-type.json
@@ -8,21 +8,21 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"id": true,
"description": "Identifier"
},
"nickname": {
- "type": "String"
+ "type": "string"
},
"serial": {
- "type": "String"
+ "type": "string"
},
"TIPOOPE": {
- "type": "String"
+ "type": "string"
},
"description": {
- "type": "String"
+ "type": "string"
}
},
"relations": {
diff --git a/modules/invoiceOut/front/descriptor-menu/index.html b/modules/invoiceOut/front/descriptor-menu/index.html
index 859486ab1..ef4c9a62e 100644
--- a/modules/invoiceOut/front/descriptor-menu/index.html
+++ b/modules/invoiceOut/front/descriptor-menu/index.html
@@ -76,6 +76,13 @@
translate>
Show CITES letter
+
+ Refund
+
+
+
diff --git a/modules/invoiceOut/front/descriptor-menu/index.js b/modules/invoiceOut/front/descriptor-menu/index.js
index 7738845f9..b884e50cb 100644
--- a/modules/invoiceOut/front/descriptor-menu/index.js
+++ b/modules/invoiceOut/front/descriptor-menu/index.js
@@ -116,6 +116,35 @@ class Controller extends Section {
invoiceId: this.id
});
}
+
+ async refundInvoiceOut() {
+ let filter = {
+ where: {refFk: this.invoiceOut.ref}
+ };
+ const tickets = await this.$http.get('Tickets', {filter});
+ this.tickets = tickets.data;
+ this.ticketsIds = [];
+ for (let ticket of this.tickets)
+ this.ticketsIds.push(ticket.id);
+
+ filter = {
+ where: {ticketFk: {inq: this.ticketsIds}}
+ };
+ const sales = await this.$http.get('Sales', {filter});
+ this.sales = sales.data;
+
+ const ticketServices = await this.$http.get('TicketServices', {filter});
+ this.services = ticketServices.data;
+
+ const params = {
+ sales: this.sales,
+ services: this.services
+ };
+ const query = `Sales/refund`;
+ return this.$http.post(query, params).then(res => {
+ this.$state.go('ticket.card.sale', {id: res.data});
+ });
+ }
}
Controller.$inject = ['$element', '$scope', 'vnReport', 'vnEmail'];
diff --git a/modules/invoiceOut/front/descriptor-menu/index.spec.js b/modules/invoiceOut/front/descriptor-menu/index.spec.js
index fced12e0d..c84c97a57 100644
--- a/modules/invoiceOut/front/descriptor-menu/index.spec.js
+++ b/modules/invoiceOut/front/descriptor-menu/index.spec.js
@@ -122,4 +122,34 @@ describe('vnInvoiceOutDescriptorMenu', () => {
expect(controller.vnApp.showMessage).toHaveBeenCalled();
});
});
+
+ // #4084 review with Juan
+ xdescribe('refundInvoiceOut()', () => {
+ it('should make a query and go to ticket.card.sale', () => {
+ controller.$state.go = jest.fn();
+
+ const invoiceOut = {
+ id: 1,
+ ref: 'T1111111'
+ };
+ controller.invoiceOut = invoiceOut;
+ const tickets = [{id: 1}];
+ const sales = [{id: 1}];
+ const services = [{id: 2}];
+
+ $httpBackend.expectGET(`Tickets`).respond(tickets);
+ $httpBackend.expectGET(`Sales`).respond(sales);
+ $httpBackend.expectGET(`TicketServices`).respond(services);
+
+ const expectedParams = {
+ sales: sales,
+ services: services
+ };
+ $httpBackend.expectPOST(`Sales/refund`, expectedParams).respond();
+ controller.refundInvoiceOut();
+ $httpBackend.flush();
+
+ expect(controller.$state.go).toHaveBeenCalledWith('ticket.card.sale', {id: undefined});
+ });
+ });
});
diff --git a/modules/invoiceOut/front/descriptor-menu/locale/es.yml b/modules/invoiceOut/front/descriptor-menu/locale/es.yml
index a76f6aad3..8949f1f91 100644
--- a/modules/invoiceOut/front/descriptor-menu/locale/es.yml
+++ b/modules/invoiceOut/front/descriptor-menu/locale/es.yml
@@ -12,6 +12,8 @@ Are you sure you want to delete this invoice?: Estas seguro de eliminar esta fac
Are you sure you want to clone this invoice?: Estas seguro de clonar esta factura?
InvoiceOut booked: Factura asentada
Are you sure you want to book this invoice?: Estas seguro de querer asentar esta factura?
+Are you sure you want to refund this invoice?: Estas seguro de querer abonar esta factura?
+Create a single ticket with all the content of the current invoice: Crear un ticket unico con todo el contenido de la factura actual
Regenerate PDF invoice: Regenerar PDF factura
The invoice PDF document has been regenerated: El documento PDF de la factura ha sido regenerado
The email can't be empty: El correo no puede estar vacío
diff --git a/modules/invoiceOut/front/index/global-invoicing/index.html b/modules/invoiceOut/front/index/global-invoicing/index.html
index 9fd412d0e..3d245b8d8 100644
--- a/modules/invoiceOut/front/index/global-invoicing/index.html
+++ b/modules/invoiceOut/front/index/global-invoicing/index.html
@@ -19,7 +19,7 @@
ng-if="$ctrl.isInvoicing">
- Invoicing in progress...
+ Adding invoices to queue...
@@ -66,5 +66,5 @@
- Make invoice
+ Invoice
\ No newline at end of file
diff --git a/modules/invoiceOut/front/index/global-invoicing/locale/es.yml b/modules/invoiceOut/front/index/global-invoicing/locale/es.yml
index 51e165e2a..1a6e15656 100644
--- a/modules/invoiceOut/front/index/global-invoicing/locale/es.yml
+++ b/modules/invoiceOut/front/index/global-invoicing/locale/es.yml
@@ -1,7 +1,7 @@
Create global invoice: Crear factura global
Some fields are required: Algunos campos son obligatorios
Max date: Fecha límite
-Invoicing in progress...: Facturación en progreso...
+Adding invoices to queue...: Añadiendo facturas a la cola...
Invoice date: Fecha de factura
From client: Desde el cliente
To client: Hasta el cliente
diff --git a/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js b/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js
index 6c692848b..25e661aee 100644
--- a/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js
+++ b/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js
@@ -1,12 +1,11 @@
-const models = require('vn-loopback/server/server').models;
-
+const {models} = require('vn-loopback/server/server');
describe('item lastEntriesFilter()', () => {
- const minDate = new Date(value);
- minHour.setHours(0, 0, 0, 0);
- const maxDate = new Date(value);
- maxHour.setHours(23, 59, 59, 59);
+ it('should return one entry for the given item', async() => {
+ const minDate = new Date();
+ minDate.setHours(0, 0, 0, 0);
+ const maxDate = new Date();
+ maxDate.setHours(23, 59, 59, 59);
- it('should return one entry for a given item', async() => {
const tx = await models.Item.beginTransaction({});
const options = {transaction: tx};
@@ -23,13 +22,18 @@ describe('item lastEntriesFilter()', () => {
}
});
- it('should return five entries for a given item', async() => {
+ it('should return five entries for the given item', async() => {
+ const minDate = new Date();
+ minDate.setHours(0, 0, 0, 0);
+ minDate.setMonth(minDate.getMonth() - 2, 1);
+
+ const maxDate = new Date();
+ maxDate.setHours(23, 59, 59, 59);
+
const tx = await models.Item.beginTransaction({});
const options = {transaction: tx};
try {
- minDate.setMonth(minDate.getMonth() - 2, 1);
-
const filter = {where: {itemFk: 1, landed: {between: [minDate, maxDate]}}};
const result = await models.Item.lastEntriesFilter(filter, options);
diff --git a/modules/item/back/models/expense.json b/modules/item/back/models/expense.json
index 65af02013..368876fbe 100644
--- a/modules/item/back/models/expense.json
+++ b/modules/item/back/models/expense.json
@@ -13,13 +13,10 @@
"description": "Identifier"
},
"name": {
- "type": "String"
+ "type": "string"
},
"isWithheld": {
"type": "number"
- },
- "taxTypeFk": {
- "type": "number"
}
},
"relations": {
@@ -28,13 +25,5 @@
"model": "TaxType",
"foreignKey": "taxTypeFk"
}
- },
- "acls": [
- {
- "accessType": "READ",
- "principalType": "ROLE",
- "principalId": "$everyone",
- "permission": "ALLOW"
- }
- ]
+ }
}
\ No newline at end of file
diff --git a/modules/item/back/models/genus.json b/modules/item/back/models/genus.json
index f18d8e4ae..007454130 100644
--- a/modules/item/back/models/genus.json
+++ b/modules/item/back/models/genus.json
@@ -8,12 +8,12 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"id": true,
"description": "Identifier"
},
"name": {
- "type": "String"
+ "type": "string"
}
},
"acls": [
diff --git a/modules/item/back/models/ink.json b/modules/item/back/models/ink.json
index a3cd857bf..6a39daafe 100644
--- a/modules/item/back/models/ink.json
+++ b/modules/item/back/models/ink.json
@@ -8,12 +8,12 @@
},
"properties": {
"id": {
- "type": "String",
+ "type": "string",
"id": true,
"description": "Identifier"
},
"name": {
- "type": "String"
+ "type": "string"
},
"showOrder": {
"type": "number"
diff --git a/modules/item/back/models/item-barcode.json b/modules/item/back/models/item-barcode.json
index b9de53dd1..e2ce347cb 100644
--- a/modules/item/back/models/item-barcode.json
+++ b/modules/item/back/models/item-barcode.json
@@ -13,12 +13,12 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"id": true,
"description": "Identifier"
},
"code": {
- "type": "String",
+ "type": "string",
"required": true
}
},
diff --git a/modules/item/back/models/item-botanical.json b/modules/item/back/models/item-botanical.json
index 6c465f0ee..8d8fd389f 100644
--- a/modules/item/back/models/item-botanical.json
+++ b/modules/item/back/models/item-botanical.json
@@ -12,7 +12,7 @@
},
"properties": {
"itemFk": {
- "type": "Number",
+ "type": "number",
"id": true,
"description": "Identifier"
}
diff --git a/modules/item/back/models/item-log.json b/modules/item/back/models/item-log.json
index c52931193..633a8f86b 100644
--- a/modules/item/back/models/item-log.json
+++ b/modules/item/back/models/item-log.json
@@ -9,40 +9,40 @@
"properties": {
"id": {
"id": true,
- "type": "Number",
+ "type": "number",
"forceId": false
},
"originFk": {
- "type": "Number",
+ "type": "number",
"required": true
},
"userFk": {
- "type": "Number"
+ "type": "number"
},
"action": {
- "type": "String",
+ "type": "string",
"required": true
},
"changedModel": {
- "type": "String"
+ "type": "string"
},
"oldInstance": {
- "type": "Object"
+ "type": "object"
},
"newInstance": {
- "type": "Object"
+ "type": "object"
},
"creationDate": {
- "type": "Date"
+ "type": "date"
},
"changedModelId": {
- "type": "Number"
+ "type": "number"
},
"changedModelValue": {
- "type": "String"
+ "type": "string"
},
"description": {
- "type": "String"
+ "type": "string"
}
},
"relations": {
diff --git a/modules/item/back/models/item-placement.json b/modules/item/back/models/item-placement.json
index 7bbb2dc91..0c036ef14 100644
--- a/modules/item/back/models/item-placement.json
+++ b/modules/item/back/models/item-placement.json
@@ -8,17 +8,17 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"id": true
},
"code": {
- "type": "String"
+ "type": "string"
},
"itemFk": {
- "type": "Number"
+ "type": "number"
},
"warehouseFk": {
- "type": "Number"
+ "type": "number"
}
},
"relations": {
diff --git a/modules/item/back/models/item-shelving-sale.json b/modules/item/back/models/item-shelving-sale.json
index 04f505ddd..8b89a7597 100644
--- a/modules/item/back/models/item-shelving-sale.json
+++ b/modules/item/back/models/item-shelving-sale.json
@@ -8,15 +8,15 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"id": true,
"description": "Identifier"
},
"quantity": {
- "type": "Number"
+ "type": "number"
},
"created": {
- "type": "Date"
+ "type": "date"
}
},
"relations": {
diff --git a/modules/item/back/models/item-shelving.json b/modules/item/back/models/item-shelving.json
index f0391c565..951a4553a 100644
--- a/modules/item/back/models/item-shelving.json
+++ b/modules/item/back/models/item-shelving.json
@@ -8,27 +8,27 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"id": true,
"description": "Identifier"
},
"shelve": {
- "type": "String"
+ "type": "string"
},
"shelvingFk": {
- "type": "String"
+ "type": "string"
},
"itemFk": {
- "type": "Number"
+ "type": "number"
},
"deep": {
- "type": "Number"
+ "type": "number"
},
"quantity": {
- "type": "Number"
+ "type": "number"
},
"created": {
- "type": "Date"
+ "type": "date"
}
},
"relations": {
diff --git a/modules/item/back/models/item-tag.json b/modules/item/back/models/item-tag.json
index 6beeb29d3..5660b3628 100644
--- a/modules/item/back/models/item-tag.json
+++ b/modules/item/back/models/item-tag.json
@@ -13,23 +13,23 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"id": true,
"description": "Identifier"
},
"value": {
- "type": "String"
+ "type": "string"
},
"itemFk": {
- "type": "Number",
+ "type": "number",
"required": true
},
"tagFk": {
- "type": "Number",
+ "type": "number",
"required": true
},
"priority": {
- "type": "Number",
+ "type": "number",
"required": true
}
},
diff --git a/modules/item/back/models/item-tax-country.json b/modules/item/back/models/item-tax-country.json
index 24c621518..f10a9eb72 100644
--- a/modules/item/back/models/item-tax-country.json
+++ b/modules/item/back/models/item-tax-country.json
@@ -13,21 +13,21 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"id": true,
"description": "Identifier"
},
"effectived": {
- "type": "Boolean"
+ "type": "boolean"
},
"itemFk": {
- "type": "Number"
+ "type": "number"
},
"countryFk": {
- "type": "Number"
+ "type": "number"
},
"taxClassFk": {
- "type": "Number"
+ "type": "number"
}
},
"relations": {
diff --git a/modules/item/back/models/item-type-tag.json b/modules/item/back/models/item-type-tag.json
index ca374e00e..8c4d50a07 100644
--- a/modules/item/back/models/item-type-tag.json
+++ b/modules/item/back/models/item-type-tag.json
@@ -8,12 +8,12 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"id": true,
"description": "Identifier"
},
"priority": {
- "type": "Number"
+ "type": "number"
}
},
"relations": {
diff --git a/modules/item/back/models/item-type.json b/modules/item/back/models/item-type.json
index cb9d5ace8..843d9877f 100644
--- a/modules/item/back/models/item-type.json
+++ b/modules/item/back/models/item-type.json
@@ -21,8 +21,11 @@
"life": {
"type": "number"
},
- "isPackaging": {
- "type": "boolean"
+ "promo": {
+ "type": "number"
+ },
+ "isUnconventionalSize": {
+ "type": "number"
}
},
"relations": {
@@ -40,6 +43,16 @@
"type": "belongsTo",
"model": "ItemCategory",
"foreignKey": "categoryFk"
+ },
+ "itemPackingType": {
+ "type": "belongsTo",
+ "model": "ItemPackingType",
+ "foreignKey": "itemPackingTypeFk"
+ },
+ "temperature": {
+ "type": "belongsTo",
+ "model": "Temperature",
+ "foreignKey": "temperatureFk"
}
},
"acls": [
diff --git a/modules/item/back/models/item.json b/modules/item/back/models/item.json
index efde2690f..01b6ba093 100644
--- a/modules/item/back/models/item.json
+++ b/modules/item/back/models/item.json
@@ -140,6 +140,9 @@
},
"isFloramondo": {
"type": "boolean"
+ },
+ "packingShelve": {
+ "type": "number"
}
},
"relations": {
diff --git a/modules/item/back/models/producer.json b/modules/item/back/models/producer.json
index 81a36f8d1..593a172b5 100644
--- a/modules/item/back/models/producer.json
+++ b/modules/item/back/models/producer.json
@@ -8,12 +8,12 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"id": true,
"description": "Identifier"
},
"name": {
- "type": "String"
+ "type": "string"
}
},
"acls": [
diff --git a/modules/item/back/models/specie.json b/modules/item/back/models/specie.json
index c5a1f455e..f24474416 100644
--- a/modules/item/back/models/specie.json
+++ b/modules/item/back/models/specie.json
@@ -8,12 +8,12 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"id": true,
"description": "Identifier"
},
"name": {
- "type": "String"
+ "type": "string"
}
},
"acls": [
diff --git a/modules/item/back/models/tag.json b/modules/item/back/models/tag.json
index 4cd1ad74e..6c5f5c0ba 100644
--- a/modules/item/back/models/tag.json
+++ b/modules/item/back/models/tag.json
@@ -8,25 +8,25 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"id": true,
"description": "Identifier"
},
"name": {
- "type": "String",
+ "type": "string",
"required": true
},
"isFree": {
- "type": "Boolean"
+ "type": "boolean"
},
"sourceTable": {
- "type": "String"
+ "type": "string"
},
"unit": {
- "type": "String"
+ "type": "string"
},
"isQuantitative": {
- "type": "Boolean",
+ "type": "boolean",
"mysql": {
"columnName": "isQuantitatif"
}
diff --git a/modules/item/front/index.js b/modules/item/front/index.js
index c328b1c8d..6a8d1b3b7 100644
--- a/modules/item/front/index.js
+++ b/modules/item/front/index.js
@@ -23,4 +23,4 @@ import './waste/index/';
import './waste/detail';
import './fixed-price';
import './fixed-price-search-panel';
-
+import './item-type';
diff --git a/modules/item/front/item-type/basic-data/index.html b/modules/item/front/item-type/basic-data/index.html
new file mode 100644
index 000000000..1417a05ab
--- /dev/null
+++ b/modules/item/front/item-type/basic-data/index.html
@@ -0,0 +1,62 @@
+
+
+
\ No newline at end of file
diff --git a/modules/item/front/item-type/basic-data/index.js b/modules/item/front/item-type/basic-data/index.js
new file mode 100644
index 000000000..ec280fdf8
--- /dev/null
+++ b/modules/item/front/item-type/basic-data/index.js
@@ -0,0 +1,12 @@
+import ngModule from '../../module';
+import Section from 'salix/components/section';
+
+export default class Controller extends Section {}
+
+ngModule.component('vnItemTypeBasicData', {
+ template: require('./index.html'),
+ controller: Controller,
+ bindings: {
+ itemType: '<'
+ }
+});
diff --git a/modules/item/front/item-type/card/index.html b/modules/item/front/item-type/card/index.html
new file mode 100644
index 000000000..80af6088e
--- /dev/null
+++ b/modules/item/front/item-type/card/index.html
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/modules/item/front/item-type/card/index.js b/modules/item/front/item-type/card/index.js
new file mode 100644
index 000000000..fa6b37340
--- /dev/null
+++ b/modules/item/front/item-type/card/index.js
@@ -0,0 +1,23 @@
+import ngModule from '../../module';
+import ModuleCard from 'salix/components/module-card';
+
+class Controller extends ModuleCard {
+ reload() {
+ const filter = {
+ include: [
+ {relation: 'worker'},
+ {relation: 'category'},
+ {relation: 'itemPackingType'},
+ {relation: 'temperature'}
+ ]
+ };
+
+ this.$http.get(`ItemTypes/${this.$params.id}`, {filter})
+ .then(res => this.itemType = res.data);
+ }
+}
+
+ngModule.vnComponent('vnItemTypeCard', {
+ template: require('./index.html'),
+ controller: Controller
+});
diff --git a/modules/item/front/item-type/card/index.spec.js b/modules/item/front/item-type/card/index.spec.js
new file mode 100644
index 000000000..ab2314bb9
--- /dev/null
+++ b/modules/item/front/item-type/card/index.spec.js
@@ -0,0 +1,27 @@
+import './index';
+
+describe('component vnItemTypeCard', () => {
+ let controller;
+ let $httpBackend;
+
+ beforeEach(ngModule('item'));
+
+ beforeEach(inject(($componentController, _$httpBackend_) => {
+ $httpBackend = _$httpBackend_;
+ controller = $componentController('vnItemTypeCard', {$element: null});
+ }));
+
+ describe('reload()', () => {
+ it('should reload the controller data', () => {
+ controller.$params.id = 1;
+
+ const itemType = {id: 1};
+
+ $httpBackend.expectGET('ItemTypes/1').respond(itemType);
+ controller.reload();
+ $httpBackend.flush();
+
+ expect(controller.itemType).toEqual(itemType);
+ });
+ });
+});
diff --git a/modules/item/front/item-type/create/index.html b/modules/item/front/item-type/create/index.html
new file mode 100644
index 000000000..44cb5183d
--- /dev/null
+++ b/modules/item/front/item-type/create/index.html
@@ -0,0 +1,62 @@
+
+
+
diff --git a/modules/item/front/item-type/create/index.js b/modules/item/front/item-type/create/index.js
new file mode 100644
index 000000000..ccf7744be
--- /dev/null
+++ b/modules/item/front/item-type/create/index.js
@@ -0,0 +1,15 @@
+import ngModule from '../../module';
+import Section from 'salix/components/section';
+
+export default class Controller extends Section {
+ onSubmit() {
+ return this.$.watcher.submit().then(res =>
+ this.$state.go('item.itemType.card.basicData', {id: res.data.id})
+ );
+ }
+}
+
+ngModule.component('vnItemTypeCreate', {
+ template: require('./index.html'),
+ controller: Controller
+});
diff --git a/modules/item/front/item-type/create/index.spec.js b/modules/item/front/item-type/create/index.spec.js
new file mode 100644
index 000000000..4b000df9a
--- /dev/null
+++ b/modules/item/front/item-type/create/index.spec.js
@@ -0,0 +1,34 @@
+import './index';
+
+describe('component vnItemTypeCreate', () => {
+ let $scope;
+ let $state;
+ let controller;
+
+ beforeEach(ngModule('item'));
+
+ beforeEach(inject(($componentController, $rootScope, _$state_) => {
+ $scope = $rootScope.$new();
+ $state = _$state_;
+ $scope.watcher = {
+ submit: () => {
+ return {
+ then: callback => {
+ callback({data: {id: '1234'}});
+ }
+ };
+ }
+ };
+ const $element = angular.element(' ');
+ controller = $componentController('vnItemTypeCreate', {$element, $scope});
+ }));
+
+ describe('onSubmit()', () => {
+ it(`should call submit() on the watcher then expect a callback`, () => {
+ jest.spyOn($state, 'go');
+ controller.onSubmit();
+
+ expect(controller.$state.go).toHaveBeenCalledWith('item.itemType.card.basicData', {id: '1234'});
+ });
+ });
+});
diff --git a/modules/item/front/item-type/descriptor/index.html b/modules/item/front/item-type/descriptor/index.html
new file mode 100644
index 000000000..5a0e8ed49
--- /dev/null
+++ b/modules/item/front/item-type/descriptor/index.html
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/modules/item/front/item-type/descriptor/index.js b/modules/item/front/item-type/descriptor/index.js
new file mode 100644
index 000000000..9322c599a
--- /dev/null
+++ b/modules/item/front/item-type/descriptor/index.js
@@ -0,0 +1,20 @@
+import ngModule from '../../module';
+import Descriptor from 'salix/components/descriptor';
+
+class Controller extends Descriptor {
+ get itemType() {
+ return this.entity;
+ }
+
+ set itemType(value) {
+ this.entity = value;
+ }
+}
+
+ngModule.component('vnItemTypeDescriptor', {
+ template: require('./index.html'),
+ controller: Controller,
+ bindings: {
+ itemType: '<'
+ }
+});
diff --git a/modules/item/front/item-type/index.js b/modules/item/front/item-type/index.js
new file mode 100644
index 000000000..5dcbe4097
--- /dev/null
+++ b/modules/item/front/item-type/index.js
@@ -0,0 +1,8 @@
+import './main';
+import './index/';
+import './summary';
+import './card';
+import './descriptor';
+import './create';
+import './basic-data';
+import './search-panel';
diff --git a/modules/item/front/item-type/index/index.html b/modules/item/front/item-type/index/index.html
new file mode 100644
index 000000000..50b9eb172
--- /dev/null
+++ b/modules/item/front/item-type/index/index.html
@@ -0,0 +1,43 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/modules/item/front/item-type/index/index.js b/modules/item/front/item-type/index/index.js
new file mode 100644
index 000000000..54ecba997
--- /dev/null
+++ b/modules/item/front/item-type/index/index.js
@@ -0,0 +1,14 @@
+import ngModule from '../../module';
+import Section from 'salix/components/section';
+
+export default class Controller extends Section {
+ preview(itemType) {
+ this.selectedItemType = itemType;
+ this.$.summary.show();
+ }
+}
+
+ngModule.component('vnItemTypeIndex', {
+ template: require('./index.html'),
+ controller: Controller
+});
diff --git a/modules/item/front/item-type/index/index.spec.js b/modules/item/front/item-type/index/index.spec.js
new file mode 100644
index 000000000..887c03f7f
--- /dev/null
+++ b/modules/item/front/item-type/index/index.spec.js
@@ -0,0 +1,34 @@
+import './index';
+
+describe('Item', () => {
+ describe('Component vnItemTypeIndex', () => {
+ let controller;
+ let $window;
+
+ beforeEach(ngModule('item'));
+
+ beforeEach(inject(($componentController, _$window_) => {
+ $window = _$window_;
+ const $element = angular.element(' ');
+ controller = $componentController('vnItemTypeIndex', {$element});
+ }));
+
+ describe('preview()', () => {
+ it('should show the dialog summary', () => {
+ controller.$.summary = {show: () => {}};
+ jest.spyOn(controller.$.summary, 'show');
+
+ const itemType = {id: 1};
+
+ const event = new MouseEvent('click', {
+ view: $window,
+ bubbles: true,
+ cancelable: true
+ });
+ controller.preview(event, itemType);
+
+ expect(controller.$.summary.show).toHaveBeenCalledWith();
+ });
+ });
+ });
+});
diff --git a/modules/item/front/item-type/index/locale/es.yml b/modules/item/front/item-type/index/locale/es.yml
new file mode 100644
index 000000000..1a71ff212
--- /dev/null
+++ b/modules/item/front/item-type/index/locale/es.yml
@@ -0,0 +1,2 @@
+Item Type: Familia
+New itemType: Nueva familia
\ No newline at end of file
diff --git a/modules/item/front/item-type/main/index.html b/modules/item/front/item-type/main/index.html
new file mode 100644
index 000000000..faba696c0
--- /dev/null
+++ b/modules/item/front/item-type/main/index.html
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/modules/item/front/item-type/main/index.js b/modules/item/front/item-type/main/index.js
new file mode 100644
index 000000000..0dea00abb
--- /dev/null
+++ b/modules/item/front/item-type/main/index.js
@@ -0,0 +1,24 @@
+import ngModule from '../../module';
+import ModuleMain from 'salix/components/module-main';
+
+export default class ItemType extends ModuleMain {
+ exprBuilder(param, value) {
+ switch (param) {
+ case 'search':
+ return /^\d+$/.test(value)
+ ? {id: value}
+ : {or: [
+ {name: {like: `%${value}%`}},
+ {code: {like: `%${value}%`}}
+ ]};
+ case 'name':
+ case 'code':
+ return {[param]: {like: `%${value}%`}};
+ }
+ }
+}
+
+ngModule.vnComponent('vnItemType', {
+ controller: ItemType,
+ template: require('./index.html')
+});
diff --git a/modules/item/front/item-type/main/index.spec.js b/modules/item/front/item-type/main/index.spec.js
new file mode 100644
index 000000000..dcb14ec0e
--- /dev/null
+++ b/modules/item/front/item-type/main/index.spec.js
@@ -0,0 +1,31 @@
+import './index';
+
+describe('Item', () => {
+ describe('Component vnItemType', () => {
+ let controller;
+
+ beforeEach(ngModule('item'));
+
+ beforeEach(inject($componentController => {
+ const $element = angular.element(' ');
+ controller = $componentController('vnItemType', {$element});
+ }));
+
+ describe('exprBuilder()', () => {
+ it('should return a filter based on a search by id', () => {
+ const filter = controller.exprBuilder('search', '123');
+
+ expect(filter).toEqual({id: '123'});
+ });
+
+ it('should return a filter based on a search by name or code', () => {
+ const filter = controller.exprBuilder('search', 'Alstroemeria');
+
+ expect(filter).toEqual({or: [
+ {name: {like: '%Alstroemeria%'}},
+ {code: {like: '%Alstroemeria%'}},
+ ]});
+ });
+ });
+ });
+});
diff --git a/modules/item/front/item-type/main/locale/es.yml b/modules/item/front/item-type/main/locale/es.yml
new file mode 100644
index 000000000..7aceac46f
--- /dev/null
+++ b/modules/item/front/item-type/main/locale/es.yml
@@ -0,0 +1 @@
+Search itemType by id, name or code: Buscar familia por id, nombre o código
\ No newline at end of file
diff --git a/modules/item/front/item-type/search-panel/index.html b/modules/item/front/item-type/search-panel/index.html
new file mode 100644
index 000000000..4aa762900
--- /dev/null
+++ b/modules/item/front/item-type/search-panel/index.html
@@ -0,0 +1,22 @@
+
+
+
\ No newline at end of file
diff --git a/modules/item/front/item-type/search-panel/index.js b/modules/item/front/item-type/search-panel/index.js
new file mode 100644
index 000000000..17a439c39
--- /dev/null
+++ b/modules/item/front/item-type/search-panel/index.js
@@ -0,0 +1,7 @@
+import ngModule from '../../module';
+import SearchPanel from 'core/components/searchbar/search-panel';
+
+ngModule.component('vnItemTypeSearchPanel', {
+ template: require('./index.html'),
+ controller: SearchPanel
+});
diff --git a/modules/item/front/item-type/summary/index.html b/modules/item/front/item-type/summary/index.html
new file mode 100644
index 000000000..d003c8f38
--- /dev/null
+++ b/modules/item/front/item-type/summary/index.html
@@ -0,0 +1,50 @@
+
+
+ {{summary.id}} - {{summary.name}} - {{summary.worker.firstName}} {{summary.worker.lastName}}
+
+
+
+ Basic data
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/modules/item/front/item-type/summary/index.js b/modules/item/front/item-type/summary/index.js
new file mode 100644
index 000000000..7645de8b1
--- /dev/null
+++ b/modules/item/front/item-type/summary/index.js
@@ -0,0 +1,33 @@
+import ngModule from '../../module';
+import Component from 'core/lib/component';
+
+class Controller extends Component {
+ set itemType(value) {
+ this._itemType = value;
+ this.$.summary = null;
+ if (!value) return;
+
+ const filter = {
+ include: [
+ {relation: 'worker'},
+ {relation: 'category'},
+ {relation: 'itemPackingType'},
+ {relation: 'temperature'}
+ ]
+ };
+ this.$http.get(`ItemTypes/${value.id}`, {filter})
+ .then(res => this.$.summary = res.data);
+ }
+
+ get itemType() {
+ return this._itemType;
+ }
+}
+
+ngModule.component('vnItemTypeSummary', {
+ template: require('./index.html'),
+ controller: Controller,
+ bindings: {
+ itemType: '<'
+ }
+});
diff --git a/modules/item/front/item-type/summary/locale/es.yml b/modules/item/front/item-type/summary/locale/es.yml
new file mode 100644
index 000000000..8f4cef70f
--- /dev/null
+++ b/modules/item/front/item-type/summary/locale/es.yml
@@ -0,0 +1,4 @@
+Life: Vida
+Promo: Promoción
+Item packing type: Tipo de embalaje
+Is unconventional size: Es de tamaño poco convencional
\ No newline at end of file
diff --git a/modules/item/front/routes.json b/modules/item/front/routes.json
index 9e21e1697..5743d0ce7 100644
--- a/modules/item/front/routes.json
+++ b/modules/item/front/routes.json
@@ -9,7 +9,8 @@
{"state": "item.index", "icon": "icon-item"},
{"state": "item.request", "icon": "icon-buyrequest"},
{"state": "item.waste.index", "icon": "icon-claims"},
- {"state": "item.fixedPrice", "icon": "icon-fixedPrice"}
+ {"state": "item.fixedPrice", "icon": "icon-fixedPrice"},
+ {"state": "item.itemType", "icon": "contact_support"}
],
"card": [
{"state": "item.card.basicData", "icon": "settings"},
@@ -20,6 +21,9 @@
{"state": "item.card.diary", "icon": "icon-transaction"},
{"state": "item.card.last-entries", "icon": "icon-regentry"},
{"state": "item.card.log", "icon": "history"}
+ ],
+ "itemType": [
+ {"state": "item.itemType.card.basicData", "icon": "settings"}
]
},
"keybindings": [
@@ -169,6 +173,47 @@
"component": "vn-fixed-price",
"description": "Fixed prices",
"acl": ["buyer"]
+ },
+ {
+ "url" : "/item-type?q",
+ "state": "item.itemType",
+ "component": "vn-item-type",
+ "description": "Item Type",
+ "acl": ["buyer"]
+ },
+ {
+ "url": "/create",
+ "state": "item.itemType.create",
+ "component": "vn-item-type-create",
+ "description": "New itemType",
+ "acl": ["buyer"]
+ },
+ {
+ "url": "/:id",
+ "state": "item.itemType.card",
+ "component": "vn-item-type-card",
+ "abstract": true,
+ "description": "Detail"
+ },
+ {
+ "url": "/summary",
+ "state": "item.itemType.card.summary",
+ "component": "vn-item-type-summary",
+ "description": "Summary",
+ "params": {
+ "item-type": "$ctrl.itemType"
+ },
+ "acl": ["buyer"]
+ },
+ {
+ "url": "/basic-data",
+ "state": "item.itemType.card.basicData",
+ "component": "vn-item-type-basic-data",
+ "description": "Basic data",
+ "params": {
+ "item-type": "$ctrl.itemType"
+ },
+ "acl": ["buyer"]
}
]
}
\ No newline at end of file
diff --git a/modules/mdb/back/methods/mdbVersion/upload.js b/modules/mdb/back/methods/mdbVersion/upload.js
new file mode 100644
index 000000000..3d54c0250
--- /dev/null
+++ b/modules/mdb/back/methods/mdbVersion/upload.js
@@ -0,0 +1,121 @@
+const fs = require('fs-extra');
+const path = require('path');
+const UserError = require('vn-loopback/util/user-error');
+
+module.exports = Self => {
+ Self.remoteMethodCtx('upload', {
+ description: 'Upload and attach a access file',
+ accepts: [
+ {
+ arg: 'appName',
+ type: 'string',
+ required: true,
+ description: 'The app name'
+ },
+ {
+ arg: 'newVersion',
+ type: 'number',
+ required: true,
+ description: `The new version number`
+ },
+ {
+ arg: 'branch',
+ type: 'string',
+ required: true,
+ description: `The branch name`
+ }
+ ],
+ returns: {
+ type: ['object'],
+ root: true
+ },
+ http: {
+ path: `/upload`,
+ verb: 'POST'
+ }
+ });
+
+ Self.upload = async(ctx, appName, newVersion, branch, options) => {
+ const models = Self.app.models;
+ const myOptions = {};
+
+ const TempContainer = models.TempContainer;
+ const AccessContainer = models.AccessContainer;
+ const fileOptions = {};
+
+ let tx;
+
+ if (typeof options == 'object')
+ Object.assign(myOptions, options);
+
+ if (!myOptions.transaction) {
+ tx = await Self.beginTransaction({});
+ myOptions.transaction = tx;
+ }
+
+ let srcFile;
+ try {
+ const tempContainer = await TempContainer.container('access');
+ const uploaded = await TempContainer.upload(tempContainer.name, ctx.req, ctx.result, fileOptions);
+ const files = Object.values(uploaded.files).map(file => {
+ return file[0];
+ });
+ const uploadedFile = files[0];
+
+ const file = await TempContainer.getFile(tempContainer.name, uploadedFile.name);
+ srcFile = path.join(file.client.root, file.container, file.name);
+
+ const accessContainer = await AccessContainer.container('.archive');
+ const destinationFile = path.join(
+ accessContainer.client.root, accessContainer.name, appName, `${newVersion}.7z`);
+
+ if (process.env.NODE_ENV == 'test')
+ await fs.unlink(srcFile);
+ else {
+ await fs.move(srcFile, destinationFile, {
+ overwrite: true
+ });
+ await fs.chmod(destinationFile, 0o644);
+
+ const existBranch = await models.MdbBranch.findOne({
+ where: {name: branch}
+ });
+
+ if (!existBranch)
+ throw new UserError('Not exist this branch');
+
+ const branchPath = path.join(accessContainer.client.root, 'branches', branch);
+ await fs.mkdir(branchPath, {recursive: true});
+
+ const destinationBranch = path.join(branchPath, `${appName}.7z`);
+ const destinationRoot = path.join(accessContainer.client.root, `${appName}.7z`);
+ try {
+ await fs.unlink(destinationBranch);
+ } catch (e) {}
+ await fs.symlink(destinationFile, destinationBranch);
+
+ if (branch == 'master') {
+ try {
+ await fs.unlink(destinationRoot);
+ } catch (e) {}
+ await fs.symlink(destinationFile, destinationRoot);
+ }
+ }
+
+ await models.MdbVersion.upsert({
+ app: appName,
+ branchFk: branch,
+ version: newVersion
+ });
+
+ if (tx) await tx.commit();
+ } catch (e) {
+ if (tx) await tx.rollback();
+
+ if (fs.existsSync(srcFile))
+ await fs.unlink(srcFile);
+
+ throw e;
+ }
+ };
+};
diff --git a/modules/mdb/back/model-config.json b/modules/mdb/back/model-config.json
new file mode 100644
index 000000000..d5be8de87
--- /dev/null
+++ b/modules/mdb/back/model-config.json
@@ -0,0 +1,11 @@
+{
+ "MdbBranch": {
+ "dataSource": "vn"
+ },
+ "MdbVersion": {
+ "dataSource": "vn"
+ },
+ "AccessContainer": {
+ "dataSource": "accessStorage"
+ }
+}
diff --git a/modules/mdb/back/models/mdb-container.json b/modules/mdb/back/models/mdb-container.json
new file mode 100644
index 000000000..a927b30f1
--- /dev/null
+++ b/modules/mdb/back/models/mdb-container.json
@@ -0,0 +1,10 @@
+{
+ "name": "AccessContainer",
+ "base": "Container",
+ "acls": [{
+ "accessType": "*",
+ "principalType": "ROLE",
+ "principalId": "developer",
+ "permission": "ALLOW"
+ }]
+}
\ No newline at end of file
diff --git a/modules/mdb/back/models/mdbBranch.json b/modules/mdb/back/models/mdbBranch.json
new file mode 100644
index 000000000..486dfaf25
--- /dev/null
+++ b/modules/mdb/back/models/mdbBranch.json
@@ -0,0 +1,16 @@
+{
+ "name": "MdbBranch",
+ "base": "VnModel",
+ "options": {
+ "mysql": {
+ "table": "mdbBranch"
+ }
+ },
+ "properties": {
+ "name": {
+ "id": true,
+ "type": "string",
+ "description": "Identifier"
+ }
+ }
+}
\ No newline at end of file
diff --git a/modules/mdb/back/models/mdbVersion.js b/modules/mdb/back/models/mdbVersion.js
new file mode 100644
index 000000000..b36ee2a60
--- /dev/null
+++ b/modules/mdb/back/models/mdbVersion.js
@@ -0,0 +1,3 @@
+module.exports = Self => {
+ require('../methods/mdbVersion/upload')(Self);
+};
diff --git a/modules/mdb/back/models/mdbVersion.json b/modules/mdb/back/models/mdbVersion.json
new file mode 100644
index 000000000..02635ff8a
--- /dev/null
+++ b/modules/mdb/back/models/mdbVersion.json
@@ -0,0 +1,26 @@
+{
+ "name": "MdbVersion",
+ "base": "VnModel",
+ "options": {
+ "mysql": {
+ "table": "mdbVersion"
+ }
+ },
+ "properties": {
+ "app": {
+ "type": "string",
+ "description": "The app name",
+ "id": true
+ },
+ "version": {
+ "type": "number"
+ }
+ },
+ "relations": {
+ "branch": {
+ "type": "belongsTo",
+ "model": "MdbBranch",
+ "foreignKey": "branchFk"
+ }
+ }
+}
\ No newline at end of file
diff --git a/modules/monitor/back/methods/sales-monitor/clientsFilter.js b/modules/monitor/back/methods/sales-monitor/clientsFilter.js
index 44554c7e3..723d1e349 100644
--- a/modules/monitor/back/methods/sales-monitor/clientsFilter.js
+++ b/modules/monitor/back/methods/sales-monitor/clientsFilter.js
@@ -43,11 +43,9 @@ module.exports = Self => {
TIME(v.stamp) AS hour,
DATE(v.stamp) AS dated,
wtc.workerFk
- FROM hedera.userSession s
- JOIN hedera.visitUser v ON v.id = s.userVisitFk
+ FROM hedera.visitUser v
JOIN client c ON c.id = v.userFk
- LEFT JOIN account.user u ON c.salesPersonFk = u.id
- LEFT JOIN worker w ON c.salesPersonFk = w.id
+ JOIN account.user u ON c.salesPersonFk = u.id
LEFT JOIN sharingCart sc ON sc.workerFk = c.salesPersonFk
AND vn.VN_CURDATE() BETWEEN sc.started AND sc.ended
LEFT JOIN workerTeamCollegues wtc
@@ -58,7 +56,9 @@ module.exports = Self => {
const where = filter.where;
where['wtc.workerFk'] = userId;
- stmt.merge(conn.makeSuffix(filter));
+ stmt.merge(conn.makeWhere(filter.where));
+ stmt.merge(`GROUP BY clientFk, v.stamp`);
+ stmt.merge(conn.makePagination(filter));
return conn.executeStmt(stmt, myOptions);
};
diff --git a/modules/monitor/back/methods/sales-monitor/salesFilter.js b/modules/monitor/back/methods/sales-monitor/salesFilter.js
index 07c0f540b..694b8fb94 100644
--- a/modules/monitor/back/methods/sales-monitor/salesFilter.js
+++ b/modules/monitor/back/methods/sales-monitor/salesFilter.js
@@ -304,7 +304,8 @@ module.exports = Self => {
{'tp.hasTicketRequest': true},
{'tp.hasComponentLack': true},
{'tp.isTaxDataChecked': false},
- {'tp.isAvailable': false}
+ {'tp.itemShortage': {neq: null}},
+ {'tp.isTooLittle': true}
]};
} else if (hasProblems === false) {
whereProblems = {and: [
@@ -313,7 +314,8 @@ module.exports = Self => {
{'tp.hasTicketRequest': false},
{'tp.hasComponentLack': false},
{'tp.isTaxDataChecked': true},
- {'tp.isAvailable': true}
+ {'tp.itemShortage': null},
+ {'tp.isTooLittle': false}
]};
}
diff --git a/modules/monitor/back/methods/sales-monitor/specs/clientsFilter.spec.js b/modules/monitor/back/methods/sales-monitor/specs/clientsFilter.spec.js
index 3fcc6c91a..bcb37830c 100644
--- a/modules/monitor/back/methods/sales-monitor/specs/clientsFilter.spec.js
+++ b/modules/monitor/back/methods/sales-monitor/specs/clientsFilter.spec.js
@@ -6,12 +6,49 @@ describe('SalesMonitor clientsFilter()', () => {
try {
const options = {transaction: tx};
-
const ctx = {req: {accessToken: {userId: 18}}, args: {}};
- const filter = {order: 'dated DESC'};
+
+ const from = new Date();
+ const to = new Date();
+ from.setHours(0, 0, 0, 0);
+ to.setHours(23, 59, 59, 59);
+
+ const filter = {
+ where: {
+ 'v.stamp': {between: [from, to]}
+ }
+ };
const result = await models.SalesMonitor.clientsFilter(ctx, filter, options);
- expect(result.length).toEqual(9);
+ expect(result.length).toEqual(3);
+
+ await tx.rollback();
+ } catch (e) {
+ await tx.rollback();
+ throw e;
+ }
+ });
+
+ it('should return the clients web activity filtered', async() => {
+ const tx = await models.SalesMonitor.beginTransaction({});
+
+ try {
+ const options = {transaction: tx};
+ const ctx = {req: {accessToken: {userId: 18}}, args: {}};
+ const yesterday = new Date();
+ yesterday.setDate(yesterday.getDate() - 1);
+ const today = new Date();
+ yesterday.setHours(0, 0, 0, 0);
+ today.setHours(23, 59, 59, 59);
+
+ const filter = {
+ where: {
+ 'v.stamp': {between: [yesterday, today]}
+ }
+ };
+ const result = await models.SalesMonitor.clientsFilter(ctx, filter, options);
+
+ expect(result.length).toEqual(5);
await tx.rollback();
} catch (e) {
diff --git a/modules/monitor/front/index/clients/index.html b/modules/monitor/front/index/clients/index.html
index 35b52fa09..eafc2256e 100644
--- a/modules/monitor/front/index/clients/index.html
+++ b/modules/monitor/front/index/clients/index.html
@@ -88,8 +88,16 @@
-
+
+
+
+
+
Salesperson
-
+
Date
@@ -98,8 +98,8 @@
icon="icon-buyrequest">
@@ -153,8 +153,8 @@
-
- {{::ticket.shipped | date: 'dd/MM/yyyy'}}
+
+ {{::ticket.shippedDate | date: 'dd/MM/yyyy'}}
{{::ticket.zoneLanding | date: 'HH:mm'}}
diff --git a/modules/monitor/front/index/tickets/index.js b/modules/monitor/front/index/tickets/index.js
index 58b56bbc5..91d9079d8 100644
--- a/modules/monitor/front/index/tickets/index.js
+++ b/modules/monitor/front/index/tickets/index.js
@@ -52,8 +52,8 @@ export default class Controller extends Section {
}
},
{
- field: 'shipped',
- searchable: false
+ field: 'shippedDate',
+ datepicker: true
},
{
field: 'theoreticalHour',
@@ -136,7 +136,7 @@ export default class Controller extends Section {
return {'z.hour': value};
case 'practicalHour':
return {'zed.etc': value};
- case 'shipped':
+ case 'shippedDate':
return {'t.shipped': {
between: this.dateRange(value)}
};
diff --git a/modules/order/back/models/order-row.json b/modules/order/back/models/order-row.json
index 44d5a103a..4b78bfdad 100644
--- a/modules/order/back/models/order-row.json
+++ b/modules/order/back/models/order-row.json
@@ -8,12 +8,12 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"id": true,
"description": "Identifier"
},
"warehouseFk": {
- "type": "Number"
+ "type": "number"
},
"shipped": {
"type": "date",
@@ -22,22 +22,22 @@
}
},
"quantity": {
- "type": "Number",
+ "type": "number",
"mysql": {
"columnName": "amount"
}
},
"price": {
- "type": "Number"
+ "type": "number"
},
"rate": {
- "type": "Number"
+ "type": "number"
},
"created": {
"type": "date"
},
"saleFk": {
- "type": "Number"
+ "type": "number"
}
},
"relations": {
diff --git a/modules/order/back/models/order-ticket.json b/modules/order/back/models/order-ticket.json
index 2875ebdfc..9fe144b47 100644
--- a/modules/order/back/models/order-ticket.json
+++ b/modules/order/back/models/order-ticket.json
@@ -9,11 +9,11 @@
"properties": {
"orderFk": {
"id": true,
- "type": "Number"
+ "type": "number"
},
"ticketFk": {
"id": true,
- "type": "Number"
+ "type": "number"
}
},
"relations": {
diff --git a/modules/order/back/models/order.json b/modules/order/back/models/order.json
index 38755c2a5..169c0c550 100644
--- a/modules/order/back/models/order.json
+++ b/modules/order/back/models/order.json
@@ -8,80 +8,80 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"id": true,
"description": "Identifier"
},
"landed": {
- "type": "Date",
+ "type": "date",
"required": true,
"mysql": {
"columnName": "date_send"
}
},
"clientFk": {
- "type": "Number",
+ "type": "number",
"required": true,
"mysql": {
"columnName": "customer_id"
}
},
"addressFk": {
- "type": "Number",
+ "type": "number",
"required": true,
"mysql": {
"columnName": "address_id"
}
},
"agencyModeFk": {
- "type": "Number",
+ "type": "number",
"required": true,
"mysql": {
"columnName": "agency_id"
}
},
"companyFk": {
- "type": "Number",
+ "type": "number",
"required": true,
"mysql": {
"columnName": "company_id"
}
},
"note": {
- "type": "String"
+ "type": "string"
},
"sourceApp": {
- "type": "String",
+ "type": "string",
"mysql": {
"columnName": "source_app"
}
},
"isConfirmed": {
- "type": "Number",
+ "type": "number",
"mysql": {
"columnName": "confirmed"
}
},
"created": {
- "type": "Date",
+ "type": "date",
"mysql": {
"columnName": "date_make"
}
},
"firstRowStamp": {
- "type": "Date",
+ "type": "date",
"mysql": {
"columnName": "first_row_stamp"
}
},
"confirmed": {
- "type": "Date",
+ "type": "date",
"mysql": {
"columnName": "confirm_date"
}
},
"total": {
- "type": "Number"
+ "type": "number"
}
},
"relations": {
diff --git a/modules/order/front/index/index.html b/modules/order/front/index/index.html
index a2a4a5226..c4bed7307 100644
--- a/modules/order/front/index/index.html
+++ b/modules/order/front/index/index.html
@@ -33,7 +33,7 @@
{{::order.name | dashIfEmpty}}
-
+
@@ -46,7 +46,7 @@
disabled="true">
- {{::order.created | date: 'dd/MM/yyyy HH:mm'}}
+ {{::order.created | date: 'dd/MM/yyyy HH:mm'}}
{{::order.landed | date:'dd/MM/yyyy'}}
diff --git a/modules/route/back/methods/agency-term/specs/createInvoiceIn.spec.js b/modules/route/back/methods/agency-term/specs/createInvoiceIn.spec.js
index 81686144d..ad4613caf 100644
--- a/modules/route/back/methods/agency-term/specs/createInvoiceIn.spec.js
+++ b/modules/route/back/methods/agency-term/specs/createInvoiceIn.spec.js
@@ -1,7 +1,6 @@
const models = require('vn-loopback/server/server').models;
-// Include after #3638 export database
-xdescribe('AgencyTerm createInvoiceIn()', () => {
+describe('AgencyTerm createInvoiceIn()', () => {
const rows = [
{
routeFk: 2,
@@ -17,6 +16,7 @@ xdescribe('AgencyTerm createInvoiceIn()', () => {
];
it('should make an invoiceIn', async() => {
+ pending('Include after #3638 export database');
const tx = await models.AgencyTerm.beginTransaction({});
const options = {transaction: tx};
@@ -32,8 +32,12 @@ xdescribe('AgencyTerm createInvoiceIn()', () => {
await models.AgencyTerm.createInvoiceIn(rows, dms, options);
const [newInvoiceIn] = await models.InvoiceIn.rawSql('SELECT MAX(id) id FROM invoiceIn', null, options);
- const [newInvoiceInDueDay] = await models.InvoiceInDueDay.rawSql('SELECT MAX(id) id FROM invoiceInDueDay', null, options);
- const [newInvoiceInTax] = await models.InvoiceInTax.rawSql('SELECT MAX(id) id FROM invoiceInTax', null, options);
+
+ const dueDayQuery = 'SELECT MAX(id) id FROM invoiceInDueDay';
+ const [newInvoiceInDueDay] = await models.InvoiceInDueDay.rawSql(dueDayQuery, null, options);
+
+ const taxQuery = 'SELECT MAX(id) id FROM invoiceInTax';
+ const [newInvoiceInTax] = await models.InvoiceInTax.rawSql(taxQuery, null, options);
expect(newInvoiceIn.id).toBeGreaterThan(oldInvoiceIn.id);
expect(newInvoiceInDueDay.id).toBeGreaterThan(oldInvoiceInDueDay.id);
diff --git a/modules/route/back/methods/route/getSuggestedTickets.js b/modules/route/back/methods/route/getSuggestedTickets.js
index f0333e66b..c1a9c7cae 100644
--- a/modules/route/back/methods/route/getSuggestedTickets.js
+++ b/modules/route/back/methods/route/getSuggestedTickets.js
@@ -59,6 +59,12 @@ module.exports = Self => {
fields: ['id', 'name']
}
},
+ {
+ relation: 'agencyMode',
+ scope: {
+ fields: ['id', 'name']
+ }
+ },
{
relation: 'address',
scope: {
diff --git a/modules/route/back/methods/route/specs/guessPriority.spec.js b/modules/route/back/methods/route/specs/guessPriority.spec.js
index 892324acf..902647ba1 100644
--- a/modules/route/back/methods/route/specs/guessPriority.spec.js
+++ b/modules/route/back/methods/route/specs/guessPriority.spec.js
@@ -1,9 +1,21 @@
const app = require('vn-loopback/server/server');
+const LoopBackContext = require('loopback-context');
describe('route guessPriority()', () => {
const targetRouteId = 7;
let routeTicketsToRestore;
+ const activeCtx = {
+ accessToken: {userId: 9},
+ __: () => {}
+ };
+
+ beforeAll(() => {
+ spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
+ active: activeCtx
+ });
+ });
+
afterAll(async() => {
let restoreFixtures = [];
routeTicketsToRestore.forEach(ticket => {
@@ -12,12 +24,9 @@ describe('route guessPriority()', () => {
await Promise.all(restoreFixtures);
});
- it('should call guessPriority() and then check the tickets in the target route now have their priorities defined', async() => {
+ it('should call guessPriority() then check all tickets in that route have their priorities defined', async() => {
const ctx = {
- req: {
- accessToken: {userId: 9},
- __: () => {}
- },
+ req: activeCtx
};
routeTicketsToRestore = await app.models.Ticket.find({where: {routeFk: targetRouteId}});
diff --git a/modules/route/back/models/deliveryPoint.json b/modules/route/back/models/deliveryPoint.json
index c6c0a2116..639f21e35 100644
--- a/modules/route/back/models/deliveryPoint.json
+++ b/modules/route/back/models/deliveryPoint.json
@@ -8,15 +8,15 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"id": true,
"description": "Identifier"
},
"name": {
- "type": "String"
+ "type": "string"
},
"ubication": {
- "type": "String"
+ "type": "string"
}
}
}
diff --git a/modules/route/back/models/route-log.json b/modules/route/back/models/route-log.json
index abaeeb722..37f898267 100644
--- a/modules/route/back/models/route-log.json
+++ b/modules/route/back/models/route-log.json
@@ -9,40 +9,40 @@
"properties": {
"id": {
"id": true,
- "type": "Number",
+ "type": "number",
"forceId": false
},
"originFk": {
- "type": "Number",
+ "type": "number",
"required": true
},
"userFk": {
- "type": "Number"
+ "type": "number"
},
"action": {
- "type": "String",
+ "type": "string",
"required": true
},
"changedModel": {
- "type": "String"
+ "type": "string"
},
"oldInstance": {
- "type": "Object"
+ "type": "object"
},
"newInstance": {
- "type": "Object"
+ "type": "object"
},
"creationDate": {
- "type": "Date"
+ "type": "date"
},
"changedModelId": {
- "type": "Number"
+ "type": "number"
},
"changedModelValue": {
- "type": "String"
+ "type": "string"
},
"description": {
- "type": "String"
+ "type": "string"
}
},
"relations": {
diff --git a/modules/route/back/models/route.json b/modules/route/back/models/route.json
index bdb641096..46fb6b76f 100644
--- a/modules/route/back/models/route.json
+++ b/modules/route/back/models/route.json
@@ -11,7 +11,7 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"id": true,
"description": "Identifier"
},
@@ -22,10 +22,10 @@
"type": "date"
},
"kmStart": {
- "type": "Number"
+ "type": "number"
},
"kmEnd": {
- "type": "Number"
+ "type": "number"
},
"started": {
"type": "date"
@@ -40,13 +40,13 @@
}
},
"cost": {
- "type": "Number"
+ "type": "number"
},
"m3": {
- "type": "Number"
+ "type": "number"
},
"description": {
- "type": "String"
+ "type": "string"
}
},
"relations": {
diff --git a/modules/route/back/models/vehicle.json b/modules/route/back/models/vehicle.json
index 399480c98..a35926bef 100644
--- a/modules/route/back/models/vehicle.json
+++ b/modules/route/back/models/vehicle.json
@@ -8,27 +8,27 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"id": true,
"description": "Identifier"
},
"numberPlate": {
- "type": "String"
+ "type": "string"
},
"tradeMark": {
- "type": "String"
+ "type": "string"
},
"model": {
- "type": "String"
+ "type": "string"
},
"m3": {
- "type": "Number"
+ "type": "number"
},
"description": {
- "type": "String"
+ "type": "string"
},
"isActive": {
- "type": "Number"
+ "type": "number"
}
},
"relations": {
diff --git a/modules/route/front/locale/en.yml b/modules/route/front/locale/en.yml
new file mode 100644
index 000000000..0e5302b14
--- /dev/null
+++ b/modules/route/front/locale/en.yml
@@ -0,0 +1 @@
+Unlink zone: Unlink zone {{zoneName}} from agency {{agencyName}}
\ No newline at end of file
diff --git a/modules/route/front/locale/es.yml b/modules/route/front/locale/es.yml
index 268bc4812..74ab2cd61 100644
--- a/modules/route/front/locale/es.yml
+++ b/modules/route/front/locale/es.yml
@@ -1,4 +1,5 @@
Routes: Rutas
Search routes by id: Buscar rutas por identificador
New route: Nueva ruta
-route: ruta
\ No newline at end of file
+route: ruta
+Unlink zone: Desvincular zona {{zoneName}} de agencia {{agencyName}}
\ No newline at end of file
diff --git a/modules/route/front/ticket-popup/index.html b/modules/route/front/ticket-popup/index.html
index 33684a433..99e3364b8 100644
--- a/modules/route/front/ticket-popup/index.html
+++ b/modules/route/front/ticket-popup/index.html
@@ -33,7 +33,7 @@
PC
Address
- Warehouse
+ Zone
@@ -62,7 +62,7 @@
@@ -76,4 +76,9 @@
question="{{$ctrl.confirmationMessage}}"
message="Unlink selected zone?">
+
+
+
+
+
diff --git a/modules/supplier/back/methods/supplier/getSummary.js b/modules/supplier/back/methods/supplier/getSummary.js
index 67f5267b6..bf3fa56f5 100644
--- a/modules/supplier/back/methods/supplier/getSummary.js
+++ b/modules/supplier/back/methods/supplier/getSummary.js
@@ -41,7 +41,9 @@ module.exports = Self => {
'sageTaxTypeFk',
'sageTransactionTypeFk',
'sageWithholdingFk',
- 'workerFk'
+ 'workerFk',
+ 'supplierActivityFk',
+ 'healthRegister'
],
include: [
{
@@ -98,14 +100,15 @@ module.exports = Self => {
}
}
},
+ {
+ relation: 'supplierActivity',
+ scope: {
+ fields: ['code', 'name']
+ }
+ }
]
};
- let supplier = await Self.app.models.Supplier.findOne(filter);
- const farmerCode = 2;
- if (supplier.sageWithholdingFk == farmerCode)
- supplier.isFarmer = true;
-
- return supplier;
+ return Self.app.models.Supplier.findOne(filter);
};
};
diff --git a/modules/supplier/back/methods/supplier/specs/getSummary.spec.js b/modules/supplier/back/methods/supplier/specs/getSummary.spec.js
index 21e56882f..30713f517 100644
--- a/modules/supplier/back/methods/supplier/specs/getSummary.spec.js
+++ b/modules/supplier/back/methods/supplier/specs/getSummary.spec.js
@@ -25,12 +25,4 @@ describe('Supplier getSummary()', () => {
expect(payMethod.name).toEqual('PayMethod one');
});
-
- it(`should get if supplier is farmer by sageWithholdingFk`, async() => {
- const supplier = await app.models.Supplier.findById(2);
- const supplierSummary = await app.models.Supplier.getSummary(2);
-
- expect(supplier.isFarmer).toBeUndefined();
- expect(supplierSummary.isFarmer).toEqual(true);
- });
});
diff --git a/modules/supplier/back/methods/supplier/specs/updateFiscalData.spec.js b/modules/supplier/back/methods/supplier/specs/updateFiscalData.spec.js
index 0eec54926..a47e547d1 100644
--- a/modules/supplier/back/methods/supplier/specs/updateFiscalData.spec.js
+++ b/modules/supplier/back/methods/supplier/specs/updateFiscalData.spec.js
@@ -66,6 +66,8 @@ describe('Supplier updateFiscalData', () => {
city: 'VALENCIA',
provinceFk: 2,
countryFk: 1,
+ supplierActivityFk: 'animals',
+ healthRegister: '400664487H'
};
const result = await app.models.Supplier.updateFiscalData(ctx, supplierId);
@@ -80,6 +82,8 @@ describe('Supplier updateFiscalData', () => {
expect(result.city).toEqual('VALENCIA');
expect(result.provinceFk).toEqual(2);
expect(result.countryFk).toEqual(1);
+ expect(result.supplierActivityFk).toEqual('animals');
+ expect(result.healthRegister).toEqual('400664487H');
// Restores
ctx.args = defaultData;
diff --git a/modules/supplier/back/methods/supplier/updateFiscalData.js b/modules/supplier/back/methods/supplier/updateFiscalData.js
index daa602af0..4604b3f91 100644
--- a/modules/supplier/back/methods/supplier/updateFiscalData.js
+++ b/modules/supplier/back/methods/supplier/updateFiscalData.js
@@ -56,6 +56,14 @@ module.exports = Self => {
{
arg: 'countryFk',
type: 'any'
+ },
+ {
+ arg: 'supplierActivityFk',
+ type: 'string'
+ },
+ {
+ arg: 'healthRegister',
+ type: 'string'
}],
returns: {
arg: 'res',
diff --git a/modules/supplier/back/model-config.json b/modules/supplier/back/model-config.json
index 7c1bba1ec..dbc387ed2 100644
--- a/modules/supplier/back/model-config.json
+++ b/modules/supplier/back/model-config.json
@@ -11,6 +11,9 @@
"SupplierAccount": {
"dataSource": "vn"
},
+ "SupplierActivity": {
+ "dataSource": "vn"
+ },
"SupplierAgencyTerm": {
"dataSource": "vn"
},
diff --git a/modules/supplier/back/models/pay-dem.json b/modules/supplier/back/models/pay-dem.json
index f214f3e3a..1253c751c 100644
--- a/modules/supplier/back/models/pay-dem.json
+++ b/modules/supplier/back/models/pay-dem.json
@@ -8,12 +8,12 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"id": true,
"description": "Identifier"
},
"payDem": {
- "type": "Number"
+ "type": "number"
}
}
}
diff --git a/modules/supplier/back/models/supplier-account.json b/modules/supplier/back/models/supplier-account.json
index 8e2838fe5..2ee83338b 100644
--- a/modules/supplier/back/models/supplier-account.json
+++ b/modules/supplier/back/models/supplier-account.json
@@ -12,15 +12,15 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"id": true,
"description": "Identifier"
},
"iban": {
- "type": "String"
+ "type": "string"
},
"beneficiary": {
- "type": "String"
+ "type": "string"
}
},
"relations": {
diff --git a/modules/supplier/back/models/supplier-activity.json b/modules/supplier/back/models/supplier-activity.json
new file mode 100644
index 000000000..7a0b9a537
--- /dev/null
+++ b/modules/supplier/back/models/supplier-activity.json
@@ -0,0 +1,18 @@
+{
+ "name": "SupplierActivity",
+ "base": "VnModel",
+ "options": {
+ "mysql": {
+ "table": "supplierActivity"
+ }
+ },
+ "properties": {
+ "code": {
+ "type": "string",
+ "id": true
+ },
+ "name": {
+ "type": "string"
+ }
+ }
+}
\ No newline at end of file
diff --git a/modules/supplier/back/models/supplier-contact.json b/modules/supplier/back/models/supplier-contact.json
index 104a3a404..9e13c33a8 100644
--- a/modules/supplier/back/models/supplier-contact.json
+++ b/modules/supplier/back/models/supplier-contact.json
@@ -12,27 +12,27 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"id": true,
"description": "Identifier"
},
"supplierFk": {
- "type": "String"
+ "type": "string"
},
"phone": {
- "type": "String"
+ "type": "string"
},
"mobile": {
- "type": "String"
+ "type": "string"
},
"email": {
- "type": "String"
+ "type": "string"
},
"observation": {
- "type": "String"
+ "type": "string"
},
"name": {
- "type": "String"
+ "type": "string"
}
},
"relations": {
diff --git a/modules/supplier/back/models/supplier.json b/modules/supplier/back/models/supplier.json
index 8b4b8f26f..b27073ca5 100644
--- a/modules/supplier/back/models/supplier.json
+++ b/modules/supplier/back/models/supplier.json
@@ -101,6 +101,12 @@
},
"isPayMethodChecked": {
"type": "boolean"
+ },
+ "supplierActivityFk": {
+ "type": "string"
+ },
+ "healthRegister": {
+ "type": "string"
}
},
"relations": {
@@ -159,6 +165,11 @@
"type": "hasMany",
"model": "SupplierAddress",
"foreignKey": "supplierFk"
+ },
+ "supplierActivity": {
+ "type": "belongsTo",
+ "model": "SupplierActivity",
+ "foreignKey": "supplierActivityFk"
}
}
}
\ No newline at end of file
diff --git a/modules/supplier/front/agency-term/index/index.html b/modules/supplier/front/agency-term/index/index.html
index ac3b9b0d5..9d53226c5 100644
--- a/modules/supplier/front/agency-term/index/index.html
+++ b/modules/supplier/front/agency-term/index/index.html
@@ -78,7 +78,7 @@
diff --git a/modules/supplier/front/fiscal-data/index.html b/modules/supplier/front/fiscal-data/index.html
index fc44468f4..77a5cce4e 100644
--- a/modules/supplier/front/fiscal-data/index.html
+++ b/modules/supplier/front/fiscal-data/index.html
@@ -30,6 +30,11 @@
data="sageWithholdings"
order="withholding">
+
+
@@ -87,6 +92,22 @@
{{id}}: {{transaction}}
+
+
+
+
+
+
-
-
@@ -118,6 +113,13 @@
label="Sage withholding"
value="{{::$ctrl.summary.sageWithholding.withholding}}">
+
+
+
diff --git a/modules/supplier/front/summary/locale/es.yml b/modules/supplier/front/summary/locale/es.yml
index 512b75f9d..35291e579 100644
--- a/modules/supplier/front/summary/locale/es.yml
+++ b/modules/supplier/front/summary/locale/es.yml
@@ -7,4 +7,6 @@ Sage tax type: Tipo de impuesto Sage
Sage transaction type: Tipo de transacción Sage
Sage withholding: Retencion Sage
Go to the supplier: Ir al proveedor
-Responsible: Responsable
\ No newline at end of file
+Responsible: Responsable
+Supplier activity: Actividad proveedor
+Healt register: Pasaporte sanitario
\ No newline at end of file
diff --git a/modules/ticket/back/methods/expedition-state/filter.js b/modules/ticket/back/methods/expedition-state/filter.js
new file mode 100644
index 000000000..1483780f7
--- /dev/null
+++ b/modules/ticket/back/methods/expedition-state/filter.js
@@ -0,0 +1,41 @@
+const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
+
+module.exports = Self => {
+ Self.remoteMethod('filter', {
+ description: 'Find all instances of the model matched by filter from the data source.',
+ accessType: 'READ',
+ accepts: [
+ {
+ arg: 'filter',
+ type: 'object',
+ description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string',
+ http: {source: 'query'},
+ },
+ ],
+ returns: {
+ type: ['object'],
+ root: true,
+ },
+ http: {
+ path: `/filter`,
+ verb: 'GET',
+ },
+ });
+
+ Self.filter = async(filter, options) => {
+ const myOptions = {};
+
+ if (typeof options == 'object')
+ Object.assign(myOptions, options);
+
+ const stmt = new ParameterizedSQL(
+ `SELECT es.created, u.name, u.id workerFk, est.description state
+ FROM vn.expeditionState es
+ JOIN vn.expeditionStateType est ON est.id = es.typeFk
+ JOIN account.user u ON u.id = es.userFk
+ `);
+ stmt.merge(Self.buildSuffix(filter, 'es'));
+
+ return Self.rawStmt(stmt, myOptions);
+ };
+};
diff --git a/modules/ticket/back/methods/expedition-state/specs/filter.spec.js b/modules/ticket/back/methods/expedition-state/specs/filter.spec.js
new file mode 100644
index 000000000..f144606eb
--- /dev/null
+++ b/modules/ticket/back/methods/expedition-state/specs/filter.spec.js
@@ -0,0 +1,21 @@
+const models = require('vn-loopback/server/server').models;
+
+describe('expeditionState filter()', () => {
+ it('should return the expedition states matching the filter', async() => {
+ const tx = await models.ExpeditionState.beginTransaction({});
+
+ try {
+ const options = {transaction: tx};
+
+ const filter = {where: {expeditionFk: 5}};
+ const response = await models.ExpeditionState.filter(filter, options);
+
+ expect(response.length).toEqual(2);
+
+ await tx.rollback();
+ } catch (e) {
+ await tx.rollback();
+ throw e;
+ }
+ });
+});
diff --git a/modules/ticket/back/methods/expedition/filter.js b/modules/ticket/back/methods/expedition/filter.js
index 5eb7510b7..723d7c844 100644
--- a/modules/ticket/back/methods/expedition/filter.js
+++ b/modules/ticket/back/methods/expedition/filter.js
@@ -36,7 +36,6 @@ module.exports = Self => {
e.workerFk,
i1.name packageItemName,
e.counter,
- e.checked,
i2.name freightItemName,
e.itemFk,
u.name userName,
@@ -47,9 +46,10 @@ module.exports = Self => {
e.packagingFk,
es.workerFk expeditionScanWorkerFk,
su.name scannerUserName,
- es.scanned
- FROM
- vn.expedition e
+ es.scanned,
+ est.description state
+ FROM vn.expedition e
+ LEFT JOIN vn.expeditionStateType est ON est.id = e.stateTypeFk
LEFT JOIN vn.item i2 ON i2.id = e.itemFk
INNER JOIN vn.item i1 ON i1.id = e.isBox
LEFT JOIN vn.packaging p ON p.id = e.packagingFk
diff --git a/modules/ticket/back/methods/sale/refund.js b/modules/ticket/back/methods/sale/refund.js
index 9c87f23d3..83a420a8e 100644
--- a/modules/ticket/back/methods/sale/refund.js
+++ b/modules/ticket/back/methods/sale/refund.js
@@ -2,19 +2,19 @@ const UserError = require('vn-loopback/util/user-error');
module.exports = Self => {
Self.remoteMethodCtx('refund', {
- description: 'Create ticket with the selected lines changing the sign to the quantites',
+ description: 'Create ticket refund with lines and services changing the sign to the quantites',
accessType: 'WRITE',
accepts: [{
arg: 'sales',
description: 'The sales',
type: ['object'],
- required: true
+ required: false
},
{
- arg: 'ticketId',
- type: 'number',
- required: true,
- description: 'The ticket id'
+ arg: 'services',
+ type: ['object'],
+ required: false,
+ description: 'The services'
}],
returns: {
type: 'number',
@@ -26,7 +26,7 @@ module.exports = Self => {
}
});
- Self.refund = async(ctx, sales, ticketId, options) => {
+ Self.refund = async(ctx, sales, services, options) => {
const myOptions = {};
let tx;
@@ -39,7 +39,6 @@ module.exports = Self => {
}
try {
- const salesIds = [];
const userId = ctx.req.accessToken.userId;
const isClaimManager = await Self.app.models.Account.hasRole(userId, 'claimManager');
@@ -49,39 +48,47 @@ module.exports = Self => {
if (!hasValidRole)
throw new UserError(`You don't have privileges to create refund`);
- for (let sale of sales)
- salesIds.push(sale.id);
+ const salesIds = [];
+ if (sales) {
+ for (let sale of sales)
+ salesIds.push(sale.id);
+ } else
+ salesIds.push(null);
+
+ const servicesIds = [];
+ if (services) {
+ for (let service of services)
+ servicesIds.push(service.id);
+ } else
+ servicesIds.push(null);
const query = `
DROP TEMPORARY TABLE IF EXISTS tmp.sale;
DROP TEMPORARY TABLE IF EXISTS tmp.ticketService;
CREATE TEMPORARY TABLE tmp.sale
- SELECT s.id, s.itemFk, - s.quantity, s.concept, s.price, s.discount
+ SELECT s.id, s.itemFk, s.quantity, s.concept, s.price, s.discount, s.ticketFk
FROM sale s
WHERE s.id IN (?);
- CREATE TEMPORARY TABLE tmp.ticketService(
- description VARCHAR(50),
- quantity DECIMAL (10,2),
- price DECIMAL (10,2),
- taxClassFk INT,
- ticketServiceTypeFk INT
- );
-
- CALL vn.ticket_doRefund(?, @newTicket);
+ CREATE TEMPORARY TABLE tmp.ticketService
+ SELECT ts.description, ts.quantity, ts.price, ts.taxClassFk, ts.ticketServiceTypeFk, ts.ticketFk
+ FROM ticketService ts
+ WHERE ts.id IN (?);
+
+ CALL vn.ticket_doRefund(@newTicket);
DROP TEMPORARY TABLE tmp.sale;
DROP TEMPORARY TABLE tmp.ticketService;`;
- await Self.rawSql(query, [salesIds, ticketId], myOptions);
+ await Self.rawSql(query, [salesIds, servicesIds], myOptions);
const [newTicket] = await Self.rawSql('SELECT @newTicket id', null, myOptions);
- ticketId = newTicket.id;
+ const newTicketId = newTicket.id;
if (tx) await tx.commit();
- return ticketId;
+ return newTicketId;
} catch (e) {
if (tx) await tx.rollback();
throw e;
diff --git a/modules/ticket/back/methods/sale/refundAll.js b/modules/ticket/back/methods/sale/refundAll.js
deleted file mode 100644
index 6fcd27f0a..000000000
--- a/modules/ticket/back/methods/sale/refundAll.js
+++ /dev/null
@@ -1,78 +0,0 @@
-const UserError = require('vn-loopback/util/user-error');
-
-module.exports = Self => {
- Self.remoteMethodCtx('refundAll', {
- description: 'Create ticket with all lines and services changing the sign to the quantites',
- accessType: 'WRITE',
- accepts: [{
- arg: 'ticketId',
- type: 'number',
- required: true,
- description: 'The ticket id'
- }],
- returns: {
- type: 'number',
- root: true
- },
- http: {
- path: `/refundAll`,
- verb: 'post'
- }
- });
-
- Self.refundAll = async(ctx, ticketId, options) => {
- const myOptions = {};
- let tx;
-
- if (typeof options == 'object')
- Object.assign(myOptions, options);
-
- if (!myOptions.transaction) {
- tx = await Self.beginTransaction({});
- myOptions.transaction = tx;
- }
-
- try {
- const userId = ctx.req.accessToken.userId;
-
- const isClaimManager = await Self.app.models.Account.hasRole(userId, 'claimManager');
- const isSalesAssistant = await Self.app.models.Account.hasRole(userId, 'salesAssistant');
- const hasValidRole = isClaimManager || isSalesAssistant;
-
- if (!hasValidRole)
- throw new UserError(`You don't have privileges to create refund`);
-
- const query = `
- DROP TEMPORARY TABLE IF EXISTS tmp.sale;
- DROP TEMPORARY TABLE IF EXISTS tmp.ticketService;
-
- CREATE TEMPORARY TABLE tmp.sale
- SELECT s.id, s.itemFk, - s.quantity, s.concept, s.price, s.discount
- FROM sale s
- JOIN ticket t ON t.id = s.ticketFk
- WHERE t.id IN (?);
-
- CREATE TEMPORARY TABLE tmp.ticketService
- SELECT ts.description, - ts.quantity, ts.price, ts.taxClassFk, ts.ticketServiceTypeFk
- FROM ticketService ts
- WHERE ts.ticketFk IN (?);
-
- CALL vn.ticket_doRefund(?, @newTicket);
-
- DROP TEMPORARY TABLE tmp.sale;
- DROP TEMPORARY TABLE tmp.ticketService;`;
-
- await Self.rawSql(query, [ticketId, ticketId, ticketId], myOptions);
-
- const [newTicket] = await Self.rawSql('SELECT @newTicket id', null, myOptions);
- ticketId = newTicket.id;
-
- if (tx) await tx.commit();
-
- return ticketId;
- } catch (e) {
- if (tx) await tx.rollback();
- throw e;
- }
- };
-};
diff --git a/modules/ticket/back/methods/sale/specs/refund.spec.js b/modules/ticket/back/methods/sale/specs/refund.spec.js
index 40fd6c17e..5cb353055 100644
--- a/modules/ticket/back/methods/sale/specs/refund.spec.js
+++ b/modules/ticket/back/methods/sale/specs/refund.spec.js
@@ -1,20 +1,20 @@
const models = require('vn-loopback/server/server').models;
describe('sale refund()', () => {
+ const sales = [
+ {id: 7, ticketFk: 11},
+ {id: 8, ticketFk: 11}
+ ];
+ const services = [{id: 1}];
+
it('should create ticket with the selected lines changing the sign to the quantites', async() => {
const tx = await models.Sale.beginTransaction({});
const ctx = {req: {accessToken: {userId: 9}}};
- const ticketId = 11;
- const sales = [
- {id: 7, ticketFk: 11},
- {id: 8, ticketFk: 11}
- ];
-
try {
const options = {transaction: tx};
- const response = await models.Sale.refund(ctx, sales, ticketId, options);
+ const response = await models.Sale.refund(ctx, sales, services, options);
const [newTicketId] = await models.Sale.rawSql('SELECT MAX(t.id) id FROM vn.ticket t;', null, options);
expect(response).toEqual(newTicketId.id);
@@ -30,17 +30,12 @@ describe('sale refund()', () => {
const tx = await models.Sale.beginTransaction({});
const ctx = {req: {accessToken: {userId: 1}}};
- const ticketId = 11;
- const sales = [
- {id: 7, ticketFk: 11}
- ];
-
let error;
try {
const options = {transaction: tx};
- await models.Sale.refund(ctx, sales, ticketId, options);
+ await models.Sale.refund(ctx, sales, services, options);
await tx.rollback();
} catch (e) {
diff --git a/modules/ticket/back/methods/ticket/filter.js b/modules/ticket/back/methods/ticket/filter.js
index 331f2c486..b4ed91bce 100644
--- a/modules/ticket/back/methods/ticket/filter.js
+++ b/modules/ticket/back/methods/ticket/filter.js
@@ -324,7 +324,7 @@ module.exports = Self => {
case true:
condition = `or`;
hasProblem = true;
- range = 0;
+ range = {neq: null};
hasWhere = true;
break;
@@ -340,7 +340,7 @@ module.exports = Self => {
{'tp.isFreezed': hasProblem},
{'tp.risk': hasProblem},
{'tp.hasTicketRequest': hasProblem},
- {'tp.isAvailable': range}
+ {'tp.itemShortage': range}
]};
if (hasWhere)
diff --git a/modules/ticket/back/methods/ticket/getSales.js b/modules/ticket/back/methods/ticket/getSales.js
index 6dfee5dfa..3e45b3fb5 100644
--- a/modules/ticket/back/methods/ticket/getSales.js
+++ b/modules/ticket/back/methods/ticket/getSales.js
@@ -94,7 +94,7 @@ module.exports = Self => {
sale.visible = itemStock.visible;
sale.claim = claimedSales.get(sale.id);
if (problems) {
- sale.isAvailable = problems.isAvailable;
+ sale.itemShortage = problems.itemShortage;
sale.hasTicketRequest = problems.hasTicketRequest;
sale.hasComponentLack = problems.hasComponentLack;
}
diff --git a/modules/ticket/back/methods/ticket/sendSms.js b/modules/ticket/back/methods/ticket/sendSms.js
index efe8ff206..a0adcae07 100644
--- a/modules/ticket/back/methods/ticket/sendSms.js
+++ b/modules/ticket/back/methods/ticket/sendSms.js
@@ -45,7 +45,7 @@ module.exports = Self => {
const userId = ctx.req.accessToken.userId;
try {
- const sms = await Self.app.models.Sms.send(ctx, id, destination, message);
+ const sms = await Self.app.models.Sms.send(ctx, destination, message);
const logRecord = {
originFk: id,
userFk: userId,
diff --git a/modules/ticket/back/methods/ticket/specs/filter.spec.js b/modules/ticket/back/methods/ticket/specs/filter.spec.js
index b251d5335..4b583fc87 100644
--- a/modules/ticket/back/methods/ticket/specs/filter.spec.js
+++ b/modules/ticket/back/methods/ticket/specs/filter.spec.js
@@ -39,7 +39,7 @@ describe('ticket filter()', () => {
const filter = {};
const result = await models.Ticket.filter(ctx, filter, options);
- expect(result.length).toEqual(4);
+ expect(result.length).toEqual(6);
await tx.rollback();
} catch (e) {
diff --git a/modules/ticket/back/methods/ticket/specs/setDeleted.spec.js b/modules/ticket/back/methods/ticket/specs/setDeleted.spec.js
index 04e1c140a..9b629e634 100644
--- a/modules/ticket/back/methods/ticket/specs/setDeleted.spec.js
+++ b/modules/ticket/back/methods/ticket/specs/setDeleted.spec.js
@@ -28,8 +28,9 @@ describe('ticket setDeleted()', () => {
expect(error.message).toEqual('You must delete the claim id %d first');
});
- // test excluded by task #3693
- xit('should delete the ticket, remove the stowaway link and change the stowaway ticket state to "FIXING" and get rid of the itemshelving', async() => {
+
+ it('should delete ticket, remove stowaway and itemshelving then change stowaway state to "FIXING" ', async() => {
+ pending('test excluded by task #3693');
const tx = await models.Ticket.beginTransaction({});
try {
diff --git a/modules/ticket/back/model-config.json b/modules/ticket/back/model-config.json
index 5d5f08694..41885ee33 100644
--- a/modules/ticket/back/model-config.json
+++ b/modules/ticket/back/model-config.json
@@ -14,6 +14,9 @@
"Expedition": {
"dataSource": "vn"
},
+ "ExpeditionState": {
+ "dataSource": "vn"
+ },
"Packaging": {
"dataSource": "vn"
},
diff --git a/modules/ticket/back/models/annual-average-invoiced.json b/modules/ticket/back/models/annual-average-invoiced.json
index d1f582011..02f097d41 100644
--- a/modules/ticket/back/models/annual-average-invoiced.json
+++ b/modules/ticket/back/models/annual-average-invoiced.json
@@ -8,7 +8,7 @@
},
"properties": {
"invoiced": {
- "type": "Number"
+ "type": "number"
},
"clientFk": {
"id": true
diff --git a/modules/ticket/back/models/component-type.json b/modules/ticket/back/models/component-type.json
index d72217a24..26daf5216 100644
--- a/modules/ticket/back/models/component-type.json
+++ b/modules/ticket/back/models/component-type.json
@@ -9,11 +9,11 @@
"properties": {
"id": {
"id": true,
- "type": "Number",
+ "type": "number",
"description": "Identifier"
},
"type": {
- "type": "String"
+ "type": "string"
},
"isBase":{
"type":"Boolean"
diff --git a/modules/ticket/back/models/component.json b/modules/ticket/back/models/component.json
index 002b4804f..46ac492c5 100644
--- a/modules/ticket/back/models/component.json
+++ b/modules/ticket/back/models/component.json
@@ -9,26 +9,26 @@
"properties": {
"id": {
"id": true,
- "type": "Number",
+ "type": "number",
"description": "Identifier"
},
"name": {
- "type": "String"
+ "type": "string"
},
"classRate": {
- "type": "Number"
+ "type": "number"
},
"tax": {
- "type": "Number"
+ "type": "number"
},
"isRenewable": {
- "type": "Number"
+ "type": "number"
},
"typeFk": {
- "type": "Number"
+ "type": "number"
},
"code": {
- "type": "String"
+ "type": "string"
}
},
"relations": {
diff --git a/modules/ticket/back/models/expedition-state.js b/modules/ticket/back/models/expedition-state.js
new file mode 100644
index 000000000..af76af718
--- /dev/null
+++ b/modules/ticket/back/models/expedition-state.js
@@ -0,0 +1,3 @@
+module.exports = function(Self) {
+ require('../methods/expedition-state/filter')(Self);
+};
diff --git a/modules/ticket/back/models/expedition-state.json b/modules/ticket/back/models/expedition-state.json
new file mode 100644
index 000000000..262eb2e38
--- /dev/null
+++ b/modules/ticket/back/models/expedition-state.json
@@ -0,0 +1,28 @@
+{
+ "name": "ExpeditionState",
+ "base": "VnModel",
+ "options": {
+ "mysql": {
+ "table": "expeditionState"
+ }
+ },
+ "properties": {
+ "id": {
+ "id": true,
+ "type": "number",
+ "description": "Identifier"
+ },
+ "created": {
+ "type": "date"
+ },
+ "expeditionFk": {
+ "type": "number"
+ },
+ "typeFk": {
+ "type": "number"
+ },
+ "userFk": {
+ "type": "number"
+ }
+ }
+}
diff --git a/modules/ticket/back/models/expedition.json b/modules/ticket/back/models/expedition.json
index c0b8d6508..fc94f185d 100644
--- a/modules/ticket/back/models/expedition.json
+++ b/modules/ticket/back/models/expedition.json
@@ -13,17 +13,17 @@
"properties": {
"id": {
"id": true,
- "type": "Number",
+ "type": "number",
"description": "Identifier"
},
"isBox": {
- "type": "Number"
+ "type": "number"
},
"created": {
- "type": "Date"
+ "type": "date"
},
"counter": {
- "type": "Number"
+ "type": "number"
}
},
"relations": {
diff --git a/modules/ticket/back/models/sale-checked.json b/modules/ticket/back/models/sale-checked.json
index 8ac52d598..96d790505 100644
--- a/modules/ticket/back/models/sale-checked.json
+++ b/modules/ticket/back/models/sale-checked.json
@@ -8,7 +8,7 @@
},
"properties": {
"isChecked": {
- "type": "Number"
+ "type": "number"
},
"saleFk": {
"id": true
diff --git a/modules/ticket/back/models/sale-component.json b/modules/ticket/back/models/sale-component.json
index 3b7991fbb..bf0f73e29 100644
--- a/modules/ticket/back/models/sale-component.json
+++ b/modules/ticket/back/models/sale-component.json
@@ -8,14 +8,14 @@
},
"properties": {
"value": {
- "type": "Number"
+ "type": "number"
},
"saleFk": {
- "type": "Number",
+ "type": "number",
"id": 2
},
"componentFk": {
- "type": "Number",
+ "type": "number",
"id": 1
}
},
diff --git a/modules/ticket/back/models/sale-tracking.json b/modules/ticket/back/models/sale-tracking.json
index 43b0df160..4a103ea15 100644
--- a/modules/ticket/back/models/sale-tracking.json
+++ b/modules/ticket/back/models/sale-tracking.json
@@ -9,23 +9,23 @@
"properties": {
"id": {
"id": true,
- "type": "Number",
+ "type": "number",
"forceId": false
},
"saleFk": {
- "type": "Number"
+ "type": "number"
},
"stateFk": {
- "type": "Number"
+ "type": "number"
},
"isChecked": {
"type": "boolean"
},
"created": {
- "type": "Date"
+ "type": "date"
},
"originalQuantity": {
- "type": "Number"
+ "type": "number"
}
},
"relations": {
diff --git a/modules/ticket/back/models/sale.js b/modules/ticket/back/models/sale.js
index 2652aded2..2a4457263 100644
--- a/modules/ticket/back/models/sale.js
+++ b/modules/ticket/back/models/sale.js
@@ -7,7 +7,6 @@ module.exports = Self => {
require('../methods/sale/updateConcept')(Self);
require('../methods/sale/recalculatePrice')(Self);
require('../methods/sale/refund')(Self);
- require('../methods/sale/refundAll')(Self);
require('../methods/sale/canEdit')(Self);
Self.validatesPresenceOf('concept', {
diff --git a/modules/ticket/back/models/sale.json b/modules/ticket/back/models/sale.json
index 767a3e59e..e18f0291f 100644
--- a/modules/ticket/back/models/sale.json
+++ b/modules/ticket/back/models/sale.json
@@ -14,30 +14,33 @@
"properties": {
"id": {
"id": true,
- "type": "Number",
+ "type": "number",
"description": "Identifier"
},
"concept": {
- "type": "String",
+ "type": "string",
"required": true
},
"quantity": {
- "type": "Number"
+ "type": "number"
},
"price": {
- "type": "Number"
+ "type": "number"
},
"discount": {
- "type": "Number"
+ "type": "number"
},
"reserved": {
"type": "boolean"
},
"isPicked": {
- "type": "Number"
+ "type": "number"
},
"created": {
"type": "date"
+ },
+ "originalQuantity":{
+ "type": "number"
}
},
"relations": {
diff --git a/modules/ticket/back/models/stowaway.json b/modules/ticket/back/models/stowaway.json
index 5a925cd20..ef3aeb40d 100644
--- a/modules/ticket/back/models/stowaway.json
+++ b/modules/ticket/back/models/stowaway.json
@@ -9,15 +9,15 @@
"properties": {
"id": {
"id": true,
- "type": "Number",
+ "type": "number",
"forceId": false
},
"shipFk": {
- "type": "Number",
+ "type": "number",
"required": false
},
"created":{
- "type": "Date",
+ "type": "date",
"required": false
}
},
diff --git a/modules/ticket/back/models/ticket-config.json b/modules/ticket/back/models/ticket-config.json
index ff6818bb5..a1c96e7f6 100644
--- a/modules/ticket/back/models/ticket-config.json
+++ b/modules/ticket/back/models/ticket-config.json
@@ -9,11 +9,11 @@
"properties": {
"id": {
"id": true,
- "type": "Number",
+ "type": "number",
"description": "Identifier"
},
"scopeDays": {
- "type": "Number"
+ "type": "number"
}
}
}
diff --git a/modules/ticket/back/models/ticket-last-state.json b/modules/ticket/back/models/ticket-last-state.json
index 6c8bc66d5..e871a8ee6 100644
--- a/modules/ticket/back/models/ticket-last-state.json
+++ b/modules/ticket/back/models/ticket-last-state.json
@@ -12,10 +12,10 @@
},
"ticketFk": {
"id": true,
- "type": "Number"
+ "type": "number"
},
"ticketTrackingFk": {
- "type": "Number"
+ "type": "number"
}
},
"relations": {
diff --git a/modules/ticket/back/models/ticket-log.json b/modules/ticket/back/models/ticket-log.json
index 950742e98..169bdeaa0 100644
--- a/modules/ticket/back/models/ticket-log.json
+++ b/modules/ticket/back/models/ticket-log.json
@@ -9,40 +9,40 @@
"properties": {
"id": {
"id": true,
- "type": "Number",
+ "type": "number",
"forceId": false
},
"originFk": {
- "type": "Number",
+ "type": "number",
"required": true
},
"userFk": {
- "type": "Number"
+ "type": "number"
},
"action": {
- "type": "String",
+ "type": "string",
"required": true
},
"changedModel": {
- "type": "String"
+ "type": "string"
},
"oldInstance": {
- "type": "Object"
+ "type": "object"
},
"newInstance": {
- "type": "Object"
+ "type": "object"
},
"creationDate": {
- "type": "Date"
+ "type": "date"
},
"changedModelId": {
- "type": "Number"
+ "type": "number"
},
"changedModelValue": {
- "type": "String"
+ "type": "string"
},
"description": {
- "type": "String"
+ "type": "string"
}
},
"relations": {
diff --git a/modules/ticket/back/models/ticket-observation.json b/modules/ticket/back/models/ticket-observation.json
index ba4f85ce8..9035e4440 100644
--- a/modules/ticket/back/models/ticket-observation.json
+++ b/modules/ticket/back/models/ticket-observation.json
@@ -13,11 +13,11 @@
"properties": {
"id": {
"id": true,
- "type": "Number",
+ "type": "number",
"description": "Identifier"
},
"description": {
- "type": "String",
+ "type": "string",
"required": true
}
},
diff --git a/modules/ticket/back/models/ticket-packaging.json b/modules/ticket/back/models/ticket-packaging.json
index feea541fa..533f4064c 100644
--- a/modules/ticket/back/models/ticket-packaging.json
+++ b/modules/ticket/back/models/ticket-packaging.json
@@ -13,17 +13,17 @@
"properties": {
"id": {
"id": true,
- "type": "Number",
+ "type": "number",
"description": "Identifier"
},
"quantity": {
- "type": "Number"
+ "type": "number"
},
"created": {
- "type": "Date"
+ "type": "date"
},
"pvp": {
- "type": "Number"
+ "type": "number"
}
},
"relations": {
diff --git a/modules/ticket/back/models/ticket-request.json b/modules/ticket/back/models/ticket-request.json
index f216cd531..01601c7f6 100644
--- a/modules/ticket/back/models/ticket-request.json
+++ b/modules/ticket/back/models/ticket-request.json
@@ -12,29 +12,29 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"id": true,
"description": "Identifier"
},
"description": {
- "type": "String",
+ "type": "string",
"required": true
},
"created": {
- "type": "Date"
+ "type": "date"
},
"quantity": {
- "type": "Number",
+ "type": "number",
"required": true
},
"price": {
- "type": "Number"
+ "type": "number"
},
"isOk": {
- "type": "Boolean"
+ "type": "boolean"
},
"response": {
- "type": "String"
+ "type": "string"
}
},
"relations": {
diff --git a/modules/ticket/back/models/ticket-service-type.json b/modules/ticket/back/models/ticket-service-type.json
index 623d0f398..ec2c9232a 100644
--- a/modules/ticket/back/models/ticket-service-type.json
+++ b/modules/ticket/back/models/ticket-service-type.json
@@ -7,16 +7,16 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"id": true,
"description": "Identifier"
},
"name": {
- "type": "String",
+ "type": "string",
"required": true
},
"expenseFk": {
- "type": "Number",
+ "type": "number",
"mysql": {
"columnName": "expenceFk"
}
diff --git a/modules/ticket/back/models/ticket-service.json b/modules/ticket/back/models/ticket-service.json
index 8b0c490a8..347b6b976 100644
--- a/modules/ticket/back/models/ticket-service.json
+++ b/modules/ticket/back/models/ticket-service.json
@@ -13,32 +13,32 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"id": true,
"description": "Identifier"
},
"ticketFk": {
- "type": "Number",
+ "type": "number",
"required": true
},
"description": {
- "type": "String",
+ "type": "string",
"required": true
},
"quantity": {
- "type": "Number",
+ "type": "number",
"required": true
},
"price": {
- "type": "Number",
+ "type": "number",
"required": true
},
"taxClassFk": {
- "type": "Number",
+ "type": "number",
"required": true
},
"ticketServiceTypeFk": {
- "type": "Number",
+ "type": "number",
"required": true
}
},
diff --git a/modules/ticket/back/models/ticket-tracking.json b/modules/ticket/back/models/ticket-tracking.json
index c2c365013..e80e2f8f4 100644
--- a/modules/ticket/back/models/ticket-tracking.json
+++ b/modules/ticket/back/models/ticket-tracking.json
@@ -14,20 +14,20 @@
"properties": {
"id": {
"id": true,
- "type": "Number",
+ "type": "number",
"forceId": false
},
"created": {
- "type": "Date"
+ "type": "date"
},
"ticketFk": {
- "type": "Number"
+ "type": "number"
},
"stateFk": {
- "type": "Number"
+ "type": "number"
},
"workerFk": {
- "type": "Number"
+ "type": "number"
}
},
"relations": {
diff --git a/modules/ticket/back/models/ticket-update-action.json b/modules/ticket/back/models/ticket-update-action.json
index 3072c2172..e69f7e1ab 100644
--- a/modules/ticket/back/models/ticket-update-action.json
+++ b/modules/ticket/back/models/ticket-update-action.json
@@ -9,15 +9,15 @@
"properties": {
"id": {
"id": true,
- "type": "Number",
+ "type": "number",
"description": "Identifier"
},
"description": {
- "type": "String",
+ "type": "string",
"required": true
},
"code": {
- "type": "String"
+ "type": "string"
}
},
"acls": [
diff --git a/modules/ticket/back/models/ticket-weekly.json b/modules/ticket/back/models/ticket-weekly.json
index 6d432831f..d81baf4ad 100644
--- a/modules/ticket/back/models/ticket-weekly.json
+++ b/modules/ticket/back/models/ticket-weekly.json
@@ -14,10 +14,10 @@
"properties": {
"ticketFk": {
"id": true,
- "type": "Number"
+ "type": "number"
},
"weekDay": {
- "type": "Number"
+ "type": "number"
}
},
"relations": {
diff --git a/modules/ticket/front/descriptor-menu/index.html b/modules/ticket/front/descriptor-menu/index.html
index c99575d42..1dcfd669f 100644
--- a/modules/ticket/front/descriptor-menu/index.html
+++ b/modules/ticket/front/descriptor-menu/index.html
@@ -302,7 +302,7 @@
\ No newline at end of file
diff --git a/modules/ticket/front/descriptor-menu/index.js b/modules/ticket/front/descriptor-menu/index.js
index 1c80a6f9d..c6388654e 100644
--- a/modules/ticket/front/descriptor-menu/index.js
+++ b/modules/ticket/front/descriptor-menu/index.js
@@ -273,9 +273,21 @@ class Controller extends Section {
.then(() => this.vnApp.showSuccess(this.$t('Data saved!')));
}
- refundAll() {
- const params = {ticketId: this.id};
- const query = `Sales/refundAll`;
+ async refund() {
+ const filter = {
+ where: {ticketFk: this.id}
+ };
+ const sales = await this.$http.get('Sales', {filter});
+ this.sales = sales.data;
+
+ const ticketServices = await this.$http.get('TicketServices', {filter});
+ this.services = ticketServices.data;
+
+ const params = {
+ sales: this.sales,
+ services: this.services
+ };
+ const query = `Sales/refund`;
return this.$http.post(query, params).then(res => {
this.$state.go('ticket.card.sale', {id: res.data});
});
diff --git a/modules/ticket/front/descriptor-menu/index.spec.js b/modules/ticket/front/descriptor-menu/index.spec.js
index 75f3522ae..af377d8ea 100644
--- a/modules/ticket/front/descriptor-menu/index.spec.js
+++ b/modules/ticket/front/descriptor-menu/index.spec.js
@@ -262,16 +262,27 @@ describe('Ticket Component vnTicketDescriptorMenu', () => {
});
});
- describe('refundAll()', () => {
+ // #4084 review with Juan
+ xdescribe('refund()', () => {
it('should make a query and go to ticket.card.sale', () => {
- jest.spyOn(controller.$state, 'go').mockReturnValue();
- const expectedParams = {ticketId: ticket.id};
+ controller.$state.go = jest.fn();
- $httpBackend.expect('POST', `Sales/refundAll`, expectedParams).respond({ticketId: 16});
- controller.refundAll();
+ controller._id = ticket.id;
+ const sales = [{id: 1}];
+ const services = [{id: 2}];
+
+ $httpBackend.expectGET(`Sales`).respond(sales);
+ $httpBackend.expectGET(`TicketServices`).respond(services);
+
+ const expectedParams = {
+ sales: sales,
+ services: services
+ };
+ $httpBackend.expectPOST(`Sales/refund`, expectedParams).respond();
+ controller.refund();
$httpBackend.flush();
- expect(controller.$state.go).toHaveBeenCalledWith('ticket.card.sale', {id: {ticketId: ticket.id}});
+ expect(controller.$state.go).toHaveBeenCalledWith('ticket.card.sale', {id: undefined});
});
});
diff --git a/modules/ticket/front/expedition/index.html b/modules/ticket/front/expedition/index.html
index bdbb2c3e8..a41d368f6 100644
--- a/modules/ticket/front/expedition/index.html
+++ b/modules/ticket/front/expedition/index.html
@@ -19,10 +19,9 @@
Package type
Counter
externalId
- Packager
Created
- Palletizer
- Scanned
+ State
+
@@ -33,7 +32,7 @@
vn-tooltip="Delete expedition">
- {{expedition.id | zeroFill:6}}
+ {{expedition.id | zeroFill:6}}
{{::expedition.freightItemName}}
{{::expedition.counter}}
{{::expedition.externalId}}
-
-
- {{::expedition.userName | dashIfEmpty}}
-
-
{{::expedition.created | date:'dd/MM/yyyy HH:mm'}}
+ {{::expedition.state}}
-
- {{::expedition.scannerUserName | dashIfEmpty}}
-
+
+
- {{::expedition.scanned | date:'dd/MM/yyyy HH:mm'}}
@@ -77,4 +71,44 @@
on-accept="$ctrl.onDialogAccept($data)"
question="Delete expedition"
message="Are you sure you want to delete this expedition?">
-
\ No newline at end of file
+
+
+
+
+
+
+
+
+
+
+ State
+ Worker
+ Created
+
+
+
+
+ {{::expeditionState.state}}
+
+
+ {{::expeditionState.name || 'System' | translate}}
+
+
+ {{::expeditionState.created | date:'dd/MM/yyyy HH:mm'}}
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/modules/ticket/front/expedition/index.js b/modules/ticket/front/expedition/index.js
index 0c395e6ce..120d89bb2 100644
--- a/modules/ticket/front/expedition/index.js
+++ b/modules/ticket/front/expedition/index.js
@@ -6,6 +6,11 @@ class Controller extends Section {
return this.$http.delete(`Expeditions/${id}`)
.then(() => this.$.model.refresh());
}
+
+ showLog(expedition) {
+ this.expedition = expedition;
+ this.$.statusLog.show();
+ }
}
ngModule.vnComponent('vnTicketExpedition', {
diff --git a/modules/ticket/front/expedition/index.spec.js b/modules/ticket/front/expedition/index.spec.js
index 425539aef..586ef2109 100644
--- a/modules/ticket/front/expedition/index.spec.js
+++ b/modules/ticket/front/expedition/index.spec.js
@@ -5,10 +5,12 @@ describe('Ticket', () => {
let controller;
let $scope;
let $httpBackend;
+ let $window;
beforeEach(ngModule('ticket'));
- beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => {
+ beforeEach(inject(($componentController, $rootScope, _$httpBackend_, _$window_) => {
+ $window = _$window_;
$httpBackend = _$httpBackend_;
$scope = $rootScope.$new();
$scope.model = {
@@ -30,5 +32,23 @@ describe('Ticket', () => {
expect($scope.model.refresh).toHaveBeenCalledWith();
});
});
+
+ describe('showLog()', () => {
+ it('should show the popover status log', () => {
+ controller.$.statusLog = {show: () => {}};
+ jest.spyOn(controller.$.statusLog, 'show');
+
+ const expedition = {id: 1};
+
+ const event = new MouseEvent('click', {
+ view: $window,
+ bubbles: true,
+ cancelable: true
+ });
+ controller.showLog(event, expedition);
+
+ expect(controller.$.statusLog.show).toHaveBeenCalledWith();
+ });
+ });
});
});
diff --git a/modules/ticket/front/expedition/locale/es.yml b/modules/ticket/front/expedition/locale/es.yml
new file mode 100644
index 000000000..d23cf25af
--- /dev/null
+++ b/modules/ticket/front/expedition/locale/es.yml
@@ -0,0 +1 @@
+Status log: Hitorial de estados
\ No newline at end of file
diff --git a/modules/ticket/front/index/index.html b/modules/ticket/front/index/index.html
index 36af86001..1e18ce284 100644
--- a/modules/ticket/front/index/index.html
+++ b/modules/ticket/front/index/index.html
@@ -52,8 +52,8 @@
icon="icon-buyrequest">
diff --git a/modules/ticket/front/index/locale/es.yml b/modules/ticket/front/index/locale/es.yml
index eac0084f6..74b17b0f3 100644
--- a/modules/ticket/front/index/locale/es.yml
+++ b/modules/ticket/front/index/locale/es.yml
@@ -1,6 +1,7 @@
Weekly tickets: Tickets programados
Go to lines: Ir a lineas
Not available: No disponible
+Not visible: No visible
Payment on account...: Pago a cuenta...
Set as delivered and open delivery note(s): Marcar como servido/s y abrir albarán/es
Closure: Cierre
diff --git a/modules/ticket/front/sale/index.html b/modules/ticket/front/sale/index.html
index 836fadb9b..f4e5840f3 100644
--- a/modules/ticket/front/sale/index.html
+++ b/modules/ticket/front/sale/index.html
@@ -95,8 +95,8 @@
translate-attr="{title: 'Reserved'}">
diff --git a/modules/ticket/front/sale/index.js b/modules/ticket/front/sale/index.js
index bb8a81bc4..987333e28 100644
--- a/modules/ticket/front/sale/index.js
+++ b/modules/ticket/front/sale/index.js
@@ -483,7 +483,7 @@ class Controller extends Section {
const sales = this.selectedValidSales();
if (!sales) return;
- const params = {sales: sales, ticketId: this.ticket.id};
+ const params = {sales: sales};
const query = `Sales/refund`;
this.resetChanges();
this.$http.post(query, params).then(res => {
diff --git a/modules/ticket/front/services/index.html b/modules/ticket/front/services/index.html
index 13fd84b00..bb5505ce6 100644
--- a/modules/ticket/front/services/index.html
+++ b/modules/ticket/front/services/index.html
@@ -42,7 +42,7 @@
diff --git a/modules/ticket/front/volume/index.js b/modules/ticket/front/volume/index.js
index 81491bca0..a3d531898 100644
--- a/modules/ticket/front/volume/index.js
+++ b/modules/ticket/front/volume/index.js
@@ -20,7 +20,7 @@ class Controller extends Section {
set sales(value) {
this._sales = value;
- if (value) this.applyVolumes();
+ if (value && value.length) this.applyVolumes();
}
applyVolumes() {
diff --git a/modules/travel/back/methods/travel/specs/cloneWithEntries.spec.js b/modules/travel/back/methods/travel/specs/cloneWithEntries.spec.js
index b4bfecbfb..aa92fa308 100644
--- a/modules/travel/back/methods/travel/specs/cloneWithEntries.spec.js
+++ b/modules/travel/back/methods/travel/specs/cloneWithEntries.spec.js
@@ -1,7 +1,6 @@
const app = require('vn-loopback/server/server');
-// #2687 - Cannot make a data rollback because of the triggers
-xdescribe('Travel cloneWithEntries()', () => {
+describe('Travel cloneWithEntries()', () => {
const models = app.models;
const travelId = 5;
const currentUserId = 1102;
@@ -9,44 +8,45 @@ xdescribe('Travel cloneWithEntries()', () => {
let travelBefore;
let newTravelId;
- afterAll(async() => {
- try {
- const entries = await models.Entry.find({
- where: {
- travelFk: newTravelId
- }
- });
- const entriesId = entries.map(entry => entry.id);
+ // afterAll(async() => {
+ // try {
+ // const entries = await models.Entry.find({
+ // where: {
+ // travelFk: newTravelId
+ // }
+ // });
+ // const entriesId = entries.map(entry => entry.id);
- // Destroy all entries buys
- await models.Buy.destroyAll({
- where: {
- entryFk: {inq: entriesId}
- }
- });
+ // // Destroy all entries buys
+ // await models.Buy.destroyAll({
+ // where: {
+ // entryFk: {inq: entriesId}
+ // }
+ // });
- // Destroy travel entries
- await models.Entry.destroyAll({
- where: {
- travelFk: newTravelId
- }
- });
+ // // Destroy travel entries
+ // await models.Entry.destroyAll({
+ // where: {
+ // travelFk: newTravelId
+ // }
+ // });
- // Destroy new travel
- await models.Travel.destroyById(newTravelId);
+ // // Destroy new travel
+ // await models.Travel.destroyById(newTravelId);
- // Restore original travel shipped & landed
- const travel = await models.Travel.findById(travelId);
- await travel.updateAttributes({
- shipped: travelBefore.shipped,
- landed: travelBefore.landed
- });
- } catch (error) {
- console.error(error);
- }
- });
+ // // Restore original travel shipped & landed
+ // const travel = await models.Travel.findById(travelId);
+ // await travel.updateAttributes({
+ // shipped: travelBefore.shipped,
+ // landed: travelBefore.landed
+ // });
+ // } catch (error) {
+ // console.error(error);
+ // }
+ // });
it(`should clone the travel and the containing entries`, async() => {
+ pending('#2687 - Cannot make a data rollback because of the triggers');
const warehouseThree = 3;
const agencyModeOne = 1;
const yesterday = new Date();
diff --git a/modules/travel/back/models/thermograph.json b/modules/travel/back/models/thermograph.json
index 2519fffc4..bd9ad3119 100644
--- a/modules/travel/back/models/thermograph.json
+++ b/modules/travel/back/models/thermograph.json
@@ -8,13 +8,13 @@
},
"properties": {
"id": {
- "type": "String",
+ "type": "string",
"id": true,
"description": "Identifier",
"required": true
},
"model": {
- "type": "String",
+ "type": "string",
"required": true
}
}
diff --git a/modules/travel/back/models/travel-log.json b/modules/travel/back/models/travel-log.json
index d53be88f1..d07f83e50 100644
--- a/modules/travel/back/models/travel-log.json
+++ b/modules/travel/back/models/travel-log.json
@@ -9,40 +9,40 @@
"properties": {
"id": {
"id": true,
- "type": "Number",
+ "type": "number",
"forceId": false
},
"originFk": {
- "type": "Number",
+ "type": "number",
"required": true
},
"userFk": {
- "type": "Number"
+ "type": "number"
},
"action": {
- "type": "String",
+ "type": "string",
"required": true
},
"changedModel": {
- "type": "String"
+ "type": "string"
},
"oldInstance": {
- "type": "Object"
+ "type": "object"
},
"newInstance": {
- "type": "Object"
+ "type": "object"
},
"creationDate": {
- "type": "Date"
+ "type": "date"
},
"changedModelId": {
- "type": "String"
+ "type": "string"
},
"changedModelValue": {
- "type": "String"
+ "type": "string"
},
"description": {
- "type": "String"
+ "type": "string"
}
},
"relations": {
diff --git a/modules/travel/back/models/travel.json b/modules/travel/back/models/travel.json
index cd2f1d653..95330e263 100644
--- a/modules/travel/back/models/travel.json
+++ b/modules/travel/back/models/travel.json
@@ -12,7 +12,7 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"id": true,
"description": "Identifier"
},
@@ -23,28 +23,28 @@
"type": "date"
},
"isDelivered": {
- "type": "Boolean"
+ "type": "boolean"
},
"isReceived": {
- "type": "Boolean"
+ "type": "boolean"
},
"ref": {
- "type": "String"
+ "type": "string"
},
"totalEntries": {
- "type": "Number"
+ "type": "number"
},
"m3": {
- "type": "Number"
+ "type": "number"
},
"kg": {
- "type": "Number"
+ "type": "number"
},
"cargoSupplierFk": {
- "type": "Number"
+ "type": "number"
},
"agencyModeFk": {
- "type": "Number",
+ "type": "number",
"mysql": {
"columnName": "agencyFk"
}
diff --git a/modules/worker/back/methods/worker/createAbsence.js b/modules/worker/back/methods/worker/createAbsence.js
index 81c5d1192..153c28b60 100644
--- a/modules/worker/back/methods/worker/createAbsence.js
+++ b/modules/worker/back/methods/worker/createAbsence.js
@@ -135,7 +135,8 @@ module.exports = Self => {
function formatDate(date) {
let day = date.getDate();
if (day < 10) day = `0${day}`;
- let month = date.getMonth();
+
+ let month = date.getMonth() + 1;
if (month < 10) month = `0${month}`;
let year = date.getFullYear();
diff --git a/modules/worker/back/methods/worker/deleteAbsence.js b/modules/worker/back/methods/worker/deleteAbsence.js
index 72e9243d9..45dc04b2d 100644
--- a/modules/worker/back/methods/worker/deleteAbsence.js
+++ b/modules/worker/back/methods/worker/deleteAbsence.js
@@ -87,7 +87,7 @@ module.exports = Self => {
function formatDate(date) {
let day = date.getDate();
if (day < 10) day = `0${day}`;
- let month = date.getMonth();
+ let month = date.getMonth() + 1;
if (month < 10) month = `0${month}`;
let year = date.getFullYear();
diff --git a/modules/worker/back/model-config.json b/modules/worker/back/model-config.json
index c155e331d..c6b984bd2 100644
--- a/modules/worker/back/model-config.json
+++ b/modules/worker/back/model-config.json
@@ -20,6 +20,9 @@
"EducationLevel": {
"dataSource": "vn"
},
+ "Sector": {
+ "dataSource": "vn"
+ },
"WorkCenter": {
"dataSource": "vn"
},
diff --git a/modules/worker/back/models/absence-type.json b/modules/worker/back/models/absence-type.json
index f4e9aed18..7fc62f780 100644
--- a/modules/worker/back/models/absence-type.json
+++ b/modules/worker/back/models/absence-type.json
@@ -9,19 +9,19 @@
"properties": {
"id": {
"id": true,
- "type": "Number"
+ "type": "number"
},
"name": {
- "type": "String"
+ "type": "string"
},
"rgb": {
- "type": "String"
+ "type": "string"
},
"code": {
- "type": "String"
+ "type": "string"
},
"holidayEntitlementRate": {
- "type": "Number"
+ "type": "number"
}
},
"acls": [
diff --git a/modules/worker/back/models/calendar-holiday.json b/modules/worker/back/models/calendar-holiday.json
index 544452553..f7777c2b7 100644
--- a/modules/worker/back/models/calendar-holiday.json
+++ b/modules/worker/back/models/calendar-holiday.json
@@ -9,14 +9,14 @@
"properties": {
"calendarHolidaysNameFk": {
"id": true,
- "type": "Number"
+ "type": "number"
},
"calendarHolidaysTypeFk": {
"id": true,
- "type": "Number"
+ "type": "number"
},
"dated": {
- "type": "Date"
+ "type": "date"
}
},
"relations": {
diff --git a/modules/worker/back/models/calendar-holidays-name.json b/modules/worker/back/models/calendar-holidays-name.json
index d04ef9c74..d2798f106 100644
--- a/modules/worker/back/models/calendar-holidays-name.json
+++ b/modules/worker/back/models/calendar-holidays-name.json
@@ -9,10 +9,10 @@
"properties": {
"id": {
"id": true,
- "type": "Number"
+ "type": "number"
},
"name": {
- "type": "String"
+ "type": "string"
}
},
"acls": [
diff --git a/modules/worker/back/models/calendar-holidays-type.json b/modules/worker/back/models/calendar-holidays-type.json
index 178331b87..cf738d353 100644
--- a/modules/worker/back/models/calendar-holidays-type.json
+++ b/modules/worker/back/models/calendar-holidays-type.json
@@ -9,13 +9,13 @@
"properties": {
"id": {
"id": true,
- "type": "Number"
+ "type": "number"
},
"name": {
- "type": "String"
+ "type": "string"
},
"hexColour": {
- "type": "String"
+ "type": "string"
}
},
"acls": [
diff --git a/modules/worker/back/models/calendar.json b/modules/worker/back/models/calendar.json
index 1da7179c4..40d29c519 100644
--- a/modules/worker/back/models/calendar.json
+++ b/modules/worker/back/models/calendar.json
@@ -13,13 +13,13 @@
"properties": {
"id": {
"id": true,
- "type": "Number"
+ "type": "number"
},
"businessFk": {
- "type": "Number"
+ "type": "number"
},
"dated": {
- "type": "Date"
+ "type": "date"
}
},
"relations": {
diff --git a/modules/worker/back/models/device.json b/modules/worker/back/models/device.json
index 5367faedf..566f7da7d 100644
--- a/modules/worker/back/models/device.json
+++ b/modules/worker/back/models/device.json
@@ -9,13 +9,13 @@
"properties": {
"id": {
"id": true,
- "type": "Number"
+ "type": "number"
},
"sn": {
- "type": "String"
+ "type": "string"
},
"model": {
- "type": "String"
+ "type": "string"
}
},
"relations": {
diff --git a/modules/worker/back/models/sector.json b/modules/worker/back/models/sector.json
new file mode 100644
index 000000000..8bd5e773f
--- /dev/null
+++ b/modules/worker/back/models/sector.json
@@ -0,0 +1,20 @@
+{
+ "name": "Sector",
+ "base": "VnModel",
+ "options": {
+ "mysql": {
+ "table": "sector"
+ }
+ },
+ "properties": {
+ "id": {
+ "type": "number",
+ "id": true,
+ "description": "Identifier"
+ },
+ "description": {
+ "type": "string",
+ "required": true
+ }
+ }
+}
\ No newline at end of file
diff --git a/modules/worker/back/models/work-center-holiday.json b/modules/worker/back/models/work-center-holiday.json
index eddfd7af1..e5f201d9d 100644
--- a/modules/worker/back/models/work-center-holiday.json
+++ b/modules/worker/back/models/work-center-holiday.json
@@ -9,13 +9,13 @@
"properties": {
"workCenterFk": {
"id": true,
- "type": "Number"
+ "type": "number"
},
"days": {
- "type": "Number"
+ "type": "number"
},
"year": {
- "type": "Number"
+ "type": "number"
}
},
"relations": {
diff --git a/modules/worker/back/models/work-center.json b/modules/worker/back/models/work-center.json
index a0e651bba..2d7bab24e 100644
--- a/modules/worker/back/models/work-center.json
+++ b/modules/worker/back/models/work-center.json
@@ -9,10 +9,10 @@
"properties": {
"id": {
"id": true,
- "type": "Number"
+ "type": "number"
},
"name": {
- "type": "String"
+ "type": "string"
}
},
"relations": {
diff --git a/modules/worker/back/models/worker-department.json b/modules/worker/back/models/worker-department.json
index 0eeca50e7..b169cbf5e 100644
--- a/modules/worker/back/models/worker-department.json
+++ b/modules/worker/back/models/worker-department.json
@@ -9,10 +9,10 @@
"properties": {
"workerFk": {
"id": true,
- "type": "Number"
+ "type": "number"
},
"departmentFk": {
- "type": "Number"
+ "type": "number"
}
},
"relations": {
diff --git a/modules/worker/back/models/worker-dms.json b/modules/worker/back/models/worker-dms.json
index 80634cfcc..575cfbc24 100644
--- a/modules/worker/back/models/worker-dms.json
+++ b/modules/worker/back/models/worker-dms.json
@@ -13,25 +13,25 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"id": true
},
"dmsFk": {
- "type": "Number",
+ "type": "number",
"required": true,
"mysql": {
"columnName": "document"
}
},
"workerFk": {
- "type": "Number",
+ "type": "number",
"required": true,
"mysql": {
"columnName": "worker"
}
},
"isReadableByWorker": {
- "type": "Boolean"
+ "type": "boolean"
}
},
"relations": {
diff --git a/modules/worker/back/models/worker-log.json b/modules/worker/back/models/worker-log.json
index f100f3486..d2fa0487d 100644
--- a/modules/worker/back/models/worker-log.json
+++ b/modules/worker/back/models/worker-log.json
@@ -9,40 +9,40 @@
"properties": {
"id": {
"id": true,
- "type": "Number",
+ "type": "number",
"forceId": false
},
"originFk": {
- "type": "Number",
+ "type": "number",
"required": true
},
"userFk": {
- "type": "Number"
+ "type": "number"
},
"action": {
- "type": "String",
+ "type": "string",
"required": true
},
"changedModel": {
- "type": "String"
+ "type": "string"
},
"oldInstance": {
- "type": "Object"
+ "type": "object"
},
"newInstance": {
- "type": "Object"
+ "type": "object"
},
"creationDate": {
- "type": "Date"
+ "type": "date"
},
"changedModelId": {
- "type": "String"
+ "type": "string"
},
"changedModelValue": {
- "type": "String"
+ "type": "string"
},
"description": {
- "type": "String"
+ "type": "string"
}
},
"relations": {
diff --git a/modules/worker/back/models/worker-mana.json b/modules/worker/back/models/worker-mana.json
index b98b2a325..0e50b8f63 100644
--- a/modules/worker/back/models/worker-mana.json
+++ b/modules/worker/back/models/worker-mana.json
@@ -8,11 +8,11 @@
},
"properties": {
"amount": {
- "type": "Number"
+ "type": "number"
},
"workerFk": {
"id": true,
- "type": "Number"
+ "type": "number"
}
},
"relations": {
diff --git a/modules/worker/back/models/worker-media.json b/modules/worker/back/models/worker-media.json
index 805ff383b..8a28fb422 100644
--- a/modules/worker/back/models/worker-media.json
+++ b/modules/worker/back/models/worker-media.json
@@ -9,10 +9,10 @@
"properties": {
"workerFk": {
"id": true,
- "type": "Number"
+ "type": "number"
},
"mediaValue": {
- "type": "String"
+ "type": "string"
}
},
"relations": {
diff --git a/modules/worker/back/models/worker-team-collegues.json b/modules/worker/back/models/worker-team-collegues.json
index 2e4a0a4f8..18b7d90bd 100644
--- a/modules/worker/back/models/worker-team-collegues.json
+++ b/modules/worker/back/models/worker-team-collegues.json
@@ -9,11 +9,11 @@
"properties": {
"workerFk": {
"id": true,
- "type": "Number"
+ "type": "number"
},
"collegueFk": {
"id": true,
- "type": "Number"
+ "type": "number"
}
},
"relations": {
diff --git a/modules/worker/back/models/worker-team.json b/modules/worker/back/models/worker-team.json
index 4cd4b1244..0b490ba6e 100644
--- a/modules/worker/back/models/worker-team.json
+++ b/modules/worker/back/models/worker-team.json
@@ -8,12 +8,12 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"id": true,
"description": "Identifier"
},
"team": {
- "type": "Number"
+ "type": "number"
}
},
"relations": {
diff --git a/modules/worker/back/models/worker-time-control-mail.json b/modules/worker/back/models/worker-time-control-mail.json
index 7f8522757..daf3d5155 100644
--- a/modules/worker/back/models/worker-time-control-mail.json
+++ b/modules/worker/back/models/worker-time-control-mail.json
@@ -9,26 +9,26 @@
"properties": {
"id": {
"id": true,
- "type": "Number",
+ "type": "number",
"required": true
},
"workerFk": {
- "type": "Number"
+ "type": "number"
},
"year": {
- "type": "Number"
+ "type": "number"
},
"week": {
- "type": "Number"
+ "type": "number"
},
"state": {
- "type": "String"
+ "type": "string"
},
"updated": {
- "type": "Date"
+ "type": "date"
},
"emailResponse": {
- "type": "String"
+ "type": "string"
}
},
"acls": [
diff --git a/modules/worker/back/models/worker-time-control-params.json b/modules/worker/back/models/worker-time-control-params.json
index cc904cf40..14cabbfb0 100644
--- a/modules/worker/back/models/worker-time-control-params.json
+++ b/modules/worker/back/models/worker-time-control-params.json
@@ -9,19 +9,19 @@
},
"properties": {
"mailHost": {
- "type": "String"
+ "type": "string"
},
"mailUser": {
- "type": "String"
+ "type": "string"
},
"mailPass": {
- "type": "String"
+ "type": "string"
},
"mailSuccessFolder": {
- "type": "String"
+ "type": "string"
},
"mailErrorFolder": {
- "type": "String"
+ "type": "string"
}
},
"acls": [
diff --git a/modules/worker/back/models/worker.json b/modules/worker/back/models/worker.json
index c8054caff..f7a344358 100644
--- a/modules/worker/back/models/worker.json
+++ b/modules/worker/back/models/worker.json
@@ -46,6 +46,9 @@
},
"SSN": {
"type" : "string"
+ },
+ "labelerFk": {
+ "type" : "number"
}
},
"relations": {
@@ -78,6 +81,11 @@
"type": "hasMany",
"model": "WorkerTeamCollegues",
"foreignKey": "workerFk"
+ },
+ "sector": {
+ "type": "belongsTo",
+ "model": "Sector",
+ "foreignKey": "sectorFk"
}
}
}
\ No newline at end of file
diff --git a/modules/zone/back/models/agency-mode.json b/modules/zone/back/models/agency-mode.json
index ded58e819..027cec190 100644
--- a/modules/zone/back/models/agency-mode.json
+++ b/modules/zone/back/models/agency-mode.json
@@ -9,7 +9,7 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"id": true,
"description": "Identifier"
},
@@ -24,10 +24,10 @@
"type": "number"
},
"m3": {
- "type": "Number"
+ "type": "number"
},
"inflation": {
- "type": "Number"
+ "type": "number"
},
"reportMail": {
"type": "string"
@@ -36,7 +36,7 @@
"type": "boolean"
},
"code": {
- "type": "String",
+ "type": "string",
"required": false
}
},
diff --git a/modules/zone/back/models/delivery-method.json b/modules/zone/back/models/delivery-method.json
index 8106c1d4f..31454f2f8 100644
--- a/modules/zone/back/models/delivery-method.json
+++ b/modules/zone/back/models/delivery-method.json
@@ -9,7 +9,7 @@
},
"properties": {
"id": {
- "type": "Number",
+ "type": "number",
"id": true,
"description": "Identifier"
},
diff --git a/modules/zone/back/models/zone-closure.json b/modules/zone/back/models/zone-closure.json
index 895374838..0483a0c83 100644
--- a/modules/zone/back/models/zone-closure.json
+++ b/modules/zone/back/models/zone-closure.json
@@ -9,10 +9,10 @@
"properties": {
"zoneFk": {
"id": true,
- "type": "Number"
+ "type": "number"
},
"dated": {
- "type": "Date",
+ "type": "date",
"required": true
},
"hour": {
diff --git a/modules/zone/back/models/zone-estimated-delivery.json b/modules/zone/back/models/zone-estimated-delivery.json
index d65cee3b5..399de8f58 100644
--- a/modules/zone/back/models/zone-estimated-delivery.json
+++ b/modules/zone/back/models/zone-estimated-delivery.json
@@ -9,28 +9,28 @@
"properties": {
"zoneFk": {
"id": true,
- "type": "Number"
+ "type": "number"
},
"hourTheoretical": {
"type": "date"
},
"totalVolume": {
- "type": "Number"
+ "type": "number"
},
"remainingVolume": {
- "type": "Number"
+ "type": "number"
},
"speed": {
- "type": "Number"
+ "type": "number"
},
"hourEffective": {
- "type": "Date"
+ "type": "date"
},
"minutesLess": {
- "type": "Date"
+ "type": "date"
},
"etc": {
- "type": "Date"
+ "type": "date"
}
},
diff --git a/modules/zone/back/models/zone-event.json b/modules/zone/back/models/zone-event.json
index 54c9c4a7d..7cf4b8301 100644
--- a/modules/zone/back/models/zone-event.json
+++ b/modules/zone/back/models/zone-event.json
@@ -13,41 +13,41 @@
"properties": {
"id": {
"id": true,
- "type": "Number"
+ "type": "number"
},
"zoneFk": {
"id": true,
- "type": "Number"
+ "type": "number"
},
"type": {
- "type": "String"
+ "type": "string"
},
"dated": {
- "type": "Date"
+ "type": "date"
},
"started": {
- "type": "Date"
+ "type": "date"
},
"ended": {
- "type": "Date"
+ "type": "date"
},
"weekDays": {
- "type": "String"
+ "type": "string"
},
"hour": {
- "type": "Date"
+ "type": "date"
},
"travelingDays": {
- "type": "Number"
+ "type": "number"
},
"price": {
- "type": "Number"
+ "type": "number"
},
"bonus": {
- "type": "Number"
+ "type": "number"
},
"m3Max": {
- "type": "Number"
+ "type": "number"
}
},
"relations": {
diff --git a/modules/zone/back/models/zone-exclusion.json b/modules/zone/back/models/zone-exclusion.json
index f1c80debd..415bce40c 100644
--- a/modules/zone/back/models/zone-exclusion.json
+++ b/modules/zone/back/models/zone-exclusion.json
@@ -9,10 +9,10 @@
"properties": {
"id": {
"id": true,
- "type": "Number"
+ "type": "number"
},
"dated": {
- "type": "Date",
+ "type": "date",
"required": true
}
},
diff --git a/modules/zone/back/models/zone-geo.json b/modules/zone/back/models/zone-geo.json
index 0a001235f..e9d9aa3eb 100644
--- a/modules/zone/back/models/zone-geo.json
+++ b/modules/zone/back/models/zone-geo.json
@@ -9,22 +9,22 @@
"properties": {
"id": {
"id": true,
- "type": "Number"
+ "type": "number"
},
"name": {
- "type": "String"
+ "type": "string"
},
"lft": {
- "type": "Number"
+ "type": "number"
},
"rgt": {
- "type": "Number"
+ "type": "number"
},
"depth": {
- "type": "Number"
+ "type": "number"
},
"sons": {
- "type": "Number"
+ "type": "number"
}
}
}
\ No newline at end of file
diff --git a/modules/zone/back/models/zone-included.json b/modules/zone/back/models/zone-included.json
index e462b7a65..595f47a78 100644
--- a/modules/zone/back/models/zone-included.json
+++ b/modules/zone/back/models/zone-included.json
@@ -14,10 +14,10 @@
"properties": {
"zoneFk": {
"id": true,
- "type": "Number"
+ "type": "number"
},
"isIncluded": {
- "type": "Boolean"
+ "type": "boolean"
}
},
"relations": {
diff --git a/modules/zone/back/models/zone-log.json b/modules/zone/back/models/zone-log.json
index ddca9261b..c2c66c155 100644
--- a/modules/zone/back/models/zone-log.json
+++ b/modules/zone/back/models/zone-log.json
@@ -9,40 +9,40 @@
"properties": {
"id": {
"id": true,
- "type": "Number",
+ "type": "number",
"forceId": false
},
"originFk": {
- "type": "Number",
+ "type": "number",
"required": true
},
"userFk": {
- "type": "Number"
+ "type": "number"
},
"action": {
- "type": "String",
+ "type": "string",
"required": true
},
"changedModel": {
- "type": "String"
+ "type": "string"
},
"oldInstance": {
- "type": "Object"
+ "type": "object"
},
"newInstance": {
- "type": "Object"
+ "type": "object"
},
"creationDate": {
- "type": "Date"
+ "type": "date"
},
"changedModelId": {
- "type": "String"
+ "type": "string"
},
"changedModelValue": {
- "type": "String"
+ "type": "string"
},
"description": {
- "type": "String"
+ "type": "string"
}
},
"relations": {
diff --git a/modules/zone/back/models/zone-warehouse.json b/modules/zone/back/models/zone-warehouse.json
index 0f0e43f4a..003e4e3c2 100644
--- a/modules/zone/back/models/zone-warehouse.json
+++ b/modules/zone/back/models/zone-warehouse.json
@@ -13,10 +13,10 @@
"properties": {
"id": {
"id": true,
- "type": "Number"
+ "type": "number"
},
"warehouseFk": {
- "type": "Number",
+ "type": "number",
"required": true
}
},
diff --git a/modules/zone/front/basic-data/index.html b/modules/zone/front/basic-data/index.html
index eb701a803..1836216a2 100644
--- a/modules/zone/front/basic-data/index.html
+++ b/modules/zone/front/basic-data/index.html
@@ -67,7 +67,6 @@
diff --git a/modules/zone/front/delivery-days/index.js b/modules/zone/front/delivery-days/index.js
index e4d5e72e9..71e8c8ab7 100644
--- a/modules/zone/front/delivery-days/index.js
+++ b/modules/zone/front/delivery-days/index.js
@@ -73,15 +73,14 @@ class Controller extends Section {
for (let event of $events)
zoneIds.push(event.zoneFk);
- this.$.zoneEvents.show($event.target);
-
const params = {
zoneIds: zoneIds,
date: day
};
this.$http.post(`Zones/getZoneClosing`, params)
- .then(res => this.zoneClosing = res.data);
+ .then(res => this.zoneClosing = res.data)
+ .then(() => this.$.zoneEvents.show($event.target));
}
preview(zone) {
diff --git a/package.json b/package.json
index 35c27fc0c..52741641a 100644
--- a/package.json
+++ b/package.json
@@ -68,7 +68,6 @@
"gulp-env": "^0.4.0",
"gulp-file": "^0.4.0",
"gulp-install": "^1.1.0",
- "gulp-jasmine": "^4.0.0",
"gulp-merge-json": "^1.3.1",
"gulp-nodemon": "^2.5.0",
"gulp-print": "^2.0.1",
@@ -78,7 +77,7 @@
"html-loader-jest": "^0.2.1",
"html-webpack-plugin": "^4.0.0-beta.11",
"identity-obj-proxy": "^3.0.0",
- "jasmine": "^3.10.0",
+ "jasmine": "^4.1.0",
"jasmine-reporters": "^2.4.0",
"jasmine-spec-reporter": "^7.0.0",
"jest": "^26.0.1",
@@ -88,7 +87,7 @@
"minimist": "^1.2.5",
"mysql2": "^1.7.0",
"node-sass": "^4.14.1",
- "nodemon": "^1.19.4",
+ "nodemon": "^2.0.16",
"plugin-error": "^1.0.1",
"raw-loader": "^1.0.0",
"regenerator-runtime": "^0.13.7",
@@ -102,7 +101,10 @@
},
"scripts": {
"dbtest": "nodemon -q db/tests.js -w db/tests",
- "test": "jest --watch",
+ "test:back": "nodemon -q back/tests.js --config back/nodemonConfig.json",
+ "test:back:ci": "node back/tests.js ci",
+ "test:e2e": "node e2e/helpers/tests.js",
+ "test:front": "jest --watch",
"back": "nodemon --inspect -w modules ./node_modules/gulp/bin/gulp.js back",
"lint": "eslint ./ --cache --ignore-pattern .gitignore",
"docker": "docker build --progress=plain -t salix-db ./db"
diff --git a/print/methods/routes.js b/print/methods/routes.js
index ea40e0743..28671b3da 100644
--- a/print/methods/routes.js
+++ b/print/methods/routes.js
@@ -16,7 +16,7 @@ module.exports = [
cb: require('./closure')
},
{
- url: '/api/notify',
- cb: require('./notify')
+ url: '/api/schedule',
+ cb: require('./schedule')
}
];
diff --git a/print/methods/notify/consumption.js b/print/methods/schedule/consumption.js
similarity index 100%
rename from print/methods/notify/consumption.js
rename to print/methods/schedule/consumption.js
diff --git a/print/methods/notify/index.js b/print/methods/schedule/index.js
similarity index 76%
rename from print/methods/notify/index.js
rename to print/methods/schedule/index.js
index df4705d1e..05d54b2ed 100644
--- a/print/methods/notify/index.js
+++ b/print/methods/schedule/index.js
@@ -2,5 +2,6 @@ const express = require('express');
const router = new express.Router();
router.post('/consumption', require('./consumption'));
+router.post('/invoice', require('./invoice'));
module.exports = router;
diff --git a/print/methods/schedule/invoice.js b/print/methods/schedule/invoice.js
new file mode 100644
index 000000000..c76ca85b5
--- /dev/null
+++ b/print/methods/schedule/invoice.js
@@ -0,0 +1,114 @@
+const db = require('vn-print/core/database');
+const Email = require('vn-print/core/email');
+const Report = require('vn-print/core/report');
+const storage = require('vn-print/core/storage');
+
+module.exports = async function(request, response, next) {
+ try {
+ response.status(200).json({
+ message: 'Success'
+ });
+
+ const invoices = await db.rawSql(`
+ SELECT
+ io.id,
+ io.clientFk,
+ io.issued,
+ io.ref,
+ c.email recipient,
+ c.salesPersonFk,
+ c.isToBeMailed,
+ c.hasToInvoice,
+ co.hasDailyInvoice,
+ eu.email salesPersonEmail
+ FROM invoiceOut_queue ioq
+ JOIN invoiceOut io ON io.id = ioq.invoiceFk
+ JOIN client c ON c.id = io.clientFk
+ JOIN province p ON p.id = c.provinceFk
+ JOIN country co ON co.id = p.countryFk
+ LEFT JOIN account.emailUser eu ON eu.userFk = c.salesPersonFk
+ WHERE status = ''`);
+
+ let connection;
+ let invoiceId;
+ for (const invoiceOut of invoices) {
+ try {
+ invoiceId = invoiceOut.id;
+ connection = await db.getConnection();
+ connection.query('START TRANSACTION');
+
+ const args = Object.assign({
+ invoiceId: invoiceOut.id,
+ recipientId: invoiceOut.clientFk,
+ recipient: invoiceOut.recipient,
+ replyTo: invoiceOut.salesPersonEmail
+ }, response.locals);
+
+ const invoiceReport = new Report('invoice', args);
+ const stream = await invoiceReport.toPdfStream();
+
+ const issued = invoiceOut.issued;
+ const year = issued.getFullYear().toString();
+ const month = (issued.getMonth() + 1).toString();
+ const day = issued.getDate().toString();
+
+ const fileName = `${year}${invoiceOut.ref}.pdf`;
+
+ // Store invoice
+ storage.write(stream, {
+ type: 'invoice',
+ path: `${year}/${month}/${day}`,
+ fileName: fileName
+ });
+
+ connection.query('UPDATE invoiceOut SET hasPdf = true WHERE id = ?', [invoiceOut.id]);
+
+ const isToBeMailed = invoiceOut.recipient && invoiceOut.salesPersonFk && invoiceOut.isToBeMailed;
+
+ if (isToBeMailed) {
+ const mailOptions = {
+ overrideAttachments: true,
+ attachments: []
+ };
+
+ const invoiceAttachment = {
+ filename: fileName,
+ content: stream
+ };
+
+ if (invoiceOut.serial == 'E' && invoiceOut.companyCode == 'VNL') {
+ const exportation = new Report('exportation', args);
+ const stream = await exportation.toPdfStream();
+ const fileName = `CITES-${invoiceOut.ref}.pdf`;
+
+ mailOptions.attachments.push({
+ filename: fileName,
+ content: stream
+ });
+ }
+
+ mailOptions.attachments.push(invoiceAttachment);
+
+ const email = new Email('invoice', args);
+ await email.send(mailOptions);
+ }
+ // Update queue status
+ sql = `UPDATE invoiceOut_queue
+ SET status = "printed",
+ printed = NOW()
+ WHERE invoiceFk = ?`;
+ connection.query(sql, [invoiceOut.id]);
+ connection.query('COMMIT');
+ } catch (error) {
+ connection.query('ROLLBACK');
+ connection.release();
+ sql = `UPDATE invoiceOut_queue
+ SET status = ?
+ WHERE invoiceFk = ?`;
+ await db.rawSql(sql, [error.message, invoiceId]);
+ }
+ }
+ } catch (error) {
+ next(error);
+ }
+};
diff --git a/print/templates/email/osticket-report/osticket-report.html b/print/templates/email/osticket-report/osticket-report.html
index 76973c8e1..a9cf9a24a 100644
--- a/print/templates/email/osticket-report/osticket-report.html
+++ b/print/templates/email/osticket-report/osticket-report.html
@@ -35,8 +35,8 @@
diff --git a/print/templates/reports/delivery-note/delivery-note.js b/print/templates/reports/delivery-note/delivery-note.js
index adda6e756..f9dba0578 100755
--- a/print/templates/reports/delivery-note/delivery-note.js
+++ b/print/templates/reports/delivery-note/delivery-note.js
@@ -7,6 +7,10 @@ const fs = require('fs-extra');
module.exports = {
name: 'delivery-note',
+ created() {
+ if (!this.type)
+ this.type = 'deliveryNote';
+ },
async serverPrefetch() {
this.client = await this.fetchClient(this.ticketId);
this.ticket = await this.fetchTicket(this.ticketId);
@@ -129,7 +133,7 @@ module.exports = {
},
type: {
type: String,
- required: true
+ required: false
}
}
};
diff --git a/print/templates/reports/driver-route/sql/routes.sql b/print/templates/reports/driver-route/sql/routes.sql
index 3fbe59b0d..4b6f6a318 100644
--- a/print/templates/reports/driver-route/sql/routes.sql
+++ b/print/templates/reports/driver-route/sql/routes.sql
@@ -14,5 +14,6 @@ FROM route r
LEFT JOIN account.user u ON u.id = w.userFk
LEFT JOIN agencyMode am ON am.id = r.agencyModeFk
LEFT JOIN agency a ON a.id = am.agencyFk
- LEFT JOIN supplier s ON s.id = a.supplierFk
+ LEFT JOIN supplierAgencyTerm sa ON sa.agencyFk = a.id
+ LEFT JOIN supplier s ON s.id = sa.supplierFk
WHERE r.id IN(?)
\ No newline at end of file
diff --git a/storage/access/.keep b/storage/access/.keep
new file mode 100644
index 000000000..8e2556896
--- /dev/null
+++ b/storage/access/.keep
@@ -0,0 +1 @@
+Forces tmp folder creation!
\ No newline at end of file
diff --git a/storage/dms/8f1/7.jpg b/storage/dms/8f1/7.jpg
new file mode 100644
index 000000000..83052dea6
Binary files /dev/null and b/storage/dms/8f1/7.jpg differ
diff --git a/storage/dms/c9f/8.mp4 b/storage/dms/c9f/8.mp4
new file mode 100644
index 000000000..b11552f9c
Binary files /dev/null and b/storage/dms/c9f/8.mp4 differ