SSF-153 Volunteer Create Order Endpoint#126
Conversation
There was a problem hiding this comment.
last few nits and a note of consideration @sam-schu @Yurika-Kan : the order create method does 4 db operations across 4 different tables but if one of the steps fails then the db could reflect a partially updated state (e.g. reservedQuantities aren't set but orders are made, or donations aren't matched). i looked into it and we could maybe wrap this in a transaction so that all operations succeed or are rolled back/fail. thoughts?
sam-schu
left a comment
There was a problem hiding this comment.
Thanks for making separate service functions to better organize the logic not directly related to orders! What was the rationale for making endpoints corresponding to all of those service functions?
Also, agreeing with @amywng that using a transaction to make the database updates all-or-nothing is a great idea
amywng
left a comment
There was a problem hiding this comment.
one small nit but other than that LGTM!!!
sam-schu
left a comment
There was a problem hiding this comment.
Can we also give the repos that are coming from the transaction manager the transaction prefix?
sam-schu
left a comment
There was a problem hiding this comment.
The order table now includes a column to track the order's assignee, which should be the volunteer who created the order. Can we make sure that when we create an order, the volunteer who called the endpoint is set as the assignee?
sam-schu
left a comment
There was a problem hiding this comment.
When I try to call the endpoint with a body like
{
"foodRequestId": 2,
"manufacturerId": 1,
"itemAllocations": {
"1": 2
}
}
that should be valid, I get the following error:
[Nest] 20308 - 04/02/2026, 7:59:50 PM ERROR [ExceptionsHandler] Cannot read properties of null (reading 'slice')
TypeError: Cannot read properties of null (reading 'slice')
at Object.from (C:\Users\short\GitHub\ssf\dist\apps\backend\main.js:580:22)
at ApplyValueTransformers.transformFrom (C:\Users\short\GitHub\ssf\src\util\ApplyValueTransformers.ts:17:28)
at PostgresDriver.prepareHydratedValue (C:\Users\short\GitHub\ssf\src\driver\postgres\PostgresDriver.ts:743:42)
at RawSqlResultsToEntityTransformer.transformColumns (C:\Users\short\GitHub\ssf\src\query-builder\transformer\RawSqlResultsToEntityTransformer.ts:246:29)
...
Can you reproduce?
sam-schu
left a comment
There was a problem hiding this comment.
approved!!! thank you so much for all your work on this very complex & annoying endpoint! volunteer order matching flow is coming along very well :)
…github.com/Code-4-Community/ssf into jw/ssf-153-volunteer-create-order-endpoint
* fix getFMDonations endpoint (#150) * [SSF-171] update volunteers endpoint (#138) * update volunteers endpoint * comments * comments * initial comments * fix findByIds methods * comments * last things * comments * final comments * SSF-153 Volunteer Create Order Endpoint (#126) * logic for creating order itself * functionality for creating allocations and updating donation item reserved quantities * finish route functionality * all tests except create order service test * finish test * touch ups * comments * comment * comments * comments * fix import bug * import * import fix * comment * remove controller endpoints * comments * making transaction naming clear * comment * format * comments * comments * fix tests * commetns * simplify duplicate check --------- Co-authored-by: Amy Wang <147568742+amywng@users.noreply.github.com>
ℹ️ Issue
(https://vidushimisra.atlassian.net/browse/SSF-153)
📝 Description
This PR adds an endpoint for volunteers to create a new order. There is a lot of criteria going into this route with lots of checks and side effects, the ticket details what I mean.
There were a decent amount of new routes that had to be added for this functionality to work. Here is the list:
/create-multiple in allocations
/associated-donations, /all, /set-quantities, in donation items
/match-all in donations
/create in order
✔️ Verification
I tested functionality of all backend routes with Postman and I also wrote and made sure all tests passed.
🏕️ (Optional) Future Work / Notes
As a note, there are no tests for allocations, and no service tests yet for donation items. These will be added in a future ticket.