From 001e98e98f786fa03361da9a95ebe1db9d3db26e Mon Sep 17 00:00:00 2001 From: Gustav Larsson Date: Wed, 31 Jan 2024 15:49:39 +0100 Subject: [PATCH] Fix sumCollectiveTransactions --- server/lib/budget.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/server/lib/budget.js b/server/lib/budget.js index 78a66ab6933..33ac0165fc5 100644 --- a/server/lib/budget.js +++ b/server/lib/budget.js @@ -588,7 +588,11 @@ export async function sumCollectivesTransactions( } else if (transactionType === 'CREDIT_WITH_HOST_FEE_AND_PAYMENT_PROCESSOR_FEE') { where = { ...where, - [Op.or]: [{ type: CREDIT }, { type: DEBIT, kind: 'HOST_FEE' }, { type: DEBIT, kind: 'PAYMENT_PROCESSOR_FEE' }], + [Op.or]: [ + { type: CREDIT }, + { type: DEBIT, kind: 'HOST_FEE' }, + { type: DEBIT, kind: 'PAYMENT_PROCESSOR_FEE', OrderId: { [Op.not]: null } }, + ], }; } else { where.type = transactionType; @@ -611,7 +615,17 @@ export async function sumCollectivesTransactions( ['CREDIT_WITH_HOST_FEE_AND_PAYMENT_PROCESSOR_FEE', 'DEBIT_WITHOUT_HOST_FEE'].includes(transactionType) && parseToBoolean(config.ledger.separatePaymentProcessorFees) === true ) { - where[Op.and].push({ [Op.or]: [{ isRefund: { [Op.not]: true } }, { kind: 'PAYMENT_PROCESSOR_COVER' }] }); + where[Op.and].push({ + [Op.or]: [ + { isRefund: { [Op.not]: true } }, + { + kind: 'PAYMENT_PROCESSOR_COVER', + ...(transactionType === 'CREDIT_WITH_HOST_FEE_AND_PAYMENT_PROCESSOR_FEE' && { + OrderId: { [Op.not]: null }, + }), + }, + ], + }); } else { where[Op.and].push({ isRefund: { [Op.not]: true } }); }