diff --git a/client/ticket/src/sale/index.html b/client/ticket/src/sale/index.html index 903147dc8..e1fd2eb95 100644 --- a/client/ticket/src/sale/index.html +++ b/client/ticket/src/sale/index.html @@ -125,7 +125,7 @@ {{(sale.quantity * sale.price) - - ((sale.discount * (sale.quantity * sale.price))/100) | currency:' €':2 + ((sale.discount * (sale.quantity * sale.price))/100) | currency:'€':2 }} @@ -147,15 +147,15 @@

Subtotal - {{$ctrl.subTotal | currency:' €':2}} + {{$ctrl.subTotal | currency:'€':2}}

VAT - {{$ctrl.VAT | currency:' €':2}} + {{$ctrl.VAT | currency:'€':2}}

Total - {{$ctrl.total | currency:' €':2}} + {{$ctrl.total | currency:'€':2}}

@@ -216,7 +216,7 @@ vn-id="editPricePopover" on-open="$ctrl.getManaSalespersonMana()"> -
MANÁ: {{$ctrl.mana | currency:' €':0}}
+
MANÁ: {{$ctrl.mana | currency:'€':0}}
New price

{{($ctrl.sale.quantity * $ctrl.editedPrice) - (($ctrl.sale.discount * ($ctrl.sale.quantity * $ctrl.editedPrice))/100) - | currency:' €':2}}

+ | currency:'€':2}}

diff --git a/client/ticket/src/sale/index.js b/client/ticket/src/sale/index.js index 09d3cfb74..67ba0b934 100644 --- a/client/ticket/src/sale/index.js +++ b/client/ticket/src/sale/index.js @@ -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(); } diff --git a/client/ticket/src/sale/index.spec.js b/client/ticket/src/sale/index.spec.js index c18c8a7e5..174d729a1 100644 --- a/client/ticket/src/sale/index.spec.js +++ b/client/ticket/src/sale/index.spec.js @@ -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(); diff --git a/services/loopback/common/methods/ticket/isEditable.js b/services/loopback/common/methods/ticket/isEditable.js index a3968a315..0edd3259d 100644 --- a/services/loopback/common/methods/ticket/isEditable.js +++ b/services/loopback/common/methods/ticket/isEditable.js @@ -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; }; }; diff --git a/services/ticket/common/methods/ticket-tracking/changeState.js b/services/ticket/common/methods/ticket-tracking/changeState.js index 4fa41e9ba..c99dd7908 100644 --- a/services/ticket/common/methods/ticket-tracking/changeState.js +++ b/services/ticket/common/methods/ticket-tracking/changeState.js @@ -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);