first step bankEntity
This commit is contained in:
parent
490c05f8a9
commit
6017894ba9
|
@ -0,0 +1 @@
|
||||||
|
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('SupplierAccount', '*', 'WRITE', 'ALLOW', 'ROLE', 'administrative');
|
|
@ -45,6 +45,11 @@
|
||||||
"type": "belongsTo",
|
"type": "belongsTo",
|
||||||
"model": "Supplier",
|
"model": "Supplier",
|
||||||
"foreignKey": "supplierFk"
|
"foreignKey": "supplierFk"
|
||||||
|
},
|
||||||
|
"bankEntity": {
|
||||||
|
"type": "belongsTo",
|
||||||
|
"model": "BankEntity",
|
||||||
|
"foreignKey": "bankEntityFk"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,75 @@
|
||||||
|
<vn-crud-model
|
||||||
|
vn-id="model"
|
||||||
|
url="SupplierAccounts"
|
||||||
|
fields="['id', 'supplierFk', 'iban', 'bankEntityFk']"
|
||||||
|
link="{bankEntityFk: $ctrl.$params.id}"
|
||||||
|
include="$ctrl.include"
|
||||||
|
data="$ctrl.supplierAccounts"
|
||||||
|
auto-load="true">
|
||||||
|
</vn-crud-model>
|
||||||
|
<vn-watcher
|
||||||
|
vn-id="watcher"
|
||||||
|
data="$ctrl.supplierAccounts"
|
||||||
|
form="form">
|
||||||
|
</vn-watcher>
|
||||||
|
<vn-crud-model
|
||||||
|
url="BankEntities"
|
||||||
|
fields="['countryFk','id','name', 'bic']"
|
||||||
|
data="bankEntities"
|
||||||
|
auto-load="true">
|
||||||
|
</vn-crud-model>
|
||||||
|
<form name="form" ng-submit="$ctrl.onSubmit()" class="vn-w-md">
|
||||||
|
<vn-card class="vn-pa-lg">
|
||||||
|
<vn-horizontal ng-repeat="supplierAccount in $ctrl.supplierAccounts">
|
||||||
|
<vn-autocomplete vn-two vn-focus
|
||||||
|
label="Bank entity"
|
||||||
|
initial-data="$ctrl.getName(bankEntity)"
|
||||||
|
ng-model="supplierAccount.bankEntityFk"
|
||||||
|
data="bankEntities"
|
||||||
|
on-change="$ctrl.getName(bankEntity)"
|
||||||
|
show-field="name"
|
||||||
|
rule>
|
||||||
|
</vn-autocomplete>
|
||||||
|
<append>
|
||||||
|
<vn-icon-button
|
||||||
|
icon="add_circle"
|
||||||
|
vn-tooltip="New bank entity"
|
||||||
|
ng-click="bankentity.open()">
|
||||||
|
</vn-icon-button>
|
||||||
|
</append>
|
||||||
|
<vn-textfield vn-three
|
||||||
|
ng-show="supplierAccount.iban || supplierAccount.iban == undefined"
|
||||||
|
label="Iban"
|
||||||
|
ng-model="supplierAccount.iban"
|
||||||
|
rule>
|
||||||
|
</vn-textfield>
|
||||||
|
<vn-none>
|
||||||
|
<vn-icon-button
|
||||||
|
vn-tooltip="Remove account"
|
||||||
|
icon="delete"
|
||||||
|
ng-click="model.remove($index)"
|
||||||
|
tabindex="-1">
|
||||||
|
</vn-icon-button>
|
||||||
|
</vn-none>
|
||||||
|
</vn-horizontal>
|
||||||
|
<vn-one>
|
||||||
|
<vn-icon-button
|
||||||
|
vn-bind="+"
|
||||||
|
vn-tooltip="Add account"
|
||||||
|
icon="add_circle"
|
||||||
|
ng-click="$ctrl.add()">
|
||||||
|
</vn-icon-button>
|
||||||
|
</vn-one>
|
||||||
|
</vn-card>
|
||||||
|
<vn-button-bar>
|
||||||
|
<vn-submit
|
||||||
|
disabled="!watcher.dataChanged()"
|
||||||
|
label="Save">
|
||||||
|
</vn-submit>
|
||||||
|
</vn-button-bar>
|
||||||
|
</form>
|
||||||
|
<!-- New bankentity dialog -->
|
||||||
|
<vn-new-bankentity
|
||||||
|
vn-id="bankentity"
|
||||||
|
on-response="$ctrl.onResponse($response)">
|
||||||
|
</vn-new-bankentity>
|
|
@ -0,0 +1,49 @@
|
||||||
|
import ngModule from '../module';
|
||||||
|
import Section from 'salix/components/section';
|
||||||
|
|
||||||
|
class Controller extends Section {
|
||||||
|
constructor($element, $) {
|
||||||
|
super($element, $);
|
||||||
|
this.include = {
|
||||||
|
relation: 'bankEntity',
|
||||||
|
scope: {
|
||||||
|
fields: ['countryFk', 'id', 'name', 'bic']
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
add() {
|
||||||
|
this.$.model.insert({
|
||||||
|
supplierFk: this.$params.id
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
onSubmit() {
|
||||||
|
this.$.watcher.check();
|
||||||
|
this.$.model.save().then(() => {
|
||||||
|
this.$.watcher.notifySaved();
|
||||||
|
this.$.watcher.updateOriginalData();
|
||||||
|
this.card.reload();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
showBankEntity(event) {
|
||||||
|
if (event.defaultPrevented) return;
|
||||||
|
event.preventDefault();
|
||||||
|
this.$.bankEntity.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
onBankEntityAccept() {
|
||||||
|
const query = `SupplierAccounts/${this.$params.id}/createBankEntity`;
|
||||||
|
return this.$http.patch(query, this.newBankEntity)
|
||||||
|
.then(res => this.supplierAccount.bankEntityFk = res.data.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ngModule.vnComponent('vnSupplierAccount', {
|
||||||
|
template: require('./index.html'),
|
||||||
|
controller: Controller,
|
||||||
|
require: {
|
||||||
|
card: '^vnSupplierCard'
|
||||||
|
}
|
||||||
|
});
|
|
@ -0,0 +1,34 @@
|
||||||
|
import './index.js';
|
||||||
|
import crudModel from 'core/mocks/crud-model';
|
||||||
|
|
||||||
|
describe('Item', () => {
|
||||||
|
describe('Component vnItemTags', () => {
|
||||||
|
let $scope;
|
||||||
|
let controller;
|
||||||
|
|
||||||
|
beforeEach(ngModule('item'));
|
||||||
|
|
||||||
|
beforeEach(inject(($componentController, $rootScope) => {
|
||||||
|
$scope = $rootScope.$new();
|
||||||
|
$scope.model = crudModel;
|
||||||
|
$scope.model.data = [{priority: 1}, {priority: 2}, {priority: 1}];
|
||||||
|
const $element = angular.element('<vn-item-tags></vn-item-tags>');
|
||||||
|
controller = $componentController('vnItemTags', {$element, $scope});
|
||||||
|
}));
|
||||||
|
|
||||||
|
describe('getHighestPriority', () => {
|
||||||
|
it('should return the highest priority value + 1 from the array', () => {
|
||||||
|
let result = controller.getHighestPriority();
|
||||||
|
|
||||||
|
expect(result).toEqual(3);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return 1 when there is no priority defined', () => {
|
||||||
|
$scope.model.data = [];
|
||||||
|
let result = controller.getHighestPriority();
|
||||||
|
|
||||||
|
expect(result).toEqual(1);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,2 @@
|
||||||
|
Bank entity: Entidad bancaria
|
||||||
|
swift: Swift BIC
|
|
@ -0,0 +1,40 @@
|
||||||
|
<vn-dialog class="edit"
|
||||||
|
vn-id="bankentityDialog"
|
||||||
|
on-open="$ctrl.onOpen()"
|
||||||
|
on-accept="$ctrl.onAccept()"
|
||||||
|
message="New bank entity">
|
||||||
|
<tpl-body>
|
||||||
|
<p translate>Please, ensure you put the correct data!</p>
|
||||||
|
<vn-horizontal>
|
||||||
|
<vn-textfield
|
||||||
|
vn-one
|
||||||
|
vn-focus
|
||||||
|
vn-id="entityname"
|
||||||
|
label="Name"
|
||||||
|
ng-model="$ctrl.location.name"
|
||||||
|
required="true">
|
||||||
|
</vn-textfield>
|
||||||
|
</vn-horizontal>
|
||||||
|
<vn-horizontal>
|
||||||
|
<vn-textfield
|
||||||
|
vn-one
|
||||||
|
vn-focus
|
||||||
|
vn-id="bic"
|
||||||
|
label="Swift"
|
||||||
|
ng-model="$ctrl.location.bic"
|
||||||
|
required="true">
|
||||||
|
</vn-textfield>
|
||||||
|
<vn-autocomplete vn-one
|
||||||
|
ng-model="$ctrl.location.countryFk"
|
||||||
|
url="Countries"
|
||||||
|
show-field="country"
|
||||||
|
value-field="id"
|
||||||
|
label="Country">
|
||||||
|
</vn-autocomplete>
|
||||||
|
</vn-horizontal>
|
||||||
|
</tpl-body>
|
||||||
|
<tpl-buttons>
|
||||||
|
<input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/>
|
||||||
|
<button id= "savePostcode" response="accept" translate>Save</button>
|
||||||
|
</tpl-buttons>
|
||||||
|
</vn-dialog>
|
|
@ -0,0 +1,42 @@
|
||||||
|
import ngModule from '../module';
|
||||||
|
import Component from 'core/lib/component';
|
||||||
|
import './style.scss';
|
||||||
|
|
||||||
|
class Controller extends Component {
|
||||||
|
open() {
|
||||||
|
this.$.bankentityDialog.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
onOpen() {
|
||||||
|
this.location = {};
|
||||||
|
this.$.bankentity.focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
onCountryResponse(response) {
|
||||||
|
this.location.countryFk = response.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
onAccept() {
|
||||||
|
try {
|
||||||
|
if (!this.location.countryFk)
|
||||||
|
throw new Error(`The country can't be empty`);
|
||||||
|
|
||||||
|
this.$http.patch(`bankentities`, this.location).then(() => {
|
||||||
|
this.vnApp.showMessage(this.$t('The bankentity has been created. You can save the data now'));
|
||||||
|
this.emit('response', {$response: this.location});
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
this.vnApp.showError(this.$t(e.message));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ngModule.vnComponent('vnNewBankentity', {
|
||||||
|
template: require('./index.html'),
|
||||||
|
controller: Controller,
|
||||||
|
bindings: {
|
||||||
|
data: '<',
|
||||||
|
}
|
||||||
|
});
|
|
@ -0,0 +1,34 @@
|
||||||
|
import './index';
|
||||||
|
|
||||||
|
describe('Supplier', () => {
|
||||||
|
describe('Component vnNewBankentity', () => {
|
||||||
|
let controller;
|
||||||
|
let $httpBackend;
|
||||||
|
let $scope;
|
||||||
|
|
||||||
|
beforeEach(ngModule('supplier'));
|
||||||
|
|
||||||
|
beforeEach(inject(($componentController, _$httpBackend_, $rootScope) => {
|
||||||
|
$httpBackend = _$httpBackend_;
|
||||||
|
$scope = $rootScope.$new();
|
||||||
|
const $element = angular.element('<vn-dialog></vn-dialog>');
|
||||||
|
controller = $componentController('vnNewBankentity', {$element, $scope});
|
||||||
|
controller.client = {id: 101};
|
||||||
|
}));
|
||||||
|
|
||||||
|
describe('onAccept()', () => {
|
||||||
|
it('should perform a POST query and show a success snackbar', () => {
|
||||||
|
let params = {countryFk: 1};
|
||||||
|
controller.location = {countryFk: 1};
|
||||||
|
|
||||||
|
jest.spyOn(controller.vnApp, 'showMessage');
|
||||||
|
$httpBackend.expect('PATCH', `bankentity`, params).respond(200, params);
|
||||||
|
|
||||||
|
controller.onAccept();
|
||||||
|
$httpBackend.flush();
|
||||||
|
|
||||||
|
expect(controller.vnApp.showMessage).toHaveBeenCalledWith('The bankentity has been created. You can save the data now');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,11 @@
|
||||||
|
New postcode: Nuevo código postal
|
||||||
|
New city: Nueva ciudad
|
||||||
|
New province: Nueva provincia
|
||||||
|
Please, ensure you put the correct data!: ¡Por favor, asegúrate de poner los datos correctos!
|
||||||
|
The postcode can't be empty: El código postal no puede quedar vacío
|
||||||
|
The town can't be empty: La población no puede quedar vacía
|
||||||
|
The province can't be empty: La provincia no puede quedar vacía
|
||||||
|
The country can't be empty: El país no puede quedar vacío
|
||||||
|
The postcode has been created. You can save the data now: Se ha creado el código postal. Ahora puedes guardar los datos
|
||||||
|
The city has been created: Se ha creado la ciudad
|
||||||
|
The province has been created: Se ha creado la provincia
|
|
@ -0,0 +1,9 @@
|
||||||
|
@import "variables";
|
||||||
|
|
||||||
|
vn-new-bankentity {
|
||||||
|
vn-dialog {
|
||||||
|
p {
|
||||||
|
color: $color-alert
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -8,6 +8,7 @@ import './search-panel';
|
||||||
import './summary';
|
import './summary';
|
||||||
import './basic-data';
|
import './basic-data';
|
||||||
import './fiscal-data';
|
import './fiscal-data';
|
||||||
|
import './account';
|
||||||
import './contact';
|
import './contact';
|
||||||
import './log';
|
import './log';
|
||||||
import './consumption';
|
import './consumption';
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
{"state": "supplier.index", "icon": "icon-supplier"}
|
{"state": "supplier.index", "icon": "icon-supplier"}
|
||||||
],
|
],
|
||||||
"card": [
|
"card": [
|
||||||
|
{"state": "supplier.card.account", "icon": "face"},
|
||||||
{"state": "supplier.card.basicData", "icon": "settings"},
|
{"state": "supplier.card.basicData", "icon": "settings"},
|
||||||
{"state": "supplier.card.fiscalData", "icon": "account_balance"},
|
{"state": "supplier.card.fiscalData", "icon": "account_balance"},
|
||||||
{"state": "supplier.card.billingData", "icon": "icon-payment"},
|
{"state": "supplier.card.billingData", "icon": "icon-payment"},
|
||||||
|
@ -96,6 +97,15 @@
|
||||||
"supplier": "$ctrl.supplier"
|
"supplier": "$ctrl.supplier"
|
||||||
},
|
},
|
||||||
"acl": ["administrative"]
|
"acl": ["administrative"]
|
||||||
|
},{
|
||||||
|
"url": "/account",
|
||||||
|
"state": "supplier.card.account",
|
||||||
|
"component": "vn-supplier-account",
|
||||||
|
"description": "Account",
|
||||||
|
"params": {
|
||||||
|
"supplier": "$ctrl.supplier"
|
||||||
|
},
|
||||||
|
"acl": ["administrative"]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
Loading…
Reference in New Issue