This commit is contained in:
Bernat 2019-10-15 07:07:21 +02:00
commit 9a65cafe19
10 changed files with 26 additions and 41 deletions

View File

@ -1,7 +1,5 @@
vn-item-descriptor-popover {
vn-item-descriptor {
body > .vn-popover vn-item-descriptor {
display: block;
width: 16em;
min-height: 28em;
}
}

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.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

View File

@ -1,6 +1,6 @@
<div class="header vn-pa-md">
<section class="header vn-pa-md">
<h5>MANÁ: {{$ctrl.mana | currency: 'EUR':0}}</h5>
</div>
</section>
<div class="vn-pa-md">
<vn-input-number
vn-focus

View File

@ -218,9 +218,9 @@
enable="true">
</vn-spinner>
<div ng-if="$ctrl.mana != null">
<div class="header vn-pa-md">
<section class="header vn-pa-md">
<h5>MANÁ: {{$ctrl.mana | currency: 'EUR':0}}</h5>
</div>
</section>
<div class="vn-pa-md">
<vn-input-number
vn-focus

View File

@ -89,17 +89,19 @@ vn-ticket-sale {
}
}
.edit-price {
width: 200px;
min-width: 200px;
.header {
section.header {
background-color: $color-main;
color: $color-font-dark;
text-align: center;
h5 {
color: inherit;
margin: 0 auto;
}
}
p.simulatorTitle {
margin-bottom: 0px;
font-size: 12px;