Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 2940-invoiceInTax-section
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
commit
48e6079527
|
@ -0,0 +1 @@
|
||||||
|
Delete me!
|
|
@ -1,8 +1,7 @@
|
||||||
<vn-crud-model
|
<vn-crud-model
|
||||||
vn-id="ticketsModel"
|
vn-id="ticketsModel"
|
||||||
auto-load="true"
|
|
||||||
url="Tickets"
|
url="Tickets"
|
||||||
link="{clientFk: $ctrl.$params.id}"
|
link="{clientFk: $ctrl.client.id}"
|
||||||
filter="::$ctrl.ticketFilter"
|
filter="::$ctrl.ticketFilter"
|
||||||
limit="5"
|
limit="5"
|
||||||
data="tickets"
|
data="tickets"
|
||||||
|
@ -297,8 +296,8 @@
|
||||||
<vn-th field="routeFk" expand>Route</vn-th>
|
<vn-th field="routeFk" expand>Route</vn-th>
|
||||||
<vn-th field="packages" shrink>Packages</vn-th>
|
<vn-th field="packages" shrink>Packages</vn-th>
|
||||||
<vn-th field="shipped" shrink-date>Date</vn-th>
|
<vn-th field="shipped" shrink-date>Date</vn-th>
|
||||||
<vn-th>State</vn-th>
|
<vn-th field="stateFk">State</vn-th>
|
||||||
<vn-th shrink>Total</vn-th>
|
<vn-th field="totalWithVat" shrink>Total</vn-th>
|
||||||
<vn-th></vn-th>
|
<vn-th></vn-th>
|
||||||
</vn-tr>
|
</vn-tr>
|
||||||
</vn-thead>
|
</vn-thead>
|
||||||
|
|
|
@ -33,10 +33,19 @@ class Controller extends Summary {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
$onChanges() {
|
get client() {
|
||||||
if (!this.client)
|
return this._client;
|
||||||
return;
|
}
|
||||||
|
|
||||||
|
set client(value) {
|
||||||
|
this._client = value;
|
||||||
|
if (value) {
|
||||||
|
this.loadData();
|
||||||
|
this.loadTickets();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
loadData() {
|
||||||
this.$http.get(`Clients/${this.client.id}/summary`).then(res => {
|
this.$http.get(`Clients/${this.client.id}/summary`).then(res => {
|
||||||
if (res && res.data) {
|
if (res && res.data) {
|
||||||
this.summary = res.data;
|
this.summary = res.data;
|
||||||
|
@ -49,6 +58,10 @@ class Controller extends Summary {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
loadTickets() {
|
||||||
|
this.$.$applyAsync(() => this.$.ticketsModel.refresh());
|
||||||
|
}
|
||||||
|
|
||||||
get isEmployee() {
|
get isEmployee() {
|
||||||
return this.aclService.hasAny(['employee']);
|
return this.aclService.hasAny(['employee']);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import './index';
|
import './index';
|
||||||
|
import crudModel from 'core/mocks/crud-model';
|
||||||
|
|
||||||
describe('Client', () => {
|
describe('Client', () => {
|
||||||
describe('Component vnClientSummary', () => {
|
describe('Component vnClientSummary', () => {
|
||||||
|
@ -13,17 +14,30 @@ describe('Client', () => {
|
||||||
$httpBackend = _$httpBackend_;
|
$httpBackend = _$httpBackend_;
|
||||||
const $element = angular.element('<vn-client-summary></vn-client-summary>');
|
const $element = angular.element('<vn-client-summary></vn-client-summary>');
|
||||||
controller = $componentController('vnClientSummary', {$element});
|
controller = $componentController('vnClientSummary', {$element});
|
||||||
controller.client = {id: 1101};
|
controller._client = {id: 1101};
|
||||||
|
controller.$.ticketsModel = crudModel;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
describe('$onChanges()', () => {
|
describe('client() setter', () => {
|
||||||
|
it('should call to the loadData() and loadTickets() methods', () => {
|
||||||
|
controller.loadData = jest.fn();
|
||||||
|
controller.loadTickets = jest.fn();
|
||||||
|
|
||||||
|
controller.client = {id: 1102};
|
||||||
|
|
||||||
|
expect(controller.loadData).toHaveBeenCalledWith();
|
||||||
|
expect(controller.loadTickets).toHaveBeenCalledWith();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('loadData()', () => {
|
||||||
it('should perform a GET query and then define the summary property', () => {
|
it('should perform a GET query and then define the summary property', () => {
|
||||||
let res = {name: 'Superman', classifications: []};
|
let res = {name: 'Superman', classifications: []};
|
||||||
|
|
||||||
jest.spyOn(controller, 'sumRisk').mockReturnThis();
|
jest.spyOn(controller, 'sumRisk').mockReturnThis();
|
||||||
$httpBackend.expect('GET', `Clients/1101/summary`).respond(200, res);
|
$httpBackend.expect('GET', `Clients/1101/summary`).respond(200, res);
|
||||||
|
|
||||||
controller.$onChanges();
|
controller.loadData();
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
|
||||||
expect(controller.summary).toBeDefined();
|
expect(controller.summary).toBeDefined();
|
||||||
|
@ -31,6 +45,17 @@ describe('Client', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('loadTickets()', () => {
|
||||||
|
it('should call to the model refresh() method', () => {
|
||||||
|
jest.spyOn(controller.$.ticketsModel, 'refresh');
|
||||||
|
|
||||||
|
controller.loadTickets();
|
||||||
|
controller.$.$apply();
|
||||||
|
|
||||||
|
expect(controller.$.ticketsModel.refresh).toHaveBeenCalledWith();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('sumRisk()', () => {
|
describe('sumRisk()', () => {
|
||||||
it('should sum property amount of an array', () => {
|
it('should sum property amount of an array', () => {
|
||||||
controller.summary = {
|
controller.summary = {
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
Buys: Compras
|
Buys: Compras
|
||||||
Delete buy(s): Eliminar compra(s)
|
Delete buy(s): Eliminar compra(s)
|
||||||
|
Add buy: Añadir compra
|
|
@ -1,7 +1,7 @@
|
||||||
<vn-crud-model
|
<vn-crud-model
|
||||||
vn-id="ticketsModel"
|
vn-id="ticketsModel"
|
||||||
|
url="InvoiceOuts/{{$ctrl.invoiceOut.id}}/getTickets"
|
||||||
limit="10"
|
limit="10"
|
||||||
auto-load="true"
|
|
||||||
data="tickets">
|
data="tickets">
|
||||||
</vn-crud-model>
|
</vn-crud-model>
|
||||||
<vn-card class="summary">
|
<vn-card class="summary">
|
||||||
|
|
|
@ -3,22 +3,26 @@ import Summary from 'salix/components/summary';
|
||||||
import './style.scss';
|
import './style.scss';
|
||||||
|
|
||||||
class Controller extends Summary {
|
class Controller extends Summary {
|
||||||
set invoiceOut(value) {
|
|
||||||
this._invoiceOut = value;
|
|
||||||
if (value && value.id) {
|
|
||||||
this.getSummary();
|
|
||||||
this.$.ticketsModel.url = `InvoiceOuts/${this.invoiceOut.id}/getTickets`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
get invoiceOut() {
|
get invoiceOut() {
|
||||||
return this._invoiceOut;
|
return this._invoiceOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
getSummary() {
|
set invoiceOut(value) {
|
||||||
return this.$http.get(`InvoiceOuts/${this.invoiceOut.id}/summary`)
|
this._invoiceOut = value;
|
||||||
|
if (value && value.id) {
|
||||||
|
this.loadData();
|
||||||
|
this.loadTickets();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
loadData() {
|
||||||
|
this.$http.get(`InvoiceOuts/${this.invoiceOut.id}/summary`)
|
||||||
.then(res => this.summary = res.data);
|
.then(res => this.summary = res.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
loadTickets() {
|
||||||
|
this.$.$applyAsync(() => this.$.ticketsModel.refresh());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ngModule.vnComponent('vnInvoiceOutSummary', {
|
ngModule.vnComponent('vnInvoiceOutSummary', {
|
||||||
|
|
|
@ -18,10 +18,10 @@ describe('InvoiceOut', () => {
|
||||||
controller.$.ticketsModel = crudModel;
|
controller.$.ticketsModel = crudModel;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
describe('getSummary()', () => {
|
describe('loadData()', () => {
|
||||||
it('should perform a query to set summary', () => {
|
it('should perform a query to set summary', () => {
|
||||||
$httpBackend.expect('GET', `InvoiceOuts/1/summary`).respond(200, 'the data you are looking for');
|
$httpBackend.expect('GET', `InvoiceOuts/1/summary`).respond(200, 'the data you are looking for');
|
||||||
controller.getSummary();
|
controller.loadData();
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
|
||||||
expect(controller.summary).toEqual('the data you are looking for');
|
expect(controller.summary).toEqual('the data you are looking for');
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
<vn-th field="provinceFk" class="expendable">Province</vn-th>
|
<vn-th field="provinceFk" class="expendable">Province</vn-th>
|
||||||
<vn-th field="stateFk">State</vn-th>
|
<vn-th field="stateFk">State</vn-th>
|
||||||
<vn-th field="zoneFk">Zone</vn-th>
|
<vn-th field="zoneFk">Zone</vn-th>
|
||||||
<vn-th shrink>Total</vn-th>
|
<vn-th field="totalWithVat" shrink>Total</vn-th>
|
||||||
<vn-th></vn-th>
|
<vn-th></vn-th>
|
||||||
</vn-tr>
|
</vn-tr>
|
||||||
</vn-thead>
|
</vn-thead>
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue