supplier summary dscriptor and card
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
eba892766f
commit
256206ace4
|
@ -1,12 +1,12 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethod('getSummary', {
|
||||
description: 'Updates the item taxes',
|
||||
description: 'Return the claim summary',
|
||||
accessType: 'READ',
|
||||
accepts: [{
|
||||
arg: 'id',
|
||||
type: 'number',
|
||||
required: true,
|
||||
description: 'The item id',
|
||||
description: 'The claim id',
|
||||
http: {source: 'path'}
|
||||
}],
|
||||
returns: {
|
||||
|
|
|
@ -1,29 +1,29 @@
|
|||
{
|
||||
"name": "PayMethod",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "payMethod"
|
||||
"name": "PayMethod",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "payMethod"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "Number",
|
||||
"id": true,
|
||||
"description": "Identifier"
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"required": true
|
||||
},
|
||||
"graceDays": {
|
||||
"type": "string"
|
||||
},
|
||||
"outstandingDebt": {
|
||||
"type": "Number"
|
||||
},
|
||||
"ibanRequired": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "Number",
|
||||
"id": true,
|
||||
"description": "Identifier"
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"required": true
|
||||
},
|
||||
"graceDays": {
|
||||
"type": "string"
|
||||
},
|
||||
"outstandingDebt": {
|
||||
"type": "Number"
|
||||
},
|
||||
"ibanRequired": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,74 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethod('getSummary', {
|
||||
description: 'Returns the supplier summary',
|
||||
accessType: 'READ',
|
||||
accepts: {
|
||||
arg: 'id',
|
||||
type: 'number',
|
||||
required: true,
|
||||
description: 'The supplier id',
|
||||
http: {source: 'path'}
|
||||
},
|
||||
returns: {
|
||||
type: 'object',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/:id/getSummary`,
|
||||
verb: 'GET'
|
||||
}
|
||||
});
|
||||
Self.getSummary = async id => {
|
||||
let filter = {
|
||||
where: {id: id},
|
||||
fields: [
|
||||
'id',
|
||||
'name',
|
||||
'nickname',
|
||||
'isOfficial',
|
||||
'isActive',
|
||||
'note',
|
||||
'nif',
|
||||
'street',
|
||||
'city',
|
||||
'postCode',
|
||||
'provinceFk',
|
||||
'countryFk',
|
||||
'payMethodFk',
|
||||
'payDemFk',
|
||||
'payDay',
|
||||
'account',
|
||||
'isFarmer',
|
||||
],
|
||||
include: [
|
||||
{
|
||||
relation: 'province',
|
||||
scope: {
|
||||
fields: ['id', 'name']
|
||||
}
|
||||
},
|
||||
{
|
||||
relation: 'country',
|
||||
scope: {
|
||||
fields: ['id', 'name', 'code']
|
||||
}
|
||||
},
|
||||
{
|
||||
relation: 'payMethod',
|
||||
scope: {
|
||||
fields: ['id', 'name']
|
||||
}
|
||||
},
|
||||
{
|
||||
relation: 'payDem',
|
||||
scope: {
|
||||
fields: ['id', 'payDem']
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
let supplier = await Self.app.models.Supplier.findOne(filter);
|
||||
return supplier;
|
||||
};
|
||||
};
|
|
@ -1,5 +1,8 @@
|
|||
{
|
||||
"Supplier": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"PayDem": {
|
||||
"dataSource": "vn"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"name": "PayDem",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "payDem"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "Number",
|
||||
"id": true,
|
||||
"description": "Identifier"
|
||||
},
|
||||
"payDem": {
|
||||
"type": "Number"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,3 +1,4 @@
|
|||
module.exports = Self => {
|
||||
require('../methods/supplier/filter')(Self);
|
||||
require('../methods/supplier/getSummary')(Self);
|
||||
};
|
||||
|
|
|
@ -45,6 +45,12 @@
|
|||
"isActive": {
|
||||
"type": "Boolean"
|
||||
},
|
||||
"isOfficial": {
|
||||
"type": "Boolean"
|
||||
},
|
||||
"note": {
|
||||
"type": "String"
|
||||
},
|
||||
"street": {
|
||||
"type": "String"
|
||||
},
|
||||
|
@ -63,10 +69,35 @@
|
|||
"payDemFk": {
|
||||
"type": "Number"
|
||||
},
|
||||
"payDay": {
|
||||
"type": "Number"
|
||||
},
|
||||
"nickname": {
|
||||
"type": "String"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"payMethod": {
|
||||
"type": "belongsTo",
|
||||
"model": "PayMethod",
|
||||
"foreignKey": "payMethodFk"
|
||||
},
|
||||
"payDem": {
|
||||
"type": "belongsTo",
|
||||
"model": "PayDem",
|
||||
"foreignKey": "payDemFk"
|
||||
},
|
||||
"province": {
|
||||
"type": "belongsTo",
|
||||
"model": "Province",
|
||||
"foreignKey": "provinceFk"
|
||||
},
|
||||
"country": {
|
||||
"type": "belongsTo",
|
||||
"model": "Country",
|
||||
"foreignKey": "countryFk"
|
||||
}
|
||||
},
|
||||
"acls": [
|
||||
{
|
||||
"accessType": "READ",
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
<vn-portal slot="menu">
|
||||
<vn-supplier-descriptor supplier="$ctrl.supplier"></vn-entry-descriptor>
|
||||
<vn-left-menu source="card"></vn-left-menu>
|
||||
</vn-portal>
|
||||
<ui-view></ui-view>
|
|
@ -0,0 +1,42 @@
|
|||
import ngModule from '../module';
|
||||
import ModuleCard from 'salix/components/module-card';
|
||||
|
||||
class Controller extends ModuleCard {
|
||||
reload() {
|
||||
let filter = {
|
||||
include: [
|
||||
{
|
||||
relation: 'province',
|
||||
scope: {
|
||||
fields: ['id', 'name']
|
||||
}
|
||||
},
|
||||
{
|
||||
relation: 'country',
|
||||
scope: {
|
||||
fields: ['id', 'name', 'code']
|
||||
}
|
||||
},
|
||||
{
|
||||
relation: 'payMethod',
|
||||
scope: {
|
||||
fields: ['id', 'name']
|
||||
}
|
||||
},
|
||||
{
|
||||
relation: 'payDem',
|
||||
scope: {
|
||||
fields: ['id', 'payDem']
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
this.$http.get(`Suppliers/${this.$params.id}`, {filter})
|
||||
.then(response => this.supplier = response.data);
|
||||
}
|
||||
}
|
||||
|
||||
ngModule.vnComponent('vnSupplierCard', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller
|
||||
});
|
|
@ -0,0 +1,14 @@
|
|||
<vn-descriptor-content
|
||||
module="supplier"
|
||||
description="$ctrl.supplier.name">
|
||||
<slot-body>
|
||||
<div class="attributes">
|
||||
<vn-label-value label="Tax number"
|
||||
value="{{$ctrl.supplier.nif}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value label="Alias"
|
||||
value="{{$ctrl.supplier.nickname}}">
|
||||
</vn-label-value>
|
||||
</div>
|
||||
</slot-body>
|
||||
</vn-descriptor-content>
|
|
@ -0,0 +1,33 @@
|
|||
import ngModule from '../module';
|
||||
import Descriptor from 'salix/components/descriptor';
|
||||
|
||||
class Controller extends Descriptor {
|
||||
get supplier() {
|
||||
return this.entity;
|
||||
}
|
||||
|
||||
set supplier(value) {
|
||||
this.entity = value;
|
||||
}
|
||||
loadData() {
|
||||
const filter = {
|
||||
fields: [
|
||||
'id',
|
||||
'name',
|
||||
'nickname',
|
||||
'nif'
|
||||
]
|
||||
};
|
||||
|
||||
return this.getData(`Suppliers/${this.id}`, {filter})
|
||||
.then(res => this.entity = res.data);
|
||||
}
|
||||
}
|
||||
|
||||
ngModule.vnComponent('vnSupplierDescriptor', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller,
|
||||
bindings: {
|
||||
supplier: '<'
|
||||
}
|
||||
});
|
|
@ -0,0 +1,43 @@
|
|||
import './index.js';
|
||||
|
||||
describe('Entry Component vnEntryDescriptor', () => {
|
||||
let $httpBackend;
|
||||
let controller;
|
||||
const entry = {id: 2};
|
||||
|
||||
beforeEach(ngModule('entry'));
|
||||
|
||||
beforeEach(inject(($componentController, _$httpBackend_) => {
|
||||
$httpBackend = _$httpBackend_;
|
||||
controller = $componentController('vnEntryDescriptor', {$element: null}, {entry});
|
||||
}));
|
||||
|
||||
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}`;
|
||||
jest.spyOn(controller, 'getData');
|
||||
|
||||
$httpBackend.expectGET(query).respond();
|
||||
controller.loadData();
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(controller.getData).toHaveBeenCalledTimes(1);
|
||||
expect(controller.getData).toHaveBeenCalledWith(query, jasmine.any(Object));
|
||||
});
|
||||
});
|
||||
});
|
|
@ -0,0 +1 @@
|
|||
Tax number: NIF / CIF
|
|
@ -3,3 +3,6 @@ export * from './module';
|
|||
import './main';
|
||||
import './index/';
|
||||
import './search-panel';
|
||||
import './summary';
|
||||
import './card';
|
||||
import './descriptor';
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
"module": "supplier",
|
||||
"name": "Suppliers",
|
||||
"icon" : "icon-supplier",
|
||||
"dependencies": ["client", "item"],
|
||||
"validations" : true,
|
||||
"menus": {
|
||||
"main": [
|
||||
|
@ -22,6 +23,19 @@
|
|||
"state": "supplier.index",
|
||||
"component": "vn-supplier-index",
|
||||
"description": "Suppliers"
|
||||
}, {
|
||||
"url": "/:id",
|
||||
"state": "supplier.card",
|
||||
"abstract": true,
|
||||
"component": "vn-supplier-card"
|
||||
}, {
|
||||
"url": "/summary",
|
||||
"state": "supplier.card.summary",
|
||||
"component": "vn-supplier-summary",
|
||||
"description": "Summary",
|
||||
"params": {
|
||||
"supplier": "$ctrl.supplier"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
<vn-card class="summary">
|
||||
<h5>{{$ctrl.summary.name}} - {{$ctrl.summary.id}}</h5>
|
||||
<vn-horizontal>
|
||||
<vn-one>
|
||||
<h4 translate>Basic data</h4>
|
||||
<vn-label-value label="Id"
|
||||
value="{{$ctrl.summary.id}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value label="Supplier alias"
|
||||
value="{{$ctrl.summary.nickname}}">
|
||||
</vn-label-value>
|
||||
<vn-check
|
||||
label="Is official"
|
||||
ng-model="$ctrl.summary.isOfficial"
|
||||
disabled="true">
|
||||
</vn-check>
|
||||
<vn-check
|
||||
label="Is active"
|
||||
ng-model="$ctrl.summary.isActive"
|
||||
disabled="true">
|
||||
</vn-check>
|
||||
<vn-label-value label="Notes"
|
||||
value="{{$ctrl.summary.note}}">
|
||||
</vn-label-value>
|
||||
</vn-one>
|
||||
<vn-one>
|
||||
<h4 translate>Fiscal address</h4>
|
||||
<vn-label-value label="Social name"
|
||||
value="{{$ctrl.summary.name}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value label="NIF / CIF"
|
||||
value="{{$ctrl.summary.nif}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value label="Street" ellipsize="false"
|
||||
value="{{$ctrl.summary.street}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value label="City"
|
||||
value="{{$ctrl.summary.city}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value label="Postcode"
|
||||
value="{{$ctrl.summary.postcode}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value label="Province"
|
||||
value="{{$ctrl.summary.province.name}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value label="Country"
|
||||
value="{{$ctrl.summary.country.country}}">
|
||||
</vn-label-value>
|
||||
</vn-one>
|
||||
<vn-one>
|
||||
<h4 translate>Billing data</h4>
|
||||
<vn-label-value label="Pay method"
|
||||
value="{{$ctrl.summary.payMethod.name}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value label="Pay dem"
|
||||
value="{{$ctrl.summary.payDem.payDem}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value label="Pay day"
|
||||
value="{{$ctrl.summary.payDay}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value label="Account"
|
||||
value="{{$ctrl.summary.account}}">
|
||||
</vn-label-value>
|
||||
<vn-check
|
||||
label="Is Farmer"
|
||||
ng-model="$ctrl.summary.isFarmer"
|
||||
disabled="true">
|
||||
</vn-check>
|
||||
</vn-one>
|
||||
</vn-horizontal>
|
||||
</vn-card>
|
||||
<vn-worker-descriptor-popover
|
||||
vn-id="workerDescriptor">
|
||||
</vn-worker-descriptor-popover>
|
|
@ -0,0 +1,44 @@
|
|||
import ngModule from '../module';
|
||||
import Section from 'salix/components/section';
|
||||
import './style.scss';
|
||||
|
||||
class Controller extends Section {
|
||||
$onChanges() {
|
||||
if (!this.supplier)
|
||||
return;
|
||||
|
||||
this.getSummary();
|
||||
}
|
||||
|
||||
getSummary() {
|
||||
this.$http.get(`Suppliers/${this.supplier.id}/getSummary`).then(response => {
|
||||
this.summary = response.data;
|
||||
});
|
||||
}
|
||||
|
||||
// sumRisk() {
|
||||
// let total = 0;
|
||||
// this.summary.clientRisks.forEach(risk => {
|
||||
// total += risk.amount;
|
||||
// });
|
||||
// return total;
|
||||
// }
|
||||
|
||||
// claimRate(priceIncreasing) {
|
||||
// if (priceIncreasing)
|
||||
// return priceIncreasing * 100;
|
||||
// }
|
||||
|
||||
// claimingRate(rate) {
|
||||
// if (rate)
|
||||
// return rate * 100;
|
||||
// }
|
||||
}
|
||||
|
||||
ngModule.vnComponent('vnSupplierSummary', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller,
|
||||
bindings: {
|
||||
supplier: '<'
|
||||
}
|
||||
});
|
|
@ -0,0 +1,52 @@
|
|||
import './index';
|
||||
|
||||
describe('Client', () => {
|
||||
describe('Component vnClientSummary', () => {
|
||||
let controller;
|
||||
let $httpBackend;
|
||||
let $scope;
|
||||
|
||||
beforeEach(ngModule('client'));
|
||||
|
||||
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};
|
||||
}));
|
||||
|
||||
describe('$onChanges()', () => {
|
||||
it('should perform a GET query and then define the summary property', () => {
|
||||
let res = {name: 'Superman', classifications: []};
|
||||
|
||||
jest.spyOn(controller, 'sumRisk').mockReturnThis();
|
||||
$httpBackend.expect('GET', `Clients/101/summary`).respond(200, res);
|
||||
|
||||
controller.$onChanges();
|
||||
$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);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
|
@ -0,0 +1,7 @@
|
|||
@import "variables";
|
||||
|
||||
vn-client-summary {
|
||||
.alert span {
|
||||
color: $color-alert !important
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue