#1759 Forzar desenrutado al cambiar datos básicos de ticket

This commit is contained in:
Joan Sanchez 2019-10-14 14:43:10 +02:00
parent ecda659a8c
commit 300ba61fd3
6 changed files with 14 additions and 29 deletions

View File

@ -55,11 +55,6 @@ module.exports = Self => {
type: 'Boolean',
description: 'Ticket is deleted',
required: true
}, {
arg: 'hasToBeUnrouted',
type: 'Boolean',
description: 'Ticket should be removed from ticket',
required: true
}, {
arg: 'option',
type: 'Number',
@ -77,7 +72,7 @@ module.exports = Self => {
});
Self.componentUpdate = async(ctx, id, clientId, agencyModeId, addressId, zoneId, warehouseId,
companyId, shipped, landed, isDeleted, hasToBeUnrouted, option) => {
companyId, shipped, landed, isDeleted, option) => {
const userId = ctx.req.accessToken.userId;
const models = Self.app.models;
const isEditable = await models.Ticket.isEditable(ctx, id);
@ -85,10 +80,6 @@ module.exports = Self => {
if (!isEditable)
throw new UserError(`The sales of this ticket can't be modified`);
const hasDeliveryRole = await models.Account.hasRole(userId, 'delivery');
if (!hasDeliveryRole)
hasToBeUnrouted = true;
const isProductionBoss = await models.Account.hasRole(userId, 'productionBoss');
if (!isProductionBoss) {
const zoneShipped = await models.Agency.getShipped(landed, addressId, agencyModeId, warehouseId);
@ -97,6 +88,8 @@ module.exports = Self => {
throw new UserError(`You don't have privileges to change the zone`);
}
// Force unroute
const hasToBeUnrouted = true;
let query = 'CALL vn.ticket_componentMakeUpdate(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)';
let res = await Self.rawSql(query, [
id,

View File

@ -37,13 +37,12 @@ describe('ticket componentUpdate()', () => {
const companyId = 442;
const isDeleted = false;
const landed = tomorrow;
const hasToBeUnrouted = false;
const option = 1;
let ctx = {req: {accessToken: {userId: 101}}};
await app.models.Ticket.componentUpdate(ctx, ticketId, clientId, agencyModeId, addressId,
zoneId, warehouseId, companyId, shipped, landed, isDeleted, hasToBeUnrouted, option);
zoneId, warehouseId, companyId, shipped, landed, isDeleted, option);
[componentValue] = await app.models.SaleComponent.rawSql(componentOfSaleSeven);
let firstvalueAfterChange = componentValue.value;
@ -65,12 +64,11 @@ describe('ticket componentUpdate()', () => {
const companyId = 442;
const isDeleted = false;
const landed = tomorrow;
const hasToBeUnrouted = false;
const option = 1;
let ctx = {req: {accessToken: {userId: 101}}};
await app.models.Ticket.componentUpdate(ctx, ticketId, clientId, agencyModeId, addressId,
zoneId, warehouseId, companyId, shipped, landed, isDeleted, hasToBeUnrouted, option);
zoneId, warehouseId, companyId, shipped, landed, isDeleted, option);
[componentValue] = await app.models.SaleComponent.rawSql(componentOfSaleSeven);
let firstvalueAfterChange = componentValue.value;

View File

@ -10,12 +10,5 @@
initial-data="$ctrl.ticket.option">
</vn-autocomplete>
</vn-horizontal>
<vn-horizontal>
<vn-check
vn-one label="Remove from route"
ng-model="$ctrl.ticket.hasToBeUnrouted"
vn-acl="delivery">
</vn-check>
</vn-horizontal>
</vn-card>
</form>

View File

@ -15,7 +15,6 @@ class Controller {
$onChanges() {
this.ticket.option = 1;
this.ticket.hasToBeUnrouted = true;
}
onStepChange(state) {
@ -40,15 +39,15 @@ class Controller {
shipped: this.ticket.shipped,
landed: this.ticket.landed,
isDeleted: this.ticket.isDeleted,
hasToBeUnrouted: this.ticket.hasToBeUnrouted,
option: this.ticket.option
};
this.$http.post(query, params).then(res => {
if (res.data) {
this.$state.go('ticket.card.summary', {id: this.$state.params.id});
this.card.reload();
}
this.vnApp.showMessage(
this.$translate.instant(`The ticket has been unrouted`)
);
this.card.reload();
this.$state.go('ticket.card.summary', {id: this.$state.params.id});
});
}
}

View File

@ -31,6 +31,7 @@ describe('ticket', () => {
});
it('should perform a post query correctly then call two functions()', () => {
spyOn(controller.vnApp, 'showMessage');
controller.card = {reload: () => {}};
spyOn(controller.card, 'reload');
@ -60,8 +61,9 @@ describe('ticket', () => {
controller.onSubmit();
$httpBackend.flush();
expect(controller.$state.go).toHaveBeenCalledWith('ticket.card.summary', jasmine.any(Object));
expect(controller.vnApp.showMessage).toHaveBeenCalledWith('The ticket has been unrouted');
expect(controller.card.reload).toHaveBeenCalledWith();
expect(controller.$state.go).toHaveBeenCalledWith('ticket.card.summary', jasmine.any(Object));
});
});
});

View File

@ -1,4 +1,4 @@
Charge: Cargo
Choose an option: Selecciona una opción
Charge difference to: Diferencia a cargo de
Remove from route: Sacar de la ruta
The ticket has been unrouted: El ticket ha sido desenrutado