ver "0.5.8"
Lista movimenti in formato Tabella
This commit is contained in:
@@ -17,9 +17,9 @@ mongoose.plugin(schema => {
|
|||||||
const MovementSchema = new Schema({
|
const MovementSchema = new Schema({
|
||||||
_id: {
|
_id: {
|
||||||
type: String,
|
type: String,
|
||||||
default: function () {
|
default: function() {
|
||||||
return new ObjectID().toString()
|
return new ObjectID().toString();
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
idapp: {
|
idapp: {
|
||||||
type: String,
|
type: String,
|
||||||
@@ -74,7 +74,8 @@ MovementSchema.pre('save', async function(next) {
|
|||||||
|
|
||||||
MovementSchema.statics.getFieldsForSearch = function() {
|
MovementSchema.statics.getFieldsForSearch = function() {
|
||||||
return [
|
return [
|
||||||
{field: 'nome_conto', type: tools.FieldType.string},
|
{field: 'causal', type: tools.FieldType.string},
|
||||||
|
{field: 'amount', type: tools.FieldType.number},
|
||||||
];
|
];
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -176,26 +177,26 @@ MovementSchema.statics.getQueryMovsByCircuitId = async function(idapp, username,
|
|||||||
},
|
},
|
||||||
{$unwind: '$accto'},
|
{$unwind: '$accto'},
|
||||||
{
|
{
|
||||||
"$lookup": {
|
'$lookup': {
|
||||||
"from": "circuits",
|
'from': 'circuits',
|
||||||
"localField": "accfrom.circuitId",
|
'localField': 'accfrom.circuitId',
|
||||||
"foreignField": "_id",
|
'foreignField': '_id',
|
||||||
"as": "circuitfrom"
|
'as': 'circuitfrom',
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"$unwind": "$circuitfrom"
|
'$unwind': '$circuitfrom',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"$lookup": {
|
'$lookup': {
|
||||||
"from": "circuits",
|
'from': 'circuits',
|
||||||
"localField": "accto.circuitId",
|
'localField': 'accto.circuitId',
|
||||||
"foreignField": "_id",
|
'foreignField': '_id',
|
||||||
"as": "circuitto"
|
'as': 'circuitto',
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"$unwind": "$circuitto"
|
'$unwind': '$circuitto',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
$lookup: {
|
$lookup: {
|
||||||
@@ -247,6 +248,151 @@ MovementSchema.statics.getQueryMovsByCircuitId = async function(idapp, username,
|
|||||||
return [];
|
return [];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
MovementSchema.statics.getQueryAllUsersMovsByCircuitId = async function(idapp, circuitId) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (!circuitId) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
let aggr1 = [
|
||||||
|
{
|
||||||
|
$match: {
|
||||||
|
idapp,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$lookup: {
|
||||||
|
from: 'accounts',
|
||||||
|
localField: 'accountFromId',
|
||||||
|
foreignField: '_id',
|
||||||
|
as: 'accfrom',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{$unwind: '$accfrom'},
|
||||||
|
{
|
||||||
|
$lookup: {
|
||||||
|
from: 'users',
|
||||||
|
let: {username: '$accfrom.username', idapp: '$accfrom.idapp'},
|
||||||
|
pipeline: [
|
||||||
|
{
|
||||||
|
$match:
|
||||||
|
{
|
||||||
|
$expr:
|
||||||
|
{
|
||||||
|
$and:
|
||||||
|
[
|
||||||
|
{$eq: ['$$username', '$username']},
|
||||||
|
{$eq: ['$$idapp', '$idapp']},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
as: 'userfrom',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$unwind: {
|
||||||
|
path: '$userfrom',
|
||||||
|
preserveNullAndEmptyArrays: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$lookup: {
|
||||||
|
from: 'accounts',
|
||||||
|
localField: 'accountToId',
|
||||||
|
foreignField: '_id',
|
||||||
|
as: 'accto',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$unwind: {
|
||||||
|
path: '$accto',
|
||||||
|
preserveNullAndEmptyArrays: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'$lookup': {
|
||||||
|
'from': 'circuits',
|
||||||
|
'localField': 'accfrom.circuitId',
|
||||||
|
'foreignField': '_id',
|
||||||
|
'as': 'circuitfrom',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$unwind: {
|
||||||
|
path: '$circuitfrom',
|
||||||
|
preserveNullAndEmptyArrays: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'$lookup': {
|
||||||
|
'from': 'circuits',
|
||||||
|
'localField': 'accto.circuitId',
|
||||||
|
'foreignField': '_id',
|
||||||
|
'as': 'circuitto',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$unwind: {
|
||||||
|
path: '$circuitto',
|
||||||
|
preserveNullAndEmptyArrays: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$lookup: {
|
||||||
|
from: 'users',
|
||||||
|
let: {username: '$accto.username', idapp: '$accto.idapp'},
|
||||||
|
pipeline: [
|
||||||
|
{
|
||||||
|
$match:
|
||||||
|
{
|
||||||
|
$expr:
|
||||||
|
{
|
||||||
|
$and:
|
||||||
|
[
|
||||||
|
{$eq: ['$$username', '$username']},
|
||||||
|
{$eq: ['$$idapp', '$idapp']},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
as: 'userto',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$unwind: {
|
||||||
|
path: '$userto',
|
||||||
|
preserveNullAndEmptyArrays: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$project:
|
||||||
|
{
|
||||||
|
transactionDate: 1,
|
||||||
|
amount: 1,
|
||||||
|
causal: 1,
|
||||||
|
'circuitfrom.symbol': 1,
|
||||||
|
'circuitto.symbol': 1,
|
||||||
|
'userfrom.username': 1,
|
||||||
|
'userfrom.profile.img': 1,
|
||||||
|
'userto.username': 1,
|
||||||
|
'userto.profile.img': 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
return aggr1;
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return [];
|
||||||
|
};
|
||||||
|
|
||||||
MovementSchema.statics.getMovsByCircuitId = async function(idapp, username, circuitId) {
|
MovementSchema.statics.getMovsByCircuitId = async function(idapp, username, circuitId) {
|
||||||
const MyMovement = this;
|
const MyMovement = this;
|
||||||
|
|
||||||
|
|||||||
@@ -1938,19 +1938,14 @@ module.exports = {
|
|||||||
|
|
||||||
query.push(...myquery);
|
query.push(...myquery);
|
||||||
|
|
||||||
/*} else if (params.table === 'circuits') {
|
} else if (params.querytype === shared_consts.QUERYTYPE_LIST_ALLMOVEMENTS) {
|
||||||
const qacirc = this.getLookup(
|
|
||||||
{
|
const {Movement} = require('../models/movement');
|
||||||
lk_tab: 'accounts',
|
|
||||||
lk_LF: 'circuitId',
|
const myquery = await Movement.getQueryAllUsersMovsByCircuitId(params.idapp, params.myid);
|
||||||
lk_FF: '_id',
|
|
||||||
lk_as: 'account',
|
query.push(...myquery);
|
||||||
}, 0, {
|
|
||||||
'acc': 1,
|
|
||||||
});
|
|
||||||
if (qacirc) query = [...query, ...qacirc];
|
|
||||||
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newvers) {
|
if (newvers) {
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ module.exports = {
|
|||||||
QUERYTYPE_CIRCUIT: 10,
|
QUERYTYPE_CIRCUIT: 10,
|
||||||
QUERYTYPE_REFUSED_USER_CIRCUIT: 12,
|
QUERYTYPE_REFUSED_USER_CIRCUIT: 12,
|
||||||
QUERYTYPE_LIST_MOVEMENTS: 15,
|
QUERYTYPE_LIST_MOVEMENTS: 15,
|
||||||
|
QUERYTYPE_LIST_ALLMOVEMENTS: 16,
|
||||||
// ---------------------
|
// ---------------------
|
||||||
|
|
||||||
FILTER_EXTRALIST_NOT_REGISTERED: 1,
|
FILTER_EXTRALIST_NOT_REGISTERED: 1,
|
||||||
|
|||||||
Reference in New Issue
Block a user