hide empty left-menu, swift validation error
This commit is contained in:
parent
0b112b3d59
commit
0fa8608d47
|
@ -1,4 +1,4 @@
|
|||
<vn-card>
|
||||
<vn-card ng-if="$ctrl.items.length > 0">
|
||||
<vn-vertical pad-medium-top pad-medium-bottom>
|
||||
<vn-horizontal>
|
||||
<ul style="list-style-type: none; margin: 0; padding: 0; width: 100%;">
|
||||
|
|
|
@ -56,5 +56,6 @@
|
|||
"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 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"
|
||||
}
|
|
@ -25,15 +25,18 @@ module.exports = Self => {
|
|||
Self.validatesUniquenessOf('fi', {
|
||||
message: 'TIN must be unique'
|
||||
});
|
||||
|
||||
Self.validatesUniquenessOf('socialName', {
|
||||
message: 'The company name must be unique'
|
||||
});
|
||||
|
||||
Self.validatesFormatOf('email', {
|
||||
message: 'Invalid email',
|
||||
allowNull: true,
|
||||
allowBlank: true,
|
||||
with: /^[\w|.|-]+@[\w|-]+(\.[\w|-]+)*(,[\w|.|-]+@[\w|-]+(\.[\w|-]+)*)*$/
|
||||
});
|
||||
|
||||
Self.validatesLengthOf('postcode', {
|
||||
allowNull: true,
|
||||
allowBlank: true,
|
||||
|
@ -88,18 +91,6 @@ module.exports = Self => {
|
|||
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) {
|
||||
let changes = ctx.data || ctx.instance;
|
||||
let orgData = ctx.currentInstance;
|
||||
|
@ -140,6 +131,16 @@ module.exports = Self => {
|
|||
};
|
||||
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) {
|
||||
|
|
Loading…
Reference in New Issue