Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 5739-dockerRefactor
This commit is contained in:
commit
a9377333e6
|
@ -11,8 +11,12 @@
|
|||
"[javascript]": {
|
||||
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
|
||||
},
|
||||
"[json]": {
|
||||
"editor.defaultFormatter": "vscode.json-language-features"
|
||||
},
|
||||
"cSpell.words": [
|
||||
"salix",
|
||||
"fdescribe"
|
||||
"fdescribe",
|
||||
"Loggable"
|
||||
]
|
||||
}
|
||||
|
|
33
CHANGELOG.md
33
CHANGELOG.md
|
@ -5,23 +5,40 @@ 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).
|
||||
|
||||
## [2350.01] - 2023-12-14
|
||||
## [2404.01] - 2024-01-25
|
||||
|
||||
### Added
|
||||
### Changed
|
||||
### Fixed
|
||||
|
||||
|
||||
## [2402.01] - 2024-01-11
|
||||
|
||||
### Added
|
||||
### Changed
|
||||
### Fixed
|
||||
|
||||
## [2400.01] - 2024-01-04
|
||||
|
||||
### Added
|
||||
### Changed
|
||||
### Fixed
|
||||
|
||||
## [2350.01] - 2023-12-14
|
||||
|
||||
### Características Añadidas 🆕
|
||||
- **Tickets → Expediciones:** Añadido soporte para Viaexpress
|
||||
|
||||
|
||||
## [2348.01] - 2023-11-30
|
||||
|
||||
### Added
|
||||
- (Ticket -> Adelantar) Permite mover lineas sin generar negativos
|
||||
- (Ticket -> Adelantar) Permite modificar la fecha de los tickets
|
||||
- (Trabajadores -> Notificaciones) Nueva sección (lilium)
|
||||
### Características Añadidas 🆕
|
||||
- **Tickets → Adelantar:** Permite mover lineas sin generar negativos
|
||||
- **Tickets → Adelantar:** Permite modificar la fecha de los tickets
|
||||
- **Trabajadores → Notificaciones:** Nueva sección (lilium)
|
||||
|
||||
### Changed
|
||||
### Fixed
|
||||
- (Ticket -> RocketChat) Arreglada detección de cambios
|
||||
### Correcciones 🛠️
|
||||
- **Tickets → RocketChat:** Arreglada detección de cambios
|
||||
|
||||
|
||||
## [2346.01] - 2023-11-16
|
||||
|
|
|
@ -22,8 +22,8 @@ module.exports = Self => {
|
|||
|
||||
Self.removeFile = async(ctx, id, options) => {
|
||||
const models = Self.app.models;
|
||||
let tx;
|
||||
const myOptions = {};
|
||||
let tx;
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
|
|
@ -24,15 +24,40 @@ describe('docuware upload()', () => {
|
|||
});
|
||||
|
||||
it('should try upload file', async() => {
|
||||
const tx = await models.Docuware.beginTransaction({});
|
||||
spyOn(ticketModel, 'deliveryNotePdf').and.returnValue(new Promise(resolve => resolve({})));
|
||||
|
||||
let error;
|
||||
try {
|
||||
await models.Docuware.upload(ctx, ticketIds, fileCabinetName);
|
||||
const options = {transaction: tx};
|
||||
const user = await models.UserConfig.findById(userId, null, options);
|
||||
await user.updateAttribute('tabletFk', 'Tablet1', options);
|
||||
await models.Docuware.upload(ctx, ticketIds, fileCabinetName, options);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
error = e.message;
|
||||
error = e;
|
||||
await tx.rollback();
|
||||
}
|
||||
|
||||
expect(error).toEqual('Action not allowed on the test environment');
|
||||
expect(error.message).toEqual('Action not allowed on the test environment');
|
||||
});
|
||||
|
||||
it('should throw error when not have tablet assigned', async() => {
|
||||
const tx = await models.Docuware.beginTransaction({});
|
||||
spyOn(ticketModel, 'deliveryNotePdf').and.returnValue(new Promise(resolve => resolve({})));
|
||||
|
||||
let error;
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
await models.Docuware.upload(ctx, ticketIds, fileCabinetName, options);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
error = e;
|
||||
await tx.rollback();
|
||||
}
|
||||
|
||||
expect(error.message).toEqual('This user does not have an assigned tablet');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -29,12 +29,24 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.upload = async function(ctx, ticketIds, fileCabinet) {
|
||||
Self.upload = async function(ctx, ticketIds, fileCabinet, options) {
|
||||
delete ctx.args.ticketIds;
|
||||
const models = Self.app.models;
|
||||
const action = 'store';
|
||||
|
||||
const options = await Self.getOptions();
|
||||
const myOptions = {};
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
const userConfig = await models.UserConfig.findById(ctx.req.accessToken.userId, {
|
||||
fields: ['tabletFk']
|
||||
}, myOptions);
|
||||
|
||||
if (!userConfig?.tabletFk)
|
||||
throw new UserError('This user does not have an assigned tablet');
|
||||
|
||||
const docuwareOptions = await Self.getOptions();
|
||||
const fileCabinetId = await Self.getFileCabinet(fileCabinet);
|
||||
const dialogId = await Self.getDialog(fileCabinet, action, fileCabinetId);
|
||||
|
||||
|
@ -45,7 +57,7 @@ module.exports = Self => {
|
|||
const deliveryNote = await models.Ticket.deliveryNotePdf(ctx, {
|
||||
id,
|
||||
type: 'deliveryNote'
|
||||
});
|
||||
}, myOptions);
|
||||
// get ticket data
|
||||
const ticket = await models.Ticket.findById(id, {
|
||||
include: [{
|
||||
|
@ -54,7 +66,7 @@ module.exports = Self => {
|
|||
fields: ['id', 'name', 'fi']
|
||||
}
|
||||
}]
|
||||
});
|
||||
}, myOptions);
|
||||
|
||||
// upload file
|
||||
const templateJson = {
|
||||
|
@ -102,7 +114,7 @@ module.exports = Self => {
|
|||
{
|
||||
'FieldName': 'FILTRO_TABLET',
|
||||
'ItemElementName': 'string',
|
||||
'Item': 'Tablet1',
|
||||
'Item': userConfig.tabletFk,
|
||||
}
|
||||
]
|
||||
};
|
||||
|
@ -116,11 +128,11 @@ module.exports = Self => {
|
|||
const deleteJson = {
|
||||
'Field': [{'FieldName': 'ESTADO', 'Item': 'Pendiente eliminar', 'ItemElementName': 'String'}]
|
||||
};
|
||||
const deleteUri = `${options.url}/FileCabinets/${fileCabinetId}/Documents/${docuwareFile.id}/Fields`;
|
||||
await axios.put(deleteUri, deleteJson, options.headers);
|
||||
const deleteUri = `${docuwareOptions.url}/FileCabinets/${fileCabinetId}/Documents/${docuwareFile.id}/Fields`;
|
||||
await axios.put(deleteUri, deleteJson, docuwareOptions.headers);
|
||||
}
|
||||
|
||||
const uploadUri = `${options.url}/FileCabinets/${fileCabinetId}/Documents?StoreDialogId=${dialogId}`;
|
||||
const uploadUri = `${docuwareOptions.url}/FileCabinets/${fileCabinetId}/Documents?StoreDialogId=${dialogId}`;
|
||||
const FormData = require('form-data');
|
||||
const data = new FormData();
|
||||
|
||||
|
@ -130,7 +142,7 @@ module.exports = Self => {
|
|||
headers: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
'X-File-ModifiedDate': Date.vnNew(),
|
||||
'Cookie': options.headers.headers.Cookie,
|
||||
'Cookie': docuwareOptions.headers.headers.Cookie,
|
||||
...data.getHeaders()
|
||||
},
|
||||
};
|
||||
|
@ -141,11 +153,11 @@ module.exports = Self => {
|
|||
const $t = ctx.req.__;
|
||||
const message = $t('Failed to upload delivery note', {id});
|
||||
if (uploaded.length)
|
||||
await models.TicketTracking.setDelivered(ctx, uploaded);
|
||||
await models.TicketTracking.setDelivered(ctx, uploaded, myOptions);
|
||||
throw new UserError(message);
|
||||
}
|
||||
uploaded.push(id);
|
||||
}
|
||||
return models.TicketTracking.setDelivered(ctx, ticketIds);
|
||||
return models.TicketTracking.setDelivered(ctx, ticketIds, myOptions);
|
||||
};
|
||||
};
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
|
||||
<soap12:Body>
|
||||
<DeleteEnvio xmlns="http://82.223.6.71:82">
|
||||
<IdCliente><%= viaexpressConfig.client %></IdCliente>
|
||||
<Usuario><%= viaexpressConfig.user %></Usuario>
|
||||
<Password><%= viaexpressConfig.password %></Password>
|
||||
<etiqueta><%= externalId %></etiqueta>
|
||||
</DeleteEnvio>
|
||||
</soap12:Body>
|
||||
</soap12:Envelope>
|
|
@ -0,0 +1,45 @@
|
|||
const axios = require('axios');
|
||||
const {DOMParser} = require('xmldom');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethod('deleteExpedition', {
|
||||
description: 'Delete a shipment by providing the expedition ID, interacting with Viaexpress API',
|
||||
accessType: 'WRITE',
|
||||
accepts: [{
|
||||
arg: 'expeditionFk',
|
||||
type: 'number',
|
||||
required: true
|
||||
}],
|
||||
returns: {
|
||||
type: ['object'],
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/deleteExpedition`,
|
||||
verb: 'POST'
|
||||
}
|
||||
});
|
||||
|
||||
Self.deleteExpedition = async expeditionFk => {
|
||||
const models = Self.app.models;
|
||||
|
||||
const viaexpressConfig = await models.ViaexpressConfig.findOne({
|
||||
fields: ['url']
|
||||
});
|
||||
|
||||
const renderedXml = await models.ViaexpressConfig.deleteExpeditionRenderer(expeditionFk);
|
||||
const response = await axios.post(`${viaexpressConfig.url}ServicioVxClientes.asmx`, renderedXml, {
|
||||
headers: {
|
||||
'Content-Type': 'application/soap+xml; charset=utf-8'
|
||||
}
|
||||
});
|
||||
|
||||
const xmlString = response.data;
|
||||
const parser = new DOMParser();
|
||||
const xmlDoc = parser.parseFromString(xmlString, 'text/xml');
|
||||
const resultElement = xmlDoc.getElementsByTagName('DeleteEnvioResult')[0];
|
||||
const result = resultElement.textContent;
|
||||
|
||||
return result;
|
||||
};
|
||||
};
|
|
@ -0,0 +1,44 @@
|
|||
const fs = require('fs');
|
||||
const ejs = require('ejs');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethod('deleteExpeditionRenderer', {
|
||||
description: 'Renders the data from an XML',
|
||||
accessType: 'READ',
|
||||
accepts: [{
|
||||
arg: 'expeditionFk',
|
||||
type: 'number',
|
||||
required: true
|
||||
}],
|
||||
returns: {
|
||||
type: ['object'],
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/deleteExpeditionRenderer`,
|
||||
verb: 'GET'
|
||||
}
|
||||
});
|
||||
|
||||
Self.deleteExpeditionRenderer = async expeditionFk => {
|
||||
const models = Self.app.models;
|
||||
|
||||
const viaexpressConfig = await models.ViaexpressConfig.findOne({
|
||||
fields: ['client', 'user', 'password']
|
||||
});
|
||||
|
||||
const expedition = await models.Expedition.findOne({
|
||||
fields: ['id', 'externalId'],
|
||||
where: {id: expeditionFk}
|
||||
});
|
||||
|
||||
const data = {
|
||||
viaexpressConfig,
|
||||
externalId: expedition.externalId
|
||||
};
|
||||
|
||||
const template = fs.readFileSync(__dirname + '/deleteExpedition.ejs', 'utf-8');
|
||||
const renderedXml = ejs.render(template, data);
|
||||
return renderedXml;
|
||||
};
|
||||
};
|
|
@ -68,7 +68,7 @@ module.exports = Self => {
|
|||
userToUpdate.hasGrant = hasGrant;
|
||||
|
||||
if (roleFk) {
|
||||
const role = await models.Role.findById(roleFk, {fields: ['name']}, myOptions);
|
||||
const role = await models.VnRole.findById(roleFk, {fields: ['name']}, myOptions);
|
||||
const hasRole = await Self.hasRole(userId, role.name, myOptions);
|
||||
|
||||
if (!hasRole)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const UserError = require('vn-loopback/util/user-error');
|
||||
const {models} = require('vn-loopback/server/server');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('renewToken', {
|
||||
|
@ -16,20 +16,31 @@ module.exports = Self => {
|
|||
});
|
||||
|
||||
Self.renewToken = async function(ctx) {
|
||||
const models = Self.app.models;
|
||||
const token = ctx.req.accessToken;
|
||||
const {accessToken: token} = ctx.req;
|
||||
|
||||
const now = new Date();
|
||||
// Check if current token is valid
|
||||
|
||||
const {renewPeriod, courtesyTime} = await models.AccessTokenConfig.findOne({
|
||||
fields: ['renewPeriod', 'courtesyTime']
|
||||
});
|
||||
const now = Date.now();
|
||||
const differenceMilliseconds = now - token.created;
|
||||
const differenceSeconds = Math.floor(differenceMilliseconds / 1000);
|
||||
const isNotExceeded = differenceSeconds < renewPeriod - courtesyTime;
|
||||
if (isNotExceeded)
|
||||
return token;
|
||||
|
||||
const fields = ['renewPeriod', 'courtesyTime'];
|
||||
const accessTokenConfig = await models.AccessTokenConfig.findOne({fields});
|
||||
// Schedule to remove current token
|
||||
setTimeout(async() => {
|
||||
try {
|
||||
await Self.logout(token.id);
|
||||
} catch (err) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(err);
|
||||
}
|
||||
}, courtesyTime * 1000);
|
||||
|
||||
if (differenceSeconds < accessTokenConfig.renewPeriod - accessTokenConfig.courtesyTime)
|
||||
throw new UserError(`The renew period has not been exceeded`, 'periodNotExceeded');
|
||||
|
||||
await Self.logout(token.id);
|
||||
// Create new accessToken
|
||||
const user = await Self.findById(token.userId);
|
||||
const accessToken = await user.createAccessToken();
|
||||
|
||||
|
|
|
@ -49,13 +49,7 @@ module.exports = Self => {
|
|||
if (vnUser.twoFactor)
|
||||
throw new ForbiddenError(null, 'REQUIRES_2FA');
|
||||
}
|
||||
const validateLogin = await Self.validateLogin(user, password);
|
||||
await Self.app.models.SignInLog.create({
|
||||
token: validateLogin.token,
|
||||
userFk: vnUser.id,
|
||||
ip: ctx.req.ip
|
||||
});
|
||||
return validateLogin;
|
||||
return Self.validateLogin(user, password, ctx);
|
||||
};
|
||||
|
||||
Self.passExpired = async vnUser => {
|
||||
|
|
|
@ -70,7 +70,7 @@ describe('VnUser privileges()', () => {
|
|||
const tx = await models.VnUser.beginTransaction({});
|
||||
|
||||
const options = {transaction: tx};
|
||||
const agency = await models.Role.findOne({
|
||||
const agency = await models.VnRole.findOne({
|
||||
where: {
|
||||
name: 'agency'
|
||||
}
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
const {models} = require('vn-loopback/server/server');
|
||||
describe('Renew Token', () => {
|
||||
const startingTime = Date.now();
|
||||
let ctx = null;
|
||||
beforeAll(async() => {
|
||||
const unAuthCtx = {
|
||||
req: {
|
||||
headers: {},
|
||||
connection: {
|
||||
remoteAddress: '127.0.0.1'
|
||||
},
|
||||
getLocale: () => 'en'
|
||||
},
|
||||
args: {}
|
||||
};
|
||||
let login = await models.VnUser.signIn(unAuthCtx, 'salesAssistant', 'nightmare');
|
||||
let accessToken = await models.AccessToken.findById(login.token);
|
||||
ctx = {req: {accessToken: accessToken}};
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
jasmine.clock().install();
|
||||
jasmine.clock().mockDate(new Date(startingTime));
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jasmine.clock().uninstall();
|
||||
});
|
||||
|
||||
it('should renew token', async() => {
|
||||
const mockDate = new Date(startingTime + 26600000);
|
||||
jasmine.clock().mockDate(mockDate);
|
||||
const {id} = await models.VnUser.renewToken(ctx);
|
||||
|
||||
expect(id).not.toEqual(ctx.req.accessToken.id);
|
||||
});
|
||||
|
||||
it('NOT should renew', async() => {
|
||||
let error;
|
||||
let response;
|
||||
try {
|
||||
response = await models.VnUser.renewToken(ctx);
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
|
||||
expect(error).toBeUndefined();
|
||||
expect(response.id).toEqual(ctx.req.accessToken.id);
|
||||
});
|
||||
});
|
|
@ -2,7 +2,7 @@ const {models} = require('vn-loopback/server/server');
|
|||
|
||||
describe('VnUser Sign-in()', () => {
|
||||
const employeeId = 1;
|
||||
const unauthCtx = {
|
||||
const unAuthCtx = {
|
||||
req: {
|
||||
headers: {},
|
||||
connection: {
|
||||
|
@ -15,20 +15,18 @@ describe('VnUser Sign-in()', () => {
|
|||
const {VnUser, AccessToken, SignInLog} = models;
|
||||
describe('when credentials are correct', () => {
|
||||
it('should return the token if user uses email', async() => {
|
||||
let login = await VnUser.signIn(unauthCtx, 'salesAssistant@mydomain.com', 'nightmare');
|
||||
let login = await VnUser.signIn(unAuthCtx, 'salesAssistant@mydomain.com', 'nightmare');
|
||||
let accessToken = await AccessToken.findById(login.token);
|
||||
let ctx = {req: {accessToken: accessToken}};
|
||||
let signInLog = await SignInLog.find({where: {token: accessToken.id}});
|
||||
|
||||
expect(signInLog.length).toEqual(1);
|
||||
expect(signInLog[0].userFk).toEqual(accessToken.userId);
|
||||
expect(login.token).toBeDefined();
|
||||
expect(signInLog.length).toEqual(0);
|
||||
|
||||
await VnUser.logout(ctx.req.accessToken.id);
|
||||
});
|
||||
|
||||
it('should return the token', async() => {
|
||||
let login = await VnUser.signIn(unauthCtx, 'salesAssistant', 'nightmare');
|
||||
let login = await VnUser.signIn(unAuthCtx, 'salesAssistant', 'nightmare');
|
||||
let accessToken = await AccessToken.findById(login.token);
|
||||
let ctx = {req: {accessToken: accessToken}};
|
||||
|
||||
|
@ -38,7 +36,7 @@ describe('VnUser Sign-in()', () => {
|
|||
});
|
||||
|
||||
it('should return the token if the user doesnt exist but the client does', async() => {
|
||||
let login = await VnUser.signIn(unauthCtx, 'PetterParker', 'nightmare');
|
||||
let login = await VnUser.signIn(unAuthCtx, 'PetterParker', 'nightmare');
|
||||
let accessToken = await AccessToken.findById(login.token);
|
||||
let ctx = {req: {accessToken: accessToken}};
|
||||
|
||||
|
@ -53,7 +51,7 @@ describe('VnUser Sign-in()', () => {
|
|||
let error;
|
||||
|
||||
try {
|
||||
await VnUser.signIn(unauthCtx, 'IDontExist', 'TotallyWrongPassword');
|
||||
await VnUser.signIn(unAuthCtx, 'IDontExist', 'TotallyWrongPassword');
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
|
@ -74,7 +72,7 @@ describe('VnUser Sign-in()', () => {
|
|||
const options = {transaction: tx};
|
||||
await employee.updateAttribute('twoFactor', 'email', options);
|
||||
|
||||
await VnUser.signIn(unauthCtx, 'employee', 'nightmare', options);
|
||||
await VnUser.signIn(unAuthCtx, 'employee', 'nightmare', options);
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
|
@ -99,7 +97,7 @@ describe('VnUser Sign-in()', () => {
|
|||
const options = {transaction: tx};
|
||||
await employee.updateAttribute('passExpired', yesterday, options);
|
||||
|
||||
await VnUser.signIn(unauthCtx, 'employee', 'nightmare', options);
|
||||
await VnUser.signIn(unAuthCtx, 'employee', 'nightmare', options);
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethod('validateToken', {
|
||||
description: 'Validates the current logged user token',
|
||||
returns: {
|
||||
type: 'Boolean',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/validateToken`,
|
||||
verb: 'GET'
|
||||
}
|
||||
});
|
||||
|
||||
Self.validateToken = async function() {
|
||||
return true;
|
||||
};
|
||||
};
|
|
@ -139,9 +139,6 @@
|
|||
"Warehouse": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"VnUser": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"OsTicket": {
|
||||
"dataSource": "osticket"
|
||||
},
|
||||
|
@ -156,6 +153,12 @@
|
|||
},
|
||||
"ViaexpressConfig": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"VnUser": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"VnRole": {
|
||||
"dataSource": "vn"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,12 +29,12 @@
|
|||
"relations": {
|
||||
"readRole": {
|
||||
"type": "belongsTo",
|
||||
"model": "Role",
|
||||
"model": "VnRole",
|
||||
"foreignKey": "readRoleFk"
|
||||
},
|
||||
"writeRole": {
|
||||
"type": "belongsTo",
|
||||
"model": "Role",
|
||||
"model": "VnRole",
|
||||
"foreignKey": "writeRoleFk"
|
||||
}
|
||||
},
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"name": "docuwareTablet",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "docuwareTablet"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"tablet": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -46,12 +46,12 @@
|
|||
},
|
||||
"readRole": {
|
||||
"type": "belongsTo",
|
||||
"model": "Role",
|
||||
"model": "VnRole",
|
||||
"foreignKey": "readRoleFk"
|
||||
},
|
||||
"writeRole": {
|
||||
"type": "belongsTo",
|
||||
"model": "Role",
|
||||
"model": "VnRole",
|
||||
"foreignKey": "writeRoleFk"
|
||||
}
|
||||
},
|
||||
|
@ -64,4 +64,3 @@
|
|||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -24,8 +24,8 @@
|
|||
},
|
||||
"role": {
|
||||
"type": "belongsTo",
|
||||
"model": "Role",
|
||||
"model": "VnRole",
|
||||
"foreignKey": "roleFk"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('loopback model MailAliasAccount', () => {
|
||||
it('should fail to add a mail Alias if the worker doesnt have ACLs', async() => {
|
||||
const tx = await models.MailAliasAccount.beginTransaction({});
|
||||
let error;
|
||||
|
||||
try {
|
||||
const options = {transaction: tx, accessToken: {userId: 57}};
|
||||
await models.MailAliasAccount.create({mailAlias: 2, account: 5}, options);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
error = e;
|
||||
}
|
||||
|
||||
expect(error.message).toEqual('The alias cant be modified');
|
||||
});
|
||||
|
||||
it('should add a mail Alias', async() => {
|
||||
const tx = await models.MailAliasAccount.beginTransaction({});
|
||||
let error;
|
||||
|
||||
try {
|
||||
const options = {transaction: tx, accessToken: {userId: 9}};
|
||||
await models.MailAliasAccount.create({mailAlias: 2, account: 5}, options);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
error = e;
|
||||
}
|
||||
|
||||
expect(error).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should add a mail Alias of an inherit role', async() => {
|
||||
const tx = await models.MailAliasAccount.beginTransaction({});
|
||||
let error;
|
||||
|
||||
try {
|
||||
const options = {transaction: tx, accessToken: {userId: 9}};
|
||||
await models.MailAliasAccount.create({mailAlias: 3, account: 5}, options);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
error = e;
|
||||
}
|
||||
|
||||
expect(error).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should delete a mail Alias', async() => {
|
||||
const tx = await models.MailAliasAccount.beginTransaction({});
|
||||
let error;
|
||||
|
||||
try {
|
||||
const options = {transaction: tx, accessToken: {userId: 1}};
|
||||
const mailAclId = 2;
|
||||
await models.MailAliasAccount.destroyAll({id: mailAclId}, options);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
error = e;
|
||||
}
|
||||
|
||||
expect(error).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
|
@ -26,6 +26,9 @@
|
|||
},
|
||||
"darkMode": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"tabletFk": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
|
@ -43,6 +46,11 @@
|
|||
"type": "belongsTo",
|
||||
"model": "VnUser",
|
||||
"foreignKey": "userFk"
|
||||
}
|
||||
},
|
||||
"Tablet": {
|
||||
"type": "belongsTo",
|
||||
"model": "docuwareTablet",
|
||||
"foreignKey": "tabletFk"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
module.exports = Self => {
|
||||
require('../methods/viaexpress-config/internationalExpedition')(Self);
|
||||
require('../methods/viaexpress-config/renderer')(Self);
|
||||
require('../methods/viaexpress-config/deleteExpedition')(Self);
|
||||
require('../methods/viaexpress-config/deleteExpeditionRenderer')(Self);
|
||||
};
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"name": "VnRole",
|
||||
"base": "Role",
|
||||
"validateUpsert": true,
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "account.role"
|
||||
}
|
||||
},
|
||||
"mixins": {
|
||||
"Loggable": true
|
||||
}
|
||||
}
|
|
@ -10,7 +10,6 @@ module.exports = function(Self) {
|
|||
require('../methods/vn-user/sign-in')(Self);
|
||||
require('../methods/vn-user/acl')(Self);
|
||||
require('../methods/vn-user/recover-password')(Self);
|
||||
require('../methods/vn-user/validate-token')(Self);
|
||||
require('../methods/vn-user/privileges')(Self);
|
||||
require('../methods/vn-user/validate-auth')(Self);
|
||||
require('../methods/vn-user/renew-token')(Self);
|
||||
|
@ -124,20 +123,43 @@ module.exports = function(Self) {
|
|||
|
||||
return email.send();
|
||||
});
|
||||
Self.signInValidate = (user, userToken) => {
|
||||
|
||||
/**
|
||||
* Sign-in validate
|
||||
* @param {String} user The user
|
||||
* @param {Object} userToken Options
|
||||
* @param {Object} token accessToken
|
||||
* @param {Object} ctx context
|
||||
*/
|
||||
Self.signInValidate = async(user, userToken, token, ctx) => {
|
||||
const [[key, value]] = Object.entries(Self.userUses(user));
|
||||
if (userToken[key].toLowerCase().trim() !== value.toLowerCase().trim()) {
|
||||
console.error('ERROR!!! - Signin with other user', userToken, user);
|
||||
throw new UserError('Try again');
|
||||
const isOwner = Self.rawSql(`SELECT ? = ? `, [userToken[key], value]);
|
||||
if (!isOwner) {
|
||||
await Self.app.models.SignInLog.create({
|
||||
userName: user,
|
||||
token: token.id,
|
||||
userFk: userToken.id,
|
||||
ip: ctx.req.ip,
|
||||
owner: isOwner
|
||||
});
|
||||
throw new UserError('Try again');
|
||||
}
|
||||
};
|
||||
|
||||
Self.validateLogin = async function(user, password) {
|
||||
/**
|
||||
* Validate login params
|
||||
* @param {String} user The user
|
||||
* @param {String} password
|
||||
* @param {Object} ctx context
|
||||
*/
|
||||
Self.validateLogin = async function(user, password, ctx) {
|
||||
const loginInfo = Object.assign({password}, Self.userUses(user));
|
||||
const token = await Self.login(loginInfo, 'user');
|
||||
|
||||
const userToken = await token.user.get();
|
||||
Self.signInValidate(user, userToken);
|
||||
|
||||
if (ctx)
|
||||
await Self.signInValidate(user, userToken, token, ctx);
|
||||
|
||||
try {
|
||||
await Self.app.models.Account.sync(userToken.name, password);
|
||||
|
@ -187,8 +209,8 @@ module.exports = function(Self) {
|
|||
};
|
||||
|
||||
Self.sharedClass._methods.find(method => method.name == 'changePassword').ctor.settings.acls =
|
||||
Self.sharedClass._methods.find(method => method.name == 'changePassword').ctor.settings.acls
|
||||
.filter(acl => acl.property != 'changePassword');
|
||||
Self.sharedClass._methods.find(method => method.name == 'changePassword').ctor.settings.acls
|
||||
.filter(acl => acl.property != 'changePassword');
|
||||
|
||||
Self.userSecurity = async(ctx, userId, options) => {
|
||||
const models = Self.app.models;
|
||||
|
@ -226,10 +248,12 @@ module.exports = function(Self) {
|
|||
|
||||
const env = process.env.NODE_ENV;
|
||||
const liliumUrl = await Self.app.models.Url.findOne({
|
||||
where: {and: [
|
||||
{appName: 'lilium'},
|
||||
{environment: env}
|
||||
]}
|
||||
where: {
|
||||
and: [
|
||||
{appName: 'lilium'},
|
||||
{environment: env}
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
class Mailer {
|
||||
|
|
|
@ -7,6 +7,9 @@
|
|||
"table": "account.user"
|
||||
}
|
||||
},
|
||||
"mixins": {
|
||||
"Loggable": true
|
||||
},
|
||||
"resetPasswordTokenTTL": "604800",
|
||||
"properties": {
|
||||
"id": {
|
||||
|
@ -63,7 +66,7 @@
|
|||
"relations": {
|
||||
"role": {
|
||||
"type": "belongsTo",
|
||||
"model": "Role",
|
||||
"model": "VnRole",
|
||||
"foreignKey": "roleFk"
|
||||
},
|
||||
"roles": {
|
||||
|
@ -95,34 +98,30 @@
|
|||
"principalType": "ROLE",
|
||||
"principalId": "$everyone",
|
||||
"permission": "ALLOW"
|
||||
},
|
||||
{
|
||||
"property": "recoverPassword",
|
||||
"accessType": "EXECUTE",
|
||||
"principalType": "ROLE",
|
||||
"principalId": "$everyone",
|
||||
"permission": "ALLOW"
|
||||
},
|
||||
{
|
||||
"property": "validateToken",
|
||||
"accessType": "EXECUTE",
|
||||
"principalType": "ROLE",
|
||||
"principalId": "$authenticated",
|
||||
"permission": "ALLOW"
|
||||
},
|
||||
{
|
||||
"property": "validateAuth",
|
||||
}, {
|
||||
"property": "recoverPassword",
|
||||
"accessType": "EXECUTE",
|
||||
"principalType": "ROLE",
|
||||
"principalId": "$everyone",
|
||||
"permission": "ALLOW"
|
||||
},
|
||||
{
|
||||
}, {
|
||||
"property": "validateAuth",
|
||||
"accessType": "EXECUTE",
|
||||
"principalType": "ROLE",
|
||||
"principalId": "$everyone",
|
||||
"permission": "ALLOW"
|
||||
}, {
|
||||
"property": "privileges",
|
||||
"accessType": "*",
|
||||
"principalType": "ROLE",
|
||||
"principalId": "$authenticated",
|
||||
"permission": "ALLOW"
|
||||
}, {
|
||||
"property": "renewToken",
|
||||
"accessType": "WRITE",
|
||||
"principalType": "ROLE",
|
||||
"principalId": "$authenticated",
|
||||
"permission": "ALLOW"
|
||||
}
|
||||
],
|
||||
"scopes": {
|
||||
|
|
|
@ -7,6 +7,10 @@ process.on('warning', warning => {
|
|||
console.log(warning.stack);
|
||||
});
|
||||
|
||||
process.on('SIGUSR2', async() => {
|
||||
if (container) await container.rm();
|
||||
});
|
||||
|
||||
process.on('exit', async function() {
|
||||
if (container) await container.rm();
|
||||
});
|
||||
|
|
|
@ -118,13 +118,13 @@ BEGIN
|
|||
SELECT 'UPDATE', account.myUser_getId(), ti.id, CONCAT('Crea factura ', vNewRef)
|
||||
FROM tmp.ticketToInvoice ti;
|
||||
|
||||
CALL invoiceExpenceMake(vNewInvoiceId);
|
||||
CALL invoiceExpenseMake(vNewInvoiceId);
|
||||
CALL invoiceTaxMake(vNewInvoiceId,vTaxArea);
|
||||
|
||||
UPDATE invoiceOut io
|
||||
JOIN (
|
||||
SELECT SUM(amount) AS total
|
||||
FROM invoiceOutExpence
|
||||
FROM invoiceOutExpense
|
||||
WHERE invoiceOutFk = vNewInvoiceId
|
||||
) base
|
||||
JOIN (
|
||||
|
@ -166,18 +166,18 @@ BEGIN
|
|||
SET @vTaxableBaseServices := 0.00;
|
||||
SET @vTaxCodeGeneral := NULL;
|
||||
|
||||
INSERT INTO vn.invoiceInTax(invoiceInFk, taxableBase, expenceFk, taxTypeSageFk, transactionTypeSageFk)
|
||||
SELECT vNewInvoiceInId, @vTaxableBaseServices, sub.expenceFk, sub.taxTypeSageFk , sub.transactionTypeSageFk
|
||||
INSERT INTO vn.invoiceInTax(invoiceInFk, taxableBase, expenseFk, taxTypeSageFk, transactionTypeSageFk)
|
||||
SELECT vNewInvoiceInId, @vTaxableBaseServices, sub.expenseFk, sub.taxTypeSageFk , sub.transactionTypeSageFk
|
||||
FROM (
|
||||
SELECT @vTaxableBaseServices := SUM(tst.taxableBase) taxableBase, i.expenceFk, i.taxTypeSageFk , i.transactionTypeSageFk, @vTaxCodeGeneral := i.taxClassCodeFk
|
||||
SELECT @vTaxableBaseServices := SUM(tst.taxableBase) taxableBase, i.expenseFk, i.taxTypeSageFk , i.transactionTypeSageFk, @vTaxCodeGeneral := i.taxClassCodeFk
|
||||
FROM tmp.ticketServiceTax tst
|
||||
JOIN vn.invoiceOutTaxConfig i ON i.taxClassCodeFk = tst.code
|
||||
WHERE i.isService
|
||||
HAVING taxableBase
|
||||
) sub;
|
||||
|
||||
INSERT INTO vn.invoiceInTax(invoiceInFk, taxableBase, expenceFk, taxTypeSageFk, transactionTypeSageFk)
|
||||
SELECT vNewInvoiceInId, SUM(tt.taxableBase) - IF(tt.code = @vTaxCodeGeneral, @vTaxableBaseServices, 0) taxableBase, i.expenceFk, i.taxTypeSageFk , i.transactionTypeSageFk
|
||||
INSERT INTO vn.invoiceInTax(invoiceInFk, taxableBase, expenseFk, taxTypeSageFk, transactionTypeSageFk)
|
||||
SELECT vNewInvoiceInId, SUM(tt.taxableBase) - IF(tt.code = @vTaxCodeGeneral, @vTaxableBaseServices, 0) taxableBase, i.expenseFk, i.taxTypeSageFk , i.transactionTypeSageFk
|
||||
FROM tmp.ticketTax tt
|
||||
JOIN vn.invoiceOutTaxConfig i ON i.taxClassCodeFk = tt.code
|
||||
WHERE !i.isService
|
||||
|
|
|
@ -139,13 +139,13 @@ BEGIN
|
|||
SELECT 'UPDATE', account.myUser_getId(), ti.id, CONCAT('Crea factura ', vNewRef)
|
||||
FROM tmp.ticketToInvoice ti;
|
||||
|
||||
CALL invoiceExpenceMake(vNewInvoiceId);
|
||||
CALL invoiceExpenseMake(vNewInvoiceId);
|
||||
CALL invoiceTaxMake(vNewInvoiceId,vTaxArea);
|
||||
|
||||
UPDATE invoiceOut io
|
||||
JOIN (
|
||||
SELECT SUM(amount) total
|
||||
FROM invoiceOutExpence
|
||||
FROM invoiceOutExpense
|
||||
WHERE invoiceOutFk = vNewInvoiceId
|
||||
) base
|
||||
JOIN (
|
||||
|
@ -182,15 +182,15 @@ BEGIN
|
|||
SET @vTaxableBaseServices := 0.00;
|
||||
SET @vTaxCodeGeneral := NULL;
|
||||
|
||||
INSERT INTO invoiceInTax(invoiceInFk, taxableBase, expenceFk, taxTypeSageFk, transactionTypeSageFk)
|
||||
INSERT INTO invoiceInTax(invoiceInFk, taxableBase, expenseFk, taxTypeSageFk, transactionTypeSageFk)
|
||||
SELECT vNewInvoiceInFk,
|
||||
@vTaxableBaseServices,
|
||||
sub.expenceFk,
|
||||
sub.expenseFk,
|
||||
sub.taxTypeSageFk,
|
||||
sub.transactionTypeSageFk
|
||||
FROM (
|
||||
SELECT @vTaxableBaseServices := SUM(tst.taxableBase) taxableBase,
|
||||
i.expenceFk,
|
||||
i.expenseFk,
|
||||
i.taxTypeSageFk,
|
||||
i.transactionTypeSageFk,
|
||||
@vTaxCodeGeneral := i.taxClassCodeFk
|
||||
|
@ -200,11 +200,11 @@ BEGIN
|
|||
HAVING taxableBase
|
||||
) sub;
|
||||
|
||||
INSERT INTO invoiceInTax(invoiceInFk, taxableBase, expenceFk, taxTypeSageFk, transactionTypeSageFk)
|
||||
INSERT INTO invoiceInTax(invoiceInFk, taxableBase, expenseFk, taxTypeSageFk, transactionTypeSageFk)
|
||||
SELECT vNewInvoiceInFk,
|
||||
SUM(tt.taxableBase) - IF(tt.code = @vTaxCodeGeneral,
|
||||
@vTaxableBaseServices, 0) taxableBase,
|
||||
i.expenceFk,
|
||||
i.expenseFk,
|
||||
i.taxTypeSageFk ,
|
||||
i.transactionTypeSageFk
|
||||
FROM tmp.ticketTax tt
|
||||
|
|
|
@ -135,13 +135,13 @@ BEGIN
|
|||
INSERT INTO ticketTracking(stateFk,ticketFk,workerFk)
|
||||
SELECT * FROM tmp.updateInter;
|
||||
|
||||
CALL invoiceExpenceMake(vNewInvoiceId);
|
||||
CALL invoiceExpenseMake(vNewInvoiceId);
|
||||
CALL invoiceTaxMake(vNewInvoiceId,vTaxArea);
|
||||
|
||||
UPDATE invoiceOut io
|
||||
JOIN (
|
||||
SELECT SUM(amount) total
|
||||
FROM invoiceOutExpence
|
||||
FROM invoiceOutExpense
|
||||
WHERE invoiceOutFk = vNewInvoiceId
|
||||
) base
|
||||
JOIN (
|
||||
|
@ -178,15 +178,15 @@ BEGIN
|
|||
SET @vTaxableBaseServices := 0.00;
|
||||
SET @vTaxCodeGeneral := NULL;
|
||||
|
||||
INSERT INTO invoiceInTax(invoiceInFk, taxableBase, expenceFk, taxTypeSageFk, transactionTypeSageFk)
|
||||
INSERT INTO invoiceInTax(invoiceInFk, taxableBase, expenseFk, taxTypeSageFk, transactionTypeSageFk)
|
||||
SELECT vNewInvoiceInFk,
|
||||
@vTaxableBaseServices,
|
||||
sub.expenceFk,
|
||||
sub.expenseFk,
|
||||
sub.taxTypeSageFk,
|
||||
sub.transactionTypeSageFk
|
||||
FROM (
|
||||
SELECT @vTaxableBaseServices := SUM(tst.taxableBase) taxableBase,
|
||||
i.expenceFk,
|
||||
i.expenseFk,
|
||||
i.taxTypeSageFk,
|
||||
i.transactionTypeSageFk,
|
||||
@vTaxCodeGeneral := i.taxClassCodeFk
|
||||
|
@ -196,11 +196,11 @@ BEGIN
|
|||
HAVING taxableBase
|
||||
) sub;
|
||||
|
||||
INSERT INTO invoiceInTax(invoiceInFk, taxableBase, expenceFk, taxTypeSageFk, transactionTypeSageFk)
|
||||
INSERT INTO invoiceInTax(invoiceInFk, taxableBase, expenseFk, taxTypeSageFk, transactionTypeSageFk)
|
||||
SELECT vNewInvoiceInFk,
|
||||
SUM(tt.taxableBase) - IF(tt.code = @vTaxCodeGeneral,
|
||||
@vTaxableBaseServices, 0) taxableBase,
|
||||
i.expenceFk,
|
||||
i.expenseFk,
|
||||
i.taxTypeSageFk ,
|
||||
i.transactionTypeSageFk
|
||||
FROM tmp.ticketTax tt
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
-- Auto-generated SQL script #202311061003
|
||||
UPDATE salix.accessTokenConfig
|
||||
SET courtesyTime=60
|
||||
WHERE id=1;
|
|
@ -1,5 +1,4 @@
|
|||
|
||||
|
||||
--
|
||||
-- Table structure for table `signInLog`
|
||||
-- Description: log to debug cross-login error
|
||||
|
@ -13,7 +12,9 @@ CREATE TABLE `account`.`signInLog` (
|
|||
`token` varchar(255) NOT NULL ,
|
||||
`userFk` int(10) unsigned DEFAULT NULL,
|
||||
`creationDate` timestamp NULL DEFAULT current_timestamp(),
|
||||
`userName` varchar(30) NOT NULL,
|
||||
`ip` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL,
|
||||
`owner` tinyint(1) DEFAULT 1,
|
||||
KEY `userFk` (`userFk`),
|
||||
CONSTRAINT `signInLog_ibfk_1` FOREIGN KEY (`userFk`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
);
|
|
@ -0,0 +1,46 @@
|
|||
|
||||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`delivery_beforeInsert`
|
||||
BEFORE INSERT ON `delivery`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
|
||||
IF (NEW.longitude IS NOT NULL AND NEW.latitude IS NOT NULL AND NEW.ticketFK IS NOT NULL)
|
||||
THEN
|
||||
UPDATE address
|
||||
SET longitude = NEW.longitude,
|
||||
latitude = NEW.latitude
|
||||
WHERE id IN (
|
||||
SELECT addressFK
|
||||
FROM ticket
|
||||
WHERE id = NEW.ticketFk
|
||||
);
|
||||
END IF;
|
||||
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
||||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`delivery_beforeUpdate`
|
||||
BEFORE UPDATE ON `delivery`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
|
||||
IF (NEW.longitude IS NOT NULL AND NEW.latitude IS NOT NULL AND NEW.ticketFK IS NOT NULL)
|
||||
THEN
|
||||
UPDATE address
|
||||
SET longitude = NEW.longitude,
|
||||
latitude = NEW.latitude
|
||||
WHERE id IN (
|
||||
SELECT addressFK
|
||||
FROM ticket
|
||||
WHERE id = NEW.ticketFk
|
||||
);
|
||||
END IF;
|
||||
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
||||
|
||||
ALTER TABLE `vn`.`address` MODIFY COLUMN longitude decimal(11,7) DEFAULT NULL NULL COMMENT 'Indica la última longitud proporcionada por tabla delivery';
|
||||
ALTER TABLE `vn`.`address` MODIFY COLUMN latitude decimal(11,7) DEFAULT NULL NULL COMMENT 'Indica la última latitud proporcionada por tabla delivery';
|
|
@ -0,0 +1,6 @@
|
|||
INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) VALUES
|
||||
('VnRole','*','READ','ALLOW','ROLE','employee'),
|
||||
('VnRole','*','WRITE','ALLOW','ROLE','it');
|
||||
|
||||
DELETE FROM`salix`.`ACL` WHERE model='Role';
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
-- Definición de la tabla mailAliasACL
|
||||
|
||||
CREATE OR REPLACE TABLE `account`.`mailAliasAcl` (
|
||||
`mailAliasFk` int(10) unsigned NOT NULL,
|
||||
`roleFk` int(10) unsigned NOT NULL,
|
||||
FOREIGN KEY (`mailAliasFk`) REFERENCES `account`.`mailAlias` (`id`),
|
||||
FOREIGN KEY (`roleFk`) REFERENCES `account`.`role` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
|
|
@ -0,0 +1 @@
|
|||
ALTER TABLE `vn`.`ticketTracking` CHANGE `workerFk` `userFk` int(10) unsigned DEFAULT NULL NULL;
|
|
@ -0,0 +1,4 @@
|
|||
RENAME TABLE `vn`.`clientCreditLimit` TO `vn`.`roleCreditLimit`;
|
||||
ALTER TABLE `vn`.`roleCreditLimit` DROP FOREIGN KEY `clientCreditLimit_FK`;
|
||||
ALTER TABLE `vn`.`roleCreditLimit` ADD CONSTRAINT `roleCreditLimit_FK` FOREIGN KEY (`roleFk`) REFERENCES `account`.`role`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
ALTER TABLE `vn`.`invoiceCorrection` DROP FOREIGN KEY `cplusInvoiceTyoeFk`;
|
||||
ALTER TABLE `vn`.`invoiceCorrection` DROP FOREIGN KEY `invoiceCorrectionType_Fk33`;
|
||||
ALTER TABLE `vn`.`invoiceCorrection` DROP FOREIGN KEY `invoiceCorrection_ibfk_1`;
|
||||
|
||||
ALTER TABLE `vn`.`invoiceCorrection` ADD CONSTRAINT `siiTypeInvoiceOut_FK` FOREIGN KEY (`siiTypeInvoiceOutFk`) REFERENCES `vn`.`siiTypeInvoiceOut`(id) ON UPDATE CASCADE;
|
||||
ALTER TABLE `vn`.`invoiceCorrection` ADD CONSTRAINT `invoiceCorrectionType_FK` FOREIGN KEY (`invoiceCorrectionTypeFk`) REFERENCES `vn`.`invoiceCorrectionType`(id) ON UPDATE CASCADE;
|
||||
ALTER TABLE `vn`.`invoiceCorrection` ADD CONSTRAINT `cplusRectificationType_FK` FOREIGN KEY (`cplusRectificationTypeFk`) REFERENCES `vn`.`cplusRectificationType`(id) ON UPDATE CASCADE;
|
|
@ -0,0 +1,33 @@
|
|||
DELIMITER $$
|
||||
$$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`getTaxBases`()
|
||||
BEGIN
|
||||
/**
|
||||
* Calcula y devuelve en número de bases imponibles postivas y negativas
|
||||
* Requiere la tabla temporal tmp.ticketToInvoice(id)
|
||||
*
|
||||
* returns tmp.taxBases
|
||||
*/
|
||||
|
||||
CREATE OR REPLACE TEMPORARY TABLE tmp.ticket
|
||||
(KEY (ticketFk))
|
||||
ENGINE = MEMORY
|
||||
SELECT id ticketFk
|
||||
FROM tmp.ticketToInvoice;
|
||||
|
||||
CALL ticket_getTax(NULL);
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.taxBases;
|
||||
CREATE TEMPORARY TABLE tmp.taxBases
|
||||
ENGINE = MEMORY
|
||||
SELECT
|
||||
SUM(taxableBase > 0) as positive,
|
||||
SUM(taxableBase < 0) as negative
|
||||
FROM(
|
||||
SELECT SUM(taxableBase) taxableBase
|
||||
FROM tmp.ticketTax
|
||||
GROUP BY pgcFk
|
||||
) t;
|
||||
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -0,0 +1 @@
|
|||
DELETE FROM `account`.`signInLog` where owner <> FALSE
|
|
@ -0,0 +1,30 @@
|
|||
DELIMITER $$
|
||||
$$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`hasAnyPositiveBase`() RETURNS tinyint(1)
|
||||
DETERMINISTIC
|
||||
BEGIN
|
||||
|
||||
/**
|
||||
* Calcula si existe alguna base imponible positiva
|
||||
* Requiere la tabla temporal tmp.ticketToInvoice(id) para getTaxBases()
|
||||
*
|
||||
* returns BOOLEAN
|
||||
*/
|
||||
|
||||
DECLARE hasAnyPositiveBase BOOLEAN;
|
||||
|
||||
CALL getTaxBases();
|
||||
|
||||
SELECT positive INTO hasAnyPositiveBase
|
||||
FROM tmp.taxBases
|
||||
LIMIT 1;
|
||||
|
||||
DROP TEMPORARY TABLE
|
||||
tmp.ticketTax,
|
||||
tmp.ticket,
|
||||
tmp.taxBases;
|
||||
|
||||
RETURN hasAnyPositiveBase;
|
||||
|
||||
END$$
|
||||
DELIMITER ;
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,32 @@
|
|||
DELIMITER $$
|
||||
$$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`hasAnyNegativeBase`() RETURNS tinyint(1)
|
||||
DETERMINISTIC
|
||||
BEGIN
|
||||
|
||||
/**
|
||||
* Calcula si existe alguna base imponible negativa
|
||||
* Requiere la tabla temporal tmp.ticketToInvoice(id) para getTaxBases()
|
||||
*
|
||||
* returns BOOLEAN
|
||||
*/
|
||||
|
||||
DECLARE hasAnyNegativeBase BOOLEAN;
|
||||
|
||||
CALL getTaxBases();
|
||||
|
||||
SELECT negative INTO hasAnyNegativeBase
|
||||
FROM tmp.taxBases
|
||||
LIMIT 1;
|
||||
|
||||
DROP TEMPORARY TABLE
|
||||
tmp.ticketTax,
|
||||
tmp.ticket,
|
||||
tmp.taxBases;
|
||||
|
||||
RETURN hasAnyNegativeBase;
|
||||
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
CREATE SCHEMA IF NOT EXISTS `vn2008`;
|
||||
USE `vn`;
|
||||
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
||||
SQL SECURITY DEFINER
|
||||
VIEW `ticketState`
|
||||
AS SELECT `tt`.`created` AS `updated`,
|
||||
`tt`.`stateFk` AS `stateFk`,
|
||||
`tt`.`userFk` AS `workerFk`,
|
||||
`tls`.`ticketFk` AS `ticketFk`,
|
||||
`s`.`id` AS `state`,
|
||||
`s`.`order` AS `productionOrder`,
|
||||
`s`.`alertLevel` AS `alertLevel`,
|
||||
`s`.`code` AS `code`,
|
||||
`tls`.`ticketFk` AS `ticket`,
|
||||
`tt`.`userFk` AS `worker`,
|
||||
`s`.`isPreviousPreparable` AS `isPreviousPreparable`,
|
||||
`s`.`isPicked` AS `isPicked`
|
||||
FROM (
|
||||
(
|
||||
`ticketLastState` `tls`
|
||||
JOIN `ticketTracking` `tt` ON(`tt`.`id` = `tls`.`ticketTrackingFk`)
|
||||
)
|
||||
JOIN `state` `s` ON(`s`.`id` = `tt`.`stateFk`)
|
||||
);
|
||||
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
||||
SQL SECURITY DEFINER
|
||||
VIEW `vn2008`.`v_inter`
|
||||
AS SELECT `tt`.`id` AS `inter_id`,
|
||||
`tt`.`stateFk` AS `state_id`,
|
||||
`tt`.`notes` AS `nota`,
|
||||
`tt`.`created` AS `odbc_date`,
|
||||
`tt`.`ticketFk` AS `Id_Ticket`,
|
||||
`tt`.`userFk` AS `Id_Trabajador`,
|
||||
`tt`.`supervisorFk` AS `Id_supervisor`
|
||||
FROM `vn`.`ticketTracking` `tt`;
|
||||
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
||||
SQL SECURITY DEFINER
|
||||
VIEW `ticketStateToday`
|
||||
AS SELECT
|
||||
`ts`.`ticket` AS `ticket`,
|
||||
`ts`.`state` AS `state`,
|
||||
`ts`.`productionOrder` AS `productionOrder`,
|
||||
`ts`.`alertLevel` AS `alertLevel`,
|
||||
`ts`.`worker` AS `worker`,
|
||||
`ts`.`code` AS `code`,
|
||||
`ts`.`updated` AS `updated`,
|
||||
`ts`.`isPicked` AS `isPicked`
|
||||
FROM
|
||||
(`ticketState` `ts`
|
||||
JOIN `ticket` `t` ON
|
||||
(`t`.`id` = `ts`.`ticket`))
|
||||
WHERE
|
||||
`t`.`shipped` BETWEEN `util`.`VN_CURDATE`() AND `MIDNIGHT`(`util`.`VN_CURDATE`());
|
|
@ -0,0 +1,10 @@
|
|||
-- vn.docuwareTablet definition
|
||||
|
||||
CREATE TABLE `vn`.`docuwareTablet` (
|
||||
`tablet` varchar(100) NOT NULL PRIMARY KEY,
|
||||
`description` varchar(255) DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
|
||||
|
||||
ALTER TABLE `vn`.`userConfig`
|
||||
ADD COLUMN tabletFk varchar(100) DEFAULT NULL,
|
||||
ADD FOREIGN KEY (tabletFk) REFERENCES `vn`.`docuwareTablet`(tablet);
|
|
@ -0,0 +1,9 @@
|
|||
ALTER TABLE `vn`.`clientSms` ADD `ticketFk` int(11) NULL;
|
||||
ALTER TABLE `vn`.`clientSms` ADD CONSTRAINT `clientSms_FK_2` FOREIGN KEY (`ticketFk`) REFERENCES `vn`.`ticket`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
INSERT INTO`vn`.`clientSms` (`clientFk`, `smsFk`, `ticketFk`)
|
||||
SELECT `t`.`clientFk`, `s`.`smsFk`, `s`.`ticketFk`
|
||||
FROM `vn`.`clientSms` `s`
|
||||
JOIN `vn`.`ticket` `t` ON `t`.`id` = `s`.`ticketFk`;
|
||||
|
||||
RENAME TABLE `vn`.`ticketSms` TO `vn`.`ticketSms__`;
|
|
@ -0,0 +1,17 @@
|
|||
DELETE FROM `salix`.`ACL`
|
||||
WHERE model = 'VnUser'
|
||||
AND property = 'renewToken';
|
||||
|
||||
INSERT INTO `account`.`role` (name, description)
|
||||
VALUES ('timeControl','Tablet para fichar');
|
||||
|
||||
INSERT INTO `account`.`roleInherit` (role, inheritsFrom)
|
||||
VALUES (127, 11);
|
||||
|
||||
INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId)
|
||||
VALUES
|
||||
('WorkerTimeControl', 'login', 'READ', 'ALLOW', 'ROLE', 'timeControl'),
|
||||
('WorkerTimeControl', 'getClockIn', 'READ', 'ALLOW', 'ROLE', 'timeControl'),
|
||||
('WorkerTimeControl', 'clockIn', 'WRITE', 'ALLOW', 'ROLE', 'timeControl');
|
||||
|
||||
CALL `account`.`role_sync`();
|
|
@ -1,3 +1,7 @@
|
|||
CREATE ROLE 'salix';
|
||||
GRANT 'salix' TO 'root'@'%';
|
||||
SET DEFAULT ROLE 'salix' FOR 'root'@'%';
|
||||
|
||||
CREATE SCHEMA IF NOT EXISTS `vn2008`;
|
||||
CREATE SCHEMA IF NOT EXISTS `tmp`;
|
||||
|
||||
|
@ -362,7 +366,7 @@ INSERT INTO `vn`.`contactChannel`(`id`, `name`)
|
|||
|
||||
INSERT INTO `vn`.`client`(`id`,`name`,`fi`,`socialName`,`contact`,`street`,`city`,`postcode`,`phone`,`mobile`,`isRelevant`,`email`,`iban`,`dueDay`,`accountingAccount`,`isEqualizated`,`provinceFk`,`hasToInvoice`,`credit`,`countryFk`,`isActive`,`gestdocFk`,`quality`,`payMethodFk`,`created`,`isToBeMailed`,`contactChannelFk`,`hasSepaVnl`,`hasCoreVnl`,`hasCoreVnh`,`riskCalculated`,`clientTypeFk`, `hasToInvoiceByAddress`,`isTaxDataChecked`,`isFreezed`,`creditInsurance`,`isCreatedAsServed`,`hasInvoiceSimplified`,`salesPersonFk`,`isVies`,`eypbc`, `businessTypeFk`,`typeFk`)
|
||||
VALUES
|
||||
(1101, 'Bruce Wayne', '84612325V', 'BATMAN', 'Alfred', '1007 MOUNTAIN DRIVE, GOTHAM', 'Gotham', 46460, 1111111111, 222222222, 1, 'BruceWayne@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist','loses'),
|
||||
(1101, 'Bruce Wayne', '84612325V', 'BATMAN', 'Alfred', '1007 MOUNTAIN DRIVE, GOTHAM', 'Gotham', 46460, 1111111111, 222222222, 1, 'BruceWayne@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist','normal'),
|
||||
(1102, 'Petter Parker', '87945234L', 'SPIDER MAN', 'Aunt May', '20 INGRAM STREET, QUEENS, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'PetterParker@mydomain.com', NULL, 0, 1234567890, 0, 2, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist','normal'),
|
||||
(1103, 'Clark Kent', '06815934E', 'SUPER MAN', 'lois lane', '344 CLINTON STREET, APARTAMENT 3-D', 'Gotham', 46460, 1111111111, 222222222, 1, 'ClarkKent@mydomain.com', NULL, 0, 1234567890, 0, 3, 1, 0, 19, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist','normal'),
|
||||
(1104, 'Tony Stark', '06089160W', 'IRON MAN', 'Pepper Potts', '10880 MALIBU POINT, 90265', 'Gotham', 46460, 1111111111, 222222222, 1, 'TonyStark@mydomain.com', NULL, 0, 1234567890, 0, 2, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist','normal'),
|
||||
|
@ -372,8 +376,8 @@ INSERT INTO `vn`.`client`(`id`,`name`,`fi`,`socialName`,`contact`,`street`,`city
|
|||
(1108, 'Charles Xavier', '22641921P', 'PROFESSOR X', 'Beast', '3800 VICTORY PKWY, CINCINNATI, OH 45207, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'CharlesXavier@mydomain.com', NULL, 0, 1234567890, 0, 5, 1, 300, 13, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, NULL, 0, 0, 19, 0, 1, 'florist','normal'),
|
||||
(1109, 'Bruce Banner', '16104829E', 'HULK', 'Black widow', 'SOMEWHERE IN NEW YORK', 'Gotham', 46460, 1111111111, 222222222, 1, 'BruceBanner@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, 0, NULL, 0, 0, 9, 0, 1, 'florist','normal'),
|
||||
(1110, 'Jessica Jones', '58282869H', 'JESSICA JONES', 'Luke Cage', 'NYCC 2015 POSTER', 'Gotham', 46460, 1111111111, 222222222, 1, 'JessicaJones@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, 0, NULL, 0, 0, NULL, 0, 1, 'florist','normal'),
|
||||
(1111, 'Missing', NULL, 'MISSING MAN', 'Anton', 'THE SPACE, UNIVERSE FAR AWAY', 'Gotham', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 4, 0, 1, 0, NULL, 1, 0, NULL, 0, 1, 'others','normal'),
|
||||
(1112, 'Trash', NULL, 'GARBAGE MAN', 'Unknown name', 'NEW YORK CITY, UNDERGROUND', 'Gotham', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 4, 0, 1, 0, NULL, 1, 0, NULL, 0, 1, 'others','normal');
|
||||
(1111, 'Missing', NULL, 'MISSING MAN', 'Anton', 'THE SPACE, UNIVERSE FAR AWAY', 'Gotham', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 4, 0, 1, 0, NULL, 1, 0, NULL, 0, 1, 'others','loses'),
|
||||
(1112, 'Trash', NULL, 'GARBAGE MAN', 'Unknown name', 'NEW YORK CITY, UNDERGROUND', 'Gotham', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 4, 0, 1, 0, NULL, 1, 0, NULL, 0, 1, 'others','loses');
|
||||
|
||||
INSERT INTO `vn`.`client`(`id`, `name`, `fi`, `socialName`, `contact`, `street`, `city`, `postcode`, `isRelevant`, `email`, `iban`,`dueDay`,`accountingAccount`, `isEqualizated`, `provinceFk`, `hasToInvoice`, `credit`, `countryFk`, `isActive`, `gestdocFk`, `quality`, `payMethodFk`,`created`, `isTaxDataChecked`)
|
||||
SELECT id, name, CONCAT(RPAD(CONCAT(id,9),8,id),'A'), CONCAT(name, 'Social'), CONCAT(name, 'Contact'), CONCAT(name, 'Street'), 'GOTHAM', 46460, 1, CONCAT(name,'@mydomain.com'), NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5, util.VN_CURDATE(), 1
|
||||
|
@ -489,7 +493,7 @@ INSERT INTO `vn`.`clientCredit`(`clientFk`, `workerFk`, `amount`, `created`)
|
|||
(1104, 9, 90 , util.VN_CURDATE()),
|
||||
(1105, 9, 90 , util.VN_CURDATE());
|
||||
|
||||
INSERT INTO `vn`.`clientCreditLimit`(`id`, `maxAmount`, `roleFk`)
|
||||
INSERT INTO `vn`.`roleCreditLimit`(`id`, `maxAmount`, `roleFk`)
|
||||
VALUES
|
||||
(1, 9999999, 20),
|
||||
(2, 10000, 21),
|
||||
|
@ -598,18 +602,19 @@ INSERT INTO `vn`.`taxArea` (`code`, `claveOperacionFactura`, `CodigoTransaccion`
|
|||
|
||||
INSERT INTO `vn`.`invoiceOutSerial` (`code`, `description`, `isTaxed`, `taxAreaFk`, `isCEE`, `type`)
|
||||
VALUES
|
||||
('A', 'Global nacional', 1, 'NATIONAL', 0, 'global'),
|
||||
('T', 'Española rapida', 1, 'NATIONAL', 0, 'quick'),
|
||||
('V', 'Intracomunitaria global', 0, 'CEE', 1, 'global'),
|
||||
('M', 'Múltiple nacional', 1, 'NATIONAL', 0, 'quick'),
|
||||
('E', 'Exportación rápida', 0, 'WORLD', 0, 'quick');
|
||||
('A', 'Global nacional', 1, 'NATIONAL', 0, 'global'),
|
||||
('T', 'Española rapida', 1, 'NATIONAL', 0, 'quick'),
|
||||
('V', 'Intracomunitaria global', 0, 'CEE', 1, 'global'),
|
||||
('M', 'Múltiple nacional', 1, 'NATIONAL', 0, 'quick'),
|
||||
('R', 'Rectificativa', 1, 'NATIONAL', 0, NULL),
|
||||
('E', 'Exportación rápida', 0, 'WORLD', 0, 'quick');
|
||||
|
||||
INSERT INTO `vn`.`invoiceOut`(`id`, `serial`, `amount`, `issued`,`clientFk`, `created`, `companyFk`, `dued`, `booked`, `bankFk`, `hasPdf`)
|
||||
VALUES
|
||||
(1, 'T', 1026.24, util.VN_CURDATE(), 1101, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0),
|
||||
(2, 'T', 121.36, util.VN_CURDATE(), 1102, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0),
|
||||
(3, 'T', 8.88, util.VN_CURDATE(), 1103, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0),
|
||||
(4, 'T', 8.88, util.VN_CURDATE(), 1103, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0),
|
||||
(4, 'T', 8.88, util.VN_CURDATE(), 1104, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0),
|
||||
(5, 'A', 8.88, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1103, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 442, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 0);
|
||||
|
||||
UPDATE `vn`.`invoiceOut` SET ref = 'T1111111' WHERE id = 1;
|
||||
|
@ -630,7 +635,7 @@ 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`, `name`, `isWithheld`)
|
||||
INSERT INTO `vn`.`expense`(`id`, `name`, `isWithheld`)
|
||||
VALUES
|
||||
(2000000000, 'Inmovilizado pendiente', 0),
|
||||
(2000000001, 'Compra de bienes de inmovilizado', 0),
|
||||
|
@ -642,7 +647,7 @@ INSERT INTO `vn`.`expence`(`id`, `name`, `isWithheld`)
|
|||
(7050000000, 'Prestacion de servicios', 1);
|
||||
|
||||
|
||||
INSERT INTO `vn`.`invoiceOutExpence`(`id`, `invoiceOutFk`, `amount`, `expenceFk`, `created`)
|
||||
INSERT INTO `vn`.`invoiceOutExpense`(`id`, `invoiceOutFk`, `amount`, `expenseFk`, `created`)
|
||||
VALUES
|
||||
(1, 1, 813.06, 2000000000, util.VN_CURDATE()),
|
||||
(2, 1, 33.80, 4751000000, util.VN_CURDATE()),
|
||||
|
@ -715,7 +720,7 @@ INSERT INTO `vn`.`route`(`id`, `time`, `workerFk`, `created`, `vehicleFk`, `agen
|
|||
INSERT INTO `vn`.`ticket`(`id`, `priority`, `agencyModeFk`,`warehouseFk`,`routeFk`, `shipped`, `landed`, `clientFk`,`nickname`, `addressFk`, `refFk`, `isDeleted`, `zoneFk`, `zonePrice`, `zoneBonus`, `created`, `weight`)
|
||||
VALUES
|
||||
(1 , 3, 1, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 'Bat cave', 121, NULL, 0, 1, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1),
|
||||
(2 , 1, 1, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, NULL, 0, 1, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2),
|
||||
(2 , 1, 1, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 'Bat cave', 1, NULL, 0, 1, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2),
|
||||
(3 , 1, 7, 1, 6, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -2 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, NULL, 0, 3, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), NULL),
|
||||
(4 , 3, 2, 1, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -3 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, NULL, 0, 9, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), NULL),
|
||||
(5 , 3, 3, 3, 3, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -4 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, NULL, 0, 10, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), NULL),
|
||||
|
@ -767,7 +772,7 @@ INSERT INTO `vn`.`ticketObservation`(`id`, `ticketFk`, `observationTypeFk`, `des
|
|||
-- FIX for state hours on local, inter_afterInsert
|
||||
-- UPDATE vncontrol.inter SET odbc_date = DATE_ADD(util.VN_CURDATE(), INTERVAL -10 SECOND);
|
||||
|
||||
INSERT INTO `vn`.`ticketTracking`(`ticketFk`, `stateFk`, `workerFk`, `created`)
|
||||
INSERT INTO `vn`.`ticketTracking`(`ticketFk`, `stateFk`, `userFk`, `created`)
|
||||
VALUES
|
||||
(1, 16, 5 , DATE_ADD(util.VN_NOW(), INTERVAL -1 MONTH)),
|
||||
(2, 16, 5 , DATE_ADD(util.VN_NOW(), INTERVAL -1 MONTH)),
|
||||
|
@ -811,6 +816,7 @@ INSERT INTO `vn`.`config`(`id`, `mdbServer`, `fakeEmail`, `defaultersMaxAmount`,
|
|||
VALUES
|
||||
(1, 'beta-server', 'nightmare@mydomain.com', '200', DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH));
|
||||
|
||||
|
||||
INSERT INTO `vn`.`greugeType`(`id`, `name`, `code`)
|
||||
VALUES
|
||||
(1, 'Diff', 'diff'),
|
||||
|
@ -922,7 +928,7 @@ INSERT INTO `vn`.`itemFamily`(`code`, `description`)
|
|||
('SER', 'Services'),
|
||||
('VT', 'Sales');
|
||||
|
||||
INSERT INTO `vn`.`item`(`id`, `typeFk`, `stems`, `originFk`, `description`, `producerFk`, `intrastatFk`, `expenceFk`,
|
||||
INSERT INTO `vn`.`item`(`id`, `typeFk`, `stems`, `originFk`, `description`, `producerFk`, `intrastatFk`, `expenseFk`,
|
||||
`comment`, `relevancy`, `image`, `subName`, `minPrice`, `stars`, `family`, `isFloramondo`, `genericFk`, `itemPackingTypeFk`, `hasMinPrice`, `packingShelve`, `weightByPiece`)
|
||||
VALUES
|
||||
(1, 2, 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '1', NULL, 0, 1, 'EMB', 0, NULL, 'V', 0, 15,3),
|
||||
|
@ -1939,7 +1945,7 @@ INSERT INTO `vn`.`ticketRequest`(`id`, `description`, `requesterFk`, `attenderFk
|
|||
(4, 'Melee weapon combat first 15cm', 18, 35, 15, NULL, 1.30, NULL, NULL, 11, util.VN_CURDATE()),
|
||||
(5, 'Melee weapon combat first 15cm', 18, 35, 15, 4, 1.30, 0, NULL, 18, util.VN_CURDATE());
|
||||
|
||||
INSERT INTO `vn`.`ticketServiceType`(`id`, `name`, `expenceFk`)
|
||||
INSERT INTO `vn`.`ticketServiceType`(`id`, `name`, `expenseFk`)
|
||||
VALUES
|
||||
(1, 'Porte Agencia', 7001000000),
|
||||
(2, 'Portes Retorno', 7001000000),
|
||||
|
@ -2343,9 +2349,11 @@ INSERT INTO `vn`.`zoneEvent`(`zoneFk`, `type`, `weekDays`)
|
|||
(8, 'indefinitely', 'mon,tue,wed,thu,fri,sat,sun'),
|
||||
(10, 'indefinitely', 'mon,tue,wed,thu,fri,sat,sun');
|
||||
|
||||
INSERT INTO `vn`.`zoneEvent`(`zoneFk`, `type`, `started`, `ended`)
|
||||
INSERT INTO `vn`.`zoneEvent`(`zoneFk`, `type`, `started`, `ended`, `weekDays`)
|
||||
VALUES
|
||||
(9, 'range', DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 YEAR));
|
||||
(9, 'range', DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 YEAR), 'mon'),
|
||||
(9, 'range', util.VN_CURDATE(), NULL, 'tue'),
|
||||
(9, 'range', NULL, util.VN_CURDATE(), 'wed');
|
||||
|
||||
INSERT INTO `vn`.`workerTimeControl`(`userFk`, `timed`, `manual`, `direction`, `isSendMail`)
|
||||
VALUES
|
||||
|
@ -2561,7 +2569,7 @@ INSERT INTO `vn`.`duaInvoiceIn`(`id`, `duaFk`, `invoiceInFk`)
|
|||
(9, 9, 9),
|
||||
(10, 10, 10);
|
||||
|
||||
INSERT INTO `vn`.`invoiceInTax` (`invoiceInFk`, `taxableBase`, `expenceFk`, `foreignValue`, `taxTypeSageFk`, `transactionTypeSageFk`)
|
||||
INSERT INTO `vn`.`invoiceInTax` (`invoiceInFk`, `taxableBase`, `expenseFk`, `foreignValue`, `taxTypeSageFk`, `transactionTypeSageFk`)
|
||||
VALUES
|
||||
(1, 99.99, '2000000000', NULL, NULL, NULL),
|
||||
(2, 999.99, '2000000000', NULL, NULL, NULL),
|
||||
|
@ -2960,9 +2968,9 @@ INSERT INTO `vn`.`wagonTypeTray` (`id`, `typeFk`, `height`, `colorFk`)
|
|||
(2, 1, 50, 2),
|
||||
(3, 1, 0, 3);
|
||||
|
||||
INSERT INTO `salix`.`accessTokenConfig` (`id`, `renewPeriod`, `renewInterval`)
|
||||
INSERT INTO `salix`.`accessTokenConfig` (`id`, `renewPeriod`, `courtesyTime`, `renewInterval`)
|
||||
VALUES
|
||||
(1, 21600, 300);
|
||||
(1, 21600, 60, 300);
|
||||
|
||||
INSERT INTO `vn`.`travelConfig` (`id`, `warehouseInFk`, `warehouseOutFk`, `agencyFk`, `companyFk`)
|
||||
VALUES
|
||||
|
@ -3002,3 +3010,28 @@ INSERT INTO `vn`.`invoiceCorrectionType` (`id`, `description`)
|
|||
(1, 'Error in VAT calculation'),
|
||||
(2, 'Error in sales details'),
|
||||
(3, 'Error in customer data');
|
||||
|
||||
INSERT INTO `account`.`mailAliasAcl` (`mailAliasFk`, `roleFk`)
|
||||
VALUES
|
||||
(1, 1),
|
||||
(2, 9),
|
||||
(3, 15);
|
||||
|
||||
INSERT INTO `vn`.`docuwareTablet` (`tablet`,`description`)
|
||||
VALUES
|
||||
('Tablet1','Jarvis tablet'),
|
||||
('Tablet2','Avengers tablet');
|
||||
|
||||
INSERT INTO `vn`.`sms` (`id`, `senderFk`, `sender`, `destination`, `message`, `statusCode`, `status`, `created`)
|
||||
VALUES (1, 66, '111111111', '0001111111111', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', 0, 'OK', util.VN_CURDATE()),
|
||||
(2, 66, '222222222', '0002222222222', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', 0, 'PENDING', util.VN_CURDATE()),
|
||||
(3, 66, '333333333', '0003333333333', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', 0, 'ERROR', util.VN_CURDATE()),
|
||||
(4, 66, '444444444', '0004444444444', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', 0, 'OK', util.VN_CURDATE());
|
||||
|
||||
INSERT INTO `vn`.`clientSms` (`id`, `clientFk`, `smsFk`, `ticketFk`)
|
||||
VALUES(1, 1103, 1, NULL),
|
||||
(2, 1103, 2, NULL),
|
||||
(3, 1103, 3, 32),
|
||||
(4, 1103, 4, 32),
|
||||
(13, 1101, 1, NULL),
|
||||
(14, 1101, 4, 27);
|
|
@ -9692,7 +9692,7 @@ proc: BEGIN
|
|||
`name`,
|
||||
longName,
|
||||
subName,
|
||||
expenceFk,
|
||||
expenseFk,
|
||||
typeFk,
|
||||
intrastatFk,
|
||||
originFk,
|
||||
|
@ -10080,7 +10080,7 @@ BEGIN
|
|||
`name`,
|
||||
longName,
|
||||
subName,
|
||||
expenceFk,
|
||||
expenseFk,
|
||||
typeFk,
|
||||
intrastatFk,
|
||||
originFk,
|
||||
|
@ -17338,7 +17338,7 @@ BEGIN
|
|||
JOIN vn.XDiario x ON x.id = mci.id
|
||||
JOIN vn.supplier s ON s.id = supplierFk
|
||||
JOIN vn.invoiceInTax iit ON iit.invoiceInFk = ii.id
|
||||
JOIN vn.expence e ON e.id = iit.expenceFk
|
||||
JOIN vn.expense e ON e.id = iit.expenseFk
|
||||
JOIN TiposRetencion t ON t.CodigoRetencion = ii.withholdingSageFk
|
||||
LEFT JOIN tmp.invoiceDua id ON id.id = mci.id
|
||||
JOIN (SELECT SUM(x2.BASEEURO) taxableBase, SUM(x2.EURODEBE) taxBase
|
||||
|
@ -17441,7 +17441,7 @@ BEGIN
|
|||
i.serial COLLATE utf8mb3_unicode_ci serial,
|
||||
i.supplierFk,
|
||||
i.issued,
|
||||
IF(expenceFkDeductible, FALSE, i.isVatDeductible) isVatDeductible,
|
||||
IF(expenseFkDeductible, FALSE, i.isVatDeductible) isVatDeductible,
|
||||
IF(c.code = 'EUR', '',c.`code`) currencyFk
|
||||
FROM vn.invoiceIn i
|
||||
JOIN vn.currency c ON c.id = i.currencyFk
|
||||
|
@ -17949,7 +17949,7 @@ BEGIN
|
|||
e.id accountFk,
|
||||
UCASE(e.name),
|
||||
''
|
||||
FROM vn.expence e
|
||||
FROM vn.expense e
|
||||
UNION
|
||||
SELECT company_getCode(vCompanyFk),
|
||||
b.account,
|
||||
|
@ -22010,7 +22010,7 @@ DROP TABLE IF EXISTS `agencyTermConfig`;
|
|||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `agencyTermConfig` (
|
||||
`expenceFk` varchar(10) DEFAULT NULL,
|
||||
`expenseFk` varchar(10) DEFAULT NULL,
|
||||
`vatAccountSupported` varchar(15) DEFAULT NULL,
|
||||
`vatPercentage` decimal(28,10) DEFAULT NULL,
|
||||
`transaction` varchar(50) DEFAULT NULL
|
||||
|
@ -26391,6 +26391,7 @@ CREATE TABLE `cplusCorrectingType` (
|
|||
) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
|
||||
--
|
||||
-- Table structure for table `cplusRectificationType`
|
||||
--
|
||||
|
@ -29097,19 +29098,19 @@ SET character_set_client = utf8;
|
|||
SET character_set_client = @saved_cs_client;
|
||||
|
||||
--
|
||||
-- Table structure for table `expence`
|
||||
-- Table structure for table `expense`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `expence`;
|
||||
DROP TABLE IF EXISTS `expense`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `expence` (
|
||||
CREATE TABLE `expense` (
|
||||
`id` varchar(10) NOT NULL,
|
||||
`name` varchar(50) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL,
|
||||
`isWithheld` tinyint(4) NOT NULL DEFAULT 0,
|
||||
`code` varchar(25) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `expence_UN` (`code`)
|
||||
UNIQUE KEY `expense_UN` (`code`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
|
@ -29862,7 +29863,7 @@ CREATE TABLE `invoiceIn` (
|
|||
`bookEntried` date DEFAULT NULL COMMENT 'Fecha Asiento',
|
||||
`isVatDeductible` tinyint(1) NOT NULL DEFAULT 1,
|
||||
`withholdingSageFk` smallint(6) DEFAULT NULL COMMENT 'Tipos de retención SAGE',
|
||||
`expenceFkDeductible` varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
|
||||
`expenseFkDeductible` varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
|
||||
`editorFk` int(10) unsigned DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `proveedor_id` (`supplierFk`),
|
||||
|
@ -29877,12 +29878,12 @@ CREATE TABLE `invoiceIn` (
|
|||
KEY `recibida_ibfk_6` (`cplusRectificationTypeFk`),
|
||||
KEY `recibida_ibfk_7` (`siiTrascendencyInvoiceInFk`),
|
||||
KEY `invoiceIn_withholdingFk_idx` (`withholdingSageFk`),
|
||||
KEY `invoiceIn_expenceFkDeductible_idx` (`expenceFkDeductible`),
|
||||
KEY `invoiceIn_expenseFkDeductible_idx` (`expenseFkDeductible`),
|
||||
KEY `invoiceIn_fk_editor` (`editorFk`),
|
||||
KEY `invoiceIn_FK` (`currencyFk`),
|
||||
CONSTRAINT `invoiceInCompany_Fk` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON UPDATE CASCADE,
|
||||
CONSTRAINT `invoiceIn_FK` FOREIGN KEY (`currencyFk`) REFERENCES `currency` (`id`) ON UPDATE CASCADE,
|
||||
CONSTRAINT `invoiceIn_expenceFkDeductible` FOREIGN KEY (`expenceFkDeductible`) REFERENCES `expence` (`id`) ON UPDATE CASCADE,
|
||||
CONSTRAINT `invoiceIn_expenseFkDeductible` FOREIGN KEY (`expenseFkDeductible`) REFERENCES `expense` (`id`) ON UPDATE CASCADE,
|
||||
CONSTRAINT `invoiceIn_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`),
|
||||
CONSTRAINT `invoiceIn_ibfk_3` FOREIGN KEY (`cplusSubjectOpFk`) REFERENCES `cplusSubjectOp` (`id`) ON UPDATE CASCADE,
|
||||
CONSTRAINT `invoiceIn_ibfk_4` FOREIGN KEY (`cplusTaxBreakFk`) REFERENCES `cplusTaxBreak` (`id`) ON UPDATE CASCADE,
|
||||
|
@ -30283,7 +30284,7 @@ CREATE TABLE `invoiceInSage` (
|
|||
`taxTypeSageFk` smallint(6) NOT NULL,
|
||||
`transactionTypeSageFk` tinyint(4) NOT NULL,
|
||||
`isService` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Para diferenciar producto de servicio',
|
||||
`expenceFk` varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL,
|
||||
`expenseFk` varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL,
|
||||
`withholdingSageFk` smallint(6) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `invoiceInSafe_unique` (`taxClassFk`,`invoiceInSerialFk`,`isService`,`withholdingSageFk`),
|
||||
|
@ -30292,8 +30293,8 @@ CREATE TABLE `invoiceInSage` (
|
|||
KEY `invoiceInSage_invoiceInSerialFk` (`invoiceInSerialFk`),
|
||||
KEY `invoiceInSage_taxTypeSageFk` (`taxTypeSageFk`),
|
||||
KEY `invoiceInSage_transactionTypeSageFk` (`transactionTypeSageFk`),
|
||||
KEY `invoiceInSage_idx` (`expenceFk`),
|
||||
CONSTRAINT `invoiceInSage_expenceFk` FOREIGN KEY (`expenceFk`) REFERENCES `expence` (`id`) ON UPDATE CASCADE,
|
||||
KEY `invoiceInSage_idx` (`expenseFk`),
|
||||
CONSTRAINT `invoiceInSage_expenseFk` FOREIGN KEY (`expenseFk`) REFERENCES `expense` (`id`) ON UPDATE CASCADE,
|
||||
CONSTRAINT `invoiceInSage_invoiceInSerialFk` FOREIGN KEY (`invoiceInSerialFk`) REFERENCES `invoiceInSerial` (`code`) ON UPDATE CASCADE,
|
||||
CONSTRAINT `invoiceInSage_taxClassFk` FOREIGN KEY (`taxClassFk`) REFERENCES `taxClass` (`code`) ON UPDATE CASCADE,
|
||||
CONSTRAINT `invoiceInSage_taxTypeSageFk` FOREIGN KEY (`taxTypeSageFk`) REFERENCES `sage`.`TiposIva` (`CodigoIva`) ON UPDATE CASCADE,
|
||||
|
@ -30334,7 +30335,7 @@ CREATE TABLE `invoiceInTax` (
|
|||
`invoiceInFk` mediumint(8) unsigned NOT NULL,
|
||||
`taxCodeFk` int(10) DEFAULT NULL,
|
||||
`taxableBase` decimal(10,2) NOT NULL,
|
||||
`expenceFk` varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL,
|
||||
`expenseFk` varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL,
|
||||
`foreignValue` decimal(10,2) DEFAULT NULL,
|
||||
`taxTypeSageFk` smallint(6) DEFAULT NULL COMMENT 'Tipo de IVA SAGE',
|
||||
`transactionTypeSageFk` tinyint(4) DEFAULT NULL COMMENT 'Tipo de transacción SAGE',
|
||||
|
@ -30345,9 +30346,9 @@ CREATE TABLE `invoiceInTax` (
|
|||
KEY `recibida_iva_ibfk_2` (`taxCodeFk`),
|
||||
KEY `recibida_iva_taxTypeSageFk` (`taxTypeSageFk`),
|
||||
KEY `invoiceInTax_transactionTypeSageFk_idx` (`transactionTypeSageFk`),
|
||||
KEY `invoiceInTax_idx` (`expenceFk`),
|
||||
KEY `invoiceInTax_idx` (`expenseFk`),
|
||||
KEY `invoiceInTax_fk_editor` (`editorFk`),
|
||||
CONSTRAINT `invoiceInTax_expenceFk` FOREIGN KEY (`expenceFk`) REFERENCES `expence` (`id`) ON UPDATE CASCADE,
|
||||
CONSTRAINT `invoiceInTax_expenseFk` FOREIGN KEY (`expenseFk`) REFERENCES `expense` (`id`) ON UPDATE CASCADE,
|
||||
CONSTRAINT `invoiceInTax_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`),
|
||||
CONSTRAINT `invoiceInTax_ibfk_5` FOREIGN KEY (`invoiceInFk`) REFERENCES `invoiceIn` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `invoiceInTax_transactionTypeSageFk` FOREIGN KEY (`transactionTypeSageFk`) REFERENCES `sage`.`TiposTransacciones` (`CodigoTransaccion`) ON UPDATE CASCADE,
|
||||
|
@ -30615,23 +30616,23 @@ CREATE TABLE `invoiceOutConfig` (
|
|||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Table structure for table `invoiceOutExpence`
|
||||
-- Table structure for table `invoiceOutExpense`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `invoiceOutExpence`;
|
||||
DROP TABLE IF EXISTS `invoiceOutExpense`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `invoiceOutExpence` (
|
||||
CREATE TABLE `invoiceOutExpense` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`invoiceOutFk` int(10) unsigned NOT NULL,
|
||||
`amount` decimal(10,2) NOT NULL DEFAULT 0.00,
|
||||
`expenceFk` varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL,
|
||||
`expenseFk` varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL,
|
||||
`created` timestamp NULL DEFAULT current_timestamp(),
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `invoiceOutExpence_FK_1_idx` (`invoiceOutFk`),
|
||||
KEY `invoiceOutExpence_expenceFk_idx` (`expenceFk`),
|
||||
CONSTRAINT `invoiceOutExpence_FK_1` FOREIGN KEY (`invoiceOutFk`) REFERENCES `invoiceOut` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `invoiceOutExpence_expenceFk` FOREIGN KEY (`expenceFk`) REFERENCES `expence` (`id`) ON UPDATE CASCADE
|
||||
KEY `invoiceOutExpense_FK_1_idx` (`invoiceOutFk`),
|
||||
KEY `invoiceOutExpense_expenseFk_idx` (`expenseFk`),
|
||||
CONSTRAINT `invoiceOutExpense_FK_1` FOREIGN KEY (`invoiceOutFk`) REFERENCES `invoiceOut` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `invoiceOutExpense_expenseFk` FOREIGN KEY (`expenseFk`) REFERENCES `expense` (`id`) ON UPDATE CASCADE
|
||||
) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Desglosa la base imponible de una factura en funcion del tipo de gasto/venta';
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
|
@ -30694,7 +30695,7 @@ CREATE TABLE `invoiceOutTaxConfig` (
|
|||
`taxTypeSageFk` smallint(6) DEFAULT NULL,
|
||||
`transactionTypeSageFk` tinyint(4) DEFAULT NULL,
|
||||
`isService` tinyint(1) DEFAULT 0,
|
||||
`expenceFk` varchar(10) DEFAULT NULL,
|
||||
`expenseFk` varchar(10) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `invoiceOutTaxConfig_FK` (`taxClassCodeFk`),
|
||||
KEY `invoiceOutTaxConfig_FK_1` (`taxTypeSageFk`),
|
||||
|
@ -30737,7 +30738,7 @@ CREATE TABLE `item` (
|
|||
`description` varchar(1000) DEFAULT NULL,
|
||||
`density` int(11) NOT NULL DEFAULT 167 COMMENT 'Almacena la densidad en kg/m3 para el calculo de los portes, si no se especifica se pone por defecto la del tipo en un trigger',
|
||||
`relevancy` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'La web ordena de forma descendiente por este campo para mostrar los artículos',
|
||||
`expenceFk` varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT '7001000000',
|
||||
`expenseFk` varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT '7001000000',
|
||||
`isActive` tinyint(1) NOT NULL DEFAULT 1,
|
||||
`longName` varchar(50) DEFAULT NULL,
|
||||
`subName` varchar(50) DEFAULT NULL,
|
||||
|
@ -30792,11 +30793,11 @@ CREATE TABLE `item` (
|
|||
KEY `item_size_IDX` (`size`) USING BTREE,
|
||||
KEY `item_size_IDX2` (`longName`) USING BTREE,
|
||||
KEY `item_lastUsed_IDX` (`lastUsed`) USING BTREE,
|
||||
KEY `item_expenceFk_idx` (`expenceFk`),
|
||||
KEY `item_expenseFk_idx` (`expenseFk`),
|
||||
KEY `item_fk_editor` (`editorFk`),
|
||||
CONSTRAINT `item_FK` FOREIGN KEY (`genericFk`) REFERENCES `item` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
|
||||
CONSTRAINT `item_FK_1` FOREIGN KEY (`typeFk`) REFERENCES `itemType` (`id`),
|
||||
CONSTRAINT `item_expenceFk` FOREIGN KEY (`expenceFk`) REFERENCES `expence` (`id`) ON UPDATE CASCADE,
|
||||
CONSTRAINT `item_expenseFk` FOREIGN KEY (`expenseFk`) REFERENCES `expense` (`id`) ON UPDATE CASCADE,
|
||||
CONSTRAINT `item_family` FOREIGN KEY (`family`) REFERENCES `itemFamily` (`code`) ON UPDATE CASCADE,
|
||||
CONSTRAINT `item_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`),
|
||||
CONSTRAINT `item_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `origin` (`id`) ON UPDATE CASCADE,
|
||||
|
@ -40606,10 +40607,10 @@ DROP TABLE IF EXISTS `ticketServiceType`;
|
|||
CREATE TABLE `ticketServiceType` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL,
|
||||
`expenceFk` varchar(10) NOT NULL DEFAULT '7050000000',
|
||||
`expenseFk` varchar(10) NOT NULL DEFAULT '7050000000',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `ticketServiceType_expenceFk_idx` (`expenceFk`),
|
||||
CONSTRAINT `ticketServiceType_expenceFk` FOREIGN KEY (`expenceFk`) REFERENCES `expence` (`id`) ON UPDATE CASCADE
|
||||
KEY `ticketServiceType_expenseFk_idx` (`expenseFk`),
|
||||
CONSTRAINT `ticketServiceType_expenseFk` FOREIGN KEY (`expenseFk`) REFERENCES `expense` (`id`) ON UPDATE CASCADE
|
||||
) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci COMMENT='Lista de los posibles servicios a elegir';
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
|
@ -46533,7 +46534,7 @@ BEGIN
|
|||
WHERE io.ref = vInvoiceRef
|
||||
UNION ALL
|
||||
SELECT ioe.amount
|
||||
FROM invoiceOutExpence ioe
|
||||
FROM invoiceOutExpense ioe
|
||||
JOIN invoiceOut io ON io.id = ioe.invoiceOutFk
|
||||
WHERE io.ref = vInvoiceRef
|
||||
) t1;
|
||||
|
@ -57741,7 +57742,7 @@ DELIMITER ;
|
|||
/*!50003 SET collation_connection = @saved_col_connection */ ;
|
||||
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
|
||||
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
|
||||
/*!50003 DROP PROCEDURE IF EXISTS `invoiceExpenceMake` */;
|
||||
/*!50003 DROP PROCEDURE IF EXISTS `invoiceExpenseMake` */;
|
||||
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
|
||||
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
|
||||
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
|
||||
|
@ -57749,28 +57750,28 @@ DELIMITER ;
|
|||
/*!50003 SET character_set_results = utf8mb4 */ ;
|
||||
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
|
||||
DELIMITER ;;
|
||||
CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceExpenceMake`(IN vInvoice INT)
|
||||
CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceExpenseMake`(IN vInvoice INT)
|
||||
BEGIN
|
||||
/* Inserta las partidas de gasto correspondientes a la factura
|
||||
* REQUIERE tabla tmp.ticketToInvoice
|
||||
* @param vInvoice Numero de factura
|
||||
*/
|
||||
DELETE FROM invoiceOutExpence
|
||||
DELETE FROM invoiceOutExpense
|
||||
WHERE invoiceOutFk = vInvoice;
|
||||
|
||||
INSERT INTO invoiceOutExpence(invoiceOutFk, expenceFk, amount)
|
||||
INSERT INTO invoiceOutExpense(invoiceOutFk, expenseFk, amount)
|
||||
SELECT vInvoice,
|
||||
expenceFk,
|
||||
expenseFk,
|
||||
SUM(ROUND(quantity * price * (100 - discount)/100,2)) amount
|
||||
FROM tmp.ticketToInvoice t
|
||||
JOIN sale s ON s.ticketFk = t.id
|
||||
JOIN item i ON i.id = s.itemFk
|
||||
GROUP BY i.expenceFk
|
||||
GROUP BY i.expenseFk
|
||||
HAVING amount != 0;
|
||||
|
||||
INSERT INTO invoiceOutExpence(invoiceOutFk, expenceFk, amount)
|
||||
INSERT INTO invoiceOutExpense(invoiceOutFk, expenseFk, amount)
|
||||
SELECT vInvoice,
|
||||
tst.expenceFk,
|
||||
tst.expenseFk,
|
||||
SUM(ROUND(ts.quantity * ts.price ,2)) amount
|
||||
FROM tmp.ticketToInvoice t
|
||||
JOIN ticketService ts ON ts.ticketFk = t.id
|
||||
|
@ -58125,7 +58126,7 @@ CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceInTax_getFromEntries`(IN vId
|
|||
BEGIN
|
||||
DECLARE vRate DOUBLE DEFAULT 1;
|
||||
DECLARE vDated DATE;
|
||||
DECLARE vExpenceFk VARCHAR(10);
|
||||
DECLARE vExpenseFk VARCHAR(10);
|
||||
|
||||
SELECT MAX(rr.dated) INTO vDated
|
||||
FROM referenceRate rr
|
||||
|
@ -58139,8 +58140,8 @@ BEGIN
|
|||
WHERE dated = vDated;
|
||||
END IF;
|
||||
|
||||
SELECT id INTO vExpenceFk
|
||||
FROM vn.expence
|
||||
SELECT id INTO vExpenseFk
|
||||
FROM vn.expense
|
||||
WHERE `name` = 'Adquisición mercancia Extracomunitaria'
|
||||
GROUP BY id
|
||||
LIMIT 1;
|
||||
|
@ -58148,10 +58149,10 @@ BEGIN
|
|||
DELETE FROM invoiceInTax
|
||||
WHERE invoiceInFk = vId;
|
||||
|
||||
INSERT INTO invoiceInTax(invoiceInFk, taxableBase, expenceFk, foreignValue, taxTypeSageFk, transactionTypeSageFk)
|
||||
INSERT INTO invoiceInTax(invoiceInFk, taxableBase, expenseFk, foreignValue, taxTypeSageFk, transactionTypeSageFk)
|
||||
SELECT ii.id,
|
||||
SUM(b.buyingValue * b.quantity) / IFNULL(vRate,1) taxableBase,
|
||||
vExpenceFk,
|
||||
vExpenseFk,
|
||||
IF(ii.currencyFk = 1,NULL,SUM(b.buyingValue * b.quantity )) divisa,
|
||||
taxTypeSageFk,
|
||||
transactionTypeSageFk
|
||||
|
@ -58188,7 +58189,7 @@ BEGIN
|
|||
SELECT ii.bookEntried,
|
||||
iit.foreignValue,
|
||||
ii.companyFk,
|
||||
ii.expenceFkDeductible,
|
||||
ii.expenseFkDeductible,
|
||||
iit.taxableBase,
|
||||
iit.transactionTypeSageFk,
|
||||
ii.serial,
|
||||
|
@ -58218,8 +58219,8 @@ BEGIN
|
|||
cit.id invoicesCount,
|
||||
e.code,
|
||||
e.isWithheld,
|
||||
e.id expenceFk,
|
||||
e.name expenceName
|
||||
e.id expenseFk,
|
||||
e.name expenseName
|
||||
FROM invoiceIn ii
|
||||
JOIN supplier s ON s.id = ii.supplierFk
|
||||
LEFT JOIN province p ON p.id = s.provinceFk
|
||||
|
@ -58231,7 +58232,7 @@ BEGIN
|
|||
JOIN siiTypeInvoiceIn cit ON cit.id = ii.siiTypeInvoiceInFk
|
||||
LEFT JOIN invoiceInTax iit ON iit.invoiceInFk = ii.id
|
||||
LEFT JOIN sage.TiposTransacciones ttr ON ttr.CodigoTransaccion = iit.transactionTypeSageFk
|
||||
LEFT JOIN expence e ON e.id = iit.expenceFk
|
||||
LEFT JOIN expense e ON e.id = iit.expenseFk
|
||||
LEFT JOIN sage.TiposIva ti ON ti.CodigoIva = iit.taxTypeSageFk
|
||||
LEFT JOIN sage.taxType tt ON tt.id = ti.CodigoIva
|
||||
WHERE ii.id = vSelf;
|
||||
|
@ -58286,7 +58287,7 @@ BEGIN
|
|||
empresa_id)
|
||||
SELECT vBookNumber ASIEN,
|
||||
tii.bookEntried FECHA,
|
||||
IF(tii.isWithheld, LPAD(RIGHT(tii.supplierAccount, 5), 10, tii.expenceFk),tii.expenceFk) SUBCTA,
|
||||
IF(tii.isWithheld, LPAD(RIGHT(tii.supplierAccount, 5), 10, tii.expenseFk),tii.expenseFk) SUBCTA,
|
||||
tii.supplierAccount CONTRA,
|
||||
IF(tii.isWithheld AND tii.taxableBase < 0, NULL, ROUND(SUM(tii.taxableBase),2)) EURODEBE,
|
||||
IF(tii.isWithheld AND tii.taxableBase < 0, ROUND(SUM(-tii.taxableBase), 2), NULL) EUROHABER,
|
||||
|
@ -58301,7 +58302,7 @@ BEGIN
|
|||
tii.companyFk empresa_id
|
||||
FROM tInvoiceIn tii
|
||||
WHERE tii.code IS NULL OR tii.code <> 'suplido'
|
||||
GROUP BY tii.expenceFk;
|
||||
GROUP BY tii.expenseFk;
|
||||
|
||||
-- Líneas de IVA
|
||||
INSERT INTO XDiario(
|
||||
|
@ -58335,11 +58336,11 @@ BEGIN
|
|||
empresa_id)
|
||||
SELECT vBookNumber ASIEN,
|
||||
tii.bookEntried FECHA,
|
||||
IF(tii.expenceFkDeductible>0, tii.expenceFkDeductible, tii.CuentaIvaSoportado) SUBCTA,
|
||||
IF(tii.expenseFkDeductible>0, tii.expenseFkDeductible, tii.CuentaIvaSoportado) SUBCTA,
|
||||
tii.supplierAccount CONTRA,
|
||||
SUM(ROUND(tii.PorcentajeIva * tii.taxableBase / 100, 2)) EURODEBE,
|
||||
SUM(tii.taxableBase) BASEEURO,
|
||||
GROUP_CONCAT(DISTINCT tii.expenceName SEPARATOR ', ') CONCEPTO,
|
||||
GROUP_CONCAT(DISTINCT tii.expenseName SEPARATOR ', ') CONCEPTO,
|
||||
vSelf FACTURA,
|
||||
tii.PorcentajeIva IVA,
|
||||
IF(tii.isUeeMember AND eWithheld.id IS NULL, '', '*') AUXILIAR,
|
||||
|
@ -58365,13 +58366,13 @@ BEGIN
|
|||
LEFT JOIN (
|
||||
SELECT e.id
|
||||
FROM tInvoiceIn tii
|
||||
JOIN expence e ON e.id = tii.expenceFk
|
||||
JOIN expense e ON e.id = tii.expenseFk
|
||||
WHERE e.isWithheld
|
||||
LIMIT 1
|
||||
) eWithheld ON TRUE
|
||||
WHERE tii.taxTypeSageFk IS NOT NULL
|
||||
AND (tii.taxCode IS NULL OR tii.taxCode NOT IN ('import10', 'import21'))
|
||||
GROUP BY tii.PorcentajeIva, tii.expenceFk;
|
||||
GROUP BY tii.PorcentajeIva, tii.expenseFk;
|
||||
|
||||
-- Línea iva inversor sujeto pasivo
|
||||
INSERT INTO XDiario(
|
||||
|
@ -58408,7 +58409,7 @@ BEGIN
|
|||
tii.supplierAccount CONTRA,
|
||||
SUM(ROUND(tii.PorcentajeIva * tii.taxableBase / 100,2)) EUROHABER,
|
||||
ROUND(SUM(tii.taxableBase),2) BASEEURO,
|
||||
GROUP_CONCAT(DISTINCT tii.expenceName SEPARATOR ', ') CONCEPTO,
|
||||
GROUP_CONCAT(DISTINCT tii.expenseName SEPARATOR ', ') CONCEPTO,
|
||||
vSelf FACTURA,
|
||||
tii.PorcentajeIva IVA,
|
||||
'*' AUXILIAR,
|
||||
|
@ -58436,7 +58437,7 @@ BEGIN
|
|||
AND NOT(tii.isVies
|
||||
AND c.nontaxableTransactionTypeFk = tii.transactionTypeSageFk
|
||||
AND tii.taxCode = 'nonTaxable')
|
||||
GROUP BY tii.PorcentajeIva, tii.expenceFk;
|
||||
GROUP BY tii.PorcentajeIva, tii.expenseFk;
|
||||
|
||||
-- Actualización del registro original
|
||||
UPDATE invoiceIn ii
|
||||
|
@ -58509,14 +58510,14 @@ BEGIN
|
|||
FROM ticket
|
||||
WHERE refFk = vInvoiceRef;
|
||||
|
||||
CALL invoiceExpenceMake(vInvoiceFk);
|
||||
CALL invoiceExpenseMake(vInvoiceFk);
|
||||
|
||||
CALL invoiceTaxMake(vInvoiceFk,vTaxArea);
|
||||
|
||||
UPDATE invoiceOut io
|
||||
JOIN (
|
||||
SELECT SUM(amount) AS total
|
||||
FROM invoiceOutExpence
|
||||
FROM invoiceOutExpense
|
||||
WHERE invoiceOutFk = vInvoiceFk
|
||||
) base
|
||||
JOIN (
|
||||
|
@ -58552,7 +58553,7 @@ BEGIN
|
|||
* param vInvoice factura_id
|
||||
*/
|
||||
DECLARE vBookNumber INT;
|
||||
DECLARE vExpenceConcept VARCHAR(50);
|
||||
DECLARE vExpenseConcept VARCHAR(50);
|
||||
DECLARE vSpainCountryFk INT;
|
||||
DECLARE vOldBookNumber INT;
|
||||
|
||||
|
@ -58644,7 +58645,7 @@ BEGIN
|
|||
SELECT
|
||||
vBookNumber AS ASIEN,
|
||||
rs.FECHA,
|
||||
ioe.expenceFk AS SUBCTA,
|
||||
ioe.expenseFk AS SUBCTA,
|
||||
rs.clientBookingAccount AS CONTRA,
|
||||
ioe.amount AS EUROHABER,
|
||||
rs.Concept AS CONCEPTO,
|
||||
|
@ -58652,13 +58653,13 @@ BEGIN
|
|||
rs.FECHA_OP,
|
||||
rs.companyFk AS empresa_id
|
||||
FROM rs
|
||||
JOIN invoiceOutExpence ioe
|
||||
JOIN invoiceOutExpense ioe
|
||||
WHERE ioe.invoiceOutFk = vInvoice;
|
||||
|
||||
SELECT GROUP_CONCAT(`name` SEPARATOR ',')
|
||||
INTO vExpenceConcept
|
||||
FROM expence e
|
||||
JOIN invoiceOutExpence ioe ON ioe.expenceFk = e.id
|
||||
INTO vExpenseConcept
|
||||
FROM expense e
|
||||
JOIN invoiceOutExpense ioe ON ioe.expenseFk = e.id
|
||||
WHERE ioe.invoiceOutFk = vInvoice;
|
||||
|
||||
-- Lineas de IVA
|
||||
|
@ -58701,7 +58702,7 @@ BEGIN
|
|||
rs.clientBookingAccount AS CONTRA,
|
||||
iot.vat AS EUROHABER,
|
||||
iot.taxableBase AS BASEEURO,
|
||||
CONCAT(vExpenceConcept,' : ',rs.Concept) AS CONCEPTO,
|
||||
CONCAT(vExpenseConcept,' : ',rs.Concept) AS CONCEPTO,
|
||||
rs.invoiceNum AS FACTURA,
|
||||
IF(pe2.equFk,0,pgc.rate) AS IVA,
|
||||
IF(pe2.equFk,0,pgce.rate) AS RECEQUIV,
|
||||
|
@ -58844,7 +58845,7 @@ DELIMITER ;
|
|||
/*!50003 SET collation_connection = @saved_col_connection */ ;
|
||||
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
|
||||
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
|
||||
/*!50003 DROP PROCEDURE IF EXISTS `invoiceOutTaxAndExpence` */;
|
||||
/*!50003 DROP PROCEDURE IF EXISTS `invoiceOutTaxAndExpense` */;
|
||||
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
|
||||
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
|
||||
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
|
||||
|
@ -58852,7 +58853,7 @@ DELIMITER ;
|
|||
/*!50003 SET character_set_results = utf8mb4 */ ;
|
||||
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
|
||||
DELIMITER ;;
|
||||
CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceOutTaxAndExpence`()
|
||||
CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceOutTaxAndExpense`()
|
||||
BEGIN
|
||||
|
||||
/* Para tickets ya facturados, vuelve a repetir el proceso de facturación.
|
||||
|
@ -58906,7 +58907,7 @@ BEGIN
|
|||
FROM ticket
|
||||
WHERE refFk = vInvoiceRef;
|
||||
|
||||
CALL invoiceExpenceMake(vInvoice);
|
||||
CALL invoiceExpenseMake(vInvoice);
|
||||
CALL invoiceTaxMake(vInvoice,vCountry,vTaxArea);
|
||||
|
||||
FETCH rs INTO vInvoice ,vInvoiceRef;
|
||||
|
@ -59140,13 +59141,13 @@ BEGIN
|
|||
INSERT INTO ticketTracking(stateFk,ticketFk,workerFk)
|
||||
SELECT * FROM tmp.updateInter;
|
||||
|
||||
CALL invoiceExpenceMake(vNewInvoiceId);
|
||||
CALL invoiceExpenseMake(vNewInvoiceId);
|
||||
CALL invoiceTaxMake(vNewInvoiceId,vTaxArea);
|
||||
|
||||
UPDATE invoiceOut io
|
||||
JOIN (
|
||||
SELECT SUM(amount) total
|
||||
FROM invoiceOutExpence
|
||||
FROM invoiceOutExpense
|
||||
WHERE invoiceOutFk = vNewInvoiceId
|
||||
) base
|
||||
JOIN (
|
||||
|
@ -59183,15 +59184,15 @@ BEGIN
|
|||
SET @vTaxableBaseServices := 0.00;
|
||||
SET @vTaxCodeGeneral := NULL;
|
||||
|
||||
INSERT INTO invoiceInTax(invoiceInFk, taxableBase, expenceFk, taxTypeSageFk, transactionTypeSageFk)
|
||||
INSERT INTO invoiceInTax(invoiceInFk, taxableBase, expenseFk, taxTypeSageFk, transactionTypeSageFk)
|
||||
SELECT vNewInvoiceInFk,
|
||||
@vTaxableBaseServices,
|
||||
sub.expenceFk,
|
||||
sub.expenseFk,
|
||||
sub.taxTypeSageFk,
|
||||
sub.transactionTypeSageFk
|
||||
FROM (
|
||||
SELECT @vTaxableBaseServices := SUM(tst.taxableBase) taxableBase,
|
||||
i.expenceFk,
|
||||
i.expenseFk,
|
||||
i.taxTypeSageFk,
|
||||
i.transactionTypeSageFk,
|
||||
@vTaxCodeGeneral := i.taxClassCodeFk
|
||||
|
@ -59201,11 +59202,11 @@ BEGIN
|
|||
HAVING taxableBase
|
||||
) sub;
|
||||
|
||||
INSERT INTO invoiceInTax(invoiceInFk, taxableBase, expenceFk, taxTypeSageFk, transactionTypeSageFk)
|
||||
INSERT INTO invoiceInTax(invoiceInFk, taxableBase, expenseFk, taxTypeSageFk, transactionTypeSageFk)
|
||||
SELECT vNewInvoiceInFk,
|
||||
SUM(tt.taxableBase) - IF(tt.code = @vTaxCodeGeneral,
|
||||
@vTaxableBaseServices, 0) taxableBase,
|
||||
i.expenceFk,
|
||||
i.expenseFk,
|
||||
i.taxTypeSageFk ,
|
||||
i.transactionTypeSageFk
|
||||
FROM tmp.ticketTax tt
|
||||
|
|
|
@ -1,123 +0,0 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
|
||||
|
||||
// 2277 solucionar problema al testear procedimiento con start transaction / rollback
|
||||
xdescribe('ticket_componentMakeUpdate()', () => {
|
||||
it('should recalculate the ticket components without make modifications', async() => {
|
||||
let stmts = [];
|
||||
let stmt;
|
||||
|
||||
let params = {
|
||||
ticketId: 11,
|
||||
clientId: 1102,
|
||||
agencyModeId: 2,
|
||||
addressId: 122,
|
||||
zoneId: 3,
|
||||
warehouseId: 1,
|
||||
companyId: 442,
|
||||
isDeleted: 0,
|
||||
hasToBeUnrouted: 0,
|
||||
componentOption: 1
|
||||
};
|
||||
|
||||
stmts.push('START TRANSACTION');
|
||||
|
||||
stmt = new ParameterizedSQL('SELECT * FROM vn.ticket WHERE id = ?', [
|
||||
params.ticketId
|
||||
]);
|
||||
stmts.push(stmt);
|
||||
|
||||
let originalTicketIndex = stmts.push(stmt) - 1;
|
||||
|
||||
stmt = new ParameterizedSQL('CALL vn.ticket_componentMakeUpdate(?, ?, ?, ?, ?, ?, ?, DATE_ADD(CURDATE(), INTERVAL +1 DAY), DATE_ADD(CURDATE(), INTERVAL +1 DAY), ?, ?, ?)', [
|
||||
params.ticketId,
|
||||
params.clientId,
|
||||
params.agencyModeId,
|
||||
params.addressId,
|
||||
params.zoneId,
|
||||
params.warehouseId,
|
||||
params.companyId,
|
||||
params.isDeleted,
|
||||
params.hasToBeUnrouted,
|
||||
params.componentOption
|
||||
]);
|
||||
stmts.push(stmt);
|
||||
|
||||
stmt = new ParameterizedSQL('SELECT * FROM vn.ticket WHERE id = ?', [
|
||||
params.ticketId
|
||||
]);
|
||||
stmts.push(stmt);
|
||||
|
||||
let updatedTicketIndex = stmts.push(stmt) - 1;
|
||||
|
||||
stmts.push('ROLLBACK');
|
||||
|
||||
let sql = ParameterizedSQL.join(stmts, ';');
|
||||
let result = await app.models.Ticket.rawStmt(sql);
|
||||
|
||||
let originalTicketData = result[originalTicketIndex];
|
||||
let updatedTicketData = result[updatedTicketIndex];
|
||||
|
||||
expect(originalTicketData[0].isDeleted).toEqual(updatedTicketData[0].isDeleted);
|
||||
expect(originalTicketData[0].routeFk).toEqual(updatedTicketData[0].routeFk);
|
||||
});
|
||||
|
||||
it('should delete and unroute a ticket and recalculate the components', async() => {
|
||||
let stmts = [];
|
||||
let stmt;
|
||||
|
||||
let params = {
|
||||
ticketId: 11,
|
||||
clientId: 1102,
|
||||
agencyModeId: 2,
|
||||
addressId: 122,
|
||||
zoneId: 3,
|
||||
warehouseId: 1,
|
||||
companyId: 442,
|
||||
isDeleted: 1,
|
||||
hasToBeUnrouted: 1,
|
||||
componentOption: 1
|
||||
};
|
||||
|
||||
stmts.push('START TRANSACTION');
|
||||
|
||||
stmt = new ParameterizedSQL('SELECT * FROM vn.ticket WHERE id = ?', [
|
||||
params.ticketId
|
||||
]);
|
||||
stmts.push(stmt);
|
||||
|
||||
let originalTicketIndex = stmts.push(stmt) - 1;
|
||||
|
||||
stmt = new ParameterizedSQL('CALL vn.ticket_componentMakeUpdate(?, ?, ?, ?, ?, ?, ?, DATE_ADD(CURDATE(), INTERVAL +1 DAY), DATE_ADD(CURDATE(), INTERVAL +1 DAY), ?, ?, ?)', [
|
||||
params.ticketId,
|
||||
params.clientId,
|
||||
params.agencyModeId,
|
||||
params.addressId,
|
||||
params.zoneId,
|
||||
params.warehouseId,
|
||||
params.companyId,
|
||||
params.isDeleted,
|
||||
params.hasToBeUnrouted,
|
||||
params.componentOption
|
||||
]);
|
||||
stmts.push(stmt);
|
||||
|
||||
stmt = new ParameterizedSQL('SELECT * FROM vn.ticket WHERE id = ?', [
|
||||
params.ticketId
|
||||
]);
|
||||
stmts.push(stmt);
|
||||
|
||||
let updatedTicketIndex = stmts.push(stmt) - 1;
|
||||
|
||||
stmts.push('ROLLBACK');
|
||||
|
||||
let sql = ParameterizedSQL.join(stmts, ';');
|
||||
let result = await app.models.Ticket.rawStmt(sql);
|
||||
|
||||
let originalTicketData = result[originalTicketIndex];
|
||||
let updatedTicketData = result[updatedTicketIndex];
|
||||
|
||||
expect(originalTicketData[0].isDeleted).not.toEqual(updatedTicketData[0].isDeleted);
|
||||
expect(originalTicketData[0].routeFk).not.toEqual(updatedTicketData[0].routeFk);
|
||||
});
|
||||
});
|
|
@ -56,63 +56,6 @@ describe('Worker time control path', () => {
|
|||
expect(result).toContain(month);
|
||||
});
|
||||
|
||||
it(`should return error when insert 'out' of first entry`, async() => {
|
||||
pending('https://redmine.verdnatura.es/issues/4707');
|
||||
await page.waitToClick(selectors.workerTimeControl.mondayAddTimeButton);
|
||||
await page.pickTime(selectors.workerTimeControl.dialogTimeInput, eightAm);
|
||||
await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'out');
|
||||
await page.respondToDialog('accept');
|
||||
const message = await page.waitForSnackbar();
|
||||
|
||||
expect(message.text).toBeDefined();
|
||||
});
|
||||
|
||||
it(`should insert 'in' monday`, async() => {
|
||||
pending('https://redmine.verdnatura.es/issues/4707');
|
||||
await page.waitToClick(selectors.workerTimeControl.mondayAddTimeButton);
|
||||
await page.pickTime(selectors.workerTimeControl.dialogTimeInput, eightAm);
|
||||
await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'in');
|
||||
await page.respondToDialog('accept');
|
||||
const result = await page.waitToGetProperty(selectors.workerTimeControl.firstEntryOfMonday, 'innerText');
|
||||
|
||||
expect(result).toEqual(eightAm);
|
||||
});
|
||||
|
||||
it(`should insert 'out' monday`, async() => {
|
||||
pending('https://redmine.verdnatura.es/issues/4707');
|
||||
await page.waitToClick(selectors.workerTimeControl.mondayAddTimeButton);
|
||||
await page.pickTime(selectors.workerTimeControl.dialogTimeInput, fourPm);
|
||||
await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'out');
|
||||
await page.respondToDialog('accept');
|
||||
const result = await page.waitToGetProperty(selectors.workerTimeControl.secondEntryOfMonday, 'innerText');
|
||||
|
||||
expect(result).toEqual(fourPm);
|
||||
});
|
||||
|
||||
it(`should check Hank Pym worked 8:20 hours`, async() => {
|
||||
pending('https://redmine.verdnatura.es/issues/4707');
|
||||
await page.waitForTextInElement(selectors.workerTimeControl.mondayWorkedHours, '08:20 h.');
|
||||
await page.waitForTextInElement(selectors.workerTimeControl.weekWorkedHours, '08:20 h.');
|
||||
});
|
||||
|
||||
it('should remove first entry of monday', async() => {
|
||||
pending('https://redmine.verdnatura.es/issues/4707');
|
||||
await page.waitForTextInElement(selectors.workerTimeControl.firstEntryOfMonday, eightAm);
|
||||
await page.waitForTextInElement(selectors.workerTimeControl.secondEntryOfMonday, fourPm);
|
||||
await page.waitToClick(selectors.workerTimeControl.firstEntryOfMondayDelete);
|
||||
await page.respondToDialog('accept');
|
||||
const message = await page.waitForSnackbar();
|
||||
|
||||
expect(message.text).toContain('Entry removed');
|
||||
});
|
||||
|
||||
it(`should be the 'out' the first entry of monday`, async() => {
|
||||
pending('https://redmine.verdnatura.es/issues/4707');
|
||||
const result = await page.waitToGetProperty(selectors.workerTimeControl.firstEntryOfMonday, 'innerText');
|
||||
|
||||
expect(result).toEqual(fourPm);
|
||||
});
|
||||
|
||||
it('should change week of month', async() => {
|
||||
await page.click(selectors.workerTimeControl.thrirdWeekDay);
|
||||
const result = await page.getProperty(selectors.workerTimeControl.mondayWorkedHours, 'innerText');
|
||||
|
|
|
@ -188,17 +188,6 @@ describe('Ticket Edit sale path', () => {
|
|||
expect(result).toContain('22.50');
|
||||
});
|
||||
|
||||
it('should check in the history that logs has been added', async() => {
|
||||
pending('https://redmine.verdnatura.es/issues/5455');
|
||||
await page.reload({waitUntil: ['networkidle0', 'domcontentloaded']});
|
||||
await page.waitToClick(selectors.ticketSales.firstSaleHistoryButton);
|
||||
await page.waitForSelector(selectors.ticketSales.firstSaleHistory);
|
||||
const result = await page.countElement(selectors.ticketSales.firstSaleHistory);
|
||||
|
||||
expect(result).toBeGreaterThan(0);
|
||||
await page.waitToClick(selectors.ticketSales.closeHistory);
|
||||
});
|
||||
|
||||
it('should recalculate price of sales', async() => {
|
||||
await page.waitToClick(selectors.ticketSales.firstSaleCheckbox);
|
||||
await page.waitToClick(selectors.ticketSales.secondSaleCheckbox);
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
import selectors from '../../helpers/selectors.js';
|
||||
import getBrowser from '../../helpers/puppeteer';
|
||||
|
||||
// #2221 Local MySQL8 crashes when rest method Items/getBalance is called
|
||||
xdescribe('Ticket diary path', () => {
|
||||
let page;
|
||||
|
||||
beforeAll(async() => {
|
||||
page = (await getBrowser()).page;
|
||||
await page.loginAndModule('employee', 'ticket');
|
||||
});
|
||||
|
||||
afterAll(async() => {
|
||||
await page.browser().close();
|
||||
});
|
||||
|
||||
it(`should navigate to item diary from ticket sale and check the lines`, async() => {
|
||||
await page.accessToSearchResult('1');
|
||||
await page.waitToClick(selectors.ticketSummary.firstSaleItemId);
|
||||
await page.waitToClick(selectors.ticketSummary.popoverDiaryButton);
|
||||
await page.waitForState('item.card.diary');
|
||||
|
||||
const secondIdClass = await page.getClassName(selectors.itemDiary.secondTicketId);
|
||||
const fourthBalanceClass = await page.getClassName(selectors.itemDiary.fourthBalance);
|
||||
const firstBalanceClass = await page.getClassName(selectors.itemDiary.firstBalance);
|
||||
|
||||
expect(secondIdClass).toContain('message');
|
||||
expect(fourthBalanceClass).toContain('message');
|
||||
expect(firstBalanceClass).toContain('balance');
|
||||
});
|
||||
});
|
|
@ -35,7 +35,7 @@ describe('Ticket index payout path', () => {
|
|||
await page.waitToClick(selectors.ticketsIndex.openAdvancedSearchButton);
|
||||
await page.write(selectors.ticketsIndex.advancedSearchClient, '1101');
|
||||
await page.keyboard.press('Enter');
|
||||
await page.waitForNumberOfElements(selectors.ticketsIndex.anySearchResult, 9);
|
||||
await page.waitForNumberOfElements(selectors.ticketsIndex.anySearchResult, 10);
|
||||
await page.waitToClick(selectors.ticketsIndex.firstTicketCheckbox);
|
||||
await page.waitToClick(selectors.ticketsIndex.secondTicketCheckbox);
|
||||
|
||||
|
|
|
@ -1,114 +0,0 @@
|
|||
import selectors from '../../helpers/selectors.js';
|
||||
import getBrowser from '../../helpers/puppeteer.js';
|
||||
|
||||
// #1528 e2e claim/detail
|
||||
xdescribe('Claim detail', () => {
|
||||
let browser;
|
||||
let page;
|
||||
|
||||
beforeAll(async() => {
|
||||
browser = await getBrowser();
|
||||
page = browser.page;
|
||||
await page.loginAndModule('salesPerson', 'claim');
|
||||
await page.accessToSearchResult('1');
|
||||
await page.accessToSection('claim.card.detail');
|
||||
});
|
||||
|
||||
afterAll(async() => {
|
||||
await browser.close();
|
||||
});
|
||||
|
||||
it('should add the first claimable item from ticket to the claim', async() => {
|
||||
await page.waitToClick(selectors.claimDetail.addItemButton);
|
||||
await page.waitToClick(selectors.claimDetail.firstClaimableSaleFromTicket);
|
||||
const message = await page.waitForSnackbar();
|
||||
|
||||
expect(message.text).toContain('Data saved!');
|
||||
});
|
||||
|
||||
it('should confirm the claim contains now two items', async() => {
|
||||
const result = await page.countElement(selectors.claimDetail.claimDetailLine);
|
||||
|
||||
expect(result).toEqual(2);
|
||||
});
|
||||
|
||||
it('should edit de first item claimed quantity', async() => {
|
||||
await page.clearInput(selectors.claimDetail.firstItemQuantityInput); // selector deleted, find new upon fixes
|
||||
await page.write(selectors.claimDetail.firstItemQuantityInput, '4'); // selector deleted, find new upon fixes
|
||||
await page.keyboard.press('Enter');
|
||||
const message = await page.waitForSnackbar();
|
||||
|
||||
expect(message.text).toContain('Data saved!');
|
||||
});
|
||||
|
||||
it('should confirm the first item quantity, and the claimed total were correctly edited', async() => {
|
||||
const claimedQuantity = page
|
||||
.waitToGetProperty(selectors.claimDetail.firstItemQuantityInput, 'value'); // selector deleted, find new upon fixes
|
||||
|
||||
const totalClaimed = page
|
||||
.waitToGetProperty(selectors.claimDetail.totalClaimed, 'innerText');
|
||||
|
||||
expect(claimedQuantity).toEqual('4');
|
||||
expect(totalClaimed).toContain('€47.62');
|
||||
});
|
||||
|
||||
it('should login as salesAssistant and navigate to the claim.detail section', async() => {
|
||||
await page.loginAndModule('salesAssistant', 'claim');
|
||||
await page.accessToSearchResult('1');
|
||||
await page.accessToSection('claim.card.detail');
|
||||
let url = await page.expectURL('/detail'); // replace with waitForState
|
||||
|
||||
expect(url).toBe(true);
|
||||
});
|
||||
|
||||
it('should edit de second item claimed discount', async() => {
|
||||
await page.waitToClick(selectors.claimDetail.secondItemDiscount);
|
||||
await page.write(selectors.claimDetail.discount, '100');
|
||||
await page.keyboard.press('Enter');
|
||||
const message = await page.waitForSnackbar();
|
||||
|
||||
expect(message.text).toContain('Data saved!');
|
||||
});
|
||||
|
||||
it('should check the mana is the expected one', async() => {
|
||||
await page.waitToClick(selectors.claimDetail.secondItemDiscount);
|
||||
const result = await page.waitToGetProperty(selectors.claimDetail.discoutPopoverMana, 'innerText');
|
||||
|
||||
expect(result).toContain('MANÁ: €106');
|
||||
});
|
||||
|
||||
it('should delete the second item from the claim', async() => {
|
||||
await page.waitToClick(selectors.claimDetail.secondItemDeleteButton);
|
||||
const message = await page.waitForSnackbar();
|
||||
|
||||
expect(message.text).toContain('Data saved!');
|
||||
});
|
||||
|
||||
it('should confirm the claim contains now one item', async() => {
|
||||
const result = await page.countElement(selectors.claimDetail.claimDetailLine);
|
||||
|
||||
expect(result).toEqual(1);
|
||||
});
|
||||
|
||||
it('should add the deleted ticket from to the claim', async() => {
|
||||
await page.waitToClick(selectors.claimDetail.addItemButton);
|
||||
await page.waitToClick(selectors.claimDetail.firstClaimableSaleFromTicket);
|
||||
const message = await page.waitForSnackbar();
|
||||
|
||||
expect(message.text).toContain('Data saved!');
|
||||
});
|
||||
|
||||
it(`should have been redirected to the next section in claims`, async() => {
|
||||
let url = await page.expectURL('development'); // replace with waitForState
|
||||
|
||||
expect(url).toBe(true);
|
||||
});
|
||||
|
||||
it('should navigate back to claim.detail to confirm the claim contains now two items', async() => {
|
||||
await page.accessToSection('claim.card.detail');
|
||||
await page.waitForSelector(selectors.claimDetail.claimDetailLine);
|
||||
const result = await page.countElement(selectors.claimDetail.claimDetailLine);
|
||||
|
||||
expect(result).toEqual(2);
|
||||
});
|
||||
});
|
|
@ -26,7 +26,7 @@ describe('Route create path', () => {
|
|||
await page.waitToClick(selectors.createRouteView.submitButton);
|
||||
const message = await page.waitForSnackbar();
|
||||
|
||||
expect(message.text).toContain('Access denied');
|
||||
expect(message.text).toContain('Access Denied');
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@ describe('InvoiceOut summary path', () => {
|
|||
|
||||
it('should contain the tax breakdown', async() => {
|
||||
const firstTax = await page.waitToGetProperty(selectors.invoiceOutSummary.taxOne, 'innerText');
|
||||
|
||||
const secondTax = await page.waitToGetProperty(selectors.invoiceOutSummary.taxTwo, 'innerText');
|
||||
|
||||
expect(firstTax).toContain('10%');
|
||||
|
@ -37,10 +36,9 @@ describe('InvoiceOut summary path', () => {
|
|||
|
||||
it('should contain the tickets info', async() => {
|
||||
const firstTicket = await page.waitToGetProperty(selectors.invoiceOutSummary.ticketOne, 'innerText');
|
||||
|
||||
const secondTicket = await page.waitToGetProperty(selectors.invoiceOutSummary.ticketTwo, 'innerText');
|
||||
|
||||
expect(firstTicket).toContain('Bat cave');
|
||||
expect(secondTicket).toContain('Stark tower');
|
||||
expect(secondTicket).toContain('Bat cave');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -105,17 +105,4 @@ describe('Travel basic data path', () => {
|
|||
it(`should check the received checkbox was saved even tho it doesn't make sense`, async() => {
|
||||
await page.waitForClassPresent(selectors.travelBasicData.received, 'checked');
|
||||
});
|
||||
|
||||
it('should navigate to the travel logs', async() => {
|
||||
pending('https://redmine.verdnatura.es/issues/5455');
|
||||
await page.accessToSection('travel.card.log');
|
||||
await page.waitForState('travel.card.log');
|
||||
});
|
||||
|
||||
it('should check the 1st log contains details from the changes made', async() => {
|
||||
pending('https://redmine.verdnatura.es/issues/5455');
|
||||
const result = await page.waitToGetProperty(selectors.travelLog.firstLogFirstTD, 'innerText');
|
||||
|
||||
expect(result).toContain('new reference!');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -33,18 +33,6 @@ describe('Component vnTreeview', () => {
|
|||
$element.remove();
|
||||
});
|
||||
|
||||
// See how to test DOM element in Jest
|
||||
xdescribe('undrop()', () => {
|
||||
it(`should reset all drop events and properties`, () => {
|
||||
controller.dropping = angular.element(`<vn-treeview-child class="dropping"></vn-treeview-child>`);
|
||||
jest.spyOn(controller.dropping.classList, 'remove');
|
||||
|
||||
controller.undrop();
|
||||
|
||||
expect(controller.dropping).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('dragOver()', () => {
|
||||
it(`should set the dragClientY property`, () => {
|
||||
const event = new Event('dragover');
|
||||
|
|
|
@ -23,7 +23,6 @@ export function directive($translate, $window) {
|
|||
let rule = $attrs.rule.split('.');
|
||||
let modelName = rule.shift();
|
||||
let fieldName = rule.shift();
|
||||
|
||||
let split = $attrs.ngModel.split('.');
|
||||
if (!fieldName) fieldName = split.pop() || null;
|
||||
if (!modelName) modelName = firstUpper(split.pop() || '');
|
||||
|
|
|
@ -68,3 +68,4 @@ Load more results: Cargar más resultados
|
|||
Send cau: Enviar cau
|
||||
By sending this ticket, all the data related to the error, the section, the user, etc., are already sent.: Al enviar este cau ya se envían todos los datos relacionados con el error, la sección, el usuario, etc
|
||||
ExplainReason: Explique el motivo por el que no deberia aparecer este fallo
|
||||
You already have the mailAlias: Ya tienes este alias de correo
|
||||
|
|
|
@ -3,4 +3,4 @@ Could not contact the server: Could not contact the server, make sure you have a
|
|||
Please enter your username: Please enter your username
|
||||
It seems that the server has fall down: It seems that the server has fall down, wait a few minutes and try again
|
||||
Session has expired: Your session has expired, please login again
|
||||
Access denied: Access denied
|
||||
Access Denied: Access Denied
|
|
@ -3,5 +3,5 @@ Could not contact the server: No se ha podido contactar con el servidor, asegura
|
|||
Please enter your username: Por favor introduce tu nombre de usuario
|
||||
It seems that the server has fall down: Parece que el servidor se ha caído, espera unos minutos e inténtalo de nuevo
|
||||
Session has expired: Tu sesión ha expirado, por favor vuelve a iniciar sesión
|
||||
Access denied: Acción no permitida
|
||||
Access Denied: Acción no permitida
|
||||
Direction not found: Dirección no encontrada
|
||||
|
|
|
@ -82,7 +82,7 @@ export default class Token {
|
|||
if (!data) return;
|
||||
this.renewPeriod = data.renewPeriod;
|
||||
this.stopRenewer();
|
||||
this.inservalId = setInterval(() => this.checkValidity(), data.renewInterval * 1000);
|
||||
this.intervalId = setInterval(() => this.checkValidity(), data.renewInterval * 1000);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -103,17 +103,13 @@ export default class Token {
|
|||
const token = res.data;
|
||||
this.set(token.id, now, token.ttl, this.remember);
|
||||
})
|
||||
.catch(res => {
|
||||
if (res.data?.error?.code !== 'periodNotExceeded')
|
||||
throw res;
|
||||
})
|
||||
.finally(() => {
|
||||
this.checking = false;
|
||||
});
|
||||
}
|
||||
|
||||
stopRenewer() {
|
||||
clearInterval(this.inservalId);
|
||||
clearInterval(this.intervalId);
|
||||
}
|
||||
}
|
||||
Token.$inject = ['vnInterceptor', '$http', '$rootScope'];
|
||||
|
|
|
@ -18,6 +18,7 @@ Show summary: Mostrar vista previa
|
|||
What is new: Novedades de la versión
|
||||
Settings: Ajustes
|
||||
There is a new version, click here to reload: Hay una nueva versión, pulse aquí para recargar
|
||||
This ticket is locked: Este ticket está bloqueado
|
||||
|
||||
# Actions
|
||||
|
||||
|
|
|
@ -120,7 +120,7 @@ function $exceptionHandler(vnApp, $window, $state, $injector) {
|
|||
messageT = 'Invalid login';
|
||||
break;
|
||||
case 403:
|
||||
messageT = 'Access denied';
|
||||
messageT = exception.data?.error?.message || 'Access Denied';
|
||||
break;
|
||||
case 502:
|
||||
messageT = 'It seems that the server has fall down';
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
const LoopBackContext = require('loopback-context');
|
||||
async function handleObserve(ctx) {
|
||||
ctx.options.httpCtx = LoopBackContext.getCurrentContext();
|
||||
}
|
||||
module.exports = function(Self) {
|
||||
let Mixin = {
|
||||
'before save': handleObserve,
|
||||
'before delete': handleObserve,
|
||||
};
|
||||
for (const [listener, handler] of Object.entries(Mixin))
|
||||
Self.observe(listener, handler);
|
||||
};
|
|
@ -1,15 +0,0 @@
|
|||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
module.exports = function(Self) {
|
||||
Self.setup = function() {
|
||||
Self.super_.setup.call(this);
|
||||
};
|
||||
|
||||
Self.observe('before save', async function(ctx) {
|
||||
ctx.options.httpCtx = LoopBackContext.getCurrentContext();
|
||||
});
|
||||
|
||||
Self.observe('before delete', async function(ctx) {
|
||||
ctx.options.httpCtx = LoopBackContext.getCurrentContext();
|
||||
});
|
||||
};
|
|
@ -1,5 +0,0 @@
|
|||
{
|
||||
"name": "Loggable",
|
||||
"base": "VnModel",
|
||||
"validateUpsert": true
|
||||
}
|
|
@ -45,6 +45,7 @@
|
|||
"Extension format is invalid": "Extension format is invalid",
|
||||
"NO_ZONE_FOR_THIS_PARAMETERS": "NO_ZONE_FOR_THIS_PARAMETERS",
|
||||
"This client can't be invoiced": "This client can't be invoiced",
|
||||
"You must provide the correction information to generate a corrective invoice": "You must provide the correction information to generate a corrective invoice",
|
||||
"The introduced hour already exists": "The introduced hour already exists",
|
||||
"Invalid parameters to create a new ticket": "Invalid parameters to create a new ticket",
|
||||
"Concept cannot be blank": "Concept cannot be blank",
|
||||
|
@ -178,12 +179,13 @@
|
|||
"The renew period has not been exceeded": "The renew period has not been exceeded",
|
||||
"You can not use the same password": "You can not use the same password",
|
||||
"Valid priorities": "Valid priorities: %d",
|
||||
"Negative basis of tickets": "Negative basis of tickets: {{ticketsIds}}",
|
||||
"hasAnyNegativeBase": "Negative basis of tickets: {{ticketsIds}}",
|
||||
"hasAnyPositiveBase": "Positive basis of tickets: {{ticketsIds}}",
|
||||
"This ticket cannot be left empty.": "This ticket cannot be left empty. %s",
|
||||
"Social name should be uppercase": "Social name should be uppercase",
|
||||
"Street should be uppercase": "Street should be uppercase",
|
||||
"You don't have enough privileges.": "You don't have enough privileges.",
|
||||
"This ticket is locked.": "This ticket is locked.",
|
||||
"This ticket is locked": "This ticket is locked",
|
||||
"This ticket is not editable.": "This ticket is not editable.",
|
||||
"The ticket doesn't exist.": "The ticket doesn't exist.",
|
||||
"The sales do not exists": "The sales do not exists",
|
||||
|
@ -200,5 +202,7 @@
|
|||
"Try again": "Try again",
|
||||
"keepPrice": "keepPrice",
|
||||
"Cannot past travels with entries": "Cannot past travels with entries",
|
||||
"The notification subscription of this worker cant be modified": "The notification subscription of this worker cant be modified"
|
||||
"The notification subscription of this worker cant be modified": "The notification subscription of this worker cant be modified",
|
||||
"It was not able to remove the next expeditions:": "It was not able to remove the next expeditions: {{expeditions}}",
|
||||
"Incorrect pin": "Incorrect pin."
|
||||
}
|
||||
|
|
|
@ -72,6 +72,7 @@
|
|||
"The secret can't be blank": "La contraseña no puede estar en blanco",
|
||||
"We weren't able to send this SMS": "No hemos podido enviar el SMS",
|
||||
"This client can't be invoiced": "Este cliente no puede ser facturado",
|
||||
"You must provide the correction information to generate a corrective invoice": "Debes informar la información de corrección para generar una factura rectificativa",
|
||||
"This ticket can't be invoiced": "Este ticket no puede ser facturado",
|
||||
"You cannot add or modify services to an invoiced ticket": "No puedes añadir o modificar servicios a un ticket facturado",
|
||||
"This ticket can not be modified": "Este ticket no puede ser modificado",
|
||||
|
@ -305,14 +306,15 @@
|
|||
"Mail not sent": "Se ha producido un fallo al enviar la factura al cliente [{{clientId}}]({{{clientUrl}}}), por favor revisa la dirección de correo electrónico",
|
||||
"The renew period has not been exceeded": "El periodo de renovación no ha sido superado",
|
||||
"Valid priorities": "Prioridades válidas: %d",
|
||||
"Negative basis of tickets": "Base negativa para los tickets: {{ticketsIds}}",
|
||||
"hasAnyNegativeBase": "Base negativa para los tickets: {{ticketsIds}}",
|
||||
"hasAnyPositiveBase": "Base positivas para los tickets: {{ticketsIds}}",
|
||||
"You cannot assign an alias that you are not assigned to": "No puede asignar un alias que no tenga asignado",
|
||||
"This ticket cannot be left empty.": "Este ticket no se puede dejar vacío. %s",
|
||||
"The company has not informed the supplier account for bank transfers": "La empresa no tiene informado la cuenta de proveedor para transferencias bancarias",
|
||||
"You cannot assign/remove an alias that you are not assigned to": "No puede asignar/eliminar un alias que no tenga asignado",
|
||||
"This invoice has a linked vehicle.": "Esta factura tiene un vehiculo vinculado",
|
||||
"You don't have enough privileges.": "No tienes suficientes permisos.",
|
||||
"This ticket is locked.": "Este ticket está bloqueado.",
|
||||
"This ticket is locked": "Este ticket está bloqueado.",
|
||||
"This ticket is not editable.": "Este ticket no es editable.",
|
||||
"The ticket doesn't exist.": "No existe el ticket.",
|
||||
"Social name should be uppercase": "La razón social debe ir en mayúscula",
|
||||
|
@ -328,5 +330,11 @@
|
|||
"User disabled": "Usuario desactivado",
|
||||
"The amount cannot be less than the minimum": "La cantidad no puede ser menor que la cantidad mínima",
|
||||
"quantityLessThanMin": "La cantidad no puede ser menor que la cantidad mínima",
|
||||
"Cannot past travels with entries": "No se pueden pasar envíos con entradas"
|
||||
"Cannot past travels with entries": "No se pueden pasar envíos con entradas",
|
||||
"It was not able to remove the next expeditions:": "No se pudo eliminar las siguientes expediciones: {{expeditions}}",
|
||||
"This user does not have an assigned tablet": "Este usuario no tiene tablet asignada",
|
||||
"Incorrect pin": "Pin incorrecto.",
|
||||
"You already have the mailAlias": "Ya tienes este alias de correo",
|
||||
"The alias cant be modified": "Este alias de correo no puede ser modificado",
|
||||
"No tickets to invoice": "No hay tickets para facturar"
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
module.exports = () => {
|
||||
Date.vnUTC = () => {
|
||||
const env = process.env.NODE_ENV;
|
||||
Date.vnUTC = (env = process.env.NODE_ENV) => {
|
||||
if (!env || env === 'development')
|
||||
return new Date(Date.UTC(2001, 0, 1, 11));
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
"./middleware/salix-version": {}
|
||||
},
|
||||
"parse": {
|
||||
"body-parser#json":{}
|
||||
"body-parser#json":{}
|
||||
},
|
||||
"routes": {
|
||||
"loopback#rest": {
|
||||
|
|
|
@ -25,20 +25,19 @@
|
|||
"FieldAcl": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"Role": {
|
||||
"dataSource": "vn",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "salix.Role"
|
||||
}
|
||||
}
|
||||
},
|
||||
"RoleMapping": {
|
||||
"dataSource": "vn",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "salix.RoleMapping"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"role": {
|
||||
"type": "belongsTo",
|
||||
"model": "VnRole",
|
||||
"foreignKey": "roleId"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Schema": {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
const NotFoundError = require('vn-loopback/util/not-found-error');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethod('test', {
|
||||
|
@ -9,7 +10,8 @@ module.exports = Self => {
|
|||
});
|
||||
|
||||
Self.test = async function() {
|
||||
let connector = await Self.getSynchronizer();
|
||||
const connector = await Self.getLinker();
|
||||
if (!connector) throw new NotFoundError('Linker not configured');
|
||||
await connector.test();
|
||||
};
|
||||
};
|
|
@ -2,7 +2,7 @@ const {models} = require('vn-loopback/server/server');
|
|||
|
||||
describe('account changePassword()', () => {
|
||||
const userId = 70;
|
||||
const unauthCtx = {
|
||||
const unAuthCtx = {
|
||||
req: {
|
||||
headers: {},
|
||||
connection: {
|
||||
|
@ -79,7 +79,7 @@ describe('account changePassword()', () => {
|
|||
passExpired: yesterday
|
||||
}
|
||||
, options);
|
||||
await models.VnUser.signIn(unauthCtx, 'trainee', 'nightmare', options);
|
||||
await models.VnUser.signIn(unAuthCtx, 'trainee', 'nightmare', options);
|
||||
} catch (e) {
|
||||
if (e.message != 'Pass expired')
|
||||
throw e;
|
||||
|
|
|
@ -26,24 +26,46 @@ module.exports = Self => {
|
|||
});
|
||||
|
||||
Self.sync = async function(userName, password, force, options) {
|
||||
const models = Self.app.models;
|
||||
const myOptions = {};
|
||||
|
||||
let tx;
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
const models = Self.app.models;
|
||||
const user = await models.VnUser.findOne({
|
||||
fields: ['id', 'password'],
|
||||
where: {name: userName}
|
||||
}, myOptions);
|
||||
if (!myOptions.transaction) {
|
||||
tx = await Self.beginTransaction({});
|
||||
myOptions.transaction = tx;
|
||||
};
|
||||
|
||||
if (user && password && !await user.hasPassword(password))
|
||||
throw new ForbiddenError('Wrong password');
|
||||
try {
|
||||
const user = await models.VnUser.findOne({
|
||||
fields: ['id', 'password'],
|
||||
where: {name: userName}
|
||||
}, myOptions);
|
||||
|
||||
const isSync = !await models.UserSync.exists(userName, myOptions);
|
||||
if (user && password && !await user.hasPassword(password))
|
||||
throw new ForbiddenError('Wrong password');
|
||||
|
||||
if (!force && isSync && user) return;
|
||||
await models.AccountConfig.syncUser(userName, password);
|
||||
await models.UserSync.destroyById(userName, myOptions);
|
||||
const isSync = !await models.UserSync.exists(userName, myOptions);
|
||||
|
||||
if (!force && isSync && user) {
|
||||
if (tx) await tx.rollback();
|
||||
return;
|
||||
}
|
||||
|
||||
await Self.rawSql(`
|
||||
SELECT id
|
||||
FROM account.user
|
||||
WHERE id = ?
|
||||
FOR UPDATE`, [user.id], myOptions);
|
||||
|
||||
await models.AccountConfig.syncUser(userName, password);
|
||||
await models.UserSync.destroyById(userName, myOptions);
|
||||
if (tx) await tx.commit();
|
||||
} catch (err) {
|
||||
if (tx) await tx.rollback();
|
||||
throw err;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
|
@ -3,14 +3,14 @@ const app = require('vn-loopback/server/server');
|
|||
const UserError = require('vn-loopback/util/user-error');
|
||||
|
||||
module.exports = function(Self, options) {
|
||||
require('../methods/account-synchronizer/test')(Self);
|
||||
require('../methods/account-linker/test')(Self);
|
||||
|
||||
Self.once('attached', function() {
|
||||
app.models.AccountConfig.addSynchronizer(Self);
|
||||
app.models.AccountConfig.addLinker(Self);
|
||||
});
|
||||
|
||||
/**
|
||||
* Mixin for user synchronizers.
|
||||
* Mixin for account linkers.
|
||||
*
|
||||
* @property {Array<Model>} $
|
||||
* @property {Object} accountConfig
|
||||
|
@ -18,12 +18,12 @@ module.exports = function(Self, options) {
|
|||
*/
|
||||
let Mixin = {
|
||||
/**
|
||||
* Initalizes the synchronizer.
|
||||
* Initalizes the linker.
|
||||
*/
|
||||
async init() {},
|
||||
|
||||
/**
|
||||
* Deinitalizes the synchronizer.
|
||||
* Deinitalizes the linker.
|
||||
*/
|
||||
async deinit() {},
|
||||
|
||||
|
@ -57,7 +57,7 @@ module.exports = function(Self, options) {
|
|||
async syncRoles() {},
|
||||
|
||||
/**
|
||||
* Tests synchronizer configuration.
|
||||
* Tests linker configuration.
|
||||
*/
|
||||
async test() {
|
||||
try {
|
|
@ -14,6 +14,9 @@
|
|||
"MailAliasAccount": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"MailAliasAcl": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"MailConfig": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
|
|
|
@ -3,94 +3,85 @@ const models = require('vn-loopback/server/server').models;
|
|||
|
||||
module.exports = Self => {
|
||||
Object.assign(Self, {
|
||||
synchronizers: [],
|
||||
linkers: [],
|
||||
|
||||
addSynchronizer(synchronizer) {
|
||||
this.synchronizers.push(synchronizer);
|
||||
addLinker(linker) {
|
||||
this.linkers.push(linker);
|
||||
},
|
||||
|
||||
async getInstance() {
|
||||
let instance = await Self.findOne({
|
||||
async initEngine() {
|
||||
const accountConfig = await Self.findOne({
|
||||
fields: ['homedir', 'shell', 'idBase']
|
||||
});
|
||||
await instance.synchronizerInit();
|
||||
return instance;
|
||||
const mailConfig = await models.MailConfig.findOne({
|
||||
fields: ['domain']
|
||||
});
|
||||
|
||||
const linkers = [];
|
||||
|
||||
for (const Linker of Self.linkers) {
|
||||
const linker = await Linker.getLinker();
|
||||
if (!linker) continue;
|
||||
Object.assign(linker, {accountConfig});
|
||||
await linker.init();
|
||||
linkers.push(linker);
|
||||
}
|
||||
|
||||
Object.assign(accountConfig, {
|
||||
linkers,
|
||||
domain: mailConfig.domain
|
||||
});
|
||||
|
||||
return {
|
||||
accountConfig,
|
||||
linkers
|
||||
};
|
||||
},
|
||||
|
||||
async deinitEngine(engine) {
|
||||
for (const linker of engine.linkers)
|
||||
await linker.deinit();
|
||||
},
|
||||
|
||||
async syncUser(userName, password) {
|
||||
const engine = await Self.initEngine();
|
||||
try {
|
||||
await Self.syncUserBase(engine, userName, password, true);
|
||||
} finally {
|
||||
await Self.deinitEngine(engine);
|
||||
}
|
||||
},
|
||||
|
||||
async syncUsers() {
|
||||
let instance = await Self.getInstance();
|
||||
const engine = await Self.initEngine();
|
||||
|
||||
let usersToSync = new Set();
|
||||
for (const linker of engine.linkers)
|
||||
await linker.getUsers(usersToSync);
|
||||
|
||||
let usersToSync = await instance.synchronizerGetUsers();
|
||||
usersToSync = Array.from(usersToSync.values())
|
||||
.sort((a, b) => a.localeCompare(b));
|
||||
|
||||
for (let userName of usersToSync) {
|
||||
try {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(`Synchronizing user '${userName}'`);
|
||||
await instance.synchronizerSyncUser(userName);
|
||||
|
||||
await Self.syncUserBase(engine, userName);
|
||||
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(` -> User '${userName}' sinchronized`);
|
||||
} catch (err) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(` -> User '${userName}' synchronization error:`, err.message);
|
||||
}
|
||||
}
|
||||
|
||||
await instance.synchronizerDeinit();
|
||||
await Self.deinitEngine(engine);
|
||||
await Self.syncRoles();
|
||||
},
|
||||
|
||||
async syncUser(userName, password) {
|
||||
let instance = await Self.getInstance();
|
||||
try {
|
||||
await instance.synchronizerSyncUser(userName, password, true);
|
||||
} finally {
|
||||
await instance.synchronizerDeinit();
|
||||
}
|
||||
},
|
||||
|
||||
async syncRoles() {
|
||||
let instance = await Self.getInstance();
|
||||
try {
|
||||
await instance.synchronizerSyncRoles();
|
||||
} finally {
|
||||
await instance.synchronizerDeinit();
|
||||
}
|
||||
},
|
||||
|
||||
async getSynchronizer() {
|
||||
return await Self.findOne();
|
||||
}
|
||||
});
|
||||
|
||||
Object.assign(Self.prototype, {
|
||||
async synchronizerInit() {
|
||||
let mailConfig = await models.MailConfig.findOne({
|
||||
fields: ['domain']
|
||||
});
|
||||
|
||||
let synchronizers = [];
|
||||
|
||||
for (let Synchronizer of Self.synchronizers) {
|
||||
let synchronizer = await Synchronizer.getSynchronizer();
|
||||
if (!synchronizer) continue;
|
||||
Object.assign(synchronizer, {
|
||||
accountConfig: this
|
||||
});
|
||||
await synchronizer.init();
|
||||
synchronizers.push(synchronizer);
|
||||
}
|
||||
|
||||
Object.assign(this, {
|
||||
synchronizers,
|
||||
domain: mailConfig.domain
|
||||
});
|
||||
},
|
||||
|
||||
async synchronizerDeinit() {
|
||||
for (let synchronizer of this.synchronizers)
|
||||
await synchronizer.deinit();
|
||||
},
|
||||
|
||||
async synchronizerSyncUser(userName, password, syncGroups) {
|
||||
async syncUserBase(engine, userName, password, syncGroups) {
|
||||
if (!userName) return;
|
||||
userName = userName.toLowerCase();
|
||||
|
||||
|
@ -98,7 +89,7 @@ module.exports = Self => {
|
|||
if (['administrator', 'root'].indexOf(userName) >= 0)
|
||||
return;
|
||||
|
||||
let user = await models.VnUser.findOne({
|
||||
const user = await models.VnUser.findOne({
|
||||
where: {name: userName},
|
||||
fields: [
|
||||
'id',
|
||||
|
@ -130,27 +121,28 @@ module.exports = Self => {
|
|||
]
|
||||
});
|
||||
|
||||
let info = {
|
||||
const info = {
|
||||
user,
|
||||
hasAccount: false
|
||||
};
|
||||
|
||||
if (user) {
|
||||
let exists = await models.Account.exists(user.id);
|
||||
const exists = await models.Account.exists(user.id);
|
||||
const {accountConfig} = engine;
|
||||
Object.assign(info, {
|
||||
hasAccount: user.active && exists,
|
||||
corporateMail: `${userName}@${this.domain}`,
|
||||
uidNumber: this.idBase + user.id
|
||||
corporateMail: `${userName}@${accountConfig.domain}`,
|
||||
uidNumber: accountConfig.idBase + user.id
|
||||
});
|
||||
}
|
||||
|
||||
let errs = [];
|
||||
const errs = [];
|
||||
|
||||
for (let synchronizer of this.synchronizers) {
|
||||
for (const linker of engine.linkers) {
|
||||
try {
|
||||
await synchronizer.syncUser(userName, info, password);
|
||||
await linker.syncUser(userName, info, password);
|
||||
if (syncGroups)
|
||||
await synchronizer.syncUserGroups(userName, info);
|
||||
await linker.syncUserGroups(userName, info);
|
||||
} catch (err) {
|
||||
errs.push(err);
|
||||
}
|
||||
|
@ -159,18 +151,16 @@ module.exports = Self => {
|
|||
if (errs.length) throw errs[0];
|
||||
},
|
||||
|
||||
async synchronizerGetUsers() {
|
||||
let usersToSync = new Set();
|
||||
async syncRoles() {
|
||||
const engine = await Self.initEngine();
|
||||
try {
|
||||
await Self.rawSql(`CALL account.role_sync`);
|
||||
|
||||
for (let synchronizer of this.synchronizers)
|
||||
await synchronizer.getUsers(usersToSync);
|
||||
|
||||
return usersToSync;
|
||||
},
|
||||
|
||||
async synchronizerSyncRoles() {
|
||||
for (let synchronizer of this.synchronizers)
|
||||
await synchronizer.syncRoles();
|
||||
for (const linker of engine.linkers)
|
||||
await linker.syncRoles();
|
||||
} finally {
|
||||
await Self.deinitEngine(engine);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
|
@ -1,49 +1,49 @@
|
|||
{
|
||||
"name": "Account",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "account.account"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"id": true
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"user": {
|
||||
"type": "belongsTo",
|
||||
"model": "VnUser",
|
||||
"foreignKey": "id"
|
||||
},
|
||||
"aliases": {
|
||||
"type": "hasMany",
|
||||
"model": "MailAliasAccount",
|
||||
"foreignKey": "account"
|
||||
}
|
||||
},
|
||||
"acls": [
|
||||
{
|
||||
"property": "login",
|
||||
"accessType": "EXECUTE",
|
||||
"principalType": "ROLE",
|
||||
"principalId": "$everyone",
|
||||
"permission": "ALLOW"
|
||||
"name": "Account",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "account.account"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"id": true
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"user": {
|
||||
"type": "belongsTo",
|
||||
"model": "VnUser",
|
||||
"foreignKey": "id"
|
||||
},
|
||||
{
|
||||
"aliases": {
|
||||
"type": "hasMany",
|
||||
"model": "MailAliasAccount",
|
||||
"foreignKey": "account"
|
||||
}
|
||||
},
|
||||
"acls": [
|
||||
{
|
||||
"property": "login",
|
||||
"accessType": "EXECUTE",
|
||||
"principalType": "ROLE",
|
||||
"principalId": "$everyone",
|
||||
"permission": "ALLOW"
|
||||
},
|
||||
{
|
||||
"property": "logout",
|
||||
"accessType": "EXECUTE",
|
||||
"principalType": "ROLE",
|
||||
"principalId": "$authenticated",
|
||||
"permission": "ALLOW"
|
||||
},
|
||||
{
|
||||
"accessType": "EXECUTE",
|
||||
"principalType": "ROLE",
|
||||
"principalId": "$authenticated",
|
||||
"permission": "ALLOW"
|
||||
},
|
||||
{
|
||||
"property": "changePassword",
|
||||
"accessType": "EXECUTE",
|
||||
"principalType": "ROLE",
|
||||
"principalId": "$everyone",
|
||||
"permission": "ALLOW"
|
||||
}
|
||||
]
|
||||
"accessType": "EXECUTE",
|
||||
"principalType": "ROLE",
|
||||
"principalId": "$everyone",
|
||||
"permission": "ALLOW"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ const nthash = require('smbhash').nthash;
|
|||
module.exports = Self => {
|
||||
const shouldSync = process.env.NODE_ENV !== 'test';
|
||||
|
||||
Self.getSynchronizer = async function() {
|
||||
Self.getLinker = async function() {
|
||||
return await Self.findOne({
|
||||
fields: [
|
||||
'server',
|
||||
|
@ -24,6 +24,7 @@ module.exports = Self => {
|
|||
this.client = ldap.createClient({
|
||||
url: this.server
|
||||
});
|
||||
this.client.on('error', () => {});
|
||||
await this.client.bind(this.rdn, this.password);
|
||||
},
|
||||
|
||||
|
@ -238,7 +239,7 @@ module.exports = Self => {
|
|||
|
||||
// Prepare data
|
||||
|
||||
let roles = await $.Role.find({
|
||||
let roles = await $.VnRole.find({
|
||||
fields: ['id', 'name', 'description']
|
||||
});
|
||||
let roleRoles = await $.RoleRole.find({
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
}
|
||||
},
|
||||
"mixins": {
|
||||
"AccountSynchronizer": {}
|
||||
"AccountLinker": {}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
|
|
|
@ -2,54 +2,44 @@
|
|||
const UserError = require('vn-loopback/util/user-error');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.rewriteDbError(function(err) {
|
||||
if (err.code === 'ER_DUP_ENTRY')
|
||||
return new UserError(`You already have the mailAlias`);
|
||||
return err;
|
||||
});
|
||||
|
||||
Self.observe('before save', async ctx => {
|
||||
const changes = ctx.currentInstance || ctx.instance;
|
||||
|
||||
await Self.hasGrant(ctx, changes.mailAlias);
|
||||
await checkModifyPermission(ctx, changes.mailAlias);
|
||||
});
|
||||
|
||||
Self.observe('before delete', async ctx => {
|
||||
const mailAliasAccount = await Self.findById(ctx.where.id);
|
||||
|
||||
await Self.hasGrant(ctx, mailAliasAccount.mailAlias);
|
||||
await checkModifyPermission(ctx, mailAliasAccount.mailAlias);
|
||||
});
|
||||
|
||||
/**
|
||||
* Checks if current user has
|
||||
* grant to add/remove alias
|
||||
*
|
||||
* @param {Object} ctx - Request context
|
||||
* @param {Interger} mailAlias - mailAlias id
|
||||
* @return {Boolean} True for user with grant
|
||||
*/
|
||||
Self.hasGrant = async function(ctx, mailAlias) {
|
||||
async function checkModifyPermission(ctx, mailAliasFk) {
|
||||
const userId = ctx.options.accessToken.userId;
|
||||
const models = Self.app.models;
|
||||
const accessToken = {req: {accessToken: ctx.options.accessToken}};
|
||||
const userId = accessToken.req.accessToken.userId;
|
||||
|
||||
const canEditAlias = await models.ACL.checkAccessAcl(accessToken, 'MailAliasAccount', 'canEditAlias', 'WRITE');
|
||||
if (canEditAlias) return true;
|
||||
const roles = await models.RoleMapping.find({
|
||||
fields: ['roleId'],
|
||||
where: {principalId: userId}
|
||||
});
|
||||
|
||||
const user = await models.VnUser.findById(userId, {fields: ['hasGrant']});
|
||||
if (!user.hasGrant)
|
||||
throw new UserError(`You don't have grant privilege`);
|
||||
|
||||
const account = await models.Account.findById(userId, {
|
||||
fields: ['id'],
|
||||
include: {
|
||||
relation: 'aliases',
|
||||
scope: {
|
||||
fields: ['mailAlias']
|
||||
}
|
||||
const availableMailAlias = await models.MailAliasAcl.findOne({
|
||||
fields: ['mailAliasFk'],
|
||||
include: {relation: 'mailAlias'},
|
||||
where: {
|
||||
roleFk: {
|
||||
inq: roles.map(role => role.roleId),
|
||||
},
|
||||
mailAliasFk
|
||||
}
|
||||
});
|
||||
|
||||
const aliases = account.aliases().map(alias => alias.mailAlias);
|
||||
|
||||
const hasAlias = aliases.includes(mailAlias);
|
||||
if (!hasAlias)
|
||||
throw new UserError(`You cannot assign/remove an alias that you are not assigned to`);
|
||||
|
||||
return true;
|
||||
};
|
||||
if (!availableMailAlias) throw new UserError('The alias cant be modified');
|
||||
}
|
||||
};
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
{
|
||||
"name": "MailAliasAcl",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "account.mailAliasAcl"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"mailAliasFk": {
|
||||
"id": true,
|
||||
"type": "number"
|
||||
},
|
||||
"roleFk": {
|
||||
"id": true,
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"mailAlias": {
|
||||
"type": "belongsTo",
|
||||
"model": "MailAlias",
|
||||
"foreignKey": "mailAliasFk"
|
||||
},
|
||||
"role": {
|
||||
"type": "belongsTo",
|
||||
"model": "Role",
|
||||
"foreignKey": "roleFk"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
module.exports = Self => {
|
||||
Self.getSynchronizer = async function() {
|
||||
Self.getLinker = async function() {
|
||||
let NODE_ENV = process.env.NODE_ENV;
|
||||
if (!NODE_ENV || NODE_ENV == 'development')
|
||||
return null;
|
||||
|
@ -45,6 +45,7 @@ module.exports = Self => {
|
|||
}
|
||||
|
||||
if (!isUpdatable) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn(`RoleConfig.syncUser(): User '${userName}' cannot be updated, not managed by me`);
|
||||
return;
|
||||
}
|
||||
|
@ -82,6 +83,7 @@ module.exports = Self => {
|
|||
[mysqlUser, this.userHost]);
|
||||
} catch (err) {
|
||||
if (err.code == 'ER_REVOKE_GRANTS')
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn(`${err.code}: ${err.sqlMessage}: ${err.sql}`);
|
||||
else
|
||||
throw err;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
}
|
||||
},
|
||||
"mixins": {
|
||||
"AccountSynchronizer": {}
|
||||
"AccountLinker": {}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
|
|
|
@ -9,7 +9,7 @@ module.exports = Self => {
|
|||
Self.observe(hook, async() => {
|
||||
try {
|
||||
await Self.rawSql(`
|
||||
CREATE EVENT account.role_sync
|
||||
CREATE DEFINER = CURRENT_ROLE EVENT account.role_sync
|
||||
ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 5 SECOND
|
||||
DO CALL role_sync;
|
||||
`);
|
||||
|
|
|
@ -15,12 +15,12 @@
|
|||
"relations": {
|
||||
"owner": {
|
||||
"type": "belongsTo",
|
||||
"model": "Role",
|
||||
"model": "VnRole",
|
||||
"foreignKey": "role"
|
||||
},
|
||||
"inherits": {
|
||||
"type": "belongsTo",
|
||||
"model": "Role",
|
||||
"model": "VnRole",
|
||||
"foreignKey": "inheritsFrom"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,12 +14,12 @@
|
|||
"relations": {
|
||||
"owner": {
|
||||
"type": "belongsTo",
|
||||
"model": "Role",
|
||||
"model": "VnRole",
|
||||
"foreignKey": "role"
|
||||
},
|
||||
"inherits": {
|
||||
"type": "belongsTo",
|
||||
"model": "Role",
|
||||
"model": "VnRole",
|
||||
"foreignKey": "inheritsFrom"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ const UserAccountControlFlags = {
|
|||
module.exports = Self => {
|
||||
const shouldSync = process.env.NODE_ENV !== 'test';
|
||||
|
||||
Self.getSynchronizer = async function() {
|
||||
Self.getLinker = async function() {
|
||||
return await Self.findOne({
|
||||
fields: [
|
||||
'host',
|
||||
|
@ -39,6 +39,7 @@ module.exports = Self => {
|
|||
url: `ldaps://${this.adController}:636`,
|
||||
tlsOptions: {rejectUnauthorized: this.verifyCert}
|
||||
});
|
||||
adClient.on('error', () => {});
|
||||
await adClient.bind(bindDn, this.adPassword);
|
||||
Object.assign(this, {
|
||||
adClient,
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
}
|
||||
},
|
||||
"mixins": {
|
||||
"AccountSynchronizer": {}
|
||||
"AccountLinker": {}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
|
|
|
@ -25,7 +25,15 @@
|
|||
"type": "number"
|
||||
},
|
||||
"ip": {
|
||||
"type": "string"
|
||||
"type": "string"
|
||||
},
|
||||
"userName": {
|
||||
"type": "string"
|
||||
},
|
||||
"owner": {
|
||||
"type": "boolean",
|
||||
"required": true,
|
||||
"default": true
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.getSynchronizer = async function() {
|
||||
Self.getLinker = async function() {
|
||||
return await Self.findOne({fields: ['id']});
|
||||
};
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
}
|
||||
},
|
||||
"mixins": {
|
||||
"AccountSynchronizer": {}
|
||||
"AccountLinker": {}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
|
@ -16,4 +16,3 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
<vn-autocomplete
|
||||
label="Role"
|
||||
ng-model="$ctrl.acl.principalId"
|
||||
url="Roles"
|
||||
url="VnRoles"
|
||||
id-field="name"
|
||||
value-field="name"
|
||||
vn-focus>
|
||||
|
@ -32,7 +32,7 @@
|
|||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-textfield
|
||||
label="Property"
|
||||
label="Property"
|
||||
ng-model="$ctrl.acl.property"
|
||||
info="Use * to match all properties">
|
||||
</vn-textfield>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<vn-autocomplete
|
||||
label="Role"
|
||||
ng-model="filter.principalId"
|
||||
url="Roles"
|
||||
url="VnRoles"
|
||||
value-field="name">
|
||||
</vn-autocomplete>
|
||||
<vn-autocomplete
|
||||
|
@ -15,7 +15,7 @@
|
|||
value-field="name">
|
||||
</vn-autocomplete>
|
||||
<vn-textfield
|
||||
label="Property"
|
||||
label="Property"
|
||||
ng-model="filter.property">
|
||||
</vn-textfield>
|
||||
<vn-autocomplete
|
||||
|
@ -36,4 +36,4 @@
|
|||
</vn-submit>
|
||||
</vn-vertical>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
<vn-autocomplete
|
||||
label="Role"
|
||||
ng-model="$ctrl.user.roleFk"
|
||||
url="Roles"
|
||||
url="VnRoles"
|
||||
rule="VnUser">
|
||||
</vn-autocomplete>
|
||||
<vn-textfield
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue