This commit is contained in:
Juan Ferrer 2019-01-16 15:48:26 +01:00
commit 114c9ded7f
5 changed files with 16 additions and 6 deletions

View File

@ -54,7 +54,7 @@
<vn-icon <vn-icon
vn-tooltip="Client has debt" vn-tooltip="Client has debt"
icon="icon-risk" icon="icon-risk"
ng-class="{bright: $ctrl.client.debt > 0}"> ng-class="{bright: $ctrl.client.debt > $ctrl.client.credit}">
</vn-icon> </vn-icon>
<vn-icon <vn-icon
vn-tooltip="Client not checked" vn-tooltip="Client not checked"

View File

@ -58,7 +58,7 @@
<vn-icon vn-one <vn-icon vn-one
vn-tooltip="Client has debt" vn-tooltip="Client has debt"
icon="icon-risk" icon="icon-risk"
ng-class="{bright: $ctrl.clientDebt > 0}"> ng-class="{bright: $ctrl.ticket.client.debt > $ctrl.ticket.client.credit}">
</vn-icon> </vn-icon>
<vn-icon vn-one <vn-icon vn-one
vn-tooltip="Client not checked" vn-tooltip="Client not checked"

View File

@ -58,7 +58,6 @@ class Controller {
} }
} }
get ticket() { get ticket() {
return this._ticket; return this._ticket;
} }

View File

@ -11,7 +11,7 @@ class Controller {
{ {
relation: 'client', relation: 'client',
scope: { scope: {
fields: ['salesPersonFk', 'name', 'isActive', 'isFreezed', 'isTaxDataChecked'], fields: ['salesPersonFk', 'name', 'isActive', 'isFreezed', 'isTaxDataChecked', 'credit'],
include: { include: {
relation: 'salesPerson', relation: 'salesPerson',
fields: ['firstName', 'name'], fields: ['firstName', 'name'],
@ -40,11 +40,20 @@ class Controller {
const json = encodeURIComponent(JSON.stringify(this.filter)); const json = encodeURIComponent(JSON.stringify(this.filter));
const query = `/ticket/api/Tickets/${this.$state.params.id}?filter=${json}`; const query = `/ticket/api/Tickets/${this.$state.params.id}?filter=${json}`;
this.$http.get(query).then(res => { this.$http.get(query).then(res => {
if (res.data) if (res.data) {
this.ticket = 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() { reload() {
this.getCard(); this.getCard();
} }

View File

@ -21,8 +21,10 @@ describe('Ticket', () => {
filter = encodeURIComponent(JSON.stringify(filter)); 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.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(); controller.getCard();
$httpBackend.flush(); $httpBackend.flush();