updates - #10
Merged
Merged
updates#10
Conversation
There was a problem hiding this comment.
Pull request overview
This PR extends the notifications payload to link notifications to an associated expense and updates expense-approval notifications to include more contextual details (category/currency/amount).
Changes:
- Add
expense_idto notification queries/returns and allow setting it when creating notifications. - Update expense workflow notifications (create/approve/reject) to include category/currency/amount details and pass
expenseId.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| backend/src/modules/notifications/notifications.model.js | Adds expense_id to SELECT/INSERT/UPDATE return fields and create() signature. |
| backend/src/modules/expenses/expenses.controller.js | Enriches notification bodies for expense events and attaches expenseId when creating notifications. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| userId: firstApprover.id, | ||
| title: "New expense pending your approval", | ||
| body: `${submitter.name || "An employee"} submitted a new expense for review.`, | ||
| body: `${submitter.name || "An employee"} submitted a ${category} expense for ${currency} ${amount}.`, |
Comment on lines
+6
to
+14
| "SELECT id, title, body, is_read, expense_id, created_at FROM notifications WHERE user_id = $1 ORDER BY created_at DESC", | ||
| [userId], | ||
| ); | ||
| }, | ||
|
|
||
| create({ userId, title, body }) { | ||
| create({ userId, title, body, expenseId = null }) { | ||
| return query( | ||
| "INSERT INTO notifications (user_id, title, body) VALUES ($1, $2, $3) RETURNING id, title, body, is_read, created_at", | ||
| [userId, title, body], | ||
| "INSERT INTO notifications (user_id, title, body, expense_id) VALUES ($1, $2, $3, $4) RETURNING id, title, body, is_read, expense_id, created_at", | ||
| [userId, title, body, expenseId], |
Comment on lines
105
to
+107
| title: "New expense pending your approval", | ||
| body: `${submitter.name || "An employee"} submitted a new expense for review.`, | ||
| body: `${submitter.name || "An employee"} submitted a ${category} expense for ${currency} ${amount}.`, | ||
| expenseId: expense.id, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.