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({
|
||||
_id: {
|
||||
type: String,
|
||||
default: function () {
|
||||
return new ObjectID().toString()
|
||||
}
|
||||
default: function() {
|
||||
return new ObjectID().toString();
|
||||
},
|
||||
},
|
||||
idapp: {
|
||||
type: String,
|
||||
@@ -74,7 +74,8 @@ MovementSchema.pre('save', async function(next) {
|
||||
|
||||
MovementSchema.statics.getFieldsForSearch = function() {
|
||||
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'},
|
||||
{
|
||||
"$lookup": {
|
||||
"from": "circuits",
|
||||
"localField": "accfrom.circuitId",
|
||||
"foreignField": "_id",
|
||||
"as": "circuitfrom"
|
||||
}
|
||||
'$lookup': {
|
||||
'from': 'circuits',
|
||||
'localField': 'accfrom.circuitId',
|
||||
'foreignField': '_id',
|
||||
'as': 'circuitfrom',
|
||||
},
|
||||
},
|
||||
{
|
||||
"$unwind": "$circuitfrom"
|
||||
'$unwind': '$circuitfrom',
|
||||
},
|
||||
{
|
||||
"$lookup": {
|
||||
"from": "circuits",
|
||||
"localField": "accto.circuitId",
|
||||
"foreignField": "_id",
|
||||
"as": "circuitto"
|
||||
}
|
||||
'$lookup': {
|
||||
'from': 'circuits',
|
||||
'localField': 'accto.circuitId',
|
||||
'foreignField': '_id',
|
||||
'as': 'circuitto',
|
||||
},
|
||||
},
|
||||
{
|
||||
"$unwind": "$circuitto"
|
||||
'$unwind': '$circuitto',
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
@@ -247,6 +248,151 @@ MovementSchema.statics.getQueryMovsByCircuitId = async function(idapp, username,
|
||||
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) {
|
||||
const MyMovement = this;
|
||||
|
||||
|
||||
@@ -1938,19 +1938,14 @@ module.exports = {
|
||||
|
||||
query.push(...myquery);
|
||||
|
||||
/*} else if (params.table === 'circuits') {
|
||||
const qacirc = this.getLookup(
|
||||
{
|
||||
lk_tab: 'accounts',
|
||||
lk_LF: 'circuitId',
|
||||
lk_FF: '_id',
|
||||
lk_as: 'account',
|
||||
}, 0, {
|
||||
'acc': 1,
|
||||
});
|
||||
if (qacirc) query = [...query, ...qacirc];
|
||||
} else if (params.querytype === shared_consts.QUERYTYPE_LIST_ALLMOVEMENTS) {
|
||||
|
||||
const {Movement} = require('../models/movement');
|
||||
|
||||
const myquery = await Movement.getQueryAllUsersMovsByCircuitId(params.idapp, params.myid);
|
||||
|
||||
query.push(...myquery);
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
if (newvers) {
|
||||
|
||||
@@ -10,6 +10,7 @@ module.exports = {
|
||||
QUERYTYPE_CIRCUIT: 10,
|
||||
QUERYTYPE_REFUSED_USER_CIRCUIT: 12,
|
||||
QUERYTYPE_LIST_MOVEMENTS: 15,
|
||||
QUERYTYPE_LIST_ALLMOVEMENTS: 16,
|
||||
// ---------------------
|
||||
|
||||
FILTER_EXTRALIST_NOT_REGISTERED: 1,
|
||||
|
||||
Reference in New Issue
Block a user