Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 4291-delete_it.warehouseFk
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
commit
1fd97f167c
|
@ -33,14 +33,14 @@ module.exports = Self => {
|
|||
await Self.sendCheckingUserStatus(chat);
|
||||
await updateChat(chat, sentStatus);
|
||||
} catch (error) {
|
||||
await updateChat(chat, errorStatus);
|
||||
await updateChat(chat, errorStatus, error);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
await Self.sendMessage(chat.senderFk, chat.recipient, chat.message);
|
||||
await updateChat(chat, sentStatus);
|
||||
} catch (error) {
|
||||
await updateChat(chat, errorStatus);
|
||||
await updateChat(chat, errorStatus, error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ module.exports = Self => {
|
|||
const channelName = department && department.chatName;
|
||||
|
||||
if (channelName)
|
||||
return Self.sendMessage(chat.senderFk, `#${channelName}`, `@${recipient.name} ➔ ${message}`);
|
||||
return Self.sendMessage(chat.senderFk, `#${channelName}`, `@${recipient.name} ➔ ${chat.message}`);
|
||||
else
|
||||
return Self.sendMessage(chat.senderFk, `@${recipient.name}`, chat.message);
|
||||
} else
|
||||
|
@ -127,12 +127,14 @@ module.exports = Self => {
|
|||
*
|
||||
* @param {object} chat - The chat
|
||||
* @param {string} status - The new status
|
||||
* @param {string} error - The error
|
||||
* @return {Promise} - The request promise
|
||||
*/
|
||||
async function updateChat(chat, status) {
|
||||
async function updateChat(chat, status, error) {
|
||||
return chat.updateAttributes({
|
||||
status: status,
|
||||
attempts: ++chat.attempts
|
||||
attempts: ++chat.attempts,
|
||||
error: error
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -20,83 +20,93 @@ module.exports = Self => {
|
|||
const models = Self.app.models;
|
||||
|
||||
// Get files checksum
|
||||
const files = await Self.rawSql('SELECT name, checksum, keyValue FROM edi.fileConfig');
|
||||
const tx = await Self.beginTransaction({});
|
||||
|
||||
const updatableFiles = [];
|
||||
for (const file of files) {
|
||||
const fileChecksum = await getChecksum(file);
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
const files = await Self.rawSql('SELECT name, checksum, keyValue FROM edi.fileConfig', null, options);
|
||||
|
||||
if (file.checksum != fileChecksum) {
|
||||
updatableFiles.push({
|
||||
name: file.name,
|
||||
checksum: fileChecksum
|
||||
});
|
||||
} else
|
||||
console.debug(`File already updated, skipping...`);
|
||||
}
|
||||
const updatableFiles = [];
|
||||
for (const file of files) {
|
||||
const fileChecksum = await getChecksum(file);
|
||||
|
||||
if (updatableFiles.length === 0)
|
||||
return false;
|
||||
|
||||
// Download files
|
||||
const container = await models.TempContainer.container('edi');
|
||||
const tempPath = path.join(container.client.root, container.name);
|
||||
|
||||
let remoteFile;
|
||||
let tempDir;
|
||||
let tempFile;
|
||||
|
||||
const fileNames = updatableFiles.map(file => file.name);
|
||||
|
||||
const tables = await Self.rawSql(`
|
||||
SELECT fileName, toTable, file
|
||||
FROM edi.tableConfig
|
||||
WHERE file IN (?)`, [fileNames]);
|
||||
|
||||
for (const table of tables) {
|
||||
const fileName = table.file;
|
||||
|
||||
console.debug(`Downloading file ${fileName}...`);
|
||||
|
||||
remoteFile = `codes/${fileName}.ZIP`;
|
||||
tempDir = `${tempPath}/${fileName}`;
|
||||
tempFile = `${tempPath}/${fileName}.zip`;
|
||||
|
||||
try {
|
||||
await fs.readFile(tempFile);
|
||||
} catch (error) {
|
||||
if (error.code === 'ENOENT') {
|
||||
const downloadOutput = await downloadFile(remoteFile, tempFile);
|
||||
if (downloadOutput.error)
|
||||
continue;
|
||||
}
|
||||
if (file.checksum != fileChecksum) {
|
||||
updatableFiles.push({
|
||||
name: file.name,
|
||||
checksum: fileChecksum
|
||||
});
|
||||
} else
|
||||
console.debug(`File already updated, skipping...`);
|
||||
}
|
||||
|
||||
console.debug(`Extracting file ${fileName}...`);
|
||||
await extractFile(tempFile, tempDir);
|
||||
if (updatableFiles.length === 0)
|
||||
return false;
|
||||
|
||||
console.debug(`Updating table ${table.toTable}...`);
|
||||
await dumpData(tempDir, table);
|
||||
}
|
||||
// Download files
|
||||
const container = await models.TempContainer.container('edi');
|
||||
const tempPath = path.join(container.client.root, container.name);
|
||||
|
||||
// Update files checksum
|
||||
for (const file of updatableFiles) {
|
||||
await Self.rawSql(`
|
||||
UPDATE edi.fileConfig
|
||||
SET checksum = ?
|
||||
WHERE name = ?`,
|
||||
[file.checksum, file.name]);
|
||||
}
|
||||
let remoteFile;
|
||||
let tempDir;
|
||||
let tempFile;
|
||||
|
||||
// Clean files
|
||||
try {
|
||||
await fs.remove(tempPath);
|
||||
const fileNames = updatableFiles.map(file => file.name);
|
||||
|
||||
const tables = await Self.rawSql(`
|
||||
SELECT fileName, toTable, file
|
||||
FROM edi.tableConfig
|
||||
WHERE file IN (?)`, [fileNames], options);
|
||||
|
||||
for (const table of tables) {
|
||||
const fileName = table.file;
|
||||
|
||||
remoteFile = `codes/${fileName}.ZIP`;
|
||||
tempDir = `${tempPath}/${fileName}`;
|
||||
tempFile = `${tempPath}/${fileName}.zip`;
|
||||
|
||||
try {
|
||||
await fs.readFile(tempFile);
|
||||
} catch (error) {
|
||||
if (error.code === 'ENOENT') {
|
||||
console.debug(`Downloading file ${fileName}...`);
|
||||
const downloadOutput = await downloadFile(remoteFile, tempFile);
|
||||
if (downloadOutput.error)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
await extractFile(fileName, tempFile, tempDir);
|
||||
|
||||
console.debug(`Updating table ${table.toTable}...`);
|
||||
await dumpData(tempDir, table, options);
|
||||
}
|
||||
|
||||
// Update files checksum
|
||||
for (const file of updatableFiles) {
|
||||
console.log(`Updating file ${file.name} checksum...`);
|
||||
await Self.rawSql(`
|
||||
UPDATE edi.fileConfig
|
||||
SET checksum = ?
|
||||
WHERE name = ?`,
|
||||
[file.checksum, file.name], options);
|
||||
}
|
||||
|
||||
await tx.commit();
|
||||
|
||||
// Clean files
|
||||
try {
|
||||
console.debug(`Cleaning files...`);
|
||||
await fs.remove(tempPath);
|
||||
} catch (error) {
|
||||
if (error.code !== 'ENOENT')
|
||||
throw e;
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch (error) {
|
||||
if (error.code !== 'ENOENT')
|
||||
throw e;
|
||||
await tx.rollback();
|
||||
throw error;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
let ftpClient;
|
||||
|
@ -126,9 +136,9 @@ module.exports = Self => {
|
|||
|
||||
const response = await new Promise((resolve, reject) => {
|
||||
ftpClient.exec((err, response) => {
|
||||
if (response.error) {
|
||||
if (err || response.error) {
|
||||
console.debug(`Error downloading checksum file... ${response.error}`);
|
||||
reject(err);
|
||||
return reject(err);
|
||||
}
|
||||
|
||||
resolve(response);
|
||||
|
@ -159,9 +169,9 @@ module.exports = Self => {
|
|||
|
||||
return new Promise((resolve, reject) => {
|
||||
ftpClient.exec((err, response) => {
|
||||
if (response.error) {
|
||||
if (err || response.error) {
|
||||
console.debug(`Error downloading file... ${response.error}`);
|
||||
reject(err);
|
||||
return reject(err);
|
||||
}
|
||||
|
||||
resolve(response);
|
||||
|
@ -169,11 +179,12 @@ module.exports = Self => {
|
|||
});
|
||||
}
|
||||
|
||||
async function extractFile(tempFile, tempDir) {
|
||||
async function extractFile(fileName, tempFile, tempDir) {
|
||||
const JSZip = require('jszip');
|
||||
|
||||
try {
|
||||
await fs.mkdir(tempDir);
|
||||
console.debug(`Extracting file ${fileName}...`);
|
||||
} catch (error) {
|
||||
if (error.code !== 'EEXIST')
|
||||
throw e;
|
||||
|
@ -196,66 +207,32 @@ module.exports = Self => {
|
|||
}
|
||||
}
|
||||
|
||||
async function dumpData(tempDir, table) {
|
||||
async function dumpData(tempDir, table, options) {
|
||||
const toTable = table.toTable;
|
||||
const baseName = table.fileName;
|
||||
|
||||
const firstEntry = entries[0];
|
||||
const entryName = firstEntry.entryName;
|
||||
const startIndex = (entryName.length - 10);
|
||||
const endIndex = (entryName.length - 4);
|
||||
const dateString = entryName.substring(startIndex, endIndex);
|
||||
console.log(`Emptying table ${toTable}...`);
|
||||
const tableName = `edi.${toTable}`;
|
||||
await Self.rawSql(`DELETE FROM ??`, [tableName]);
|
||||
|
||||
const lastUpdated = new Date();
|
||||
const dirFiles = await fs.readdir(tempDir);
|
||||
const files = dirFiles.filter(file => file.startsWith(baseName));
|
||||
|
||||
let updated = null;
|
||||
if (file.updated) {
|
||||
updated = new Date(file.updated);
|
||||
updated.setHours(0, 0, 0, 0);
|
||||
}
|
||||
for (const file of files) {
|
||||
console.log(`Dumping data from file ${file}...`);
|
||||
|
||||
// Format string date to a date object
|
||||
lastUpdated.setFullYear(`20${dateString.substring(4, 6)}`);
|
||||
lastUpdated.setMonth(parseInt(dateString.substring(2, 4)) - 1);
|
||||
lastUpdated.setDate(dateString.substring(0, 2));
|
||||
lastUpdated.setHours(0, 0, 0, 0);
|
||||
const templatePath = path.join(__dirname, `./sql/${toTable}.sql`);
|
||||
const sqlTemplate = await fs.readFile(templatePath, 'utf8');
|
||||
const filePath = path.join(tempDir, file);
|
||||
|
||||
if (updated && lastUpdated <= updated) {
|
||||
console.debug(`Table ${toTable} already updated, skipping...`);
|
||||
return;
|
||||
}
|
||||
|
||||
const tx = await Self.beginTransaction({});
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const tableName = `edi.${toTable}`;
|
||||
await Self.rawSql(`DELETE FROM ??`, [tableName], options);
|
||||
|
||||
const dirFiles = await fs.readdir(tempDir);
|
||||
const files = dirFiles.filter(file => file.startsWith(baseName));
|
||||
|
||||
for (const file of files) {
|
||||
console.log(`Dumping data from file ${file}...`);
|
||||
|
||||
const templatePath = path.join(__dirname, `./sql/${toTable}.sql`);
|
||||
const sqlTemplate = await fs.readFile(templatePath, 'utf8');
|
||||
const filePath = path.join(tempDir, file);
|
||||
|
||||
await Self.rawSql(sqlTemplate, [filePath], options);
|
||||
await Self.rawSql(`
|
||||
await Self.rawSql(sqlTemplate, [filePath], options);
|
||||
await Self.rawSql(`
|
||||
UPDATE edi.tableConfig
|
||||
SET updated = ?
|
||||
WHERE fileName = ?
|
||||
`, [new Date(), baseName], options);
|
||||
}
|
||||
|
||||
tx.commit();
|
||||
} catch (error) {
|
||||
tx.rollback();
|
||||
throw error;
|
||||
}
|
||||
|
||||
console.log(`Updated table ${toTable}\n`);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -32,6 +32,9 @@
|
|||
},
|
||||
"attempts": {
|
||||
"type": "number"
|
||||
},
|
||||
"error": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"acls": [{
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
"modules/supplier/front/**/*",
|
||||
"modules/ticket/front/**/*",
|
||||
"modules/travel/front/**/*",
|
||||
"modules/shelving/front/**/*",
|
||||
"modules/worker/front/**/*",
|
||||
"modules/zone/front/**/*"
|
||||
]
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId)
|
||||
VALUES('InvoiceInDueDay', '*', '*', 'ALLOW', 'ROLE', 'administrative');
|
|
@ -1,248 +0,0 @@
|
|||
DROP PROCEDURE IF EXISTS vn.invoiceInBookingMain;
|
||||
|
||||
DELIMITER $$
|
||||
$$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`invoiceInBookingMain`(vInvoiceInId INT)
|
||||
BEGIN
|
||||
DECLARE vTotalAmount,vTotalAmountDivisa DECIMAL(10,2);
|
||||
DECLARE vBookNumber,vSerialNumber INT;
|
||||
DECLARE vRate DECIMAL(10,4);
|
||||
|
||||
CALL invoiceInBookingCommon(vInvoiceInId,vSerialNumber);
|
||||
|
||||
SELECT SUM(iit.taxableBase * IF( i.serial= 'R' AND ti.Iva <> 'HP DEVENGADO 21 ISP', 1 +(ti.PorcentajeIva/100),1)),
|
||||
SUM(iit.foreignValue * IF( i.serial= 'R', 1 + (ti.PorcentajeIva/100),1)),
|
||||
iit.taxableBase/iit.foreignValue
|
||||
INTO vTotalAmount, vTotalAmountDivisa, vRate
|
||||
FROM newInvoiceIn i
|
||||
JOIN invoiceInTax iit ON iit.invoiceInFk = i.id
|
||||
LEFT JOIN sage.TiposIva ti ON ti.CodigoIva = iit.taxTypeSageFk;
|
||||
|
||||
CALL vn.ledger_next(vBookNumber);
|
||||
|
||||
-- Apunte del proveedor
|
||||
|
||||
INSERT INTO XDiario(ASIEN,
|
||||
FECHA,
|
||||
SUBCTA,
|
||||
EUROHABER,
|
||||
CONCEPTO,
|
||||
CAMBIO,
|
||||
HABERME,
|
||||
NFACTICK,
|
||||
CLAVE,
|
||||
empresa_id
|
||||
)
|
||||
SELECT
|
||||
vBookNumber,
|
||||
n.bookEntried,
|
||||
s.supplierAccount,
|
||||
vTotalAmount EUROHABER,
|
||||
n.conceptWithSupplier,
|
||||
vRate,
|
||||
vTotalAmountDivisa,
|
||||
n.invoicesCount,
|
||||
vInvoiceInId,
|
||||
n.companyFk
|
||||
FROM newInvoiceIn n
|
||||
JOIN newSupplier s;
|
||||
|
||||
-- Línea de Gastos
|
||||
INSERT INTO XDiario ( ASIEN,
|
||||
FECHA,
|
||||
SUBCTA,
|
||||
CONTRA,
|
||||
EURODEBE,
|
||||
EUROHABER,
|
||||
CONCEPTO,
|
||||
CAMBIO,
|
||||
DEBEME,
|
||||
HABERME,
|
||||
NFACTICK,
|
||||
empresa_id
|
||||
)
|
||||
SELECT vBookNumber ASIEN,
|
||||
n.bookEntried FECHA,
|
||||
IF(e.isWithheld , LPAD(RIGHT(s.supplierAccount,5),10,iit.expenceFk),iit.expenceFk) SUBCTA,
|
||||
s.supplierAccount CONTRA,
|
||||
IF(e.isWithheld AND iit.taxableBase < 0, NULL, ROUND(SUM(iit.taxableBase),2)) EURODEBE,
|
||||
IF(e.isWithheld AND iit.taxableBase < 0,ROUND(SUM(-iit.taxableBase),2),NULL) EUROHABER,
|
||||
n.conceptWithSupplier CONCEPTO,
|
||||
vRate,
|
||||
IF(e.isWithheld,NULL,ABS(ROUND(SUM(iit.foreignValue),2))) DEBEME,
|
||||
IF(e.isWithheld,ABS(ROUND(SUM(iit.foreignValue),2)),NULL) HABERME,
|
||||
n.invoicesCount NFACTICK,
|
||||
n.companyFk empresa_id
|
||||
FROM newInvoiceIn n
|
||||
JOIN newSupplier s
|
||||
JOIN invoiceInTax iit ON iit.invoiceInFk = n.id
|
||||
JOIN (SELECT * FROM expence e GROUP BY e.id)e ON e.id = iit.expenceFk
|
||||
WHERE e.name != 'Suplidos Transitarios nacionales'
|
||||
GROUP BY iit.expenceFk;
|
||||
|
||||
-- Líneas de IVA
|
||||
|
||||
INSERT INTO XDiario( ASIEN,
|
||||
FECHA,
|
||||
SUBCTA,
|
||||
CONTRA,
|
||||
EURODEBE,
|
||||
BASEEURO,
|
||||
CONCEPTO,
|
||||
FACTURA,
|
||||
IVA,
|
||||
AUXILIAR,
|
||||
SERIE,
|
||||
TIPOOPE,
|
||||
FECHA_EX,
|
||||
FECHA_OP,
|
||||
NFACTICK,
|
||||
FACTURAEX,
|
||||
L340,
|
||||
LRECT349,
|
||||
TIPOCLAVE,
|
||||
TIPOEXENCI,
|
||||
TIPONOSUJE,
|
||||
TIPOFACT,
|
||||
TIPORECTIF,
|
||||
TERIDNIF,
|
||||
TERNIF,
|
||||
TERNOM,
|
||||
FECREGCON,
|
||||
empresa_id
|
||||
)
|
||||
SELECT vBookNumber ASIEN,
|
||||
n.bookEntried FECHA,
|
||||
IF(n.expenceFkDeductible>0, n.expenceFkDeductible, ti.CuentaIvaSoportado) SUBCTA,
|
||||
s.supplierAccount CONTRA,
|
||||
SUM(ROUND(ti.PorcentajeIva * it.taxableBase / 100 /* + 0.0001*/ , 2)) EURODEBE,
|
||||
SUM(it.taxableBase) BASEEURO,
|
||||
GROUP_CONCAT(DISTINCT e.`name` SEPARATOR ', ') CONCEPTO,
|
||||
vSerialNumber FACTURA,
|
||||
ti.PorcentajeIva IVA,
|
||||
IF(isUeeMember AND eWithheld.id IS NULL,'','*') AUXILIAR,
|
||||
n.serial SERIE,
|
||||
ttr.ClaveOperacionDefecto,
|
||||
n.issued FECHA_EX,
|
||||
n.operated FECHA_OP,
|
||||
n.invoicesCount NFACTICK,
|
||||
n.supplierRef FACTURAEX,
|
||||
TRUE L340,
|
||||
(isSameCountry OR NOT isUeeMember) LRECT349,
|
||||
n.cplusTrascendency472Fk TIPOCLAVE,
|
||||
n.cplusTaxBreakFk TIPOEXENCI,
|
||||
n.cplusSubjectOpFk TIPONOSUJE,
|
||||
n.cplusInvoiceType472Fk TIPOFACT,
|
||||
n.cplusRectificationTypeFk TIPORECTIF,
|
||||
iis.cplusTerIdNifFk TERIDNIF,
|
||||
s.nif AS TERNIF,
|
||||
s.name AS TERNOM,
|
||||
n.booked FECREGCON,
|
||||
n.companyFk
|
||||
FROM newInvoiceIn n
|
||||
JOIN newSupplier s
|
||||
JOIN invoiceInTax it ON n.id = it.invoiceInFk
|
||||
JOIN sage.TiposIva ti ON ti.CodigoIva = it.taxTypeSageFk
|
||||
JOIN sage.TiposTransacciones ttr ON ttr.CodigoTransaccion = it.transactionTypeSageFk
|
||||
JOIN invoiceInSerial iis ON iis.code = n.serial
|
||||
JOIN (SELECT * FROM expence e GROUP BY e.id)e ON e.id = it.expenceFk
|
||||
LEFT JOIN (
|
||||
SELECT eWithheld.id
|
||||
FROM invoiceInTax hold
|
||||
JOIN expence eWithheld ON eWithheld.id = hold.expenceFk AND eWithheld.isWithheld
|
||||
WHERE hold.invoiceInFk = vInvoiceInId LIMIT 1
|
||||
) eWithheld ON TRUE
|
||||
WHERE it.taxTypeSageFk IS NOT NULL
|
||||
AND it.taxTypeSageFk NOT IN (22, 90)
|
||||
GROUP BY ti.PorcentajeIva, e.id;
|
||||
|
||||
-- Línea iva inversor sujeto pasivo
|
||||
|
||||
INSERT INTO XDiario( ASIEN,
|
||||
FECHA,
|
||||
SUBCTA,
|
||||
CONTRA,
|
||||
EUROHABER,
|
||||
BASEEURO,
|
||||
CONCEPTO,
|
||||
FACTURA,
|
||||
IVA,
|
||||
AUXILIAR,
|
||||
SERIE,
|
||||
TIPOOPE,
|
||||
FECHA_EX,
|
||||
FECHA_OP,
|
||||
NFACTICK,
|
||||
FACTURAEX,
|
||||
L340,
|
||||
LRECT349,
|
||||
TIPOCLAVE,
|
||||
TIPOEXENCI,
|
||||
TIPONOSUJE,
|
||||
TIPOFACT,
|
||||
TIPORECTIF,
|
||||
TERIDNIF,
|
||||
TERNIF,
|
||||
TERNOM,
|
||||
empresa_id
|
||||
)
|
||||
SELECT vBookNumber ASIEN,
|
||||
n.bookEntried FECHA,
|
||||
ti.CuentaIvaRepercutido SUBCTA,
|
||||
s.supplierAccount CONTRA,
|
||||
SUM(ROUND(ti.PorcentajeIva * it.taxableBase / 100,2)) EUROHABER,
|
||||
ROUND(SUM(it.taxableBase),2) BASEEURO,
|
||||
GROUP_CONCAT(DISTINCT e.`name` SEPARATOR ', ') CONCEPTO,
|
||||
vSerialNumber FACTURA,
|
||||
ti.PorcentajeIva IVA,
|
||||
'*' AUXILIAR,
|
||||
n.serial SERIE,
|
||||
ttr.ClaveOperacionDefecto,
|
||||
n.issued FECHA_EX,
|
||||
n.operated FECHA_OP,
|
||||
n.invoicesCount NFACTICK,
|
||||
n.supplierRef FACTURAEX,
|
||||
FALSE L340,
|
||||
(isSameCountry OR NOT isUeeMember) LRECT349,
|
||||
1 TIPOCLAVE,
|
||||
n.cplusTaxBreakFk TIPOEXENCI,
|
||||
n.cplusSubjectOpFk TIPONOSUJE,
|
||||
n.cplusInvoiceType472Fk TIPOFACT,
|
||||
n.cplusRectificationTypeFk TIPORECTIF,
|
||||
iis.cplusTerIdNifFk TERIDNIF,
|
||||
s.nif AS TERNIF,
|
||||
s.name AS TERNOM,
|
||||
n.companyFk
|
||||
FROM newInvoiceIn n
|
||||
JOIN newSupplier s
|
||||
JOIN invoiceInTax it ON n.id = it.invoiceInFk
|
||||
JOIN sage.TiposIva ti ON ti.CodigoIva = it.taxTypeSageFk
|
||||
JOIN sage.TiposTransacciones ttr ON ttr.CodigoTransaccion = it.transactionTypeSageFk
|
||||
JOIN invoiceInSerial iis ON iis.code = n.serial
|
||||
JOIN (SELECT * FROM expence e GROUP BY e.id)e ON e.id = it.expenceFk
|
||||
WHERE ti.Iva = 'HP DEVENGADO 21 ISP' OR MID(s.account, 4, 1) = '1'
|
||||
GROUP BY ti.PorcentajeIva, e.id;
|
||||
|
||||
-- Actualización del registro original
|
||||
UPDATE invoiceIn ii
|
||||
JOIN newInvoiceIn ni ON ii.id = ni.id
|
||||
SET ii.serialNumber = vSerialNumber,
|
||||
ii.isBooked = TRUE;
|
||||
|
||||
-- Problemas derivados de la precisión en los decimales al calcular los impuestos
|
||||
UPDATE XDiario
|
||||
SET EURODEBE = EURODEBE -
|
||||
(SELECT IF(ABS(sub.difference) = 0.01, sub.difference, 0)
|
||||
FROM(
|
||||
SELECT SUM(IFNULL(ROUND(EURODEBE, 2),0)) - SUM(IFNULL(ROUND(EUROHABER, 2), 0)) difference
|
||||
FROM XDiario
|
||||
WHERE ASIEN = vBookNumber
|
||||
)sub
|
||||
)
|
||||
WHERE ASIEN = vBookNumber
|
||||
AND EURODEBE <> 0
|
||||
ORDER BY id DESC
|
||||
LIMIT 1;
|
||||
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,12 +0,0 @@
|
|||
UPDATE `vn`.`companyGroup`
|
||||
SET `code`='verdnatura'
|
||||
WHERE `id`=1;
|
||||
UPDATE `vn`.`companyGroup`
|
||||
SET `code`='ornamental'
|
||||
WHERE `id`=2;
|
||||
UPDATE `vn`.`companyGroup`
|
||||
SET `code`='other'
|
||||
WHERE `id`=3;
|
||||
UPDATE `vn`.`companyGroup`
|
||||
SET `code`='provisional'
|
||||
WHERE `id`=4;
|
|
@ -1,38 +0,0 @@
|
|||
USE vn;
|
||||
DELIMITER $$
|
||||
$$
|
||||
CREATE OR REPLACE
|
||||
ALGORITHM = UNDEFINED VIEW `vn`.`saleVolume` AS
|
||||
select
|
||||
`s`.`ticketFk` AS `ticketFk`,
|
||||
`s`.`id` AS `saleFk`,
|
||||
round(`ic`.`cm3delivery` * `s`.`quantity` / 1000, 0) AS `litros`,
|
||||
`t`.`routeFk` AS `routeFk`,
|
||||
`t`.`shipped` AS `shipped`,
|
||||
`t`.`landed` AS `landed`,
|
||||
`s`.`quantity` * `ic`.`cm3delivery` / 1000000 AS `volume`,
|
||||
`s`.`quantity` * `ic`.`grams` / 1000 AS `physicalWeight`,
|
||||
`s`.`quantity` * `ic`.`cm3delivery` * greatest(`i`.`density`, 167) / 1000000 AS `weight`,
|
||||
`s`.`quantity` * `ic`.`cm3delivery` / 1000000 AS `physicalVolume`,
|
||||
`s`.`quantity` * `ic`.`cm3delivery` * ifnull(`t`.`zonePrice`, `z`.`price`) / (`vc`.`standardFlowerBox` * 1000) AS `freight`,
|
||||
`t`.`zoneFk` AS `zoneFk`,
|
||||
`t`.`clientFk` AS `clientFk`,
|
||||
`s`.`isPicked` AS `isPicked`,
|
||||
`s`.`quantity` * `s`.`price` * (100 - `s`.`discount`) / 100 AS `eurosValue`,
|
||||
`i`.`itemPackingTypeFk` AS `itemPackingTypeFk`
|
||||
from
|
||||
(((((`sale` `s`
|
||||
join `item` `i` on
|
||||
(`i`.`id` = `s`.`itemFk`))
|
||||
join `ticket` `t` on
|
||||
(`t`.`id` = `s`.`ticketFk`))
|
||||
join `zone` `z` on
|
||||
(`z`.`id` = `t`.`zoneFk`))
|
||||
join `volumeConfig` `vc`)
|
||||
join `itemCost` `ic` on
|
||||
(`ic`.`itemFk` = `s`.`itemFk`
|
||||
and `ic`.`warehouseFk` = `t`.`warehouseFk`))
|
||||
where
|
||||
`s`.`quantity` > 0;
|
||||
$$
|
||||
DELIMITER ;
|
|
@ -1,25 +0,0 @@
|
|||
ALTER TABLE `postgresql`.`business` ADD payedHolidays INT NULL;
|
||||
ALTER TABLE `postgresql`.`business` CHANGE payedHolidays payedHolidays INT NULL AFTER reasonEndFk;
|
||||
|
||||
CREATE OR REPLACE
|
||||
ALGORITHM = UNDEFINED VIEW `vn`.`workerLabour` AS
|
||||
select
|
||||
`b`.`business_id` AS `businessFk`,
|
||||
`p`.`id_trabajador` AS `workerFk`,
|
||||
`bl`.`workcenter_id` AS `workCenterFk`,
|
||||
`b`.`date_start` AS `started`,
|
||||
`b`.`date_end` AS `ended`,
|
||||
`d`.`id` AS `departmentFk`,
|
||||
`b`.`payedHolidays` AS `payedHolidays`
|
||||
from
|
||||
((((`postgresql`.`person` `p`
|
||||
join `postgresql`.`profile` `pr` on
|
||||
((`pr`.`person_id` = `p`.`person_id`)))
|
||||
join `postgresql`.`business` `b` on
|
||||
((`b`.`client_id` = `pr`.`profile_id`)))
|
||||
join `postgresql`.`business_labour` `bl` on
|
||||
((`b`.`business_id` = `bl`.`business_id`)))
|
||||
join `vn`.`department` `d` on
|
||||
((`d`.`id` = `bl`.`department_id`)))
|
||||
order by
|
||||
`b`.`date_start` desc
|
|
@ -1,2 +0,0 @@
|
|||
DELETE FROM `salix`.`ACL`
|
||||
WHERE model = 'ClaimEnd' AND property = 'importTicketSales';
|
|
@ -1,3 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL`
|
||||
(model, property, accessType, permission, principalType, principalId)
|
||||
VALUES('Collection', 'setSaleQuantity', '*', 'ALLOW', 'ROLE', 'employee');
|
|
@ -1,3 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL`
|
||||
(model, property, accessType, permission, principalType, principalId)
|
||||
VALUES('Docuware', '*', '*', 'ALLOW', 'ROLE', 'employee');
|
|
@ -1,3 +0,0 @@
|
|||
UPDATE `salix`.`defaultViewConfig`
|
||||
SET `columns`='{"intrastat":false,"stemMultiplier":false,"landed":false,"producer":false}'
|
||||
WHERE tableCode ='itemsIndex';
|
|
@ -1,11 +0,0 @@
|
|||
CREATE TABLE `vn`.`docuware` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
`code` varchar(50) NULL,
|
||||
`fileCabinetName` varchar(50) NULL,
|
||||
`dialogName` varchar(255) DEFAULT NULL,
|
||||
`find` varchar(50) DEFAULT NULL
|
||||
);
|
||||
|
||||
INSERT INTO `vn`.`docuware` (`code`, `fileCabinetName`, `dialogName` , `find`)
|
||||
VALUES
|
||||
('deliveryClient', 'Albaranes cliente', 'findTicket', 'N__ALBAR_N');
|
|
@ -1,9 +0,0 @@
|
|||
CREATE TABLE `vn`.`docuwareConfig` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
`url` varchar(75) NULL,
|
||||
`token` varchar(1000) DEFAULT NULL
|
||||
);
|
||||
|
||||
INSERT INTO `vn`.`docuwareConfig` (`url`)
|
||||
VALUES
|
||||
('https://verdnatura.docuware.cloud/docuware/platform');
|
|
@ -1,26 +0,0 @@
|
|||
ALTER TABLE `vn`.`state` ADD classColor varchar(12) NULL;
|
||||
|
||||
UPDATE `vn`.`state` s
|
||||
SET s.classColor = 'warning'
|
||||
WHERE s.alertLevel = 1;
|
||||
|
||||
UPDATE `vn`.`state` s
|
||||
SET s.classColor = 'alert'
|
||||
WHERE s.alertLevel = 0;
|
||||
|
||||
UPDATE `vn`.`state` s
|
||||
SET s.classColor = 'success'
|
||||
WHERE s.code LIKE 'OK';
|
||||
|
||||
UPDATE `vn`.`state` s
|
||||
SET s.classColor = 'notice'
|
||||
WHERE s.code LIKE 'FREE';
|
||||
|
||||
UPDATE `vn`.`state` s
|
||||
SET s.classColor = 'success'
|
||||
WHERE s.order >= 4
|
||||
AND (s.alertLevel = 0 OR s.alertLevel = 1);
|
||||
|
||||
UPDATE `vn`.`state` s
|
||||
SET s.classColor = 'warning'
|
||||
WHERE s.code IN ('PREVIOUS_PREPARATION', 'PREPARED', 'ON_PREPARATION', 'ON_CHECKING', 'CHECKED');
|
|
@ -1,46 +0,0 @@
|
|||
DROP PROCEDURE IF EXISTS `vn`.`ticket_getMovable`;
|
||||
|
||||
DELIMITER $$
|
||||
$$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`ticket_getMovable`(vTicketFk INT, vDatedNew DATETIME, vWarehouseFk INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Cálcula el stock movible para los artículos de un ticket
|
||||
* vDatedNew debe ser menor que vDatedOld, en los otros casos se
|
||||
* asume que siempre es posible
|
||||
*
|
||||
* @param vTicketFk -> Ticket
|
||||
* @param vDatedNew -> Nueva fecha
|
||||
* @return Sales con Movible
|
||||
*/
|
||||
DECLARE vDatedOld DATETIME;
|
||||
SET vDatedNew = DATE_ADD(vDatedNew, INTERVAL 1 DAY);
|
||||
|
||||
SELECT t.shipped INTO vDatedOld
|
||||
FROM ticket t
|
||||
WHERE t.id = vTicketFk;
|
||||
|
||||
CALL itemStock(vWarehouseFk, vDatedNew, NULL);
|
||||
CALL item_getMinacum(vWarehouseFk, vDatedNew, DATEDIFF(DATE_SUB(vDatedOld, INTERVAL 1 DAY), vDatedNew), NULL);
|
||||
|
||||
SELECT s.id,
|
||||
s.itemFk,
|
||||
s.quantity,
|
||||
s.concept,
|
||||
s.price,
|
||||
s.reserved,
|
||||
s.discount,
|
||||
i.image,
|
||||
i.subName,
|
||||
il.stock + IFNULL(im.amount, 0) AS movable
|
||||
FROM ticket t
|
||||
JOIN sale s ON s.ticketFk = t.id
|
||||
JOIN item i ON i.id = s.itemFk
|
||||
LEFT JOIN tmp.itemMinacum im ON im.itemFk = s.itemFk AND im.warehouseFk = vWarehouseFk
|
||||
LEFT JOIN tmp.itemList il ON il.itemFk = s.itemFk
|
||||
WHERE t.id = vTicketFk;
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.itemList;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.itemMinacum;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,2 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL` (model,property,accessType,principalId)
|
||||
VALUES ('AgencyTerm','*','*','administrative');
|
|
@ -1,3 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId)
|
||||
VALUES
|
||||
('ClaimLog', '*', 'READ', 'ALLOW', 'ROLE', 'claimManager');
|
|
@ -1 +0,0 @@
|
|||
UPDATE `account`.`user` SET `role` = 57 WHERE id IN (2294, 4365, 7294);
|
|
@ -1,2 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId)
|
||||
VALUES ('Edi', 'updateData', 'WRITE', 'ALLOW', 'ROLE', 'employee');
|
|
@ -1,2 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL` (`id`, `model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES(304, 'Agency', '*', '*', 'ALLOW', 'ROLE', 'employee');
|
|
@ -1,2 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES('EducationLevel', '*', '*', 'ALLOW', 'ROLE', 'employee');
|
|
@ -1,3 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL`
|
||||
(`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES('InvoiceInIntrastat', '*', '*', 'ALLOW', 'ROLE', 'employee');
|
|
@ -1,3 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
('SupplierAgencyTerm', '*', '*', 'ALLOW', 'ROLE', 'administrative');
|
|
@ -1,10 +0,0 @@
|
|||
CREATE TABLE `vn`.`agencyTermConfig` (
|
||||
`expenceFk` varchar(10) DEFAULT NULL,
|
||||
`vatAccountSupported` varchar(15) DEFAULT NULL,
|
||||
`vatPercentage` decimal(28,10) DEFAULT NULL,
|
||||
`transaction` varchar(50) DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
INSERT INTO `vn`.`agencyTermConfig`
|
||||
(`expenceFk`, `vatAccountSupported`, `vatPercentage`, `transaction`)
|
||||
VALUES('6240000000', '4721000015', 21.0000000000, 'Adquisiciones intracomunitarias de servicios');
|
|
@ -1,8 +0,0 @@
|
|||
CREATE TABLE `vn`.`claimConfig` (
|
||||
`id` int(11) NOT NULL,
|
||||
`pickupContact` varchar(250),
|
||||
PRIMARY KEY (`id`)
|
||||
);
|
||||
|
||||
INSERT INTO vn.claimConfig (id, pickupContact)
|
||||
VALUES(1, 'Email: cmorenoa@logista.com Telf: 961594250 Extensión: 206');
|
|
@ -1,2 +0,0 @@
|
|||
ALTER TABLE `vn`.`claimState` ADD `hasToNotify` TINYINT DEFAULT 0 NULL;
|
||||
UPDATE `vn`.`claimState` SET `hasToNotify` = 1 WHERE `code` IN ('canceled', 'incomplete');
|
|
@ -1 +0,0 @@
|
|||
ALTER TABLE `vn`.`claim` ADD packages smallint(10) unsigned DEFAULT 0 NULL COMMENT 'packages received by the client';
|
|
@ -1,2 +0,0 @@
|
|||
INSERT INTO `vn`.`component` (`name`,`typeFk`,`classRate`,`isRenewable`,`code`,`isRequired`)
|
||||
VALUES ('maná reclamacion',7,4,0,'manaClaim',0);
|
|
@ -1,90 +0,0 @@
|
|||
ALTER TABLE `vn`.`country` ADD `a3Code` INT NULL COMMENT 'Código país para a3';
|
||||
|
||||
UPDATE `vn`.`country` c
|
||||
JOIN `vn2008`.`payroll_pais` `p` ON `p`.`pais` = `c`.`country`
|
||||
SET `c`.`a3Code` = `p`.`codpais`;
|
||||
|
||||
UPDATE `vn`.`country`
|
||||
SET `a3Code` = 710
|
||||
WHERE `country` = 'Sud-Africa'; -- ÁFRICA DEL SUR
|
||||
|
||||
UPDATE `vn`.`country`
|
||||
SET `a3Code` = 643
|
||||
WHERE `country` = 'Rusia'; -- FEDERACIÓN DE RUSIA
|
||||
|
||||
UPDATE `vn`.`country`
|
||||
SET `a3Code` = 28
|
||||
WHERE `country` = 'Antigua'; -- ANTIGUA Y BARBUDA
|
||||
|
||||
UPDATE `vn`.`country`
|
||||
SET `a3Code` = 840
|
||||
WHERE `country` = 'USA'; -- ESTADOS UNIDOS
|
||||
|
||||
UPDATE `vn`.`country`
|
||||
SET `a3Code` = 404
|
||||
WHERE `country` = 'Kenya'; -- KENIA
|
||||
|
||||
UPDATE `vn`.`country`
|
||||
SET `a3Code` = 498
|
||||
WHERE `country` = 'Moldavia'; -- REPÚBLICA DE MOLDAVIA
|
||||
|
||||
UPDATE `vn`.`country`
|
||||
SET `a3Code` = 826
|
||||
WHERE `country` = 'Gran Bretaña'; -- REINO UNIDO
|
||||
|
||||
UPDATE `vn`.`country`
|
||||
SET `a3Code` = 484
|
||||
WHERE `country` = 'Mexico'; -- MÉJICO
|
||||
|
||||
UPDATE `vn`.`country`
|
||||
SET `a3Code` = 716
|
||||
WHERE `country` = 'Zimbawe'; -- ZINBABWE
|
||||
|
||||
UPDATE `vn`.`country`
|
||||
SET `a3Code` = 203
|
||||
WHERE `country` = 'Chequia'; -- REPÚBLICA CHECA
|
||||
|
||||
UPDATE `vn`.`country`
|
||||
SET `a3Code` = 764
|
||||
WHERE `country` = 'Thailandia'; -- TAILANDIA
|
||||
|
||||
UPDATE `vn`.`country`
|
||||
SET `a3Code` = 276
|
||||
WHERE `country` = 'Alemania'; -- REPÚBLICA FEDERAL DE ALEMANIA
|
||||
|
||||
UPDATE `vn`.`country`
|
||||
SET `a3Code` = 112
|
||||
WHERE `country` = 'Bielorrusia'; -- BELARUS
|
||||
|
||||
UPDATE `vn`.`country`
|
||||
SET `a3Code` = 528
|
||||
WHERE `country` = 'Holanda'; -- PAÍSES BAJOS
|
||||
|
||||
UPDATE `vn`.`country`
|
||||
SET `a3Code` = 410
|
||||
WHERE `country` = 'Corea del Sur'; -- COREA (REPÚBLICA)
|
||||
|
||||
UPDATE `vn`.`country`
|
||||
SET `a3Code` = 724
|
||||
WHERE `country` = 'España exento'; -- ESPAÑA
|
||||
|
||||
-- Borrar registro USA de country:
|
||||
UPDATE `vn`.`supplier` `s`
|
||||
SET `s`.`countryFk` = 62
|
||||
WHERE `s`.`countryFk` = 12;
|
||||
|
||||
UPDATE `vn`.`bankEntity`
|
||||
SET `countryFk` = 62
|
||||
WHERE `countryFk` = 12;
|
||||
|
||||
DELETE FROM `vn`.`country`
|
||||
WHERE `id`= 12;
|
||||
|
||||
UPDATE `vn2008`.`payroll_pais`
|
||||
SET `pais`='COREA NORTE (REPÚBLICA DEM. POPULAR)'
|
||||
WHERE `codpais`=408;
|
||||
UPDATE `vn2008`.`payroll_pais`
|
||||
SET `pais`='COREA SUR (REPÚBLICA) '
|
||||
WHERE `codpais`=410;
|
||||
|
||||
RENAME TABLE `vn2008`.`payroll_pais` TO `vn2008`.`payroll_pais__`;
|
|
@ -1,2 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL` (`model`,`property`,`accessType`,`permission`,`principalType`,`principalId`)
|
||||
VALUES ('InvoiceInIntrastat','*','*','ALLOW','ROLE','employee');
|
|
@ -1,106 +0,0 @@
|
|||
DROP PROCEDURE IF EXISTS `bs`.`manaCustomerUpdate`;
|
||||
|
||||
DELIMITER $$
|
||||
$$
|
||||
CREATE DEFINER=`root`@`localhost` PROCEDURE `bs`.`manaCustomerUpdate`()
|
||||
BEGIN
|
||||
DECLARE vToDated DATE;
|
||||
DECLARE vFromDated DATE;
|
||||
DECLARE vForDeleteDated DATE;
|
||||
DECLARE vManaId INT;
|
||||
DECLARE vManaAutoId INT;
|
||||
DECLARE vClaimManaId INT;
|
||||
DECLARE vManaBankId INT;
|
||||
DECLARE vManaGreugeTypeId INT;
|
||||
|
||||
SELECT id INTO vManaId
|
||||
FROM `component` WHERE code = 'mana';
|
||||
|
||||
SELECT id INTO vManaAutoId
|
||||
FROM `component` WHERE code = 'autoMana';
|
||||
|
||||
SELECT id INTO vClaimManaId
|
||||
FROM `component` WHERE code = 'manaClaim';
|
||||
|
||||
SELECT id INTO vManaBankId
|
||||
FROM `bank` WHERE code = 'mana';
|
||||
|
||||
SELECT id INTO vManaGreugeTypeId
|
||||
FROM `greugeType` WHERE code = 'mana';
|
||||
|
||||
SELECT IFNULL(max(dated), '2016-01-01')
|
||||
INTO vFromDated
|
||||
FROM bs.manaCustomer;
|
||||
|
||||
DELETE
|
||||
FROM bs.manaCustomer
|
||||
WHERE dated = vFromDated;
|
||||
|
||||
SELECT IFNULL(max(dated), '2016-01-01')
|
||||
INTO vFromDated
|
||||
FROM bs.manaCustomer;
|
||||
|
||||
WHILE timestampadd(DAY,30,vFromDated) < CURDATE() DO
|
||||
|
||||
SELECT
|
||||
timestampadd(DAY,30,vFromDated),
|
||||
timestampadd(DAY,-90,vFromDated)
|
||||
INTO
|
||||
vToDated,
|
||||
vForDeleteDated;
|
||||
|
||||
DELETE FROM bs.manaCustomer
|
||||
WHERE dated <= vForDeleteDated;
|
||||
|
||||
|
||||
INSERT INTO bs.manaCustomer(Id_Cliente, Mana, dated)
|
||||
|
||||
SELECT
|
||||
Id_Cliente,
|
||||
cast(sum(mana) as decimal(10,2)) as mana,
|
||||
vToDated as dated
|
||||
FROM
|
||||
|
||||
(
|
||||
SELECT cs.Id_Cliente, Cantidad * Valor as mana
|
||||
FROM vn2008.Tickets t
|
||||
JOIN vn2008.Consignatarios cs using(Id_Consigna)
|
||||
JOIN vn2008.Movimientos m on m.Id_Ticket = t.Id_Ticket
|
||||
JOIN vn2008.Movimientos_componentes mc on mc.Id_Movimiento = m.Id_Movimiento
|
||||
WHERE Id_Componente IN (vManaAutoId, vManaId, vClaimManaId)
|
||||
AND t.Fecha > vFromDated
|
||||
AND date(t.Fecha) <= vToDated
|
||||
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT r.Id_Cliente, - Entregado
|
||||
FROM vn2008.Recibos r
|
||||
WHERE Id_Banco = vManaBankId
|
||||
AND Fechacobro > vFromDated
|
||||
AND Fechacobro <= vToDated
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT g.Id_Cliente, g.Importe
|
||||
FROM vn2008.Greuges g
|
||||
WHERE Greuges_type_id = vManaGreugeTypeId
|
||||
AND Fecha > vFromDated
|
||||
AND Fecha <= vToDated
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT Id_Cliente, mana
|
||||
FROM bs.manaCustomer
|
||||
WHERE dated = vFromDated
|
||||
) sub
|
||||
|
||||
GROUP BY Id_Cliente
|
||||
HAVING Id_Cliente;
|
||||
|
||||
SET vFromDated = vToDated;
|
||||
|
||||
END WHILE;
|
||||
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,75 +0,0 @@
|
|||
DROP PROCEDURE IF EXISTS `vn`.`manaSpellersRequery`;
|
||||
|
||||
DELIMITER $$
|
||||
$$
|
||||
CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`manaSpellersRequery`(vWorkerFk INTEGER)
|
||||
BEGIN
|
||||
/**
|
||||
* Recalcula el mana consumido por un trabajador
|
||||
*
|
||||
* @param vWorkerFk Id Trabajador
|
||||
*/
|
||||
DECLARE vWorkerIsExcluded BOOLEAN;
|
||||
DECLARE vFromDated DATE;
|
||||
DECLARE vToDated DATE DEFAULT TIMESTAMPADD(DAY,1,CURDATE());
|
||||
DECLARE vMana INT;
|
||||
DECLARE vAutoMana INT;
|
||||
DECLARE vClaimMana INT;
|
||||
DECLARE vManaBank INT;
|
||||
DECLARE vManaGreugeType INT;
|
||||
|
||||
SELECT COUNT(*) INTO vWorkerIsExcluded
|
||||
FROM workerManaExcluded
|
||||
WHERE workerFk = vWorkerFk;
|
||||
|
||||
IF NOT vWorkerIsExcluded THEN
|
||||
SELECT id INTO vMana
|
||||
FROM `component` WHERE code = 'mana';
|
||||
|
||||
SELECT id INTO vAutoMana
|
||||
FROM `component` WHERE code = 'autoMana';
|
||||
|
||||
SELECT id INTO vClaimMana
|
||||
FROM `component` WHERE code = 'manaClaim';
|
||||
|
||||
SELECT id INTO vManaBank
|
||||
FROM `bank` WHERE code = 'mana';
|
||||
|
||||
SELECT id INTO vManaGreugeType
|
||||
FROM `greugeType` WHERE code = 'mana';
|
||||
|
||||
SELECT max(dated) INTO vFromDated
|
||||
FROM clientManaCache;
|
||||
|
||||
REPLACE workerMana (workerFk, amount)
|
||||
SELECT vWorkerFk, sum(mana) FROM
|
||||
(
|
||||
SELECT s.quantity * sc.value as mana
|
||||
FROM ticket t
|
||||
JOIN address a ON a.id = t.addressFk
|
||||
JOIN client c ON c.id = a.clientFk
|
||||
JOIN sale s ON s.ticketFk = t.id
|
||||
JOIN saleComponent sc ON sc.saleFk = s.id
|
||||
WHERE c.salesPersonFk = vWorkerFk AND sc.componentFk IN (vMana, vAutoMana, vClaimMana)
|
||||
AND t.shipped > vFromDated AND t.shipped < vToDated
|
||||
UNION ALL
|
||||
SELECT - r.amountPaid
|
||||
FROM receipt r
|
||||
JOIN client c ON c.id = r.clientFk
|
||||
WHERE c.salesPersonFk = vWorkerFk AND bankFk = vManaBank
|
||||
AND payed > vFromDated
|
||||
UNION ALL
|
||||
SELECT g.amount
|
||||
FROM greuge g
|
||||
JOIN client c ON c.id = g.clientFk
|
||||
WHERE c.salesPersonFk = vWorkerFk AND g.greugeTypeFk = vManaGreugeType
|
||||
AND g.shipped > vFromDated and g.shipped < CURDATE()
|
||||
UNION ALL
|
||||
SELECT cc.mana
|
||||
FROM clientManaCache cc
|
||||
JOIN client c ON c.id = cc.clientFk
|
||||
WHERE c.salesPersonFk = vWorkerFk AND cc.dated = vFromDated
|
||||
) sub;
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,48 +0,0 @@
|
|||
ALTER TABLE `vn`.`agencyTerm` ADD `supplierFk` INT NULL;
|
||||
ALTER TABLE `vn`.`agencyTerm` CHANGE `supplierFk` `supplierFk` INT NULL AFTER `agencyFk`;
|
||||
|
||||
UPDATE `vn`.`agencyTerm` `at`
|
||||
JOIN `vn`.`agency` `a` ON `a`.`id` = `at`.`agencyFk`
|
||||
SET `at`.`supplierFk` = `a`.`supplierFk`;
|
||||
|
||||
ALTER TABLE `vn`.`agencyTerm` ADD CONSTRAINT `agencyTerm_FK` FOREIGN KEY (`agencyFk`) REFERENCES `vn`.`agency`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `vn`.`agencyTerm` ADD CONSTRAINT `agencyTerm_FK_1` FOREIGN KEY (`supplierFk`) REFERENCES `vn`.`supplier`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
RENAME TABLE `vn`.`agencyTerm` TO `vn`.`supplierAgencyTerm`;
|
||||
|
||||
CREATE OR REPLACE
|
||||
ALGORITHM = UNDEFINED
|
||||
DEFINER=`root`@`localhost`
|
||||
VIEW `vn`.`agencyTerm` AS
|
||||
SELECT
|
||||
`sat`.`agencyFk` AS `agencyFk`,
|
||||
`sat`.`minimumPackages` AS `minimumPackages`,
|
||||
`sat`.`kmPrice` AS `kmPrice`,
|
||||
`sat`.`packagePrice` AS `packagePrice`,
|
||||
`sat`.`routePrice` AS `routePrice`,
|
||||
`sat`.`minimumKm` AS `minimumKm`,
|
||||
`sat`.`minimumM3` AS `minimumM3`,
|
||||
`sat`.`m3Price` AS `m3Price`
|
||||
FROM
|
||||
`vn`.`supplierAgencyTerm` `sat`;
|
||||
|
||||
ALTER TABLE `vn`.`agency` DROP FOREIGN KEY `agency_ibfk_4`;
|
||||
ALTER TABLE `vn`.`agency` CHANGE `supplierFk` `supplierFk__` int(11) DEFAULT NULL NULL;
|
||||
|
||||
CREATE OR REPLACE
|
||||
ALGORITHM = UNDEFINED
|
||||
DEFINER=`root`@`localhost`
|
||||
VIEW `vn2008`.`agency` AS
|
||||
SELECT
|
||||
`a`.`id` AS `agency_id`,
|
||||
`a`.`name` AS `name`,
|
||||
`a`.`warehouseFk` AS `warehouse_id`,
|
||||
`a`.`isVolumetric` AS `por_volumen`,
|
||||
`a`.`bankFk` AS `Id_Banco`,
|
||||
`a`.`warehouseAliasFk` AS `warehouse_alias_id`,
|
||||
`a`.`isOwn` AS `propios`,
|
||||
`a`.`labelZone` AS `zone_label`,
|
||||
`a`.`workCenterFk` AS `workCenterFk`,
|
||||
`a`.`supplierFk__` AS `supplierFk__`
|
||||
FROM
|
||||
`vn`.`agency` `a`;
|
|
@ -1,149 +0,0 @@
|
|||
DROP PROCEDURE IF EXISTS `vn`.`ticket_doRefund`;
|
||||
|
||||
DELIMITER $$
|
||||
$$
|
||||
CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_doRefund`(IN vOriginTicket INT, OUT vNewTicket INT)
|
||||
BEGIN
|
||||
|
||||
DECLARE vDone BIT DEFAULT 0;
|
||||
DECLARE vCustomer MEDIUMINT;
|
||||
DECLARE vWarehouse TINYINT;
|
||||
DECLARE vCompany MEDIUMINT;
|
||||
DECLARE vAddress MEDIUMINT;
|
||||
DECLARE vRefundAgencyMode INT;
|
||||
DECLARE vItemFk INT;
|
||||
DECLARE vQuantity DECIMAL (10,2);
|
||||
DECLARE vConcept VARCHAR(50);
|
||||
DECLARE vPrice DECIMAL (10,2);
|
||||
DECLARE vDiscount TINYINT;
|
||||
DECLARE vSaleNew INT;
|
||||
DECLARE vSaleMain INT;
|
||||
DECLARE vZoneFk INT;
|
||||
|
||||
DECLARE vRsMainTicket CURSOR FOR
|
||||
SELECT *
|
||||
FROM tmp.sale;
|
||||
|
||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = 1;
|
||||
|
||||
SELECT id INTO vRefundAgencyMode
|
||||
FROM agencyMode WHERE `name` = 'ABONO';
|
||||
|
||||
SELECT clientFk, warehouseFk, companyFk, addressFk
|
||||
INTO vCustomer, vWarehouse, vCompany, vAddress
|
||||
FROM ticket
|
||||
WHERE id = vOriginTicket;
|
||||
|
||||
SELECT id INTO vZoneFk
|
||||
FROM zone WHERE agencyModeFk = vRefundAgencyMode
|
||||
LIMIT 1;
|
||||
|
||||
INSERT INTO vn.ticket (
|
||||
clientFk,
|
||||
shipped,
|
||||
addressFk,
|
||||
agencyModeFk,
|
||||
nickname,
|
||||
warehouseFk,
|
||||
companyFk,
|
||||
landed,
|
||||
zoneFk
|
||||
)
|
||||
SELECT
|
||||
vCustomer,
|
||||
CURDATE(),
|
||||
vAddress,
|
||||
vRefundAgencyMode,
|
||||
a.nickname,
|
||||
vWarehouse,
|
||||
vCompany,
|
||||
CURDATE(),
|
||||
vZoneFk
|
||||
FROM address a
|
||||
WHERE a.id = vAddress;
|
||||
|
||||
SET vNewTicket = LAST_INSERT_ID();
|
||||
|
||||
SET vDone := 0;
|
||||
OPEN vRsMainTicket ;
|
||||
FETCH vRsMainTicket INTO vSaleMain, vItemFk, vQuantity, vConcept, vPrice, vDiscount;
|
||||
|
||||
WHILE NOT vDone DO
|
||||
|
||||
INSERT INTO vn.sale(ticketFk, itemFk, quantity, concept, price, discount)
|
||||
VALUES( vNewTicket, vItemFk, vQuantity, vConcept, vPrice, vDiscount );
|
||||
|
||||
SET vSaleNew = LAST_INSERT_ID();
|
||||
|
||||
INSERT INTO vn.saleComponent(saleFk,componentFk,`value`)
|
||||
SELECT vSaleNew,componentFk,`value`
|
||||
FROM vn.saleComponent
|
||||
WHERE saleFk = vSaleMain;
|
||||
|
||||
FETCH vRsMainTicket INTO vSaleMain, vItemFk, vQuantity, vConcept, vPrice, vDiscount;
|
||||
|
||||
END WHILE;
|
||||
CLOSE vRsMainTicket;
|
||||
|
||||
INSERT INTO vn.ticketRefund(refundTicketFk, originalTicketFk)
|
||||
VALUES(vNewTicket, vOriginTicket);
|
||||
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
||||
CREATE TABLE `vn`.`ticketRefund` (
|
||||
`id` INT auto_increment NULL,
|
||||
`refundTicketFk` INT NOT NULL,
|
||||
`originalTicketFk` INT NOT NULL,
|
||||
CONSTRAINT `ticketRefund_PK` PRIMARY KEY (id)
|
||||
)
|
||||
ENGINE=InnoDB
|
||||
DEFAULT CHARSET=utf8
|
||||
COLLATE=utf8_unicode_ci;
|
||||
|
||||
ALTER TABLE `vn`.`ticketRefund` ADD CONSTRAINT `ticketRefund_FK` FOREIGN KEY (`refundTicketFk`) REFERENCES `vn`.`ticket`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `vn`.`ticketRefund` ADD CONSTRAINT `ticketRefund_FK_1` FOREIGN KEY (`originalTicketFk`) REFERENCES `vn`.`ticket`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
DELIMITER $$
|
||||
$$
|
||||
CREATE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticketRefund_beforeInsert`
|
||||
BEFORE INSERT ON `ticketRefund`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
DECLARE vAlreadyExists BOOLEAN DEFAULT FALSE;
|
||||
|
||||
IF NEW.refundTicketFk = NEW.originalTicketFk THEN
|
||||
CALL util.throw('Original ticket and refund ticket has same id');
|
||||
END IF;
|
||||
|
||||
SELECT COUNT(*) INTO vAlreadyExists
|
||||
FROM ticketRefund
|
||||
WHERE refundTicketFk = NEW.originalTicketFk;
|
||||
|
||||
IF vAlreadyExists > 0 THEN
|
||||
CALL util.throw('This ticket is already a refund');
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
||||
DELIMITER $$
|
||||
$$
|
||||
CREATE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticketRefund_beforeUpdate`
|
||||
BEFORE UPDATE ON `ticketRefund`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
DECLARE vAlreadyExists BOOLEAN DEFAULT FALSE;
|
||||
|
||||
IF NEW.refundTicketFk = NEW.originalTicketFk THEN
|
||||
CALL util.throw('Original ticket and refund ticket has same id');
|
||||
END IF;
|
||||
|
||||
SELECT COUNT(*) INTO vAlreadyExists
|
||||
FROM ticketRefund
|
||||
WHERE refundTicketFk = NEW.originalTicketFk;
|
||||
|
||||
IF vAlreadyExists > 0 THEN
|
||||
CALL util.throw('This ticket is already a refund');
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,16 +0,0 @@
|
|||
DROP TRIGGER `vn`.`travelThermograph_beforeInsert`;
|
||||
|
||||
ALTER TABLE `vn`.`travelThermograph` CHANGE `temperature` `temperature__` enum('COOL','WARM','DRY') CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL NULL;
|
||||
|
||||
CREATE OR REPLACE
|
||||
ALGORITHM = UNDEFINED VIEW `vn2008`.`travel_thermograph` AS
|
||||
select
|
||||
`tt`.`thermographFk` AS `thermograph_id`,
|
||||
`tt`.`created` AS `odbc_date`,
|
||||
`tt`.`warehouseFk` AS `warehouse_id`,
|
||||
`tt`.`travelFk` AS `travel_id`,
|
||||
`tt`.`temperatureFk` AS `temperature`,
|
||||
`tt`.`result` AS `result`,
|
||||
`tt`.`dmsFk` AS `gestdoc_id`
|
||||
from
|
||||
`vn`.`travelThermograph` `tt`;
|
|
@ -1,51 +0,0 @@
|
|||
|
||||
ALTER TABLE `vn`.`worker` MODIFY COLUMN `maritalStatus__` varchar(10) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL;
|
||||
UPDATE `vn`.`worker` `w`
|
||||
SET `w`.`maritalStatus__` = NULL;
|
||||
|
||||
UPDATE `vn`.`worker` `w`
|
||||
JOIN `vn`.`person` `p` ON `p`.`workerFk` = `w`.`id`
|
||||
JOIN `postgresql`.`profile` `pr` ON `pr`.`person_id` = `p`.`id`
|
||||
JOIN `vn2008`.`profile_labour_payroll` `pl` ON `pl`.`profile_id` = `pr`.`profile_id`
|
||||
SET `w`.`maritalStatus__` = `pl`.`estadocivil`;
|
||||
|
||||
ALTER TABLE `vn`.`worker` ADD `originCountryFk` mediumint(8) unsigned NULL COMMENT 'País de origen';
|
||||
ALTER TABLE `vn`.`worker` ADD `educationLevelFk` SMALLINT NULL;
|
||||
ALTER TABLE `vn`.`worker` ADD `SSN` varchar(15) NULL;
|
||||
ALTER TABLE `vn`.`worker` CHANGE `maritalStatus__` `maritalStatus` enum('S','M') CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL;
|
||||
ALTER TABLE `vn`.`worker` MODIFY COLUMN `maritalStatus` enum('S','M') CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL;
|
||||
ALTER TABLE `vn`.`worker` CHANGE `maritalStatus` maritalStatus enum('S','M') CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL AFTER sectorFk;
|
||||
ALTER TABLE `vn`.`worker` ADD CONSTRAINT `worker_FK_2` FOREIGN KEY (`educationLevelFk`) REFERENCES `vn`.`educationLevel`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `vn`.`worker` ADD CONSTRAINT `worker_FK_1` FOREIGN KEY (`originCountryFk`) REFERENCES `vn`.`country`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
INSERT INTO `vn`.`country` (`country`, `CEE`, `code`, `politicalCountryFk`, `isUeeMember`, `a3Code`)
|
||||
VALUES
|
||||
('Argentina',2,'AR',80,0,32),
|
||||
('Cuba',2,'CU',81,0,192),
|
||||
('Guinea Ecuatorial',2,'GQ',82,0,226),
|
||||
('Guinea',2,'GN',83,0,324),
|
||||
('Honduras',2,'HN',84,0,340),
|
||||
('Mali',2,'ML',85,0,466),
|
||||
('Nicaragua',2,'NI',86,0,558),
|
||||
('Pakistán',2,'PK',87,0,586),
|
||||
('Paraguay',2,'PY',88,0,600),
|
||||
('Senegal',2,'SN',89,0,686),
|
||||
('Uruguay',2,'UY',90,0,858),
|
||||
('Venezuela',2,'VE',91,0,862),
|
||||
('Bulgaria',2,'BG',92,1,100),
|
||||
('Georgia',2,'GE',93,0,268);
|
||||
|
||||
UPDATE `vn`.`worker` `w`
|
||||
JOIN `vn`.`person` `p` ON `p`.`workerFk` = `w`.`id`
|
||||
JOIN `postgresql`.`profile` `pr` ON `pr`.`person_id` = `p`.`id`
|
||||
JOIN `vn2008`.`profile_labour_payroll` `pl` ON `pl`.`profile_id` = `pr`.`profile_id`
|
||||
JOIN `vn`.`country` `co` ON `co`.`a3Code` = `pl`.`codpais`
|
||||
SET `w`.`originCountryFk` = `co`.`id`;
|
||||
|
||||
UPDATE `vn`.`worker` `w`
|
||||
JOIN `vn`.`person` `p` ON `p`.`workerFk` = `w`.`id`
|
||||
JOIN `postgresql`.`profile` `pr` ON `pr`.`person_id` = `p`.`id`
|
||||
JOIN `vn2008`.`profile_labour_payroll` pl ON `pl`.`profile_id` = `pr`.`profile_id`
|
||||
SET `w`.`SSN` = CONCAT(`pl`.`NSSProvincia`, `pl`.`NssNumero`, `pl`.`NssDC`);
|
||||
|
||||
RENAME TABLE `vn2008`.`profile_labour_payroll` TO `vn2008`.`profile_labour_payroll__`;
|
|
@ -1,3 +0,0 @@
|
|||
ALTER TABLE `postgresql`.`business_labour_payroll` DROP FOREIGN KEY `business_labour_payroll_cod_contrato`;
|
||||
ALTER TABLE `vn`.`workerBusinessType` MODIFY COLUMN `id` int(11) NOT NULL;
|
||||
ALTER TABLE `postgresql`.`business_labour_payroll` ADD CONSTRAINT `business_labour_payroll_FK` FOREIGN KEY (cod_contrato) REFERENCES `vn`.`workerBusinessType`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
@ -1,73 +0,0 @@
|
|||
DROP PROCEDURE IF EXISTS vn.timeControl_getError;
|
||||
|
||||
DELIMITER $$
|
||||
$$
|
||||
CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`timeControl_getError`(vDatedFrom DATETIME, vDatedTo DATETIME)
|
||||
BEGIN
|
||||
/*
|
||||
* @param vDatedFrom
|
||||
* @param vDatedTo
|
||||
* @table tmp.`user`(userFk)
|
||||
* Fichadas incorrectas de las cuales no se puede calcular horas trabajadas
|
||||
* @return tmp.timeControlError (id)
|
||||
*/
|
||||
DECLARE vDayMaxTime INTEGER;
|
||||
|
||||
SET @journeyCounter := 0;
|
||||
SET @lastUserFk := NULL;
|
||||
|
||||
SELECT dayMaxTime INTO vDayMaxTime
|
||||
FROM workerTimeControlConfig LIMIT 1;
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.timeControl;
|
||||
CREATE TEMPORARY TABLE tmp.timeControl
|
||||
(INDEX(id), INDEX(journeyCounter))
|
||||
ENGINE = MEMORY
|
||||
SELECT sub.id,
|
||||
sub.direction,
|
||||
sub.timed,
|
||||
IF(sub.direction = 'in' OR @hasOut OR sub.userFk <> @lastUserFk, @journeyCounter := @journeyCounter + 1, @journeyCounter) journeyCounter,
|
||||
@lastUserFk := sub.userFk workerFk,
|
||||
IF(sub.direction = 'out', @hasOut:= TRUE, @hasOut:= FALSE)
|
||||
FROM (
|
||||
SELECT DISTINCT wtc.id,
|
||||
wtc.direction,
|
||||
wtc.timed,
|
||||
wtc.userFk
|
||||
FROM workerTimeControl wtc
|
||||
JOIN tmp.`user` w ON w.userFk = wtc.userFk
|
||||
WHERE wtc.timed BETWEEN DATE_SUB(vDatedFrom, INTERVAL 1 DAY) AND DATE_ADD(vDatedTo, INTERVAL 1 DAY)
|
||||
ORDER BY wtc.userFk, wtc.timed
|
||||
) sub;
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.timeControlAux;
|
||||
CREATE TEMPORARY TABLE tmp.timeControlAux
|
||||
(INDEX(id), INDEX(journeyCounter))
|
||||
ENGINE = MEMORY
|
||||
SELECT * FROM tmp.timeControl;
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.timeControlError;
|
||||
CREATE TEMPORARY TABLE tmp.timeControlError
|
||||
(INDEX(id))
|
||||
ENGINE = MEMORY
|
||||
SELECT id
|
||||
FROM tmp.timeControlAux tca
|
||||
JOIN (SELECT journeyCounter,
|
||||
UNIX_TIMESTAMP(MAX(timed)) - UNIX_TIMESTAMP(MIN(timed)) timeWork,
|
||||
SUM(direction = 'in') totalIn,
|
||||
SUM(direction = 'out') totalOut,
|
||||
timed
|
||||
FROM tmp.timeControl
|
||||
GROUP BY journeyCounter
|
||||
HAVING COUNT(*) MOD 2 = 1
|
||||
OR totalIn <> 1
|
||||
OR totalOut <> 1
|
||||
OR timeWork >= vDayMaxTime
|
||||
)sub ON sub.journeyCounter = tca.journeyCounter
|
||||
WHERE sub.timed BETWEEN vDatedFrom AND vDatedTo;
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.timeControl;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.timeControlAux;
|
||||
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1 +0,0 @@
|
|||
ALTER TABLE `vn`.`userConfig` ADD darkMode tinyint(1) DEFAULT 1 NOT NULL COMMENT 'Salix interface dark mode';
|
|
@ -1,2 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL`(`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES('ExpeditionState', '*', 'READ', 'ALLOW', 'ROLE', 'employee');
|
|
@ -1,5 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL`(`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES('Expense', '*', 'READ', 'ALLOW', 'ROLE', 'employee');
|
||||
|
||||
INSERT INTO `salix`.`ACL`(`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES('Expense', '*', 'WRITE', 'ALLOW', 'ROLE', 'administrative');
|
|
@ -1,6 +0,0 @@
|
|||
UPDATE `salix`.`ACL`
|
||||
SET `property`='refund'
|
||||
WHERE `model`='Sale' AND `property`='payBack';
|
||||
|
||||
INSERT INTO `salix`.`ACL`(`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES('Sale', 'refundAll', 'WRITE', 'ALLOW', 'ROLE', 'employee');
|
|
@ -1,5 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES('SupplierActivity', '*', 'READ', 'ALLOW', 'ROLE', 'employee');
|
||||
|
||||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES('SupplierActivity', '*', 'WRITE', 'ALLOW', 'ROLE', 'administrative');
|
|
@ -1,5 +0,0 @@
|
|||
ALTER TABLE `vn`.`clientConfig` ADD `maxCreditRows` int(11) NULL COMMENT 'Máximo número de registros a mantener en la tabla clientCredit';
|
||||
|
||||
UPDATE `vn`.`clientConfig`
|
||||
SET `maxCreditRows` = 10
|
||||
WHERE `id` = 1;
|
|
@ -1,8 +0,0 @@
|
|||
ALTER TABLE `vn`.`propertyDms` DROP FOREIGN KEY propertyDms_FK;
|
||||
ALTER TABLE `vn`.`propertyDms` ADD CONSTRAINT propertyDms_FK FOREIGN KEY (dmsFk) REFERENCES `vn`.`dms`(id) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
ALTER TABLE `vn`.`clientDms` DROP FOREIGN KEY clientDms_ibfk_2;
|
||||
ALTER TABLE `vn`.`clientDms` ADD CONSTRAINT clientDms_ibfk_2 FOREIGN KEY (dmsFk) REFERENCES `vn`.`dms`(id) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
ALTER TABLE `vn`.`workerDocument` DROP FOREIGN KEY workerDocument_ibfk_2;
|
||||
ALTER TABLE `vn`.`workerDocument` ADD CONSTRAINT workerDocument_ibfk_2 FOREIGN KEY (document) REFERENCES `vn`.`dms`(id) ON DELETE CASCADE ON UPDATE CASCADE;
|
|
@ -1,5 +0,0 @@
|
|||
ALTER TABLE `vn`.`dmsType` ADD monthToDelete INT UNSIGNED DEFAULT NULL NULL;
|
||||
ALTER TABLE `vn`.`dmsType` MODIFY COLUMN monthToDelete int(10) unsigned DEFAULT NULL NULL COMMENT 'Meses en el pasado para ir borrando registros, dejar a null para no borrarlos nunca';
|
||||
UPDATE `vn`.`dmsType`
|
||||
SET monthToDelete=6
|
||||
WHERE id=20;
|
|
@ -1,18 +0,0 @@
|
|||
|
||||
DELIMITER $$
|
||||
$$
|
||||
CREATE TRIGGER `vn`.`dms_beforeDelete`
|
||||
BEFORE DELETE
|
||||
ON dms FOR EACH ROW
|
||||
BEGIN
|
||||
DECLARE vCanNotBeDeleted INT;
|
||||
SELECT COUNT(*) INTO vCanNotBeDeleted
|
||||
FROM dmsType dt
|
||||
WHERE NOT (code <=> 'trash')
|
||||
AND dt.id = OLD.dmsTypeFk;
|
||||
|
||||
IF vCanNotBeDeleted THEN
|
||||
CALL util.throw('A dms can not be deleted');
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,175 +0,0 @@
|
|||
DROP PROCEDURE IF EXISTS vn.clean;
|
||||
|
||||
DELIMITER $$
|
||||
$$
|
||||
CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`clean`()
|
||||
BEGIN
|
||||
DECLARE vDateShort DATETIME;
|
||||
DECLARE vOneYearAgo DATE;
|
||||
DECLARE vFourYearsAgo DATE;
|
||||
DECLARE v18Month DATE;
|
||||
DECLARE v26Month DATE;
|
||||
DECLARE v3Month DATE;
|
||||
DECLARE vTrashId varchar(15);
|
||||
|
||||
SET vDateShort = TIMESTAMPADD(MONTH, -2, CURDATE());
|
||||
SET vOneYearAgo = TIMESTAMPADD(YEAR,-1,CURDATE());
|
||||
SET vFourYearsAgo = TIMESTAMPADD(YEAR,-4,CURDATE());
|
||||
SET v18Month = TIMESTAMPADD(MONTH, -18,CURDATE());
|
||||
SET v26Month = TIMESTAMPADD(MONTH, -26,CURDATE());
|
||||
SET v3Month = TIMESTAMPADD(MONTH, -3, CURDATE());
|
||||
|
||||
DELETE FROM ticketParking WHERE created < vDateShort;
|
||||
DELETE FROM routesMonitor WHERE dated < vDateShort;
|
||||
DELETE FROM workerTimeControlLog WHERE created < vDateShort;
|
||||
DELETE FROM `message` WHERE sendDate < vDateShort;
|
||||
DELETE FROM messageInbox WHERE sendDate < vDateShort;
|
||||
DELETE FROM messageInbox WHERE sendDate < vDateShort;
|
||||
DELETE FROM workerTimeControl WHERE timed < vFourYearsAgo;
|
||||
DELETE FROM itemShelving WHERE created < CURDATE() AND visible = 0;
|
||||
DELETE FROM ticketDown WHERE created < TIMESTAMPADD(DAY,-1,CURDATE());
|
||||
DELETE FROM entryLog WHERE creationDate < vDateShort;
|
||||
DELETE IGNORE FROM expedition WHERE created < v26Month;
|
||||
DELETE FROM sms WHERE created < v18Month;
|
||||
DELETE FROM saleTracking WHERE created < vOneYearAgo;
|
||||
DELETE tobs FROM ticketObservation tobs
|
||||
JOIN ticket t ON tobs.ticketFk = t.id WHERE t.shipped < TIMESTAMPADD(YEAR,-2,CURDATE());
|
||||
DELETE sc.* FROM saleCloned sc JOIN sale s ON s.id = sc.saleClonedFk JOIN ticket t ON t.id = s.ticketFk WHERE t.shipped < vOneYearAgo;
|
||||
DELETE FROM sharingCart where ended < vDateShort;
|
||||
DELETE FROM sharingClient where ended < vDateShort;
|
||||
DELETE tw.* FROM ticketWeekly tw
|
||||
LEFT JOIN sale s ON s.ticketFk = tw.ticketFk WHERE s.itemFk IS NULL;
|
||||
DELETE FROM claim WHERE ticketCreated < vFourYearsAgo;
|
||||
DELETE FROM message WHERE sendDate < vDateShort;
|
||||
-- Robert ubicacion anterior de trevelLog comentario para debug
|
||||
DELETE sc FROM saleChecked sc
|
||||
JOIN sale s ON sc.saleFk = s.id WHERE s.created < vDateShort;
|
||||
DELETE FROM zoneEvent WHERE `type` = 'day' AND dated < v3Month;
|
||||
DELETE bm
|
||||
FROM buyMark bm
|
||||
JOIN buy b ON b.id = bm.id
|
||||
JOIN entry e ON e.id = b.entryFk
|
||||
JOIN travel t ON t.id = e.travelFk
|
||||
WHERE t.landed <= vDateShort;
|
||||
DELETE FROM stowaway WHERE created < v3Month;
|
||||
DELETE FROM vn.buy WHERE created < vDateShort AND entryFk = 9200;
|
||||
DELETE FROM vn.itemShelvingLog WHERE created < vDateShort;
|
||||
DELETE FROM vn.stockBuyed WHERE creationDate < vDateShort;
|
||||
|
||||
|
||||
-- Equipos duplicados
|
||||
DELETE w.*
|
||||
FROM workerTeam w
|
||||
JOIN (SELECT id, team, workerFk, COUNT(*) - 1 as duplicated
|
||||
FROM workerTeam
|
||||
GROUP BY team,workerFk
|
||||
HAVING duplicated
|
||||
) d ON d.team = w.team AND d.workerFk = w.workerFk AND d.id != w.id;
|
||||
|
||||
DELETE sc
|
||||
FROM saleComponent sc
|
||||
JOIN sale s ON s.id= sc.saleFk
|
||||
JOIN ticket t ON t.id= s.ticketFk
|
||||
WHERE t.shipped < v18Month;
|
||||
|
||||
DELETE c
|
||||
FROM vn.claim c
|
||||
JOIN vn.claimState cs ON cs.id = c.claimStateFk
|
||||
WHERE cs.description = "Anulado" AND
|
||||
c.created < vDateShort;
|
||||
DELETE
|
||||
FROM vn.expeditionTruck
|
||||
WHERE ETD < v3Month;
|
||||
|
||||
-- borrar travels sin entradas
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.thermographToDelete;
|
||||
CREATE TEMPORARY TABLE tmp.thermographToDelete
|
||||
SELECT th.id,th.dmsFk
|
||||
FROM vn.travel t
|
||||
LEFT JOIN vn.entry e ON e.travelFk = t.id
|
||||
JOIN vn.travelThermograph th ON th.travelFk = t.id
|
||||
WHERE t.shipped < TIMESTAMPADD(MONTH, -3, CURDATE()) AND e.travelFk IS NULL;
|
||||
|
||||
SELECT dt.id into vTrashId
|
||||
FROM vn.dmsType dt
|
||||
WHERE dt.code = 'trash';
|
||||
|
||||
UPDATE tmp.thermographToDelete th
|
||||
JOIN vn.dms d ON d.id = th.dmsFk
|
||||
SET d.dmsTypeFk = vTrashId;
|
||||
|
||||
DELETE th
|
||||
FROM tmp.thermographToDelete tmp
|
||||
JOIN vn.travelThermograph th ON th.id = tmp.id;
|
||||
|
||||
DELETE t
|
||||
FROM vn.travel t
|
||||
LEFT JOIN vn.entry e ON e.travelFk = t.id
|
||||
WHERE t.shipped < TIMESTAMPADD(MONTH, -3, CURDATE()) AND e.travelFk IS NULL;
|
||||
|
||||
UPDATE dms d
|
||||
JOIN dmsType dt ON dt.id = d.dmsTypeFk
|
||||
SET d.dmsTypeFk = vTrashId
|
||||
WHERE created < TIMESTAMPADD(MONTH, -dt.monthToDelete, CURDATE());
|
||||
|
||||
-- borrar entradas sin compras
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.entryToDelete;
|
||||
CREATE TEMPORARY TABLE tmp.entryToDelete
|
||||
SELECT e.*
|
||||
FROM vn.entry e
|
||||
LEFT JOIN vn.buy b ON b.entryFk = e.id
|
||||
JOIN vn.entryConfig ec ON e.id != ec.defaultEntry
|
||||
WHERE e.dated < TIMESTAMPADD(MONTH, -3, CURDATE()) AND b.entryFK IS NULL;
|
||||
|
||||
DELETE e
|
||||
FROM vn.entry e
|
||||
JOIN tmp.entryToDelete tmp ON tmp.id = e.id;
|
||||
|
||||
-- borrar de route registros menores a 4 años
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.routeToDelete;
|
||||
CREATE TEMPORARY TABLE tmp.routeToDelete
|
||||
SELECT *
|
||||
FROM vn.route r
|
||||
WHERE created < TIMESTAMPADD(YEAR,-4,CURDATE());
|
||||
|
||||
UPDATE tmp.routeToDelete tmp
|
||||
JOIN vn.dms d ON d.id = tmp.gestdocFk
|
||||
SET d.dmsTypeFk = vTrashId;
|
||||
|
||||
DELETE r
|
||||
FROM tmp.routeToDelete tmp
|
||||
JOIN vn.route r ON r.id = tmp.id;
|
||||
|
||||
-- borrar registros de dua y awb menores a 2 años
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.duaToDelete;
|
||||
CREATE TEMPORARY TABLE tmp.duaToDelete
|
||||
SELECT *
|
||||
FROM vn.dua
|
||||
WHERE operated < TIMESTAMPADD(YEAR,-2,CURDATE());
|
||||
|
||||
UPDATE tmp.duaToDelete tm
|
||||
JOIN vn.dms d ON d.id = tm.gestdocFk
|
||||
SET d.dmsTypeFk = vTrashId;
|
||||
|
||||
DELETE d
|
||||
FROM tmp.duaToDelete tmp
|
||||
JOIN vn.dua d ON d.id = tmp.id;
|
||||
|
||||
DELETE FROM vn.awb WHERE created < TIMESTAMPADD(YEAR,-2,CURDATE());
|
||||
|
||||
-- Borra los ficheros gestDoc
|
||||
INSERT INTO vn.printServerQueue(priorityFk, labelReportFk)VALUES(1,11);
|
||||
|
||||
-- Borra los registros de collection y ticketcollection
|
||||
DELETE FROM vn.collection WHERE created < vDateShort;
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.thermographToDelete;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.entryToDelete;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.duaToDelete;
|
||||
|
||||
DELETE FROM travelLog WHERE creationDate < v3Month;
|
||||
|
||||
CALL shelving_clean;
|
||||
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,10 +0,0 @@
|
|||
CREATE TABLE `vn`.`clientUnpaid` (
|
||||
`clientFk` int(11) NOT NULL,
|
||||
`dated` date NOT NULL,
|
||||
`amount` double DEFAULT 0,
|
||||
PRIMARY KEY (`clientFk`),
|
||||
CONSTRAINT `clientUnpaid_clientFk` FOREIGN KEY (`clientFk`) REFERENCES `vn`.`client` (`id`) ON UPDATE CASCADE
|
||||
);
|
||||
|
||||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES('ClientUnpaid', '*', '*', 'ALLOW', 'ROLE', 'administrative');
|
|
@ -1,8 +0,0 @@
|
|||
CREATE TABLE `vn`.`invoiceOut_queue` (
|
||||
`invoiceFk` int(10) unsigned not null,
|
||||
`queued` datetime default now() not null,
|
||||
`printed` datetime null,
|
||||
`status` VARCHAR(50) DEFAULT '' NULL,
|
||||
CONSTRAINT `invoiceOut_queue_pk` PRIMARY KEY (`invoiceFk`),
|
||||
CONSTRAINT `invoiceOut_queue_invoiceOut_id_fk` FOREIGN KEY (`invoiceFk`) REFERENCES `vn`.`invoiceOut` (`id`) ON UPDATE CASCADE ON DELETE CASCADE
|
||||
) comment 'Queue for PDF invoicing';
|
|
@ -1,2 +1,3 @@
|
|||
INSERT INTO `salix`.`ACL` (model,property,accessType,permission,principalType,principalId)
|
||||
VALUES ('Dms','deleteTrashFiles','WRITE','ALLOW','ROLE','employee')
|
||||
VALUES
|
||||
('ShelvingLog','*','READ','ALLOW','ROLE','employee');
|
|
@ -0,0 +1,4 @@
|
|||
INSERT INTO `salix`.`ACL`(`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
('ZoneExclusionGeo', '*', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
('ZoneExclusionGeo', '*', 'WRITE', 'ALLOW', 'ROLE', 'deliveryBoss');
|
|
@ -0,0 +1,10 @@
|
|||
UPDATE `vn`.`route` r
|
||||
JOIN(SELECT r.id, wl.workcenterFk
|
||||
FROM `vn`.`route` r
|
||||
JOIN `vn`.`routeLog` rl ON rl.originFk = r.id
|
||||
JOIN `vn`.`workerLabour` wl ON wl.workerFk = rl.userFk
|
||||
AND r.created BETWEEN wl.started AND IFNULL(wl.ended, r.created)
|
||||
WHERE r.created BETWEEN '2021-12-01' AND CURDATE()
|
||||
AND rl.action = 'insert'
|
||||
)sub ON sub.id = r.id
|
||||
SET r.commissionWorkCenterFk = sub.workcenterFk;
|
|
@ -0,0 +1,18 @@
|
|||
ALTER TABLE `vn`.`itemShelving` DROP FOREIGN KEY itemShelving_fk2;
|
||||
ALTER TABLE `vn`.`shelvingLog` DROP FOREIGN KEY shelvingLog_FK_ibfk_1;
|
||||
ALTER TABLE `vn`.`smartTag` DROP FOREIGN KEY smartTag_shelving_fk;
|
||||
ALTER TABLE `vn`.`workerShelving` DROP FOREIGN KEY workerShelving_shelving_fk;
|
||||
|
||||
ALTER TABLE `vn`.`shelving` DROP PRIMARY KEY;
|
||||
ALTER TABLE `vn`.`shelving` ADD id INT auto_increment PRIMARY KEY NULL;
|
||||
ALTER TABLE `vn`.`shelving` CHANGE id id int(11) auto_increment NOT NULL FIRST;
|
||||
ALTER TABLE `vn`.`shelving` ADD CONSTRAINT shelving_UN UNIQUE KEY (code);
|
||||
|
||||
ALTER TABLE `vn`.`itemShelving` ADD CONSTRAINT itemShelving_fk2 FOREIGN KEY (shelvingFk) REFERENCES `vn`.`shelving`(code) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
ALTER TABLE `vn`.`shelvingLog` ADD CONSTRAINT shelvingLog_FK_ibfk_1 FOREIGN KEY (originFk) REFERENCES `vn`.`shelving`(code) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
ALTER TABLE `vn`.`smartTag` ADD CONSTRAINT smartTag_FK FOREIGN KEY (shelvingFk) REFERENCES `vn`.`shelving`(code) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `vn`.`workerShelving` ADD CONSTRAINT workerShelving_FK_1 FOREIGN KEY (shelvingFk) REFERENCES `vn`.`shelving`(code) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
ALTER TABLE vn.shelvingLog DROP FOREIGN KEY shelvingLog_FK_ibfk_1;
|
||||
ALTER TABLE vn.shelvingLog MODIFY COLUMN originFk INT NOT NULL;
|
||||
ALTER TABLE vn.shelvingLog ADD CONSTRAINT shelvingLog_FK FOREIGN KEY (originFk) REFERENCES vn.shelving(id) ON DELETE CASCADE ON UPDATE CASCADE;
|
|
@ -0,0 +1,2 @@
|
|||
INSERT INTO `salix`.`ACL` (model,property,accessType,permission,principalType,principalId)
|
||||
VALUES ('Parking','*','*','ALLOW','ROLE','employee')
|
|
@ -0,0 +1,2 @@
|
|||
INSERT INTO `salix`.`ACL` (model,property,accessType,permission,principalType,principalId)
|
||||
VALUES ('Shelving','*','*','ALLOW','ROLE','employee')
|
File diff suppressed because one or more lines are too long
|
@ -122,17 +122,17 @@ INSERT INTO `vn`.`currency`(`id`, `code`, `name`, `ratio`)
|
|||
(3, 'GBP', 'Libra', 1),
|
||||
(4, 'JPY', 'Yen Japones', 1);
|
||||
|
||||
INSERT INTO `vn`.`country`(`id`, `country`, `isUeeMember`, `code`, `currencyFk`, `politicalCountryFk`, `ibanLength`, `continentFk`, `hasDailyInvoice`, `CEE`)
|
||||
INSERT INTO `vn`.`country`(`id`, `country`, `isUeeMember`, `code`, `currencyFk`, `ibanLength`, `continentFk`, `hasDailyInvoice`, `CEE`, `politicalCountryFk`)
|
||||
VALUES
|
||||
(1, 'España', 1, 'ES', 1, 1, 24, 4, 0, 1),
|
||||
(2, 'Italia', 1, 'IT', 1, 2, 27, 4, 0, 1),
|
||||
(3, 'Alemania', 1, 'DE', 1, 3, 22, 4, 0, 1),
|
||||
(4, 'Rumania', 1, 'RO', 1, 4, 24, 4, 0, 1),
|
||||
(5, 'Holanda', 1, 'NL', 1, 5, 18, 4, 0, 1),
|
||||
(8, 'Portugal', 1, 'PT', 1, 8, 27, 4, 0, 1),
|
||||
(13,'Ecuador', 0, 'EC', 1, 13, 24, 2, 1, 2),
|
||||
(19,'Francia', 1, 'FR', 1, 19, 27, 4, 0, 1),
|
||||
(30,'Canarias', 1, 'IC', 1, 1, 24, 4, 1, 2);
|
||||
(1, 'España', 1, 'ES', 1, 24, 4, 0, 1, 1),
|
||||
(2, 'Italia', 1, 'IT', 1, 27, 4, 0, 1, 2),
|
||||
(3, 'Alemania', 1, 'DE', 1, 22, 4, 0, 1, 3),
|
||||
(4, 'Rumania', 1, 'RO', 1, 24, 4, 0, 1, 4),
|
||||
(5, 'Holanda', 1, 'NL', 1, 18, 4, 0, 1, 5),
|
||||
(8, 'Portugal', 1, 'PT', 1, 27, 4, 0, 1, 8),
|
||||
(13,'Ecuador', 0, 'EC', 1, 24, 2, 1, 2, 13),
|
||||
(19,'Francia', 1, 'FR', 1, 27, 4, 0, 1, 19),
|
||||
(30,'Canarias', 1, 'IC', 1, 24, 4, 1, 2, 30);
|
||||
|
||||
INSERT INTO `vn`.`warehouseAlias`(`id`, `name`)
|
||||
VALUES
|
||||
|
@ -151,20 +151,35 @@ INSERT INTO `vn`.`warehouse`(`id`, `name`, `code`, `isComparative`, `isInventory
|
|||
|
||||
|
||||
INSERT INTO `vn`.`sector`(`id`, `description`, `warehouseFk`, `isPreviousPreparedByPacking`, `code`)
|
||||
VALUES
|
||||
VALUES
|
||||
(1, 'First sector', 1, 1, 'FIRST'),
|
||||
(2, 'Second sector', 2, 0, 'SECOND');
|
||||
|
||||
INSERT INTO `vn`.`parking` (`id`, `column`, `row`, `sectorFk`, `code`, `pickingOrder`)
|
||||
VALUES
|
||||
('1', '700', '01', '1', '700-01', '70001'),
|
||||
('2', '700', '02', '2', '700-02', '70002');
|
||||
('1', 700, '01', 1, '700-01', 70001),
|
||||
('2', 700, '02', 2, '700-02', 70002),
|
||||
('3', 100, '01', 1, '100-01', 1),
|
||||
(32397, 100, '02', 1, 'A-47-1', 1165),
|
||||
(34831, 200, '01', 1, 'K-26-2', 20220),
|
||||
(34965, 200, '02', 2, 'L-08-4', 21800),
|
||||
(39096, 200, '03', 2, 'LR-02-3', 99999);
|
||||
|
||||
INSERT INTO `vn`.`shelving` (`code`, `parkingFk`, `isPrinted`, `priority`, `parked`, `userFk`)
|
||||
INSERT INTO `vn`.`shelving` (`code`, `parkingFk`, `isPrinted`, `priority`, `userFk`, `isRecyclable`)
|
||||
VALUES
|
||||
('GVC', 1, 0, 1, 0, 1106),
|
||||
('HEJ', 2, 0, 1, 0, 1106),
|
||||
('UXN', 1, 0, 1, 0, 1106);
|
||||
('AA6', 34965, 1, 0, NULL, 0),
|
||||
('AA7', 34965, 1, 0, NULL, 0),
|
||||
('AA8', 34965, 1, 0, NULL, 0),
|
||||
('AA9', NULL, 1, 0, NULL, 0),
|
||||
('AAA', NULL, 0, 0, 1109, 1),
|
||||
('AAB', NULL, 0, 0, 1109, 1),
|
||||
('AAC', NULL, 1, 99, 1109, 1),
|
||||
('AAD', NULL, 0, 0, 1109, 1),
|
||||
('AAE', 39096, 1, 0, 1109, 1),
|
||||
('AAF', 34831, 1, 0, 1109, 1),
|
||||
('GVC', 1, 0, 1, 1106, 1),
|
||||
('HEJ', 2, 0, 1, 1106, 1),
|
||||
('UXN', 1, 0, 1, 1106, 1);
|
||||
|
||||
INSERT INTO `vn`.`accountingType`(`id`, `description`, `receiptDescription`,`code`, `maxAmount`, `daysInFuture`)
|
||||
VALUES
|
||||
|
@ -483,13 +498,29 @@ INSERT INTO `vn`.`supplierActivity`(`code`, `name`)
|
|||
('complements', 'Other complements'),
|
||||
('flowerPlants', 'Wholesale of flowers and plants'),
|
||||
('vegetablesFruits', 'Fruit and vegetable trade');
|
||||
|
||||
|
||||
INSERT INTO `vn`.`supplierAddress`(`id`, `supplierFk`, `nickname`, `street`, `provinceFk`, `postalCode`, `city`, `phone`, `mobile`)
|
||||
VALUES
|
||||
(1, 1, 'Ace Chemicals', 'The Midtown', 1, '46000', 'Gotham', '111111111', '222222222'),
|
||||
(2, 1, 'Arkham Asylum', 'Grand Avenue', 1, '46000', 'Gotham', '111111111', '222222222'),
|
||||
(3, 2, 'Wayne Tower', 'Grand Avenue', 1, '46000', 'Gotham', '111111111', '222222222'),
|
||||
(4, 2, 'Bank of Gotham', 'Founders Island', 1, '46000', 'Gotham', '111111111', '222222222'),
|
||||
(5, 442, 'GCR building', 'Bristol district', 1, '46000', 'Gotham', '111111111', '222222222'),
|
||||
(6, 442, 'The Gotham Tonight building', 'Bristol district', 1, '46000', 'Gotham', '111111111', '222222222');
|
||||
|
||||
INSERT INTO `vn`.`supplier`(`id`, `name`, `nickname`,`account`,`countryFk`,`nif`, `commission`, `created`, `isActive`, `street`, `city`, `provinceFk`, `postCode`, `payMethodFk`, `payDemFk`, `payDay`, `taxTypeSageFk`, `withholdingSageFk`, `transactionTypeSageFk`, `workerFk`, `supplierActivityFk`, `isPayMethodChecked`, `healthRegister`)
|
||||
VALUES
|
||||
(1, 'Plants SL', 'Plants nick', 4100000001, 1, '06089160W', 0, util.VN_CURDATE(), 1, 'supplier address 1', 'PONTEVEDRA', 1, 15214, 1, 1, 15, 4, 1, 1, 18, 'flowerPlants', 1, '400664487V'),
|
||||
(2, 'Farmer King', 'The farmer', 4000020002, 1, '87945234L', 0, util.VN_CURDATE(), 1, 'supplier address 2', 'GOTHAM', 2, 43022, 1, 2, 10, 93, 2, 8, 18, 'animals', 1, '400664487V'),
|
||||
(442, 'Verdnatura Levante SL', 'Verdnatura', 5115000442, 1, '06815934E', 0, util.VN_CURDATE(), 1, 'supplier address 3', 'GOTHAM', 1, 43022, 1, 2, 15, 6, 9, 3, 18, 'complements', 1, '400664487V');
|
||||
|
||||
INSERT INTO `vn`.`supplierContact`(`id`, `supplierFk`, `phone`, `mobile`, `email`, `observation`, `name`)
|
||||
VALUES
|
||||
(1, 1, 123121212, 654789123, 'supplier1@email.es', 'observation1', 'the boss'),
|
||||
(2, 1, 987456132, NULL, NULL, NULL, 'the salesperson'),
|
||||
(3, 2, 321654987, NULL, 'supplier2@email.es', NULL, NULL),
|
||||
(4, 442, 321654987, NULL, NULL, 'observation442', NULL);
|
||||
|
||||
INSERT INTO `vn`.`supplierAccount`(`id`, `supplierFk`, `iban`, `bankEntityFk`)
|
||||
VALUES
|
||||
(241, 442, 'ES111122333344111122221111', 128);
|
||||
|
@ -541,18 +572,16 @@ INSERT INTO `vn`.`invoiceOutTax` (`invoiceOutFk`, `taxableBase`, `vat`, `pgcFk`)
|
|||
(4, 8.07, 0.81, 4770000010),
|
||||
(5, 8.07, 0.81, 4770000010);
|
||||
|
||||
INSERT INTO `vn`.`expence`(`id`, `taxTypeFk`, `name`, `isWithheld`)
|
||||
INSERT INTO `vn`.`expence`(`id`, `name`, `isWithheld`)
|
||||
VALUES
|
||||
(2000000000, 1, 'Inmovilizado pendiente', 0),
|
||||
(2000000000, 3, 'Compra de bienes de inmovilizado', 0),
|
||||
(4751000000, 0, 'Retenciones', 1),
|
||||
(4751000000, 1, 'Retenciones', 1),
|
||||
(4751000000, 6, 'Retencion', 0),
|
||||
(6210000567, 0, 'Alquiler VNH', 0),
|
||||
(6240000000, 1, 'Transportes de ventas rutas', 0),
|
||||
(6240000000, 4, 'Transportes de ventas rutas', 0),
|
||||
(7001000000, 1, 'Mercaderia', 0),
|
||||
(7050000000, 1, 'Prestacion de servicios', 1);
|
||||
(2000000000, 'Inmovilizado pendiente', 0),
|
||||
(2000000001, 'Compra de bienes de inmovilizado', 0),
|
||||
(4751000000, 'Retenciones', 1),
|
||||
(4751000001, 'Retencion', 0),
|
||||
(6210000567, 'Alquiler VNH', 0),
|
||||
(6240000000, 'Transportes de ventas rutas', 0),
|
||||
(7001000000, 'Mercaderia', 0),
|
||||
(7050000000, 'Prestacion de servicios', 1);
|
||||
|
||||
|
||||
INSERT INTO `vn`.`invoiceOutExpence`(`id`, `invoiceOutFk`, `amount`, `expenceFk`, `created`)
|
||||
|
@ -1139,10 +1168,6 @@ INSERT INTO `vn`.`ticketCollection`(`ticketFk`, `collectionFk`, `level`)
|
|||
(3, 2, NULL),
|
||||
(23, 1, NULL);
|
||||
|
||||
INSERT INTO `vn`.`parking` (`column`, `row`, `sectorFk`, `code`, `pickingOrder`)
|
||||
VALUES
|
||||
('100', '01', 1, '100-01', 1);
|
||||
|
||||
INSERT INTO `vn`.`genus`(`id`, `name`)
|
||||
VALUES
|
||||
(1, 'Abelia'),
|
||||
|
@ -1312,22 +1337,6 @@ INSERT INTO `vn`.`annualAverageInvoiced`(`clientFk`, `invoiced`)
|
|||
(1104, 500),
|
||||
(1105, 5000);
|
||||
|
||||
INSERT INTO `vn`.`supplierAddress`(`id`, `supplierFk`, `nickname`, `street`, `provinceFk`, `postalCode`, `city`, `phone`, `mobile`)
|
||||
VALUES
|
||||
(1, 1, 'Ace Chemicals', 'The Midtown', 1, '46000', 'Gotham', '111111111', '222222222'),
|
||||
(2, 1, 'Arkham Asylum', 'Grand Avenue', 1, '46000', 'Gotham', '111111111', '222222222'),
|
||||
(3, 2, 'Wayne Tower', 'Grand Avenue', 1, '46000', 'Gotham', '111111111', '222222222'),
|
||||
(4, 2, 'Bank of Gotham', 'Founders Island', 1, '46000', 'Gotham', '111111111', '222222222'),
|
||||
(5, 442, 'GCR building', 'Bristol district', 1, '46000', 'Gotham', '111111111', '222222222'),
|
||||
(6, 442, 'The Gotham Tonight building', 'Bristol district', 1, '46000', 'Gotham', '111111111', '222222222');
|
||||
|
||||
INSERT INTO `vn`.`supplierContact`(`id`, `supplierFk`, `phone`, `mobile`, `email`, `observation`, `name`)
|
||||
VALUES
|
||||
(1, 1, 123121212, 654789123, 'supplier1@email.es', 'observation1', 'the boss'),
|
||||
(2, 1, 987456132, NULL, NULL, NULL, 'the salesperson'),
|
||||
(3, 2, 321654987, NULL, 'supplier2@email.es', NULL, NULL),
|
||||
(4, 442, 321654987, NULL, NULL, 'observation442', NULL);
|
||||
|
||||
INSERT INTO `cache`.`cache_calc`(`id`, `cache_id`, `cacheName`, `params`, `last_refresh`, `expires`, `created`, `connection_id`)
|
||||
VALUES
|
||||
(1, 2, 'available', CONCAT_WS('/',1,util.VN_CURDATE()), util.VN_NOW(), DATE_ADD(util.VN_NOW(),INTERVAL 15 MINUTE), util.VN_CURDATE(), NULL),
|
||||
|
@ -1342,7 +1351,7 @@ INSERT INTO `vn`.`ticketWeekly`(`ticketFk`, `weekDay`)
|
|||
(4, 4),
|
||||
(5, 6);
|
||||
|
||||
INSERT INTO `vn`.`travel`(`id`,`shipped`, `landed`, `warehouseInFk`, `warehouseOutFk`, `agencyFk`, `m3`, `kg`,`ref`, `totalEntries`, `cargoSupplierFk`)
|
||||
INSERT INTO `vn`.`travel`(`id`,`shipped`, `landed`, `warehouseInFk`, `warehouseOutFk`, `agencyModeFk`, `m3`, `kg`,`ref`, `totalEntries`, `cargoSupplierFk`)
|
||||
VALUES
|
||||
(1, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), 1, 2, 1, 100.00, 1000, 'first travel', 1, 1),
|
||||
(2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 2, 1, 150, 2000, 'second travel', 2, 2),
|
||||
|
@ -1756,6 +1765,11 @@ INSERT INTO `vn`.`claimDestination`(`id`, `description`, `addressFk`)
|
|||
(4, 'Reclam.PRAG', 12),
|
||||
(5, 'Corregido', 11);
|
||||
|
||||
INSERT INTO `vn`.`claimResponsible`(`id`, `description`, `responsability`)
|
||||
VALUES
|
||||
(1, 'Buyers', 0),
|
||||
(7, 'Quality', 0);
|
||||
|
||||
INSERT INTO `vn`.`claimDevelopment`(`id`, `claimFk`, `claimResponsibleFk`, `workerFk`, `claimReasonFk`, `claimResultFk`, `claimRedeliveryFk`, `claimDestinationFk`)
|
||||
VALUES
|
||||
(1, 1, 1, 21, 1, 1, 2, 5),
|
||||
|
@ -1863,29 +1877,20 @@ INSERT INTO `pbx`.`sip`(`user_id`, `extension`)
|
|||
(5, 1102),
|
||||
(9, 1201);
|
||||
|
||||
INSERT INTO `postgresql`.`person`(`person_id`, `name`, `nickname`, `nif`, `firstname`, `id_trabajador`)
|
||||
SELECT w.id, w.lastName, u.nickname,CONCAT(RPAD(CONCAT(w.id,9),8,w.id),'A'),w.firstName,w.id
|
||||
FROM `vn`.`worker` `w`
|
||||
JOIN `account`.`user` `u` ON `u`.`id` = `w`.`userFk`;
|
||||
INSERT INTO `postgresql`.`profile`(`profile_id`, `workerFk`, `profile_type_id`)
|
||||
SELECT w.id, w.id, 1
|
||||
FROM `vn`.`worker` `w`;
|
||||
|
||||
INSERT INTO `postgresql`.`person`(`person_id`, `name`, `nickname`, `nif`, `firstname`, `id_trabajador`)
|
||||
VALUES
|
||||
(1000, 'VERDNATURA LEVANTE SL', 'VNL', 'B78945612', NULL, NULL);
|
||||
|
||||
INSERT INTO `postgresql`.`profile`(`profile_id`, `person_id`, `profile_type_id`)
|
||||
SELECT p.person_id, p.person_id, 1
|
||||
FROM `postgresql`.`person` `p`;
|
||||
|
||||
INSERT INTO `postgresql`.`business`(`business_id`, `client_id`, `provider_id`, `date_start`, `date_end`, `workerBusiness`, `reasonEndFk`)
|
||||
SELECT p.profile_id, p.profile_id, 1000, CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR)), '-12-25'), CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL +1 YEAR)), '-01-25'), CONCAT('E-46-',RPAD(CONCAT(p.profile_id,9),8,p.profile_id)), NULL
|
||||
INSERT INTO `postgresql`.`business`(`business_id`, `client_id`, `companyCodeFk`, `date_start`, `date_end`, `workerBusiness`, `reasonEndFk`)
|
||||
SELECT p.profile_id, p.profile_id, 'VNL', CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -1 YEAR)), '-12-25'), CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL +1 YEAR)), '-01-25'), CONCAT('E-46-',RPAD(CONCAT(p.profile_id,9),8,p.profile_id)), NULL
|
||||
FROM `postgresql`.`profile` `p`;
|
||||
|
||||
INSERT INTO `postgresql`.`business_labour`(`business_id`, `notes`, `department_id`, `professional_category_id`, `incentivo`, `calendar_labour_type_id`, `porhoras`, `labour_agreement_id`, `workcenter_id`)
|
||||
SELECT b.business_id, NULL, 23, 1, 0, 1, 1, 1, 1
|
||||
FROM `postgresql`.`business` `b`;
|
||||
|
||||
INSERT INTO `postgresql`.`business` (`client_id`, `provider_id`, `date_start`, `date_end`, `workerBusiness`, `reasonEndFk`)
|
||||
SELECT p.profile_id, 1000, CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -2 YEAR)), '-12-25'), CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR)), '-12-24'), CONCAT('E-46-',RPAD(CONCAT(p.profile_id,9),8,p.profile_id)), NULL
|
||||
INSERT INTO `postgresql`.`business` (`client_id`, `companyCodeFk`, `date_start`, `date_end`, `workerBusiness`, `reasonEndFk`)
|
||||
SELECT p.profile_id, 'VNL', CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -2 YEAR)), '-12-25'), CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -1 YEAR)), '-12-24'), CONCAT('E-46-',RPAD(CONCAT(p.profile_id,9),8,p.profile_id)), NULL
|
||||
FROM `postgresql`.`profile` `p`
|
||||
WHERE `p`.`profile_id` = 1109;
|
||||
|
||||
|
@ -1896,14 +1901,13 @@ UPDATE `postgresql`.`business`
|
|||
INSERT INTO `postgresql`.`business_labour` (`business_id`, `notes`, `department_id`, `professional_category_id`, `incentivo`, `calendar_labour_type_id`, `porhoras`, `labour_agreement_id`, `workcenter_id`)
|
||||
VALUES
|
||||
(1111, NULL, 23, 1, 0.0, 1, 1, 1, 1);
|
||||
|
||||
|
||||
UPDATE `postgresql`.`business_labour` bl
|
||||
JOIN `postgresql`.`business` b ON b.business_id = bl.business_id
|
||||
JOIN `postgresql`.`profile` pr ON pr.profile_id = b.client_id
|
||||
JOIN `postgresql`.`person` p ON p.person_id = pr.person_id
|
||||
JOIN `postgresql`.`business` b ON b.business_id = bl.business_id
|
||||
JOIN `postgresql`.`profile` pr ON pr.profile_id = b.client_id
|
||||
SET bl.`professional_category_id` = 31
|
||||
WHERE p.`Id_trabajador` = 1110;
|
||||
|
||||
WHERE pr.`workerFk` = 1110;
|
||||
|
||||
UPDATE `postgresql`.`business_labour` bl
|
||||
SET bl.`department_id` = 43
|
||||
WHERE business_id IN(18, 19);
|
||||
|
@ -1925,15 +1929,6 @@ INSERT INTO `vn`.`workCenterHoliday` (`workCenterFk`, `days`, `year`)
|
|||
('1', '24.5', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR))),
|
||||
('5', '23', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR)));
|
||||
|
||||
INSERT INTO `vn`.`absenceType` (`id`, `name`, `rgb`, `code`, `holidayEntitlementRate`, `discountRate`)
|
||||
VALUES
|
||||
(1, 'Holidays', '#FF4444', 'holiday', 0, 0),
|
||||
(2, 'Leave of absence', '#C71585', 'absence', 0, 1),
|
||||
(6, 'Half holiday', '#E65F00', 'halfHoliday', 0, 0.5),
|
||||
(15, 'Half Paid Leave', '#5151c0', 'halfPaidLeave', 0, 1),
|
||||
(20, 'Furlough', '#97B92F', 'furlough', 1, 1),
|
||||
(21, 'Furlough half day', '#778899', 'halfFurlough', 0.5, 1);
|
||||
|
||||
ALTER TABLE `postgresql`.`business_labour_payroll` DROP FOREIGN KEY `business_labour_payroll_cod_categoria`;
|
||||
|
||||
INSERT INTO `vn`.`workerBusinessType` (`id`, `name`, `isFullTime`, `isPermanent`, `hasHolidayEntitlement`)
|
||||
|
@ -1949,6 +1944,15 @@ INSERT INTO `postgresql`.`business_labour_payroll` (`business_id`, `cod_tarifa`,
|
|||
(1107, 7, 12, 100, 2000),
|
||||
(1108, 7, 12, 100, 1500);
|
||||
|
||||
INSERT INTO `vn`.`absenceType` (`id`, `name`, `rgb`, `code`, `holidayEntitlementRate`, `discountRate`)
|
||||
VALUES
|
||||
(1, 'Holidays', '#FF4444', 'holiday', 0, 0),
|
||||
(2, 'Leave of absence', '#C71585', 'absence', 0, 1),
|
||||
(6, 'Half holiday', '#E65F00', 'halfHoliday', 0, 0.5),
|
||||
(15, 'Half Paid Leave', '#5151c0', 'halfPaidLeave', 0, 1),
|
||||
(20, 'Furlough', '#97B92F', 'furlough', 1, 1),
|
||||
(21, 'Furlough half day', '#778899', 'halfFurlough', 0.5, 1);
|
||||
|
||||
INSERT INTO `postgresql`.`calendar_employee` (`business_id`, `calendar_state_id`, `date`)
|
||||
VALUES
|
||||
(1, 6, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, DATE_ADD(util.VN_CURDATE(), INTERVAL -10 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 10 DAY))),
|
||||
|
@ -2465,8 +2469,8 @@ INSERT INTO `vn`.`invoiceInIntrastat` (`invoiceInFk`, `net`, `intrastatFk`, `amo
|
|||
(2, 16.10, 6021010, 25.00, 80, 5);
|
||||
|
||||
INSERT INTO `vn`.`ticketRecalc`(`ticketFk`)
|
||||
SELECT `id`
|
||||
FROM `vn`.`ticket` t
|
||||
SELECT t.id
|
||||
FROM vn.ticket t
|
||||
LEFT JOIN vn.ticketRecalc tr ON tr.ticketFk = t.id
|
||||
WHERE tr.ticketFk IS NULL;
|
||||
|
||||
|
@ -2563,8 +2567,8 @@ INSERT INTO `vn`.`supplierAgencyTerm` (`agencyFk`, `supplierFk`, `minimumPackage
|
|||
|
||||
INSERT INTO `vn`.`chat` (`senderFk`, `recipient`, `dated`, `checkUserStatus`, `message`, `status`, `attempts`)
|
||||
VALUES
|
||||
(1101, '@PetterParker', CURDATE(), 1, 'First test message', 0, 0),
|
||||
(1101, '@PetterParker', CURDATE(), 0, 'Second test message', 0, 0);
|
||||
(1101, '@PetterParker', util.VN_CURDATE(), 1, 'First test message', 0, 0),
|
||||
(1101, '@PetterParker', util.VN_CURDATE(), 0, 'Second test message', 0, 0);
|
||||
|
||||
|
||||
INSERT INTO `vn`.`mobileAppVersionControl` (`appName`, `version`, `isVersionCritical`)
|
||||
|
@ -2584,6 +2588,15 @@ INSERT INTO `vn`.`machineWorker` (`workerFk`, `machineFk`, `inTimed`, `outTimed`
|
|||
(1106, 2, util.VN_CURDATE(), NULL),
|
||||
(1106, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 DAY));
|
||||
|
||||
INSERT INTO `vn`.`zoneExclusion` (`id`, `zoneFk`, `dated`, `created`, `userFk`)
|
||||
VALUES
|
||||
(1, 1, DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=7, 7, 14) - DAYOFWEEK(util.VN_CURDATE())) DAY), util.VN_CURDATE(), 100),
|
||||
(2, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL (IF(DAYOFWEEK(util.VN_CURDATE())<=8, 8, 15) - DAYOFWEEK(util.VN_CURDATE())) DAY), util.VN_CURDATE(), 100);
|
||||
|
||||
INSERT INTO `vn`.`zoneExclusionGeo` (`zoneExclusionFk`, `geoFk`)
|
||||
VALUES
|
||||
(2, 1);
|
||||
|
||||
INSERT INTO `vn`.`mdbBranch` (`name`)
|
||||
VALUES
|
||||
('test'),
|
||||
|
@ -2594,6 +2607,11 @@ INSERT INTO `vn`.`mdbVersion` (`app`, `branchFk`, `version`)
|
|||
('tpv', 'test', '1'),
|
||||
('lab', 'master', '1');
|
||||
|
||||
INSERT INTO `vn`.`accountingConfig` (`id`, `minDate`, `maxDate`)
|
||||
VALUES
|
||||
(1, '2022-01-01', '2023-01-01');
|
||||
|
||||
|
||||
INSERT INTO `vn`.`saleGroup` (`userFk`, `parkingFk`, `sectorFk`)
|
||||
VALUES
|
||||
(1, 1, 1);
|
||||
|
@ -2612,4 +2630,8 @@ INSERT INTO `vn`.`sectorCollectionSaleGroup` (`sectorCollectionFk`, `saleGroupFk
|
|||
|
||||
INSERT INTO `vn`.`workerTimeControlConfig` (`id`, `dayBreak`, `dayBreakDriver`, `shortWeekBreak`, `longWeekBreak`, `weekScope`, `mailPass`, `mailHost`, `mailSuccessFolder`, `mailErrorFolder`, `mailUser`, `minHoursToBreak`, `breakHours`, `hoursCompleteWeek`, `startNightlyHours`, `endNightlyHours`, `maxTimePerDay`, `breakTime`, `timeToBreakTime`, `dayMaxTime`, `shortWeekDays`, `longWeekDays`)
|
||||
VALUES
|
||||
(1, 43200, 32400, 129600, 259200, 604800, '', '', 'Leidos.exito', 'Leidos.error', 'timeControl', 5.33, 0.33, 40, '22:00:00', '06:00:00', 57600, 1200, 18000, 57600, 6, 13);
|
||||
(1, 43200, 32400, 129600, 259200, 604800, '', '', 'Leidos.exito', 'Leidos.error', 'timeControl', 5.33, 0.33, 40, '22:00:00', '06:00:00', 57600, 1200, 18000, 57600, 6, 13);
|
||||
|
||||
INSERT INTO `vn`.`routeConfig` (`id`, `defaultWorkCenterFk`)
|
||||
VALUES
|
||||
(1, 9);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -29,7 +29,7 @@ describe('Entry descriptor path', () => {
|
|||
it('should click the travels button to be redirected to the travels index filtered by the current agency', async() => {
|
||||
await page.waitToClick(selectors.entryDescriptor.travelsQuicklink);
|
||||
await page.expectURL('/travel/index');
|
||||
await page.expectURL('agencyFk');
|
||||
await page.expectURL('agencyModeFk');
|
||||
});
|
||||
|
||||
it('should go back to the entry summary', async() => {
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
<div ng-transclude="actions"></div>
|
||||
</div>
|
||||
<div class="actions-right">
|
||||
<div class="totalRows" ng-if="$ctrl.model.data">
|
||||
{{model.data.length}}
|
||||
<span translate>results</span>
|
||||
<div class="totalRows" ng-if="$ctrl.model.data">
|
||||
{{model.data.length}}
|
||||
<span translate>results</span>
|
||||
</div>
|
||||
<vn-button icon="search"
|
||||
ng-if="$ctrl.options.activeButtons.search"
|
||||
|
@ -40,7 +40,8 @@
|
|||
</vn-button>
|
||||
</div>
|
||||
<vn-button icon="refresh"
|
||||
ng-click="$ctrl.model.refresh()"
|
||||
ng-click="$ctrl.refresh()"
|
||||
disabled="$ctrl.isRefreshing"
|
||||
vn-tooltip="Refresh">
|
||||
</vn-button>
|
||||
</div>
|
||||
|
@ -64,7 +65,7 @@
|
|||
|
||||
<vn-crud-model
|
||||
ng-if="$ctrl.viewConfigId"
|
||||
vn-id="userViewModel"
|
||||
vn-id="userViewModel"
|
||||
url="UserConfigViews"
|
||||
link="{tableCode: $ctrl.viewConfigId, userFk: $ctrl.currentUserId}"
|
||||
data="$ctrl.viewConfig"
|
||||
|
@ -75,9 +76,9 @@
|
|||
<div class="smart-table-columns vn-pa-md vn-w-sm">
|
||||
<vn-horizontal>
|
||||
<h6 translate style="margin:0">Shown columns</h6>
|
||||
<vn-icon
|
||||
<vn-icon
|
||||
vn-none
|
||||
icon="info"
|
||||
icon="info"
|
||||
color-marginal
|
||||
vn-tooltip="Check the columns you want to see"/>
|
||||
</vn-horizontal>
|
||||
|
@ -101,4 +102,4 @@
|
|||
</vn-horizontal>
|
||||
</div>
|
||||
</tpl-body>
|
||||
</vn-popover>
|
||||
</vn-popover>
|
||||
|
|
|
@ -511,6 +511,12 @@ export default class SmartTable extends Component {
|
|||
return this.model.save()
|
||||
.then(() => this.vnApp.showSuccess(this.$t('Data saved!')));
|
||||
}
|
||||
|
||||
refresh() {
|
||||
this.isRefreshing = true;
|
||||
this.model.refresh()
|
||||
.then(() => this.isRefreshing = false);
|
||||
}
|
||||
}
|
||||
|
||||
SmartTable.$inject = ['$element', '$scope', '$transclude'];
|
||||
|
|
|
@ -21,6 +21,7 @@ export default function moduleImport(moduleName) {
|
|||
case 'entry' : return import('entry/front');
|
||||
case 'account' : return import('account/front');
|
||||
case 'supplier' : return import('supplier/front');
|
||||
case 'shelving' : return import('shelving/front');
|
||||
case 'monitor' : return import('monitor/front');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ import './modules/route/front/module.js';
|
|||
import './modules/ticket/front/module.js';
|
||||
import './modules/travel/front/module.js';
|
||||
import './modules/worker/front/module.js';
|
||||
import './modules/shelving/front/module.js';
|
||||
|
||||
core.run(vnInterceptor => {
|
||||
vnInterceptor.setApiPath(null);
|
||||
|
|
|
@ -24,6 +24,6 @@ describe('Model rewriteDbError()', () => {
|
|||
error = e;
|
||||
}
|
||||
|
||||
expect(error.message).toEqual(`The tag can't be repeated`);
|
||||
expect(error.message).toEqual(`The tag or priority can't be repeated for an item`);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
"is not a valid date": "No es una fecha valida",
|
||||
"Barcode must be unique": "El código de barras debe ser único",
|
||||
"The warehouse can't be repeated": "El almacén no puede repetirse",
|
||||
"The tag can't be repeated": "El tag no puede repetirse",
|
||||
"The tag or priority can't be repeated for an item": "El tag o prioridad no puede repetirse para un item",
|
||||
"The observation type can't be repeated": "El tipo de observación no puede repetirse",
|
||||
"A claim with that sale already exists": "Ya existe una reclamación para esta línea",
|
||||
"You don't have enough privileges to change that field": "No tienes permisos para cambiar ese campo",
|
||||
|
|
|
@ -56,6 +56,12 @@ module.exports = Self => {
|
|||
if (!userExists) {
|
||||
await Self.rawSql('CREATE USER ?@? IDENTIFIED BY ?',
|
||||
[mysqlUser, this.userHost, password]);
|
||||
await Self.rawSql(
|
||||
`UPDATE mysql.global_priv
|
||||
SET Priv = JSON_SET(Priv, '$.autogenerated' , TRUE)
|
||||
WHERE User = ? AND Host = ?`,
|
||||
[mysqlUser, this.userHost]
|
||||
);
|
||||
userExists = true;
|
||||
} else {
|
||||
switch (this.dbType) {
|
||||
|
|
|
@ -2,36 +2,36 @@
|
|||
url="ClaimEnds/filter"
|
||||
link="{claimFk: $ctrl.$params.id}"
|
||||
data="$ctrl.salesClaimed"
|
||||
auto-load="true"
|
||||
auto-load="true"
|
||||
on-save="$ctrl.onSave()">
|
||||
</vn-crud-model>
|
||||
<vn-crud-model
|
||||
<vn-crud-model
|
||||
auto-load="true"
|
||||
url="ClaimDestinations"
|
||||
data="claimDestinations">
|
||||
</vn-crud-model>
|
||||
<vn-card class="vn-mb-md vn-pa-lg vn-w-lg" style="text-align: right"
|
||||
<vn-card class="vn-mb-md vn-pa-lg vn-w-lg" style="text-align: right"
|
||||
ng-if="$ctrl.salesClaimed.length > 0">
|
||||
<vn-label-value label="Total claimed"
|
||||
<vn-label-value label="Total claimed"
|
||||
value="{{$ctrl.claimedTotal | currency: 'EUR':2}}">
|
||||
</vn-label-value>
|
||||
</vn-card>
|
||||
<vn-card class="vn-pa-lg vn-w-lg">
|
||||
<smart-table
|
||||
model="model"
|
||||
options="$ctrl.smartTableOptions"
|
||||
<smart-table
|
||||
model="model"
|
||||
options="$ctrl.smartTableOptions"
|
||||
expr-builder="$ctrl.exprBuilder(param, value)">
|
||||
<slot-actions>
|
||||
<section class="header">
|
||||
<vn-tool-bar class="vn-mb-md">
|
||||
<vn-button
|
||||
label="Import claim"
|
||||
label="Import claim"
|
||||
disabled="$ctrl.claim.claimStateFk == $ctrl.resolvedStateId"
|
||||
vn-http-click="$ctrl.importToNewRefundTicket()"
|
||||
translate-attr="{title: 'Imports claim details'}">
|
||||
</vn-button>
|
||||
<vn-button
|
||||
label="Change destination"
|
||||
label="Change destination"
|
||||
disabled="$ctrl.checked.length == 0"
|
||||
ng-click="changeDestination.show()">
|
||||
</vn-button>
|
||||
|
@ -47,7 +47,7 @@
|
|||
</vn-range>
|
||||
</vn-tool-bar>
|
||||
<vn-check class="right"
|
||||
vn-one
|
||||
vn-one
|
||||
label="Is paid with mana"
|
||||
ng-model="$ctrl.claim.isChargedToMana"
|
||||
on-change="$ctrl.save({isChargedToMana: value})">
|
||||
|
@ -66,12 +66,24 @@
|
|||
</th>
|
||||
<th number field="itemFk">Id</th>
|
||||
<th number field="ticketFk">Ticket</th>
|
||||
<th field="claimDestinationFk">Destination</th>
|
||||
<th expand field="landed">Landed</th>
|
||||
<th number field="quantity">Quantity</th>
|
||||
<th field="concept">Description</th>
|
||||
<th number field="price">Price</th>
|
||||
<th number field="discount">Disc.</th>
|
||||
<th field="claimDestinationFk">
|
||||
<span translate>Destination</span>
|
||||
</th>
|
||||
<th expand field="landed">
|
||||
<span translate>Landed</span>
|
||||
</th>
|
||||
<th number field="quantity">
|
||||
<span translate>Quantity</span>
|
||||
</th>
|
||||
<th field="concept">
|
||||
<span translate>Description</span>
|
||||
</th>
|
||||
<th number field="price">
|
||||
<span translate>Price</span>
|
||||
</th>
|
||||
<th number field="discount">
|
||||
<span translate>Disc.</span>
|
||||
</th>
|
||||
<th number field="total">Total</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
@ -80,13 +92,13 @@
|
|||
ng-repeat="saleClaimed in $ctrl.salesClaimed"
|
||||
vn-repeat-last on-last="$ctrl.focusLastInput()">
|
||||
<td>
|
||||
<vn-check
|
||||
<vn-check
|
||||
ng-model="saleClaimed.$checked"
|
||||
vn-click-stop>
|
||||
</vn-check>
|
||||
</td>
|
||||
<td number>
|
||||
<vn-span
|
||||
<vn-span
|
||||
ng-click="itemDescriptor.show($event, saleClaimed.itemFk)"
|
||||
class="link">
|
||||
{{::saleClaimed.itemFk | zeroFill:6}}
|
||||
|
@ -94,7 +106,7 @@
|
|||
</td>
|
||||
<td number>
|
||||
<vn-span
|
||||
class="link"
|
||||
class="link"
|
||||
ng-click="ticketDescriptor.show($event, saleClaimed.ticketFk)">
|
||||
{{::saleClaimed.ticketFk}}
|
||||
</vn-span>
|
||||
|
@ -129,7 +141,7 @@
|
|||
</slot-table>
|
||||
</smart-table>
|
||||
<button-bar class="vn-pa-md">
|
||||
<vn-button
|
||||
<vn-button
|
||||
label="Regularize"
|
||||
disabled="$ctrl.claim.claimStateFk == $ctrl.resolvedStateId"
|
||||
vn-http-click="$ctrl.regularize()">
|
||||
|
@ -140,17 +152,17 @@
|
|||
vn-id="item-descriptor"
|
||||
warehouse-fk="$ctrl.vnConfig.warehouseFk">
|
||||
</vn-item-descriptor-popover>
|
||||
<vn-ticket-descriptor-popover
|
||||
<vn-ticket-descriptor-popover
|
||||
vn-id="ticket-descriptor">
|
||||
</vn-ticket-descriptor-popover>
|
||||
<vn-confirm
|
||||
vn-id="update-greuge"
|
||||
<vn-confirm
|
||||
vn-id="update-greuge"
|
||||
question="Insert greuges on client card"
|
||||
message="Do you want to insert greuges?"
|
||||
on-accept="$ctrl.onUpdateGreugeAccept()">
|
||||
</vn-confirm>
|
||||
|
||||
<!-- Dialog of change destionation -->
|
||||
<!-- Dialog of change destionation -->
|
||||
<vn-dialog
|
||||
vn-id="changeDestination"
|
||||
on-accept="$ctrl.onResponse()">
|
||||
|
@ -173,4 +185,4 @@
|
|||
<input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/>
|
||||
<button response="accept" translate>Save</button>
|
||||
</tpl-buttons>
|
||||
</vn-dialog>
|
||||
</vn-dialog>
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
<vn-autocomplete
|
||||
vn-one
|
||||
label="Billing data"
|
||||
vn-acl="salesAssistant"
|
||||
vn-acl="salesAssistant, hr"
|
||||
ng-model="$ctrl.client.payMethodFk"
|
||||
data="paymethods"
|
||||
fields="['isIbanRequiredForClients']"
|
||||
|
@ -28,7 +28,7 @@
|
|||
step="1"
|
||||
label="Due day"
|
||||
ng-model="$ctrl.client.dueDay"
|
||||
vn-acl="salesAssistant"
|
||||
vn-acl="salesAssistant, hr"
|
||||
rule>
|
||||
</vn-input-number>
|
||||
</vn-horizontal>
|
||||
|
@ -39,7 +39,7 @@
|
|||
ng-model="$ctrl.client.iban"
|
||||
rule
|
||||
on-change="$ctrl.autofillBic()"
|
||||
vn-acl="salesAssistant">
|
||||
vn-acl="salesAssistant, hr">
|
||||
</vn-textfield>
|
||||
<vn-autocomplete
|
||||
vn-one
|
||||
|
@ -52,7 +52,7 @@
|
|||
search-function="{or: [{bic: {like: $search +'%'}}, {name: {like: '%'+ $search +'%'}}]}"
|
||||
value-field="id"
|
||||
show-field="bic"
|
||||
vn-acl="salesAssistant"
|
||||
vn-acl="salesAssistant, hr"
|
||||
disabled="$ctrl.ibanCountry == 'ES'">
|
||||
<tpl-item>{{bic}} {{name}}</tpl-item>
|
||||
<append>
|
||||
|
@ -61,7 +61,7 @@
|
|||
icon="add_circle"
|
||||
vn-click-stop="bankEntity.show({countryFk: $ctrl.client.countryFk})"
|
||||
vn-tooltip="New bank entity"
|
||||
vn-acl="salesAssistant">
|
||||
vn-acl="salesAssistant, hr">
|
||||
</vn-icon-button>
|
||||
</append>
|
||||
</vn-autocomplete>
|
||||
|
@ -71,19 +71,19 @@
|
|||
vn-one
|
||||
label="Received LCR"
|
||||
ng-model="$ctrl.client.hasLcr"
|
||||
vn-acl="salesAssistant">
|
||||
vn-acl="salesAssistant, hr">
|
||||
</vn-check>
|
||||
<vn-check
|
||||
vn-one
|
||||
label="Received core VNL"
|
||||
ng-model="$ctrl.client.hasCoreVnl"
|
||||
vn-acl="salesAssistant">
|
||||
vn-acl="salesAssistant, hr">
|
||||
</vn-check>
|
||||
<vn-check
|
||||
vn-one
|
||||
label="Received B2B VNL"
|
||||
ng-model="$ctrl.client.hasSepaVnl"
|
||||
vn-acl="salesAssistant">
|
||||
vn-acl="salesAssistant, hr">
|
||||
</vn-check>
|
||||
</vn-horizontal>
|
||||
</vn-card>
|
||||
|
|
|
@ -108,6 +108,7 @@ export default class Controller extends Section {
|
|||
case 'fi':
|
||||
case 'postcode':
|
||||
case 'salesPersonFk':
|
||||
case 'provinceFk':
|
||||
return {[param]: value};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
{"state": "client.card.unpaid", "icon": "icon-defaulter"}
|
||||
]
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"keybindings": [
|
||||
{"key": "c", "state": "client.index"}
|
||||
|
|
|
@ -43,7 +43,7 @@ module.exports = Self => {
|
|||
'name',
|
||||
'shipped',
|
||||
'landed',
|
||||
'agencyFk',
|
||||
'agencyModeFk',
|
||||
'warehouseOutFk',
|
||||
'warehouseInFk',
|
||||
'isReceived',
|
||||
|
|
|
@ -137,7 +137,7 @@
|
|||
<vn-horizontal>
|
||||
<vn-autocomplete
|
||||
label="Agency"
|
||||
ng-model="$ctrl.travelFilterParams.agencyFk"
|
||||
ng-model="$ctrl.travelFilterParams.agencyModeFk"
|
||||
url="AgencyModes"
|
||||
show-field="name"
|
||||
value-field="id">
|
||||
|
|
|
@ -46,7 +46,7 @@ class Controller extends Section {
|
|||
if (!value) continue;
|
||||
|
||||
switch (key) {
|
||||
case 'agencyFk':
|
||||
case 'agencyModeFk':
|
||||
case 'warehouseInFk':
|
||||
case 'warehouseOutFk':
|
||||
case 'shipped':
|
||||
|
|
|
@ -14,7 +14,7 @@ class Controller extends ModuleCard {
|
|||
{
|
||||
relation: 'travel',
|
||||
scope: {
|
||||
fields: ['id', 'landed', 'agencyFk', 'warehouseOutFk'],
|
||||
fields: ['id', 'landed', 'agencyModeFk', 'warehouseOutFk'],
|
||||
include: [
|
||||
{
|
||||
relation: 'agency',
|
||||
|
|
|
@ -14,9 +14,9 @@ class Controller extends Descriptor {
|
|||
let travelFilter;
|
||||
const entryTravel = this.entry && this.entry.travel;
|
||||
|
||||
if (entryTravel && entryTravel.agencyFk) {
|
||||
if (entryTravel && entryTravel.agencyModeFk) {
|
||||
travelFilter = this.entry && JSON.stringify({
|
||||
agencyFk: entryTravel.agencyFk
|
||||
agencyModeFk: entryTravel.agencyModeFk
|
||||
});
|
||||
}
|
||||
return travelFilter;
|
||||
|
@ -49,7 +49,7 @@ class Controller extends Descriptor {
|
|||
{
|
||||
relation: 'travel',
|
||||
scope: {
|
||||
fields: ['id', 'landed', 'agencyFk', 'warehouseOutFk'],
|
||||
fields: ['id', 'landed', 'agencyModeFk', 'warehouseOutFk'],
|
||||
include: [
|
||||
{
|
||||
relation: 'agency',
|
||||
|
|
|
@ -123,12 +123,12 @@
|
|||
<td center title="{{::line.weight}}">{{::line.weight}}</td>
|
||||
<td center>
|
||||
<vn-chip class="transparent" translate-attr="line.groupingMode == 2 ? {title: 'Minimun amount'} : {title: 'Packing'}" ng-class="{'message': line.groupingMode == 2}">
|
||||
<span translate>{{::line.packing | dashIfEmpty}}</span>
|
||||
<span>{{::line.packing | dashIfEmpty}}</span>
|
||||
</vn-chip>
|
||||
</td>
|
||||
<td center>
|
||||
<vn-chip class="transparent" translate-attr="line.groupingMode == 1 ? {title: 'Minimun amount'} : {title: 'Grouping'}" ng-class="{'message': line.groupingMode == 1}">
|
||||
<span translate>{{::line.grouping | dashIfEmpty}}</span>
|
||||
<span>{{::line.grouping | dashIfEmpty}}</span>
|
||||
</vn-chip>
|
||||
</vn-td>
|
||||
<td center title="{{::line.buyingValue | currency: 'EUR':2}}">{{::line.buyingValue | currency: 'EUR':2}}</td>
|
||||
|
|
|
@ -5,7 +5,7 @@ module.exports = Self => {
|
|||
|
||||
Self.rewriteDbError(function(err) {
|
||||
if (err.code === 'ER_DUP_ENTRY')
|
||||
return new UserError(`The tag can't be repeated`);
|
||||
return new UserError(`The tag or priority can't be repeated for an item`);
|
||||
if (err.code === 'ER_BAD_NULL_ERROR')
|
||||
return new UserError(`Tag value cannot be blank`);
|
||||
return err;
|
||||
|
|
|
@ -70,12 +70,12 @@
|
|||
<vn-td number class="expendable">{{entry.stickers | dashIfEmpty}}</vn-td>
|
||||
<vn-td number>
|
||||
<vn-chip translate-attr="{title: 'Packing'}" ng-class="{'message': entry.groupingMode == 2}">
|
||||
<span translate>{{::entry.packing | dashIfEmpty}}</span>
|
||||
<span>{{::entry.packing | dashIfEmpty}}</span>
|
||||
</vn-chip>
|
||||
</vn-td>
|
||||
<vn-td number>
|
||||
<vn-chip translate-attr="{title: 'Grouping'}" ng-class="{'message': entry.groupingMode == 1}">
|
||||
<span translate>{{::entry.grouping | dashIfEmpty}}</span>
|
||||
<span>{{::entry.grouping | dashIfEmpty}}</span>
|
||||
</vn-chip>
|
||||
</vn-td>
|
||||
<vn-td number class="expendable">{{::entry.stems | dashIfEmpty}}</vn-td>
|
||||
|
|
|
@ -88,17 +88,19 @@ module.exports = Self => {
|
|||
await fs.mkdir(branchPath, {recursive: true});
|
||||
|
||||
const destinationBranch = path.join(branchPath, `${appName}.7z`);
|
||||
const destinationRoot = path.join(accessContainer.client.root, `${appName}.7z`);
|
||||
const destinationRelative = `../../.archive/${appName}/${newVersion}.7z`;
|
||||
try {
|
||||
await fs.unlink(destinationBranch);
|
||||
} catch (e) {}
|
||||
await fs.symlink(destinationFile, destinationBranch);
|
||||
await fs.symlink(destinationRelative, destinationBranch);
|
||||
|
||||
if (branch == 'master') {
|
||||
const destinationRoot = path.join(accessContainer.client.root, `${appName}.7z`);
|
||||
const rootRelative = `./.archive/${appName}/${newVersion}.7z`;
|
||||
try {
|
||||
await fs.unlink(destinationRoot);
|
||||
} catch (e) {}
|
||||
await fs.symlink(destinationFile, destinationRoot);
|
||||
await fs.symlink(rootRelative, destinationRoot);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -164,6 +164,10 @@ module.exports = Self => {
|
|||
let stmt;
|
||||
|
||||
stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.filter');
|
||||
|
||||
stmts.push(`SET @_optimizer_search_depth = @@optimizer_search_depth`);
|
||||
stmts.push(`SET SESSION optimizer_search_depth = 0`);
|
||||
|
||||
stmt = new ParameterizedSQL(
|
||||
`CREATE TEMPORARY TABLE tmp.filter
|
||||
(PRIMARY KEY (id))
|
||||
|
@ -207,7 +211,7 @@ module.exports = Self => {
|
|||
LEFT JOIN province p ON p.id = a.provinceFk
|
||||
LEFT JOIN warehouse w ON w.id = t.warehouseFk
|
||||
LEFT JOIN agencyMode am ON am.id = t.agencyModeFk
|
||||
LEFT JOIN ticketState ts ON ts.ticketFk = t.id
|
||||
STRAIGHT_JOIN ticketState ts ON ts.ticketFk = t.id
|
||||
LEFT JOIN state st ON st.id = ts.stateFk
|
||||
LEFT JOIN client c ON c.id = t.clientFk
|
||||
LEFT JOIN worker wk ON wk.id = c.salesPersonFk
|
||||
|
@ -224,10 +228,12 @@ module.exports = Self => {
|
|||
stmt.merge(conn.makeWhere(filter.where));
|
||||
stmts.push(stmt);
|
||||
|
||||
stmts.push(`SET SESSION optimizer_search_depth = @_optimizer_search_depth`);
|
||||
|
||||
// Get client debt balance
|
||||
stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.clientGetDebt');
|
||||
stmts.push(`
|
||||
CREATE TEMPORARY TABLE tmp.clientGetDebt
|
||||
CREATE TEMPORARY TABLE tmp.clientGetDebt
|
||||
(PRIMARY KEY (clientFk))
|
||||
ENGINE = MEMORY
|
||||
SELECT DISTINCT clientFk FROM tmp.filter`);
|
||||
|
@ -238,7 +244,7 @@ module.exports = Self => {
|
|||
|
||||
stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.tickets');
|
||||
stmt = new ParameterizedSQL(`
|
||||
CREATE TEMPORARY TABLE tmp.tickets
|
||||
CREATE TEMPORARY TABLE tmp.tickets
|
||||
(PRIMARY KEY (id))
|
||||
ENGINE = MEMORY
|
||||
SELECT f.*, r.risk AS debt
|
||||
|
@ -268,10 +274,10 @@ module.exports = Self => {
|
|||
stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.sale_getProblems');
|
||||
|
||||
stmt = new ParameterizedSQL(`
|
||||
CREATE TEMPORARY TABLE tmp.sale_getProblems
|
||||
CREATE TEMPORARY TABLE tmp.sale_getProblems
|
||||
(INDEX (ticketFk))
|
||||
ENGINE = MEMORY
|
||||
SELECT f.id ticketFk, f.clientFk, f.warehouseFk, f.shipped
|
||||
SELECT f.id ticketFk, f.clientFk, f.warehouseFk, f.shipped
|
||||
FROM tmp.filter f
|
||||
LEFT JOIN alertLevel al ON al.id = f.alertLevel
|
||||
WHERE (al.code = 'FREE' OR f.alertLevel IS NULL)
|
||||
|
@ -377,7 +383,7 @@ module.exports = Self => {
|
|||
const ticketsIndex = stmts.push(stmt) - 1;
|
||||
|
||||
stmts.push(
|
||||
`DROP TEMPORARY TABLE
|
||||
`DROP TEMPORARY TABLE
|
||||
tmp.filter,
|
||||
tmp.ticket_problems,
|
||||
tmp.sale_getProblems,
|
||||
|
|
|
@ -147,16 +147,12 @@ describe('SalesMonitor salesFilter()', () => {
|
|||
const options = {transaction: tx};
|
||||
|
||||
const ctx = {req: {accessToken: {userId: 9}}, args: {pending: false}};
|
||||
const filter = {};
|
||||
const filter = {order: 'alertLevel ASC'};
|
||||
const result = await models.SalesMonitor.salesFilter(ctx, filter, options);
|
||||
const firstRow = result[0];
|
||||
const secondRow = result[1];
|
||||
const thirdRow = result[2];
|
||||
|
||||
expect(result.length).toEqual(12);
|
||||
expect(firstRow.state).toEqual('Entregado');
|
||||
expect(secondRow.state).toEqual('Entregado');
|
||||
expect(thirdRow.state).toEqual('Entregado');
|
||||
expect(firstRow.alertLevel).not.toEqual(0);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('route updateWorkCenter()', () => {
|
||||
const routeId = 1;
|
||||
|
||||
it('should set the commission work center if the worker has workCenter', async() => {
|
||||
const tx = await models.Route.beginTransaction({});
|
||||
try {
|
||||
const developerId = 9;
|
||||
const ctx = {
|
||||
req: {
|
||||
accessToken: {userId: developerId}
|
||||
}
|
||||
};
|
||||
const options = {transaction: tx};
|
||||
|
||||
const expectedResult = 1;
|
||||
const updatedRoute = await models.Route.updateWorkCenter(ctx, routeId, options);
|
||||
|
||||
expect(updatedRoute.commissionWorkCenterFk).toEqual(expectedResult);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
|
||||
it(`shoul set the default commision work center if that worker didn't have one yet`, async() => {
|
||||
const tx = await models.Route.beginTransaction({});
|
||||
try {
|
||||
const userWithoutWorkCenter = 2;
|
||||
const ctx = {
|
||||
req: {
|
||||
accessToken: {userId: userWithoutWorkCenter}
|
||||
}
|
||||
};
|
||||
const options = {transaction: tx};
|
||||
|
||||
const expectedResult = 9;
|
||||
const updatedRoute = await models.Route.updateWorkCenter(ctx, routeId, options);
|
||||
|
||||
expect(updatedRoute.commissionWorkCenterFk).toEqual(expectedResult);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
});
|
|
@ -0,0 +1,54 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('updateWorkCenter', {
|
||||
description: 'Update the commission work center through user salix connected',
|
||||
accessType: 'WRITE',
|
||||
accepts: {
|
||||
arg: 'id',
|
||||
type: 'number',
|
||||
description: 'Route Id',
|
||||
http: {source: 'path'}
|
||||
},
|
||||
returns: {
|
||||
type: 'object',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/:id/updateWorkCenter`,
|
||||
verb: 'POST'
|
||||
}
|
||||
});
|
||||
|
||||
Self.updateWorkCenter = async(ctx, id, options) => {
|
||||
const models = Self.app.models;
|
||||
const myOptions = {};
|
||||
let tx;
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
if (!myOptions.transaction) {
|
||||
tx = await Self.beginTransaction({});
|
||||
myOptions.transaction = tx;
|
||||
}
|
||||
|
||||
try {
|
||||
const [result] = await Self.rawSql(`
|
||||
SELECT IFNULL(wl.workCenterFk, r.defaultWorkCenterFk) AS commissionWorkCenter
|
||||
FROM vn.routeConfig r
|
||||
LEFT JOIN vn.workerLabour wl ON wl.workerFk = ?
|
||||
AND CURDATE() BETWEEN wl.started AND IFNULL(wl.ended, CURDATE());
|
||||
`, [userId], myOptions);
|
||||
|
||||
const route = await models.Route.findById(id, null, myOptions);
|
||||
await route.updateAttribute('commissionWorkCenterFk', result.commissionWorkCenter, myOptions);
|
||||
|
||||
if (tx) await tx.commit();
|
||||
|
||||
return route;
|
||||
} catch (e) {
|
||||
if (tx) await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
};
|
|
@ -9,6 +9,7 @@ module.exports = Self => {
|
|||
require('../methods/route/clone')(Self);
|
||||
require('../methods/route/getSuggestedTickets')(Self);
|
||||
require('../methods/route/unlink')(Self);
|
||||
require('../methods/route/updateWorkCenter')(Self);
|
||||
|
||||
Self.validate('kmStart', validateDistance, {
|
||||
message: 'Distance must be lesser than 1000'
|
||||
|
|
|
@ -47,6 +47,9 @@
|
|||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"commissionWorkCenterFk": {
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
|
|
|
@ -4,7 +4,12 @@ import Section from 'salix/components/section';
|
|||
export default class Controller extends Section {
|
||||
onSubmit() {
|
||||
this.$.watcher.submit().then(
|
||||
res => this.$state.go('route.card.summary', {id: res.data.id})
|
||||
res => {
|
||||
this.$http.post(`Routes/${res.data.id}/updateWorkCenter`, null)
|
||||
.then(() => {
|
||||
this.$state.go('route.card.summary', {id: res.data.id});
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethod('getSummary', {
|
||||
description: 'Returns the shelving summary',
|
||||
accessType: 'READ',
|
||||
accepts: {
|
||||
arg: 'code',
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'The shelving code',
|
||||
http: {source: 'path'}
|
||||
},
|
||||
returns: {
|
||||
type: 'object',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/:code/getSummary`,
|
||||
verb: 'GET'
|
||||
}
|
||||
});
|
||||
Self.getSummary = async code => {
|
||||
let filter = {
|
||||
where: {code: code},
|
||||
fields: [
|
||||
'code',
|
||||
'parkingFk',
|
||||
'priority',
|
||||
'userFk',
|
||||
'isRecyclable'
|
||||
],
|
||||
include: [
|
||||
{
|
||||
relation: 'parking'
|
||||
},
|
||||
{
|
||||
relation: 'worker',
|
||||
scope: {
|
||||
fields: ['id', 'userFk'],
|
||||
include: {
|
||||
relation: 'user',
|
||||
scope: {
|
||||
fields: ['id', 'nickname']
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
return Self.app.models.Shelving.findOne(filter);
|
||||
};
|
||||
};
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"Parking": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"Shelving": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"ShelvingLog": {
|
||||
"dataSource": "vn"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
{
|
||||
"name": "Parking",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "parking"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "number",
|
||||
"id": true,
|
||||
"description": "Identifier"
|
||||
},
|
||||
"column": {
|
||||
"type": "string",
|
||||
"required": true
|
||||
},
|
||||
"row": {
|
||||
"type": "string",
|
||||
"required": true
|
||||
},
|
||||
"sectorFk": {
|
||||
"type": "number"
|
||||
},
|
||||
"code": {
|
||||
"type": "string"
|
||||
},
|
||||
"pickingOrder": {
|
||||
"type": "number"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
{
|
||||
"name": "ShelvingLog",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "shelvingLog"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"id": true,
|
||||
"type": "number",
|
||||
"forceId": false
|
||||
},
|
||||
"originFk": {
|
||||
"type": "number",
|
||||
"required": true
|
||||
},
|
||||
"userFk": {
|
||||
"type": "number"
|
||||
},
|
||||
"action": {
|
||||
"type": "string",
|
||||
"required": true
|
||||
},
|
||||
"changedModel": {
|
||||
"type": "string"
|
||||
},
|
||||
"oldInstance": {
|
||||
"type": "object"
|
||||
},
|
||||
"newInstance": {
|
||||
"type": "object"
|
||||
},
|
||||
"creationDate": {
|
||||
"type": "date"
|
||||
},
|
||||
"changedModelId": {
|
||||
"type": "number"
|
||||
},
|
||||
"changedModelValue": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"user": {
|
||||
"type": "belongsTo",
|
||||
"model": "Account",
|
||||
"foreignKey": "userFk"
|
||||
}
|
||||
},
|
||||
"scope": {
|
||||
"order": ["creationDate DESC", "id DESC"]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = Self => {
|
||||
require('../methods/shelving/getSummary')(Self);
|
||||
};
|
|
@ -0,0 +1,51 @@
|
|||
{
|
||||
"name": "Shelving",
|
||||
"base": "Loggable",
|
||||
"log": {
|
||||
"model": "ShelvingLog",
|
||||
"showField": "id"
|
||||
},
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "shelving"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "number",
|
||||
"id": true,
|
||||
"description": "Identifier"
|
||||
},
|
||||
"code": {
|
||||
"type": "string",
|
||||
"required": true
|
||||
},
|
||||
"parkingFk": {
|
||||
"type": "number"
|
||||
},
|
||||
"isPrinted": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"priority": {
|
||||
"type": "number"
|
||||
},
|
||||
"userFk": {
|
||||
"type": "number"
|
||||
},
|
||||
"isRecyclable": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"parking": {
|
||||
"type": "belongsTo",
|
||||
"model": "Parking",
|
||||
"foreignKey": "parkingFk"
|
||||
},
|
||||
"worker": {
|
||||
"type": "belongsTo",
|
||||
"model": "Worker",
|
||||
"foreignKey": "userFk"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
<mg-ajax path="Shelvings/{{patch.params.id}}" options="vnPatch"></mg-ajax>
|
||||
<vn-watcher
|
||||
vn-id="watcher"
|
||||
data="$ctrl.shelving"
|
||||
form="form"
|
||||
save="patch">
|
||||
</vn-watcher>
|
||||
<form name="form" ng-submit="watcher.submit()" class="vn-w-md">
|
||||
<vn-card class="vn-pa-lg">
|
||||
<vn-vertical>
|
||||
<vn-horizontal>
|
||||
<vn-textfield
|
||||
label="Code"
|
||||
ng-model="$ctrl.shelving.code"
|
||||
rule
|
||||
vn-focus>
|
||||
</vn-textfield>
|
||||
<vn-autocomplete
|
||||
vn-one
|
||||
url="Parkings"
|
||||
label="Parking"
|
||||
show-field="code"
|
||||
value-field="id"
|
||||
ng-model="$ctrl.shelving.parkingFk">
|
||||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-input-number vn-one
|
||||
label="Priority"
|
||||
ng-model="$ctrl.shelving.priority"
|
||||
rule>
|
||||
</vn-input-number>
|
||||
<vn-check
|
||||
label="Recyclable"
|
||||
ng-model="$ctrl.shelving.isRecyclable">
|
||||
</vn-check>
|
||||
</vn-horizontal>
|
||||
</vn-vertical>
|
||||
</vn-card>
|
||||
<vn-button-bar>
|
||||
<vn-submit
|
||||
disabled="!watcher.dataChanged()"
|
||||
label="Save">
|
||||
</vn-submit>
|
||||
<vn-button
|
||||
class="cancel"
|
||||
label="Undo changes"
|
||||
disabled="!watcher.dataChanged()"
|
||||
ng-click="watcher.loadOriginalData()">
|
||||
</vn-button>
|
||||
</vn-button-bar>
|
||||
</form>
|
|
@ -0,0 +1,10 @@
|
|||
import ngModule from '../module';
|
||||
import Section from 'salix/components/section';
|
||||
|
||||
ngModule.vnComponent('vnShelvingBasicData', {
|
||||
template: require('./index.html'),
|
||||
controller: Section,
|
||||
bindings: {
|
||||
shelving: '<'
|
||||
}
|
||||
});
|
|
@ -0,0 +1,8 @@
|
|||
<vn-portal slot="menu">
|
||||
<vn-shelving-descriptor
|
||||
shelving="$ctrl.shelving"
|
||||
on-change="$ctrl.reload()">
|
||||
</vn-shelving-descriptor>
|
||||
<vn-left-menu source="card"></vn-left-menu>
|
||||
</vn-portal>
|
||||
<ui-view></ui-view>
|
|
@ -0,0 +1,29 @@
|
|||
import ngModule from '../module';
|
||||
import ModuleCard from 'salix/components/module-card';
|
||||
|
||||
class Controller extends ModuleCard {
|
||||
reload() {
|
||||
const filter = {
|
||||
include: [
|
||||
{relation: 'worker',
|
||||
scope: {
|
||||
fields: ['userFk'],
|
||||
include: {
|
||||
relation: 'user',
|
||||
scope: {
|
||||
fields: ['nickname']
|
||||
}
|
||||
}
|
||||
}},
|
||||
{relation: 'parking'}
|
||||
]
|
||||
};
|
||||
this.$http.get(`Shelvings/${this.$params.id}`, {filter})
|
||||
.then(res => this.shelving = res.data);
|
||||
}
|
||||
}
|
||||
|
||||
ngModule.vnComponent('vnShelvingCard', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller
|
||||
});
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue