Skip to content

Commit

Permalink
fix: add 'original_journal' timestamp check for failed payments
Browse files Browse the repository at this point in the history
  • Loading branch information
vindard committed Nov 15, 2023
1 parent eb3f93b commit 50adabb
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions core/api/src/services/ledger/facade/volume.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 50adabb

Please sign in to comment.