diff --git a/core/api/src/services/ledger/facade/volume.ts b/core/api/src/services/ledger/facade/volume.ts index ba399fa8d9b..53d83bb02bd 100644 --- a/core/api/src/services/ledger/facade/volume.ts +++ b/core/api/src/services/ledger/facade/volume.ts @@ -10,6 +10,7 @@ import { timestampDaysAgo } from "@/utils" import { paymentAmountFromNumber } from "@/domain/shared" import { addAttributesToCurrentSpan } from "@/services/tracing" +import { MS_PER_DAY } from "@/config" export const TxnGroups = { allPaymentVolumeSince: [ @@ -72,6 +73,34 @@ const TxVolumeAmountSinceFactory = () => { $and: [{ timestamp: { $gte: timestamp } }], }, }, + { + $lookup: { + from: "medici_transactions", + localField: "_original_journal", + foreignField: "_journal", + as: "original_transactions", + }, + }, + { + $addFields: { + is_transaction_valid: { + $or: [ + { $eq: [{ $size: "$original_transactions" }, 0] }, + { + $gte: [ + { $arrayElemAt: ["$original_transactions.datetime", 0] }, + new Date(Date.now() - MS_PER_DAY), + ], + }, + ], + }, + }, + }, + { + $match: { + is_transaction_valid: true, + }, + }, { $group: { _id: null,