Merge branch 'dev' of https://git.verdnatura.es/salix into dev

This commit is contained in:
Juan 2018-05-31 16:27:21 +02:00
commit f9c0d0d911
10 changed files with 92 additions and 49 deletions

View File

@ -65,12 +65,13 @@ describe('Client', () => {
it('should define the classificationId property of the controller and then call the show method()', () => {
controller.$scope.closeContract = {show: () => {}};
spyOn(controller.$scope.closeContract, 'show');
expect(controller.classificationId).toBeFalsy();
controller.closeContract({id: 1});
expect(controller.classificationId).toEqual(1);
expect(controller.$scope.closeContract.show).toHaveBeenCalledWith();
});
});
});
});
});

View File

@ -25,6 +25,7 @@ class Controller {
}
}
}
Controller.$inject = ['$http'];
ngModule.component('vnClientDescriptor', {

View File

@ -11,9 +11,9 @@
"component": "ui-view"
},
{
"url": "/list?q",
"state": "order.list",
"component": "vn-order-list"
"url": "/index?q",
"state": "order.index",
"component": "vn-order-index"
},
{
"url": "/create",

View File

@ -4,11 +4,9 @@ class Controller {
constructor($http, $state) {
this.$http = $http;
this.$state = $state;
this.ticket = null;
}
_getTicket() {
getTicket() {
let filter = {
include: [
{relation: 'warehouse', scope: {fields: ['name']}},
@ -16,7 +14,7 @@ class Controller {
{
relation: 'client',
scope: {
fields: ['salesPersonFk', 'name'],
fields: ['salesPersonFk', 'name', 'isActive', 'isFreezed', 'isTaxDataChecked'],
include: {
relation: 'salesPerson',
fields: ['firstName', 'name']
@ -35,21 +33,21 @@ class Controller {
}
]
};
let json = encodeURIComponent(JSON.stringify(filter));
this.$http.get(`/ticket/api/Tickets/${this.$state.params.id}?filter=${json}`)
.then(res => {
if (res.data)
this.ticket = res.data;
}
);
let query = `/ticket/api/Tickets/${this.$state.params.id}?filter=${json}`;
this.$http.get(query).then(res => {
if (res.data)
this.ticket = res.data;
});
}
$onInit() {
this._getTicket();
this.getTicket();
}
reload() {
this._getTicket();
this.getTicket();
}
}

View File

@ -8,31 +8,53 @@
<vn-icon icon="desktop_windows"></vn-icon>
</a>
</vn-horizontal>
<div pad-medium>
<h5>{{$ctrl.client.name}}</h5>
<vn-label-value label="Id"
value="{{$ctrl.ticket.id}}">
</vn-label-value>
<vn-label-value label="Client"
value="{{$ctrl.ticket.client.name}}">
</vn-label-value>
<vn-label-value label="State"
value="{{$ctrl.ticket.tracking.state.name}}">
</vn-label-value>
<vn-label-value label="Sales person"
value="{{$ctrl.ticket.client.salesPerson.firstName}} {{$ctrl.ticket.client.salesPerson.name}}">
</vn-label-value>
<vn-label-value label="Shipped"
value="{{$ctrl.ticket.shipped | date: 'dd/MM/yyyy HH:mm' }}">
</vn-label-value>
<vn-label-value label="Agency"
value="{{$ctrl.ticket.agencyMode.name}}">
</vn-label-value>
<vn-label-value label="Warehouse"
value="{{$ctrl.ticket.warehouse.name}}">
</vn-label-value>
<vn-label-value label="Alias"
value="{{$ctrl.ticket.nickname}}">
</vn-label-value>
</div>
<div pad-medium>
<h5>{{$ctrl.client.name}}</h5>
<vn-label-value label="Id"
value="{{$ctrl.ticket.id}}">
</vn-label-value>
<vn-label-value label="Client"
value="{{$ctrl.ticket.client.name}}">
</vn-label-value>
<vn-label-value label="State"
value="{{$ctrl.ticket.tracking.state.name}}">
</vn-label-value>
<vn-label-value label="Sales person"
value="{{$ctrl.ticket.client.salesPerson.firstName}} {{$ctrl.ticket.client.salesPerson.name}}">
</vn-label-value>
<vn-label-value label="Shipped"
value="{{$ctrl.ticket.shipped | date: 'dd/MM/yyyy HH:mm' }}">
</vn-label-value>
<vn-label-value label="Agency"
value="{{$ctrl.ticket.agencyMode.name}}">
</vn-label-value>
<vn-label-value label="Warehouse"
value="{{$ctrl.ticket.warehouse.name}}">
</vn-label-value>
<vn-label-value label="Alias"
value="{{$ctrl.ticket.nickname}}">
</vn-label-value>
</div>
<vn-horizontal pad-medium-bottom class="footer">
<vn-icon vn-one
vn-tooltip="Client inactive"
icon="icon-disabled"
ng-class="{bright: $ctrl.ticket.client.isActive == false}">
</vn-icon>
<vn-icon vn-one
vn-tooltip="Client Frozen"
icon="icon-frozen"
ng-class="{bright: $ctrl.ticket.client.isFreezed == true}">
</vn-icon>
<vn-icon vn-one
vn-tooltip="Client has debt"
icon="icon-risk"
ng-class="{bright: $ctrl.clientDebt > 0}">
</vn-icon>
<vn-icon vn-one
vn-tooltip="Client not checked"
icon="icon-no036"
ng-class="{bright: $ctrl.ticket.client.isTaxDataChecked == false}">
</vn-icon>
</vn-horizontal>
</vn-card>

View File

@ -1,8 +1,29 @@
import ngModule from '../module';
class Controller {
constructor($http) {
this.$http = $http;
}
getClientDebt(clientFk) {
this.$http.get(`/client/api/Clients/${clientFk}/getDebt`).then(response => {
this.clientDebt = response.data.debt;
});
}
$onChanges() {
if (this.ticket)
this.getClientDebt(this.ticket.clientFk);
}
}
Controller.$inject = ['$http'];
ngModule.component('vnTicketDescriptor', {
template: require('./index.html'),
bindings: {
ticket: '<'
}
},
controller: Controller
});

View File

@ -31,7 +31,7 @@ module.exports = Self => {
}
});
Self.send = async (recipient, data, ctx) => {
Self.send = async(recipient, data, ctx) => {
let query = `SELECT vn.messageSendWithUser(?, ?, ?) AS sent`;
let [result] = await Self.rawSql(query, [ctx.req.accessToken.userId, recipient, data.message]);

View File

@ -25,7 +25,7 @@ module.exports = Self => {
}
});
Self.priceDifference = async (ticketFk, data) => {
Self.priceDifference = async(ticketFk, data) => {
let filter = {
where: {
ticketFk: ticketFk

View File

@ -25,4 +25,4 @@ module.exports = Self => {
return taxes;
};
};
};

View File

@ -25,4 +25,4 @@ module.exports = Self => {
return total.amount ? total.amount : 0.00;
};
};
};