Skip to content

Commit

Permalink
fix(TransactionReports): Only include transactions for current host f…
Browse files Browse the repository at this point in the history
…or accounts with v3 budget (#10077)
  • Loading branch information
gustavlrsn committed May 8, 2024
1 parent 97cb7f1 commit 151c646
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion server/graphql/v2/interface/Account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,7 @@ const accountFieldsDefinition = () => ({
if (args.timeUnit !== 'MONTH' && args.timeUnit !== 'QUARTER' && args.timeUnit !== 'YEAR') {
throw new Error('Only monthly, quarterly and yearly reports are supported.');
}
const budgetVersion = get(collective, 'settings.budget.version', 'v2');

const query = `
WITH
Expand Down Expand Up @@ -894,8 +895,9 @@ const accountFieldsDefinition = () => ({
) AS e ON t."ExpenseId" IS NOT NULL
WHERE
t."deletedAt" IS NULL
AND t."CollectiveId" IN (SELECT * FROM CollectiveIds)
AND t."CollectiveId" IN (SELECT "id" FROM CollectiveIds)
${args.dateTo ? 'AND t."createdAt" <= :dateTo' : ''}
${budgetVersion === 'v3' ? 'AND t."HostCollectiveId" = :hostCollectiveId' : ''}
GROUP BY
DATE_TRUNC(:timeUnit, t."createdAt"),
Expand All @@ -910,6 +912,7 @@ const accountFieldsDefinition = () => ({
const queryResult = await sequelize.query(query, {
replacements: {
collectiveId: collective.id,
hostCollectiveId: collective.HostCollectiveId,
timeUnit: args.timeUnit,
dateTo: moment(args.dateTo).utc().toISOString(),
},
Expand Down

0 comments on commit 151c646

Please sign in to comment.