2022-10-24 07:37:17 +00:00
|
|
|
const LoopBackContext = require('loopback-context');
|
|
|
|
|
2017-12-04 07:17:29 +00:00
|
|
|
module.exports = function(Self) {
|
2018-05-04 09:46:03 +00:00
|
|
|
require('../methods/greuge/sumAmount')(Self);
|
2018-01-11 10:22:56 +00:00
|
|
|
|
2022-10-24 07:37:17 +00:00
|
|
|
Self.observe('before save', function(ctx, next) {
|
|
|
|
const loopBackContext = LoopBackContext.getCurrentContext();
|
|
|
|
|
|
|
|
let userFk = loopBackContext.active.accessToken.userId;
|
|
|
|
|
|
|
|
if (ctx.instance)
|
|
|
|
ctx.instance.userFk = userFk;
|
|
|
|
else
|
|
|
|
ctx.data.userFk = userFk;
|
|
|
|
|
|
|
|
next();
|
|
|
|
});
|
|
|
|
|
2018-01-11 10:22:56 +00:00
|
|
|
Self.validatesLengthOf('description', {
|
|
|
|
max: 45,
|
2018-08-02 07:49:00 +00:00
|
|
|
message: 'Description should have maximum of 45 characters'
|
2018-01-11 10:22:56 +00:00
|
|
|
});
|
2017-12-04 07:17:29 +00:00
|
|
|
};
|