closes #4605 Create-Model-PackagingMistake #1247
|
@ -2,6 +2,7 @@ coverage
|
|||
node_modules
|
||||
dist
|
||||
storage
|
||||
.idea
|
||||
npm-debug.log
|
||||
.eslintcache
|
||||
datasources.*.json
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [2302.01] - 2023-01-12
|
||||
|
||||
### Added
|
||||
- [General](Inicio) Permite recuperar la contraseña
|
||||
- [Artículo](Datos Básicos) Añadido campo Unidades/Caja
|
||||
|
||||
### Changed
|
||||
|
||||
### Fixed
|
||||
- [General] Al utilizar el traductor de Google se descuadraban los iconos
|
||||
|
||||
### Removed
|
||||
- [Tickets](Control clientes) Eliminada sección
|
39
Dockerfile
39
Dockerfile
|
@ -1,32 +1,43 @@
|
|||
FROM debian:stretch-slim
|
||||
FROM debian:bullseye-slim
|
||||
ENV TZ Europe/Madrid
|
||||
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
# NodeJs
|
||||
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
curl \
|
||||
ca-certificates \
|
||||
gnupg2 \
|
||||
libfontconfig lftp \
|
||||
&& apt-get -y install xvfb gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 \
|
||||
libdbus-1-3 libexpat1 libfontconfig1 libgbm1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 \
|
||||
libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 \
|
||||
libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 \
|
||||
libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget \
|
||||
&& curl -sL https://deb.nodesource.com/setup_12.x | bash - \
|
||||
&& curl -fsSL https://deb.nodesource.com/setup_14.x | bash - \
|
||||
&& apt-get install -y --no-install-recommends nodejs \
|
||||
&& npm install -g npm@8.19.2
|
||||
|
||||
# Puppeteer
|
||||
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
nodejs \
|
||||
&& apt-get purge -y --auto-remove \
|
||||
gnupg2 \
|
||||
libfontconfig lftp xvfb gconf-service libasound2 libatk1.0-0 libc6 \
|
||||
libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgbm1 \
|
||||
libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 \
|
||||
libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 \
|
||||
libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 \
|
||||
libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 \
|
||||
fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& npm -g install pm2
|
||||
|
||||
# Salix
|
||||
|
||||
WORKDIR /salix
|
||||
|
||||
COPY print/package.json print/package-lock.json print/
|
||||
RUN npm --prefix ./print install --omit=dev ./print
|
||||
|
||||
COPY package.json package-lock.json ./
|
||||
COPY loopback/package.json loopback/
|
||||
COPY print/package.json print/
|
||||
RUN npm install --only=prod
|
||||
RUN npm --prefix ./print install --only=prod ./print
|
||||
RUN npm install --omit=dev
|
||||
|
||||
COPY loopback loopback
|
||||
COPY back back
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#!/usr/bin/env groovy
|
||||
|
||||
pipeline {
|
||||
agent any
|
||||
options {
|
||||
|
|
|
@ -0,0 +1,78 @@
|
|||
const UserError = require('vn-loopback/util/user-error');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('privileges', {
|
||||
description: 'Change role and hasGrant if user has privileges',
|
||||
accepts: [
|
||||
{
|
||||
arg: 'id',
|
||||
type: 'number',
|
||||
required: true,
|
||||
description: 'The user id',
|
||||
http: {source: 'path'}
|
||||
},
|
||||
{
|
||||
arg: 'roleFk',
|
||||
type: 'number',
|
||||
description: 'The new role for user',
|
||||
},
|
||||
{
|
||||
arg: 'hasGrant',
|
||||
type: 'boolean',
|
||||
description: 'Whether to has grant'
|
||||
}
|
||||
],
|
||||
http: {
|
||||
path: `/:id/privileges`,
|
||||
verb: 'POST'
|
||||
}
|
||||
});
|
||||
|
||||
Self.privileges = async function(ctx, id, roleFk, hasGrant, options) {
|
||||
if (!(hasGrant != null || roleFk)) return;
|
||||
|
||||
const models = Self.app.models;
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
|
||||
const myOptions = {};
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
const user = await models.Account.findById(userId, {fields: ['hasGrant']}, myOptions);
|
||||
|
||||
const userToUpdate = await models.Account.findById(id, {
|
||||
fields: ['id', 'name', 'hasGrant', 'roleFk', 'password'],
|
||||
include: {
|
||||
relation: 'role',
|
||||
scope: {
|
||||
fields: ['name']
|
||||
}
|
||||
}
|
||||
}, myOptions);
|
||||
|
||||
if (!user.hasGrant)
|
||||
throw new UserError(`You don't have grant privilege`);
|
||||
|
||||
const hasRoleFromUser = await models.Account.hasRole(userId, userToUpdate.role().name, myOptions);
|
||||
|
||||
if (!hasRoleFromUser)
|
||||
throw new UserError(`You don't own the role and you can't assign it to another user`);
|
||||
|
||||
if (hasGrant != null)
|
||||
userToUpdate.hasGrant = hasGrant;
|
||||
|
||||
if (roleFk) {
|
||||
const role = await models.Role.findById(roleFk, {fields: ['name']}, myOptions);
|
||||
const hasRole = await models.Account.hasRole(userId, role.name, myOptions);
|
||||
|
||||
if (!hasRole)
|
||||
throw new UserError(`You don't own the role and you can't assign it to another user`);
|
||||
|
||||
userToUpdate.roleFk = roleFk;
|
||||
}
|
||||
|
||||
await userToUpdate.save(userToUpdate);
|
||||
await models.UserAccount.sync(userToUpdate.name);
|
||||
};
|
||||
};
|
|
@ -0,0 +1,30 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethod('recoverPassword', {
|
||||
description: 'Send email to the user',
|
||||
accepts: [
|
||||
{
|
||||
arg: 'email',
|
||||
type: 'string',
|
||||
description: 'The email of user',
|
||||
required: true
|
||||
}
|
||||
],
|
||||
http: {
|
||||
path: `/recoverPassword`,
|
||||
verb: 'POST'
|
||||
}
|
||||
});
|
||||
|
||||
Self.recoverPassword = async function(email) {
|
||||
const models = Self.app.models;
|
||||
|
||||
try {
|
||||
await models.user.resetPassword({email, emailTemplate: 'recover-password'});
|
||||
} catch (err) {
|
||||
if (err.code === 'EMAIL_NOT_FOUND')
|
||||
return;
|
||||
else
|
||||
throw err;
|
||||
}
|
||||
};
|
||||
};
|
|
@ -0,0 +1,115 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('account privileges()', () => {
|
||||
const employeeId = 1;
|
||||
const developerId = 9;
|
||||
const sysadminId = 66;
|
||||
const itBossId = 104;
|
||||
const rootId = 100;
|
||||
const clarkKent = 1103;
|
||||
|
||||
it('should throw an error when user not has privileges', async() => {
|
||||
const ctx = {req: {accessToken: {userId: developerId}}};
|
||||
const tx = await models.Account.beginTransaction({});
|
||||
|
||||
let error;
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
await models.Account.privileges(ctx, employeeId, null, true, options);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
error = e;
|
||||
await tx.rollback();
|
||||
}
|
||||
|
||||
expect(error.message).toContain(`You don't have grant privilege`);
|
||||
});
|
||||
|
||||
it('should throw an error when user has privileges but not has the role', async() => {
|
||||
const ctx = {req: {accessToken: {userId: sysadminId}}};
|
||||
const tx = await models.Account.beginTransaction({});
|
||||
|
||||
let error;
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
await models.Account.privileges(ctx, employeeId, rootId, null, options);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
error = e;
|
||||
await tx.rollback();
|
||||
}
|
||||
|
||||
expect(error.message).toContain(`You don't own the role and you can't assign it to another user`);
|
||||
});
|
||||
|
||||
it('should throw an error when user has privileges but not has the role from user', async() => {
|
||||
const ctx = {req: {accessToken: {userId: sysadminId}}};
|
||||
const tx = await models.Account.beginTransaction({});
|
||||
|
||||
let error;
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
await models.Account.privileges(ctx, itBossId, developerId, null, options);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
error = e;
|
||||
await tx.rollback();
|
||||
}
|
||||
|
||||
expect(error.message).toContain(`You don't own the role and you can't assign it to another user`);
|
||||
});
|
||||
|
||||
it('should change role', async() => {
|
||||
const ctx = {req: {accessToken: {userId: sysadminId}}};
|
||||
const tx = await models.Account.beginTransaction({});
|
||||
|
||||
const options = {transaction: tx};
|
||||
const agency = await models.Role.findOne({
|
||||
where: {
|
||||
name: 'agency'
|
||||
}
|
||||
}, options);
|
||||
|
||||
let error;
|
||||
let result;
|
||||
try {
|
||||
await models.Account.privileges(ctx, clarkKent, agency.id, null, options);
|
||||
result = await models.Account.findById(clarkKent, null, options);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
error = e;
|
||||
await tx.rollback();
|
||||
}
|
||||
|
||||
expect(error).not.toBeDefined();
|
||||
expect(result.roleFk).toEqual(agency.id);
|
||||
});
|
||||
|
||||
it('should change hasGrant', async() => {
|
||||
const ctx = {req: {accessToken: {userId: sysadminId}}};
|
||||
const tx = await models.Account.beginTransaction({});
|
||||
|
||||
let error;
|
||||
let result;
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
await models.Account.privileges(ctx, clarkKent, null, true, options);
|
||||
result = await models.Account.findById(clarkKent, null, options);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
error = e;
|
||||
await tx.rollback();
|
||||
}
|
||||
|
||||
expect(error).not.toBeDefined();
|
||||
expect(result.hasGrant).toBeTruthy();
|
||||
});
|
||||
});
|
|
@ -1,6 +1,6 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
|
||||
describe('account changePassword()', () => {
|
||||
describe('account setPassword()', () => {
|
||||
it('should throw an error when password does not meet requirements', async() => {
|
||||
let req = app.models.Account.setPassword(1, 'insecurePass');
|
||||
|
||||
|
|
|
@ -29,8 +29,12 @@ module.exports = Self => {
|
|||
filter = mergeFilters(filter, {where});
|
||||
|
||||
const stmt = new ParameterizedSQL(
|
||||
`SELECT * FROM campaign`);
|
||||
`SELECT * FROM (`);
|
||||
stmt.merge('SELECT * FROM campaign');
|
||||
stmt.merge(conn.makeWhere(filter.where));
|
||||
stmt.merge('ORDER BY dated ASC');
|
||||
stmt.merge('LIMIT 10000000000000000000');
|
||||
stmt.merge(') sub');
|
||||
stmt.merge('GROUP BY code');
|
||||
stmt.merge(conn.makePagination(filter));
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ module.exports = Self => {
|
|||
let message = $t(`There's a new urgent ticket:`);
|
||||
const ostUri = 'https://cau.verdnatura.es/scp/tickets.php?id=';
|
||||
tickets.forEach(ticket => {
|
||||
message += `\r\n[ID: *${ticket.number}* - ${ticket.subject} (@${ticket.username})](${ostUri + ticket.id})`;
|
||||
message += `\r\n[ID: ${ticket.number} - ${ticket.subject} @${ticket.username}](${ostUri + ticket.id})`;
|
||||
});
|
||||
|
||||
const department = await models.Department.findOne({
|
||||
|
@ -42,7 +42,5 @@ module.exports = Self => {
|
|||
|
||||
if (channelName)
|
||||
return Self.send(ctx, `#${channelName}`, `@all ➔ ${message}`);
|
||||
|
||||
return;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -43,6 +43,9 @@ module.exports = Self => {
|
|||
if (!recipient)
|
||||
throw new Error(`Could not send message "${message}" to worker id ${recipientId} from user ${userId}`);
|
||||
|
||||
if (process.env.NODE_ENV == 'test')
|
||||
message = `[Test:Environment to user ${userId}] ` + message;
|
||||
|
||||
await models.Chat.create({
|
||||
senderFk: sender.id,
|
||||
recipient: `@${recipient.name}`,
|
||||
|
|
|
@ -27,7 +27,7 @@ describe('Chat notifyIssue()', () => {
|
|||
subject: 'Issue title'}
|
||||
]);
|
||||
// eslint-disable-next-line max-len
|
||||
const expectedMessage = `@all ➔ There's a new urgent ticket:\r\n[ID: *00001* - Issue title (@batman)](https://cau.verdnatura.es/scp/tickets.php?id=1)`;
|
||||
const expectedMessage = `@all ➔ There's a new urgent ticket:\r\n[ID: 00001 - Issue title @batman](https://cau.verdnatura.es/scp/tickets.php?id=1)`;
|
||||
|
||||
const department = await app.models.Department.findById(departmentId);
|
||||
let orgChatName = department.chatName;
|
||||
|
|
|
@ -26,11 +26,30 @@ module.exports = Self => {
|
|||
|
||||
Self.setSaleQuantity = async(saleId, quantity) => {
|
||||
const models = Self.app.models;
|
||||
const myOptions = {};
|
||||
let tx;
|
||||
|
||||
const sale = await models.Sale.findById(saleId);
|
||||
return await sale.updateAttributes({
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
if (!myOptions.transaction) {
|
||||
tx = await Self.beginTransaction({});
|
||||
myOptions.transaction = tx;
|
||||
}
|
||||
|
||||
try {
|
||||
const sale = await models.Sale.findById(saleId, null, myOptions);
|
||||
const saleUpdated = await sale.updateAttributes({
|
||||
originalQuantity: sale.quantity,
|
||||
quantity: quantity
|
||||
});
|
||||
}, myOptions);
|
||||
|
||||
if (tx) await tx.commit();
|
||||
|
||||
return saleUpdated;
|
||||
} catch (e) {
|
||||
if (tx) await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
|
@ -2,15 +2,26 @@ const models = require('vn-loopback/server/server').models;
|
|||
|
||||
describe('setSaleQuantity()', () => {
|
||||
it('should change quantity sale', async() => {
|
||||
const tx = await models.Ticket.beginTransaction({});
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const saleId = 30;
|
||||
const newQuantity = 10;
|
||||
|
||||
const originalSale = await models.Sale.findById(saleId);
|
||||
const originalSale = await models.Sale.findById(saleId, null, options);
|
||||
|
||||
await models.Collection.setSaleQuantity(saleId, newQuantity);
|
||||
const updateSale = await models.Sale.findById(saleId);
|
||||
await models.Collection.setSaleQuantity(saleId, newQuantity, options);
|
||||
const updateSale = await models.Sale.findById(saleId, null, options);
|
||||
|
||||
expect(updateSale.originalQuantity).toEqual(originalSale.quantity);
|
||||
expect(updateSale.quantity).toEqual(newQuantity);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -17,16 +17,11 @@ module.exports = Self => {
|
|||
});
|
||||
|
||||
Self.deleteTrashFiles = async options => {
|
||||
const tx = await Self.beginTransaction({});
|
||||
const myOptions = {};
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
if (!myOptions.transaction)
|
||||
myOptions.transaction = tx;
|
||||
|
||||
try {
|
||||
if (process.env.NODE_ENV == 'test')
|
||||
throw new UserError(`Action not allowed on the test environment`);
|
||||
|
||||
|
@ -52,25 +47,22 @@ module.exports = Self => {
|
|||
for (let dms of dmsToDelete) {
|
||||
const pathHash = DmsContainer.getHash(dms.id);
|
||||
const dmsContainer = await DmsContainer.container(pathHash);
|
||||
const dstFile = path.join(dmsContainer.client.root, pathHash, dms.file);
|
||||
try {
|
||||
const dstFile = path.join(dmsContainer.client.root, pathHash, dms.file);
|
||||
await fs.unlink(dstFile);
|
||||
} catch (err) {
|
||||
continue;
|
||||
if (err.code != 'ENOENT' && dms.file)
|
||||
throw err;
|
||||
}
|
||||
|
||||
await dms.destroy(myOptions);
|
||||
|
||||
const dstFolder = path.join(dmsContainer.client.root, pathHash);
|
||||
try {
|
||||
await fs.rmdir(dstFolder);
|
||||
await dms.destroy(myOptions);
|
||||
} catch (err) {
|
||||
await dms.destroy(myOptions);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (tx) await tx.commit();
|
||||
} catch (e) {
|
||||
if (tx) await tx.rollback();
|
||||
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
|
@ -0,0 +1,215 @@
|
|||
const md5 = require('md5');
|
||||
const fs = require('fs-extra');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('saveSign', {
|
||||
description: 'Save sign',
|
||||
accessType: 'WRITE',
|
||||
accepts:
|
||||
[
|
||||
{
|
||||
arg: 'signContent',
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'The sign content'
|
||||
}, {
|
||||
arg: 'tickets',
|
||||
type: ['number'],
|
||||
required: true,
|
||||
description: 'The tickets'
|
||||
}, {
|
||||
arg: 'signedTime',
|
||||
type: 'date',
|
||||
description: 'The signed time'
|
||||
}, {
|
||||
arg: 'addressFk',
|
||||
type: 'number',
|
||||
required: true,
|
||||
description: 'The address fk'
|
||||
}
|
||||
],
|
||||
returns: {
|
||||
type: 'Object',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/saveSign`,
|
||||
verb: 'POST'
|
||||
}
|
||||
});
|
||||
|
||||
async function createGestDoc(ticketId, userFk) {
|
||||
const models = Self.app.models;
|
||||
if (!await gestDocExists(ticketId)) {
|
||||
const result = await models.Ticket.findOne({
|
||||
where: {
|
||||
id: ticketId
|
||||
},
|
||||
include: [
|
||||
{
|
||||
relation: 'warehouse',
|
||||
scope: {
|
||||
fields: ['id']
|
||||
}
|
||||
}, {
|
||||
relation: 'client',
|
||||
scope: {
|
||||
fields: ['name']
|
||||
}
|
||||
}, {
|
||||
relation: 'route',
|
||||
scope: {
|
||||
fields: ['id']
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
const warehouseFk = result.warehouseFk;
|
||||
const companyFk = result.companyFk;
|
||||
const client = result.client.name;
|
||||
const route = result.route.id;
|
||||
|
||||
const resultDmsType = await models.DmsType.findOne({
|
||||
where: {
|
||||
code: 'Ticket'
|
||||
}
|
||||
});
|
||||
|
||||
const resultDms = await models.Dms.create({
|
||||
dmsTypeFk: resultDmsType.id,
|
||||
reference: ticketId,
|
||||
description: `Ticket ${ticketId} Cliente ${client} Ruta ${route}`,
|
||||
companyFk: companyFk,
|
||||
warehouseFk: warehouseFk,
|
||||
workerFk: userFk
|
||||
});
|
||||
|
||||
return resultDms.insertId;
|
||||
}
|
||||
}
|
||||
|
||||
async function gestDocExists(ticket) {
|
||||
const models = Self.app.models;
|
||||
const result = await models.TicketDms.findOne({
|
||||
where: {
|
||||
ticketFk: ticket
|
||||
},
|
||||
fields: ['dmsFk']
|
||||
});
|
||||
|
||||
if (result == null)
|
||||
return false;
|
||||
|
||||
const isSigned = await models.Ticket.findOne({
|
||||
where: {
|
||||
id: ticket
|
||||
},
|
||||
fields: ['isSigned']
|
||||
});
|
||||
|
||||
if (isSigned)
|
||||
return true;
|
||||
else
|
||||
await models.Dms.destroyById(ticket);
|
||||
}
|
||||
|
||||
async function dmsRecover(ticket, signContent) {
|
||||
const models = Self.app.models;
|
||||
await models.DmsRecover.create({
|
||||
ticketFk: ticket,
|
||||
sign: signContent
|
||||
});
|
||||
}
|
||||
|
||||
async function ticketGestdoc(ticket, dmsFk) {
|
||||
const models = Self.app.models;
|
||||
models.TicketDms.replaceOrCreate({
|
||||
ticketFk: ticket,
|
||||
dmsFk: dmsFk
|
||||
});
|
||||
|
||||
const queryVnTicketSetState = `CALL vn.ticket_setState(?, ?)`;
|
||||
|
||||
await Self.rawSql(queryVnTicketSetState, [ticket, 'DELIVERED']);
|
||||
}
|
||||
|
||||
async function updateGestdoc(file, ticket) {
|
||||
const models = Self.app.models;
|
||||
models.Dms.updateOne({
|
||||
where: {
|
||||
id: ticket
|
||||
},
|
||||
file: file,
|
||||
contentType: 'image/png'
|
||||
});
|
||||
}
|
||||
|
||||
Self.saveSign = async(ctx, signContent, tickets, signedTime) => {
|
||||
const models = Self.app.models;
|
||||
let tx = await Self.beginTransaction({});
|
||||
try {
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
|
||||
const dmsDir = `storage/dms`;
|
||||
|
||||
let image = null;
|
||||
|
||||
for (let i = 0; i < tickets.length; i++) {
|
||||
const alertLevel = await models.TicketState.findOne({
|
||||
where: {
|
||||
ticketFk: tickets[i]
|
||||
},
|
||||
fields: ['alertLevel']
|
||||
});
|
||||
|
||||
signedTime ? signedTime != undefined : signedTime = new Date();
|
||||
|
||||
if (alertLevel >= 2) {
|
||||
let dir;
|
||||
let id = null;
|
||||
let fileName = null;
|
||||
|
||||
if (!await gestDocExists(tickets[i])) {
|
||||
id = await createGestDoc(tickets[i], userId);
|
||||
|
||||
const hashDir = md5(id).substring(0, 3);
|
||||
dir = `${dmsDir}/${hashDir}`;
|
||||
|
||||
if (!fs.existsSync(dir))
|
||||
fs.mkdirSync(dir);
|
||||
|
||||
fileName = `${id}.png`;
|
||||
image = `${dir}/${fileName}`;
|
||||
} else
|
||||
|
||||
if (image != null) {
|
||||
if (!fs.existsSync(dir))
|
||||
dmsRecover(tickets[i], signContent);
|
||||
else {
|
||||
fs.writeFile(image, signContent, 'base64', async function(err) {
|
||||
if (err) {
|
||||
await tx.rollback();
|
||||
return err.message;
|
||||
}
|
||||
});
|
||||
}
|
||||
} else
|
||||
dmsRecover(tickets[i], signContent);
|
||||
|
||||
if (id != null && fileName.length > 0) {
|
||||
ticketGestdoc(tickets[i], id);
|
||||
updateGestdoc(id, fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (tx) await tx.commit();
|
||||
|
||||
return 'OK';
|
||||
} catch (err) {
|
||||
await tx.rollback();
|
||||
throw err.message;
|
||||
}
|
||||
};
|
||||
};
|
|
@ -0,0 +1,49 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethod('clean', {
|
||||
description: 'clean notifications from queue',
|
||||
accessType: 'WRITE',
|
||||
returns: {
|
||||
type: 'object',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/clean`,
|
||||
verb: 'POST'
|
||||
}
|
||||
});
|
||||
|
||||
Self.clean = async options => {
|
||||
const models = Self.app.models;
|
||||
const status = ['sent', 'error'];
|
||||
|
||||
const myOptions = {};
|
||||
let tx;
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
if (!myOptions.transaction) {
|
||||
tx = await Self.beginTransaction({});
|
||||
myOptions.transaction = tx;
|
||||
}
|
||||
|
||||
try {
|
||||
const config = await models.NotificationConfig.findOne({}, myOptions);
|
||||
|
||||
if (!config.cleanDays) return;
|
||||
|
||||
const cleanDate = new Date();
|
||||
cleanDate.setDate(cleanDate.getDate() - config.cleanDays);
|
||||
|
||||
await models.NotificationQueue.destroyAll({
|
||||
where: {status: {inq: status}},
|
||||
created: {lt: cleanDate}
|
||||
}, myOptions);
|
||||
} catch (e) {
|
||||
if (tx) await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
|
||||
if (tx) await tx.commit();
|
||||
};
|
||||
};
|
|
@ -0,0 +1,83 @@
|
|||
const {Email} = require('vn-print');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethod('send', {
|
||||
description: 'Send notifications from queue',
|
||||
accessType: 'WRITE',
|
||||
returns: {
|
||||
type: 'object',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/send`,
|
||||
verb: 'POST'
|
||||
}
|
||||
});
|
||||
|
||||
Self.send = async options => {
|
||||
const models = Self.app.models;
|
||||
const findStatus = 'pending';
|
||||
|
||||
const myOptions = {};
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
const notificationQueue = await models.NotificationQueue.find({
|
||||
where: {status: findStatus},
|
||||
include: [
|
||||
{
|
||||
relation: 'notification',
|
||||
scope: {
|
||||
include: {
|
||||
relation: 'subscription',
|
||||
scope: {
|
||||
include: {
|
||||
relation: 'user',
|
||||
scope: {
|
||||
fields: ['name', 'lang'],
|
||||
include: {
|
||||
relation: 'emailUser'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
]
|
||||
}, myOptions);
|
||||
|
||||
const statusSent = 'sent';
|
||||
const statusError = 'error';
|
||||
|
||||
for (const queue of notificationQueue) {
|
||||
const queueName = queue.notification().name;
|
||||
const queueParams = JSON.parse(queue.params);
|
||||
|
||||
for (const notificationUser of queue.notification().subscription()) {
|
||||
try {
|
||||
const sendParams = {
|
||||
recipient: notificationUser.user().emailUser().email,
|
||||
lang: notificationUser.user().lang
|
||||
};
|
||||
|
||||
if (notificationUser.userFk == queue.authorFk) {
|
||||
await queue.updateAttribute('status', statusSent);
|
||||
continue;
|
||||
}
|
||||
|
||||
const newParams = Object.assign({}, queueParams, sendParams);
|
||||
const email = new Email(queueName, newParams);
|
||||
|
||||
if (process.env.NODE_ENV != 'test')
|
||||
await email.send();
|
||||
|
||||
await queue.updateAttribute('status', statusSent);
|
||||
} catch (error) {
|
||||
await queue.updateAttribute('status', statusError);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
|
@ -0,0 +1,42 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('Notification Clean()', () => {
|
||||
it('should delete old rows with error', async() => {
|
||||
const userId = 9;
|
||||
const status = 'error';
|
||||
const tx = await models.NotificationQueue.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
|
||||
const notification = await models.Notification.findOne({}, options);
|
||||
const notificationConfig = await models.NotificationConfig.findOne({});
|
||||
|
||||
const cleanDate = new Date();
|
||||
cleanDate.setDate(cleanDate.getDate() - (notificationConfig.cleanDays + 1));
|
||||
|
||||
let before;
|
||||
let after;
|
||||
|
||||
try {
|
||||
const notificationDelete = await models.NotificationQueue.create({
|
||||
notificationFk: notification.name,
|
||||
authorFk: userId,
|
||||
status: status,
|
||||
created: cleanDate
|
||||
}, options);
|
||||
|
||||
before = await models.NotificationQueue.findById(notificationDelete.id, null, options);
|
||||
|
||||
await models.Notification.clean(options);
|
||||
|
||||
after = await models.NotificationQueue.findById(notificationDelete.id, null, options);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
|
||||
expect(before.notificationFk).toEqual(notification.name);
|
||||
expect(after).toBe(null);
|
||||
});
|
||||
});
|
|
@ -0,0 +1,33 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('Notification Send()', () => {
|
||||
it('should send notification', async() => {
|
||||
const statusPending = 'pending';
|
||||
const tx = await models.NotificationQueue.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
const filter = {
|
||||
where: {
|
||||
status: statusPending
|
||||
}
|
||||
};
|
||||
|
||||
let before;
|
||||
let after;
|
||||
|
||||
try {
|
||||
before = await models.NotificationQueue.find(filter, options);
|
||||
|
||||
await models.Notification.send(options);
|
||||
|
||||
after = await models.NotificationQueue.find(filter, options);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
|
||||
expect(before.length).toEqual(3);
|
||||
expect(after.length).toEqual(0);
|
||||
});
|
||||
});
|
|
@ -1,12 +1,13 @@
|
|||
const jsdom = require('jsdom');
|
||||
const mysql = require('mysql');
|
||||
const FormData = require('form-data');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('closeTicket', {
|
||||
description: 'Close tickets without response from the user',
|
||||
accessType: 'READ',
|
||||
returns: {
|
||||
type: 'Object',
|
||||
type: 'object',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
|
@ -54,9 +55,9 @@ module.exports = Self => {
|
|||
});
|
||||
});
|
||||
|
||||
await requestToken();
|
||||
await getRequestToken();
|
||||
|
||||
async function requestToken() {
|
||||
async function getRequestToken() {
|
||||
const response = await fetch(ostUri);
|
||||
|
||||
const result = response.headers.get('set-cookie');
|
||||
|
@ -93,24 +94,45 @@ module.exports = Self => {
|
|||
await close(token, secondCookie);
|
||||
}
|
||||
|
||||
async function close(token, secondCookie) {
|
||||
for (const ticketId of ticketsId) {
|
||||
const ostUri = `${config.host}/ajax.php/tickets/${ticketId}/status`;
|
||||
const data = {
|
||||
status_id: config.newStatusId,
|
||||
comments: config.comment,
|
||||
undefined: config.action
|
||||
};
|
||||
async function getLockCode(token, secondCookie, ticketId) {
|
||||
const ostUri = `${config.host}/ajax.php/lock/ticket/${ticketId}`;
|
||||
const params = {
|
||||
method: 'POST',
|
||||
body: new URLSearchParams(data),
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
'X-CSRFToken': token,
|
||||
'Cookie': secondCookie
|
||||
}
|
||||
};
|
||||
const response = await fetch(ostUri, params);
|
||||
const body = await response.text();
|
||||
const json = JSON.parse(body);
|
||||
|
||||
return json.code;
|
||||
}
|
||||
|
||||
async function close(token, secondCookie) {
|
||||
for (const ticketId of ticketsId) {
|
||||
const lockCode = await getLockCode(token, secondCookie, ticketId);
|
||||
let form = new FormData();
|
||||
form.append('__CSRFToken__', token);
|
||||
form.append('id', ticketId);
|
||||
form.append('a', config.responseType);
|
||||
form.append('lockCode', lockCode);
|
||||
form.append('from_email_id', config.fromEmailId);
|
||||
form.append('reply-to', config.replyTo);
|
||||
form.append('cannedResp', 0);
|
||||
form.append('response', config.comment);
|
||||
form.append('signature', 'none');
|
||||
form.append('reply_status_id', config.newStatusId);
|
||||
|
||||
const ostUri = `${config.host}/tickets.php?id=${ticketId}`;
|
||||
const params = {
|
||||
method: 'POST',
|
||||
body: form,
|
||||
headers: {
|
||||
'Cookie': secondCookie
|
||||
}
|
||||
};
|
||||
return fetch(ostUri, params);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,11 +19,11 @@ describe('getStarredModules()', () => {
|
|||
});
|
||||
|
||||
it(`should return the starred modules for a given user`, async() => {
|
||||
const newStarred = await app.models.StarredModule.create({workerFk: 9, moduleFk: 'Clients', position: 1});
|
||||
const newStarred = await app.models.StarredModule.create({workerFk: 9, moduleFk: 'customer', position: 1});
|
||||
const starredModules = await app.models.StarredModule.getStarredModules(ctx);
|
||||
|
||||
expect(starredModules.length).toEqual(1);
|
||||
expect(starredModules[0].moduleFk).toEqual('Clients');
|
||||
expect(starredModules[0].moduleFk).toEqual('customer');
|
||||
|
||||
// restores
|
||||
await app.models.StarredModule.destroyById(newStarred.id);
|
||||
|
|
|
@ -26,29 +26,29 @@ describe('setPosition()', () => {
|
|||
const filter = {
|
||||
where: {
|
||||
workerFk: ctx.req.accessToken.userId,
|
||||
moduleFk: 'Orders'
|
||||
moduleFk: 'order'
|
||||
}
|
||||
};
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
await app.models.StarredModule.toggleStarredModule(ctx, 'Orders', options);
|
||||
await app.models.StarredModule.toggleStarredModule(ctx, 'Clients', options);
|
||||
await app.models.StarredModule.toggleStarredModule(ctx, 'order', options);
|
||||
await app.models.StarredModule.toggleStarredModule(ctx, 'customer', options);
|
||||
|
||||
let orders = await app.models.StarredModule.findOne(filter, options);
|
||||
|
||||
filter.where.moduleFk = 'Clients';
|
||||
filter.where.moduleFk = 'customer';
|
||||
let clients = await app.models.StarredModule.findOne(filter, options);
|
||||
|
||||
expect(orders.position).toEqual(1);
|
||||
expect(clients.position).toEqual(2);
|
||||
|
||||
await app.models.StarredModule.setPosition(ctx, 'Clients', 'left', options);
|
||||
await app.models.StarredModule.setPosition(ctx, 'customer', 'left', options);
|
||||
|
||||
filter.where.moduleFk = 'Clients';
|
||||
filter.where.moduleFk = 'customer';
|
||||
clients = await app.models.StarredModule.findOne(filter, options);
|
||||
|
||||
filter.where.moduleFk = 'Orders';
|
||||
filter.where.moduleFk = 'order';
|
||||
orders = await app.models.StarredModule.findOne(filter, options);
|
||||
|
||||
expect(clients.position).toEqual(1);
|
||||
|
@ -67,29 +67,29 @@ describe('setPosition()', () => {
|
|||
const filter = {
|
||||
where: {
|
||||
workerFk: ctx.req.accessToken.userId,
|
||||
moduleFk: 'Orders'
|
||||
moduleFk: 'order'
|
||||
}
|
||||
};
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
await app.models.StarredModule.toggleStarredModule(ctx, 'Orders', options);
|
||||
await app.models.StarredModule.toggleStarredModule(ctx, 'Clients', options);
|
||||
await app.models.StarredModule.toggleStarredModule(ctx, 'order', options);
|
||||
await app.models.StarredModule.toggleStarredModule(ctx, 'customer', options);
|
||||
|
||||
let orders = await app.models.StarredModule.findOne(filter, options);
|
||||
|
||||
filter.where.moduleFk = 'Clients';
|
||||
filter.where.moduleFk = 'customer';
|
||||
let clients = await app.models.StarredModule.findOne(filter, options);
|
||||
|
||||
expect(orders.position).toEqual(1);
|
||||
expect(clients.position).toEqual(2);
|
||||
|
||||
await app.models.StarredModule.setPosition(ctx, 'Orders', 'right', options);
|
||||
await app.models.StarredModule.setPosition(ctx, 'order', 'right', options);
|
||||
|
||||
filter.where.moduleFk = 'Orders';
|
||||
filter.where.moduleFk = 'order';
|
||||
orders = await app.models.StarredModule.findOne(filter, options);
|
||||
|
||||
filter.where.moduleFk = 'Clients';
|
||||
filter.where.moduleFk = 'customer';
|
||||
clients = await app.models.StarredModule.findOne(filter, options);
|
||||
|
||||
expect(orders.position).toEqual(2);
|
||||
|
@ -108,35 +108,35 @@ describe('setPosition()', () => {
|
|||
const filter = {
|
||||
where: {
|
||||
workerFk: ctx.req.accessToken.userId,
|
||||
moduleFk: 'Items'
|
||||
moduleFk: 'item'
|
||||
}
|
||||
};
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
await app.models.StarredModule.toggleStarredModule(ctx, 'Clients', options);
|
||||
await app.models.StarredModule.toggleStarredModule(ctx, 'Orders', options);
|
||||
await app.models.StarredModule.toggleStarredModule(ctx, 'Clients', options);
|
||||
await app.models.StarredModule.toggleStarredModule(ctx, 'Orders', options);
|
||||
await app.models.StarredModule.toggleStarredModule(ctx, 'Items', options);
|
||||
await app.models.StarredModule.toggleStarredModule(ctx, 'Claims', options);
|
||||
await app.models.StarredModule.toggleStarredModule(ctx, 'Clients', options);
|
||||
await app.models.StarredModule.toggleStarredModule(ctx, 'Orders', options);
|
||||
await app.models.StarredModule.toggleStarredModule(ctx, 'Zones', options);
|
||||
await app.models.StarredModule.toggleStarredModule(ctx, 'customer', options);
|
||||
await app.models.StarredModule.toggleStarredModule(ctx, 'order', options);
|
||||
await app.models.StarredModule.toggleStarredModule(ctx, 'customer', options);
|
||||
await app.models.StarredModule.toggleStarredModule(ctx, 'order', options);
|
||||
await app.models.StarredModule.toggleStarredModule(ctx, 'item', options);
|
||||
await app.models.StarredModule.toggleStarredModule(ctx, 'claim', options);
|
||||
await app.models.StarredModule.toggleStarredModule(ctx, 'customer', options);
|
||||
await app.models.StarredModule.toggleStarredModule(ctx, 'order', options);
|
||||
await app.models.StarredModule.toggleStarredModule(ctx, 'zone', options);
|
||||
|
||||
const items = await app.models.StarredModule.findOne(filter, options);
|
||||
|
||||
filter.where.moduleFk = 'Claims';
|
||||
filter.where.moduleFk = 'claim';
|
||||
const claims = await app.models.StarredModule.findOne(filter, options);
|
||||
|
||||
filter.where.moduleFk = 'Clients';
|
||||
filter.where.moduleFk = 'customer';
|
||||
let clients = await app.models.StarredModule.findOne(filter, options);
|
||||
|
||||
filter.where.moduleFk = 'Orders';
|
||||
filter.where.moduleFk = 'order';
|
||||
let orders = await app.models.StarredModule.findOne(filter, options);
|
||||
|
||||
filter.where.moduleFk = 'Zones';
|
||||
filter.where.moduleFk = 'zone';
|
||||
const zones = await app.models.StarredModule.findOne(filter, options);
|
||||
|
||||
expect(items.position).toEqual(1);
|
||||
|
@ -145,12 +145,12 @@ describe('setPosition()', () => {
|
|||
expect(orders.position).toEqual(4);
|
||||
expect(zones.position).toEqual(5);
|
||||
|
||||
await app.models.StarredModule.setPosition(ctx, 'Clients', 'right', options);
|
||||
await app.models.StarredModule.setPosition(ctx, 'customer', 'right', options);
|
||||
|
||||
filter.where.moduleFk = 'Orders';
|
||||
filter.where.moduleFk = 'order';
|
||||
orders = await app.models.StarredModule.findOne(filter, options);
|
||||
|
||||
filter.where.moduleFk = 'Clients';
|
||||
filter.where.moduleFk = 'customer';
|
||||
clients = await app.models.StarredModule.findOne(filter, options);
|
||||
|
||||
expect(orders.position).toEqual(3);
|
||||
|
@ -169,31 +169,31 @@ describe('setPosition()', () => {
|
|||
const filter = {
|
||||
where: {
|
||||
workerFk: ctx.req.accessToken.userId,
|
||||
moduleFk: 'Items'
|
||||
moduleFk: 'item'
|
||||
}
|
||||
};
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
await app.models.StarredModule.toggleStarredModule(ctx, 'Items', options);
|
||||
await app.models.StarredModule.toggleStarredModule(ctx, 'Clients', options);
|
||||
await app.models.StarredModule.toggleStarredModule(ctx, 'Claims', options);
|
||||
await app.models.StarredModule.toggleStarredModule(ctx, 'Orders', options);
|
||||
await app.models.StarredModule.toggleStarredModule(ctx, 'Zones', options);
|
||||
await app.models.StarredModule.toggleStarredModule(ctx, 'item', options);
|
||||
await app.models.StarredModule.toggleStarredModule(ctx, 'customer', options);
|
||||
await app.models.StarredModule.toggleStarredModule(ctx, 'claim', options);
|
||||
await app.models.StarredModule.toggleStarredModule(ctx, 'order', options);
|
||||
await app.models.StarredModule.toggleStarredModule(ctx, 'zone', options);
|
||||
|
||||
const items = await app.models.StarredModule.findOne(filter, options);
|
||||
|
||||
filter.where.moduleFk = 'Clients';
|
||||
filter.where.moduleFk = 'customer';
|
||||
let clients = await app.models.StarredModule.findOne(filter, options);
|
||||
|
||||
filter.where.moduleFk = 'Claims';
|
||||
filter.where.moduleFk = 'claim';
|
||||
const claims = await app.models.StarredModule.findOne(filter, options);
|
||||
|
||||
filter.where.moduleFk = 'Orders';
|
||||
filter.where.moduleFk = 'order';
|
||||
let orders = await app.models.StarredModule.findOne(filter, options);
|
||||
|
||||
filter.where.moduleFk = 'Zones';
|
||||
filter.where.moduleFk = 'zone';
|
||||
const zones = await app.models.StarredModule.findOne(filter, options);
|
||||
|
||||
expect(items.position).toEqual(1);
|
||||
|
@ -202,13 +202,13 @@ describe('setPosition()', () => {
|
|||
expect(orders.position).toEqual(4);
|
||||
expect(zones.position).toEqual(5);
|
||||
|
||||
await app.models.StarredModule.toggleStarredModule(ctx, 'Claims', options);
|
||||
await app.models.StarredModule.setPosition(ctx, 'Clients', 'right', options);
|
||||
await app.models.StarredModule.toggleStarredModule(ctx, 'claim', options);
|
||||
await app.models.StarredModule.setPosition(ctx, 'customer', 'right', options);
|
||||
|
||||
filter.where.moduleFk = 'Clients';
|
||||
filter.where.moduleFk = 'customer';
|
||||
clients = await app.models.StarredModule.findOne(filter, options);
|
||||
|
||||
filter.where.moduleFk = 'Orders';
|
||||
filter.where.moduleFk = 'order';
|
||||
orders = await app.models.StarredModule.findOne(filter, options);
|
||||
|
||||
expect(orders.position).toEqual(2);
|
||||
|
|
|
@ -21,15 +21,15 @@ describe('toggleStarredModule()', () => {
|
|||
});
|
||||
|
||||
it('should create a new starred module and then remove it by calling the method again with same args', async() => {
|
||||
const starredModule = await app.models.StarredModule.toggleStarredModule(ctx, 'Orders');
|
||||
const starredModule = await app.models.StarredModule.toggleStarredModule(ctx, 'order');
|
||||
let starredModules = await app.models.StarredModule.getStarredModules(ctx);
|
||||
|
||||
expect(starredModules.length).toEqual(1);
|
||||
expect(starredModule.moduleFk).toEqual('Orders');
|
||||
expect(starredModule.moduleFk).toEqual('order');
|
||||
expect(starredModule.workerFk).toEqual(activeCtx.accessToken.userId);
|
||||
expect(starredModule.position).toEqual(starredModules.length);
|
||||
|
||||
await app.models.StarredModule.toggleStarredModule(ctx, 'Orders');
|
||||
await app.models.StarredModule.toggleStarredModule(ctx, 'order');
|
||||
starredModules = await app.models.StarredModule.getStarredModules(ctx);
|
||||
|
||||
expect(starredModules.length).toEqual(0);
|
||||
|
|
|
@ -77,6 +77,21 @@
|
|||
"Module": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"Notification": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"NotificationAcl": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"NotificationConfig": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"NotificationQueue": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"NotificationSubscription": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"Province": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
|
@ -101,6 +116,9 @@
|
|||
"Town": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"Url": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"UserConfig": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
/* eslint max-len: ["error", { "code": 150 }]*/
|
||||
const md5 = require('md5');
|
||||
const LoopBackContext = require('loopback-context');
|
||||
const {Email} = require('vn-print');
|
||||
|
||||
module.exports = Self => {
|
||||
require('../methods/account/login')(Self);
|
||||
|
@ -6,7 +9,9 @@ module.exports = Self => {
|
|||
require('../methods/account/acl')(Self);
|
||||
require('../methods/account/change-password')(Self);
|
||||
require('../methods/account/set-password')(Self);
|
||||
require('../methods/account/recover-password')(Self);
|
||||
require('../methods/account/validate-token')(Self);
|
||||
require('../methods/account/privileges')(Self);
|
||||
|
||||
// Validations
|
||||
|
||||
|
@ -26,17 +31,62 @@ module.exports = Self => {
|
|||
ctx.data.password = md5(ctx.data.password);
|
||||
});
|
||||
|
||||
Self.afterRemote('prototype.patchAttributes', async(ctx, instance) => {
|
||||
if (!ctx.args || !ctx.args.data.email) return;
|
||||
const models = Self.app.models;
|
||||
|
||||
const loopBackContext = LoopBackContext.getCurrentContext();
|
||||
const httpCtx = {req: loopBackContext.active};
|
||||
const httpRequest = httpCtx.req.http.req;
|
||||
const headers = httpRequest.headers;
|
||||
const origin = headers.origin;
|
||||
const url = origin.split(':');
|
||||
|
||||
const userId = ctx.instance.id;
|
||||
const user = await models.user.findById(userId);
|
||||
|
||||
class Mailer {
|
||||
async send(verifyOptions, cb) {
|
||||
const params = {
|
||||
url: verifyOptions.verifyHref,
|
||||
recipient: verifyOptions.to,
|
||||
lang: ctx.req.getLocale()
|
||||
};
|
||||
|
||||
const email = new Email('email-verify', params);
|
||||
email.send();
|
||||
|
||||
cb(null, verifyOptions.to);
|
||||
}
|
||||
}
|
||||
|
||||
const options = {
|
||||
type: 'email',
|
||||
to: instance.email,
|
||||
from: {},
|
||||
redirect: `${origin}/#!/account/${instance.id}/basic-data?emailConfirmed`,
|
||||
template: false,
|
||||
mailer: new Mailer,
|
||||
host: url[1].split('/')[2],
|
||||
port: url[2],
|
||||
protocol: url[0],
|
||||
user: Self
|
||||
};
|
||||
|
||||
await user.verify(options);
|
||||
});
|
||||
|
||||
Self.remoteMethod('getCurrentUserData', {
|
||||
description: 'Gets the current user data',
|
||||
accepts: [
|
||||
{
|
||||
arg: 'ctx',
|
||||
type: 'Object',
|
||||
type: 'object',
|
||||
http: {source: 'context'}
|
||||
}
|
||||
],
|
||||
returns: {
|
||||
type: 'Object',
|
||||
type: 'object',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
|
@ -57,7 +107,7 @@ module.exports = Self => {
|
|||
*
|
||||
* @param {Integer} userId The user id
|
||||
* @param {String} name The role name
|
||||
* @param {Object} options Options
|
||||
* @param {object} options Options
|
||||
* @return {Boolean} %true if user has the role, %false otherwise
|
||||
*/
|
||||
Self.hasRole = async function(userId, name, options) {
|
||||
|
@ -69,8 +119,8 @@ module.exports = Self => {
|
|||
* Get all user roles.
|
||||
*
|
||||
* @param {Integer} userId The user id
|
||||
* @param {Object} options Options
|
||||
* @return {Object} User role list
|
||||
* @param {object} options Options
|
||||
* @return {object} User role list
|
||||
*/
|
||||
Self.getRoles = async(userId, options) => {
|
||||
let result = await Self.rawSql(
|
||||
|
|
|
@ -40,6 +40,9 @@
|
|||
"email": {
|
||||
"type": "string"
|
||||
},
|
||||
"emailVerified": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"created": {
|
||||
"type": "date"
|
||||
},
|
||||
|
@ -48,6 +51,9 @@
|
|||
},
|
||||
"image": {
|
||||
"type": "string"
|
||||
},
|
||||
"hasGrant": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
|
@ -85,6 +91,13 @@
|
|||
"principalType": "ROLE",
|
||||
"principalId": "$everyone",
|
||||
"permission": "ALLOW"
|
||||
},
|
||||
{
|
||||
"property": "recoverPassword",
|
||||
"accessType": "EXECUTE",
|
||||
"principalType": "ROLE",
|
||||
"principalId": "$everyone",
|
||||
"permission": "ALLOW"
|
||||
},
|
||||
{
|
||||
"property": "logout",
|
||||
|
@ -99,6 +112,13 @@
|
|||
"principalType": "ROLE",
|
||||
"principalId": "$authenticated",
|
||||
"permission": "ALLOW"
|
||||
},
|
||||
{
|
||||
"property": "privileges",
|
||||
"accessType": "*",
|
||||
"principalType": "ROLE",
|
||||
"principalId": "$authenticated",
|
||||
"permission": "ALLOW"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -4,4 +4,23 @@ module.exports = Self => {
|
|||
require('../methods/chat/sendCheckingPresence')(Self);
|
||||
require('../methods/chat/notifyIssues')(Self);
|
||||
require('../methods/chat/sendQueued')(Self);
|
||||
|
||||
Self.observe('before save', async function(ctx) {
|
||||
if (!ctx.isNewInstance) return;
|
||||
|
||||
let {message} = ctx.instance;
|
||||
if (!message) return;
|
||||
|
||||
const parts = message.match(/(?<=\[)[a-zA-Z0-9_\-+!@#$%^&*()={};':"\\|,.<>/?\s]*(?=])/g);
|
||||
if (!parts) return;
|
||||
|
||||
const replacedParts = parts.map(part => {
|
||||
return part.replace(/[!$%^&*()={};':"\\,.<>/?]/g, '');
|
||||
});
|
||||
|
||||
for (const [index, part] of parts.entries())
|
||||
message = message.replace(part, replacedParts[index]);
|
||||
|
||||
ctx.instance.message = message;
|
||||
});
|
||||
};
|
||||
|
|
|
@ -6,6 +6,7 @@ module.exports = Self => {
|
|||
require('../methods/dms/removeFile')(Self);
|
||||
require('../methods/dms/updateFile')(Self);
|
||||
require('../methods/dms/deleteTrashFiles')(Self);
|
||||
require('../methods/dms/saveSign')(Self);
|
||||
|
||||
Self.checkRole = async function(ctx, id) {
|
||||
const models = Self.app.models;
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
module.exports = Self => {
|
||||
require('../methods/notification/send')(Self);
|
||||
require('../methods/notification/clean')(Self);
|
||||
};
|
|
@ -0,0 +1,30 @@
|
|||
{
|
||||
"name": "Notification",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "util.notification"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "number",
|
||||
"id": true,
|
||||
"description": "Identifier"
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"required": true
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"subscription": {
|
||||
"type": "hasMany",
|
||||
"model": "NotificationSubscription",
|
||||
"foreignKey": "notificationFk"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"name": "NotificationAcl",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "util.notificationAcl"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"notification": {
|
||||
"type": "belongsTo",
|
||||
"model": "Notification",
|
||||
"foreignKey": "notificationFk"
|
||||
},
|
||||
"role": {
|
||||
"type": "belongsTo",
|
||||
"model": "Role",
|
||||
"foreignKey": "roleFk"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"name": "NotificationConfig",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "util.notificationConfig"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "number",
|
||||
"id": true,
|
||||
"description": "Identifier"
|
||||
},
|
||||
"cleanDays": {
|
||||
"type": "number"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
{
|
||||
"name": "NotificationQueue",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "util.notificationQueue"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "number",
|
||||
"id": true,
|
||||
"description": "Identifier"
|
||||
},
|
||||
"params": {
|
||||
"type": "string"
|
||||
},
|
||||
"status": {
|
||||
"type": "string"
|
||||
},
|
||||
"created": {
|
||||
"type": "date"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"notification": {
|
||||
"type": "belongsTo",
|
||||
"model": "Notification",
|
||||
"foreignKey": "notificationFk",
|
||||
"primaryKey": "name"
|
||||
},
|
||||
"author": {
|
||||
"type": "belongsTo",
|
||||
"model": "Account",
|
||||
"foreignKey": "authorFk"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
{
|
||||
"name": "NotificationSubscription",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "util.notificationSubscription"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"notificationFk": {
|
||||
"type": "number",
|
||||
"id": true,
|
||||
"description": "Identifier"
|
||||
},
|
||||
"userFk": {
|
||||
"type": "number",
|
||||
"id": true,
|
||||
"description": "Identifier"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"notification": {
|
||||
"type": "belongsTo",
|
||||
"model": "Notification",
|
||||
"foreignKey": "notificationFk"
|
||||
},
|
||||
"user": {
|
||||
"type": "belongsTo",
|
||||
"model": "Account",
|
||||
"foreignKey": "userFk"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -27,9 +27,6 @@
|
|||
"newStatusId": {
|
||||
"type": "number"
|
||||
},
|
||||
"action": {
|
||||
"type": "string"
|
||||
},
|
||||
"day": {
|
||||
"type": "number"
|
||||
},
|
||||
|
@ -47,6 +44,15 @@
|
|||
},
|
||||
"portDb": {
|
||||
"type": "number"
|
||||
},
|
||||
"responseType": {
|
||||
"type": "string"
|
||||
},
|
||||
"fromEmailId": {
|
||||
"type": "number"
|
||||
},
|
||||
"replyTo": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,14 +1,14 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('loopback model Account', () => {
|
||||
it('should return true if the user has the given role', async() => {
|
||||
let result = await app.models.Account.hasRole(1, 'employee');
|
||||
let result = await models.Account.hasRole(1, 'employee');
|
||||
|
||||
expect(result).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should return false if the user doesnt have the given role', async() => {
|
||||
let result = await app.models.Account.hasRole(1, 'administrator');
|
||||
let result = await models.Account.hasRole(1, 'administrator');
|
||||
|
||||
expect(result).toBeFalsy();
|
||||
});
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('account recoverPassword()', () => {
|
||||
const userId = 1107;
|
||||
|
||||
const activeCtx = {
|
||||
accessToken: {userId: userId},
|
||||
http: {
|
||||
req: {
|
||||
headers: {origin: 'http://localhost'}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: activeCtx
|
||||
});
|
||||
});
|
||||
|
||||
it('should send email with token', async() => {
|
||||
const userId = 1107;
|
||||
const user = await models.Account.findById(userId);
|
||||
|
||||
await models.Account.recoverPassword(user.email);
|
||||
|
||||
const result = await models.AccessToken.findOne({where: {userId: userId}});
|
||||
|
||||
expect(result).toBeDefined();
|
||||
});
|
||||
});
|
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"name": "Url",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "salix.url"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"appName": {
|
||||
"type": "string",
|
||||
"required": true,
|
||||
"id": 1
|
||||
},
|
||||
"environment": {
|
||||
"type": "string",
|
||||
"required": true,
|
||||
"id": 2
|
||||
},
|
||||
"url": {
|
||||
"type": "string",
|
||||
"required": true
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
const LoopBackContext = require('loopback-context');
|
||||
const {Email} = require('vn-print');
|
||||
|
||||
module.exports = function(Self) {
|
||||
Self.on('resetPasswordRequest', async function(info) {
|
||||
const loopBackContext = LoopBackContext.getCurrentContext();
|
||||
const httpCtx = {req: loopBackContext.active};
|
||||
const httpRequest = httpCtx.req.http.req;
|
||||
const headers = httpRequest.headers;
|
||||
const origin = headers.origin;
|
||||
|
||||
const user = await Self.app.models.Account.findById(info.user.id);
|
||||
const params = {
|
||||
recipient: info.email,
|
||||
lang: user.lang,
|
||||
url: `${origin}/#!/reset-password?access_token=${info.accessToken.id}`
|
||||
};
|
||||
|
||||
const options = Object.assign({}, info.options);
|
||||
for (const param in options)
|
||||
params[param] = options[param];
|
||||
|
||||
const email = new Email(options.emailTemplate, params);
|
||||
|
||||
return email.send();
|
||||
});
|
||||
};
|
|
@ -7,13 +7,18 @@ process.on('warning', warning => {
|
|||
console.log(warning.stack);
|
||||
});
|
||||
|
||||
process.on('exit', async function() {
|
||||
if (container) await container.rm();
|
||||
});
|
||||
|
||||
let container;
|
||||
async function test() {
|
||||
let isCI = false;
|
||||
|
||||
if (process.argv[2] === 'ci')
|
||||
isCI = true;
|
||||
|
||||
const container = new Docker();
|
||||
container = new Docker();
|
||||
|
||||
await container.run(isCI);
|
||||
dataSources = JSON.parse(JSON.stringify(dataSources));
|
||||
|
@ -46,6 +51,7 @@ async function test() {
|
|||
jasmine.addReporter(new JunitReporter.JUnitXmlReporter());
|
||||
|
||||
jasmine.jasmine.DEFAULT_TIMEOUT_INTERVAL = 30000;
|
||||
jasmine.exitOnCompletion = true;
|
||||
}
|
||||
|
||||
const backSpecs = [
|
||||
|
@ -60,11 +66,10 @@ async function test() {
|
|||
helpers: [],
|
||||
});
|
||||
|
||||
jasmine.exitOnCompletion = false;
|
||||
await jasmine.execute();
|
||||
if (app) await app.disconnect();
|
||||
if (container) await container.rm();
|
||||
console.log('app disconnected & container removed');
|
||||
console.log('App disconnected & container removed');
|
||||
}
|
||||
|
||||
test();
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
ALTER TABLE `vn`.`accountingType` ADD daysInFuture INT NULL;
|
||||
ALTER TABLE `vn`.`accountingType` MODIFY COLUMN daysInFuture int(11) DEFAULT 0 NULL;
|
||||
UPDATE `vn`.`accountingType` SET daysInFuture=1 WHERE id=8;
|
|
@ -1,4 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
('ItemType', '*', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
('ItemType', '*', 'WRITE', 'ALLOW', 'ROLE', 'buyer');
|
|
@ -1,14 +0,0 @@
|
|||
CREATE TABLE IF NOT EXISTS `vn`.`mdbBranch` (
|
||||
`name` VARCHAR(255),
|
||||
PRIMARY KEY(`name`)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `vn`.`mdbVersion` (
|
||||
`app` VARCHAR(255) NOT NULL,
|
||||
`branchFk` VARCHAR(255) NOT NULL,
|
||||
`version` INT,
|
||||
CONSTRAINT `mdbVersion_branchFk` FOREIGN KEY (`branchFk`) REFERENCES `vn`.`mdbBranch` (`name`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
);
|
||||
|
||||
INSERT IGNORE INTO `salix`.`ACL` (`id`, `model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES(318, 'MdbVersion', '*', '*', 'ALLOW', 'ROLE', 'developer');
|
|
@ -1,13 +0,0 @@
|
|||
CREATE TABLE `vn`.`chat` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`senderFk` int(10) unsigned DEFAULT NULL,
|
||||
`recipient` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
|
||||
`dated` date DEFAULT NULL,
|
||||
`checkUserStatus` tinyint(1) DEFAULT NULL,
|
||||
`message` varchar(200) COLLATE utf8_unicode_ci DEFAULT NULL,
|
||||
`status` tinyint(1) DEFAULT NULL,
|
||||
`attempts` int(1) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `chat_FK` (`senderFk`),
|
||||
CONSTRAINT `chat_FK` FOREIGN KEY (`senderFk`) REFERENCES `account`.`user` (`id`) ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
|
@ -1,8 +0,0 @@
|
|||
ALTER TABLE `vn`.`creditInsurance` ADD creditClassificationFk int(11) NULL;
|
||||
|
||||
UPDATE `vn`.`creditInsurance` AS `destiny`
|
||||
SET `destiny`.`creditClassificationFk`= (SELECT creditClassification FROM `vn`.`creditInsurance` AS `origin` WHERE `origin`.id = `destiny`.id);
|
||||
|
||||
ALTER TABLE `vn`.`creditInsurance`
|
||||
ADD CONSTRAINT `creditInsurance_creditClassificationFk` FOREIGN KEY (`creditClassificationFk`)
|
||||
REFERENCES `vn`.`creditClassification` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
|
@ -1,3 +0,0 @@
|
|||
INSERT INTO `salix`.`defaultViewConfig` (tableCode, columns)
|
||||
VALUES ('clientsDetail', '{"id":true,"phone":true,"city":true,"socialName":true,"salesPersonFk":true,"email":true,"name":false,"fi":false,"credit":false,"creditInsurance":false,"mobile":false,"street":false,"countryFk":false,"provinceFk":false,"postcode":false,"created":false,"businessTypeFk":false,"payMethodFk":false,"sageTaxTypeFk":false,"sageTransactionTypeFk":false,"isActive":false,"isVies":false,"isTaxDataChecked":false,"isEqualizated":false,"isFreezed":false,"hasToInvoice":false,"hasToInvoiceByAddress":false,"isToBeMailed":false,"hasLcr":false,"hasCoreVnl":false,"hasSepaVnl":false}');
|
||||
|
|
@ -1,127 +0,0 @@
|
|||
DROP PROCEDURE IF EXISTS `vn`.`ticket_doRefund`;
|
||||
|
||||
DELIMITER $$
|
||||
$$
|
||||
CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_doRefund`(OUT vNewTicket INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Crea un ticket de abono a partir de tmp.sale y/o tmp.ticketService
|
||||
*
|
||||
* @return vNewTicket
|
||||
*/
|
||||
DECLARE vDone BIT DEFAULT 0;
|
||||
DECLARE vClientFk 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 vDescription VARCHAR(50);
|
||||
DECLARE vTaxClassFk INT;
|
||||
DECLARE vTicketServiceTypeFk INT;
|
||||
DECLARE vOriginTicket INT;
|
||||
|
||||
DECLARE cSales CURSOR FOR
|
||||
SELECT s.id, s.itemFk, - s.quantity, s.concept, s.price, s.discount
|
||||
FROM tmp.sale s;
|
||||
|
||||
DECLARE cTicketServices CURSOR FOR
|
||||
SELECT ts.description, - ts.quantity, ts.price, ts.taxClassFk, ts.ticketServiceTypeFk
|
||||
FROM tmp.ticketService ts;
|
||||
|
||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||
|
||||
SELECT sub.ticketFk INTO vOriginTicket
|
||||
FROM (
|
||||
SELECT s.ticketFk
|
||||
FROM tmp.sale s
|
||||
UNION ALL
|
||||
SELECT ts.ticketFk
|
||||
FROM tmp.ticketService ts
|
||||
) sub
|
||||
LIMIT 1;
|
||||
|
||||
SELECT id INTO vRefundAgencyMode
|
||||
FROM agencyMode WHERE `name` = 'ABONO';
|
||||
|
||||
SELECT clientFk, warehouseFk, companyFk, addressFk
|
||||
INTO vClientFk, 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
|
||||
vClientFk,
|
||||
CURDATE(),
|
||||
vAddress,
|
||||
vRefundAgencyMode,
|
||||
a.nickname,
|
||||
vWarehouse,
|
||||
vCompany,
|
||||
CURDATE(),
|
||||
vZoneFk
|
||||
FROM address a
|
||||
WHERE a.id = vAddress;
|
||||
|
||||
SET vNewTicket = LAST_INSERT_ID();
|
||||
|
||||
SET vDone := FALSE;
|
||||
OPEN cSales;
|
||||
FETCH cSales 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 cSales INTO vSaleMain, vItemFk, vQuantity, vConcept, vPrice, vDiscount;
|
||||
|
||||
END WHILE;
|
||||
CLOSE cSales;
|
||||
|
||||
SET vDone := FALSE;
|
||||
OPEN cTicketServices;
|
||||
FETCH cTicketServices INTO vDescription, vQuantity, vPrice, vTaxClassFk, vTicketServiceTypeFk;
|
||||
|
||||
WHILE NOT vDone DO
|
||||
|
||||
INSERT INTO vn.ticketService(description, quantity, price, taxClassFk, ticketFk, ticketServiceTypeFk)
|
||||
VALUES(vDescription, vQuantity, vPrice, vTaxClassFk, vNewTicket, vTicketServiceTypeFk);
|
||||
|
||||
FETCH cTicketServices INTO vDescription, vQuantity, vPrice, vTaxClassFk, vTicketServiceTypeFk;
|
||||
|
||||
END WHILE;
|
||||
CLOSE cTicketServices;
|
||||
|
||||
INSERT INTO vn.ticketRefund(refundTicketFk, originalTicketFk)
|
||||
VALUES(vNewTicket, vOriginTicket);
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,11 +0,0 @@
|
|||
DELIMITER $$
|
||||
$$
|
||||
CREATE DEFINER=`root`@`localhost` TRIGGER `vn`.`creditInsurance_beforeInsert`
|
||||
BEFORE INSERT ON `creditInsurance`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
IF NEW.creditClassificationFk THEN
|
||||
SET NEW.creditClassification = NEW.creditClassificationFk;
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1 +0,0 @@
|
|||
RENAME TABLE `edi`.`fileConfig` to `edi`.`tableConfig`;
|
|
@ -1,22 +0,0 @@
|
|||
CREATE TABLE `edi`.`fileConfig`
|
||||
(
|
||||
name varchar(25) NOT NULL,
|
||||
checksum text NULL,
|
||||
keyValue tinyint(1) default true NOT NULL,
|
||||
constraint fileConfig_pk
|
||||
primary key (name)
|
||||
);
|
||||
|
||||
create unique index fileConfig_name_uindex
|
||||
on `edi`.`fileConfig` (name);
|
||||
|
||||
|
||||
INSERT INTO `edi`.`fileConfig` (name, checksum, keyValue)
|
||||
VALUES ('FEC010104', null, 0);
|
||||
|
||||
INSERT INTO `edi`.`fileConfig` (name, checksum, keyValue)
|
||||
VALUES ('VBN020101', null, 1);
|
||||
|
||||
INSERT INTO `edi`.`fileConfig` (name, checksum, keyValue)
|
||||
VALUES ('florecompc2', null, 1);
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
ALTER TABLE `vn`.`chat` MODIFY COLUMN message TEXT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL NULL;
|
||||
ALTER TABLE `vn`.`chat` MODIFY COLUMN dated DATETIME DEFAULT NULL NULL;
|
||||
ALTER TABLE `vn`.`chat` ADD error TEXT NULL;
|
|
@ -1,3 +0,0 @@
|
|||
ALTER TABLE `vn`.`creditInsurance`
|
||||
ADD CONSTRAINT `creditInsurance_creditClassificationFk` FOREIGN KEY (`creditClassificationFk`)
|
||||
REFERENCES `vn`.`creditClassification` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
|
@ -1,21 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL` (model,property,accessType,permission,principalType,principalId)
|
||||
VALUES
|
||||
('InvoiceOut','refund','WRITE','ALLOW','ROLE','invoicing'),
|
||||
('InvoiceOut','refund','WRITE','ALLOW','ROLE','salesAssistant'),
|
||||
('InvoiceOut','refund','WRITE','ALLOW','ROLE','claimManager'),
|
||||
('Ticket','refund','WRITE','ALLOW','ROLE','invoicing'),
|
||||
('Ticket','refund','WRITE','ALLOW','ROLE','salesAssistant'),
|
||||
('Ticket','refund','WRITE','ALLOW','ROLE','claimManager'),
|
||||
('Sale','refund','WRITE','ALLOW','ROLE','salesAssistant'),
|
||||
('Sale','refund','WRITE','ALLOW','ROLE','claimManager'),
|
||||
('TicketRefund','*','WRITE','ALLOW','ROLE','invoicing'),
|
||||
('ClaimObservation','*','WRITE','ALLOW','ROLE','salesPerson'),
|
||||
('ClaimObservation','*','READ','ALLOW','ROLE','salesPerson'),
|
||||
('Client','setPassword','WRITE','ALLOW','ROLE','salesPerson'),
|
||||
('Client','updateUser','WRITE','ALLOW','ROLE','salesPerson');
|
||||
|
||||
DELETE FROM `salix`.`ACL` WHERE id=313;
|
||||
|
||||
UPDATE `salix`.`ACL`
|
||||
SET principalId='invoicing'
|
||||
WHERE id=297;
|
|
@ -1,4 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL`(`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
('ZoneExclusionGeo', '*', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
('ZoneExclusionGeo', '*', 'WRITE', 'ALLOW', 'ROLE', 'deliveryBoss');
|
|
@ -1,2 +0,0 @@
|
|||
ALTER TABLE `vn2008`.`albaran_gestdoc` DROP FOREIGN KEY fk_albaran_gestdoc_gestdoc1;
|
||||
ALTER TABLE `vn2008`.`albaran_gestdoc` ADD CONSTRAINT albaran_gestdoc_FK FOREIGN KEY (gestdoc_id) REFERENCES `vn`.`dms`(id) ON DELETE CASCADE ON UPDATE CASCADE;
|
|
@ -1,3 +0,0 @@
|
|||
alter table `vn`.`client`
|
||||
add hasIncoterms tinyint(1) default 0 not null comment 'Received incoterms authorization from client';
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
DROP FUNCTION `account`.`userGetId`;
|
||||
DROP FUNCTION `account`.`myUserGetName`;
|
||||
DROP FUNCTION `account`.`myUserGetId`;
|
||||
DROP FUNCTION `account`.`myUserHasRole`;
|
||||
DROP FUNCTION `account`.`myUserHasRoleId`;
|
||||
DROP FUNCTION `account`.`userGetName`;
|
||||
DROP FUNCTION `account`.`userHasRole`;
|
||||
DROP FUNCTION `account`.`userHasRoleId`;
|
||||
DROP PROCEDURE `account`.`myUserLogout`;
|
||||
DROP PROCEDURE `account`.`userLogin`;
|
||||
DROP PROCEDURE `account`.`userLoginWithKey`;
|
||||
DROP PROCEDURE `account`.`userLoginWithName`;
|
||||
DROP PROCEDURE `account`.`userSetPassword`;
|
|
@ -1 +0,0 @@
|
|||
ALTER TABLE `vn`.`item` MODIFY COLUMN description TEXT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL NULL;
|
|
@ -1,5 +0,0 @@
|
|||
ALTER TABLE `vn`.`itemType` CHANGE `transaction` transaction__ tinyint(4) DEFAULT 0 NOT NULL;
|
||||
ALTER TABLE `vn`.`itemType` CHANGE location location__ varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL NULL;
|
||||
ALTER TABLE `vn`.`itemType` CHANGE hasComponents hasComponents__ tinyint(1) DEFAULT 1 NOT NULL;
|
||||
ALTER TABLE `vn`.`itemType` CHANGE warehouseFk warehouseFk__ smallint(6) unsigned DEFAULT 60 NOT NULL;
|
||||
ALTER TABLE `vn`.`itemType` CHANGE compression compression__ decimal(5,2) DEFAULT 1.00 NULL;
|
|
@ -1,10 +0,0 @@
|
|||
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;
|
|
@ -1,2 +0,0 @@
|
|||
INSERT INTO `vn`.`sample` (code, description, isVisible, hasCompany, hasPreview, datepickerEnabled)
|
||||
VALUES ('incoterms-authorization', 'Autorización de incoterms', 1, 1, 1, 0);
|
|
@ -1,18 +0,0 @@
|
|||
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;
|
|
@ -1,21 +0,0 @@
|
|||
DROP PROCEDURE IF EXISTS `vn`.`ticketRefund_beforeUpsert`;
|
||||
|
||||
DELIMITER $$
|
||||
$$
|
||||
CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticketRefund_beforeUpsert`(vRefundTicketFk INT, vOriginalTicketFk INT)
|
||||
BEGIN
|
||||
DECLARE vAlreadyExists BOOLEAN DEFAULT FALSE;
|
||||
|
||||
IF vRefundTicketFk = vOriginalTicketFk THEN
|
||||
CALL util.throw('Original ticket and refund ticket has same id');
|
||||
END IF;
|
||||
|
||||
SELECT COUNT(*) INTO vAlreadyExists
|
||||
FROM ticketRefund
|
||||
WHERE originalTicketFk = vOriginalTicketFk;
|
||||
|
||||
IF vAlreadyExists > 0 THEN
|
||||
CALL util.throw('This ticket is already a refund');
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,13 +0,0 @@
|
|||
CREATE TABLE `vn`.`claimObservation` (
|
||||
`id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`claimFk` int(10) unsigned NOT NULL,
|
||||
`workerFk` int(10) unsigned DEFAULT NULL,
|
||||
`text` text COLLATE utf8_unicode_ci NOT NULL,
|
||||
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `worker_key` (`workerFk`),
|
||||
KEY `claim_key` (`claimFk`),
|
||||
KEY `claimObservation_created_IDX` (`created`) USING BTREE,
|
||||
CONSTRAINT `claimObservation_ibfk_1` FOREIGN KEY (`claimFk`) REFERENCES `vn`.`claim` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `claimObservation_ibfk_2` FOREIGN KEY (`workerFk`) REFERENCES `vn`.`worker` (`id`) ON UPDATE CASCADE
|
||||
) COMMENT='Todas las observaciones referentes a una reclamación'
|
|
@ -1,2 +0,0 @@
|
|||
INSERT INTO `vn`.`claimObservation` (`claimFk`, `text`, `created`)
|
||||
SELECT `id`, `observation`, `created` FROM `vn`.`claim`
|
|
@ -1,2 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL` (model,property,accessType,permission,principalType,principalId)
|
||||
VALUES ('Parking','*','*','ALLOW','ROLE','employee')
|
|
@ -1,2 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL` (model,property,accessType,permission,principalType,principalId)
|
||||
VALUES ('Shelving','*','*','ALLOW','ROLE','employee')
|
|
@ -1,20 +0,0 @@
|
|||
CREATE TABLE `vn`.`osTicketConfig` (
|
||||
`id` int(11) NOT NULL,
|
||||
`host` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
|
||||
`user` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
|
||||
`password` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
|
||||
`oldStatus` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
|
||||
`newStatusId` int(11) DEFAULT NULL,
|
||||
`action` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
|
||||
`day` int(11) DEFAULT NULL,
|
||||
`comment` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
|
||||
`hostDb` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
|
||||
`userDb` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
|
||||
`passwordDb` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
|
||||
`portDb` int(11) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
|
||||
|
||||
INSERT INTO `vn`.`osTicketConfig`(`id`, `host`, `user`, `password`, `oldStatus`, `newStatusId`, `action`, `day`, `comment`, `hostDb`, `userDb`, `passwordDb`, `portDb`)
|
||||
VALUES
|
||||
(0, 'https://cau.verdnatura.es/scp', NULL, NULL, 'open', 3, 'Cerrar', 60, 'Este CAU se ha cerrado automáticamente', NULL, NULL, NULL, NULL);
|
|
@ -0,0 +1,3 @@
|
|||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
('Receipt', 'receiptPdf', '*', 'ALLOW', 'ROLE', 'salesAssistant');
|
|
@ -0,0 +1 @@
|
|||
ALTER TABLE `account`.`user` ADD hasGrant TINYINT(1) NOT NULL;
|
|
@ -0,0 +1,2 @@
|
|||
INSERT INTO `salix`.`ACL` (model,property,accessType,permission,principalId)
|
||||
VALUES ('WorkerDisableExcluded','*','*','ALLOW','hr');
|
|
@ -1,3 +1,3 @@
|
|||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
('OsTicket', '*', '*', 'ALLOW', 'ROLE', 'employee');
|
||||
('Business', '*', '*', 'ALLOW', 'ROLE', 'hr');
|
|
@ -1,3 +1,3 @@
|
|||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
('OsTicketConfig', '*', '*', 'ALLOW', 'ROLE', 'it');
|
||||
('Sale', 'usesMana', '*', 'ALLOW', 'ROLE', 'employee');
|
|
@ -0,0 +1,2 @@
|
|||
INSERT INTO `vn`.`payDem` (id,payDem)
|
||||
VALUES (7,'0');
|
|
@ -0,0 +1,4 @@
|
|||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
('InvoiceIn', 'invoiceInPdf', 'READ', 'ALLOW', 'ROLE', 'administrative'),
|
||||
('InvoiceIn', 'invoiceInEmail', 'WRITE', 'ALLOW', 'ROLE', 'administrative');
|
|
@ -0,0 +1,2 @@
|
|||
INSERT INTO `salix`.`ACL` (model,property,accessType,principalId)
|
||||
VALUES ('Supplier','newSupplier','WRITE','administrative');
|
|
@ -0,0 +1,23 @@
|
|||
DROP FUNCTION IF EXISTS `util`.`notification_send`;
|
||||
DELIMITER $$
|
||||
CREATE DEFINER=`root`@`localhost` FUNCTION `util`.`notification_send`(vNotificationName VARCHAR(255), vParams TEXT, vAuthorFk INT)
|
||||
RETURNS INT
|
||||
MODIFIES SQL DATA
|
||||
BEGIN
|
||||
/**
|
||||
* Sends a notification.
|
||||
*
|
||||
* @param vNotificationName The notification name
|
||||
* @param vParams The notification parameters formatted as JSON
|
||||
* @param vAuthorFk The notification author or %NULL if there is no author
|
||||
* @return The notification id
|
||||
*/
|
||||
|
||||
INSERT INTO notificationQueue
|
||||
SET notificationFk = vNotificationName,
|
||||
params = vParams,
|
||||
authorFk = vAuthorFk;
|
||||
|
||||
RETURN LAST_INSERT_ID();
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -0,0 +1,63 @@
|
|||
USE util;
|
||||
|
||||
CREATE TABLE notification(
|
||||
id INT PRIMARY KEY,
|
||||
`name` VARCHAR(255) UNIQUE,
|
||||
`description` VARCHAR(255)
|
||||
);
|
||||
|
||||
CREATE TABLE notificationAcl(
|
||||
notificationFk INT,
|
||||
roleFk INT(10) unsigned,
|
||||
PRIMARY KEY(notificationFk, roleFk)
|
||||
);
|
||||
|
||||
ALTER TABLE `util`.`notificationAcl` ADD CONSTRAINT `notificationAcl_ibfk_1` FOREIGN KEY (`notificationFk`) REFERENCES `util`.`notification` (`id`)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE CASCADE;
|
||||
|
||||
ALTER TABLE `util`.`notificationAcl` ADD CONSTRAINT `notificationAcl_ibfk_2` FOREIGN KEY (`roleFk`) REFERENCES `account`.`role`(`id`)
|
||||
ON DELETE RESTRICT
|
||||
ON UPDATE CASCADE;
|
||||
|
||||
CREATE TABLE notificationSubscription(
|
||||
notificationFk INT,
|
||||
userFk INT(10) unsigned,
|
||||
PRIMARY KEY(notificationFk, userFk)
|
||||
);
|
||||
|
||||
ALTER TABLE `util`.`notificationSubscription` ADD CONSTRAINT `notificationSubscription_ibfk_1` FOREIGN KEY (`notificationFk`) REFERENCES `util`.`notification` (`id`)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE CASCADE;
|
||||
|
||||
ALTER TABLE `util`.`notificationSubscription` ADD CONSTRAINT `notificationSubscription_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user`(`id`)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE CASCADE;
|
||||
|
||||
CREATE TABLE notificationQueue(
|
||||
id INT PRIMARY KEY AUTO_INCREMENT,
|
||||
notificationFk VARCHAR(255),
|
||||
params JSON,
|
||||
authorFk INT(10) unsigned NULL,
|
||||
`status` ENUM('pending', 'sent', 'error') NOT NULL DEFAULT 'pending',
|
||||
created DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
INDEX(notificationFk),
|
||||
INDEX(authorFk),
|
||||
INDEX(status)
|
||||
);
|
||||
|
||||
ALTER TABLE `util`.`notificationQueue` ADD CONSTRAINT `nnotificationQueue_ibfk_1` FOREIGN KEY (`notificationFk`) REFERENCES `util`.`notification` (`name`)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE CASCADE;
|
||||
|
||||
ALTER TABLE `util`.`notificationQueue` ADD CONSTRAINT `notificationQueue_ibfk_2` FOREIGN KEY (`authorFk`) REFERENCES `account`.`user`(`id`)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE CASCADE;
|
||||
|
||||
CREATE TABLE notificationConfig(
|
||||
id INT PRIMARY KEY AUTO_INCREMENT,
|
||||
cleanDays MEDIUMINT
|
||||
);
|
||||
|
||||
INSERT INTO notificationConfig
|
||||
SET cleanDays = 90;
|
|
@ -0,0 +1 @@
|
|||
ALTER TABLE `vn`.`supplier` MODIFY COLUMN payMethodFk tinyint(3) unsigned NULL;
|
|
@ -0,0 +1 @@
|
|||
ALTER TABLE `vn`.`supplier` MODIFY COLUMN supplierActivityFk varchar(45) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL NULL;
|
|
@ -0,0 +1,35 @@
|
|||
drop procedure `vn`.`ticket_closeByTicket`;
|
||||
|
||||
DELIMITER $$
|
||||
$$
|
||||
create
|
||||
definer = `root`@`localhost` procedure `vn`.`ticket_closeByTicket`(IN vTicketFk int)
|
||||
BEGIN
|
||||
|
||||
/**
|
||||
* Inserta el ticket en la tabla temporal
|
||||
* para ser cerrado.
|
||||
*
|
||||
* @param vTicketFk Id del ticket
|
||||
*/
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.ticket_close;
|
||||
CREATE TEMPORARY TABLE tmp.ticket_close ENGINE = MEMORY (
|
||||
SELECT
|
||||
t.id AS ticketFk
|
||||
FROM ticket t
|
||||
JOIN agencyMode am ON am.id = t.agencyModeFk
|
||||
LEFT JOIN ticketState ts ON ts.ticketFk = t.id
|
||||
JOIN alertLevel al ON al.id = ts.alertLevel
|
||||
WHERE al.code = 'PACKED' OR (am.code = 'refund' AND al.code != 'delivered')
|
||||
AND t.id = vTicketFk
|
||||
AND t.refFk IS NULL
|
||||
GROUP BY t.id);
|
||||
|
||||
CALL ticket_close();
|
||||
|
||||
DROP TEMPORARY TABLE tmp.ticket_close;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
CREATE TABLE `vn`.`zipConfig` (
|
||||
`id` double(10,2) NOT NULL,
|
||||
`maxSize` int(11) DEFAULT NULL COMMENT 'in MegaBytes',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
|
||||
|
||||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
('ZipConfig', '*', '*', 'ALLOW', 'ROLE', 'employee');
|
|
@ -0,0 +1,5 @@
|
|||
INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId)
|
||||
VALUES
|
||||
('ClaimRma', '*', 'READ', 'ALLOW', 'ROLE', 'claimManager'),
|
||||
('ClaimRma', '*', 'WRITE', 'ALLOW', 'ROLE', 'claimManager');
|
||||
|
|
@ -0,0 +1 @@
|
|||
ALTER TABLE `vn`.`claim` ADD rma varchar(100) NULL ;
|
|
@ -0,0 +1,7 @@
|
|||
CREATE TABLE `vn`.`claimRma` (
|
||||
id INT UNSIGNED auto_increment NOT NULL PRIMARY KEY,
|
||||
code varchar(100) NOT NULL,
|
||||
created timestamp DEFAULT current_timestamp() NOT NULL,
|
||||
workerFk INTEGER UNSIGNED NOT NULL
|
||||
)
|
||||
ENGINE=InnoDB;
|
|
@ -0,0 +1,3 @@
|
|||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
('Notification', '*', 'WRITE', 'ALLOW', 'ROLE', 'developer');
|
|
@ -0,0 +1,12 @@
|
|||
CREATE TABLE `vn`.`packingSiteConfig` (
|
||||
`id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`shinobiUrl` varchar(255) NOT NULL,
|
||||
`shinobiToken` varchar(255) NOT NULL,
|
||||
`shinobiGroupKey` varchar(255) NOT NULL,
|
||||
`avgBoxingTime` INT(3) NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
);
|
||||
|
||||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
('Boxing', '*', '*', 'ALLOW', 'ROLE', 'employee');
|
|
@ -0,0 +1,56 @@
|
|||
ALTER TABLE `vn`.`packingSite` ADD monitorId varchar(255) NULL;
|
||||
|
||||
UPDATE `vn`.`packingSite`
|
||||
SET monitorId = 'VbiUcajdaT'
|
||||
WHERE code = 'h1';
|
||||
UPDATE `vn`.`packingSite`
|
||||
SET monitorId = 'qKMPn9aaVe'
|
||||
WHERE code = 'h2';
|
||||
UPDATE `vn`.`packingSite`
|
||||
SET monitorId = '3CtdIAGPAv'
|
||||
WHERE code = 'h3';
|
||||
UPDATE `vn`.`packingSite`
|
||||
SET monitorId = 'Xme2hiqz1f'
|
||||
WHERE code = 'h4';
|
||||
UPDATE `vn`.`packingSite`
|
||||
SET monitorId = 'aulxefgfJU'
|
||||
WHERE code = 'h5';
|
||||
UPDATE `vn`.`packingSite`
|
||||
SET monitorId = '6Ou0D1bhBw'
|
||||
WHERE code = 'h6';
|
||||
UPDATE `vn`.`packingSite`
|
||||
SET monitorId = 'eVUvnE6pNw'
|
||||
WHERE code = 'h7';
|
||||
UPDATE `vn`.`packingSite`
|
||||
SET monitorId = '0wsmSvqmrs'
|
||||
WHERE code = 'h8';
|
||||
UPDATE `vn`.`packingSite`
|
||||
SET monitorId = 'r2l2RyyF4I'
|
||||
WHERE code = 'h9';
|
||||
UPDATE `vn`.`packingSite`
|
||||
SET monitorId = 'EdjHLIiDVD'
|
||||
WHERE code = 'h10';
|
||||
UPDATE `vn`.`packingSite`
|
||||
SET monitorId = 'czC45kmwqI'
|
||||
WHERE code = 'h11';
|
||||
UPDATE `vn`.`packingSite`
|
||||
SET monitorId = 'PNsmxPaCwQ'
|
||||
WHERE code = 'h12';
|
||||
UPDATE `vn`.`packingSite`
|
||||
SET monitorId = 'agVssO0FDC'
|
||||
WHERE code = 'h13';
|
||||
UPDATE `vn`.`packingSite`
|
||||
SET monitorId = 'f2SPNENHPo'
|
||||
WHERE code = 'h14';
|
||||
UPDATE `vn`.`packingSite`
|
||||
SET monitorId = '6UR7gUZxks'
|
||||
WHERE code = 'h15';
|
||||
UPDATE `vn`.`packingSite`
|
||||
SET monitorId = 'bOB0f8WZ2V'
|
||||
WHERE code = 'h16';
|
||||
UPDATE `vn`.`packingSite`
|
||||
SET monitorId = 'MIR1nXaL0n'
|
||||
WHERE code = 'h17';
|
||||
UPDATE `vn`.`packingSite`
|
||||
SET monitorId = '0Oj9SgGTXR'
|
||||
WHERE code = 'h18';
|
|
@ -0,0 +1,33 @@
|
|||
CREATE TABLE `salix`.`url` (
|
||||
`appName` varchar(100) NOT NULL,
|
||||
`environment` varchar(100) NOT NULL,
|
||||
`url` varchar(255) NOT NULL,
|
||||
PRIMARY KEY (`appName`,`environment`)
|
||||
);
|
||||
|
||||
INSERT INTO `salix`.`url` (`appName`, `environment`, `url`)
|
||||
VALUES
|
||||
('salix', 'production', 'https://salix.verdnatura.es/#!/');
|
||||
INSERT INTO `salix`.`url` (`appName`, `environment`, `url`)
|
||||
VALUES
|
||||
('salix', 'test', 'https://test-salix.verdnatura.es/#!/');
|
||||
INSERT INTO `salix`.`url` (`appName`, `environment`, `url`)
|
||||
VALUES
|
||||
('salix', 'dev', 'http://localhost:5000/#!/');
|
||||
INSERT INTO `salix`.`url` (`appName`, `environment`, `url`)
|
||||
VALUES
|
||||
('lilium', 'production', 'https://lilium.verdnatura.es/#/');
|
||||
INSERT INTO `salix`.`url` (`appName`, `environment`, `url`)
|
||||
VALUES
|
||||
('lilium', 'test', 'https://test-lilium.verdnatura.es/#/');
|
||||
INSERT INTO `salix`.`url` (`appName`, `environment`, `url`)
|
||||
VALUES
|
||||
('lilium', 'dev', 'http://localhost:8080/#/');
|
||||
|
||||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
('Url', '*', 'READ', 'ALLOW', 'ROLE', 'employee');
|
||||
|
||||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
('Url', '*', 'WRITE', 'ALLOW', 'ROLE', 'it');
|
|
@ -0,0 +1,2 @@
|
|||
DELETE FROM `salix`.`ACL`
|
||||
WHERE model = 'UserPassword';
|
|
@ -0,0 +1 @@
|
|||
ALTER TABLE `vn`.`claimConfig` DROP COLUMN `pickupContact`;
|
|
@ -0,0 +1,4 @@
|
|||
INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId)
|
||||
VALUES
|
||||
('ItemShelving', '*', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
('ItemShelving', '*', 'WRITE', 'ALLOW', 'ROLE', 'production');
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue