Merge branch 'dev'
gitea/salix/master This commit looks good
Details
gitea/salix/master This commit looks good
Details
This commit is contained in:
commit
5ce7ca2497
|
@ -1,5 +1,7 @@
|
|||
node_modules
|
||||
dist/*
|
||||
e2e/dms/*/
|
||||
!e2e/dms/temp/
|
||||
npm-debug.log
|
||||
.eslintcache
|
||||
datasources.*.json
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
const UserError = require('vn-loopback/util/user-error');
|
||||
const fs = require('fs-extra');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('download', {
|
||||
Self.remoteMethodCtx('downloadFile', {
|
||||
description: 'Download a document',
|
||||
accessType: 'READ',
|
||||
accepts: [
|
||||
{
|
||||
arg: 'id',
|
||||
type: 'String',
|
||||
type: 'Number',
|
||||
description: 'The document id',
|
||||
http: {source: 'path'}
|
||||
}
|
||||
|
@ -29,48 +28,38 @@ module.exports = Self => {
|
|||
}
|
||||
],
|
||||
http: {
|
||||
path: `/:id/download`,
|
||||
path: `/:id/downloadFile`,
|
||||
verb: 'GET'
|
||||
}
|
||||
});
|
||||
|
||||
Self.download = async function(ctx, id) {
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
Self.downloadFile = async function(ctx, id) {
|
||||
const env = process.env.NODE_ENV;
|
||||
const document = await Self.findById(id, {
|
||||
include: {
|
||||
relation: 'dmsType',
|
||||
scope: {
|
||||
fields: ['path', 'readRoleFk'],
|
||||
include: {
|
||||
relation: 'readRole'
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
const readRole = document.dmsType().readRole().name;
|
||||
const hasRequiredRole = await Self.app.models.Account.hasRole(userId, readRole);
|
||||
const storageConnector = Self.app.dataSources.storage.connector;
|
||||
const models = Self.app.models;
|
||||
const dms = await Self.findById(id);
|
||||
|
||||
if (!hasRequiredRole)
|
||||
const hasReadRole = await models.DmsType.hasReadRole(ctx, dms.dmsTypeFk);
|
||||
if (!hasReadRole)
|
||||
throw new UserError(`You don't have enough privileges`);
|
||||
|
||||
if (env && env != 'development') {
|
||||
const path = `/${document.companyFk}/${document.dmsType().path}/${document.file}`;
|
||||
const pathHash = storageConnector.getPathHash(dms.id);
|
||||
file = {
|
||||
path: `/var/lib/salix/dms/${path}`,
|
||||
contentType: 'application/octet-stream',
|
||||
name: document.file
|
||||
container: pathHash,
|
||||
name: dms.file
|
||||
};
|
||||
} else {
|
||||
file = {
|
||||
path: `${process.cwd()}/README.md`,
|
||||
contentType: 'text/plain',
|
||||
name: `README.md`
|
||||
container: 'temp',
|
||||
name: `file.txt`
|
||||
};
|
||||
}
|
||||
|
||||
await fs.access(file.path);
|
||||
let stream = fs.createReadStream(file.path);
|
||||
const stream = await models.Container.downloadStream(file.container, file.name);
|
||||
|
||||
return [stream, file.contentType, `filename="${file.name}"`];
|
||||
};
|
||||
};
|
|
@ -0,0 +1,34 @@
|
|||
const UserError = require('vn-loopback/util/user-error');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('removeFile', {
|
||||
description: 'Makes a logical delete moving a file to a trash folder',
|
||||
accessType: 'WRITE',
|
||||
accepts: [{
|
||||
arg: 'id',
|
||||
type: 'Number',
|
||||
description: 'The document id',
|
||||
http: {source: 'path'}
|
||||
}],
|
||||
returns: {
|
||||
type: 'Object',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/:id/removeFile`,
|
||||
verb: 'POST'
|
||||
}
|
||||
});
|
||||
|
||||
Self.removeFile = async(ctx, id) => {
|
||||
const models = Self.app.models;
|
||||
const trashDmsType = await models.DmsType.findOne({where: {code: 'trash'}});
|
||||
const dms = await models.Dms.findById(id);
|
||||
|
||||
const hasWriteRole = await models.DmsType.hasWriteRole(ctx, dms.dmsTypeFk);
|
||||
if (!hasWriteRole)
|
||||
throw new UserError(`You don't have enough privileges`);
|
||||
|
||||
return dms.updateAttribute('dmsTypeFk', trashDmsType.id);
|
||||
};
|
||||
};
|
|
@ -1,15 +1,11 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
|
||||
/**
|
||||
* Pendiente de fixtures dms, dmsType, ticketDms
|
||||
* CAU: 10728
|
||||
*/
|
||||
xdescribe('dms download()', () => {
|
||||
describe('dms downloadFile()', () => {
|
||||
let dmsId = 1;
|
||||
it('should return a response for an employee with text content-type', async() => {
|
||||
let workerFk = 107;
|
||||
let ctx = {req: {accessToken: {userId: workerFk}}};
|
||||
const result = await app.models.Dms.download(ctx, dmsId);
|
||||
let workerId = 107;
|
||||
let ctx = {req: {accessToken: {userId: workerId}}};
|
||||
const result = await app.models.Dms.downloadFile(ctx, dmsId);
|
||||
|
||||
expect(result[1]).toEqual('text/plain');
|
||||
});
|
||||
|
@ -19,7 +15,7 @@ xdescribe('dms download()', () => {
|
|||
let ctx = {req: {accessToken: {userId: clientId}}};
|
||||
|
||||
let error;
|
||||
await app.models.Dms.download(ctx, dmsId).catch(e => {
|
||||
await app.models.Dms.downloadFile(ctx, dmsId).catch(e => {
|
||||
error = e;
|
||||
}).finally(() => {
|
||||
expect(error.message).toEqual(`You don't have enough privileges`);
|
|
@ -0,0 +1,19 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
|
||||
describe('dms removeFile()', () => {
|
||||
let dmsId = 1;
|
||||
|
||||
it(`should return an error for a user without enough privileges`, async() => {
|
||||
let clientId = 101;
|
||||
let ctx = {req: {accessToken: {userId: clientId}}};
|
||||
|
||||
let error;
|
||||
await app.models.Dms.removeFile(ctx, dmsId).catch(e => {
|
||||
error = e;
|
||||
}).finally(() => {
|
||||
expect(error.message).toEqual(`You don't have enough privileges`);
|
||||
});
|
||||
|
||||
expect(error).toBeDefined();
|
||||
});
|
||||
});
|
|
@ -0,0 +1,18 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
|
||||
describe('dms uploadFile()', () => {
|
||||
it(`should return an error for a user without enough privileges`, async() => {
|
||||
let clientId = 101;
|
||||
let ticketDmsTypeId = 14;
|
||||
let ctx = {req: {accessToken: {userId: clientId}}, args: {dmsTypeId: ticketDmsTypeId}};
|
||||
|
||||
let error;
|
||||
await app.models.Dms.uploadFile(ctx).catch(e => {
|
||||
error = e;
|
||||
}).finally(() => {
|
||||
expect(error.message).toEqual(`You don't have enough privileges`);
|
||||
});
|
||||
|
||||
expect(error).toBeDefined();
|
||||
});
|
||||
});
|
|
@ -0,0 +1,141 @@
|
|||
const UserError = require('vn-loopback/util/user-error');
|
||||
const fs = require('fs-extra');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('uploadFile', {
|
||||
description: 'Uploads a file and inserts into dms model',
|
||||
accessType: 'WRITE',
|
||||
accepts: [
|
||||
{
|
||||
arg: 'warehouseId',
|
||||
type: 'Number',
|
||||
description: ''
|
||||
}, {
|
||||
arg: 'companyId',
|
||||
type: 'Number',
|
||||
description: ''
|
||||
}, {
|
||||
arg: 'dmsTypeId',
|
||||
type: 'Number',
|
||||
description: ''
|
||||
}, {
|
||||
arg: 'reference',
|
||||
type: 'String',
|
||||
description: ''
|
||||
}, {
|
||||
arg: 'description',
|
||||
type: 'String',
|
||||
description: ''
|
||||
}, {
|
||||
arg: 'hasFile',
|
||||
type: 'Boolean',
|
||||
description: ''
|
||||
}],
|
||||
returns: {
|
||||
type: 'Object',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/uploadFile`,
|
||||
verb: 'POST'
|
||||
}
|
||||
});
|
||||
|
||||
Self.uploadFile = async(ctx, options) => {
|
||||
const storageConnector = Self.app.dataSources.storage.connector;
|
||||
const models = Self.app.models;
|
||||
const fileOptions = {};
|
||||
const args = ctx.args;
|
||||
|
||||
let tx;
|
||||
let myOptions = {};
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
if (!myOptions.transaction) {
|
||||
tx = await Self.beginTransaction({});
|
||||
myOptions.transaction = tx;
|
||||
}
|
||||
|
||||
try {
|
||||
const hasWriteRole = await models.DmsType.hasWriteRole(ctx, args.dmsTypeId);
|
||||
if (!hasWriteRole)
|
||||
throw new UserError(`You don't have enough privileges`);
|
||||
|
||||
// Upload file to temporary path
|
||||
const tempContainer = await getContainer('temp');
|
||||
const uploaded = await models.Container.upload(tempContainer.name, ctx.req, ctx.result, fileOptions);
|
||||
const files = Object.values(uploaded.files).map(file => {
|
||||
return file[0];
|
||||
});
|
||||
|
||||
const addedDms = [];
|
||||
for (const file of files) {
|
||||
const newDms = await createDms(ctx, file.name, myOptions);
|
||||
const pathHash = storageConnector.getPathHash(newDms.id);
|
||||
const container = await getContainer(pathHash);
|
||||
|
||||
const originPath = `${tempContainer.client.root}/${tempContainer.name}/${file.name}`;
|
||||
const destinationPath = `${container.client.root}/${pathHash}/${newDms.file}`;
|
||||
|
||||
fs.rename(originPath, destinationPath);
|
||||
|
||||
addedDms.push(newDms);
|
||||
}
|
||||
|
||||
if (tx) await tx.commit();
|
||||
return addedDms;
|
||||
} catch (e) {
|
||||
if (tx) await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
|
||||
async function createDms(ctx, fileName, myOptions) {
|
||||
const models = Self.app.models;
|
||||
const storageConnector = Self.app.dataSources.storage.connector;
|
||||
const myUserId = ctx.req.accessToken.userId;
|
||||
const myWorker = await models.Worker.findOne({where: {userFk: myUserId}});
|
||||
const args = ctx.args;
|
||||
|
||||
const newDms = await Self.create({
|
||||
workerFk: myWorker.id,
|
||||
dmsTypeFk: args.dmsTypeId,
|
||||
companyFk: args.companyId,
|
||||
warehouseFk: args.warehouseId,
|
||||
reference: args.reference,
|
||||
description: args.description,
|
||||
hasFile: args.hasFile
|
||||
}, myOptions);
|
||||
|
||||
const extension = storageConnector.getFileExtension(fileName);
|
||||
fileName = `${newDms.id}.${extension}`;
|
||||
|
||||
return newDms.updateAttribute('file', fileName, myOptions);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a container instance
|
||||
* If doesn't exists creates a new one
|
||||
*
|
||||
* @param {String} name Container name
|
||||
* @return {Object} Container instance
|
||||
*/
|
||||
async function getContainer(name) {
|
||||
const models = Self.app.models;
|
||||
let container;
|
||||
try {
|
||||
container = await models.Container.getContainer(name);
|
||||
} catch (err) {
|
||||
if (err.code === 'ENOENT') {
|
||||
container = await models.Container.createContainer({
|
||||
name: name
|
||||
});
|
||||
} else throw err;
|
||||
}
|
||||
|
||||
return container;
|
||||
}
|
||||
};
|
|
@ -11,6 +11,9 @@
|
|||
"Company": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"Container": {
|
||||
"dataSource": "storage"
|
||||
},
|
||||
"Delivery": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
|
@ -43,6 +46,12 @@
|
|||
},
|
||||
"DmsType": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"Town": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"Postcode": {
|
||||
"dataSource": "vn"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,12 @@
|
|||
"type": "hasOne",
|
||||
"model": "EmailUser",
|
||||
"foreignKey": "userFk"
|
||||
}
|
||||
},
|
||||
"worker": {
|
||||
"type": "hasOne",
|
||||
"model": "Worker",
|
||||
"foreignKey": "userFk"
|
||||
}
|
||||
},
|
||||
"acls": [
|
||||
{
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"name": "Container",
|
||||
"base": "VnModel",
|
||||
"idInjection": true,
|
||||
"options": {
|
||||
"validateUpsert": true
|
||||
},
|
||||
"properties": {},
|
||||
"validations": [],
|
||||
"relations": {},
|
||||
"acls": [],
|
||||
"methods": []
|
||||
}
|
|
@ -1,3 +1,5 @@
|
|||
module.exports = Self => {
|
||||
require('../methods/dms/download')(Self);
|
||||
require('../methods/dms/downloadFile')(Self);
|
||||
require('../methods/dms/uploadFile')(Self);
|
||||
require('../methods/dms/removeFile')(Self);
|
||||
};
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
{
|
||||
"name": "Dms",
|
||||
"description": "Documental Managment system",
|
||||
|
@ -22,6 +23,12 @@
|
|||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"hardCopyNumber": {
|
||||
"type": "Number"
|
||||
},
|
||||
"hasFile": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"created": {
|
||||
"type": "Date"
|
||||
}
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
module.exports = Self => {
|
||||
/**
|
||||
* Checks if current user has
|
||||
* read privileges over a dms
|
||||
*
|
||||
* @param {Object} ctx - Request context
|
||||
* @param {Interger} id - DmsType id
|
||||
* @return {Boolean} True for user with read privileges
|
||||
*/
|
||||
Self.hasReadRole = async(ctx, id) => {
|
||||
const models = Self.app.models;
|
||||
const dmsType = await models.DmsType.findById(id, {
|
||||
include: {
|
||||
relation: 'readRole'
|
||||
}
|
||||
});
|
||||
|
||||
return await hasRole(ctx, dmsType);
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks if current user has
|
||||
* write privileges over a dms
|
||||
*
|
||||
* @param {Object} ctx - Request context
|
||||
* @param {Interger} id - DmsType id
|
||||
* @return {Boolean} True for user with write privileges
|
||||
*/
|
||||
Self.hasWriteRole = async(ctx, id) => {
|
||||
const models = Self.app.models;
|
||||
const dmsType = await models.DmsType.findById(id, {
|
||||
include: {
|
||||
relation: 'writeRole'
|
||||
}
|
||||
});
|
||||
|
||||
return await hasRole(ctx, dmsType);
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks if current user has
|
||||
* read or write privileges
|
||||
* @param {Object} ctx - Context
|
||||
* @param {Object} dmsType - Dms type [read/write]
|
||||
*/
|
||||
async function hasRole(ctx, dmsType) {
|
||||
const models = Self.app.models;
|
||||
const myUserId = ctx.req.accessToken.userId;
|
||||
|
||||
const readRole = dmsType.readRole() && dmsType.readRole().name;
|
||||
const writeRole = dmsType.writeRole() && dmsType.writeRole().name;
|
||||
const requiredRole = readRole || writeRole;
|
||||
|
||||
const hasRequiredRole = await models.Account.hasRole(myUserId, requiredRole);
|
||||
const isRoot = await models.Account.hasRole(myUserId, 'root');
|
||||
|
||||
if (isRoot || hasRequiredRole)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
|
@ -20,6 +20,10 @@
|
|||
"path": {
|
||||
"type": "string",
|
||||
"required": true
|
||||
},
|
||||
"code": {
|
||||
"type": "string",
|
||||
"required": true
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
let UserError = require('vn-loopback/util/user-error');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.rewriteDbError(function(err) {
|
||||
if (err.code === 'ER_DUP_ENTRY')
|
||||
return new UserError(`This postcode already exists`);
|
||||
return err;
|
||||
});
|
||||
};
|
|
@ -0,0 +1,50 @@
|
|||
{
|
||||
"name": "Postcode",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "postCode"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"code": {
|
||||
"id": true,
|
||||
"type": "String"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"town": {
|
||||
"type": "belongsTo",
|
||||
"model": "Town",
|
||||
"foreignKey": "townFk"
|
||||
},
|
||||
"geo": {
|
||||
"type": "belongsTo",
|
||||
"model": "ZoneGeo",
|
||||
"foreignKey": "geoFk"
|
||||
}
|
||||
},
|
||||
"acls": [{
|
||||
"accessType": "READ",
|
||||
"principalType": "ROLE",
|
||||
"principalId": "$everyone",
|
||||
"permission": "ALLOW"
|
||||
}],
|
||||
"scopes": {
|
||||
"location": {
|
||||
"include": {
|
||||
"relation": "town",
|
||||
"scope": {
|
||||
"include": {
|
||||
"relation": "province",
|
||||
"scope": {
|
||||
"include": {
|
||||
"relation": "country"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,4 @@
|
|||
module.exports = Self => {
|
||||
// Validations
|
||||
|
||||
Self.validatesUniquenessOf('extension', {
|
||||
message: `The extension must be unique`
|
||||
});
|
||||
|
|
|
@ -16,7 +16,8 @@
|
|||
}
|
||||
},
|
||||
"extension": {
|
||||
"type": "Number"
|
||||
"type": "String",
|
||||
"required": true
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
{
|
||||
"name": "Town",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "town"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"id": true,
|
||||
"type": "Number"
|
||||
},
|
||||
"name": {
|
||||
"type": "String"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"province": {
|
||||
"type": "belongsTo",
|
||||
"model": "Province",
|
||||
"foreignKey": "provinceFk"
|
||||
},
|
||||
"postcodes": {
|
||||
"type": "hasMany",
|
||||
"model": "Postcode",
|
||||
"foreignKey": "townFk"
|
||||
},
|
||||
"geo": {
|
||||
"type": "belongsTo",
|
||||
"model": "ZoneGeo",
|
||||
"foreignKey": "geoFk"
|
||||
}
|
||||
},
|
||||
"acls": [{
|
||||
"accessType": "READ",
|
||||
"principalType": "ROLE",
|
||||
"principalId": "$everyone",
|
||||
"permission": "ALLOW"
|
||||
}],
|
||||
"scopes": {
|
||||
"location": {
|
||||
"include": [{
|
||||
"relation": "postcodes"
|
||||
},
|
||||
{
|
||||
"relation": "province",
|
||||
"scope": {
|
||||
"include": {
|
||||
"relation": "country"
|
||||
}
|
||||
}
|
||||
}],
|
||||
"fields": ["id", "name", "provinceFk"]
|
||||
}
|
||||
}
|
||||
}
|
|
@ -31,5 +31,5 @@
|
|||
"permission": "ALLOW"
|
||||
}
|
||||
],
|
||||
"scope" : {"where": {"isInventory": {"neq": 0}}}
|
||||
"scope" : {"where": {"isForTicket": {"neq": 0}}}
|
||||
}
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL` (`id`, `model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('160', 'TicketServiceType', '*', 'READ', 'ALLOW', 'ROLE', 'employee');
|
|
@ -1,76 +0,0 @@
|
|||
|
||||
DROP function IF EXISTS `vn`.`clientGetSalesPerson`;
|
||||
DELIMITER $$
|
||||
CREATE DEFINER=`root`@`%` FUNCTION `vn`.`clientGetSalesPerson`(vClientFk INT, vDated DATE) RETURNS int(11)
|
||||
DETERMINISTIC
|
||||
BEGIN
|
||||
/**
|
||||
* Dado un id cliente y una fecha, devuelve su comercial para ese dia, teniendo
|
||||
* en cuenta la jerarquía de las tablas: 1º la de sharingClient, 2º la de
|
||||
* sharingCart y tercero la de clientes.
|
||||
*
|
||||
* @param vClientFk El id del cliente
|
||||
* @param vDated Fecha a comprobar
|
||||
* @return El id del comercial para la fecha dada
|
||||
**/
|
||||
DECLARE vSalesperson INT DEFAULT NULL;
|
||||
DECLARE vSubstitute INT DEFAULT NULL;
|
||||
DECLARE vLoop BOOLEAN;
|
||||
|
||||
-- Obtiene el comercial original y el de sharingClient
|
||||
|
||||
SELECT c.salesPersonFk, s.workerFk
|
||||
INTO vSalesperson, vSubstitute
|
||||
FROM client c
|
||||
LEFT JOIN sharingClient s
|
||||
ON c.id = s.clientFk
|
||||
AND vDated BETWEEN s.started AND s.ended
|
||||
WHERE c.id = vClientFk
|
||||
ORDER BY s.id
|
||||
LIMIT 1;
|
||||
|
||||
-- Si no hay ninguno en sharingClient busca en sharingCart
|
||||
|
||||
IF vSubstitute IS NOT NULL
|
||||
THEN
|
||||
SET vSalesperson = vSubstitute;
|
||||
ELSEIF vSalesperson IS NOT NULL
|
||||
THEN
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.stack;
|
||||
CREATE TEMPORARY TABLE tmp.stack
|
||||
(INDEX (substitute))
|
||||
ENGINE = MEMORY
|
||||
SELECT vSalesperson substitute;
|
||||
|
||||
l: LOOP
|
||||
SELECT workerSubstitute INTO vSubstitute
|
||||
FROM sharingCart
|
||||
WHERE vDated BETWEEN started AND ended
|
||||
AND workerFk = vSalesperson
|
||||
ORDER BY id
|
||||
LIMIT 1;
|
||||
|
||||
IF vSubstitute IS NULL THEN
|
||||
LEAVE l;
|
||||
END IF;
|
||||
|
||||
SELECT COUNT(*) > 0 INTO vLoop
|
||||
FROM tmp.stack WHERE substitute = vSubstitute;
|
||||
|
||||
IF vLoop THEN
|
||||
LEAVE l;
|
||||
END IF;
|
||||
|
||||
INSERT INTO tmp.stack SET
|
||||
substitute = vSubstitute;
|
||||
|
||||
SET vSalesperson = vSubstitute;
|
||||
END LOOP;
|
||||
|
||||
DROP TEMPORARY TABLE tmp.stack;
|
||||
END IF;
|
||||
|
||||
RETURN vSalesperson;
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
|
@ -1 +0,0 @@
|
|||
ALTER TABLE `vn2008`.`Greuges` CHANGE COLUMN `Fecha` `Fecha` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ;
|
|
@ -1,9 +0,0 @@
|
|||
ALTER TABLE `vn2008`.`Facturas`
|
||||
DROP FOREIGN KEY `invoice_bank_id`;
|
||||
ALTER TABLE `vn2008`.`Facturas`
|
||||
CHANGE COLUMN `Id_Banco` `Id_Banco` INT(11) NULL DEFAULT NULL ;
|
||||
ALTER TABLE `vn2008`.`Facturas`
|
||||
ADD CONSTRAINT `invoice_bank_id`
|
||||
FOREIGN KEY (`Id_Banco`)
|
||||
REFERENCES `vn2008`.`Bancos` (`Id_Banco`)
|
||||
ON UPDATE CASCADE;
|
|
@ -1,13 +0,0 @@
|
|||
ALTER TABLE `vn2008`.`Colas`
|
||||
DROP FOREIGN KEY `Colas_ibfk_1`,
|
||||
DROP FOREIGN KEY `Colas_ibfk_2`,
|
||||
DROP FOREIGN KEY `Colas_ibfk_3`,
|
||||
DROP FOREIGN KEY `Colas_ibfk_5`;
|
||||
ALTER TABLE `vn2008`.`Colas`
|
||||
CHANGE COLUMN `Id_Impresora` `Id_Impresora` TINYINT(3) UNSIGNED NULL DEFAULT NULL ,
|
||||
CHANGE COLUMN `Id_Prioridad` `Id_Prioridad` TINYINT(3) UNSIGNED NULL DEFAULT NULL ;
|
||||
ALTER TABLE `vn2008`.`Colas`
|
||||
ADD CONSTRAINT `Colas_ibfk_3`
|
||||
FOREIGN KEY (`Id_Prioridad`)
|
||||
REFERENCES `vn2008`.`Prioridades` (`Id_Prioridad`)
|
||||
ON UPDATE CASCADE;
|
|
@ -1,21 +0,0 @@
|
|||
DROP TABLE IF EXISTS `vn`.`routeLog`;
|
||||
|
||||
CREATE TABLE `vn`.`routeLog` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`originFk` int(10) unsigned NOT NULL,
|
||||
`userFk` int(10) unsigned DEFAULT NULL,
|
||||
`action` set('insert','update','delete') COLLATE utf8_unicode_ci NOT NULL,
|
||||
`creationDate` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`description` text CHARACTER SET utf8,
|
||||
`changedModel` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL,
|
||||
`oldInstance` text COLLATE utf8_unicode_ci,
|
||||
`newInstance` text COLLATE utf8_unicode_ci,
|
||||
`changedModelId` int(11) DEFAULT NULL,
|
||||
`changedModelValue` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `originFk` (`originFk`),
|
||||
KEY `userFk` (`userFk`),
|
||||
CONSTRAINT `routeLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `vn2008`.`Rutas` (`Id_Ruta`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `routeLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
CREATE
|
||||
ALGORITHM = UNDEFINED
|
||||
DEFINER = `root`@`%`
|
||||
SQL SECURITY DEFINER
|
||||
VIEW `vn`.`sharingCart` AS
|
||||
SELECT
|
||||
`s`.`id` AS `id`,
|
||||
`s`.`Id_Trabajador` AS `workerFk`,
|
||||
`s`.`datSTART` AS `started`,
|
||||
`s`.`datEND` AS `ended`,
|
||||
`s`.`Id_Suplente` AS `workerSubstitute`,
|
||||
`s`.`odbc_date` AS `created`
|
||||
FROM
|
||||
`vn2008`.`sharingcart` `s`
|
|
@ -1,13 +0,0 @@
|
|||
CREATE
|
||||
OR REPLACE ALGORITHM = UNDEFINED
|
||||
DEFINER = `root`@`%`
|
||||
SQL SECURITY DEFINER
|
||||
VIEW `vn`.`sharingClient` AS
|
||||
SELECT
|
||||
`s`.`id` AS `id`,
|
||||
`s`.`Id_Trabajador` AS `workerFk`,
|
||||
`s`.`datSTART` AS `started`,
|
||||
`s`.`datEND` AS `ended`,
|
||||
`s`.`Id_Cliente` AS `clientFk`
|
||||
FROM
|
||||
`vn2008`.`sharingclient` `s`;
|
|
@ -1,11 +0,0 @@
|
|||
DROP TRIGGER IF EXISTS `vn2008`.`TicketsAfterUpdate`;
|
||||
|
||||
DELIMITER $$
|
||||
USE `vn2008`$$
|
||||
CREATE DEFINER=`root`@`%` TRIGGER `vn2008`.`TicketsAfterUpdate`
|
||||
AFTER UPDATE ON `Tickets` FOR EACH ROW
|
||||
BEGIN
|
||||
|
||||
CALL stock.queueAdd ('ticket', NEW.Id_Ticket, OLD.Id_Ticket);
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,4 +0,0 @@
|
|||
DROP TABLE IF EXISTS `vn`.`ticketConfig`;
|
||||
|
||||
CREATE TABLE `vn`.`ticketConfig` (`id` INT NOT NULL AUTO_INCREMENT, `scopeDays` TINYINT(3) NULL, PRIMARY KEY (`id`));
|
||||
INSERT INTO `vn`.`ticketConfig` (`id`, `scopeDays`) VALUES ('1', '6');
|
|
@ -1,74 +0,0 @@
|
|||
|
||||
DROP procedure IF EXISTS `vn`.`ticketCreateWithUser`;
|
||||
|
||||
DELIMITER $$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`ticketCreateWithUser`(
|
||||
vClientId INT
|
||||
,vShipped DATE
|
||||
,vWarehouseId INT
|
||||
,vCompanyFk INT
|
||||
,vAddressFk INT
|
||||
,vAgencyType INT
|
||||
,vRouteFk INT
|
||||
,vlanded DATE
|
||||
,vUserId INT
|
||||
,OUT vNewTicket INT)
|
||||
BEGIN
|
||||
|
||||
IF vClientId IS NULL THEN
|
||||
CALL util.throw ('CLIENT_NOT_ESPECIFIED');
|
||||
END IF;
|
||||
|
||||
IF NOT vAddressFk OR vAddressFk IS NULL THEN
|
||||
SELECT id INTO vAddressFk
|
||||
FROM address
|
||||
WHERE clientFk = vClientId AND isDefaultAddress;
|
||||
END IF;
|
||||
|
||||
INSERT INTO vn2008.Tickets (
|
||||
Id_Cliente,
|
||||
Fecha,
|
||||
Id_Consigna,
|
||||
Id_Agencia,
|
||||
Alias,
|
||||
warehouse_id,
|
||||
Id_Ruta,
|
||||
empresa_id,
|
||||
landing
|
||||
)
|
||||
SELECT
|
||||
vClientId,
|
||||
vShipped,
|
||||
a.id,
|
||||
IF(vAgencyType, vAgencyType, a.agencyModeFk),
|
||||
a.nickname,
|
||||
vWarehouseId,
|
||||
IF(vRouteFk,vRouteFk,NULL),
|
||||
vCompanyFk,
|
||||
vlanded
|
||||
FROM address a
|
||||
JOIN agencyMode am ON am.id = a.agencyModeFk
|
||||
WHERE a.id = vAddressFk;
|
||||
|
||||
SET vNewTicket = LAST_INSERT_ID();
|
||||
|
||||
INSERT INTO ticketObservation(ticketFk, observationTypeFk, description)
|
||||
SELECT vNewTicket, ao.observationTypeFk, ao.description
|
||||
FROM addressObservation ao
|
||||
JOIN address a ON a.id = ao.addressFk
|
||||
WHERE a.id = vAddressFk;
|
||||
|
||||
-- CALL logAddWithUser(vNewTicket, vUserId, 'insert', 'ticket', CONCAT('Ha creado el ticket', ' ', vNewTicket));
|
||||
INSERT INTO vn.ticketLog
|
||||
SET originFk = vNewTicket, userFk = vUserId, `action` = 'insert', description = CONCAT('Ha creado el ticket:', ' ', vNewTicket);
|
||||
|
||||
IF (SELECT ct.isCreatedAsServed FROM vn.clientType ct JOIN vn.client c ON c.typeFk = ct.code WHERE c.id = vClientId ) <> FALSE THEN
|
||||
INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador)
|
||||
SELECT id, vNewTicket, getWorker()
|
||||
FROM state
|
||||
WHERE `code` = 'DELIVERED';
|
||||
END IF;
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
DROP TABLE IF EXISTS `vn`.`ticketServiceType`;
|
||||
|
||||
CREATE TABLE vn.`ticketServiceType` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Lista de los posibles servicios a elegir';
|
||||
|
||||
INSERT INTO `vn`.`ticketServiceType` (`name`) VALUES ('Porte Agencia');
|
||||
INSERT INTO `vn`.`ticketServiceType` (`name`) VALUES ('Portes Retorno');
|
||||
INSERT INTO `vn`.`ticketServiceType` (`name`) VALUES ('Porte Carry');
|
||||
INSERT INTO `vn`.`ticketServiceType` (`name`) VALUES ('Cargo FITOSANITARIO');
|
||||
INSERT INTO `vn`.`ticketServiceType` (`name`) VALUES ('Documentos');
|
|
@ -1,46 +0,0 @@
|
|||
DROP procedure IF EXISTS `vn`.`worker_getHierarch`;
|
||||
|
||||
DELIMITER $$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`worker_getHierarch`(vBoss INT)
|
||||
BEGIN
|
||||
DECLARE EXIT HANDLER FOR 1062 BEGIN
|
||||
CALL util.throw('INFINITE_LOOP');
|
||||
END;
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS workerHierarch;
|
||||
CREATE TEMPORARY TABLE workerHierarch
|
||||
(PRIMARY KEY (workerFk))
|
||||
ENGINE = MEMORY
|
||||
SELECT vBoss AS workerFk;
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.workerHierarchList;
|
||||
CREATE TEMPORARY TABLE tmp.workerHierarchList
|
||||
(PRIMARY KEY (workerFk))
|
||||
ENGINE = MEMORY
|
||||
SELECT vBoss AS workerFk, 0 AS isChecked;
|
||||
|
||||
|
||||
WHILE (SELECT COUNT(*) FROM tmp.workerHierarchList WHERE NOT isChecked) > 0 DO
|
||||
|
||||
INSERT INTO tmp.workerHierarchList
|
||||
SELECT w.id, 0
|
||||
FROM worker w
|
||||
JOIN workerHierarch wh ON wh.workerFk = w.bossFk;
|
||||
|
||||
UPDATE tmp.workerHierarchList whl
|
||||
JOIN workerHierarch wh ON wh.workerFk = whl.workerFk
|
||||
SET whl.isChecked = 1;
|
||||
|
||||
TRUNCATE workerHierarch;
|
||||
|
||||
INSERT INTO workerHierarch
|
||||
SELECT workerFk
|
||||
FROM tmp.workerHierarchList
|
||||
WHERE NOT isChecked;
|
||||
|
||||
END WHILE;
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS workerHierarch;
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
|
@ -1,6 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL` (`id`, `model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES (161, 'TicketConfig', '*', 'READ', 'ALLOW', 'ROLE', 'employee');
|
||||
INSERT INTO `salix`.`ACL` (`id`, `model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES (162, 'InvoiceOut', 'delete', 'WRITE', 'ALLOW', 'ROLE', 'invoicing');
|
||||
INSERT INTO `salix`.`ACL` (`id`, `model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES (163, 'InvoiceOut', 'book', 'WRITE', 'ALLOW', 'ROLE', 'invoicing');
|
||||
INSERT INTO `salix`.`ACL` (`id`, `model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES (164, 'InvoiceOut', 'regenerate', 'WRITE', 'ALLOW', 'ROLE', 'invoicing');
|
||||
INSERT INTO `salix`.`ACL` (`id`, `model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES (165, 'TicketDms', '*', 'READ', 'ALLOW', 'ROLE', 'employee');
|
||||
INSERT INTO `salix`.`ACL` (`id`, `model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES (166, 'Dms', 'download', 'READ', 'ALLOW', 'ROLE', 'employee');
|
|
@ -1,71 +0,0 @@
|
|||
DROP procedure IF EXISTS `nst`.`nodeAdd`;
|
||||
|
||||
DELIMITER $$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `nst`.`nodeAdd`(IN `vScheme` VARCHAR(45), IN `vTable` VARCHAR(45), IN `vParentFk` INT, IN `vChild` VARCHAR(100))
|
||||
BEGIN
|
||||
DECLARE vSql TEXT;
|
||||
DECLARE vTableClone VARCHAR(45);
|
||||
|
||||
SET vTableClone = CONCAT(vTable, 'Clone');
|
||||
|
||||
CALL util.exec(CONCAT('DROP TEMPORARY TABLE IF EXISTS tmp.', vTableClone));
|
||||
CALL util.exec(CONCAT(
|
||||
'CREATE TEMPORARY TABLE tmp.', vTableClone,
|
||||
' ENGINE = MEMORY',
|
||||
' SELECT * FROM ', vScheme, '.', vTable
|
||||
));
|
||||
|
||||
CALL util.exec(CONCAT(
|
||||
'SELECT COUNT(c.id) INTO @childs',
|
||||
' FROM ', vScheme, '.', vTable, ' p',
|
||||
' LEFT JOIN tmp.', vTableClone, ' c ON c.lft',
|
||||
' BETWEEN p.lft AND p.rgt AND c.id != ', vParentFk,
|
||||
' WHERE p.id = ', vParentFk
|
||||
));
|
||||
|
||||
IF @childs = 0 THEN
|
||||
CALL util.exec(CONCAT(
|
||||
'SELECT lft INTO @vLeft',
|
||||
' FROM ', vScheme, '.', vTable,
|
||||
' WHERE id = ', vParentFk
|
||||
));
|
||||
ELSE
|
||||
CALL util.exec(CONCAT(
|
||||
'SELECT c.rgt INTO @vLeft',
|
||||
' FROM ', vScheme, '.', vTable, ' p',
|
||||
' JOIN tmp.', vTableClone, ' c ON c.lft BETWEEN p.lft AND p.rgt',
|
||||
' WHERE p.id = ', vParentFk,
|
||||
' ORDER BY c.lft',
|
||||
' DESC LIMIT 1'
|
||||
));
|
||||
END IF;
|
||||
|
||||
CALL util.exec(CONCAT(
|
||||
'UPDATE ', vScheme, '.', vTable, ' SET rgt = rgt + 2',
|
||||
' WHERE rgt > @vLeft',
|
||||
' ORDER BY rgt DESC'
|
||||
));
|
||||
CALL util.exec(CONCAT(
|
||||
'UPDATE ', vScheme, '.', vTable, ' SET lft = lft + 2',
|
||||
' WHERE lft > @vLeft',
|
||||
' ORDER BY lft DESC'
|
||||
));
|
||||
|
||||
SET vChild = REPLACE(vChild, "'", "\\'");
|
||||
|
||||
CALL util.exec(CONCAT(
|
||||
'INSERT INTO ', vScheme, '.', vTable, ' (name, lft, rgt)',
|
||||
' VALUES ("', vChild, '", @vLeft + 1, @vLeft + 2)'
|
||||
));
|
||||
|
||||
CALL util.exec(CONCAT(
|
||||
'SELECT id, name, lft, rgt, depth, sons',
|
||||
' FROM ', vScheme, '.', vTable,
|
||||
' WHERE id = LAST_INSERT_ID()'
|
||||
));
|
||||
|
||||
CALL util.exec(CONCAT('DROP TEMPORARY TABLE tmp.', vTableClone));
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
DROP procedure IF EXISTS `nst`.`nodeDelete`;
|
||||
|
||||
DELIMITER $$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `nst`.`nodeDelete`(IN `vScheme` VARCHAR(45), IN `vTable` VARCHAR(45), IN `vNodeId` INT)
|
||||
BEGIN
|
||||
DECLARE vMyRight INT;
|
||||
DECLARE vMyLeft INT;
|
||||
DECLARE vMyWidth INT;
|
||||
|
||||
CALL util.exec(CONCAT(
|
||||
'SELECT t.rgt, t.lft, t.rgt - t.lft + 1',
|
||||
' INTO @vMyRight, @vMyLeft, @vMyWidth',
|
||||
' FROM ', vScheme, '.', vTable, ' t',
|
||||
' WHERE t.id = ', vNodeId
|
||||
));
|
||||
|
||||
CALL util.exec(CONCAT(
|
||||
'DELETE FROM ', vScheme, '.', vTable,
|
||||
' WHERE lft BETWEEN @vMyLeft AND @vMyRight'
|
||||
));
|
||||
|
||||
CALL util.exec(CONCAT(
|
||||
'UPDATE ', vScheme, '.', vTable, ' SET rgt = rgt - @vMyWidth'
|
||||
' WHERE rgt > @vMyRight ORDER BY rgt'
|
||||
));
|
||||
|
||||
CALL util.exec(CONCAT(
|
||||
'UPDATE ', vScheme, '.', vTable, ' SET lft = lft - @vMyWidth'
|
||||
' WHERE lft > @vMyRight ORDER BY lft'
|
||||
));
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
DROP procedure IF EXISTS `nst`.`nodeRecalc`;
|
||||
|
||||
DELIMITER $$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `nst`.`nodeRecalc`(IN `vScheme` VARCHAR(45), IN `vTable` VARCHAR(45))
|
||||
BEGIN
|
||||
CALL util.exec(CONCAT (
|
||||
'UPDATE ', vScheme, '.', vTable, ' d',
|
||||
' JOIN (SELECT',
|
||||
' node.id,',
|
||||
' COUNT(parent.id) - 1 as depth,',
|
||||
' cast((node.rgt - node.lft - 1) / 2 as DECIMAL) as sons',
|
||||
' FROM ',
|
||||
' ', vScheme, '.', vTable, ' AS node,',
|
||||
' ', vScheme, '.', vTable, ' AS parent',
|
||||
' WHERE node.lft BETWEEN parent.lft AND parent.rgt',
|
||||
' GROUP BY node.id',
|
||||
' ORDER BY node.lft) n ON n.id = d.id ',
|
||||
' SET d.`depth` = n.depth, d.sons = n.sons'
|
||||
));
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
DROP VIEW IF EXISTS `vn`.`dmsTicket` ;
|
||||
USE `vn`;
|
||||
CREATE
|
||||
OR REPLACE ALGORITHM = UNDEFINED
|
||||
DEFINER = `root`@`%`
|
||||
SQL SECURITY DEFINER
|
||||
VIEW `vn`.`ticketDms` AS
|
||||
SELECT
|
||||
`g`.`Id_Ticket` AS `ticketFk`,
|
||||
`g`.`gestdoc_id` AS `dmsFk`
|
||||
FROM
|
||||
`vn2008`.`tickets_gestdoc` `g`;
|
|
@ -1,7 +0,0 @@
|
|||
ALTER TABLE `vn2008`.`gesttip`
|
||||
ADD COLUMN `writeRoleFk` INT(10) UNSIGNED NULL AFTER `path`,
|
||||
ADD COLUMN `readRoleFk` INT(10) UNSIGNED NULL AFTER `writeRoleFk`,
|
||||
ADD CONSTRAINT `readRoleFk` FOREIGN KEY (`readRoleFk`) REFERENCES `account`.`role` (`id`),
|
||||
ADD CONSTRAINT `writeRoleFk` FOREIGN KEY (`writeRoleFk`) REFERENCES `account`.`role` (`id`);
|
||||
|
||||
UPDATE `vn2008`.`gesttip` SET `readRoleFk`='1' WHERE `id`='14';
|
|
@ -1,13 +0,0 @@
|
|||
CREATE
|
||||
OR REPLACE ALGORITHM = UNDEFINED
|
||||
DEFINER = `root`@`%`
|
||||
SQL SECURITY DEFINER
|
||||
VIEW `vn`.`dmsType` AS
|
||||
SELECT
|
||||
`g`.`id` AS `id`,
|
||||
`g`.`tipo` AS `name`,
|
||||
`g`.`path` AS `path`,
|
||||
`g`.`readRoleFk` AS `readRoleFk`,
|
||||
`g`.`writeRoleFk` AS `writeRoleFk`
|
||||
FROM
|
||||
`vn2008`.`gesttip` `g`;
|
|
@ -1,5 +0,0 @@
|
|||
|
||||
ALTER TABLE `vn`.`zone`
|
||||
DROP PRIMARY KEY,
|
||||
ADD PRIMARY KEY (`id`),
|
||||
ADD INDEX `zone_name_idx` (`name` ASC);
|
|
@ -1,15 +0,0 @@
|
|||
CREATE TABLE `vn`.`device` (
|
||||
`id` INT NOT NULL,
|
||||
`sn` VARCHAR(50) NULL,
|
||||
`model` VARCHAR(50) NULL,
|
||||
`userFk` INT(10) UNSIGNED NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
INDEX `device_fk1_idx` (`userFk` ASC),
|
||||
CONSTRAINT `device_fk1`
|
||||
FOREIGN KEY (`userFk`)
|
||||
REFERENCES `account`.`user` (`id`)
|
||||
ON DELETE NO ACTION
|
||||
ON UPDATE NO ACTION);
|
||||
|
||||
ALTER TABLE `vn`.`device`
|
||||
CHANGE COLUMN `id` `id` INT(11) NOT NULL AUTO_INCREMENT ;
|
|
@ -1,74 +0,0 @@
|
|||
USE `nst`;
|
||||
DROP procedure IF EXISTS `nodeAdd`;
|
||||
|
||||
DELIMITER $$
|
||||
USE `nst`$$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `nodeAdd`(IN `vScheme` VARCHAR(45), IN `vTable` VARCHAR(45), IN `vParentFk` INT, IN `vChild` VARCHAR(100))
|
||||
BEGIN
|
||||
DECLARE vSql TEXT;
|
||||
DECLARE vTableClone VARCHAR(45);
|
||||
|
||||
SET vTableClone = CONCAT(vTable, 'Clone');
|
||||
|
||||
CALL util.exec(CONCAT('DROP TEMPORARY TABLE IF EXISTS tmp.', vTableClone));
|
||||
CALL util.exec(CONCAT(
|
||||
'CREATE TEMPORARY TABLE tmp.', vTableClone,
|
||||
' ENGINE = MEMORY',
|
||||
' SELECT * FROM ', vScheme, '.', vTable
|
||||
));
|
||||
|
||||
CALL util.exec(CONCAT(
|
||||
'SELECT COUNT(c.id) INTO @childs',
|
||||
' FROM ', vScheme, '.', vTable, ' p',
|
||||
' LEFT JOIN tmp.', vTableClone, ' c ON c.lft',
|
||||
' BETWEEN p.lft AND p.rgt AND c.id != ', vParentFk,
|
||||
' WHERE p.id = ', vParentFk
|
||||
));
|
||||
|
||||
IF @childs = 0 THEN
|
||||
CALL util.exec(CONCAT(
|
||||
'SELECT lft INTO @vLeft',
|
||||
' FROM ', vScheme, '.', vTable,
|
||||
' WHERE id = ', vParentFk
|
||||
));
|
||||
ELSE
|
||||
CALL util.exec(CONCAT(
|
||||
'SELECT c.rgt INTO @vLeft',
|
||||
' FROM ', vScheme, '.', vTable, ' p',
|
||||
' JOIN tmp.', vTableClone, ' c ON c.depth = p.depth + 1'
|
||||
' AND c.lft BETWEEN p.lft AND p.rgt',
|
||||
' WHERE p.id = ', vParentFk,
|
||||
' ORDER BY c.lft',
|
||||
' DESC LIMIT 1'
|
||||
));
|
||||
END IF;
|
||||
|
||||
CALL util.exec(CONCAT(
|
||||
'UPDATE ', vScheme, '.', vTable, ' SET rgt = rgt + 2',
|
||||
' WHERE rgt > @vLeft',
|
||||
' ORDER BY rgt DESC'
|
||||
));
|
||||
CALL util.exec(CONCAT(
|
||||
'UPDATE ', vScheme, '.', vTable, ' SET lft = lft + 2',
|
||||
' WHERE lft > @vLeft',
|
||||
' ORDER BY lft DESC'
|
||||
));
|
||||
|
||||
SET vChild = REPLACE(vChild, "'", "\\'");
|
||||
|
||||
CALL util.exec(CONCAT(
|
||||
'INSERT INTO ', vScheme, '.', vTable, ' (name, lft, rgt)',
|
||||
' VALUES ("', vChild, '", @vLeft + 1, @vLeft + 2)'
|
||||
));
|
||||
|
||||
-- CALL util.exec(CONCAT(
|
||||
-- 'SELECT id, name, lft, rgt, depth, sons',
|
||||
-- ' FROM ', vScheme, '.', vTable,
|
||||
-- ' WHERE id = LAST_INSERT_ID()'
|
||||
-- ));
|
||||
|
||||
CALL util.exec(CONCAT('DROP TEMPORARY TABLE tmp.', vTableClone));
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -1,28 +0,0 @@
|
|||
DROP procedure IF EXISTS `vn`.`zoneNest`;
|
||||
|
||||
DELIMITER $$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`zoneNest`()
|
||||
BEGIN
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.zoneGeo;
|
||||
CREATE TEMPORARY TABLE tmp.zoneGeo
|
||||
(id INT AUTO_INCREMENT PRIMARY KEY)
|
||||
ENGINE = MEMORY
|
||||
SELECT * FROM vn.zoneGeo;
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.country;
|
||||
CREATE TEMPORARY TABLE tmp.country
|
||||
SELECT id FROM country
|
||||
WHERE country IN('España exento');
|
||||
|
||||
CALL vn.zoneNestCountry();
|
||||
CALL vn.zoneNestProvince();
|
||||
CALL vn.zoneNestTown();
|
||||
CALL vn.zoneNestPostcode();
|
||||
CALL vn.nestTree('tmp', 'zoneGeo', 'vn', 'zoneGeo');
|
||||
|
||||
DROP TEMPORARY TABLE
|
||||
tmp.zoneGeo,
|
||||
tmp.country;
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
|
@ -1,55 +0,0 @@
|
|||
DROP procedure IF EXISTS `vn`.`zoneNestCountry`;
|
||||
|
||||
DELIMITER $$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`zoneNestCountry`()
|
||||
BEGIN
|
||||
|
||||
DECLARE vDone BOOL;
|
||||
DECLARE vParent INT DEFAULT 1;
|
||||
DECLARE vGeoFk INT;
|
||||
DECLARE vChildFk INT;
|
||||
DECLARE vChildName VARCHAR(100);
|
||||
DECLARE countryCur CURSOR FOR
|
||||
SELECT 1, c.id, c.`country`
|
||||
FROM vn.country c
|
||||
JOIN tmp.country tc ON tc.id = c.id
|
||||
ORDER BY c.`country`;
|
||||
|
||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||
|
||||
-- Remove existing countries
|
||||
DELETE zg FROM vn.country c
|
||||
JOIN tmp.country tc ON tc.id = c.id
|
||||
JOIN tmp.zoneGeo zg ON zg.id = c.geoFk;
|
||||
|
||||
-- Reset country geoFk
|
||||
UPDATE vn.country c
|
||||
JOIN tmp.country tc ON tc.id = c.id
|
||||
SET c.geoFk = NULL
|
||||
WHERE c.geoFk IS NOT NULL;
|
||||
|
||||
-- > Country cursor start
|
||||
OPEN countryCur;
|
||||
|
||||
countryLoop: LOOP
|
||||
SET vDone = FALSE;
|
||||
|
||||
FETCH countryCur INTO vParent, vChildFk, vChildName;
|
||||
|
||||
IF vDone THEN
|
||||
LEAVE countryLoop;
|
||||
END IF;
|
||||
|
||||
CALL nst.nodeAdd('tmp', 'zoneGeo', vParent, vChildName);
|
||||
END LOOP;
|
||||
CLOSE countryCur;
|
||||
-- < Country cursor end
|
||||
|
||||
UPDATE country c
|
||||
JOIN tmp.zoneGeo z ON z.name = c.country
|
||||
SET c.geoFk = z.id
|
||||
WHERE c.geoFk IS NULL;
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
|
|
@ -1,61 +0,0 @@
|
|||
DROP procedure IF EXISTS `vn`.`zoneNestPostcode`;
|
||||
|
||||
DELIMITER $$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`zoneNestPostcode`()
|
||||
BEGIN
|
||||
|
||||
DECLARE vDone BOOL;
|
||||
DECLARE vParent INT DEFAULT 1;
|
||||
DECLARE vGeoFk INT;
|
||||
DECLARE vChildFk INT;
|
||||
DECLARE vChildName VARCHAR(100);
|
||||
DECLARE postcodeCur CURSOR FOR
|
||||
SELECT t.geoFk, pc.`code`, pc.`code`
|
||||
FROM vn.postCode pc
|
||||
JOIN vn.town t ON t.id = pc.townFk
|
||||
JOIN vn.province p ON p.id = t.provinceFk
|
||||
JOIN tmp.country tc ON tc.id = p.countryFk
|
||||
ORDER BY t.geoFk, pc.`code`;
|
||||
|
||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||
|
||||
-- Remove existing postCodes from zoneGeo
|
||||
DELETE zg FROM vn.postCode pc
|
||||
JOIN vn.town t ON t.id = pc.townFk
|
||||
JOIN vn.province p ON p.id = t.provinceFk
|
||||
JOIN tmp.country tc ON tc.id = p.countryFk
|
||||
JOIN tmp.zoneGeo zg ON zg.id = pc.geoFk;
|
||||
|
||||
-- Reset town geoFk
|
||||
UPDATE vn.postCode pc
|
||||
JOIN vn.town t ON t.id = pc.townFk
|
||||
JOIN vn.province p ON p.id = t.provinceFk
|
||||
JOIN tmp.country tc ON tc.id = p.countryFk
|
||||
SET pc.geoFk = NULL
|
||||
WHERE pc.geoFk IS NOT NULL;
|
||||
|
||||
-- > Postcode cursor start
|
||||
OPEN postcodeCur;
|
||||
|
||||
postcodeLoop: LOOP
|
||||
SET vDone = FALSE;
|
||||
|
||||
FETCH postcodeCur INTO vParent, vChildFk, vChildName;
|
||||
|
||||
IF vDone THEN
|
||||
LEAVE postcodeLoop;
|
||||
END IF;
|
||||
|
||||
CALL nst.nodeAdd('tmp', 'zoneGeo', vParent, vChildName);
|
||||
END LOOP;
|
||||
CLOSE postcodeCur;
|
||||
-- < Postcode cursor end
|
||||
|
||||
UPDATE postCode p
|
||||
JOIN tmp.zoneGeo z ON z.name = p.code
|
||||
SET p.geoFk = z.id
|
||||
WHERE p.geoFk IS NULL;
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
|
|
@ -1,56 +0,0 @@
|
|||
DROP procedure IF EXISTS `vn`.`zoneNestProvince`;
|
||||
|
||||
DELIMITER $$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`zoneNestProvince`()
|
||||
BEGIN
|
||||
|
||||
DECLARE vDone BOOL;
|
||||
DECLARE vParent INT DEFAULT 1;
|
||||
DECLARE vGeoFk INT;
|
||||
DECLARE vChildFk INT;
|
||||
DECLARE vChildName VARCHAR(100);
|
||||
DECLARE provinceCur CURSOR FOR
|
||||
SELECT c.geoFk, p.id, p.`name`
|
||||
FROM province p
|
||||
JOIN tmp.country tc ON tc.id = p.countryFk
|
||||
JOIN vn.country c ON c.id = tc.id
|
||||
ORDER BY c.geoFk, p.`name`;
|
||||
|
||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||
|
||||
-- Remove existing provinces from zoneGeo
|
||||
DELETE zg FROM vn.province p
|
||||
JOIN tmp.country tc ON tc.id = p.countryFk
|
||||
JOIN tmp.zoneGeo zg ON zg.id = p.geoFk;
|
||||
|
||||
-- Reset country geoFk
|
||||
UPDATE vn.province p
|
||||
JOIN tmp.country tc ON tc.id = p.countryFk
|
||||
SET p.geoFk = NULL
|
||||
WHERE p.geoFk IS NOT NULL;
|
||||
|
||||
-- > Province cursor start
|
||||
OPEN provinceCur;
|
||||
|
||||
provinceLoop: LOOP
|
||||
SET vDone = FALSE;
|
||||
|
||||
FETCH provinceCur INTO vParent, vChildFk, vChildName;
|
||||
|
||||
IF vDone THEN
|
||||
LEAVE provinceLoop;
|
||||
END IF;
|
||||
|
||||
CALL nst.nodeAdd('tmp', 'zoneGeo', vParent, vChildName);
|
||||
END LOOP;
|
||||
CLOSE provinceCur;
|
||||
-- < Province cursor end
|
||||
|
||||
UPDATE province p
|
||||
JOIN tmp.zoneGeo z ON z.name = p.name
|
||||
SET p.geoFk = z.id
|
||||
WHERE p.geoFk IS NULL;
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
|
|
@ -1,59 +0,0 @@
|
|||
DROP procedure IF EXISTS `vn`.`zoneNestTown`;
|
||||
|
||||
DELIMITER $$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`zoneNestTown`()
|
||||
BEGIN
|
||||
|
||||
DECLARE vDone BOOL;
|
||||
DECLARE vParent INT DEFAULT 1;
|
||||
DECLARE vGeoFk INT;
|
||||
DECLARE vChildFk INT;
|
||||
DECLARE vChildName VARCHAR(100);
|
||||
DECLARE townCur CURSOR FOR
|
||||
SELECT p.geoFk, t.id, t.`name`
|
||||
FROM vn.town t
|
||||
JOIN vn.province p ON p.id = t.provinceFk
|
||||
JOIN tmp.country tc ON tc.id = p.countryFk
|
||||
ORDER BY p.geoFk, t.`name`;
|
||||
|
||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||
|
||||
-- Remove existing towns from zoneGeo
|
||||
DELETE zg FROM vn.town t
|
||||
JOIN vn.province p ON p.id = t.provinceFk
|
||||
JOIN tmp.country tc ON tc.id = p.countryFk
|
||||
JOIN tmp.zoneGeo zg ON zg.id = t.geoFk;
|
||||
|
||||
-- Reset town geoFk
|
||||
UPDATE vn.town t
|
||||
JOIN vn.province p ON p.id = t.provinceFk
|
||||
JOIN tmp.country tc ON tc.id = p.countryFk
|
||||
SET t.geoFk = NULL
|
||||
WHERE t.geoFk IS NOT NULL;
|
||||
|
||||
-- > Town cursor start
|
||||
OPEN townCur;
|
||||
|
||||
townLoop: LOOP
|
||||
SET vDone = FALSE;
|
||||
|
||||
FETCH townCur INTO vParent, vChildFk, vChildName;
|
||||
|
||||
IF vDone THEN
|
||||
LEAVE townLoop;
|
||||
END IF;
|
||||
|
||||
CALL nst.nodeAdd('tmp', 'zoneGeo', vParent, vChildName);
|
||||
END LOOP;
|
||||
CLOSE townCur;
|
||||
-- < Town cursor end
|
||||
|
||||
UPDATE town t
|
||||
JOIN tmp.zoneGeo z ON z.name = t.name
|
||||
LEFT JOIN province p ON p.geoFk = z.id
|
||||
SET t.geoFk = z.id
|
||||
WHERE p.geoFk IS NULL;
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
|
||||
CREATE
|
||||
OR REPLACE ALGORITHM = UNDEFINED
|
||||
DEFINER = `root`@`%`
|
||||
SQL SECURITY DEFINER
|
||||
VIEW `vn`.`ticketGetVolume` AS
|
||||
SELECT
|
||||
`s`.`ticketFk` AS `ticketFk`,
|
||||
`t`.`routeFk` AS `routeFk`,
|
||||
`s`.`id` AS `saleFk`,
|
||||
`t`.`shipped` AS `Fecha`,
|
||||
(((`s`.`quantity` * `r`.`cm3`) * `i`.`compression`) / 1000000) AS `volume`
|
||||
FROM
|
||||
(((`vn`.`sale` `s`
|
||||
JOIN `vn`.`item` `i` ON ((`i`.`id` = `s`.`itemFk`)))
|
||||
JOIN `vn`.`ticket` `t` ON ((`t`.`id` = `s`.`ticketFk`)))
|
||||
JOIN `bi`.`rotacion` `r` ON (((`r`.`Id_Article` = `s`.`itemFk`)
|
||||
AND (`r`.`warehouse_id` = `t`.`warehouseFk`))));
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
|
||||
DROP function IF EXISTS `vn`.`ticketTotalVolume`;
|
||||
|
||||
DELIMITER $$
|
||||
USE `vn`$$
|
||||
CREATE DEFINER=`root`@`%` FUNCTION `ticketTotalVolume`(vTicketId INT) RETURNS decimal(10,3)
|
||||
READS SQL DATA
|
||||
BEGIN
|
||||
-- Devuelte el volumen total del ticket sumado
|
||||
-- DECLARE vWarehouseId INTEGER;
|
||||
-- DECLARE vShippedDate DATE;
|
||||
DECLARE vVolume DECIMAL(10,3);
|
||||
/*
|
||||
SELECT warehouseFk, shipped INTO vWarehouseId,vShippedDate FROM vn.ticket WHERE id = vTicketId;
|
||||
|
||||
SELECT IFNULL(SUM(s.quantity * i.compression * r.cm3)/1000000,0) INTO vVolume
|
||||
FROM sale s
|
||||
JOIN vn.item i ON i.id = s.itemFk
|
||||
JOIN bi.rotacion r on r.Id_Article = s.itemFk AND r.warehouse_id = vWarehouseId
|
||||
WHERE s.ticketFk = vTicketId;
|
||||
*/
|
||||
SELECT sum(volume) INTO vVolume
|
||||
FROM ticketGetVolume
|
||||
WHERE ticketFk = vTicketId;
|
||||
RETURN vVolume;
|
||||
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
|
|
@ -1,61 +0,0 @@
|
|||
|
||||
DROP procedure IF EXISTS `vn`.`available_calc`;
|
||||
DELIMITER $$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`available_calc`(
|
||||
vDate DATE,
|
||||
vAddress INT,
|
||||
vAgencyMode INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Calculates the available for all available stores
|
||||
* according to the given parameters.
|
||||
*
|
||||
* @param vDate The delivery date
|
||||
* @param vAddress The delivery address id
|
||||
* @param vAgencyMode The shipping agency
|
||||
* @return tmp.availableCalc(calcFk) The available cache ids
|
||||
*/
|
||||
DECLARE vCalcFk INT;
|
||||
DECLARE vShipment DATE;
|
||||
DECLARE vWarehouse INT;
|
||||
DECLARE vDone BOOL;
|
||||
|
||||
DECLARE cWarehouses CURSOR FOR
|
||||
SELECT warehouseFk, shipped FROM tmp.zoneGetShipped;
|
||||
|
||||
DECLARE CONTINUE HANDLER FOR NOT FOUND
|
||||
SET vDone = TRUE;
|
||||
|
||||
-- Establecemos los almacenes y las fechas que van a entrar al disponible
|
||||
|
||||
CALL vn.zoneGetShippedWarehouse(vDate, vAddress, vAgencyMode);
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.availableCalc;
|
||||
CREATE TEMPORARY TABLE tmp.availableCalc(
|
||||
calcFk INT UNSIGNED,
|
||||
PRIMARY KEY (calcFk)
|
||||
)
|
||||
ENGINE = MEMORY;
|
||||
|
||||
OPEN cWarehouses;
|
||||
|
||||
l: LOOP
|
||||
SET vDone = FALSE;
|
||||
FETCH cWarehouses INTO vWarehouse, vShipment;
|
||||
|
||||
IF vDone THEN
|
||||
LEAVE l;
|
||||
END IF;
|
||||
|
||||
CALL `cache`.available_refresh(vCalcFk, FALSE, vWarehouse, vShipment);
|
||||
|
||||
INSERT IGNORE INTO tmp.availableCalc
|
||||
SET calcFk = vCalcFk;
|
||||
END LOOP;
|
||||
|
||||
CLOSE cWarehouses;
|
||||
DROP TEMPORARY TABLE tmp.zoneGetShipped;
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
|
||||
DROP procedure IF EXISTS `vn`.`catalog_calcFromItem`;
|
||||
DELIMITER $$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`catalog_calcFromItem`(
|
||||
vLanded DATE,
|
||||
vAddressFk INT,
|
||||
vAgencyModeFk INT,
|
||||
vItemFk INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Calculates available and price for a single item.
|
||||
*
|
||||
* @param vItemFk The item id
|
||||
* @return tmp.ticketCalculateItem
|
||||
* @return tmp.ticketComponentPrice
|
||||
* @return tmp.ticketComponent
|
||||
* @return tmp.ticketLot
|
||||
* @return tmp.zoneGetShipped
|
||||
*/
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.item;
|
||||
CREATE TEMPORARY TABLE tmp.item
|
||||
ENGINE = MEMORY
|
||||
SELECT vItemFk itemFk;
|
||||
|
||||
CALL ticketCalculate(vLanded, vAddressFk, vAgencyModeFk);
|
||||
DROP TEMPORARY TABLE tmp.item;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,41 +0,0 @@
|
|||
|
||||
DROP procedure IF EXISTS `hedera`.`catalog_calcFromMyAddress`;
|
||||
DELIMITER $$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `hedera`.`catalog_calcFromMyAddress`(vDelivery DATE, vAddress INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Gets the available items list.
|
||||
*
|
||||
* @param vDelivery Delivery date
|
||||
* @param vAddress Address id
|
||||
* @return tmp.ticketCalculateItem
|
||||
* @return tmp.ticketComponentPrice
|
||||
* @return tmp.ticketComponent
|
||||
* @return tmp.ticketLot
|
||||
* @return tmp.zoneGetShipped
|
||||
*/
|
||||
DECLARE vAgencyMode INT;
|
||||
|
||||
SELECT a.agencyModeFk
|
||||
INTO vAgencyMode
|
||||
FROM myClient c
|
||||
JOIN vn.address a ON a.clientFk = c.id
|
||||
WHERE a.id = vAddress;
|
||||
|
||||
CALL vn.available_calc(vDelivery, vAddress, vAgencyMode);
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.item;
|
||||
CREATE TEMPORARY TABLE tmp.item
|
||||
(INDEX (itemFk))
|
||||
ENGINE = MEMORY
|
||||
SELECT c.item_id itemFk
|
||||
FROM `cache`.available c
|
||||
JOIN tmp.availableCalc a ON a.calcFk = c.calc_id
|
||||
WHERE c.available > 0
|
||||
GROUP BY c.item_id;
|
||||
|
||||
CALL vn.ticketCalculate(vDelivery, vAddress, vAgencyMode);
|
||||
|
||||
DROP TEMPORARY TABLE tmp.item;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,398 +0,0 @@
|
|||
|
||||
USE `vn2008`;
|
||||
DROP procedure IF EXISTS `vn2008`.`bionic_available_`;
|
||||
|
||||
DELIMITER $$
|
||||
USE `vn2008`$$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `__bionic_available_`(
|
||||
vDate DATE,
|
||||
vAddress INT,
|
||||
vAgency INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Calcula el disponible para un conjunto de almacenes y fechas
|
||||
* devueltos por el procedimiento agencyHourGetShipped()
|
||||
*
|
||||
* @deprecated Use vn.available_calc()
|
||||
* @table t_bionic_available Tabla con los ids de cache
|
||||
*/
|
||||
DECLARE vAvailableCalc INT;
|
||||
DECLARE vShipment DATE;
|
||||
DECLARE vAgencyId INT;
|
||||
DECLARE vWh INT;
|
||||
DECLARE vDone BOOL;
|
||||
DECLARE cTravelTree CURSOR FOR
|
||||
SELECT warehouseFk, shipped FROM tmp.agencyHourGetShipped;
|
||||
|
||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||
|
||||
-- Establecemos los almacenes y las fechas que van a entrar al disponible
|
||||
|
||||
SELECT agency_id INTO vAgencyId
|
||||
FROM Agencias WHERE Id_Agencia = vAgency;
|
||||
|
||||
CALL vn.agencyHourGetShipped (vDate, vAddress, vAgencyId);
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS t_bionic_available;
|
||||
CREATE TEMPORARY TABLE t_bionic_available(
|
||||
calc_id INT UNSIGNED,
|
||||
PRIMARY KEY (calc_id)
|
||||
)
|
||||
ENGINE = MEMORY;
|
||||
|
||||
OPEN cTravelTree;
|
||||
l: LOOP
|
||||
SET vDone = FALSE;
|
||||
FETCH cTravelTree INTO vWh, vShipment;
|
||||
|
||||
IF vDone THEN
|
||||
LEAVE l;
|
||||
END IF;
|
||||
|
||||
CALL `cache`.available_refresh (vAvailableCalc, FALSE, vWh, vShipment);
|
||||
|
||||
INSERT IGNORE INTO t_bionic_available
|
||||
SET calc_id = vAvailableCalc;
|
||||
END LOOP;
|
||||
|
||||
CLOSE cTravelTree;
|
||||
DROP TEMPORARY TABLE tmp.agencyHourGetShipped;
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
;
|
||||
|
||||
|
||||
USE `hedera`;
|
||||
DROP procedure IF EXISTS `hedera`.`bionic_from_item`;
|
||||
|
||||
DELIMITER $$
|
||||
USE `hedera`$$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `__bionic_from_item`(vItem INT)
|
||||
BEGIN
|
||||
DECLARE vDate DATE;
|
||||
DECLARE vAddress INT;
|
||||
DECLARE vAgencyMode INT;
|
||||
|
||||
SELECT sent, addressFk, agencyModeFk
|
||||
INTO vDate, vAddress, vAgencyMode
|
||||
FROM myBasket;
|
||||
|
||||
CALL vn2008.bionic_from_item(vDate, vAddress, vAgencyMode, vItem);
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
;
|
||||
|
||||
|
||||
USE `vn2008`;
|
||||
DROP procedure IF EXISTS `vn2008`.`bionic_from_order`;
|
||||
|
||||
DELIMITER $$
|
||||
USE `vn2008`$$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `__bionic_from_order`(
|
||||
v_date DATE, -- fecha de recepcion de mercancia
|
||||
v_consigna INT,
|
||||
v_agencia INT,
|
||||
v_order INT)
|
||||
BEGIN
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.bionic_calc;
|
||||
CREATE TEMPORARY TABLE tmp.bionic_calc
|
||||
(PRIMARY KEY (item_id))
|
||||
ENGINE = MEMORY
|
||||
SELECT item_id FROM order_row
|
||||
WHERE order_id = v_order GROUP BY item_id;
|
||||
|
||||
CALL bionic_calc (v_date, v_consigna, v_agencia);
|
||||
DROP TEMPORARY TABLE tmp.bionic_calc;
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
;
|
||||
|
||||
|
||||
USE `hedera`;
|
||||
DROP procedure IF EXISTS `hedera`.`bionicCalcWithDate`;
|
||||
|
||||
DELIMITER $$
|
||||
USE `hedera`$$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `__bionicCalcWithDate`(vDate DATE)
|
||||
BEGIN
|
||||
DECLARE vMyAddressFk INTEGER;
|
||||
DECLARE vMyAgencyModeFk INTEGER;
|
||||
|
||||
SELECT id, agencyModeFk INTO vMyAddressFk, vMyAgencyModeFk
|
||||
FROM myAddress
|
||||
WHERE isDefaultAddress;
|
||||
|
||||
CALL vn2008.bionic_calc(vDate, vMyAddressFk, vMyAgencyModeFk);
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
;
|
||||
|
||||
|
||||
USE `hedera`;
|
||||
DROP procedure IF EXISTS `hedera`.`bionic_calc`;
|
||||
|
||||
DELIMITER $$
|
||||
USE `hedera`$$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `__bionic_calc`()
|
||||
BEGIN
|
||||
DECLARE vDate DATE;
|
||||
DECLARE vAddress INT;
|
||||
DECLARE vAgencyMode INT;
|
||||
|
||||
SELECT sent, addressFk, agencyModeFk
|
||||
INTO vDate, vAddress, vAgencyMode
|
||||
FROM myBasket;
|
||||
|
||||
CALL vn2008.bionic_calc(vDate, vAddress, vAgencyMode);
|
||||
|
||||
IF account.myUserGetName() = 'visitor'
|
||||
THEN
|
||||
DROP TEMPORARY TABLE tmp.bionic_component;
|
||||
UPDATE tmp.bionic_item SET price = NULL;
|
||||
END IF;
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
;
|
||||
|
||||
|
||||
USE `hedera`;
|
||||
DROP procedure IF EXISTS `hedera`.`itemGetAvailableOrder`;
|
||||
|
||||
DELIMITER $$
|
||||
USE `hedera`$$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `__itemGetAvailableOrder`(vOrder INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Gets the available items list with an order params.
|
||||
*
|
||||
* @table tmp.itemAvailable
|
||||
*/
|
||||
DECLARE vDelivery DATE;
|
||||
DECLARE vAddress INT;
|
||||
DECLARE vAgency INT;
|
||||
|
||||
SELECT landed, addressFk, agencyModeFk
|
||||
INTO vDelivery, vAddress, vAgency
|
||||
FROM myOrder
|
||||
WHERE id = vOrder;
|
||||
|
||||
CALL vn2008.bionic_available_ (vDelivery, vAddress, vAgency);
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.itemAvailable;
|
||||
CREATE TEMPORARY TABLE tmp.itemAvailable
|
||||
(INDEX (id))
|
||||
ENGINE = MEMORY
|
||||
SELECT c.item_id id
|
||||
FROM cache.available c
|
||||
JOIN vn2008.t_bionic_available a ON c.calc_id = a.calc_id
|
||||
WHERE c.available > 0
|
||||
GROUP BY c.item_id;
|
||||
|
||||
DROP TEMPORARY TABLE vn2008.t_bionic_available;
|
||||
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
;
|
||||
|
||||
|
||||
USE `hedera`;
|
||||
DROP procedure IF EXISTS `hedera`.`itemGetAvailable`;
|
||||
|
||||
DELIMITER $$
|
||||
USE `hedera`$$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `__itemGetAvailable`()
|
||||
BEGIN
|
||||
/**
|
||||
* Gets the available items list.
|
||||
*
|
||||
* @table tmp.itemAvailable
|
||||
*/
|
||||
DECLARE vDelivery DATE;
|
||||
DECLARE vAddress INT;
|
||||
DECLARE vAgency INT;
|
||||
|
||||
SELECT sent, addressFk, agencyModeFk
|
||||
INTO vDelivery, vAddress, vAgency
|
||||
FROM myBasket;
|
||||
|
||||
CALL vn2008.bionic_available_ (vDelivery, vAddress, vAgency);
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.itemAvailable;
|
||||
CREATE TEMPORARY TABLE tmp.itemAvailable
|
||||
(INDEX (id))
|
||||
ENGINE = MEMORY
|
||||
SELECT c.item_id id
|
||||
FROM cache.available c
|
||||
JOIN vn2008.t_bionic_available a ON c.calc_id = a.calc_id
|
||||
WHERE c.available > 0
|
||||
GROUP BY c.item_id;
|
||||
|
||||
DROP TEMPORARY TABLE vn2008.t_bionic_available;
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
;
|
||||
|
||||
|
||||
USE `hedera`;
|
||||
DROP procedure IF EXISTS `hedera`.`myItemGetAvailableFromDate`;
|
||||
|
||||
DELIMITER $$
|
||||
USE `hedera`$$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `__myItemGetAvailableFromDate`(vDelivery DATE)
|
||||
BEGIN
|
||||
/**
|
||||
* Gets the available items list.
|
||||
*
|
||||
* @deprecated Use item_calcCatalogFromMyAddress()
|
||||
* @param vDelivery Delivery date
|
||||
*/
|
||||
DECLARE vAddress INT;
|
||||
DECLARE vAgencyMode INT;
|
||||
|
||||
SELECT a.agencyModeFk, a.id
|
||||
INTO vAgencyMode, vAddress
|
||||
FROM myClient c
|
||||
JOIN vn.address a ON a.id = c.defaultAddressFk;
|
||||
|
||||
CALL vn2008.bionic_available_ (vDelivery, vAddress, vAgencyMode);
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.item;
|
||||
CREATE TEMPORARY TABLE tmp.item
|
||||
(INDEX (itemFk))
|
||||
ENGINE = MEMORY
|
||||
SELECT c.item_id itemFk
|
||||
FROM cache.available c
|
||||
JOIN vn2008.t_bionic_available a ON c.calc_id = a.calc_id
|
||||
WHERE c.available > 0
|
||||
GROUP BY c.item_id;
|
||||
|
||||
CALL vn.ticketCalculate(vDelivery, vAddress, vAgencyMode);
|
||||
-- -------------------
|
||||
/*SELECT b.itemFk, b.item, b.available, b.price
|
||||
FROM tmp.ticketCalculateItem b
|
||||
JOIN vn.item i ON i.id = b.itemFk
|
||||
WHERE b.available > 0
|
||||
ORDER BY i.relevancy DESC, i.name, i.size;
|
||||
|
||||
select * from tmp.ticketComponentPrice;*/
|
||||
-- -------------------
|
||||
DROP TEMPORARY TABLE vn2008.t_bionic_available;
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
;
|
||||
|
||||
|
||||
USE `hedera`;
|
||||
DROP procedure IF EXISTS `hedera`.`myItemGetAvailable`;
|
||||
|
||||
DELIMITER $$
|
||||
USE `hedera`$$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `__myItemGetAvailable`(vDelivery DATE, vAddress INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Gets the available items list.
|
||||
*
|
||||
* @deprecated Use item_calcCatalogFromMyAddress()
|
||||
* @param vDelivery Delivery date
|
||||
* @param vAddress Id Address
|
||||
*/
|
||||
DECLARE vAgencyMode INT;
|
||||
|
||||
SELECT a.agencyModeFk
|
||||
INTO vAgencyMode
|
||||
FROM myClient c
|
||||
JOIN vn.address a ON a.clientFk = c.id
|
||||
WHERE a.id = vAddress;
|
||||
|
||||
CALL vn2008.bionic_available_ (vDelivery, vAddress, vAgencyMode);
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.item;
|
||||
CREATE TEMPORARY TABLE tmp.item
|
||||
(INDEX (itemFk))
|
||||
ENGINE = MEMORY
|
||||
SELECT c.item_id itemFk
|
||||
FROM cache.available c
|
||||
JOIN vn2008.t_bionic_available a ON c.calc_id = a.calc_id
|
||||
WHERE c.available > 0
|
||||
GROUP BY c.item_id;
|
||||
|
||||
CALL vn.ticketCalculate(vDelivery, vAddress, vAgencyMode);
|
||||
-- -------------------
|
||||
/*SELECT b.itemFk, b.item, b.available, b.price
|
||||
FROM tmp.ticketCalculateItem b
|
||||
JOIN vn.item i ON i.id = b.itemFk
|
||||
WHERE b.available > 0
|
||||
ORDER BY i.relevancy DESC, i.name, i.size;
|
||||
|
||||
select * from tmp.ticketComponentPrice;*/
|
||||
-- -------------------
|
||||
DROP TEMPORARY TABLE vn2008.t_bionic_available;
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
;
|
||||
|
||||
|
||||
USE `hedera`;
|
||||
DROP procedure IF EXISTS `hedera`.`myOrderAddItem`;
|
||||
|
||||
DELIMITER $$
|
||||
USE `hedera`$$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `__myOrderAddItem`(
|
||||
vSelf INT,
|
||||
vWarehouse INT,
|
||||
vItem INT,
|
||||
vAmount INT)
|
||||
BEGIN
|
||||
/**
|
||||
* @deprecated Use myOrder_addItem()
|
||||
*/
|
||||
CALL myOrder_addItem(vSelf, vWarehouse, vItem, vAmount);
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
;
|
||||
|
||||
|
||||
USE `hedera`;
|
||||
DROP procedure IF EXISTS `hedera`.`myOrderConfirm`;
|
||||
|
||||
DELIMITER $$
|
||||
USE `hedera`$$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `__myOrderConfirm`(vSelf INT)
|
||||
BEGIN
|
||||
/**
|
||||
* @deprecated Use myOrder_confirm()
|
||||
*/
|
||||
CALL myOrder_confirm(vSelf);
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
;
|
||||
|
||||
|
||||
USE `hedera`;
|
||||
DROP procedure IF EXISTS `hedera`.`myOrderNewFromDate`;
|
||||
|
||||
DELIMITER $$
|
||||
USE `hedera`$$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `__myOrderNewFromDate`(
|
||||
OUT vSelf INT,
|
||||
vLandingDate DATE)
|
||||
BEGIN
|
||||
/**
|
||||
* @deprecated Use myOrder_newWithDate()
|
||||
*/
|
||||
CALL myOrder_newWithDate(vSelf, vLandingDate);
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
;
|
|
@ -1,19 +0,0 @@
|
|||
|
||||
DROP procedure IF EXISTS `hedera`.`myBasket_calcCatalogFromItem`;
|
||||
DELIMITER $$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `hedera`.`myBasket_calcCatalogFromItem`(vItem INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Gets the availability and prices for the given item
|
||||
* using current user basket parameters.
|
||||
*
|
||||
* @table tmp.item(itemFk)
|
||||
* @return tmp.ticketCalculateItem
|
||||
* @return tmp.ticketComponentPrice
|
||||
* @return tmp.ticketComponent
|
||||
* @return tmp.ticketLot
|
||||
* @return tmp.zoneGetShipped
|
||||
*/
|
||||
CALL order_calcCatalogFromItem(myBasket_getId(), vItem);
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,19 +0,0 @@
|
|||
|
||||
DROP procedure IF EXISTS `hedera`.`myBasket_calcCatalogFull`;
|
||||
DELIMITER $$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `hedera`.`myBasket_calcCatalogFull`()
|
||||
BEGIN
|
||||
/**
|
||||
* Gets the availability and prices for the given items
|
||||
* using current user basket parameters.
|
||||
*
|
||||
* @table tmp.item(itemFk)
|
||||
* @return tmp.ticketCalculateItem
|
||||
* @return tmp.ticketComponentPrice
|
||||
* @return tmp.ticketComponent
|
||||
* @return tmp.ticketLot
|
||||
* @return tmp.zoneGetShipped
|
||||
*/
|
||||
CALL order_calcCatalogFull(myBasket_getId());
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,14 +0,0 @@
|
|||
|
||||
DROP procedure IF EXISTS `hedera`.`myBasket_getAvailable`;
|
||||
DELIMITER $$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `hedera`.`myBasket_getAvailable`()
|
||||
BEGIN
|
||||
/**
|
||||
* Gets the available items list.
|
||||
*
|
||||
* @table tmp.itemAvailable
|
||||
*/
|
||||
CALL order_getAvailable(myBasket_getId());
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
|
||||
DROP procedure IF EXISTS `hedera`.`myOrder_getAvailable`;
|
||||
DELIMITER $$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `hedera`.`myOrder_getAvailable`(vSelf INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Gets the available items list.
|
||||
*
|
||||
* @param vSelf The order id
|
||||
* @table tmp.itemAvailable
|
||||
*/
|
||||
DECLARE isMine BOOL;
|
||||
|
||||
SELECT COUNT(*) INTO isMine
|
||||
FROM myOrder
|
||||
WHERE id = vSelf;
|
||||
|
||||
IF isMine THEN
|
||||
CALL order_getAvailable(vSelf);
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,105 +0,0 @@
|
|||
|
||||
DROP procedure IF EXISTS `hedera`.`order_addItem`;
|
||||
DELIMITER $$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `hedera`.`order_addItem`(
|
||||
vSelf INT,
|
||||
vWarehouse INT,
|
||||
vItem INT,
|
||||
vAmount INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Adds an item to the order, checking availability and grouping.
|
||||
*
|
||||
* @param vSelf The order id
|
||||
* @param vWarehouse The warehouse id
|
||||
* @param vItem The item id
|
||||
* @param vAmount The amount to add
|
||||
*/
|
||||
DECLARE vRow INT;
|
||||
DECLARE vAdd INT;
|
||||
DECLARE vAvailable INT;
|
||||
DECLARE vDone BOOL;
|
||||
DECLARE vGrouping INT;
|
||||
DECLARE vRate INT;
|
||||
DECLARE vShipment DATE;
|
||||
DECLARE vPrice DECIMAL(10,2);
|
||||
DECLARE cur CURSOR FOR
|
||||
SELECT `grouping`, price, rate
|
||||
FROM tmp.ticketComponentPrice
|
||||
WHERE warehouseFk = vWarehouse
|
||||
AND itemFk = vItem
|
||||
ORDER BY `grouping` DESC;
|
||||
|
||||
DECLARE CONTINUE HANDLER FOR NOT FOUND
|
||||
SET vDone = TRUE;
|
||||
|
||||
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
||||
BEGIN
|
||||
ROLLBACK;
|
||||
RESIGNAL;
|
||||
END;
|
||||
|
||||
CALL order_calcCatalogFromItem(vSelf, vItem);
|
||||
START TRANSACTION;
|
||||
|
||||
SELECT shipped INTO vShipment
|
||||
FROM tmp.zoneGetShipped
|
||||
WHERE warehouseFk = vWarehouse;
|
||||
|
||||
SELECT available INTO vAvailable
|
||||
FROM tmp.ticketLot
|
||||
WHERE warehouseFk = vWarehouse
|
||||
AND itemFk = vItem;
|
||||
|
||||
IF vAmount > IFNULL(vAvailable, 0) THEN
|
||||
CALL util.throw ('ORDER_ROW_UNAVAILABLE');
|
||||
END IF;
|
||||
|
||||
OPEN cur;
|
||||
|
||||
l: LOOP
|
||||
SET vDone = FALSE;
|
||||
FETCH cur INTO vGrouping, vPrice, vRate;
|
||||
|
||||
IF vDone THEN
|
||||
LEAVE l;
|
||||
END IF;
|
||||
|
||||
SET vAdd = vAmount - MOD(vAmount, vGrouping);
|
||||
SET vAmount = vAmount - vAdd;
|
||||
|
||||
IF vAdd = 0 THEN
|
||||
ITERATE l;
|
||||
END IF;
|
||||
|
||||
INSERT INTO orderRow SET
|
||||
orderFk = vSelf,
|
||||
itemFk = vItem,
|
||||
warehouseFk = vWarehouse,
|
||||
shipment = vShipment,
|
||||
rate = vRate,
|
||||
amount = vAdd,
|
||||
price = vPrice;
|
||||
|
||||
SET vRow = LAST_INSERT_ID();
|
||||
|
||||
INSERT INTO orderRowComponent (rowFk, componentFk, price)
|
||||
SELECT vRow, c.componentFk, c.cost
|
||||
FROM tmp.ticketComponent c
|
||||
JOIN vn.component t
|
||||
ON t.id = c.componentFk
|
||||
AND (t.classRate IS NULL OR t.classRate = vRate)
|
||||
WHERE c.warehouseFk = vWarehouse
|
||||
AND c.itemFk = vItem;
|
||||
END LOOP;
|
||||
|
||||
CLOSE cur;
|
||||
|
||||
IF vAmount > 0 THEN
|
||||
CALL util.throw ('AMOUNT_NOT_MATCH_GROUPING');
|
||||
END IF;
|
||||
|
||||
COMMIT;
|
||||
CALL vn.ticketCalculatePurge;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,36 +0,0 @@
|
|||
|
||||
DROP procedure IF EXISTS `hedera`.`order_calcCatalog`;
|
||||
DELIMITER $$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `hedera`.`order_calcCatalog`(vSelf INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Gets the availability and prices for order items.
|
||||
*
|
||||
* @param vSelf The order id
|
||||
* @return tmp.ticketCalculateItem
|
||||
* @return tmp.ticketComponentPrice
|
||||
* @return tmp.ticketComponent
|
||||
* @return tmp.ticketLot
|
||||
*/
|
||||
DECLARE vDate DATE;
|
||||
DECLARE vAddress INT;
|
||||
DECLARE vAgencyMode INT;
|
||||
|
||||
SELECT date_send, address_id, agency_id
|
||||
INTO vDate, vAddress, vAgencyMode
|
||||
FROM `order`
|
||||
WHERE id = vSelf;
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.item;
|
||||
CREATE TEMPORARY TABLE tmp.item
|
||||
(PRIMARY KEY (itemFk))
|
||||
ENGINE = MEMORY
|
||||
SELECT itemFk FROM orderRow
|
||||
WHERE orderFk = vSelf
|
||||
GROUP BY itemFk;
|
||||
|
||||
CALL vn.ticketCalculate(vDate, vAddress, vAgencyMode);
|
||||
|
||||
DROP TEMPORARY TABLE tmp.item;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,30 +0,0 @@
|
|||
|
||||
DROP procedure IF EXISTS `hedera`.`order_calcCatalogFromItem`;
|
||||
DELIMITER $$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `hedera`.`order_calcCatalogFromItem`(vSelf INT, vItem INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Gets the availability and prices for the given item
|
||||
* using the order parameters.
|
||||
*
|
||||
* @param vSelf The order id
|
||||
* @table tmp.item(itemFk)
|
||||
* @return tmp.ticketCalculateItem
|
||||
* @return tmp.ticketComponentPrice
|
||||
* @return tmp.ticketComponent
|
||||
* @return tmp.ticketLot
|
||||
* @return tmp.zoneGetShipped
|
||||
*/
|
||||
DECLARE vDate DATE;
|
||||
DECLARE vAddress INT;
|
||||
DECLARE vAgencyMode INT;
|
||||
|
||||
SELECT date_send, address_id, agency_id
|
||||
INTO vDate, vAddress, vAgencyMode
|
||||
FROM `order`
|
||||
WHERE id = vSelf;
|
||||
|
||||
CALL vn.catalog_calcFromItem(vDate, vAddress, vAgencyMode, vItem);
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
|
||||
DROP procedure IF EXISTS `hedera`.`order_calcCatalogFull`;
|
||||
DELIMITER $$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `hedera`.`order_calcCatalogFull`(vSelf INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Gets the availability and prices for the given items
|
||||
* using the order parameters.
|
||||
*
|
||||
* @param vSelf The order id
|
||||
* @table tmp.item(itemFk)
|
||||
* @return tmp.ticketCalculateItem
|
||||
* @return tmp.ticketComponentPrice
|
||||
* @return tmp.ticketComponent
|
||||
* @return tmp.ticketLot
|
||||
* @return tmp.zoneGetShipped
|
||||
*/
|
||||
DECLARE vDate DATE;
|
||||
DECLARE vAddress INT;
|
||||
DECLARE vAgencyMode INT;
|
||||
|
||||
SELECT date_send, address_id, agency_id
|
||||
INTO vDate, vAddress, vAgencyMode
|
||||
FROM `order`
|
||||
WHERE id = vSelf;
|
||||
|
||||
CALL vn.ticketCalculate(vDate, vAddress, vAgencyMode);
|
||||
|
||||
IF account.myUserGetName() = 'visitor'
|
||||
THEN
|
||||
DROP TEMPORARY TABLE tmp.ticketComponent;
|
||||
UPDATE tmp.ticketCalculateItem SET price = NULL;
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,34 +0,0 @@
|
|||
DROP procedure IF EXISTS `hedera`.`order_getAvailable`;
|
||||
DELIMITER $$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `hedera`.`order_getAvailable`(vSelf INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Gets the available items list.
|
||||
*
|
||||
* @param vSelf The order id
|
||||
* @table tmp.itemAvailable
|
||||
*/
|
||||
DECLARE vDelivery DATE;
|
||||
DECLARE vAddress INT;
|
||||
DECLARE vAgencyMode INT;
|
||||
|
||||
SELECT date_send, address_id, agency_id
|
||||
INTO vDelivery, vAddress, vAgencyMode
|
||||
FROM `order`
|
||||
WHERE id = vSelf;
|
||||
|
||||
CALL vn.available_calc(vDelivery, vAddress, vAgencyMode);
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.itemAvailable;
|
||||
CREATE TEMPORARY TABLE tmp.itemAvailable
|
||||
(INDEX (id))
|
||||
ENGINE = MEMORY
|
||||
SELECT DISTINCT a.item_id id
|
||||
FROM `cache`.available a
|
||||
JOIN tmp.availableCalc c ON c.calcFk = a.calc_id
|
||||
WHERE a.available > 0;
|
||||
|
||||
DROP TEMPORARY TABLE tmp.availableCalc;
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
|
@ -1,71 +0,0 @@
|
|||
|
||||
DROP procedure IF EXISTS `hedera`.`order_update`;
|
||||
DELIMITER $$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `hedera`.`order_update`(vSelf INT)
|
||||
proc: BEGIN
|
||||
/**
|
||||
* Actualiza las líneas de un pedido.
|
||||
*
|
||||
* @param vSelf Id del pedido
|
||||
*/
|
||||
DECLARE vDate DATE;
|
||||
DECLARE vAddress INT;
|
||||
DECLARE vAgencyMode INT;
|
||||
DECLARE vNRows INT;
|
||||
|
||||
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
||||
BEGIN
|
||||
ROLLBACK;
|
||||
RESIGNAL;
|
||||
END;
|
||||
|
||||
START TRANSACTION;
|
||||
|
||||
SELECT COUNT(*) INTO vNRows
|
||||
FROM orderRow WHERE orderFk = vSelf;
|
||||
|
||||
IF vNRows > 0
|
||||
THEN
|
||||
CALL order_calcCatalog(vSelf);
|
||||
|
||||
DELETE c
|
||||
FROM orderRow r
|
||||
JOIN orderRowComponent c ON c.rowFk = r.id
|
||||
WHERE r.orderFk = vSelf;
|
||||
|
||||
UPDATE orderRow r
|
||||
LEFT JOIN tmp.ticketComponentPrice p
|
||||
ON p.warehouseFk = r.warehouseFk
|
||||
AND p.itemFk = r.itemFk
|
||||
AND p.rate = r.rate
|
||||
LEFT JOIN tmp.zoneGetShipped t
|
||||
ON t.warehouseFk = r.warehouseFk
|
||||
SET
|
||||
r.price = p.price,
|
||||
r.amount = IF(p.itemFk IS NOT NULL,
|
||||
r.amount + IF(@m := MOD(r.amount, p.`grouping`), p.`grouping` - @m, 0), 0),
|
||||
r.shipment = t.shipped
|
||||
WHERE r.orderFk = vSelf;
|
||||
|
||||
INSERT INTO orderRowComponent(rowFk, componentFk, price)
|
||||
SELECT r.id, c.componentFk, c.cost
|
||||
FROM orderRow r
|
||||
JOIN tmp.ticketComponent c
|
||||
ON c.warehouseFk = r.warehouseFk
|
||||
AND c.itemFk = r.itemFk
|
||||
JOIN vn.component t
|
||||
ON t.id = c.componentFk
|
||||
AND (t.classRate IS NULL OR t.classRate = r.rate)
|
||||
WHERE r.orderFk = vSelf;
|
||||
|
||||
CALL vn.ticketCalculatePurge;
|
||||
END IF;
|
||||
|
||||
UPDATE `order` SET date_make = NOW()
|
||||
WHERE id = vSelf;
|
||||
|
||||
COMMIT;
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
|
|
@ -1 +0,0 @@
|
|||
RENAME TABLE hedera.myOrderMyTicket TO hedera.myOrderTicket;
|
|
@ -1,10 +0,0 @@
|
|||
GRANT EXECUTE ON PROCEDURE vn.zoneGetAgency TO `account`@`%`;
|
||||
GRANT EXECUTE ON PROCEDURE hedera.myBasket_calcCatalogFromItem TO `guest`@`%`;
|
||||
GRANT EXECUTE ON PROCEDURE hedera.myBasket_calcCatalogFull TO `guest`@`%`;
|
||||
GRANT EXECUTE ON PROCEDURE hedera.myBasket_getAvailable TO `guest`@`%`;
|
||||
GRANT EXECUTE ON PROCEDURE hedera.myOrder_getAvailable TO `guest`@`%`;
|
||||
GRANT EXECUTE ON PROCEDURE hedera.catalog_calcFromMyAddress TO account@'%';
|
||||
REVOKE SELECT ON TABLE hedera.myOrderMyTicket FROM account@'%';
|
||||
GRANT SELECT ON TABLE hedera.myOrderTicket TO account@'%';
|
||||
|
||||
CALL account.privSync;
|
|
@ -0,0 +1,16 @@
|
|||
UPDATE `salix`.`ACL` SET principalId ='employee' WHERE id = 122;
|
||||
|
||||
INSERT INTO `salix`.`ACL` (`id`, `model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
(167, 'Worker', 'isSubordinate', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
(168, 'Worker', 'mySubordinates', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
(169, 'WorkerTimeControl', 'filter', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
(170, 'WorkerTimeControl', 'addTime', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
|
||||
(171, 'TicketServiceType', '*', 'WRITE', 'ALLOW', 'ROLE', 'administrative');
|
||||
|
||||
-- ONLY FOR ACL ALREADY ON PRODUCTION
|
||||
INSERT IGNORE INTO `salix`.`ACL` (`id`, `model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
(172, 'Sms', '*', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
(173, 'Sms', 'send', 'WRITE', 'ALLOW', 'ROLE', 'employee');
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
ALTER TABLE `vn2008`.`cl_est`
|
||||
ADD COLUMN `roleFk` INT(10) UNSIGNED NOT NULL DEFAULT '1' AFTER `estado`;
|
||||
|
||||
ALTER TABLE `vn2008`.`cl_est`
|
||||
ADD INDEX `roleFgn_idx` (`roleFk` ASC);
|
||||
|
||||
ALTER TABLE `vn2008`.`cl_est`
|
||||
ADD CONSTRAINT `roleFgn`
|
||||
FOREIGN KEY (`roleFk`)
|
||||
REFERENCES `account`.`role` (`id`)
|
||||
ON DELETE RESTRICT
|
||||
ON UPDATE CASCADE;
|
|
@ -0,0 +1,10 @@
|
|||
CREATE
|
||||
ALGORITHM = UNDEFINED
|
||||
DEFINER = `root`@`%`
|
||||
SQL SECURITY DEFINER
|
||||
VIEW `vn`.`clientDms` AS
|
||||
SELECT
|
||||
`g`.`Id_Cliente` AS `clientFk`,
|
||||
`g`.`gest_doc_id` AS `dmsFk`
|
||||
FROM
|
||||
`vn2008`.`clientes_gestdoc` `g`
|
|
@ -1,18 +1,17 @@
|
|||
USE `vn`;
|
||||
CREATE
|
||||
CREATE
|
||||
OR REPLACE ALGORITHM = UNDEFINED
|
||||
DEFINER = `root`@`%`
|
||||
DEFINER = `root`@`%`
|
||||
SQL SECURITY DEFINER
|
||||
VIEW `vn`.`dms` AS
|
||||
SELECT
|
||||
SELECT
|
||||
`g`.`id` AS `id`,
|
||||
`g`.`gesttip_id` AS `dmsTypeFk`,
|
||||
`g`.`file` AS `file`,
|
||||
`g`.`trabajador_id` AS `workerFk`,
|
||||
`g`.`warehouse_id` AS `warehouseFk`,
|
||||
`g`.`emp_id` AS `companyFk`,
|
||||
`g`.`orden` AS `priority`,
|
||||
`g`.`file` AS `hasFile`,
|
||||
`g`.`orden` AS `hardCopyNumber`,
|
||||
`g`.`original` AS `hasFile`,
|
||||
`g`.`sref` AS `reference`,
|
||||
`g`.`brief` AS `description`,
|
||||
`g`.`odbc_date` AS `created`
|
|
@ -0,0 +1 @@
|
|||
UPDATE `vn2008`.`mandato_tipo` SET `Nombre`='LCR' WHERE `idmandato_tipo`='3';
|
|
@ -0,0 +1,4 @@
|
|||
|
||||
INSERT INTO `vn`.`sample`(`code`, `description`, `isVisible`, `hasCompany`)
|
||||
VALUES
|
||||
('client-lcr', 'Email de solicitud de datos bancarios LCR', 1, 1);
|
|
@ -0,0 +1,2 @@
|
|||
ALTER TABLE `bi`.`tarifa_componentes`
|
||||
ADD COLUMN `code` VARCHAR(45) NULL DEFAULT NULL AFTER `is_renewable`;
|
|
@ -0,0 +1,11 @@
|
|||
CREATE
|
||||
OR REPLACE ALGORITHM = UNDEFINED
|
||||
DEFINER = `root`@`%`
|
||||
SQL SECURITY DEFINER
|
||||
VIEW `vn`.`claimState` AS
|
||||
SELECT
|
||||
`c`.`id` AS `id`,
|
||||
`c`.`estado` AS `description`,
|
||||
`c`.`roleFk` AS `roleFk`
|
||||
FROM
|
||||
`vn2008`.`cl_est` `c`;
|
|
@ -0,0 +1,16 @@
|
|||
|
||||
CREATE
|
||||
OR REPLACE ALGORITHM = UNDEFINED
|
||||
DEFINER = `root`@`%`
|
||||
SQL SECURITY DEFINER
|
||||
VIEW `vn`.`componentRate` AS
|
||||
SELECT
|
||||
`t`.`Id_Componente` AS `id`,
|
||||
`t`.`Componente` AS `name`,
|
||||
`t`.`tarifa_componentes_series_id` AS `componentTypeRate`,
|
||||
`t`.`tarifa_class` AS `classRate`,
|
||||
`t`.`tax` AS `tax`,
|
||||
`t`.`is_renewable` AS `isRenewable`,
|
||||
`t`.`code` AS `code`
|
||||
FROM
|
||||
`bi`.`tarifa_componentes` `t`;
|
|
@ -0,0 +1,26 @@
|
|||
CREATE OR REPLACE
|
||||
ALGORITHM = UNDEFINED
|
||||
DEFINER = `root`@`%`
|
||||
SQL SECURITY DEFINER
|
||||
VIEW `vn`.`ticket` AS
|
||||
SELECT
|
||||
`t`.`Id_Ticket` AS `id`,
|
||||
`t`.`Id_Cliente` AS `clientFk`,
|
||||
`t`.`warehouse_id` AS `warehouseFk`,
|
||||
`t`.`Fecha` AS `shipped`,
|
||||
`t`.`landing` AS `landed`,
|
||||
`t`.`Alias` AS `nickname`,
|
||||
`t`.`Factura` AS `refFk`,
|
||||
`t`.`Id_Consigna` AS `addressFk`,
|
||||
`t`.`Localizacion` AS `location`,
|
||||
`t`.`Solucion` AS `solution`,
|
||||
`t`.`Id_Ruta` AS `routeFk`,
|
||||
`t`.`empresa_id` AS `companyFk`,
|
||||
`t`.`Id_Agencia` AS `agencyModeFk`,
|
||||
`t`.`Prioridad` AS `priority`,
|
||||
`t`.`Bultos` AS `packages`,
|
||||
`t`.`isDeleted` AS `isDeleted`,
|
||||
`t`.`odbc_date` AS `created`,
|
||||
`t`.`zoneFk` AS `zoneFk`
|
||||
FROM
|
||||
`vn2008`.`Tickets` `t`;
|
|
@ -0,0 +1,17 @@
|
|||
INSERT INTO `salix`.`ACL` ( `model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
('Dms', 'removeFile', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Dms', 'uploadFile', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Dms', 'downloadFile', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Client', 'uploadFile', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
|
||||
('ClientDms', 'removeFile', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
|
||||
('ClientDms', '*', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Ticket', 'uploadFile', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
|
||||
('TicketDms', 'removeFile', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
|
||||
('TicketDms', '*', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Route', 'updateVolume', 'WRITE', 'ALLOW', 'ROLE', 'deliveryBoss');
|
||||
|
||||
|
||||
|
||||
INSERT INTO `salix`.`ACL` (`id`, `model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('', 'Agency', 'getLanded', 'READ', 'ALLOW', 'ROLE', 'employee');
|
||||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('Agency', 'getShipped', 'READ', 'ALLOW', 'ROLE', 'employee');
|
|
@ -0,0 +1,15 @@
|
|||
ALTER TABLE `vn2008`.`clientes_gestdoc`
|
||||
DROP FOREIGN KEY `clientes_gestdoc_ibfk_3`;
|
||||
ALTER TABLE `vn2008`.`clientes_gestdoc`
|
||||
DROP PRIMARY KEY,
|
||||
ADD PRIMARY KEY (`gest_doc_id`);
|
||||
|
||||
ALTER TABLE `vn2008`.`clientes_gestdoc`
|
||||
ADD INDEX `fk_clientes_gestdoc_1_idx` (`Id_Cliente` ASC);
|
||||
|
||||
ALTER TABLE `vn2008`.`clientes_gestdoc`
|
||||
ADD CONSTRAINT `fk_clientes_gestdoc_3`
|
||||
FOREIGN KEY (`Id_Cliente`)
|
||||
REFERENCES `vn2008`.`Clientes` (`id_cliente`)
|
||||
ON DELETE RESTRICT
|
||||
ON UPDATE CASCADE;
|
|
@ -0,0 +1,28 @@
|
|||
DROP TRIGGER IF EXISTS `vn2008`.`expeditionsBeforeInsert`;
|
||||
|
||||
DELIMITER $$
|
||||
CREATE DEFINER=`root`@`%` TRIGGER `vn2008`.`expeditionsBeforeInsert`
|
||||
BEFORE INSERT ON `expeditions` FOR EACH ROW
|
||||
-- Edit trigger body code below this line. Do not edit lines above this one
|
||||
BEGIN
|
||||
DECLARE intcounter INT;
|
||||
DECLARE vShipFk INT;
|
||||
|
||||
IF NEW.EsBulto > 0 THEN
|
||||
|
||||
UPDATE Tickets SET Bultos = nz(Bultos) + 1 WHERE Id_Ticket = NEW.ticket_id;
|
||||
SELECT IFNULL(MAX(counter),0) +1 INTO intcounter FROM expeditions e
|
||||
INNER JOIN Tickets t1 ON e.ticket_id = t1.Id_Ticket
|
||||
LEFT JOIN vn.ticketState ts ON ts.ticket = t1.Id_Ticket
|
||||
INNER JOIN Tickets t2 ON t2.Id_Consigna = t1.Id_Consigna AND DATE(t2.Fecha) = DATE(t1.Fecha) AND t1.warehouse_id = t2.warehouse_id
|
||||
WHERE t2.Id_Ticket = NEW.ticket_id AND ts.alertLevel < 3 AND t1.empresa_id = t2.empresa_id AND t1.Id_Agencia = t2.Id_Agencia;
|
||||
SET NEW.`counter` = intcounter;
|
||||
END IF;
|
||||
|
||||
-- JGF 14/01/19 si existe un polizon queda anulado
|
||||
SELECT shipFk INTO vShipFk FROM vn.stowaway WHERE id = NEW.ticket_id;
|
||||
IF vShipFk THEN
|
||||
CALL vn.stowawayUnBoarding(vShipFk, NEW.ticket_id);
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -0,0 +1,21 @@
|
|||
-- adds column to table
|
||||
ALTER TABLE `vn2008`.`gesttip`
|
||||
ADD COLUMN `code` VARCHAR(45) NOT NULL AFTER `readRoleFk`;
|
||||
|
||||
-- adds column to view
|
||||
CREATE
|
||||
OR REPLACE ALGORITHM = UNDEFINED
|
||||
DEFINER = `root`@`%`
|
||||
SQL SECURITY DEFINER
|
||||
VIEW `vn`.`dmsType` AS
|
||||
SELECT
|
||||
`g`.`id` AS `id`,
|
||||
`g`.`tipo` AS `name`,
|
||||
`g`.`path` AS `path`,
|
||||
`g`.`readRoleFk` AS `readRoleFk`,
|
||||
`g`.`writeRoleFk` AS `writeRoleFk`,
|
||||
`g`.`code` AS `code`
|
||||
FROM
|
||||
`vn2008`.`gesttip` `g`;
|
||||
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
|
||||
DROP procedure IF EXISTS `vn`.`routeUpdateM3`;
|
||||
|
||||
DELIMITER $$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`routeUpdateM3`(vRoute INT)
|
||||
BEGIN
|
||||
|
||||
UPDATE vn.route r
|
||||
JOIN (SELECT routeFk, SUM(volume) AS m3
|
||||
FROM ticketGetVolume
|
||||
WHERE routeFk = vRoute
|
||||
) v ON v.routeFk = r.id
|
||||
SET r.m3 = v.m3;
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
UPDATE `bi`.`tarifa_componentes` SET `code`='specialPrices' WHERE `Id_Componente`='10';
|
||||
UPDATE `bi`.`tarifa_componentes` SET `code`='extraCostPerWeekDay' WHERE `Id_Componente`='14';
|
||||
UPDATE `bi`.`tarifa_componentes` SET `code`='delivery' WHERE `Id_Componente`='15';
|
||||
UPDATE `bi`.`tarifa_componentes` SET `code`='debtCollection' WHERE `Id_Componente`='17';
|
||||
UPDATE `bi`.`tarifa_componentes` SET `code`='adjustment' WHERE `Id_Componente`='21';
|
||||
UPDATE `bi`.`tarifa_componentes` SET `code`='salePerPackage' WHERE `Id_Componente`='22';
|
||||
UPDATE `bi`.`tarifa_componentes` SET `code`='salePerBox' WHERE `Id_Componente`='23';
|
||||
UPDATE `bi`.`tarifa_componentes` SET `code`='purchaseValue' WHERE `Id_Componente`='28';
|
||||
UPDATE `bi`.`tarifa_componentes` SET `code`='margin' WHERE `Id_Componente`='29';
|
||||
UPDATE `bi`.`tarifa_componentes` SET `code`='lastUnitsDiscount' WHERE `Id_Componente`='32';
|
||||
UPDATE `bi`.`tarifa_componentes` SET `code`='salePerBox' WHERE `Id_Componente`='33';
|
||||
UPDATE `bi`.`tarifa_componentes` SET `code`='buyerDiscount' WHERE `Id_Componente`='34';
|
||||
UPDATE `bi`.`tarifa_componentes` SET `code`='mismatch' WHERE `Id_Componente`='36';
|
||||
UPDATE `bi`.`tarifa_componentes` SET `code`='mana' WHERE `Id_Componente`='37';
|
||||
UPDATE `bi`.`tarifa_componentes` SET `code`='bagged' WHERE `Id_Componente`='38';
|
||||
UPDATE `bi`.`tarifa_componentes` SET `code`='autoMana' WHERE `Id_Componente`='39';
|
||||
UPDATE `bi`.`tarifa_componentes` SET `code`='freightCharge' WHERE `Id_Componente`='41';
|
|
@ -0,0 +1,49 @@
|
|||
|
||||
DROP procedure IF EXISTS `vn`.`zoneGetWarehouse`;
|
||||
|
||||
DELIMITER $$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`zoneGetWarehouse`(vAddress INT, vLanded DATE, vWarehouse INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Devuelve el listado de agencias disponibles para la fecha,
|
||||
* dirección y warehouse pasadas
|
||||
*
|
||||
* @param vAddress
|
||||
* @param vWarehouse warehouse
|
||||
* @param vLanded Fecha de recogida
|
||||
* @select Listado de agencias disponibles
|
||||
*/
|
||||
|
||||
DECLARE vPostalCode varchar(10);
|
||||
|
||||
SELECT postalCode INTO vPostalCode
|
||||
FROM address WHERE id = vAddress;
|
||||
SELECT * FROM (
|
||||
SELECT * FROM (
|
||||
SELECT am.id agencyModeFk,
|
||||
am.name agencyMode,
|
||||
am.description,
|
||||
am.deliveryMethodFk,
|
||||
TIMESTAMPADD(DAY,-z.travelingDays, vLanded) shipped,
|
||||
z.warehouseFk,
|
||||
zi.isIncluded,
|
||||
z.id zoneFk
|
||||
FROM zoneGeo zgSon
|
||||
JOIN zoneGeo zgFather ON zgSon.lft BETWEEN zgFather.lft AND zgFather.rgt
|
||||
JOIN zoneIncluded zi ON zi.geoFk = zgFather.id
|
||||
JOIN zone z ON z.id = zi.zoneFk
|
||||
JOIN zoneCalendar zc ON zc.zoneFk = z.id
|
||||
JOIN agencyMode am ON am.id = z.agencyModeFk
|
||||
WHERE zgSon.`name` LIKE vPostalCode
|
||||
AND delivered = vLanded
|
||||
AND z.warehouseFk = vWarehouse
|
||||
AND IF(TIMESTAMPADD(DAY,-z.travelingDays, vLanded) = CURDATE(), hour(now()) < hour(z.`hour`),TRUE)
|
||||
ORDER BY z.id, zgFather.depth DESC) t
|
||||
GROUP BY zoneFk
|
||||
HAVING isIncluded > 0) t
|
||||
GROUP BY agencyModeFk;
|
||||
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
UPDATE `vn2008`.`gesttip` SET `writeRoleFk`='1', `readRoleFk`='1' WHERE `id`='5';
|
||||
UPDATE `vn2008`.`gesttip` SET `writeRoleFk`='1', `readRoleFk`='1' WHERE `id`='12';
|
||||
UPDATE `vn2008`.`gesttip` SET `writeRoleFk`='1', `readRoleFk`='1' WHERE `id`='14';
|
||||
UPDATE `vn2008`.`gesttip` SET `writeRoleFk`='1', `readRoleFk`='1' WHERE `id`='13';
|
||||
UPDATE `vn2008`.`gesttip` SET `code`='invoiceIn' WHERE `id`='1';
|
||||
UPDATE `vn2008`.`gesttip` SET `code`='officialDoc' WHERE `id`='2';
|
||||
UPDATE `vn2008`.`gesttip` SET `code`='hhrrData' WHERE `id`='3';
|
||||
UPDATE `vn2008`.`gesttip` SET `code`='deliveryNote' WHERE `id`='4';
|
||||
UPDATE `vn2008`.`gesttip` SET `code`='miscellaneous' WHERE `id`='5';
|
||||
UPDATE `vn2008`.`gesttip` SET `code`='tests' WHERE `id`='6';
|
||||
UPDATE `vn2008`.`gesttip` SET `code`='economicActivitiesTax' WHERE `id`='7';
|
||||
UPDATE `vn2008`.`gesttip` SET `code`='fiscal' WHERE `id`='8';
|
||||
UPDATE `vn2008`.`gesttip` SET `code`='vehicles' WHERE `id`='9';
|
||||
UPDATE `vn2008`.`gesttip` SET `code`='templates' WHERE `id`='10';
|
||||
UPDATE `vn2008`.`gesttip` SET `code`='contracts' WHERE `id`='11';
|
||||
UPDATE `vn2008`.`gesttip` SET `code`='paymentsLaw' WHERE `id`='12';
|
||||
UPDATE `vn2008`.`gesttip` SET `code`='trash' WHERE `id`='13';
|
||||
UPDATE `vn2008`.`gesttip` SET `code`='ticket' WHERE `id`='14';
|
||||
UPDATE `vn2008`.`gesttip` SET `code`='budgets' WHERE `id`='15';
|
||||
UPDATE `vn2008`.`gesttip` SET `code`='logistics' WHERE `id`='16';
|
||||
UPDATE `vn2008`.`gesttip` SET `code`='cmr' WHERE `id`='17';
|
||||
UPDATE `vn2008`.`gesttip` SET `code`='dua' WHERE `id`='18';
|
||||
UPDATE `vn2008`.`gesttip` SET `code`='fixedAssets' WHERE `id`='19';
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
ALTER TABLE `vn2008`.`Paises`
|
||||
ADD COLUMN `ibanLength` TINYINT(4) NULL DEFAULT NULL AFTER `isUeeMember`;
|
||||
|
||||
CREATE
|
||||
OR REPLACE ALGORITHM = UNDEFINED
|
||||
DEFINER = `root`@`%`
|
||||
SQL SECURITY DEFINER
|
||||
VIEW `vn`.`country` AS
|
||||
SELECT
|
||||
`p`.`Id` AS `id`,
|
||||
`p`.`Pais` AS `country`,
|
||||
`p`.`CEE` AS `CEE`,
|
||||
`p`.`isUeeMember` AS `isUeeMember`,
|
||||
`p`.`Codigo` AS `code`,
|
||||
`p`.`Id_Moneda` AS `currencyFk`,
|
||||
`p`.`Id_Paisreal` AS `politicalCountryFk`,
|
||||
`p`.`geoFk` AS `geoFk`,
|
||||
`p`.`ibanLength` AS `ibanLength`
|
||||
FROM
|
||||
`vn2008`.`Paises` `p`;
|
||||
|
||||
UPDATE `vn2008`.`Paises` SET `ibanLength`=22 WHERE `Id`=1;
|
||||
UPDATE `vn2008`.`Paises` SET `ibanLength`=25 WHERE `Id`=2;
|
||||
UPDATE `vn2008`.`Paises` SET `ibanLength`=20 WHERE `Id`=3;
|
||||
UPDATE `vn2008`.`Paises` SET `ibanLength`=22 WHERE `Id`=4;
|
||||
UPDATE `vn2008`.`Paises` SET `ibanLength`=16 WHERE `Id`=5;
|
||||
UPDATE `vn2008`.`Paises` SET `ibanLength`=25 WHERE `Id`=19;
|
||||
UPDATE `vn2008`.`Paises` SET `ibanLength`=22 WHERE `Id`=30;
|
|
@ -0,0 +1,5 @@
|
|||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
('Zone', 'editPrices', 'WRITE', 'ALLOW', 'ROLE', 'deliveryBoss'),
|
||||
('Postcode', '*', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Ticket', 'addSale', 'WRITE', 'ALLOW', 'ROLE', 'employee');
|
|
@ -0,0 +1,3 @@
|
|||
ALTER TABLE `vn`.`zoneCalendar`
|
||||
ADD COLUMN `price` DOUBLE NOT NULL AFTER `delivered`,
|
||||
ADD COLUMN `bonus` DOUBLE NOT NULL AFTER `price`;
|
|
@ -0,0 +1,139 @@
|
|||
DROP procedure IF EXISTS `vn`.`ticketGetProblems`;
|
||||
|
||||
DELIMITER $$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`ticketGetProblems`()
|
||||
BEGIN
|
||||
|
||||
DECLARE vWarehouse INT;
|
||||
DECLARE vDate DATE;
|
||||
DECLARE vAvailableCache INT;
|
||||
DECLARE vVisibleCache INT;
|
||||
DECLARE vDone INT DEFAULT 0;
|
||||
|
||||
DECLARE vCursor CURSOR FOR
|
||||
SELECT DISTINCT tt.warehouseFk, date(tt.shipped)
|
||||
FROM tmp.ticketGetProblems tt
|
||||
WHERE DATE(tt.shipped) BETWEEN CURDATE()
|
||||
AND TIMESTAMPADD(DAY, 1.9, CURDATE());
|
||||
|
||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = 1;
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.ticketProblems;
|
||||
CREATE TEMPORARY TABLE tmp.ticketProblems (
|
||||
ticketFk INT(11) PRIMARY KEY,
|
||||
isFreezed INTEGER(1) DEFAULT 0,
|
||||
risk DECIMAL(10,2) DEFAULT 0,
|
||||
hasTicketRequest INTEGER(1) DEFAULT 0,
|
||||
isAvailable INTEGER(1) DEFAULT 1
|
||||
) ENGINE = MEMORY;
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.ticketList;
|
||||
CREATE TEMPORARY TABLE tmp.ticketList
|
||||
(PRIMARY KEY (ticketFk))
|
||||
ENGINE = MEMORY
|
||||
SELECT tp.ticketFk, c.id clientFk
|
||||
FROM tmp.ticketGetProblems tp
|
||||
JOIN vn.client c ON c.id = tp.clientFk;
|
||||
|
||||
|
||||
INSERT INTO tmp.ticketProblems(ticketFk, isFreezed)
|
||||
SELECT DISTINCT tl.ticketFk, 1
|
||||
FROM tmp.ticketList tl
|
||||
JOIN vn.client c ON c.id = tl.clientFk
|
||||
WHERE c.isFreezed;
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.clientGetDebt;
|
||||
CREATE TEMPORARY TABLE tmp.clientGetDebt
|
||||
(PRIMARY KEY (clientFk))
|
||||
ENGINE = MEMORY
|
||||
SELECT DISTINCT clientFk
|
||||
FROM tmp.ticketList;
|
||||
|
||||
CALL clientGetDebt(CURDATE());
|
||||
|
||||
|
||||
INSERT INTO tmp.ticketProblems(ticketFk, risk)
|
||||
SELECT DISTINCT tl.ticketFk, r.risk
|
||||
FROM tmp.ticketList tl
|
||||
JOIN vn.ticket t ON t.id = tl.ticketFk
|
||||
JOIN vn.agencyMode a ON t.agencyModeFk = a.id
|
||||
JOIN tmp.risk r ON r.clientFk = t.clientFk
|
||||
JOIN vn.client c ON c.id = t.clientFk
|
||||
WHERE r.risk > c.credit + 10
|
||||
AND a.deliveryMethodFk != 3
|
||||
ON DUPLICATE KEY UPDATE
|
||||
risk = r.risk;
|
||||
|
||||
INSERT INTO tmp.ticketProblems(ticketFk, hasTicketRequest)
|
||||
SELECT DISTINCT tl.ticketFk, 1
|
||||
FROM tmp.ticketList tl
|
||||
JOIN vn.ticketRequest tr ON tr.ticketFk = tl.ticketFk
|
||||
WHERE tr.isOK IS NULL
|
||||
ON DUPLICATE KEY UPDATE
|
||||
hasTicketRequest = 1;
|
||||
|
||||
OPEN vCursor;
|
||||
|
||||
WHILE NOT vDone
|
||||
DO
|
||||
FETCH vCursor INTO vWarehouse, vDate;
|
||||
|
||||
CALL cache.visible_refresh(vVisibleCache, FALSE, vWarehouse);
|
||||
CALL cache.available_refresh(vAvailableCache, FALSE, vWarehouse, vDate);
|
||||
|
||||
|
||||
INSERT INTO tmp.ticketProblems(ticketFk, isAvailable)
|
||||
SELECT tl.ticketFk, 0
|
||||
FROM tmp.ticketList tl
|
||||
JOIN vn.ticket t ON t.id = tl.ticketFk
|
||||
LEFT 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
|
||||
LEFT JOIN cache.available av ON av.item_id = i.id
|
||||
AND av.calc_id = vAvailableCache
|
||||
WHERE date(t.shipped) = vDate
|
||||
AND categoryFk != 6
|
||||
AND IFNULL(av.available, 0) < 0
|
||||
AND s.isPicked = FALSE
|
||||
AND NOT i.generic
|
||||
AND vWarehouse = t.warehouseFk
|
||||
GROUP BY tl.ticketFk
|
||||
ON DUPLICATE KEY UPDATE
|
||||
isAvailable = 0;
|
||||
|
||||
INSERT INTO tmp.ticketProblems(ticketFk, isAvailable)
|
||||
SELECT tl.ticketFk, 0
|
||||
FROM tmp.ticketList tl
|
||||
JOIN vn.ticket t ON t.id = tl.ticketFk
|
||||
LEFT 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
|
||||
LEFT JOIN cache.visible v ON i.id = v.item_id AND v.calc_id = vVisibleCache
|
||||
LEFT JOIN cache.available av ON av.item_id = i.id AND av.calc_id = vAvailableCache
|
||||
WHERE IFNULL(av.available, 0) >= 0
|
||||
AND s.quantity > IFNULL(v.visible, 0)
|
||||
AND s.isPicked = FALSE
|
||||
AND s.reserved = FALSE
|
||||
AND it.categoryFk != 6
|
||||
AND date(t.shipped) = vDate
|
||||
AND NOT i.generic
|
||||
AND CURDATE() = vDate
|
||||
AND t.warehouseFk = vWarehouse
|
||||
GROUP BY tl.ticketFk
|
||||
ON DUPLICATE KEY UPDATE
|
||||
isAvailable = 0;
|
||||
|
||||
END WHILE;
|
||||
|
||||
CLOSE vCursor;
|
||||
|
||||
SELECT * FROM tmp.ticketProblems;
|
||||
|
||||
DROP TEMPORARY TABLE
|
||||
tmp.clientGetDebt,
|
||||
tmp.ticketList;
|
||||
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
|
|
@ -5,7 +5,7 @@ export MYSQL_PWD=root
|
|||
mysql_import() {
|
||||
FILE=$1
|
||||
echo "[INFO] -> Imported $FILE"
|
||||
mysql -u root --comments -f < "$FILE"
|
||||
mysql -u root --default-character-set=utf8 --comments -f < "$FILE"
|
||||
}
|
||||
|
||||
mysql_import dump/structure.sql
|
||||
|
|
File diff suppressed because one or more lines are too long
1489
db/dump/fixtures.sql
1489
db/dump/fixtures.sql
File diff suppressed because it is too large
Load Diff
12931
db/dump/structure.sql
12931
db/dump/structure.sql
File diff suppressed because it is too large
Load Diff
|
@ -50,7 +50,6 @@ TABLES=(
|
|||
accion_dits
|
||||
bionic_updating_options
|
||||
businessReasonEnd
|
||||
cl_est
|
||||
cl_con
|
||||
cl_res
|
||||
cl_dev
|
||||
|
|
|
@ -20,21 +20,27 @@ describe('last_buy_refresh()', () => {
|
|||
|
||||
let lastBuyTable = result[lastBuyTableIndex];
|
||||
|
||||
expect(lastBuyTable.length).toEqual(4);
|
||||
expect(lastBuyTable.length).toEqual(6);
|
||||
|
||||
expect(lastBuyTable[0].item_id).toEqual(1);
|
||||
expect(lastBuyTable[1].item_id).toEqual(2);
|
||||
expect(lastBuyTable[2].item_id).toEqual(3);
|
||||
expect(lastBuyTable[3].item_id).toEqual(4);
|
||||
expect(lastBuyTable[4].item_id).toEqual(8);
|
||||
expect(lastBuyTable[5].item_id).toEqual(9);
|
||||
|
||||
expect(lastBuyTable[0].warehouse_id).toEqual(1);
|
||||
expect(lastBuyTable[1].warehouse_id).toEqual(1);
|
||||
expect(lastBuyTable[2].warehouse_id).toEqual(1);
|
||||
expect(lastBuyTable[3].warehouse_id).toEqual(1);
|
||||
expect(lastBuyTable[4].warehouse_id).toEqual(1);
|
||||
expect(lastBuyTable[5].warehouse_id).toEqual(1);
|
||||
|
||||
expect(lastBuyTable[1].buy_id).toEqual(4);
|
||||
expect(lastBuyTable[0].buy_id).toEqual(3);
|
||||
expect(lastBuyTable[2].buy_id).toEqual(5);
|
||||
expect(lastBuyTable[3].buy_id).toEqual(6);
|
||||
expect(lastBuyTable[3].buy_id).toEqual(8);
|
||||
expect(lastBuyTable[4].buy_id).toEqual(6);
|
||||
expect(lastBuyTable[5].buy_id).toEqual(7);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -29,21 +29,27 @@ describe('buyUltimate()', () => {
|
|||
|
||||
let buyUltimateTable = result[buyUltimateTableIndex];
|
||||
|
||||
expect(buyUltimateTable.length).toEqual(4);
|
||||
expect(buyUltimateTable.length).toEqual(6);
|
||||
|
||||
expect(buyUltimateTable[0].itemFk).toEqual(1);
|
||||
expect(buyUltimateTable[1].itemFk).toEqual(2);
|
||||
expect(buyUltimateTable[2].itemFk).toEqual(3);
|
||||
expect(buyUltimateTable[3].itemFk).toEqual(4);
|
||||
expect(buyUltimateTable[4].itemFk).toEqual(8);
|
||||
expect(buyUltimateTable[5].itemFk).toEqual(9);
|
||||
|
||||
expect(buyUltimateTable[0].warehouseFk).toEqual(1);
|
||||
expect(buyUltimateTable[1].warehouseFk).toEqual(1);
|
||||
expect(buyUltimateTable[2].warehouseFk).toEqual(1);
|
||||
expect(buyUltimateTable[3].warehouseFk).toEqual(1);
|
||||
expect(buyUltimateTable[4].warehouseFk).toEqual(1);
|
||||
expect(buyUltimateTable[5].warehouseFk).toEqual(1);
|
||||
|
||||
expect(buyUltimateTable[1].buyFk).toEqual(4);
|
||||
expect(buyUltimateTable[0].buyFk).toEqual(3);
|
||||
expect(buyUltimateTable[2].buyFk).toEqual(5);
|
||||
expect(buyUltimateTable[3].buyFk).toEqual(6);
|
||||
expect(buyUltimateTable[3].buyFk).toEqual(8);
|
||||
expect(buyUltimateTable[4].buyFk).toEqual(6);
|
||||
expect(buyUltimateTable[5].buyFk).toEqual(7);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -86,18 +86,20 @@ describe('ticket ticketCalculateClon()', () => {
|
|||
|
||||
stmt = new ParameterizedSQL('CALL vn.ticketCalculateClon(@result, ?)', [params.originalTicketId]);
|
||||
stmts.push(stmt);
|
||||
|
||||
let orderIndex = stmts.push(`SELECT * FROM vn.orderTicket WHERE ticketFk = @result`) - 1;
|
||||
|
||||
stmts.push('ROLLBACK');
|
||||
|
||||
let sql = ParameterizedSQL.join(stmts, ';');
|
||||
let result = await app.models.Ticket.rawStmt(sql);
|
||||
|
||||
let expectedOrder = 11;
|
||||
let newestTicketIdInFixtures = 21;
|
||||
let error;
|
||||
|
||||
expect(result[orderIndex][0].orderFk).toEqual(expectedOrder);
|
||||
expect(result[orderIndex][0].ticketFk).toBeGreaterThan(newestTicketIdInFixtures);
|
||||
try {
|
||||
await app.models.Ticket.rawStmt(sql);
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
|
||||
expect(error).toBeDefined();
|
||||
expect(error.statusCode).toBe(500);
|
||||
expect(error.code).toBe('ER_SIGNAL_EXCEPTION');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -14,8 +14,8 @@ describe('ticket ticketCreateWithUser()', () => {
|
|||
shipped: today,
|
||||
warehouseFk: 1,
|
||||
companyFk: 442,
|
||||
addressFk: 1,
|
||||
agencyModeFk: 2,
|
||||
addressFk: 121,
|
||||
agencyModeFk: 1,
|
||||
routeFk: null,
|
||||
landed: today,
|
||||
userId: 18
|
||||
|
@ -64,8 +64,8 @@ describe('ticket ticketCreateWithUser()', () => {
|
|||
shipped: today,
|
||||
warehouseFk: 1,
|
||||
companyFk: 442,
|
||||
addressFk: 1,
|
||||
agencyModeFk: 2,
|
||||
addressFk: 121,
|
||||
agencyModeFk: 1,
|
||||
routeFk: null,
|
||||
landed: today,
|
||||
userId: 18
|
||||
|
@ -91,7 +91,6 @@ describe('ticket ticketCreateWithUser()', () => {
|
|||
let sql = ParameterizedSQL.join(stmts, ';');
|
||||
let result = await app.models.Ticket.rawStmt(sql);
|
||||
|
||||
|
||||
let firstTicketObservation = result[ticketObsevationsIndex][0];
|
||||
let secondTicketObservation = result[ticketObsevationsIndex][1];
|
||||
let thirdTicketObservation = result[ticketObsevationsIndex][2];
|
||||
|
@ -116,7 +115,7 @@ describe('ticket ticketCreateWithUser()', () => {
|
|||
warehouseFk: 1,
|
||||
companyFk: 442,
|
||||
addressFk: 0,
|
||||
agencyModeFk: 2,
|
||||
agencyModeFk: 1,
|
||||
routeFk: null,
|
||||
landed: today,
|
||||
userId: 18
|
||||
|
@ -162,8 +161,8 @@ describe('ticket ticketCreateWithUser()', () => {
|
|||
shipped: today,
|
||||
warehouseFk: 1,
|
||||
companyFk: 442,
|
||||
addressFk: 0,
|
||||
agencyModeFk: 2,
|
||||
addressFk: 121,
|
||||
agencyModeFk: 1,
|
||||
routeFk: null,
|
||||
landed: today,
|
||||
userId: 18
|
||||
|
@ -186,7 +185,7 @@ describe('ticket ticketCreateWithUser()', () => {
|
|||
params.userId
|
||||
]);
|
||||
stmts.push(stmt);
|
||||
|
||||
stmts.push(`select @newTicketId`);
|
||||
let ticketStateCodeIndex = stmts.push(`SELECT code FROM vn.ticketState WHERE ticketFk = @newTicketId`) - 1;
|
||||
|
||||
stmts.push('ROLLBACK');
|
||||
|
@ -196,6 +195,6 @@ describe('ticket ticketCreateWithUser()', () => {
|
|||
|
||||
let ticketStateCode = result[ticketStateCodeIndex][0].code;
|
||||
|
||||
expect(ticketStateCode).toEqual('DELIVERED');
|
||||
expect(ticketStateCode).toEqual('FREE');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
It works!
|
|
@ -1,3 +1,3 @@
|
|||
export default {
|
||||
module.exports = {
|
||||
url: 'http://localhost:5000'
|
||||
};
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue