Skip to content

[SSF 227] - Volunteer archive and edit orders backend#193

Open
dburkhart07 wants to merge 7 commits into
mainfrom
ddb/SSF-227-volunteer-archive-and-edit-orders-backend
Open

[SSF 227] - Volunteer archive and edit orders backend#193
dburkhart07 wants to merge 7 commits into
mainfrom
ddb/SSF-227-volunteer-archive-and-edit-orders-backend

Conversation

@dburkhart07

Copy link
Copy Markdown

ℹ️ Issue

Closes #227

📝 Description

  • Wrote migration to add new order status enum CLOSED
  • Added this new enum into the entire repo, including all the frontend order management pages organized by status to have a new page
  • Added new endpoint to close order and free all allocations as a result
  • Added new endpoint to edit several allocations
  • Auth gated all endpoints
  • Wrote tests

NOTE: For editing allocations, the way I designed it was that the dto would take in an allocationId or donationItemId. Should the allocationId be provided, it would be an edited allocation that already exists in the order. Should it be a donationItemId, it is a new allocation to be created for that order. Finally, all existing allocations that are do not get their ids provided will be assumed to be deleted. I made sure to check that all the donationItemIds involved in the editing are part of the donations from the food manufacturers, and all donations affected as assessed to see if they'ev either beomce matched or available as a result to gaining or losing allocations.

✔️ Verification

  • Verified both endpoints
  • Verified all tests passed
  • Smoke tested all order pages to make sure closed status showed up
  • Ran migration forwards and backwards

🏕️ (Optional) Future Work / Notes

We will have to account for this setup in our frontend implementation so that no allocations with a 0 quantity for the order get sent to the backend.

@Yurika-Kan Yurika-Kan self-assigned this Jun 20, 2026

@Yurika-Kan Yurika-Kan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

looking pretty good~ crucial questions about donation status setting tho!

Comment thread apps/backend/src/orders/order.service.ts Outdated
donationItemId?: number;

@IsInt()
@Min(1)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

in the case that we want to omit an item from being part of the update, we would want this value to be 0~ this contradicts the service logic that treats 0 as a legal drop

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

the way i intend for this to be used in the frontend is this:

  1. passing in an allocationId means you want to edit an existing allocations quantity to a new number (just decrease it, not delete it)
  2. passing in a donationItemId means you want to add a new allocation to the order

both cases above require the allocated quantity to be at minimum 1.

all allocations not included in here (which will happen if they are set to 0), will then be free'd.

Comment thread apps/backend/src/allocations/allocations.service.ts
Comment thread apps/backend/src/allocations/allocations.service.ts Outdated
Comment thread apps/backend/src/allocations/allocations.service.ts Outdated
Comment thread apps/backend/src/orders/order.service.spec.ts
@dburkhart07 dburkhart07 requested a review from Yurika-Kan June 25, 2026 03:29
Comment thread apps/backend/src/orders/order.controller.ts Outdated
Comment thread apps/backend/src/orders/order.service.ts Outdated
Comment thread apps/backend/src/orders/order.service.spec.ts Outdated

@Yurika-Kan Yurika-Kan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

taking care of new order status~

side effects of adding new enum CLOSED:

  • in [request.service.ts:309-315], this method updateRequestStatus decides request status (done when all associated orders = DELIVERED). however now with CLOSED (order) introduced, there can be a case where all orders are DELIVERED but one is CLOSED, resulting in that associated request never reaching closed status. we want to close a food request if all of its associated orders are either DELIVERED or CLOSED. can we update that logic here?

`
const allDelivered = orders.every(
(order) => order.status === OrderStatus.DELIVERED,
);

request.status = allDelivered
  ? FoodRequestStatus.CLOSED
  : FoodRequestStatus.ACTIVE;`

@dburkhart07 dburkhart07 requested a review from Yurika-Kan June 28, 2026 21:06
Comment thread apps/backend/src/orders/order.controller.spec.ts
Comment thread apps/backend/src/orders/order.service.ts

await this.allocationsService.freeAllByOrder(orderId, transactionManager);

await this.donationService.recheckDonationAllocationStatus(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Will there ever be a case where the donation should instead be fulfilled instead of MATCHED/AVAILABLE? Trying to think about this case but not sure

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

i dont think so. if we close a request, that means the donation pertaining to it has donation items being asked for, putting this donation in matched always. closing an order will then make it so that, all the donation items are now free, and the order becomes available, or it just becomes matched. there is no way for those donation items to somehow become delivered to a pantry, and then potentially fulfilled by closing an order.

Comment thread apps/backend/src/orders/order.service.ts Outdated
Comment thread apps/backend/src/orders/order.service.ts
Comment thread apps/backend/src/donations/donations.service.ts
@dburkhart07 dburkhart07 requested a review from Juwang110 June 30, 2026 06:32

@Yurika-Kan Yurika-Kan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

even tho a CLOSED order now counts as complete ie delivering the remaining orders will close the request, manually closing an order should not close the request when

there is only one order to that active request --> close order => request stays active
there is a DELIVERED order A and PENDING order B both to same request--> close B --> request stays active

Comment thread apps/backend/src/orders/order.service.ts
@Yurika-Kan

Copy link
Copy Markdown
Collaborator

so in close order, drop the updaterequeststatus call and in updaterequeststatus compute it over nonclosed orders only so nothing is blocked by any closed orders

@dburkhart07 dburkhart07 requested a review from Yurika-Kan July 1, 2026 05:51
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