From 0333ba96b0a7d81f58855950b345a28bfa2731df Mon Sep 17 00:00:00 2001 From: gerard Date: Wed, 5 Sep 2018 11:45:33 +0200 Subject: [PATCH] Tarea #445 claim.detail --- client/claim/src/detail/index.html | 28 ++++++++++++++++----------- client/claim/src/detail/index.js | 16 ++++++++++----- client/claim/src/detail/index.spec.js | 12 +++++++++++- 3 files changed, 39 insertions(+), 17 deletions(-) diff --git a/client/claim/src/detail/index.html b/client/claim/src/detail/index.html index 068765e2a..6137d76a9 100644 --- a/client/claim/src/detail/index.html +++ b/client/claim/src/detail/index.html @@ -2,12 +2,22 @@ vn-id="model" url="claim/api/ClaimBeginnings" filter="$ctrl.filter" - data="$ctrl.salesClaimed" on-data-change="$ctrl.onDataChange()"> + data="$ctrl.salesClaimed"> - Detail + + Detail +
+ + + + +
+
@@ -22,12 +32,13 @@ - + {{saleClaimed.sale.id}} {{saleClaimed.sale.ticket.landed | dateTime: 'dd/MM/yyyy'}} {{saleClaimed.sale.quantity}} - - - -
+ + + { + this.paidTotal += (sale.sale.quantity * sale.sale.price) - ((sale.sale.discount * (sale.sale.quantity * sale.sale.price)) / 100); + }); + this.claimedTotal = 0; + this.salesClaimed.forEach(sale => { + this.claimedTotal += (sale.quantity * sale.sale.price) - ((sale.sale.discount * (sale.quantity * sale.sale.price)) / 100); + }); + } } Controller.$inject = ['$state', '$scope', '$http', '$translate', 'vnApp']; diff --git a/client/claim/src/detail/index.spec.js b/client/claim/src/detail/index.spec.js index d6769a022..084841f4a 100644 --- a/client/claim/src/detail/index.spec.js +++ b/client/claim/src/detail/index.spec.js @@ -1,6 +1,6 @@ import './index.js'; -describe('claim', () => { +fdescribe('claim', () => { describe('Component vnClaimDetail', () => { let $componentController; let controller; @@ -90,5 +90,15 @@ describe('claim', () => { expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!'); }); }); + + describe('calculateTotals()', () => { + it('should set paidTotal and claimedTotal to 0 if salesClaimed has no data', () => { + controller.salesClaimed = []; + controller.calculateTotals(); + + expect(controller.paidTotal).toEqual(0); + expect(controller.claimedTotal).toEqual(0); + }); + }); }); });