fixed billing data swift validations

This commit is contained in:
Joan 2018-11-22 15:17:35 +01:00
parent 29bea28dd3
commit 4e1d7e2822
4 changed files with 13 additions and 14 deletions

View File

@ -39,6 +39,7 @@
field="$ctrl.client.bankEntityFk"
fields="['name']"
initial-data="$ctrl.client.bankEntityFk"
on-change="$ctrl.autofillBic()"
search-function="{or: [{bic: {regexp: $search}}, {name: {regexp: $search}}]}"
value-field="id"
show-field="bic"

View File

@ -28,7 +28,6 @@ export default class Controller {
if (this.hasPaymethodChanges())
shouldNotify = true;
this.autofillBic();
this.$scope.watcher.submit().then(() => {
if (shouldNotify)
this.notifyChanges();
@ -87,10 +86,13 @@ export default class Controller {
if (countryCode != 'ES') return;
let json = encodeURIComponent(JSON.stringify(filter));
this.client.bankEntityFk = undefined;
this.$http.get(`/client/api/BankEntities?filter=${json}`).then(response => {
if (response.data && response.data[0])
const hasData = response.data && response.data[0];
if (hasData)
this.client.bankEntityFk = response.data[0].id;
else if (!hasData)
this.client.bankEntityFk = null;
});
}
}

View File

@ -15,24 +15,22 @@ export default class Textfield extends Input {
this.hasMouseIn = false;
this.input.addEventListener('keydown', () => {
if (!this.oldValue) {
if (!this.oldValue)
this.saveOldValue();
}
});
this.input.addEventListener('keyup', e => {
if (e.key == "Escape") {
if (e.key == 'Escape') {
this.value = this.oldValue;
this.cancelled = true;
e.stopPropagation();
}
if (e.key == "Escape" || e.key == "Enter")
if (e.key == 'Escape' || e.key == 'Enter')
this.input.blur();
});
this.input.addEventListener('blur', () => {
if (this.onChange && !this.cancelled &&
(this.oldValue && this.oldValue != this.value))
if (this.onChange && !this.cancelled && (this.oldValue != this.value))
this.onChange();
else
this.cancelled = false;

View File

@ -129,11 +129,9 @@ module.exports = Self => {
});
function hasBic(err, done) {
Self.app.models.PayMethod.findById(this.payMethodFk, (_, instance) => {
if (instance && instance.ibanRequired && !this.bankEntityFk)
err();
done();
});
if (this.iban && !this.bankEntityFk)
err();
done();
}
Self.observe('before save', async function(ctx) {