diff --git a/modules/claim/front/detail/index.html b/modules/claim/front/detail/index.html index a7031e31a..ba7a34ffd 100644 --- a/modules/claim/front/detail/index.html +++ b/modules/claim/front/detail/index.html @@ -146,9 +146,7 @@

New price

-

{{($ctrl.saleClaimed.quantity * $ctrl.saleClaimed.sale.price) - - (($ctrl.newDiscount * ($ctrl.saleClaimed.quantity * $ctrl.saleClaimed.sale.price))/100) - | currency: 'EUR':2}} +

{{$ctrl.newPrice | currency: 'EUR':2}}

diff --git a/modules/claim/front/detail/index.js b/modules/claim/front/detail/index.js index ef457807a..137ad4d70 100644 --- a/modules/claim/front/detail/index.js +++ b/modules/claim/front/detail/index.js @@ -37,6 +37,15 @@ class Controller { return this._salesClaimed; } + get newDiscount() { + return this._newDiscount; + } + + set newDiscount(value) { + this._newDiscount = value; + this.updateNewPrice(); + } + openAddSalesDialog() { this.getClaimableFromTicket(); this.$.addSales.show(); @@ -140,6 +149,11 @@ class Controller { } } + updateNewPrice() { + this.newPrice = (this.saleClaimed.quantity * this.saleClaimed.sale.price) - + ((this.newDiscount * (this.saleClaimed.quantity * this.saleClaimed.sale.price)) / 100); + } + clearDiscount() { this.newDiscount = null; } diff --git a/modules/claim/front/detail/index.spec.js b/modules/claim/front/detail/index.spec.js index 9312ef2fc..175266215 100644 --- a/modules/claim/front/detail/index.spec.js +++ b/modules/claim/front/detail/index.spec.js @@ -93,12 +93,16 @@ describe('claim', () => { }); }); - describe('updateDiscount()', () => { + fdescribe('updateDiscount()', () => { it('should perform a query if the new discount differs from the claim discount', () => { + controller.saleClaimed = {sale: { + discount: 5, + id: 7, + ticketFk: 1, + price: 2, + quantity: 10}}; controller.newDiscount = 10; - controller.saleClaimed = {sale: {discount: 5}}; - controller.saleClaimed = {sale: {id: 7}}; - controller.saleClaimed = {sale: {ticketFk: 1}}; + spyOn(controller.vnApp, 'showSuccess'); spyOn(controller, 'clearDiscount'); diff --git a/modules/ticket/front/sale/editDiscount.html b/modules/ticket/front/sale/editDiscount.html index 7648d2ddc..e4c7cf9cd 100644 --- a/modules/ticket/front/sale/editDiscount.html +++ b/modules/ticket/front/sale/editDiscount.html @@ -13,8 +13,6 @@

New price

-

{{($ctrl.edit[0].quantity * $ctrl.edit[0].price) - - (($ctrl.newDiscount * ($ctrl.edit[0].quantity * $ctrl.edit[0].price))/100) - | currency: 'EUR':2}}

+

{{$ctrl.newPrice | currency: 'EUR':2}}

\ No newline at end of file diff --git a/modules/ticket/front/sale/editDiscount.js b/modules/ticket/front/sale/editDiscount.js index 2ad12b159..e623e2eba 100644 --- a/modules/ticket/front/sale/editDiscount.js +++ b/modules/ticket/front/sale/editDiscount.js @@ -28,6 +28,20 @@ class Controller { return this._bulk; } + get newDiscount() { + return this._newDiscount; + } + + set newDiscount(value) { + this._newDiscount = value; + this.updateNewPrice(); + } + + updateNewPrice() { + if (this.newDiscount && this.edit[0]) + this.newPrice = (this.edit[0].quantity * this.edit[0].price) - ((this.newDiscount * (this.edit[0].quantity * this.edit[0].price)) / 100); + } + setNewDiscount() { if (!this.newDiscount && this.edit[0]) this.newDiscount = this.edit[0].discount; diff --git a/modules/ticket/front/sale/index.html b/modules/ticket/front/sale/index.html index 454bab75c..293082d75 100644 --- a/modules/ticket/front/sale/index.html +++ b/modules/ticket/front/sale/index.html @@ -186,9 +186,7 @@

New price

-

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

+

{{$ctrl.newPrice | currency: 'EUR':2}}

diff --git a/modules/ticket/front/sale/index.js b/modules/ticket/front/sale/index.js index 0293f12d0..c5c70998f 100644 --- a/modules/ticket/front/sale/index.js +++ b/modules/ticket/front/sale/index.js @@ -21,16 +21,25 @@ class Controller { this.imagesPath = '//verdnatura.es/vn-image-data/catalog'; } + get sales() { + return this._sales; + } set sales(value) { this._sales = value; this.refreshTotal(); } - get sales() { - return this._sales; + get editedPrice() { + return this._editedPrice; } + set editedPrice(value) { + this._editedPrice = value; + this.updateNewPrice(); + } + + refreshTotal() { this.loadSubTotal(); this.loadVAT(); @@ -270,6 +279,10 @@ class Controller { this.$scope.editPricePopover.hide(); } + updateNewPrice() { + this.newPrice = this.sale.quantity * this.editedPrice - ((this.sale.discount * (this.sale.quantity * this.editedPrice)) / 100); + } + showEditPopover(event, sale) { this.sale = sale; this.edit = [{