Skip to content

Commit

Permalink
Merge pull request #53 from afaneca/develop
Browse files Browse the repository at this point in the history
2.1.3
  • Loading branch information
afaneca committed May 31, 2024
2 parents 576c8e4 + aeb3134 commit d5b8007
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/controllers/transactionController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ const createTransactionSchema = joi.object({

const createTransaction = async (req, res, next) => {
try {
await new Promise(resolve => setTimeout(resolve, 5000));
const sessionData = await CommonsController.checkAuthSessionValidity(req);
const trx = await createTransactionSchema.validateAsync(req.body);
await TransactionService.createTransaction(sessionData.userId, {
Expand Down
15 changes: 11 additions & 4 deletions src/services/transactionService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,13 @@ const deleteTransaction = async (userId: bigint, transactionId: number, dbClient
throw APIError.notFound(`Account could not be found.`);
}

// Delete trx references from transaction_has_tags
await prismaTx.transaction_has_tags.deleteMany({
where: {
transactions_transaction_id: transactionId,
}
});

// Delete transaction
await prismaTx.transactions.delete({
where: {
Expand Down Expand Up @@ -743,11 +750,11 @@ const getAllTransactionsForUserInCategoryAndInMonth = async (
AND (transactions.type = ${type}
OR transactions.type = 'T')
AND transactions.date_timestamp >= ${DateTimeUtils.getUnixTimestampFromDate(
minDate
)}
minDate
)}
AND transactions.date_timestamp <= ${DateTimeUtils.getUnixTimestampFromDate(
maxDate
)}
maxDate
)}
GROUP BY transaction_id
ORDER BY transactions.date_timestamp
DESC`;
Expand Down

0 comments on commit d5b8007

Please sign in to comment.