Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 5770_sambaGroups
This commit is contained in:
commit
faf747ee5d
|
@ -58,7 +58,7 @@ pipeline {
|
|||
stage('Frontend') {
|
||||
steps {
|
||||
nodejs('node-v20') {
|
||||
sh 'jest --ci --reporters=default --reporters=jest-junit --maxWorkers=2'
|
||||
sh 'jest --ci --reporters=default --reporters=jest-junit --maxWorkers=4'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -106,13 +106,15 @@ pipeline {
|
|||
}}
|
||||
steps {
|
||||
configFileProvider([
|
||||
configFile(fileId: "config.${env.NODE_ENV}.ini",
|
||||
configFile(fileId: "config.${NODE_ENV}.ini",
|
||||
variable: 'MYSQL_CONFIG')
|
||||
]) {
|
||||
sh 'cp "$MYSQL_CONFIG" db/config.$NODE_ENV.ini'
|
||||
sh 'mkdir -p db/remotes'
|
||||
sh 'cp "$MYSQL_CONFIG" db/remotes/$NODE_ENV.ini'
|
||||
}
|
||||
nodejs('node-v20') {
|
||||
sh 'npx myt push $NODE_ENV --force --commit'
|
||||
}
|
||||
|
||||
sh 'db/import-changes.sh -f $NODE_ENV'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -95,10 +95,7 @@ describe('image upload()', () => {
|
|||
spyOn(containerModel, 'upload');
|
||||
|
||||
const ctx = {req: {accessToken: {userId: hhrrId}},
|
||||
args: {
|
||||
id: itemId,
|
||||
collection: 'user'
|
||||
}
|
||||
args: {id: itemId, collection: 'user'}
|
||||
};
|
||||
|
||||
try {
|
||||
|
@ -109,7 +106,7 @@ describe('image upload()', () => {
|
|||
});
|
||||
|
||||
it('should try to upload a file for the collection "catalog" and throw a privilege error', async() => {
|
||||
const ctx = {req: {accessToken: {userId: hhrrId}},
|
||||
const ctx = {req: {accessToken: {userId: 1}},
|
||||
args: {
|
||||
id: workerId,
|
||||
collection: 'catalog'
|
||||
|
|
|
@ -1,16 +1,11 @@
|
|||
const {ParameterizedSQL} = require('loopback-connector');
|
||||
const {buildFilter, mergeFilters} = require('vn-loopback/util/filter');
|
||||
// const {models} = require('vn-loopback/server/server');
|
||||
const {buildFilter} = require('vn-loopback/util/filter');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethod('filter', {
|
||||
description:
|
||||
'Find all postcodes of the model matched by postcode, town, province or country.',
|
||||
accessType: 'READ',
|
||||
returns: {
|
||||
type: ['object'],
|
||||
root: true,
|
||||
},
|
||||
accepts: [
|
||||
{
|
||||
arg: 'filter',
|
||||
|
@ -25,6 +20,10 @@ module.exports = Self => {
|
|||
http: {source: 'query'}
|
||||
},
|
||||
],
|
||||
returns: {
|
||||
type: ['object'],
|
||||
root: true,
|
||||
},
|
||||
http: {
|
||||
path: `/filter`,
|
||||
verb: 'GET',
|
||||
|
@ -32,30 +31,34 @@ module.exports = Self => {
|
|||
});
|
||||
Self.filter = async(ctx, filter, options) => {
|
||||
const myOptions = {};
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
filter = ctx?.filter ?? {};
|
||||
|
||||
const conn = Self.dataSource.connector;
|
||||
const where = buildFilter(ctx.args, (param, value) => {
|
||||
const where = buildFilter(filter?.where, (param, value) => {
|
||||
switch (param) {
|
||||
case 'search':
|
||||
return {or: [
|
||||
{'pc.code': {like: `%${value}%`}},
|
||||
{'t.name': {like: `%${value}%`}},
|
||||
{'p.name': {like: `%${value}%`}},
|
||||
{'c.country': {like: `%${value}%`}}
|
||||
]
|
||||
return {
|
||||
or: [
|
||||
{'pc.code': {like: `%${value}%`}},
|
||||
{'t.name': {like: `%${value}%`}},
|
||||
{'p.name': {like: `%${value}%`}},
|
||||
{'c.country': {like: `%${value}%`}}
|
||||
]
|
||||
};
|
||||
}
|
||||
}) ?? {};
|
||||
|
||||
filter = mergeFilters(ctx.args?.filter ?? {}, {where});
|
||||
delete ctx.filter.where;
|
||||
|
||||
const stmts = [];
|
||||
let stmt;
|
||||
stmt = new ParameterizedSQL(`
|
||||
SELECT
|
||||
pc.townFk,
|
||||
t.provinceFk,
|
||||
p.countryFk,
|
||||
pc.code,
|
||||
t.name as town,
|
||||
p.name as province,
|
||||
|
@ -67,7 +70,7 @@ module.exports = Self => {
|
|||
JOIN country c on c.id = p.countryFk
|
||||
`);
|
||||
|
||||
stmt.merge(conn.makeSuffix(filter));
|
||||
stmt.merge(conn.makeSuffix({where, ...ctx}));
|
||||
const itemsIndex = stmts.push(stmt) - 1;
|
||||
|
||||
const sql = ParameterizedSQL.join(stmts, ';');
|
||||
|
|
|
@ -7,13 +7,13 @@ describe('Postcode filter()', () => {
|
|||
|
||||
try {
|
||||
const ctx = {
|
||||
args: {
|
||||
|
||||
filter: {
|
||||
},
|
||||
limit: 1
|
||||
};
|
||||
const results = await models.Postcode.filter(ctx, options);
|
||||
|
||||
expect(results.length).toBeGreaterThan(0);
|
||||
expect(results.length).toEqual(1);
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
|
@ -27,8 +27,10 @@ describe('Postcode filter()', () => {
|
|||
|
||||
try {
|
||||
const ctx = {
|
||||
args: {
|
||||
search: 46,
|
||||
filter: {
|
||||
where: {
|
||||
search: 46,
|
||||
}
|
||||
},
|
||||
};
|
||||
const results = await models.Postcode.filter(ctx, options);
|
||||
|
@ -47,8 +49,10 @@ describe('Postcode filter()', () => {
|
|||
|
||||
try {
|
||||
const ctx = {
|
||||
args: {
|
||||
search: 'Alz',
|
||||
filter: {
|
||||
where: {
|
||||
search: 'Alz',
|
||||
}
|
||||
},
|
||||
};
|
||||
const results = await models.Postcode.filter(ctx, options);
|
||||
|
@ -67,8 +71,10 @@ describe('Postcode filter()', () => {
|
|||
|
||||
try {
|
||||
const ctx = {
|
||||
args: {
|
||||
search: 'one',
|
||||
filter: {
|
||||
where: {
|
||||
search: 'one',
|
||||
}
|
||||
},
|
||||
};
|
||||
const results = await models.Postcode.filter(ctx, options);
|
||||
|
@ -87,8 +93,10 @@ describe('Postcode filter()', () => {
|
|||
|
||||
try {
|
||||
const ctx = {
|
||||
args: {
|
||||
search: 'Ec',
|
||||
filter: {
|
||||
where: {
|
||||
search: 'Ec',
|
||||
}
|
||||
},
|
||||
};
|
||||
const results = await models.Postcode.filter(ctx, options);
|
||||
|
|
|
@ -79,10 +79,10 @@ module.exports = function(Self) {
|
|||
Self.getRoles = async(userId, options) => {
|
||||
const result = await Self.rawSql(
|
||||
`SELECT r.name
|
||||
FROM account.user u
|
||||
JOIN account.roleRole rr ON rr.role = u.role
|
||||
JOIN account.role r ON r.id = rr.inheritsFrom
|
||||
WHERE u.id = ?`, [userId], options);
|
||||
FROM account.user u
|
||||
JOIN account.roleRole rr ON rr.role = u.role
|
||||
JOIN account.role r ON r.id = rr.inheritsFrom
|
||||
WHERE u.id = ?`, [userId], options);
|
||||
|
||||
const roles = [];
|
||||
for (const role of result)
|
||||
|
@ -142,7 +142,7 @@ module.exports = function(Self) {
|
|||
ip: ctx.req.ip,
|
||||
owner: isOwner
|
||||
});
|
||||
throw new UserError('Try again');
|
||||
throw new UserError('Try again');
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
const Docker = require('../db/docker.js');
|
||||
const path = require('path');
|
||||
const Myt = require('@verdnatura/myt/myt');
|
||||
const Run = require('@verdnatura/myt/myt-run');
|
||||
let dataSources = require('../loopback/server/datasources.json');
|
||||
|
||||
let myt;
|
||||
|
||||
process.on('warning', warning => {
|
||||
console.log(warning.name);
|
||||
console.log(warning.message);
|
||||
|
@ -8,28 +12,29 @@ process.on('warning', warning => {
|
|||
});
|
||||
|
||||
process.on('SIGUSR2', async() => {
|
||||
if (container) await container.rm();
|
||||
if (myt) await myt.deinit();
|
||||
});
|
||||
|
||||
process.on('exit', async function() {
|
||||
if (container) await container.rm();
|
||||
if (myt) await myt.deinit();
|
||||
});
|
||||
|
||||
let container;
|
||||
async function test() {
|
||||
let isCI = false;
|
||||
const isCI = process.argv[2] === 'ci';
|
||||
|
||||
if (process.argv[2] === 'ci')
|
||||
isCI = true;
|
||||
myt = new Myt();
|
||||
await myt.init({
|
||||
workspace: path.join(__dirname, '..'),
|
||||
random: true,
|
||||
ci: isCI,
|
||||
network: isCI ? 'jenkins' : null
|
||||
});
|
||||
const {dbConfig} = await myt.run(Run);
|
||||
|
||||
container = new Docker();
|
||||
|
||||
await container.run(isCI);
|
||||
dataSources = JSON.parse(JSON.stringify(dataSources));
|
||||
|
||||
Object.assign(dataSources.vn, {
|
||||
host: container.dbConf.host,
|
||||
port: container.dbConf.port
|
||||
host: dbConfig.host,
|
||||
port: dbConfig.port
|
||||
});
|
||||
|
||||
const bootOptions = {dataSources};
|
||||
|
@ -77,7 +82,7 @@ async function test() {
|
|||
|
||||
await jasmine.execute();
|
||||
if (app) await app.disconnect();
|
||||
if (container) await container.rm();
|
||||
if (myt) await myt.deinit();
|
||||
console.log('App disconnected & container removed');
|
||||
}
|
||||
|
||||
|
|
|
@ -1,49 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId)
|
||||
VALUES
|
||||
('ClientConsumptionQueue', '*', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Ticket', 'deliveryNotePdf', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Ticket', 'deliveryNoteEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Ticket', 'deliveryNoteCsvPdf', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Ticket', 'deliveryNoteCsvEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Client', 'campaignMetricsPdf', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Client', 'campaignMetricsEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Client', 'clientWelcomeHtml', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Client', 'clientWelcomeEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Client', 'creditRequestPdf', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Client', 'creditRequestHtml', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Client', 'creditRequestEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Client', 'printerSetupHtml', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Client', 'printerSetupEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Client', 'sepaCoreEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Client', 'letterDebtorPdf', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Client', 'letterDebtorStHtml', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Client', 'letterDebtorStEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Client', 'letterDebtorNdHtml', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Client', 'letterDebtorNdEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Client', 'clientDebtStatementPdf', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Client', 'clientDebtStatementHtml', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Client', 'clientDebtStatementEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Client', 'incotermsAuthorizationPdf', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Client', 'incotermsAuthorizationHtml', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Client', 'incotermsAuthorizationEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Client', 'consumptionSendQueued', 'WRITE', 'ALLOW', 'ROLE', 'system'),
|
||||
('InvoiceOut', 'invoiceEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
|
||||
('InvoiceOut', 'exportationPdf', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
('InvoiceOut', 'sendQueued', 'WRITE', 'ALLOW', 'ROLE', 'system'),
|
||||
('Ticket', 'invoiceCsvPdf', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Ticket', 'invoiceCsvEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Supplier', 'campaignMetricsPdf', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Supplier', 'campaignMetricsEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Travel', 'extraCommunityPdf', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Travel', 'extraCommunityEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Entry', 'entryOrderPdf', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
('OsTicket', 'osTicketReportEmail', 'WRITE', 'ALLOW', 'ROLE', 'system'),
|
||||
('Item', 'buyerWasteEmail', 'WRITE', 'ALLOW', 'ROLE', 'system'),
|
||||
('Claim', 'claimPickupPdf', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Claim', 'claimPickupEmail', 'WRITE', 'ALLOW', 'ROLE', 'claimManager'),
|
||||
('Item', 'labelPdf', 'READ', 'ALLOW', 'ROLE', 'employee');
|
||||
|
||||
INSERT INTO `salix`.`ACL` (model,property,accessType,permission,principalType,principalId)
|
||||
VALUES ('Sector','*','READ','ALLOW','ROLE','employee');
|
||||
INSERT INTO `salix`.`ACL` (model,property,accessType,permission,principalType,principalId)
|
||||
VALUES ('Sector','*','WRITE','ALLOW','ROLE','employee');
|
|
@ -1,3 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
('Receipt', 'receiptPdf', '*', 'ALLOW', 'ROLE', 'salesAssistant');
|
|
@ -1,9 +0,0 @@
|
|||
create table `vn`.`clientConsumptionQueue`
|
||||
(
|
||||
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
params json not null,
|
||||
queued datetime default current_timestamp() not null,
|
||||
printed datetime null,
|
||||
status varchar(50) default '' null
|
||||
)
|
||||
comment 'Queue for client consumption PDF mailing';
|
|
@ -1 +0,0 @@
|
|||
rename table `vn`.`invoiceOut_queue` to `vn`.`invoiceOutQueue`;
|
|
@ -1,5 +0,0 @@
|
|||
ALTER TABLE `vn`.`itemConfig`
|
||||
ADD id int null PRIMARY KEY first;
|
||||
|
||||
ALTER TABLE `vn`.`itemConfig`
|
||||
ADD wasteRecipients VARCHAR(50) NOT NULL comment 'Weekly waste report schedule recipients';
|
|
@ -1,10 +0,0 @@
|
|||
create table `salix`.`printConfig`
|
||||
(
|
||||
id int auto_increment,
|
||||
itRecipient varchar(50) null comment 'IT recipients for report mailing',
|
||||
incidencesEmail varchar(50) null comment 'CAU destinatary email',
|
||||
constraint printConfig_pk
|
||||
primary key (id)
|
||||
)
|
||||
comment 'Print service config';
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
alter table `vn`.`sample`
|
||||
add model VARCHAR(25) null comment 'Model name in plural';
|
||||
|
||||
UPDATE vn.sample t
|
||||
SET t.model = 'Clients'
|
||||
WHERE t.id IN(12, 13, 14, 15, 16, 18, 19, 20);
|
|
@ -1 +0,0 @@
|
|||
ALTER TABLE `account`.`user` ADD hasGrant TINYINT(1) NOT NULL;
|
|
@ -1,2 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL` (model,property,accessType,permission,principalId)
|
||||
VALUES ('WorkerDisableExcluded','*','*','ALLOW','hr');
|
|
@ -1,3 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
('Business', '*', '*', 'ALLOW', 'ROLE', 'hr');
|
|
@ -1,3 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
('Sale', 'usesMana', '*', 'ALLOW', 'ROLE', 'employee');
|
|
@ -1,2 +0,0 @@
|
|||
INSERT INTO `vn`.`payDem` (id,payDem)
|
||||
VALUES (7,'0');
|
|
@ -1,4 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
('InvoiceIn', 'invoiceInPdf', 'READ', 'ALLOW', 'ROLE', 'administrative'),
|
||||
('InvoiceIn', 'invoiceInEmail', 'WRITE', 'ALLOW', 'ROLE', 'administrative');
|
|
@ -1,2 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL` (model,property,accessType,principalId)
|
||||
VALUES ('Supplier','newSupplier','WRITE','administrative');
|
|
@ -1,63 +0,0 @@
|
|||
USE util;
|
||||
|
||||
CREATE TABLE notification(
|
||||
id INT PRIMARY KEY,
|
||||
`name` VARCHAR(255) UNIQUE,
|
||||
`description` VARCHAR(255)
|
||||
);
|
||||
|
||||
CREATE TABLE notificationAcl(
|
||||
notificationFk INT,
|
||||
roleFk INT(10) unsigned,
|
||||
PRIMARY KEY(notificationFk, roleFk)
|
||||
);
|
||||
|
||||
ALTER TABLE `util`.`notificationAcl` ADD CONSTRAINT `notificationAcl_ibfk_1` FOREIGN KEY (`notificationFk`) REFERENCES `util`.`notification` (`id`)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE CASCADE;
|
||||
|
||||
ALTER TABLE `util`.`notificationAcl` ADD CONSTRAINT `notificationAcl_ibfk_2` FOREIGN KEY (`roleFk`) REFERENCES `account`.`role`(`id`)
|
||||
ON DELETE RESTRICT
|
||||
ON UPDATE CASCADE;
|
||||
|
||||
CREATE TABLE notificationSubscription(
|
||||
notificationFk INT,
|
||||
userFk INT(10) unsigned,
|
||||
PRIMARY KEY(notificationFk, userFk)
|
||||
);
|
||||
|
||||
ALTER TABLE `util`.`notificationSubscription` ADD CONSTRAINT `notificationSubscription_ibfk_1` FOREIGN KEY (`notificationFk`) REFERENCES `util`.`notification` (`id`)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE CASCADE;
|
||||
|
||||
ALTER TABLE `util`.`notificationSubscription` ADD CONSTRAINT `notificationSubscription_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user`(`id`)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE CASCADE;
|
||||
|
||||
CREATE TABLE notificationQueue(
|
||||
id INT PRIMARY KEY AUTO_INCREMENT,
|
||||
notificationFk VARCHAR(255),
|
||||
params JSON,
|
||||
authorFk INT(10) unsigned NULL,
|
||||
`status` ENUM('pending', 'sent', 'error') NOT NULL DEFAULT 'pending',
|
||||
created DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
INDEX(notificationFk),
|
||||
INDEX(authorFk),
|
||||
INDEX(status)
|
||||
);
|
||||
|
||||
ALTER TABLE `util`.`notificationQueue` ADD CONSTRAINT `nnotificationQueue_ibfk_1` FOREIGN KEY (`notificationFk`) REFERENCES `util`.`notification` (`name`)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE CASCADE;
|
||||
|
||||
ALTER TABLE `util`.`notificationQueue` ADD CONSTRAINT `notificationQueue_ibfk_2` FOREIGN KEY (`authorFk`) REFERENCES `account`.`user`(`id`)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE CASCADE;
|
||||
|
||||
CREATE TABLE notificationConfig(
|
||||
id INT PRIMARY KEY AUTO_INCREMENT,
|
||||
cleanDays MEDIUMINT
|
||||
);
|
||||
|
||||
INSERT INTO notificationConfig
|
||||
SET cleanDays = 90;
|
|
@ -1 +0,0 @@
|
|||
ALTER TABLE `vn`.`supplier` MODIFY COLUMN payMethodFk tinyint(3) unsigned NULL;
|
|
@ -1 +0,0 @@
|
|||
ALTER TABLE `vn`.`supplier` MODIFY COLUMN supplierActivityFk varchar(45) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL NULL;
|
|
@ -1,5 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId)
|
||||
VALUES
|
||||
('ClaimRma', '*', 'READ', 'ALLOW', 'ROLE', 'claimManager'),
|
||||
('ClaimRma', '*', 'WRITE', 'ALLOW', 'ROLE', 'claimManager');
|
||||
|
|
@ -1 +0,0 @@
|
|||
ALTER TABLE `vn`.`claim` ADD rma varchar(100) NULL ;
|
|
@ -1,7 +0,0 @@
|
|||
CREATE TABLE `vn`.`claimRma` (
|
||||
id INT UNSIGNED auto_increment NOT NULL PRIMARY KEY,
|
||||
code varchar(100) NOT NULL,
|
||||
created timestamp DEFAULT current_timestamp() NOT NULL,
|
||||
workerFk INTEGER UNSIGNED NOT NULL
|
||||
)
|
||||
ENGINE=InnoDB;
|
|
@ -1,3 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
('Notification', '*', 'WRITE', 'ALLOW', 'ROLE', 'developer');
|
|
@ -1,12 +0,0 @@
|
|||
CREATE TABLE `vn`.`packingSiteConfig` (
|
||||
`id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`shinobiUrl` varchar(255) NOT NULL,
|
||||
`shinobiToken` varchar(255) NOT NULL,
|
||||
`shinobiGroupKey` varchar(255) NOT NULL,
|
||||
`avgBoxingTime` INT(3) NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
);
|
||||
|
||||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
('Boxing', '*', '*', 'ALLOW', 'ROLE', 'employee');
|
|
@ -1,56 +0,0 @@
|
|||
ALTER TABLE `vn`.`packingSite` ADD monitorId varchar(255) NULL;
|
||||
|
||||
UPDATE `vn`.`packingSite`
|
||||
SET monitorId = 'VbiUcajdaT'
|
||||
WHERE code = 'h1';
|
||||
UPDATE `vn`.`packingSite`
|
||||
SET monitorId = 'qKMPn9aaVe'
|
||||
WHERE code = 'h2';
|
||||
UPDATE `vn`.`packingSite`
|
||||
SET monitorId = '3CtdIAGPAv'
|
||||
WHERE code = 'h3';
|
||||
UPDATE `vn`.`packingSite`
|
||||
SET monitorId = 'Xme2hiqz1f'
|
||||
WHERE code = 'h4';
|
||||
UPDATE `vn`.`packingSite`
|
||||
SET monitorId = 'aulxefgfJU'
|
||||
WHERE code = 'h5';
|
||||
UPDATE `vn`.`packingSite`
|
||||
SET monitorId = '6Ou0D1bhBw'
|
||||
WHERE code = 'h6';
|
||||
UPDATE `vn`.`packingSite`
|
||||
SET monitorId = 'eVUvnE6pNw'
|
||||
WHERE code = 'h7';
|
||||
UPDATE `vn`.`packingSite`
|
||||
SET monitorId = '0wsmSvqmrs'
|
||||
WHERE code = 'h8';
|
||||
UPDATE `vn`.`packingSite`
|
||||
SET monitorId = 'r2l2RyyF4I'
|
||||
WHERE code = 'h9';
|
||||
UPDATE `vn`.`packingSite`
|
||||
SET monitorId = 'EdjHLIiDVD'
|
||||
WHERE code = 'h10';
|
||||
UPDATE `vn`.`packingSite`
|
||||
SET monitorId = 'czC45kmwqI'
|
||||
WHERE code = 'h11';
|
||||
UPDATE `vn`.`packingSite`
|
||||
SET monitorId = 'PNsmxPaCwQ'
|
||||
WHERE code = 'h12';
|
||||
UPDATE `vn`.`packingSite`
|
||||
SET monitorId = 'agVssO0FDC'
|
||||
WHERE code = 'h13';
|
||||
UPDATE `vn`.`packingSite`
|
||||
SET monitorId = 'f2SPNENHPo'
|
||||
WHERE code = 'h14';
|
||||
UPDATE `vn`.`packingSite`
|
||||
SET monitorId = '6UR7gUZxks'
|
||||
WHERE code = 'h15';
|
||||
UPDATE `vn`.`packingSite`
|
||||
SET monitorId = 'bOB0f8WZ2V'
|
||||
WHERE code = 'h16';
|
||||
UPDATE `vn`.`packingSite`
|
||||
SET monitorId = 'MIR1nXaL0n'
|
||||
WHERE code = 'h17';
|
||||
UPDATE `vn`.`packingSite`
|
||||
SET monitorId = '0Oj9SgGTXR'
|
||||
WHERE code = 'h18';
|
|
@ -1,33 +0,0 @@
|
|||
CREATE TABLE `salix`.`url` (
|
||||
`appName` varchar(100) NOT NULL,
|
||||
`environment` varchar(100) NOT NULL,
|
||||
`url` varchar(255) NOT NULL,
|
||||
PRIMARY KEY (`appName`,`environment`)
|
||||
);
|
||||
|
||||
INSERT INTO `salix`.`url` (`appName`, `environment`, `url`)
|
||||
VALUES
|
||||
('salix', 'production', 'https://salix.verdnatura.es/#!/');
|
||||
INSERT INTO `salix`.`url` (`appName`, `environment`, `url`)
|
||||
VALUES
|
||||
('salix', 'test', 'https://test-salix.verdnatura.es/#!/');
|
||||
INSERT INTO `salix`.`url` (`appName`, `environment`, `url`)
|
||||
VALUES
|
||||
('salix', 'dev', 'http://localhost:5000/#!/');
|
||||
INSERT INTO `salix`.`url` (`appName`, `environment`, `url`)
|
||||
VALUES
|
||||
('lilium', 'production', 'https://lilium.verdnatura.es/#/');
|
||||
INSERT INTO `salix`.`url` (`appName`, `environment`, `url`)
|
||||
VALUES
|
||||
('lilium', 'test', 'https://test-lilium.verdnatura.es/#/');
|
||||
INSERT INTO `salix`.`url` (`appName`, `environment`, `url`)
|
||||
VALUES
|
||||
('lilium', 'dev', 'http://localhost:8080/#/');
|
||||
|
||||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
('Url', '*', 'READ', 'ALLOW', 'ROLE', 'employee');
|
||||
|
||||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
('Url', '*', 'WRITE', 'ALLOW', 'ROLE', 'it');
|
|
@ -1,2 +0,0 @@
|
|||
DELETE FROM `salix`.`ACL`
|
||||
WHERE model = 'UserPassword';
|
|
@ -1 +0,0 @@
|
|||
ALTER TABLE `vn`.`claimConfig` DROP COLUMN `pickupContact`;
|
|
@ -1,4 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId)
|
||||
VALUES
|
||||
('ItemShelving', '*', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
('ItemShelving', '*', 'WRITE', 'ALLOW', 'ROLE', 'production');
|
|
@ -1,4 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId)
|
||||
VALUES
|
||||
('ItemShelvingPlacementSupplyStock', '*', 'READ', 'ALLOW', 'ROLE', 'employee');
|
||||
|
|
@ -1 +0,0 @@
|
|||
ALTER TABLE `vn`.`workerTimeControlMail` CHANGE emailResponse reason text CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL NULL;
|
|
@ -1,54 +0,0 @@
|
|||
DROP PROCEDURE IF EXISTS `vn`.`zone_getPostalCode`;
|
||||
|
||||
DELIMITER $$
|
||||
$$
|
||||
CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zone_getPostalCode`(vSelf INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Devuelve los códigos postales incluidos en una zona
|
||||
*/
|
||||
DECLARE vGeoFk INT DEFAULT NULL;
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.zoneNodes;
|
||||
CREATE TEMPORARY TABLE tmp.zoneNodes (
|
||||
geoFk INT,
|
||||
name VARCHAR(100),
|
||||
parentFk INT,
|
||||
sons INT,
|
||||
isChecked BOOL DEFAULT 0,
|
||||
zoneFk INT,
|
||||
PRIMARY KEY zoneNodesPk (zoneFk, geoFk),
|
||||
INDEX(geoFk))
|
||||
ENGINE = MEMORY;
|
||||
|
||||
CALL zone_getLeaves2(vSelf, NULL , NULL);
|
||||
|
||||
UPDATE tmp.zoneNodes zn
|
||||
SET isChecked = 0
|
||||
WHERE parentFk IS NULL;
|
||||
|
||||
myLoop: LOOP
|
||||
SET vGeoFk = NULL;
|
||||
SELECT geoFk INTO vGeoFk
|
||||
FROM tmp.zoneNodes zn
|
||||
WHERE NOT isChecked
|
||||
LIMIT 1;
|
||||
|
||||
CALL zone_getLeaves2(vSelf, vGeoFk, NULL);
|
||||
UPDATE tmp.zoneNodes
|
||||
SET isChecked = TRUE
|
||||
WHERE geoFk = vGeoFk;
|
||||
|
||||
IF vGeoFk IS NULL THEN
|
||||
LEAVE myLoop;
|
||||
END IF;
|
||||
END LOOP;
|
||||
|
||||
DELETE FROM tmp.zoneNodes
|
||||
WHERE sons > 0;
|
||||
|
||||
SELECT zn.geoFk, zn.name
|
||||
FROM tmp.zoneNodes zn
|
||||
JOIN zone z ON z.id = zn.zoneFk;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,2 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL` (model,property,accessType,permission,principalType,principalId)
|
||||
VALUES ('NotificationQueue','*','*','ALLOW','ROLE','employee');
|
|
@ -1,7 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
('InvoiceOut', 'clientsToInvoice', 'WRITE', 'ALLOW', 'ROLE', 'invoicing');
|
||||
|
||||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
('InvoiceOut', 'invoiceClient', 'WRITE', 'ALLOW', 'ROLE', 'invoicing');
|
|
@ -1 +0,0 @@
|
|||
Alter table `vn`.`expedition` RENAME COLUMN itemFk TO itemFk__;
|
|
@ -1,8 +0,0 @@
|
|||
ALTER TABLE
|
||||
`vn`.`client`
|
||||
ADD
|
||||
COLUMN `hasElectronicInvoice` TINYINT(1) NOT NULL DEFAULT 0 COMMENT 'Registro de facturas mediante FACe'
|
||||
AFTER
|
||||
`hasInvoiceSimplified`;
|
||||
|
||||
-- sería más correcto hasElectronicInvoice pero ya existe un campo hasInvoiceSimplified
|
|
@ -1 +0,0 @@
|
|||
DROP PROCEDURE IF EXISTS `vn`.`collection_missingTrash`;
|
|
@ -1 +0,0 @@
|
|||
DROP TABLE `vn`.`invoiceOutQueue`;
|
|
@ -1,4 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
('Sale', 'editTracked', 'WRITE', 'ALLOW', 'ROLE', 'production'),
|
||||
('Sale', 'editFloramondo', 'WRITE', 'ALLOW', 'ROLE', 'salesAssistant');
|
|
@ -1 +0,0 @@
|
|||
ALTER TABLE `vn`.`greuge` CHANGE `userFK` `userFk` int(10) unsigned DEFAULT NULL NULL;
|
|
@ -1,4 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
('Receipt', 'balanceCompensationEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Receipt', 'balanceCompensationPdf', 'READ', 'ALLOW', 'ROLE', 'employee');
|
|
@ -1,8 +0,0 @@
|
|||
ALTER TABLE `vn`.`osTicketConfig` DROP COLUMN `action`;
|
||||
ALTER TABLE `vn`.`osTicketConfig` ADD responseType varchar(100) NULL;
|
||||
ALTER TABLE `vn`.`osTicketConfig` ADD fromEmailId INT NULL;
|
||||
ALTER TABLE `vn`.`osTicketConfig` ADD replyTo varchar(100) NULL;
|
||||
|
||||
UPDATE `vn`.`osTicketConfig`
|
||||
SET responseType='reply', fromEmailId=5, replyTo='all'
|
||||
WHERE id=0;
|
|
@ -1,14 +0,0 @@
|
|||
DROP PROCEDURE IF EXISTS `vn`.`ticket_canMerge`;
|
||||
|
||||
DELIMITER $$
|
||||
$$
|
||||
CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_canMerge`(vDated DATE, vScopeDays INT, vLitersMax INT, vLinesMax INT, vWarehouseFk INT)
|
||||
BEGIN
|
||||
CALL vn.ticket_canbePostponed(vDated,TIMESTAMPADD(DAY, vScopeDays, vDated),vLitersMax,vLinesMax,vWarehouseFk);
|
||||
END $$
|
||||
DELIMITER ;
|
||||
|
||||
INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId)
|
||||
VALUES
|
||||
('Ticket', 'getTicketsFuture', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Ticket', 'merge', 'WRITE', 'ALLOW', 'ROLE', 'employee');
|
|
@ -1,79 +0,0 @@
|
|||
DROP PROCEDURE IF EXISTS `vn`.`ticket_canbePostponed`;
|
||||
|
||||
DELIMITER $$
|
||||
$$
|
||||
CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_canbePostponed`(vOriginDated DATE, vFutureDated DATE, vLitersMax INT, vLinesMax INT, vWarehouseFk INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Devuelve un listado de tickets susceptibles de fusionarse con otros tickets en el futuro
|
||||
*
|
||||
* @param vOriginDated Fecha en cuestión
|
||||
* @param vFutureDated Fecha en el futuro a sondear
|
||||
* @param vLitersMax Volumen máximo de los tickets a catapultar
|
||||
* @param vLinesMax Número máximo de lineas de los tickets a catapultar
|
||||
* @param vWarehouseFk Identificador de vn.warehouse
|
||||
*/
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.filter;
|
||||
CREATE TEMPORARY TABLE tmp.filter
|
||||
(INDEX (id))
|
||||
SELECT sv.ticketFk id,
|
||||
GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk) ipt,
|
||||
CAST(sum(litros) AS DECIMAL(10,0)) liters,
|
||||
CAST(count(*) AS DECIMAL(10,0)) `lines`,
|
||||
st.name state,
|
||||
sub2.id ticketFuture,
|
||||
t.landed originETD,
|
||||
sub2.landed destETD,
|
||||
sub2.iptd tfIpt,
|
||||
sub2.state tfState,
|
||||
t.clientFk,
|
||||
t.warehouseFk,
|
||||
ts.alertLevel,
|
||||
t.shipped,
|
||||
sub2.shipped tfShipped,
|
||||
t.workerFk,
|
||||
st.code code,
|
||||
sub2.code tfCode
|
||||
FROM vn.saleVolume sv
|
||||
JOIN vn.sale s ON s.id = sv.saleFk
|
||||
JOIN vn.item i ON i.id = s.itemFk
|
||||
JOIN vn.ticket t ON t.id = sv.ticketFk
|
||||
JOIN vn.address a ON a.id = t.addressFk
|
||||
JOIN vn.province p ON p.id = a.provinceFk
|
||||
JOIN vn.country c ON c.id = p.countryFk
|
||||
JOIN vn.ticketState ts ON ts.ticketFk = t.id
|
||||
JOIN vn.state st ON st.id = ts.stateFk
|
||||
JOIN vn.alertLevel al ON al.id = ts.alertLevel
|
||||
LEFT JOIN vn.ticketParking tp ON tp.ticketFk = t.id
|
||||
LEFT JOIN (
|
||||
SELECT *
|
||||
FROM (
|
||||
SELECT
|
||||
t.addressFk ,
|
||||
t.id,
|
||||
t.landed,
|
||||
t.shipped,
|
||||
st.name state,
|
||||
st.code code,
|
||||
GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk) iptd
|
||||
FROM vn.ticket t
|
||||
JOIN vn.ticketState ts ON ts.ticketFk = t.id
|
||||
JOIN vn.state st ON st.id = ts.stateFk
|
||||
JOIN vn.sale s ON s.ticketFk = t.id
|
||||
JOIN vn.item i ON i.id = s.itemFk
|
||||
WHERE t.shipped BETWEEN vFutureDated
|
||||
AND util.dayend(vFutureDated)
|
||||
AND t.warehouseFk = vWarehouseFk
|
||||
GROUP BY t.id
|
||||
) sub
|
||||
GROUP BY sub.addressFk
|
||||
) sub2 ON sub2.addressFk = t.addressFk AND t.id != sub2.id
|
||||
WHERE t.shipped BETWEEN vOriginDated AND util.dayend(vOriginDated)
|
||||
AND t.warehouseFk = vWarehouseFk
|
||||
AND al.code = 'FREE'
|
||||
AND tp.ticketFk IS NULL
|
||||
GROUP BY sv.ticketFk
|
||||
HAVING liters <= IFNULL(vLitersMax, 9999) AND `lines` <= IFNULL(vLinesMax, 9999) AND ticketFuture;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
@ -1,88 +0,0 @@
|
|||
DROP PROCEDURE IF EXISTS `vn`.`timeBusiness_calculate`;
|
||||
|
||||
DELIMITER $$
|
||||
$$
|
||||
CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`timeBusiness_calculate`(vDatedFrom DATETIME, vDatedTo DATETIME)
|
||||
BEGIN
|
||||
/**
|
||||
* Horas que debe trabajar un empleado según contrato y día.
|
||||
* @param vDatedFrom workerTimeControl
|
||||
* @param vDatedTo workerTimeControl
|
||||
* @table tmp.user(userFk)
|
||||
* @return tmp.timeBusinessCalculate
|
||||
*/
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.timeBusinessCalculate;
|
||||
CREATE TEMPORARY TABLE tmp.timeBusinessCalculate
|
||||
(INDEX (departmentFk))
|
||||
SELECT dated,
|
||||
businessFk,
|
||||
userFk,
|
||||
departmentFk,
|
||||
hourStart,
|
||||
hourEnd,
|
||||
timeTable,
|
||||
timeWorkSeconds,
|
||||
SEC_TO_TIME(timeWorkSeconds) timeWorkSexagesimal,
|
||||
timeWorkSeconds / 3600 timeWorkDecimal,
|
||||
timeWorkSeconds timeBusinessSeconds,
|
||||
SEC_TO_TIME(timeWorkSeconds) timeBusinessSexagesimal,
|
||||
timeWorkSeconds / 3600 timeBusinessDecimal,
|
||||
name type,
|
||||
permissionRate,
|
||||
hoursWeek,
|
||||
discountRate,
|
||||
isAllowedToWork
|
||||
FROM(SELECT t.dated,
|
||||
b.id businessFk,
|
||||
w.id,
|
||||
b.departmentFk,
|
||||
IF(j.start = NULL, NULL, GROUP_CONCAT(DISTINCT LEFT(j.start,5) ORDER BY j.start ASC SEPARATOR ' - ')) hourStart ,
|
||||
IF(j.start = NULL, NULL, GROUP_CONCAT(DISTINCT LEFT(j.end,5) ORDER BY j.end ASC SEPARATOR ' - ')) hourEnd,
|
||||
IF(j.start = NULL, NULL, GROUP_CONCAT(DISTINCT LEFT(j.start,5), " - ", LEFT(j.end,5) ORDER BY j.end ASC SEPARATOR ' - ')) timeTable,
|
||||
IF(j.start = NULL, 0, IFNULL(SUM(TIME_TO_SEC(j.end)) - SUM(TIME_TO_SEC(j.start)), 0)) timeWorkSeconds,
|
||||
at2.name,
|
||||
at2.permissionRate,
|
||||
at2.discountRate,
|
||||
cl.hours_week hoursWeek,
|
||||
at2.isAllowedToWork
|
||||
FROM time t
|
||||
LEFT JOIN business b ON t.dated BETWEEN b.started AND IFNULL(b.ended, vDatedTo)
|
||||
LEFT JOIN worker w ON w.id = b.workerFk
|
||||
JOIN tmp.`user` u ON u.userFK = w.id
|
||||
LEFT JOIN workCenter wc ON wc.id = b.workcenterFK
|
||||
LEFT JOIN postgresql.calendar_labour_type cl ON cl.calendar_labour_type_id = b.calendarTypeFk
|
||||
LEFT JOIN postgresql.journey j ON j.business_id = b.id AND j.day_id = WEEKDAY(t.dated) + 1
|
||||
LEFT JOIN postgresql.calendar_employee ce ON ce.businessFk = b.id AND ce.date = t.dated
|
||||
LEFT JOIN absenceType at2 ON at2.id = ce.calendar_state_id
|
||||
WHERE t.dated BETWEEN vDatedFrom AND vDatedTo
|
||||
GROUP BY w.id, t.dated
|
||||
)sub;
|
||||
|
||||
UPDATE tmp.timeBusinessCalculate t
|
||||
LEFT JOIN postgresql.journey j ON j.business_id = t.businessFk
|
||||
SET t.timeWorkSeconds = t.hoursWeek / 5 * 3600,
|
||||
t.timeWorkSexagesimal = SEC_TO_TIME( t.hoursWeek / 5 * 3600),
|
||||
t.timeWorkDecimal = t.hoursWeek / 5,
|
||||
t.timeBusinessSeconds = t.hoursWeek / 5 * 3600,
|
||||
t.timeBusinessSexagesimal = SEC_TO_TIME( t.hoursWeek / 5 * 3600),
|
||||
t.timeBusinessDecimal = t.hoursWeek / 5
|
||||
WHERE DAYOFWEEK(t.dated) IN(2,3,4,5,6) AND j.journey_id IS NULL ;
|
||||
|
||||
UPDATE tmp.timeBusinessCalculate t
|
||||
SET t.timeWorkSeconds = t.timeWorkSeconds - (t.timeWorkSeconds * permissionRate) ,
|
||||
t.timeWorkSexagesimal = SEC_TO_TIME ((t.timeWorkDecimal - (t.timeWorkDecimal * permissionRate)) * 3600),
|
||||
t.timeWorkDecimal = t.timeWorkDecimal - (t.timeWorkDecimal * permissionRate)
|
||||
WHERE permissionRate <> 0;
|
||||
|
||||
UPDATE tmp.timeBusinessCalculate t
|
||||
JOIN calendarHolidays ch ON ch.dated = t.dated
|
||||
JOIN business b ON b.id = t.businessFk
|
||||
AND b.workcenterFk = ch.workcenterFk
|
||||
SET t.timeWorkSeconds = 0,
|
||||
t.timeWorkSexagesimal = 0,
|
||||
t.timeWorkDecimal = 0,
|
||||
t.permissionrate = 1,
|
||||
t.type = 'Festivo'
|
||||
WHERE t.type IS NULL;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,6 +0,0 @@
|
|||
UPDATE
|
||||
`vn`.`client`
|
||||
SET
|
||||
hasElectronicInvoice = TRUE
|
||||
WHERE
|
||||
businessTypeFk = 'officialOrganism';
|
|
@ -1,4 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
('MdbApp', 'lock', 'WRITE', 'ALLOW', 'ROLE', 'developer'),
|
||||
('MdbApp', 'unlock', 'WRITE', 'ALLOW', 'ROLE', 'developer');
|
|
@ -1,3 +0,0 @@
|
|||
UPDATE `vn`.`collection`
|
||||
SET sectorFk=1
|
||||
WHERE id=1;
|
|
@ -1 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL` (`model`,`property`,`accessType`,`permission`,`principalId`) VALUES ('Dms','saveSign','*','ALLOW','employee');
|
|
@ -1,3 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
('TicketLog', 'getChanges', 'READ', 'ALLOW', 'ROLE', 'employee');
|
|
@ -1 +0,0 @@
|
|||
ALTER TABLE `vn`.`entry` DROP COLUMN `ref`;
|
|
@ -1,12 +0,0 @@
|
|||
CREATE TABLE `vn`.`invoiceInConfig` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`retentionRate` int(3) NOT NULL,
|
||||
`retentionName` varchar(25) NOT NULL,
|
||||
`sageWithholdingFk` smallint(6) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
CONSTRAINT `invoiceInConfig_sageWithholdingFk` FOREIGN KEY (`sageWithholdingFk`) REFERENCES `sage`.`TiposRetencion`(`CodigoRetencion`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
|
||||
|
||||
INSERT INTO `vn`.`invoiceInConfig` (`id`, `retentionRate`, `retentionName`, `sageWithholdingFk`)
|
||||
VALUES
|
||||
(1, -2, 'Retención 2%', 2);
|
|
@ -1,225 +0,0 @@
|
|||
DROP PROCEDURE IF EXISTS `vn`.`invoiceOut_new`;
|
||||
DELIMITER $$
|
||||
CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceOut_new`(
|
||||
vSerial VARCHAR(255),
|
||||
vInvoiceDate DATETIME,
|
||||
vTaxArea VARCHAR(25),
|
||||
OUT vNewInvoiceId INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Creación de facturas emitidas.
|
||||
* requiere previamente tabla tmp.ticketToInvoice(id).
|
||||
*
|
||||
* @param vSerial serie a la cual se hace la factura
|
||||
* @param vInvoiceDate fecha de la factura
|
||||
* @param vTaxArea tipo de iva en relacion a la empresa y al cliente
|
||||
* @param vNewInvoiceId id de la factura que se acaba de generar
|
||||
* @return vNewInvoiceId
|
||||
*/
|
||||
DECLARE vSpainCountryCode INT DEFAULT 1;
|
||||
DECLARE vIsAnySaleToInvoice BOOL;
|
||||
DECLARE vIsAnyServiceToInvoice BOOL;
|
||||
DECLARE vNewRef VARCHAR(255);
|
||||
DECLARE vWorker INT DEFAULT account.myUser_getId();
|
||||
DECLARE vCompany INT;
|
||||
DECLARE vSupplier INT;
|
||||
DECLARE vClient INT;
|
||||
DECLARE vCplusStandardInvoiceTypeFk INT DEFAULT 1;
|
||||
DECLARE vCplusCorrectingInvoiceTypeFk INT DEFAULT 6;
|
||||
DECLARE vCplusSimplifiedInvoiceTypeFk INT DEFAULT 2;
|
||||
DECLARE vCorrectingSerial VARCHAR(1) DEFAULT 'R';
|
||||
DECLARE vSimplifiedSerial VARCHAR(1) DEFAULT 'S';
|
||||
DECLARE vNewInvoiceInId INT;
|
||||
DECLARE vIsInterCompany BOOL;
|
||||
|
||||
SET vInvoiceDate = IFNULL(vInvoiceDate,CURDATE());
|
||||
|
||||
SELECT t.clientFk, t.companyFk
|
||||
INTO vClient, vCompany
|
||||
FROM tmp.ticketToInvoice tt
|
||||
JOIN ticket t ON t.id = tt.id
|
||||
LIMIT 1;
|
||||
|
||||
-- Eliminem de tmp.ticketToInvoice els tickets que no han de ser facturats
|
||||
DELETE ti.*
|
||||
FROM tmp.ticketToInvoice ti
|
||||
JOIN ticket t ON t.id = ti.id
|
||||
JOIN sale s ON s.ticketFk = t.id
|
||||
JOIN item i ON i.id = s.itemFk
|
||||
JOIN supplier su ON su.id = t.companyFk
|
||||
JOIN client c ON c.id = t.clientFk
|
||||
LEFT JOIN itemTaxCountry itc ON itc.itemFk = i.id AND itc.countryFk = su.countryFk
|
||||
WHERE YEAR(t.shipped) < 2001
|
||||
OR c.isTaxDataChecked = FALSE
|
||||
OR t.isDeleted
|
||||
OR c.hasToInvoice = FALSE
|
||||
OR itc.id IS NULL;
|
||||
|
||||
SELECT SUM(s.quantity * s.price * (100 - s.discount)/100), ts.id
|
||||
INTO vIsAnySaleToInvoice, vIsAnyServiceToInvoice
|
||||
FROM tmp.ticketToInvoice t
|
||||
LEFT JOIN sale s ON s.ticketFk = t.id
|
||||
LEFT JOIN ticketService ts ON ts.ticketFk = t.id;
|
||||
|
||||
IF (vIsAnySaleToInvoice OR vIsAnyServiceToInvoice)
|
||||
AND (vCorrectingSerial = vSerial OR NOT hasAnyNegativeBase())
|
||||
THEN
|
||||
|
||||
-- el trigger añade el siguiente Id_Factura correspondiente a la vSerial
|
||||
INSERT INTO invoiceOut
|
||||
(
|
||||
ref,
|
||||
serial,
|
||||
issued,
|
||||
clientFk,
|
||||
dued,
|
||||
companyFk,
|
||||
siiTypeInvoiceOutFk
|
||||
)
|
||||
SELECT
|
||||
1,
|
||||
vSerial,
|
||||
vInvoiceDate,
|
||||
vClient,
|
||||
getDueDate(vInvoiceDate, dueDay),
|
||||
vCompany,
|
||||
IF(vSerial = vCorrectingSerial,
|
||||
vCplusCorrectingInvoiceTypeFk,
|
||||
IF(vSerial = vSimplifiedSerial,
|
||||
vCplusSimplifiedInvoiceTypeFk,
|
||||
vCplusStandardInvoiceTypeFk))
|
||||
FROM client
|
||||
WHERE id = vClient;
|
||||
|
||||
|
||||
SET vNewInvoiceId = LAST_INSERT_ID();
|
||||
|
||||
SELECT `ref`
|
||||
INTO vNewRef
|
||||
FROM invoiceOut
|
||||
WHERE id = vNewInvoiceId;
|
||||
|
||||
UPDATE ticket t
|
||||
JOIN tmp.ticketToInvoice ti ON ti.id = t.id
|
||||
SET t.refFk = vNewRef;
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.updateInter;
|
||||
CREATE TEMPORARY TABLE tmp.updateInter ENGINE = MEMORY
|
||||
SELECT s.id,ti.id ticket_id,vWorker Id_Trabajador
|
||||
FROM tmp.ticketToInvoice ti
|
||||
LEFT JOIN ticketState ts ON ti.id = ts.ticket
|
||||
JOIN state s
|
||||
WHERE IFNULL(ts.alertLevel,0) < 3 and s.`code` = getAlert3State(ti.id);
|
||||
|
||||
INSERT INTO vncontrol.inter(state_id,Id_Ticket,Id_Trabajador)
|
||||
SELECT * FROM tmp.updateInter;
|
||||
|
||||
INSERT INTO ticketLog (action, userFk, originFk, description)
|
||||
SELECT 'UPDATE', account.myUser_getId(), ti.id, CONCAT('Crea factura ', vNewRef)
|
||||
FROM tmp.ticketToInvoice ti;
|
||||
|
||||
CALL invoiceExpenseMake(vNewInvoiceId);
|
||||
CALL invoiceTaxMake(vNewInvoiceId,vTaxArea);
|
||||
|
||||
UPDATE invoiceOut io
|
||||
JOIN (
|
||||
SELECT SUM(amount) AS total
|
||||
FROM invoiceOutExpense
|
||||
WHERE invoiceOutFk = vNewInvoiceId
|
||||
) base
|
||||
JOIN (
|
||||
SELECT SUM(vat) AS total
|
||||
FROM invoiceOutTax
|
||||
WHERE invoiceOutFk = vNewInvoiceId
|
||||
) vat
|
||||
SET io.amount = base.total + vat.total
|
||||
WHERE io.id = vNewInvoiceId;
|
||||
|
||||
DROP TEMPORARY TABLE tmp.updateInter;
|
||||
|
||||
SELECT ios.isCEE INTO vIsInterCompany
|
||||
FROM vn.ticket t
|
||||
JOIN vn.invoiceOut io ON io.`ref` = t.refFk
|
||||
JOIN vn.invoiceOutSerial ios ON ios.code = io.serial
|
||||
WHERE t.refFk = vNewRef
|
||||
LIMIT 1;
|
||||
|
||||
IF (vIsInterCompany) THEN
|
||||
|
||||
SELECT vCompany INTO vSupplier;
|
||||
SELECT id INTO vCompany FROM company WHERE clientFk = vClient;
|
||||
|
||||
INSERT INTO invoiceIn(supplierFk, supplierRef, issued, companyFk)
|
||||
SELECT vSupplier, vNewRef, vInvoiceDate, vCompany;
|
||||
|
||||
SET vNewInvoiceInId = LAST_INSERT_ID();
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.ticket;
|
||||
CREATE TEMPORARY TABLE tmp.ticket
|
||||
(KEY (ticketFk))
|
||||
ENGINE = MEMORY
|
||||
SELECT id ticketFk
|
||||
FROM tmp.ticketToInvoice;
|
||||
|
||||
CALL `ticket_getTax`('NATIONAL');
|
||||
|
||||
SET @vTaxableBaseServices := 0.00;
|
||||
SET @vTaxCodeGeneral := NULL;
|
||||
|
||||
INSERT INTO vn.invoiceInTax(invoiceInFk, taxableBase, expenseFk, taxTypeSageFk, transactionTypeSageFk)
|
||||
SELECT vNewInvoiceInId, @vTaxableBaseServices, sub.expenseFk, sub.taxTypeSageFk , sub.transactionTypeSageFk
|
||||
FROM (
|
||||
SELECT @vTaxableBaseServices := SUM(tst.taxableBase) taxableBase, i.expenseFk, i.taxTypeSageFk , i.transactionTypeSageFk, @vTaxCodeGeneral := i.taxClassCodeFk
|
||||
FROM tmp.ticketServiceTax tst
|
||||
JOIN vn.invoiceOutTaxConfig i ON i.taxClassCodeFk = tst.code
|
||||
WHERE i.isService
|
||||
HAVING taxableBase
|
||||
) sub;
|
||||
|
||||
INSERT INTO vn.invoiceInTax(invoiceInFk, taxableBase, expenseFk, taxTypeSageFk, transactionTypeSageFk)
|
||||
SELECT vNewInvoiceInId, SUM(tt.taxableBase) - IF(tt.code = @vTaxCodeGeneral, @vTaxableBaseServices, 0) taxableBase, i.expenseFk, i.taxTypeSageFk , i.transactionTypeSageFk
|
||||
FROM tmp.ticketTax tt
|
||||
JOIN vn.invoiceOutTaxConfig i ON i.taxClassCodeFk = tt.code
|
||||
WHERE !i.isService
|
||||
GROUP BY tt.pgcFk
|
||||
HAVING taxableBase
|
||||
ORDER BY tt.priority;
|
||||
|
||||
CALL invoiceInDueDay_calculate(vNewInvoiceInId);
|
||||
|
||||
INSERT INTO invoiceInIntrastat (
|
||||
invoiceInFk,
|
||||
intrastatFk,
|
||||
amount,
|
||||
stems,
|
||||
countryFk,
|
||||
net)
|
||||
SELECT
|
||||
vNewInvoiceInId invoiceInFk,
|
||||
i.intrastatFk,
|
||||
CAST(SUM((s.quantity * s.price * (100 - s.discount) / 100 )) AS DECIMAL(10,2)) subtotal,
|
||||
CAST(SUM(IFNULL(i.stems, 1) * s.quantity) AS DECIMAL(10,2)) stems,
|
||||
su.countryFk,
|
||||
CAST(SUM(IFNULL(i.stems, 1)
|
||||
* s.quantity
|
||||
* IF(ic.grams, ic.grams, i.weightByPiece) / 1000) AS DECIMAL(10,2)) netKg
|
||||
FROM sale s
|
||||
JOIN ticket t ON s.ticketFk = t.id
|
||||
JOIN supplier su ON su.id = t.companyFk
|
||||
JOIN item i ON i.id = s.itemFk
|
||||
JOIN vn.itemCost ic ON ic.itemFk = i.id AND ic.warehouseFk = t.warehouseFk
|
||||
JOIN intrastat ir ON ir.id = i.intrastatFk
|
||||
WHERE t.refFk = vNewRef;
|
||||
|
||||
DROP TEMPORARY TABLE tmp.ticket;
|
||||
DROP TEMPORARY TABLE tmp.ticketAmount;
|
||||
DROP TEMPORARY TABLE tmp.ticketTax;
|
||||
DROP TEMPORARY TABLE tmp.ticketServiceTax;
|
||||
|
||||
END IF;
|
||||
|
||||
END IF;
|
||||
|
||||
DROP TEMPORARY TABLE `tmp`.`ticketToInvoice`;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,11 +0,0 @@
|
|||
CREATE TABLE `vn`.`mdbApp` (
|
||||
`app` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL,
|
||||
`baselineBranchFk` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
|
||||
`userFk` int(10) unsigned DEFAULT NULL,
|
||||
`locked` datetime DEFAULT NULL,
|
||||
PRIMARY KEY (`app`),
|
||||
KEY `mdbApp_FK` (`userFk`),
|
||||
KEY `mdbApp_FK_1` (`baselineBranchFk`),
|
||||
CONSTRAINT `mdbApp_FK` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
|
||||
CONSTRAINT `mdbApp_FK_1` FOREIGN KEY (`baselineBranchFk`) REFERENCES `mdbBranch` (`name`) ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci
|
|
@ -1,24 +0,0 @@
|
|||
DROP FUNCTION IF EXISTS `util`.`notification_send`;
|
||||
|
||||
DELIMITER $$
|
||||
$$
|
||||
CREATE DEFINER=`root`@`localhost` FUNCTION `util`.`notification_send`(vNotificationName VARCHAR(255), vParams TEXT, vAuthorFk INT) RETURNS int(11)
|
||||
MODIFIES SQL DATA
|
||||
BEGIN
|
||||
/**
|
||||
* Sends a notification.
|
||||
*
|
||||
* @param vNotificationName The notification name
|
||||
* @param vParams The notification parameters formatted as JSON
|
||||
* @param vAuthorFk The notification author or %NULL if there is no author
|
||||
* @return The notification id
|
||||
*/
|
||||
|
||||
INSERT INTO notificationQueue
|
||||
SET notificationFk = vNotificationName,
|
||||
params = vParams,
|
||||
authorFk = vAuthorFk;
|
||||
|
||||
RETURN LAST_INSERT_ID();
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,8 +0,0 @@
|
|||
CREATE TABLE `vn`.`ticketSms` (
|
||||
`smsFk` mediumint(8) unsigned NOT NULL,
|
||||
`ticketFk` int(11) DEFAULT NULL,
|
||||
PRIMARY KEY (`smsFk`),
|
||||
KEY `ticketSms_FK_1` (`ticketFk`),
|
||||
CONSTRAINT `ticketSms_FK` FOREIGN KEY (`smsFk`) REFERENCES `sms` (`id`) ON UPDATE CASCADE,
|
||||
CONSTRAINT `ticketSms_FK_1` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci
|
|
@ -1,104 +0,0 @@
|
|||
DROP PROCEDURE IF EXISTS `vn`.`ticket_canAdvance`;
|
||||
|
||||
DELIMITER $$
|
||||
$$
|
||||
CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_canAdvance`(vDateFuture DATE, vDateToAdvance DATE, vWarehouseFk INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Devuelve los tickets y la cantidad de lineas de venta que se pueden adelantar.
|
||||
*
|
||||
* @param vDateFuture Fecha de los tickets que se quieren adelantar.
|
||||
* @param vDateToAdvance Fecha a cuando se quiere adelantar.
|
||||
* @param vWarehouseFk Almacén
|
||||
*/
|
||||
|
||||
DECLARE vDateInventory DATE;
|
||||
|
||||
SELECT inventoried INTO vDateInventory FROM vn.config;
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.stock;
|
||||
CREATE TEMPORARY TABLE tmp.stock
|
||||
(itemFk INT PRIMARY KEY,
|
||||
amount INT)
|
||||
ENGINE = MEMORY;
|
||||
|
||||
INSERT INTO tmp.stock(itemFk, amount)
|
||||
SELECT itemFk, SUM(quantity) amount FROM
|
||||
(
|
||||
SELECT itemFk, quantity
|
||||
FROM vn.itemTicketOut
|
||||
WHERE shipped >= vDateInventory
|
||||
AND shipped < vDateFuture
|
||||
AND warehouseFk = vWarehouseFk
|
||||
UNION ALL
|
||||
SELECT itemFk, quantity
|
||||
FROM vn.itemEntryIn
|
||||
WHERE landed >= vDateInventory
|
||||
AND landed < vDateFuture
|
||||
AND isVirtualStock = FALSE
|
||||
AND warehouseInFk = vWarehouseFk
|
||||
UNION ALL
|
||||
SELECT itemFk, quantity
|
||||
FROM vn.itemEntryOut
|
||||
WHERE shipped >= vDateInventory
|
||||
AND shipped < vDateFuture
|
||||
AND warehouseOutFk = vWarehouseFk
|
||||
) t
|
||||
GROUP BY itemFk HAVING amount != 0;
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.filter;
|
||||
CREATE TEMPORARY TABLE tmp.filter
|
||||
(INDEX (id))
|
||||
SELECT s.ticketFk futureId,
|
||||
t2.ticketFk id,
|
||||
sum((s.quantity <= IFNULL(st.amount,0))) hasStock,
|
||||
count(DISTINCT s.id) saleCount,
|
||||
t2.state,
|
||||
t2.stateCode,
|
||||
st.name futureState,
|
||||
st.code futureStateCode,
|
||||
GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) futureIpt,
|
||||
t2.ipt,
|
||||
t.workerFk,
|
||||
CAST(sum(litros) AS DECIMAL(10,0)) liters,
|
||||
CAST(count(*) AS DECIMAL(10,0)) `lines`,
|
||||
t2.shipped,
|
||||
t.shipped futureShipped,
|
||||
t2.totalWithVat,
|
||||
t.totalWithVat futureTotalWithVat
|
||||
FROM vn.ticket t
|
||||
JOIN vn.ticketState ts ON ts.ticketFk = t.id
|
||||
JOIN vn.state st ON st.id = ts.stateFk
|
||||
JOIN vn.saleVolume sv ON t.id = sv.ticketFk
|
||||
JOIN (SELECT
|
||||
t2.id ticketFk,
|
||||
t2.addressFk,
|
||||
st.name state,
|
||||
st.code stateCode,
|
||||
GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) ipt,
|
||||
t2.shipped,
|
||||
t2.totalWithVat
|
||||
FROM vn.ticket t2
|
||||
JOIN vn.sale s ON s.ticketFk = t2.id
|
||||
JOIN vn.item i ON i.id = s.itemFk
|
||||
JOIN vn.ticketState ts ON ts.ticketFk = t2.id
|
||||
JOIN vn.state st ON st.id = ts.stateFk
|
||||
LEFT JOIN vn.itemPackingType ipt ON ipt.code = i.itemPackingTypeFk
|
||||
WHERE t2.shipped BETWEEN vDateToAdvance AND util.dayend(vDateToAdvance)
|
||||
AND t2.warehouseFk = vWarehouseFk
|
||||
GROUP BY t2.id) t2 ON t2.addressFk = t.addressFk
|
||||
JOIN vn.sale s ON s.ticketFk = t.id
|
||||
JOIN vn.item i ON i.id = s.itemFk
|
||||
LEFT JOIN vn.itemPackingType ipt ON ipt.code = i.itemPackingTypeFk
|
||||
LEFT JOIN tmp.stock st ON st.itemFk = s.itemFk
|
||||
WHERE t.shipped BETWEEN vDateFuture AND util.dayend(vDateFuture)
|
||||
AND t.warehouseFk = vWarehouseFk
|
||||
GROUP BY t.id;
|
||||
|
||||
DROP TEMPORARY TABLE tmp.stock;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
||||
INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId)
|
||||
VALUES
|
||||
('Ticket', 'getTicketsAdvance', 'READ', 'ALLOW', 'ROLE', 'employee');
|
|
@ -1,73 +0,0 @@
|
|||
DROP PROCEDURE IF EXISTS `vn`.`ticket_canbePostponed`;
|
||||
|
||||
DELIMITER $$
|
||||
$$
|
||||
CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_canbePostponed`(vOriginDated DATE, vFutureDated DATE, vWarehouseFk INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Devuelve un listado de tickets susceptibles de fusionarse con otros tickets en el futuro
|
||||
*
|
||||
* @param vOriginDated Fecha en cuestión
|
||||
* @param vFutureDated Fecha en el futuro a sondear
|
||||
* @param vWarehouseFk Identificador de vn.warehouse
|
||||
*/
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.filter;
|
||||
CREATE TEMPORARY TABLE tmp.filter
|
||||
(INDEX (id))
|
||||
SELECT sv.ticketFk id,
|
||||
sub2.id futureId,
|
||||
GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk) ipt,
|
||||
CAST(sum(litros) AS DECIMAL(10,0)) liters,
|
||||
CAST(count(*) AS DECIMAL(10,0)) `lines`,
|
||||
st.name state,
|
||||
sub2.iptd futureIpt,
|
||||
sub2.state futureState,
|
||||
t.clientFk,
|
||||
t.warehouseFk,
|
||||
ts.alertLevel,
|
||||
t.shipped,
|
||||
sub2.shipped futureShipped,
|
||||
t.workerFk,
|
||||
st.code stateCode,
|
||||
sub2.code futureStateCode
|
||||
FROM vn.saleVolume sv
|
||||
JOIN vn.sale s ON s.id = sv.saleFk
|
||||
JOIN vn.item i ON i.id = s.itemFk
|
||||
JOIN vn.ticket t ON t.id = sv.ticketFk
|
||||
JOIN vn.address a ON a.id = t.addressFk
|
||||
JOIN vn.province p ON p.id = a.provinceFk
|
||||
JOIN vn.country c ON c.id = p.countryFk
|
||||
JOIN vn.ticketState ts ON ts.ticketFk = t.id
|
||||
JOIN vn.state st ON st.id = ts.stateFk
|
||||
JOIN vn.alertLevel al ON al.id = ts.alertLevel
|
||||
LEFT JOIN vn.ticketParking tp ON tp.ticketFk = t.id
|
||||
LEFT JOIN (
|
||||
SELECT *
|
||||
FROM (
|
||||
SELECT
|
||||
t.addressFk,
|
||||
t.id,
|
||||
t.shipped,
|
||||
st.name state,
|
||||
st.code code,
|
||||
GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk) iptd
|
||||
FROM vn.ticket t
|
||||
JOIN vn.ticketState ts ON ts.ticketFk = t.id
|
||||
JOIN vn.state st ON st.id = ts.stateFk
|
||||
JOIN vn.sale s ON s.ticketFk = t.id
|
||||
JOIN vn.item i ON i.id = s.itemFk
|
||||
WHERE t.shipped BETWEEN vFutureDated
|
||||
AND util.dayend(vFutureDated)
|
||||
AND t.warehouseFk = vWarehouseFk
|
||||
GROUP BY t.id
|
||||
) sub
|
||||
GROUP BY sub.addressFk
|
||||
) sub2 ON sub2.addressFk = t.addressFk AND t.id != sub2.id
|
||||
WHERE t.shipped BETWEEN vOriginDated AND util.dayend(vOriginDated)
|
||||
AND t.warehouseFk = vWarehouseFk
|
||||
AND al.code = 'FREE'
|
||||
AND tp.ticketFk IS NULL
|
||||
GROUP BY sv.ticketFk
|
||||
HAVING futureId;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,2 +0,0 @@
|
|||
DROP PROCEDURE IF EXISTS `ticket_split`;
|
||||
DROP PROCEDURE IF EXISTS `ticket_merge`;
|
|
@ -1,4 +0,0 @@
|
|||
INSERT INTO `util`.`notification` (id, name, description) VALUES(3, 'book-entries-imported-incorrectly', 'accounting entries exported incorrectly');
|
||||
INSERT INTO `util`.`notificationAcl` (notificationFk, roleFk) VALUES(3, 5);
|
||||
INSERT IGNORE INTO `util`.`notificationSubscription` (notificationFk, userFk) VALUES(3, 19663);
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
CREATE TABLE `vn`.`stateI18n` (
|
||||
`stateFk` tinyint(3) unsigned NOT NULL,
|
||||
`lang` char(2) NOT NULL,
|
||||
`name` varchar(255) NOT NULL,
|
||||
PRIMARY KEY (`stateFk`, `lang`),
|
||||
CONSTRAINT `stateI18n_state_id` FOREIGN KEY (`stateFk`) REFERENCES `vn`.`state` (`id`)
|
||||
) ENGINE = InnoDB DEFAULT CHARSET = utf8;
|
|
@ -1,60 +0,0 @@
|
|||
UPDATE salix.module t
|
||||
SET t.code = 'supplier'
|
||||
WHERE t.code LIKE 'Suppliers' ESCAPE '#';
|
||||
|
||||
UPDATE salix.module t
|
||||
SET t.code = 'travel'
|
||||
WHERE t.code LIKE 'Travels' ESCAPE '#';
|
||||
|
||||
UPDATE salix.module t
|
||||
SET t.code = 'ticket'
|
||||
WHERE t.code LIKE 'Tickets' ESCAPE '#';
|
||||
|
||||
UPDATE salix.module t
|
||||
SET t.code = 'zone'
|
||||
WHERE t.code LIKE 'Zones' ESCAPE '#';
|
||||
|
||||
UPDATE salix.module t
|
||||
SET t.code = 'monitor'
|
||||
WHERE t.code LIKE 'Monitors' ESCAPE '#';
|
||||
|
||||
UPDATE salix.module t
|
||||
SET t.code = 'entry'
|
||||
WHERE t.code LIKE 'Entries' ESCAPE '#';
|
||||
|
||||
UPDATE salix.module t
|
||||
SET t.code = 'invoiceIn'
|
||||
WHERE t.code LIKE 'Invoices in' ESCAPE '#';
|
||||
|
||||
UPDATE salix.module t
|
||||
SET t.code = 'customer'
|
||||
WHERE t.code LIKE 'Clients' ESCAPE '#';
|
||||
|
||||
UPDATE salix.module t
|
||||
SET t.code = 'route'
|
||||
WHERE t.code LIKE 'Routes' ESCAPE '#';
|
||||
|
||||
UPDATE salix.module t
|
||||
SET t.code = 'item'
|
||||
WHERE t.code LIKE 'Items' ESCAPE '#';
|
||||
|
||||
UPDATE salix.module t
|
||||
SET t.code = 'claim'
|
||||
WHERE t.code LIKE 'Claims' ESCAPE '#';
|
||||
|
||||
UPDATE salix.module t
|
||||
SET t.code = 'account'
|
||||
WHERE t.code LIKE 'Users' ESCAPE '#';
|
||||
|
||||
UPDATE salix.module t
|
||||
SET t.code = 'invoiceOut'
|
||||
WHERE t.code LIKE 'Invoices out' ESCAPE '#';
|
||||
|
||||
UPDATE salix.module t
|
||||
SET t.code = 'order'
|
||||
WHERE t.code LIKE 'Orders' ESCAPE '#';
|
||||
|
||||
UPDATE salix.module t
|
||||
SET t.code = 'worker'
|
||||
WHERE t.code LIKE 'Workers' ESCAPE '#';
|
||||
|
|
@ -1,73 +0,0 @@
|
|||
INSERT INTO
|
||||
`vn`.`stateI18n` (`stateFk`, `lang`, `name`)
|
||||
VALUES
|
||||
(1, 'en', 'Fix'),
|
||||
(1, 'es', 'Arreglar'),
|
||||
(2, 'en', 'Free'),
|
||||
(2, 'es', 'Libre'),
|
||||
(3, 'en', 'OK'),
|
||||
(3, 'es', 'OK'),
|
||||
(4, 'en', 'Printed'),
|
||||
(4, 'es', 'Impreso'),
|
||||
(5, 'en', 'Preparation'),
|
||||
(5, 'es', 'Preparación'),
|
||||
(6, 'en', 'In Review'),
|
||||
(6, 'es', 'En Revisión'),
|
||||
(7, 'en', 'Unfinished'),
|
||||
(7, 'es', 'Sin Acabar'),
|
||||
(8, 'en', 'Reviewed'),
|
||||
(8, 'es', 'Revisado'),
|
||||
(9, 'en', 'Fitting'),
|
||||
(9, 'es', 'Encajando'),
|
||||
(10, 'en', 'Fitted'),
|
||||
(10, 'es', 'Encajado'),
|
||||
(11, 'en', 'Billed'),
|
||||
(11, 'es', 'Facturado'),
|
||||
(12, 'en', 'Blocked'),
|
||||
(12, 'es', 'Bloqueado'),
|
||||
(13, 'en', 'In Delivery'),
|
||||
(13, 'es', 'En Reparto'),
|
||||
(14, 'en', 'Prepared'),
|
||||
(14, 'es', 'Preparado'),
|
||||
(15, 'en', 'Pending Collection'),
|
||||
(15, 'es', 'Pendiente de Recogida'),
|
||||
(16, 'en', 'Delivered'),
|
||||
(16, 'es', 'Entregado'),
|
||||
(20, 'en', 'Assigned'),
|
||||
(20, 'es', 'Asignado'),
|
||||
(21, 'en', 'Returned'),
|
||||
(21, 'es', 'Retornado'),
|
||||
(22, 'en', 'Pending to extend'),
|
||||
(22, 'es', 'Pendiente ampliar'),
|
||||
(23, 'en', 'URGENT'),
|
||||
(23, 'es', 'URGENTE'),
|
||||
(24, 'en', 'Chained'),
|
||||
(24, 'es', 'Encadenado'),
|
||||
(25, 'en', 'Shipping'),
|
||||
(25, 'es', 'Embarcando'),
|
||||
(26, 'en', 'Preparation'),
|
||||
(26, 'es', 'Preparación previa'),
|
||||
(27, 'en', 'Assisted preparation'),
|
||||
(27, 'es', 'Preparación asistida'),
|
||||
(28, 'en', 'Preparation OK'),
|
||||
(28, 'es', 'Previa OK'),
|
||||
(29, 'en', 'Preparation Printed'),
|
||||
(29, 'es', 'Previa Impreso'),
|
||||
(30, 'en', 'Shipped'),
|
||||
(30, 'es', 'Embarcado'),
|
||||
(31, 'en', 'Stowaway printed'),
|
||||
(31, 'es', 'Polizón Impreso'),
|
||||
(32, 'en', 'Stowaway OK'),
|
||||
(32, 'es', 'Polizón OK'),
|
||||
(33, 'en', 'Auto_Printed'),
|
||||
(33, 'es', 'Auto_Impreso'),
|
||||
(34, 'en', 'Pending payment'),
|
||||
(34, 'es', 'Pendiente de pago'),
|
||||
(35, 'en', 'Half-Embedded'),
|
||||
(35, 'es', 'Semi-Encajado'),
|
||||
(36, 'en', 'Preparation Reviewing'),
|
||||
(36, 'es', 'Previa Revisando'),
|
||||
(37, 'en', 'Preparation Reviewed'),
|
||||
(37, 'es', 'Previa Revisado'),
|
||||
(38, 'en', 'Preparation Chamber'),
|
||||
(38, 'es', 'Preparación Cámara');
|
|
@ -1,16 +0,0 @@
|
|||
UPDATE `vn`.starredModule SET moduleFk = 'customer' WHERE moduleFk = 'Clients';
|
||||
UPDATE `vn`.starredModule SET moduleFk = 'ticket' WHERE moduleFk = 'Tickets';
|
||||
UPDATE `vn`.starredModule SET moduleFk = 'route' WHERE moduleFk = 'Routes';
|
||||
UPDATE `vn`.starredModule SET moduleFk = 'zone' WHERE moduleFk = 'Zones';
|
||||
UPDATE `vn`.starredModule SET moduleFk = 'order' WHERE moduleFk = 'Orders';
|
||||
UPDATE `vn`.starredModule SET moduleFk = 'claim' WHERE moduleFk = 'Claims';
|
||||
UPDATE `vn`.starredModule SET moduleFk = 'item' WHERE moduleFk = 'Items';
|
||||
UPDATE `vn`.starredModule SET moduleFk = 'worker' WHERE moduleFk = 'Workers';
|
||||
UPDATE `vn`.starredModule SET moduleFk = 'entry' WHERE moduleFk = 'Entries';
|
||||
UPDATE `vn`.starredModule SET moduleFk = 'invoiceOut' WHERE moduleFk = 'Invoices out';
|
||||
UPDATE `vn`.starredModule SET moduleFk = 'invoiceIn' WHERE moduleFk = 'Invoices in';
|
||||
UPDATE `vn`.starredModule SET moduleFk = 'monitor' WHERE moduleFk = 'Monitors';
|
||||
UPDATE `vn`.starredModule SET moduleFk = 'user' WHERE moduleFk = 'Users';
|
||||
UPDATE `vn`.starredModule SET moduleFk = 'supplier' WHERE moduleFk = 'Suppliers';
|
||||
UPDATE `vn`.starredModule SET moduleFk = 'travel' WHERE moduleFk = 'Travels';
|
||||
UPDATE `vn`.starredModule SET moduleFk = 'shelving' WHERE moduleFk = 'Shelvings';
|
|
@ -1,28 +0,0 @@
|
|||
ALTER TABLE `vn`.`mdbApp` DROP PRIMARY KEY;
|
||||
ALTER TABLE `vn`.`mdbApp` ADD CONSTRAINT mdbApp_PK PRIMARY KEY (app,baselineBranchFk);
|
||||
|
||||
INSERT INTO `vn`.`mdbApp` (app,baselineBranchFk)
|
||||
VALUES ('com','master');
|
||||
INSERT INTO `vn`.`mdbApp` (app,baselineBranchFk)
|
||||
VALUES ('enc','master');
|
||||
INSERT INTO `vn`.`mdbApp` (app,baselineBranchFk)
|
||||
VALUES ('ent','master');
|
||||
INSERT INTO `vn`.`mdbApp` (app,baselineBranchFk)
|
||||
VALUES ('eti','master');
|
||||
INSERT INTO `vn`.`mdbApp` (app,baselineBranchFk)
|
||||
VALUES ('lab','master');
|
||||
INSERT INTO `vn`.`mdbApp` (app,baselineBranchFk)
|
||||
VALUES ('tpv','master');
|
||||
INSERT INTO `vn`.`mdbApp` (app,baselineBranchFk)
|
||||
VALUES ('com','dev');
|
||||
INSERT INTO `vn`.`mdbApp` (app,baselineBranchFk)
|
||||
VALUES ('enc','dev');
|
||||
INSERT INTO `vn`.`mdbApp` (app,baselineBranchFk)
|
||||
VALUES ('ent','dev');
|
||||
INSERT INTO `vn`.`mdbApp` (app,baselineBranchFk)
|
||||
VALUES ('eti','dev');
|
||||
INSERT INTO `vn`.`mdbApp` (app,baselineBranchFk)
|
||||
VALUES ('lab','dev');
|
||||
INSERT INTO `vn`.`mdbApp` (app,baselineBranchFk)
|
||||
VALUES ('tpv','dev');
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
UPDATE `vn`.`osTicketConfig`
|
||||
SET oldStatus='1,6'
|
||||
WHERE id=0;
|
||||
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL` (`model`,`property`,`accessType`,`permission`,`principalId`)
|
||||
VALUES ('ItemShelvingSale','*','*','ALLOW','employee');
|
|
@ -1 +0,0 @@
|
|||
ALTER TABLE `vn`.`supplier` ADD UNIQUE (name, countryFk);
|
|
@ -1,4 +0,0 @@
|
|||
SET FOREIGN_KEY_CHECKS = 0;
|
||||
ALTER TABLE `vn`.`report` MODIFY COLUMN id tinyint(3) unsigned NOT NULL AUTO_INCREMENT;
|
||||
ALTER TABLE `vn`.`printer` MODIFY COLUMN id tinyint(3) unsigned NOT NULL AUTO_INCREMENT;
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
|
@ -1,3 +0,0 @@
|
|||
ALTER TABLE `vn`.`itemPackingType` ADD isActive BOOLEAN NOT NULL;
|
||||
UPDATE `vn`.`itemPackingType` SET isActive = 0 WHERE code IN ('P', 'F');
|
||||
UPDATE `vn`.`itemPackingType` SET isActive = 1 WHERE code IN ('V', 'H');
|
|
@ -1,23 +0,0 @@
|
|||
CREATE OR REPLACE TABLE `vn`.`docuware` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`code` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL,
|
||||
`fileCabinetName` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL,
|
||||
`action` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL,
|
||||
`dialogName` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL,
|
||||
`findById` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
|
||||
|
||||
INSERT INTO `vn`.`docuware` (`code`, `fileCabinetName`, `action`, `dialogName`, `findById`)
|
||||
VALUES
|
||||
('deliveryNote', 'Albaranes cliente', 'find', 'find', 'N__ALBAR_N'),
|
||||
('deliveryNote', 'Albaranes cliente', 'store', 'Archivar', 'N__ALBAR_N');
|
||||
|
||||
INSERT INTO `salix`.`ACL` (`model`,`property`,`accessType`,`permission`,`principalId`)
|
||||
VALUES
|
||||
('Docuware','checkFile','READ','ALLOW','employee'),
|
||||
('Docuware','download','READ','ALLOW','salesPerson'),
|
||||
('Docuware','upload','WRITE','ALLOW','productionAssi'),
|
||||
('Docuware','deliveryNoteEmail','WRITE','ALLOW','salesPerson');
|
||||
|
||||
ALTER TABLE `vn`.`docuwareConfig` CHANGE token cookie varchar(1000) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL NULL;
|
|
@ -1,5 +0,0 @@
|
|||
ALTER TABLE `vn`.`itemConfig` ADD defaultTag INT DEFAULT 56 NOT NULL;
|
||||
ALTER TABLE `vn`.`itemConfig` ADD CONSTRAINT itemConfig_FK FOREIGN KEY (defaultTag) REFERENCES vn.tag(id);
|
||||
ALTER TABLE `vn`.`itemConfig` ADD validPriorities varchar(50) DEFAULT '[1,2,3]' NOT NULL;
|
||||
ALTER TABLE `vn`.`itemConfig` ADD defaultPriority INT DEFAULT 2 NOT NULL;
|
||||
ALTER TABLE `vn`.`item` MODIFY COLUMN relevancy tinyint(1) DEFAULT 0 NOT NULL COMMENT 'La web ordena de forma descendiente por este campo para mostrar los artículos';
|
|
@ -1,6 +0,0 @@
|
|||
ALTER TABLE `vn`.`workerTimeControlConfig` ADD teleworkingStart INT NULL COMMENT 'Hora comienzo jornada de los teletrabajdores expresada en segundos';
|
||||
ALTER TABLE `vn`.`workerTimeControlConfig` ADD teleworkingStartBreakTime INT NULL COMMENT 'Hora comienzo descanso de los teletrabjadores expresada en segundos';
|
||||
|
||||
UPDATE `vn`.`workerTimeControlConfig`
|
||||
SET `teleworkingStart`=28800, `teleworkingStartBreakTime`=32400
|
||||
WHERE `id`=1;
|
|
@ -1,5 +0,0 @@
|
|||
ALTER TABLE `vn`.`itemConfig` ADD defaultTag INT DEFAULT 56 NOT NULL;
|
||||
ALTER TABLE `vn`.`itemConfig` ADD CONSTRAINT itemConfig_FK FOREIGN KEY (defaultTag) REFERENCES vn.tag(id);
|
||||
ALTER TABLE `vn`.`itemConfig` ADD validPriorities varchar(50) DEFAULT '[1,2,3]' NOT NULL;
|
||||
ALTER TABLE `vn`.`itemConfig` ADD defaultPriority INT DEFAULT 2 NOT NULL;
|
||||
ALTER TABLE `vn`.`item` MODIFY COLUMN relevancy tinyint(1) DEFAULT 0 NOT NULL COMMENT 'La web ordena de forma descendiente por este campo para mostrar los artículos';
|
|
@ -1,18 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId)
|
||||
VALUES ('VnUser', '*', '*', 'ALLOW', 'ROLE', 'employee');
|
||||
|
||||
INSERT INTO `salix`.`ACL` (id, model, property, accessType, permission, principalType, principalId)
|
||||
VALUES ('VnUser', 'acl', 'READ', 'ALLOW', 'ROLE', 'account');
|
||||
|
||||
INSERT INTO `salix`.`ACL` (id, model, property, accessType, permission, principalType, principalId)
|
||||
VALUES ('VnUser', 'getCurrentUserData', 'READ', 'ALLOW', 'ROLE', 'account');
|
||||
|
||||
INSERT INTO `salix`.`ACL` (id, model, property, accessType, permission, principalType, principalId)
|
||||
VALUES ('VnUser', 'changePassword', '*', 'ALLOW', 'ROLE', 'account');
|
||||
|
||||
|
||||
|
||||
UPDATE `hedera`.`imageCollection` t
|
||||
SET t.model = 'VnUser'
|
||||
WHERE t.id = 6;
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
('Tag', 'onSubmit', 'WRITE', 'ALLOW', 'ROLE', 'employee');
|
|
@ -1,24 +0,0 @@
|
|||
UPDATE `salix`.`ACL`
|
||||
SET accessType='READ'
|
||||
WHERE model='Worker'
|
||||
AND property='*'
|
||||
AND accessType='*'
|
||||
AND permission='ALLOW'
|
||||
AND principalType='ROLE'
|
||||
AND principalId='employee';
|
||||
|
||||
|
||||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
('Worker', 'updateAttributes', 'WRITE', 'ALLOW', 'ROLE', 'hr'),
|
||||
('Worker', 'createAbsence', '*', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Worker', 'updateAbsence', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Worker', 'deleteAbsence', '*', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Worker', 'new', 'WRITE', 'ALLOW', 'ROLE', 'hr'),
|
||||
('Role', '*', 'READ', 'ALLOW', 'ROLE', 'hr');
|
||||
|
||||
ALTER TABLE `vn`.`workerConfig` ADD roleFk int(10) unsigned NOT NULL COMMENT 'Rol por defecto al dar de alta un trabajador nuevo';
|
||||
UPDATE `vn`.`workerConfig`
|
||||
SET roleFk = 1
|
||||
WHERE id = 1;
|
||||
|
|
@ -1,110 +0,0 @@
|
|||
DROP PROCEDURE IF EXISTS vn.ticket_canAdvance;
|
||||
|
||||
DELIMITER $$
|
||||
$$
|
||||
CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_canAdvance`(vDateFuture DATE, vDateToAdvance DATE, vWarehouseFk INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Devuelve los tickets y la cantidad de lineas de venta que se pueden adelantar.
|
||||
*
|
||||
* @param vDateFuture Fecha de los tickets que se quieren adelantar.
|
||||
* @param vDateToAdvance Fecha a cuando se quiere adelantar.
|
||||
* @param vWarehouseFk Almacén
|
||||
*/
|
||||
|
||||
DECLARE vDateInventory DATE;
|
||||
|
||||
SELECT inventoried INTO vDateInventory FROM vn.config;
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.stock;
|
||||
CREATE TEMPORARY TABLE tmp.stock
|
||||
(itemFk INT PRIMARY KEY,
|
||||
amount INT)
|
||||
ENGINE = MEMORY;
|
||||
|
||||
INSERT INTO tmp.stock(itemFk, amount)
|
||||
SELECT itemFk, SUM(quantity) amount FROM
|
||||
(
|
||||
SELECT itemFk, quantity
|
||||
FROM vn.itemTicketOut
|
||||
WHERE shipped >= vDateInventory
|
||||
AND shipped < vDateFuture
|
||||
AND warehouseFk = vWarehouseFk
|
||||
UNION ALL
|
||||
SELECT itemFk, quantity
|
||||
FROM vn.itemEntryIn
|
||||
WHERE landed >= vDateInventory
|
||||
AND landed < vDateFuture
|
||||
AND isVirtualStock = FALSE
|
||||
AND warehouseInFk = vWarehouseFk
|
||||
UNION ALL
|
||||
SELECT itemFk, quantity
|
||||
FROM vn.itemEntryOut
|
||||
WHERE shipped >= vDateInventory
|
||||
AND shipped < vDateFuture
|
||||
AND warehouseOutFk = vWarehouseFk
|
||||
) t
|
||||
GROUP BY itemFk HAVING amount != 0;
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.filter;
|
||||
CREATE TEMPORARY TABLE tmp.filter
|
||||
(INDEX (id))
|
||||
SELECT s.ticketFk futureId,
|
||||
t2.ticketFk id,
|
||||
count(DISTINCT s.id) saleCount,
|
||||
t2.state,
|
||||
t2.isNotValidated,
|
||||
st.name futureState,
|
||||
st.isNotValidated futureIsNotValidated,
|
||||
GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) futureIpt,
|
||||
t2.ipt,
|
||||
t.workerFk,
|
||||
CAST(SUM(litros) AS DECIMAL(10,0)) futureLiters,
|
||||
CAST(COUNT(*) AS DECIMAL(10,0)) `futureLines`,
|
||||
t2.shipped,
|
||||
t.shipped futureShipped,
|
||||
t2.totalWithVat,
|
||||
t.totalWithVat futureTotalWithVat,
|
||||
t2.agency,
|
||||
am.name futureAgency,
|
||||
t2.lines,
|
||||
t2.liters,
|
||||
SUM((s.quantity <= IFNULL(st.amount,0))) hasStock
|
||||
FROM vn.ticket t
|
||||
JOIN vn.ticketState ts ON ts.ticketFk = t.id
|
||||
JOIN vn.state st ON st.id = ts.stateFk
|
||||
JOIN vn.saleVolume sv ON t.id = sv.ticketFk
|
||||
JOIN (SELECT
|
||||
t2.id ticketFk,
|
||||
t2.addressFk,
|
||||
st.isNotValidated,
|
||||
st.name state,
|
||||
GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) ipt,
|
||||
t2.shipped,
|
||||
t2.totalWithVat,
|
||||
am.name agency,
|
||||
CAST(SUM(litros) AS DECIMAL(10,0)) liters,
|
||||
CAST(COUNT(*) AS DECIMAL(10,0)) `lines`
|
||||
FROM vn.ticket t2
|
||||
JOIN vn.saleVolume sv ON t2.id = sv.ticketFk
|
||||
JOIN vn.sale s ON s.ticketFk = t2.id
|
||||
JOIN vn.item i ON i.id = s.itemFk
|
||||
JOIN vn.ticketState ts ON ts.ticketFk = t2.id
|
||||
JOIN vn.state st ON st.id = ts.stateFk
|
||||
JOIN vn.agencyMode am ON t2.agencyModeFk = am.id
|
||||
LEFT JOIN vn.itemPackingType ipt ON ipt.code = i.itemPackingTypeFk
|
||||
WHERE t2.shipped BETWEEN vDateToAdvance AND util.dayend(vDateToAdvance)
|
||||
AND t2.warehouseFk = vWarehouseFk
|
||||
GROUP BY t2.id) t2 ON t2.addressFk = t.addressFk
|
||||
JOIN vn.sale s ON s.ticketFk = t.id
|
||||
JOIN vn.item i ON i.id = s.itemFk
|
||||
JOIN vn.agencyMode am ON t.agencyModeFk = am.id
|
||||
LEFT JOIN vn.itemPackingType ipt ON ipt.code = i.itemPackingTypeFk
|
||||
LEFT JOIN tmp.stock st ON st.itemFk = s.itemFk
|
||||
WHERE t.shipped BETWEEN vDateFuture AND util.dayend(vDateFuture)
|
||||
AND t.warehouseFk = vWarehouseFk
|
||||
GROUP BY t.id;
|
||||
|
||||
DROP TEMPORARY TABLE tmp.stock;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,6 +0,0 @@
|
|||
UPDATE `vn`.`client`
|
||||
SET isToBeMailed = FALSE
|
||||
WHERE
|
||||
mailAddress is NULL
|
||||
AND email is NULL
|
||||
AND isToBeMailed = TRUE;
|
|
@ -1,3 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
('Client', 'getClientOrSupplierReference', 'READ', 'ALLOW', 'ROLE', 'employee');
|
|
@ -1,127 +0,0 @@
|
|||
DROP PROCEDURE IF EXISTS `vn`.`ticket_canAdvance`;
|
||||
|
||||
DELIMITER $$
|
||||
$$
|
||||
CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_canAdvance`(vDateFuture DATE, vDateToAdvance DATE, vWarehouseFk INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Devuelve los tickets y la cantidad de lineas de venta que se pueden adelantar.
|
||||
*
|
||||
* @param vDateFuture Fecha de los tickets que se quieren adelantar.
|
||||
* @param vDateToAdvance Fecha a cuando se quiere adelantar.
|
||||
* @param vWarehouseFk Almacén
|
||||
*/
|
||||
|
||||
DECLARE vDateInventory DATE;
|
||||
|
||||
SELECT inventoried INTO vDateInventory FROM config;
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.stock;
|
||||
CREATE TEMPORARY TABLE tmp.stock
|
||||
(itemFk INT PRIMARY KEY,
|
||||
amount INT)
|
||||
ENGINE = MEMORY;
|
||||
|
||||
INSERT INTO tmp.stock(itemFk, amount)
|
||||
SELECT itemFk, SUM(quantity) amount FROM
|
||||
(
|
||||
SELECT itemFk, quantity
|
||||
FROM itemTicketOut
|
||||
WHERE shipped >= vDateInventory
|
||||
AND shipped < vDateFuture
|
||||
AND warehouseFk = vWarehouseFk
|
||||
UNION ALL
|
||||
SELECT itemFk, quantity
|
||||
FROM itemEntryIn
|
||||
WHERE landed >= vDateInventory
|
||||
AND landed < vDateFuture
|
||||
AND isVirtualStock = FALSE
|
||||
AND warehouseInFk = vWarehouseFk
|
||||
UNION ALL
|
||||
SELECT itemFk, quantity
|
||||
FROM itemEntryOut
|
||||
WHERE shipped >= vDateInventory
|
||||
AND shipped < vDateFuture
|
||||
AND warehouseOutFk = vWarehouseFk
|
||||
) t
|
||||
GROUP BY itemFk HAVING amount != 0;
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.filter;
|
||||
CREATE TEMPORARY TABLE tmp.filter
|
||||
(INDEX (id))
|
||||
|
||||
SELECT
|
||||
origin.ticketFk futureId,
|
||||
dest.ticketFk id,
|
||||
dest.state,
|
||||
origin.futureState,
|
||||
origin.futureIpt,
|
||||
dest.ipt,
|
||||
origin.workerFk,
|
||||
origin.futureLiters,
|
||||
origin.futureLines,
|
||||
dest.shipped,
|
||||
origin.shipped futureShipped,
|
||||
dest.totalWithVat,
|
||||
origin.totalWithVat futureTotalWithVat,
|
||||
dest.agency,
|
||||
origin.futureAgency,
|
||||
dest.lines,
|
||||
dest.liters,
|
||||
origin.futureLines - origin.hasStock AS notMovableLines,
|
||||
(origin.futureLines = origin.hasStock) AS isFullMovable
|
||||
FROM (
|
||||
SELECT
|
||||
s.ticketFk,
|
||||
t.workerFk,
|
||||
t.shipped,
|
||||
t.totalWithVat,
|
||||
st.name futureState,
|
||||
t.addressFk,
|
||||
am.name futureAgency,
|
||||
count(s.id) futureLines,
|
||||
GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) futureIpt,
|
||||
CAST(SUM(litros) AS DECIMAL(10,0)) futureLiters,
|
||||
SUM((s.quantity <= IFNULL(st.amount,0))) hasStock
|
||||
FROM ticket t
|
||||
JOIN sale s ON s.ticketFk = t.id
|
||||
JOIN saleVolume sv ON sv.saleFk = s.id
|
||||
JOIN item i ON i.id = s.itemFk
|
||||
JOIN ticketState ts ON ts.ticketFk = t.id
|
||||
JOIN state st ON st.id = ts.stateFk
|
||||
JOIN agencyMode am ON t.agencyModeFk = am.id
|
||||
LEFT JOIN itemPackingType ipt ON ipt.code = i.itemPackingTypeFk
|
||||
LEFT JOIN tmp.stock st ON st.itemFk = i.id
|
||||
WHERE t.shipped BETWEEN vDateFuture AND util.dayend(vDateFuture)
|
||||
AND t.warehouseFk = vWarehouseFk
|
||||
GROUP BY t.id
|
||||
) origin
|
||||
JOIN (
|
||||
SELECT
|
||||
t.id ticketFk,
|
||||
t.addressFk,
|
||||
st.name state,
|
||||
GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) ipt,
|
||||
t.shipped,
|
||||
t.totalWithVat,
|
||||
am.name agency,
|
||||
CAST(SUM(litros) AS DECIMAL(10,0)) liters,
|
||||
CAST(COUNT(*) AS DECIMAL(10,0)) `lines`
|
||||
FROM ticket t
|
||||
JOIN sale s ON s.ticketFk = t.id
|
||||
JOIN saleVolume sv ON sv.saleFk = s.id
|
||||
JOIN item i ON i.id = s.itemFk
|
||||
JOIN ticketState ts ON ts.ticketFk = t.id
|
||||
JOIN state st ON st.id = ts.stateFk
|
||||
JOIN agencyMode am ON t.agencyModeFk = am.id
|
||||
LEFT JOIN itemPackingType ipt ON ipt.code = i.itemPackingTypeFk
|
||||
WHERE t.shipped BETWEEN vDateToAdvance AND util.dayend(vDateToAdvance)
|
||||
AND t.warehouseFk = vWarehouseFk
|
||||
AND st.order <= 5
|
||||
GROUP BY t.id
|
||||
) dest ON dest.addressFk = origin.addressFk
|
||||
WHERE origin.hasStock != 0;
|
||||
|
||||
DROP TEMPORARY TABLE tmp.stock;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,6 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId)
|
||||
VALUES('ClaimBeginning', 'isEditable', 'READ', 'ALLOW', 'ROLE', 'employee');
|
||||
|
||||
DELETE FROM `salix`.`ACL`
|
||||
WHERE model='Claim' AND property='isEditable';
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL` (model,property,accessType,principalId)
|
||||
VALUES
|
||||
('NotificationSubscription','*','*','employee'),
|
||||
('NotificationAcl','*','READ','employee');
|
|
@ -1,4 +0,0 @@
|
|||
ALTER TABLE `vn`.`itemConfig` ADD warehouseFk smallint(6) unsigned NULL;
|
||||
UPDATE `vn`.`itemConfig`
|
||||
SET warehouseFk=60
|
||||
WHERE id=0;
|
|
@ -1,4 +0,0 @@
|
|||
ALTER TABLE
|
||||
`util`.`notificationSubscription`
|
||||
ADD
|
||||
CONSTRAINT `notificationSubscription_UN` UNIQUE KEY (`notificationFk`, `userFk`);
|
|
@ -1,7 +0,0 @@
|
|||
ALTER TABLE `util`.`notificationSubscription`
|
||||
ADD `id` int(11) auto_increment NULL,
|
||||
DROP PRIMARY KEY,
|
||||
ADD CONSTRAINT PRIMARY KEY (`id`);
|
||||
|
||||
ALTER TABLE `util`.`notificationSubscription`
|
||||
ADD KEY `notificationSubscription_ibfk_1` (`notificationFk`);
|
|
@ -1,3 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
('ItemConfig', '*', '*', 'ALLOW', 'ROLE', 'employee');
|
|
@ -1,16 +0,0 @@
|
|||
ALTER TABLE `vn`.`supplier` ADD `isVies` tinyint(4) DEFAULT 0 NOT NULL;
|
||||
|
||||
UPDATE `vn`.`supplier` s
|
||||
JOIN vn.country c ON c.id = s.countryFk
|
||||
SET s.nif = MID(s.nif, 3, LENGTH(s.nif)-1), s.isVies = TRUE
|
||||
WHERE s.nif <> TRIM(IF(c.code = LEFT(s.nif, 2), MID(s.nif, 3, LENGTH(s.nif)-1), s.nif));
|
||||
|
||||
INSERT IGNORE INTO `vn`.`chat`
|
||||
(senderFk, recipient, checkUserStatus, message, status, attempts)
|
||||
VALUES(19263, '#informatica-cau', 0, '
|
||||
```
|
||||
UPDATE `vn`.`supplier` s
|
||||
JOIN vn.country c ON c.id = s.countryFk
|
||||
SET s.nif = MID(s.nif, 3, LENGTH(s.nif)-1), s.isVies = TRUE
|
||||
WHERE s.nif <> TRIM(IF(c.code = LEFT(s.nif, 2), MID(s.nif, 3, LENGTH(s.nif)-1), s.nif));
|
||||
```', 0, 0);
|
|
@ -1,15 +0,0 @@
|
|||
ALTER TABLE `vn`.`worker` ADD locker INT UNSIGNED NULL UNIQUE;
|
||||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
('DeviceProduction', '*', '*', 'ALLOW', 'ROLE', 'hr'),
|
||||
('DeviceProductionModels', '*', '*', 'ALLOW', 'ROLE', 'hr'),
|
||||
('DeviceProductionState', '*', '*', 'ALLOW', 'ROLE', 'hr'),
|
||||
('DeviceProductionUser', '*', '*', 'ALLOW', 'ROLE', 'hr'),
|
||||
('DeviceProduction', '*', '*', 'ALLOW', 'ROLE', 'productionAssi'),
|
||||
('DeviceProductionModels', '*', '*', 'ALLOW', 'ROLE', 'productionAssi'),
|
||||
('DeviceProductionState', '*', '*', 'ALLOW', 'ROLE', 'productionAssi'),
|
||||
('DeviceProductionUser', '*', '*', 'ALLOW', 'ROLE', 'productionAssi'),
|
||||
('Worker', 'deallocatePDA', '*', 'ALLOW', 'ROLE', 'hr'),
|
||||
('Worker', 'allocatePDA', '*', 'ALLOW', 'ROLE', 'hr'),
|
||||
('Worker', 'deallocatePDA', '*', 'ALLOW', 'ROLE', 'productionAssi'),
|
||||
('Worker', 'allocatePDA', '*', 'ALLOW', 'ROLE', 'productionAssi');
|
|
@ -1,74 +0,0 @@
|
|||
DROP TABLE `vn`.`dmsRecover`;
|
||||
|
||||
ALTER TABLE `vn`.`delivery` DROP FOREIGN KEY delivery_FK;
|
||||
ALTER TABLE `vn`.`delivery` DROP COLUMN addressFk;
|
||||
ALTER TABLE `vn`.`delivery` ADD ticketFk INT NOT NULL;
|
||||
ALTER TABLE `vn`.`delivery` ADD CONSTRAINT delivery_ticketFk_FK FOREIGN KEY (`ticketFk`) REFERENCES `vn`.`ticket`(`id`);
|
||||
|
||||
DELETE FROM `salix`.`ACL` WHERE `property` = 'saveSign';
|
||||
INSERT INTO `salix`.`ACL` (`model`,`property`,`accessType`,`permission`,`principalId`)
|
||||
VALUES
|
||||
('Ticket','saveSign','WRITE','ALLOW','employee');
|
||||
|
||||
DROP PROCEDURE IF EXISTS vn.route_getTickets;
|
||||
|
||||
DELIMITER $$
|
||||
$$
|
||||
CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`route_getTickets`(vRouteFk INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Pasado un RouteFk devuelve la información
|
||||
* de sus tickets.
|
||||
*
|
||||
* @param vRouteFk
|
||||
*
|
||||
* @select Información de los tickets
|
||||
*/
|
||||
|
||||
SELECT
|
||||
t.id Id,
|
||||
t.clientFk Client,
|
||||
a.id Address,
|
||||
t.packages Packages,
|
||||
a.street AddressName,
|
||||
a.postalCode PostalCode,
|
||||
a.city City,
|
||||
sub2.itemPackingTypeFk PackingType,
|
||||
c.phone ClientPhone,
|
||||
c.mobile ClientMobile,
|
||||
a.phone AddressPhone,
|
||||
a.mobile AddressMobile,
|
||||
d.longitude Longitude,
|
||||
d.latitude Latitude,
|
||||
wm.mediaValue SalePersonPhone,
|
||||
tob.Note Note,
|
||||
t.isSigned Signed
|
||||
FROM ticket t
|
||||
JOIN client c ON t.clientFk = c.id
|
||||
JOIN address a ON t.addressFk = a.id
|
||||
LEFT JOIN delivery d ON t.id = d.ticketFk
|
||||
LEFT JOIN workerMedia wm ON wm.workerFk = c.salesPersonFk
|
||||
LEFT JOIN
|
||||
(SELECT tob.description Note, t.id
|
||||
FROM ticketObservation tob
|
||||
JOIN ticket t ON tob.ticketFk = t.id
|
||||
JOIN observationType ot ON ot.id = tob.observationTypeFk
|
||||
WHERE t.routeFk = vRouteFk
|
||||
AND ot.code = 'delivery'
|
||||
)tob ON tob.id = t.id
|
||||
LEFT JOIN
|
||||
(SELECT sub.ticketFk,
|
||||
CONCAT('(', GROUP_CONCAT(DISTINCT sub.itemPackingTypeFk ORDER BY sub.items DESC SEPARATOR ','), ') ') itemPackingTypeFk
|
||||
FROM (SELECT s.ticketFk , i.itemPackingTypeFk, COUNT(*) items
|
||||
FROM ticket t
|
||||
JOIN sale s ON s.ticketFk = t.id
|
||||
JOIN item i ON i.id = s.itemFk
|
||||
WHERE t.routeFk = vRouteFk
|
||||
GROUP BY t.id,i.itemPackingTypeFk)sub
|
||||
GROUP BY sub.ticketFk
|
||||
) sub2 ON sub2.ticketFk = t.id
|
||||
WHERE t.routeFk = vRouteFk
|
||||
GROUP BY t.id
|
||||
ORDER BY t.priority;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,6 +0,0 @@
|
|||
ALTER TABLE vn.invoiceOutSerial
|
||||
ADD `type` ENUM('global', 'quick') DEFAULT NULL NULL;
|
||||
|
||||
UPDATE vn.invoiceOutSerial
|
||||
SET type = 'global'
|
||||
WHERE code IN ('A','V');
|
|
@ -1,6 +0,0 @@
|
|||
UPDATE `vn`.`report`
|
||||
SET `method`='InvoiceOuts/{refFk}/invoice-out-pdf'
|
||||
WHERE name='invoice';
|
||||
|
||||
ALTER TABLE `vn`.`printQueue` MODIFY COLUMN printerFk tinyint(3) unsigned DEFAULT 82 NOT NULL;
|
||||
|
|
@ -1,258 +0,0 @@
|
|||
DROP PROCEDURE IF EXISTS `vn`.`invoiceOut_new`;
|
||||
|
||||
DELIMITER $$
|
||||
$$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceOut_new`(
|
||||
vSerial VARCHAR(255),
|
||||
vInvoiceDate DATE,
|
||||
vTaxArea VARCHAR(25),
|
||||
OUT vNewInvoiceId INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Creación de facturas emitidas.
|
||||
* requiere previamente tabla tmp.ticketToInvoice(id).
|
||||
*
|
||||
* @param vSerial serie a la cual se hace la factura
|
||||
* @param vInvoiceDate fecha de la factura
|
||||
* @param vTaxArea tipo de iva en relacion a la empresa y al cliente
|
||||
* @param vNewInvoiceId id de la factura que se acaba de generar
|
||||
* @return vNewInvoiceId
|
||||
*/
|
||||
DECLARE vIsAnySaleToInvoice BOOL;
|
||||
DECLARE vIsAnyServiceToInvoice BOOL;
|
||||
DECLARE vNewRef VARCHAR(255);
|
||||
DECLARE vWorker INT DEFAULT account.myUser_getId();
|
||||
DECLARE vCompanyFk INT;
|
||||
DECLARE vInterCompanyFk INT;
|
||||
DECLARE vClientFk INT;
|
||||
DECLARE vCplusStandardInvoiceTypeFk INT DEFAULT 1;
|
||||
DECLARE vCplusCorrectingInvoiceTypeFk INT DEFAULT 6;
|
||||
DECLARE vCplusSimplifiedInvoiceTypeFk INT DEFAULT 2;
|
||||
DECLARE vCorrectingSerial VARCHAR(1) DEFAULT 'R';
|
||||
DECLARE vSimplifiedSerial VARCHAR(1) DEFAULT 'S';
|
||||
DECLARE vNewInvoiceInFk INT;
|
||||
DECLARE vIsInterCompany BOOL DEFAULT FALSE;
|
||||
DECLARE vIsCEESerial BOOL DEFAULT FALSE;
|
||||
DECLARE vIsCorrectInvoiceDate BOOL;
|
||||
DECLARE vMaxShipped DATE;
|
||||
|
||||
SET vInvoiceDate = IFNULL(vInvoiceDate, util.CURDATE());
|
||||
|
||||
SELECT t.clientFk,
|
||||
t.companyFk,
|
||||
MAX(DATE(t.shipped)),
|
||||
DATE(vInvoiceDate) >= invoiceOut_getMaxIssued(
|
||||
vSerial,
|
||||
t.companyFk,
|
||||
YEAR(vInvoiceDate))
|
||||
INTO vClientFk,
|
||||
vCompanyFk,
|
||||
vMaxShipped,
|
||||
vIsCorrectInvoiceDate
|
||||
FROM tmp.ticketToInvoice tt
|
||||
JOIN ticket t ON t.id = tt.id;
|
||||
|
||||
IF(vMaxShipped > vInvoiceDate) THEN
|
||||
CALL util.throw("Invoice date can't be less than max date");
|
||||
END IF;
|
||||
|
||||
IF NOT vIsCorrectInvoiceDate THEN
|
||||
CALL util.throw('Exists an invoice with a previous date');
|
||||
END IF;
|
||||
|
||||
-- Eliminem de tmp.ticketToInvoice els tickets que no han de ser facturats
|
||||
DELETE ti.*
|
||||
FROM tmp.ticketToInvoice ti
|
||||
JOIN ticket t ON t.id = ti.id
|
||||
JOIN sale s ON s.ticketFk = t.id
|
||||
JOIN item i ON i.id = s.itemFk
|
||||
JOIN supplier su ON su.id = t.companyFk
|
||||
JOIN client c ON c.id = t.clientFk
|
||||
LEFT JOIN itemTaxCountry itc ON itc.itemFk = i.id AND itc.countryFk = su.countryFk
|
||||
WHERE (YEAR(t.shipped) < 2001 AND t.isDeleted)
|
||||
OR c.isTaxDataChecked = FALSE
|
||||
OR t.isDeleted
|
||||
OR c.hasToInvoice = FALSE
|
||||
OR itc.id IS NULL;
|
||||
|
||||
SELECT SUM(s.quantity * s.price * (100 - s.discount)/100) <> 0
|
||||
INTO vIsAnySaleToInvoice
|
||||
FROM tmp.ticketToInvoice t
|
||||
JOIN sale s ON s.ticketFk = t.id;
|
||||
|
||||
SELECT COUNT(*) > 0 INTO vIsAnyServiceToInvoice
|
||||
FROM tmp.ticketToInvoice t
|
||||
JOIN ticketService ts ON ts.ticketFk = t.id;
|
||||
|
||||
IF (vIsAnySaleToInvoice OR vIsAnyServiceToInvoice)
|
||||
AND (vCorrectingSerial = vSerial OR NOT hasAnyNegativeBase())
|
||||
THEN
|
||||
|
||||
-- el trigger añade el siguiente Id_Factura correspondiente a la vSerial
|
||||
INSERT INTO invoiceOut(
|
||||
ref,
|
||||
serial,
|
||||
issued,
|
||||
clientFk,
|
||||
dued,
|
||||
companyFk,
|
||||
siiTypeInvoiceOutFk
|
||||
)
|
||||
SELECT
|
||||
1,
|
||||
vSerial,
|
||||
vInvoiceDate,
|
||||
vClientFk,
|
||||
getDueDate(vInvoiceDate, dueDay),
|
||||
vCompanyFk,
|
||||
IF(vSerial = vCorrectingSerial,
|
||||
vCplusCorrectingInvoiceTypeFk,
|
||||
IF(vSerial = vSimplifiedSerial,
|
||||
vCplusSimplifiedInvoiceTypeFk,
|
||||
vCplusStandardInvoiceTypeFk))
|
||||
FROM client
|
||||
WHERE id = vClientFk;
|
||||
|
||||
SET vNewInvoiceId = LAST_INSERT_ID();
|
||||
|
||||
SELECT `ref`
|
||||
INTO vNewRef
|
||||
FROM invoiceOut
|
||||
WHERE id = vNewInvoiceId;
|
||||
|
||||
UPDATE ticket t
|
||||
JOIN tmp.ticketToInvoice ti ON ti.id = t.id
|
||||
SET t.refFk = vNewRef;
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.updateInter;
|
||||
CREATE TEMPORARY TABLE tmp.updateInter ENGINE = MEMORY
|
||||
SELECT s.id,ti.id ticket_id,vWorker Id_Trabajador
|
||||
FROM tmp.ticketToInvoice ti
|
||||
LEFT JOIN ticketState ts ON ti.id = ts.ticket
|
||||
JOIN state s
|
||||
WHERE IFNULL(ts.alertLevel,0) < 3 and s.`code` = getAlert3State(ti.id);
|
||||
|
||||
INSERT INTO ticketTracking(stateFk,ticketFk,workerFk)
|
||||
SELECT * FROM tmp.updateInter;
|
||||
|
||||
INSERT INTO ticketLog (action, userFk, originFk, description)
|
||||
SELECT 'UPDATE', account.myUser_getId(), ti.id, CONCAT('Crea factura ', vNewRef)
|
||||
FROM tmp.ticketToInvoice ti;
|
||||
|
||||
CALL invoiceExpenseMake(vNewInvoiceId);
|
||||
CALL invoiceTaxMake(vNewInvoiceId,vTaxArea);
|
||||
|
||||
UPDATE invoiceOut io
|
||||
JOIN (
|
||||
SELECT SUM(amount) total
|
||||
FROM invoiceOutExpense
|
||||
WHERE invoiceOutFk = vNewInvoiceId
|
||||
) base
|
||||
JOIN (
|
||||
SELECT SUM(vat) total
|
||||
FROM invoiceOutTax
|
||||
WHERE invoiceOutFk = vNewInvoiceId
|
||||
) vat
|
||||
SET io.amount = base.total + vat.total
|
||||
WHERE io.id = vNewInvoiceId;
|
||||
|
||||
DROP TEMPORARY TABLE tmp.updateInter;
|
||||
|
||||
SELECT COUNT(*), id
|
||||
INTO vIsInterCompany, vInterCompanyFk
|
||||
FROM company
|
||||
WHERE clientFk = vClientFk;
|
||||
|
||||
IF (vIsInterCompany) THEN
|
||||
|
||||
INSERT INTO invoiceIn(supplierFk, supplierRef, issued, companyFk)
|
||||
SELECT vCompanyFk, vNewRef, vInvoiceDate, vInterCompanyFk;
|
||||
|
||||
SET vNewInvoiceInFk = LAST_INSERT_ID();
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.ticket;
|
||||
CREATE TEMPORARY TABLE tmp.ticket
|
||||
(KEY (ticketFk))
|
||||
ENGINE = MEMORY
|
||||
SELECT id ticketFk
|
||||
FROM tmp.ticketToInvoice;
|
||||
|
||||
CALL `ticket_getTax`('NATIONAL');
|
||||
|
||||
SET @vTaxableBaseServices := 0.00;
|
||||
SET @vTaxCodeGeneral := NULL;
|
||||
|
||||
INSERT INTO invoiceInTax(invoiceInFk, taxableBase, expenseFk, taxTypeSageFk, transactionTypeSageFk)
|
||||
SELECT vNewInvoiceInFk,
|
||||
@vTaxableBaseServices,
|
||||
sub.expenseFk,
|
||||
sub.taxTypeSageFk,
|
||||
sub.transactionTypeSageFk
|
||||
FROM (
|
||||
SELECT @vTaxableBaseServices := SUM(tst.taxableBase) taxableBase,
|
||||
i.expenseFk,
|
||||
i.taxTypeSageFk,
|
||||
i.transactionTypeSageFk,
|
||||
@vTaxCodeGeneral := i.taxClassCodeFk
|
||||
FROM tmp.ticketServiceTax tst
|
||||
JOIN invoiceOutTaxConfig i ON i.taxClassCodeFk = tst.code
|
||||
WHERE i.isService
|
||||
HAVING taxableBase
|
||||
) sub;
|
||||
|
||||
INSERT INTO invoiceInTax(invoiceInFk, taxableBase, expenseFk, taxTypeSageFk, transactionTypeSageFk)
|
||||
SELECT vNewInvoiceInFk,
|
||||
SUM(tt.taxableBase) - IF(tt.code = @vTaxCodeGeneral,
|
||||
@vTaxableBaseServices, 0) taxableBase,
|
||||
i.expenseFk,
|
||||
i.taxTypeSageFk ,
|
||||
i.transactionTypeSageFk
|
||||
FROM tmp.ticketTax tt
|
||||
JOIN invoiceOutTaxConfig i ON i.taxClassCodeFk = tt.code
|
||||
WHERE !i.isService
|
||||
GROUP BY tt.pgcFk
|
||||
HAVING taxableBase
|
||||
ORDER BY tt.priority;
|
||||
|
||||
CALL invoiceInDueDay_calculate(vNewInvoiceInFk);
|
||||
|
||||
SELECT COUNT(*) INTO vIsCEESerial
|
||||
FROM invoiceOutSerial
|
||||
WHERE code = vSerial;
|
||||
|
||||
IF vIsCEESerial THEN
|
||||
|
||||
INSERT INTO invoiceInIntrastat (
|
||||
invoiceInFk,
|
||||
intrastatFk,
|
||||
amount,
|
||||
stems,
|
||||
countryFk,
|
||||
net)
|
||||
SELECT
|
||||
vNewInvoiceInFk,
|
||||
i.intrastatFk,
|
||||
SUM(CAST((s.quantity * s.price * (100 - s.discount) / 100 ) AS DECIMAL(10, 2))),
|
||||
SUM(CAST(IFNULL(i.stems, 1) * s.quantity AS DECIMAL(10, 2))),
|
||||
su.countryFk,
|
||||
CAST(SUM(IFNULL(i.stems, 1)
|
||||
* s.quantity
|
||||
* IF(ic.grams, ic.grams, IFNULL(i.weightByPiece, 0)) / 1000) AS DECIMAL(10, 2))
|
||||
FROM sale s
|
||||
JOIN ticket t ON s.ticketFk = t.id
|
||||
JOIN supplier su ON su.id = t.companyFk
|
||||
JOIN item i ON i.id = s.itemFk
|
||||
LEFT JOIN itemCost ic ON ic.itemFk = i.id AND ic.warehouseFk = t.warehouseFk
|
||||
WHERE t.refFk = vNewRef
|
||||
GROUP BY i.intrastatFk;
|
||||
|
||||
END IF;
|
||||
DROP TEMPORARY TABLE tmp.ticket;
|
||||
DROP TEMPORARY TABLE tmp.ticketAmount;
|
||||
DROP TEMPORARY TABLE tmp.ticketTax;
|
||||
DROP TEMPORARY TABLE tmp.ticketServiceTax;
|
||||
END IF;
|
||||
END IF;
|
||||
DROP TEMPORARY TABLE tmp.`ticketToInvoice`;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,3 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES ('Operator', '*', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Operator', '*', 'WRITE', 'ALLOW', 'ROLE', 'employee');
|
|
@ -1,16 +0,0 @@
|
|||
ALTER TABLE `vn`.`chat` ADD statusNew enum('pending','sent','error','sending') DEFAULT 'pending' NOT NULL;
|
||||
|
||||
UPDATE `vn`.`chat`
|
||||
SET statusNew = 'pending'
|
||||
WHERE status = 0;
|
||||
|
||||
UPDATE `vn`.`chat`
|
||||
SET statusNew = 'sent'
|
||||
WHERE status = 1;
|
||||
|
||||
UPDATE `vn`.`chat`
|
||||
SET statusNew = 'error'
|
||||
WHERE status = 2;
|
||||
|
||||
ALTER TABLE `vn`.`chat` CHANGE status status__ tinyint(1) DEFAULT NULL NULL;
|
||||
ALTER TABLE `vn`.`chat` CHANGE statusNew status enum('pending','sent','error','sending') CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT 'pending' NOT NULL;
|
|
@ -1,4 +0,0 @@
|
|||
ALTER TABLE `vn`.`invoiceInConfig` ADD daysAgo INT UNSIGNED DEFAULT 45 COMMENT 'Días en el pasado para mostrar facturas en invoiceIn series en salix';
|
||||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
('InvoiceIn', 'getSerial', 'READ', 'ALLOW', 'ROLE', 'administrative');
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue