ENG-197: Derive bridge transfer types from obligation types#294
ENG-197: Derive bridge transfer types from obligation types#294Connorbelez merged 1 commit intomainfrom
Conversation
There was a problem hiding this comment.
Sorry @Connorbelez, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (12)
📝 WalkthroughWalkthroughThe PR replaces a hardcoded Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Possibly related PRs
Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
There was a problem hiding this comment.
Pull request overview
Updates the Phase M2a collection-attempt → transferRequest bridge to derive inbound transferType from the bridged obligation’s type, avoiding misclassification of non-interest collections and aligning tests with the actual initiated→confirmed GT flow.
Changes:
- Added reverse obligation→transfer mapping plus
obligationTypeToTransferType()helper with a safe default. - Updated
emitPaymentReceivedto use the derived transfer type instead of a hardcoded value. - Refreshed transfer bridge tests to reflect initiated insert + immediate
FUNDS_SETTLEDtransition, and added mapping coverage.
Reviewed changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| specs/ENG-197/tasks.md | Master task list documenting the mapping + bridge + test updates. |
| specs/ENG-197/chunks/manifest.md | Chunk breakdown for implementation and verification. |
| specs/ENG-197/chunks/chunk-01-bridge-mapping/tasks.md | Tasks for reverse mapping + bridge integration. |
| specs/ENG-197/chunks/chunk-01-bridge-mapping/status.md | Status/verification notes for mapping + bridge changes. |
| specs/ENG-197/chunks/chunk-01-bridge-mapping/context.md | Context and constraints for the bridge mapping work. |
| specs/ENG-197/chunks/chunk-02-tests-verification/tasks.md | Tasks for updating bridge tests and verification. |
| specs/ENG-197/chunks/chunk-02-tests-verification/status.md | Status/verification notes for test updates. |
| specs/ENG-197/chunks/chunk-02-tests-verification/context.md | Context describing how tests now match production GT behavior. |
| convex/payments/transfers/types.ts | Adds OBLIGATION_TYPE_TO_TRANSFER_TYPE, default, and helper function. |
| convex/engine/effects/collectionAttempt.ts | Uses obligationTypeToTransferType(firstOblForBridge.type) when inserting the bridged transfer request. |
| convex/payments/transfers/tests/types.test.ts | Adds unit coverage for reverse mapping + fallback behavior. |
| convex/payments/transfers/tests/bridge.test.ts | Updates bridge tests to initiated insert semantics and validates type derivation + settlement payload shape. |
| convex/_generated/api.d.ts | Regenerated Convex API typings after module/function surface changes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@coderabbitai please review |
|
🧠 Learnings used✅ Actions performedReview triggered.
|
703dbec to
e7b92b5
Compare
### TL;DR Fixed hardcoded transfer type in collection attempt bridge to dynamically derive transfer types from obligation types, ensuring proper categorization of interest, principal, late fees, and arrears cure collections. ### What changed? - Added reverse mapping `OBLIGATION_TYPE_TO_TRANSFER_TYPE` and helper function `obligationTypeToTransferType()` to derive transfer types from obligation types - Replaced hardcoded `borrower_interest_collection` in the collection attempt bridge with dynamic lookup based on the first obligation's type - Updated bridge tests to reflect actual production behavior where transfers start as `initiated` status and transition to `confirmed` via GT - Added comprehensive test coverage for obligation-to-transfer type mapping with proper fallback handling ### How to test? Run the following commands to verify the changes: ```bash bunx convex codegen bun check bun typecheck bun test convex/payments/transfers/__tests__/types.test.ts convex/payments/transfers/__tests__/bridge.test.ts ``` Test that collection attempts for different obligation types (regular_interest, principal_repayment, late_fee, arrears_cure) create bridge transfers with the correct transfer types. ### Why make this change? The bridge was incorrectly labeling all transfers as interest collections regardless of the actual obligation type. This caused misclassification of principal payments, late fees, and arrears cures, making financial reporting and reconciliation inaccurate. The fix ensures proper transfer categorization while maintaining existing Phase M2a behavior and idempotency guarantees.
### TL;DR Fixed hardcoded transfer type in collection attempt bridge to dynamically derive transfer types from obligation types, ensuring proper categorization of interest, principal, late fees, and arrears cure collections. ### What changed? - Added reverse mapping `OBLIGATION_TYPE_TO_TRANSFER_TYPE` and helper function `obligationTypeToTransferType()` to derive transfer types from obligation types - Replaced hardcoded `borrower_interest_collection` in the collection attempt bridge with dynamic lookup based on the first obligation's type - Updated bridge tests to reflect actual production behavior where transfers start as `initiated` status and transition to `confirmed` via GT - Added comprehensive test coverage for obligation-to-transfer type mapping with proper fallback handling ### How to test? Run the following commands to verify the changes: ```bash bunx convex codegen bun check bun typecheck bun test convex/payments/transfers/__tests__/types.test.ts convex/payments/transfers/__tests__/bridge.test.ts ``` Test that collection attempts for different obligation types (regular_interest, principal_repayment, late_fee, arrears_cure) create bridge transfers with the correct transfer types. ### Why make this change? The bridge was incorrectly labeling all transfers as interest collections regardless of the actual obligation type. This caused misclassification of principal payments, late fees, and arrears cures, making financial reporting and reconciliation inaccurate. The fix ensures proper transfer categorization while maintaining existing Phase M2a behavior and idempotency guarantees.

TL;DR
Fixed hardcoded transfer type in collection attempt bridge to dynamically derive transfer types from obligation types, ensuring proper categorization of interest, principal, late fees, and arrears cure collections.
What changed?
OBLIGATION_TYPE_TO_TRANSFER_TYPEand helper functionobligationTypeToTransferType()to derive transfer types from obligation typesborrower_interest_collectionin the collection attempt bridge with dynamic lookup based on the first obligation's typeinitiatedstatus and transition toconfirmedvia GTHow to test?
Run the following commands to verify the changes:
bunx convex codegen bun check bun typecheck bun test convex/payments/transfers/__tests__/types.test.ts convex/payments/transfers/__tests__/bridge.test.tsTest that collection attempts for different obligation types (regular_interest, principal_repayment, late_fee, arrears_cure) create bridge transfers with the correct transfer types.
Why make this change?
The bridge was incorrectly labeling all transfers as interest collections regardless of the actual obligation type. This caused misclassification of principal payments, late fees, and arrears cures, making financial reporting and reconciliation inaccurate. The fix ensures proper transfer categorization while maintaining existing Phase M2a behavior and idempotency guarantees.
Summary by CodeRabbit
Bug Fixes
Tests