Merge branch 'master' into hotfix-extraCommunityEntryRef
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
commit
d941e2e18f
|
@ -17,7 +17,7 @@ rules:
|
||||||
camelcase: 0
|
camelcase: 0
|
||||||
default-case: 0
|
default-case: 0
|
||||||
no-eq-null: 0
|
no-eq-null: 0
|
||||||
no-console: ["error"]
|
no-console: ["warn"]
|
||||||
no-warning-comments: 0
|
no-warning-comments: 0
|
||||||
no-empty: [error, allowEmptyCatch: true]
|
no-empty: [error, allowEmptyCatch: true]
|
||||||
complexity: 0
|
complexity: 0
|
||||||
|
|
|
@ -8,11 +8,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
## [2326.01] - 2023-06-29
|
## [2326.01] - 2023-06-29
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
- (Entradas -> Correo) Al cambiar el tipo de cambio enviará un correo a las personas designadas
|
||||||
|
- (General -> Históricos) Botón para ver el estado del registro en cada punto
|
||||||
|
- (General -> Históricos) Al filtar por registro se muestra todo el histórial desde que fue creado
|
||||||
|
- (Tickets -> Índice) Permite enviar varios albaranes a Docuware
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
- (General -> Históricos) Los registros se muestran agrupados por usuario y entidad
|
||||||
|
- (Facturas -> Facturación global) Optimizada, generación de PDFs y notificaciones en paralelo
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
-
|
- (General -> Históricos) Duplicidades eliminadas
|
||||||
|
- (Facturas -> Facturación global) Solucionados fallos que paran el proceso
|
||||||
|
|
||||||
## [2324.01] - 2023-06-15
|
## [2324.01] - 2023-06-15
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,9 @@ const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
describe('docuware upload()', () => {
|
describe('docuware upload()', () => {
|
||||||
const userId = 9;
|
const userId = 9;
|
||||||
const ticketId = 10;
|
const ticketIds = [10];
|
||||||
const ctx = {
|
const ctx = {
|
||||||
|
args: {ticketIds},
|
||||||
req: {
|
req: {
|
||||||
getLocale: () => {
|
getLocale: () => {
|
||||||
return 'en';
|
return 'en';
|
||||||
|
@ -27,7 +28,7 @@ describe('docuware upload()', () => {
|
||||||
|
|
||||||
let error;
|
let error;
|
||||||
try {
|
try {
|
||||||
await models.Docuware.upload(ctx, ticketId, fileCabinetName);
|
await models.Docuware.upload(ctx, ticketIds, fileCabinetName);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
error = e.message;
|
error = e.message;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,34 +3,34 @@ const axios = require('axios');
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('upload', {
|
Self.remoteMethodCtx('upload', {
|
||||||
description: 'Upload an docuware PDF',
|
description: 'Upload docuware PDFs',
|
||||||
accessType: 'WRITE',
|
accessType: 'WRITE',
|
||||||
accepts: [
|
accepts: [
|
||||||
{
|
{
|
||||||
arg: 'id',
|
arg: 'ticketIds',
|
||||||
type: 'number',
|
type: ['number'],
|
||||||
description: 'The ticket id',
|
description: 'The ticket ids',
|
||||||
http: {source: 'path'}
|
required: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
arg: 'fileCabinet',
|
arg: 'fileCabinet',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
description: 'The file cabinet'
|
description: 'The file cabinet',
|
||||||
},
|
required: true
|
||||||
{
|
|
||||||
arg: 'dialog',
|
|
||||||
type: 'string',
|
|
||||||
description: 'The dialog'
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
returns: [],
|
returns: {
|
||||||
|
type: 'object',
|
||||||
|
root: true
|
||||||
|
},
|
||||||
http: {
|
http: {
|
||||||
path: `/:id/upload`,
|
path: `/upload`,
|
||||||
verb: 'POST'
|
verb: 'POST'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.upload = async function(ctx, id, fileCabinet) {
|
Self.upload = async function(ctx, ticketIds, fileCabinet) {
|
||||||
|
delete ctx.args.ticketIds;
|
||||||
const models = Self.app.models;
|
const models = Self.app.models;
|
||||||
const action = 'store';
|
const action = 'store';
|
||||||
|
|
||||||
|
@ -38,104 +38,114 @@ module.exports = Self => {
|
||||||
const fileCabinetId = await Self.getFileCabinet(fileCabinet);
|
const fileCabinetId = await Self.getFileCabinet(fileCabinet);
|
||||||
const dialogId = await Self.getDialog(fileCabinet, action, fileCabinetId);
|
const dialogId = await Self.getDialog(fileCabinet, action, fileCabinetId);
|
||||||
|
|
||||||
// get delivery note
|
const uploaded = [];
|
||||||
const deliveryNote = await models.Ticket.deliveryNotePdf(ctx, {
|
for (id of ticketIds) {
|
||||||
id,
|
// get delivery note
|
||||||
type: 'deliveryNote'
|
ctx.args.id = id;
|
||||||
});
|
const deliveryNote = await models.Ticket.deliveryNotePdf(ctx, {
|
||||||
|
id,
|
||||||
// get ticket data
|
type: 'deliveryNote'
|
||||||
const ticket = await models.Ticket.findById(id, {
|
|
||||||
include: [{
|
|
||||||
relation: 'client',
|
|
||||||
scope: {
|
|
||||||
fields: ['id', 'socialName', 'fi']
|
|
||||||
}
|
|
||||||
}]
|
|
||||||
});
|
|
||||||
|
|
||||||
// upload file
|
|
||||||
const templateJson = {
|
|
||||||
'Fields': [
|
|
||||||
{
|
|
||||||
'FieldName': 'N__ALBAR_N',
|
|
||||||
'ItemElementName': 'string',
|
|
||||||
'Item': id,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'FieldName': 'CIF_PROVEEDOR',
|
|
||||||
'ItemElementName': 'string',
|
|
||||||
'Item': ticket.client().fi,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'FieldName': 'CODIGO_PROVEEDOR',
|
|
||||||
'ItemElementName': 'string',
|
|
||||||
'Item': ticket.client().id,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'FieldName': 'NOMBRE_PROVEEDOR',
|
|
||||||
'ItemElementName': 'string',
|
|
||||||
'Item': ticket.client().socialName,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'FieldName': 'FECHA_FACTURA',
|
|
||||||
'ItemElementName': 'date',
|
|
||||||
'Item': ticket.shipped,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'FieldName': 'TOTAL_FACTURA',
|
|
||||||
'ItemElementName': 'Decimal',
|
|
||||||
'Item': ticket.totalWithVat,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'FieldName': 'ESTADO',
|
|
||||||
'ItemElementName': 'string',
|
|
||||||
'Item': 'Pendiente procesar',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'FieldName': 'FIRMA_',
|
|
||||||
'ItemElementName': 'string',
|
|
||||||
'Item': 'Si',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'FieldName': 'FILTRO_TABLET',
|
|
||||||
'ItemElementName': 'string',
|
|
||||||
'Item': 'Tablet1',
|
|
||||||
}
|
|
||||||
]
|
|
||||||
};
|
|
||||||
|
|
||||||
if (process.env.NODE_ENV != 'production')
|
|
||||||
throw new UserError('Action not allowed on the test environment');
|
|
||||||
|
|
||||||
// delete old
|
|
||||||
const docuwareFile = await models.Docuware.checkFile(ctx, id, fileCabinet, false);
|
|
||||||
if (docuwareFile) {
|
|
||||||
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 uploadUri = `${options.url}/FileCabinets/${fileCabinetId}/Documents?StoreDialogId=${dialogId}`;
|
|
||||||
const FormData = require('form-data');
|
|
||||||
const data = new FormData();
|
|
||||||
|
|
||||||
data.append('document', JSON.stringify(templateJson), 'schema.json');
|
|
||||||
data.append('file[]', deliveryNote[0], 'file.pdf');
|
|
||||||
const uploadOptions = {
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'multipart/form-data',
|
|
||||||
'X-File-ModifiedDate': Date.vnNew(),
|
|
||||||
'Cookie': options.headers.headers.Cookie,
|
|
||||||
...data.getHeaders()
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
return await axios.post(uploadUri, data, uploadOptions)
|
|
||||||
.catch(() => {
|
|
||||||
throw new UserError('Failed to upload file');
|
|
||||||
});
|
});
|
||||||
|
// get ticket data
|
||||||
|
const ticket = await models.Ticket.findById(id, {
|
||||||
|
include: [{
|
||||||
|
relation: 'client',
|
||||||
|
scope: {
|
||||||
|
fields: ['id', 'name', 'fi']
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
});
|
||||||
|
|
||||||
|
// upload file
|
||||||
|
const templateJson = {
|
||||||
|
'Fields': [
|
||||||
|
{
|
||||||
|
'FieldName': 'N__ALBAR_N',
|
||||||
|
'ItemElementName': 'string',
|
||||||
|
'Item': id,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'FieldName': 'CIF_PROVEEDOR',
|
||||||
|
'ItemElementName': 'string',
|
||||||
|
'Item': ticket.client().fi,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'FieldName': 'CODIGO_PROVEEDOR',
|
||||||
|
'ItemElementName': 'string',
|
||||||
|
'Item': ticket.client().id,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'FieldName': 'NOMBRE_PROVEEDOR',
|
||||||
|
'ItemElementName': 'string',
|
||||||
|
'Item': ticket.client().name + ' - ' + id,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'FieldName': 'FECHA_FACTURA',
|
||||||
|
'ItemElementName': 'date',
|
||||||
|
'Item': ticket.shipped,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'FieldName': 'TOTAL_FACTURA',
|
||||||
|
'ItemElementName': 'Decimal',
|
||||||
|
'Item': ticket.totalWithVat,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'FieldName': 'ESTADO',
|
||||||
|
'ItemElementName': 'string',
|
||||||
|
'Item': 'Pendiente procesar',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'FieldName': 'FIRMA_',
|
||||||
|
'ItemElementName': 'string',
|
||||||
|
'Item': 'Si',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'FieldName': 'FILTRO_TABLET',
|
||||||
|
'ItemElementName': 'string',
|
||||||
|
'Item': 'Tablet1',
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
if (process.env.NODE_ENV != 'production')
|
||||||
|
throw new UserError('Action not allowed on the test environment');
|
||||||
|
|
||||||
|
// delete old
|
||||||
|
const docuwareFile = await models.Docuware.checkFile(ctx, id, fileCabinet, false);
|
||||||
|
if (docuwareFile) {
|
||||||
|
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 uploadUri = `${options.url}/FileCabinets/${fileCabinetId}/Documents?StoreDialogId=${dialogId}`;
|
||||||
|
const FormData = require('form-data');
|
||||||
|
const data = new FormData();
|
||||||
|
|
||||||
|
data.append('document', JSON.stringify(templateJson), 'schema.json');
|
||||||
|
data.append('file[]', deliveryNote[0], 'file.pdf');
|
||||||
|
const uploadOptions = {
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'multipart/form-data',
|
||||||
|
'X-File-ModifiedDate': Date.vnNew(),
|
||||||
|
'Cookie': options.headers.headers.Cookie,
|
||||||
|
...data.getHeaders()
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
await axios.post(uploadUri, data, uploadOptions);
|
||||||
|
} catch (err) {
|
||||||
|
const $t = ctx.req.__;
|
||||||
|
const message = $t('Failed to upload delivery note', {id});
|
||||||
|
if (uploaded.length)
|
||||||
|
await models.TicketTracking.setDelivered(ctx, uploaded);
|
||||||
|
throw new UserError(message);
|
||||||
|
}
|
||||||
|
uploaded.push(id);
|
||||||
|
}
|
||||||
|
return models.TicketTracking.setDelivered(ctx, ticketIds);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
const UserError = require('vn-loopback/util/user-error');
|
||||||
|
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.remoteMethodCtx('renewToken', {
|
||||||
|
description: 'Checks if the token has more than renewPeriod seconds to live and if so, renews it',
|
||||||
|
accessType: 'WRITE',
|
||||||
|
accepts: [],
|
||||||
|
returns: {
|
||||||
|
type: 'Object',
|
||||||
|
root: true
|
||||||
|
},
|
||||||
|
http: {
|
||||||
|
path: `/renewToken`,
|
||||||
|
verb: 'POST'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Self.renewToken = async function(ctx) {
|
||||||
|
const models = Self.app.models;
|
||||||
|
const token = ctx.req.accessToken;
|
||||||
|
|
||||||
|
const now = new Date();
|
||||||
|
const differenceMilliseconds = now - token.created;
|
||||||
|
const differenceSeconds = Math.floor(differenceMilliseconds / 1000);
|
||||||
|
|
||||||
|
const fields = ['renewPeriod', 'courtesyTime'];
|
||||||
|
const accessTokenConfig = await models.AccessTokenConfig.findOne({fields});
|
||||||
|
|
||||||
|
if (differenceSeconds < accessTokenConfig.renewPeriod - accessTokenConfig.courtesyTime)
|
||||||
|
throw new UserError(`The renew period has not been exceeded`, 'periodNotExceeded');
|
||||||
|
|
||||||
|
await Self.logout(token.id);
|
||||||
|
const user = await Self.findById(token.userId);
|
||||||
|
const accessToken = await user.createAccessToken();
|
||||||
|
|
||||||
|
return {id: accessToken.id, ttl: accessToken.ttl};
|
||||||
|
};
|
||||||
|
};
|
|
@ -76,6 +76,6 @@ module.exports = Self => {
|
||||||
|
|
||||||
let loginInfo = Object.assign({password}, userInfo);
|
let loginInfo = Object.assign({password}, userInfo);
|
||||||
token = await Self.login(loginInfo, 'user');
|
token = await Self.login(loginInfo, 'user');
|
||||||
return {token: token.id};
|
return {token: token.id, ttl: token.ttl};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -9,7 +9,7 @@ describe('VnUser signIn()', () => {
|
||||||
|
|
||||||
expect(login.token).toBeDefined();
|
expect(login.token).toBeDefined();
|
||||||
|
|
||||||
await models.VnUser.signOut(ctx);
|
await models.VnUser.logout(ctx.req.accessToken.id);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return the token if the user doesnt exist but the client does', async() => {
|
it('should return the token if the user doesnt exist but the client does', async() => {
|
||||||
|
@ -19,7 +19,7 @@ describe('VnUser signIn()', () => {
|
||||||
|
|
||||||
expect(login.token).toBeDefined();
|
expect(login.token).toBeDefined();
|
||||||
|
|
||||||
await models.VnUser.signOut(ctx);
|
await models.VnUser.logout(ctx.req.accessToken.id);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,42 +0,0 @@
|
||||||
const {models} = require('vn-loopback/server/server');
|
|
||||||
|
|
||||||
describe('VnUser signOut()', () => {
|
|
||||||
it('should logout and remove token after valid login', async() => {
|
|
||||||
let loginResponse = await models.VnUser.signOut('buyer', 'nightmare');
|
|
||||||
let accessToken = await models.AccessToken.findById(loginResponse.token);
|
|
||||||
let ctx = {req: {accessToken: accessToken}};
|
|
||||||
|
|
||||||
let logoutResponse = await models.VnUser.signOut(ctx);
|
|
||||||
let tokenAfterLogout = await models.AccessToken.findById(loginResponse.token);
|
|
||||||
|
|
||||||
expect(logoutResponse).toBeTrue();
|
|
||||||
expect(tokenAfterLogout).toBeNull();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should throw a 401 error when token is invalid', async() => {
|
|
||||||
let error;
|
|
||||||
let ctx = {req: {accessToken: {id: 'invalidToken'}}};
|
|
||||||
|
|
||||||
try {
|
|
||||||
response = await models.VnUser.signOut(ctx);
|
|
||||||
} catch (e) {
|
|
||||||
error = e;
|
|
||||||
}
|
|
||||||
|
|
||||||
expect(error).toBeDefined();
|
|
||||||
expect(error.statusCode).toBe(401);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should throw an error when no token is passed', async() => {
|
|
||||||
let error;
|
|
||||||
let ctx = {req: {accessToken: null}};
|
|
||||||
|
|
||||||
try {
|
|
||||||
response = await models.VnUser.signOut(ctx);
|
|
||||||
} catch (e) {
|
|
||||||
error = e;
|
|
||||||
}
|
|
||||||
|
|
||||||
expect(error).toBeDefined();
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -2,6 +2,14 @@
|
||||||
"AccountingType": {
|
"AccountingType": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
|
"AccessTokenConfig": {
|
||||||
|
"dataSource": "vn",
|
||||||
|
"options": {
|
||||||
|
"mysql": {
|
||||||
|
"table": "salix.accessTokenConfig"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"Bank": {
|
"Bank": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
{
|
||||||
|
"name": "AccessTokenConfig",
|
||||||
|
"base": "VnModel",
|
||||||
|
"options": {
|
||||||
|
"mysql": {
|
||||||
|
"table": "accessTokenConfig"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"properties": {
|
||||||
|
"id": {
|
||||||
|
"type": "number",
|
||||||
|
"id": true,
|
||||||
|
"description": "Identifier"
|
||||||
|
},
|
||||||
|
"renewPeriod": {
|
||||||
|
"type": "number",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"courtesyTime": {
|
||||||
|
"type": "number",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"renewInterval": {
|
||||||
|
"type": "number",
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"acls": [{
|
||||||
|
"accessType": "READ",
|
||||||
|
"principalType": "ROLE",
|
||||||
|
"principalId": "$everyone",
|
||||||
|
"permission": "ALLOW"
|
||||||
|
}]
|
||||||
|
}
|
|
@ -10,6 +10,9 @@ module.exports = function(Self) {
|
||||||
require('../methods/vn-user/recover-password')(Self);
|
require('../methods/vn-user/recover-password')(Self);
|
||||||
require('../methods/vn-user/validate-token')(Self);
|
require('../methods/vn-user/validate-token')(Self);
|
||||||
require('../methods/vn-user/privileges')(Self);
|
require('../methods/vn-user/privileges')(Self);
|
||||||
|
require('../methods/vn-user/renew-token')(Self);
|
||||||
|
|
||||||
|
Self.definition.settings.acls = Self.definition.settings.acls.filter(acl => acl.property !== 'create');
|
||||||
|
|
||||||
// Validations
|
// Validations
|
||||||
|
|
||||||
|
|
|
@ -118,5 +118,24 @@
|
||||||
"principalId": "$authenticated",
|
"principalId": "$authenticated",
|
||||||
"permission": "ALLOW"
|
"permission": "ALLOW"
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"scopes": {
|
||||||
|
"preview": {
|
||||||
|
"fields": [
|
||||||
|
"id",
|
||||||
|
"name",
|
||||||
|
"username",
|
||||||
|
"roleFk",
|
||||||
|
"nickname",
|
||||||
|
"lang",
|
||||||
|
"active",
|
||||||
|
"created",
|
||||||
|
"updated",
|
||||||
|
"image",
|
||||||
|
"hasGrant",
|
||||||
|
"realm",
|
||||||
|
"email"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId)
|
INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId)
|
||||||
VALUES
|
VALUES
|
||||||
('VnUser', '*', '*', 'ALLOW', 'ROLE', 'employee'),
|
|
||||||
('VnUser','acl','READ','ALLOW','ROLE','account'),
|
('VnUser','acl','READ','ALLOW','ROLE','account'),
|
||||||
('VnUser','getCurrentUserData','READ','ALLOW','ROLE','account'),
|
('VnUser','getCurrentUserData','READ','ALLOW','ROLE','account'),
|
||||||
('VnUser','changePassword', 'WRITE', 'ALLOW', 'ROLE', 'account'),
|
('VnUser','changePassword', 'WRITE', 'ALLOW', 'ROLE', 'account'),
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
CREATE TABLE `vn`.`travelConfig` (
|
||||||
|
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`warehouseInFk` smallint(6) unsigned NOT NULL DEFAULT 8 COMMENT 'Warehouse de origen',
|
||||||
|
`warehouseOutFk` smallint(6) unsigned NOT NULL DEFAULT 60 COMMENT 'Warehouse destino',
|
||||||
|
`agencyFk` int(11) NOT NULL DEFAULT 1378 COMMENT 'Agencia por defecto',
|
||||||
|
`companyFk` int(10) unsigned NOT NULL DEFAULT 442 COMMENT 'Compañía por defecto',
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
KEY `travelConfig_FK` (`warehouseInFk`),
|
||||||
|
KEY `travelConfig_FK_1` (`warehouseOutFk`),
|
||||||
|
KEY `travelConfig_FK_2` (`agencyFk`),
|
||||||
|
KEY `travelConfig_FK_3` (`companyFk`),
|
||||||
|
CONSTRAINT `travelConfig_FK` FOREIGN KEY (`warehouseInFk`) REFERENCES `warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT `travelConfig_FK_1` FOREIGN KEY (`warehouseOutFk`) REFERENCES `warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT `travelConfig_FK_2` FOREIGN KEY (`agencyFk`) REFERENCES `agencyMode` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT `travelConfig_FK_3` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
|
||||||
|
|
||||||
|
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||||
|
VALUES
|
||||||
|
('Entry', 'addFromPackaging', 'WRITE', 'ALLOW', 'ROLE', 'production'),
|
||||||
|
('Entry', 'addFromBuy', 'WRITE', 'ALLOW', 'ROLE', 'production'),
|
||||||
|
('Supplier', 'getItemsPackaging', 'READ', 'ALLOW', 'ROLE', 'production');
|
|
@ -0,0 +1,8 @@
|
||||||
|
DELETE
|
||||||
|
FROM `salix`.`ACL`
|
||||||
|
WHERE model='Account' AND property='*' AND accessType='*';
|
||||||
|
|
||||||
|
INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId)
|
||||||
|
VALUES
|
||||||
|
('Account', '*', 'WRITE', 'ALLOW', 'ROLE', 'sysadmin'),
|
||||||
|
('Account', '*', 'READ', 'ALLOW', 'ROLE', 'employee');
|
|
@ -0,0 +1,5 @@
|
||||||
|
DELETE FROM `salix`.`ACL` WHERE model = 'MailAliasAccount';
|
||||||
|
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||||
|
VALUES
|
||||||
|
('MailAliasAccount', '*', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||||
|
('MailAliasAccount', '*', 'WRITE', 'ALLOW', 'ROLE', 'itManagement');
|
|
@ -0,0 +1,5 @@
|
||||||
|
DELETE FROM `salix`.`ACL` WHERE model = 'MailForward';
|
||||||
|
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||||
|
VALUES
|
||||||
|
('MailForward', '*', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||||
|
('MailForward', '*', 'WRITE', 'ALLOW', 'ROLE', 'itManagement');
|
|
@ -0,0 +1,5 @@
|
||||||
|
DELETE FROM `salix`.`ACL` WHERE model = 'Role';
|
||||||
|
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||||
|
VALUES
|
||||||
|
('Role', '*', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||||
|
('Role', '*', 'WRITE', 'ALLOW', 'ROLE', 'it');
|
|
@ -0,0 +1,10 @@
|
||||||
|
DELETE
|
||||||
|
FROM `salix`.`ACL`
|
||||||
|
WHERE model = 'VnUser' AND property = '*' AND principalId = 'employee';
|
||||||
|
|
||||||
|
INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId)
|
||||||
|
VALUES
|
||||||
|
('VnUser', '*', '*', 'ALLOW', 'ROLE', 'itManagement'),
|
||||||
|
('VnUser', '__get__preview', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||||
|
('VnUser', 'preview', '*', 'ALLOW', 'ROLE', 'employee'),
|
||||||
|
('VnUser', 'create', '*', 'ALLOW', 'ROLE', 'itManagement');
|
|
@ -0,0 +1,3 @@
|
||||||
|
INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId)
|
||||||
|
VALUES
|
||||||
|
('VnUser', 'renewToken', 'WRITE', 'ALLOW', 'ROLE', 'employee')
|
|
@ -0,0 +1,40 @@
|
||||||
|
DELIMITER $$
|
||||||
|
$$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`entry_updateComission`(vCurrency INT)
|
||||||
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Actualiza la comision de las entradas de hoy a futuro y las recalcula
|
||||||
|
*
|
||||||
|
* @param vCurrency id del tipo de moneda(SAR,EUR,USD,GBP,JPY)
|
||||||
|
*/
|
||||||
|
DECLARE vCurrencyName VARCHAR(25);
|
||||||
|
DECLARE vComission INT;
|
||||||
|
|
||||||
|
CREATE OR REPLACE TEMPORARY TABLE tmp.recalcEntryCommision
|
||||||
|
SELECT e.id
|
||||||
|
FROM vn.entry e
|
||||||
|
JOIN vn.travel t ON t.id = e.travelFk
|
||||||
|
JOIN vn.warehouse w ON w.id = t.warehouseInFk
|
||||||
|
WHERE t.shipped >= util.VN_CURDATE()
|
||||||
|
AND e.currencyFk = vCurrency;
|
||||||
|
|
||||||
|
SET vComission = currency_getCommission(vCurrency);
|
||||||
|
|
||||||
|
UPDATE vn.entry e
|
||||||
|
JOIN tmp.recalcEntryCommision tmp ON tmp.id = e.id
|
||||||
|
SET e.commission = vComission;
|
||||||
|
|
||||||
|
SELECT `name` INTO vCurrencyName
|
||||||
|
FROM currency
|
||||||
|
WHERE id = vCurrency;
|
||||||
|
|
||||||
|
CALL entry_recalc();
|
||||||
|
SELECT util.notification_send(
|
||||||
|
'entry-update-comission',
|
||||||
|
JSON_OBJECT('currencyName', vCurrencyName, 'referenceCurrent', vComission),
|
||||||
|
account.myUser_getId()
|
||||||
|
);
|
||||||
|
|
||||||
|
DROP TEMPORARY TABLE tmp.recalcEntryCommision;
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -0,0 +1,71 @@
|
||||||
|
CREATE TABLE `vn`.`packingSiteAdvanced` (
|
||||||
|
`ticketFk` int(11),
|
||||||
|
`workerFk` int(10) unsigned,
|
||||||
|
PRIMARY KEY (`ticketFk`),
|
||||||
|
KEY `packingSiteAdvanced_FK_1` (`workerFk`),
|
||||||
|
CONSTRAINT `packingSiteAdvanced_FK` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT `packingSiteAdvanced_FK_1` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
|
||||||
|
|
||||||
|
|
||||||
|
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||||
|
VALUES
|
||||||
|
('PackingSiteAdvanced', '*', '*', 'ALLOW', 'ROLE', 'production');
|
||||||
|
|
||||||
|
DROP PROCEDURE IF EXISTS `vn`.`packingSite_startCollection`;
|
||||||
|
|
||||||
|
DELIMITER $$
|
||||||
|
$$
|
||||||
|
CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`packingSite_startCollection`(vSelf INT, vTicketFk INT)
|
||||||
|
proc: BEGIN
|
||||||
|
/**
|
||||||
|
* @param vSelf packingSite id
|
||||||
|
* @param vTicketFk A ticket id from the collection to start
|
||||||
|
*/
|
||||||
|
DECLARE vExists BOOL;
|
||||||
|
DECLARE vIsAdvanced BOOL;
|
||||||
|
DECLARE vNewCollectionFk INT;
|
||||||
|
DECLARE vOldCollectionFk INT;
|
||||||
|
DECLARE vIsPackingByOther BOOL;
|
||||||
|
|
||||||
|
SELECT id, collectionFk
|
||||||
|
INTO vExists, vOldCollectionFk
|
||||||
|
FROM packingSite
|
||||||
|
WHERE id = vSelf;
|
||||||
|
|
||||||
|
IF NOT vExists THEN
|
||||||
|
CALL util.throw('packingSiteNotExists');
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT COUNT(*) > 0
|
||||||
|
INTO vIsAdvanced
|
||||||
|
FROM packingSiteAdvanced
|
||||||
|
WHERE ticketFk = vTicketFk;
|
||||||
|
|
||||||
|
IF vIsAdvanced THEN
|
||||||
|
LEAVE proc;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT collectionFk INTO vNewCollectionFk
|
||||||
|
FROM ticketCollection WHERE ticketFk = vTicketFk;
|
||||||
|
|
||||||
|
IF vOldCollectionFk IS NOT NULL
|
||||||
|
AND vOldCollectionFk <> vNewCollectionFk THEN
|
||||||
|
SELECT COUNT(*) > 0
|
||||||
|
INTO vIsPackingByOther
|
||||||
|
FROM packingSite
|
||||||
|
WHERE id <> vSelf
|
||||||
|
AND collectionFk = vOldCollectionFk;
|
||||||
|
|
||||||
|
IF NOT vIsPackingByOther AND NOT collection_isPacked(vOldCollectionFk) THEN
|
||||||
|
CALL util.throw('cannotChangeCollection');
|
||||||
|
END IF;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
UPDATE packingSite SET collectionFk = vNewCollectionFk
|
||||||
|
WHERE id = vSelf;
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
CREATE TABLE `salix`.`accessTokenConfig` (
|
||||||
|
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`renewPeriod` int(10) unsigned DEFAULT NULL,
|
||||||
|
`courtesyTime` int(10) unsigned DEFAULT NULL,
|
||||||
|
`renewInterval` int(10) unsigned DEFAULT NULL,
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
|
||||||
|
|
||||||
|
INSERT IGNORE INTO `salix`.`accessTokenConfig` (`id`, `renewPeriod`, `courtesyTime`, `renewInterval`)
|
||||||
|
VALUES
|
||||||
|
(1, 21600, 5, 300);
|
|
@ -0,0 +1,13 @@
|
||||||
|
INSERT INTO `salix`.`ACL` (model,property,accessType,permission,principalType,principalId)
|
||||||
|
VALUES
|
||||||
|
('InvoiceOut','makePdfAndNotify','WRITE','ALLOW','ROLE','invoicing'),
|
||||||
|
('InvoiceOutConfig','*','READ','ALLOW','ROLE','invoicing');
|
||||||
|
|
||||||
|
CREATE OR REPLACE TABLE `vn`.`invoiceOutConfig` (
|
||||||
|
id INT UNSIGNED auto_increment NOT NULL,
|
||||||
|
parallelism int UNSIGNED DEFAULT 1 NOT NULL,
|
||||||
|
PRIMARY KEY (id)
|
||||||
|
)
|
||||||
|
ENGINE=InnoDB
|
||||||
|
DEFAULT CHARSET=utf8mb3
|
||||||
|
COLLATE=utf8mb3_unicode_ci;
|
|
@ -603,6 +603,9 @@ UPDATE `vn`.`invoiceOut` SET ref = 'T3333333' WHERE id = 3;
|
||||||
UPDATE `vn`.`invoiceOut` SET ref = 'T4444444' WHERE id = 4;
|
UPDATE `vn`.`invoiceOut` SET ref = 'T4444444' WHERE id = 4;
|
||||||
UPDATE `vn`.`invoiceOut` SET ref = 'A1111111' WHERE id = 5;
|
UPDATE `vn`.`invoiceOut` SET ref = 'A1111111' WHERE id = 5;
|
||||||
|
|
||||||
|
INSERT INTO vn.invoiceOutConfig
|
||||||
|
SET parallelism = 8;
|
||||||
|
|
||||||
INSERT INTO `vn`.`invoiceOutTax` (`invoiceOutFk`, `taxableBase`, `vat`, `pgcFk`)
|
INSERT INTO `vn`.`invoiceOutTax` (`invoiceOutFk`, `taxableBase`, `vat`, `pgcFk`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, 895.76, 89.58, 4722000010),
|
(1, 895.76, 89.58, 4722000010),
|
||||||
|
@ -696,12 +699,12 @@ 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`)
|
INSERT INTO `vn`.`ticket`(`id`, `priority`, `agencyModeFk`,`warehouseFk`,`routeFk`, `shipped`, `landed`, `clientFk`,`nickname`, `addressFk`, `refFk`, `isDeleted`, `zoneFk`, `zonePrice`, `zoneBonus`, `created`)
|
||||||
VALUES
|
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, 'T1111111', 0, 1, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
|
(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)),
|
||||||
(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, 'T1111111', 0, 1, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
|
(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)),
|
||||||
(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, 'T2222222', 0, 3, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH)),
|
(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)),
|
||||||
(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, 'T3333333', 0, 9, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH)),
|
(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)),
|
||||||
(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, 'T4444444', 0, 10, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH)),
|
(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)),
|
||||||
(6 , 1, 3, 3, 3, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 'Mountain Drive Gotham', 1, 'A1111111', 0, 10, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
|
(6 , 1, 3, 3, 3, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 'Mountain Drive Gotham', 1, NULL, 0, 10, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
|
||||||
(7 , NULL, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1101, 'Mountain Drive Gotham', 1, NULL, 0, 3, 5, 1, util.VN_CURDATE()),
|
(7 , NULL, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1101, 'Mountain Drive Gotham', 1, NULL, 0, 3, 5, 1, util.VN_CURDATE()),
|
||||||
(8 , NULL, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1101, 'Bat cave', 121, NULL, 0, 3, 5, 1, util.VN_CURDATE()),
|
(8 , NULL, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1101, 'Bat cave', 121, NULL, 0, 3, 5, 1, util.VN_CURDATE()),
|
||||||
(9 , NULL, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1104, 'Stark tower', 124, NULL, 0, 3, 5, 1, util.VN_CURDATE()),
|
(9 , NULL, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1104, 'Stark tower', 124, NULL, 0, 3, 5, 1, util.VN_CURDATE()),
|
||||||
|
@ -2569,6 +2572,26 @@ INSERT INTO `vn`.`ticketRecalc`(`ticketFk`)
|
||||||
|
|
||||||
CALL `vn`.`ticket_doRecalc`();
|
CALL `vn`.`ticket_doRecalc`();
|
||||||
|
|
||||||
|
UPDATE `vn`.`ticket`
|
||||||
|
SET refFk = 'T1111111'
|
||||||
|
WHERE id IN (1,2);
|
||||||
|
|
||||||
|
UPDATE `vn`.`ticket`
|
||||||
|
SET refFk = 'T2222222'
|
||||||
|
WHERE id = 3;
|
||||||
|
|
||||||
|
UPDATE `vn`.`ticket`
|
||||||
|
SET refFk = 'T3333333'
|
||||||
|
WHERE id = 4;
|
||||||
|
|
||||||
|
UPDATE `vn`.`ticket`
|
||||||
|
SET refFk = 'T4444444'
|
||||||
|
WHERE id = 5;
|
||||||
|
|
||||||
|
UPDATE `vn`.`ticket`
|
||||||
|
SET refFk = 'A1111111'
|
||||||
|
WHERE id = 6;
|
||||||
|
|
||||||
INSERT INTO `vn`.`zoneAgencyMode`(`id`, `agencyModeFk`, `zoneFk`)
|
INSERT INTO `vn`.`zoneAgencyMode`(`id`, `agencyModeFk`, `zoneFk`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, 1, 1),
|
(1, 1, 1),
|
||||||
|
@ -2736,7 +2759,8 @@ INSERT INTO `util`.`notification` (`id`, `name`, `description`)
|
||||||
(1, 'print-email', 'notification fixture one'),
|
(1, 'print-email', 'notification fixture one'),
|
||||||
(2, 'invoice-electronic', 'A electronic invoice has been generated'),
|
(2, 'invoice-electronic', 'A electronic invoice has been generated'),
|
||||||
(3, 'not-main-printer-configured', 'A printer distinct than main has been configured'),
|
(3, 'not-main-printer-configured', 'A printer distinct than main has been configured'),
|
||||||
(4, 'supplier-pay-method-update', 'A supplier pay method has been updated');
|
(4, 'supplier-pay-method-update', 'A supplier pay method has been updated'),
|
||||||
|
(5, 'modified-entry', 'An entry has been modified');
|
||||||
|
|
||||||
INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`)
|
INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`)
|
||||||
VALUES
|
VALUES
|
||||||
|
@ -2894,6 +2918,10 @@ INSERT INTO `vn`.`wagonTypeTray` (`id`, `typeFk`, `height`, `colorFk`)
|
||||||
(2, 1, 50, 2),
|
(2, 1, 50, 2),
|
||||||
(3, 1, 0, 3);
|
(3, 1, 0, 3);
|
||||||
|
|
||||||
|
INSERT INTO `salix`.`accessTokenConfig` (`id`, `renewPeriod`, `renewInterval`)
|
||||||
|
VALUES
|
||||||
|
(1, 21600, 300);
|
||||||
|
|
||||||
INSERT INTO `vn`.`travelConfig` (`id`, `warehouseInFk`, `warehouseOutFk`, `agencyFk`, `companyFk`)
|
INSERT INTO `vn`.`travelConfig` (`id`, `warehouseInFk`, `warehouseOutFk`, `agencyFk`, `companyFk`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, 1, 1, 1, 442);
|
(1, 1, 1, 1, 442);
|
||||||
|
|
|
@ -12605,7 +12605,7 @@ BEGIN
|
||||||
FROM myTicket t
|
FROM myTicket t
|
||||||
WHERE shipped BETWEEN TIMESTAMP(vFrom) AND TIMESTAMP(vTo, '23:59:59');
|
WHERE shipped BETWEEN TIMESTAMP(vFrom) AND TIMESTAMP(vTo, '23:59:59');
|
||||||
|
|
||||||
CALL vn.ticketGetTotal;
|
CALL vn.ticketGetTotal(NULL);
|
||||||
|
|
||||||
SELECT v.id, IFNULL(v.landed, v.shipped) landed,
|
SELECT v.id, IFNULL(v.landed, v.shipped) landed,
|
||||||
v.shipped, v.companyFk, v.nickname,
|
v.shipped, v.companyFk, v.nickname,
|
||||||
|
@ -47167,7 +47167,7 @@ BEGIN
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
SELECT vTicketId ticketFk;
|
SELECT vTicketId ticketFk;
|
||||||
|
|
||||||
CALL ticketGetTotal;
|
CALL ticketGetTotal(NULL);
|
||||||
|
|
||||||
SELECT total INTO vTotal FROM tmp.ticketTotal;
|
SELECT total INTO vTotal FROM tmp.ticketTotal;
|
||||||
|
|
||||||
|
@ -58494,6 +58494,13 @@ BEGIN
|
||||||
DECLARE vIsCEESerial BOOL DEFAULT FALSE;
|
DECLARE vIsCEESerial BOOL DEFAULT FALSE;
|
||||||
DECLARE vIsCorrectInvoiceDate BOOL;
|
DECLARE vIsCorrectInvoiceDate BOOL;
|
||||||
DECLARE vMaxShipped DATE;
|
DECLARE vMaxShipped DATE;
|
||||||
|
DECLARE vDone BOOL;
|
||||||
|
DECLARE vTicketFk INT;
|
||||||
|
DECLARE vCursor CURSOR FOR
|
||||||
|
SELECT id
|
||||||
|
FROM ticketToInvoice;
|
||||||
|
|
||||||
|
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||||
|
|
||||||
SET vInvoiceDate = IFNULL(vInvoiceDate, util.VN_CURDATE());
|
SET vInvoiceDate = IFNULL(vInvoiceDate, util.VN_CURDATE());
|
||||||
|
|
||||||
|
@ -58579,6 +58586,20 @@ BEGIN
|
||||||
FROM invoiceOut
|
FROM invoiceOut
|
||||||
WHERE id = vNewInvoiceId;
|
WHERE id = vNewInvoiceId;
|
||||||
|
|
||||||
|
OPEN vCursor;
|
||||||
|
l: LOOP
|
||||||
|
SET vDone = FALSE;
|
||||||
|
FETCH vCursor INTO vTicketFk;
|
||||||
|
|
||||||
|
IF vDone THEN
|
||||||
|
LEAVE l;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
CALL ticket_recalc(vTicketFk, vTaxArea);
|
||||||
|
|
||||||
|
END LOOP;
|
||||||
|
CLOSE vCursor;
|
||||||
|
|
||||||
UPDATE ticket t
|
UPDATE ticket t
|
||||||
JOIN tmp.ticketToInvoice ti ON ti.id = t.id
|
JOIN tmp.ticketToInvoice ti ON ti.id = t.id
|
||||||
SET t.refFk = vNewRef;
|
SET t.refFk = vNewRef;
|
||||||
|
@ -58594,10 +58615,6 @@ BEGIN
|
||||||
INSERT INTO ticketTracking(stateFk,ticketFk,workerFk)
|
INSERT INTO ticketTracking(stateFk,ticketFk,workerFk)
|
||||||
SELECT * FROM tmp.updateInter;
|
SELECT * FROM tmp.updateInter;
|
||||||
|
|
||||||
INSERT INTO ticketLog (action, userFk, originFk, description)
|
|
||||||
SELECT 'UPDATE', account.myUser_getId(), ti.id, CONCAT('Crea factura ', vNewRef)
|
|
||||||
FROM tmp.ticketToInvoice ti;
|
|
||||||
|
|
||||||
CALL invoiceExpenceMake(vNewInvoiceId);
|
CALL invoiceExpenceMake(vNewInvoiceId);
|
||||||
CALL invoiceTaxMake(vNewInvoiceId,vTaxArea);
|
CALL invoiceTaxMake(vNewInvoiceId,vTaxArea);
|
||||||
|
|
||||||
|
@ -69870,7 +69887,7 @@ DELIMITER ;
|
||||||
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
|
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
|
||||||
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
|
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
|
||||||
DELIMITER ;;
|
DELIMITER ;;
|
||||||
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketGetTotal`()
|
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketGetTotal`(vTaxArea VARCHAR(25))
|
||||||
BEGIN
|
BEGIN
|
||||||
/**
|
/**
|
||||||
* Calcula el total con IVA para un conjunto de tickets.
|
* Calcula el total con IVA para un conjunto de tickets.
|
||||||
|
@ -69878,7 +69895,7 @@ BEGIN
|
||||||
* @table tmp.ticket(ticketFk) Identificadores de los tickets a calcular
|
* @table tmp.ticket(ticketFk) Identificadores de los tickets a calcular
|
||||||
* @return tmp.ticketTotal Total para cada ticket
|
* @return tmp.ticketTotal Total para cada ticket
|
||||||
*/
|
*/
|
||||||
CALL ticket_getTax(NULL);
|
CALL ticket_getTax(vTaxArea);
|
||||||
|
|
||||||
DROP TEMPORARY TABLE IF EXISTS tmp.ticketTotal;
|
DROP TEMPORARY TABLE IF EXISTS tmp.ticketTotal;
|
||||||
CREATE TEMPORARY TABLE tmp.ticketTotal
|
CREATE TEMPORARY TABLE tmp.ticketTotal
|
||||||
|
@ -70029,7 +70046,7 @@ BEGIN
|
||||||
AND clientFk = vClientFk
|
AND clientFk = vClientFk
|
||||||
AND shipped > '2001-01-01';
|
AND shipped > '2001-01-01';
|
||||||
|
|
||||||
CALL vn.ticketGetTotal;
|
CALL vn.ticketGetTotal(NULL);
|
||||||
|
|
||||||
SELECT c.id,
|
SELECT c.id,
|
||||||
c.name as Cliente,
|
c.name as Cliente,
|
||||||
|
@ -71878,7 +71895,7 @@ proc: BEGIN
|
||||||
LEAVE myLoop;
|
LEAVE myLoop;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
CALL ticket_recalc(vTicketFk);
|
CALL ticket_recalc(vTicketFk, NULL);
|
||||||
END LOOP;
|
END LOOP;
|
||||||
|
|
||||||
CLOSE cCur;
|
CLOSE cCur;
|
||||||
|
@ -72333,15 +72350,15 @@ BEGIN
|
||||||
JOIN ticket t ON t.id = tmpTicket.ticketFk;
|
JOIN ticket t ON t.id = tmpTicket.ticketFk;
|
||||||
|
|
||||||
CALL addressTaxArea ();
|
CALL addressTaxArea ();
|
||||||
|
|
||||||
IF vTaxArea > '' THEN
|
IF vTaxArea IS NOT NULL THEN
|
||||||
UPDATE tmp.addressTaxArea
|
UPDATE tmp.addressTaxArea
|
||||||
SET areaFk = vTaxArea;
|
SET areaFk = vTaxArea;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
/* Solo se calcula la base imponible (taxableBase) y el impuesto se calculará posteriormente
|
/* Solo se calcula la base imponible (taxableBase) y el impuesto se calculará posteriormente
|
||||||
* No se debería cambiar el sistema por problemas con los decimales
|
* No se debería cambiar el sistema por problemas con los decimales
|
||||||
*/
|
*/
|
||||||
|
|
||||||
DROP TEMPORARY TABLE IF EXISTS tmp.ticketTax;
|
DROP TEMPORARY TABLE IF EXISTS tmp.ticketTax;
|
||||||
CREATE TEMPORARY TABLE tmp.ticketTax
|
CREATE TEMPORARY TABLE tmp.ticketTax
|
||||||
(PRIMARY KEY (ticketFk, code, rate))
|
(PRIMARY KEY (ticketFk, code, rate))
|
||||||
|
@ -72349,7 +72366,7 @@ BEGIN
|
||||||
SELECT * FROM (
|
SELECT * FROM (
|
||||||
SELECT tmpTicket.ticketFk,
|
SELECT tmpTicket.ticketFk,
|
||||||
bp.pgcFk,
|
bp.pgcFk,
|
||||||
SUM(s.quantity * s.price * (100 - s.discount)/100 ) AS taxableBase,
|
SUM(s.quantity * s.price * (100 - s.discount)/100 ) taxableBase,
|
||||||
pgc.rate,
|
pgc.rate,
|
||||||
tc.code,
|
tc.code,
|
||||||
bp.priority
|
bp.priority
|
||||||
|
@ -72369,7 +72386,7 @@ BEGIN
|
||||||
JOIN pgc ON pgc.code = bp.pgcFk
|
JOIN pgc ON pgc.code = bp.pgcFk
|
||||||
JOIN taxClass tc ON tc.id = bp.taxClassFk
|
JOIN taxClass tc ON tc.id = bp.taxClassFk
|
||||||
GROUP BY tmpTicket.ticketFk, pgc.code, pgc.rate
|
GROUP BY tmpTicket.ticketFk, pgc.code, pgc.rate
|
||||||
HAVING taxableBase != 0) t3
|
HAVING taxableBase <> 0) t3
|
||||||
ORDER BY priority;
|
ORDER BY priority;
|
||||||
|
|
||||||
DROP TEMPORARY TABLE IF EXISTS tmp.ticketServiceTax;
|
DROP TEMPORARY TABLE IF EXISTS tmp.ticketServiceTax;
|
||||||
|
@ -72378,7 +72395,7 @@ BEGIN
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
SELECT tt.ticketFk,
|
SELECT tt.ticketFk,
|
||||||
pgc.code pgcFk,
|
pgc.code pgcFk,
|
||||||
SUM(ts.quantity * ts.price) AS taxableBase,
|
SUM(ts.quantity * ts.price) taxableBase,
|
||||||
pgc.rate,
|
pgc.rate,
|
||||||
tc.code
|
tc.code
|
||||||
FROM tmp.ticket tt
|
FROM tmp.ticket tt
|
||||||
|
@ -72394,7 +72411,7 @@ BEGIN
|
||||||
JOIN pgc ON pgc.code = bp.pgcFk
|
JOIN pgc ON pgc.code = bp.pgcFk
|
||||||
JOIN taxClass tc ON tc.id = bp.taxClassFk
|
JOIN taxClass tc ON tc.id = bp.taxClassFk
|
||||||
GROUP BY tt.ticketFk, pgc.code
|
GROUP BY tt.ticketFk, pgc.code
|
||||||
HAVING taxableBase != 0;
|
HAVING taxableBase <> 0;
|
||||||
|
|
||||||
INSERT INTO tmp.ticketTax (ticketFk, pgcFk, taxableBase, rate, code)
|
INSERT INTO tmp.ticketTax (ticketFk, pgcFk, taxableBase, rate, code)
|
||||||
SELECT ts.ticketFk, ts.pgcFk, ts.taxableBase, ts.rate, ts.code
|
SELECT ts.ticketFk, ts.pgcFk, ts.taxableBase, ts.rate, ts.code
|
||||||
|
@ -72405,8 +72422,8 @@ BEGIN
|
||||||
CREATE TEMPORARY TABLE tmp.ticketAmount
|
CREATE TEMPORARY TABLE tmp.ticketAmount
|
||||||
(INDEX (ticketFk))
|
(INDEX (ticketFk))
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
SELECT ticketFk,
|
SELECT ticketFk,
|
||||||
taxableBase,
|
taxableBase,
|
||||||
SUM(CAST(taxableBase * rate / 100 AS DECIMAL(10, 2))) tax,
|
SUM(CAST(taxableBase * rate / 100 AS DECIMAL(10, 2))) tax,
|
||||||
code
|
code
|
||||||
FROM tmp.ticketTax
|
FROM tmp.ticketTax
|
||||||
|
@ -72725,20 +72742,31 @@ DELIMITER ;
|
||||||
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
|
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
|
||||||
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
|
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
|
||||||
DELIMITER ;;
|
DELIMITER ;;
|
||||||
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_recalc`(vTicketId INT)
|
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_recalc`(vSelf INT, vTaxArea VARCHAR(25))
|
||||||
BEGIN
|
proc:BEGIN
|
||||||
/**
|
/**
|
||||||
* Calcula y guarda el total con/sin IVA en un ticket.
|
* Calcula y guarda el total con/sin IVA en un ticket.
|
||||||
*
|
*
|
||||||
* @param vTicketId Identificador del ticket
|
* @param vTicketId Identificador del ticket
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
DECLARE hasInvoice BOOL;
|
||||||
|
|
||||||
|
SELECT COUNT(*) INTO hasInvoice
|
||||||
|
FROM ticket
|
||||||
|
WHERE id = vSelf
|
||||||
|
AND refFk IS NOT NULL;
|
||||||
|
|
||||||
|
IF hasInvoice THEN
|
||||||
|
LEAVE proc;
|
||||||
|
END IF;
|
||||||
|
|
||||||
DROP TEMPORARY TABLE IF EXISTS tmp.ticket;
|
DROP TEMPORARY TABLE IF EXISTS tmp.ticket;
|
||||||
CREATE TEMPORARY TABLE tmp.ticket
|
CREATE TEMPORARY TABLE tmp.ticket
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
SELECT vTicketId ticketFk;
|
SELECT vSelf ticketFk;
|
||||||
|
|
||||||
CALL ticketGetTotal;
|
CALL ticketGetTotal(vTaxArea);
|
||||||
|
|
||||||
UPDATE ticket t
|
UPDATE ticket t
|
||||||
JOIN tmp.ticketTotal tt ON tt.ticketFk = t.id
|
JOIN tmp.ticketTotal tt ON tt.ticketFk = t.id
|
||||||
|
|
|
@ -311,9 +311,9 @@ export default {
|
||||||
},
|
},
|
||||||
clientDefaulter: {
|
clientDefaulter: {
|
||||||
anyClient: 'vn-client-defaulter tbody > tr',
|
anyClient: 'vn-client-defaulter tbody > tr',
|
||||||
firstClientName: 'vn-client-defaulter tbody > tr:nth-child(1) > td:nth-child(2) > span',
|
firstClientName: 'vn-client-defaulter tbody > tr:nth-child(2) > td:nth-child(2) > span',
|
||||||
firstSalesPersonName: 'vn-client-defaulter tbody > tr:nth-child(1) > td:nth-child(3) > span',
|
firstSalesPersonName: 'vn-client-defaulter tbody > tr:nth-child(2) > td:nth-child(3) > span',
|
||||||
firstObservation: 'vn-client-defaulter tbody > tr:nth-child(1) > td:nth-child(8) > vn-textarea[ng-model="defaulter.observation"]',
|
firstObservation: 'vn-client-defaulter tbody > tr:nth-child(2) > td:nth-child(8) > vn-textarea[ng-model="defaulter.observation"]',
|
||||||
allDefaulterCheckbox: 'vn-client-defaulter thead vn-multi-check',
|
allDefaulterCheckbox: 'vn-client-defaulter thead vn-multi-check',
|
||||||
addObservationButton: 'vn-client-defaulter vn-button[icon="icon-notes"]',
|
addObservationButton: 'vn-client-defaulter vn-button[icon="icon-notes"]',
|
||||||
observation: '.vn-dialog.shown vn-textarea[ng-model="$ctrl.defaulter.observation"]',
|
observation: '.vn-dialog.shown vn-textarea[ng-model="$ctrl.defaulter.observation"]',
|
||||||
|
@ -334,15 +334,15 @@ export default {
|
||||||
},
|
},
|
||||||
itemsIndex: {
|
itemsIndex: {
|
||||||
createItemButton: `vn-float-button`,
|
createItemButton: `vn-float-button`,
|
||||||
firstSearchResult: 'vn-item-index tbody tr:nth-child(1)',
|
firstSearchResult: 'vn-item-index tbody tr:nth-child(2)',
|
||||||
searchResult: 'vn-item-index tbody tr:not(.empty-rows)',
|
searchResult: 'vn-item-index tbody tr:not(.empty-rows)',
|
||||||
firstResultPreviewButton: 'vn-item-index tbody > :nth-child(1) .buttons > [icon="preview"]',
|
firstResultPreviewButton: 'vn-item-index tbody > :nth-child(2) .buttons > [icon="preview"]',
|
||||||
searchResultCloneButton: 'vn-item-index .buttons > [icon="icon-clone"]',
|
searchResultCloneButton: 'vn-item-index .buttons > [icon="icon-clone"]',
|
||||||
acceptClonationAlertButton: '.vn-confirm.shown [response="accept"]',
|
acceptClonationAlertButton: '.vn-confirm.shown [response="accept"]',
|
||||||
closeItemSummaryPreview: '.vn-popup.shown',
|
closeItemSummaryPreview: '.vn-popup.shown',
|
||||||
shownColumns: 'vn-item-index vn-button[id="shownColumns"]',
|
shownColumns: 'vn-item-index vn-button[id="shownColumns"]',
|
||||||
shownColumnsList: '.vn-popover.shown .content',
|
shownColumnsList: '.vn-popover.shown .content',
|
||||||
firstItemImage: 'vn-item-index tbody > tr:nth-child(1) > td:nth-child(1) > img',
|
firstItemImage: 'vn-item-index tbody > tr:nth-child(2) > td:nth-child(1) > img',
|
||||||
firstItemImageTd: 'vn-item-index smart-table tr:nth-child(1) td:nth-child(1)',
|
firstItemImageTd: 'vn-item-index smart-table tr:nth-child(1) td:nth-child(1)',
|
||||||
firstItemId: 'vn-item-index tbody > tr:nth-child(1) > td:nth-child(2)',
|
firstItemId: 'vn-item-index tbody > tr:nth-child(1) > td:nth-child(2)',
|
||||||
idCheckbox: '.vn-popover.shown vn-horizontal:nth-child(3) > vn-check[label="Identifier"]',
|
idCheckbox: '.vn-popover.shown vn-horizontal:nth-child(3) > vn-check[label="Identifier"]',
|
||||||
|
@ -479,9 +479,6 @@ export default {
|
||||||
fourthBalance: 'vn-item-diary vn-tbody > vn-tr:nth-child(4) > vn-td.balance > span',
|
fourthBalance: 'vn-item-diary vn-tbody > vn-tr:nth-child(4) > vn-td.balance > span',
|
||||||
firstBalance: 'vn-item-diary vn-tbody > vn-tr:nth-child(1) > vn-td.balance'
|
firstBalance: 'vn-item-diary vn-tbody > vn-tr:nth-child(1) > vn-td.balance'
|
||||||
},
|
},
|
||||||
itemLog: {
|
|
||||||
anyLineCreated: 'vn-item-log > vn-log vn-tbody > vn-tr',
|
|
||||||
},
|
|
||||||
ticketSummary: {
|
ticketSummary: {
|
||||||
header: 'vn-ticket-summary > vn-card > h5',
|
header: 'vn-ticket-summary > vn-card > h5',
|
||||||
state: 'vn-ticket-summary vn-label-value[label="State"] > section > span',
|
state: 'vn-ticket-summary vn-label-value[label="State"] > section > span',
|
||||||
|
@ -523,11 +520,11 @@ export default {
|
||||||
searchResultDate: 'vn-ticket-summary [label=Landed] span',
|
searchResultDate: 'vn-ticket-summary [label=Landed] span',
|
||||||
topbarSearch: 'vn-searchbar',
|
topbarSearch: 'vn-searchbar',
|
||||||
moreMenu: 'vn-ticket-index vn-icon-button[icon=more_vert]',
|
moreMenu: 'vn-ticket-index vn-icon-button[icon=more_vert]',
|
||||||
fourthWeeklyTicket: 'vn-ticket-weekly-index vn-card smart-table slot-table tr:nth-child(4)',
|
fourthWeeklyTicket: 'vn-ticket-weekly-index vn-card smart-table slot-table tr:nth-child(5)',
|
||||||
fiveWeeklyTicket: 'vn-ticket-weekly-index vn-card smart-table slot-table tr:nth-child(5)',
|
fiveWeeklyTicket: 'vn-ticket-weekly-index vn-card smart-table slot-table tr:nth-child(6)',
|
||||||
weeklyTicket: 'vn-ticket-weekly-index vn-card smart-table slot-table table tbody tr',
|
weeklyTicket: 'vn-ticket-weekly-index vn-card smart-table slot-table table tbody tr',
|
||||||
firstWeeklyTicketDeleteIcon: 'vn-ticket-weekly-index vn-card smart-table slot-table tr:nth-child(1) vn-icon-button[icon="delete"]',
|
firstWeeklyTicketDeleteIcon: 'vn-ticket-weekly-index vn-card smart-table slot-table tr:nth-child(2) vn-icon-button[icon="delete"]',
|
||||||
firstWeeklyTicketAgency: 'vn-ticket-weekly-index vn-card smart-table slot-table tr:nth-child(1) [ng-model="weekly.agencyModeFk"]',
|
firstWeeklyTicketAgency: 'vn-ticket-weekly-index vn-card smart-table slot-table tr:nth-child(2) [ng-model="weekly.agencyModeFk"]',
|
||||||
acceptDeleteTurn: '.vn-confirm.shown button[response="accept"]'
|
acceptDeleteTurn: '.vn-confirm.shown button[response="accept"]'
|
||||||
},
|
},
|
||||||
createTicketView: {
|
createTicketView: {
|
||||||
|
@ -572,8 +569,8 @@ export default {
|
||||||
submitNotesButton: 'button[type=submit]'
|
submitNotesButton: 'button[type=submit]'
|
||||||
},
|
},
|
||||||
ticketExpedition: {
|
ticketExpedition: {
|
||||||
firstSaleCheckbox: 'vn-ticket-expedition tr:nth-child(1) vn-check[ng-model="expedition.checked"]',
|
firstSaleCheckbox: 'vn-ticket-expedition tr:nth-child(2) vn-check[ng-model="expedition.checked"]',
|
||||||
thirdSaleCheckbox: 'vn-ticket-expedition tr:nth-child(3) vn-check[ng-model="expedition.checked"]',
|
thirdSaleCheckbox: 'vn-ticket-expedition tr:nth-child(4) vn-check[ng-model="expedition.checked"]',
|
||||||
deleteExpeditionButton: 'vn-ticket-expedition slot-actions > vn-button[icon="delete"]',
|
deleteExpeditionButton: 'vn-ticket-expedition slot-actions > vn-button[icon="delete"]',
|
||||||
moveExpeditionButton: 'vn-ticket-expedition slot-actions > vn-button[icon="keyboard_arrow_down"]',
|
moveExpeditionButton: 'vn-ticket-expedition slot-actions > vn-button[icon="keyboard_arrow_down"]',
|
||||||
moreMenuWithoutRoute: 'vn-item[name="withoutRoute"]',
|
moreMenuWithoutRoute: 'vn-item[name="withoutRoute"]',
|
||||||
|
@ -667,15 +664,6 @@ export default {
|
||||||
thirdRemoveRequestButton: 'vn-ticket-request-index vn-tr:nth-child(3) vn-icon[icon="delete"]',
|
thirdRemoveRequestButton: 'vn-ticket-request-index vn-tr:nth-child(3) vn-icon[icon="delete"]',
|
||||||
thirdRequestQuantity: 'vn-ticket-request-index vn-table vn-tr:nth-child(3) > vn-td:nth-child(6) vn-input-number',
|
thirdRequestQuantity: 'vn-ticket-request-index vn-table vn-tr:nth-child(3) > vn-td:nth-child(6) vn-input-number',
|
||||||
saveButton: 'vn-ticket-request-create button[type=submit]',
|
saveButton: 'vn-ticket-request-create button[type=submit]',
|
||||||
|
|
||||||
},
|
|
||||||
ticketLog: {
|
|
||||||
firstTD: 'vn-ticket-log vn-table vn-td:nth-child(1)',
|
|
||||||
logButton: 'vn-left-menu a[ui-sref="ticket.card.log"]',
|
|
||||||
user: 'vn-ticket-log vn-tbody vn-tr vn-td:nth-child(2)',
|
|
||||||
action: 'vn-ticket-log vn-tbody vn-tr vn-td:nth-child(4)',
|
|
||||||
changes: 'vn-ticket-log vn-data-viewer vn-tbody vn-tr table tr:nth-child(2) td.after',
|
|
||||||
id: 'vn-ticket-log vn-tr:nth-child(1) table tr:nth-child(1) td.before'
|
|
||||||
},
|
},
|
||||||
ticketService: {
|
ticketService: {
|
||||||
addServiceButton: 'vn-ticket-service vn-icon-button[vn-tooltip="Add service"] > button',
|
addServiceButton: 'vn-ticket-service vn-icon-button[vn-tooltip="Add service"] > button',
|
||||||
|
@ -712,7 +700,7 @@ export default {
|
||||||
problems: 'vn-check[label="With problems"]',
|
problems: 'vn-check[label="With problems"]',
|
||||||
tableButtonSearch: 'vn-button[vn-tooltip="Search"]',
|
tableButtonSearch: 'vn-button[vn-tooltip="Search"]',
|
||||||
moveButton: 'vn-button[vn-tooltip="Future tickets"]',
|
moveButton: 'vn-button[vn-tooltip="Future tickets"]',
|
||||||
firstCheck: 'tbody > tr:nth-child(1) > td > vn-check',
|
firstCheck: 'tbody > tr:nth-child(2) > td > vn-check',
|
||||||
multiCheck: 'vn-multi-check',
|
multiCheck: 'vn-multi-check',
|
||||||
tableId: 'vn-textfield[name="id"]',
|
tableId: 'vn-textfield[name="id"]',
|
||||||
tableFutureId: 'vn-textfield[name="futureId"]',
|
tableFutureId: 'vn-textfield[name="futureId"]',
|
||||||
|
@ -736,7 +724,7 @@ export default {
|
||||||
tableButtonSearch: 'vn-button[vn-tooltip="Search"]',
|
tableButtonSearch: 'vn-button[vn-tooltip="Search"]',
|
||||||
moveButton: 'vn-button[vn-tooltip="Advance tickets"]',
|
moveButton: 'vn-button[vn-tooltip="Advance tickets"]',
|
||||||
acceptButton: '.vn-confirm.shown button[response="accept"]',
|
acceptButton: '.vn-confirm.shown button[response="accept"]',
|
||||||
firstCheck: 'tbody > tr:nth-child(1) > td > vn-check',
|
firstCheck: 'tbody > tr:nth-child(2) > td > vn-check',
|
||||||
tableId: 'vn-textfield[name="id"]',
|
tableId: 'vn-textfield[name="id"]',
|
||||||
tableFutureId: 'vn-textfield[name="futureId"]',
|
tableFutureId: 'vn-textfield[name="futureId"]',
|
||||||
tableLiters: 'vn-textfield[name="liters"]',
|
tableLiters: 'vn-textfield[name="liters"]',
|
||||||
|
@ -810,7 +798,7 @@ export default {
|
||||||
claimAction: {
|
claimAction: {
|
||||||
importClaimButton: 'vn-claim-action vn-button[label="Import claim"]',
|
importClaimButton: 'vn-claim-action vn-button[label="Import claim"]',
|
||||||
anyLine: 'vn-claim-action vn-tbody > vn-tr',
|
anyLine: 'vn-claim-action vn-tbody > vn-tr',
|
||||||
firstDeleteLine: 'vn-claim-action tr:nth-child(1) vn-icon-button[icon="delete"]',
|
firstDeleteLine: 'vn-claim-action tr:nth-child(2) vn-icon-button[icon="delete"]',
|
||||||
isPaidWithManaCheckbox: 'vn-claim-action vn-check[ng-model="$ctrl.claim.isChargedToMana"]'
|
isPaidWithManaCheckbox: 'vn-claim-action vn-check[ng-model="$ctrl.claim.isChargedToMana"]'
|
||||||
},
|
},
|
||||||
ordersIndex: {
|
ordersIndex: {
|
||||||
|
@ -1179,8 +1167,6 @@ export default {
|
||||||
allBuyCheckbox: 'vn-entry-buy-index thead vn-check',
|
allBuyCheckbox: 'vn-entry-buy-index thead vn-check',
|
||||||
firstBuyCheckbox: 'vn-entry-buy-index tbody:nth-child(2) vn-check',
|
firstBuyCheckbox: 'vn-entry-buy-index tbody:nth-child(2) vn-check',
|
||||||
deleteBuysButton: 'vn-entry-buy-index vn-button[icon="delete"]',
|
deleteBuysButton: 'vn-entry-buy-index vn-button[icon="delete"]',
|
||||||
addBuyButton: 'vn-entry-buy-index vn-icon[icon="add"]',
|
|
||||||
secondBuyPackingPrice: 'vn-entry-buy-index tbody:nth-child(3) > tr:nth-child(1) vn-input-number[ng-model="buy.price3"]',
|
|
||||||
secondBuyGroupingPrice: 'vn-entry-buy-index tbody:nth-child(3) > tr:nth-child(1) vn-input-number[ng-model="buy.price2"]',
|
secondBuyGroupingPrice: 'vn-entry-buy-index tbody:nth-child(3) > tr:nth-child(1) vn-input-number[ng-model="buy.price2"]',
|
||||||
secondBuyPrice: 'vn-entry-buy-index tbody:nth-child(3) > tr:nth-child(1) vn-input-number[ng-model="buy.buyingValue"]',
|
secondBuyPrice: 'vn-entry-buy-index tbody:nth-child(3) > tr:nth-child(1) vn-input-number[ng-model="buy.buyingValue"]',
|
||||||
secondBuyGrouping: 'vn-entry-buy-index tbody:nth-child(3) > tr:nth-child(1) vn-input-number[ng-model="buy.grouping"]',
|
secondBuyGrouping: 'vn-entry-buy-index tbody:nth-child(3) > tr:nth-child(1) vn-input-number[ng-model="buy.grouping"]',
|
||||||
|
@ -1216,7 +1202,7 @@ export default {
|
||||||
addTagButton: 'vn-icon-button[vn-tooltip="Add tag"]',
|
addTagButton: 'vn-icon-button[vn-tooltip="Add tag"]',
|
||||||
itemTagInput: 'vn-autocomplete[ng-model="itemTag.tagFk"]',
|
itemTagInput: 'vn-autocomplete[ng-model="itemTag.tagFk"]',
|
||||||
itemTagValueInput: 'vn-autocomplete[ng-model="itemTag.value"]',
|
itemTagValueInput: 'vn-autocomplete[ng-model="itemTag.value"]',
|
||||||
firstBuy: 'vn-entry-latest-buys tbody > tr:nth-child(1)',
|
firstBuy: 'vn-entry-latest-buys tbody > tr:nth-child(2)',
|
||||||
allBuysCheckBox: 'vn-entry-latest-buys thead vn-check',
|
allBuysCheckBox: 'vn-entry-latest-buys thead vn-check',
|
||||||
secondBuyCheckBox: 'vn-entry-latest-buys tbody tr:nth-child(2) vn-check[ng-model="buy.checked"]',
|
secondBuyCheckBox: 'vn-entry-latest-buys tbody tr:nth-child(2) vn-check[ng-model="buy.checked"]',
|
||||||
editBuysButton: 'vn-entry-latest-buys vn-button[icon="edit"]',
|
editBuysButton: 'vn-entry-latest-buys vn-button[icon="edit"]',
|
||||||
|
|
|
@ -19,15 +19,14 @@ describe('SmartTable SearchBar integration', () => {
|
||||||
await page.waitToClick(selectors.itemsIndex.openAdvancedSearchButton);
|
await page.waitToClick(selectors.itemsIndex.openAdvancedSearchButton);
|
||||||
await page.autocompleteSearch(selectors.itemsIndex.advancedSearchItemType, 'Anthurium');
|
await page.autocompleteSearch(selectors.itemsIndex.advancedSearchItemType, 'Anthurium');
|
||||||
await page.waitToClick(selectors.itemsIndex.advancedSearchButton);
|
await page.waitToClick(selectors.itemsIndex.advancedSearchButton);
|
||||||
await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 3);
|
await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 4);
|
||||||
|
|
||||||
await page.reload({
|
await page.reload({
|
||||||
waitUntil: 'networkidle2'
|
waitUntil: 'networkidle2'
|
||||||
});
|
});
|
||||||
|
|
||||||
await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 3);
|
await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 4);
|
||||||
|
|
||||||
await page.waitToClick(selectors.itemsIndex.advancedSmartTableButton);
|
|
||||||
await page.write(selectors.itemsIndex.advancedSmartTableGrouping, '1');
|
await page.write(selectors.itemsIndex.advancedSmartTableGrouping, '1');
|
||||||
await page.keyboard.press('Enter');
|
await page.keyboard.press('Enter');
|
||||||
await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 2);
|
await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 2);
|
||||||
|
@ -36,7 +35,7 @@ describe('SmartTable SearchBar integration', () => {
|
||||||
waitUntil: 'networkidle2'
|
waitUntil: 'networkidle2'
|
||||||
});
|
});
|
||||||
|
|
||||||
await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 2);
|
await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should filter in section without smart-table and search in searchBar go to zone section', async() => {
|
it('should filter in section without smart-table and search in searchBar go to zone section', async() => {
|
||||||
|
|
|
@ -5,8 +5,8 @@ const $ = {
|
||||||
userName: 'vn-client-web-access vn-textfield[ng-model="$ctrl.account.name"]',
|
userName: 'vn-client-web-access vn-textfield[ng-model="$ctrl.account.name"]',
|
||||||
email: 'vn-client-web-access vn-textfield[ng-model="$ctrl.account.email"]',
|
email: 'vn-client-web-access vn-textfield[ng-model="$ctrl.account.email"]',
|
||||||
saveButton: 'vn-client-web-access button[type=submit]',
|
saveButton: 'vn-client-web-access button[type=submit]',
|
||||||
nameValue: 'vn-client-log .change:nth-child(1) .basic-json:nth-child(2) vn-json-value',
|
nameValue: 'vn-client-log .changes-log:nth-child(2) .basic-json:nth-child(2) vn-json-value',
|
||||||
activeValue: 'vn-client-log .change:nth-child(2) .basic-json:nth-child(1) vn-json-value'
|
activeValue: 'vn-client-log .changes-log:nth-child(3) .basic-json:nth-child(1) vn-json-value'
|
||||||
};
|
};
|
||||||
|
|
||||||
describe('Client web access path', () => {
|
describe('Client web access path', () => {
|
||||||
|
@ -39,9 +39,9 @@ describe('Client web access path', () => {
|
||||||
const userName = await page.getValue($.userName);
|
const userName = await page.getValue($.userName);
|
||||||
const email = await page.getValue($.email);
|
const email = await page.getValue($.email);
|
||||||
|
|
||||||
await page.accessToSection('client.card.log');
|
// await page.accessToSection('client.card.log');
|
||||||
const logName = await page.innerText($.nameValue);
|
// const logName = await page.innerText($.nameValue);
|
||||||
const logActive = await page.innerText($.activeValue);
|
// const logActive = await page.innerText($.activeValue);
|
||||||
|
|
||||||
expect(enableMessage.type).toBe('success');
|
expect(enableMessage.type).toBe('success');
|
||||||
expect(modifyMessage.type).toBe('success');
|
expect(modifyMessage.type).toBe('success');
|
||||||
|
@ -50,7 +50,7 @@ describe('Client web access path', () => {
|
||||||
expect(userName).toEqual('Legion');
|
expect(userName).toEqual('Legion');
|
||||||
expect(email).toEqual('legion@marvel.com');
|
expect(email).toEqual('legion@marvel.com');
|
||||||
|
|
||||||
expect(logName).toEqual('Legion');
|
// expect(logName).toEqual('Legion');
|
||||||
expect(logActive).toEqual('✗');
|
// expect(logActive).toEqual('✗');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -19,7 +19,7 @@ describe('Client defaulter path', () => {
|
||||||
it('should count the amount of clients in the turns section', async() => {
|
it('should count the amount of clients in the turns section', async() => {
|
||||||
const result = await page.countElement(selectors.clientDefaulter.anyClient);
|
const result = await page.countElement(selectors.clientDefaulter.anyClient);
|
||||||
|
|
||||||
expect(result).toEqual(5);
|
expect(result).toEqual(6);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should check contain expected client', async() => {
|
it('should check contain expected client', async() => {
|
||||||
|
|
|
@ -53,7 +53,7 @@ describe('Worker create path', () => {
|
||||||
expect(message.text).toContain('Data saved!');
|
expect(message.text).toContain('Data saved!');
|
||||||
|
|
||||||
// 'rollback'
|
// 'rollback'
|
||||||
await page.loginAndModule('sysadmin', 'account');
|
await page.loginAndModule('itManagement', 'account');
|
||||||
await page.accessToSearchResult(newWorker);
|
await page.accessToSearchResult(newWorker);
|
||||||
|
|
||||||
await page.waitToClick(selectors.accountDescriptor.menuButton);
|
await page.waitToClick(selectors.accountDescriptor.menuButton);
|
||||||
|
|
|
@ -18,11 +18,11 @@ describe('Item summary path', () => {
|
||||||
await page.doSearch('Ranged weapon');
|
await page.doSearch('Ranged weapon');
|
||||||
const resultsCount = await page.countElement(selectors.itemsIndex.searchResult);
|
const resultsCount = await page.countElement(selectors.itemsIndex.searchResult);
|
||||||
|
|
||||||
await page.waitForTextInElement(selectors.itemsIndex.searchResult, 'Ranged weapon');
|
await page.waitForTextInElement(selectors.itemsIndex.firstSearchResult, 'Ranged weapon');
|
||||||
await page.waitToClick(selectors.itemsIndex.firstResultPreviewButton);
|
await page.waitToClick(selectors.itemsIndex.firstResultPreviewButton);
|
||||||
const isVisible = await page.isVisible(selectors.itemSummary.basicData);
|
const isVisible = await page.isVisible(selectors.itemSummary.basicData);
|
||||||
|
|
||||||
expect(resultsCount).toBe(3);
|
expect(resultsCount).toBe(4);
|
||||||
expect(isVisible).toBeTruthy();
|
expect(isVisible).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ describe('Item summary path', () => {
|
||||||
await page.waitToClick(selectors.itemsIndex.firstResultPreviewButton);
|
await page.waitToClick(selectors.itemsIndex.firstResultPreviewButton);
|
||||||
await page.waitForSelector(selectors.itemSummary.basicData, {visible: true});
|
await page.waitForSelector(selectors.itemSummary.basicData, {visible: true});
|
||||||
|
|
||||||
expect(resultsCount).toBe(2);
|
expect(resultsCount).toBe(3);
|
||||||
});
|
});
|
||||||
|
|
||||||
it(`should now check the item summary preview shows fields from basic data`, async() => {
|
it(`should now check the item summary preview shows fields from basic data`, async() => {
|
||||||
|
|
|
@ -18,7 +18,7 @@ describe('Item log path', () => {
|
||||||
await page.doSearch('Knowledge artifact');
|
await page.doSearch('Knowledge artifact');
|
||||||
const nResults = await page.countElement(selectors.itemsIndex.searchResult);
|
const nResults = await page.countElement(selectors.itemsIndex.searchResult);
|
||||||
|
|
||||||
expect(nResults).toEqual(0);
|
expect(nResults).toEqual(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should access to the create item view by clicking the create floating button', async() => {
|
it('should access to the create item view by clicking the create floating button', async() => {
|
||||||
|
|
|
@ -27,6 +27,6 @@ describe('Ticket expeditions and log path', () => {
|
||||||
const result = await page
|
const result = await page
|
||||||
.countElement(selectors.ticketExpedition.expeditionRow);
|
.countElement(selectors.ticketExpedition.expeditionRow);
|
||||||
|
|
||||||
expect(result).toEqual(3);
|
expect(result).toEqual(4);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -19,7 +19,7 @@ describe('Ticket descriptor path', () => {
|
||||||
it('should count the amount of tickets in the turns section', async() => {
|
it('should count the amount of tickets in the turns section', async() => {
|
||||||
const result = await page.countElement(selectors.ticketsIndex.weeklyTicket);
|
const result = await page.countElement(selectors.ticketsIndex.weeklyTicket);
|
||||||
|
|
||||||
expect(result).toEqual(6);
|
expect(result).toEqual(7);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should go back to the ticket index then search and access a ticket summary', async() => {
|
it('should go back to the ticket index then search and access a ticket summary', async() => {
|
||||||
|
@ -89,7 +89,7 @@ describe('Ticket descriptor path', () => {
|
||||||
await page.doSearch('11');
|
await page.doSearch('11');
|
||||||
const nResults = await page.countElement(selectors.ticketsIndex.searchWeeklyResult);
|
const nResults = await page.countElement(selectors.ticketsIndex.searchWeeklyResult);
|
||||||
|
|
||||||
expect(nResults).toEqual(1);
|
expect(nResults).toEqual(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should delete the weekly ticket 11', async() => {
|
it('should delete the weekly ticket 11', async() => {
|
||||||
|
@ -104,7 +104,7 @@ describe('Ticket descriptor path', () => {
|
||||||
await page.doSearch();
|
await page.doSearch();
|
||||||
const nResults = await page.countElement(selectors.ticketsIndex.searchWeeklyResult);
|
const nResults = await page.countElement(selectors.ticketsIndex.searchWeeklyResult);
|
||||||
|
|
||||||
expect(nResults).toEqual(6);
|
expect(nResults).toEqual(7);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should update the agency then remove it afterwards', async() => {
|
it('should update the agency then remove it afterwards', async() => {
|
||||||
|
|
|
@ -29,7 +29,7 @@ describe('Ticket expeditions', () => {
|
||||||
const result = await page
|
const result = await page
|
||||||
.countElement(selectors.ticketExpedition.expeditionRow);
|
.countElement(selectors.ticketExpedition.expeditionRow);
|
||||||
|
|
||||||
expect(result).toEqual(1);
|
expect(result).toEqual(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
it(`should move one expedition to new ticket with route`, async() => {
|
it(`should move one expedition to new ticket with route`, async() => {
|
||||||
|
@ -45,6 +45,6 @@ describe('Ticket expeditions', () => {
|
||||||
const result = await page
|
const result = await page
|
||||||
.countElement(selectors.ticketExpedition.expeditionRow);
|
.countElement(selectors.ticketExpedition.expeditionRow);
|
||||||
|
|
||||||
expect(result).toEqual(1);
|
expect(result).toEqual(2);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -87,7 +87,7 @@ describe('Ticket Future path', () => {
|
||||||
await page.clearInput(selectors.ticketFuture.futureState);
|
await page.clearInput(selectors.ticketFuture.futureState);
|
||||||
await page.waitToClick(selectors.ticketFuture.submit);
|
await page.waitToClick(selectors.ticketFuture.submit);
|
||||||
|
|
||||||
await page.waitForNumberOfElements(selectors.ticketFuture.searchResult, 4);
|
await page.waitForNumberOfElements(selectors.ticketFuture.searchResult, 5);
|
||||||
await page.waitToClick(selectors.ticketFuture.multiCheck);
|
await page.waitToClick(selectors.ticketFuture.multiCheck);
|
||||||
await page.waitToClick(selectors.ticketFuture.firstCheck);
|
await page.waitToClick(selectors.ticketFuture.firstCheck);
|
||||||
await page.waitToClick(selectors.ticketFuture.moveButton);
|
await page.waitToClick(selectors.ticketFuture.moveButton);
|
||||||
|
|
|
@ -9,7 +9,7 @@ describe('Travel descriptor path', () => {
|
||||||
browser = await getBrowser();
|
browser = await getBrowser();
|
||||||
page = browser.page;
|
page = browser.page;
|
||||||
await page.loginAndModule('buyer', 'travel');
|
await page.loginAndModule('buyer', 'travel');
|
||||||
await page.write(selectors.travelIndex.generalSearchFilter, '1');
|
await page.write(selectors.travelIndex.generalSearchFilter, '3');
|
||||||
await page.keyboard.press('Enter');
|
await page.keyboard.press('Enter');
|
||||||
await page.waitForState('travel.card.summary');
|
await page.waitForState('travel.card.summary');
|
||||||
});
|
});
|
||||||
|
@ -23,7 +23,7 @@ describe('Travel descriptor path', () => {
|
||||||
await page.waitForState('travel.index');
|
await page.waitForState('travel.index');
|
||||||
const result = await page.countElement(selectors.travelIndex.anySearchResult);
|
const result = await page.countElement(selectors.travelIndex.anySearchResult);
|
||||||
|
|
||||||
expect(result).toBeGreaterThanOrEqual(7);
|
expect(result).toBeGreaterThanOrEqual(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should navigate to the first search result', async() => {
|
it('should navigate to the first search result', async() => {
|
||||||
|
|
|
@ -66,97 +66,4 @@ describe('Entry import, create and edit buys path', () => {
|
||||||
await page.waitToClick(selectors.globalItems.acceptButton);
|
await page.waitToClick(selectors.globalItems.acceptButton);
|
||||||
await page.waitForNumberOfElements(selectors.entryBuys.anyBuyLine, 1);
|
await page.waitForNumberOfElements(selectors.entryBuys.anyBuyLine, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should add a new buy', async() => {
|
|
||||||
await page.waitToClick(selectors.entryBuys.addBuyButton);
|
|
||||||
await page.write(selectors.entryBuys.secondBuyPackingPrice, '999');
|
|
||||||
await page.write(selectors.entryBuys.secondBuyGroupingPrice, '999');
|
|
||||||
await page.write(selectors.entryBuys.secondBuyPrice, '999');
|
|
||||||
await page.write(selectors.entryBuys.secondBuyGrouping, '999');
|
|
||||||
await page.write(selectors.entryBuys.secondBuyPacking, '999');
|
|
||||||
await page.write(selectors.entryBuys.secondBuyWeight, '999');
|
|
||||||
await page.write(selectors.entryBuys.secondBuyStickers, '999');
|
|
||||||
await page.autocompleteSearch(selectors.entryBuys.secondBuyPackage, '1');
|
|
||||||
await page.write(selectors.entryBuys.secondBuyQuantity, '999');
|
|
||||||
await page.autocompleteSearch(selectors.entryBuys.secondBuyItem, '1');
|
|
||||||
const message = await page.waitForSnackbar();
|
|
||||||
|
|
||||||
expect(message.text).toContain('Data saved!');
|
|
||||||
|
|
||||||
await page.waitForNumberOfElements(selectors.entryBuys.anyBuyLine, 2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should edit the newest buy and check data', async() => {
|
|
||||||
await page.clearInput(selectors.entryBuys.secondBuyPackingPrice);
|
|
||||||
await page.waitForTimeout(250);
|
|
||||||
await page.write(selectors.entryBuys.secondBuyPackingPrice, '100');
|
|
||||||
await page.keyboard.press('Enter');
|
|
||||||
await page.waitForSnackbar();
|
|
||||||
|
|
||||||
await page.clearInput(selectors.entryBuys.secondBuyGroupingPrice);
|
|
||||||
await page.waitForTimeout(250);
|
|
||||||
await page.write(selectors.entryBuys.secondBuyGroupingPrice, '200');
|
|
||||||
await page.keyboard.press('Enter');
|
|
||||||
await page.waitForSnackbar();
|
|
||||||
|
|
||||||
await page.clearInput(selectors.entryBuys.secondBuyPrice);
|
|
||||||
await page.waitForTimeout(250);
|
|
||||||
await page.write(selectors.entryBuys.secondBuyPrice, '300');
|
|
||||||
await page.keyboard.press('Enter');
|
|
||||||
await page.waitForSnackbar();
|
|
||||||
|
|
||||||
await page.clearInput(selectors.entryBuys.secondBuyGrouping);
|
|
||||||
await page.waitForTimeout(250);
|
|
||||||
await page.write(selectors.entryBuys.secondBuyGrouping, '400');
|
|
||||||
await page.keyboard.press('Enter');
|
|
||||||
await page.waitForSnackbar();
|
|
||||||
|
|
||||||
await page.clearInput(selectors.entryBuys.secondBuyPacking);
|
|
||||||
await page.waitForTimeout(250);
|
|
||||||
await page.write(selectors.entryBuys.secondBuyPacking, '500');
|
|
||||||
await page.keyboard.press('Enter');
|
|
||||||
await page.waitForSnackbar();
|
|
||||||
|
|
||||||
await page.clearInput(selectors.entryBuys.secondBuyWeight);
|
|
||||||
await page.waitForTimeout(250);
|
|
||||||
await page.write(selectors.entryBuys.secondBuyWeight, '600');
|
|
||||||
await page.keyboard.press('Enter');
|
|
||||||
await page.waitForSnackbar();
|
|
||||||
|
|
||||||
await page.clearInput(selectors.entryBuys.secondBuyStickers);
|
|
||||||
await page.waitForTimeout(250);
|
|
||||||
await page.write(selectors.entryBuys.secondBuyStickers, '700');
|
|
||||||
await page.keyboard.press('Enter');
|
|
||||||
await page.waitForSnackbar();
|
|
||||||
|
|
||||||
await page.autocompleteSearch(selectors.entryBuys.secondBuyPackage, '94');
|
|
||||||
await page.waitForSnackbar();
|
|
||||||
|
|
||||||
await page.clearInput(selectors.entryBuys.secondBuyQuantity);
|
|
||||||
await page.waitForTimeout(250);
|
|
||||||
await page.write(selectors.entryBuys.secondBuyQuantity, '800');
|
|
||||||
await page.keyboard.press('Enter');
|
|
||||||
|
|
||||||
await page.reloadSection('entry.card.buy.index');
|
|
||||||
|
|
||||||
const secondBuyPackingPrice = await page.getValue(selectors.entryBuys.secondBuyPackingPrice);
|
|
||||||
const secondBuyGroupingPrice = await page.getValue(selectors.entryBuys.secondBuyGroupingPrice);
|
|
||||||
const secondBuyPrice = await page.getValue(selectors.entryBuys.secondBuyPrice);
|
|
||||||
const secondBuyGrouping = await page.getValue(selectors.entryBuys.secondBuyGrouping);
|
|
||||||
const secondBuyPacking = await page.getValue(selectors.entryBuys.secondBuyPacking);
|
|
||||||
const secondBuyWeight = await page.getValue(selectors.entryBuys.secondBuyWeight);
|
|
||||||
const secondBuyStickers = await page.getValue(selectors.entryBuys.secondBuyStickers);
|
|
||||||
const secondBuyPackage = await page.getValue(selectors.entryBuys.secondBuyPackage);
|
|
||||||
const secondBuyQuantity = await page.getValue(selectors.entryBuys.secondBuyQuantity);
|
|
||||||
|
|
||||||
expect(secondBuyPackingPrice).toEqual('100');
|
|
||||||
expect(secondBuyGroupingPrice).toEqual('200');
|
|
||||||
expect(secondBuyPrice).toEqual('300');
|
|
||||||
expect(secondBuyGrouping).toEqual('400');
|
|
||||||
expect(secondBuyPacking).toEqual('500');
|
|
||||||
expect(secondBuyWeight).toEqual('600');
|
|
||||||
expect(secondBuyStickers).toEqual('700');
|
|
||||||
expect(secondBuyPackage).toEqual('94');
|
|
||||||
expect(secondBuyQuantity).toEqual('800');
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -8,7 +8,7 @@ describe('Account create and basic data path', () => {
|
||||||
beforeAll(async() => {
|
beforeAll(async() => {
|
||||||
browser = await getBrowser();
|
browser = await getBrowser();
|
||||||
page = browser.page;
|
page = browser.page;
|
||||||
await page.loginAndModule('developer', 'account');
|
await page.loginAndModule('itManagement', 'account');
|
||||||
});
|
});
|
||||||
|
|
||||||
afterAll(async() => {
|
afterAll(async() => {
|
||||||
|
|
|
@ -4,8 +4,8 @@ vn-avatar {
|
||||||
display: block;
|
display: block;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
height: 36px;
|
height: 38px;
|
||||||
width: 36px;
|
width: 38px;
|
||||||
font-size: 22px;
|
font-size: 22px;
|
||||||
background-color: $color-main;
|
background-color: $color-main;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|
|
@ -40,6 +40,8 @@ export default class SmartTable extends Component {
|
||||||
this._options = options;
|
this._options = options;
|
||||||
if (!options) return;
|
if (!options) return;
|
||||||
|
|
||||||
|
options.defaultSearch = true;
|
||||||
|
|
||||||
if (options.defaultSearch)
|
if (options.defaultSearch)
|
||||||
this.displaySearch();
|
this.displaySearch();
|
||||||
|
|
||||||
|
|
|
@ -59,12 +59,13 @@ export default class Auth {
|
||||||
password: password || undefined
|
password: password || undefined
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const now = new Date();
|
||||||
return this.$http.post('VnUsers/signIn', params)
|
return this.$http.post('VnUsers/signIn', params)
|
||||||
.then(json => this.onLoginOk(json, remember));
|
.then(json => this.onLoginOk(json, now, remember));
|
||||||
}
|
}
|
||||||
|
|
||||||
onLoginOk(json, remember) {
|
onLoginOk(json, now, remember) {
|
||||||
this.vnToken.set(json.data.token, remember);
|
this.vnToken.set(json.data.token, now, json.data.ttl, remember);
|
||||||
|
|
||||||
return this.loadAcls().then(() => {
|
return this.loadAcls().then(() => {
|
||||||
let continueHash = this.$state.params.continue;
|
let continueHash = this.$state.params.continue;
|
||||||
|
|
|
@ -11,3 +11,4 @@ import './report';
|
||||||
import './email';
|
import './email';
|
||||||
import './file';
|
import './file';
|
||||||
import './date';
|
import './date';
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,16 @@
|
||||||
import ngModule from '../module';
|
import ngModule from '../module';
|
||||||
import HttpError from 'core/lib/http-error';
|
import HttpError from 'core/lib/http-error';
|
||||||
|
|
||||||
interceptor.$inject = ['$q', 'vnApp', 'vnToken', '$translate'];
|
interceptor.$inject = ['$q', 'vnApp', '$translate'];
|
||||||
function interceptor($q, vnApp, vnToken, $translate) {
|
function interceptor($q, vnApp, $translate) {
|
||||||
let apiPath = 'api/';
|
let apiPath = 'api/';
|
||||||
|
let token = sessionStorage.getItem('vnToken')
|
||||||
|
?? localStorage.getItem('vnToken');
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
setToken(newToken) {
|
||||||
|
token = newToken;
|
||||||
|
},
|
||||||
setApiPath(path) {
|
setApiPath(path) {
|
||||||
apiPath = path;
|
apiPath = path;
|
||||||
},
|
},
|
||||||
|
@ -14,8 +19,8 @@ function interceptor($q, vnApp, vnToken, $translate) {
|
||||||
|
|
||||||
if (config.url.charAt(0) !== '/' && apiPath)
|
if (config.url.charAt(0) !== '/' && apiPath)
|
||||||
config.url = `${apiPath}${config.url}`;
|
config.url = `${apiPath}${config.url}`;
|
||||||
if (vnToken.token)
|
if (token)
|
||||||
config.headers.Authorization = vnToken.token;
|
config.headers.Authorization = token;
|
||||||
if ($translate.use())
|
if ($translate.use())
|
||||||
config.headers['Accept-Language'] = $translate.use();
|
config.headers['Accept-Language'] = $translate.use();
|
||||||
if (config.filter) {
|
if (config.filter) {
|
||||||
|
|
|
@ -6,29 +6,118 @@ import ngModule from '../module';
|
||||||
* @property {String} token The current login token or %null
|
* @property {String} token The current login token or %null
|
||||||
*/
|
*/
|
||||||
export default class Token {
|
export default class Token {
|
||||||
constructor() {
|
constructor(vnInterceptor, $http, $rootScope) {
|
||||||
|
Object.assign(this, {
|
||||||
|
vnInterceptor,
|
||||||
|
$http,
|
||||||
|
$rootScope
|
||||||
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.token = sessionStorage.getItem('vnToken');
|
this.getStorage(sessionStorage);
|
||||||
if (!this.token)
|
this.remember = true;
|
||||||
this.token = localStorage.getItem('vnToken');
|
|
||||||
|
if (!this.token) {
|
||||||
|
this.getStorage(localStorage);
|
||||||
|
this.remember = false;
|
||||||
|
}
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
set(value, remember) {
|
|
||||||
|
set(token, created, ttl, remember) {
|
||||||
this.unset();
|
this.unset();
|
||||||
|
|
||||||
|
Object.assign(this, {
|
||||||
|
token,
|
||||||
|
created,
|
||||||
|
ttl,
|
||||||
|
remember
|
||||||
|
});
|
||||||
|
this.vnInterceptor.setToken(token);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (remember)
|
if (remember)
|
||||||
localStorage.setItem('vnToken', value);
|
this.setStorage(localStorage, token, created, ttl);
|
||||||
else
|
else
|
||||||
sessionStorage.setItem('vnToken', value);
|
this.setStorage(sessionStorage, token, created, ttl);
|
||||||
} catch (e) {}
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
this.token = value;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unset() {
|
unset() {
|
||||||
localStorage.removeItem('vnToken');
|
|
||||||
sessionStorage.removeItem('vnToken');
|
|
||||||
this.token = null;
|
this.token = null;
|
||||||
|
this.created = null;
|
||||||
|
this.ttl = null;
|
||||||
|
this.remember = null;
|
||||||
|
this.vnInterceptor.setToken(null);
|
||||||
|
|
||||||
|
this.removeStorage(localStorage);
|
||||||
|
this.removeStorage(sessionStorage);
|
||||||
|
}
|
||||||
|
|
||||||
|
getStorage(storage) {
|
||||||
|
this.token = storage.getItem('vnToken');
|
||||||
|
if (!this.token) return;
|
||||||
|
const created = storage.getItem('vnTokenCreated');
|
||||||
|
this.created = created && new Date(created);
|
||||||
|
this.renewPeriod = storage.getItem('vnTokenRenewPeriod');
|
||||||
|
}
|
||||||
|
|
||||||
|
setStorage(storage, token, created, ttl) {
|
||||||
|
storage.setItem('vnToken', token);
|
||||||
|
storage.setItem('vnTokenCreated', created.toJSON());
|
||||||
|
storage.setItem('vnTokenTtl', ttl);
|
||||||
|
}
|
||||||
|
|
||||||
|
removeStorage(storage) {
|
||||||
|
storage.removeItem('vnToken');
|
||||||
|
storage.removeItem('vnTokenCreated');
|
||||||
|
storage.removeItem('vnTokenTtl');
|
||||||
|
}
|
||||||
|
|
||||||
|
fetchConfig() {
|
||||||
|
const filter = {fields: ['renewInterval', 'renewPeriod']};
|
||||||
|
this.$http.get('AccessTokenConfigs/findOne', {filter}).then(res => {
|
||||||
|
const data = res.data;
|
||||||
|
if (!data) return;
|
||||||
|
this.renewPeriod = data.renewPeriod;
|
||||||
|
this.stopRenewer();
|
||||||
|
this.inservalId = setInterval(() => this.checkValidity(), data.renewInterval * 1000);
|
||||||
|
this.checkValidity();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
checkValidity() {
|
||||||
|
if (this.checking || !this.created) return;
|
||||||
|
this.checking = true;
|
||||||
|
const renewPeriod = Math.min(this.ttl, this.renewPeriod) * 1000;
|
||||||
|
const maxDate = this.created.getTime() + renewPeriod;
|
||||||
|
const now = new Date();
|
||||||
|
|
||||||
|
if (now.getTime() <= maxDate) {
|
||||||
|
this.checking = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.$http.post('VnUsers/renewToken')
|
||||||
|
.then(res => {
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Token.$inject = ['vnInterceptor', '$http', '$rootScope'];
|
||||||
|
|
||||||
ngModule.service('vnToken', Token);
|
ngModule.service('vnToken', Token);
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
<button class="buttonAccount">
|
<button class="buttonAccount">
|
||||||
<img
|
<img
|
||||||
id="user"
|
id="user"
|
||||||
ng-src="{{$ctrl.getImageUrl()}}"
|
ng-src="{{::$ctrl.getImageUrl()}}"
|
||||||
ng-click="userPopover.show($event)"
|
ng-click="userPopover.show($event)"
|
||||||
translate-attr="{title: 'Account'}"
|
translate-attr="{title: 'Account'}"
|
||||||
on-error-src/>
|
on-error-src/>
|
||||||
|
@ -93,4 +93,4 @@
|
||||||
</vn-list>
|
</vn-list>
|
||||||
</vn-portal>
|
</vn-portal>
|
||||||
<ui-view class="main-view"></ui-view>
|
<ui-view class="main-view"></ui-view>
|
||||||
<vn-scroll-up></vn-scroll-up>
|
<vn-scroll-up></vn-scroll-up>
|
||||||
|
|
|
@ -30,6 +30,10 @@ export class Layout extends Component {
|
||||||
refresh() {
|
refresh() {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$onDestroy() {
|
||||||
|
this.vnToken.stopRenewer();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Layout.$inject = ['$element', '$scope', 'vnModules'];
|
Layout.$inject = ['$element', '$scope', 'vnModules'];
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
vn-id="model"
|
vn-id="model"
|
||||||
url="{{$ctrl.url}}"
|
url="{{$ctrl.url}}"
|
||||||
filter="$ctrl.filter"
|
filter="$ctrl.filter"
|
||||||
link="{originFk: $ctrl.originId}"
|
|
||||||
where="{changedModel: $ctrl.changedModel, changedModelId: $ctrl.changedModelId}"
|
|
||||||
data="$ctrl.logs"
|
data="$ctrl.logs"
|
||||||
order="creationDate DESC, id DESC"
|
order="creationDate DESC, id DESC"
|
||||||
limit="20">
|
limit="20">
|
||||||
|
@ -17,90 +15,110 @@
|
||||||
<vn-data-viewer
|
<vn-data-viewer
|
||||||
model="model"
|
model="model"
|
||||||
class="vn-w-sm vn-px-sm vn-pb-xl">
|
class="vn-w-sm vn-px-sm vn-pb-xl">
|
||||||
<div class="change vn-mb-sm" ng-repeat="log in $ctrl.logs">
|
<div class="origin-log" ng-repeat="originLog in $ctrl.logTree">
|
||||||
<div class="left">
|
<div class="origin-info vn-mb-md" ng-if="::$ctrl.logTree.length > 1">
|
||||||
<vn-avatar class="vn-mt-xs"
|
<h6 class="origin-id">
|
||||||
ng-class="::{system: !log.user}"
|
{{::$ctrl.modelI18n}} #{{::originLog.originFk}}
|
||||||
val="{{::log.user ? log.user.nickname : $ctrl.$t('System')}}"
|
</h6>
|
||||||
ng-click="$ctrl.showWorkerDescriptor($event, log)">
|
|
||||||
<img
|
|
||||||
ng-if="::log.user.image"
|
|
||||||
ng-src="/api/Images/user/160x160/{{::log.userFk}}/download?access_token={{::$ctrl.vnToken.token}}">
|
|
||||||
</img>
|
|
||||||
</vn-avatar>
|
|
||||||
<div class="arrow bg-panel"></div>
|
|
||||||
<div class="line"></div>
|
<div class="line"></div>
|
||||||
</div>
|
</div>
|
||||||
<vn-card class="detail">
|
<div class="user-log vn-mb-sm" ng-repeat="userLog in ::originLog.logs">
|
||||||
<div class="header vn-pa-sm">
|
<div class="timeline">
|
||||||
<div class="action-model">
|
<div class="user-avatar">
|
||||||
<span class="model-name"
|
<vn-avatar
|
||||||
ng-if="::$ctrl.showModelName && log.changedModel"
|
ng-class="::{system: !userLog.user}"
|
||||||
ng-style="::{backgroundColor: $ctrl.hashToColor(log.changedModel)}"
|
val="{{::userLog.user ? userLog.user.nickname : $ctrl.$t('System')}}"
|
||||||
title="{{::log.changedModel}}">
|
ng-click="$ctrl.showWorkerDescriptor($event, userLog)">
|
||||||
{{::log.changedModelI18n}}
|
<img
|
||||||
</span>
|
ng-if="::userLog.user.image"
|
||||||
</div>
|
ng-src="/api/Images/user/160x160/{{::userLog.userFk}}/download?access_token={{::$ctrl.vnToken.token}}">
|
||||||
<div
|
</img>
|
||||||
class="action-date text-secondary text-caption vn-ml-sm"
|
</vn-avatar>
|
||||||
title="{{::log.creationDate | date:'dd/MM/yyyy HH:mm:ss'}}">
|
|
||||||
{{::$ctrl.relativeDate(log.creationDate)}}
|
|
||||||
<vn-icon
|
|
||||||
class="action vn-ml-xs"
|
|
||||||
ng-class="::$ctrl.actionsClass[log.action]"
|
|
||||||
icon="{{::$ctrl.actionsIcon[log.action]}}"
|
|
||||||
translate-attr="::{title: $ctrl.actionsText[log.action]}">
|
|
||||||
</vn-icon>
|
|
||||||
</div>
|
</div>
|
||||||
|
<div class="arrow bg-panel" ng-if="::$ctrl.byRecord"></div>
|
||||||
|
<div class="line"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="model vn-pb-sm vn-px-sm"
|
<div class="user-changes">
|
||||||
ng-if="::$ctrl.showModelName">
|
<div class="model-log" ng-repeat="modelLog in ::userLog.logs">
|
||||||
<span class="model-id" ng-if="::log.changedModelId">#{{::log.changedModelId}}</span>
|
<div class="model-info vn-my-sm" ng-if="::!$ctrl.byRecord">
|
||||||
<vn-icon
|
<vn-icon
|
||||||
icon="filter_alt"
|
icon="filter_alt"
|
||||||
translate-attr="{title: 'Show all record changes'}"
|
translate-attr="{title: 'Show all record changes'}"
|
||||||
ng-click="$ctrl.filterByEntity(log)">
|
ng-click="$ctrl.filterByRecord(modelLog)">
|
||||||
</vn-icon>
|
</vn-icon>
|
||||||
<span class="model-value" title="{{::log.changedModelValue}}">{{::log.changedModelValue}}</span>
|
<span class="model-name"
|
||||||
</div>
|
ng-if="::$ctrl.showModelName && modelLog.model"
|
||||||
<div class="changes vn-pa-sm"
|
ng-style="::{backgroundColor: $ctrl.hashToColor(modelLog.model)}"
|
||||||
ng-class="{expanded: log.expand}"
|
title="{{::modelLog.model}}">
|
||||||
ng-if="::log.props.length || log.description">
|
{{::modelLog.modelI18n}}
|
||||||
<vn-icon
|
|
||||||
icon="expand_more"
|
|
||||||
translate-attr="{title: 'Details'}"
|
|
||||||
ng-click="log.expand = !log.expand">
|
|
||||||
</vn-icon>
|
|
||||||
<span ng-if="::log.props.length"
|
|
||||||
class="attributes">
|
|
||||||
<span ng-if="!log.expand" ng-repeat="prop in ::log.props"
|
|
||||||
class="basic-json">
|
|
||||||
<span class="json-field" title="{{::prop.name}}">
|
|
||||||
{{::prop.nameI18n}}:
|
|
||||||
</span>
|
</span>
|
||||||
<vn-json-value value="::prop.val.val"></vn-json-value><span ng-if="::!$last">,</span>
|
<span class="model-id" ng-if="::modelLog.id">#{{::modelLog.id}}</span>
|
||||||
</span>
|
<span class="model-value" title="{{::modelLog.showValue}}">{{::modelLog.showValue}}</span>
|
||||||
<div ng-if="log.expand" class="expanded-json">
|
|
||||||
<div ng-repeat="prop in ::log.props">
|
|
||||||
<span class="json-field" title="{{::prop.name}}">
|
|
||||||
{{::prop.nameI18n}}:
|
|
||||||
</span>
|
|
||||||
<vn-log-value val="::prop.val"></vn-log-value>
|
|
||||||
<span ng-if="::log.action == 'update'">
|
|
||||||
← <vn-log-value val="::prop.old"></vn-log-value>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</span>
|
<vn-card class="changes-log vn-mb-xs" ng-repeat="log in ::modelLog.logs">
|
||||||
<span ng-if="::!log.props.length" class="description">
|
<div class="change-info vn-pa-sm">
|
||||||
{{::log.description}}
|
<div
|
||||||
</span>
|
class="date text-secondary text-caption vn-mr-sm"
|
||||||
</vn-card>
|
title="{{::log.creationDate | date:'dd/MM/yyyy HH:mm:ss'}}">
|
||||||
|
{{::$ctrl.relativeDate(log.creationDate)}}
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<vn-icon
|
||||||
|
class="pit vn-ml-xs"
|
||||||
|
icon="preview"
|
||||||
|
translate-attr="::{title: 'View record at this point in time'}"
|
||||||
|
ng-show="::log.action != 'insert'"
|
||||||
|
ng-click="$ctrl.viewPitInstance($event, log.id, modelLog)">
|
||||||
|
</vn-icon>
|
||||||
|
<vn-icon
|
||||||
|
class="action vn-ml-xs"
|
||||||
|
ng-class="::$ctrl.actionsClass[log.action]"
|
||||||
|
icon="{{::$ctrl.actionsIcon[log.action]}}"
|
||||||
|
translate-attr="::{title: $ctrl.actionsText[log.action]}">
|
||||||
|
</vn-icon>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="change-detail vn-pa-sm"
|
||||||
|
ng-class="{expanded: log.expand}"
|
||||||
|
ng-if="::log.props.length || log.description">
|
||||||
|
<vn-icon
|
||||||
|
icon="expand_more"
|
||||||
|
translate-attr="{title: 'Details'}"
|
||||||
|
ng-click="log.expand = !log.expand">
|
||||||
|
</vn-icon>
|
||||||
|
<span ng-if="::log.props.length"
|
||||||
|
class="attributes">
|
||||||
|
<span ng-if="!log.expand" ng-repeat="prop in ::log.props"
|
||||||
|
class="basic-json">
|
||||||
|
<span class="json-field" title="{{::prop.name}}">
|
||||||
|
{{::prop.nameI18n}}:
|
||||||
|
</span>
|
||||||
|
<vn-json-value value="::prop.val.val"></vn-json-value><span ng-if="::!$last">,</span>
|
||||||
|
</span>
|
||||||
|
<div ng-if="log.expand" class="expanded-json">
|
||||||
|
<div ng-repeat="prop in ::log.props">
|
||||||
|
<span class="json-field" title="{{::prop.name}}">
|
||||||
|
{{::prop.nameI18n}}:
|
||||||
|
</span>
|
||||||
|
<vn-log-value val="::prop.val"></vn-log-value>
|
||||||
|
<span ng-if="::log.action == 'update'">
|
||||||
|
← <vn-log-value val="::prop.old"></vn-log-value>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</span>
|
||||||
|
<span ng-if="::!log.props.length" class="description">
|
||||||
|
{{::log.description}}
|
||||||
|
</span>
|
||||||
|
</vn-card>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</vn-data-viewer>
|
</vn-data-viewer>
|
||||||
<vn-float-button
|
<vn-float-button
|
||||||
ng-if="model.userFilter"
|
ng-if="$ctrl.hasFilter"
|
||||||
icon="filter_alt_off"
|
icon="filter_alt_off"
|
||||||
translate-attr="{title: 'Quit filter'}"
|
translate-attr="{title: 'Quit filter'}"
|
||||||
ng-click="$ctrl.resetFilter()"
|
ng-click="$ctrl.resetFilter()"
|
||||||
|
@ -212,5 +230,33 @@
|
||||||
</vn-date-picker>
|
</vn-date-picker>
|
||||||
</form>
|
</form>
|
||||||
</vn-side-menu>
|
</vn-side-menu>
|
||||||
<vn-worker-descriptor-popover vn-id="workerDescriptor">
|
<vn-popover vn-id="instance-popover">
|
||||||
|
<tpl-body class="vn-log-instance">
|
||||||
|
<vn-spinner
|
||||||
|
ng-if="$ctrl.instance.canceler"
|
||||||
|
class="loading vn-pa-sm"
|
||||||
|
enable="true">
|
||||||
|
</vn-spinner>
|
||||||
|
<div
|
||||||
|
ng-if="!$ctrl.instance.canceler" class="instance">
|
||||||
|
<h6 class="header vn-pa-sm">
|
||||||
|
{{$ctrl.instance.modelLog.modelI18n}} #{{$ctrl.instance.modelLog.id}}
|
||||||
|
</h6>
|
||||||
|
<div class="change-detail vn-pa-sm">
|
||||||
|
<div ng-if="$ctrl.instance.props"
|
||||||
|
ng-repeat="prop in $ctrl.instance.props">
|
||||||
|
<span class="json-field" title="{{::prop.name}}">
|
||||||
|
{{::prop.nameI18n}}:
|
||||||
|
</span>
|
||||||
|
<vn-log-value val="::prop.val"></vn-log-value>
|
||||||
|
</div>
|
||||||
|
<div ng-if="!$ctrl.instance.props" translate>
|
||||||
|
No data
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</tpl-body>
|
||||||
|
</vn-popover>
|
||||||
|
<vn-worker-descriptor-popover
|
||||||
|
vn-id="worker-descriptor">
|
||||||
</vn-worker-descriptor-popover>
|
</vn-worker-descriptor-popover>
|
||||||
|
|
|
@ -3,7 +3,10 @@ import Section from '../section';
|
||||||
import {hashToColor} from 'core/lib/string';
|
import {hashToColor} from 'core/lib/string';
|
||||||
import './style.scss';
|
import './style.scss';
|
||||||
|
|
||||||
const validDate = /^(-?(?:[1-9][0-9]*)?[0-9]{4})-(1[0-2]|0[1-9])-(3[01]|0[1-9]|[12][0-9])T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])(.[0-9]+)?(Z)?$/;
|
const validDate = new RegExp(
|
||||||
|
/^(-?(?:[1-9][0-9]*)?[0-9]{4})-(1[0-2]|0[1-9])-(3[01]|0[1-9]|[12][0-9])/.source
|
||||||
|
+ /T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])(.[0-9]+)?(Z)?$/.source
|
||||||
|
);
|
||||||
|
|
||||||
export default class Controller extends Section {
|
export default class Controller extends Section {
|
||||||
constructor($element, $) {
|
constructor($element, $) {
|
||||||
|
@ -28,6 +31,20 @@ export default class Controller extends Section {
|
||||||
select: 'visibility'
|
select: 'visibility'
|
||||||
};
|
};
|
||||||
this.filter = {
|
this.filter = {
|
||||||
|
fields: [
|
||||||
|
'id',
|
||||||
|
'originFk',
|
||||||
|
'userFk',
|
||||||
|
'action',
|
||||||
|
'changedModel',
|
||||||
|
'oldInstance',
|
||||||
|
'newInstance',
|
||||||
|
'creationDate',
|
||||||
|
'changedModel',
|
||||||
|
'changedModelId',
|
||||||
|
'changedModelValue',
|
||||||
|
'description'
|
||||||
|
],
|
||||||
include: [{
|
include: [{
|
||||||
relation: 'user',
|
relation: 'user',
|
||||||
scope: {
|
scope: {
|
||||||
|
@ -48,6 +65,11 @@ export default class Controller extends Section {
|
||||||
this.today.setHours(0, 0, 0, 0);
|
this.today.setHours(0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$onInit() {
|
||||||
|
const match = this.url?.match(/(.*)Logs$/);
|
||||||
|
this.modelI18n = match && this.translateModel(match[1]);
|
||||||
|
}
|
||||||
|
|
||||||
$postLink() {
|
$postLink() {
|
||||||
this.resetFilter();
|
this.resetFilter();
|
||||||
this.$.$watch(
|
this.$.$watch(
|
||||||
|
@ -63,47 +85,75 @@ export default class Controller extends Section {
|
||||||
|
|
||||||
set logs(value) {
|
set logs(value) {
|
||||||
this._logs = value;
|
this._logs = value;
|
||||||
|
this.logTree = [];
|
||||||
if (!value) return;
|
if (!value) return;
|
||||||
|
|
||||||
const empty = {};
|
const empty = {};
|
||||||
const validations = window.validations;
|
const validations = window.validations;
|
||||||
const castJsonValue = this.castJsonValue;
|
|
||||||
|
|
||||||
for (const log of value) {
|
let originLog;
|
||||||
|
let userLog;
|
||||||
|
let modelLog;
|
||||||
|
let nLogs;
|
||||||
|
|
||||||
|
for (let i = 0; i < value.length; i++) {
|
||||||
|
const log = value[i];
|
||||||
|
const prevLog = i > 0 ? value[i - 1] : null;
|
||||||
|
const locale = validations[log.changedModel]?.locale || empty;
|
||||||
|
|
||||||
|
// Origin
|
||||||
|
|
||||||
|
const originChanged = !prevLog
|
||||||
|
|| log.originFk != prevLog.originFk;
|
||||||
|
if (originChanged) {
|
||||||
|
this.logTree.push(originLog = {
|
||||||
|
originFk: log.originFk,
|
||||||
|
logs: []
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// User
|
||||||
|
|
||||||
|
const userChanged = originChanged
|
||||||
|
|| log.userFk != prevLog.userFk;
|
||||||
|
if (userChanged) {
|
||||||
|
originLog.logs.push(userLog = {
|
||||||
|
user: log.user,
|
||||||
|
userFk: log.userFk,
|
||||||
|
logs: []
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Model
|
||||||
|
|
||||||
|
const modelChanged = userChanged
|
||||||
|
|| log.changedModel != prevLog.changedModel
|
||||||
|
|| log.changedModelId != prevLog.changedModelId
|
||||||
|
|| nLogs >= 6;
|
||||||
|
if (modelChanged) {
|
||||||
|
userLog.logs.push(modelLog = {
|
||||||
|
model: log.changedModel,
|
||||||
|
modelI18n: firstUpper(locale.name) || log.changedModel,
|
||||||
|
id: log.changedModelId,
|
||||||
|
showValue: log.changedModelValue,
|
||||||
|
logs: []
|
||||||
|
});
|
||||||
|
nLogs = 0;
|
||||||
|
}
|
||||||
|
nLogs++;
|
||||||
|
|
||||||
|
modelLog.logs.push(log);
|
||||||
|
|
||||||
|
// Changes
|
||||||
|
|
||||||
const notDelete = log.action != 'delete';
|
const notDelete = log.action != 'delete';
|
||||||
const olds = (notDelete ? log.oldInstance : null) || empty;
|
const olds = (notDelete ? log.oldInstance : null) || empty;
|
||||||
const vals = (notDelete ? log.newInstance : log.oldInstance) || empty;
|
const vals = (notDelete ? log.newInstance : log.oldInstance) || empty;
|
||||||
const locale = validations[log.changedModel]?.locale || empty;
|
|
||||||
log.changedModelI18n = firstUpper(locale.name) || log.changedModel;
|
|
||||||
|
|
||||||
let props = Object.keys(olds).concat(Object.keys(vals));
|
let propNames = Object.keys(olds).concat(Object.keys(vals));
|
||||||
props = [...new Set(props)];
|
propNames = [...new Set(propNames)];
|
||||||
|
|
||||||
log.props = [];
|
log.props = this.parseProps(propNames, locale, vals, olds);
|
||||||
for (const prop of props) {
|
|
||||||
if (prop.endsWith('$')) continue;
|
|
||||||
log.props.push({
|
|
||||||
name: prop,
|
|
||||||
nameI18n: firstUpper(locale.columns?.[prop]) || prop,
|
|
||||||
old: getVal(olds, prop),
|
|
||||||
val: getVal(vals, prop)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
log.props.sort(
|
|
||||||
(a, b) => a.nameI18n.localeCompare(b.nameI18n));
|
|
||||||
}
|
|
||||||
|
|
||||||
function getVal(vals, prop) {
|
|
||||||
let val, id;
|
|
||||||
const showProp = `${prop}$`;
|
|
||||||
|
|
||||||
if (vals[showProp] != null) {
|
|
||||||
val = vals[showProp];
|
|
||||||
id = vals[prop];
|
|
||||||
} else
|
|
||||||
val = vals[prop];
|
|
||||||
|
|
||||||
return {val: castJsonValue(val), id};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,17 +164,76 @@ export default class Controller extends Section {
|
||||||
set models(value) {
|
set models(value) {
|
||||||
this._models = value;
|
this._models = value;
|
||||||
if (!value) return;
|
if (!value) return;
|
||||||
for (const model of value) {
|
for (const model of value)
|
||||||
const name = model.changedModel;
|
model.changedModelI18n = this.translateModel(model.changedModel);
|
||||||
model.changedModelI18n =
|
|
||||||
firstUpper(window.validations[name]?.locale?.name) || name;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get showModelName() {
|
get showModelName() {
|
||||||
return !(this.changedModel && this.changedModelId);
|
return !(this.changedModel && this.changedModelId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
parseProps(propNames, locale, vals, olds) {
|
||||||
|
const castJsonValue = this.castJsonValue;
|
||||||
|
const props = [];
|
||||||
|
|
||||||
|
for (const prop of propNames) {
|
||||||
|
if (prop.endsWith('$')) continue;
|
||||||
|
props.push({
|
||||||
|
name: prop,
|
||||||
|
nameI18n: firstUpper(locale.columns?.[prop]) || prop,
|
||||||
|
val: getVal(vals, prop),
|
||||||
|
old: olds && getVal(olds, prop)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
props.sort(
|
||||||
|
(a, b) => a.nameI18n.localeCompare(b.nameI18n));
|
||||||
|
|
||||||
|
function getVal(vals, prop) {
|
||||||
|
let val; let id;
|
||||||
|
const showProp = `${prop}$`;
|
||||||
|
|
||||||
|
if (vals[showProp] != null) {
|
||||||
|
val = vals[showProp];
|
||||||
|
id = vals[prop];
|
||||||
|
} else
|
||||||
|
val = vals[prop];
|
||||||
|
|
||||||
|
return {val: castJsonValue(val), id};
|
||||||
|
}
|
||||||
|
|
||||||
|
return props;
|
||||||
|
}
|
||||||
|
|
||||||
|
viewPitInstance(event, id, modelLog) {
|
||||||
|
if (this.instance?.canceler)
|
||||||
|
this.instance.canceler.resolve();
|
||||||
|
|
||||||
|
const canceler = this.$q.defer();
|
||||||
|
this.instance = {
|
||||||
|
modelLog,
|
||||||
|
canceler
|
||||||
|
};
|
||||||
|
const options = {timeout: canceler.promise};
|
||||||
|
|
||||||
|
this.$http.get(`${this.url}/${id}/pitInstance`, options)
|
||||||
|
.then(res => {
|
||||||
|
const instance = res.data;
|
||||||
|
const propNames = Object.keys(instance);
|
||||||
|
const locale = window.validations[modelLog.model]?.locale || {};
|
||||||
|
this.instance.props = this.parseProps(propNames, locale, instance);
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
this.instance.canceler = null;
|
||||||
|
this.$.$applyAsync(() => this.$.instancePopover.relocate());
|
||||||
|
});
|
||||||
|
|
||||||
|
this.$.instancePopover.show(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
translateModel(name) {
|
||||||
|
return firstUpper(window.validations[name]?.locale?.name) || name;
|
||||||
|
}
|
||||||
|
|
||||||
castJsonValue(value) {
|
castJsonValue(value) {
|
||||||
return typeof value === 'string' && validDate.test(value)
|
return typeof value === 'string' && validDate.test(value)
|
||||||
? new Date(value)
|
? new Date(value)
|
||||||
|
@ -160,12 +269,11 @@ export default class Controller extends Section {
|
||||||
applyFilter() {
|
applyFilter() {
|
||||||
const filter = this.$.filter;
|
const filter = this.$.filter;
|
||||||
|
|
||||||
function getParam(prop, value) {
|
const getParam = (prop, value) => {
|
||||||
if (value == null || value == '') return null;
|
if (value == null || value == '') return null;
|
||||||
switch (prop) {
|
switch (prop) {
|
||||||
case 'search':
|
case 'search':
|
||||||
const or = [];
|
if (/^\s*[0-9]+\s*$/.test(value) || this.byRecord)
|
||||||
if (/^\s*[0-9]+\s*$/.test(value))
|
|
||||||
return {changedModelId: value.trim()};
|
return {changedModelId: value.trim()};
|
||||||
else
|
else
|
||||||
return {changedModelValue: {like: `%${value}%`}};
|
return {changedModelValue: {like: `%${value}%`}};
|
||||||
|
@ -177,72 +285,86 @@ export default class Controller extends Section {
|
||||||
]};
|
]};
|
||||||
case 'who':
|
case 'who':
|
||||||
switch (value) {
|
switch (value) {
|
||||||
case 'all':
|
|
||||||
return null;
|
|
||||||
case 'user':
|
case 'user':
|
||||||
return {userFk: {neq: null}};
|
return {userFk: {neq: null}};
|
||||||
case 'system':
|
case 'system':
|
||||||
return {userFk: null};
|
return {userFk: null};
|
||||||
|
case 'all':
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
case 'actions':
|
case 'actions': {
|
||||||
const inq = [];
|
const inq = [];
|
||||||
for (const action in value) {
|
for (const action in value) {
|
||||||
if (value[action])
|
if (value[action])
|
||||||
inq.push(action);
|
inq.push(action);
|
||||||
}
|
}
|
||||||
return inq.length ? {action: {inq}} : null;
|
return inq.length ? {action: {inq}} : null;
|
||||||
|
}
|
||||||
case 'from':
|
case 'from':
|
||||||
if (filter.to) {
|
if (filter.to)
|
||||||
return {creationDate: {gte: value}};
|
return {creationDate: {gte: value}};
|
||||||
} else {
|
else {
|
||||||
const to = new Date(value);
|
const to = new Date(value);
|
||||||
to.setHours(23, 59, 59, 999);
|
to.setHours(23, 59, 59, 999);
|
||||||
return {creationDate: {between: [value, to]}};
|
return {creationDate: {between: [value, to]}};
|
||||||
}
|
}
|
||||||
case 'to':
|
case 'to': {
|
||||||
const to = new Date(value);
|
const to = new Date(value);
|
||||||
to.setHours(23, 59, 59, 999);
|
to.setHours(23, 59, 59, 999);
|
||||||
return {creationDate: {lte: to}};
|
return {creationDate: {lte: to}};
|
||||||
|
}
|
||||||
case 'userFk':
|
case 'userFk':
|
||||||
return filter.who != 'system'
|
return filter.who != 'system'
|
||||||
? {[prop]: value} : null;
|
? {[prop]: value} : null;
|
||||||
default:
|
default:
|
||||||
return {[prop]: value};
|
return {[prop]: value};
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
|
this.hasFilter = false;
|
||||||
const and = [];
|
const and = [];
|
||||||
|
|
||||||
|
if (!filter.search || !filter.changedModel)
|
||||||
|
this.byRecord = false;
|
||||||
|
if (!this.byRecord)
|
||||||
|
and.push({originFk: this.originId});
|
||||||
|
|
||||||
for (const prop in filter) {
|
for (const prop in filter) {
|
||||||
const param = getParam(prop, filter[prop]);
|
const param = getParam(prop, filter[prop]);
|
||||||
if (param) and.push(param);
|
if (param) {
|
||||||
|
and.push(param);
|
||||||
|
this.hasFilter = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const lbFilter = and.length ? {where: {and}} : null;
|
const lbFilter = and.length ? {where: {and}} : null;
|
||||||
return this.$.model.applyFilter(lbFilter);
|
return this.$.model.applyFilter(lbFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
filterByEntity(log) {
|
filterByRecord(modelLog) {
|
||||||
|
this.byRecord = true;
|
||||||
this.$.filter = {
|
this.$.filter = {
|
||||||
who: 'all',
|
who: 'all',
|
||||||
search: log.changedModelId,
|
search: modelLog.id,
|
||||||
changedModel: log.changedModel
|
changedModel: modelLog.model
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
searchUser(search) {
|
searchUser(search) {
|
||||||
if (/^[0-9]+$/.test(search)) {
|
if (/^[0-9]+$/.test(search))
|
||||||
return {id: search};
|
return {id: search};
|
||||||
} else {
|
else {
|
||||||
return {or: [
|
return {or: [
|
||||||
{name: search},
|
{name: search},
|
||||||
{nickname: {like: `%${search}%`}}
|
{nickname: {like: `%${search}%`}}
|
||||||
]}
|
]};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
showWorkerDescriptor(event, log) {
|
showWorkerDescriptor(event, userLog) {
|
||||||
if (log.user?.worker)
|
if (userLog.user?.worker)
|
||||||
this.$.workerDescriptor.show(event.target, log.userFk);
|
this.$.workerDescriptor.show(event.target, userLog.userFk);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,4 +24,5 @@ Changes: Cambios
|
||||||
today: hoy
|
today: hoy
|
||||||
yesterday: ayer
|
yesterday: ayer
|
||||||
Show all record changes: Mostrar todos los cambios realizados en el registro
|
Show all record changes: Mostrar todos los cambios realizados en el registro
|
||||||
|
View record at this point in time: Ver el registro en este punto
|
||||||
Quit filter: Quitar filtro
|
Quit filter: Quitar filtro
|
||||||
|
|
|
@ -1,167 +1,246 @@
|
||||||
@import "util";
|
@import "util";
|
||||||
|
|
||||||
vn-log {
|
vn-log {
|
||||||
.change {
|
.origin-log {
|
||||||
|
&:first-child > .origin-info {
|
||||||
|
margin-top: 0;
|
||||||
|
}
|
||||||
|
& > .origin-info {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
margin-top: 28px;
|
||||||
|
gap: 6px;
|
||||||
|
|
||||||
|
& > .origin-id {
|
||||||
|
overflow: hidden;
|
||||||
|
white-space: nowrap;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
color: $color-font-secondary;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
& > .line {
|
||||||
|
flex-grow: 1;
|
||||||
|
background-color: $color-font-secondary;
|
||||||
|
height: 2px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.user-log {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|
||||||
& > .left {
|
& > .timeline {
|
||||||
position: relative;
|
position: relative;
|
||||||
padding-right: 10px;
|
padding-right: 10px;
|
||||||
|
width: 38px;
|
||||||
|
min-width: 38px;
|
||||||
|
flex-grow: auto;
|
||||||
|
|
||||||
& > vn-avatar {
|
|
||||||
cursor: pointer;
|
|
||||||
|
|
||||||
&.system {
|
|
||||||
background-color: $color-main !important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
& > .arrow {
|
& > .arrow {
|
||||||
height: 8px;
|
height: 8px;
|
||||||
width: 8px;
|
width: 8px;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
transform: rotateY(0deg) rotate(45deg);
|
transform: rotateY(0deg) rotate(45deg);
|
||||||
top: 18px;
|
top: 15px;
|
||||||
right: -4px;
|
right: -4px;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
}
|
}
|
||||||
|
& > .user-avatar {
|
||||||
|
background-color: $color-bg;
|
||||||
|
padding: $spacing-sm 0;
|
||||||
|
margin-top: -$spacing-sm;
|
||||||
|
position: sticky;
|
||||||
|
top: 64px;
|
||||||
|
|
||||||
|
& > vn-avatar {
|
||||||
|
cursor: pointer;
|
||||||
|
display: block;
|
||||||
|
|
||||||
|
&.system {
|
||||||
|
background-color: $color-main !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
& > .line {
|
& > .line {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
background-color: $color-main;
|
background-color: $color-main;
|
||||||
width: 2px;
|
width: 2px;
|
||||||
left: 17px;
|
left: 18px;
|
||||||
z-index: -1;
|
z-index: -1;
|
||||||
top: 44px;
|
top: 0;
|
||||||
bottom: -8px;
|
bottom: -$spacing-sm;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
&:last-child > .left > .line {
|
&:last-child > .timeline > .line {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
.detail {
|
& > .user-changes {
|
||||||
position: relative;
|
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
width: 100%;
|
|
||||||
border-radius: 2px;
|
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.model-log {
|
||||||
|
& > .model-info {
|
||||||
|
overflow: hidden;
|
||||||
|
white-space: nowrap;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
min-height: 22px;
|
||||||
|
|
||||||
& > .header {
|
& > .model-name {
|
||||||
display: flex;
|
display: inline-block;
|
||||||
justify-content: space-between;
|
padding: 2px 5px;
|
||||||
align-items: center;
|
color: $color-font-dark;
|
||||||
overflow: hidden;
|
border-radius: 8px;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
& > .model-value {
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
& > .model-id {
|
||||||
|
color: $color-font-secondary;
|
||||||
|
font-size: .9rem;
|
||||||
|
}
|
||||||
|
& > vn-icon[icon="filter_alt"] {
|
||||||
|
@extend %clickable-light;
|
||||||
|
vertical-align: middle;
|
||||||
|
font-size: 18px;
|
||||||
|
color: $color-font-secondary;
|
||||||
|
float: right;
|
||||||
|
display: none;
|
||||||
|
|
||||||
& > .action-model {
|
@include mobile {
|
||||||
display: inline-flex;
|
display: initial;
|
||||||
overflow: hidden;
|
|
||||||
|
|
||||||
& > .model-name {
|
|
||||||
display: inline-block;
|
|
||||||
padding: 2px 5px;
|
|
||||||
color: $color-font-dark;
|
|
||||||
border-radius: 8px;
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
& > .action-date {
|
|
||||||
white-space: nowrap;
|
|
||||||
|
|
||||||
& > .action {
|
|
||||||
display: inline-flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
color: $color-font-bg;
|
|
||||||
vertical-align: middle;
|
|
||||||
border-radius: 50%;
|
|
||||||
width: 24px;
|
|
||||||
height: 24px;
|
|
||||||
font-size: 18px;
|
|
||||||
|
|
||||||
&.notice {
|
|
||||||
background-color: $color-notice-medium
|
|
||||||
}
|
|
||||||
&.success {
|
|
||||||
background-color: $color-success-medium;
|
|
||||||
}
|
|
||||||
&.warning {
|
|
||||||
background-color: $color-main-medium;
|
|
||||||
}
|
|
||||||
&.alert {
|
|
||||||
background-color: lighten($color-alert, 5%);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
& > .model {
|
}
|
||||||
overflow: hidden;
|
&:hover > .model-info > vn-icon[icon="filter_alt"] {
|
||||||
text-overflow: ellipsis;
|
display: initial;
|
||||||
white-space: nowrap;
|
}
|
||||||
max-height: 18px;
|
}
|
||||||
|
.changes-log {
|
||||||
|
position: relative;
|
||||||
|
max-width: 100%;
|
||||||
|
width: 100%;
|
||||||
|
border-radius: 2px;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
& > vn-icon {
|
&:last-child {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
& > .change-info {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
& > .date {
|
||||||
|
overflow: hidden;
|
||||||
|
white-space: nowrap;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
& > div {
|
||||||
|
white-space: nowrap;
|
||||||
|
|
||||||
|
& > vn-icon.pit {
|
||||||
@extend %clickable-light;
|
@extend %clickable-light;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
padding: 2px;
|
font-size: 20px;
|
||||||
margin: -2px;
|
|
||||||
font-size: 18px;
|
|
||||||
color: $color-font-secondary;
|
color: $color-font-secondary;
|
||||||
float: right;
|
|
||||||
display: none;
|
display: none;
|
||||||
|
|
||||||
@include mobile {
|
@include mobile {
|
||||||
display: initial;
|
display: inline-block;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
& > .model-value {
|
& > .action {
|
||||||
font-style: italic;
|
display: inline-flex;
|
||||||
}
|
align-items: center;
|
||||||
& > .model-id {
|
justify-content: center;
|
||||||
color: $color-font-secondary;
|
color: $color-font-bg;
|
||||||
font-size: .9rem;
|
vertical-align: middle;
|
||||||
}
|
border-radius: 50%;
|
||||||
}
|
width: 24px;
|
||||||
&:hover > .model > vn-icon {
|
height: 24px;
|
||||||
display: initial;
|
font-size: 18px;
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.changes {
|
|
||||||
overflow: hidden;
|
|
||||||
background-color: rgba(255, 255, 255, .05);
|
|
||||||
color: $color-font-light;
|
|
||||||
position: relative;
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
white-space: nowrap;
|
|
||||||
min-height: 34px;
|
|
||||||
box-sizing: border-box;
|
|
||||||
|
|
||||||
& > vn-icon {
|
&.notice {
|
||||||
@extend %clickable;
|
background-color: $color-notice-medium
|
||||||
float: right;
|
}
|
||||||
position: relative;
|
&.success {
|
||||||
transition-property: transform, background-color;
|
background-color: $color-success-medium;
|
||||||
transition-duration: 150ms;
|
}
|
||||||
margin: -5px;
|
&.warning {
|
||||||
margin-left: 4px;
|
background-color: $color-main-medium;
|
||||||
padding: 1px;
|
}
|
||||||
border-radius: 50%;
|
&.alert {
|
||||||
|
background-color: lighten($color-alert, 5%);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&:hover vn-icon.pit {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
&.expanded {
|
& > .change-detail {
|
||||||
text-overflow: initial;
|
overflow: hidden;
|
||||||
white-space: initial;
|
background-color: rgba(255, 255, 255, .05);
|
||||||
|
color: $color-font-light;
|
||||||
|
position: relative;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
min-height: 34px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
|
||||||
& > vn-icon {
|
& > vn-icon {
|
||||||
transform: rotate(180deg);
|
@extend %clickable;
|
||||||
|
float: right;
|
||||||
|
position: relative;
|
||||||
|
transition-property: transform, background-color;
|
||||||
|
transition-duration: 150ms;
|
||||||
|
margin: -5px;
|
||||||
|
margin-left: 4px;
|
||||||
|
padding: 1px;
|
||||||
|
border-radius: 50%;
|
||||||
|
}
|
||||||
|
&.expanded {
|
||||||
|
text-overflow: initial;
|
||||||
|
white-space: initial;
|
||||||
|
|
||||||
|
& > vn-icon {
|
||||||
|
transform: rotate(180deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
& > .no-changes {
|
||||||
|
font-style: italic;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
& > .no-changes {
|
}
|
||||||
font-style: italic;
|
.id-value {
|
||||||
|
font-size: .9rem;
|
||||||
|
color: $color-font-secondary;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.vn-log-instance {
|
||||||
|
display: block;
|
||||||
|
|
||||||
|
& > .loading {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
& > .instance {
|
||||||
|
min-width: 180px;
|
||||||
|
max-width: 400px;
|
||||||
|
|
||||||
|
& > .header {
|
||||||
|
background-color: $color-main;
|
||||||
|
color: $color-font-dark;
|
||||||
|
overflow: hidden;
|
||||||
|
white-space: nowrap;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
& > .change-detail {
|
||||||
|
color: $color-font-light;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
vn-log-value > .id-value {
|
|
||||||
font-size: .9rem;
|
|
||||||
color: $color-font-secondary;
|
|
||||||
}
|
|
||||||
|
|
|
@ -11,7 +11,8 @@ function config($stateProvider, $urlRouterProvider) {
|
||||||
abstract: true,
|
abstract: true,
|
||||||
template: '<vn-layout></vn-layout>',
|
template: '<vn-layout></vn-layout>',
|
||||||
resolve: {
|
resolve: {
|
||||||
config: ['vnConfig', vnConfig => vnConfig.initialize()]
|
config: ['vnConfig', vnConfig => vnConfig.initialize()],
|
||||||
|
token: ['vnToken', vnToken => vnToken.fetchConfig()]
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.state('outLayout', {
|
.state('outLayout', {
|
||||||
|
|
|
@ -0,0 +1,91 @@
|
||||||
|
const NotFoundError = require('vn-loopback/util/not-found-error');
|
||||||
|
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.remoteMethod('pitInstance', {
|
||||||
|
description: 'Gets the status of instance at specific point in time',
|
||||||
|
accepts: [
|
||||||
|
{
|
||||||
|
arg: 'id',
|
||||||
|
type: 'integer',
|
||||||
|
description: 'The log id',
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
returns: {
|
||||||
|
type: [Self],
|
||||||
|
root: true
|
||||||
|
},
|
||||||
|
http: {
|
||||||
|
path: `/:id/pitInstance`,
|
||||||
|
verb: 'GET'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Self.pitInstance = async function(id) {
|
||||||
|
const log = await Self.findById(id, {
|
||||||
|
fields: [
|
||||||
|
'changedModel',
|
||||||
|
'changedModelId',
|
||||||
|
'creationDate'
|
||||||
|
]
|
||||||
|
});
|
||||||
|
if (!log)
|
||||||
|
throw new NotFoundError();
|
||||||
|
|
||||||
|
const where = {
|
||||||
|
changedModel: log.changedModel,
|
||||||
|
changedModelId: log.changedModelId
|
||||||
|
};
|
||||||
|
|
||||||
|
// Fetch creation and all update logs for record up to requested log
|
||||||
|
|
||||||
|
const createdWhere = {
|
||||||
|
action: 'insert',
|
||||||
|
creationDate: {lte: log.creationDate}
|
||||||
|
};
|
||||||
|
const createdLog = await Self.findOne({
|
||||||
|
fields: ['id', 'creationDate', 'newInstance'],
|
||||||
|
where: Object.assign(createdWhere, where),
|
||||||
|
order: 'creationDate DESC, id DESC'
|
||||||
|
});
|
||||||
|
|
||||||
|
const instance = {};
|
||||||
|
|
||||||
|
let logsWhere = {
|
||||||
|
action: 'update'
|
||||||
|
};
|
||||||
|
if (createdLog) {
|
||||||
|
Object.assign(instance, createdLog.newInstance);
|
||||||
|
Object.assign(logsWhere, {
|
||||||
|
creationDate: {between: [
|
||||||
|
createdLog.creationDate,
|
||||||
|
log.creationDate
|
||||||
|
]},
|
||||||
|
id: {between: [
|
||||||
|
Math.min(id, createdLog.id),
|
||||||
|
Math.max(id, createdLog.id)
|
||||||
|
]}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
Object.assign(logsWhere, {
|
||||||
|
creationDate: {lte: log.creationDate},
|
||||||
|
id: {lte: id}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const logs = await Self.find({
|
||||||
|
fields: ['newInstance'],
|
||||||
|
where: Object.assign(logsWhere, where),
|
||||||
|
order: 'creationDate, id'
|
||||||
|
});
|
||||||
|
if (!logs.length && !createdLog)
|
||||||
|
throw new NotFoundError('No logs found for record');
|
||||||
|
|
||||||
|
// Merge all logs in order into one instance
|
||||||
|
|
||||||
|
for (const log of logs)
|
||||||
|
Object.assign(instance, log.newInstance);
|
||||||
|
|
||||||
|
return instance;
|
||||||
|
};
|
||||||
|
};
|
|
@ -5,6 +5,7 @@ module.exports = function(Self) {
|
||||||
Self.super_.setup.call(this);
|
Self.super_.setup.call(this);
|
||||||
require('../methods/log/editors')(this);
|
require('../methods/log/editors')(this);
|
||||||
require('../methods/log/models')(this);
|
require('../methods/log/models')(this);
|
||||||
|
require('../methods/log/pitInstance')(this);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -115,7 +115,7 @@
|
||||||
"This client is not invoiceable": "This client is not invoiceable",
|
"This client is not invoiceable": "This client is not invoiceable",
|
||||||
"INACTIVE_PROVIDER": "Inactive provider",
|
"INACTIVE_PROVIDER": "Inactive provider",
|
||||||
"reference duplicated": "reference duplicated",
|
"reference duplicated": "reference duplicated",
|
||||||
"The PDF document does not exists": "The PDF document does not exists. Try regenerating it from 'Regenerate invoice PDF' option",
|
"The PDF document does not exist": "The PDF document does not exists. Try regenerating it from 'Regenerate invoice PDF' option",
|
||||||
"This item is not available": "This item is not available",
|
"This item is not available": "This item is not available",
|
||||||
"Deny buy request": "Purchase request for ticket id [{{ticketId}}]({{{url}}}) has been rejected. Reason: {{observation}}",
|
"Deny buy request": "Purchase request for ticket id [{{ticketId}}]({{{url}}}) has been rejected. Reason: {{observation}}",
|
||||||
"The type of business must be filled in basic data": "The type of business must be filled in basic data",
|
"The type of business must be filled in basic data": "The type of business must be filled in basic data",
|
||||||
|
@ -174,5 +174,8 @@
|
||||||
"A claim with that sale already exists": "A claim with that sale already exists",
|
"A claim with that sale already exists": "A claim with that sale already exists",
|
||||||
"Pass expired": "The password has expired, change it from Salix",
|
"Pass expired": "The password has expired, change it from Salix",
|
||||||
"Can't transfer claimed sales": "Can't transfer claimed sales",
|
"Can't transfer claimed sales": "Can't transfer claimed sales",
|
||||||
"Invalid quantity": "Invalid quantity"
|
"Invalid quantity": "Invalid quantity",
|
||||||
}
|
"Failed to upload delivery note": "Error to upload delivery note {{id}}",
|
||||||
|
"Mail not sent": "There has been an error sending the invoice to the client [{{clientId}}]({{{clientUrl}}}), please check the email address",
|
||||||
|
"The renew period has not been exceeded": "The renew period has not been exceeded"
|
||||||
|
}
|
|
@ -177,7 +177,6 @@
|
||||||
"You can not select this payment method without a registered bankery account": "No se puede utilizar este método de pago si no has registrado una cuenta bancaria",
|
"You can not select this payment method without a registered bankery account": "No se puede utilizar este método de pago si no has registrado una cuenta bancaria",
|
||||||
"Action not allowed on the test environment": "Esta acción no está permitida en el entorno de pruebas",
|
"Action not allowed on the test environment": "Esta acción no está permitida en el entorno de pruebas",
|
||||||
"The selected ticket is not suitable for this route": "El ticket seleccionado no es apto para esta ruta",
|
"The selected ticket is not suitable for this route": "El ticket seleccionado no es apto para esta ruta",
|
||||||
"Sorts whole route": "Reordena ruta entera",
|
|
||||||
"New ticket request has been created with price": "Se ha creado una nueva petición de compra '{{description}}' para el día *{{shipped}}*, con una cantidad de *{{quantity}}* y un precio de *{{price}} €*",
|
"New ticket request has been created with price": "Se ha creado una nueva petición de compra '{{description}}' para el día *{{shipped}}*, con una cantidad de *{{quantity}}* y un precio de *{{price}} €*",
|
||||||
"New ticket request has been created": "Se ha creado una nueva petición de compra '{{description}}' para el día *{{shipped}}*, con una cantidad de *{{quantity}}*",
|
"New ticket request has been created": "Se ha creado una nueva petición de compra '{{description}}' para el día *{{shipped}}*, con una cantidad de *{{quantity}}*",
|
||||||
"Swift / BIC cannot be empty": "Swift / BIC no puede estar vacío",
|
"Swift / BIC cannot be empty": "Swift / BIC no puede estar vacío",
|
||||||
|
@ -211,7 +210,7 @@
|
||||||
"You don't have enough privileges to set this credit amount": "No tienes suficientes privilegios para establecer esta cantidad de crédito",
|
"You don't have enough privileges to set this credit amount": "No tienes suficientes privilegios para establecer esta cantidad de crédito",
|
||||||
"You can't change the credit set to zero from a financialBoss": "No puedes cambiar el cŕedito establecido a cero por un jefe de finanzas",
|
"You can't change the credit set to zero from a financialBoss": "No puedes cambiar el cŕedito establecido a cero por un jefe de finanzas",
|
||||||
"Amounts do not match": "Las cantidades no coinciden",
|
"Amounts do not match": "Las cantidades no coinciden",
|
||||||
"The PDF document does not exists": "El documento PDF no existe. Prueba a regenerarlo desde la opción 'Regenerar PDF factura'",
|
"The PDF document does not exist": "El documento PDF no existe. Prueba a regenerarlo desde la opción 'Regenerar PDF factura'",
|
||||||
"The type of business must be filled in basic data": "El tipo de negocio debe estar rellenado en datos básicos",
|
"The type of business must be filled in basic data": "El tipo de negocio debe estar rellenado en datos básicos",
|
||||||
"You can't create a claim from a ticket delivered more than seven days ago": "No puedes crear una reclamación de un ticket entregado hace más de siete días",
|
"You can't create a claim from a ticket delivered more than seven days ago": "No puedes crear una reclamación de un ticket entregado hace más de siete días",
|
||||||
"The worker has hours recorded that day": "El trabajador tiene horas fichadas ese día",
|
"The worker has hours recorded that day": "El trabajador tiene horas fichadas ese día",
|
||||||
|
@ -258,14 +257,14 @@
|
||||||
"App name does not exist": "El nombre de aplicación no es válido",
|
"App name does not exist": "El nombre de aplicación no es válido",
|
||||||
"Try again": "Vuelve a intentarlo",
|
"Try again": "Vuelve a intentarlo",
|
||||||
"Aplicación bloqueada por el usuario 9": "Aplicación bloqueada por el usuario 9",
|
"Aplicación bloqueada por el usuario 9": "Aplicación bloqueada por el usuario 9",
|
||||||
"Failed to upload file": "Error al subir archivo",
|
"Failed to upload delivery note": "Error al subir albarán {{id}}",
|
||||||
"The DOCUWARE PDF document does not exists": "El documento PDF Docuware no existe",
|
"The DOCUWARE PDF document does not exists": "El documento PDF Docuware no existe",
|
||||||
"It is not possible to modify tracked sales": "No es posible modificar líneas de pedido que se hayan empezado a preparar",
|
"It is not possible to modify tracked sales": "No es posible modificar líneas de pedido que se hayan empezado a preparar",
|
||||||
"It is not possible to modify sales that their articles are from Floramondo": "No es posible modificar líneas de pedido cuyos artículos sean de Floramondo",
|
"It is not possible to modify sales that their articles are from Floramondo": "No es posible modificar líneas de pedido cuyos artículos sean de Floramondo",
|
||||||
"It is not possible to modify cloned sales": "No es posible modificar líneas de pedido clonadas",
|
"It is not possible to modify cloned sales": "No es posible modificar líneas de pedido clonadas",
|
||||||
"A supplier with the same name already exists. Change the country.": "Un proveedor con el mismo nombre ya existe. Cambie el país.",
|
"A supplier with the same name already exists. Change the country.": "Un proveedor con el mismo nombre ya existe. Cambie el país.",
|
||||||
"There is no assigned email for this client": "No hay correo asignado para este cliente",
|
"There is no assigned email for this client": "No hay correo asignado para este cliente",
|
||||||
"Exists an invoice with a previous date": "Existe una factura con fecha anterior",
|
"Exists an invoice with a future date": "Existe una factura con fecha posterior",
|
||||||
"Invoice date can't be less than max date": "La fecha de factura no puede ser inferior a la fecha límite",
|
"Invoice date can't be less than max date": "La fecha de factura no puede ser inferior a la fecha límite",
|
||||||
"Warehouse inventory not set": "El almacén inventario no está establecido",
|
"Warehouse inventory not set": "El almacén inventario no está establecido",
|
||||||
"This locker has already been assigned": "Esta taquilla ya ha sido asignada",
|
"This locker has already been assigned": "Esta taquilla ya ha sido asignada",
|
||||||
|
@ -293,5 +292,10 @@
|
||||||
"Pass expired": "La contraseña ha caducado, cambiela desde Salix",
|
"Pass expired": "La contraseña ha caducado, cambiela desde Salix",
|
||||||
"Invalid NIF for VIES": "Invalid NIF for VIES",
|
"Invalid NIF for VIES": "Invalid NIF for VIES",
|
||||||
"Ticket does not exist": "Este ticket no existe",
|
"Ticket does not exist": "Este ticket no existe",
|
||||||
"Ticket is already signed": "Este ticket ya ha sido firmado"
|
"Ticket is already signed": "Este ticket ya ha sido firmado",
|
||||||
|
"Fecha fuera de rango": "Fecha fuera de rango",
|
||||||
|
"Error while generating PDF": "Error al generar PDF",
|
||||||
|
"Error when sending mail to client": "Error al enviar el correo al cliente",
|
||||||
|
"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"
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,9 @@
|
||||||
<vn-icon-button
|
<vn-icon-button
|
||||||
icon="delete"
|
icon="delete"
|
||||||
translate-attr="{title: 'Unsubscribe'}"
|
translate-attr="{title: 'Unsubscribe'}"
|
||||||
ng-click="removeConfirm.show(row)">
|
ng-click="removeConfirm.show(row)"
|
||||||
|
vn-acl="itManagement"
|
||||||
|
vn-acl-action="remove">
|
||||||
</vn-icon-button>
|
</vn-icon-button>
|
||||||
</vn-item-section>
|
</vn-item-section>
|
||||||
</vn-item>
|
</vn-item>
|
||||||
|
@ -30,9 +32,11 @@
|
||||||
translate-attr="{title: 'Add'}"
|
translate-attr="{title: 'Add'}"
|
||||||
vn-bind="+"
|
vn-bind="+"
|
||||||
ng-click="$ctrl.onAddClick()"
|
ng-click="$ctrl.onAddClick()"
|
||||||
fixed-bottom-right>
|
fixed-bottom-right
|
||||||
|
vn-acl="itManagement"
|
||||||
|
vn-acl-action="remove">
|
||||||
</vn-float-button>
|
</vn-float-button>
|
||||||
<vn-dialog
|
<vn-dialog
|
||||||
vn-id="dialog"
|
vn-id="dialog"
|
||||||
on-accept="$ctrl.onAddSave()">
|
on-accept="$ctrl.onAddSave()">
|
||||||
<tpl-body>
|
<tpl-body>
|
||||||
|
@ -49,7 +53,7 @@
|
||||||
<button response="accept" translate>Save</button>
|
<button response="accept" translate>Save</button>
|
||||||
</tpl-buttons>
|
</tpl-buttons>
|
||||||
</vn-dialog>
|
</vn-dialog>
|
||||||
<vn-confirm
|
<vn-confirm
|
||||||
vn-id="removeConfirm"
|
vn-id="removeConfirm"
|
||||||
message="User will be removed from alias"
|
message="User will be removed from alias"
|
||||||
question="Are you sure you want to continue?"
|
question="Are you sure you want to continue?"
|
||||||
|
|
|
@ -5,6 +5,7 @@ import './style.scss';
|
||||||
class Controller extends ModuleCard {
|
class Controller extends ModuleCard {
|
||||||
reload() {
|
reload() {
|
||||||
const filter = {
|
const filter = {
|
||||||
|
where: {id: this.$params.id},
|
||||||
include: {
|
include: {
|
||||||
relation: 'role',
|
relation: 'role',
|
||||||
scope: {
|
scope: {
|
||||||
|
@ -14,8 +15,11 @@ class Controller extends ModuleCard {
|
||||||
};
|
};
|
||||||
|
|
||||||
return Promise.all([
|
return Promise.all([
|
||||||
this.$http.get(`VnUsers/${this.$params.id}`, {filter})
|
this.$http.get(`VnUsers/preview`, {filter})
|
||||||
.then(res => this.user = res.data),
|
.then(res => {
|
||||||
|
const [user] = res.data;
|
||||||
|
this.user = user;
|
||||||
|
}),
|
||||||
this.$http.get(`Accounts/${this.$params.id}/exists`)
|
this.$http.get(`Accounts/${this.$params.id}/exists`)
|
||||||
.then(res => this.hasAccount = res.data.exists)
|
.then(res => this.hasAccount = res.data.exists)
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -15,12 +15,12 @@ describe('component vnUserCard', () => {
|
||||||
it('should reload the controller data', () => {
|
it('should reload the controller data', () => {
|
||||||
controller.$params.id = 1;
|
controller.$params.id = 1;
|
||||||
|
|
||||||
$httpBackend.expectGET('VnUsers/1').respond('foo');
|
$httpBackend.expectGET('VnUsers/preview').respond('foo');
|
||||||
$httpBackend.expectGET('Accounts/1/exists').respond({exists: true});
|
$httpBackend.expectGET('Accounts/1/exists').respond({exists: true});
|
||||||
controller.reload();
|
controller.reload();
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
|
||||||
expect(controller.user).toBe('foo');
|
expect(controller.user).toBe('f');
|
||||||
expect(controller.hasAccount).toBeTruthy();
|
expect(controller.hasAccount).toBeTruthy();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -12,18 +12,18 @@
|
||||||
<vn-card class="vn-pa-lg">
|
<vn-card class="vn-pa-lg">
|
||||||
<vn-vertical>
|
<vn-vertical>
|
||||||
<vn-textfield
|
<vn-textfield
|
||||||
label="Name"
|
label="Name"
|
||||||
ng-model="$ctrl.user.name"
|
ng-model="$ctrl.user.name"
|
||||||
rule="VnUser"
|
rule="VnUser"
|
||||||
vn-focus>
|
vn-focus>
|
||||||
</vn-textfield>
|
</vn-textfield>
|
||||||
<vn-textfield
|
<vn-textfield
|
||||||
label="Nickname"
|
label="Nickname"
|
||||||
ng-model="$ctrl.user.nickname"
|
ng-model="$ctrl.user.nickname"
|
||||||
rule="VnUser">
|
rule="VnUser">
|
||||||
</vn-textfield>
|
</vn-textfield>
|
||||||
<vn-textfield
|
<vn-textfield
|
||||||
label="Email"
|
label="Email"
|
||||||
ng-model="$ctrl.user.email"
|
ng-model="$ctrl.user.email"
|
||||||
rule="VnUser">
|
rule="VnUser">
|
||||||
</vn-textfield>
|
</vn-textfield>
|
||||||
|
@ -39,7 +39,7 @@
|
||||||
type="password">
|
type="password">
|
||||||
</vn-textfield>
|
</vn-textfield>
|
||||||
<vn-check
|
<vn-check
|
||||||
label="Active"
|
label="Active"
|
||||||
ng-model="$ctrl.user.active">
|
ng-model="$ctrl.user.active">
|
||||||
</vn-check>
|
</vn-check>
|
||||||
</vn-vertical>
|
</vn-vertical>
|
||||||
|
|
|
@ -2,6 +2,11 @@ import ngModule from '../module';
|
||||||
import Section from 'salix/components/section';
|
import Section from 'salix/components/section';
|
||||||
|
|
||||||
export default class Controller extends Section {
|
export default class Controller extends Section {
|
||||||
|
constructor($element, $) {
|
||||||
|
super($element, $);
|
||||||
|
this.user = {active: true};
|
||||||
|
}
|
||||||
|
|
||||||
onSubmit() {
|
onSubmit() {
|
||||||
return this.$.watcher.submit().then(res => {
|
return this.$.watcher.submit().then(res => {
|
||||||
this.$state.go('account.card.basicData', {id: res.data.id});
|
this.$state.go('account.card.basicData', {id: res.data.id});
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<vn-item
|
<vn-item
|
||||||
ng-click="deleteUser.show()"
|
ng-click="deleteUser.show()"
|
||||||
name="deleteUser"
|
name="deleteUser"
|
||||||
vn-acl="it"
|
vn-acl="itManagement"
|
||||||
vn-acl-action="remove"
|
vn-acl-action="remove"
|
||||||
translate>
|
translate>
|
||||||
Delete
|
Delete
|
||||||
|
@ -15,7 +15,7 @@
|
||||||
ng-if="::$root.user.id == $ctrl.id"
|
ng-if="::$root.user.id == $ctrl.id"
|
||||||
ng-click="$ctrl.onChangePassClick(true)"
|
ng-click="$ctrl.onChangePassClick(true)"
|
||||||
name="changePassword"
|
name="changePassword"
|
||||||
vn-acl="hr"
|
vn-acl="sysadmin"
|
||||||
vn-acl-action="remove"
|
vn-acl-action="remove"
|
||||||
translate>
|
translate>
|
||||||
Change password
|
Change password
|
||||||
|
@ -23,7 +23,7 @@
|
||||||
<vn-item
|
<vn-item
|
||||||
ng-click="$ctrl.onChangePassClick(false)"
|
ng-click="$ctrl.onChangePassClick(false)"
|
||||||
name="setPassword"
|
name="setPassword"
|
||||||
vn-acl="hr"
|
vn-acl="sysadmin"
|
||||||
vn-acl-action="remove"
|
vn-acl-action="remove"
|
||||||
translate>
|
translate>
|
||||||
Set password
|
Set password
|
||||||
|
@ -32,7 +32,7 @@
|
||||||
ng-if="!$ctrl.hasAccount"
|
ng-if="!$ctrl.hasAccount"
|
||||||
ng-click="enableAccount.show()"
|
ng-click="enableAccount.show()"
|
||||||
name="enableAccount"
|
name="enableAccount"
|
||||||
vn-acl="it"
|
vn-acl="sysadmin"
|
||||||
vn-acl-action="remove"
|
vn-acl-action="remove"
|
||||||
translate>
|
translate>
|
||||||
Enable account
|
Enable account
|
||||||
|
@ -41,7 +41,7 @@
|
||||||
ng-if="$ctrl.hasAccount"
|
ng-if="$ctrl.hasAccount"
|
||||||
ng-click="disableAccount.show()"
|
ng-click="disableAccount.show()"
|
||||||
name="disableAccount"
|
name="disableAccount"
|
||||||
vn-acl="it"
|
vn-acl="sysadmin"
|
||||||
vn-acl-action="remove"
|
vn-acl-action="remove"
|
||||||
translate>
|
translate>
|
||||||
Disable account
|
Disable account
|
||||||
|
@ -50,7 +50,7 @@
|
||||||
ng-if="!$ctrl.user.active"
|
ng-if="!$ctrl.user.active"
|
||||||
ng-click="activateUser.show()"
|
ng-click="activateUser.show()"
|
||||||
name="activateUser"
|
name="activateUser"
|
||||||
vn-acl="hr"
|
vn-acl="itManagement"
|
||||||
vn-acl-action="remove"
|
vn-acl-action="remove"
|
||||||
translate>
|
translate>
|
||||||
Activate user
|
Activate user
|
||||||
|
@ -59,7 +59,7 @@
|
||||||
ng-if="$ctrl.user.active"
|
ng-if="$ctrl.user.active"
|
||||||
ng-click="deactivateUser.show()"
|
ng-click="deactivateUser.show()"
|
||||||
name="deactivateUser"
|
name="deactivateUser"
|
||||||
vn-acl="hr"
|
vn-acl="itManagement"
|
||||||
vn-acl-action="remove"
|
vn-acl-action="remove"
|
||||||
translate>
|
translate>
|
||||||
Deactivate user
|
Deactivate user
|
||||||
|
|
|
@ -14,11 +14,11 @@
|
||||||
<vn-item-section>
|
<vn-item-section>
|
||||||
<h6>{{::user.nickname}}</h6>
|
<h6>{{::user.nickname}}</h6>
|
||||||
<vn-label-value
|
<vn-label-value
|
||||||
label="Id"
|
label="Id"
|
||||||
value="{{::user.id}}">
|
value="{{::user.id}}">
|
||||||
</vn-label-value>
|
</vn-label-value>
|
||||||
<vn-label-value
|
<vn-label-value
|
||||||
label="User"
|
label="User"
|
||||||
value="{{::user.name}}">
|
value="{{::user.name}}">
|
||||||
</vn-label-value>
|
</vn-label-value>
|
||||||
</vn-item-section>
|
</vn-item-section>
|
||||||
|
@ -36,12 +36,12 @@
|
||||||
<vn-popup vn-id="summary">
|
<vn-popup vn-id="summary">
|
||||||
<vn-user-summary user="$ctrl.selectedUser"></vn-user-summary>
|
<vn-user-summary user="$ctrl.selectedUser"></vn-user-summary>
|
||||||
</vn-popup>
|
</vn-popup>
|
||||||
<a
|
<a
|
||||||
fixed-bottom-right
|
fixed-bottom-right
|
||||||
ui-sref="account.create"
|
ui-sref="account.create"
|
||||||
vn-tooltip="New user"
|
vn-tooltip="New user"
|
||||||
vn-bind="+"
|
vn-bind="+"
|
||||||
vn-acl="it"
|
vn-acl="itManagement"
|
||||||
vn-acl-action="remove">
|
vn-acl-action="remove">
|
||||||
<vn-float-button icon="add"></vn-float-button>
|
<vn-float-button icon="add"></vn-float-button>
|
||||||
</a>
|
</a>
|
||||||
|
|
|
@ -14,12 +14,12 @@
|
||||||
<vn-card class="vn-pa-lg">
|
<vn-card class="vn-pa-lg">
|
||||||
<vn-vertical>
|
<vn-vertical>
|
||||||
<vn-check
|
<vn-check
|
||||||
label="Enable mail forwarding"
|
label="Enable mail forwarding"
|
||||||
ng-model="watcher.hasData">
|
ng-model="watcher.hasData">
|
||||||
</vn-check>
|
</vn-check>
|
||||||
<vn-textfield
|
<vn-textfield
|
||||||
ng-if="watcher.hasData"
|
ng-if="watcher.hasData"
|
||||||
label="Forward email"
|
label="Forward email"
|
||||||
ng-model="data.forwardTo"
|
ng-model="data.forwardTo"
|
||||||
info="All emails will be forwarded to the specified address."
|
info="All emails will be forwarded to the specified address."
|
||||||
rule="MailForward"
|
rule="MailForward"
|
||||||
|
|
|
@ -4,3 +4,4 @@ Enable mail forwarding: Habilitar redirección de correo
|
||||||
All emails will be forwarded to the specified address.: >
|
All emails will be forwarded to the specified address.: >
|
||||||
Todos los correos serán reenviados a la dirección especificada, no se
|
Todos los correos serán reenviados a la dirección especificada, no se
|
||||||
mantendrá copia de los mismos en el buzón del usuario.
|
mantendrá copia de los mismos en el buzón del usuario.
|
||||||
|
You don't have enough privileges: No tienes suficientes permisos
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<vn-crud-model
|
<vn-crud-model
|
||||||
vn-id="model"
|
vn-id="model"
|
||||||
url="VnUsers"
|
url="VnUsers/preview"
|
||||||
filter="::$ctrl.filter"
|
filter="::$ctrl.filter"
|
||||||
limit="20">
|
limit="20">
|
||||||
</vn-crud-model>
|
</vn-crud-model>
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
<mg-ajax path="VnUsers/{{post.params.id}}/privileges" options="vnPost"></mg-ajax>
|
<mg-ajax path="VnUsers/{{post.params.id}}/privileges" options="vnPost"></mg-ajax>
|
||||||
<vn-watcher
|
<vn-watcher
|
||||||
vn-id="watcher"
|
vn-id="watcher"
|
||||||
url="VnUsers"
|
|
||||||
data="$ctrl.user"
|
data="$ctrl.user"
|
||||||
id-value="$ctrl.$params.id"
|
|
||||||
form="form"
|
form="form"
|
||||||
save="post">
|
save="post">
|
||||||
</vn-watcher>
|
</vn-watcher>
|
||||||
|
@ -11,15 +9,16 @@
|
||||||
name="form"
|
name="form"
|
||||||
ng-submit="watcher.submit()"
|
ng-submit="watcher.submit()"
|
||||||
class="vn-w-md">
|
class="vn-w-md">
|
||||||
<vn-card class="vn-pa-lg" vn-focus>
|
<vn-card class="vn-pa-lg">
|
||||||
<vn-vertical>
|
<vn-vertical>
|
||||||
<vn-check
|
<vn-check
|
||||||
label="Has grant"
|
label="Has grant"
|
||||||
ng-model="$ctrl.user.hasGrant">
|
ng-model="$ctrl.user.hasGrant">
|
||||||
</vn-check>
|
</vn-check>
|
||||||
</vn-vertical>
|
</vn-vertical>
|
||||||
<vn-vertical
|
</vn-card>
|
||||||
class="vn-mt-md">
|
<vn-card class="vn-pa-lg vn-mt-md">
|
||||||
|
<vn-vertical>
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
label="Role"
|
label="Role"
|
||||||
ng-model="$ctrl.user.roleFk"
|
ng-model="$ctrl.user.roleFk"
|
||||||
|
|
|
@ -1,9 +1,21 @@
|
||||||
import ngModule from '../module';
|
import ngModule from '../module';
|
||||||
import Section from 'salix/components/section';
|
import Section from 'salix/components/section';
|
||||||
|
|
||||||
export default class Controller extends Section {}
|
export default class Controller extends Section {
|
||||||
|
get user() {
|
||||||
|
return this._user;
|
||||||
|
}
|
||||||
|
|
||||||
|
set user(value) {
|
||||||
|
this._user = value;
|
||||||
|
if (!value) return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ngModule.component('vnUserPrivileges', {
|
ngModule.component('vnUserPrivileges', {
|
||||||
template: require('./index.html'),
|
template: require('./index.html'),
|
||||||
controller: Controller
|
controller: Controller,
|
||||||
|
bindings: {
|
||||||
|
user: '<'
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -49,15 +49,13 @@
|
||||||
"url": "/index?q",
|
"url": "/index?q",
|
||||||
"state": "account.index",
|
"state": "account.index",
|
||||||
"component": "vn-user-index",
|
"component": "vn-user-index",
|
||||||
"description": "Users",
|
"description": "Users"
|
||||||
"acl": ["marketing", "hr"]
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"url": "/create",
|
"url": "/create",
|
||||||
"state": "account.create",
|
"state": "account.create",
|
||||||
"component": "vn-user-create",
|
"component": "vn-user-create",
|
||||||
"description": "New user",
|
"description": "New user"
|
||||||
"acl": ["it"]
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"url": "/:id",
|
"url": "/:id",
|
||||||
|
@ -80,7 +78,7 @@
|
||||||
"state": "account.card.basicData",
|
"state": "account.card.basicData",
|
||||||
"component": "vn-user-basic-data",
|
"component": "vn-user-basic-data",
|
||||||
"description": "Basic data",
|
"description": "Basic data",
|
||||||
"acl": ["hr"]
|
"acl": ["itManagement"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"url" : "/log",
|
"url" : "/log",
|
||||||
|
@ -98,8 +96,7 @@
|
||||||
"url": "/roles",
|
"url": "/roles",
|
||||||
"state": "account.card.roles",
|
"state": "account.card.roles",
|
||||||
"component": "vn-user-roles",
|
"component": "vn-user-roles",
|
||||||
"description": "Inherited roles",
|
"description": "Inherited roles"
|
||||||
"acl": ["it"]
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"url": "/mail-forwarding",
|
"url": "/mail-forwarding",
|
||||||
|
@ -111,15 +108,16 @@
|
||||||
"url": "/aliases",
|
"url": "/aliases",
|
||||||
"state": "account.card.aliases",
|
"state": "account.card.aliases",
|
||||||
"component": "vn-user-aliases",
|
"component": "vn-user-aliases",
|
||||||
"description": "Mail aliases",
|
"description": "Mail aliases"
|
||||||
"acl": ["marketing", "hr"]
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"url": "/privileges",
|
"url": "/privileges",
|
||||||
"state": "account.card.privileges",
|
"state": "account.card.privileges",
|
||||||
"component": "vn-user-privileges",
|
"component": "vn-user-privileges",
|
||||||
"description": "Privileges",
|
"description": "Privileges",
|
||||||
"acl": ["hr"]
|
"params": {
|
||||||
|
"user": "$ctrl.user"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"url": "/role?q",
|
"url": "/role?q",
|
||||||
|
@ -180,8 +178,7 @@
|
||||||
"url": "/alias?q",
|
"url": "/alias?q",
|
||||||
"state": "account.alias",
|
"state": "account.alias",
|
||||||
"component": "vn-alias",
|
"component": "vn-alias",
|
||||||
"description": "Mail aliases",
|
"description": "Mail aliases"
|
||||||
"acl": ["marketing"]
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"url": "/create",
|
"url": "/create",
|
||||||
|
|
|
@ -8,6 +8,7 @@ class Controller extends Summary {
|
||||||
if (!value) return;
|
if (!value) return;
|
||||||
|
|
||||||
const filter = {
|
const filter = {
|
||||||
|
where: {id: value.id},
|
||||||
include: {
|
include: {
|
||||||
relation: 'role',
|
relation: 'role',
|
||||||
scope: {
|
scope: {
|
||||||
|
@ -15,8 +16,11 @@ class Controller extends Summary {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
this.$http.get(`VnUsers/${value.id}`, {filter})
|
this.$http.get(`VnUsers/preview`, {filter})
|
||||||
.then(res => this.$.summary = res.data);
|
.then(res => {
|
||||||
|
const [summary] = res.data;
|
||||||
|
this.$.summary = summary;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
get isHr() {
|
get isHr() {
|
||||||
return this.aclService.hasAny(['hr']);
|
return this.aclService.hasAny(['hr']);
|
||||||
|
|
|
@ -77,14 +77,6 @@ module.exports = Self => {
|
||||||
if (salesPersonId)
|
if (salesPersonId)
|
||||||
await models.Chat.sendCheckingPresence(ctx, salesPersonId, message);
|
await models.Chat.sendCheckingPresence(ctx, salesPersonId, message);
|
||||||
|
|
||||||
await models.ClaimLog.create({
|
|
||||||
originFk: args.id,
|
|
||||||
userFk: userId,
|
|
||||||
action: 'insert',
|
|
||||||
description: 'Claim-pickup-order sent',
|
|
||||||
changedModel: 'Mail'
|
|
||||||
});
|
|
||||||
|
|
||||||
const email = new Email('claim-pickup-order', params);
|
const email = new Email('claim-pickup-order', params);
|
||||||
|
|
||||||
return email.send();
|
return email.send();
|
||||||
|
|
|
@ -52,4 +52,5 @@ columns:
|
||||||
hasInvoiceSimplified: simplified invoice
|
hasInvoiceSimplified: simplified invoice
|
||||||
typeFk: type
|
typeFk: type
|
||||||
lastSalesPersonFk: last salesperson
|
lastSalesPersonFk: last salesperson
|
||||||
|
rating: rating
|
||||||
|
recommendedCredit: recommended credit
|
||||||
|
|
|
@ -52,4 +52,5 @@ columns:
|
||||||
hasInvoiceSimplified: factura simple
|
hasInvoiceSimplified: factura simple
|
||||||
typeFk: tipo
|
typeFk: tipo
|
||||||
lastSalesPersonFk: último comercial
|
lastSalesPersonFk: último comercial
|
||||||
|
rating: clasificación
|
||||||
|
recommendedCredit: crédito recomendado
|
||||||
|
|
|
@ -19,9 +19,6 @@ module.exports = Self => {
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.confirmTransaction = async(ctx, id, options) => {
|
Self.confirmTransaction = async(ctx, id, options) => {
|
||||||
const models = Self.app.models;
|
|
||||||
const userId = ctx.req.accessToken.userId;
|
|
||||||
|
|
||||||
let tx;
|
let tx;
|
||||||
const myOptions = {userId: ctx.req.accessToken.userId};
|
const myOptions = {userId: ctx.req.accessToken.userId};
|
||||||
|
|
||||||
|
@ -34,29 +31,8 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const oldTpvTransaction = await models.TpvTransaction.findById(id, null, myOptions);
|
|
||||||
|
|
||||||
const confirm = await Self.rawSql('CALL hedera.tpvTransaction_confirmById(?)', [id], myOptions);
|
const confirm = await Self.rawSql('CALL hedera.tpvTransaction_confirmById(?)', [id], myOptions);
|
||||||
|
|
||||||
const tpvTransaction = await models.TpvTransaction.findById(id, null, myOptions);
|
|
||||||
|
|
||||||
const oldInstance = {status: oldTpvTransaction.status};
|
|
||||||
const newInstance = {status: tpvTransaction.status};
|
|
||||||
|
|
||||||
const logRecord = {
|
|
||||||
originFk: tpvTransaction.clientFk,
|
|
||||||
userFk: userId,
|
|
||||||
action: 'update',
|
|
||||||
changedModel: 'TpvTransaction',
|
|
||||||
changedModelId: id,
|
|
||||||
oldInstance: oldInstance,
|
|
||||||
newInstance: newInstance
|
|
||||||
};
|
|
||||||
|
|
||||||
await models.ClientLog.create(logRecord, myOptions);
|
|
||||||
|
|
||||||
if (tx) await tx.commit();
|
if (tx) await tx.commit();
|
||||||
|
|
||||||
return confirm;
|
return confirm;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (tx) await tx.rollback();
|
if (tx) await tx.rollback();
|
||||||
|
|
|
@ -30,34 +30,9 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.sendSms = async(ctx, id, destination, message, options) => {
|
Self.sendSms = async(ctx, id, destination, message) => {
|
||||||
const models = Self.app.models;
|
const models = Self.app.models;
|
||||||
const myOptions = {};
|
|
||||||
|
|
||||||
if (typeof options == 'object')
|
|
||||||
Object.assign(myOptions, options);
|
|
||||||
|
|
||||||
const userId = ctx.req.accessToken.userId;
|
|
||||||
|
|
||||||
const sms = await models.Sms.send(ctx, destination, message);
|
const sms = await models.Sms.send(ctx, destination, message);
|
||||||
const logRecord = {
|
|
||||||
originFk: id,
|
|
||||||
userFk: userId,
|
|
||||||
action: 'insert',
|
|
||||||
changedModel: 'sms',
|
|
||||||
newInstance: {
|
|
||||||
destinationFk: id,
|
|
||||||
destination: destination,
|
|
||||||
message: message,
|
|
||||||
statusCode: sms.statusCode,
|
|
||||||
status: sms.status
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const clientLog = await models.ClientLog.create(logRecord, myOptions);
|
|
||||||
|
|
||||||
sms.logId = clientLog.id;
|
|
||||||
|
|
||||||
return sms;
|
return sms;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -13,10 +13,7 @@ describe('client sendSms()', () => {
|
||||||
|
|
||||||
const sms = await models.Client.sendSms(ctx, id, destination, message, options);
|
const sms = await models.Client.sendSms(ctx, id, destination, message, options);
|
||||||
|
|
||||||
const createdLog = await models.ClientLog.findById(sms.logId, null, options);
|
expect(sms).toBeDefined();
|
||||||
const json = JSON.parse(JSON.stringify(createdLog.newInstance));
|
|
||||||
|
|
||||||
expect(json.message).toEqual(message);
|
|
||||||
|
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
@ -144,20 +144,7 @@ module.exports = Self => {
|
||||||
|
|
||||||
if (taxDataChecked && !hasSageData)
|
if (taxDataChecked && !hasSageData)
|
||||||
throw new UserError(`You need to fill sage information before you check verified data`);
|
throw new UserError(`You need to fill sage information before you check verified data`);
|
||||||
if (args.despiteOfClient) {
|
|
||||||
const logRecord = {
|
|
||||||
originFk: clientId,
|
|
||||||
userFk: userId,
|
|
||||||
action: 'update',
|
|
||||||
changedModel: 'Client',
|
|
||||||
changedModelId: clientId,
|
|
||||||
description: $t(`Client checked as validated despite of duplication`, {
|
|
||||||
clientId: args.despiteOfClient
|
|
||||||
})
|
|
||||||
};
|
|
||||||
|
|
||||||
await models.ClientLog.create(logRecord, myOptions);
|
|
||||||
}
|
|
||||||
// Remove unwanted properties
|
// Remove unwanted properties
|
||||||
delete args.ctx;
|
delete args.ctx;
|
||||||
delete args.id;
|
delete args.id;
|
||||||
|
|
|
@ -479,21 +479,6 @@ module.exports = Self => {
|
||||||
hasChanges = oldData.name != changes.name || oldData.active != changes.active;
|
hasChanges = oldData.name != changes.name || oldData.active != changes.active;
|
||||||
|
|
||||||
if (!hasChanges) return;
|
if (!hasChanges) return;
|
||||||
|
|
||||||
const isClient = await Self.app.models.Client.count({id: oldData.id});
|
|
||||||
if (isClient) {
|
|
||||||
const loopBackContext = LoopBackContext.getCurrentContext();
|
|
||||||
const userId = loopBackContext.active.accessToken.userId;
|
|
||||||
const logRecord = {
|
|
||||||
originFk: oldData.id,
|
|
||||||
userFk: userId,
|
|
||||||
action: 'update',
|
|
||||||
changedModel: 'VnUser',
|
|
||||||
oldInstance: {name: oldData.name, active: oldData.active},
|
|
||||||
newInstance: {name: changes.name, active: changes.active}
|
|
||||||
};
|
|
||||||
await Self.app.models.ClientLog.create(logRecord);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
<vn-watcher
|
<vn-watcher
|
||||||
vn-id="watcher"
|
vn-id="watcher"
|
||||||
url="VnUsers"
|
|
||||||
id-field="id"
|
|
||||||
data="$ctrl.account"
|
data="$ctrl.account"
|
||||||
form="form">
|
form="form">
|
||||||
</vn-watcher>
|
</vn-watcher>
|
||||||
|
@ -51,9 +49,9 @@
|
||||||
label="Save">
|
label="Save">
|
||||||
</vn-submit>
|
</vn-submit>
|
||||||
<vn-button
|
<vn-button
|
||||||
ng-if="$ctrl.canChangePassword"
|
ng-if="$ctrl.canChangePassword"
|
||||||
label="Change password"
|
label="Change password"
|
||||||
vn-dialog="change-pass">
|
vn-dialog="change-pass">
|
||||||
</vn-button>
|
</vn-button>
|
||||||
<vn-button
|
<vn-button
|
||||||
class="cancel"
|
class="cancel"
|
||||||
|
|
|
@ -8,6 +8,22 @@ export default class Controller extends Section {
|
||||||
this.canEnableCheckBox = true;
|
this.canEnableCheckBox = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
set client(value) {
|
||||||
|
this._client = value;
|
||||||
|
if (!value) return;
|
||||||
|
|
||||||
|
const filter = {where: {id: value.id}};
|
||||||
|
this.$http.get(`VnUsers/preview`, {filter})
|
||||||
|
.then(res => {
|
||||||
|
const [user] = res.data;
|
||||||
|
this.account = user;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
get client() {
|
||||||
|
return this._client;
|
||||||
|
}
|
||||||
|
|
||||||
$onChanges() {
|
$onChanges() {
|
||||||
if (this.client) {
|
if (this.client) {
|
||||||
this.account = this.client.account;
|
this.account = this.client.account;
|
||||||
|
|
|
@ -5,12 +5,14 @@ describe('Component VnClientWebAccess', () => {
|
||||||
let $scope;
|
let $scope;
|
||||||
let vnApp;
|
let vnApp;
|
||||||
let controller;
|
let controller;
|
||||||
|
let $httpParamSerializer;
|
||||||
|
|
||||||
beforeEach(ngModule('client'));
|
beforeEach(ngModule('client'));
|
||||||
|
|
||||||
beforeEach(inject(($componentController, $rootScope, _$httpBackend_, _vnApp_) => {
|
beforeEach(inject(($componentController, $rootScope, _$httpBackend_, _$httpParamSerializer_, _vnApp_) => {
|
||||||
$scope = $rootScope.$new();
|
$scope = $rootScope.$new();
|
||||||
$httpBackend = _$httpBackend_;
|
$httpBackend = _$httpBackend_;
|
||||||
|
$httpParamSerializer = _$httpParamSerializer_;
|
||||||
vnApp = _vnApp_;
|
vnApp = _vnApp_;
|
||||||
jest.spyOn(vnApp, 'showError');
|
jest.spyOn(vnApp, 'showError');
|
||||||
const $element = angular.element('<vn-client-web-access></vn-client-web-access>');
|
const $element = angular.element('<vn-client-web-access></vn-client-web-access>');
|
||||||
|
@ -32,7 +34,10 @@ describe('Component VnClientWebAccess', () => {
|
||||||
describe('isCustomer()', () => {
|
describe('isCustomer()', () => {
|
||||||
it('should return true if the password can be modified', () => {
|
it('should return true if the password can be modified', () => {
|
||||||
controller.client = {id: '1234'};
|
controller.client = {id: '1234'};
|
||||||
|
const filter = {where: {id: controller.client.id}};
|
||||||
|
const serializedParams = $httpParamSerializer({filter});
|
||||||
|
|
||||||
|
$httpBackend.expectGET(`VnUsers/preview?${serializedParams}`).respond('foo');
|
||||||
$httpBackend.expectGET(`Clients/${controller.client.id}/hasCustomerRole`).respond(true);
|
$httpBackend.expectGET(`Clients/${controller.client.id}/hasCustomerRole`).respond(true);
|
||||||
controller.isCustomer();
|
controller.isCustomer();
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
@ -42,7 +47,10 @@ describe('Component VnClientWebAccess', () => {
|
||||||
|
|
||||||
it(`should return a false if the password can't be modified`, () => {
|
it(`should return a false if the password can't be modified`, () => {
|
||||||
controller.client = {id: '1234'};
|
controller.client = {id: '1234'};
|
||||||
|
const filter = {where: {id: controller.client.id}};
|
||||||
|
const serializedParams = $httpParamSerializer({filter});
|
||||||
|
|
||||||
|
$httpBackend.expectGET(`VnUsers/preview?${serializedParams}`).respond('foo');
|
||||||
$httpBackend.expectGET(`Clients/${controller.client.id}/hasCustomerRole`).respond(false);
|
$httpBackend.expectGET(`Clients/${controller.client.id}/hasCustomerRole`).respond(false);
|
||||||
controller.isCustomer();
|
controller.isCustomer();
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
@ -54,9 +62,12 @@ describe('Component VnClientWebAccess', () => {
|
||||||
describe('checkConditions()', () => {
|
describe('checkConditions()', () => {
|
||||||
it('should perform a query to check if the client is valid', () => {
|
it('should perform a query to check if the client is valid', () => {
|
||||||
controller.client = {id: '1234'};
|
controller.client = {id: '1234'};
|
||||||
|
const filter = {where: {id: controller.client.id}};
|
||||||
|
const serializedParams = $httpParamSerializer({filter});
|
||||||
|
|
||||||
expect(controller.canEnableCheckBox).toBeTruthy();
|
expect(controller.canEnableCheckBox).toBeTruthy();
|
||||||
|
|
||||||
|
$httpBackend.expectGET(`VnUsers/preview?${serializedParams}`).respond('foo');
|
||||||
$httpBackend.expectGET(`Clients/${controller.client.id}/isValidClient`).respond(false);
|
$httpBackend.expectGET(`Clients/${controller.client.id}/isValidClient`).respond(false);
|
||||||
controller.checkConditions();
|
controller.checkConditions();
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
@ -82,7 +93,10 @@ describe('Component VnClientWebAccess', () => {
|
||||||
controller.newPassword = 'm24x8';
|
controller.newPassword = 'm24x8';
|
||||||
controller.repeatPassword = 'm24x8';
|
controller.repeatPassword = 'm24x8';
|
||||||
controller.canChangePassword = true;
|
controller.canChangePassword = true;
|
||||||
|
const filter = {where: {id: controller.client.id}};
|
||||||
|
const serializedParams = $httpParamSerializer({filter});
|
||||||
|
|
||||||
|
$httpBackend.expectGET(`VnUsers/preview?${serializedParams}`).respond('foo');
|
||||||
const query = `Clients/${controller.client.id}/setPassword`;
|
const query = `Clients/${controller.client.id}/setPassword`;
|
||||||
$httpBackend.expectPATCH(query, {newPassword: controller.newPassword}).respond('done');
|
$httpBackend.expectPATCH(query, {newPassword: controller.newPassword}).respond('done');
|
||||||
controller.onPassChange();
|
controller.onPassChange();
|
||||||
|
|
|
@ -1,165 +0,0 @@
|
||||||
|
|
||||||
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
|
|
||||||
|
|
||||||
module.exports = Self => {
|
|
||||||
Self.remoteMethodCtx('addBuy', {
|
|
||||||
description: 'Inserts a new buy for the current entry',
|
|
||||||
accessType: 'WRITE',
|
|
||||||
accepts: [{
|
|
||||||
arg: 'id',
|
|
||||||
type: 'number',
|
|
||||||
required: true,
|
|
||||||
description: 'The entry id',
|
|
||||||
http: {source: 'path'}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
arg: 'itemFk',
|
|
||||||
type: 'number',
|
|
||||||
required: true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
arg: 'quantity',
|
|
||||||
type: 'number',
|
|
||||||
required: true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
arg: 'packageFk',
|
|
||||||
type: 'string',
|
|
||||||
required: true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
arg: 'packing',
|
|
||||||
type: 'number',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
arg: 'grouping',
|
|
||||||
type: 'number'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
arg: 'weight',
|
|
||||||
type: 'number',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
arg: 'stickers',
|
|
||||||
type: 'number',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
arg: 'price2',
|
|
||||||
type: 'number',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
arg: 'price3',
|
|
||||||
type: 'number',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
arg: 'buyingValue',
|
|
||||||
type: 'number'
|
|
||||||
}],
|
|
||||||
returns: {
|
|
||||||
type: 'object',
|
|
||||||
root: true
|
|
||||||
},
|
|
||||||
http: {
|
|
||||||
path: `/:id/addBuy`,
|
|
||||||
verb: 'POST'
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Self.addBuy = async(ctx, options) => {
|
|
||||||
const conn = Self.dataSource.connector;
|
|
||||||
let tx;
|
|
||||||
const myOptions = {};
|
|
||||||
|
|
||||||
if (typeof options == 'object')
|
|
||||||
Object.assign(myOptions, options);
|
|
||||||
|
|
||||||
if (!myOptions.transaction) {
|
|
||||||
tx = await Self.beginTransaction({});
|
|
||||||
myOptions.transaction = tx;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
const models = Self.app.models;
|
|
||||||
|
|
||||||
ctx.args.entryFk = ctx.args.id;
|
|
||||||
|
|
||||||
// remove unwanted properties
|
|
||||||
delete ctx.args.id;
|
|
||||||
delete ctx.args.ctx;
|
|
||||||
|
|
||||||
const newBuy = await models.Buy.create(ctx.args, myOptions);
|
|
||||||
|
|
||||||
const filter = {
|
|
||||||
fields: [
|
|
||||||
'id',
|
|
||||||
'itemFk',
|
|
||||||
'stickers',
|
|
||||||
'packing',
|
|
||||||
'grouping',
|
|
||||||
'quantity',
|
|
||||||
'packageFk',
|
|
||||||
'weight',
|
|
||||||
'buyingValue',
|
|
||||||
'price2',
|
|
||||||
'price3'
|
|
||||||
],
|
|
||||||
include: {
|
|
||||||
relation: 'item',
|
|
||||||
scope: {
|
|
||||||
fields: [
|
|
||||||
'id',
|
|
||||||
'typeFk',
|
|
||||||
'name',
|
|
||||||
'size',
|
|
||||||
'minPrice',
|
|
||||||
'tag5',
|
|
||||||
'value5',
|
|
||||||
'tag6',
|
|
||||||
'value6',
|
|
||||||
'tag7',
|
|
||||||
'value7',
|
|
||||||
'tag8',
|
|
||||||
'value8',
|
|
||||||
'tag9',
|
|
||||||
'value9',
|
|
||||||
'tag10',
|
|
||||||
'value10',
|
|
||||||
'groupingMode'
|
|
||||||
],
|
|
||||||
include: {
|
|
||||||
relation: 'itemType',
|
|
||||||
scope: {
|
|
||||||
fields: ['code', 'description']
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const stmts = [];
|
|
||||||
let stmt;
|
|
||||||
|
|
||||||
stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.buyRecalc');
|
|
||||||
stmt = new ParameterizedSQL(
|
|
||||||
`CREATE TEMPORARY TABLE tmp.buyRecalc
|
|
||||||
(INDEX (id))
|
|
||||||
ENGINE = MEMORY
|
|
||||||
SELECT ? AS id`, [newBuy.id]);
|
|
||||||
|
|
||||||
stmts.push(stmt);
|
|
||||||
stmts.push('CALL buy_recalcPrices()');
|
|
||||||
|
|
||||||
const sql = ParameterizedSQL.join(stmts, ';');
|
|
||||||
await conn.executeStmt(sql, myOptions);
|
|
||||||
|
|
||||||
const buy = await models.Buy.findById(newBuy.id, filter, myOptions);
|
|
||||||
|
|
||||||
if (tx) await tx.commit();
|
|
||||||
|
|
||||||
return buy;
|
|
||||||
} catch (e) {
|
|
||||||
if (tx) await tx.rollback();
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
|
|
@ -46,7 +46,7 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let buy = await models.Buy.findOne({where: {entryFk: args.id}}, myOptions);
|
let buy = await models.Buy.findOne({where: {entryFk: args.id, itemFk: args.item}}, myOptions);
|
||||||
if (buy)
|
if (buy)
|
||||||
await buy.updateAttribute('printedStickers', args.printedStickers, myOptions);
|
await buy.updateAttribute('printedStickers', args.printedStickers, myOptions);
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -75,7 +75,7 @@ module.exports = Self => {
|
||||||
value[field] = newValue;
|
value[field] = newValue;
|
||||||
|
|
||||||
if (filter) {
|
if (filter) {
|
||||||
ctx.args.filter = {where: filter, limit: null};
|
ctx.args = {where: filter, limit: null};
|
||||||
lines = await models.Buy.latestBuysFilter(ctx, null, myOptions);
|
lines = await models.Buy.latestBuysFilter(ctx, null, myOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,42 +0,0 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
|
||||||
const LoopBackContext = require('loopback-context');
|
|
||||||
|
|
||||||
describe('entry addBuy()', () => {
|
|
||||||
const activeCtx = {
|
|
||||||
accessToken: {userId: 18},
|
|
||||||
};
|
|
||||||
|
|
||||||
const ctx = {
|
|
||||||
req: activeCtx
|
|
||||||
};
|
|
||||||
|
|
||||||
const entryId = 2;
|
|
||||||
it('should create a new buy for the given entry', async() => {
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
|
||||||
active: activeCtx
|
|
||||||
});
|
|
||||||
const itemId = 4;
|
|
||||||
const quantity = 10;
|
|
||||||
|
|
||||||
ctx.args = {
|
|
||||||
id: entryId,
|
|
||||||
itemFk: itemId,
|
|
||||||
quantity: quantity,
|
|
||||||
packageFk: 3
|
|
||||||
};
|
|
||||||
|
|
||||||
const tx = await models.Entry.beginTransaction({});
|
|
||||||
const options = {transaction: tx};
|
|
||||||
|
|
||||||
try {
|
|
||||||
const newBuy = await models.Entry.addBuy(ctx, options);
|
|
||||||
|
|
||||||
expect(newBuy.itemFk).toEqual(itemId);
|
|
||||||
|
|
||||||
await tx.rollback();
|
|
||||||
} catch (e) {
|
|
||||||
await tx.rollback();
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -53,7 +53,36 @@ describe('Buy editLatestsBuys()', () => {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const filter = {'i.typeFk': 1};
|
const filter = {'categoryFk': 1, 'tags': []};
|
||||||
|
const ctx = {
|
||||||
|
args: {
|
||||||
|
filter: filter
|
||||||
|
},
|
||||||
|
req: {accessToken: {userId: 1}}
|
||||||
|
};
|
||||||
|
|
||||||
|
const field = 'size';
|
||||||
|
const newValue = 88;
|
||||||
|
|
||||||
|
await models.Buy.editLatestBuys(ctx, field, newValue, null, filter, options);
|
||||||
|
|
||||||
|
const [result] = await models.Buy.latestBuysFilter(ctx, null, options);
|
||||||
|
|
||||||
|
expect(result[field]).toEqual(newValue);
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should change the value of a given column for filter tags', async() => {
|
||||||
|
const tx = await models.Buy.beginTransaction({});
|
||||||
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
try {
|
||||||
|
const filter = {'tags': [{tagFk: 1, value: 'Brown'}]};
|
||||||
const ctx = {
|
const ctx = {
|
||||||
args: {
|
args: {
|
||||||
filter: filter
|
filter: filter
|
||||||
|
|
|
@ -3,7 +3,6 @@ module.exports = Self => {
|
||||||
require('../methods/entry/filter')(Self);
|
require('../methods/entry/filter')(Self);
|
||||||
require('../methods/entry/getEntry')(Self);
|
require('../methods/entry/getEntry')(Self);
|
||||||
require('../methods/entry/getBuys')(Self);
|
require('../methods/entry/getBuys')(Self);
|
||||||
require('../methods/entry/addBuy')(Self);
|
|
||||||
require('../methods/entry/importBuys')(Self);
|
require('../methods/entry/importBuys')(Self);
|
||||||
require('../methods/entry/importBuysPreview')(Self);
|
require('../methods/entry/importBuysPreview')(Self);
|
||||||
require('../methods/entry/lastItemBuys')(Self);
|
require('../methods/entry/lastItemBuys')(Self);
|
||||||
|
|
|
@ -222,13 +222,6 @@
|
||||||
</vn-data-viewer>
|
</vn-data-viewer>
|
||||||
<div fixed-bottom-right>
|
<div fixed-bottom-right>
|
||||||
<vn-vertical style="align-items: center;">
|
<vn-vertical style="align-items: center;">
|
||||||
<vn-button class="round md vn-mb-sm"
|
|
||||||
ng-click="model.insert({})"
|
|
||||||
icon="add"
|
|
||||||
vn-tooltip="Add buy"
|
|
||||||
tooltip-position="left"
|
|
||||||
vn-bind="+">
|
|
||||||
</vn-button>
|
|
||||||
<a ui-sref="entry.card.buy.import" >
|
<a ui-sref="entry.card.buy.import" >
|
||||||
<vn-button class="round md vn-mb-sm"
|
<vn-button class="round md vn-mb-sm"
|
||||||
icon="publish"
|
icon="publish"
|
||||||
|
|
|
@ -13,11 +13,6 @@ export default class Controller extends Section {
|
||||||
query: `Buys/${buy.id}`,
|
query: `Buys/${buy.id}`,
|
||||||
method: 'patch'
|
method: 'patch'
|
||||||
};
|
};
|
||||||
} else {
|
|
||||||
options = {
|
|
||||||
query: `Entries/${this.entry.id}/addBuy`,
|
|
||||||
method: 'post'
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
this.$http[options.method](options.query, buy).then(res => {
|
this.$http[options.method](options.query, buy).then(res => {
|
||||||
if (!res.data) return;
|
if (!res.data) return;
|
||||||
|
|
|
@ -25,17 +25,6 @@ describe('Entry buy', () => {
|
||||||
controller.saveBuy(buy);
|
controller.saveBuy(buy);
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
});
|
});
|
||||||
|
|
||||||
it(`should call the entry addBuy post route if the received buy has no ID`, () => {
|
|
||||||
controller.entry = {id: 1};
|
|
||||||
const buy = {itemFk: 1, quantity: 1, packageFk: 1};
|
|
||||||
|
|
||||||
const query = `Entries/${controller.entry.id}/addBuy`;
|
|
||||||
|
|
||||||
$httpBackend.expectPOST(query).respond(200);
|
|
||||||
controller.saveBuy(buy);
|
|
||||||
$httpBackend.flush();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('deleteBuys()', () => {
|
describe('deleteBuys()', () => {
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
const UserError = require('vn-loopback/util/user-error');
|
const UserError = require('vn-loopback/util/user-error');
|
||||||
const print = require('vn-print');
|
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('createPdf', {
|
Self.remoteMethodCtx('createPdf', {
|
||||||
|
@ -25,56 +24,28 @@ module.exports = Self => {
|
||||||
|
|
||||||
Self.createPdf = async function(ctx, id, options) {
|
Self.createPdf = async function(ctx, id, options) {
|
||||||
const models = Self.app.models;
|
const models = Self.app.models;
|
||||||
|
options = typeof options == 'object'
|
||||||
if (process.env.NODE_ENV == 'test')
|
? Object.assign({}, options) : {};
|
||||||
throw new UserError(`Action not allowed on the test environment`);
|
|
||||||
|
|
||||||
let tx;
|
let tx;
|
||||||
const myOptions = {};
|
if (!options.transaction)
|
||||||
|
tx = options.transaction = await Self.beginTransaction({});
|
||||||
if (typeof options == 'object')
|
|
||||||
Object.assign(myOptions, options);
|
|
||||||
|
|
||||||
if (!myOptions.transaction) {
|
|
||||||
tx = await Self.beginTransaction({});
|
|
||||||
myOptions.transaction = tx;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const invoiceOut = await Self.findById(id, null, myOptions);
|
const invoiceOut = await Self.findById(id, {fields: ['hasPdf']}, options);
|
||||||
const canCreatePdf = await models.ACL.checkAccessAcl(ctx, 'InvoiceOut', 'canCreatePdf', 'WRITE');
|
|
||||||
|
|
||||||
if (invoiceOut.hasPdf && !canCreatePdf)
|
if (invoiceOut.hasPdf) {
|
||||||
throw new UserError(`You don't have enough privileges`);
|
const canCreatePdf = await models.ACL.checkAccessAcl(ctx, 'InvoiceOut', 'canCreatePdf', 'WRITE');
|
||||||
|
if (!canCreatePdf)
|
||||||
|
throw new UserError(`You don't have enough privileges`);
|
||||||
|
}
|
||||||
|
|
||||||
await invoiceOut.updateAttributes({
|
await Self.makePdf(id, options);
|
||||||
hasPdf: true
|
|
||||||
}, myOptions);
|
|
||||||
|
|
||||||
const invoiceReport = new print.Report('invoice', {
|
|
||||||
reference: invoiceOut.ref,
|
|
||||||
recipientId: invoiceOut.clientFk
|
|
||||||
});
|
|
||||||
const buffer = await invoiceReport.toPdfStream();
|
|
||||||
|
|
||||||
const issued = invoiceOut.issued;
|
|
||||||
const year = issued.getFullYear().toString();
|
|
||||||
const month = (issued.getMonth() + 1).toString();
|
|
||||||
const day = issued.getDate().toString();
|
|
||||||
|
|
||||||
const fileName = `${year}${invoiceOut.ref}.pdf`;
|
|
||||||
|
|
||||||
// Store invoice
|
|
||||||
await print.storage.write(buffer, {
|
|
||||||
type: 'invoice',
|
|
||||||
path: `${year}/${month}/${day}`,
|
|
||||||
fileName: fileName
|
|
||||||
});
|
|
||||||
|
|
||||||
if (tx) await tx.commit();
|
if (tx) await tx.commit();
|
||||||
} catch (e) {
|
} catch (err) {
|
||||||
if (tx) await tx.rollback();
|
if (tx) await tx.rollback();
|
||||||
throw e;
|
throw err;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const UserError = require('vn-loopback/util/user-error');
|
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('download', {
|
Self.remoteMethodCtx('download', {
|
||||||
|
@ -37,45 +36,43 @@ module.exports = Self => {
|
||||||
|
|
||||||
Self.download = async function(ctx, id, options) {
|
Self.download = async function(ctx, id, options) {
|
||||||
const models = Self.app.models;
|
const models = Self.app.models;
|
||||||
const myOptions = {};
|
options = typeof options == 'object'
|
||||||
|
? Object.assign({}, options) : {};
|
||||||
|
|
||||||
if (typeof options == 'object')
|
const pdfFile = await Self.filePath(id, options);
|
||||||
Object.assign(myOptions, options);
|
|
||||||
|
const container = await models.InvoiceContainer.container(pdfFile.year);
|
||||||
|
const rootPath = container.client.root;
|
||||||
|
|
||||||
|
const file = {
|
||||||
|
path: path.join(rootPath, pdfFile.path, pdfFile.name),
|
||||||
|
contentType: 'application/pdf',
|
||||||
|
name: pdfFile.name
|
||||||
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const invoiceOut = await models.InvoiceOut.findById(id, null, myOptions);
|
await fs.access(file.path);
|
||||||
|
} catch (error) {
|
||||||
|
await Self.createPdf(ctx, id, options);
|
||||||
|
}
|
||||||
|
|
||||||
const issued = invoiceOut.issued;
|
let stream = await fs.createReadStream(file.path);
|
||||||
const year = issued.getFullYear().toString();
|
// XXX: To prevent unhandled ENOENT error
|
||||||
const month = (issued.getMonth() + 1).toString();
|
// https://stackoverflow.com/questions/17136536/is-enoent-from-fs-createreadstream-uncatchable
|
||||||
const day = issued.getDate().toString();
|
stream.on('error', err => {
|
||||||
|
const e = new Error(err.message);
|
||||||
const container = await models.InvoiceContainer.container(year);
|
err.stack = e.stack;
|
||||||
const rootPath = container.client.root;
|
console.error(err);
|
||||||
const src = path.join(rootPath, year, month, day);
|
});
|
||||||
const fileName = `${year}${invoiceOut.ref}.pdf`;
|
|
||||||
const fileSrc = path.join(src, fileName);
|
|
||||||
|
|
||||||
const file = {
|
|
||||||
path: fileSrc,
|
|
||||||
contentType: 'application/pdf',
|
|
||||||
name: fileName
|
|
||||||
};
|
|
||||||
|
|
||||||
|
if (process.env.NODE_ENV == 'test') {
|
||||||
try {
|
try {
|
||||||
await fs.access(file.path);
|
await fs.access(file.path);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
await Self.createPdf(ctx, id, myOptions);
|
stream = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const stream = fs.createReadStream(file.path);
|
|
||||||
|
|
||||||
return [stream, file.contentType, `filename="${file.name}"`];
|
|
||||||
} catch (error) {
|
|
||||||
if (error.code === 'ENOENT')
|
|
||||||
throw new UserError('The PDF document does not exists');
|
|
||||||
|
|
||||||
throw error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return [stream, file.contentType, `filename="${pdfFile.name}"`];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -30,15 +30,10 @@ module.exports = Self => {
|
||||||
type: 'number',
|
type: 'number',
|
||||||
description: 'The company id to invoice',
|
description: 'The company id to invoice',
|
||||||
required: true
|
required: true
|
||||||
}, {
|
|
||||||
arg: 'printerFk',
|
|
||||||
type: 'number',
|
|
||||||
description: 'The printer to print',
|
|
||||||
required: true
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
returns: {
|
returns: {
|
||||||
type: 'object',
|
type: 'number',
|
||||||
root: true
|
root: true
|
||||||
},
|
},
|
||||||
http: {
|
http: {
|
||||||
|
@ -50,26 +45,22 @@ module.exports = Self => {
|
||||||
Self.invoiceClient = async(ctx, options) => {
|
Self.invoiceClient = async(ctx, options) => {
|
||||||
const args = ctx.args;
|
const args = ctx.args;
|
||||||
const models = Self.app.models;
|
const models = Self.app.models;
|
||||||
const myOptions = {userId: ctx.req.accessToken.userId};
|
options = typeof options == 'object'
|
||||||
|
? Object.assign({}, options) : {};
|
||||||
|
options.userId = ctx.req.accessToken.userId;
|
||||||
|
|
||||||
let tx;
|
let tx;
|
||||||
|
if (!options.transaction)
|
||||||
if (typeof options == 'object')
|
tx = options.transaction = await Self.beginTransaction({});
|
||||||
Object.assign(myOptions, options);
|
|
||||||
|
|
||||||
if (!myOptions.transaction) {
|
|
||||||
tx = await Self.beginTransaction({});
|
|
||||||
myOptions.transaction = tx;
|
|
||||||
}
|
|
||||||
|
|
||||||
const minShipped = Date.vnNew();
|
const minShipped = Date.vnNew();
|
||||||
minShipped.setFullYear(args.maxShipped.getFullYear() - 1);
|
minShipped.setFullYear(args.maxShipped.getFullYear() - 1);
|
||||||
|
|
||||||
let invoiceId;
|
let invoiceId;
|
||||||
let invoiceOut;
|
|
||||||
try {
|
try {
|
||||||
const client = await models.Client.findById(args.clientId, {
|
const client = await models.Client.findById(args.clientId, {
|
||||||
fields: ['id', 'hasToInvoiceByAddress']
|
fields: ['id', 'hasToInvoiceByAddress']
|
||||||
}, myOptions);
|
}, options);
|
||||||
|
|
||||||
if (client.hasToInvoiceByAddress) {
|
if (client.hasToInvoiceByAddress) {
|
||||||
await Self.rawSql('CALL ticketToInvoiceByAddress(?, ?, ?, ?)', [
|
await Self.rawSql('CALL ticketToInvoiceByAddress(?, ?, ?, ?)', [
|
||||||
|
@ -77,49 +68,58 @@ module.exports = Self => {
|
||||||
args.maxShipped,
|
args.maxShipped,
|
||||||
args.addressId,
|
args.addressId,
|
||||||
args.companyFk
|
args.companyFk
|
||||||
], myOptions);
|
], options);
|
||||||
} else {
|
} else {
|
||||||
await Self.rawSql('CALL invoiceFromClient(?, ?, ?)', [
|
await Self.rawSql('CALL invoiceFromClient(?, ?, ?)', [
|
||||||
args.maxShipped,
|
args.maxShipped,
|
||||||
client.id,
|
client.id,
|
||||||
args.companyFk
|
args.companyFk
|
||||||
], myOptions);
|
], options);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make invoice
|
// Check negative bases
|
||||||
const isSpanishCompany = await getIsSpanishCompany(args.companyFk, myOptions);
|
|
||||||
|
|
||||||
// Validates ticket nagative base
|
let query =
|
||||||
const hasAnyNegativeBase = await getNegativeBase(myOptions);
|
`SELECT COUNT(*) isSpanishCompany
|
||||||
|
FROM supplier s
|
||||||
|
JOIN country c ON c.id = s.countryFk
|
||||||
|
AND c.code = 'ES'
|
||||||
|
WHERE s.id = ?`;
|
||||||
|
const [supplierCompany] = await Self.rawSql(query, [
|
||||||
|
args.companyFk
|
||||||
|
], options);
|
||||||
|
|
||||||
|
const isSpanishCompany = supplierCompany?.isSpanishCompany;
|
||||||
|
|
||||||
|
query = 'SELECT hasAnyNegativeBase() AS base';
|
||||||
|
const [result] = await Self.rawSql(query, null, options);
|
||||||
|
|
||||||
|
const hasAnyNegativeBase = result?.base;
|
||||||
if (hasAnyNegativeBase && isSpanishCompany)
|
if (hasAnyNegativeBase && isSpanishCompany)
|
||||||
throw new UserError('Negative basis');
|
throw new UserError('Negative basis');
|
||||||
|
|
||||||
|
// Invoicing
|
||||||
|
|
||||||
query = `SELECT invoiceSerial(?, ?, ?) AS serial`;
|
query = `SELECT invoiceSerial(?, ?, ?) AS serial`;
|
||||||
const [invoiceSerial] = await Self.rawSql(query, [
|
const [invoiceSerial] = await Self.rawSql(query, [
|
||||||
client.id,
|
client.id,
|
||||||
args.companyFk,
|
args.companyFk,
|
||||||
'G'
|
'G'
|
||||||
], myOptions);
|
], options);
|
||||||
const serialLetter = invoiceSerial.serial;
|
const serialLetter = invoiceSerial.serial;
|
||||||
|
|
||||||
query = `CALL invoiceOut_new(?, ?, NULL, @invoiceId)`;
|
query = `CALL invoiceOut_new(?, ?, NULL, @invoiceId)`;
|
||||||
await Self.rawSql(query, [
|
await Self.rawSql(query, [
|
||||||
serialLetter,
|
serialLetter,
|
||||||
args.invoiceDate
|
args.invoiceDate
|
||||||
], myOptions);
|
], options);
|
||||||
|
|
||||||
const [newInvoice] = await Self.rawSql(`SELECT @invoiceId id`, null, myOptions);
|
const [newInvoice] = await Self.rawSql(`SELECT @invoiceId id`, null, options);
|
||||||
if (newInvoice.id) {
|
if (!newInvoice)
|
||||||
await Self.rawSql('CALL invoiceOutBooking(?)', [newInvoice.id], myOptions);
|
throw new UserError('No tickets to invoice', 'notInvoiced');
|
||||||
|
|
||||||
invoiceOut = await models.InvoiceOut.findById(newInvoice.id, {
|
await Self.rawSql('CALL invoiceOutBooking(?)', [newInvoice.id], options);
|
||||||
include: {
|
invoiceId = newInvoice.id;
|
||||||
relation: 'client'
|
|
||||||
}
|
|
||||||
}, myOptions);
|
|
||||||
|
|
||||||
invoiceId = newInvoice.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tx) await tx.commit();
|
if (tx) await tx.commit();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -127,47 +127,6 @@ module.exports = Self => {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (invoiceId) {
|
|
||||||
if (!invoiceOut.client().isToBeMailed) {
|
|
||||||
const query = `
|
|
||||||
CALL vn.report_print(
|
|
||||||
'invoice',
|
|
||||||
?,
|
|
||||||
account.myUser_getId(),
|
|
||||||
JSON_OBJECT('refFk', ?),
|
|
||||||
'normal'
|
|
||||||
);`;
|
|
||||||
await models.InvoiceOut.rawSql(query, [args.printerFk, invoiceOut.ref]);
|
|
||||||
} else {
|
|
||||||
ctx.args = {
|
|
||||||
reference: invoiceOut.ref,
|
|
||||||
recipientId: invoiceOut.clientFk,
|
|
||||||
recipient: invoiceOut.client().email
|
|
||||||
};
|
|
||||||
await models.InvoiceOut.invoiceEmail(ctx, invoiceOut.ref);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return invoiceId;
|
return invoiceId;
|
||||||
};
|
};
|
||||||
|
|
||||||
async function getNegativeBase(options) {
|
|
||||||
const models = Self.app.models;
|
|
||||||
const query = 'SELECT hasAnyNegativeBase() AS base';
|
|
||||||
const [result] = await models.InvoiceOut.rawSql(query, null, options);
|
|
||||||
return result && result.base;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function getIsSpanishCompany(companyId, options) {
|
|
||||||
const models = Self.app.models;
|
|
||||||
const query = `SELECT COUNT(*) isSpanishCompany
|
|
||||||
FROM supplier s
|
|
||||||
JOIN country c ON c.id = s.countryFk
|
|
||||||
AND c.code = 'ES'
|
|
||||||
WHERE s.id = ?`;
|
|
||||||
const [supplierCompany] = await models.InvoiceOut.rawSql(query, [
|
|
||||||
companyId
|
|
||||||
], options);
|
|
||||||
|
|
||||||
return supplierCompany && supplierCompany.isSpanishCompany;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
const UserError = require('vn-loopback/util/user-error');
|
||||||
const {Email} = require('vn-print');
|
const {Email} = require('vn-print');
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
|
@ -10,20 +11,17 @@ module.exports = Self => {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
required: true,
|
required: true,
|
||||||
http: {source: 'path'}
|
http: {source: 'path'}
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
arg: 'recipient',
|
arg: 'recipient',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
description: 'The recipient email',
|
description: 'The recipient email',
|
||||||
required: true,
|
required: true,
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
arg: 'replyTo',
|
arg: 'replyTo',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
description: 'The sender email to reply to',
|
description: 'The sender email to reply to',
|
||||||
required: false
|
required: false
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
arg: 'recipientId',
|
arg: 'recipientId',
|
||||||
type: 'number',
|
type: 'number',
|
||||||
description: 'The recipient id to send to the recipient preferred language',
|
description: 'The recipient id to send to the recipient preferred language',
|
||||||
|
@ -42,16 +40,13 @@ module.exports = Self => {
|
||||||
|
|
||||||
Self.invoiceEmail = async(ctx, reference) => {
|
Self.invoiceEmail = async(ctx, reference) => {
|
||||||
const args = Object.assign({}, ctx.args);
|
const args = Object.assign({}, ctx.args);
|
||||||
const {InvoiceOut} = Self.app.models;
|
|
||||||
const params = {
|
const params = {
|
||||||
recipient: args.recipient,
|
recipient: args.recipient,
|
||||||
lang: ctx.req.getLocale()
|
lang: ctx.req.getLocale()
|
||||||
};
|
};
|
||||||
|
|
||||||
const invoiceOut = await InvoiceOut.findOne({
|
const invoiceOut = await Self.findOne({
|
||||||
where: {
|
where: {ref: reference}
|
||||||
ref: reference
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
delete args.ctx;
|
delete args.ctx;
|
||||||
|
@ -74,6 +69,10 @@ module.exports = Self => {
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
return email.send(mailOptions);
|
try {
|
||||||
|
return email.send(mailOptions);
|
||||||
|
} catch (err) {
|
||||||
|
throw new UserError('Error when sending mail to client', 'mailNotSent');
|
||||||
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,87 @@
|
||||||
|
const UserError = require('vn-loopback/util/user-error');
|
||||||
|
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.remoteMethodCtx('makePdfAndNotify', {
|
||||||
|
description: 'Create invoice PDF and send it to client',
|
||||||
|
accessType: 'WRITE',
|
||||||
|
accepts: [
|
||||||
|
{
|
||||||
|
arg: 'id',
|
||||||
|
type: 'number',
|
||||||
|
description: 'The invoice id',
|
||||||
|
required: true,
|
||||||
|
http: {source: 'path'}
|
||||||
|
}, {
|
||||||
|
arg: 'printerFk',
|
||||||
|
type: 'number',
|
||||||
|
description: 'The printer to print',
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
http: {
|
||||||
|
path: '/:id/makePdfAndNotify',
|
||||||
|
verb: 'POST'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Self.makePdfAndNotify = async function(ctx, id, printerFk) {
|
||||||
|
const models = Self.app.models;
|
||||||
|
|
||||||
|
options = typeof options == 'object'
|
||||||
|
? Object.assign({}, options) : {};
|
||||||
|
options.userId = ctx.req.accessToken.userId;
|
||||||
|
|
||||||
|
try {
|
||||||
|
await Self.makePdf(id, options);
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
throw new UserError('Error while generating PDF', 'pdfError');
|
||||||
|
}
|
||||||
|
|
||||||
|
const invoiceOut = await Self.findById(id, {
|
||||||
|
fields: ['ref', 'clientFk'],
|
||||||
|
include: {
|
||||||
|
relation: 'client',
|
||||||
|
scope: {
|
||||||
|
fields: ['id', 'email', 'isToBeMailed', 'salesPersonFk']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, options);
|
||||||
|
|
||||||
|
const ref = invoiceOut.ref;
|
||||||
|
const client = invoiceOut.client();
|
||||||
|
|
||||||
|
if (client.isToBeMailed) {
|
||||||
|
try {
|
||||||
|
ctx.args = {
|
||||||
|
reference: ref,
|
||||||
|
recipientId: client.id,
|
||||||
|
recipient: client.email
|
||||||
|
};
|
||||||
|
await Self.invoiceEmail(ctx, ref);
|
||||||
|
} catch (err) {
|
||||||
|
const origin = ctx.req.headers.origin;
|
||||||
|
const message = ctx.req.__('Mail not sent', {
|
||||||
|
clientId: client.id,
|
||||||
|
clientUrl: `${origin}/#!/claim/${id}/summary`
|
||||||
|
});
|
||||||
|
const salesPersonId = client.salesPersonFk;
|
||||||
|
|
||||||
|
if (salesPersonId)
|
||||||
|
await models.Chat.sendCheckingPresence(ctx, salesPersonId, message);
|
||||||
|
|
||||||
|
throw new UserError('Error when sending mail to client', 'mailNotSent');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const query = `
|
||||||
|
CALL vn.report_print(
|
||||||
|
'invoice',
|
||||||
|
?,
|
||||||
|
account.myUser_getId(),
|
||||||
|
JSON_OBJECT('refFk', ?),
|
||||||
|
'normal'
|
||||||
|
);`;
|
||||||
|
await Self.rawSql(query, [printerFk, ref], options);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
|
@ -1,28 +0,0 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
|
||||||
const fs = require('fs-extra');
|
|
||||||
|
|
||||||
describe('InvoiceOut download()', () => {
|
|
||||||
const userId = 9;
|
|
||||||
const invoiceId = 1;
|
|
||||||
const ctx = {
|
|
||||||
req: {
|
|
||||||
|
|
||||||
accessToken: {userId: userId},
|
|
||||||
headers: {origin: 'http://localhost:5000'},
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
it('should return the downloaded file name', async() => {
|
|
||||||
spyOn(models.InvoiceContainer, 'container').and.returnValue({
|
|
||||||
client: {root: '/path'}
|
|
||||||
});
|
|
||||||
spyOn(fs, 'createReadStream').and.returnValue(new Promise(resolve => resolve('streamObject')));
|
|
||||||
spyOn(fs, 'access').and.returnValue(true);
|
|
||||||
spyOn(models.InvoiceOut, 'createPdf').and.returnValue(new Promise(resolve => resolve(true)));
|
|
||||||
|
|
||||||
const result = await models.InvoiceOut.download(ctx, invoiceId);
|
|
||||||
|
|
||||||
expect(result[1]).toEqual('application/pdf');
|
|
||||||
expect(result[2]).toMatch(/filename="\d{4}T1111111.pdf"/);
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -18,12 +18,14 @@ describe('InvoiceOut invoiceClient()', () => {
|
||||||
accessToken: {userId: userId},
|
accessToken: {userId: userId},
|
||||||
__: value => {
|
__: value => {
|
||||||
return value;
|
return value;
|
||||||
}
|
},
|
||||||
|
headers: {origin: 'http://localhost'}
|
||||||
|
|
||||||
};
|
};
|
||||||
const ctx = {req: activeCtx};
|
const ctx = {req: activeCtx};
|
||||||
|
|
||||||
it('should make a global invoicing', async() => {
|
it('should make a global invoicing', async() => {
|
||||||
spyOn(models.InvoiceOut, 'createPdf').and.returnValue(new Promise(resolve => resolve(true)));
|
spyOn(models.InvoiceOut, 'makePdf').and.returnValue(new Promise(resolve => resolve(true)));
|
||||||
spyOn(models.InvoiceOut, 'invoiceEmail');
|
spyOn(models.InvoiceOut, 'invoiceEmail');
|
||||||
|
|
||||||
const tx = await models.InvoiceOut.beginTransaction({});
|
const tx = await models.InvoiceOut.beginTransaction({});
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
"InvoiceOut": {
|
"InvoiceOut": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
|
"InvoiceOutConfig": {
|
||||||
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
"InvoiceOutSerial": {
|
"InvoiceOutSerial": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
{
|
||||||
|
"name": "InvoiceOutConfig",
|
||||||
|
"base": "VnModel",
|
||||||
|
"options": {
|
||||||
|
"mysql": {
|
||||||
|
"table": "invoiceOutConfig"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"properties": {
|
||||||
|
"id": {
|
||||||
|
"id": true,
|
||||||
|
"type": "number",
|
||||||
|
"description": "Identifier"
|
||||||
|
},
|
||||||
|
"parallelism": {
|
||||||
|
"type": "number",
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue