[WIP] provider reassigned orders (single column on payment_orders)#731
Draft
sundayonah wants to merge 1 commit intomainfrom
Draft
[WIP] provider reassigned orders (single column on payment_orders)#731sundayonah wants to merge 1 commit intomainfrom
sundayonah wants to merge 1 commit intomainfrom
Conversation
Contributor
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Reassigned Orders
Overview
Providers see orders that were automatically moved away from them (reassigned due to inactivity) by adding one nullable column on
payment_ordersand using it for the "Reassigned" list and display status. No new table.User Story (Reference)
As a Provider on Paycrest,
I want to see orders that were automatically moved away from me due to inactivity,
So that I can track missed orders and improve my response time.
Acceptance criteria:
Schema Change
payment_orders(existing)reassigned_from_provider_id(nullable, FK →provider_profiles.id)reassigned_from_provider_idfor list queries.Migration: One migration adding the column, FK, and index. No new tables.
Implementation Flow
Step 1: Schema (Ent)
payment_ordersschema, add optional edge/field:reassigned_from_provider(FK toProviderProfile).go run ent/migrate/main.goor Atlas).Step 2: Reassign Logic (
tasks/order_requests.go)In
reassignCancelledOrder, before clearing the provider and setting status:reassigned_from_provider_id = order.Edges.Provider.ID.Order of operations: set reassigned-from → then clear provider → then (optional) release balance, delete fulfillment, etc.
Step 3: List API – Reassigned (
controllers/provider/provider.go)When
status=reassigned:payment_orderswherereassigned_from_provider_id = provider.ID.updated_atdesc, apply pagination (page, pageSize).displayStatus: "reassigned"for each order.Reuse existing response builder; only the query and
displayStatusdiffer.Step 4: Clear Reassigned-From When Order Is (Re)assigned (optional)
When an order is assigned to a new provider (queue or OTC) or accepted:
reassigned_from_provider_id = nilso the order no longer appears in the previous provider’s "Reassigned" list.(If product wants it to stay in "Reassigned" even after someone else takes it, skip this step.)
Step 5: Dashboard
GET /provider/orders?currency=...&status=reassigned&page=...&pageSize=....displayStatus(e.g. badge "Reassigned") in list and detail.Data Flow (Summary)
[Reassign trigger]
→ reassignCancelledOrder:
[Provider GET /orders?status=reassigned]
→ Query: payment_orders WHERE reassigned_from_provider_id = :provider_id
(+ currency/institution filters)
→ Paginate, build response
→ Each order: displayStatus: "reassigned"
Files to Touch (Checklist)
aggregator/ent/schema/paymentorder.go(add edge/field)aggregator/ent/migrate/migrations/aggregator/tasks/order_requests.goaggregator/controllers/provider/provider.goaggregator/services/priority_queue.go,aggregator/controllers/provider/provider.go(if clearing on assign/accept)_provider.provider.orders.tsx,ListProviderOrders.tsx