test, translate and supplier searpanel, summary
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Bernat Exposito Domenech 2020-10-26 08:38:43 +01:00
parent e3757e9191
commit 58168e78ab
21 changed files with 105 additions and 148 deletions

View File

@ -1,2 +0,0 @@
ALTER TABLE `vn`.`supplier`
ADD COLUMN `email` VARCHAR(45) NULL AFTER `isTrucker`;

View File

@ -1208,11 +1208,11 @@ INSERT INTO `vn`.`annualAverageInvoiced`(`clientFk`, `invoiced`)
(104, 500),
(105, 5000);
INSERT INTO `vn`.`supplier`(`id`, `name`, `nickname`,`account`,`countryFk`,`nif`,`isFarmer`,`retAccount`,`commission`, `created`, `postcodeFk`, `isActive`, `street`, `city`, `provinceFk`, `postCode`, `payMethodFk`, `payDemFk`, `phone`, `payDay`, `email`)
INSERT INTO `vn`.`supplier`(`id`, `name`, `nickname`,`account`,`countryFk`,`nif`,`isFarmer`,`retAccount`,`commission`, `created`, `postcodeFk`, `isActive`, `street`, `city`, `provinceFk`, `postCode`, `payMethodFk`, `payDemFk`, `payDay`)
VALUES
(1, 'Plants SL', 'Plants nick', 4000000001, 1, '06089160W', 0, NULL, 0, CURDATE(), 1111, 1, 'supplier address 1', 'PONTEVEDRA', 1, 15214, 1, 1, 123456789, 15, 'supplier_one@gmail.es'),
(2, 'Flower King', 'The king', 4000000002, 1, 'B22222222', 0, NULL, 0, CURDATE(), 2222, 1, 'supplier address 2', 'LONDON', 2, 45671, 1, 2, 987654321, 10, 'supplier_two@gmail.es'),
(442, 'Verdnatura Levante SL', 'Verdnatura', 4000000442, 1, 'C33333333', 0, NULL, 0, CURDATE(), 3333, 1, 'supplier address 3', 'SILLA', 1, 43022, 1, 2, 987123654, 15, 'supplier_three@gmail.es');
(1, 'Plants SL', 'Plants nick', 4000000001, 1, '06089160W', 0, NULL, 0, CURDATE(), 1111, 1, 'supplier address 1', 'PONTEVEDRA', 1, 15214, 1, 1, 15),
(2, 'Flower King', 'The king', 4000000002, 1, 'B22222222', 0, NULL, 0, CURDATE(), 2222, 1, 'supplier address 2', 'LONDON', 2, 45671, 1, 2, 10),
(442, 'Verdnatura Levante SL', 'Verdnatura', 4000000442, 1, 'C33333333', 0, NULL, 0, CURDATE(), 3333, 1, 'supplier address 3', 'SILLA', 1, 43022, 1, 2, 15);
INSERT INTO `cache`.`cache_calc`(`id`, `cache_id`, `cacheName`, `params`, `last_refresh`, `expires`, `created`, `connection_id`)
VALUES

View File

@ -56,7 +56,7 @@ describe('Update Claim', () => {
hasToPickUp: false
}
};
await app.models.Claim.updateClaim(ctx, newClaim.id,);
await app.models.Claim.updateClaim(ctx, newClaim.id);
let updatedClaim = await app.models.Claim.findById(newClaim.id);

View File

