insert mail
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
072f88d1a5
commit
488ef17559
|
@ -0,0 +1 @@
|
|||
DROP TRIGGER vn.supplierAccount_AfterInsert;
|
|
@ -1,4 +1,5 @@
|
|||
const validateIban = require('vn-loopback/util/validateIban');
|
||||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.validateAsync('iban', ibanValidation, {
|
||||
|
@ -19,4 +20,16 @@ module.exports = Self => {
|
|||
err();
|
||||
done();
|
||||
}
|
||||
Self.observe('after save', async ctx => {
|
||||
const loopBackContext = LoopBackContext.getCurrentContext();
|
||||
const models = Self.app.models;
|
||||
const user = await models.user.findById(loopBackContext.active.accessToken.userId);
|
||||
const bankEntity = await models.BankEntity.findById(ctx.instance.bankEntityFk);
|
||||
await Self.app.models.Mail.create({
|
||||
sender: 'finanzas@verdnatura.es',
|
||||
subject: 'Añadida cuenta bancaria al proveedor' + ctx.instance.supplierFk,
|
||||
body: user.username + ' ha añadido: ' +
|
||||
ctx.instance.iban + ', entidad: ' + bankEntity.name + ', bic: ' + bankEntity.bic
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue