Skip to content

SSF-153 Volunteer Create Order Endpoint#126

Merged
Juwang110 merged 38 commits intomainfrom
jw/ssf-153-volunteer-create-order-endpoint
Apr 7, 2026
Merged

SSF-153 Volunteer Create Order Endpoint#126
Juwang110 merged 38 commits intomainfrom
jw/ssf-153-volunteer-create-order-endpoint

Conversation

@Juwang110
Copy link
Copy Markdown

ℹ️ 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.

Copy link
Copy Markdown
Member

@amywng amywng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r1

@Juwang110 Juwang110 requested a review from amywng March 12, 2026 14:40
@Juwang110 Juwang110 requested a review from amywng March 13, 2026 14:59
Copy link
Copy Markdown
Member

@amywng amywng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Collaborator

@sam-schu sam-schu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@Juwang110 Juwang110 requested review from amywng and sam-schu March 15, 2026 16:06
Copy link
Copy Markdown
Member

@amywng amywng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one small nit but other than that LGTM!!!

@Juwang110 Juwang110 requested a review from sam-schu March 22, 2026 19:55
Copy link
Copy Markdown
Collaborator

@sam-schu sam-schu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also give the repos that are coming from the transaction manager the transaction prefix?

@Juwang110 Juwang110 requested a review from sam-schu March 25, 2026 14:50
Copy link
Copy Markdown
Collaborator

@sam-schu sam-schu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@Juwang110 Juwang110 requested a review from sam-schu April 1, 2026 18:53
Copy link
Copy Markdown
Collaborator

@sam-schu sam-schu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@Juwang110 Juwang110 requested a review from sam-schu April 5, 2026 19:13
Copy link
Copy Markdown
Collaborator

@sam-schu sam-schu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approved!!! thank you so much for all your work on this very complex & annoying endpoint! volunteer order matching flow is coming along very well :)

@Juwang110 Juwang110 merged commit a190258 into main Apr 7, 2026
4 checks passed
@Juwang110 Juwang110 deleted the jw/ssf-153-volunteer-create-order-endpoint branch April 7, 2026 14:59
Juwang110 added a commit that referenced this pull request Apr 7, 2026
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants