diff --git a/backend/src/graphql/resolver/AdminResolver.ts b/backend/src/graphql/resolver/AdminResolver.ts index d8c6a28b8..27230c7a5 100644 --- a/backend/src/graphql/resolver/AdminResolver.ts +++ b/backend/src/graphql/resolver/AdminResolver.ts @@ -213,7 +213,9 @@ async function getUserCreations(id: number): Promise { const transactionCreationRepository = getCustomRepository(TransactionCreationRepository) const createdAmountBeforeLastMonth = await transactionCreationRepository .createQueryBuilder('transaction_creations') - .select('SUM(transaction_creations.amount)', 'sum') + .select('transaction_creations.target_date') + .addSelect('MONTH(transaction_creations.target_date)', 'target_month') + .addSelect('transaction_creations.amount') .where('transaction_creations.state_user_id = :id', { id }) .andWhere({ targetDate: Raw((alias) => `${alias} >= :date and ${alias} < :endDate`, { @@ -221,8 +223,8 @@ async function getUserCreations(id: number): Promise { endDate: dateNextMonth, }), }) - .orderBy('MONTH(transaction_creations.target_date)', 'ASC') - .getRawOne() + .orderBy('target_month', 'ASC') + .getRawMany() console.log('createdAmountBeforeLastMonth', id, createdAmountBeforeLastMonth) const pendingCreationRepository = getCustomRepository(PendingCreationRepository)