Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 4146-claim_pickup_order
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
commit
2b060a1437
|
@ -0,0 +1,58 @@
|
|||
const UserError = require('vn-loopback/util/user-error');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('privileges', {
|
||||
description: 'Change role and hasGrant if user has privileges',
|
||||
accepts: [
|
||||
{
|
||||
arg: 'id',
|
||||
type: 'number',
|
||||
required: true,
|
||||
description: 'The user id',
|
||||
http: {source: 'path'}
|
||||
},
|
||||
{
|
||||
arg: 'roleFk',
|
||||
type: 'number',
|
||||
description: 'The new role for user',
|
||||
},
|
||||
{
|
||||
arg: 'hasGrant',
|
||||
type: 'boolean',
|
||||
description: 'Whether to has grant'
|
||||
}
|
||||
],
|
||||
http: {
|
||||
path: `/:id/privileges`,
|
||||
verb: 'POST'
|
||||
}
|
||||
});
|
||||
|
||||
Self.privileges = async function(ctx, id, roleFk, hasGrant, options) {
|
||||
const models = Self.app.models;
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
|
||||
const myOptions = {};
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
const user = await models.Account.findById(userId, null, myOptions);
|
||||
|
||||
if (!user.hasGrant)
|
||||
throw new UserError(`You don't have enough privileges`);
|
||||
|
||||
const userToUpdate = await models.Account.findById(id);
|
||||
if (hasGrant != null)
|
||||
return await userToUpdate.updateAttribute('hasGrant', hasGrant, myOptions);
|
||||
if (!roleFk) return;
|
||||
|
||||
const role = await models.Role.findById(roleFk, null, myOptions);
|
||||
const hasRole = await models.Account.hasRole(userId, role.name, myOptions);
|
||||
|
||||
if (!hasRole)
|
||||
throw new UserError(`You don't have enough privileges`);
|
||||
|
||||
await userToUpdate.updateAttribute('roleFk', roleFk, myOptions);
|
||||
};
|
||||
};
|
|
@ -0,0 +1,99 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('account privileges()', () => {
|
||||
const employeeId = 1;
|
||||
const developerId = 9;
|
||||
const sysadminId = 66;
|
||||
const bruceWayneId = 1101;
|
||||
|
||||
it('should throw an error when user not has privileges', async() => {
|
||||
const ctx = {req: {accessToken: {userId: developerId}}};
|
||||
const tx = await models.Account.beginTransaction({});
|
||||
|
||||
let error;
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
await models.Account.privileges(ctx, employeeId, null, true, options);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
error = e;
|
||||
await tx.rollback();
|
||||
}
|
||||
|
||||
expect(error.message).toContain(`You don't have enough privileges`);
|
||||
});
|
||||
|
||||
it('should throw an error when user has privileges but not has the role', async() => {
|
||||
const ctx = {req: {accessToken: {userId: sysadminId}}};
|
||||
const tx = await models.Account.beginTransaction({});
|
||||
|
||||
let error;
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const root = await models.Role.findOne({
|
||||
where: {
|
||||
name: 'root'
|
||||
}
|
||||
}, options);
|
||||
await models.Account.privileges(ctx, employeeId, root.id, null, options);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
error = e;
|
||||
await tx.rollback();
|
||||
}
|
||||
|
||||
expect(error.message).toContain(`You don't have enough privileges`);
|
||||
});
|
||||
|
||||
it('should change role', async() => {
|
||||
const ctx = {req: {accessToken: {userId: sysadminId}}};
|
||||
const tx = await models.Account.beginTransaction({});
|
||||
|
||||
const options = {transaction: tx};
|
||||
const agency = await models.Role.findOne({
|
||||
where: {
|
||||
name: 'agency'
|
||||
}
|
||||
}, options);
|
||||
|
||||
let error;
|
||||
let result;
|
||||
try {
|
||||
await models.Account.privileges(ctx, bruceWayneId, agency.id, null, options);
|
||||
result = await models.Account.findById(bruceWayneId, null, options);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
error = e;
|
||||
await tx.rollback();
|
||||
}
|
||||
|
||||
expect(error).not.toBeDefined();
|
||||
expect(result.roleFk).toEqual(agency.id);
|
||||
});
|
||||
|
||||
it('should change hasGrant', async() => {
|
||||
const ctx = {req: {accessToken: {userId: sysadminId}}};
|
||||
const tx = await models.Account.beginTransaction({});
|
||||
|
||||
let error;
|
||||
let result;
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
await models.Account.privileges(ctx, bruceWayneId, null, true, options);
|
||||
result = await models.Account.findById(bruceWayneId, null, options);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
error = e;
|
||||
await tx.rollback();
|
||||
}
|
||||
|
||||
expect(error).not.toBeDefined();
|
||||
expect(result.hasGrant).toBeTruthy();
|
||||
});
|
||||
});
|
|
@ -8,7 +8,7 @@ module.exports = Self => {
|
|||
},
|
||||
http: {
|
||||
path: `/notifyIssues`,
|
||||
verb: 'GET'
|
||||
verb: 'POST'
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -33,14 +33,14 @@ module.exports = Self => {
|
|||
await Self.sendCheckingUserStatus(chat);
|
||||
await updateChat(chat, sentStatus);
|
||||
} catch (error) {
|
||||
await updateChat(chat, errorStatus);
|
||||
await updateChat(chat, errorStatus, error);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
await Self.sendMessage(chat.senderFk, chat.recipient, chat.message);
|
||||
await updateChat(chat, sentStatus);
|
||||
} catch (error) {
|
||||
await updateChat(chat, errorStatus);
|
||||
await updateChat(chat, errorStatus, error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ module.exports = Self => {
|
|||
const channelName = department && department.chatName;
|
||||
|
||||
if (channelName)
|
||||
return Self.sendMessage(chat.senderFk, `#${channelName}`, `@${recipient.name} ➔ ${message}`);
|
||||
return Self.sendMessage(chat.senderFk, `#${channelName}`, `@${recipient.name} ➔ ${chat.message}`);
|
||||
else
|
||||
return Self.sendMessage(chat.senderFk, `@${recipient.name}`, chat.message);
|
||||
} else
|
||||
|
@ -127,12 +127,14 @@ module.exports = Self => {
|
|||
*
|
||||
* @param {object} chat - The chat
|
||||
* @param {string} status - The new status
|
||||
* @param {string} error - The error
|
||||
* @return {Promise} - The request promise
|
||||
*/
|
||||
async function updateChat(chat, status) {
|
||||
async function updateChat(chat, status, error) {
|
||||
return chat.updateAttributes({
|
||||
status: status,
|
||||
attempts: ++chat.attempts
|
||||
attempts: ++chat.attempts,
|
||||
error: error
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -2,10 +2,10 @@ const models = require('vn-loopback/server/server').models;
|
|||
|
||||
describe('ticket getCollection()', () => {
|
||||
it('should return a list of collections', async() => {
|
||||
let ctx = {req: {accessToken: {userId: 1106}}};
|
||||
let ctx = {req: {accessToken: {userId: 1107}}};
|
||||
let response = await models.Collection.getCollection(ctx);
|
||||
|
||||
expect(response.length).toBeGreaterThan(0);
|
||||
expect(response[0].collectionFk).toEqual(1);
|
||||
expect(response[0].collectionFk).toEqual(3);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -17,14 +17,16 @@ module.exports = Self => {
|
|||
});
|
||||
|
||||
Self.deleteTrashFiles = async options => {
|
||||
const tx = await Self.beginTransaction({});
|
||||
let tx;
|
||||
const myOptions = {};
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
if (!myOptions.transaction)
|
||||
if (!myOptions.transaction) {
|
||||
tx = await Self.beginTransaction({});
|
||||
myOptions.transaction = tx;
|
||||
}
|
||||
|
||||
try {
|
||||
if (process.env.NODE_ENV == 'test')
|
||||
|
@ -53,14 +55,17 @@ module.exports = Self => {
|
|||
const pathHash = DmsContainer.getHash(dms.id);
|
||||
const dmsContainer = await DmsContainer.container(pathHash);
|
||||
const dstFile = path.join(dmsContainer.client.root, pathHash, dms.file);
|
||||
try {
|
||||
await fs.unlink(dstFile);
|
||||
} catch (err) {
|
||||
continue;
|
||||
}
|
||||
const dstFolder = path.join(dmsContainer.client.root, pathHash);
|
||||
await fs.unlink(dstFile);
|
||||
try {
|
||||
await fs.rmdir(dstFolder);
|
||||
await dms.destroy(myOptions);
|
||||
} catch (err) {
|
||||
await dms.destroy(myOptions);
|
||||
}
|
||||
} catch (err) {}
|
||||
|
||||
await dms.destroy(myOptions);
|
||||
}
|
||||
if (tx) await tx.commit();
|
||||
} catch (e) {
|
||||
|
|
|
@ -12,7 +12,7 @@ module.exports = Self => {
|
|||
},
|
||||
http: {
|
||||
path: `/updateData`,
|
||||
verb: 'GET'
|
||||
verb: 'POST'
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -20,83 +20,93 @@ module.exports = Self => {
|
|||
const models = Self.app.models;
|
||||
|
||||
// Get files checksum
|
||||
const files = await Self.rawSql('SELECT name, checksum, keyValue FROM edi.fileConfig');
|
||||
const tx = await Self.beginTransaction({});
|
||||
|
||||
const updatableFiles = [];
|
||||
for (const file of files) {
|
||||
const fileChecksum = await getChecksum(file);
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
const files = await Self.rawSql('SELECT name, checksum, keyValue FROM edi.fileConfig', null, options);
|
||||
|
||||
if (file.checksum != fileChecksum) {
|
||||
updatableFiles.push({
|
||||
name: file.name,
|
||||
checksum: fileChecksum
|
||||
});
|
||||
} else
|
||||
console.debug(`File already updated, skipping...`);
|
||||
}
|
||||
const updatableFiles = [];
|
||||
for (const file of files) {
|
||||
const fileChecksum = await getChecksum(file);
|
||||
|
||||
if (updatableFiles.length === 0)
|
||||
return false;
|
||||
|
||||
// Download files
|
||||
const container = await models.TempContainer.container('edi');
|
||||
const tempPath = path.join(container.client.root, container.name);
|
||||
|
||||
let remoteFile;
|
||||
let tempDir;
|
||||
let tempFile;
|
||||
|
||||
const fileNames = updatableFiles.map(file => file.name);
|
||||
|
||||
const tables = await Self.rawSql(`
|
||||
SELECT fileName, toTable, file
|
||||
FROM edi.tableConfig
|
||||
WHERE file IN (?)`, [fileNames]);
|
||||
|
||||
for (const table of tables) {
|
||||
const fileName = table.file;
|
||||
|
||||
console.debug(`Downloading file ${fileName}...`);
|
||||
|
||||
remoteFile = `codes/${fileName}.ZIP`;
|
||||
tempDir = `${tempPath}/${fileName}`;
|
||||
tempFile = `${tempPath}/${fileName}.zip`;
|
||||
|
||||
try {
|
||||
await fs.readFile(tempFile);
|
||||
} catch (error) {
|
||||
if (error.code === 'ENOENT') {
|
||||
const downloadOutput = await downloadFile(remoteFile, tempFile);
|
||||
if (downloadOutput.error)
|
||||
continue;
|
||||
}
|
||||
if (file.checksum != fileChecksum) {
|
||||
updatableFiles.push({
|
||||
name: file.name,
|
||||
checksum: fileChecksum
|
||||
});
|
||||
} else
|
||||
console.debug(`File already updated, skipping...`);
|
||||
}
|
||||
|
||||
console.debug(`Extracting file ${fileName}...`);
|
||||
await extractFile(tempFile, tempDir);
|
||||
if (updatableFiles.length === 0)
|
||||
return false;
|
||||
|
||||
console.debug(`Updating table ${table.toTable}...`);
|
||||
await dumpData(tempDir, table);
|
||||
}
|
||||
// Download files
|
||||
const container = await models.TempContainer.container('edi');
|
||||
const tempPath = path.join(container.client.root, container.name);
|
||||
|
||||
// Update files checksum
|
||||
for (const file of updatableFiles) {
|
||||
await Self.rawSql(`
|
||||
UPDATE edi.fileConfig
|
||||
SET checksum = ?
|
||||
WHERE name = ?`,
|
||||
[file.checksum, file.name]);
|
||||
}
|
||||
let remoteFile;
|
||||
let tempDir;
|
||||
let tempFile;
|
||||
|
||||
// Clean files
|
||||
try {
|
||||
await fs.remove(tempPath);
|
||||
const fileNames = updatableFiles.map(file => file.name);
|
||||
|
||||
const tables = await Self.rawSql(`
|
||||
SELECT fileName, toTable, file
|
||||
FROM edi.tableConfig
|
||||
WHERE file IN (?)`, [fileNames], options);
|
||||
|
||||
for (const table of tables) {
|
||||
const fileName = table.file;
|
||||
|
||||
remoteFile = `codes/${fileName}.ZIP`;
|
||||
tempDir = `${tempPath}/${fileName}`;
|
||||
tempFile = `${tempPath}/${fileName}.zip`;
|
||||
|
||||
try {
|
||||
await fs.readFile(tempFile);
|
||||
} catch (error) {
|
||||
if (error.code === 'ENOENT') {
|
||||
console.debug(`Downloading file ${fileName}...`);
|
||||
const downloadOutput = await downloadFile(remoteFile, tempFile);
|
||||
if (downloadOutput.error)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
await extractFile(fileName, tempFile, tempDir);
|
||||
|
||||
console.debug(`Updating table ${table.toTable}...`);
|
||||
await dumpData(tempDir, table, options);
|
||||
}
|
||||
|
||||
// Update files checksum
|
||||
for (const file of updatableFiles) {
|
||||
console.log(`Updating file ${file.name} checksum...`);
|
||||
await Self.rawSql(`
|
||||
UPDATE edi.fileConfig
|
||||
SET checksum = ?
|
||||
WHERE name = ?`,
|
||||
[file.checksum, file.name], options);
|
||||
}
|
||||
|
||||
await tx.commit();
|
||||
|
||||
// Clean files
|
||||
try {
|
||||
console.debug(`Cleaning files...`);
|
||||
await fs.remove(tempPath);
|
||||
} catch (error) {
|
||||
if (error.code !== 'ENOENT')
|
||||
throw e;
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch (error) {
|
||||
if (error.code !== 'ENOENT')
|
||||
throw e;
|
||||
await tx.rollback();
|
||||
throw error;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
let ftpClient;
|
||||
|
@ -126,9 +136,9 @@ module.exports = Self => {
|
|||
|
||||
const response = await new Promise((resolve, reject) => {
|
||||
ftpClient.exec((err, response) => {
|
||||
if (response.error) {
|
||||
if (err || response.error) {
|
||||
console.debug(`Error downloading checksum file... ${response.error}`);
|
||||
reject(err);
|
||||
return reject(err);
|
||||
}
|
||||
|
||||
resolve(response);
|
||||
|
@ -159,9 +169,9 @@ module.exports = Self => {
|
|||
|
||||
return new Promise((resolve, reject) => {
|
||||
ftpClient.exec((err, response) => {
|
||||
if (response.error) {
|
||||
if (err || response.error) {
|
||||
console.debug(`Error downloading file... ${response.error}`);
|
||||
reject(err);
|
||||
return reject(err);
|
||||
}
|
||||
|
||||
resolve(response);
|
||||
|
@ -169,11 +179,12 @@ module.exports = Self => {
|
|||
});
|
||||
}
|
||||
|
||||
async function extractFile(tempFile, tempDir) {
|
||||
async function extractFile(fileName, tempFile, tempDir) {
|
||||
const JSZip = require('jszip');
|
||||
|
||||
try {
|
||||
await fs.mkdir(tempDir);
|
||||
console.debug(`Extracting file ${fileName}...`);
|
||||
} catch (error) {
|
||||
if (error.code !== 'EEXIST')
|
||||
throw e;
|
||||
|
@ -196,66 +207,32 @@ module.exports = Self => {
|
|||
}
|
||||
}
|
||||
|
||||
async function dumpData(tempDir, table) {
|
||||
async function dumpData(tempDir, table, options) {
|
||||
const toTable = table.toTable;
|
||||
const baseName = table.fileName;
|
||||
|
||||
const firstEntry = entries[0];
|
||||
const entryName = firstEntry.entryName;
|
||||
const startIndex = (entryName.length - 10);
|
||||
const endIndex = (entryName.length - 4);
|
||||
const dateString = entryName.substring(startIndex, endIndex);
|
||||
console.log(`Emptying table ${toTable}...`);
|
||||
const tableName = `edi.${toTable}`;
|
||||
await Self.rawSql(`DELETE FROM ??`, [tableName]);
|
||||
|
||||
const lastUpdated = new Date();
|
||||
const dirFiles = await fs.readdir(tempDir);
|
||||
const files = dirFiles.filter(file => file.startsWith(baseName));
|
||||
|
||||
let updated = null;
|
||||
if (file.updated) {
|
||||
updated = new Date(file.updated);
|
||||
updated.setHours(0, 0, 0, 0);
|
||||
}
|
||||
for (const file of files) {
|
||||
console.log(`Dumping data from file ${file}...`);
|
||||
|
||||
// Format string date to a date object
|
||||
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);
|
||||
const templatePath = path.join(__dirname, `./sql/${toTable}.sql`);
|
||||
const sqlTemplate = await fs.readFile(templatePath, 'utf8');
|
||||
const filePath = path.join(tempDir, file);
|
||||
|
||||
if (updated && lastUpdated <= updated) {
|
||||
console.debug(`Table ${toTable} already updated, skipping...`);
|
||||
return;
|
||||
}
|
||||
|
||||
const tx = await Self.beginTransaction({});
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const tableName = `edi.${toTable}`;
|
||||
await Self.rawSql(`DELETE FROM ??`, [tableName], options);
|
||||
|
||||
const dirFiles = await fs.readdir(tempDir);
|
||||
const files = dirFiles.filter(file => file.startsWith(baseName));
|
||||
|
||||
for (const file of files) {
|
||||
console.log(`Dumping data from file ${file}...`);
|
||||
|
||||
const templatePath = path.join(__dirname, `./sql/${toTable}.sql`);
|
||||
const sqlTemplate = await fs.readFile(templatePath, 'utf8');
|
||||
const filePath = path.join(tempDir, file);
|
||||
|
||||
await Self.rawSql(sqlTemplate, [filePath], options);
|
||||
await Self.rawSql(`
|
||||
await Self.rawSql(sqlTemplate, [filePath], options);
|
||||
await Self.rawSql(`
|
||||
UPDATE edi.tableConfig
|
||||
SET updated = ?
|
||||
WHERE fileName = ?
|
||||
`, [new Date(), baseName], options);
|
||||
}
|
||||
|
||||
tx.commit();
|
||||
} catch (error) {
|
||||
tx.rollback();
|
||||
throw error;
|
||||
}
|
||||
|
||||
console.log(`Updated table ${toTable}\n`);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -0,0 +1,118 @@
|
|||
const jsdom = require('jsdom');
|
||||
const mysql = require('mysql');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('closeTicket', {
|
||||
description: 'Close tickets without response from the user',
|
||||
accessType: 'READ',
|
||||
returns: {
|
||||
type: 'Object',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/closeTicket`,
|
||||
verb: 'POST'
|
||||
}
|
||||
});
|
||||
|
||||
Self.closeTicket = async ctx => {
|
||||
const models = Self.app.models;
|
||||
const config = await models.OsTicketConfig.findOne();
|
||||
const ostUri = `${config.host}/login.php`;
|
||||
|
||||
if (!config.user || !config.password || !config.userDb || !config.passwordDb)
|
||||
return false;
|
||||
|
||||
const con = mysql.createConnection({
|
||||
host: `${config.hostDb}`,
|
||||
user: `${config.userDb}`,
|
||||
password: `${config.passwordDb}`,
|
||||
port: `${config.portDb}`
|
||||
});
|
||||
|
||||
const sql = `SELECT ot.ticket_id, ot.number
|
||||
FROM osticket.ost_ticket ot
|
||||
JOIN osticket.ost_ticket_status ots ON ots.id = ot.status_id
|
||||
JOIN osticket.ost_thread ot2 ON ot2.object_id = ot.ticket_id AND ot2.object_type = 'T'
|
||||
JOIN (
|
||||
SELECT ote.thread_id, MAX(ote.created) created, MAX(ote.updated) updated
|
||||
FROM osticket.ost_thread_entry ote
|
||||
WHERE ote.staff_id != 0 AND ote.type = 'R'
|
||||
GROUP BY ote.thread_id
|
||||
) sub ON sub.thread_id = ot2.id
|
||||
WHERE ot.isanswered = 1
|
||||
AND ots.state = '${config.oldStatus}'
|
||||
AND IF(sub.updated > sub.created, sub.updated, sub.created) < DATE_SUB(CURDATE(), INTERVAL ${config.day} DAY)`;
|
||||
|
||||
let ticketsId = [];
|
||||
con.connect(err => {
|
||||
if (err) throw err;
|
||||
con.query(sql, (err, results) => {
|
||||
if (err) throw err;
|
||||
for (const result of results)
|
||||
ticketsId.push(result.ticket_id);
|
||||
});
|
||||
});
|
||||
|
||||
await requestToken();
|
||||
|
||||
async function requestToken() {
|
||||
const response = await fetch(ostUri);
|
||||
|
||||
const result = response.headers.get('set-cookie');
|
||||
const [firtHeader] = result.split(' ');
|
||||
const firtCookie = firtHeader.substring(0, firtHeader.length - 1);
|
||||
const body = await response.text();
|
||||
const dom = new jsdom.JSDOM(body);
|
||||
const token = dom.window.document.querySelector('[name="__CSRFToken__"]').value;
|
||||
|
||||
await login(token, firtCookie);
|
||||
}
|
||||
|
||||
async function login(token, firtCookie) {
|
||||
const data = {
|
||||
__CSRFToken__: token,
|
||||
do: 'scplogin',
|
||||
userid: config.user,
|
||||
passwd: config.password,
|
||||
ajax: 1
|
||||
};
|
||||
const params = {
|
||||
method: 'POST',
|
||||
body: new URLSearchParams(data),
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
'Cookie': firtCookie
|
||||
}
|
||||
};
|
||||
const response = await fetch(ostUri, params);
|
||||
const result = response.headers.get('set-cookie');
|
||||
const [firtHeader] = result.split(' ');
|
||||
const secondCookie = firtHeader.substring(0, firtHeader.length - 1);
|
||||
|
||||
await close(token, secondCookie);
|
||||
}
|
||||
|
||||
async function close(token, secondCookie) {
|
||||
for (const ticketId of ticketsId) {
|
||||
const ostUri = `${config.host}/ajax.php/tickets/${ticketId}/status`;
|
||||
const data = {
|
||||
status_id: config.newStatusId,
|
||||
comments: config.comment,
|
||||
undefined: config.action
|
||||
};
|
||||
const params = {
|
||||
method: 'POST',
|
||||
body: new URLSearchParams(data),
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
'X-CSRFToken': token,
|
||||
'Cookie': secondCookie
|
||||
}
|
||||
};
|
||||
|
||||
return fetch(ostUri, params);
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
|
@ -0,0 +1,29 @@
|
|||
const {Email} = require('vn-print');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('osTicketReportEmail', {
|
||||
description: 'Sends the buyer waste email',
|
||||
accessType: 'WRITE',
|
||||
accepts: [],
|
||||
returns: {
|
||||
type: ['object'],
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: '/osticket-report-email',
|
||||
verb: 'POST'
|
||||
}
|
||||
});
|
||||
|
||||
Self.osTicketReportEmail = async ctx => {
|
||||
const models = Self.app.models;
|
||||
const printConfig = await models.PrintConfig.findOne();
|
||||
|
||||
const email = new Email('osticket-report', {
|
||||
recipient: printConfig.itRecipient,
|
||||
lang: ctx.req.getLocale()
|
||||
});
|
||||
|
||||
return email.send();
|
||||
};
|
||||
};
|
|
@ -116,8 +116,14 @@
|
|||
"OsTicket": {
|
||||
"dataSource": "osticket"
|
||||
},
|
||||
"OsTicketConfig": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"Edi": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"PrintConfig": {
|
||||
"dataSource": "vn"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ module.exports = Self => {
|
|||
require('../methods/account/change-password')(Self);
|
||||
require('../methods/account/set-password')(Self);
|
||||
require('../methods/account/validate-token')(Self);
|
||||
require('../methods/account/privileges')(Self);
|
||||
|
||||
// Validations
|
||||
|
||||
|
@ -77,7 +78,7 @@ module.exports = Self => {
|
|||
`SELECT r.name
|
||||
FROM account.user u
|
||||
JOIN account.roleRole rr ON rr.role = u.role
|
||||
JOIN account.role r ON r.id = rr.inheritsFrom
|
||||
JOIN account.role r ON r.id = rr.inheritsFrom
|
||||
WHERE u.id = ?`, [userId], options);
|
||||
|
||||
let roles = [];
|
||||
|
|
|
@ -48,6 +48,9 @@
|
|||
},
|
||||
"image": {
|
||||
"type": "string"
|
||||
},
|
||||
"hasGrant": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
|
|
|
@ -32,6 +32,9 @@
|
|||
},
|
||||
"attempts": {
|
||||
"type": "number"
|
||||
},
|
||||
"error": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"acls": [{
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
{
|
||||
"name": "OsTicketConfig",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "osTicketConfig"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "number",
|
||||
"id": true,
|
||||
"description": "Identifier"
|
||||
},
|
||||
"host": {
|
||||
"type": "string"
|
||||
},
|
||||
"user": {
|
||||
"type": "string"
|
||||
},
|
||||
"password": {
|
||||
"type": "string"
|
||||
},
|
||||
"oldStatus": {
|
||||
"type": "string"
|
||||
},
|
||||
"newStatusId": {
|
||||
"type": "number"
|
||||
},
|
||||
"action": {
|
||||
"type": "string"
|
||||
},
|
||||
"day": {
|
||||
"type": "number"
|
||||
},
|
||||
"comment": {
|
||||
"type": "string"
|
||||
},
|
||||
"hostDb": {
|
||||
"type": "string"
|
||||
},
|
||||
"userDb": {
|
||||
"type": "string"
|
||||
},
|
||||
"passwordDb": {
|
||||
"type": "string"
|
||||
},
|
||||
"portDb": {
|
||||
"type": "number"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
module.exports = Self => {
|
||||
require('../methods/osticket/osTicketReportEmail')(Self);
|
||||
require('../methods/osticket/closeTicket')(Self);
|
||||
};
|
|
@ -1,12 +1,5 @@
|
|||
{
|
||||
"name": "OsTicket",
|
||||
"base": "VnModel",
|
||||
"acls": [{
|
||||
"property": "validations",
|
||||
"accessType": "EXECUTE",
|
||||
"principalType": "ROLE",
|
||||
"principalId": "$everyone",
|
||||
"permission": "ALLOW"
|
||||
}]
|
||||
"base": "VnModel"
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
"name": "PrintConfig",
|
||||
"description": "Print config",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "salix.printConfig"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"id": true,
|
||||
"type": "number",
|
||||
"description": "Identifier"
|
||||
},
|
||||
"itRecipient": {
|
||||
"type": "string"
|
||||
},
|
||||
"incidencesEmail": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"acls": [{
|
||||
"accessType": "READ",
|
||||
"principalType": "ROLE",
|
||||
"principalId": "$everyone",
|
||||
"permission": "ALLOW"
|
||||
}]
|
||||
}
|
|
@ -18,6 +18,7 @@
|
|||
"modules/supplier/front/**/*",
|
||||
"modules/ticket/front/**/*",
|
||||
"modules/travel/front/**/*",
|
||||
"modules/shelving/front/**/*",
|
||||
"modules/worker/front/**/*",
|
||||
"modules/zone/front/**/*"
|
||||
]
|
||||
|
|
|
@ -7,13 +7,18 @@ process.on('warning', warning => {
|
|||
console.log(warning.stack);
|
||||
});
|
||||
|
||||
process.on('exit', async function() {
|
||||
if (container) await container.rm();
|
||||
});
|
||||
|
||||
let container;
|
||||
async function test() {
|
||||
let isCI = false;
|
||||
|
||||
if (process.argv[2] === 'ci')
|
||||
isCI = true;
|
||||
|
||||
const container = new Docker();
|
||||
container = new Docker();
|
||||
|
||||
await container.run(isCI);
|
||||
dataSources = JSON.parse(JSON.stringify(dataSources));
|
||||
|
@ -46,6 +51,7 @@ async function test() {
|
|||
jasmine.addReporter(new JunitReporter.JUnitXmlReporter());
|
||||
|
||||
jasmine.jasmine.DEFAULT_TIMEOUT_INTERVAL = 30000;
|
||||
jasmine.exitOnCompletion = true;
|
||||
}
|
||||
|
||||
const backSpecs = [
|
||||
|
@ -60,11 +66,10 @@ async function test() {
|
|||
helpers: [],
|
||||
});
|
||||
|
||||
jasmine.exitOnCompletion = false;
|
||||
await jasmine.execute();
|
||||
if (app) await app.disconnect();
|
||||
if (container) await container.rm();
|
||||
console.log('app disconnected & container removed');
|
||||
console.log('App disconnected & container removed');
|
||||
}
|
||||
|
||||
test();
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId)
|
||||
VALUES('InvoiceInDueDay', '*', '*', 'ALLOW', 'ROLE', 'administrative');
|
|
@ -1,248 +0,0 @@
|
|||
DROP PROCEDURE IF EXISTS vn.invoiceInBookingMain;
|
||||
|
||||
DELIMITER $$
|
||||
$$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`invoiceInBookingMain`(vInvoiceInId INT)
|
||||
BEGIN
|
||||
DECLARE vTotalAmount,vTotalAmountDivisa DECIMAL(10,2);
|
||||
DECLARE vBookNumber,vSerialNumber INT;
|
||||
DECLARE vRate DECIMAL(10,4);
|
||||
|
||||
CALL invoiceInBookingCommon(vInvoiceInId,vSerialNumber);
|
||||
|
||||
SELECT SUM(iit.taxableBase * IF( i.serial= 'R' AND ti.Iva <> 'HP DEVENGADO 21 ISP', 1 +(ti.PorcentajeIva/100),1)),
|
||||
SUM(iit.foreignValue * IF( i.serial= 'R', 1 + (ti.PorcentajeIva/100),1)),
|
||||
iit.taxableBase/iit.foreignValue
|
||||
INTO vTotalAmount, vTotalAmountDivisa, vRate
|
||||
FROM newInvoiceIn i
|
||||
JOIN invoiceInTax iit ON iit.invoiceInFk = i.id
|
||||
LEFT JOIN sage.TiposIva ti ON ti.CodigoIva = iit.taxTypeSageFk;
|
||||
|
||||
CALL vn.ledger_next(vBookNumber);
|
||||
|
||||
-- Apunte del proveedor
|
||||
|
||||
INSERT INTO XDiario(ASIEN,
|
||||
FECHA,
|
||||
SUBCTA,
|
||||
EUROHABER,
|
||||
CONCEPTO,
|
||||
CAMBIO,
|
||||
HABERME,
|
||||
NFACTICK,
|
||||
CLAVE,
|
||||
empresa_id
|
||||
)
|
||||
SELECT
|
||||
vBookNumber,
|
||||
n.bookEntried,
|
||||
s.supplierAccount,
|
||||
vTotalAmount EUROHABER,
|
||||
n.conceptWithSupplier,
|
||||
vRate,
|
||||
vTotalAmountDivisa,
|
||||
n.invoicesCount,
|
||||
vInvoiceInId,
|
||||
n.companyFk
|
||||
FROM newInvoiceIn n
|
||||
JOIN newSupplier s;
|
||||
|
||||
-- Línea de Gastos
|
||||
INSERT INTO XDiario ( ASIEN,
|
||||
FECHA,
|
||||
SUBCTA,
|
||||
CONTRA,
|
||||
EURODEBE,
|
||||
EUROHABER,
|
||||
CONCEPTO,
|
||||
CAMBIO,
|
||||
DEBEME,
|
||||
HABERME,
|
||||
NFACTICK,
|
||||
empresa_id
|
||||
)
|
||||
SELECT vBookNumber ASIEN,
|
||||
n.bookEntried FECHA,
|
||||
IF(e.isWithheld , LPAD(RIGHT(s.supplierAccount,5),10,iit.expenceFk),iit.expenceFk) SUBCTA,
|
||||
s.supplierAccount CONTRA,
|
||||
IF(e.isWithheld AND iit.taxableBase < 0, NULL, ROUND(SUM(iit.taxableBase),2)) EURODEBE,
|
||||
IF(e.isWithheld AND iit.taxableBase < 0,ROUND(SUM(-iit.taxableBase),2),NULL) EUROHABER,
|
||||
n.conceptWithSupplier CONCEPTO,
|
||||
vRate,
|
||||
IF(e.isWithheld,NULL,ABS(ROUND(SUM(iit.foreignValue),2))) DEBEME,
|
||||
IF(e.isWithheld,ABS(ROUND(SUM(iit.foreignValue),2)),NULL) HABERME,
|
||||
n.invoicesCount NFACTICK,
|
||||
n.companyFk empresa_id
|
||||
FROM newInvoiceIn n
|
||||
JOIN newSupplier s
|
||||
JOIN invoiceInTax iit ON iit.invoiceInFk = n.id
|
||||
JOIN (SELECT * FROM expence e GROUP BY e.id)e ON e.id = iit.expenceFk
|
||||
WHERE e.name != 'Suplidos Transitarios nacionales'
|
||||
GROUP BY iit.expenceFk;
|
||||
|
||||
-- Líneas de IVA
|
||||
|
||||
INSERT INTO XDiario( ASIEN,
|
||||
FECHA,
|
||||
SUBCTA,
|
||||
CONTRA,
|
||||
EURODEBE,
|
||||
BASEEURO,
|
||||
CONCEPTO,
|
||||
FACTURA,
|
||||
IVA,
|
||||
AUXILIAR,
|
||||
SERIE,
|
||||
TIPOOPE,
|
||||
FECHA_EX,
|
||||
FECHA_OP,
|
||||
NFACTICK,
|
||||
FACTURAEX,
|
||||
L340,
|
||||
LRECT349,
|
||||
TIPOCLAVE,
|
||||
TIPOEXENCI,
|
||||
TIPONOSUJE,
|
||||
TIPOFACT,
|
||||
TIPORECTIF,
|
||||
TERIDNIF,
|
||||
TERNIF,
|
||||
TERNOM,
|
||||
FECREGCON,
|
||||
empresa_id
|
||||
)
|
||||
SELECT vBookNumber ASIEN,
|
||||
n.bookEntried FECHA,
|
||||
IF(n.expenceFkDeductible>0, n.expenceFkDeductible, ti.CuentaIvaSoportado) SUBCTA,
|
||||
s.supplierAccount CONTRA,
|
||||
SUM(ROUND(ti.PorcentajeIva * it.taxableBase / 100 /* + 0.0001*/ , 2)) EURODEBE,
|
||||
SUM(it.taxableBase) BASEEURO,
|
||||
GROUP_CONCAT(DISTINCT e.`name` SEPARATOR ', ') CONCEPTO,
|
||||
vSerialNumber FACTURA,
|
||||
ti.PorcentajeIva IVA,
|
||||
IF(isUeeMember AND eWithheld.id IS NULL,'','*') AUXILIAR,
|
||||
n.serial SERIE,
|
||||
ttr.ClaveOperacionDefecto,
|
||||
n.issued FECHA_EX,
|
||||
n.operated FECHA_OP,
|
||||
n.invoicesCount NFACTICK,
|
||||
n.supplierRef FACTURAEX,
|
||||
TRUE L340,
|
||||
(isSameCountry OR NOT isUeeMember) LRECT349,
|
||||
n.cplusTrascendency472Fk TIPOCLAVE,
|
||||
n.cplusTaxBreakFk TIPOEXENCI,
|
||||
n.cplusSubjectOpFk TIPONOSUJE,
|
||||
n.cplusInvoiceType472Fk TIPOFACT,
|
||||
n.cplusRectificationTypeFk TIPORECTIF,
|
||||
iis.cplusTerIdNifFk TERIDNIF,
|
||||
s.nif AS TERNIF,
|
||||
s.name AS TERNOM,
|
||||
n.booked FECREGCON,
|
||||
n.companyFk
|
||||
FROM newInvoiceIn n
|
||||
JOIN newSupplier s
|
||||
JOIN invoiceInTax it ON n.id = it.invoiceInFk
|
||||
JOIN sage.TiposIva ti ON ti.CodigoIva = it.taxTypeSageFk
|
||||
JOIN sage.TiposTransacciones ttr ON ttr.CodigoTransaccion = it.transactionTypeSageFk
|
||||
JOIN invoiceInSerial iis ON iis.code = n.serial
|
||||
JOIN (SELECT * FROM expence e GROUP BY e.id)e ON e.id = it.expenceFk
|
||||
LEFT JOIN (
|
||||
SELECT eWithheld.id
|
||||
FROM invoiceInTax hold
|
||||
JOIN expence eWithheld ON eWithheld.id = hold.expenceFk AND eWithheld.isWithheld
|
||||
WHERE hold.invoiceInFk = vInvoiceInId LIMIT 1
|
||||
) eWithheld ON TRUE
|
||||
WHERE it.taxTypeSageFk IS NOT NULL
|
||||
AND it.taxTypeSageFk NOT IN (22, 90)
|
||||
GROUP BY ti.PorcentajeIva, e.id;
|
||||
|
||||
-- Línea iva inversor sujeto pasivo
|
||||
|
||||
INSERT INTO XDiario( ASIEN,
|
||||
FECHA,
|
||||
SUBCTA,
|
||||
CONTRA,
|
||||
EUROHABER,
|
||||
BASEEURO,
|
||||
CONCEPTO,
|
||||
FACTURA,
|
||||
IVA,
|
||||
AUXILIAR,
|
||||
SERIE,
|
||||
TIPOOPE,
|
||||
FECHA_EX,
|
||||
FECHA_OP,
|
||||
NFACTICK,
|
||||
FACTURAEX,
|
||||
L340,
|
||||
LRECT349,
|
||||
TIPOCLAVE,
|
||||
TIPOEXENCI,
|
||||
TIPONOSUJE,
|
||||
TIPOFACT,
|
||||
TIPORECTIF,
|
||||
TERIDNIF,
|
||||
TERNIF,
|
||||
TERNOM,
|
||||
empresa_id
|
||||
)
|
||||
SELECT vBookNumber ASIEN,
|
||||
n.bookEntried FECHA,
|
||||
ti.CuentaIvaRepercutido SUBCTA,
|
||||
s.supplierAccount CONTRA,
|
||||
SUM(ROUND(ti.PorcentajeIva * it.taxableBase / 100,2)) EUROHABER,
|
||||
ROUND(SUM(it.taxableBase),2) BASEEURO,
|
||||
GROUP_CONCAT(DISTINCT e.`name` SEPARATOR ', ') CONCEPTO,
|
||||
vSerialNumber FACTURA,
|
||||
ti.PorcentajeIva IVA,
|
||||
'*' AUXILIAR,
|
||||
n.serial SERIE,
|
||||
ttr.ClaveOperacionDefecto,
|
||||
n.issued FECHA_EX,
|
||||
n.operated FECHA_OP,
|
||||
n.invoicesCount NFACTICK,
|
||||
n.supplierRef FACTURAEX,
|
||||
FALSE L340,
|
||||
(isSameCountry OR NOT isUeeMember) LRECT349,
|
||||
1 TIPOCLAVE,
|
||||
n.cplusTaxBreakFk TIPOEXENCI,
|
||||
n.cplusSubjectOpFk TIPONOSUJE,
|
||||
n.cplusInvoiceType472Fk TIPOFACT,
|
||||
n.cplusRectificationTypeFk TIPORECTIF,
|
||||
iis.cplusTerIdNifFk TERIDNIF,
|
||||
s.nif AS TERNIF,
|
||||
s.name AS TERNOM,
|
||||
n.companyFk
|
||||
FROM newInvoiceIn n
|
||||
JOIN newSupplier s
|
||||
JOIN invoiceInTax it ON n.id = it.invoiceInFk
|
||||
JOIN sage.TiposIva ti ON ti.CodigoIva = it.taxTypeSageFk
|
||||
JOIN sage.TiposTransacciones ttr ON ttr.CodigoTransaccion = it.transactionTypeSageFk
|
||||
JOIN invoiceInSerial iis ON iis.code = n.serial
|
||||
JOIN (SELECT * FROM expence e GROUP BY e.id)e ON e.id = it.expenceFk
|
||||
WHERE ti.Iva = 'HP DEVENGADO 21 ISP' OR MID(s.account, 4, 1) = '1'
|
||||
GROUP BY ti.PorcentajeIva, e.id;
|
||||
|
||||
-- Actualización del registro original
|
||||
UPDATE invoiceIn ii
|
||||
JOIN newInvoiceIn ni ON ii.id = ni.id
|
||||
SET ii.serialNumber = vSerialNumber,
|
||||
ii.isBooked = TRUE;
|
||||
|
||||
-- Problemas derivados de la precisión en los decimales al calcular los impuestos
|
||||
UPDATE XDiario
|
||||
SET EURODEBE = EURODEBE -
|
||||
(SELECT IF(ABS(sub.difference) = 0.01, sub.difference, 0)
|
||||
FROM(
|
||||
SELECT SUM(IFNULL(ROUND(EURODEBE, 2),0)) - SUM(IFNULL(ROUND(EUROHABER, 2), 0)) difference
|
||||
FROM XDiario
|
||||
WHERE ASIEN = vBookNumber
|
||||
)sub
|
||||
)
|
||||
WHERE ASIEN = vBookNumber
|
||||
AND EURODEBE <> 0
|
||||
ORDER BY id DESC
|
||||
LIMIT 1;
|
||||
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,12 +0,0 @@
|
|||
UPDATE `vn`.`companyGroup`
|
||||
SET `code`='verdnatura'
|
||||
WHERE `id`=1;
|
||||
UPDATE `vn`.`companyGroup`
|
||||
SET `code`='ornamental'
|
||||
WHERE `id`=2;
|
||||
UPDATE `vn`.`companyGroup`
|
||||
SET `code`='other'
|
||||
WHERE `id`=3;
|
||||
UPDATE `vn`.`companyGroup`
|
||||
SET `code`='provisional'
|
||||
WHERE `id`=4;
|
|
@ -1,38 +0,0 @@
|
|||
USE vn;
|
||||
DELIMITER $$
|
||||
$$
|
||||
CREATE OR REPLACE
|
||||
ALGORITHM = UNDEFINED VIEW `vn`.`saleVolume` AS
|
||||
select
|
||||
`s`.`ticketFk` AS `ticketFk`,
|
||||
`s`.`id` AS `saleFk`,
|
||||
round(`ic`.`cm3delivery` * `s`.`quantity` / 1000, 0) AS `litros`,
|
||||
`t`.`routeFk` AS `routeFk`,
|
||||
`t`.`shipped` AS `shipped`,
|
||||
`t`.`landed` AS `landed`,
|
||||
`s`.`quantity` * `ic`.`cm3delivery` / 1000000 AS `volume`,
|
||||
`s`.`quantity` * `ic`.`grams` / 1000 AS `physicalWeight`,
|
||||
`s`.`quantity` * `ic`.`cm3delivery` * greatest(`i`.`density`, 167) / 1000000 AS `weight`,
|
||||
`s`.`quantity` * `ic`.`cm3delivery` / 1000000 AS `physicalVolume`,
|
||||
`s`.`quantity` * `ic`.`cm3delivery` * ifnull(`t`.`zonePrice`, `z`.`price`) / (`vc`.`standardFlowerBox` * 1000) AS `freight`,
|
||||
`t`.`zoneFk` AS `zoneFk`,
|
||||
`t`.`clientFk` AS `clientFk`,
|
||||
`s`.`isPicked` AS `isPicked`,
|
||||
`s`.`quantity` * `s`.`price` * (100 - `s`.`discount`) / 100 AS `eurosValue`,
|
||||
`i`.`itemPackingTypeFk` AS `itemPackingTypeFk`
|
||||
from
|
||||
(((((`sale` `s`
|
||||
join `item` `i` on
|
||||
(`i`.`id` = `s`.`itemFk`))
|
||||
join `ticket` `t` on
|
||||
(`t`.`id` = `s`.`ticketFk`))
|
||||
join `zone` `z` on
|
||||
(`z`.`id` = `t`.`zoneFk`))
|
||||
join `volumeConfig` `vc`)
|
||||
join `itemCost` `ic` on
|
||||
(`ic`.`itemFk` = `s`.`itemFk`
|
||||
and `ic`.`warehouseFk` = `t`.`warehouseFk`))
|
||||
where
|
||||
`s`.`quantity` > 0;
|
||||
$$
|
||||
DELIMITER ;
|
|
@ -1,25 +0,0 @@
|
|||
ALTER TABLE `postgresql`.`business` ADD payedHolidays INT NULL;
|
||||
ALTER TABLE `postgresql`.`business` CHANGE payedHolidays payedHolidays INT NULL AFTER reasonEndFk;
|
||||
|
||||
CREATE OR REPLACE
|
||||
ALGORITHM = UNDEFINED VIEW `vn`.`workerLabour` AS
|
||||
select
|
||||
`b`.`business_id` AS `businessFk`,
|
||||
`p`.`id_trabajador` AS `workerFk`,
|
||||
`bl`.`workcenter_id` AS `workCenterFk`,
|
||||
`b`.`date_start` AS `started`,
|
||||
`b`.`date_end` AS `ended`,
|
||||
`d`.`id` AS `departmentFk`,
|
||||
`b`.`payedHolidays` AS `payedHolidays`
|
||||
from
|
||||
((((`postgresql`.`person` `p`
|
||||
join `postgresql`.`profile` `pr` on
|
||||
((`pr`.`person_id` = `p`.`person_id`)))
|
||||
join `postgresql`.`business` `b` on
|
||||
((`b`.`client_id` = `pr`.`profile_id`)))
|
||||
join `postgresql`.`business_labour` `bl` on
|
||||
((`b`.`business_id` = `bl`.`business_id`)))
|
||||
join `vn`.`department` `d` on
|
||||
((`d`.`id` = `bl`.`department_id`)))
|
||||
order by
|
||||
`b`.`date_start` desc
|
|
@ -1,2 +0,0 @@
|
|||
DELETE FROM `salix`.`ACL`
|
||||
WHERE model = 'ClaimEnd' AND property = 'importTicketSales';
|
|
@ -1,3 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL`
|
||||
(model, property, accessType, permission, principalType, principalId)
|
||||
VALUES('Collection', 'setSaleQuantity', '*', 'ALLOW', 'ROLE', 'employee');
|
|
@ -1,3 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL`
|
||||
(model, property, accessType, permission, principalType, principalId)
|
||||
VALUES('Docuware', '*', '*', 'ALLOW', 'ROLE', 'employee');
|
|
@ -1,3 +0,0 @@
|
|||
UPDATE `salix`.`defaultViewConfig`
|
||||
SET `columns`='{"intrastat":false,"stemMultiplier":false,"landed":false,"producer":false}'
|
||||
WHERE tableCode ='itemsIndex';
|
|
@ -1,11 +0,0 @@
|
|||
CREATE TABLE `vn`.`docuware` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
`code` varchar(50) NULL,
|
||||
`fileCabinetName` varchar(50) NULL,
|
||||
`dialogName` varchar(255) DEFAULT NULL,
|
||||
`find` varchar(50) DEFAULT NULL
|
||||
);
|
||||
|
||||
INSERT INTO `vn`.`docuware` (`code`, `fileCabinetName`, `dialogName` , `find`)
|
||||
VALUES
|
||||
('deliveryClient', 'Albaranes cliente', 'findTicket', 'N__ALBAR_N');
|
|
@ -1,9 +0,0 @@
|
|||
CREATE TABLE `vn`.`docuwareConfig` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
`url` varchar(75) NULL,
|
||||
`token` varchar(1000) DEFAULT NULL
|
||||
);
|
||||
|
||||
INSERT INTO `vn`.`docuwareConfig` (`url`)
|
||||
VALUES
|
||||
('https://verdnatura.docuware.cloud/docuware/platform');
|
|
@ -1,26 +0,0 @@
|
|||
ALTER TABLE `vn`.`state` ADD classColor varchar(12) NULL;
|
||||
|
||||
UPDATE `vn`.`state` s
|
||||
SET s.classColor = 'warning'
|
||||
WHERE s.alertLevel = 1;
|
||||
|
||||
UPDATE `vn`.`state` s
|
||||
SET s.classColor = 'alert'
|
||||
WHERE s.alertLevel = 0;
|
||||
|
||||
UPDATE `vn`.`state` s
|
||||
SET s.classColor = 'success'
|
||||
WHERE s.code LIKE 'OK';
|
||||
|
||||
UPDATE `vn`.`state` s
|
||||
SET s.classColor = 'notice'
|
||||
WHERE s.code LIKE 'FREE';
|
||||
|
||||
UPDATE `vn`.`state` s
|
||||
SET s.classColor = 'success'
|
||||
WHERE s.order >= 4
|
||||
AND (s.alertLevel = 0 OR s.alertLevel = 1);
|
||||
|
||||
UPDATE `vn`.`state` s
|
||||
SET s.classColor = 'warning'
|
||||
WHERE s.code IN ('PREVIOUS_PREPARATION', 'PREPARED', 'ON_PREPARATION', 'ON_CHECKING', 'CHECKED');
|
|
@ -1,46 +0,0 @@
|
|||
DROP PROCEDURE IF EXISTS `vn`.`ticket_getMovable`;
|
||||
|
||||
DELIMITER $$
|
||||
$$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`ticket_getMovable`(vTicketFk INT, vDatedNew DATETIME, vWarehouseFk INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Cálcula el stock movible para los artículos de un ticket
|
||||
* vDatedNew debe ser menor que vDatedOld, en los otros casos se
|
||||
* asume que siempre es posible
|
||||
*
|
||||
* @param vTicketFk -> Ticket
|
||||
* @param vDatedNew -> Nueva fecha
|
||||
* @return Sales con Movible
|
||||
*/
|
||||
DECLARE vDatedOld DATETIME;
|
||||
SET vDatedNew = DATE_ADD(vDatedNew, INTERVAL 1 DAY);
|
||||
|
||||
SELECT t.shipped INTO vDatedOld
|
||||
FROM ticket t
|
||||
WHERE t.id = vTicketFk;
|
||||
|
||||
CALL itemStock(vWarehouseFk, vDatedNew, NULL);
|
||||
CALL item_getMinacum(vWarehouseFk, vDatedNew, DATEDIFF(DATE_SUB(vDatedOld, INTERVAL 1 DAY), vDatedNew), NULL);
|
||||
|
||||
SELECT s.id,
|
||||
s.itemFk,
|
||||
s.quantity,
|
||||
s.concept,
|
||||
s.price,
|
||||
s.reserved,
|
||||
s.discount,
|
||||
i.image,
|
||||
i.subName,
|
||||
il.stock + IFNULL(im.amount, 0) AS movable
|
||||
FROM ticket t
|
||||
JOIN sale s ON s.ticketFk = t.id
|
||||
JOIN item i ON i.id = s.itemFk
|
||||
LEFT JOIN tmp.itemMinacum im ON im.itemFk = s.itemFk AND im.warehouseFk = vWarehouseFk
|
||||
LEFT JOIN tmp.itemList il ON il.itemFk = s.itemFk
|
||||
WHERE t.id = vTicketFk;
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.itemList;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.itemMinacum;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,2 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL` (model,property,accessType,principalId)
|
||||
VALUES ('AgencyTerm','*','*','administrative');
|
|
@ -1,3 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId)
|
||||
VALUES
|
||||
('ClaimLog', '*', 'READ', 'ALLOW', 'ROLE', 'claimManager');
|
|
@ -1 +0,0 @@
|
|||
UPDATE `account`.`user` SET `role` = 57 WHERE id IN (2294, 4365, 7294);
|
|
@ -1,2 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId)
|
||||
VALUES ('Edi', 'updateData', 'WRITE', 'ALLOW', 'ROLE', 'employee');
|
|
@ -1,2 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL` (`id`, `model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES(304, 'Agency', '*', '*', 'ALLOW', 'ROLE', 'employee');
|
|
@ -1,3 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL`
|
||||
(`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES('InvoiceInIntrastat', '*', '*', 'ALLOW', 'ROLE', 'employee');
|
|
@ -1,10 +0,0 @@
|
|||
CREATE TABLE `vn`.`agencyTermConfig` (
|
||||
`expenceFk` varchar(10) DEFAULT NULL,
|
||||
`vatAccountSupported` varchar(15) DEFAULT NULL,
|
||||
`vatPercentage` decimal(28,10) DEFAULT NULL,
|
||||
`transaction` varchar(50) DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
INSERT INTO `vn`.`agencyTermConfig`
|
||||
(`expenceFk`, `vatAccountSupported`, `vatPercentage`, `transaction`)
|
||||
VALUES('6240000000', '4721000015', 21.0000000000, 'Adquisiciones intracomunitarias de servicios');
|
|
@ -1,8 +0,0 @@
|
|||
CREATE TABLE `vn`.`claimConfig` (
|
||||
`id` int(11) NOT NULL,
|
||||
`pickupContact` varchar(250),
|
||||
PRIMARY KEY (`id`)
|
||||
);
|
||||
|
||||
INSERT INTO vn.claimConfig (id, pickupContact)
|
||||
VALUES(1, 'Email: cmorenoa@logista.com Telf: 961594250 Extensión: 206');
|
|
@ -1,2 +0,0 @@
|
|||
ALTER TABLE `vn`.`claimState` ADD `hasToNotify` TINYINT DEFAULT 0 NULL;
|
||||
UPDATE `vn`.`claimState` SET `hasToNotify` = 1 WHERE `code` IN ('canceled', 'incomplete');
|
|
@ -1 +0,0 @@
|
|||
ALTER TABLE `vn`.`claim` ADD packages smallint(10) unsigned DEFAULT 0 NULL COMMENT 'packages received by the client';
|
|
@ -1,2 +0,0 @@
|
|||
INSERT INTO `vn`.`component` (`name`,`typeFk`,`classRate`,`isRenewable`,`code`,`isRequired`)
|
||||
VALUES ('maná reclamacion',7,4,0,'manaClaim',0);
|
|
@ -1,90 +0,0 @@
|
|||
ALTER TABLE `vn`.`country` ADD `a3Code` INT NULL COMMENT 'Código país para a3';
|
||||
|
||||
UPDATE `vn`.`country` c
|
||||
JOIN `vn2008`.`payroll_pais` `p` ON `p`.`pais` = `c`.`country`
|
||||
SET `c`.`a3Code` = `p`.`codpais`;
|
||||
|
||||
UPDATE `vn`.`country`
|
||||
SET `a3Code` = 710
|
||||
WHERE `country` = 'Sud-Africa'; -- ÁFRICA DEL SUR
|
||||
|
||||
UPDATE `vn`.`country`
|
||||
SET `a3Code` = 643
|
||||
WHERE `country` = 'Rusia'; -- FEDERACIÓN DE RUSIA
|
||||
|
||||
UPDATE `vn`.`country`
|
||||
SET `a3Code` = 28
|
||||
WHERE `country` = 'Antigua'; -- ANTIGUA Y BARBUDA
|
||||
|
||||
UPDATE `vn`.`country`
|
||||
SET `a3Code` = 840
|
||||
WHERE `country` = 'USA'; -- ESTADOS UNIDOS
|
||||
|
||||
UPDATE `vn`.`country`
|
||||
SET `a3Code` = 404
|
||||
WHERE `country` = 'Kenya'; -- KENIA
|
||||
|
||||
UPDATE `vn`.`country`
|
||||
SET `a3Code` = 498
|
||||
WHERE `country` = 'Moldavia'; -- REPÚBLICA DE MOLDAVIA
|
||||
|
||||
UPDATE `vn`.`country`
|
||||
SET `a3Code` = 826
|
||||
WHERE `country` = 'Gran Bretaña'; -- REINO UNIDO
|
||||
|
||||
UPDATE `vn`.`country`
|
||||
SET `a3Code` = 484
|
||||
WHERE `country` = 'Mexico'; -- MÉJICO
|
||||
|
||||
UPDATE `vn`.`country`
|
||||
SET `a3Code` = 716
|
||||
WHERE `country` = 'Zimbawe'; -- ZINBABWE
|
||||
|
||||
UPDATE `vn`.`country`
|
||||
SET `a3Code` = 203
|
||||
WHERE `country` = 'Chequia'; -- REPÚBLICA CHECA
|
||||
|
||||
UPDATE `vn`.`country`
|
||||
SET `a3Code` = 764
|
||||
WHERE `country` = 'Thailandia'; -- TAILANDIA
|
||||
|
||||
UPDATE `vn`.`country`
|
||||
SET `a3Code` = 276
|
||||
WHERE `country` = 'Alemania'; -- REPÚBLICA FEDERAL DE ALEMANIA
|
||||
|
||||
UPDATE `vn`.`country`
|
||||
SET `a3Code` = 112
|
||||
WHERE `country` = 'Bielorrusia'; -- BELARUS
|
||||
|
||||
UPDATE `vn`.`country`
|
||||
SET `a3Code` = 528
|
||||
WHERE `country` = 'Holanda'; -- PAÍSES BAJOS
|
||||
|
||||
UPDATE `vn`.`country`
|
||||
SET `a3Code` = 410
|
||||
WHERE `country` = 'Corea del Sur'; -- COREA (REPÚBLICA)
|
||||
|
||||
UPDATE `vn`.`country`
|
||||
SET `a3Code` = 724
|
||||
WHERE `country` = 'España exento'; -- ESPAÑA
|
||||
|
||||
-- Borrar registro USA de country:
|
||||
UPDATE `vn`.`supplier` `s`
|
||||
SET `s`.`countryFk` = 62
|
||||
WHERE `s`.`countryFk` = 12;
|
||||
|
||||
UPDATE `vn`.`bankEntity`
|
||||
SET `countryFk` = 62
|
||||
WHERE `countryFk` = 12;
|
||||
|
||||
DELETE FROM `vn`.`country`
|
||||
WHERE `id`= 12;
|
||||
|
||||
UPDATE `vn2008`.`payroll_pais`
|
||||
SET `pais`='COREA NORTE (REPÚBLICA DEM. POPULAR)'
|
||||
WHERE `codpais`=408;
|
||||
UPDATE `vn2008`.`payroll_pais`
|
||||
SET `pais`='COREA SUR (REPÚBLICA) '
|
||||
WHERE `codpais`=410;
|
||||
|
||||
RENAME TABLE `vn2008`.`payroll_pais` TO `vn2008`.`payroll_pais__`;
|
|
@ -1,2 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL` (`model`,`property`,`accessType`,`permission`,`principalType`,`principalId`)
|
||||
VALUES ('InvoiceInIntrastat','*','*','ALLOW','ROLE','employee');
|
|
@ -1,106 +0,0 @@
|
|||
DROP PROCEDURE IF EXISTS `bs`.`manaCustomerUpdate`;
|
||||
|
||||
DELIMITER $$
|
||||
$$
|
||||
CREATE DEFINER=`root`@`localhost` PROCEDURE `bs`.`manaCustomerUpdate`()
|
||||
BEGIN
|
||||
DECLARE vToDated DATE;
|
||||
DECLARE vFromDated DATE;
|
||||
DECLARE vForDeleteDated DATE;
|
||||
DECLARE vManaId INT;
|
||||
DECLARE vManaAutoId INT;
|
||||
DECLARE vClaimManaId INT;
|
||||
DECLARE vManaBankId INT;
|
||||
DECLARE vManaGreugeTypeId INT;
|
||||
|
||||
SELECT id INTO vManaId
|
||||
FROM `component` WHERE code = 'mana';
|
||||
|
||||
SELECT id INTO vManaAutoId
|
||||
FROM `component` WHERE code = 'autoMana';
|
||||
|
||||
SELECT id INTO vClaimManaId
|
||||
FROM `component` WHERE code = 'manaClaim';
|
||||
|
||||
SELECT id INTO vManaBankId
|
||||
FROM `bank` WHERE code = 'mana';
|
||||
|
||||
SELECT id INTO vManaGreugeTypeId
|
||||
FROM `greugeType` WHERE code = 'mana';
|
||||
|
||||
SELECT IFNULL(max(dated), '2016-01-01')
|
||||
INTO vFromDated
|
||||
FROM bs.manaCustomer;
|
||||
|
||||
DELETE
|
||||
FROM bs.manaCustomer
|
||||
WHERE dated = vFromDated;
|
||||
|
||||
SELECT IFNULL(max(dated), '2016-01-01')
|
||||
INTO vFromDated
|
||||
FROM bs.manaCustomer;
|
||||
|
||||
WHILE timestampadd(DAY,30,vFromDated) < CURDATE() DO
|
||||
|
||||
SELECT
|
||||
timestampadd(DAY,30,vFromDated),
|
||||
timestampadd(DAY,-90,vFromDated)
|
||||
INTO
|
||||
vToDated,
|
||||
vForDeleteDated;
|
||||
|
||||
DELETE FROM bs.manaCustomer
|
||||
WHERE dated <= vForDeleteDated;
|
||||
|
||||
|
||||
INSERT INTO bs.manaCustomer(Id_Cliente, 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, 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
|
||||
AND Fechacobro > vFromDated
|
||||
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
|
||||
) sub
|
||||
|
||||
GROUP BY Id_Cliente
|
||||
HAVING Id_Cliente;
|
||||
|
||||
SET vFromDated = vToDated;
|
||||
|
||||
END WHILE;
|
||||
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,75 +0,0 @@
|
|||
DROP PROCEDURE IF EXISTS `vn`.`manaSpellersRequery`;
|
||||
|
||||
DELIMITER $$
|
||||
$$
|
||||
CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`manaSpellersRequery`(vWorkerFk INTEGER)
|
||||
BEGIN
|
||||
/**
|
||||
* Recalcula el mana consumido por un trabajador
|
||||
*
|
||||
* @param vWorkerFk Id Trabajador
|
||||
*/
|
||||
DECLARE vWorkerIsExcluded BOOLEAN;
|
||||
DECLARE vFromDated DATE;
|
||||
DECLARE vToDated DATE DEFAULT TIMESTAMPADD(DAY,1,CURDATE());
|
||||
DECLARE vMana INT;
|
||||
DECLARE vAutoMana INT;
|
||||
DECLARE vClaimMana INT;
|
||||
DECLARE vManaBank INT;
|
||||
DECLARE vManaGreugeType INT;
|
||||
|
||||
SELECT COUNT(*) INTO vWorkerIsExcluded
|
||||
FROM workerManaExcluded
|
||||
WHERE workerFk = vWorkerFk;
|
||||
|
||||
IF NOT vWorkerIsExcluded THEN
|
||||
SELECT id INTO vMana
|
||||
FROM `component` WHERE code = 'mana';
|
||||
|
||||
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';
|
||||
|
||||
SELECT id INTO vManaGreugeType
|
||||
FROM `greugeType` WHERE code = 'mana';
|
||||
|
||||
SELECT max(dated) INTO vFromDated
|
||||
FROM clientManaCache;
|
||||
|
||||
REPLACE workerMana (workerFk, amount)
|
||||
SELECT vWorkerFk, sum(mana) FROM
|
||||
(
|
||||
SELECT s.quantity * sc.value as mana
|
||||
FROM ticket t
|
||||
JOIN address a ON a.id = t.addressFk
|
||||
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, vClaimMana)
|
||||
AND t.shipped > vFromDated AND t.shipped < vToDated
|
||||
UNION ALL
|
||||
SELECT - r.amountPaid
|
||||
FROM receipt r
|
||||
JOIN client c ON c.id = r.clientFk
|
||||
WHERE c.salesPersonFk = vWorkerFk AND bankFk = vManaBank
|
||||
AND payed > vFromDated
|
||||
UNION ALL
|
||||
SELECT g.amount
|
||||
FROM greuge g
|
||||
JOIN client c ON c.id = g.clientFk
|
||||
WHERE c.salesPersonFk = vWorkerFk AND g.greugeTypeFk = vManaGreugeType
|
||||
AND g.shipped > vFromDated and g.shipped < CURDATE()
|
||||
UNION ALL
|
||||
SELECT cc.mana
|
||||
FROM clientManaCache cc
|
||||
JOIN client c ON c.id = cc.clientFk
|
||||
WHERE c.salesPersonFk = vWorkerFk AND cc.dated = vFromDated
|
||||
) sub;
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,48 +0,0 @@
|
|||
ALTER TABLE `vn`.`agencyTerm` ADD `supplierFk` INT NULL;
|
||||
ALTER TABLE `vn`.`agencyTerm` CHANGE `supplierFk` `supplierFk` INT NULL AFTER `agencyFk`;
|
||||
|
||||
UPDATE `vn`.`agencyTerm` `at`
|
||||
JOIN `vn`.`agency` `a` ON `a`.`id` = `at`.`agencyFk`
|
||||
SET `at`.`supplierFk` = `a`.`supplierFk`;
|
||||
|
||||
ALTER TABLE `vn`.`agencyTerm` ADD CONSTRAINT `agencyTerm_FK` FOREIGN KEY (`agencyFk`) REFERENCES `vn`.`agency`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `vn`.`agencyTerm` ADD CONSTRAINT `agencyTerm_FK_1` FOREIGN KEY (`supplierFk`) REFERENCES `vn`.`supplier`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
RENAME TABLE `vn`.`agencyTerm` TO `vn`.`supplierAgencyTerm`;
|
||||
|
||||
CREATE OR REPLACE
|
||||
ALGORITHM = UNDEFINED
|
||||
DEFINER=`root`@`localhost`
|
||||
VIEW `vn`.`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
|
||||
`vn`.`supplierAgencyTerm` `sat`;
|
||||
|
||||
ALTER TABLE `vn`.`agency` DROP FOREIGN KEY `agency_ibfk_4`;
|
||||
ALTER TABLE `vn`.`agency` CHANGE `supplierFk` `supplierFk__` int(11) DEFAULT NULL NULL;
|
||||
|
||||
CREATE OR REPLACE
|
||||
ALGORITHM = UNDEFINED
|
||||
DEFINER=`root`@`localhost`
|
||||
VIEW `vn2008`.`agency` AS
|
||||
SELECT
|
||||
`a`.`id` AS `agency_id`,
|
||||
`a`.`name` AS `name`,
|
||||
`a`.`warehouseFk` AS `warehouse_id`,
|
||||
`a`.`isVolumetric` AS `por_volumen`,
|
||||
`a`.`bankFk` AS `Id_Banco`,
|
||||
`a`.`warehouseAliasFk` AS `warehouse_alias_id`,
|
||||
`a`.`isOwn` AS `propios`,
|
||||
`a`.`labelZone` AS `zone_label`,
|
||||
`a`.`workCenterFk` AS `workCenterFk`,
|
||||
`a`.`supplierFk__` AS `supplierFk__`
|
||||
FROM
|
||||
`vn`.`agency` `a`;
|
|
@ -1,149 +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 vRsMainTicket CURSOR FOR
|
||||
SELECT *
|
||||
FROM tmp.sale;
|
||||
|
||||
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,
|
||||
CURDATE(),
|
||||
vAddress,
|
||||
vRefundAgencyMode,
|
||||
a.nickname,
|
||||
vWarehouse,
|
||||
vCompany,
|
||||
CURDATE(),
|
||||
vZoneFk
|
||||
FROM address a
|
||||
WHERE a.id = vAddress;
|
||||
|
||||
SET vNewTicket = LAST_INSERT_ID();
|
||||
|
||||
SET vDone := 0;
|
||||
OPEN vRsMainTicket ;
|
||||
FETCH vRsMainTicket 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 vRsMainTicket INTO vSaleMain, vItemFk, vQuantity, vConcept, vPrice, vDiscount;
|
||||
|
||||
END WHILE;
|
||||
CLOSE vRsMainTicket;
|
||||
|
||||
INSERT INTO vn.ticketRefund(refundTicketFk, originalTicketFk)
|
||||
VALUES(vNewTicket, vOriginTicket);
|
||||
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
||||
CREATE TABLE `vn`.`ticketRefund` (
|
||||
`id` INT auto_increment NULL,
|
||||
`refundTicketFk` INT NOT NULL,
|
||||
`originalTicketFk` INT NOT NULL,
|
||||
CONSTRAINT `ticketRefund_PK` PRIMARY KEY (id)
|
||||
)
|
||||
ENGINE=InnoDB
|
||||
DEFAULT CHARSET=utf8
|
||||
COLLATE=utf8_unicode_ci;
|
||||
|
||||
ALTER TABLE `vn`.`ticketRefund` ADD CONSTRAINT `ticketRefund_FK` FOREIGN KEY (`refundTicketFk`) REFERENCES `vn`.`ticket`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `vn`.`ticketRefund` ADD CONSTRAINT `ticketRefund_FK_1` FOREIGN KEY (`originalTicketFk`) REFERENCES `vn`.`ticket`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
DELIMITER $$
|
||||
$$
|
||||
CREATE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticketRefund_beforeInsert`
|
||||
BEFORE INSERT ON `ticketRefund`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
DECLARE vAlreadyExists BOOLEAN DEFAULT FALSE;
|
||||
|
||||
IF NEW.refundTicketFk = NEW.originalTicketFk THEN
|
||||
CALL util.throw('Original ticket and refund ticket has same id');
|
||||
END IF;
|
||||
|
||||
SELECT COUNT(*) INTO vAlreadyExists
|
||||
FROM ticketRefund
|
||||
WHERE refundTicketFk = NEW.originalTicketFk;
|
||||
|
||||
IF vAlreadyExists > 0 THEN
|
||||
CALL util.throw('This ticket is already a refund');
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
||||
DELIMITER $$
|
||||
$$
|
||||
CREATE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticketRefund_beforeUpdate`
|
||||
BEFORE UPDATE ON `ticketRefund`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
DECLARE vAlreadyExists BOOLEAN DEFAULT FALSE;
|
||||
|
||||
IF NEW.refundTicketFk = NEW.originalTicketFk THEN
|
||||
CALL util.throw('Original ticket and refund ticket has same id');
|
||||
END IF;
|
||||
|
||||
SELECT COUNT(*) INTO vAlreadyExists
|
||||
FROM ticketRefund
|
||||
WHERE refundTicketFk = NEW.originalTicketFk;
|
||||
|
||||
IF vAlreadyExists > 0 THEN
|
||||
CALL util.throw('This ticket is already a refund');
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,16 +0,0 @@
|
|||
DROP TRIGGER `vn`.`travelThermograph_beforeInsert`;
|
||||
|
||||
ALTER TABLE `vn`.`travelThermograph` CHANGE `temperature` `temperature__` enum('COOL','WARM','DRY') CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL NULL;
|
||||
|
||||
CREATE OR REPLACE
|
||||
ALGORITHM = UNDEFINED VIEW `vn2008`.`travel_thermograph` AS
|
||||
select
|
||||
`tt`.`thermographFk` AS `thermograph_id`,
|
||||
`tt`.`created` AS `odbc_date`,
|
||||
`tt`.`warehouseFk` AS `warehouse_id`,
|
||||
`tt`.`travelFk` AS `travel_id`,
|
||||
`tt`.`temperatureFk` AS `temperature`,
|
||||
`tt`.`result` AS `result`,
|
||||
`tt`.`dmsFk` AS `gestdoc_id`
|
||||
from
|
||||
`vn`.`travelThermograph` `tt`;
|
|
@ -1,51 +0,0 @@
|
|||
|
||||
ALTER TABLE `vn`.`worker` MODIFY COLUMN `maritalStatus__` varchar(10) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL;
|
||||
UPDATE `vn`.`worker` `w`
|
||||
SET `w`.`maritalStatus__` = NULL;
|
||||
|
||||
UPDATE `vn`.`worker` `w`
|
||||
JOIN `vn`.`person` `p` ON `p`.`workerFk` = `w`.`id`
|
||||
JOIN `postgresql`.`profile` `pr` ON `pr`.`person_id` = `p`.`id`
|
||||
JOIN `vn2008`.`profile_labour_payroll` `pl` ON `pl`.`profile_id` = `pr`.`profile_id`
|
||||
SET `w`.`maritalStatus__` = `pl`.`estadocivil`;
|
||||
|
||||
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;
|
||||
|
||||
INSERT INTO `vn`.`country` (`country`, `CEE`, `code`, `politicalCountryFk`, `isUeeMember`, `a3Code`)
|
||||
VALUES
|
||||
('Argentina',2,'AR',80,0,32),
|
||||
('Cuba',2,'CU',81,0,192),
|
||||
('Guinea Ecuatorial',2,'GQ',82,0,226),
|
||||
('Guinea',2,'GN',83,0,324),
|
||||
('Honduras',2,'HN',84,0,340),
|
||||
('Mali',2,'ML',85,0,466),
|
||||
('Nicaragua',2,'NI',86,0,558),
|
||||
('Pakistán',2,'PK',87,0,586),
|
||||
('Paraguay',2,'PY',88,0,600),
|
||||
('Senegal',2,'SN',89,0,686),
|
||||
('Uruguay',2,'UY',90,0,858),
|
||||
('Venezuela',2,'VE',91,0,862),
|
||||
('Bulgaria',2,'BG',92,1,100),
|
||||
('Georgia',2,'GE',93,0,268);
|
||||
|
||||
UPDATE `vn`.`worker` `w`
|
||||
JOIN `vn`.`person` `p` ON `p`.`workerFk` = `w`.`id`
|
||||
JOIN `postgresql`.`profile` `pr` ON `pr`.`person_id` = `p`.`id`
|
||||
JOIN `vn2008`.`profile_labour_payroll` `pl` ON `pl`.`profile_id` = `pr`.`profile_id`
|
||||
JOIN `vn`.`country` `co` ON `co`.`a3Code` = `pl`.`codpais`
|
||||
SET `w`.`originCountryFk` = `co`.`id`;
|
||||
|
||||
UPDATE `vn`.`worker` `w`
|
||||
JOIN `vn`.`person` `p` ON `p`.`workerFk` = `w`.`id`
|
||||
JOIN `postgresql`.`profile` `pr` ON `pr`.`person_id` = `p`.`id`
|
||||
JOIN `vn2008`.`profile_labour_payroll` pl ON `pl`.`profile_id` = `pr`.`profile_id`
|
||||
SET `w`.`SSN` = CONCAT(`pl`.`NSSProvincia`, `pl`.`NssNumero`, `pl`.`NssDC`);
|
||||
|
||||
RENAME TABLE `vn2008`.`profile_labour_payroll` TO `vn2008`.`profile_labour_payroll__`;
|
|
@ -1,3 +0,0 @@
|
|||
ALTER TABLE `postgresql`.`business_labour_payroll` DROP FOREIGN KEY `business_labour_payroll_cod_contrato`;
|
||||
ALTER TABLE `vn`.`workerBusinessType` MODIFY COLUMN `id` int(11) NOT NULL;
|
||||
ALTER TABLE `postgresql`.`business_labour_payroll` ADD CONSTRAINT `business_labour_payroll_FK` FOREIGN KEY (cod_contrato) REFERENCES `vn`.`workerBusinessType`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
@ -1,73 +0,0 @@
|
|||
DROP PROCEDURE IF EXISTS vn.timeControl_getError;
|
||||
|
||||
DELIMITER $$
|
||||
$$
|
||||
CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`timeControl_getError`(vDatedFrom DATETIME, vDatedTo DATETIME)
|
||||
BEGIN
|
||||
/*
|
||||
* @param vDatedFrom
|
||||
* @param vDatedTo
|
||||
* @table tmp.`user`(userFk)
|
||||
* Fichadas incorrectas de las cuales no se puede calcular horas trabajadas
|
||||
* @return tmp.timeControlError (id)
|
||||
*/
|
||||
DECLARE vDayMaxTime INTEGER;
|
||||
|
||||
SET @journeyCounter := 0;
|
||||
SET @lastUserFk := NULL;
|
||||
|
||||
SELECT dayMaxTime INTO vDayMaxTime
|
||||
FROM workerTimeControlConfig LIMIT 1;
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.timeControl;
|
||||
CREATE TEMPORARY TABLE tmp.timeControl
|
||||
(INDEX(id), INDEX(journeyCounter))
|
||||
ENGINE = MEMORY
|
||||
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))
|
||||
ENGINE = MEMORY
|
||||
SELECT * FROM tmp.timeControl;
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.timeControlError;
|
||||
CREATE TEMPORARY TABLE tmp.timeControlError
|
||||
(INDEX(id))
|
||||
ENGINE = MEMORY
|
||||
SELECT id
|
||||
FROM tmp.timeControlAux tca
|
||||
JOIN (SELECT journeyCounter,
|
||||
UNIX_TIMESTAMP(MAX(timed)) - UNIX_TIMESTAMP(MIN(timed)) timeWork,
|
||||
SUM(direction = 'in') totalIn,
|
||||
SUM(direction = 'out') totalOut,
|
||||
timed
|
||||
FROM tmp.timeControl
|
||||
GROUP BY journeyCounter
|
||||
HAVING COUNT(*) MOD 2 = 1
|
||||
OR totalIn <> 1
|
||||
OR totalOut <> 1
|
||||
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;
|
||||
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1 +0,0 @@
|
|||
ALTER TABLE `vn`.`userConfig` ADD darkMode tinyint(1) DEFAULT 1 NOT NULL COMMENT 'Salix interface dark mode';
|
|
@ -1,2 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL`(`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES('ExpeditionState', '*', 'READ', 'ALLOW', 'ROLE', 'employee');
|
|
@ -1,5 +0,0 @@
|
|||
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');
|
|
@ -1,6 +0,0 @@
|
|||
UPDATE `salix`.`ACL`
|
||||
SET `property`='refund'
|
||||
WHERE `model`='Sale' AND `property`='payBack';
|
||||
|
||||
INSERT INTO `salix`.`ACL`(`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES('Sale', 'refundAll', 'WRITE', 'ALLOW', 'ROLE', 'employee');
|
|
@ -1,5 +0,0 @@
|
|||
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');
|
|
@ -1,5 +0,0 @@
|
|||
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;
|
|
@ -1,8 +0,0 @@
|
|||
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;
|
|
@ -1,5 +0,0 @@
|
|||
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;
|
|
@ -1,18 +0,0 @@
|
|||
|
||||
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 ;
|
|
@ -1,175 +0,0 @@
|
|||
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 ;
|
|
@ -1,10 +0,0 @@
|
|||
CREATE TABLE `vn`.`clientUnpaid` (
|
||||
`clientFk` int(11) NOT NULL,
|
||||
`dated` date NOT NULL,
|
||||
`amount` double DEFAULT 0,
|
||||
PRIMARY KEY (`clientFk`),
|
||||
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');
|
|
@ -1,8 +0,0 @@
|
|||
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';
|
|
@ -1,2 +1,3 @@
|
|||
ALTER TABLE `vn`.`accountingType` ADD daysInFuture INT NULL;
|
||||
ALTER TABLE `vn`.`accountingType` MODIFY COLUMN daysInFuture int(11) DEFAULT 0 NULL;
|
||||
ALTER TABLE `vn`.`accountingType` MODIFY COLUMN daysInFuture int(11) DEFAULT 0 NULL;
|
||||
UPDATE `vn`.`accountingType` SET daysInFuture=1 WHERE id=8;
|
|
@ -0,0 +1,3 @@
|
|||
ALTER TABLE `vn`.`chat` MODIFY COLUMN message TEXT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL NULL;
|
||||
ALTER TABLE `vn`.`chat` MODIFY COLUMN dated DATETIME DEFAULT NULL NULL;
|
||||
ALTER TABLE `vn`.`chat` ADD error TEXT NULL;
|
|
@ -0,0 +1,3 @@
|
|||
ALTER TABLE `vn`.`creditInsurance`
|
||||
ADD CONSTRAINT `creditInsurance_creditClassificationFk` FOREIGN KEY (`creditClassificationFk`)
|
||||
REFERENCES `vn`.`creditClassification` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
|
@ -1,2 +1,3 @@
|
|||
INSERT INTO `salix`.`ACL` (model,property,accessType,permission,principalType,principalId)
|
||||
VALUES ('Dms','deleteTrashFiles','WRITE','ALLOW','ROLE','employee')
|
||||
VALUES
|
||||
('ShelvingLog','*','READ','ALLOW','ROLE','employee');
|
|
@ -0,0 +1,4 @@
|
|||
INSERT INTO `salix`.`ACL`(`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
('ZoneExclusionGeo', '*', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
('ZoneExclusionGeo', '*', 'WRITE', 'ALLOW', 'ROLE', 'deliveryBoss');
|
|
@ -0,0 +1,5 @@
|
|||
ALTER TABLE `vn`.`itemType` CHANGE `transaction` transaction__ tinyint(4) DEFAULT 0 NOT NULL;
|
||||
ALTER TABLE `vn`.`itemType` CHANGE location location__ varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL NULL;
|
||||
ALTER TABLE `vn`.`itemType` CHANGE hasComponents hasComponents__ tinyint(1) DEFAULT 1 NOT NULL;
|
||||
ALTER TABLE `vn`.`itemType` CHANGE warehouseFk warehouseFk__ smallint(6) unsigned DEFAULT 60 NOT NULL;
|
||||
ALTER TABLE `vn`.`itemType` CHANGE compression compression__ decimal(5,2) DEFAULT 1.00 NULL;
|
|
@ -0,0 +1,10 @@
|
|||
UPDATE `vn`.`route` r
|
||||
JOIN(SELECT r.id, wl.workcenterFk
|
||||
FROM `vn`.`route` r
|
||||
JOIN `vn`.`routeLog` rl ON rl.originFk = r.id
|
||||
JOIN `vn`.`workerLabour` wl ON wl.workerFk = rl.userFk
|
||||
AND r.created BETWEEN wl.started AND IFNULL(wl.ended, r.created)
|
||||
WHERE r.created BETWEEN '2021-12-01' AND CURDATE()
|
||||
AND rl.action = 'insert'
|
||||
)sub ON sub.id = r.id
|
||||
SET r.commissionWorkCenterFk = sub.workcenterFk;
|
|
@ -0,0 +1,18 @@
|
|||
ALTER TABLE `vn`.`itemShelving` DROP FOREIGN KEY itemShelving_fk2;
|
||||
ALTER TABLE `vn`.`shelvingLog` DROP FOREIGN KEY shelvingLog_FK_ibfk_1;
|
||||
ALTER TABLE `vn`.`smartTag` DROP FOREIGN KEY smartTag_shelving_fk;
|
||||
ALTER TABLE `vn`.`workerShelving` DROP FOREIGN KEY workerShelving_shelving_fk;
|
||||
|
||||
ALTER TABLE `vn`.`shelving` DROP PRIMARY KEY;
|
||||
ALTER TABLE `vn`.`shelving` ADD id INT auto_increment PRIMARY KEY NULL;
|
||||
ALTER TABLE `vn`.`shelving` CHANGE id id int(11) auto_increment NOT NULL FIRST;
|
||||
ALTER TABLE `vn`.`shelving` ADD CONSTRAINT shelving_UN UNIQUE KEY (code);
|
||||
|
||||
ALTER TABLE `vn`.`itemShelving` ADD CONSTRAINT itemShelving_fk2 FOREIGN KEY (shelvingFk) REFERENCES `vn`.`shelving`(code) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
ALTER TABLE `vn`.`shelvingLog` ADD CONSTRAINT shelvingLog_FK_ibfk_1 FOREIGN KEY (originFk) REFERENCES `vn`.`shelving`(code) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
ALTER TABLE `vn`.`smartTag` ADD CONSTRAINT smartTag_FK FOREIGN KEY (shelvingFk) REFERENCES `vn`.`shelving`(code) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `vn`.`workerShelving` ADD CONSTRAINT workerShelving_FK_1 FOREIGN KEY (shelvingFk) REFERENCES `vn`.`shelving`(code) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
ALTER TABLE vn.shelvingLog DROP FOREIGN KEY shelvingLog_FK_ibfk_1;
|
||||
ALTER TABLE vn.shelvingLog MODIFY COLUMN originFk INT NOT NULL;
|
||||
ALTER TABLE vn.shelvingLog ADD CONSTRAINT shelvingLog_FK FOREIGN KEY (originFk) REFERENCES vn.shelving(id) ON DELETE CASCADE ON UPDATE CASCADE;
|
|
@ -0,0 +1,2 @@
|
|||
INSERT INTO `salix`.`ACL` (model,property,accessType,permission,principalType,principalId)
|
||||
VALUES ('Parking','*','*','ALLOW','ROLE','employee')
|
|
@ -0,0 +1,2 @@
|
|||
INSERT INTO `salix`.`ACL` (model,property,accessType,permission,principalType,principalId)
|
||||
VALUES ('Shelving','*','*','ALLOW','ROLE','employee')
|
|
@ -1,3 +1,3 @@
|
|||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
('SupplierAgencyTerm', '*', '*', 'ALLOW', 'ROLE', 'administrative');
|
||||
('OsTicket', '*', '*', 'ALLOW', 'ROLE', 'employee');
|
|
@ -1,2 +1,3 @@
|
|||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES('EducationLevel', '*', '*', 'ALLOW', 'ROLE', 'employee');
|
||||
VALUES
|
||||
('OsTicketConfig', '*', '*', 'ALLOW', 'ROLE', 'it');
|
|
@ -0,0 +1,20 @@
|
|||
CREATE TABLE `vn`.`osTicketConfig` (
|
||||
`id` int(11) NOT NULL,
|
||||
`host` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
|
||||
`user` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
|
||||
`password` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
|
||||
`oldStatus` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
|
||||
`newStatusId` int(11) DEFAULT NULL,
|
||||
`action` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
|
||||
`day` int(11) DEFAULT NULL,
|
||||
`comment` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
|
||||
`hostDb` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
|
||||
`userDb` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
|
||||
`passwordDb` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
|
||||
`portDb` int(11) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
|
||||
|
||||
INSERT INTO `vn`.`osTicketConfig`(`id`, `host`, `user`, `password`, `oldStatus`, `newStatusId`, `action`, `day`, `comment`, `hostDb`, `userDb`, `passwordDb`, `portDb`)
|
||||
VALUES
|
||||
(0, 'https://cau.verdnatura.es/scp', NULL, NULL, 'open', 3, 'Cerrar', 60, 'Este CAU se ha cerrado automáticamente', NULL, NULL, NULL, NULL);
|
|
@ -0,0 +1,49 @@
|
|||
INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId)
|
||||
VALUES
|
||||
('ClientConsumptionQueue', '*', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Ticket', 'deliveryNotePdf', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Ticket', 'deliveryNoteEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Ticket', 'deliveryNoteCsvPdf', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Ticket', 'deliveryNoteCsvEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Client', 'campaignMetricsPdf', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Client', 'campaignMetricsEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Client', 'clientWelcomeHtml', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Client', 'clientWelcomeEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Client', 'creditRequestPdf', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Client', 'creditRequestHtml', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Client', 'creditRequestEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Client', 'printerSetupHtml', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Client', 'printerSetupEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Client', 'sepaCoreEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Client', 'letterDebtorPdf', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Client', 'letterDebtorStHtml', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Client', 'letterDebtorStEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Client', 'letterDebtorNdHtml', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Client', 'letterDebtorNdEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Client', 'clientDebtStatementPdf', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Client', 'clientDebtStatementHtml', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Client', 'clientDebtStatementEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Client', 'incotermsAuthorizationPdf', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Client', 'incotermsAuthorizationHtml', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Client', 'incotermsAuthorizationEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Client', 'consumptionSendQueued', 'WRITE', 'ALLOW', 'ROLE', 'system'),
|
||||
('InvoiceOut', 'invoiceEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
|
||||
('InvoiceOut', 'exportationPdf', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
('InvoiceOut', 'sendQueued', 'WRITE', 'ALLOW', 'ROLE', 'system'),
|
||||
('Ticket', 'invoiceCsvPdf', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Ticket', 'invoiceCsvEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Supplier', 'campaignMetricsPdf', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Supplier', 'campaignMetricsEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Travel', 'extraCommunityPdf', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Travel', 'extraCommunityEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Entry', 'entryOrderPdf', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
('OsTicket', 'osTicketReportEmail', 'WRITE', 'ALLOW', 'ROLE', 'system'),
|
||||
('Item', 'buyerWasteEmail', 'WRITE', 'ALLOW', 'ROLE', 'system'),
|
||||
('Claim', 'claimPickupPdf', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Claim', 'claimPickupEmail', 'WRITE', 'ALLOW', 'ROLE', 'claimManager'),
|
||||
('Item', 'labelPdf', 'READ', 'ALLOW', 'ROLE', 'employee');
|
||||
|
||||
INSERT INTO `salix`.`ACL` (model,property,accessType,permission,principalType,principalId)
|
||||
VALUES ('Sector','*','READ','ALLOW','ROLE','employee');
|
||||
INSERT INTO `salix`.`ACL` (model,property,accessType,permission,principalType,principalId)
|
||||
VALUES ('Sector','*','WRITE','ALLOW','ROLE','employee');
|
|
@ -0,0 +1,9 @@
|
|||
create table `vn`.`clientConsumptionQueue`
|
||||
(
|
||||
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
params json not null,
|
||||
queued datetime default current_timestamp() not null,
|
||||
printed datetime null,
|
||||
status varchar(50) default '' null
|
||||
)
|
||||
comment 'Queue for client consumption PDF mailing';
|
|
@ -0,0 +1 @@
|
|||
rename table `vn`.`invoiceOut_queue` to `vn`.`invoiceOutQueue`;
|
|
@ -0,0 +1,5 @@
|
|||
ALTER TABLE `vn`.`itemConfig`
|
||||
ADD id int null PRIMARY KEY first;
|
||||
|
||||
ALTER TABLE `vn`.`itemConfig`
|
||||
ADD wasteRecipients VARCHAR(50) NOT NULL comment 'Weekly waste report schedule recipients';
|
|
@ -0,0 +1,10 @@
|
|||
create table `salix`.`printConfig`
|
||||
(
|
||||
id int auto_increment,
|
||||
itRecipient varchar(50) null comment 'IT recipients for report mailing',
|
||||
incidencesEmail varchar(50) null comment 'CAU destinatary email',
|
||||
constraint printConfig_pk
|
||||
primary key (id)
|
||||
)
|
||||
comment 'Print service config';
|
||||
|
|
@ -0,0 +1,100 @@
|
|||
DROP TRIGGER IF EXISTS vn.sale_afterUpdate;
|
||||
USE vn;
|
||||
|
||||
DELIMITER $$
|
||||
$$
|
||||
CREATE DEFINER=`root`@`localhost` TRIGGER `vn`.`sale_afterUpdate`
|
||||
AFTER UPDATE ON `sale`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
DECLARE vIsToSendMail BOOL;
|
||||
DECLARE vPickedLines INT;
|
||||
DECLARE vCollectionFk INT;
|
||||
DECLARE vUserRole VARCHAR(255);
|
||||
|
||||
IF !(NEW.id <=> OLD.id)
|
||||
OR !(NEW.ticketFk <=> OLD.ticketFk)
|
||||
OR !(NEW.itemFk <=> OLD.itemFk)
|
||||
OR !(NEW.quantity <=> OLD.quantity)
|
||||
OR !(NEW.created <=> OLD.created)
|
||||
OR !(NEW.isPicked <=> OLD.isPicked) THEN
|
||||
CALL stock.log_add('sale', NEW.id, OLD.id);
|
||||
END IF;
|
||||
|
||||
IF !(NEW.price <=> OLD.price)
|
||||
OR !(NEW.ticketFk <=> OLD.ticketFk)
|
||||
OR !(NEW.itemFk <=> OLD.itemFk)
|
||||
OR !(NEW.quantity <=> OLD.quantity)
|
||||
OR !(NEW.discount <=> OLD.discount) THEN
|
||||
CALL ticket_requestRecalc(NEW.ticketFk);
|
||||
CALL ticket_requestRecalc(OLD.ticketFk);
|
||||
END IF;
|
||||
|
||||
IF !(OLD.ticketFk <=> NEW.ticketFk) THEN
|
||||
UPDATE ticketRequest SET ticketFk = NEW.ticketFk
|
||||
WHERE saleFk = NEW.id;
|
||||
END IF;
|
||||
|
||||
SELECT account.myUser_getName() INTO vUserRole;
|
||||
SELECT account.user_getMysqlRole(vUserRole) INTO vUserRole;
|
||||
|
||||
IF !(OLD.quantity <=> NEW.quantity) THEN
|
||||
SELECT COUNT(*) INTO vIsToSendMail
|
||||
FROM vncontrol.inter i
|
||||
JOIN vn.state s ON s.id = i.state_id
|
||||
WHERE s.code='PACKED'
|
||||
AND i.Id_Ticket = OLD.ticketFk
|
||||
AND vUserRole IN ('salesPerson', 'salesTeamBoss')
|
||||
LIMIT 1;
|
||||
|
||||
IF vIsToSendMail THEN
|
||||
CALL vn.mail_insert('jefesventas@verdnatura.es',
|
||||
'noreply@verdnatura.es',
|
||||
CONCAT('Ticket ', OLD.ticketFk ,' modificada cantidad tras encajado'),
|
||||
CONCAT('Ticket <a href="https://salix.verdnatura.es/#!/ticket/', OLD.ticketFk ,'/log">', OLD.ticketFk ,'</a>. <br>',
|
||||
'Modificada la catidad de ', OLD.quantity, ' a ' , NEW.quantity,
|
||||
' del artículo ', OLD.itemFk, ' tras estado encajado del ticket. <br>',
|
||||
'Este email se ha generado automáticamente' )
|
||||
);
|
||||
END IF;
|
||||
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
|
||||
JOIN vn.ticket t ON t.id = s.ticketFk
|
||||
JOIN vn.route r ON r.id = t.routeFk
|
||||
WHERE r.isOk = FALSE
|
||||
AND s.id = NEW.id
|
||||
AND r.created >= 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 ;
|
|
@ -0,0 +1,6 @@
|
|||
alter table `vn`.`sample`
|
||||
add model VARCHAR(25) null comment 'Model name in plural';
|
||||
|
||||
UPDATE vn.sample t
|
||||
SET t.model = 'Clients'
|
||||
WHERE t.id IN(12, 13, 14, 15, 16, 18, 19, 20);
|
|
@ -0,0 +1 @@
|
|||
ALTER TABLE `account`.`user` ADD hasGrant TINYINT(1) NOT NULL;
|
22
db/docker.js
22
db/docker.js
|
@ -19,8 +19,9 @@ module.exports = class Docker {
|
|||
* to avoid a bug with OverlayFS driver on MacOS.
|
||||
*
|
||||
* @param {Boolean} ci continuous integration environment argument
|
||||
* @param {String} networkName Name of the container network
|
||||
*/
|
||||
async run(ci) {
|
||||
async run(ci, networkName = 'jenkins') {
|
||||
let d = new Date();
|
||||
let pad = v => v < 10 ? '0' + v : v;
|
||||
let stamp = `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`;
|
||||
|
@ -42,8 +43,16 @@ module.exports = class Docker {
|
|||
|
||||
let runChown = process.platform != 'linux';
|
||||
|
||||
let network = '';
|
||||
if (ci) network = `--network="${networkName}"`;
|
||||
|
||||
log('Starting container...');
|
||||
const container = await this.execP(`docker run --env RUN_CHOWN=${runChown} -d ${dockerArgs} salix-db`);
|
||||
const container = await this.execP(`
|
||||
docker run \
|
||||
${network} \
|
||||
--env RUN_CHOWN=${runChown} \
|
||||
-d ${dockerArgs} salix-db
|
||||
`);
|
||||
this.id = container.stdout.trim();
|
||||
|
||||
try {
|
||||
|
@ -51,10 +60,11 @@ module.exports = class Docker {
|
|||
let inspect = await this.execP(`docker inspect -f "{{json .NetworkSettings}}" ${this.id}`);
|
||||
let netSettings = JSON.parse(inspect.stdout);
|
||||
|
||||
if (ci)
|
||||
this.dbConf.host = netSettings.Gateway;
|
||||
|
||||
this.dbConf.port = netSettings.Ports['3306/tcp'][0]['HostPort'];
|
||||
if (ci) {
|
||||
this.dbConf.host = netSettings.Networks[networkName].IPAddress;
|
||||
this.dbConf.port = 3306;
|
||||
} else
|
||||
this.dbConf.port = netSettings.Ports['3306/tcp'][0]['HostPort'];
|
||||
}
|
||||
|
||||
await this.wait();
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -13,6 +13,10 @@ INSERT INTO `salix`.`AccessToken` (`id`, `ttl`, `created`, `userId`)
|
|||
VALUES
|
||||
('DEFAULT_TOKEN', '1209600', util.VN_CURDATE(), 66);
|
||||
|
||||
INSERT INTO `salix`.`printConfig` (`id`, `itRecipient`, `incidencesEmail`)
|
||||
VALUES
|
||||
(1, 'it@gotamcity.com', 'incidences@gotamcity.com');
|
||||
|
||||
INSERT INTO `vn`.`ticketConfig` (`id`, `scopeDays`)
|
||||
VALUES
|
||||
('1', '6');
|
||||
|
@ -122,17 +126,17 @@ INSERT INTO `vn`.`currency`(`id`, `code`, `name`, `ratio`)
|
|||
(3, 'GBP', 'Libra', 1),
|
||||
(4, 'JPY', 'Yen Japones', 1);
|
||||
|
||||
INSERT INTO `vn`.`country`(`id`, `country`, `isUeeMember`, `code`, `currencyFk`, `politicalCountryFk`, `ibanLength`, `continentFk`, `hasDailyInvoice`, `CEE`)
|
||||
INSERT INTO `vn`.`country`(`id`, `country`, `isUeeMember`, `code`, `currencyFk`, `ibanLength`, `continentFk`, `hasDailyInvoice`, `CEE`, `politicalCountryFk`)
|
||||
VALUES
|
||||
(1, 'España', 1, 'ES', 1, 1, 24, 4, 0, 1),
|
||||
(2, 'Italia', 1, 'IT', 1, 2, 27, 4, 0, 1),
|
||||
(3, 'Alemania', 1, 'DE', 1, 3, 22, 4, 0, 1),
|
||||
(4, 'Rumania', 1, 'RO', 1, 4, 24, 4, 0, 1),
|
||||
(5, 'Holanda', 1, 'NL', 1, 5, 18, 4, 0, 1),
|
||||
(8, 'Portugal', 1, 'PT', 1, 8, 27, 4, 0, 1),
|
||||
(13,'Ecuador', 0, 'EC', 1, 13, 24, 2, 1, 2),
|
||||
(19,'Francia', 1, 'FR', 1, 19, 27, 4, 0, 1),
|
||||
(30,'Canarias', 1, 'IC', 1, 1, 24, 4, 1, 2);
|
||||
(1, 'España', 1, 'ES', 1, 24, 4, 0, 1, 1),
|
||||
(2, 'Italia', 1, 'IT', 1, 27, 4, 0, 1, 2),
|
||||
(3, 'Alemania', 1, 'DE', 1, 22, 4, 0, 1, 3),
|
||||
(4, 'Rumania', 1, 'RO', 1, 24, 4, 0, 1, 4),
|
||||
(5, 'Holanda', 1, 'NL', 1, 18, 4, 0, 1, 5),
|
||||
(8, 'Portugal', 1, 'PT', 1, 27, 4, 0, 1, 8),
|
||||
(13,'Ecuador', 0, 'EC', 1, 24, 2, 1, 2, 13),
|
||||
(19,'Francia', 1, 'FR', 1, 27, 4, 0, 1, 19),
|
||||
(30,'Canarias', 1, 'IC', 1, 24, 4, 1, 2, 30);
|
||||
|
||||
INSERT INTO `vn`.`warehouseAlias`(`id`, `name`)
|
||||
VALUES
|
||||
|
@ -146,7 +150,9 @@ INSERT INTO `vn`.`warehouse`(`id`, `name`, `code`, `isComparative`, `isInventory
|
|||
(3, 'Warehouse Three', NULL, 1, 1, 1, 1, 0, 0, 2, 1, 1),
|
||||
(4, 'Warehouse Four', NULL, 1, 1, 1, 1, 0, 0, 2, 1, 1),
|
||||
(5, 'Warehouse Five', NULL, 1, 1, 1, 1, 0, 0, 2, 1, 1),
|
||||
(13, 'Inventory', NULL, 1, 1, 1, 0, 0, 0, 2, 1, 0);
|
||||
(13, 'Inventory', NULL, 1, 1, 1, 0, 0, 0, 2, 1, 0),
|
||||
(60, 'Algemesi', NULL, 1, 1, 1, 0, 0, 0, 2, 1, 0);
|
||||
|
||||
|
||||
INSERT INTO `vn`.`sector`(`id`, `description`, `warehouseFk`, `isPreviousPreparedByPacking`, `code`)
|
||||
VALUES
|
||||
|
@ -155,14 +161,29 @@ INSERT INTO `vn`.`sector`(`id`, `description`, `warehouseFk`, `isPreviousPrepare
|
|||
|
||||
INSERT INTO `vn`.`parking` (`id`, `column`, `row`, `sectorFk`, `code`, `pickingOrder`)
|
||||
VALUES
|
||||
('1', '700', '01', '1', '700-01', '70001'),
|
||||
('2', '700', '02', '2', '700-02', '70002');
|
||||
('1', 700, '01', 1, '700-01', 70001),
|
||||
('2', 700, '02', 2, '700-02', 70002),
|
||||
('3', 100, '01', 1, '100-01', 1),
|
||||
(32397, 100, '02', 1, 'A-47-1', 1165),
|
||||
(34831, 200, '01', 1, 'K-26-2', 20220),
|
||||
(34965, 200, '02', 2, 'L-08-4', 21800),
|
||||
(39096, 200, '03', 2, 'LR-02-3', 99999);
|
||||
|
||||
INSERT INTO `vn`.`shelving` (`code`, `parkingFk`, `isPrinted`, `priority`, `parked`, `userFk`)
|
||||
INSERT INTO `vn`.`shelving` (`code`, `parkingFk`, `isPrinted`, `priority`, `userFk`, `isRecyclable`)
|
||||
VALUES
|
||||
('GVC', 1, 0, 1, 0, 1106),
|
||||
('HEJ', 2, 0, 1, 0, 1106),
|
||||
('UXN', 1, 0, 1, 0, 1106);
|
||||
('AA6', 34965, 1, 0, NULL, 0),
|
||||
('AA7', 34965, 1, 0, NULL, 0),
|
||||
('AA8', 34965, 1, 0, NULL, 0),
|
||||
('AA9', NULL, 1, 0, NULL, 0),
|
||||
('AAA', NULL, 0, 0, 1109, 1),
|
||||
('AAB', NULL, 0, 0, 1109, 1),
|
||||
('AAC', NULL, 1, 99, 1109, 1),
|
||||
('AAD', NULL, 0, 0, 1109, 1),
|
||||
('AAE', 39096, 1, 0, 1109, 1),
|
||||
('AAF', 34831, 1, 0, 1109, 1),
|
||||
('GVC', 1, 0, 1, 1106, 1),
|
||||
('HEJ', 2, 0, 1, 1106, 1),
|
||||
('UXN', 1, 0, 1, 1106, 1);
|
||||
|
||||
INSERT INTO `vn`.`accountingType`(`id`, `description`, `receiptDescription`,`code`, `maxAmount`, `daysInFuture`)
|
||||
VALUES
|
||||
|
@ -482,12 +503,28 @@ INSERT INTO `vn`.`supplierActivity`(`code`, `name`)
|
|||
('flowerPlants', 'Wholesale of flowers and plants'),
|
||||
('vegetablesFruits', 'Fruit and vegetable trade');
|
||||
|
||||
INSERT INTO `vn`.`supplierAddress`(`id`, `supplierFk`, `nickname`, `street`, `provinceFk`, `postalCode`, `city`, `phone`, `mobile`)
|
||||
VALUES
|
||||
(1, 1, 'Ace Chemicals', 'The Midtown', 1, '46000', 'Gotham', '111111111', '222222222'),
|
||||
(2, 1, 'Arkham Asylum', 'Grand Avenue', 1, '46000', 'Gotham', '111111111', '222222222'),
|
||||
(3, 2, 'Wayne Tower', 'Grand Avenue', 1, '46000', 'Gotham', '111111111', '222222222'),
|
||||
(4, 2, 'Bank of Gotham', 'Founders Island', 1, '46000', 'Gotham', '111111111', '222222222'),
|
||||
(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`, `healthRegister`)
|
||||
VALUES
|
||||
(1, 'Plants SL', 'Plants nick', 4100000001, 1, '06089160W', 0, util.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, util.VN_CURDATE(), 1, 'supplier address 2', 'GOTHAM', 2, 43022, 1, 2, 10, 93, 2, 8, 18, 'animals', 1, '400664487V'),
|
||||
(442, 'Verdnatura Levante SL', 'Verdnatura', 5115000442, 1, '06815934E', 0, util.VN_CURDATE(), 1, 'supplier address 3', 'GOTHAM', 1, 43022, 1, 2, 15, 6, 9, 3, 18, 'complements', 1, '400664487V');
|
||||
|
||||
INSERT INTO `vn`.`supplierContact`(`id`, `supplierFk`, `phone`, `mobile`, `email`, `observation`, `name`)
|
||||
VALUES
|
||||
(1, 1, 123121212, 654789123, 'supplier1@email.es', 'observation1', 'the boss'),
|
||||
(2, 1, 987456132, NULL, NULL, NULL, 'the salesperson'),
|
||||
(3, 2, 321654987, NULL, 'supplier2@email.es', NULL, NULL),
|
||||
(4, 442, 321654987, NULL, NULL, 'observation442', NULL);
|
||||
|
||||
INSERT INTO `vn`.`supplierAccount`(`id`, `supplierFk`, `iban`, `bankEntityFk`)
|
||||
VALUES
|
||||
(241, 442, 'ES111122333344111122221111', 128);
|
||||
|
@ -539,18 +576,16 @@ INSERT INTO `vn`.`invoiceOutTax` (`invoiceOutFk`, `taxableBase`, `vat`, `pgcFk`)
|
|||
(4, 8.07, 0.81, 4770000010),
|
||||
(5, 8.07, 0.81, 4770000010);
|
||||
|
||||
INSERT INTO `vn`.`expence`(`id`, `taxTypeFk`, `name`, `isWithheld`)
|
||||
INSERT INTO `vn`.`expence`(`id`, `name`, `isWithheld`)
|
||||
VALUES
|
||||
(2000000000, 1, 'Inmovilizado pendiente', 0),
|
||||
(2000000000, 3, 'Compra de bienes de inmovilizado', 0),
|
||||
(4751000000, 0, 'Retenciones', 1),
|
||||
(4751000000, 1, 'Retenciones', 1),
|
||||
(4751000000, 6, 'Retencion', 0),
|
||||
(6210000567, 0, 'Alquiler VNH', 0),
|
||||
(6240000000, 1, 'Transportes de ventas rutas', 0),
|
||||
(6240000000, 4, 'Transportes de ventas rutas', 0),
|
||||
(7001000000, 1, 'Mercaderia', 0),
|
||||
(7050000000, 1, 'Prestacion de servicios', 1);
|
||||
(2000000000, 'Inmovilizado pendiente', 0),
|
||||
(2000000001, 'Compra de bienes de inmovilizado', 0),
|
||||
(4751000000, 'Retenciones', 1),
|
||||
(4751000001, 'Retencion', 0),
|
||||
(6210000567, 'Alquiler VNH', 0),
|
||||
(6240000000, 'Transportes de ventas rutas', 0),
|
||||
(7001000000, 'Mercaderia', 0),
|
||||
(7050000000, 'Prestacion de servicios', 1);
|
||||
|
||||
|
||||
INSERT INTO `vn`.`invoiceOutExpence`(`id`, `invoiceOutFk`, `amount`, `expenceFk`, `created`)
|
||||
|
@ -766,14 +801,14 @@ INSERT INTO `vn`.`temperature`(`code`, `name`, `description`)
|
|||
('warm', 'Warm', 'Warm'),
|
||||
('cool', 'Cool', 'Cool');
|
||||
|
||||
INSERT INTO `vn`.`itemType`(`id`, `code`, `name`, `categoryFk`, `warehouseFk`, `life`,`workerFk`, `isPackaging`, `temperatureFk`)
|
||||
INSERT INTO `vn`.`itemType`(`id`, `code`, `name`, `categoryFk`, `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');
|
||||
(1, 'CRI', 'Crisantemo', 2, 31, 35, 0, 'cool'),
|
||||
(2, 'ITG', 'Anthurium', 1, 31, 35, 0, 'cool'),
|
||||
(3, 'WPN', 'Paniculata', 2, 31, 35, 0, 'cool'),
|
||||
(4, 'PRT', 'Delivery ports', 3, NULL, 35, 1, 'warm'),
|
||||
(5, 'CON', 'Container', 3, NULL, 35, 1, 'warm'),
|
||||
(6, 'ALS', 'Alstroemeria', 1, 31, 16, 0, 'warm');
|
||||
|
||||
INSERT INTO `vn`.`ink`(`id`, `name`, `picture`, `showOrder`, `hex`)
|
||||
VALUES
|
||||
|
@ -833,23 +868,23 @@ INSERT INTO `vn`.`itemFamily`(`code`, `description`)
|
|||
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`, `packingShelve`)
|
||||
VALUES
|
||||
(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);
|
||||
(1, 2, 70, 'YEL', 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '1', NULL, 0, 1, 'VT', 0, NULL, 'V', 0, 15,3),
|
||||
(2, 2, 70, 'BLU', 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '2', NULL, 0, 2, 'VT', 0, NULL, 'H', 0, 10,2),
|
||||
(3, 1, 60, 'YEL', 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '3', NULL, 0, 5, 'VT', 0, NULL, NULL, 0, 5,5),
|
||||
(4, 1, 60, 'YEL', 1, 1, 'Increases block', 1, 05080000, 4751000000, NULL, 0, '4', NULL, 0, 3, 'VT', 0, NULL, NULL, 0, NULL,NULL),
|
||||
(5, 3, 30, 'RED', 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '5', NULL, 0, 3, 'VT', 0, NULL, NULL, 0, NULL,NULL),
|
||||
(6, 5, 30, 'RED', 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '6', NULL, 0, 4, 'VT', 0, NULL, NULL, 0, NULL,NULL),
|
||||
(7, 5, 90, 'BLU', 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '7', NULL, 0, 4, 'VT', 0, NULL, NULL, 0, NULL,NULL),
|
||||
(8, 2, 70, 'YEL', 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '8', NULL, 0, 5, 'VT', 0, NULL, NULL, 0, NULL,NULL),
|
||||
(9, 2, 70, 'BLU', 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '9', NULL, 0, 4, 'VT', 1, NULL, NULL, 0, NULL,NULL),
|
||||
(10, 1, 60, 'YEL', 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '10', NULL, 0, 4, 'VT', 0, NULL, NULL, 0, NULL,NULL),
|
||||
(11, 1, 60, 'YEL', 1, 1, NULL, 1, 05080000, 4751000000, NULL, 0, '11', NULL, 0, 4, 'VT', 0, NULL, NULL, 0, NULL,NULL),
|
||||
(12, 3, 30, 'RED', 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '12', NULL, 0, 3, 'VT', 0, NULL, NULL, 0, NULL,NULL),
|
||||
(13, 5, 30, 'RED', 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '13', NULL, 1, 2, 'VT', 1, NULL, NULL, 1, NULL,NULL),
|
||||
(14, 5, 90, 'BLU', 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 4, 'VT', 1, NULL, NULL, 0, NULL,NULL),
|
||||
(15, 4, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 0, 'EMB', 0, NULL, NULL, 0, NULL,NULL),
|
||||
(16, 6, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 0, 'EMB', 0, NULL, NULL, 0, NULL,NULL),
|
||||
(71, 6, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 0, 'VT', 0, NULL, NULL, 0, NULL,NULL);
|
||||
|
||||
-- Update the taxClass after insert of the items
|
||||
UPDATE `vn`.`itemTaxCountry` SET `taxClassFk` = 2
|
||||
|
@ -885,16 +920,19 @@ INSERT INTO `vn`.`expeditionStateType`(`id`, `description`, `code`)
|
|||
|
||||
INSERT INTO `vn`.`expedition`(`id`, `agencyModeFk`, `ticketFk`, `isBox`, `created`, `itemFk`, `counter`, `workerFk`, `externalId`, `packagingFk`, `stateTypeFk`)
|
||||
VALUES
|
||||
(1, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 15, 1, 18, 'UR9000006041', 94, 1),
|
||||
(2, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 16, 2, 18, 'UR9000006041', 94, 1),
|
||||
(3, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL, 3, 18, 'UR9000006041', 94, 2),
|
||||
(4, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL, 4, 18, 'UR9000006041', 94, 2),
|
||||
(5, 1, 2, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL, 1, 18, NULL, 94, 3),
|
||||
(6, 7, 3, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), NULL, 1, 18, NULL, 94, 3),
|
||||
(7, 2, 4, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), NULL, 1, 18, NULL, 94, NULL),
|
||||
(8, 3, 5, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), NULL, 1, 18, NULL, 94, 1),
|
||||
(9, 3, 6, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL, 1, 18, NULL, 94, 2),
|
||||
(10, 7, 7, 71, NOW(), NULL, 1, 18, NULL, 94, 3);
|
||||
(1, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 15, 1, 18, 'UR9000006041', 94, 1),
|
||||
(2, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 16, 2, 18, 'UR9000006041', 94, 1),
|
||||
(3, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL, 3, 18, 'UR9000006041', 94, 2),
|
||||
(4, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL, 4, 18, 'UR9000006041', 94, 2),
|
||||
(5, 1, 2, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL, 1, 18, NULL, 94, 3),
|
||||
(6, 7, 3, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), NULL, 1, 18, NULL, 94, 3),
|
||||
(7, 2, 4, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), NULL, 1, 18, NULL, 94, NULL),
|
||||
(8, 3, 5, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), NULL, 1, 18, NULL, 94, 1),
|
||||
(9, 3, 6, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL, 1, 18, NULL, 94, 2),
|
||||
(10, 7, 7, 71, NOW(), NULL, 1, 18, NULL, 94, 3),
|
||||
(11, 7, 8, 71, NOW(), NULL, 1, 18, NULL, 94, 3),
|
||||
(12, 7, 9, 71, NOW(), NULL, 1, 18, NULL, 94, 3),
|
||||
(13, 1, 10, 71, NOW(), NULL, 1, 18, NULL, 94, 3);
|
||||
|
||||
|
||||
INSERT INTO `vn`.`expeditionState`(`id`, `created`, `expeditionFk`, `typeFk`, `userFk`)
|
||||
|
@ -1310,22 +1348,6 @@ INSERT INTO `vn`.`annualAverageInvoiced`(`clientFk`, `invoiced`)
|
|||
(1104, 500),
|
||||
(1105, 5000);
|
||||
|
||||
INSERT INTO `vn`.`supplierAddress`(`id`, `supplierFk`, `nickname`, `street`, `provinceFk`, `postalCode`, `city`, `phone`, `mobile`)
|
||||
VALUES
|
||||
(1, 1, 'Ace Chemicals', 'The Midtown', 1, '46000', 'Gotham', '111111111', '222222222'),
|
||||
(2, 1, 'Arkham Asylum', 'Grand Avenue', 1, '46000', 'Gotham', '111111111', '222222222'),
|
||||
(3, 2, 'Wayne Tower', 'Grand Avenue', 1, '46000', 'Gotham', '111111111', '222222222'),
|
||||
(4, 2, 'Bank of Gotham', 'Founders Island', 1, '46000', 'Gotham', '111111111', '222222222'),
|
||||
(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`.`supplierContact`(`id`, `supplierFk`, `phone`, `mobile`, `email`, `observation`, `name`)
|
||||
VALUES
|
||||
(1, 1, 123121212, 654789123, 'supplier1@email.es', 'observation1', 'the boss'),
|
||||
(2, 1, 987456132, NULL, NULL, NULL, 'the salesperson'),
|
||||
(3, 2, 321654987, NULL, 'supplier2@email.es', NULL, NULL),
|
||||
(4, 442, 321654987, NULL, NULL, 'observation442', NULL);
|
||||
|
||||
INSERT INTO `cache`.`cache_calc`(`id`, `cache_id`, `cacheName`, `params`, `last_refresh`, `expires`, `created`, `connection_id`)
|
||||
VALUES
|
||||
(1, 2, 'available', CONCAT_WS('/',1,util.VN_CURDATE()), util.VN_NOW(), DATE_ADD(util.VN_NOW(),INTERVAL 15 MINUTE), util.VN_CURDATE(), NULL),
|
||||
|
@ -1340,7 +1362,7 @@ INSERT INTO `vn`.`ticketWeekly`(`ticketFk`, `weekDay`)
|
|||
(4, 4),
|
||||
(5, 6);
|
||||
|
||||
INSERT INTO `vn`.`travel`(`id`,`shipped`, `landed`, `warehouseInFk`, `warehouseOutFk`, `agencyFk`, `m3`, `kg`,`ref`, `totalEntries`, `cargoSupplierFk`)
|
||||
INSERT INTO `vn`.`travel`(`id`,`shipped`, `landed`, `warehouseInFk`, `warehouseOutFk`, `agencyModeFk`, `m3`, `kg`,`ref`, `totalEntries`, `cargoSupplierFk`)
|
||||
VALUES
|
||||
(1, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), 1, 2, 1, 100.00, 1000, 'first travel', 1, 1),
|
||||
(2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 2, 1, 150, 2000, 'second travel', 2, 2),
|
||||
|
@ -1351,7 +1373,7 @@ INSERT INTO `vn`.`travel`(`id`,`shipped`, `landed`, `warehouseInFk`, `warehouseO
|
|||
(7, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 4, 1, 50.00, 500, 'seventh travel', 2, 1),
|
||||
(8, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 1, 1, 50.00, 500, 'eight travel', 1, 2);
|
||||
|
||||
INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed`, `companyFk`, `ref`,`isInventory`, `isRaid`, `notes`, `evaNotes`)
|
||||
INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed`, `companyFk`, `ref`,`isExcludedFromAvailable`, `isRaid`, `notes`, `evaNotes`)
|
||||
VALUES
|
||||
(1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 1, 442, 'Movement 1', 0, 0, '', ''),
|
||||
(2, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 0, 442, 'Movement 2', 0, 0, 'this is the note two', 'observation two'),
|
||||
|
@ -1767,6 +1789,11 @@ INSERT INTO `vn`.`claimEnd`(`id`, `saleFk`, `claimFk`, `workerFk`, `claimDestina
|
|||
(1, 31, 4, 21, 2),
|
||||
(2, 32, 3, 21, 3);
|
||||
|
||||
INSERT INTO `vn`.`claimConfig`(`id`, `pickupContact`, `maxResponsibility`)
|
||||
VALUES
|
||||
(1, 'Contact description', 50),
|
||||
(2, 'Contact description', 30);
|
||||
|
||||
INSERT INTO `hedera`.`tpvMerchant`(`id`, `description`, `companyFk`, `bankFk`, `secretKey`)
|
||||
VALUES
|
||||
(1, 'Arkham Bank', 442, 1, 'h12387193H10238'),
|
||||
|
@ -1861,39 +1888,53 @@ INSERT INTO `pbx`.`sip`(`user_id`, `extension`)
|
|||
(5, 1102),
|
||||
(9, 1201);
|
||||
|
||||
INSERT INTO `postgresql`.`person`(`person_id`, `name`, `nickname`, `nif`, `firstname`, `id_trabajador`)
|
||||
SELECT w.id, w.lastName, u.nickname,CONCAT(RPAD(CONCAT(w.id,9),8,w.id),'A'),w.firstName,w.id
|
||||
FROM `vn`.`worker` `w`
|
||||
JOIN `account`.`user` `u` ON `u`.`id` = `w`.`userFk`;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.worker;
|
||||
CREATE TEMPORARY TABLE tmp.worker
|
||||
(PRIMARY KEY (id))
|
||||
ENGINE = MEMORY
|
||||
SELECT w.id, w.id as `workerFk`, 'VNL', CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -1 YEAR)), '-12-25'), CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL +1 YEAR)), '-12-25'), CONCAT('E-46-', RPAD(CONCAT(w.id, 9), 8, w.id)), NULL as `notes`, NULL as `departmentFk`, 23, 1 as `workerBusinessProfessionalCategoryFk`, 1 as `calendarTypeFk`, 1 as `isHourlyLabor`, 1 as `workerBusinessAgreementFk`, 1 as `workcenterFk`
|
||||
FROM `vn`.`worker` `w`;
|
||||
|
||||
INSERT INTO `postgresql`.`person`(`person_id`, `name`, `nickname`, `nif`, `firstname`, `id_trabajador`)
|
||||
VALUES
|
||||
(1000, 'VERDNATURA LEVANTE SL', 'VNL', 'B78945612', NULL, NULL);
|
||||
INSERT INTO `vn`.`business`(`id`, `workerFk`, `companyCodeFk`, `started`, `ended`, `workerBusiness`, `reasonEndFk`, `notes`, `departmentFk`, `workerBusinessProfessionalCategoryFk`, `calendarTypeFk`, `isHourlyLabor`, `workerBusinessAgreementFk`, `workcenterFk`)
|
||||
SELECT * FROM tmp.worker;
|
||||
|
||||
INSERT INTO `postgresql`.`profile`(`profile_id`, `person_id`, `profile_type_id`)
|
||||
SELECT p.person_id, p.person_id, 1
|
||||
FROM `postgresql`.`person` `p`;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.worker;
|
||||
CREATE TEMPORARY TABLE tmp.worker
|
||||
(PRIMARY KEY (id))
|
||||
ENGINE = MEMORY
|
||||
SELECT '1111' as 'id', w.id as `workerFk`, 'VNL', CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -2 YEAR)), '-12-25'), CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -1 YEAR)), '-12-24'), CONCAT('E-46-', RPAD(CONCAT(w.id, 9), 8, w.id)), NULL as `notes`, NULL as `departmentFk`, 23, 1 as `workerBusinessProfessionalCategoryFk`, 1 as `calendarTypeFk`, 1 as `isHourlyLabor`, 1 as `workerBusinessAgreementFk`, 1 as `workcenterFk`
|
||||
FROM `vn`.`worker` `w`
|
||||
WHERE `w`.`id` = 1109;
|
||||
|
||||
INSERT INTO `postgresql`.`business`(`business_id`, `client_id`, `provider_id`, `date_start`, `date_end`, `workerBusiness`, `reasonEndFk`)
|
||||
SELECT p.profile_id, p.profile_id, 1000, CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR)), '-12-25'), CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL +1 YEAR)), '-01-25'), CONCAT('E-46-',RPAD(CONCAT(p.profile_id,9),8,p.profile_id)), NULL
|
||||
FROM `postgresql`.`profile` `p`;
|
||||
INSERT INTO `vn`.`business` (`id`, `workerFk`, `companyCodeFk`, `started`, `ended`, `workerBusiness`, `reasonEndFk`, `notes`, `departmentFk`, `workerBusinessProfessionalCategoryFk`, `calendarTypeFk`, `isHourlyLabor`, `workerBusinessAgreementFk`, `workcenterFk`)
|
||||
SELECT * FROM tmp.worker;
|
||||
|
||||
INSERT INTO `postgresql`.`business_labour`(`business_id`, `notes`, `department_id`, `professional_category_id`, `incentivo`, `calendar_labour_type_id`, `porhoras`, `labour_agreement_id`, `workcenter_id`)
|
||||
SELECT b.business_id, NULL, 23, 1, 0, 1, 1, 1, 1
|
||||
FROM `postgresql`.`business` `b`;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.worker;
|
||||
|
||||
INSERT INTO `postgresql`.`business` (`client_id`, `provider_id`, `date_start`, `date_end`, `workerBusiness`, `reasonEndFk`)
|
||||
SELECT p.profile_id, 1000, CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -2 YEAR)), '-12-25'), CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR)), '-12-24'), CONCAT('E-46-',RPAD(CONCAT(p.profile_id,9),8,p.profile_id)), NULL
|
||||
FROM `postgresql`.`profile` `p`
|
||||
WHERE `p`.`profile_id` = 1109;
|
||||
|
||||
UPDATE `postgresql`.`business`
|
||||
UPDATE `vn`.`business`
|
||||
SET `payedHolidays`= 8
|
||||
WHERE `business_id`= 1106;
|
||||
WHERE `id`= 1106;
|
||||
|
||||
INSERT INTO `postgresql`.`business_labour` (`business_id`, `notes`, `department_id`, `professional_category_id`, `incentivo`, `calendar_labour_type_id`, `porhoras`, `labour_agreement_id`, `workcenter_id`)
|
||||
UPDATE `vn`.`business` b
|
||||
SET b.`workerBusinessProfessionalCategoryFk` = 31
|
||||
WHERE b.`workerFk` = 1110;
|
||||
|
||||
UPDATE `vn`.`business` b
|
||||
SET b.`departmentFk` = 43
|
||||
WHERE b.id IN(18, 19);
|
||||
|
||||
INSERT INTO `vn`.`workCenterHoliday` (`workCenterFk`, `days`, `year`)
|
||||
VALUES
|
||||
(1111, NULL, 23, 1, 0.0, 1, 1, 1, 1);
|
||||
('1', '27.5', YEAR(util.VN_CURDATE())),
|
||||
('5', '22', YEAR(util.VN_CURDATE())),
|
||||
('1', '24.5', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR))),
|
||||
('5', '23', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR)));
|
||||
|
||||
INSERT INTO `vn`.`workerBusinessType` (`id`, `name`, `isFullTime`, `isPermanent`, `hasHolidayEntitlement`)
|
||||
VALUES
|
||||
(1, 'CONTRATO HOLANDA', 1, 0, 1),
|
||||
(100, 'INDEFINIDO A TIEMPO COMPLETO', 1, 1, 1),
|
||||
(109, 'CONVERSION DE TEMPORAL EN INDEFINIDO T.COMPLETO', 1, 1, 1);
|
||||
|
||||
UPDATE `postgresql`.`business_labour` bl
|
||||
JOIN `postgresql`.`business` b ON b.business_id = bl.business_id
|
||||
|
@ -1906,10 +1947,12 @@ UPDATE `postgresql`.`business_labour` bl
|
|||
SET bl.`department_id` = 43
|
||||
WHERE business_id IN(18, 19);
|
||||
|
||||
INSERT INTO `postgresql`.`media`(`media_id`, `media_type_id`, `value`, `sort`)
|
||||
VALUES
|
||||
(1, 10, 600123321, 0),
|
||||
(2, 10, 700987987, 0);
|
||||
UPDATE `vn`.`business` b
|
||||
SET `rate` = 7,
|
||||
`workerBusinessCategoryFk` = 12,
|
||||
`workerBusinessTypeFk` = 100,
|
||||
`amount` = 2000
|
||||
WHERE b.id = 1107;
|
||||
|
||||
INSERT INTO `postgresql`.`profile_media`(`profile_media_id`, `profile_id`, `media_id`)
|
||||
VALUES
|
||||
|
@ -2561,8 +2604,8 @@ INSERT INTO `vn`.`supplierAgencyTerm` (`agencyFk`, `supplierFk`, `minimumPackage
|
|||
|
||||
INSERT INTO `vn`.`chat` (`senderFk`, `recipient`, `dated`, `checkUserStatus`, `message`, `status`, `attempts`)
|
||||
VALUES
|
||||
(1101, '@PetterParker', CURDATE(), 1, 'First test message', 0, 0),
|
||||
(1101, '@PetterParker', CURDATE(), 0, 'Second test message', 0, 0);
|
||||
(1101, '@PetterParker', util.VN_CURDATE(), 1, 'First test message', 0, 0),
|
||||
(1101, '@PetterParker', util.VN_CURDATE(), 0, 'Second test message', 0, 0);
|
||||
|
||||
|
||||
INSERT INTO `vn`.`mobileAppVersionControl` (`appName`, `version`, `isVersionCritical`)
|
||||
|
@ -2582,6 +2625,15 @@ INSERT INTO `vn`.`machineWorker` (`workerFk`, `machineFk`, `inTimed`, `outTimed`
|
|||
(1106, 2, util.VN_CURDATE(), NULL),
|
||||
(1106, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 DAY));
|
||||
|
||||
INSERT INTO `vn`.`zoneExclusion` (`id`, `zoneFk`, `dated`, `created`, `userFk`)
|
||||
VALUES
|
||||
(1, 1, DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=7, 7, 14) - DAYOFWEEK(util.VN_CURDATE())) DAY), util.VN_CURDATE(), 100),
|
||||
(2, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL (IF(DAYOFWEEK(util.VN_CURDATE())<=8, 8, 15) - DAYOFWEEK(util.VN_CURDATE())) DAY), util.VN_CURDATE(), 100);
|
||||
|
||||
INSERT INTO `vn`.`zoneExclusionGeo` (`zoneExclusionFk`, `geoFk`)
|
||||
VALUES
|
||||
(2, 1);
|
||||
|
||||
INSERT INTO `vn`.`mdbBranch` (`name`)
|
||||
VALUES
|
||||
('test'),
|
||||
|
@ -2592,6 +2644,11 @@ INSERT INTO `vn`.`mdbVersion` (`app`, `branchFk`, `version`)
|
|||
('tpv', 'test', '1'),
|
||||
('lab', 'master', '1');
|
||||
|
||||
INSERT INTO `vn`.`accountingConfig` (`id`, `minDate`, `maxDate`)
|
||||
VALUES
|
||||
(1, '2022-01-01', '2023-01-01');
|
||||
|
||||
|
||||
INSERT INTO `vn`.`saleGroup` (`userFk`, `parkingFk`, `sectorFk`)
|
||||
VALUES
|
||||
(1, 1, 1);
|
||||
|
|
31088
db/dump/structure.sql
31088
db/dump/structure.sql
File diff suppressed because it is too large
Load Diff
|
@ -239,7 +239,7 @@ xdescribe('worker workerTimeControl_check()', () => {
|
|||
|
||||
stmts.push('START TRANSACTION');
|
||||
|
||||
stmt = new ParameterizedSQL(`INSERT INTO postgresql.calendar_employee(business_id,calendar_state_id,date)
|
||||
stmt = new ParameterizedSQL(`INSERT INTO postgresql.calendar_employee(businessFk,calendar_state_id,date)
|
||||
VALUES
|
||||
(?,1,CURDATE())`, [
|
||||
workerId
|
||||
|
@ -282,7 +282,7 @@ xdescribe('worker workerTimeControl_check()', () => {
|
|||
|
||||
stmts.push('START TRANSACTION');
|
||||
|
||||
stmt = new ParameterizedSQL(`UPDATE postgresql.business SET date_end=DATE_ADD(CURDATE(), INTERVAL -1 DAY) WHERE business_id=?`, [
|
||||
stmt = new ParameterizedSQL(`UPDATE vn.business SET ended = DATE_ADD(CURDATE(), INTERVAL -1 DAY) WHERE id = ?`, [
|
||||
workerId
|
||||
]);
|
||||
stmts.push(stmt);
|
||||
|
|
|
@ -51,14 +51,12 @@ export default {
|
|||
accountDescriptor: {
|
||||
menuButton: 'vn-user-descriptor vn-icon-button[icon="more_vert"]',
|
||||
deleteAccount: '.vn-menu [name="deleteUser"]',
|
||||
changeRole: '.vn-menu [name="changeRole"]',
|
||||
setPassword: '.vn-menu [name="setPassword"]',
|
||||
activateAccount: '.vn-menu [name="enableAccount"]',
|
||||
activateUser: '.vn-menu [name="activateUser"]',
|
||||
deactivateUser: '.vn-menu [name="deactivateUser"]',
|
||||
newPassword: 'vn-textfield[ng-model="$ctrl.newPassword"]',
|
||||
repeatPassword: 'vn-textfield[ng-model="$ctrl.repeatPassword"]',
|
||||
newRole: 'vn-autocomplete[ng-model="$ctrl.newRole"]',
|
||||
activeAccountIcon: 'vn-icon[icon="contact_mail"]',
|
||||
activeUserIcon: 'vn-icon[icon="icon-disabled"]',
|
||||
acceptButton: 'button[response="accept"]',
|
||||
|
@ -143,6 +141,11 @@ export default {
|
|||
verifyCert: 'vn-account-samba vn-check[ng-model="$ctrl.config.verifyCert"]',
|
||||
save: 'vn-account-samba vn-submit'
|
||||
},
|
||||
accountPrivileges: {
|
||||
checkHasGrant: 'vn-user-privileges vn-check[ng-model="$ctrl.user.hasGrant"]',
|
||||
role: 'vn-user-privileges vn-autocomplete[ng-model="$ctrl.user.roleFk"]',
|
||||
save: 'vn-user-privileges vn-submit'
|
||||
},
|
||||
clientsIndex: {
|
||||
createClientButton: `vn-float-button`
|
||||
},
|
||||
|
@ -391,7 +394,7 @@ export default {
|
|||
intrastadCheckbox: '.vn-popover.shown vn-horizontal:nth-child(3) > vn-check[label="Intrastat"]',
|
||||
originCheckbox: '.vn-popover.shown vn-horizontal:nth-child(3) > vn-check[label="Origin"]',
|
||||
buyerCheckbox: '.vn-popover.shown vn-horizontal:nth-child(3) > vn-check[label="Buyer"]',
|
||||
densityCheckbox: '.vn-popover.shown vn-horizontal:nth-child(3) > vn-check[label="Density"]',
|
||||
weightByPieceCheckbox: '.vn-popover.shown vn-horizontal:nth-child(3) > vn-check[label="Weight/Piece"]',
|
||||
saveFieldsButton: '.vn-popover.shown vn-button[label="Save"] > button'
|
||||
},
|
||||
itemFixedPrice: {
|
||||
|
@ -835,14 +838,16 @@ export default {
|
|||
confirmButton: '.vn-confirm.shown button[response="accept"]',
|
||||
},
|
||||
routeIndex: {
|
||||
anyResult: 'vn-table a',
|
||||
firstRouteCheckbox: 'a:nth-child(1) vn-td:nth-child(1) > vn-check',
|
||||
anyResult: 'vn-route-index tbody > tr',
|
||||
firstRouteCheckbox: 'vn-route-index tbody > tr:nth-child(1) > td:nth-child(1) > vn-check',
|
||||
addNewRouteButton: 'vn-route-index a[ui-sref="route.create"]',
|
||||
cloneButton: 'vn-route-index button > vn-icon[icon="icon-clone"]',
|
||||
submitClonationButton: 'tpl-buttons > button[response="accept"]',
|
||||
openAdvancedSearchButton: 'vn-searchbar .append vn-icon[icon="arrow_drop_down"]',
|
||||
searchAgencyAutocomlete: 'vn-route-search-panel vn-autocomplete[ng-model="filter.agencyModeFk"]',
|
||||
advancedSearchButton: 'vn-route-search-panel button[type=submit]',
|
||||
previewButton: 'vn-route-index tbody > tr:nth-child(7) > td:nth-child(11) > vn-icon-button[icon="preview"]',
|
||||
|
||||
},
|
||||
createRouteView: {
|
||||
worker: 'vn-route-create vn-autocomplete[ng-model="$ctrl.route.workerFk"]',
|
||||
|
@ -862,6 +867,8 @@ export default {
|
|||
firstTicketDescriptor: '.vn-popover.shown vn-ticket-descriptor',
|
||||
firstAlias: 'vn-route-summary vn-tbody > vn-tr:nth-child(1) > vn-td:nth-child(3) > span',
|
||||
firstClientDescriptor: '.vn-popover.shown vn-client-descriptor',
|
||||
goToRouteSummaryButton: 'vn-route-summary > vn-card > h5 > a',
|
||||
|
||||
},
|
||||
routeBasicData: {
|
||||
worker: 'vn-route-basic-data vn-autocomplete[ng-model="$ctrl.route.workerFk"]',
|
||||
|
@ -1014,9 +1021,9 @@ export default {
|
|||
save: 'vn-travel-create vn-submit > button'
|
||||
},
|
||||
travelExtraCommunity: {
|
||||
anySearchResult: 'vn-travel-extra-community > vn-data-viewer div > vn-tbody > vn-tr',
|
||||
firstTravelReference: 'vn-travel-extra-community vn-tbody:nth-child(2) vn-td-editable[name="reference"]',
|
||||
firstTravelLockedKg: 'vn-travel-extra-community vn-tbody:nth-child(2) vn-td-editable[name="lockedKg"]',
|
||||
anySearchResult: 'vn-travel-extra-community > vn-card div > tbody > tr[ng-attr-id="{{::travel.id}}"]',
|
||||
firstTravelReference: 'vn-travel-extra-community tbody:nth-child(2) vn-td-editable[name="reference"]',
|
||||
firstTravelLockedKg: 'vn-travel-extra-community tbody:nth-child(2) vn-td-editable[name="lockedKg"]',
|
||||
removeContinentFilter: 'vn-searchbar > form > vn-textfield > div.container > div.prepend > prepend > div > span:nth-child(3) > vn-icon > i'
|
||||
},
|
||||
travelBasicData: {
|
||||
|
@ -1102,7 +1109,7 @@ export default {
|
|||
company: 'vn-entry-basic-data vn-autocomplete[ng-model="$ctrl.entry.companyFk"]',
|
||||
ordered: 'vn-entry-basic-data vn-check[ng-model="$ctrl.entry.isOrdered"]',
|
||||
confirmed: 'vn-entry-basic-data vn-check[ng-model="$ctrl.entry.isConfirmed"]',
|
||||
inventory: 'vn-entry-basic-data vn-check[ng-model="$ctrl.entry.isInventory"]',
|
||||
inventory: 'vn-entry-basic-data vn-check[ng-model="$ctrl.entry.isExcludedFromAvailable"]',
|
||||
raid: 'vn-entry-basic-data vn-check[ng-model="$ctrl.entry.isRaid"]',
|
||||
booked: 'vn-entry-basic-data vn-check[ng-model="$ctrl.entry.isBooked"]',
|
||||
save: 'vn-entry-basic-data button[type=submit]',
|
||||
|
|
|
@ -8,7 +8,7 @@ describe('Client Edit web access path', () => {
|
|||
beforeAll(async() => {
|
||||
browser = await getBrowser();
|
||||
page = browser.page;
|
||||
await page.loginAndModule('employee', 'client');
|
||||
await page.loginAndModule('salesPerson', 'client');
|
||||
await page.accessToSearchResult('max');
|
||||
await page.accessToSection('client.card.webAccess');
|
||||
});
|
||||
|
|
|
@ -31,7 +31,7 @@ describe('Item index path', () => {
|
|||
await page.waitToClick(selectors.itemsIndex.intrastadCheckbox);
|
||||
await page.waitToClick(selectors.itemsIndex.originCheckbox);
|
||||
await page.waitToClick(selectors.itemsIndex.buyerCheckbox);
|
||||
await page.waitToClick(selectors.itemsIndex.densityCheckbox);
|
||||
await page.waitToClick(selectors.itemsIndex.weightByPieceCheckbox);
|
||||
await page.waitToClick(selectors.itemsIndex.saveFieldsButton);
|
||||
const message = await page.waitForSnackbar();
|
||||
|
||||
|
@ -64,7 +64,7 @@ describe('Item index path', () => {
|
|||
await page.waitToClick(selectors.itemsIndex.intrastadCheckbox);
|
||||
await page.waitToClick(selectors.itemsIndex.originCheckbox);
|
||||
await page.waitToClick(selectors.itemsIndex.buyerCheckbox);
|
||||
await page.waitToClick(selectors.itemsIndex.densityCheckbox);
|
||||
await page.waitToClick(selectors.itemsIndex.weightByPieceCheckbox);
|
||||
await page.waitToClick(selectors.itemsIndex.saveFieldsButton);
|
||||
const message = await page.waitForSnackbar();
|
||||
|
||||
|
|
|
@ -9,7 +9,8 @@ describe('Route summary path', () => {
|
|||
browser = await getBrowser();
|
||||
page = browser.page;
|
||||
await page.loginAndModule('employee', 'route');
|
||||
await page.waitToClick('vn-route-index vn-tbody > a:nth-child(7)');
|
||||
await page.waitToClick(selectors.routeIndex.previewButton);
|
||||
await page.waitToClick(selectors.routeSummary.goToRouteSummaryButton);
|
||||
});
|
||||
|
||||
afterAll(async() => {
|
||||
|
@ -34,6 +35,8 @@ describe('Route summary path', () => {
|
|||
});
|
||||
|
||||
it('should click on the first ticket ID making the descriptor popover visible', async() => {
|
||||
await page.waitForState('route.card.summary');
|
||||
await page.waitForTimeout(250);
|
||||
await page.waitToClick(selectors.routeSummary.firstTicketID);
|
||||
await page.waitForSelector(selectors.routeSummary.firstTicketDescriptor);
|
||||
const visible = await page.isVisible(selectors.routeSummary.firstTicketDescriptor);
|
||||
|
|
|
@ -22,7 +22,7 @@ describe('InvoiceOut manual invoice path', () => {
|
|||
});
|
||||
|
||||
it('should create an invoice from a ticket', async() => {
|
||||
await page.autocompleteSearch(selectors.invoiceOutIndex.manualInvoiceTicket, '7');
|
||||
await page.autocompleteSearch(selectors.invoiceOutIndex.manualInvoiceTicket, '15');
|
||||
await page.autocompleteSearch(selectors.invoiceOutIndex.manualInvoiceSerial, 'Global nacional');
|
||||
await page.autocompleteSearch(selectors.invoiceOutIndex.manualInvoiceTaxArea, 'national');
|
||||
await page.waitToClick(selectors.invoiceOutIndex.saveInvoice);
|
||||
|
|
|
@ -22,6 +22,10 @@ describe('Travel extra community path', () => {
|
|||
await page.writeOnEditableTD(selectors.travelExtraCommunity.firstTravelReference, 'edited reference');
|
||||
await page.waitForSpinnerLoad();
|
||||
await page.writeOnEditableTD(selectors.travelExtraCommunity.firstTravelLockedKg, '1500');
|
||||
|
||||
const message = await page.waitForSnackbar();
|
||||
|
||||
expect(message.text).toContain('Data saved!');
|
||||
});
|
||||
|
||||
it('should reload the index and confirm the reference and locked kg were edited', async() => {
|
||||
|
|
|
@ -29,7 +29,7 @@ describe('Entry descriptor path', () => {
|
|||
it('should click the travels button to be redirected to the travels index filtered by the current agency', async() => {
|
||||
await page.waitToClick(selectors.entryDescriptor.travelsQuicklink);
|
||||
await page.expectURL('/travel/index');
|
||||
await page.expectURL('agencyFk');
|
||||
await page.expectURL('agencyModeFk');
|
||||
});
|
||||
|
||||
it('should go back to the entry summary', async() => {
|
||||
|
|
|
@ -62,27 +62,6 @@ describe('Account create and basic data path', () => {
|
|||
});
|
||||
|
||||
describe('Descriptor option', () => {
|
||||
describe('Edit role', () => {
|
||||
it('should edit the role using the descriptor menu', async() => {
|
||||
await page.waitToClick(selectors.accountDescriptor.menuButton);
|
||||
await page.waitToClick(selectors.accountDescriptor.changeRole);
|
||||
await page.autocompleteSearch(selectors.accountDescriptor.newRole, 'adminBoss');
|
||||
await page.waitToClick(selectors.accountDescriptor.acceptButton);
|
||||
const message = await page.waitForSnackbar();
|
||||
|
||||
expect(message.text).toContain('Role changed succesfully!');
|
||||
});
|
||||
|
||||
it('should reload the roles section to see now there are more roles', async() => {
|
||||
// when role updates db takes time to return changes, without this timeout the result would have been 3
|
||||
await page.waitForTimeout(1000);
|
||||
await page.reloadSection('account.card.roles');
|
||||
const rolesCount = await page.countElement(selectors.accountRoles.anyResult);
|
||||
|
||||
expect(rolesCount).toEqual(61);
|
||||
});
|
||||
});
|
||||
|
||||
describe('activate account', () => {
|
||||
it(`should check the active account icon isn't present in the descriptor`, async() => {
|
||||
await page.waitForNumberOfElements(selectors.accountDescriptor.activeAccountIcon, 0);
|
||||
|
@ -150,10 +129,12 @@ describe('Account create and basic data path', () => {
|
|||
|
||||
describe('Set password', () => {
|
||||
it('should set the password using the descriptor menu', async() => {
|
||||
const newPassword = 'quantum.12345';
|
||||
|
||||
await page.waitToClick(selectors.accountDescriptor.menuButton);
|
||||
await page.waitToClick(selectors.accountDescriptor.setPassword);
|
||||
await page.write(selectors.accountDescriptor.newPassword, 'quantum.crypt0graphy');
|
||||
await page.write(selectors.accountDescriptor.repeatPassword, 'quantum.crypt0graphy');
|
||||
await page.write(selectors.accountDescriptor.newPassword, newPassword);
|
||||
await page.write(selectors.accountDescriptor.repeatPassword, newPassword);
|
||||
await page.waitToClick(selectors.accountDescriptor.acceptButton);
|
||||
const message = await page.waitForSnackbar();
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue