Bug #571 usuario con privilegios cambia el estado de un ticket bloqueado
This commit is contained in:
parent
b6cc14065e
commit
49ea108771
|
@ -125,7 +125,7 @@
|
|||
</vn-td>
|
||||
<vn-td number>
|
||||
{{(sale.quantity * sale.price) -
|
||||
((sale.discount * (sale.quantity * sale.price))/100) | currency:' €':2
|
||||
((sale.discount * (sale.quantity * sale.price))/100) | currency:'€':2
|
||||
}}
|
||||
</vn-td>
|
||||
</vn-tr>
|
||||
|
@ -147,15 +147,15 @@
|
|||
<section>
|
||||
<p>
|
||||
<vn-label translate>Subtotal</vn-label>
|
||||
<span>{{$ctrl.subTotal | currency:' €':2}}</span>
|
||||
<span>{{$ctrl.subTotal | currency:'€':2}}</span>
|
||||
</p>
|
||||
<p>
|
||||
<vn-label translate>VAT</vn-label>
|
||||
<span>{{$ctrl.VAT | currency:' €':2}}</span>
|
||||
<span>{{$ctrl.VAT | currency:'€':2}}</span>
|
||||
</p>
|
||||
<p>
|
||||
<vn-label><strong>Total</strong></vn-label>
|
||||
<strong>{{$ctrl.total | currency:' €':2}}</strong>
|
||||
<strong>{{$ctrl.total | currency:'€':2}}</strong>
|
||||
</p>
|
||||
</section>
|
||||
</vn-td>
|
||||
|
@ -216,7 +216,7 @@
|
|||
vn-id="editPricePopover"
|
||||
on-open="$ctrl.getManaSalespersonMana()">
|
||||
<vn-horizontal pad-medium class="header">
|
||||
<h5>MANÁ: {{$ctrl.mana | currency:' €':0}}</h5>
|
||||
<h5>MANÁ: {{$ctrl.mana | currency:'€':0}}</h5>
|
||||
</vn-horizontal>
|
||||
<div pad-medium>
|
||||
<vn-textfield
|
||||
|
@ -232,7 +232,7 @@
|
|||
<p class="simulatorTitle" translate>New price</p>
|
||||
<p>{{($ctrl.sale.quantity * $ctrl.editedPrice)
|
||||
- (($ctrl.sale.discount * ($ctrl.sale.quantity * $ctrl.editedPrice))/100)
|
||||
| currency:' €':2}}</p>
|
||||
| currency:'€':2}}</p>
|
||||
</div>
|
||||
</div>
|
||||
</vn-popover>
|
||||
|
|
|
@ -114,7 +114,7 @@ class Controller {
|
|||
|
||||
onStateChange(value) {
|
||||
let params = {ticketFk: this.$state.params.id, stateFk: value};
|
||||
this.$http.post(`/ticket/api/TicketTrackings`, params).then(() => {
|
||||
this.$http.post(`/ticket/api/TicketTrackings/changeState`, params).then(() => {
|
||||
this.card.reload();
|
||||
this.vnApp.showSuccess(this.translate.instant('Data saved!'));
|
||||
});
|
||||
|
@ -265,6 +265,7 @@ class Controller {
|
|||
this.$http.post(`/ticket/api/Sales/updatePrice`, {id: this.edit.id, price: this.editedPrice, ticketFk: this.ticket.id}).then(() => {
|
||||
this.sale.price = this.edit.price;
|
||||
this.$scope.model.refresh();
|
||||
this.vnApp.showSuccess(this.translate.instant('Data saved!'));
|
||||
});
|
||||
}
|
||||
this.$scope.editPricePopover.hide();
|
||||
|
@ -303,8 +304,6 @@ class Controller {
|
|||
updateQuantity(id, quantity) {
|
||||
this.$http.post(`/ticket/api/Sales/${id}/updateQuantity`, {quantity: parseInt(quantity)}).then(() => {
|
||||
this.vnApp.showSuccess(this.translate.instant('Data saved!'));
|
||||
}).catch(e => {
|
||||
this.vnApp.showError(this.translate.instant(e.data.error.message));
|
||||
});
|
||||
this.$scope.model.refresh();
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import './index.js';
|
||||
|
||||
describe('Ticket', () => {
|
||||
fdescribe('Ticket', () => {
|
||||
describe('Component vnTicketSale', () => {
|
||||
let $componentController;
|
||||
let controller;
|
||||
|
@ -20,9 +20,7 @@ describe('Ticket', () => {
|
|||
$scope = $rootScope.$new();
|
||||
$state = _$state_;
|
||||
$state.params.id = 1;
|
||||
controller = $componentController('vnTicketSale', {$scope: $scope}, {$state: $state});
|
||||
controller.ticket = {id: 1};
|
||||
controller.$scope = {model: {data: [
|
||||
$scope.model = {data: [
|
||||
{
|
||||
id: 1,
|
||||
quantity: 5,
|
||||
|
@ -37,11 +35,10 @@ describe('Ticket', () => {
|
|||
discount: 0,
|
||||
checked: true
|
||||
}
|
||||
]}, accept: () => {
|
||||
return {
|
||||
then: () => {}
|
||||
};
|
||||
}};
|
||||
]};
|
||||
$scope.addTurn = {show: () => {}};
|
||||
controller = $componentController('vnTicketSale', {$scope: $scope}, {$state: $state});
|
||||
controller.ticket = {id: 1};
|
||||
}));
|
||||
|
||||
describe('getSales()', () => {
|
||||
|
@ -148,19 +145,22 @@ describe('Ticket', () => {
|
|||
});
|
||||
});
|
||||
|
||||
xdescribe('addTurn(day)', () => {
|
||||
describe('addTurn(day)', () => {
|
||||
it('should make a query and call $.addTurn.hide() and vnApp.showSuccess()', () => {
|
||||
controller.$scope.addTurn = {hide: () => {}};
|
||||
spyOn(controller.$scope.addTurn, 'hide');
|
||||
controller.showAddTurnDialog();
|
||||
|
||||
$httpBackend.expectPATCH(`/ticket/api/TicketWeeklies`).respond();
|
||||
controller.addTurn(1);
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(controller.$scope.addTurn.show).toHaveBeenCalledWith();
|
||||
expect(controller.$scope.addTurn.hide).toHaveBeenCalledWith();
|
||||
});
|
||||
});
|
||||
|
||||
describe('onStateChange()', () => {
|
||||
it('should perform a POST', () => {
|
||||
$httpBackend.expectPOST(`/ticket/api/TicketTrackings`).respond();
|
||||
it('should perform a post and then call a function', () => {
|
||||
$httpBackend.expectPOST(`/ticket/api/TicketTrackings/changeState`).respond();
|
||||
controller.card = {reload: () => {}};
|
||||
controller.onStateChange(3);
|
||||
$httpBackend.flush();
|
||||
|
|
|
@ -22,6 +22,9 @@ module.exports = Self => {
|
|||
Self.isEditable = async ticketFk => {
|
||||
let state = await Self.app.models.TicketState.findOne({where: {ticketFk: ticketFk}, fields: 'alertLevel'});
|
||||
let exists = await Self.app.models.Ticket.findOne({where: {id: ticketFk}, fields: 'isDeleted'});
|
||||
return (exists && state == null && exists.isDeleted == 0) || (exists.isDeleted == 0 && state.alertLevel == 0);
|
||||
if (!exists || exists.isDeleted == 1 || state.alertLevel > 0)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -19,7 +19,7 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.changeState = async (params, ctx) => {
|
||||
Self.changeState = async params => {
|
||||
let isEditable = await Self.app.models.Ticket.isEditable(params.ticketFk);
|
||||
if (isEditable)
|
||||
return await Self.app.models.TicketTracking.create(params);
|
||||
|
|
Loading…
Reference in New Issue