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

This commit is contained in:
Sergio De la torre 2024-05-20 09:13:44 +02:00
commit b71984c53f
1223 changed files with 28660 additions and 25469 deletions

1
.gitignore vendored
View File

@ -10,3 +10,4 @@ print.*.json
db.json
junit.xml
.DS_Store
storage

33
.husky/addReferenceTag.js Normal file
View File

@ -0,0 +1,33 @@
const fs = require('fs');
const path = require('path');
function getCurrentBranchName(p = process.cwd()) {
if (!fs.existsSync(p)) return false;
const gitHeadPath = path.join(p, '.git', 'HEAD');
if (!fs.existsSync(gitHeadPath))
return getCurrentBranchName(path.resolve(p, '..'));
const headContent = fs.readFileSync(gitHeadPath, 'utf-8');
return headContent.trim().split('/')[2];
}
const branchName = getCurrentBranchName();
if (branchName) {
const msgPath = `.git/COMMIT_EDITMSG`;
const msg = fs.readFileSync(msgPath, 'utf-8');
const reference = branchName.match(/^\d+/);
const referenceTag = `refs #${reference}`;
if (!msg.includes(referenceTag) && reference) {
const splitedMsg = msg.split(':');
if (splitedMsg.length > 1) {
const finalMsg = splitedMsg[0] + ': ' + referenceTag + splitedMsg.slice(1).join(':');
fs.writeFileSync(msgPath, finalMsg);
}
}
}

8
.husky/commit-msg Executable file
View File

@ -0,0 +1,8 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
echo "Running husky commit-msg hook"
npx --no-install commitlint --edit
echo "Adding reference tag to commit message"
node .husky/addReferenceTag.js

View File

@ -1,3 +1,4 @@
# Changelog
All notable changes to this project will be documented in this file.
@ -5,13 +6,23 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [2408.01] - 2024-02-22
### Added
### Changed
## [24.20.01] - 2024-05-14
### Fixed
- (Worker -> time-control) Corrección de errores
- (InvoiceOut -> Crear factura) Cuando falla al crear una factura, se devuelve un error
- (Worker -> Ver albarán) Ya no aparece la página en blanco
### Changed
- (InvoiceOut) Las facturas ahora muestran el ticket del cual proviene el abono
## [24.18.01] - 2024-05-07
## [24.16.01] - 2024-04-18
## [2414.01] - 2024-04-04
## [2408.01] - 2024-02-22
## [2406.01] - 2024-02-08

15
Jenkinsfile vendored
View File

@ -5,9 +5,15 @@ def FROM_GIT
def RUN_TESTS
def RUN_BUILD
def BRANCH_ENV = [
test: 'test',
master: 'production'
]
node {
stage('Setup') {
env.NODE_ENV = 'dev'
env.BACK_REPLICAS = 1
env.NODE_ENV = BRANCH_ENV[env.BRANCH_NAME] ?: 'dev'
PROTECTED_BRANCH = [
'dev',
@ -18,7 +24,6 @@ node {
FROM_GIT = env.JOB_NAME.startsWith('gitea/')
RUN_TESTS = !PROTECTED_BRANCH && FROM_GIT
RUN_BUILD = PROTECTED_BRANCH && FROM_GIT
// https://www.jenkins.io/doc/book/pipeline/jenkinsfile/#using-environment-variables
echo "NODE_NAME: ${env.NODE_NAME}"
echo "WORKSPACE: ${env.WORKSPACE}"
@ -65,6 +70,7 @@ pipeline {
stage('Back') {
steps {
sh 'pnpm install --prefer-offline'
sh 'node node_modules/puppeteer/install.mjs'
}
}
stage('Print') {
@ -97,7 +103,7 @@ pipeline {
NODE_ENV = ''
}
steps {
sh 'npm run test:back:ci'
sh 'node back/tests.js --ci --junit --network jenkins'
}
post {
always {
@ -229,11 +235,12 @@ pipeline {
if (index != -1)
message = message.substring(0, index)
setEnv()
rocketSend(
channel: 'vn-database',
message: "*DB version uploaded:* ${message}"
+"\n$COMMITTER_EMAIL ($BRANCH_NAME)"
+"\n$GIT_URL/commit/$GIT_COMMIT",
+"\n$RUN_DISPLAY_URL",
rawMessage: true
)
}

View File

@ -54,6 +54,12 @@ For end-to-end tests run from project's root.
$ npm run test:e2e
```
## Generate changeLog test → master
```
$ bash changelog.sh
```
## Visual Studio Code extensions
Open Visual Studio Code, press Ctrl+P and paste the following commands.

View File

@ -3,14 +3,14 @@ const {models} = require('vn-loopback/server/server');
describe('Chat send()', () => {
it('should return true as response', async() => {
let ctx = {req: {accessToken: {userId: 1}}};
let response = await models.Chat.send(ctx, '@salesPerson', 'I changed something');
let response = await models.Chat.send(ctx, '@salesperson', 'I changed something');
expect(response).toEqual(true);
});
it('should return false as response', async() => {
let ctx = {req: {accessToken: {userId: 18}}};
let response = await models.Chat.send(ctx, '@salesPerson', 'I changed something');
let response = await models.Chat.send(ctx, '@salesperson', 'I changed something');
expect(response).toEqual(false);
});

View File

@ -0,0 +1,32 @@
const UserError = require('vn-loopback/util/user-error');
module.exports = Self => {
Self.remoteMethodCtx('assign', {
description: 'Assign a collection',
accessType: 'WRITE',
http: {
path: `/assign`,
verb: 'POST'
},
returns: {
type: ['object'],
root: true
},
});
Self.assign = async(ctx, options) => {
const userId = ctx.req.accessToken.userId;
const myOptions = {userId};
if (typeof options == 'object')
Object.assign(myOptions, options);
const [, , [{collectionFk}]] =
await Self.rawSql('CALL vn.collection_assign(?, @vCollectionFk); SELECT @vCollectionFk collectionFk',
[userId], myOptions);
if (!collectionFk) throw new UserError('There are not picking tickets');
await Self.rawSql('CALL vn.collection_printSticker(?, NULL)', [collectionFk], myOptions);
return collectionFk;
};
};

View File

@ -0,0 +1,158 @@
module.exports = Self => {
Self.remoteMethodCtx('getSales', {
description: 'Get sales from ticket or collection',
accessType: 'READ',
accepts: [
{
arg: 'collectionOrTicketFk',
type: 'number',
required: true
}, {
arg: 'print',
type: 'boolean',
required: true
}, {
arg: 'source',
type: 'string',
required: true
},
],
returns: {
type: 'Object',
root: true
},
http: {
path: `/getSales`,
verb: 'GET'
},
});
Self.getSales = async(ctx, collectionOrTicketFk, print, source, options) => {
const models = Self.app.models;
const userId = ctx.req.accessToken.userId;
const myOptions = {userId};
const $t = ctx.req.__;
if (typeof options == 'object')
Object.assign(myOptions, options);
const [{id}] = await Self.rawSql('SELECT vn.ticket_get(?) as id',
[collectionOrTicketFk],
myOptions);
const [tickets] = await Self.rawSql('CALL vn.collection_getTickets(?)', [id], myOptions);
if (source) {
await Self.rawSql(
'CALL vn.ticketStateToday_setState(?,?)', [id, source], myOptions
);
}
const [sales] = await Self.rawSql('CALL vn.sale_getFromTicketOrCollection(?)',
[id], myOptions);
const isPicker = source != 'CHECKER';
const [placements] = await Self.rawSql('CALL vn.collectionPlacement_get(?, ?)',
[id, isPicker], myOptions
);
if (print) await Self.rawSql('CALL vn.collection_printSticker(?,NULL)', [id], myOptions);
for (let ticket of tickets) {
let observations = ticket.observaciones.split(' ');
for (let observation of observations) {
const salesPerson = ticket.salesPersonFk;
if (observation.startsWith('#') || observation.startsWith('@')) {
await models.Chat.send(ctx,
observation,
$t('ticketCommercial', {ticket: ticket.ticketFk, salesPerson})
);
}
}
}
return getCollection(id, tickets, sales, placements, myOptions);
};
async function getCollection(id, tickets, sales, placements, options) {
const collection = {
collectionFk: id,
tickets: [],
};
for (let ticket of tickets) {
const {ticketFk} = ticket;
ticket.sales = [];
const barcodes = await getBarcodes(ticketFk, options);
await Self.rawSql(
'CALL util.log_add(?, ?, ?, ?, ?, ?, ?, ?)',
['vn', 'ticket', 'Ticket', ticketFk, ticketFk, 'select', null, null],
options
);
for (let sale of sales) {
if (sale.ticketFk == ticketFk) {
sale.placements = [];
for (const salePlacement of placements) {
if (salePlacement.saleFk == sale.saleFk && salePlacement.order) {
const placement = {
saleFk: salePlacement.saleFk,
itemFk: salePlacement.itemFk,
placement: salePlacement.placement,
shelving: salePlacement.shelving,
created: salePlacement.created,
visible: salePlacement.visible,
order: salePlacement.order,
grouping: salePlacement.grouping,
priority: salePlacement.priority,
saleOrder: salePlacement.saleOrder,
isPreviousPrepared: salePlacement.isPreviousPrepared,
itemShelvingSaleFk: salePlacement.itemShelvingSaleFk,
ticketFk: salePlacement.ticketFk,
id: salePlacement.id
};
sale.placements.push(placement);
}
}
sale.barcodes = [];
for (const barcode of barcodes) {
if (barcode.movementId == sale.saleFk) {
if (barcode.code) {
sale.barcodes.push(barcode.code);
sale.barcodes.push(`0 ${barcode.code}`);
}
if (barcode.id) {
sale.barcodes.push(barcode.id);
sale.barcodes.push(`0 ${barcode.id}`);
}
}
}
ticket.sales.push(sale);
}
}
collection.tickets.push(ticket);
}
return collection;
}
async function getBarcodes(ticketId, options) {
const query =
`SELECT s.id movementId,
b.code,
c.id
FROM vn.sale s
LEFT JOIN vn.itemBarcode b ON b.itemFk = s.itemFk
LEFT JOIN vn.buy c ON c.itemFk = s.itemFk
LEFT JOIN vn.entry e ON e.id = c.entryFk
LEFT JOIN vn.travel tr ON tr.id = e.travelFk
WHERE s.ticketFk = ?
AND tr.landed >= DATE_SUB(CURDATE(), INTERVAL 1 YEAR)`;
return Self.rawSql(query, [ticketId], options);
}
};

View File

@ -1,20 +0,0 @@
module.exports = Self => {
Self.remoteMethod('getSectors', {
description: 'Get all sectors',
accessType: 'READ',
returns: {
type: 'Object',
root: true
},
http: {
path: `/getSectors`,
verb: 'GET'
}
});
Self.getSectors = async() => {
const query = `CALL vn.sector_get()`;
const [result] = await Self.rawSql(query);
return result;
};
};

View File

@ -0,0 +1,38 @@
const models = require('vn-loopback/server/server').models;
const LoopBackContext = require('loopback-context');
describe('ticket assign()', () => {
let ctx;
let options;
let tx;
beforeEach(async() => {
ctx = {
req: {
accessToken: {userId: 1106},
headers: {origin: 'http://localhost'},
__: value => value
},
args: {}
};
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
active: ctx.req
});
options = {transaction: tx};
tx = await models.Sale.beginTransaction({});
options.transaction = tx;
});
afterEach(async() => {
await tx.rollback();
});
it('should throw an error when there is not picking tickets', async() => {
try {
await models.Collection.assign(ctx, options);
} catch (e) {
expect(e.message).toEqual('There are not picking tickets');
}
});
});

View File

@ -0,0 +1,62 @@
const {models} = require('vn-loopback/server/server');
describe('collection getSales()', () => {
const collectionOrTicketFk = 999999;
const print = true;
const source = 'CHECKER';
beforeAll(() => {
ctx = {
req: {
accessToken: {userId: 9},
headers: {origin: 'http://localhost'},
}
};
});
it('should return a collection with tickets, placements and barcodes settled correctly', async() => {
const tx = await models.Collection.beginTransaction({});
const options = {transaction: tx};
try {
const collection = await models.Collection.getSales(ctx,
collectionOrTicketFk, print, source, options);
const [firstTicket] = collection.tickets;
const [firstSale] = firstTicket.sales;
const [firstPlacement] = firstSale.placements;
expect(collection.tickets.length).toBeTruthy();
expect(collection.collectionFk).toEqual(firstTicket.ticketFk);
expect(firstSale.ticketFk).toEqual(firstTicket.ticketFk);
expect(firstSale.placements.length).toBeTruthy();
expect(firstSale.barcodes.length).toBeTruthy();
expect(firstSale.saleFk).toEqual(firstPlacement.saleFk);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
it('should print a sticker', async() => {
const tx = await models.Collection.beginTransaction({});
const options = {transaction: tx};
const query = 'SELECT * FROM printQueue pq JOIN printQueueArgs pqa ON pqa.printQueueFk = pq.id';
try {
const printQueueBefore = await models.Collection.rawSql(
query, [], options);
await models.Collection.getSales(ctx,
collectionOrTicketFk, true, source, options);
const printQueueAfter = await models.Collection.rawSql(
query, [], options);
expect(printQueueAfter.length).toEqual(printQueueBefore.length + 1);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});

View File

@ -1,11 +0,0 @@
const {models} = require('vn-loopback/server/server');
describe('getSectors()', () => {
it('return list of sectors', async() => {
let response = await models.Collection.getSectors();
expect(response.length).toBeGreaterThan(0);
expect(response[0].id).toEqual(1);
expect(response[0].description).toEqual('First sector');
});
});

View File

@ -29,7 +29,8 @@ module.exports = Self => {
http: {
path: `/:id/downloadFile`,
verb: 'GET'
}
},
accessScopes: ['DEFAULT', 'read:multimedia']
});
Self.downloadFile = async function(ctx, id) {

View File

@ -49,7 +49,6 @@ module.exports = Self => {
Self.uploadFile = async(ctx, options) => {
const models = Self.app.models;
const TempContainer = models.TempContainer;
const DmsContainer = models.DmsContainer;
const fileOptions = {};
const args = ctx.args;
@ -79,19 +78,21 @@ module.exports = Self => {
const addedDms = [];
for (const uploadedFile of files) {
const newDms = await createDms(ctx, uploadedFile, myOptions);
const pathHash = DmsContainer.getHash(newDms.id);
const file = await TempContainer.getFile(tempContainer.name, uploadedFile.name);
srcFile = path.join(file.client.root, file.container, file.name);
const dmsContainer = await DmsContainer.container(pathHash);
const dstFile = path.join(dmsContainer.client.root, pathHash, newDms.file);
await fs.move(srcFile, dstFile, {
overwrite: true
});
const data = {
workerFk: ctx.req.accessToken.userId,
dmsTypeFk: args.dmsTypeId,
companyFk: args.companyId,
warehouseFk: args.warehouseId,
reference: args.reference,
description: args.description,
contentType: uploadedFile.type,
hasFile: args.hasFile
};
const extension = await models.DmsContainer.getFileExtension(uploadedFile.name);
const newDms = await Self.createFromFile(data, extension, srcFile, myOptions);
addedDms.push(newDms);
}
@ -107,27 +108,4 @@ module.exports = Self => {
throw e;
}
};
async function createDms(ctx, file, myOptions) {
const models = Self.app.models;
const myUserId = ctx.req.accessToken.userId;
const args = ctx.args;
const newDms = await Self.create({
workerFk: myUserId,
dmsTypeFk: args.dmsTypeId,
companyFk: args.companyId,
warehouseFk: args.warehouseId,
reference: args.reference,
description: args.description,
contentType: file.type,
hasFile: args.hasFile
}, myOptions);
let fileName = file.name;
const extension = models.DmsContainer.getFileExtension(fileName);
fileName = `${newDms.id}.${extension}`;
return newDms.updateAttribute('file', fileName, myOptions);
}
};

View File

@ -42,7 +42,8 @@ module.exports = Self => {
http: {
path: `/:id/download`,
verb: 'GET'
}
},
accessScopes: ['DEFAULT', 'read:multimedia']
});
Self.download = async function(id, fileCabinet, filter) {

View File

@ -47,7 +47,8 @@ module.exports = Self => {
http: {
path: `/:collection/:size/:id/download`,
verb: 'GET'
}
},
accessScopes: ['DEFAULT', 'read:multimedia']
});
Self.download = async function(ctx, collection, size, id) {
@ -87,6 +88,6 @@ module.exports = Self => {
await fs.access(file.path);
const stream = fs.createReadStream(file.path);
return [stream, file.contentType, `filename="${file.name}"`];
return [stream, file.contentType, `filename="${fileName}"`];
};
};

View File

@ -4,20 +4,21 @@ describe('image download()', () => {
const collection = 'user';
const size = '160x160';
const employeeId = 1;
const developerId = 9;
const jessicaJonesId = 1110;
const ctx = {req: {accessToken: {userId: employeeId}}};
it('should return the image content-type of the user', async() => {
const userId = 9;
const image = await models.Image.download(ctx, collection, size, userId);
const image = await models.Image.download(ctx, collection, size, developerId);
const contentType = image[1];
expect(contentType).toEqual('image/png');
});
it(`should return false if the user doesn't have image`, async() => {
const userId = 1110;
const image = await models.Image.download(ctx, collection, size, userId);
it('should return the user profile picture', async() => {
const image = await models.Image.download(ctx, collection, size, jessicaJonesId);
const fileName = image[2];
expect(image).toBeFalse();
expect(fileName).toMatch('1110.png');
});
});

View File

@ -0,0 +1,132 @@
const {models} = require('vn-loopback/server/server');
describe('machineWorker updateInTime()', () => {
const itBoss = 104;
const davidCharles = 1106;
beforeAll(async() => {
ctx = {
req: {
accessToken: {},
headers: {origin: 'http://localhost'},
__: value => value
}
};
});
it('should throw an error if the plate does not exist', async() => {
const tx = await models.MachineWorker.beginTransaction({});
const options = {transaction: tx};
const plate = 'RE-123';
ctx.req.accessToken.userId = 1106;
try {
await models.MachineWorker.updateInTime(ctx, plate, options);
await tx.rollback();
} catch (e) {
const error = e;
expect(error.message).toContain('the plate does not exist');
await tx.rollback();
}
});
it('should grab a machine where is not in use', async() => {
const tx = await models.MachineWorker.beginTransaction({});
const options = {transaction: tx};
const plate = 'RE-003';
ctx.req.accessToken.userId = 1107;
try {
const totalBefore = await models.MachineWorker.find(null, options);
await models.MachineWorker.updateInTime(ctx, plate, options);
const totalAfter = await models.MachineWorker.find(null, options);
expect(totalAfter.length).toEqual(totalBefore.length + 1);
await tx.rollback();
} catch (e) {
await tx.rollback();
}
});
describe('less than 12h', () => {
const plate = 'RE-001';
it('should trow an error if it is not himself', async() => {
const tx = await models.MachineWorker.beginTransaction({});
const options = {transaction: tx};
ctx.req.accessToken.userId = davidCharles;
try {
await models.MachineWorker.updateInTime(ctx, plate, options);
await tx.rollback();
} catch (e) {
const error = e;
expect(error.message).toContain('This machine is already in use');
await tx.rollback();
}
});
it('should throw an error if it is himself with a different machine', async() => {
const tx = await models.MachineWorker.beginTransaction({});
const options = {transaction: tx};
ctx.req.accessToken.userId = itBoss;
const plate = 'RE-003';
try {
await models.MachineWorker.updateInTime(ctx, plate, options);
await tx.rollback();
} catch (e) {
const error = e;
expect(error.message).toEqual('You are already using a machine');
await tx.rollback();
}
});
it('should set the out time if it is himself', async() => {
const tx = await models.MachineWorker.beginTransaction({});
const options = {transaction: tx};
ctx.req.accessToken.userId = itBoss;
try {
const isNotParked = await models.MachineWorker.findOne({
where: {workerFk: itBoss}
}, options);
await models.MachineWorker.updateInTime(ctx, plate, options);
const isParked = await models.MachineWorker.findOne({
where: {workerFk: itBoss}
}, options);
expect(isNotParked.outTime).toBeNull();
expect(isParked.outTime).toBeDefined();
await tx.rollback();
} catch (e) {
await tx.rollback();
}
});
});
describe('equal or more than 12h', () => {
const plate = 'RE-002';
it('should set the out time and grab the machine', async() => {
const tx = await models.MachineWorker.beginTransaction({});
const options = {transaction: tx};
ctx.req.accessToken.userId = davidCharles;
const filter = {
where: {workerFk: davidCharles, machineFk: 2}
};
try {
const isNotParked = await models.MachineWorker.findOne(filter, options);
const totalBefore = await models.MachineWorker.find(null, options);
await models.MachineWorker.updateInTime(ctx, plate, options);
const isParked = await models.MachineWorker.findOne(filter, options);
const totalAfter = await models.MachineWorker.find(null, options);
expect(isNotParked.outTime).toBeNull();
expect(isParked.outTime).toBeDefined();
expect(totalAfter.length).toEqual(totalBefore.length + 1);
await tx.rollback();
} catch (e) {
await tx.rollback();
}
});
});
});

View File

@ -0,0 +1,77 @@
const UserError = require('vn-loopback/util/user-error');
module.exports = Self => {
Self.remoteMethodCtx('updateInTime', {
description: 'Updates the corresponding registry if the worker has been registered in the last few hours',
accessType: 'WRITE',
accepts: [
{
arg: 'plate',
type: 'string',
}
],
http: {
path: `/updateInTime`,
verb: 'POST'
}
});
Self.updateInTime = async(ctx, plate, options) => {
const models = Self.app.models;
const userId = ctx.req.accessToken.userId;
const $t = ctx.req.__;
let tx;
const myOptions = {};
if (typeof options == 'object')
Object.assign(myOptions, options);
if (!myOptions.transaction) {
tx = await Self.beginTransaction({});
myOptions.transaction = tx;
}
try {
const machine = await models.Machine.findOne({
fields: ['id', 'plate'],
where: {plate}
}, myOptions);
if (!machine)
throw new UserError($t('the plate does not exist', {plate}));
const machineWorker = await Self.findOne({
where: {
or: [{machineFk: machine.id}, {workerFk: userId}],
outTime: null,
}
}, myOptions);
const {maxHours} = await models.MachineWorkerConfig.findOne({fields: ['maxHours']}, myOptions);
const hoursDifference = (Date.vnNow() - machineWorker?.inTime?.getTime() ?? 0) / (60 * 60 * 1000);
if (machineWorker) {
const isHimself = userId == machineWorker.workerFk;
const isSameMachine = machine.id == machineWorker.machineFk;
if (hoursDifference < maxHours && !isHimself)
throw new UserError($t('This machine is already in use.'));
if (hoursDifference < maxHours && isHimself && !isSameMachine)
throw new UserError($t('You are already using a machine'));
await machineWorker.updateAttributes({
outTime: Date.vnNew()
}, myOptions);
}
if (!machineWorker || hoursDifference >= maxHours)
await models.MachineWorker.create({machineFk: machine.id, workerFk: userId}, myOptions);
if (tx) await tx.commit();
} catch (e) {
if (tx) await tx.rollback();
throw e;
}
};
};

View File

@ -0,0 +1,50 @@
module.exports = Self => {
Self.remoteMethodCtx('getVersion', {
description: 'gets app version data',
accessType: 'READ',
accepts: [{
arg: 'app',
type: 'string',
required: true
}],
returns: {
type: ['object'],
root: true
},
http: {
path: `/getVersion`,
verb: 'GET'
}
});
Self.getVersion = async(ctx, app) => {
const {models} = Self.app;
const userId = ctx.req.accessToken.userId;
const workerFk = await models.WorkerAppTester.findOne({
where: {
workerFk: userId
}
});
let fields = ['id', 'appName'];
if (workerFk)
fields = fields.concat(['isVersionBetaCritical', 'versionBeta', 'urlBeta']);
else
fields = fields.concat(['isVersionCritical', 'version', 'urlProduction']);
const filter = {
where: {
appName: app
},
fields,
};
const result = await Self.findOne(filter);
return {
isVersionCritical: result?.isVersionBetaCritical ?? result?.isVersionCritical,
version: result?.versionBeta ?? result?.version,
url: result?.urlBeta ?? result?.urlProduction
};
};
};

View File

@ -0,0 +1,29 @@
const {models} = require('vn-loopback/server/server');
describe('mobileAppVersionControl getVersion()', () => {
const appName = 'delivery';
const appNameVersion = '9.2';
const appNameVersionBeta = '9.7';
beforeAll(async() => {
ctx = {
req: {
accessToken: {},
headers: {origin: 'http://localhost'},
}
};
});
it('should get the version app', async() => {
ctx.req.accessToken.userId = 9;
const {version} = await models.MobileAppVersionControl.getVersion(ctx, appName);
expect(version).toEqual(appNameVersion);
});
it('should get the beta version app', async() => {
ctx.req.accessToken.userId = 66;
const {version} = await models.MobileAppVersionControl.getVersion(ctx, appName);
expect(version).toEqual(appNameVersionBeta);
});
});

View File

@ -0,0 +1,20 @@
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:mrw="http://www.mrw.es/">
<soap:Header>
<mrw:AuthInfo>
<mrw:CodigoFranquicia><%= mrw.franchiseCode %></mrw:CodigoFranquicia>
<mrw:CodigoAbonado><%= mrw.subscriberCode %></mrw:CodigoAbonado>
<mrw:CodigoDepartamento/>
<mrw:UserName><%= mrw.user %></mrw:UserName>
<mrw:Password><%= mrw.password %></mrw:Password>
</mrw:AuthInfo>
</soap:Header>
<soap:Body>
<mrw:CancelarEnvio>
<mrw:request>
<mrw:CancelaEnvio>
<mrw:NumeroEnvioOriginal><%= externalId %></mrw:NumeroEnvioOriginal>
</mrw:CancelaEnvio>
</mrw:request>
</mrw:CancelarEnvio>
</soap:Body>
</soap:Envelope>

View File

@ -0,0 +1,46 @@
const axios = require('axios');
const fs = require('fs');
const ejs = require('ejs');
const {DOMParser} = require('xmldom');
module.exports = Self => {
Self.remoteMethod('cancelShipment', {
description: 'Cancel a shipment by providing the expedition ID, interacting with MRW WebService',
accessType: 'WRITE',
accepts: [{
arg: 'expeditionFk',
type: 'number',
required: true
}],
returns: {
type: ['object'],
root: true
},
http: {
path: `/cancelShipment`,
verb: 'POST'
}
});
Self.cancelShipment = async expeditionFk => {
const models = Self.app.models;
const mrw = await models.MrwConfig.findOne();
const {externalId} = await models.Expedition.findById(expeditionFk);
const template = fs.readFileSync(__dirname + '/cancelShipment.ejs', 'utf-8');
const renderedXml = ejs.render(template, {mrw, externalId});
const response = await axios.post(mrw.url, renderedXml, {
headers: {
'Content-Type': 'application/soap+xml; charset=utf-8'
}
});
const xmlString = response.data;
const parser = new DOMParser();
const xmlDoc = parser.parseFromString(xmlString, 'text/xml');
const [resultElement] = xmlDoc.getElementsByTagName('Mensaje');
return resultElement.textContent;
};
};

View File

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:mrw="http://www.mrw.es/">
<soap:Header>
<mrw:AuthInfo>
<mrw:CodigoFranquicia><%= mrw.franchiseCode %></mrw:CodigoFranquicia>
<mrw:CodigoAbonado><%= mrw.subscriberCode %></mrw:CodigoAbonado>
<mrw:CodigoDepartamento/>
<mrw:UserName><%= mrw.user %></mrw:UserName>
<mrw:Password><%= mrw.password %></mrw:Password>
</mrw:AuthInfo>
</soap:Header>
<soap:Body>
<mrw:TransmEnvio>
<mrw:request>
<mrw:DatosEntrega>
<mrw:Direccion>
<mrw:CodigoTipoVia/>
<mrw:Via><%= expeditionData.street %></mrw:Via>
<mrw:Numero/>
<mrw:Resto/>
<mrw:CodigoPostal><%= expeditionData.postalCode %></mrw:CodigoPostal>
<mrw:Poblacion><%= expeditionData.city %></mrw:Poblacion>
<mrw:Provincia/>
<mrw:CodigoPais/>
</mrw:Direccion>
<mrw:Nif><%= expeditionData.fi %></mrw:Nif>
<mrw:Nombre><%= expeditionData.clientName %></mrw:Nombre>
<mrw:Telefono><%= expeditionData.phone %></mrw:Telefono>
</mrw:DatosEntrega>
<mrw:DatosServicio>
<mrw:Fecha><%= expeditionData.created %></mrw:Fecha>
<mrw:Referencia><%= expeditionData.expeditionDataId %></mrw:Referencia>
<mrw:CodigoServicio><%= expeditionData.serviceType %></mrw:CodigoServicio>
<mrw:NumeroBultos>1</mrw:NumeroBultos>
<mrw:EntregaSabado><%= expeditionData.weekDays %></mrw:EntregaSabado>
<mrw:Peso><%= expeditionData.kg %></mrw:Peso>
<mrw:Reembolso/>
<mrw:ImporteReembolso/>
</mrw:DatosServicio>
</mrw:request>
</mrw:TransmEnvio>
</soap:Body>
</soap:Envelope>

View File

@ -0,0 +1,118 @@
const axios = require('axios');
const {DOMParser} = require('xmldom');
const fs = require('fs');
const ejs = require('ejs');
const UserError = require('vn-loopback/util/user-error');
module.exports = Self => {
Self.remoteMethod('createShipment', {
description: 'Create an expedition and return a base64Binary label from de MRW WebService',
accessType: 'WRITE',
accepts: [{
arg: 'expeditionFk',
type: 'number',
required: true
}],
returns: {
type: ['object'],
root: true
},
http: {
path: `/createShipment`,
verb: 'POST'
}
});
Self.createShipment = async(expeditionFk, options) => {
const myOptions = {};
let tx;
if (typeof options == 'object')
Object.assign(myOptions, options);
if (!myOptions.transaction) {
tx = await Self.beginTransaction({});
myOptions.transaction = tx;
}
const models = Self.app.models;
const mrw = await models.MrwConfig.findOne(null, myOptions);
if (!mrw)
throw new UserError(`Some mrwConfig parameters are not set`);
const query =
`SELECT CASE co.code
WHEN 'ES' THEN a.postalCode
WHEN 'PT' THEN LEFT(a.postalCode, 4)
WHEN 'AD' THEN REPLACE(a.postalCode, 'AD', '00')
END postalCode,
a.city,
a.street,
co.code countryCode,
c.fi,
c.name clientName,
c.phone,
DATE_FORMAT(t.shipped, '%d/%m/%Y') created,
t.shipped,
e.id expeditionId,
LPAD(IF(mw.params IS NULL, ms.serviceType, mw.serviceType), 4 ,'0') serviceType,
IF(mw.weekdays, 'S', 'N') weekDays
FROM expedition e
JOIN ticket t ON e.ticketFk = t.id
JOIN agencyMode am ON am.id = t.agencyModeFk
JOIN mrwService ms ON ms.agencyModeCodeFk = am.code
LEFT JOIN mrwServiceWeekday mw ON mw.weekdays = DATE_FORMAT(t.shipped, '%a')
JOIN client c ON t.clientFk = c.id
JOIN address a ON t.addressFk = a.id
JOIN province p ON a.provinceFk = p.id
JOIN country co ON co.id = p.countryFk
WHERE e.id = ?
LIMIT 1`;
const [expeditionData] = await Self.rawSql(query, [expeditionFk], myOptions);
if (!expeditionData)
throw new UserError(`This expedition is not a MRW shipment`);
const today = Date.vnNew();
today.setHours(0, 0, 0, 0);
if (expeditionData?.shipped.setHours(0, 0, 0, 0) < today)
throw new UserError(`This ticket has a shipped date earlier than today`);
const shipmentResponse = await sendXmlDoc('createShipment', {mrw, expeditionData}, 'application/soap+xml');
const shipmentId = getTextByTag(shipmentResponse, 'NumeroEnvio');
if (!shipmentId)
throw new UserError(getTextByTag(shipmentResponse, 'Mensaje'));
const getLabelResponse = await sendXmlDoc('getLabel', {mrw, shipmentId}, 'text/xml');
const file = getTextByTag(getLabelResponse, 'EtiquetaFile');
try {
await models.Expedition.updateAll({id: expeditionFk}, {externalId: shipmentId}, myOptions);
if (tx) await tx.commit();
} catch (error) {
if (tx) await tx.rollback();
throw error;
}
return file;
};
function getTextByTag(xmlDoc, tag) {
return xmlDoc?.getElementsByTagName(tag)[0]?.textContent;
}
async function sendXmlDoc(xmlDock, params, contentType) {
const parser = new DOMParser();
const xmlTemplate = fs.readFileSync(__dirname + `/${xmlDock}.ejs`, 'utf-8');
const renderedTemplate = ejs.render(xmlTemplate, params);
const data = await axios.post(params.mrw.url, renderedTemplate, {
headers: {
'Content-Type': `${contentType}; charset=utf-8`
}
});
return parser.parseFromString(data.data, 'text/xml');
}
};

View File

@ -0,0 +1,25 @@
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:mrw="http://www.mrw.es/">
<soapenv:Header>
<mrw:AuthInfo>
<mrw:CodigoFranquicia><%= mrw.franchiseCode %></mrw:CodigoFranquicia>
<mrw:CodigoAbonado><%= mrw.subscriberCode %></mrw:CodigoAbonado>
<mrw:CodigoDepartamento/>
<mrw:UserName><%= mrw.user %></mrw:UserName>
<mrw:Password><%= mrw.password %></mrw:Password>
</mrw:AuthInfo>
</soapenv:Header>
<soapenv:Body>
<mrw:GetEtiquetaEnvio>
<mrw:request>
<mrw:NumeroEnvio><%= shipmentId %></mrw:NumeroEnvio>
<mrw:NumerosEtiqueta>1</mrw:NumerosEtiqueta>
<mrw:SeparadorNumerosEnvio></mrw:SeparadorNumerosEnvio>
<mrw:FechaInicioEnvio></mrw:FechaInicioEnvio>
<mrw:FechaFinEnvio></mrw:FechaFinEnvio>
<mrw:TipoEtiquetaEnvio>0</mrw:TipoEtiquetaEnvio>
<mrw:ReportTopMargin>0</mrw:ReportTopMargin>
<mrw:ReportLeftMargin>0</mrw:ReportLeftMargin>
</mrw:request>
</mrw:GetEtiquetaEnvio>
</soapenv:Body>
</soapenv:Envelope>

View File

@ -0,0 +1,121 @@
const models = require('vn-loopback/server/server').models;
const axios = require('axios');
const fs = require('fs');
const mockBase64Binary = 'base64BinaryString';
const ticket1 = {
'id': '44',
'clientFk': 1101,
'shipped': Date.vnNew(),
'nickname': 'MRW',
'addressFk': 1,
'agencyModeFk': 999
};
const expedition1 = {
'id': 17,
'agencyModeFk': 999,
'ticketFk': 44,
'freightItemFk': 71,
'created': '2001-01-01',
'counter': 1,
'workerFk': 18,
'packagingFk': '94',
'hostFk': '',
'stateTypeFk': 3,
'hasNewRoute': 0,
'isBox': 71,
'editorFk': 100
};
let tx;
let options;
describe('MRWConfig createShipment()', () => {
beforeEach(async() => {
options = tx = undefined;
tx = await models.MrwConfig.beginTransaction({});
options = {transaction: tx};
await models.Agency.create(
{'id': 999, 'name': 'mrw'},
options
);
await models.AgencyMode.create(
{'id': 999, 'name': 'mrw', 'agencyFk': 999, 'code': 'mrw'},
options
);
await models.MrwConfig.create(
{
'id': 1,
'url': 'https://url.com',
'user': 'user',
'password': 'password',
'franchiseCode': 'franchiseCode',
'subscriberCode': 'subscriberCode'
}, options
);
await models.Application.rawSql(
`INSERT INTO vn.mrwService
SET agencyModeCodeFk = 'mrw',
clientType = 1,
serviceType = 1,
kg = 1`, null, options
);
await models.Ticket.create(ticket1, options);
await models.Expedition.create(expedition1, options);
});
afterEach(async() => {
await tx.rollback();
});
it('should create a shipment and return a base64Binary label', async() => {
const mockPostResponses = [
{data: fs.readFileSync(__dirname + '/mockGetLabel.xml', 'utf-8')},
{data: fs.readFileSync(__dirname + '/mockCreateShipment.xml', 'utf-8')}
];
spyOn(axios, 'post').and.callFake(() => Promise.resolve(mockPostResponses.pop()));
const base64Binary = await models.MrwConfig.createShipment(expedition1.id, options);
expect(base64Binary).toEqual(mockBase64Binary);
});
it('should fail if mrwConfig has no data', async() => {
let error;
await models.MrwConfig.createShipment(expedition1.id).catch(e => {
error = e;
}).finally(async() => {
expect(error.message).toEqual(`Some mrwConfig parameters are not set`);
});
expect(error).toBeDefined();
});
it('should fail if expeditionFk is not a MrwExpedition', async() => {
let error;
await models.MrwConfig.createShipment(undefined, options).catch(e => {
error = e;
}).finally(async() => {
expect(error.message).toEqual(`This expedition is not a MRW shipment`);
});
});
it(' should fail if the creation date of this ticket is before the current date it', async() => {
let error;
const yesterday = Date.vnNew();
yesterday.setDate(yesterday.getDate() - 1);
await models.Ticket.updateAll({id: ticket1.id}, {shipped: yesterday}, options);
await models.MrwConfig.createShipment(expedition1.id, options).catch(e => {
error = e;
}).finally(async() => {
expect(error.message).toEqual(`This ticket has a shipped date earlier than today`);
});
});
});

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<TransmEnvioResponse xmlns="http://www.mrw.es/">
<TransmEnvioResult>
<Estado>1</Estado>
<Mensaje />
<NumeroSolicitud>1</NumeroSolicitud>
<NumeroEnvio>1</NumeroEnvio>
<Url>http://url.com</Url>
</TransmEnvioResult>
</TransmEnvioResponse>
</soap:Body>
</soap:Envelope>

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetEtiquetaEnvioResponse xmlns="http://www.mrw.es/">
<GetEtiquetaEnvioResult>
<Estado>1</Estado>
<Mensaje />
<EtiquetaFile>base64BinaryString</EtiquetaFile>
</GetEtiquetaEnvioResult>
</GetEtiquetaEnvioResponse>
</soap:Body>
</soap:Envelope>

View File

@ -45,7 +45,6 @@ module.exports = Self => {
});
availableNotificationsMap.delete(active.notificationFk);
}
return {
active: [...activeNotificationsMap.entries()],
available: [...availableNotificationsMap.entries()]

View File

@ -4,10 +4,10 @@ describe('NotificationSubscription getList()', () => {
it('should return a list of available and active notifications of a user', async() => {
const userId = 9;
const {active, available} = await models.NotificationSubscription.getList(userId);
const notifications = await models.Notification.find({});
const totalAvailable = notifications.length - active.length;
const notifications = await models.NotificationSubscription.getAvailable(userId);
const totalAvailable = notifications.size - active.length;
expect(active.length).toEqual(2);
expect(active.length).toEqual(3);
expect(available.length).toEqual(totalAvailable);
});
});

View File

@ -46,7 +46,7 @@ module.exports = Self => {
html += `<strong>${data}</strong>:<br/>${tryParse(additionalData[data])}<br/>`;
const subjectReason = httpRequest?.data?.error;
smtp.send({
await smtp.send({
to: `${config.app.reportEmail}, ${emailUser.email}`,
subject:
'[Support-Salix] ' +

View File

@ -45,7 +45,7 @@ module.exports = Self => {
{'pc.code': {like: `%${value}%`}},
{'t.name': {like: `%${value}%`}},
{'p.name': {like: `%${value}%`}},
{'c.country': {like: `%${value}%`}}
{'c.name': {like: `%${value}%`}}
]
};
}
@ -62,7 +62,7 @@ module.exports = Self => {
pc.code,
t.name as town,
p.name as province,
c.country
c.name country
FROM
postCode pc
JOIN town t on t.id = pc.townFk

View File

@ -19,12 +19,12 @@ module.exports = Self => {
}
});
Self.getUrl = async(appName = 'salix') => {
const {url} = await Self.app.models.Url.findOne({
const url = await Self.app.models.Url.findOne({
where: {
appName,
enviroment: process.env.NODE_ENV || 'development'
environment: process.env.NODE_ENV || 'development'
}
});
return url;
return url?.url;
};
};

View File

@ -12,8 +12,8 @@ module.exports = Self => {
http: {
path: `/renewToken`,
verb: 'POST'
}
});
},
accessScopes: ['DEFAULT', 'read:multimedia']});
Self.renewToken = async function(ctx) {
const {accessToken: token} = ctx.req;
@ -33,16 +33,23 @@ module.exports = Self => {
// Schedule to remove current token
setTimeout(async() => {
try {
await Self.logout(token.id);
const exists = await models.AccessToken.findById(token.id);
exists && await Self.logout(token.id);
} catch (err) {
// eslint-disable-next-line no-console
console.error(err);
}
}, courtesyTime * 1000);
// Get scopes
let createTokenOptions = {};
const {scopes} = token;
if (scopes)
createTokenOptions = {scopes: [scopes[0]]};
// Create new accessToken
const user = await Self.findById(token.userId);
const accessToken = await user.createAccessToken();
const accessToken = await user.accessTokens.create(createTokenOptions);
return {id: accessToken.id, ttl: accessToken.ttl};
};

View File

@ -0,0 +1,27 @@
module.exports = Self => {
Self.remoteMethodCtx('shareToken', {
description: 'Returns token to view files or images and share it',
accessType: 'WRITE',
accepts: [],
returns: {
type: 'Object',
root: true
},
http: {
path: `/shareToken`,
verb: 'GET'
}
});
Self.shareToken = async function(ctx) {
const {accessToken: token} = ctx.req;
const user = await Self.findById(token.userId);
const multimediaToken = await user.accessTokens.create({
scopes: ['read:multimedia']
});
return {multimediaToken};
};
};

View File

@ -28,11 +28,25 @@ describe('Renew Token', () => {
});
it('should renew token', async() => {
const {courtesyTime} = await models.AccessTokenConfig.findOne({
fields: ['courtesyTime']
});
const mockDate = new Date(startingTime + 26600000);
jasmine.clock().mockDate(mockDate);
const {id} = await models.VnUser.renewToken(ctx);
expect(id).not.toEqual(ctx.req.accessToken.id);
await models.VnUser.logout(ctx.req.accessToken.id);
jasmine.clock().tick((courtesyTime + 10) * 1000);
let tokenNotExists;
try {
tokenNotExists = await models.AccessToken.findById(ctx.req.accessToken.id);
} catch (e) {
error = e;
}
expect(tokenNotExists).toBeNull();
});
it('NOT should renew', async() => {

View File

@ -0,0 +1,64 @@
const {models} = require('vn-loopback/server/server');
const TOKEN_MULTIMEDIA = 'read:multimedia';
describe('Share Token', () => {
let ctx = null;
const startingTime = Date.now();
let multimediaToken = null;
beforeAll(async() => {
const unAuthCtx = {
req: {
headers: {},
connection: {
remoteAddress: '127.0.0.1'
},
getLocale: () => 'en'
},
args: {}
};
let login = await models.VnUser.signIn(unAuthCtx, 'salesAssistant', 'nightmare');
let accessToken = await models.AccessToken.findById(login.token);
ctx = {req: {accessToken: accessToken}};
});
beforeEach(async() => {
multimediaToken = await models.VnUser.shareToken(ctx);
jasmine.clock().install();
jasmine.clock().mockDate(new Date(startingTime));
});
afterEach(() => {
jasmine.clock().uninstall();
});
it('should generate token', async() => {
expect(Object.keys(multimediaToken).length).toEqual(1);
expect(multimediaToken.multimediaToken.userId).toEqual(ctx.req.accessToken.userId);
expect(multimediaToken.multimediaToken.scopes[0]).toEqual(TOKEN_MULTIMEDIA);
});
it('NOT should renew', async() => {
let error;
let response;
try {
response = await models.VnUser.renewToken(ctx);
} catch (e) {
error = e;
}
expect(error).toBeUndefined();
expect(response.id).toEqual(ctx.req.accessToken.id);
});
it('should renew token', async() => {
const mockDate = new Date(startingTime + 26600000);
jasmine.clock().mockDate(mockDate);
const newShareToken = await models.VnUser.renewToken({req: {accessToken: multimediaToken.multimediaToken}});
const {id} = newShareToken;
expect(id).not.toEqual(ctx.req.accessToken.id);
const newMultimediaToken = await models.AccessToken.findById(id);
expect(newMultimediaToken.scopes[0]).toEqual(TOKEN_MULTIMEDIA);
});
});

View File

@ -13,7 +13,7 @@
"AuthCode": {
"dataSource": "vn"
},
"Bank": {
"Accounting": {
"dataSource": "vn"
},
"Buyer": {
@ -79,15 +79,24 @@
"Language": {
"dataSource": "vn"
},
"Machine": {
"dataSource": "vn"
},
"MachineWorker": {
"dataSource": "vn"
},
"MachineWorkerConfig": {
"dataSource": "vn"
},
"MobileAppVersionControl": {
"dataSource": "vn"
},
"Module": {
"dataSource": "vn"
},
"MrwConfig": {
"dataSource": "vn"
},
"Notification": {
"dataSource": "vn"
},
@ -115,6 +124,9 @@
"Postcode": {
"dataSource": "vn"
},
"ReferenceRate": {
"dataSource": "vn"
},
"SageWithholding": {
"dataSource": "vn"
},
@ -159,8 +171,20 @@
},
"VnRole": {
"dataSource": "vn"
},
"WorkerActivity": {
"dataSource": "vn"
},
"WorkerActivityType": {
"dataSource": "vn"
},
"ProductionConfig": {
"dataSource": "vn"
},
"AgencyLog": {
"dataSource": "vn"
},
"AgencyWorkCenter": {
"dataSource": "vn"
}
}

View File

@ -1,9 +1,9 @@
{
"name": "Bank",
"name": "Accounting",
"base": "VnModel",
"options": {
"mysql": {
"table": "bank"
"table": "accounting"
}
},
"properties": {
@ -22,10 +22,7 @@
},
"accountingTypeFk": {
"type": "number",
"required": true,
"mysql": {
"columnName": "cash"
}
"required": true
},
"entityFk": {
"type": "number",

View File

@ -0,0 +1,9 @@
{
"name": "AgencyLog",
"base": "Log",
"options": {
"mysql": {
"table": "agencyLog"
}
}
}

View File

@ -0,0 +1,8 @@
const UserError = require('vn-loopback/util/user-error');
module.exports = Self => {
Self.rewriteDbError(function(err) {
if (err.code === 'ER_DUP_ENTRY')
return new UserError(`This workCenter is already assigned to this agency`);
return err;
});
};

View File

@ -0,0 +1,41 @@
{
"name": "AgencyWorkCenter",
"base": "VnModel",
"options": {
"mysql": {
"table": "agencyWorkCenter"
}
},
"properties": {
"id": {
"id": true,
"type": "number",
"forceId": false
},
"agencyFk": {
"type": "number",
"required": false
},
"workCenterFk": {
"type": "number",
"required": false
}
},
"relations": {
"agency": {
"type": "belongsTo",
"model": "WorkCenter",
"foreignKey": "agencyFk"
},
"workCenter": {
"type": "belongsTo",
"model": "WorkCenter",
"foreignKey": "workCenterFk"
}
},
"scope": {
"include":{
"relation": "workCenter"
}
}
}

View File

@ -1,7 +1,8 @@
module.exports = Self => {
require('../methods/collection/getCollection')(Self);
require('../methods/collection/getSectors')(Self);
require('../methods/collection/setSaleQuantity')(Self);
require('../methods/collection/previousLabel')(Self);
require('../methods/collection/getTickets')(Self);
require('../methods/collection/assign')(Self);
require('../methods/collection/getSales')(Self);
};

View File

@ -1,6 +1,11 @@
{
"name": "Collection",
"base": "VnModel",
"options": {
"mysql": {
"table": "collection"
}
},
"acls": [{
"property": "validations",
"accessType": "EXECUTE",
@ -9,4 +14,3 @@
"permission": "ALLOW"
}]
}

View File

@ -13,7 +13,7 @@
"id": true,
"description": "Identifier"
},
"country": {
"name": {
"type": "string",
"required": true
},

View File

@ -1,4 +1,6 @@
const UserError = require('vn-loopback/util/user-error');
const fs = require('fs-extra');
const path = require('path');
module.exports = Self => {
require('../methods/dms/downloadFile')(Self);
@ -35,4 +37,32 @@ module.exports = Self => {
return [stream, dms.contentType, `filename="${dms.file}"`];
};
Self.getPath = async function(dms) {
const models = Self.app.models;
const pathHash = await models.DmsContainer.getHash(dms.id);
const dmsContainer = await models.DmsContainer.container(pathHash);
const dstFile = path.join(dmsContainer.client.root, pathHash, dms.file);
return dstFile;
};
Self.createWithExtension = async function(data, extension, options) {
const newDms = await Self.create(data, options);
return newDms.updateAttribute('file', `${newDms.id}.${extension}`, options);
};
Self.createFromFile = async function(data, extension, srcFile, options) {
const dms = await Self.createWithExtension(data, extension, options);
const dstFile = await Self.getPath(dms);
await fs.move(srcFile, dstFile, {overwrite: true});
return dms;
};
Self.createFromStream = async function(data, extension, stream, options) {
const dms = await Self.createWithExtension(data, extension, options);
const dstFile = await Self.getPath(dms);
const writeStream = await fs.createWriteStream(dstFile);
await stream.pipe(writeStream);
return dms;
};
};

View File

@ -0,0 +1,18 @@
{
"name": "MachineWorkerConfig",
"base": "VnModel",
"options": {
"mysql": {
"table": "vn.machineWorkerConfig"
}
},
"properties": {
"id": {
"type": "number",
"id": true
},
"maxHours": {
"type": "number"
}
}
}

View File

@ -0,0 +1,3 @@
module.exports = Self => {
require('../methods/machine-worker/updateInTime')(Self);
};

18
back/models/machine.json Normal file
View File

@ -0,0 +1,18 @@
{
"name": "Machine",
"base": "VnModel",
"options": {
"mysql": {
"table": "vn.machine"
}
},
"properties": {
"id": {
"type": "number",
"id": true
},
"plate": {
"type": "string"
}
}
}

View File

@ -0,0 +1,3 @@
module.exports = Self => {
require('../methods/mobile-app-version-control/getVersion')(Self);
};

View File

@ -0,0 +1,39 @@
{
"name": "MobileAppVersionControl",
"base": "VnModel",
"options": {
"mysql": {
"table": "vn.mobileAppVersionControl"
}
},
"properties": {
"id": {
"type": "number",
"id": true
},
"appName": {
"type": "string"
},
"version": {
"type": "string"
},
"isVersionCritical": {
"type": "boolean"
},
"urlProduction": {
"type": "string"
},
"urlBeta": {
"type": "string"
},
"versionBeta": {
"type": "string"
},
"isVersionBetaCritical": {
"type": "boolean"
}
}
}

View File

@ -0,0 +1,4 @@
module.exports = Self => {
require('../methods/mrw-config/createShipment')(Self);
require('../methods/mrw-config/cancelShipment')(Self);
};

View File

@ -0,0 +1,32 @@
{
"name": "MrwConfig",
"base": "VnModel",
"options": {
"mysql": {
"table": "mrwConfig"
}
},
"properties": {
"id": {
"type": "number",
"id": true,
"required": true
},
"url": {
"type": "string",
"required": true
},
"user": {
"type": "string"
},
"password": {
"type": "string"
},
"franchiseCode": {
"type": "string"
},
"subscriberCode": {
"type": "string"
}
}
}

View File

@ -47,7 +47,7 @@
},
"bank": {
"type": "belongsTo",
"model": "Bank",
"model": "Accounting",
"foreignKey": "bankFk"
},
"payMethod": {

View File

@ -0,0 +1,19 @@
{
"name": "ProductionConfig",
"base": "VnModel",
"options": {
"mysql": {
"table": "productionConfig"
}
},
"properties": {
"id": {
"type": "number",
"required": true,
"id": true
},
"backupPrinterNotificationDelay": {
"type": "string"
}
}
}

View File

@ -0,0 +1,36 @@
{
"name": "ReferenceRate",
"base": "PersistedModel",
"options": {
"mysql": {
"table": "referenceRate"
}
},
"properties": {
"id": {
"type": "number",
"id": true,
"description": "Identifier"
},
"currencyFk": {
"type": "number",
"required": true
},
"dated": {
"type": "date",
"required": true
},
"value": {
"type": "number",
"required": true
}
},
"acls": [
{
"accessType": "READ",
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "ALLOW"
}
]
}

View File

@ -1,23 +1,6 @@
const models = require('vn-loopback/server/server').models;
describe('loopback model MailAliasAccount', () => {
it('should fail to add a mail Alias if the worker doesnt have ACLs', async() => {
const tx = await models.MailAliasAccount.beginTransaction({});
let error;
try {
const options = {transaction: tx, accessToken: {userId: 57}};
await models.MailAliasAccount.create({mailAlias: 2, account: 5}, options);
await tx.rollback();
} catch (e) {
await tx.rollback();
error = e;
}
expect(error.message).toEqual('The alias cant be modified');
});
it('should add a mail Alias', async() => {
const tx = await models.MailAliasAccount.beginTransaction({});
let error;

View File

@ -41,8 +41,7 @@ describe('loopback model NotificationSubscription', () => {
try {
const options = {transaction: tx, accessToken: {userId: 9}};
const notificationSubscriptionId = 2;
await models.NotificationSubscription.destroyAll({id: notificationSubscriptionId}, options);
await models.NotificationSubscription.destroyAll({id: 2}, options);
await tx.rollback();
} catch (e) {
@ -76,8 +75,7 @@ describe('loopback model NotificationSubscription', () => {
try {
const options = {transaction: tx, accessToken: {userId: 9}};
const notificationSubscriptionId = 6;
await models.NotificationSubscription.destroyAll({id: notificationSubscriptionId}, options);
await models.NotificationSubscription.destroyAll({id: 6}, options);
await tx.rollback();
} catch (e) {
@ -111,8 +109,7 @@ describe('loopback model NotificationSubscription', () => {
try {
const options = {transaction: tx, accessToken: {userId: 19}};
const notificationSubscriptionId = 4;
await models.NotificationSubscription.destroyAll({id: notificationSubscriptionId}, options);
await models.NotificationSubscription.destroyAll({id: 4}, options);
await tx.rollback();
} catch (e) {

View File

@ -13,6 +13,7 @@ module.exports = function(Self) {
require('../methods/vn-user/privileges')(Self);
require('../methods/vn-user/validate-auth')(Self);
require('../methods/vn-user/renew-token')(Self);
require('../methods/vn-user/share-token')(Self);
require('../methods/vn-user/update-user')(Self);
Self.definition.settings.acls = Self.definition.settings.acls.filter(acl => acl.property !== 'create');

View File

@ -98,30 +98,41 @@
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "ALLOW"
}, {
},
{
"property": "recoverPassword",
"accessType": "EXECUTE",
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "ALLOW"
}, {
},
{
"property": "validateAuth",
"accessType": "EXECUTE",
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "ALLOW"
}, {
},
{
"property": "privileges",
"accessType": "*",
"principalType": "ROLE",
"principalId": "$authenticated",
"permission": "ALLOW"
}, {
},
{
"property": "renewToken",
"accessType": "WRITE",
"principalType": "ROLE",
"principalId": "$authenticated",
"permission": "ALLOW"
},
{
"property": "shareToken",
"accessType": "WRITE",
"principalType": "ROLE",
"principalId": "$authenticated",
"permission": "ALLOW"
}
],
"scopes": {

View File

@ -0,0 +1,39 @@
{
"name": "WorkerActivity",
"base": "VnModel",
"options": {
"mysql": {
"table": "workerActivity"
}
},
"properties": {
"id": {
"id": true,
"type": "number"
},
"created": {
"type": "date"
},
"model": {
"type": "string"
},
"event": {
"type": "string"
},
"description": {
"type": "string"
},
"relations": {
"workerFk": {
"type": "belongsTo",
"model": "Worker",
"foreignKey": "workerFk"
},
"workerActivityTypeFk": {
"type": "belongsTo",
"model": "WorkerActivityType",
"foreignKey": "workerActivityTypeFk"
}
}
}
}

View File

@ -0,0 +1,19 @@
{
"name": "WorkerActivityType",
"base": "VnModel",
"options": {
"mysql": {
"table": "workerActivityType"
}
},
"properties": {
"code": {
"id": true,
"type": "string"
},
"description": {
"type": "string",
"required": false
}
}
}

View File

@ -17,7 +17,8 @@ const opts = getopts(process.argv.slice(2), {
let server;
const PARALLEL = false;
const TIMEOUT = 900000;
const SETUP_TIMEOUT = 15 * 60 * 1000;
const SPEC_TIMEOUT = 30 * 1000;
process.on('exit', teardown);
process.on('uncaughtException', onError);
@ -74,9 +75,9 @@ async function test() {
let runner;
const config = {
globalSetup: setup,
globalSetupTimeout: TIMEOUT,
globalSetupTimeout: SETUP_TIMEOUT,
globalTeardown: teardown,
globalTeardownTimeout: TIMEOUT,
globalTeardownTimeout: SETUP_TIMEOUT,
spec_dir: '.',
spec_files: [
'back/**/*[sS]pec.js',
@ -111,10 +112,11 @@ async function test() {
runner.addReporter(new JunitReporter.JUnitXmlReporter());
}
if (opts.ci)
runner.jasmine.DEFAULT_TIMEOUT_INTERVAL = TIMEOUT;
runner.jasmine.DEFAULT_TIMEOUT_INTERVAL = SPEC_TIMEOUT;
// runner.loadConfigFile('back/jasmine.json');
runner.loadConfig(config);
process.env.SPEC_IS_RUNNING = true;
await runner.execute();
}

34
changelog.sh Normal file
View File

@ -0,0 +1,34 @@
features_types=(chore feat style)
changes_types=(refactor perf)
fix_types=(fix revert)
file="CHANGELOG.md"
file_tmp="temp_log.txt"
file_current_tmp="temp_current_log.txt"
setType(){
echo "### $1" >> $file_tmp
arr=("$@")
echo "" > $file_current_tmp
for i in "${arr[@]}"
do
git log --grep="$i" --oneline --no-merges --format="- %s %d by:%an" master..test >> $file_current_tmp
done
# remove duplicates
sort -o $file_current_tmp -u $file_current_tmp
cat $file_current_tmp >> $file_tmp
echo "" >> $file_tmp
# remove tmp current file
[ -e $file_current_tmp ] && rm $file_current_tmp
}
echo "# Version XX.XX - XXXX-XX-XX" >> $file_tmp
echo "" >> $file_tmp
setType "Added 🆕" "${features_types[@]}"
setType "Changed 📦" "${changes_types[@]}"
setType "Fixed 🛠️" "${fix_types[@]}"
cat $file >> $file_tmp
mv $file_tmp $file

1
commitlint.config.js Normal file
View File

@ -0,0 +1 @@
module.exports = {extends: ['@commitlint/config-conventional']};

13
db/.editorconfig Normal file
View File

@ -0,0 +1,13 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# http://editorconfig.org
root = true
[*]
indent_style = tab
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

16
db/.pullinfo.json Normal file
View File

@ -0,0 +1,16 @@
{
"lastPull": "2024-02-15T08:58:24.000Z",
"shaSums": {
"srt": {
"view": {
"routePalletized": "765f8933a6a5a86dfe8f22825cc77351bc8620cdf1be9d3f25abb130460f3a61",
"ticketPalletized": "c327f3243e717cc607f01d3747967ba68158f90ef1038986b0aa6ae6d5ce7309"
}
},
"vn": {
"view": {
"expeditionPallet_Print": "288cbd6e8289df083ed5eb1a2c808f7a82ba4c90c8ad9781104808a7a54471fb"
}
}
}
}

24
db/dbWatcher.js Normal file
View File

@ -0,0 +1,24 @@
const fs = require('fs');
const {spawn} = require('child_process');
function watchDatabaseChanges() {
console.log('Watching for changes in db/routines and db/versions');
fs.watch('db', {recursive: true}, (eventType, filename) => {
if (filename.endsWith('.sql')) {
let command;
if (filename.startsWith('routines')) command = 'push';
else if (filename.startsWith('versions')) command = 'run';
if (command) {
const process = spawn('myt', [command]);
process.stdout.on('data', data => console.log(data.toString()));
process.stderr.on('data', data => console.error(`stderr: ${data}`));
process.on('error', error => console.error(`error: ${error.message}`));
process.on('close', () => console.log('Watching for changes in db/routines and db/versions'));
}
}
});
}
if (require.main === module) watchDatabaseChanges();
module.exports = watchDatabaseChanges;

View File

@ -3,8 +3,7 @@ USE `util`;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
INSERT INTO `version` VALUES ('salix','10230','53f69ae8e526a4a5d827c237a5b076d38507b392','2020-11-09 11:06:43',NULL);
INSERT INTO `version` VALUES ('vn-database','10818','b7edbbe12f35d0cbc3e6b83e54977ac1c8acfc74','2024-01-25 10:00:48','10831');
INSERT INTO `version` VALUES ('vn-database','11031','12f36dc825b6660062e2c86fde9c6b451cb58f0d','2024-05-14 08:25:58','11048');
INSERT INTO `versionLog` VALUES ('vn-database','10107','00-firstScript.sql','jenkins@10.0.2.69','2022-04-23 10:53:53',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10112','00-firstScript.sql','jenkins@10.0.2.69','2022-05-09 09:14:53',NULL,NULL);
@ -539,6 +538,7 @@ INSERT INTO `versionLog` VALUES ('vn-database','10757','00-firstScript.sql','jen
INSERT INTO `versionLog` VALUES ('vn-database','10758','00-sectorType.sql','jenkins@db-proxy1.static.verdnatura.es','2023-12-14 12:17:18',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10758','01-dipole.sql','jenkins@db-proxy1.static.verdnatura.es','2023-12-14 12:17:18',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10758','02-agencyMode.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-01-25 09:00:32',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10758','03-item.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-02-15 09:45:44',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10761','00-firstScript.sql','jenkins@db-proxy1.static.verdnatura.es','2023-11-16 09:30:58',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10764','00-firstScript.sql','jenkins@db-proxy2.static.verdnatura.es','2024-01-04 12:07:59',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10768','00-firstScript.sql','jenkins@db-proxy2.static.verdnatura.es','2023-11-30 13:11:37',NULL,NULL);
@ -546,6 +546,7 @@ INSERT INTO `versionLog` VALUES ('vn-database','10771','00-firstScript.sql','jen
INSERT INTO `versionLog` VALUES ('vn-database','10773','00-firstScript.sql','jenkins@db-proxy2.static.verdnatura.es','2023-11-30 13:11:38',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10775','00-firstScript.sql','jenkins@db-proxy2.static.verdnatura.es','2024-01-03 10:18:16',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10778','00-firstScript.sql','jenkins@db-proxy2.static.verdnatura.es','2023-11-30 13:11:38',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10781','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-02-15 09:45:54',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10782','00-firstScript.sql','jenkins@db-proxy2.static.verdnatura.es','2024-01-03 10:18:16',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10783','00-firstScript.sql','jenkins@db-proxy1.static.verdnatura.es','2023-11-24 14:49:17',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10784','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-01-25 09:00:32',NULL,NULL);
@ -574,7 +575,235 @@ INSERT INTO `versionLog` VALUES ('vn-database','10815','00-firstScript.sql','jen
INSERT INTO `versionLog` VALUES ('vn-database','10816','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-01-25 09:00:36',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10817','00-invoiceOutConfig_refLen.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-01-24 21:47:35',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10818','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-01-25 09:00:36',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10819','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-02-15 09:45:54',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10820','00-grants.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-02-15 09:45:55',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10825','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-01 10:24:54',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10827','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-01-23 12:32:13',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10828','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-02-15 09:45:55',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10828','01-RevokeClientes_regalos_lista.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-02-15 09:45:55',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10832','00-newWareHouse.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-21 07:01:26',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10832','00-util_tx_commit.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-02-15 09:45:55',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10832','00-util_tx_rollback.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-02-15 09:45:55',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10832','00-util_tx_start.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-02-15 09:45:55',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10832','01-update_procedure_TravelCloneWithEntries.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-02-15 09:45:55',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10832','02-grant_privileges_util_tx.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-02-15 09:45:55',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10835','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-22 08:32:52',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10835','01-Bancos_poliza.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-22 08:32:52',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10835','03-Entradas_orden.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-22 08:32:53',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10835','04-Pagares.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-22 08:32:53',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10835','05-Proveedores_gestdoc.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-22 08:32:53',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10835','06-Remesas.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-22 08:32:53',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10835','07-Saldos_Prevision.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-22 08:32:53',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10835','08-Series.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-22 08:32:53',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10835','09-Split_lines.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-22 08:32:53',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10835','10-Split.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-22 08:32:53',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10835','11-Vehiculos_consumo.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-22 08:32:53',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10835','12-account_conciliacion.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-22 08:32:53',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10835','13-account_detail.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-22 08:32:53',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10835','14-account_detail_type.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-22 08:32:53',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10835','15-agencia_descuadre.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-22 08:32:53',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10835','16-airline.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-22 08:32:53',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10835','17-airport.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-22 08:32:53',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10835','18-albaran.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-22 08:32:53',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10835','19-albaran_gestdoc.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-22 08:32:53',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10835','20-albaran_state.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-22 08:32:53',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10835','21-awb_component.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-22 08:32:54',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10835','22-awb_component_template.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-22 08:32:54',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10835','23-awb_component_type.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-22 08:32:54',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10835','24-awb_gestdoc.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-22 08:32:54',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10835','25-awb_recibida.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-22 08:32:54',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10835','26-awb_role.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-22 08:32:54',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10835','27-awb_unit.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-22 08:32:54',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10835','28-balance_nest_tree.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-22 08:32:54',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10835','29-buy_edi_k012.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-22 08:32:55',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10835','30-buy_edi_k03.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-22 08:32:55',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10835','31-buy_edi_k04.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-22 08:32:55',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10835','32-definitivo.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-22 08:32:55',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10835','33-dropTables.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-22 08:32:55',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10835','34-permisos.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-22 08:32:57',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10838','00-createInventoryConfig.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-07 22:36:27',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10841','00-entryDms.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-07 08:12:55',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10845','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-02-15 09:45:55',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10848','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-02-15 09:45:55',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10849','00-roleLog.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-02-15 09:45:55',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10849','01-userLog.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-02-15 09:45:55',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10849','02-entryLog.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-02-15 09:45:55',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10849','03-clientLog.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-02-15 09:45:55',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10849','04-itemLog.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-02-15 09:45:55',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10849','05-shelvingLog.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-02-15 09:45:55',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10849','06-workerLog.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-02-15 09:45:55',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10849','07-deviceProductionLog.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-02-15 09:45:55',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10849','08-zoneLog.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-02-15 09:45:55',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10849','09-rateLog.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-02-15 09:45:55',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10849','10-ticketLog.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-02-15 09:45:55',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10849','11-userLog.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-02-15 09:45:55',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10849','12-routeLog.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-02-15 09:45:55',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10849','13-claimLog.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-02-15 09:45:55',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10849','14-supplierLog.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-02-15 09:45:55',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10849','15-invoiceInLog.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-02-15 09:45:55',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10849','16-travelLog.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-02-15 09:45:55',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10849','17-packingSiteDeviceLog.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-02-15 09:45:55',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10851','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-01-30 13:31:15',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10853','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-02-15 09:46:05',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10853','00-secondScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-02-15 09:46:06',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10854','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-01-30 16:20:34',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10855','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-02-15 09:46:06',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10856','00-cloneAcl.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-22 08:32:57',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10857','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-22 08:32:57',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10858','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-02-15 09:46:06',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10859','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-14 07:45:25',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10861','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-02-15 09:46:06',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10862','00-alterAgencyTermConfig.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-07 08:12:55',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10862','00-alterGastosResumen.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-07 08:12:55',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10862','00-alterInvoiceOutTaxConfig.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-07 08:12:55',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10862','00-alterItemGroupToOffer.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-07 08:12:55',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10862','01-ventasContablesPk.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-07 08:12:57',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10862','02-updateExpenseRegularize.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-07 08:12:57',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10862','03-updateExpense.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-07 08:12:57',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10862','04-updateExpenseConflict.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-07 08:12:57',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10863','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-22 08:32:59',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10865','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-22 08:32:59',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10867','00-createAclInvoiceIn.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-22 08:32:59',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10867','01-createInvoiceInCorrection.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-22 08:33:00',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10868','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-22 08:33:00',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10869','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-22 08:33:00',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10871','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-22 08:33:00',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10872','00-aclUpdateFiscalData.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-22 08:33:00',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10873','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-22 08:33:00',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10874','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-22 08:33:00',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10876','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-22 08:33:00',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10878','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-22 08:33:00',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10879','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-22 08:33:00',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10880','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-04 07:33:50',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10881','00-alterTableNotification.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-04 07:33:50',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10881','01-notification.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-04 07:33:50',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10882','00-vehicle.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-22 08:33:01',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10883','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-22 08:33:01',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10884','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-22 08:33:01',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10885','00-revokeUpdateClient.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-07 08:12:57',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10887','00-schemaAndUser.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-04 07:33:50',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10887','01-tables.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-04 07:33:50',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10888','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-16 07:39:57',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10889','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-23 09:55:56',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10890','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-22 08:33:01',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10891','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-07 08:12:58',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10892','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-04 07:34:53',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10893','00-sage.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-04 07:34:53',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10895','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-07 07:31:53',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10895','01-secondScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-07 07:31:56',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10895','02-thirdScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-07 07:31:59',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10896','01-financialProductType.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-07 08:12:58',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10896','02-flight.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-07 08:12:58',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10896','03-gastos_resumen.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-07 08:13:00',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10896','04-integra2.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-07 08:13:01',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10896','05-integra2_province.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-07 08:13:01',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10896','06-intervalos__delete.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-07 08:13:01',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10896','10-mail_templates__delete.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-07 08:13:01',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10896','12-ticket_location__delete.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-07 08:13:01',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10896','13-turn__delete.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-07 08:13:01',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10896','14-movement_label.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-07 08:13:01',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10896','15-pago_sdc.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-07 08:13:01',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10896','25-warehouse_pickup.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-07 08:13:01',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10896','29-kk.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-07 08:13:03',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10896','30-permissions.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-07 08:13:03',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10898','00-table.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-07 08:13:03',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10900','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-18 07:40:50',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10903','00-professionalCategoryAddCode.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-23 08:38:28',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10905','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-21 07:01:26',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10906','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-07 08:13:04',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10908','00-createSupplierDms.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-07 08:13:24',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10909','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-02-26 11:07:35',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10912','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-07 08:13:25',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10913','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-21 07:01:26',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10914','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-28 11:52:54',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10915','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-21 07:01:26',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10917','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-18 07:40:51',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10918','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-21 07:01:27',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10919','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-04 07:34:53',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10922','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-02-29 13:44:58',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10923','00-createParkingLog.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-21 07:15:51',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10923','01-aclParkingLog.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-21 07:15:51',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10924','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-21 07:15:51',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10925','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-21 07:15:51',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10926','00-refactorClaimState.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-21 07:15:51',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10928','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-21 07:15:52',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10929','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-21 07:16:19',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10930','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-18 07:40:51',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10930','01-Tramos.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-18 07:40:51',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10930','02-dock.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-18 07:40:51',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10930','03-Proveedores_cargueras.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-18 07:40:51',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10930','04-payroll_employee.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-18 07:40:51',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10930','05-payroll_centros.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-18 07:40:51',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10930','06-payroll_conceptos.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-18 07:40:52',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10930','07-Permisos.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-18 07:40:52',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10932','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-04 07:34:53',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10940','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-03-06 16:48:18',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10941','00-restoreVn2008Jerarquia.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-03-07 09:36:57',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10942','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-07 10:24:45',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10943','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-03-07 10:29:57',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10944','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-07 07:31:59',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10946','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-03-08 07:56:17',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10948','00-addReconciliationConfig.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-18 07:40:52',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10948','02-grantPrivileges.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-18 07:40:52',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10948','03-modifyColumn.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-18 07:40:52',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10949','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-18 07:40:52',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10950','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-07 07:31:59',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10953','00-account.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-04 07:34:54',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10953','01-bs.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-04 07:34:54',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10953','02-edi.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-04 07:34:54',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10953','03-hedera.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-04 07:34:54',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10953','04-pbx.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-04 07:34:54',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10953','05-sage.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-04 07:34:55',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10953','06-salix.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-04 07:34:55',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10953','06-srt.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-04 07:34:55',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10953','07-util.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-04 07:34:55',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10953','08-vn.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-04 07:34:56',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10953','08-vn2.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-04 07:34:58',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10956','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-04 07:34:58',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10957','00-aclTicketClone.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-04 07:34:58',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10959','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-18 13:32:25',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10962','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-25 08:27:35',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10964','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-18 07:40:52',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10967','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-18 07:40:52',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10968','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-04 07:34:58',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10969','00-aclSupplierDms.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-04 07:34:58',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10970','00-specialPrice.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-04 07:34:58',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10971','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-18 07:40:52',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10973','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-18 07:40:52',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10975','00-action.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-03 12:03:46',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10975','01-expeditionFk.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-03 12:04:52',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10976','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-18 07:40:57',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10977','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-18 07:40:57',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10984','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-07 07:31:59',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10988','00-pbx_prefix.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-04-11 17:00:16',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10990','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-07 07:31:59',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10991','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-14 07:45:26',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10992','00-acl.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-14 07:45:26',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10992','00-referenceRate.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-14 07:45:26',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10994','00-modifyAcls.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-07 07:31:59',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10995','01-agencyLogCreate.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-14 07:45:26',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10995','02-agencyWorkCenterCreate.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-14 07:45:26',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10995','03-tableAcl.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-14 07:45:26',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10996','00-dropOrderRecalc.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-07 07:31:59',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10996','01-dropTicketRecalc.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-07 07:31:59',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10996','02-dropTravelRecalc.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-07 07:31:59',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','10997','00-groupingMode.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-07 07:34:21',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11001','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-14 07:45:26',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11002','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-14 07:45:26',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11003','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-07 07:34:21',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11007','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-07 07:34:21',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11008','00-alter.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-14 07:45:27',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11012','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-14 07:45:27',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11014','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-14 07:45:27',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11016','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-27 13:16:09',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11018','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-07 07:34:21',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11021','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-30 09:07:56',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11026','00-entryAlter.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-14 07:45:27',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11026','01-entryUpdate.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-14 07:45:27',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11026','02-entryInternal.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-14 07:45:27',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11031','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-14 07:45:27',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11033','00-rollbackAcls.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-07 12:45:45',NULL,NULL);
INSERT INTO `versionLog` VALUES ('vn-database','11045','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-10 14:53:29',NULL,NULL);
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
@ -589,8 +818,8 @@ INSERT INTO `role` VALUES (1,'employee','Empleado básico',1,'2017-05-19 09:04:5
INSERT INTO `role` VALUES (2,'customer','Privilegios básicos de un cliente',1,'2017-05-19 09:04:58','2023-06-02 22:33:28',NULL);
INSERT INTO `role` VALUES (3,'agency','Consultar tablas de predicciones de bultos',1,'2017-05-19 09:04:58','2017-05-19 09:04:58',NULL);
INSERT INTO `role` VALUES (5,'administrative','Tareas relacionadas con la contabilidad',1,'2017-05-19 09:04:58','2017-05-19 09:04:58',NULL);
INSERT INTO `role` VALUES (6,'guest','Privilegios para usuarios sin cuenta',1,'2017-05-19 09:04:58','2017-05-19 09:04:58',NULL);
INSERT INTO `role` VALUES (9,'developer','Desarrolladores del sistema',1,'2017-05-19 09:04:58','2017-05-19 09:04:58',NULL);
INSERT INTO `role` VALUES (6,'guest','Privilegios para usuarios no autenticados',1,'2017-05-19 09:04:58','2024-04-06 12:05:08',1437);
INSERT INTO `role` VALUES (9,'developer','Desarrollador raso',1,'2017-05-19 09:04:58','2024-03-27 14:14:58',1437);
INSERT INTO `role` VALUES (11,'account','Privilegios relacionados con el login',0,'2017-05-19 09:04:58','2017-09-20 19:06:35',NULL);
INSERT INTO `role` VALUES (13,'teamBoss','Jefe de equipo/departamento',1,'2017-05-19 09:04:58','2021-06-30 15:29:30',NULL);
INSERT INTO `role` VALUES (15,'logistic','Departamento de compras, responsables de la logistica',1,'2017-05-19 09:04:58','2018-02-12 11:50:10',NULL);
@ -631,7 +860,7 @@ INSERT INTO `role` VALUES (57,'deliveryBoss','Jefe de personal de reparto',1,'20
INSERT INTO `role` VALUES (58,'packager','Departamento encajadores',1,'2019-01-21 13:43:45','2019-01-21 13:43:45',NULL);
INSERT INTO `role` VALUES (59,'packagerBoss','Jefe departamento encajadores',1,'2019-01-21 13:44:10','2019-01-21 13:44:10',NULL);
INSERT INTO `role` VALUES (60,'productionAssi','Tareas relacionadas con producción y administración',1,'2019-01-29 14:29:01','2019-01-29 14:29:01',NULL);
INSERT INTO `role` VALUES (61,'replenisherBos','Jefe de Complementos/Camara',1,'2019-07-01 08:44:07','2019-07-01 08:44:07',NULL);
INSERT INTO `role` VALUES (61,'replenisherBoss','Jefe de Complementos/Camara',1,'2019-07-01 08:44:07','2024-02-01 12:07:29',19336);
INSERT INTO `role` VALUES (62,'noLogin','Role without login access to MySQL',0,'2019-07-01 08:50:19','2019-07-02 15:42:05',NULL);
INSERT INTO `role` VALUES (64,'balanceSheet','Consulta de Balance',0,'2019-07-16 14:12:08','2019-07-16 14:12:08',NULL);
INSERT INTO `role` VALUES (65,'officeBoss','Jefe de filial',1,'2019-08-02 08:54:26','2019-08-02 08:54:26',NULL);
@ -663,12 +892,13 @@ INSERT INTO `role` VALUES (115,'itManagement','TI management',1,'2023-03-29 09:2
INSERT INTO `role` VALUES (119,'palletizerBoss','Jefe de paletizadores',1,'2023-06-07 13:51:54','2023-06-07 13:51:54',NULL);
INSERT INTO `role` VALUES (120,'developerBoss','Jefe de proyecto de desarrollo',1,'2023-06-19 09:07:21','2023-06-19 09:07:21',21709);
INSERT INTO `role` VALUES (121,'buyerSalesAssistant','Rol para compradores que también son responsables de ventas',1,'2023-06-23 16:48:19','2023-06-23 16:48:19',NULL);
INSERT INTO `role` VALUES (122,'logisticAssistant','Jefe auxiliar de logística',1,'2023-06-26 09:21:15','2023-06-26 09:21:15',NULL);
INSERT INTO `role` VALUES (122,'logisticAssist','Jefe auxiliar de logística',1,'2023-06-26 09:21:15','2024-03-15 13:38:26',19295);
INSERT INTO `role` VALUES (123,'deliveryAssistant','Jefe auxiliar repartos',1,'2023-10-05 08:47:48','2023-10-05 08:47:48',10578);
INSERT INTO `role` VALUES (124,'hrBuyer','Recursos Humanos con Buyer',1,'2023-10-23 13:50:43','2023-10-23 13:50:43',NULL);
INSERT INTO `role` VALUES (125,'claimViewer','Trabajadores que consulta las reclamaciones ',1,'2023-11-16 09:14:46','2023-11-16 09:14:46',10578);
INSERT INTO `role` VALUES (126,'greenhouseBoss','Jefe de invernadero',1,'2023-11-16 14:32:13','2023-11-16 14:32:13',NULL);
INSERT INTO `role` VALUES (127,'timeControl','Tablet para fichar',1,'2024-01-09 16:36:56','2024-01-09 16:36:56',NULL);
INSERT INTO `role` VALUES (129,'buyerAssistant','Comprador que tienes mas permisos para ayudar al buyerBoss en algunas tareas',1,'2024-02-06 06:59:12','2024-02-06 06:59:12',783);
INSERT INTO `roleInherit` VALUES (1,1,2,NULL);
INSERT INTO `roleInherit` VALUES (2,1,3,NULL);
@ -781,7 +1011,6 @@ INSERT INTO `roleInherit` VALUES (142,35,75,NULL);
INSERT INTO `roleInherit` VALUES (143,15,49,NULL);
INSERT INTO `roleInherit` VALUES (145,17,67,NULL);
INSERT INTO `roleInherit` VALUES (146,38,13,NULL);
INSERT INTO `roleInherit` VALUES (147,101,35,NULL);
INSERT INTO `roleInherit` VALUES (148,101,13,NULL);
INSERT INTO `roleInherit` VALUES (150,15,56,NULL);
INSERT INTO `roleInherit` VALUES (152,69,47,NULL);
@ -905,7 +1134,6 @@ INSERT INTO `roleInherit` VALUES (312,115,120,NULL);
INSERT INTO `roleInherit` VALUES (314,43,18,NULL);
INSERT INTO `roleInherit` VALUES (315,121,35,NULL);
INSERT INTO `roleInherit` VALUES (316,121,21,NULL);
INSERT INTO `roleInherit` VALUES (317,122,15,NULL);
INSERT INTO `roleInherit` VALUES (318,16,122,NULL);
INSERT INTO `roleInherit` VALUES (319,37,49,NULL);
INSERT INTO `roleInherit` VALUES (320,37,18,NULL);
@ -932,6 +1160,11 @@ INSERT INTO `roleInherit` VALUES (355,127,11,NULL);
INSERT INTO `roleInherit` VALUES (356,123,125,NULL);
INSERT INTO `roleInherit` VALUES (357,36,35,NULL);
INSERT INTO `roleInherit` VALUES (358,36,49,NULL);
INSERT INTO `roleInherit` VALUES (359,129,35,NULL);
INSERT INTO `roleInherit` VALUES (360,101,129,NULL);
INSERT INTO `roleInherit` VALUES (361,50,112,NULL);
INSERT INTO `roleInherit` VALUES (362,122,15,NULL);
INSERT INTO `roleInherit` VALUES (364,35,18,NULL);
INSERT INTO `userPassword` VALUES (1,7,1,0,2,1);
@ -1025,7 +1258,7 @@ INSERT INTO `ACL` VALUES (105,'ItemBarcode','*','WRITE','ALLOW','ROLE','marketin
INSERT INTO `ACL` VALUES (106,'ItemBotanical','*','WRITE','ALLOW','ROLE','marketingBoss');
INSERT INTO `ACL` VALUES (108,'ItemPlacement','*','WRITE','ALLOW','ROLE','marketingBoss');
INSERT INTO `ACL` VALUES (109,'UserConfig','*','*','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (110,'Bank','*','READ','ALLOW','ROLE','trainee');
INSERT INTO `ACL` VALUES (110,'Accounting','*','READ','ALLOW','ROLE','trainee');
INSERT INTO `ACL` VALUES (111,'ClientLog','*','READ','ALLOW','ROLE','trainee');
INSERT INTO `ACL` VALUES (112,'Defaulter','*','READ','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (113,'ClientRisk','*','READ','ALLOW','ROLE','trainee');
@ -1113,7 +1346,6 @@ INSERT INTO `ACL` VALUES (211,'TravelLog','*','READ','ALLOW','ROLE','buyer');
INSERT INTO `ACL` VALUES (212,'Thermograph','*','*','ALLOW','ROLE','buyer');
INSERT INTO `ACL` VALUES (213,'TravelThermograph','*','WRITE','ALLOW','ROLE','buyer');
INSERT INTO `ACL` VALUES (214,'Entry','*','*','ALLOW','ROLE','buyer');
INSERT INTO `ACL` VALUES (215,'TicketWeekly','*','WRITE','ALLOW','ROLE','buyer');
INSERT INTO `ACL` VALUES (216,'TravelThermograph','*','READ','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (218,'Intrastat','*','*','ALLOW','ROLE','buyer');
INSERT INTO `ACL` VALUES (221,'UserConfig','getUserConfig','READ','ALLOW','ROLE','account');
@ -1160,7 +1392,7 @@ INSERT INTO `ACL` VALUES (274,'InvoiceInLog','*','READ','ALLOW','ROLE','administ
INSERT INTO `ACL` VALUES (275,'InvoiceOut','createManualInvoice','WRITE','ALLOW','ROLE','invoicing');
INSERT INTO `ACL` VALUES (276,'InvoiceOut','globalInvoicing','WRITE','ALLOW','ROLE','invoicing');
INSERT INTO `ACL` VALUES (278,'RoleInherit','*','WRITE','ALLOW','ROLE','grant');
INSERT INTO `ACL` VALUES (279,'MailAlias','*','*','ALLOW','ROLE','marketing');
INSERT INTO `ACL` VALUES (279,'MailAlias','*','READ','ALLOW','ROLE','marketing');
INSERT INTO `ACL` VALUES (283,'EntryObservation','*','*','ALLOW','ROLE','buyer');
INSERT INTO `ACL` VALUES (284,'LdapConfig','*','*','ALLOW','ROLE','sysadmin');
INSERT INTO `ACL` VALUES (285,'SambaConfig','*','*','ALLOW','ROLE','sysadmin');
@ -1170,7 +1402,7 @@ INSERT INTO `ACL` VALUES (293,'RoleInherit','*','*','ALLOW','ROLE','it');
INSERT INTO `ACL` VALUES (294,'RoleRole','*','*','ALLOW','ROLE','it');
INSERT INTO `ACL` VALUES (295,'AccountConfig','*','*','ALLOW','ROLE','sysadmin');
INSERT INTO `ACL` VALUES (296,'Collection','*','READ','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (297,'Sale','refund','WRITE','ALLOW','ROLE','invoicing');
INSERT INTO `ACL` VALUES (297,'Sale','clone','WRITE','ALLOW','ROLE','invoicing');
INSERT INTO `ACL` VALUES (298,'InvoiceInDueDay','*','*','ALLOW','ROLE','administrative');
INSERT INTO `ACL` VALUES (299,'Collection','setSaleQuantity','*','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (302,'AgencyTerm','*','*','ALLOW','ROLE','administrative');
@ -1197,8 +1429,8 @@ INSERT INTO `ACL` VALUES (323,'InvoiceOut','refund','WRITE','ALLOW','ROLE','clai
INSERT INTO `ACL` VALUES (324,'Ticket','refund','WRITE','ALLOW','ROLE','invoicing');
INSERT INTO `ACL` VALUES (325,'Ticket','refund','WRITE','ALLOW','ROLE','salesAssistant');
INSERT INTO `ACL` VALUES (326,'Ticket','refund','WRITE','ALLOW','ROLE','claimManager');
INSERT INTO `ACL` VALUES (327,'Sale','refund','WRITE','ALLOW','ROLE','salesAssistant');
INSERT INTO `ACL` VALUES (328,'Sale','refund','WRITE','ALLOW','ROLE','claimManager');
INSERT INTO `ACL` VALUES (327,'Sale','clone','WRITE','ALLOW','ROLE','salesAssistant');
INSERT INTO `ACL` VALUES (328,'Sale','clone','WRITE','ALLOW','ROLE','claimManager');
INSERT INTO `ACL` VALUES (329,'TicketRefund','*','WRITE','ALLOW','ROLE','invoicing');
INSERT INTO `ACL` VALUES (330,'ClaimObservation','*','WRITE','ALLOW','ROLE','salesPerson');
INSERT INTO `ACL` VALUES (331,'ClaimObservation','*','READ','ALLOW','ROLE','salesPerson');
@ -1506,9 +1738,7 @@ INSERT INTO `ACL` VALUES (673,'InvoiceOut','makePdfAndNotify','WRITE','ALLOW','R
INSERT INTO `ACL` VALUES (674,'InvoiceOutConfig','*','READ','ALLOW','ROLE','invoicing');
INSERT INTO `ACL` VALUES (676,'Ticket','invoiceTickets','WRITE','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (680,'MailAliasAccount','*','READ','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (681,'MailAliasAccount','create','WRITE','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (682,'MailAliasAccount','deleteById','WRITE','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (683,'MailAliasAccount','canEditAlias','WRITE','ALLOW','ROLE','itManagement');
INSERT INTO `ACL` VALUES (683,'MailAliasAccount','canEditAlias','WRITE','ALLOW','ROLE','developerBoss');
INSERT INTO `ACL` VALUES (684,'WorkerDisableExcluded','*','READ','ALLOW','ROLE','itManagement');
INSERT INTO `ACL` VALUES (685,'WorkerDisableExcluded','*','WRITE','ALLOW','ROLE','itManagement');
INSERT INTO `ACL` VALUES (686,'MailForward','*','*','ALLOW','ROLE','hr');
@ -1519,7 +1749,6 @@ INSERT INTO `ACL` VALUES (690,'Roadmap','*','*','ALLOW','ROLE','palletizerBoss')
INSERT INTO `ACL` VALUES (691,'Roadmap','*','*','ALLOW','ROLE','productionBoss');
INSERT INTO `ACL` VALUES (692,'ExpeditionTruck','*','*','ALLOW','ROLE','production');
INSERT INTO `ACL` VALUES (693,'ExpeditionTruck','*','*','ALLOW','ROLE','productionBoss');
INSERT INTO `ACL` VALUES (694,'MailAliasAccount','canEditAlias','WRITE','ALLOW','ROLE','marketingBoss');
INSERT INTO `ACL` VALUES (695,'ViaexpressConfig','internationalExpedition','WRITE','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (696,'ViaexpressConfig','renderer','READ','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (697,'Ticket','transferClient','WRITE','ALLOW','ROLE','administrative');
@ -1553,7 +1782,7 @@ INSERT INTO `ACL` VALUES (725,'Account','findOne','READ','ALLOW','ROLE','employe
INSERT INTO `ACL` VALUES (726,'Account','findById','READ','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (727,'Account','find','READ','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (728,'Account','exists','READ','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (729,'Sale','refund','WRITE','ALLOW','ROLE','buyer');
INSERT INTO `ACL` VALUES (729,'Sale','clone','WRITE','ALLOW','ROLE','buyer');
INSERT INTO `ACL` VALUES (730,'Ticket','setDeleted','WRITE','ALLOW','ROLE','deliveryAssistant');
INSERT INTO `ACL` VALUES (732,'Sale','isInPreparing','*','ALLOW','ROLE','production');
INSERT INTO `ACL` VALUES (733,'Train','*','READ','ALLOW','ROLE','production');
@ -1610,6 +1839,54 @@ INSERT INTO `ACL` VALUES (783,'WorkerTimeControl','resendWeeklyHourEmail','WRITE
INSERT INTO `ACL` VALUES (784,'VnRole','*','READ','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (785,'VnRole','*','WRITE','ALLOW','ROLE','it');
INSERT INTO `ACL` VALUES (786,'State','isAllEditable','READ','ALLOW','ROLE','delivery');
INSERT INTO `ACL` VALUES (787,'Ticket','makePdfList','*','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (788,'Ticket','invoiceTicketsAndPdf','*','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (789,'InvoiceIn','*','*','ALLOW','ROLE','buyer');
INSERT INTO `ACL` VALUES (790,'InvoiceIn','getSerial','READ','ALLOW','ROLE','buyer');
INSERT INTO `ACL` VALUES (791,'InvoiceIn','corrective','WRITE','ALLOW','ROLE','administrative');
INSERT INTO `ACL` VALUES (792,'InvoiceInCorrection','*','*','ALLOW','ROLE','administrative');
INSERT INTO `ACL` VALUES (793,'Supplier','updateAllFiscalData','WRITE','ALLOW','ROLE','administrative');
INSERT INTO `ACL` VALUES (794,'Supplier','updateFiscalData','WRITE','ALLOW','ROLE','buyer');
INSERT INTO `ACL` VALUES (795,'Ticket','myLastModified','*','ALLOW','ROLE','production');
INSERT INTO `ACL` VALUES (796,'MrwConfig','cancelShipment','WRITE','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (797,'MrwConfig','createShipment','WRITE','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (798,'MailAliasAccount','*','*','ALLOW','ROLE','itManagement');
INSERT INTO `ACL` VALUES (799,'Ticket','saveCmr','*','ALLOW','ROLE','developer');
INSERT INTO `ACL` VALUES (800,'EntryDms','*','*','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (801,'MailAliasAccount','create','WRITE','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (802,'MailAliasAccount','deleteById','WRITE','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (804,'DeviceProduction','*','READ','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (805,'Collection','assign','WRITE','ALLOW','ROLE','production');
INSERT INTO `ACL` VALUES (806,'ExpeditionPallet','getPallet','READ','ALLOW','ROLE','production');
INSERT INTO `ACL` VALUES (807,'MachineWorker','updateInTime','WRITE','ALLOW','ROLE','production');
INSERT INTO `ACL` VALUES (808,'MobileAppVersionControl','getVersion','READ','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (809,'SaleTracking','delete','WRITE','ALLOW','ROLE','production');
INSERT INTO `ACL` VALUES (810,'SaleTracking','updateTracking','WRITE','ALLOW','ROLE','production');
INSERT INTO `ACL` VALUES (811,'SaleTracking','setPicked','WRITE','ALLOW','ROLE','production');
INSERT INTO `ACL` VALUES (813,'Sale','getFromSectorCollection','READ','ALLOW','ROLE','production');
INSERT INTO `ACL` VALUES (814,'ItemBarcode','delete','WRITE','ALLOW','ROLE','production');
INSERT INTO `ACL` VALUES (815,'WorkerActivityType','*','READ','ALLOW','ROLE','production');
INSERT INTO `ACL` VALUES (816,'WorkerActivity','*','*','ALLOW','ROLE','production');
INSERT INTO `ACL` VALUES (817,'ParkingLog','*','READ','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (818,'ExpeditionPallet','*','*','ALLOW','ROLE','production');
INSERT INTO `ACL` VALUES (819,'Ticket','addSaleByCode','WRITE','ALLOW','ROLE','production');
INSERT INTO `ACL` VALUES (820,'TicketCollection','*','READ','ALLOW','ROLE','production');
INSERT INTO `ACL` VALUES (821,'Ticket','clone','WRITE','ALLOW','ROLE','administrative');
INSERT INTO `ACL` VALUES (822,'SupplierDms','*','*','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (823,'MailAlias','*','*','ALLOW','ROLE','developerBoss');
INSERT INTO `ACL` VALUES (824,'ItemShelving','hasItemOlder','READ','ALLOW','ROLE','production');
INSERT INTO `ACL` VALUES (825,'Application','getEnumValues','*','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (826,'Ticket','editZone','WRITE','ALLOW','ROLE','salesAssistant');
INSERT INTO `ACL` VALUES (827,'TicketWeekly','deleteById','WRITE','ALLOW','ROLE','buyerBoss');
INSERT INTO `ACL` VALUES (828,'TicketWeekly','upsert','WRITE','ALLOW','ROLE','buyer');
INSERT INTO `ACL` VALUES (830,'InvoiceIn','*','READ','ALLOW','ROLE','deliveryBoss');
INSERT INTO `ACL` VALUES (831,'InvoiceIn','exchangeRateUpdate','*','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (832,'AgencyLog','*','READ','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (833,'AgencyWorkCenter','*','READ','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (834,'AgencyMode','*','READ','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (835,'Agency','*','READ','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (836,'Agency','*','WRITE','ALLOW','ROLE','deliveryAssistant');
INSERT INTO `ACL` VALUES (837,'AgencyWorkCenter','*','WRITE','ALLOW','ROLE','deliveryAssistant');
INSERT INTO `fieldAcl` VALUES (1,'Client','name','update','employee');
INSERT INTO `fieldAcl` VALUES (2,'Client','contact','update','employee');
@ -1708,8 +1985,6 @@ USE `vn`;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
INSERT INTO `agencyTermConfig` VALUES ('6240000000','4721000015',21.0000000000,'Adquisiciones intracomunitarias de servicios');
INSERT INTO `alertLevel` VALUES ('FREE',0,1);
INSERT INTO `alertLevel` VALUES ('ON_PREPARATION',1,1);
INSERT INTO `alertLevel` VALUES ('PACKED',2,0);
@ -1757,6 +2032,7 @@ INSERT INTO `businessType` VALUES ('others','Otros');
INSERT INTO `businessType` VALUES ('otherSector','Profesional de otro sector');
INSERT INTO `businessType` VALUES ('restoration','Restauración');
INSERT INTO `businessType` VALUES ('trainingCentre','Centro de formación');
INSERT INTO `businessType` VALUES ('VIP','Very important person');
INSERT INTO `businessType` VALUES ('wholesaler','Mayorista');
INSERT INTO `businessType` VALUES ('worker','Trabajador');
@ -1909,6 +2185,7 @@ INSERT INTO `component` VALUES (45,'maná reclamacion',7,4,NULL,0,'manaClaim',0)
INSERT INTO `component` VALUES (46,'recargo a particular',2,NULL,0.25,0,'individual',0);
INSERT INTO `component` VALUES (47,'promocion Italia',4,NULL,NULL,1,'italianOffer',0);
INSERT INTO `component` VALUES (48,'fusión de lineas',4,NULL,NULL,1,'lineFusion',0);
INSERT INTO `component` VALUES (49,'sustitución',4,NULL,NULL,1,'substitution',0);
INSERT INTO `componentType` VALUES (1,'coste',1,0,'COST');
INSERT INTO `componentType` VALUES (2,'com ventas',1,1,NULL);
@ -1929,59 +2206,61 @@ INSERT INTO `continent` VALUES (3,'África','AF');
INSERT INTO `continent` VALUES (4,'Europa','EU');
INSERT INTO `continent` VALUES (5,'Oceanía','OC');
INSERT INTO `department` VALUES (1,'VN','VERDNATURA',1,106,763,0,0,0,0,28,NULL,'/',NULL,0,NULL,0,0,0,0,NULL,NULL);
INSERT INTO `department` VALUES (22,'shopping','COMPRAS',2,3,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL);
INSERT INTO `department` VALUES (23,'CMA','CAMARA',13,14,NULL,72,1,1,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,1,NULL,NULL);
INSERT INTO `department` VALUES (31,'it','INFORMATICA',4,5,NULL,72,0,0,1,0,1,'/1/','informatica-cau',1,NULL,1,0,0,0,NULL,NULL);
INSERT INTO `department` VALUES (34,'accounting','CONTABILIDAD',6,7,NULL,0,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL);
INSERT INTO `department` VALUES (35,'finance','FINANZAS',8,9,NULL,0,0,0,1,0,1,'/1/',NULL,1,'begonya@verdnatura.es',1,0,0,0,NULL,NULL);
INSERT INTO `department` VALUES (36,'labor','LABORAL',10,11,NULL,0,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL);
INSERT INTO `department` VALUES (37,'PROD','PRODUCCION',12,33,NULL,72,1,1,1,10,1,'/1/',NULL,0,NULL,0,1,1,1,NULL,NULL);
INSERT INTO `department` VALUES (38,'picking','SACADO',15,16,NULL,72,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL,NULL);
INSERT INTO `department` VALUES (39,'packing','ENCAJADO',17,18,NULL,72,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL,NULL);
INSERT INTO `department` VALUES (41,'administration','ADMINISTRACION',34,35,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL);
INSERT INTO `department` VALUES (43,'VT','VENTAS',36,61,NULL,0,0,0,1,12,1,'/1/',NULL,1,'',1,0,0,0,NULL,NULL);
INSERT INTO `department` VALUES (44,'management','GERENCIA',62,63,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL);
INSERT INTO `department` VALUES (45,'logistic','LOGISTICA',64,65,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL);
INSERT INTO `department` VALUES (46,'delivery','REPARTO',66,67,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,0,0,NULL,NULL);
INSERT INTO `department` VALUES (48,'storage','ALMACENAJE',68,69,NULL,0,1,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL);
INSERT INTO `department` VALUES (49,NULL,'PROPIEDAD',70,71,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL);
INSERT INTO `department` VALUES (52,NULL,'CARGA AEREA',72,73,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL);
INSERT INTO `department` VALUES (53,'marketing','MARKETING Y COMUNICACIÓN',74,75,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL);
INSERT INTO `department` VALUES (54,NULL,'ORNAMENTALES',76,77,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL);
INSERT INTO `department` VALUES (55,NULL,'TALLER NATURAL',19,20,14548,72,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,0,1118,NULL);
INSERT INTO `department` VALUES (56,NULL,'TALLER ARTIFICIAL',21,22,8470,72,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,0,1927,NULL);
INSERT INTO `department` VALUES (58,'CMP','CAMPOS',78,81,NULL,72,0,0,1,1,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL);
INSERT INTO `department` VALUES (59,'maintenance','MANTENIMIENTO',82,83,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,0,0,NULL,NULL);
INSERT INTO `department` VALUES (60,'claims','RECLAMACIONES',84,85,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,1,1,0,0,NULL,NULL);
INSERT INTO `department` VALUES (61,NULL,'VNH',86,89,NULL,73,0,0,1,1,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL);
INSERT INTO `department` VALUES (66,NULL,'VERDNAMADRID',90,91,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL);
INSERT INTO `department` VALUES (68,NULL,'COMPLEMENTOS',23,24,NULL,72,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,0,0,NULL,NULL);
INSERT INTO `department` VALUES (69,NULL,'VERDNABARNA',92,93,NULL,74,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL);
INSERT INTO `department` VALUES (80,NULL,'EQUIPO J VALLES',37,38,4250,72,0,0,2,0,43,'/1/43/','jvp_equipo',1,'gestioncomercial@verdnatura.es',1,0,0,0,NULL,NULL);
INSERT INTO `department` VALUES (86,NULL,'LIMPIEZA',94,95,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL);
INSERT INTO `department` VALUES (89,NULL,'COORDINACION',96,97,NULL,0,1,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL);
INSERT INTO `department` VALUES (90,NULL,'TRAILER',87,88,NULL,0,0,0,2,0,61,'/1/61/',NULL,0,NULL,0,0,0,0,NULL,NULL);
INSERT INTO `department` VALUES (91,'artificial','ARTIFICIAL',25,26,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL,NULL);
INSERT INTO `department` VALUES (92,NULL,'EQUIPO SILVERIO',39,40,1203,0,0,0,2,0,43,'/1/43/','sdc_equipo',1,'gestioncomercial@verdnatura.es',1,0,0,0,NULL,NULL);
INSERT INTO `department` VALUES (94,NULL,'EQUIPO J BROCAL',41,42,3797,0,0,0,2,0,43,'/1/43/','jes_equipo',1,'gestioncomercial@verdnatura.es',1,0,0,0,NULL,NULL);
INSERT INTO `department` VALUES (95,NULL,'EQUIPO C ZAMBRANO',43,44,4667,0,0,0,2,0,43,'/1/43/','czg_equipo',1,'gestioncomercial@verdnatura.es',1,0,0,0,NULL,NULL);
INSERT INTO `department` VALUES (96,NULL,'EQUIPO C LOPEZ',45,46,4661,0,0,0,2,0,43,'/1/43/','cla_equipo',1,'gestioncomercial@verdnatura.es',1,0,0,0,NULL,NULL);
INSERT INTO `department` VALUES (115,NULL,'EQUIPO CLAUDI',47,48,3810,0,0,0,2,0,43,'/1/43/','csr_equipo',1,'gestioncomercial@verdnatura.es',1,0,0,0,NULL,NULL);
INSERT INTO `department` VALUES (123,NULL,'EQUIPO ELENA BASCUÑANA',49,50,7102,0,0,0,2,0,43,'/1/43/','ebt_equipo',1,'gestioncomercial@verdnatura.es',1,0,0,0,NULL,NULL);
INSERT INTO `department` VALUES (124,NULL,'CONTROL INTERNO',98,99,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,1,0,0,0,NULL,NULL);
INSERT INTO `department` VALUES (125,NULL,'EQUIPO MIRIAM MAR',51,52,1118,0,0,0,2,0,43,'/1/43/','mir_equipo',1,'gestioncomercial@verdnatura.es',1,0,0,0,NULL,NULL);
INSERT INTO `department` VALUES (126,NULL,'PRESERVADO',27,28,NULL,0,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,0,NULL,NULL);
INSERT INTO `department` VALUES (128,NULL,'PALETIZADO',29,30,NULL,0,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL,NULL);
INSERT INTO `department` VALUES (130,NULL,'REVISION',31,32,NULL,0,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL,NULL);
INSERT INTO `department` VALUES (131,'greenhouse','INVERNADERO',79,80,NULL,0,0,0,2,0,58,'/1/58/',NULL,0,NULL,0,1,0,0,NULL,NULL);
INSERT INTO `department` VALUES (132,NULL,'EQUIPO DC',53,54,1731,0,0,0,2,0,43,'/1/43/','dc_equipo',1,'gestioncomercial@verdnatura.es',1,0,0,0,NULL,NULL);
INSERT INTO `department` VALUES (133,'franceTeam','EQUIPO FRANCIA',55,56,1731,72,0,0,2,0,43,'/1/43/','fra_equipo',1,'gestioncomercial@verdnatura.es',1,0,0,0,NULL,NULL);
INSERT INTO `department` VALUES (134,NULL,'EQUIPO RODRI',57,58,6264,0,0,0,2,0,43,'/1/43/','rhr_equipo',1,'gestioncomercial@verdnatura.es',1,0,0,0,NULL,NULL);
INSERT INTO `department` VALUES (135,'routers','ENRUTADORES',100,101,NULL,0,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL);
INSERT INTO `department` VALUES (136,'heavyVehicles','VEHICULOS PESADOS',102,103,NULL,0,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL);
INSERT INTO `department` VALUES (137,'sorter','SORTER',104,105,NULL,0,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL);
INSERT INTO `department` VALUES (139,NULL,'EQUIPO MIRIAM MAR 2',59,60,3803,0,0,0,2,0,43,'/1/43/','mir2_equipo',1,'gestioncomercial@verdnatura.es',1,0,0,0,NULL,NULL);
INSERT INTO `department` VALUES (1,'VN','VERDNATURA',1,110,763,0,0,0,0,26,NULL,'/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (22,'shopping','COMPRAS',2,3,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (23,'CMA','CAMARA',13,14,NULL,72,1,1,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,1,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (31,'it','INFORMATICA',4,5,NULL,72,0,0,1,0,1,'/1/','informatica-cau',1,NULL,1,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (34,'accounting','CONTABILIDAD',6,7,NULL,0,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (35,'finance','FINANZAS',8,9,NULL,0,0,0,1,0,1,'/1/',NULL,1,'begonya@verdnatura.es',1,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (36,'labor','LABORAL',10,11,NULL,0,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (37,'PROD','PRODUCCION',12,35,NULL,72,1,1,1,11,1,'/1/',NULL,0,NULL,0,1,1,1,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (38,'picking','SACADO',15,16,NULL,72,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (39,'packing','ENCAJADO',17,18,NULL,72,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (41,'administration','ADMINISTRACION',36,37,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (43,'VT','VENTAS',38,69,NULL,0,0,0,1,15,1,'/1/',NULL,1,'',1,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (44,'management','GERENCIA',70,71,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (45,'logistic','LOGISTICA',72,73,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (46,'delivery','REPARTO',74,75,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (48,'storage','ALMACENAJE',76,77,NULL,0,1,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (49,NULL,'PROPIEDAD',78,79,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (52,NULL,'CARGA AEREA',80,81,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (53,'marketing','MARKETING Y COMUNICACIÓN',39,40,NULL,72,0,0,2,0,43,'/1/43/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (54,NULL,'ORNAMENTALES',82,83,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (55,NULL,'TALLER NATURAL',19,20,14548,72,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,0,1118,NULL,NULL,NULL);
INSERT INTO `department` VALUES (56,NULL,'TALLER ARTIFICIAL',21,22,8470,72,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,0,1927,NULL,NULL,NULL);
INSERT INTO `department` VALUES (58,'CMP','CAMPOS',84,87,NULL,72,0,0,1,1,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (59,'maintenance','MANTENIMIENTO',88,89,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (60,'claims','RECLAMACIONES',41,42,NULL,72,0,0,2,0,43,'/1/43/',NULL,1,NULL,1,1,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (61,NULL,'VNH',90,93,NULL,73,0,0,1,1,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (66,NULL,'VERDNAMADRID',94,95,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (68,NULL,'COMPLEMENTOS',23,24,NULL,72,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (69,NULL,'VERDNABARNA',96,97,NULL,74,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (80,'vallesTeam','EQUIPO ESPAÑA 5',43,44,4250,72,0,0,2,0,43,'/1/43/','jvp_equipo',1,'equipojvalles@verdnatura.es',0,0,0,0,NULL,NULL,'5300',NULL);
INSERT INTO `department` VALUES (86,NULL,'LIMPIEZA',98,99,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (89,NULL,'COORDINACION',100,101,NULL,0,1,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (90,NULL,'TRAILER',91,92,NULL,0,0,0,2,0,61,'/1/61/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (91,'artificial','ARTIFICIAL',25,26,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (92,NULL,'EQUIPO SILVERIO',45,46,1203,0,0,0,2,0,43,'/1/43/','sdc_equipo',0,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (94,'spainTeam2','EQUIPO ESPAÑA 2',47,48,3797,0,0,0,2,0,43,'/1/43/','es2_equipo',0,'es2@verdnatura.es',0,0,0,0,NULL,NULL,'5100',NULL);
INSERT INTO `department` VALUES (95,'spainTeam1','EQUIPO ESPAÑA 1',49,50,24065,0,0,0,2,0,43,'/1/43/','es1_equipo',0,'es1@verdnatura.es',0,0,0,0,NULL,NULL,'5000',NULL);
INSERT INTO `department` VALUES (96,NULL,'EQUIPO C LOPEZ',51,52,4661,0,0,0,2,0,43,'/1/43/','cla_equipo',0,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (115,NULL,'EQUIPO CLAUDI',53,54,3810,0,0,0,2,0,43,'/1/43/','csr_equipo',0,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (123,NULL,'EQUIPO ELENA BASCUÑANA',55,56,7102,0,0,0,2,0,43,'/1/43/','ebt_equipo',0,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (124,NULL,'CONTROL INTERNO',102,103,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,1,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (125,'miriamMarTeam','EQUIPO ESPAÑA 3',57,58,1118,0,0,0,2,0,43,'/1/43/','mir_equipo',0,'equipomirgir@verdnatura.es',0,0,0,0,NULL,NULL,'5200',NULL);
INSERT INTO `department` VALUES (126,NULL,'PRESERVADO',27,28,NULL,0,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (128,NULL,'PALETIZADO',29,30,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (130,NULL,'REVISION',31,32,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (131,'greenhouse','INVERNADERO',85,86,NULL,0,0,0,2,0,58,'/1/58/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (132,NULL,'EQUIPO DC',59,60,1731,0,0,0,2,0,43,'/1/43/','dc_equipo',1,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (133,'franceTeam','EQUIPO FRANCIA',61,62,1731,72,0,0,2,0,43,'/1/43/','fr_equipo',1,'gestionfrancia@verdnatura.es',0,0,0,0,NULL,NULL,'3300',NULL);
INSERT INTO `department` VALUES (134,'portugalTeam','EQUIPO PORTUGAL',63,64,6264,0,0,0,2,0,43,'/1/43/','pt_equipo',1,'portugal@verdnatura.es',0,0,0,0,NULL,NULL,'3500',NULL);
INSERT INTO `department` VALUES (135,'routers','ENRUTADORES',104,105,NULL,0,0,0,1,0,1,'/1/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (136,'heavyVehicles','VEHICULOS PESADOS',106,107,NULL,0,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (137,'sorter','SORTER',108,109,NULL,0,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (139,'soriaTeam','EQUIPO ESPAÑA 4',65,66,3803,0,0,0,2,0,43,'/1/43/','jss_equipo',1,'equipojsoria@verdnatura.es',0,0,0,0,NULL,NULL,'5400',NULL);
INSERT INTO `department` VALUES (140,'hollandTeam','EQUIPO HOLANDA',67,68,NULL,0,0,0,2,0,43,'/1/43/','nl_equipo',1,NULL,1,0,0,0,NULL,NULL,NULL,NULL);
INSERT INTO `department` VALUES (141,NULL,'PREVIA',33,34,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,NULL);
INSERT INTO `docuware` VALUES (1,'deliveryNote','Albaranes cliente','find','find','N__ALBAR_N',NULL);
INSERT INTO `docuware` VALUES (2,'deliveryNote','Albaranes cliente','store','Archivar','N__ALBAR_N',NULL);
@ -2284,7 +2563,7 @@ INSERT INTO `volumeConfig` VALUES (2.67,1.60,0.8,150,0.30,120,57,2.0,50,200,10,1
INSERT INTO `workCenter` VALUES (1,'Silla',20,859,1,'Av espioca 100',552703,NULL);
INSERT INTO `workCenter` VALUES (2,'Mercaflor',19,NULL,NULL,NULL,NULL,NULL);
INSERT INTO `workCenter` VALUES (3,'Marjales',26,20008,NULL,NULL,NULL,NULL);
INSERT INTO `workCenter` VALUES (4,'VNH',NULL,NULL,NULL,NULL,NULL,NULL);
INSERT INTO `workCenter` VALUES (4,'VNH',NULL,NULL,7,NULL,NULL,NULL);
INSERT INTO `workCenter` VALUES (5,'Madrid',28,2869,5,'Av constitución 3',554145,2.00);
INSERT INTO `workCenter` VALUES (6,'Vilassar',88,88038,NULL,'Cami del Crist, 33',556412,NULL);
INSERT INTO `workCenter` VALUES (7,'Tenerife',NULL,NULL,NULL,NULL,NULL,NULL);
@ -2312,7 +2591,7 @@ USE `cache`;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
INSERT INTO `cache` VALUES (1,'equalizator','00:19:00');
INSERT INTO `cache` VALUES (2,'available','00:06:00');
INSERT INTO `cache` VALUES (2,'available','00:01:00');
INSERT INTO `cache` VALUES (3,'stock','00:30:00');
INSERT INTO `cache` VALUES (4,'last_buy','23:59:00');
INSERT INTO `cache` VALUES (5,'weekly_sales','12:00:00');

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -7,8 +7,12 @@ SET foreign_key_checks = 0;
-- XXX: vn-database
INSERT INTO util.config (environment, mockTime, mockUtcTime, mockEnabled)
VALUES ('local', '2001-01-01 12:00:00', '2001-01-01 11:00:00', TRUE);
INSERT INTO util.config (id, environment, mockTime, mockUtcTime, mockEnabled)
VALUES (1, 'local', '2001-01-01 12:00:00', '2001-01-01 11:00:00', TRUE);
INSERT INTO util.binlogQueue (code,logName, `position`)
VALUES ('mylogger', 'bin.000001', 4);
/* #5483
INSERT INTO vn.entryConfig (defaultEntry, mailToNotify, inventorySupplierFk, maxLockTime, defaultSupplierFk)
VALUES(1, NULL, 1, 300, 1);
@ -66,9 +70,6 @@ UPDATE vn.supplier
SET isTrucker = 1
WHERE id = 2;
INSERT INTO vn.cmr (id, truckPlate, observations, senderInstruccions, paymentInstruccions, specialAgreements, created, companyFk, addressToFk, addressFromFk, supplierFk, packagesList, merchandiseDetail, state, landed, ead)
VALUES (2, NULL, NULL, NULL, 'Carriage paid', NULL, '2022-06-27 13:31:11.000', 442, 3, 2, 2, NULL, NULL, NULL, NULL, NULL);
-- XXX: tpv
UPDATE `vn`.`claimRatio` SET `claimAmount` = '10' WHERE (`clientFk` = '1101');
@ -116,9 +117,6 @@ INSERT INTO vn.ticket (clientFk, warehouseFk, shipped, nickname, refFk, addressF
(100, 4, '2022-07-12 00:00:00', 'root', NULL, 195, NULL, NULL, 0, 0, 0, 0, NULL, 0, '2022-07-12 16:18:58', 1, NULL, 4, NULL, 1, 567, 1, '2022-07-12', 0, 0, 6, NULL, NULL, NULL, NULL, NULL),
(100, 5, '2022-07-12 00:00:00', 'root', NULL, 195, NULL, NULL, 0, 0, 0, 0, NULL, 0, '2022-07-12 16:18:58', 1, NULL, 5, NULL, 1, 567, 1, '2022-07-12', 0, 0, 1, NULL, NULL, NULL, NULL, NULL);
*/
INSERT INTO vn.sector (description,warehouseFk) VALUES
('Sector One',1);
INSERT INTO vn.saleGroup (userFk,parkingFk,sectorFk) VALUES
(100,1,1);
@ -140,9 +138,6 @@ INSERT INTO vn.ticket (clientFk, warehouseFk, shipped, nickname, refFk, addressF
INSERT INTO vn.sale (itemFk, ticketFk, concept, quantity, originalQuantity, price, discount, priceFixed, reserved, isPicked, isPriceFixed, created, isAdded)
VALUES (1, 24, 'Ranged weapon longbow 2m', 1.00, NULL, 8.07, 0, 0.00, 0, 0, 0, '2022-07-06 00:00:00', 0);
*/
INSERT INTO vn2008.zones (zone_id,name,printingOrder)
VALUES (1,'zone Test',1);
-- XXX: lab
INSERT INTO `vn`.`businessReasonEnd` (`id`, `reason`)
@ -151,7 +146,7 @@ INSERT INTO `vn`.`businessReasonEnd` (`id`, `reason`)
('2', 'No supera PP empresa'),
('3', 'Despido');
INSERT INTO `vn2008`.`payroll_categorias` (`codcategoria`, `descripcion`, `Tarifa`)
INSERT INTO `vn`.`payrollCategories` (`id`, `description`, `rate`)
VALUES
('11', 'INFORMATICA', '2'),
('12', 'AUX INFORMATICA', '7');
@ -162,16 +157,6 @@ INSERT INTO `vn`.`occupationCode` (`code`, `name`)
('b', 'Representantes de comercio'),
('c', 'Personal de oficios en trabajos de construcción en general, y en instalac.,edificios y obras');
INSERT INTO `vn2008`.`payroll_employee` (`CodTrabajador`,`nss`,`codpuesto`,`codempresa`,`codcontrato`,`FAntiguedad`,`grupotarifa`,`codcategoria`,`ContratoTemporal`)
VALUES
(36,'46/10515497-58',6,20,189,'2009-01-02',5,10,0),
(43,'46/10235353-50',7,20,189,'2009-04-21',5,10,0),
(76,'46/10250562-30',1,20,189,'2009-09-07',9,5,0),
(1106,'46/10297768-94',4,20,100,'2021-03-09',7,18,0),
(1107,'46/1627085-11',15,20,402,'2021-03-15',9,6,1),
(1108,'46/10446901-41',25,20,502,'2021-03-22',10,29,1),
(1109,'46/10552113-8',3,20,402,'2021-03-23',9,9,1),
(1110,'46/10723579-75',3,20,402,'2021-03-23',9,9,1);
INSERT INTO `vn`.`trainingCourseType` (`id`, `name`)
VALUES

File diff suppressed because it is too large Load Diff

View File

@ -7,7 +7,7 @@ BEGIN
* The user name must only contain lowercase letters or, starting with second
* character, numbers or underscores.
*/
IF vUserName NOT REGEXP '^[a-z0-9_-]*$' THEN
IF vUserName NOT REGEXP BINARY '^[a-z0-9_-]+$' THEN
SIGNAL SQLSTATE '45000'
SET MESSAGE_TEXT = 'INVALID_USER_NAME';
END IF;

View File

@ -1,16 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `bi`.`nz`(vData DOUBLE)
RETURNS double
DETERMINISTIC
BEGIN
/**
* Devuelve 0, si el parámetro es NULL:
*/
DECLARE vResult DOUBLE;
SET vResult = IFNULL(vData,0);
RETURN vResult;
END$$
DELIMITER ;

View File

@ -42,9 +42,9 @@ BEGIN
CREATE TEMPORARY TABLE maxInvoice
(PRIMARY KEY (Id_Cliente))
ENGINE = MEMORY
SELECT DISTINCT Id_Cliente, max(Fecha) as maxFecha
FROM vn2008.Facturas
GROUP BY Id_Cliente
SELECT DISTINCT clientFk Id_Cliente, max(issued) as maxFecha
FROM vn.invoiceOut
GROUP BY clientFk
HAVING maxFecha < timestampadd(month,-2,datFEC);
WHILE datFEC < util.VN_CURDATE() DO
@ -53,10 +53,10 @@ BEGIN
SELECT Id_Cliente, datFEC as Fecha, Greuge, Ventas, 0
FROM (
SELECT Id_Cliente, sum(Importe) as Greuge
FROM vn2008.Greuges
where Fecha <= datFEC
group by Id_Cliente
SELECT clientFk Id_Cliente, sum(amount) as Greuge
FROM vn.greuge
where shipped <= datFEC
group by clientFk
) sub
RIGHT JOIN
@ -91,15 +91,15 @@ BEGIN
-- Recobro
UPDATE bi.Greuge_Evolution ge
JOIN (
SELECT cs.Id_Cliente, sum(Valor * Cantidad) as Importe
FROM vn2008.Tickets t
JOIN vn2008.Consignatarios cs on cs.Id_Consigna = t.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 t.Fecha >= datFEC
AND t.Fecha < datFEC_TOMORROW
AND mc.Id_Componente = 17 -- Recobro
GROUP BY cs.Id_Cliente
SELECT a.clientFk Id_Cliente, sum(sc.value * s.quantity) as Importe
FROM vn.ticket t
JOIN vn.address a on a.id = t.addressFk
JOIN vn.sale s on s.ticketFk = t.id
JOIN vn.saleComponent sc on sc.saleFk = s.id
WHERE t.shipped >= datFEC
AND t.shipped < datFEC_TOMORROW
AND sc.componentFk = 17 -- Recobro
GROUP BY a.clientFk
) sub using(Id_Cliente)
SET Recobro = Importe
WHERE ge.Fecha = datFEC;

View File

@ -24,7 +24,7 @@ BEGIN
WHERE Periodo < vMaxPeriod;
SELECT MIN(period) INTO vCurrentPeriod
FROM vn2008.time
FROM vn.time
WHERE period > vPreviousPeriod;
SET vYear = FLOOR(vCurrentPeriod / 100);
@ -66,7 +66,7 @@ BEGIN
WHERE periodo < vMaxPeriod;
SELECT MIN(period) INTO vCurrentPeriod
FROM vn2008.time
FROM vn.time
WHERE period > vPreviousPeriod;
SET vYear = FLOOR(vCurrentPeriod / 100);
@ -108,7 +108,7 @@ BEGIN
WHERE periodo < vMaxPeriod;
SELECT MIN(period) INTO vCurrentPeriod
FROM vn2008.time
FROM vn.time
WHERE period > vPreviousPeriod;
SET vYear = FLOOR(vCurrentPeriod / 100);
@ -156,7 +156,7 @@ BEGIN
WHERE periodo < vMaxPeriod;
SELECT MIN(period) INTO vCurrentPeriod
FROM vn2008.time
FROM vn.time
WHERE period > vPreviousPeriod;
SET vYear = FLOOR(vCurrentPeriod / 100);
@ -198,7 +198,7 @@ BEGIN
WHERE periodo < vMaxPeriod;
SELECT MIN(period) INTO vCurrentPeriod
FROM vn2008.time
FROM vn.time
WHERE period > vPreviousPeriod;
SET vYear = FLOOR(vCurrentPeriod / 100);

View File

@ -23,31 +23,31 @@ BEGIN
Importe
)
SELECT
tp.Tipo AS Familia,
r.reino AS Reino,
tr.CodigoTrabajador AS Comercial,
tr2.CodigoTrabajador AS Comprador,
p.name AS Provincia,
w.name AS almacen,
tm.year AS Año,
tm.month AS Mes,
tm.week AS Semana,
dm.description AS Vista,
bt.importe AS Importe
it.name,
ic.name,
w.code,
w2.code,
p.name,
wa.name,
tm.year,
tm.month,
tm.week,
dm.description,
bt.importe
FROM bs.ventas bt
LEFT JOIN vn2008.Tipos tp ON tp.tipo_id = bt.tipo_id
LEFT JOIN vn2008.reinos r ON r.id = tp.reino_id
LEFT JOIN vn2008.Clientes c on c.Id_Cliente = bt.Id_Cliente
LEFT JOIN vn2008.Trabajadores tr ON tr.Id_Trabajador = c.Id_Trabajador
LEFT JOIN vn2008.Trabajadores tr2 ON tr2.Id_Trabajador = tp.Id_Trabajador
JOIN vn2008.time tm ON tm.date = bt.fecha
JOIN vn2008.Movimientos m ON m.Id_Movimiento = bt.Id_Movimiento
LEFT JOIN vn2008.Tickets t ON t.Id_Ticket = m.Id_Ticket
JOIN vn2008.Agencias a ON a.Id_Agencia = t.Id_Agencia
LEFT JOIN vn.deliveryMethod dm ON dm.id = a.Vista
LEFT JOIN vn2008.Consignatarios cs ON cs.Id_Consigna = t.Id_Consigna
LEFT JOIN vn2008.province p ON p.province_id = cs.province_id
LEFT JOIN vn.warehouse w ON w.id = t.warehouse_id
WHERE bt.fecha >= vLastMonth AND r.mercancia;
LEFT JOIN vn.itemType it ON it.id = bt.tipo_id
LEFT JOIN vn.itemCategory ic ON ic.id = it.categoryFk
LEFT JOIN vn.client c on c.id = bt.Id_Cliente
LEFT JOIN vn.worker w ON w.id = c.salesPersonFk
LEFT JOIN vn.worker w2 ON w2.id = it.workerFk
JOIN vn.time tm ON tm.dated = bt.fecha
JOIN vn.sale s ON s.id = bt.Id_Movimiento
LEFT JOIN vn.ticket t ON t.id = s.ticketFk
JOIN vn.agencyMode am ON am.id = t.agencyModeFk
LEFT JOIN vn.deliveryMethod dm ON dm.id = am.deliveryMethodFk
LEFT JOIN vn.address a ON a.id = t.addressFk
LEFT JOIN vn.province p ON p.id = a.provinceFk
LEFT JOIN vn.warehouse wa ON wa.id = t.warehouseFk
WHERE bt.fecha >= vLastMonth AND ic.merchandise;
END$$
DELIMITER ;

View File

@ -11,93 +11,92 @@ BEGIN
-- Reclamaciones demasiado sensibles
INSERT INTO vn2008.Greuges(Fecha, Id_Cliente, Comentario,
Importe, Greuges_type_id,Id_Ticket)
SELECT cm.Fecha
, cm.Id_Cliente
, concat('Claim ',cm.id,' : ', m.Concepte)
,round( -1 * ((sensib -1)/4) * Cantidad *
Preu * (100 - Descuento) / 100, 2) AS Reclamaciones
INSERT INTO vn.greuge(shipped, clientFk, description,
amount, greugeTypeFk, ticketFk)
SELECT c.ticketCreated
, c.clientFk
, concat('Claim ', c.id,' : ', s.concept)
,round( -1 * ((c.responsibility -1)/4) * s.quantity *
s.price * (100 - s.discount) / 100, 2)
, 4
, m.Id_Ticket
FROM vn2008.Movimientos m
JOIN vn2008.cl_act ca USING(Id_Movimiento)
JOIN vn2008.cl_main cm ON cm.id = ca.cl_main_id
WHERE ca.cl_sol_id NOT IN (1,5)
AND ca.greuge = 0
AND cm.cl_est_id = 3;
, s.ticketFk
FROM vn.sale s
JOIN vn.claimEnd ce ON ce.saleFk = s.id
JOIN vn.claim c ON c.id = ce.claimFk
WHERE ce.claimDestinationFk NOT IN (1,5)
AND NOT ce.isGreuge
AND c.claimStateFk = 3;
-- Reclamaciones que pasan a Maná
INSERT INTO vn2008.Greuges(Fecha, Id_Cliente, Comentario,
Importe , Greuges_type_id,Id_Ticket)
SELECT cm.Fecha
, cm.Id_Cliente
, concat('Claim_mana ',cm.id,' : ', m.Concepte)
,round( ((sensib -1)/4) * Cantidad * Preu * (100 - Descuento) / 100, 2)
AS Reclamaciones
INSERT INTO vn.greuge(shipped, clientFk, description,
amount, greugeTypeFk, ticketFk)
SELECT c.ticketCreated
, c.clientFk
, concat('Claim_mana ',c.id,' : ', s.concept)
,round( ((c.responsibility -1)/4) * s.quantity * s.price * (100 - s.discount) / 100, 2)
,3
,m.Id_Ticket
FROM vn2008.Movimientos m
JOIN vn2008.cl_act ca USING(Id_Movimiento)
JOIN vn2008.cl_main cm ON cm.id = ca.cl_main_id
WHERE ca.cl_sol_id NOT IN (1,5)
AND ca.greuge = 0
AND cm.cl_est_id = 3
AND cm.mana;
,s.ticketFk
FROM vn.sale s
JOIN vn.claimEnd ce ON ce.saleFk = s.id
JOIN vn.claim c ON c.id = ce.claimFk
WHERE ce.claimDestinationFk NOT IN (1,5)
AND NOT ce.isGreuge
AND c.claimStateFk = 3
AND c.isChargedToMana;
-- Marcamos para no repetir
UPDATE vn2008.cl_act ca
JOIN vn2008.cl_main cm ON cm.id = ca.cl_main_id
SET greuge = 1
WHERE ca.cl_sol_id NOT IN (1,5)
AND ca.greuge = 0
AND cm.cl_est_id = 3;
UPDATE vn.claimEnd ce
JOIN vn.claim c ON c.id = ce.claimFk
SET c.isChargedToMana = TRUE
WHERE ce.claimDestinationFk NOT IN (1,5)
AND NOT ce.isGreuge
AND c.claimStateFk = 3;
-- Recobros
DROP TEMPORARY TABLE IF EXISTS tmp.ticket_list;
CREATE TEMPORARY TABLE tmp.ticket_list
(PRIMARY KEY (Id_Ticket))
SELECT DISTINCT t.Id_Ticket
FROM vn2008.Movimientos_componentes mc
JOIN vn2008.Movimientos m ON mc.Id_Movimiento = m.Id_Movimiento
JOIN vn2008.Tickets t ON t.Id_Ticket = m.Id_Ticket
JOIN vn2008.Tickets_state ts ON ts.Id_Ticket = t.Id_Ticket
JOIN vn.ticketTracking tt ON tt.id = ts.inter_id
JOIN vn2008.state s ON s.id = tt.stateFk
WHERE mc.Id_Componente = 17
AND mc.greuge = 0
AND t.Fecha >= '2016-10-01'
AND t.Fecha < util.VN_CURDATE()
AND s.alert_level >= 3;
SELECT DISTINCT t.id Id_Ticket
FROM vn.saleComponent sc
JOIN vn.sale s ON sc.saleFk = s.id
JOIN vn.ticket t ON t.id = s.ticketFk
JOIN vn.ticketLastState ts ON ts.ticketFk = t.id
JOIN vn.ticketTracking tt ON tt.id = ts.ticketTrackingFk
JOIN vn.state st ON st.id = tt.stateFk
WHERE sc.componentFk = 17
AND sc.isGreuge = 0
AND t.shipped >= '2016-10-01'
AND t.shipped < util.VN_CURDATE()
AND st.alertLevel >= 3;
DELETE g.*
FROM vn2008.Greuges g
JOIN tmp.ticket_list t ON g.Id_Ticket = t.Id_Ticket
WHERE Greuges_type_id = 2;
FROM vn.greuge g
JOIN tmp.ticket_list t ON g.ticketFk = t.Id_Ticket
WHERE g.greugeTypeFk = 2;
INSERT INTO vn2008.Greuges (Id_Cliente,Comentario,Importe,Fecha,
Greuges_type_id, Id_Ticket)
SELECT Id_Cliente
,concat('recobro ', m.Id_Ticket), - round(SUM(mc.Valor*Cantidad),2)
AS dif
,date(t.Fecha)
INSERT INTO vn.greuge(clientFk, description, amount,shipped,
greugeTypeFk, ticketFk)
SELECT t.clientFk
,concat('recobro ', s.ticketFk), - round(SUM(sc.value*s.quantity),2)
AS dif,
date(t.shipped)
, 2
,tt.Id_Ticket
FROM vn2008.Movimientos m
JOIN vn2008.Tickets t ON t.Id_Ticket = m.Id_Ticket
JOIN tmp.ticket_list tt ON tt.Id_Ticket = t.Id_Ticket
JOIN vn2008.Movimientos_componentes mc
ON mc.Id_Movimiento = m.Id_Movimiento AND mc.Id_Componente = 17
GROUP BY t.Id_Ticket
FROM vn.sale s
JOIN vn.ticket t ON t.id = s.ticketFk
JOIN tmp.ticket_list tt ON tt.Id_Ticket = t.id
JOIN vn.saleComponent sc
ON sc.saleFk = s.id AND sc.componentFk = 17
GROUP BY t.id
HAVING ABS(dif) > 1;
UPDATE vn2008.Movimientos_componentes mc
JOIN vn2008.Movimientos m ON m.Id_Movimiento = mc.Id_Movimiento
JOIN tmp.ticket_list tt ON tt.Id_Ticket = m.Id_Ticket
SET greuge = 1
WHERE Id_Componente = 17;
UPDATE vn.saleComponent sc
JOIN vn.sale s ON s.id = sc.saleFk
JOIN tmp.ticket_list tt ON tt.Id_Ticket = s.ticketFk
SET sc.isGreuge = 1
WHERE sc.componentFk = 17;
/*
* Recalculamos la ratio de las reclamaciones, que luego
@ -105,38 +104,37 @@ BEGIN
*/
REPLACE bi.claims_ratio(Id_Cliente, Consumo, Reclamaciones, Ratio, recobro)
SELECT Id_Cliente, 0,0,0,0
FROM vn2008.Clientes;
SELECT id, 0,0,0,0
FROM vn.client;
REPLACE bi.claims_ratio(Id_Cliente, Consumo, Reclamaciones, Ratio, recobro)
SELECT fm.Id_Cliente, 12 * fm.Consumo, Reclamaciones,
round(Reclamaciones / (12*fm.Consumo),4) AS Ratio, 0
round(Reclamaciones / (12*fm.Consumo),4), 0
FROM bi.facturacion_media_anual fm
LEFT JOIN(
SELECT cm.Id_Cliente, round(sum(-1 * ((sensib -1)/4) *
Cantidad * Preu * (100 - Descuento) / 100))
SELECT c.clientFk, round(sum(-1 * ((c.responsibility -1)/4) *
s.quantity * s.price * (100 - s.discount) / 100))
AS Reclamaciones
FROM vn2008.Movimientos m
JOIN vn2008.cl_act ca
ON ca.Id_Movimiento = m.Id_Movimiento
JOIN vn2008.cl_main cm ON cm.id = ca.cl_main_id
WHERE ca.cl_sol_id NOT IN (1,5)
AND cm.cl_est_id = 3
AND cm.Fecha >= TIMESTAMPADD(YEAR, -1, util.VN_CURDATE())
GROUP BY cm.Id_Cliente
) claims ON claims.Id_Cliente = fm.Id_Cliente;
FROM vn.sale s
JOIN vn.claimEnd ce ON ce.saleFk = s.id
JOIN vn.claim c ON c.id = ce.claimFk
WHERE ce.claimDestinationFk NOT IN (1,5)
AND c.claimStateFk = 3
AND c.ticketCreated >= TIMESTAMPADD(YEAR, -1, util.VN_CURDATE())
GROUP BY c.clientFk
) claims ON claims.clientFk = fm.Id_Cliente;
-- Calculamos el porcentaje del recobro para añadirlo al precio de venta
UPDATE bi.claims_ratio cr
JOIN (
SELECT Id_Cliente, nz(SUM(Importe)) AS Greuge
FROM vn2008.Greuges
WHERE Fecha <= util.VN_CURDATE()
GROUP BY Id_Cliente
SELECT clientFk Id_Cliente, IFNULL(SUM(amount), 0) AS Greuge
FROM vn.greuge
WHERE shipped <= util.VN_CURDATE()
GROUP BY clientFk
) g ON g.Id_Cliente = cr.Id_Cliente
SET recobro = GREATEST(0,round(nz(Greuge) /
(nz(Consumo) * vMonthToRefund / 12 ) ,3));
SET recobro = GREATEST(0,round(IFNULL(Greuge, 0) /
(IFNULL(Consumo, 0) * vMonthToRefund / 12 ) ,3));
-- Protección neonatos
UPDATE bi.claims_ratio cr

View File

@ -1,9 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bi`.`clean_launcher`()
BEGIN
/**
* Borra registros de las principales tablas (excepto de "ticket").
*/
CALL vn2008.clean(0);
END$$
DELIMITER ;

View File

@ -1,32 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bi`.`comparativa_add`()
BEGIN
DECLARE lastCOMP INT; # Se trata de una variable para almacenar el ultimo valor del Periodo
DECLARE vMaxPeriod INT;
DECLARE vMaxWeek INT;
SELECT t.period, t.`week` INTO vMaxPeriod, vMaxWeek
FROM vn.`time` t
WHERE t.dated = util.VN_CURDATE();
SELECT MAX(Periodo) INTO lastCOMP FROM vn2008.Comparativa;
-- Fijaremos las ventas con más de un mes de antiguedad en la tabla Comparativa
IF lastCOMP < vMaxPeriod - 3 AND vMaxWeek > 3 THEN
REPLACE vn2008.Comparativa(Periodo, Id_Article, warehouse_id, Cantidad,price)
SELECT tm.period as Periodo, m.Id_Article, t.warehouse_id, sum(m.Cantidad), sum(v.importe)
FROM bs.ventas v
JOIN vn2008.time tm ON tm.date = v.fecha
JOIN vn2008.Movimientos m ON m.Id_Movimiento = v.Id_Movimiento
JOIN vn2008.Tipos tp ON tp.tipo_id = v.tipo_id
JOIN vn2008.reinos r ON r.id = tp.reino_id
JOIN vn2008.Tickets t ON t.Id_Ticket = m.Id_Ticket
WHERE tm.period BETWEEN lastCOMP AND vMaxPeriod - 3
AND t.Id_Cliente NOT IN(400,200)
AND t.warehouse_id NOT IN (0,13)
GROUP BY m.Id_Article, Periodo, t.warehouse_id;
END IF;
END$$
DELIMITER ;

View File

@ -1,40 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bi`.`comparativa_add_manual`(IN vStarted DATE, IN vEnded DATE)
BEGIN
/**
* Recalcula la tabla Comparativa para dos valores dados
*
* @param vStarted fecha desde
* @param vEnded fecha hasta
*/
DECLARE periodStart INT;
DECLARE periodEnd INT;
-- Seleccionamos la fecha minima/maxima del periodo que vamos a consultar
SELECT t.period INTO periodStart
FROM vn.`time` t
WHERE t.dated = vStarted;
SELECT t.period INTO periodEnd
FROM vn.`time` t
WHERE t.dated = vEnded;
DELETE FROM vn2008.Comparativa
WHERE Periodo BETWEEN periodStart AND periodEnd;
INSERT INTO vn2008.Comparativa(Periodo, Id_Article, warehouse_id, Cantidad,price)
SELECT tm.period as Periodo, m.Id_Article, t.warehouse_id, sum(m.Cantidad), sum(v.importe)
FROM bs.ventas v
JOIN vn2008.time tm ON tm.date = v.fecha
JOIN vn2008.Movimientos m ON m.Id_Movimiento = v.Id_Movimiento
JOIN vn2008.Tipos tp ON tp.tipo_id = v.tipo_id
JOIN vn2008.reinos r ON r.id = tp.reino_id
JOIN vn2008.Tickets t ON t.Id_Ticket = m.Id_Ticket
WHERE tm.period BETWEEN periodStart AND periodEnd
AND t.Id_Cliente NOT IN(400,200)
AND t.warehouse_id NOT IN (0,13)
GROUP BY m.Id_Article, Periodo, t.warehouse_id;
END$$
DELIMITER ;

View File

@ -2,7 +2,7 @@ DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bi`.`defaultersFromDate`(IN vDate DATE)
BEGIN
SELECT t1.*, c.Cliente, w.code AS workerCode, c.pay_met_id,c.Vencimiento
SELECT t1.*, c.name Cliente, w.code workerCode, c.payMethodFk pay_met_id, c.dueDay Vencimiento
FROM (
-- Filtramos aquellos clientes cuyo saldo se ha incrementado de ayer a hoy
select * from(
@ -18,7 +18,7 @@ BEGIN
having today.amount > 0 and difference <> 0
) newDefaulters
)t1 left join vn2008.Clientes c ON t1.client = c.Id_Cliente
left join vn.worker w ON w.id = c.Id_Trabajador;
)t1 left join vn.client c ON c.id = t1.client
left join vn.worker w ON w.id = c.salesPersonFk;
END$$
DELIMITER ;

View File

@ -8,14 +8,15 @@ BEGIN
DECLARE vAmountInvoice DECIMAL(10,2);
DECLARE vGraceDays INT;
DECLARE defaulters CURSOR FOR
SELECT client, amount, graceDays FROM bi.defaulters d
JOIN vn2008.Clientes c ON c.Id_Cliente = d.client
JOIN vn2008.pay_met pm ON pm.id = c.pay_met_id
SELECT d.client, d.amount, pm.graceDays
FROM bi.defaulters d
JOIN vn.client c ON c.id = d.client
JOIN vn.payMethod pm ON pm.id = c.payMethodFk
WHERE hasChanged AND date = vDate;
DECLARE invoices CURSOR FOR
SELECT Vencimiento, importe FROM vn2008.Facturas f
WHERE f.Fecha >= '2016-01-01' AND f.Id_Cliente = vClient ORDER BY f.Fecha DESC;
SELECT dued Vencimiento, amount importe FROM vn.invoiceOut
WHERE issued >= '2016-01-01' AND clientFk = vClient ORDER BY issued DESC;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;

View File

@ -1,8 +1,19 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bi`.`greuge_dif_porte_add`()
BEGIN
DECLARE datSTART DATETIME DEFAULT TIMESTAMPADD(DAY,-60,util.VN_CURDATE()); -- '2019-07-01'
DECLARE datEND DATETIME DEFAULT TIMESTAMPADD(DAY,-1,util.VN_CURDATE());
/**
* Calculates the greuge based on a specific date in the 'grievanceConfig' table
*/
DECLARE vDateStarted DATETIME;
DECLARE vDateEnded DATETIME DEFAULT (util.VN_CURDATE() - INTERVAL 1 DAY);
DECLARE vDaysAgoOffset INT;
SELECT daysAgoOffset INTO vDaysAgoOffset
FROM vn.greugeConfig;
SET vDateStarted = util.VN_CURDATE() - INTERVAL vDaysAgoOffset DAY;
DROP TEMPORARY TABLE IF EXISTS tmp.dp;
@ -11,35 +22,34 @@ BEGIN
(PRIMARY KEY (ticketFk))
ENGINE = MEMORY
SELECT t.id ticketFk,
SUM((t.zonePrice - t.zoneBonus) * ebv.ratio) AS teorico,
00000.00 as practico,
00000.00 as greuge,
SUM((t.zonePrice - t.zoneBonus) * ebv.ratio) teorico,
00000.00 practico,
00000.00 greuge,
t.clientFk,
t.shipped
FROM
vn.ticket t
JOIN vn2008.Clientes cli ON cli.Id_cliente = t.clientFk
LEFT JOIN vn2008.expeditions e ON e.ticket_id = t.id
JOIN vn.expeditionBoxVol ebv ON ebv.boxFk = e.EsBulto
FROM vn.ticket t
JOIN vn.client c ON c.id = t.clientFk
LEFT JOIN vn.expedition e ON e.ticketFk = t.id
JOIN vn.expeditionBoxVol ebv ON ebv.boxFk = e.freightItemFk
JOIN vn.zone z ON t.zoneFk = z.id
WHERE
t.shipped between datSTART AND datEND
AND cli.`real`
AND t.companyFk IN (442 , 567)
AND z.isVolumetric = FALSE
JOIN vn.company cp ON cp.id = t.companyFk
WHERE t.shipped BETWEEN vDateStarted AND vDateEnded
AND c.isRelevant
AND cp.code IN ('VNL', 'VNH')
AND NOT z.isVolumetric
GROUP BY t.id;
-- Agencias que cobran por volumen
INSERT INTO tmp.dp
SELECT sv.ticketFk,
SUM(IFNULL(sv.freight,0)) AS teorico,
00000.00 as practico,
00000.00 as greuge,
SUM(IFNULL(sv.freight,0)) teorico,
00000.00 practico,
00000.00 greuge,
sv.clientFk,
sv.shipped
FROM vn.saleVolume sv
JOIN vn.zone z ON z.id = sv.zoneFk
AND sv.shipped BETWEEN datSTART AND datEND
AND sv.shipped BETWEEN vDateStarted AND vDateEnded
AND z.isVolumetric != FALSE
GROUP BY sv.ticketFk;
@ -48,11 +58,12 @@ BEGIN
CREATE TEMPORARY TABLE tmp.dp_aux
(PRIMARY KEY (ticketFk))
ENGINE = MEMORY
SELECT dp.ticketFk, sum(Cantidad * Valor) as valor
SELECT dp.ticketFk, SUM(s.quantity * sc.value) valor
FROM tmp.dp
JOIN vn2008.Movimientos m ON m.Id_Ticket = dp.ticketFk
JOIN vn2008.Movimientos_componentes mc using(Id_Movimiento)
WHERE mc.Id_Componente = 15
JOIN vn.sale s ON s.ticketFk = dp.ticketFk
JOIN vn.saleComponent sc ON sc.saleFk = s.id
JOIN vn.component c ON c.id = sc.componentFk
WHERE c.code = 'delivery'
GROUP BY dp.ticketFk;
UPDATE tmp.dp
@ -64,23 +75,24 @@ BEGIN
CREATE TEMPORARY TABLE tmp.dp_aux
(PRIMARY KEY (ticketFk))
ENGINE = MEMORY
SELECT dp.ticketFk, sum(Importe) Importe
SELECT dp.ticketFk, SUM(g.amount) Importe
FROM tmp.dp
JOIN vn2008.Greuges g ON g.Id_Ticket = dp.ticketFk
WHERE Greuges_type_id = 1 -- dif_porte
JOIN vn.greuge g ON g.ticketFk = dp.ticketFk
JOIN vn.greugeType gt ON gt.id = g.greugeTypeFk
WHERE gt.code = 'freightDifference' -- dif_porte
GROUP BY dp.ticketFk;
UPDATE tmp.dp
JOIN tmp.dp_aux USING(ticketFk)
SET greuge = IFNULL(Importe,0);
INSERT INTO vn2008.Greuges (Id_Cliente,Comentario,Importe,Fecha, Greuges_type_id, Id_Ticket)
SELECT dp.clientFk
, concat('dif_porte ', dp.ticketFk)
, round(IFNULL(dp.teorico,0) - IFNULL(dp.practico,0) - IFNULL(dp.greuge,0),2) as Importe
, date(dp.shipped)
, 1
,dp.ticketFk
INSERT INTO vn.greuge (clientFk,description,amount,shipped,greugeTypeFk,ticketFk)
SELECT dp.clientFk,
CONCAT('dif_porte ', dp.ticketFk),
ROUND(IFNULL(dp.teorico,0) - IFNULL(dp.practico,0) - IFNULL(dp.greuge,0),2) Importe,
date(dp.shipped),
1,
dp.ticketFk
FROM tmp.dp
JOIN vn.client c ON c.id = dp.clientFk
WHERE ABS(IFNULL(dp.teorico,0) - IFNULL(dp.practico,0) - IFNULL(dp.greuge,0)) > 1

View File

@ -1,7 +1,7 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bi`.`rutasAnalyze`(
vYear INT,
vMonth INT
vDatedFrom DATE,
vDatedTo DATE
)
BEGIN
/**
@ -9,8 +9,7 @@ BEGIN
* y lo almacena en la tabla bi.rutasBoard
*/
DELETE FROM rutasBoard
WHERE YEAR(Fecha) = vYear
AND MONTH(Fecha) = vMonth;
WHERE Fecha BETWEEN vDatedFrom AND vDatedTo;
-- Rellenamos la tabla con los datos de las rutas VOLUMETRICAS, especialmente con los bultos "virtuales"
INSERT INTO rutasBoard(
@ -27,7 +26,7 @@ BEGIN
LEFT JOIN vn.`zone` z ON z.id = t.zoneFk
JOIN vn.saleVolume sv ON sv.ticketFk = t.id
JOIN vn.expeditionBoxVol ebv ON ebv.code = 'transportBox'
WHERE YEAR(r.created) = vYear AND MONTH(r.created) = vMonth
WHERE r.created BETWEEN vDatedFrom AND vDatedTo
AND z.isVolumetric
GROUP BY r.id;
@ -44,8 +43,7 @@ BEGIN
FROM vn.route r
JOIN vn.ticket t ON t.routeFk = r.id
LEFT JOIN vn.`zone` z ON z.id = t.zoneFk
WHERE YEAR(r.created) = vYear
AND MONTH(r.created) = vMonth
WHERE r.created BETWEEN vDatedFrom AND vDatedTo
AND NOT z.isVolumetric
GROUP BY r.id
ON DUPLICATE KEY UPDATE Bultos = Bultos + VALUES(Bultos);
@ -56,15 +54,13 @@ BEGIN
SELECT t.routeFk,
SUM(s.quantity * sc.value) totalPractice
FROM vn.route r
JOIN vn.`time` tm ON tm.dated = r.created
JOIN vn.ticket t ON t.routeFk = r.id
JOIN vn.sale s ON s.ticketFk = t.id
JOIN vn.saleComponent sc ON sc.saleFk = s.id
JOIN vn.component c ON c.id = sc.componentFk
JOIN vn.componentType ct ON ct.id = c.typeFk
WHERE ct.code = 'FREIGHT'
AND tm.`year` = vYear
AND tm.`month` = vMonth
AND r.created BETWEEN vDatedFrom AND vDatedTo
GROUP BY r.id
) sub ON sub.routeFk = r.Id_Ruta
SET r.practico = IFNULL(sub.totalPractice / r.Bultos, 0);
@ -76,14 +72,12 @@ BEGIN
SUM(t.zonePrice/ ebv.ratio) / COUNT(*) averageTheoreticalVolume
FROM vn.ticket t
JOIN vn.route r ON r.id = t.routeFk
JOIN vn.`time` tm ON tm.dated = r.created
JOIN vn.expedition e ON e.ticketFk = t.id
JOIN vn.expeditionBoxVol ebv ON ebv.boxFk = e.freightItemFk
JOIN vn.address ad ON ad.id = t.addressFk
JOIN vn.client c ON c.id = ad.clientFk
LEFT JOIN vn.`zone` z ON z.id = t.zoneFk
WHERE tm.`year` = vYear
AND tm.`month` = vMonth
WHERE r.created BETWEEN vDatedFrom AND vDatedTo
AND NOT z.isVolumetric
GROUP BY t.routeFk
) sub ON r.Id_Ruta = sub.routeFk
@ -96,12 +90,10 @@ BEGIN
SUM(freight) averageTheoreticalVolume
FROM vn.ticket t
JOIN vn.route r ON r.id = t.routeFk
JOIN vn.`time` tm ON tm.dated = r.created
JOIN vn.saleVolume sf ON sf.ticketFk = t.id
JOIN vn.client c ON c.id = t.clientFk
JOIN vn.`zone` z ON z.id = t.zoneFk
WHERE tm.`year` = vYear
AND tm.`month` = vMonth
WHERE r.created BETWEEN vDatedFrom AND vDatedTo
AND z.isVolumetric
GROUP BY t.routeFk
) sub ON r.Id_Ruta = sub.routeFk
@ -114,11 +106,9 @@ BEGIN
SUM(g.amount) greuge
FROM vn.ticket t
JOIN vn.route r ON r.id = t.routeFk
JOIN vn.`time` tm ON tm.dated = r.created
JOIN vn.greuge g ON g.ticketFk = t.id
JOIN vn.greugeType gt ON gt.id = g.greugeTypeFk
WHERE tm.`year` = vYear
AND tm.`month` = vMonth
WHERE r.created BETWEEN vDatedFrom AND vDatedTo
AND gt.code = 'freightDifference'
GROUP BY t.routeFk
) sub ON r.Id_Ruta = sub.routeFk

View File

@ -4,6 +4,6 @@ BEGIN
/**
* Call rutasAnalyze
*/
CALL rutasAnalyze(YEAR(util.VN_CURDATE()), MONTH(util.VN_CURDATE()));
CALL rutasAnalyze(util.VN_CURDATE() - INTERVAL 30 DAY , util.VN_CURDATE());
END$$
DELIMITER ;

View File

@ -1,19 +0,0 @@
CREATE OR REPLACE DEFINER=`root`@`localhost`
SQL SECURITY DEFINER
VIEW `bi`.`last_Id_Cubo`
AS SELECT `C`.`Id_Compra` AS `Id_Compra`,
`C`.`Id_Article` AS `Id_Article`,
`tr`.`warehouse_id` AS `warehouse_id`,
`C`.`Id_Cubo` AS `Id_Cubo`,
`C`.`Packing` AS `Packing`
FROM (
(
`vn2008`.`Compres` `C`
JOIN `vn2008`.`Entradas` `E` ON(`C`.`Id_Entrada` = `E`.`Id_Entrada`)
)
JOIN `vn2008`.`travel` `tr` ON(`E`.`travel_id` = `tr`.`id`)
)
WHERE `C`.`Id_Cubo` IS NOT NULL
AND `C`.`Id_Cubo` <> '--'
AND `tr`.`landing` > `util`.`VN_CURDATE`() - INTERVAL 18 MONTH
ORDER BY `C`.`Id_Compra` DESC

View File

@ -1,21 +0,0 @@
CREATE OR REPLACE DEFINER=`root`@`localhost`
SQL SECURITY DEFINER
VIEW `bi`.`v_clientes_jerarquia`
AS SELECT `c`.`id_cliente` AS `Id_Cliente`,
`c`.`cliente` AS `Cliente`,
`t`.`CodigoTrabajador` AS `Comercial`,
`tj`.`CodigoTrabajador` AS `Jefe`
FROM (
(
(
`vn2008`.`Clientes` `c`
JOIN `vn2008`.`Trabajadores` `t` ON(`t`.`Id_Trabajador` = `c`.`Id_Trabajador`)
)
JOIN `vn2008`.`jerarquia` ON(
`vn2008`.`jerarquia`.`worker_id` = `c`.`Id_Trabajador`
)
)
JOIN `vn2008`.`Trabajadores` `tj` ON(
`tj`.`Id_Trabajador` = `vn2008`.`jerarquia`.`boss_id`
)
)

View File

@ -1,23 +0,0 @@
CREATE OR REPLACE DEFINER=`root`@`localhost`
SQL SECURITY DEFINER
VIEW `bi`.`v_ventas_contables`
AS SELECT `time`.`year` AS `year`,
`time`.`month` AS `month`,
cast(
sum(
`m`.`Cantidad` * `m`.`Preu` * (100 - `m`.`Descuento`) / 100
) AS decimal(10, 0)
) AS `importe`
FROM (
(
(
`vn2008`.`Tickets` `t`
JOIN `bi`.`f_tvc` ON(`t`.`Id_Ticket` = `bi`.`f_tvc`.`Id_Ticket`)
)
JOIN `vn2008`.`Movimientos` `m` ON(`t`.`Id_Ticket` = `m`.`Id_Ticket`)
)
JOIN `vn2008`.`time` ON(`time`.`date` = cast(`t`.`Fecha` AS date))
)
WHERE `t`.`Fecha` >= '2014-01-01'
GROUP BY `time`.`year`,
`time`.`month`

View File

@ -1,112 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`bancos_evolution_add`(vStartingDate DATE)
BEGIN
/**
* Inserta en la tabla bancos_evolution los saldos acumulados de cada banco
*
* @param vStartingDate Fecha desde la cual se recalculan la tabla bs.bancos_evolution
*/
DECLARE vCurrentDate DATE;
DECLARE vMaxDate DATE DEFAULT TIMESTAMPADD(MONTH, 7, util.VN_CURDATE());
IF IFNULL(vStartingDate,0) < TIMESTAMPADD(YEAR, -5, util.VN_CURDATE()) THEN
CALL util.throw('invalid date');
END IF;
DELETE FROM bs.bancos_evolution WHERE Fecha >= vStartingDate;
SET vCurrentDate = vStartingDate;
INSERT INTO bs.bancos_evolution(Fecha, Id_Banco, saldo)
SELECT vCurrentDate, Id_Banco, deuda
FROM bs.bancos_evolution
WHERE Fecha = TIMESTAMPADD(DAY,-1,vCurrentDate);
WHILE vCurrentDate < vMaxDate DO
-- insertar solo el dia de ayer
INSERT INTO bs.bancos_evolution(Fecha ,Id_Banco, saldo)
SELECT vCurrentDate, Id_Banco, SUM(saldo)
FROM (
SELECT Id_Banco ,saldo
FROM bs.bancos_evolution
WHERE Fecha = TIMESTAMPADD(DAY,-1,vCurrentDate) -- los saldos acumulados del dia anterior
UNION ALL
SELECT c.Id_Banco, IFNULL(SUM(Entrada),0) - IFNULL(SUM(Salida),0) as saldo
FROM vn2008.Cajas c
JOIN vn2008.Bancos b using(Id_Banco) -- saldos de las cajas
JOIN vn.accountingType at2 ON at2.id = b.cash
WHERE at2.code IN ('wireTransfer','fundingLine')
AND Cajafecha = vCurrentDate
AND (Serie = 'MB' OR at2.code = 'fundingLine')
GROUP BY Id_Banco
)sub
GROUP BY Id_Banco
ON DUPLICATE KEY UPDATE saldo = saldo + VALUES(saldo);
SET vCurrentDate = TIMESTAMPADD(DAY,1,vCurrentDate);
END WHILE;
-- Ahora actualizamos la quilla
UPDATE bs.bancos_evolution be
JOIN
(
SELECT bp.Id_Banco, - sum(bp.importe) as quilla, t.dated
FROM vn.time t
JOIN vn2008.Bancos_poliza bp ON t.dated between apertura AND IFNULL(cierre, t.dated)
WHERE t.dated BETWEEN vStartingDate AND vMaxDate
GROUP BY Id_Banco, t.dated
) sub ON be.Id_Banco = sub.Id_Banco AND sub.dated = be.Fecha
SET be.quilla = sub.quilla;
-- pagos futuros no concilidados
INSERT INTO bs.bancos_evolution(Fecha, Id_Banco, saldo)
SELECT t.dated, p.id_banco, - importe
FROM vn.time t
join vn2008.pago p ON p.fecha <= t.dated
WHERE t.dated BETWEEN util.VN_CURDATE() AND vMaxDate
AND p.fecha BETWEEN util.VN_CURDATE() AND vMaxDate
AND NOT conciliado
ON DUPLICATE KEY UPDATE saldo = saldo + VALUES(saldo);
-- cobros futuros
INSERT INTO bs.bancos_evolution(Fecha, Id_Banco, saldo)
SELECT t.dated, r.Id_Banco, SUM(Entregado)
FROM vn.time t
JOIN vn2008.Recibos r ON r.Fechacobro <= t.dated
WHERE r.Fechacobro > util.VN_CURDATE() AND r.Fechacobro <= vMaxDate
AND t.dated BETWEEN util.VN_CURDATE() AND vMaxDate
GROUP BY t.dated, r.Id_Banco
ON DUPLICATE KEY UPDATE saldo = saldo + VALUES(saldo);
-- saldos de la tabla prevision
INSERT INTO bs.bancos_evolution(Fecha, Id_Banco, saldo)
SELECT t.dated, sp.Id_Banco, SUM(Importe)
FROM vn.time t
JOIN vn2008.Saldos_Prevision sp ON sp.Fecha <= t.dated
JOIN vn2008.Bancos b ON sp.Id_Banco = b.Id_Banco
JOIN vn.accountingType at2 ON at2.id = b.cash
WHERE at2.code IN ('wireTransfer','fundingLine')
AND t.dated BETWEEN vStartingDate AND vMaxDate
GROUP BY t.dated, sp.Id_Banco
ON DUPLICATE KEY UPDATE saldo = saldo + VALUES(saldo);
-- Utilizamos el saldo_auxiliar para calcular lo dispuesto en las polizas
UPDATE bs.bancos_evolution be
SET saldo_aux = saldo
WHERE Fecha >= vStartingDate;
-- Deuda
UPDATE bs.bancos_evolution be
JOIN vn2008.Bancos b using(Id_Banco)
JOIN vn.accountingType at2 ON at2.id = b.cash
SET be.deuda = IF(at2.code = 'fundingLine', be.saldo_aux, 0)
, be.saldo = IF(at2.code = 'fundingLine', 0, be.saldo_aux)
WHERE Fecha >= vStartingDate;
-- Liquidez
update bs.bancos_evolution set liquidez = saldo - quilla + deuda WHERE Fecha >= vStartingDate;
-- Disponibilidad
update bs.bancos_evolution set `disponibilidad ajena` = - quilla + deuda WHERE Fecha >= vStartingDate;
END$$
DELIMITER ;

View File

@ -1,111 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`comercialesCompleto`(IN vWorker INT, vDate DATE)
BEGIN
DECLARE vAYearAgoStarted DATE DEFAULT DATE_FORMAT(TIMESTAMPADD(YEAR, - 1, vDate), '%Y-%m-01');
DECLARE vAYearAgoEnded DATE DEFAULT TIMESTAMPADD(YEAR, - 1, LAST_DAY(vDate));
CALL vn.worker_GetHierarchy(vWorker);
INSERT IGNORE INTO tmp.workerHierarchyList (workerFk)
SELECT wd2.workerFk
FROM vn.workerDepartment wd2
WHERE wd2.workerFk = vWorker;
-- Falta que en algunos casos solo tenga en cuenta los tipos afectados.
SELECT
c.Id_Cliente id_cliente,
c.Cliente cliente,
cr.recobro * 100 tarifa,
c.Telefono telefono,
c.movil,
c.POBLACION poblacion,
p.`name` provincia,
ROUND(f.futur, 2) futur,
c.Credito credito,
pm.`name` forma_pago,
ROUND(c365 / 12, 2) consumo_medio365,
ROUND(c365, 2) consumo365,
ROUND(CmLy.peso, 2) peso_mes_año_pasado,
ROUND(CmLy.peso * 1.19, 2) objetivo,
tr.CodigoTrabajador,
ROUND(mes_actual.consumo, 2) consumoMes,
ROUND(IFNULL(mes_actual.consumo, 0) - IFNULL(CmLy.peso * 1.19, 0), 2) como_lo_llevo,
DATE(LastTicket) ultimo_ticket,
dead.muerto,
g.Greuge,
cr.recobro
FROM
vn2008.Clientes c
LEFT JOIN
(SELECT g.Id_Cliente, CAST( SUM(Importe) as DECIMAL(12,2)) AS Greuge
FROM vn2008.Greuges g
JOIN vn.`client` c ON c.id = g.Id_Cliente
LEFT JOIN vn.worker w ON c.salesPersonFk = w.id
WHERE (c.salesPersonFk = vWorker OR w.bossFk = vWorker)
GROUP BY Id_Cliente
) g ON g.Id_Cliente = c.Id_Cliente
LEFT JOIN
vn2008.province p ON p.province_id = c.province_id
JOIN
vn2008.pay_met pm ON pm.id = c.pay_met_id
LEFT JOIN
vn2008.Trabajadores tr ON c.Id_Trabajador = tr.Id_Trabajador
LEFT JOIN
bi.claims_ratio cr on cr.Id_Cliente = c.Id_Cliente
LEFT JOIN
(SELECT v.Id_Cliente, SUM(importe) c365 -- optimizat de 6s /5.3s/ 4.7s a 0.3/0.4/0.3
FROM bs.ventas v
JOIN vn2008.Clientes c ON c.Id_Cliente = v.Id_Cliente
WHERE v.fecha BETWEEN TIMESTAMPADD(YEAR, - 1, vDate) AND vDate
GROUP BY v.Id_Cliente) c365 ON c365.Id_Cliente = c.Id_Cliente
LEFT JOIN
(SELECT
Id_Cliente, SUM(importe) consumo
FROM
bs.ventas v
INNER JOIN vn2008.Clientes c USING (Id_Cliente)
LEFT JOIN vn2008.Trabajadores tr ON c.Id_Trabajador = tr.Id_Trabajador
WHERE
(c.Id_Trabajador = vWorker OR tr.boss = vWorker)
AND (v.fecha BETWEEN TIMESTAMPADD(DAY, - DAY(vDate) + 1, vDate) AND TIMESTAMPADD(DAY, - 1, vDate))
GROUP BY Id_Cliente) mes_actual ON mes_actual.Id_Cliente = c.Id_Cliente
LEFT JOIN
(SELECT t.Id_Cliente, SUM(m.preu * m.Cantidad * (1 - m.Descuento / 100)) futur
FROM vn2008.Tickets t
JOIN vn2008.Clientes c ON c.Id_Cliente = t.Id_Cliente
JOIN vn2008.Movimientos m ON m.Id_Ticket = t.Id_Ticket
LEFT JOIN vn2008.Trabajadores tr ON c.Id_Trabajador = tr.Id_Trabajador
WHERE
(c.Id_Trabajador = vWorker OR tr.boss = vWorker)
AND t.Fecha BETWEEN vDate AND util.dayEnd(LAST_DAY(vDate))
GROUP BY Id_Cliente) f ON c.Id_Cliente = f.Id_Cliente
LEFT JOIN
(SELECT MAX(t.Fecha) LastTicket, c.Id_Cliente
FROM vn2008.Tickets t
JOIN vn2008.Clientes c ON c.Id_cliente = t.Id_Cliente
LEFT JOIN vn2008.Trabajadores tr ON c.Id_Trabajador = tr.Id_Trabajador
WHERE
(c.Id_Trabajador = vWorker OR tr.boss = vWorker)
GROUP BY t.Id_Cliente) LastTicket ON LastTicket.Id_Cliente = c.Id_Cliente
LEFT JOIN
(
SELECT SUM(importe) peso, c.Id_Cliente
FROM bs.ventas v
JOIN vn2008.Clientes c ON c.Id_Cliente = v.Id_Cliente
LEFT JOIN vn2008.Trabajadores tr ON c.Id_Trabajador = tr.Id_Trabajador
WHERE fecha BETWEEN vAYearAgoStarted and vAYearAgoEnded
AND (c.Id_Trabajador = vWorker OR tr.boss = vWorker)
GROUP BY c.Id_Cliente) CmLy ON CmLy.Id_Cliente = c.Id_Cliente
LEFT JOIN
(SELECT c.Id_Cliente,
IF(MAX(Fecha) < DATE_FORMAT(TIMESTAMPADD(MONTH, - 1, vDate), '%Y- %m-01'), TRUE, FALSE) muerto
FROM vn2008.Facturas f
JOIN vn2008.Clientes c ON c.Id_cliente = f.Id_Cliente
LEFT JOIN vn2008.Trabajadores tr ON c.Id_Trabajador = tr.Id_Trabajador
WHERE (c.Id_Trabajador = vWorker OR tr.boss = vWorker)
GROUP BY Id_Cliente) dead ON dead.Id_Cliente = c.Id_Cliente
JOIN tmp.workerHierarchyList s ON s.workerFk = c.Id_Trabajador;
DROP TEMPORARY TABLE tmp.workerHierarchyList;
END$$
DELIMITER ;

View File

@ -15,10 +15,10 @@ BEGIN
SET lastYearSales =
(SELECT SUM(importe + recargo)
FROM ventas v
JOIN vn2008.empresa e ON e.id = v.empresa_id
JOIN vn2008.empresa_grupo eg ON eg.empresa_grupo_id = e.empresa_grupo
JOIN vn.company c ON c.id = v.empresa_id
JOIN vn.companyGroup cg ON cg.id = c.companyGroupFk
WHERE fecha BETWEEN oneYearBefore AND vDated
AND eg.grupo = 'Verdnatura'
AND cg.code = 'Verdnatura'
)
WHERE updated = vDated;

View File

@ -22,7 +22,7 @@ BEGIN
FROM vn.component WHERE code = 'manaClaim';
SELECT id INTO vManaBankId
FROM vn.bank WHERE code = 'mana';
FROM vn.accounting WHERE code = 'mana';
SELECT id INTO vManaGreugeTypeId
FROM vn.greugeType WHERE code = 'mana';
@ -31,62 +31,55 @@ BEGIN
INTO vManaFromDays, vManaToDays
FROM vn.salespersonConfig;
SELECT MAX(dated)
INTO vFromDated
SELECT MAX(dated) INTO vFromDated
FROM vn.clientManaCache;
DELETE
FROM vn.clientManaCache
DELETE FROM vn.clientManaCache
WHERE dated = vFromDated;
SELECT MAX(dated)
INTO vFromDated
SELECT MAX(dated) INTO vFromDated
FROM vn.clientManaCache;
IF ISNULL(vFromDated) THEN
IF vFromDated IS NULL THEN
SELECT manaDateFrom
INTO vFromDated
FROM vn.salespersonConfig;
END IF;
WHILE vFromDated + INTERVAL vManaToDays DAY < util.VN_CURDATE() DO
SELECT
vFromDated + INTERVAL vManaToDays DAY,
SELECT vFromDated + INTERVAL vManaToDays DAY,
vFromDated - INTERVAL vManaFromDays DAY
INTO
vToDated,
INTO vToDated,
vForDeleteDated;
DELETE FROM vn.clientManaCache
WHERE dated <= vForDeleteDated;
INSERT INTO vn.clientManaCache(clientFk, mana, dated)
SELECT
Id_Cliente,
SELECT Id_Cliente,
SUM(mana),
vToDated
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
FROM (
SELECT a.clientFk Id_Cliente, s.quantity * sc.value mana
FROM vn.ticket t
JOIN vn.address a ON a.id = t.addressFk
JOIN vn.sale s ON s.ticketFk = t.id
JOIN vn.saleComponent sc ON sc.saleFk = s.id
WHERE sc.componentFk IN (vManaAutoId, vManaId, vClaimManaId)
AND t.shipped > vFromDated
AND DATE(t.shipped) <= vToDated
UNION ALL
SELECT r.Id_Cliente, - Entregado
FROM vn2008.Recibos r
WHERE Id_Banco = vManaBankId
AND Fechacobro > vFromDated
AND Fechacobro <= vToDated
SELECT clientFk, - amountPaid
FROM vn.receipt
WHERE bankFk = vManaBankId
AND payed > vFromDated
AND payed <= vToDated
UNION ALL
SELECT g.Id_Cliente, g.Importe
FROM vn2008.Greuges g
WHERE Greuges_type_id = vManaGreugeTypeId
AND Fecha > vFromDated
AND Fecha <= vToDated
SELECT clientFk, amount
FROM vn.greuge
WHERE greugeTypeFk = vManaGreugeTypeId
AND shipped > vFromDated
AND shipped <= vToDated
UNION ALL
SELECT clientFk, mana
FROM vn.clientManaCache

View File

@ -0,0 +1,64 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`sale_add`(
IN vStarted DATE,
IN vEnded DATE
)
BEGIN
/**
* Añade las ventas que se realizaron entre 2 fechas a la tabla bs.sale
*
* @param vStarted Fecha de inicio
* @param vEnded Fecha de fin
*
*/
IF vStarted < (util.VN_CURDATE() - INTERVAL 5 YEAR) OR vStarted > vEnded THEN
CALL util.throw('Wrong date');
END IF;
DELETE FROM sale
WHERE dated BETWEEN vStarted AND vEnded;
REPLACE sale(
saleFk,
amount,
surcharge,
dated,
typeFk,
clientFk,
companyFk,
margin
)WITH calculatedSales AS(
SELECT s.id saleFk,
CAST(SUM(IF(ct.isBase, s.quantity * sc.value, 0)) AS DECIMAL(10, 3)) amount,
CAST(SUM(IF(ct.isBase, 0, s.quantity * sc.value)) AS DECIMAL(10, 3)) surcharge,
s.total,
DATE(t.shipped) dated,
i.typeFk,
t.clientFk,
t.companyFk,
CAST(SUM(IF(ct.isMargin, s.quantity * sc.value, 0 )) AS DECIMAL(10, 3)) marginComponents
FROM vn.ticket t
STRAIGHT_JOIN vn.sale s ON s.ticketFk = t.id
JOIN vn.item i ON i.id = s.itemFk
JOIN vn.itemType it ON it.id = i.typeFk
JOIN vn.itemCategory ic ON ic.id = it.categoryFk
JOIN vn.saleComponent sc ON sc.saleFk = s.id
JOIN vn.component c ON c.id = sc.componentFk
JOIN vn.componentType ct ON ct.id = c.typeFk
WHERE t.shipped BETWEEN vStarted AND vEnded
AND s.quantity <> 0
AND ic.merchandise
GROUP BY s.id
)SELECT saleFk,
amount,
surcharge,
dated,
typeFk,
clientFk,
companyFk,
IF (marginComponents IS NULL,
0,
CAST(marginComponents + amount + surcharge - total AS DECIMAL(10, 3)))
FROM calculatedSales;
END$$
DELIMITER ;

View File

@ -1,13 +1,12 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`ventas_add_launcher`()
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`sales_addLauncher`()
BEGIN
/**
* Añade las ventas a la tabla bs.sale que se realizaron desde hace un mes hasta hoy
*
*/
DECLARE vCurDate DATE DEFAULT util.VN_CURDATE();
CALL ventas_add(vCurDate - INTERVAL 1 MONTH, vCurDate);
CALL sale_add(vCurDate - INTERVAL 1 MONTH, vCurDate);
END$$
DELIMITER ;

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