Postcode auto-fill fix
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
413283288f
commit
fd05455027
|
@ -52,7 +52,7 @@ export default class Controller extends Section {
|
||||||
if (!this.address.provinceFk)
|
if (!this.address.provinceFk)
|
||||||
this.address.provinceFk = province.id;
|
this.address.provinceFk = province.id;
|
||||||
|
|
||||||
if (postcodes.length === 1)
|
if (!this.address.postalCode && postcodes.length === 1)
|
||||||
this.address.postalCode = postcodes[0].code;
|
this.address.postalCode = postcodes[0].code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -128,7 +128,7 @@ export default class Controller extends Section {
|
||||||
if (!this.client.countryFk)
|
if (!this.client.countryFk)
|
||||||
this.client.countryFk = country.id;
|
this.client.countryFk = country.id;
|
||||||
|
|
||||||
if (postcodes.length === 1)
|
if (!this.client.postcode && postcodes.length === 1)
|
||||||
this.client.postcode = postcodes[0].code;
|
this.client.postcode = postcodes[0].code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,27 @@ module.exports = Self => {
|
||||||
message: 'Invalid TIN'
|
message: 'Invalid TIN'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Self.validatesLengthOf('postCode', {
|
||||||
|
allowNull: true,
|
||||||
|
allowBlank: true,
|
||||||
|
min: 3, max: 10
|
||||||
|
});
|
||||||
|
|
||||||
|
Self.validateAsync('postCode', hasValidPostcode, {
|
||||||
|
message: `The postcode doesn't exist. Please enter a correct one`
|
||||||
|
});
|
||||||
|
|
||||||
|
async function hasValidPostcode(err, done) {
|
||||||
|
if (!this.postcode)
|
||||||
|
return done();
|
||||||
|
|
||||||
|
const models = Self.app.models;
|
||||||
|
const postcode = await models.Postcode.findById(this.postcode);
|
||||||
|
|
||||||
|
if (!postcode) err();
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
|
||||||
async function tinIsValid(err, done) {
|
async function tinIsValid(err, done) {
|
||||||
const filter = {
|
const filter = {
|
||||||
fields: ['code'],
|
fields: ['code'],
|
||||||
|
|
|
@ -59,7 +59,7 @@
|
||||||
<vn-horizontal>
|
<vn-horizontal>
|
||||||
<vn-textfield
|
<vn-textfield
|
||||||
vn-one
|
vn-one
|
||||||
label="IBAN"
|
label="Account"
|
||||||
ng-model="$ctrl.supplier.account"
|
ng-model="$ctrl.supplier.account"
|
||||||
rule>
|
rule>
|
||||||
</vn-textfield>
|
</vn-textfield>
|
||||||
|
|
|
@ -38,7 +38,7 @@ export default class Controller extends Section {
|
||||||
if (!this.supplier.countryFk)
|
if (!this.supplier.countryFk)
|
||||||
this.supplier.countryFk = country.id;
|
this.supplier.countryFk = country.id;
|
||||||
|
|
||||||
if (postcodes.length === 1)
|
if (!this.supplier.postCode && postcodes.length === 1)
|
||||||
this.supplier.postCode = postcodes[0].code;
|
this.supplier.postCode = postcodes[0].code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue