From f7cf8cd65689872a1e44ecfd29d241208f97c6da Mon Sep 17 00:00:00 2001 From: jgallego Date: Wed, 16 Jan 2019 15:38:50 +0100 Subject: [PATCH] Bug #976 --- modules/client/front/descriptor/index.html | 2 +- modules/item/front/ticket-descriptor/index.html | 2 +- modules/item/front/ticket-descriptor/index.js | 1 - modules/ticket/front/card/index.js | 13 +++++++++++-- modules/ticket/front/card/index.spec.js | 4 +++- 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/modules/client/front/descriptor/index.html b/modules/client/front/descriptor/index.html index f3d1d86b1..c30818226 100644 --- a/modules/client/front/descriptor/index.html +++ b/modules/client/front/descriptor/index.html @@ -54,7 +54,7 @@ + ng-class="{bright: $ctrl.client.debt > $ctrl.client.credit}"> + ng-class="{bright: $ctrl.ticket.client.debt > $ctrl.ticket.client.credit}"> { - if (res.data) + if (res.data) { this.ticket = res.data; + this.getDebt(res.data.client.id); + } }); } + getDebt(id) { + const query = `/ticket/api/Clients/${id}/getDebt`; + this.$http.get(query).then(res => { + if (res.data) + this.ticket.client.debt = res.data.debt; + }); + } reload() { this.getCard(); } diff --git a/modules/ticket/front/card/index.spec.js b/modules/ticket/front/card/index.spec.js index 912815e5d..886b30e53 100644 --- a/modules/ticket/front/card/index.spec.js +++ b/modules/ticket/front/card/index.spec.js @@ -21,8 +21,10 @@ describe('Ticket', () => { filter = encodeURIComponent(JSON.stringify(filter)); - $httpBackend.when('GET', `/ticket/api/Tickets/1?filter=${filter}`).respond({id: 1}); + $httpBackend.when('GET', `/ticket/api/Tickets/1?filter=${filter}`).respond({id: 1, client: {id: 1}}); $httpBackend.expect('GET', `/ticket/api/Tickets/1?filter=${filter}`); + $httpBackend.when('GET', `/ticket/api/Clients/1/getDebt`).respond(); + $httpBackend.expect('GET', `/ticket/api/Clients/1/getDebt`); controller.getCard(); $httpBackend.flush();