Context
When the debtor pays, investors realize yield. Until automated Soroban/oracle settlement is fully wired, the backend still needs a correct, auditable settlement path that closes the invoice and investments and records returns.
Contributor workflow
- Apply on Drips before opening a PR: Claim this issue through the Drips platform before you open a pull request. Unsolicited PRs from unassigned contributors may be closed without review.
- ETA required: Your application must include an ETA for when you will open the first draft PR.
- Draft PR within 24 hours: If a draft PR is not linked on this issue within 24 hours of assignment, maintainers may unassign you so someone else can take the issue.
Goals
- Implement settlement that transitions:
- Invoice:
funded → settled (reject invalid states with stable error.code).
- Investments:
confirmed → settled with actual_return populated.
- Pro-rata returns: Distribute settlement proceeds across investors by their committed amounts (document formula; handle rounding to last investor or fixed precision—state choice).
- Create or update
Transaction rows of type payment where it aids audit (link to users/invoices as your schema allows).
- Idempotency: Calling settlement twice must not double-pay in DB terms.
MVP input (choose and document)
- Either authenticated admin endpoint, or seller endpoint with strict checks, accepting e.g.
paidAmount, stellarTxHash (optional), settledAt.
- Clearly label in code comments / PR that this is an MVP bridge until on-chain settlement drives status.
Acceptance criteria
PR submission requirements
Context
When the debtor pays, investors realize yield. Until automated Soroban/oracle settlement is fully wired, the backend still needs a correct, auditable settlement path that closes the invoice and investments and records returns.
Contributor workflow
Goals
funded→settled(reject invalid states with stableerror.code).confirmed→settledwithactual_returnpopulated.Transactionrows of typepaymentwhere it aids audit (link to users/invoices as your schema allows).MVP input (choose and document)
paidAmount,stellarTxHash(optional),settledAt.Acceptance criteria
400with stable codes.npm run type-checkpasses; tests pass.PR submission requirements
Closes #9.