Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 5914-transferInvoiceOut
This commit is contained in:
commit
27ab6639c9
|
@ -15,17 +15,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
### Fixed
|
||||
|
||||
|
||||
## [2332.01] - 2023-08-09
|
||||
## [2332.01] - 2023-08-10
|
||||
|
||||
### Added
|
||||
- (Trabajadores -> Gestión documental) Soporte para Docuware
|
||||
- (General -> Agencia) Soporte para Viaexpress
|
||||
- (Tickets -> SMS) Nueva sección en Lilium
|
||||
|
||||
### Changed
|
||||
- (General -> Tickets) Devuelve el motivo por el cual no es editable
|
||||
- (Desplegables -> Trabajadores) Mejorados
|
||||
- (General -> Clientes) Razón social y dirección en mayúsculas
|
||||
|
||||
### Fixed
|
||||
- (Clientes -> SMS) Al pasar el ratón por encima muestra el mensaje completo
|
||||
|
||||
|
||||
## [2330.01] - 2023-07-27
|
||||
|
|
|
@ -7,6 +7,11 @@ module.exports = Self => {
|
|||
type: 'string',
|
||||
description: 'The user name or email',
|
||||
required: true
|
||||
},
|
||||
{
|
||||
arg: 'app',
|
||||
type: 'string',
|
||||
description: 'The directory for mail'
|
||||
}
|
||||
],
|
||||
http: {
|
||||
|
@ -15,7 +20,7 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.recoverPassword = async function(user) {
|
||||
Self.recoverPassword = async function(user, app) {
|
||||
const models = Self.app.models;
|
||||
|
||||
const usesEmail = user.indexOf('@') !== -1;
|
||||
|
@ -29,7 +34,7 @@ module.exports = Self => {
|
|||
}
|
||||
|
||||
try {
|
||||
await Self.resetPassword({email: user, emailTemplate: 'recover-password'});
|
||||
await Self.resetPassword({email: user, emailTemplate: 'recover-password', app});
|
||||
} catch (err) {
|
||||
if (err.code === 'EMAIL_NOT_FOUND')
|
||||
return;
|
||||
|
|
|
@ -53,19 +53,13 @@ module.exports = Self => {
|
|||
return Self.validateLogin(user, password);
|
||||
};
|
||||
|
||||
Self.passExpired = async(vnUser, myOptions) => {
|
||||
Self.passExpired = async vnUser => {
|
||||
const today = Date.vnNew();
|
||||
today.setHours(0, 0, 0, 0);
|
||||
|
||||
if (vnUser.passExpired && vnUser.passExpired.getTime() <= today.getTime()) {
|
||||
const $ = Self.app.models;
|
||||
const changePasswordToken = await $.AccessToken.create({
|
||||
scopes: ['changePassword'],
|
||||
userId: vnUser.id
|
||||
}, myOptions);
|
||||
const err = new UserError('Pass expired', 'passExpired');
|
||||
changePasswordToken.twoFactor = vnUser.twoFactor ? true : false;
|
||||
err.details = {token: changePasswordToken};
|
||||
err.details = {userId: vnUser.id, twoFactor: vnUser.twoFactor ? true : false};
|
||||
throw err;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -96,11 +96,21 @@ module.exports = function(Self) {
|
|||
const headers = httpRequest.headers;
|
||||
const origin = headers.origin;
|
||||
|
||||
const defaultHash = '/reset-password?access_token=$token$';
|
||||
const recoverHashes = {
|
||||
hedera: 'verificationToken=$token$'
|
||||
};
|
||||
|
||||
const app = info.options?.app;
|
||||
let recoverHash = app ? recoverHashes[app] : defaultHash;
|
||||
recoverHash = recoverHash.replace('$token$', info.accessToken.id);
|
||||
|
||||
const user = await Self.app.models.VnUser.findById(info.user.id);
|
||||
|
||||
const params = {
|
||||
recipient: info.email,
|
||||
lang: user.lang,
|
||||
url: `${origin}/#!/reset-password?access_token=${info.accessToken.id}`
|
||||
url: origin + '/#!' + recoverHash
|
||||
};
|
||||
|
||||
const options = Object.assign({}, info.options);
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId)
|
||||
VALUES
|
||||
('TicketSms', 'find', 'READ', 'ALLOW', 'ROLE', 'salesPerson');
|
|
@ -0,0 +1,6 @@
|
|||
UPDATE `salix`.`ACL`
|
||||
SET principalId='salesPerson'
|
||||
WHERE
|
||||
model='Ticket'
|
||||
AND property='setDeleted'
|
||||
AND accessType='WRITE';
|
|
@ -10,7 +10,7 @@ describe('Ticket create path', () => {
|
|||
beforeAll(async() => {
|
||||
browser = await getBrowser();
|
||||
page = browser.page;
|
||||
await page.loginAndModule('employee', 'ticket');
|
||||
await page.loginAndModule('salesPerson', 'ticket');
|
||||
});
|
||||
|
||||
afterAll(async() => {
|
||||
|
|
|
@ -15,9 +15,6 @@ export default class Controller {
|
|||
}
|
||||
|
||||
$onInit() {
|
||||
if (!this.$state.params.id)
|
||||
this.$state.go('login');
|
||||
|
||||
this.$http.get('UserPasswords/findOne')
|
||||
.then(res => {
|
||||
this.passRequirements = res.data;
|
||||
|
@ -25,7 +22,7 @@ export default class Controller {
|
|||
}
|
||||
|
||||
submit() {
|
||||
const userId = this.$state.params.userId;
|
||||
const userId = parseInt(this.$state.params.userId);
|
||||
const oldPassword = this.oldPassword;
|
||||
const newPassword = this.newPassword;
|
||||
const repeatPassword = this.repeatPassword;
|
||||
|
@ -36,18 +33,13 @@ export default class Controller {
|
|||
if (newPassword != this.repeatPassword)
|
||||
throw new UserError(`Passwords don't match`);
|
||||
|
||||
const headers = {
|
||||
Authorization: this.$state.params.id
|
||||
};
|
||||
|
||||
this.$http.patch('Accounts/change-password',
|
||||
{
|
||||
id: userId,
|
||||
userId,
|
||||
oldPassword,
|
||||
newPassword,
|
||||
code
|
||||
},
|
||||
{headers}
|
||||
}
|
||||
).then(() => {
|
||||
this.vnApp.showSuccess(this.$translate.instant('Password updated!'));
|
||||
this.$state.go('login');
|
||||
|
|
|
@ -36,7 +36,7 @@ export default class Controller {
|
|||
|
||||
const err = req.data?.error;
|
||||
if (err?.code == 'passExpired')
|
||||
this.$state.go('change-password', err.details.token);
|
||||
this.$state.go('change-password', err.details);
|
||||
|
||||
this.loading = false;
|
||||
this.password = '';
|
||||
|
|
|
@ -45,7 +45,7 @@ function config($stateProvider, $urlRouterProvider) {
|
|||
})
|
||||
.state('change-password', {
|
||||
parent: 'outLayout',
|
||||
url: '/change-password?id&userId&twoFactor',
|
||||
url: '/change-password?userId&twoFactor',
|
||||
description: 'Change password',
|
||||
template: '<vn-change-password></vn-change-password>'
|
||||
})
|
||||
|
|
|
@ -179,6 +179,7 @@
|
|||
"You can not use the same password": "You can not use the same password",
|
||||
"Valid priorities": "Valid priorities: %d",
|
||||
"Negative basis of tickets": "Negative basis of tickets: {{ticketsIds}}",
|
||||
"This ticket cannot be left empty.": "This ticket cannot be left empty. %s",
|
||||
"Social name should be uppercase": "Social name should be uppercase",
|
||||
"Street should be uppercase": "Street should be uppercase",
|
||||
"You don't have enough privileges.": "You don't have enough privileges.",
|
||||
|
|
|
@ -306,6 +306,7 @@
|
|||
"Valid priorities": "Prioridades válidas: %d",
|
||||
"Negative basis of tickets": "Base negativa para los tickets: {{ticketsIds}}",
|
||||
"You cannot assign an alias that you are not assigned to": "No puede asignar un alias que no tenga asignado",
|
||||
"This ticket cannot be left empty.": "Este ticket no se puede dejar vacío. %s",
|
||||
"The company has not informed the supplier account for bank transfers": "La empresa no tiene informado la cuenta de proveedor para transferencias bancarias",
|
||||
"You cannot assign/remove an alias that you are not assigned to": "No puede asignar/eliminar un alias que no tenga asignado",
|
||||
"This invoice has a linked vehicle.": "Esta factura tiene un vehiculo vinculado",
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
const UserError = require('vn-loopback/util/user-error');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('changePassword', {
|
||||
Self.remoteMethod('changePassword', {
|
||||
description: 'Changes the user password',
|
||||
accessType: 'WRITE',
|
||||
accessScopes: ['changePassword'],
|
||||
accepts: [
|
||||
{
|
||||
arg: 'userId',
|
||||
type: 'integer',
|
||||
description: 'The user id',
|
||||
required: true
|
||||
}, {
|
||||
arg: 'oldPassword',
|
||||
type: 'string',
|
||||
description: 'The old password',
|
||||
|
@ -28,9 +31,7 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.changePassword = async function(ctx, oldPassword, newPassword, code, options) {
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
|
||||
Self.changePassword = async function(userId, oldPassword, newPassword, code, options) {
|
||||
const myOptions = {};
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const {models} = require('vn-loopback/server/server');
|
||||
|
||||
describe('account changePassword()', () => {
|
||||
const ctx = {req: {accessToken: {userId: 70}}};
|
||||
const userId = 70;
|
||||
const unauthCtx = {
|
||||
req: {
|
||||
headers: {},
|
||||
|
@ -20,7 +20,7 @@ describe('account changePassword()', () => {
|
|||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
await models.Account.changePassword(ctx, 'wrongPassword', 'nightmare.9999', null, options);
|
||||
await models.Account.changePassword(userId, 'wrongPassword', 'nightmare.9999', null, options);
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
|
@ -37,8 +37,8 @@ describe('account changePassword()', () => {
|
|||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
await models.Account.changePassword(ctx, 'nightmare', 'nightmare.9999', null, options);
|
||||
await models.Account.changePassword(ctx, 'nightmare.9999', 'nightmare.9999', null, options);
|
||||
await models.Account.changePassword(userId, 'nightmare', 'nightmare.9999', null, options);
|
||||
await models.Account.changePassword(userId, 'nightmare.9999', 'nightmare.9999', null, options);
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
|
@ -54,7 +54,7 @@ describe('account changePassword()', () => {
|
|||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
await models.Account.changePassword(ctx, 'nightmare', 'nightmare.9999', null, options);
|
||||
await models.Account.changePassword(userId, 'nightmare', 'nightmare.9999', null, options);
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
|
@ -86,8 +86,8 @@ describe('account changePassword()', () => {
|
|||
}
|
||||
|
||||
try {
|
||||
const authCode = await models.AuthCode.findOne({where: {userFk: 70}}, options);
|
||||
await models.Account.changePassword(ctx, 'nightmare', 'nightmare.9999', authCode.code, options);
|
||||
const authCode = await models.AuthCode.findOne({where: {userFk: userId}}, options);
|
||||
await models.Account.changePassword(userId, 'nightmare', 'nightmare.9999', authCode.code, options);
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
auto-load="true">
|
||||
</vn-crud-model>
|
||||
<vn-data-viewer model="model">
|
||||
<vn-card class="vn-w-md">
|
||||
<vn-card class="vn-w-lg">
|
||||
<vn-table model="model" auto-load="false">
|
||||
<vn-thead>
|
||||
<vn-tr>
|
||||
|
@ -27,7 +27,7 @@
|
|||
</span>
|
||||
</vn-td>
|
||||
<vn-td number expand>{{::clientSms.sms.destination}}</vn-td>
|
||||
<vn-td>{{::clientSms.sms.message}}</vn-td>
|
||||
<vn-td expand vn-tooltip="{{::clientSms.sms.message}}">{{::clientSms.sms.message}}</vn-td>
|
||||
<vn-td>{{::clientSms.sms.status}}</vn-td>
|
||||
<vn-td shrink-datetime>{{::clientSms.sms.created | date:'dd/MM/yyyy HH:mm'}}</vn-td>
|
||||
</vn-tr>
|
||||
|
|
|
@ -0,0 +1,133 @@
|
|||
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
|
||||
const buildFilter = require('vn-loopback/util/filter').buildFilter;
|
||||
const mergeFilters = require('vn-loopback/util/filter').mergeFilters;
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethod('getExternalCmrs', {
|
||||
description: 'Returns an array of external cmrs',
|
||||
accessType: 'READ',
|
||||
accepts: [
|
||||
{
|
||||
arg: 'filter',
|
||||
type: 'object',
|
||||
description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string',
|
||||
},
|
||||
{
|
||||
arg: 'cmrFk',
|
||||
type: 'integer',
|
||||
description: 'Searchs the route by id',
|
||||
},
|
||||
{
|
||||
arg: 'ticketFk',
|
||||
type: 'integer',
|
||||
description: 'The worker id',
|
||||
},
|
||||
{
|
||||
arg: 'country',
|
||||
type: 'string',
|
||||
description: 'The agencyMode id',
|
||||
},
|
||||
{
|
||||
arg: 'clientFk',
|
||||
type: 'integer',
|
||||
description: 'The vehicle id',
|
||||
},
|
||||
{
|
||||
arg: 'hasCmrDms',
|
||||
type: 'boolean',
|
||||
description: 'The vehicle id',
|
||||
},
|
||||
{
|
||||
arg: 'shipped',
|
||||
type: 'date',
|
||||
description: 'The to date filter',
|
||||
},
|
||||
],
|
||||
returns: {
|
||||
type: ['object'],
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/getExternalCmrs`,
|
||||
verb: 'GET'
|
||||
}
|
||||
});
|
||||
|
||||
Self.getExternalCmrs = async(
|
||||
filter,
|
||||
cmrFk,
|
||||
ticketFk,
|
||||
country,
|
||||
clientFk,
|
||||
hasCmrDms,
|
||||
shipped,
|
||||
options
|
||||
) => {
|
||||
const params = {
|
||||
cmrFk,
|
||||
ticketFk,
|
||||
country,
|
||||
clientFk,
|
||||
hasCmrDms,
|
||||
shipped,
|
||||
};
|
||||
const conn = Self.dataSource.connector;
|
||||
|
||||
let where = buildFilter(params, (param, value) => {return {[param]: value}});
|
||||
filter = mergeFilters(filter, {where});
|
||||
|
||||
if (!filter.where) {
|
||||
const yesterday = new Date();
|
||||
yesterday.setDate(yesterday.getDate() - 1);
|
||||
filter.where = {'shipped': yesterday.toISOString().split('T')[0]}
|
||||
}
|
||||
|
||||
const myOptions = {};
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
let stmts = [];
|
||||
const stmt = new ParameterizedSQL(`
|
||||
SELECT *
|
||||
FROM (
|
||||
SELECT t.cmrFk,
|
||||
t.id ticketFk,
|
||||
co.country,
|
||||
t.clientFk,
|
||||
sub.id hasCmrDms,
|
||||
DATE(t.shipped) shipped
|
||||
FROM ticket t
|
||||
JOIN ticketState ts ON ts.ticketFk = t.id
|
||||
JOIN state s ON s.id = ts.stateFk
|
||||
JOIN alertLevel al ON al.id = s.alertLevel
|
||||
JOIN client c ON c.id = t.clientFk
|
||||
JOIN address a ON a.id = t.addressFk
|
||||
JOIN province p ON p.id = a.provinceFk
|
||||
JOIN country co ON co.id = p.countryFk
|
||||
JOIN agencyMode am ON am.id = t.agencyModeFk
|
||||
JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk
|
||||
JOIN warehouse w ON w.id = t.warehouseFk
|
||||
LEFT JOIN (
|
||||
SELECT td.ticketFk, d.id
|
||||
FROM ticketDms td
|
||||
JOIN dms d ON d.id = td.dmsFk
|
||||
JOIN dmsType dt ON dt.id = d.dmsTypeFk
|
||||
WHERE dt.name = 'cmr'
|
||||
) sub ON sub.ticketFk = t.id
|
||||
WHERE co.code <> 'ES'
|
||||
AND am.name <> 'ABONO'
|
||||
AND w.code = 'ALG'
|
||||
AND dm.code = 'DELIVERY'
|
||||
AND t.cmrFk
|
||||
) sub
|
||||
`);
|
||||
|
||||
stmt.merge(conn.makeSuffix(filter));
|
||||
const itemsIndex = stmts.push(stmt) - 1;
|
||||
|
||||
const sql = ParameterizedSQL.join(stmts, ';');
|
||||
const result = await conn.executeStmt(sql);
|
||||
return itemsIndex === 0 ? result : result[itemsIndex];
|
||||
};
|
||||
};
|
|
@ -15,6 +15,7 @@ module.exports = Self => {
|
|||
require('../methods/route/sendSms')(Self);
|
||||
require('../methods/route/downloadZip')(Self);
|
||||
require('../methods/route/cmr')(Self);
|
||||
require('../methods/route/getExternalCmrs')(Self);
|
||||
|
||||
Self.validate('kmStart', validateDistance, {
|
||||
message: 'Distance must be lesser than 1000'
|
||||
|
|
|
@ -46,8 +46,6 @@ class Controller extends Section {
|
|||
}
|
||||
|
||||
deleteRoadmaps() {
|
||||
console.log(this.checked);
|
||||
|
||||
for (const roadmap of this.checked) {
|
||||
this.$http.delete(`Roadmaps/${roadmap.id}`)
|
||||
.then(() => this.$.model.refresh())
|
||||
|
|
|
@ -5,6 +5,8 @@ describe('sale transferSales()', () => {
|
|||
const userId = 1101;
|
||||
const activeCtx = {
|
||||
accessToken: {userId: userId},
|
||||
headers: {origin: ''},
|
||||
__: value => value
|
||||
};
|
||||
const ctx = {req: activeCtx};
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@ module.exports = Self => {
|
|||
const userId = ctx.req.accessToken.userId;
|
||||
const models = Self.app.models;
|
||||
const myOptions = {userId};
|
||||
const $t = ctx.req.__; // $translate
|
||||
let tx;
|
||||
|
||||
if (typeof options == 'object')
|
||||
|
@ -95,9 +96,18 @@ module.exports = Self => {
|
|||
|
||||
const isTicketEmpty = await models.Ticket.isEmpty(id, myOptions);
|
||||
if (isTicketEmpty) {
|
||||
await originalTicket.updateAttributes({
|
||||
isDeleted: true
|
||||
}, myOptions);
|
||||
try {
|
||||
await models.Ticket.setDeleted(ctx, id, myOptions);
|
||||
} catch (e) {
|
||||
if (e.statusCode === 400) {
|
||||
throw new UserError(
|
||||
`This ticket cannot be left empty.`,
|
||||
'TRANSFER_SET_DELETED',
|
||||
$t(e.message, ...e.translateArgs)
|
||||
);
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
if (tx) await tx.commit();
|
||||
|
|
|
@ -36,3 +36,4 @@ import './future';
|
|||
import './future-search-panel';
|
||||
import './advance';
|
||||
import './advance-search-panel';
|
||||
import './sms';
|
||||
|
|
|
@ -26,7 +26,8 @@
|
|||
{"state": "ticket.card.components", "icon": "icon-components"},
|
||||
{"state": "ticket.card.saleTracking", "icon": "assignment"},
|
||||
{"state": "ticket.card.dms.index", "icon": "cloud_download"},
|
||||
{"state": "ticket.card.boxing", "icon": "science"}
|
||||
{"state": "ticket.card.boxing", "icon": "science"},
|
||||
{"state": "ticket.card.sms", "icon": "sms"}
|
||||
]
|
||||
},
|
||||
"keybindings": [
|
||||
|
@ -287,6 +288,15 @@
|
|||
"state": "ticket.advance",
|
||||
"component": "vn-ticket-advance",
|
||||
"description": "Advance tickets"
|
||||
},
|
||||
{
|
||||
"url": "/sms",
|
||||
"state": "ticket.card.sms",
|
||||
"component": "vn-ticket-sms",
|
||||
"description": "Sms",
|
||||
"params": {
|
||||
"ticket": "$ctrl.ticket"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
<vn-card>
|
||||
</vn-card>
|
|
@ -0,0 +1,21 @@
|
|||
import ngModule from '../module';
|
||||
import Section from 'salix/components/section';
|
||||
|
||||
class Controller extends Section {
|
||||
constructor($element, $) {
|
||||
super($element, $);
|
||||
}
|
||||
|
||||
async $onInit() {
|
||||
this.$state.go('ticket.card.summary', {id: this.$params.id});
|
||||
window.location.href = await this.vnApp.getUrl(`ticket/${this.$params.id}/sms`);
|
||||
}
|
||||
}
|
||||
|
||||
ngModule.vnComponent('vnTicketSms', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller,
|
||||
bindings: {
|
||||
ticket: '<'
|
||||
}
|
||||
});
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "salix-back",
|
||||
"version": "23.34.01",
|
||||
"version": "23.32.02",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
|
|
Loading…
Reference in New Issue