From 77d6da3a7f5d32805938659f21950221400b8e0b Mon Sep 17 00:00:00 2001 From: Gerard Date: Fri, 23 Nov 2018 08:21:21 +0100 Subject: [PATCH 1/4] =?UTF-8?q?#393=20validador=20del=20iban=20en=20client?= =?UTF-8?q?=20solo=20tiene=20que=20validar=20iban=20de=20Espa=C3=B1a?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- services/loopback/common/models/client.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/loopback/common/models/client.js b/services/loopback/common/models/client.js index 5b0be47f5..0341793a1 100644 --- a/services/loopback/common/models/client.js +++ b/services/loopback/common/models/client.js @@ -54,7 +54,7 @@ module.exports = Self => { }; let country = await Self.app.models.Country.findOne(filter); let code = country ? country.code.toLowerCase() : null; - if (code === 'fr') + if (code != 'es') return done(); if (!validateIban(this.iban)) From 04325f1b0f5ac817b87c82f4d34689562a0458f8 Mon Sep 17 00:00:00 2001 From: jgallego Date: Fri, 23 Nov 2018 08:40:39 +0100 Subject: [PATCH 2/4] bug de la fecha en Web Payment --- client/client/src/web-payment/index.html | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/client/client/src/web-payment/index.html b/client/client/src/web-payment/index.html index ec34bcd7a..f87f20fc7 100644 --- a/client/client/src/web-payment/index.html +++ b/client/client/src/web-payment/index.html @@ -32,9 +32,10 @@ {{::transaction.id}} - {{::transaction.amount | currency: ' €':2}} - {{::transaction.created | date:'dd/MM/yyyy'}} - + {{::transaction.amount | currency: '€':2}} + {{::transaction.created | dateTime:'dd/MM/yyyy'}} + + Date: Fri, 23 Nov 2018 08:44:19 +0100 Subject: [PATCH 3/4] 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 @@ From 0f4b6b85c14d1db2f30bfc5c75ea7276e8b46778 Mon Sep 17 00:00:00 2001 From: Gerard Date: Fri, 23 Nov 2018 08:56:53 +0100 Subject: [PATCH 4/4] test fixed --- client/order/src/create/card.spec.js | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/client/order/src/create/card.spec.js b/client/order/src/create/card.spec.js index 42ca110b1..3699f43a3 100644 --- a/client/order/src/create/card.spec.js +++ b/client/order/src/create/card.spec.js @@ -19,12 +19,6 @@ describe('Order', () => { })); describe('set order', () => { - it(`should not set order if the value given is null`, () => { - controller.order = null; - - expect(controller.order).toEqual({}); - }); - it(`should set order if the value given is not null`, () => { controller.order = 1; @@ -88,7 +82,7 @@ describe('Order', () => { $httpBackend.flush(); expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!'); - expect(controller.$state.go).toHaveBeenCalledWith("order.card.catalog", {id: 1}); + expect(controller.$state.go).toHaveBeenCalledWith('order.card.catalog', {id: 1}); }); }); });