hide empty left-menu, swift validation error

This commit is contained in:
Joan Sanchez 2018-10-23 14:56:38 +02:00
parent 0b112b3d59
commit 0fa8608d47
3 changed files with 16 additions and 14 deletions

View File

@ -1,4 +1,4 @@
<vn-card> <vn-card ng-if="$ctrl.items.length > 0">
<vn-vertical pad-medium-top pad-medium-bottom> <vn-vertical pad-medium-top pad-medium-bottom>
<vn-horizontal> <vn-horizontal>
<ul style="list-style-type: none; margin: 0; padding: 0; width: 100%;"> <ul style="list-style-type: none; margin: 0; padding: 0; width: 100%;">

View File

@ -56,5 +56,6 @@
"The sales of this ticket can't be modified": "Los movimientos de este tiquet no pueden ser modificadas", "The sales of this ticket can't be modified": "Los movimientos de este tiquet no pueden ser modificadas",
"You can't create an order for a inactive client": "You can't create an order for a inactive client", "You can't create an order for a inactive client": "You can't create an order for a inactive client",
"You can't create an order for a client that doesn't has tax data verified": "You can't create an order for a client that doesn't has tax data verified", "You can't create an order for a client that doesn't has tax data verified": "You can't create an order for a client that doesn't has tax data verified",
"You don't have enough privileges": "You don't have enough privileges" "You don't have enough privileges": "You don't have enough privileges",
"That payment method requires a BIC": "That payment method requires a BIC"
} }

View File

@ -25,15 +25,18 @@ module.exports = Self => {
Self.validatesUniquenessOf('fi', { Self.validatesUniquenessOf('fi', {
message: 'TIN must be unique' message: 'TIN must be unique'
}); });
Self.validatesUniquenessOf('socialName', { Self.validatesUniquenessOf('socialName', {
message: 'The company name must be unique' message: 'The company name must be unique'
}); });
Self.validatesFormatOf('email', { Self.validatesFormatOf('email', {
message: 'Invalid email', message: 'Invalid email',
allowNull: true, allowNull: true,
allowBlank: true, allowBlank: true,
with: /^[\w|.|-]+@[\w|-]+(\.[\w|-]+)*(,[\w|.|-]+@[\w|-]+(\.[\w|-]+)*)*$/ with: /^[\w|.|-]+@[\w|-]+(\.[\w|-]+)*(,[\w|.|-]+@[\w|-]+(\.[\w|-]+)*)*$/
}); });
Self.validatesLengthOf('postcode', { Self.validatesLengthOf('postcode', {
allowNull: true, allowNull: true,
allowBlank: true, allowBlank: true,
@ -88,18 +91,6 @@ module.exports = Self => {
err(); err();
} }
Self.validateAsync('payMethodFk', hasIban, {
message: 'That payment method requires an IBAN'
});
function hasIban(err, done) {
Self.app.models.PayMethod.findById(this.payMethodFk, (_, instance) => {
if (instance && instance.ibanRequired && (!this.iban || !this.bankEntityFk))
err();
done();
});
}
Self.observe('before save', async function(ctx) { Self.observe('before save', async function(ctx) {
let changes = ctx.data || ctx.instance; let changes = ctx.data || ctx.instance;
let orgData = ctx.currentInstance; let orgData = ctx.currentInstance;
@ -140,6 +131,16 @@ module.exports = Self => {
}; };
await Self.app.models.ClientCredit.create(newCredit); await Self.app.models.ClientCredit.create(newCredit);
} }
if (finalState && finalState.payMethodFk) {
let payMethod = await Self.app.models.PayMethod.findById(finalState.payMethodFk);
if (payMethod && payMethod.ibanRequired && !finalState.iban)
throw new UserError('That payment method requires an IBAN');
if (payMethod && payMethod.ibanRequired && !finalState.bankEntityFk)
throw new UserError('That payment method requires a BIC');
}
}); });
async function validateCreditChange(ctx, finalState) { async function validateCreditChange(ctx, finalState) {