From 8e65d437eedadbce5eaaa0b1497d4d6ee0f9759c Mon Sep 17 00:00:00 2001 From: Joan Date: Fri, 23 Nov 2018 08:44:19 +0100 Subject: [PATCH] disable bic field for spanish iban --- client/client/src/billing-data/index.html | 3 ++- client/client/src/billing-data/index.js | 11 +++++++++-- client/client/src/billing-data/index.spec.js | 9 +++++++++ client/client/src/web-payment/index.html | 1 + 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/client/client/src/billing-data/index.html b/client/client/src/billing-data/index.html index 579cd885c..99820fd04 100644 --- a/client/client/src/billing-data/index.html +++ b/client/client/src/billing-data/index.html @@ -43,7 +43,8 @@ search-function="{or: [{bic: {regexp: $search}}, {name: {regexp: $search}}]}" value-field="id" show-field="bic" - vn-acl="salesAssistant"> + vn-acl="salesAssistant" + disabled="$ctrl.ibanCountry == 'ES'"> {{bic}} diff --git a/client/client/src/billing-data/index.js b/client/client/src/billing-data/index.js index e5c666a4a..9fff88238 100644 --- a/client/client/src/billing-data/index.js +++ b/client/client/src/billing-data/index.js @@ -76,14 +76,21 @@ export default class Controller { return true; } + get ibanCountry() { + if (!this.client || !this.client.iban) return false; + + let countryCode = this.client.iban.substr(0, 2); + + return countryCode; + } + autofillBic() { if (!this.client.iban) return; - let countryCode = this.client.iban.substr(0, 2); let bankEntityId = parseInt(this.client.iban.substr(4, 4)); let filter = {where: {id: bankEntityId}}; - if (countryCode != 'ES') return; + if (this.ibanCountry != 'ES') return; let json = encodeURIComponent(JSON.stringify(filter)); this.$http.get(`/client/api/BankEntities?filter=${json}`).then(response => { diff --git a/client/client/src/billing-data/index.spec.js b/client/client/src/billing-data/index.spec.js index fe085aa7e..3fa509e01 100644 --- a/client/client/src/billing-data/index.spec.js +++ b/client/client/src/billing-data/index.spec.js @@ -136,5 +136,14 @@ describe('Client', () => { 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'); + }); + }); }); }); diff --git a/client/client/src/web-payment/index.html b/client/client/src/web-payment/index.html index 901a590d7..0156124c0 100644 --- a/client/client/src/web-payment/index.html +++ b/client/client/src/web-payment/index.html @@ -26,6 +26,7 @@