#1181 No modificar ticket.basicData en reparto
This commit is contained in:
parent
fc63fdf379
commit
62acb534e1
|
@ -1,6 +1,8 @@
|
||||||
|
const UserError = require('vn-loopback/util/user-error');
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethod('priceDifference', {
|
Self.remoteMethod('priceDifference', {
|
||||||
description: 'Returns sales with price difference',
|
description: 'Returns sales with price difference if the ticket is editable',
|
||||||
accessType: 'READ',
|
accessType: 'READ',
|
||||||
accepts: [{
|
accepts: [{
|
||||||
arg: 'ticketFk',
|
arg: 'ticketFk',
|
||||||
|
@ -26,6 +28,10 @@ module.exports = Self => {
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.priceDifference = async(ticketFk, data) => {
|
Self.priceDifference = async(ticketFk, data) => {
|
||||||
|
let thisTicketIsEditable = await Self.app.models.Ticket.isEditable(ticketFk);
|
||||||
|
if (!thisTicketIsEditable)
|
||||||
|
throw new UserError(`The sales of this ticket can't be modified`);
|
||||||
|
|
||||||
let filter = {
|
let filter = {
|
||||||
where: {
|
where: {
|
||||||
ticketFk: ticketFk
|
ticketFk: ticketFk
|
||||||
|
|
|
@ -118,7 +118,7 @@ class Controller {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async onStepChange(state) {
|
async onStepChange() {
|
||||||
if (this.isFormInvalid()) {
|
if (this.isFormInvalid()) {
|
||||||
return this.vnApp.showError(
|
return this.vnApp.showError(
|
||||||
this.$translate.instant('Some fields are invalid')
|
this.$translate.instant('Some fields are invalid')
|
||||||
|
@ -138,11 +138,15 @@ class Controller {
|
||||||
this.ticket.sale = res.data;
|
this.ticket.sale = res.data;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}, res => {
|
}, err => {
|
||||||
if (res.data.error.message === 'NO_AGENCY_AVAILABLE') {
|
if (err.data.error.message === 'NO_AGENCY_AVAILABLE') {
|
||||||
this.vnApp.showMessage(
|
this.vnApp.showMessage(
|
||||||
this.$translate.instant(`There's no available agency for this landing date`)
|
this.$translate.instant(`There's no available agency for this landing date`)
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
this.vnApp.showMessage(
|
||||||
|
this.$translate.instant(err.data.error.message)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue