Merge branch 'dev' into 5013-observaciones_facturas
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Vicent Llopis 2023-03-24 09:37:13 +00:00
commit 91cc91716f
1 changed files with 25 additions and 25 deletions

View File

@ -1,7 +1,7 @@
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
const buildFilter = require('vn-loopback/util/filter').buildFilter;
const {mergeFilters, mergeWhere} = require('vn-loopback/util/filter');
const { mergeFilters, mergeWhere } = require('vn-loopback/util/filter');
module.exports = Self => {
Self.remoteMethodCtx('logs', {
@ -12,27 +12,27 @@ module.exports = Self => {
arg: 'id',
type: 'Number',
description: 'The claim id',
http: {source: 'path'}
http: { source: 'path' }
},
{
arg: 'filter',
type: 'object',
http: {source: 'query'}
http: { source: 'query' }
},
{
arg: 'search',
type: 'string',
http: {source: 'query'}
http: { source: 'query' }
},
{
arg: 'userFk',
type: 'number',
http: {source: 'query'}
http: { source: 'query' }
},
{
arg: 'created',
type: 'date',
http: {source: 'query'}
http: { source: 'query' }
},
],
returns: {
@ -45,7 +45,7 @@ module.exports = Self => {
}
});
Self.logs = async(ctx, id, filter, options) => {
Self.logs = async (ctx, id, filter, options) => {
const conn = Self.dataSource.connector;
const args = ctx.args;
const myOptions = {};
@ -59,22 +59,22 @@ module.exports = Self => {
case 'search':
return {
or: [
{changedModel: {like: `%${value}%`}},
{oldInstance: {like: `%${value}%`}}
{ changedModel: { like: `%${value}%` } },
{ oldInstance: { like: `%${value}%` } }
]
};
case 'userFk':
return {'cl.userFk': value};
return { 'cl.userFk': value };
case 'created':
value.setHours(0, 0, 0, 0);
to = new Date(value);
to.setHours(23, 59, 59, 999);
return {creationDate: {between: [value, to]}};
return { creationDate: { between: [value, to] } };
}
});
where = mergeWhere(where, {['cl.originFk']: id});
filter = mergeFilters(args.filter, {where});
where = mergeWhere(where, { ['cl.originFk']: id });
filter = mergeFilters(args.filter, { where });
const stmts = [];
@ -102,8 +102,8 @@ module.exports = Self => {
const logs = [];
for (const row of result) {
const changes = [];
const oldInstance = JSON.parse(row.oldInstance);
const newInstance = JSON.parse(row.newInstance);
const oldInstance = JSON.parse(row.oldInstance) || {};
const newInstance = JSON.parse(row.newInstance) || {};
const mergedProperties = [...Object.keys(oldInstance), ...Object.keys(newInstance)];
const properties = new Set(mergedProperties);
for (const property of properties) {