@ -186,12 +186,6 @@
"model": "BankEntity",
"foreignKey": "bankEntityFk"
},
"supplier": {
"type": "belongsTo",
"model": "Supplier",
"foreignKey": "fi",
"primaryKey": "nif"
},
"defaulters": {
"type": "hasMany",
"model": "Defaulter",

View File

@ -51,7 +51,7 @@ describe('Client', () => {
}
};
const serializedParams = $httpParamSerializer({filter});
$httpBackend.expect('GET', `ClientRisks?${serializedParams}`,).respond([{amount: 20}]);
$httpBackend.expect('GET', `ClientRisks?${serializedParams}`).respond([{amount: 20}]);
controller.getAmountPaid();
$httpBackend.flush();
@ -65,7 +65,7 @@ describe('Client', () => {
controller.$params = {id: 101};
$httpBackend.expect('POST', `Receipts`,).respond({id: 1});
$httpBackend.expect('POST', `Receipts`).respond({id: 1});
controller.responseHandler('accept');
$httpBackend.flush();

View File

@ -18,7 +18,7 @@ describe('Component vnOrderIndex', () => {
beforeEach(ngModule('order'));
beforeEach(inject(($componentController, _$window_,) => {
beforeEach(inject(($componentController, _$window_) => {
$window = _$window_;
const $element = angular.element('<vn-order-index></vn-order-index>');
controller = $componentController('vnOrderIndex', {$element});

View File

@ -1,25 +0,0 @@
module.exports = Self => {
Self.remoteMethod('isAClient', {
description: 'Returns the supplier summary',
accessType: 'READ',
accepts: {
arg: 'nif',
type: 'string',
required: true,
description: 'The supplier nif',
http: {source: 'path'}
},
returns: {
type: 'object',
root: true
},
http: {
path: `/:nif/isAClient`,
verb: 'GET'
}
});
Self.isAClient = async nif => {
const client = await Self.app.models.Client.findOne({where: {fi: nif}});
return client;
};
};

View File

@ -1,28 +1,28 @@
const app = require('vn-loopback/server/server');
describe('Supplier getSummary()', () => {
// it('should return the supplier matching "search"', async() => {
// let ctx = {
// args: {
// search: 1
// }
// };
it('should return a summary object containing data from one supplier', async() => {
const supplier = await app.models.Supplier.getSummary(1);
// let result = await app.models.Supplier.filter(ctx);
expect(supplier.id).toEqual(1);
expect(supplier.name).toEqual('Plants SL');
expect(supplier.nif).toEqual('06089160W');
});
// expect(result.length).toEqual(1);
// expect(result[0].id).toEqual(1);
// });
it(`should return a summary object containing it's supplier country`, async() => {
const supplier = await app.models.Supplier.getSummary(1);
const country = supplier.country();
// it('should return the supplier matching the province', async() => {
// let ctx = {
// args: {
// provinceFk: 1
// }
// };
expect(country.id).toEqual(1);
expect(country.code).toEqual('ES');
});
// let result = await app.models.Supplier.filter(ctx);
it(`should return a summary object containing it's billing data`, async() => {
const supplier = await app.models.Supplier.getSummary(1);
const payMethod = supplier.payMethod();
// expect(result.length).toEqual(2);
// });
expect(supplier.account).toEqual(4000000001);
expect(supplier.payDay).toEqual(15);
expect(payMethod.name).toEqual('PayMethod one');
});
});

View File

@ -1,5 +1,4 @@
module.exports = Self => {
require('../methods/supplier/filter')(Self);
require('../methods/supplier/getSummary')(Self);
require('../methods/supplier/isAClient')(Self);
};

View File

@ -100,8 +100,8 @@
"client": {
"type": "belongsTo",
"model": "Client",
"foreignKey": "fi",
"primaryKey": "nif"
"foreignKey": "nif",
"primaryKey": "fi"
}
},
"acls": [

View File

@ -44,9 +44,9 @@
</div>
<div ng-transclude="btnTwo">
<vn-quick-link
ng-if="$ctrl.isAClient"
ng-if="$ctrl.supplier.client.fi"
tooltip="Go to client"
state="['client.card.summary', {id: $ctrl.isAClient.id}]"
state="['client.card.summary', {id: $ctrl.supplier.client.id}]"
icon="person">
</vn-quick-link>
</div>

View File

@ -8,8 +8,6 @@ class Controller extends Descriptor {
set supplier(value) {
this.entity = value;
console.log('this.entity', this.entity);
// this.iSupplierAClient();
}
get entryFilter() {
@ -30,22 +28,6 @@ class Controller extends Descriptor {
to
});
}
// iSupplierAClient() {
// if (!this.supplier) return;
// const filter = {
// where: {fi: this.supplier.nif}
// };
// this.$http.get('Clients/findOne', {filter}).then(res => {
// if (res.data)
// this.isAClient = res.data;
// }).catch(error => {
// return this.isAClient = false;
// });
// // this.$http.get(`Suppliers/${this.supplier.nif}/isAClient`).then(res => {
// // this.isAClient = res.data;
// // });
// }
loadData() {
const filter = {
@ -83,8 +65,8 @@ class Controller extends Descriptor {
]
};
return this.getData(`Suppliers/${this.id}`, {filter})
.then(res => this.entity = res.data);
return this.getData(`Suppliers/${this.supplier.id}`, {filter})
.then(res => this.supplier = res.data);
}
}

View File

@ -1,43 +1,64 @@
import './index.js';
describe('Entry Component vnEntryDescriptor', () => {
describe('Supplier Component vnSupplierDescriptor', () => {
let $httpBackend;
let controller;
const entry = {id: 2};
let $httpParamSerializer;
const supplier = {id: 1};
beforeEach(ngModule('entry'));
beforeEach(ngModule('supplier'));
beforeEach(inject(($componentController, _$httpBackend_) => {
beforeEach(inject(($componentController, _$httpBackend_, _$httpParamSerializer_) => {
$httpBackend = _$httpBackend_;
controller = $componentController('vnEntryDescriptor', {$element: null}, {entry});
$httpParamSerializer = _$httpParamSerializer_;
controller = $componentController('vnSupplierDescriptor', {$element: null}, {supplier});
}));
describe('showEntryReport()', () => {
it('should open a new window showing a delivery note PDF document', () => {
jest.spyOn(controller.vnReport, 'show');
window.open = jasmine.createSpy('open');
const params = {
clientId: controller.vnConfig.storage.currentUserWorkerId,
entryId: entry.id
};
controller.showEntryReport();
expect(controller.vnReport.show).toHaveBeenCalledWith('entry-order', params);
});
});
describe('loadData()', () => {
it('should perform ask for the entry', () => {
let query = `Entries/${entry.id}`;
it('should perform ask for the supplier', () => {
const filter = {
fields: [
'id',
'name',
'nickname',
'nif',
'payMethodFk',
'payDemFk',
'payDay',
'isActive',
'isOfficial',
'account'
],
include: [
{
relation: 'payMethod',
scope: {
fields: ['id', 'name']
}
},
{
relation: 'payDem',
scope: {
fields: ['id', 'payDem']
}
},
{
relation: 'client',
scope: {
fields: ['id', 'fi']
}
}
]
};
const serializedParams = $httpParamSerializer({filter});
let query = `Suppliers/${controller.supplier.id}?${serializedParams}`;
jest.spyOn(controller, 'getData');
$httpBackend.expectGET(query).respond();
$httpBackend.expect('GET', query).respond({id: 1});
controller.loadData();
$httpBackend.flush();
expect(controller.getData).toHaveBeenCalledTimes(1);
expect(controller.getData).toHaveBeenCalledWith(query, jasmine.any(Object));
});
});
});

View File

@ -1 +1,3 @@
Tax number: NIF / CIF
Tax number: NIF / CIF
All entries with current supplier: Todas las entradas con el proveedor actual
Go to client: Ir al cliente

View File

@ -8,7 +8,7 @@
<vn-searchbar
vn-focus
panel="vn-supplier-search-panel"
info="Search suppliers by id name or alias"
info="Search suppliers by id, name or alias"
model="model">
</vn-searchbar>
</vn-portal>

View File

@ -5,7 +5,7 @@
vn-one
label="General search"
ng-model="filter.search"
info="Search suppliers by id name or alias"
info="Search suppliers by id, name or alias"
vn-focus>
</vn-textfield>
</vn-horizontal>

View File

@ -1,3 +1,4 @@
Province: Provincia
Country: País
Tax number: Nif
Tax number: Nif
Search suppliers by id, name or alias: Busca proveedores por el id, el nombre o el alias

View File

@ -6,7 +6,7 @@
<vn-label-value label="Id"
value="{{$ctrl.summary.id}}">
</vn-label-value>
<vn-label-value label="Supplier alias"
<vn-label-value label="Alias"
value="{{$ctrl.summary.nickname}}">
</vn-label-value>
<vn-check
@ -52,7 +52,7 @@
<vn-label-value label="Pay method"
value="{{$ctrl.summary.payMethod.name}}">
</vn-label-value>
<vn-label-value label="Pay dem"
<vn-label-value label="Payment deadline"
value="{{$ctrl.summary.payDem.payDem}}">
</vn-label-value>
<vn-label-value label="Pay day"

View File

@ -11,7 +11,7 @@ class Controller extends Section {
}
getSummary() {
this.$http.get(`Suppliers/${this.supplier.id}/getSummary`).then(response => {
return this.$http.get(`Suppliers/${this.supplier.id}/getSummary`).then(response => {
this.summary = response.data;
});
}

View File

@ -1,51 +1,31 @@
import './index';
describe('Client', () => {
describe('Component vnClientSummary', () => {
describe('Supplier', () => {
describe('Component vnSupplierSummary', () => {
let controller;
let $httpBackend;
let $scope;
beforeEach(ngModule('client'));
beforeEach(ngModule('supplier'));
beforeEach(inject(($componentController, _$httpBackend_, $rootScope) => {
$httpBackend = _$httpBackend_;
$scope = $rootScope.$new();
const $element = angular.element('<vn-client-summary></vn-client-summary>');
controller = $componentController('vnClientSummary', {$element, $scope});
controller.client = {id: 101};
const $element = angular.element('<vn-supplier-summary></vn-supplier-summary>');
controller = $componentController('vnSupplierSummary', {$element, $scope});
}));
describe('$onChanges()', () => {
it('should perform a GET query and then define the summary property', () => {
let res = {name: 'Superman', classifications: []};
describe('getSummary()', () => {
it('should perform a get asking for the supplier data', () => {
controller.supplier = {id: 1};
jest.spyOn(controller, 'sumRisk').mockReturnThis();
$httpBackend.expect('GET', `Clients/101/summary`).respond(200, res);
const query = `Suppliers/${controller.supplier.id}/getSummary`;
controller.$onChanges();
$httpBackend.expectGET(query).respond({id: 1});
controller.getSummary();
$httpBackend.flush();
expect(controller.summary).toBeDefined();
expect(controller.summary.name).toEqual('Superman');
});
});
describe('sumRisk()', () => {
it('should sum property amount of an array', () => {
controller.summary = {
clientRisks: [{
companyFk: 442,
amount: 100
},
{
companyFk: 567,
amount: 200
}]};
let result = controller.sumRisk();
expect(result).toEqual(300);
expect(controller.summary).toEqual({id: 1});
});
});
});

View File

@ -0,0 +1,5 @@
Is official: Es oficial
Country: País
Tax number: Nif
Search suppliers by id, name or alias: Busca proveedores por el id, el nombre o el alias
Is Farmer: Es agrícola