disable bic field for spanish iban

This commit is contained in:
Joan 2018-11-23 08:44:19 +01:00
parent 4e1d7e2822
commit 8e65d437ee
4 changed files with 21 additions and 3 deletions

View File

@ -43,7 +43,8 @@
search-function="{or: [{bic: {regexp: $search}}, {name: {regexp: $search}}]}" search-function="{or: [{bic: {regexp: $search}}, {name: {regexp: $search}}]}"
value-field="id" value-field="id"
show-field="bic" show-field="bic"
vn-acl="salesAssistant"> vn-acl="salesAssistant"
disabled="$ctrl.ibanCountry == 'ES'">
<tpl-item> <tpl-item>
<vn-horizontal> <vn-horizontal>
<vn-one>{{bic}}</vn-one> <vn-one>{{bic}}</vn-one>

View File

@ -76,14 +76,21 @@ export default class Controller {
return true; return true;
} }
get ibanCountry() {
if (!this.client || !this.client.iban) return false;
let countryCode = this.client.iban.substr(0, 2);
return countryCode;
}
autofillBic() { autofillBic() {
if (!this.client.iban) return; if (!this.client.iban) return;
let countryCode = this.client.iban.substr(0, 2);
let bankEntityId = parseInt(this.client.iban.substr(4, 4)); let bankEntityId = parseInt(this.client.iban.substr(4, 4));
let filter = {where: {id: bankEntityId}}; let filter = {where: {id: bankEntityId}};
if (countryCode != 'ES') return; if (this.ibanCountry != 'ES') return;
let json = encodeURIComponent(JSON.stringify(filter)); let json = encodeURIComponent(JSON.stringify(filter));
this.$http.get(`/client/api/BankEntities?filter=${json}`).then(response => { this.$http.get(`/client/api/BankEntities?filter=${json}`).then(response => {

View File

@ -136,5 +136,14 @@ describe('Client', () => {
expect(controller.client.bankEntityFk).toEqual(128); expect(controller.client.bankEntityFk).toEqual(128);
}); });
}); });
describe('ibanCountry()', () => {
it('should return a country code from iban', () => {
controller.client.iban = 'ES123';
let countryCode = controller.ibanCountry;
expect(countryCode).toEqual('ES');
});
});
}); });
}); });

View File

@ -26,6 +26,7 @@
<vn-icon-button <vn-icon-button
icon="check" icon="check"
vn-acl="administrative" vn-acl="administrative"
vn-acl-action="remove"
vn-tooltip="Confirm transaction" vn-tooltip="Confirm transaction"
ng-show="::!transaction.isConfirmed" ng-show="::!transaction.isConfirmed"
ng-click="$ctrl.confirm(transaction)"> ng-click="$ctrl.confirm(transaction)">