check bank entity refs 5834
gitea/salix/pipeline/head Build queued... Details

This commit is contained in:
Jorge Penadés 2023-11-03 09:15:41 +01:00
parent ce9fafdcab
commit 2cdebcd69f
7 changed files with 27 additions and 9 deletions

View File

@ -10,4 +10,20 @@ module.exports = Self => {
Self.validatesUniquenessOf('bic', {
message: 'This BIC already exist.'
});
Self.validateAsync('bic', checkBic, {
message: 'Bank entity id must be specified'
});
async function checkBic(err, done) {
const filter = {
fields: ['code'],
where: {id: this.countryFk}
};
const country = await Self.app.models.Country.findOne(filter);
const code = country ? country.code.toLowerCase() : null;
if (code == 'es' && !this.id)
err();
done();
}
};

View File

@ -41,7 +41,8 @@
vn-one
ng-show="country.selection.code === 'ES'"
label="Entity code"
ng-model="$ctrl.data.id">
ng-model="$ctrl.data.id"
required="true">
</vn-textfield>
</vn-horizontal>
</tpl-body>

View File

@ -10,7 +10,7 @@ class Controller extends Dialog {
if (!this.data.countryFk)
throw new Error(`The country can't be empty`);
return this.$http.post(`bankEntities`, this.data)
return this.$http.post(`BankEntities`, this.data)
.then(res => this.data.id = res.data.id)
.then(() => super.responseHandler(response))
.then(() => this.vnApp.showSuccess(this.$t('Data saved!')));

View File

@ -196,6 +196,7 @@
"Negative basis of tickets: 23": "Negative basis of tickets: 23",
"Booking completed": "Booking complete",
"The ticket is in preparation": "The ticket [{{ticketId}}]({{{ticketUrl}}}) of the sales person {{salesPersonId}} is in preparation",
"You can only add negative amounts in refund tickets": "You can only add negative amounts in refund tickets"
"You can only add negative amounts in refund tickets": "You can only add negative amounts in refund tickets",
"Bank entity must be specified": "Bank entity must be specified"
}

View File

@ -325,5 +325,7 @@
"Booking completed": "Reserva completada",
"The ticket is in preparation": "El ticket [{{ticketId}}]({{{ticketUrl}}}) del comercial {{salesPersonId}} está en preparación",
"The amount cannot be less than the minimum": "La cantidad no puede ser menor que la cantidad mímina",
"quantityLessThanMin": "La cantidad no puede ser menor que la cantidad mímina"
"quantityLessThanMin": "La cantidad no puede ser menor que la cantidad mímina",
"Bank entity must be specified": "La entidad bancaria es obligatoria"
}

View File

@ -51,15 +51,12 @@ export default class Controller extends Section {
autofillBic() {
if (!this.client || !this.client.iban) return;
let bankEntityId = parseInt(this.client.iban.substr(4, 4));
let filter = {where: {id: bankEntityId}};
if (this.ibanCountry != 'ES') return;
this.$http.get(`BankEntities`, {filter}).then(response => {
const hasData = response.data && response.data[0];
if (hasData)
this.client.bankEntityFk = response.data[0].id;
else if (!hasData)

View File

@ -30,7 +30,8 @@ export default class Controller extends Section {
}
autofillBic() {
if (!this.worker || !this.worker.iban) return;
AutoFillBicComponent.controller.prototype.autofillBic(this.client);
/* if (!this.worker || !this.worker.iban) return;
let bankEntityId = parseInt(this.worker.iban.substr(4, 4));
let filter = {where: {id: bankEntityId}};
@ -42,7 +43,7 @@ export default class Controller extends Section {
this.worker.bankEntityFk = response.data[0].id;
else if (!hasData)
this.worker.bankEntityFk = null;
});
}); */
}
generateCodeUser() {